From 97bc86fa70f1a03a5984d63eabc44b1ce41d3d70 Mon Sep 17 00:00:00 2001 From: Danila Poyarkov Date: Sun, 16 Aug 2026 13:40:44 +0300 Subject: [PATCH] fix(app): use callable fetch adapter type (#535) --- src/app/ai/chat/model.ts | 3 ++- src/app/ai/providers/types.ts | 4 +++- src/app/http/types.ts | 1 + src/app/tauri/http.ts | 4 +++- 4 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 src/app/http/types.ts diff --git a/src/app/ai/chat/model.ts b/src/app/ai/chat/model.ts index 62f35f7a0..c3c235e0e 100644 --- a/src/app/ai/chat/model.ts +++ b/src/app/ai/chat/model.ts @@ -2,6 +2,7 @@ import type { LanguageModel } from 'ai' import { modelProviderAdapter } from '@/app/ai/providers/registry' import type { ModelConfig } from '@/app/ai/providers/types' +import type { FetchFunction } from '@/app/http/types' import { isTauri } from '@/app/tauri/env' import { tauriFetch } from '@/app/tauri/http' @@ -20,7 +21,7 @@ export function resolveLanguageModelID( return config.modelID } -function desktopFetch(): typeof fetch | undefined { +function desktopFetch(): FetchFunction | undefined { return isTauri() ? tauriFetch : undefined } diff --git a/src/app/ai/providers/types.ts b/src/app/ai/providers/types.ts index bdfaf2692..0eb83641f 100644 --- a/src/app/ai/providers/types.ts +++ b/src/app/ai/providers/types.ts @@ -2,6 +2,8 @@ import type { LanguageModel } from 'ai' import type { AIProviderID } from '@open-pencil/core/constants' +import type { FetchFunction } from '@/app/http/types' + export type ModelConfig = { providerID: AIProviderID apiKey: string @@ -12,7 +14,7 @@ export type ModelConfig = { } export type ModelProviderRuntime = { - fetch?: typeof fetch + fetch?: FetchFunction } export interface ModelProviderAdapter { diff --git a/src/app/http/types.ts b/src/app/http/types.ts new file mode 100644 index 000000000..fc54c0116 --- /dev/null +++ b/src/app/http/types.ts @@ -0,0 +1 @@ +export type FetchFunction = (input: RequestInfo | URL, init?: RequestInit) => Promise diff --git a/src/app/tauri/http.ts b/src/app/tauri/http.ts index 3a4227f9a..29fefb760 100644 --- a/src/app/tauri/http.ts +++ b/src/app/tauri/http.ts @@ -1,3 +1,5 @@ +import type { FetchFunction } from '@/app/http/types' + export interface ProxyHttpHeader { name: string value: string @@ -72,7 +74,7 @@ export interface TauriFetchOptions { maxResponseBytes?: number } -export function createTauriFetch(options: TauriFetchOptions = {}): typeof fetch { +export function createTauriFetch(options: TauriFetchOptions = {}): FetchFunction { return (input, init) => tauriFetch(input, init, options.maxResponseBytes, options.timeoutMs) }