@subimpact/e 0.99.7 → 0.99.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/bundle/chunks/{anthropic-messages-UID2PALB.js → anthropic-messages-GS2TPNKJ.js} +1 -1
- package/dist/bundle/chunks/azure-openai-responses-E3QGN4VN.js +2 -0
- package/dist/bundle/chunks/bedrock-converse-stream.js +2 -2
- package/dist/bundle/chunks/{chunk-OENUXCXU.js → chunk-AMXQFKYC.js} +1 -1
- package/dist/bundle/chunks/{chunk-OSKPX3Z5.js → chunk-C47CLQZK.js} +1 -1
- package/dist/bundle/chunks/chunk-HQHD6PZI.js +2 -0
- package/dist/bundle/chunks/{chunk-ZDC7MWVF.js → chunk-K7HFCKO6.js} +1 -1
- package/dist/bundle/chunks/chunk-KJUDFE6Y.js +11 -0
- package/dist/bundle/chunks/{chunk-VVPSHZFU.js → chunk-OY7LPJPR.js} +5 -5
- package/dist/bundle/chunks/{chunk-R5J3MOBF.js → chunk-WE4MXUQS.js} +2 -2
- package/dist/bundle/chunks/{chunk-JKK652B2.js → chunk-ZF24NZZF.js} +15 -15
- package/dist/bundle/chunks/{cloudflare-workers-ai-system-one-NPQN263E.js → cloudflare-workers-ai-system-one-NHSAQJW5.js} +1 -1
- package/dist/bundle/chunks/{easter-egg-3d-567GSTG6.js → easter-egg-3d-BEGJLGMY.js} +1 -1
- package/dist/bundle/chunks/{google-generative-ai-3Z6VNDJN.js → google-generative-ai-VQRZUF33.js} +1 -1
- package/dist/bundle/chunks/{google-vertex-NU6OFGNA.js → google-vertex-3Y7I23IX.js} +1 -1
- package/dist/bundle/chunks/{mistral-conversations-DKVFNQL6.js → mistral-conversations-Q22M3IBG.js} +1 -1
- package/dist/bundle/chunks/openai-chatgpt.js +1 -1
- package/dist/bundle/chunks/{openai-codex-responses-3GKGNXC4.js → openai-codex-responses-4MYQSO5E.js} +1 -1
- package/dist/bundle/chunks/openai-completions-OSRCWAAA.js +7 -0
- package/dist/bundle/chunks/openai-responses-UHF3DHNG.js +3 -0
- package/dist/bundle/chunks/{typesafe-system-one-A4CZTQWZ.js → typesafe-system-one-PRR5K6CI.js} +1 -1
- package/dist/bundle/chunks/{virtual-modules-EKUHB2H5.js → virtual-modules-WTPTTSLL.js} +1 -1
- package/dist/bundle/cli-runtime.js +1 -1
- package/dist/bundle/index.js +1 -1
- package/dist/bundle/rpc-entry.js +1 -1
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +4 -1
- package/dist/cli/args.js.map +1 -1
- package/dist/core/model-config.d.ts +36 -0
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +14 -2
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-resolver.js +1 -1
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/provider-composer.d.ts +2 -1
- package/dist/core/provider-composer.d.ts.map +1 -1
- package/dist/core/provider-composer.js +13 -0
- package/dist/core/provider-composer.js.map +1 -1
- package/dist/modes/interactive/components/e-logo.d.ts +9 -7
- package/dist/modes/interactive/components/e-logo.d.ts.map +1 -1
- package/dist/modes/interactive/components/e-logo.js +15 -11
- package/dist/modes/interactive/components/e-logo.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +2 -2
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +22 -45
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +2 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +24 -5
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/utils/image-convert.d.ts +12 -0
- package/dist/utils/image-convert.d.ts.map +1 -1
- package/dist/utils/image-convert.js +45 -6
- package/dist/utils/image-convert.js.map +1 -1
- package/docs/models.md +26 -0
- package/package.json +1 -1
- package/dist/bundle/chunks/azure-openai-responses-TLHNIYZK.js +0 -2
- package/dist/bundle/chunks/chunk-6D7LHLKG.js +0 -2
- package/dist/bundle/chunks/chunk-7JGR3GZN.js +0 -11
- package/dist/bundle/chunks/openai-completions-JXDDPZ23.js +0 -7
- package/dist/bundle/chunks/openai-responses-S7GKCCDG.js +0 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider-composer.js","sourceRoot":"","sources":["../../src/core/provider-composer.ts"],"names":[],"mappings":"AAAA,OAAO,EAWN,WAAW,EACX,UAAU,GAcV,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,8CAA8C,CAAC;AAEvG,OAAO,EACN,qBAAqB,EACrB,yBAAyB,EACzB,oBAAoB,EACpB,uBAAuB,EACvB,yBAAyB,EACzB,qBAAqB,GACrB,MAAM,2BAA2B,CAAC;AA6EnC,MAAM,CAAC,MAAM,gBAAgB,GAAG,qBAAqB,CAAC;AAEtD,SAAS,oBAAoB,CAAC,QAA8B;IAC3D,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,YAAY,EAAE,EAAE,IAAI,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AAC5E,CAAC;AAED,SAAS,WAAW,CACnB,IAA0B,EAC1B,QAAkE;IAElE,IAAI,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC3B,MAAM,MAAM,GAAG,EAAE,GAAG,IAAI,EAAE,GAAG,QAAQ,EAAuC,CAAC;IAC7E,MAAM,UAAU,GAAG,IAA2C,CAAC;IAC/D,MAAM,cAAc,GAAG,QAAmC,CAAC;IAC3D,MAAM,YAAY,GAAG,MAAiC,CAAC;IACvD,KAAK,MAAM,GAAG,IAAI,CAAC,mBAAmB,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,kBAAkB,CAAU,EAAE,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CAAC,OAAO,IAAI,UAAU,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,CAAC,OAAO,EAAE,GAAG,UAAU,EAAE,CAAC,CAAC,CAAC,SAAS;QACtF,UAAU,EAAE,SAAS,EAAE,UAAU,IAAI,MAAM,EAAE,UAAU,IAAI,KAAK;KAChE,CAAC;AACH,CAAC;AAED,MAAM,UAAU,2BAA2B,CAC1C,MAAsC,EACtC,SAA0C;IAE1C,MAAM,KAAK,GAAG,gBAAgB,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAClD,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC1C,IAAI,oBAAoB,CAAC,KAAK,CAAC;QAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,qBAAqB,EAAE,CAAC;IAC5F,MAAM,KAAK,GAAG,yBAAyB,CAAC,KAAK,CAAC,CAAC;IAC/C,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,OAAO,uBAAuB,CAAC,KAAK,CAAC;YACpC,CAAC,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;YACtE,CAAC,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;IAC1B,CAAC;IACD,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;AACvG,CAAC","sourcesContent":["import {\n\ttype AnyModel,\n\ttype Api,\n\ttype ApiKeyAuth,\n\ttype AssistantMessageEventStream,\n\ttype AuthContext,\n\ttype AuthInteraction,\n\ttype AuthResult,\n\ttype ClassifierApi,\n\ttype Credential,\n\ttype ImageApi,\n\tisModelType,\n\tlazyStream,\n\ttype Model,\n\ttype ModelAuth,\n\ttype OAuthAuth,\n\ttype OAuthCredentials,\n\ttype OAuthLoginCallbacks,\n\ttype Provider,\n\ttype ProviderClassifier,\n\ttype ProviderHeaders,\n\ttype ProviderImages,\n\ttype RefreshModelsContext,\n\ttype SimpleStreamOptions,\n\ttype StreamOptions,\n\ttype TranscriptContext,\n} from \"@earendil-works/pi-ai\";\nimport { getApiProvider } from \"@earendil-works/pi-ai/compat\";\nimport { classifierErrorResult, imageErrorResult } from \"@earendil-works/pi-ai/utils/model-operations\";\nimport type { ModelConfig, ModelsJsonModel, ModelsJsonModelOverride, ModelsJsonProvider } from \"./model-config.ts\";\nimport {\n\tclearConfigValueCache,\n\tgetConfigValueEnvVarNames,\n\tisCommandConfigValue,\n\tisConfigValueConfigured,\n\tresolveConfigValueOrThrow,\n\tresolveHeadersOrThrow,\n} from \"./resolve-config-value.ts\";\n\nexport interface ExtensionOAuthConfig {\n\tname: string;\n\t/** Whether access through this auth method is backed by a provider subscription. */\n\tisSubscription?: boolean;\n\t/** @deprecated Retained for extension source compatibility; ignored by canonical auth flows. */\n\tusesCallbackServer?: boolean;\n\tlogin(callbacks: OAuthLoginCallbacks): Promise<OAuthCredentials>;\n\trefreshToken(credentials: OAuthCredentials, signal: AbortSignal): Promise<OAuthCredentials>;\n\tgetApiKey(credentials: OAuthCredentials): string;\n\tmodifyModels?(models: Model<Api>[], credentials: OAuthCredentials): Model<Api>[];\n}\n\ninterface ProviderModelConfigBase {\n\tid: string;\n\tname: string;\n\tapi?: string;\n\tbaseUrl?: string;\n\tinput: (\"text\" | \"image\")[];\n\tinputLimits?: AnyModel[\"inputLimits\"];\n\tcost: AnyModel[\"cost\"];\n\theaders?: Record<string, string>;\n}\n\nexport interface ProviderChatModelConfig extends ProviderModelConfigBase {\n\ttype?: \"chat\";\n\tapi?: Api;\n\treasoning: boolean;\n\tthinkingLevelMap?: Model<Api>[\"thinkingLevelMap\"];\n\tpromptCache?: Model<Api>[\"promptCache\"];\n\tcontextWindow: number;\n\tmaxTokens: number;\n\tsamplingParams?: Record<string, unknown>;\n\tcompat?: Model<Api>[\"compat\"];\n}\n\nexport interface ProviderImageModelConfig extends ProviderModelConfigBase {\n\ttype: \"image\";\n\tapi?: ImageApi;\n\toutput: (\"text\" | \"image\")[];\n}\n\nexport interface ProviderClassifierModelConfig extends ProviderModelConfigBase {\n\ttype: \"classifier\";\n\tapi?: ClassifierApi;\n\tcontextWindow: number;\n}\n\nexport type ProviderModelConfig = ProviderChatModelConfig | ProviderImageModelConfig | ProviderClassifierModelConfig;\n\n/** Input type for the extension registerProvider API. */\nexport interface ProviderConfigInput {\n\tname?: string;\n\tbaseUrl?: string;\n\tapiKey?: string;\n\tapi?: Api;\n\tstreamSimple?: (\n\t\tmodel: Model<Api>,\n\t\tcontext: TranscriptContext,\n\t\toptions?: SimpleStreamOptions,\n\t) => AssistantMessageEventStream;\n\timages?: Partial<Record<ImageApi, ProviderImages>>;\n\tclassifiers?: Partial<Record<ClassifierApi, ProviderClassifier>>;\n\theaders?: Record<string, string>;\n\tauthHeader?: boolean;\n\toauth?: ExtensionOAuthConfig;\n\tmodels?: ProviderModelConfig[];\n\trefreshModels?(context: RefreshModelsContext): Promise<ProviderModelConfig[]>;\n}\n\nexport type AuthStatus = {\n\tconfigured: boolean;\n\tsource?: \"stored\" | \"runtime\" | \"environment\" | \"fallback\" | \"models_json_key\" | \"models_json_command\";\n\tlabel?: string;\n};\n\nexport const clearApiKeyCache = clearConfigValueCache;\n\nfunction getAllProviderModels(provider: Provider | undefined): readonly AnyModel[] {\n\treturn provider ? (provider.getAllModels?.() ?? provider.getModels()) : [];\n}\n\nfunction mergeCompat(\n\tbase: Model<Api>[\"compat\"],\n\toverride: Model<Api>[\"compat\"] | ModelsJsonModelOverride[\"compat\"],\n): Model<Api>[\"compat\"] {\n\tif (!override) return base;\n\tconst merged = { ...base, ...override } as NonNullable<Model<Api>[\"compat\"]>;\n\tconst baseNested = base as Record<string, unknown> | undefined;\n\tconst overrideNested = override as Record<string, unknown>;\n\tconst mergedNested = merged as Record<string, unknown>;\n\tfor (const key of [\"openRouterRouting\", \"vercelGatewayRouting\", \"chatTemplateKwargs\", \"chatTemplateArgs\"] as const) {\n\t\tconst baseValue = baseNested?.[key];\n\t\tconst overrideValue = overrideNested[key];\n\t\tif (\n\t\t\t(typeof baseValue === \"object\" && baseValue !== null) ||\n\t\t\t(typeof overrideValue === \"object\" && overrideValue !== null)\n\t\t) {\n\t\t\tmergedNested[key] = { ...(baseValue as object | undefined), ...(overrideValue as object | undefined) };\n\t\t}\n\t}\n\treturn merged;\n}\n\nfunction mergeInputLimits(\n\tbase: Model<Api>[\"inputLimits\"],\n\toverride: ModelsJsonModelOverride[\"inputLimits\"],\n): Model<Api>[\"inputLimits\"] {\n\tif (!override) return base;\n\treturn {\n\t\t...base,\n\t\t...override,\n\t\timages: override.images\n\t\t\t? {\n\t\t\t\t\t...base?.images,\n\t\t\t\t\t...override.images,\n\t\t\t\t\tresize: override.images.resize\n\t\t\t\t\t\t? { ...base?.images?.resize, ...override.images.resize }\n\t\t\t\t\t\t: base?.images?.resize,\n\t\t\t\t}\n\t\t\t: base?.images,\n\t};\n}\n\nfunction applyModelOverride(model: Model<Api>, override: ModelsJsonModelOverride): Model<Api> {\n\treturn {\n\t\t...model,\n\t\tname: override.name ?? model.name,\n\t\treasoning: override.reasoning ?? model.reasoning,\n\t\tthinkingLevelMap: override.thinkingLevelMap\n\t\t\t? { ...model.thinkingLevelMap, ...override.thinkingLevelMap }\n\t\t\t: model.thinkingLevelMap,\n\t\tinput: (override.input as (\"text\" | \"image\")[] | undefined) ?? model.input,\n\t\tinputLimits: mergeInputLimits(model.inputLimits, override.inputLimits),\n\t\tcost: override.cost\n\t\t\t? {\n\t\t\t\t\tinput: override.cost.input ?? model.cost.input,\n\t\t\t\t\toutput: override.cost.output ?? model.cost.output,\n\t\t\t\t\tcacheRead: override.cost.cacheRead ?? model.cost.cacheRead,\n\t\t\t\t\tcacheWrite: override.cost.cacheWrite ?? model.cost.cacheWrite,\n\t\t\t\t\ttiers: override.cost.tiers ?? model.cost.tiers,\n\t\t\t\t}\n\t\t\t: model.cost,\n\t\tpromptCache: override.promptCache ? { ...model.promptCache, ...override.promptCache } : model.promptCache,\n\t\tcontextWindow: override.contextWindow ?? model.contextWindow,\n\t\tmaxTokens: override.maxTokens ?? model.maxTokens,\n\t\tsamplingParams: override.samplingParams\n\t\t\t? { ...model.samplingParams, ...override.samplingParams }\n\t\t\t: model.samplingParams,\n\t\tcompat: mergeCompat(model.compat, override.compat),\n\t};\n}\n\nfunction modelFromJson(\n\tproviderId: string,\n\tdefinition: ModelsJsonModel,\n\tproviderConfig: ModelsJsonProvider,\n\tdefaults: Model<Api> | undefined,\n): Model<Api> {\n\tconst api = definition.api ?? providerConfig.api ?? defaults?.api;\n\tif (!api) {\n\t\tthrow new Error(\n\t\t\t`Provider ${providerId}, model ${definition.id}: no \"api\" specified. Set at provider or model level.`,\n\t\t);\n\t}\n\tconst baseUrl = definition.baseUrl ?? providerConfig.baseUrl ?? defaults?.baseUrl;\n\tif (!baseUrl) throw new Error(`Provider ${providerId}: \"baseUrl\" is required when defining custom models.`);\n\tif (definition.contextWindow !== undefined && definition.contextWindow <= 0) {\n\t\tthrow new Error(`Provider ${providerId}, model ${definition.id}: invalid contextWindow`);\n\t}\n\tif (definition.maxTokens !== undefined && definition.maxTokens <= 0) {\n\t\tthrow new Error(`Provider ${providerId}, model ${definition.id}: invalid maxTokens`);\n\t}\n\treturn {\n\t\tid: definition.id,\n\t\tname: definition.name ?? definition.id,\n\t\tapi: api as Api,\n\t\tprovider: providerId,\n\t\tbaseUrl,\n\t\treasoning: definition.reasoning ?? false,\n\t\tthinkingLevelMap: definition.thinkingLevelMap,\n\t\tinput: (definition.input ?? [\"text\"]) as (\"text\" | \"image\")[],\n\t\tinputLimits: definition.inputLimits,\n\t\tcost: definition.cost ?? { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },\n\t\tpromptCache: definition.promptCache,\n\t\tcontextWindow: definition.contextWindow ?? 128000,\n\t\tmaxTokens: definition.maxTokens ?? 16384,\n\t\tsamplingParams: definition.samplingParams,\n\t\theaders: undefined,\n\t\tcompat: mergeCompat(providerConfig.compat, definition.compat),\n\t};\n}\n\nfunction findModelDefaults(models: readonly AnyModel[], modelId: string, api?: Api): Model<Api> | undefined {\n\tconst chatModels = models.filter((model) => isModelType(model, \"chat\"));\n\treturn (\n\t\tchatModels.find((model) => model.id === modelId) ??\n\t\t(api ? chatModels.find((model) => model.api === api) : undefined) ??\n\t\tchatModels.find((model) => model.api === \"openai-completions\") ??\n\t\tchatModels[0]\n\t);\n}\n\nfunction findExtensionModelDefaults(\n\tmodels: readonly AnyModel[],\n\tdefinition: ProviderModelConfig,\n): AnyModel | undefined {\n\tconst type = definition.type ?? \"chat\";\n\tconst candidates = models.filter((model) => isModelType(model, type));\n\treturn (\n\t\tcandidates.find((model) => model.id === definition.id) ??\n\t\t(definition.api ? candidates.find((model) => model.api === definition.api) : undefined) ??\n\t\t(type === \"chat\" ? candidates.find((model) => model.api === \"openai-completions\") : undefined) ??\n\t\tcandidates[0]\n\t);\n}\n\nfunction extensionModelFromDefinition(\n\tproviderId: string,\n\tmodels: readonly AnyModel[],\n\tconfig: ProviderConfigInput,\n\tdefinition: ProviderModelConfig,\n): AnyModel {\n\tconst type = definition.type ?? \"chat\";\n\tconst defaults = findExtensionModelDefaults(models, definition);\n\tconst api = definition.api ?? (type === \"chat\" ? config.api : undefined) ?? defaults?.api;\n\tif (!api) {\n\t\tthrow new Error(\n\t\t\t`Provider ${providerId}, model ${definition.id}: no \"api\" specified. Set it at model level${type === \"chat\" ? \" or provider level\" : \"\"}.`,\n\t\t);\n\t}\n\tconst baseUrl = definition.baseUrl ?? config.baseUrl ?? defaults?.baseUrl;\n\tif (!baseUrl) throw new Error(`Provider ${providerId}: \"baseUrl\" is required when defining custom models.`);\n\tif (definition.type === \"image\") {\n\t\treturn { ...definition, api: api as ImageApi, provider: providerId, baseUrl, headers: undefined };\n\t}\n\tif (definition.type === \"classifier\") {\n\t\treturn { ...definition, api: api as ClassifierApi, provider: providerId, baseUrl, headers: undefined };\n\t}\n\treturn { ...definition, api: api as Api, provider: providerId, baseUrl, headers: undefined };\n}\n\nfunction applyModelsJson(\n\tproviderId: string,\n\tbaseModels: readonly AnyModel[],\n\tconfig: ModelsJsonProvider | undefined,\n): AnyModel[] {\n\tif (!config) return [...baseModels];\n\tif (config.oauth && !config.baseUrl) {\n\t\tthrow new Error(`Provider ${providerId}: \"baseUrl\" is required when \"oauth\" is set.`);\n\t}\n\tconst hasOverrides = config.modelOverrides && Object.keys(config.modelOverrides).length > 0;\n\tif (\n\t\t!config.models?.length &&\n\t\t!config.baseUrl &&\n\t\t!config.headers &&\n\t\t!config.compat &&\n\t\t!hasOverrides &&\n\t\t!config.apiKey &&\n\t\t!config.oauth &&\n\t\tconfig.authHeader === undefined\n\t) {\n\t\tthrow new Error(\n\t\t\t`Provider ${providerId}: must specify \"baseUrl\", \"headers\", \"compat\", \"modelOverrides\", or \"models\".`,\n\t\t);\n\t}\n\n\tconst models: AnyModel[] = baseModels.map((model) => {\n\t\tconst baseUrl = config.oauth === \"radius\" ? model.baseUrl : (config.baseUrl ?? model.baseUrl);\n\t\treturn isModelType(model, \"chat\")\n\t\t\t? { ...model, baseUrl, compat: mergeCompat(model.compat, config.compat) }\n\t\t\t: { ...model, baseUrl };\n\t});\n\tfor (const definition of config.models ?? []) {\n\t\tconst existingIndex = models.findIndex((model) => isModelType(model, \"chat\") && model.id === definition.id);\n\t\tconst defaults = findModelDefaults(models, definition.id, definition.api ?? config.api);\n\t\tconst model = modelFromJson(providerId, definition, config, defaults);\n\t\tif (existingIndex >= 0) models[existingIndex] = model;\n\t\telse models.push(model);\n\t}\n\treturn models;\n}\n\nfunction applyExtension(\n\tproviderId: string,\n\tmodels: readonly AnyModel[],\n\tconfig: ProviderConfigInput | undefined,\n): AnyModel[] {\n\tif (!config) return [...models];\n\tif (!config.models) {\n\t\treturn config.baseUrl ? models.map((model) => ({ ...model, baseUrl: config.baseUrl! })) : [...models];\n\t}\n\treturn config.models.map((definition) => extensionModelFromDefinition(providerId, models, config, definition));\n}\n\nfunction adaptOAuth(config: ExtensionOAuthConfig): OAuthAuth {\n\treturn {\n\t\tname: config.name,\n\t\tisSubscription: config.isSubscription,\n\t\tlogin: async (callbacks) => {\n\t\t\tconst credential = await config.login({\n\t\t\t\tonAuth: (info) => callbacks.notify({ type: \"auth_url\", ...info }),\n\t\t\t\tonDeviceCode: (info) => callbacks.notify({ type: \"device_code\", ...info }),\n\t\t\t\tonPrompt: (prompt) => callbacks.prompt({ type: \"text\", ...prompt }),\n\t\t\t\tonProgress: (message) => callbacks.notify({ type: \"progress\", message }),\n\t\t\t\tonManualCodeInput: () => callbacks.prompt({ type: \"manual_code\", message: \"Paste the authorization code\" }),\n\t\t\t\tonSelect: (prompt) => callbacks.prompt({ type: \"select\", ...prompt }),\n\t\t\t\tsignal: callbacks.signal,\n\t\t\t});\n\t\t\treturn { ...credential, type: \"oauth\" };\n\t\t},\n\t\trefresh: async (credential, signal) => ({ ...(await config.refreshToken(credential, signal)), type: \"oauth\" }),\n\t\ttoAuth: async (credential) => ({ apiKey: config.getApiKey(credential) }),\n\t};\n}\n\nfunction withConfiguredAuth(\n\tauth: ModelAuth,\n\theaders: Record<string, string> | undefined,\n\tauthHeader: boolean,\n): ModelAuth {\n\tlet mergedHeaders: ProviderHeaders | undefined =\n\t\tauth.headers || headers ? { ...auth.headers, ...headers } : undefined;\n\tif (authHeader) {\n\t\tif (!auth.apiKey) throw new Error(\"authHeader requires a resolved API key\");\n\t\tmergedHeaders = { ...mergedHeaders, Authorization: `Bearer ${auth.apiKey}` };\n\t}\n\treturn { ...auth, headers: mergedHeaders };\n}\n\nfunction configuredApiKey(\n\tconfig: ModelsJsonProvider | undefined,\n\textension: ProviderConfigInput | undefined,\n): string | undefined {\n\treturn extension?.apiKey ?? config?.apiKey;\n}\n\nfunction configuredHeaders(\n\tconfig: ModelsJsonProvider | undefined,\n\textension: ProviderConfigInput | undefined,\n): Record<string, string> | undefined {\n\tif (!config?.headers && !extension?.headers) return undefined;\n\treturn { ...config?.headers, ...extension?.headers };\n}\n\nasync function configContextEnv(\n\tvalues: readonly string[],\n\tctx: AuthContext,\n\texplicit?: Record<string, string>,\n): Promise<Record<string, string> | undefined> {\n\tconst env = { ...explicit };\n\tfor (const name of new Set(values.flatMap(getConfigValueEnvVarNames))) {\n\t\tif (env[name] !== undefined) continue;\n\t\tconst value = await ctx.env(name);\n\t\tif (value !== undefined) env[name] = value;\n\t}\n\treturn Object.keys(env).length > 0 ? env : undefined;\n}\n\nfunction composeApiKeyAuth(\n\tproviderId: string,\n\tbase: Provider | undefined,\n\tconfig: ModelsJsonProvider | undefined,\n\textension: ProviderConfigInput | undefined,\n): ApiKeyAuth | undefined {\n\tconst inherited = base?.auth.apiKey;\n\tconst rawKey = configuredApiKey(config, extension);\n\tconst oauth = extension?.oauth ?? base?.auth.oauth;\n\t// OAuth-only providers get no fabricated API-key login method.\n\tif (!inherited && rawKey === undefined && oauth) return undefined;\n\tconst rawHeaders = configuredHeaders(config, extension);\n\tconst authHeader = extension?.authHeader ?? config?.authHeader ?? false;\n\treturn {\n\t\tname: inherited?.name ?? \"API key\",\n\t\tlogin:\n\t\t\tinherited?.login ??\n\t\t\t(async (interaction: AuthInteraction) => ({\n\t\t\t\ttype: \"api_key\",\n\t\t\t\tkey: await interaction.prompt({ type: \"secret\", message: \"Enter API key\" }),\n\t\t\t})),\n\t\tcheck: async (input) => {\n\t\t\tif (input.credential) {\n\t\t\t\tif (inherited?.check) return inherited.check(input);\n\t\t\t\tif (input.credential.key) return { type: \"api_key\", source: \"stored credential\" };\n\t\t\t\tconst resolved = await inherited?.resolve(input);\n\t\t\t\treturn resolved ? { type: \"api_key\", source: resolved.source } : undefined;\n\t\t\t}\n\t\t\tif (rawKey !== undefined) {\n\t\t\t\tif (isCommandConfigValue(rawKey)) return { type: \"api_key\", source: \"configured API key\" };\n\t\t\t\tconst envNames = getConfigValueEnvVarNames(rawKey);\n\t\t\t\tfor (const name of envNames) {\n\t\t\t\t\tif ((await input.ctx.env(name)) === undefined) return undefined;\n\t\t\t\t}\n\t\t\t\treturn { type: \"api_key\", source: \"configured API key\" };\n\t\t\t}\n\t\t\tif (inherited?.check) return inherited.check(input);\n\t\t\tconst resolved = await inherited?.resolve(input);\n\t\t\treturn resolved ? { type: \"api_key\", source: resolved.source } : undefined;\n\t\t},\n\t\tresolve: async (input) => {\n\t\t\tlet result: AuthResult | undefined;\n\t\t\tif (input.credential) {\n\t\t\t\tresult = inherited\n\t\t\t\t\t? await inherited.resolve(input)\n\t\t\t\t\t: input.credential.key\n\t\t\t\t\t\t? { auth: { apiKey: input.credential.key }, env: input.credential.env, source: \"stored credential\" }\n\t\t\t\t\t\t: undefined;\n\t\t\t} else if (rawKey !== undefined) {\n\t\t\t\tconst env = await configContextEnv([rawKey], input.ctx);\n\t\t\t\tconst key = resolveConfigValueOrThrow(rawKey, `API key for provider \"${providerId}\"`, env);\n\t\t\t\tresult = inherited\n\t\t\t\t\t? await inherited.resolve({ ...input, credential: { type: \"api_key\", key } })\n\t\t\t\t\t: { auth: { apiKey: key }, source: \"configured API key\" };\n\t\t\t} else {\n\t\t\t\tresult = await inherited?.resolve(input);\n\t\t\t}\n\t\t\tif (!result) return undefined;\n\t\t\tconst explicitEnv = { ...(input.credential?.env ?? {}), ...(result.env ?? {}) };\n\t\t\tconst headerEnv = await configContextEnv(Object.values(rawHeaders ?? {}), input.ctx, explicitEnv);\n\t\t\tconst headers = resolveHeadersOrThrow(rawHeaders, `provider \"${providerId}\"`, headerEnv);\n\t\t\treturn { ...result, auth: withConfiguredAuth(result.auth, headers, authHeader) };\n\t\t},\n\t};\n}\n\nfunction composeOAuthAuth(\n\tproviderId: string,\n\tbase: Provider | undefined,\n\tconfig: ModelsJsonProvider | undefined,\n\textension: ProviderConfigInput | undefined,\n): OAuthAuth | undefined {\n\tconst oauth = extension?.oauth ? adaptOAuth(extension.oauth) : base?.auth.oauth;\n\tif (!oauth) return undefined;\n\tconst rawHeaders = configuredHeaders(config, extension);\n\tconst authHeader = extension?.authHeader ?? config?.authHeader ?? false;\n\treturn {\n\t\t...oauth,\n\t\ttoAuth: async (credential) => {\n\t\t\tconst auth = await oauth.toAuth(credential);\n\t\t\tconst env = credential.env;\n\t\t\tconst headers = resolveHeadersOrThrow(\n\t\t\t\trawHeaders,\n\t\t\t\t`provider \"${providerId}\"`,\n\t\t\t\ttypeof env === \"object\" && env !== null ? (env as Record<string, string>) : undefined,\n\t\t\t);\n\t\t\treturn withConfiguredAuth(auth, headers, authHeader);\n\t\t},\n\t};\n}\n\nfunction rawModelHeaders(\n\tmodel: AnyModel,\n\tconfig: ModelsJsonProvider | undefined,\n\textension: ProviderConfigInput | undefined,\n): Record<string, string> | undefined {\n\t// models.json definitions and overrides are chat-only. Extension definitions\n\t// are matched by operation and id so colliding models cannot share headers.\n\tconst chatDefinition = isModelType(model, \"chat\")\n\t\t? config?.models?.find((entry) => entry.id === model.id)\n\t\t: undefined;\n\tconst extensionModel = extension?.models?.find(\n\t\t(entry) => (entry.type ?? \"chat\") === (model.type ?? \"chat\") && entry.id === model.id,\n\t);\n\tconst headers = {\n\t\t...(isModelType(model, \"chat\") ? config?.modelOverrides?.[model.id]?.headers : undefined),\n\t\t...chatDefinition?.headers,\n\t\t...extensionModel?.headers,\n\t};\n\treturn Object.keys(headers).length > 0 ? headers : undefined;\n}\n\nexport function validateExtensionProvider(\n\tproviderId: string,\n\tbase: Provider | undefined,\n\tmodelsConfig: ModelsJsonProvider | undefined,\n\textension: ProviderConfigInput,\n): void {\n\tif (extension.streamSimple && !extension.api) {\n\t\tthrow new Error(`Provider ${providerId}: \"api\" is required when registering streamSimple.`);\n\t}\n\tapplyExtension(providerId, applyModelsJson(providerId, getAllProviderModels(base), modelsConfig), extension);\n}\n\n/** Compose built-in, models.json, and extension layers without reading credentials. */\nexport function composeModelProvider(\n\tproviderId: string,\n\tbase: Provider | undefined,\n\tmodelConfig: ModelConfig,\n\textension: ProviderConfigInput | undefined,\n): Provider {\n\tconst config = modelConfig.getProvider(providerId);\n\tlet extensionOAuthCredential: OAuthCredentials | undefined;\n\tlet refreshedExtensionModels: ProviderConfigInput[\"models\"];\n\tconst currentExtension = (): ProviderConfigInput | undefined =>\n\t\textension && refreshedExtensionModels ? { ...extension, models: refreshedExtensionModels } : extension;\n\t// models.json modelOverrides are the topmost user-config layer: they apply once,\n\t// after custom-model upserts, extension model replacement, and legacy OAuth projection.\n\tconst getAllModels = (): AnyModel[] => {\n\t\tlet models = applyExtension(\n\t\t\tproviderId,\n\t\t\tapplyModelsJson(providerId, getAllProviderModels(base), config),\n\t\t\tcurrentExtension(),\n\t\t);\n\t\tif (extensionOAuthCredential && extension?.oauth?.modifyModels) {\n\t\t\t// The extension hook is chat-only; other model types pass through untouched.\n\t\t\tmodels = [\n\t\t\t\t...extension.oauth.modifyModels(\n\t\t\t\t\tmodels.filter((model) => isModelType(model, \"chat\")),\n\t\t\t\t\textensionOAuthCredential,\n\t\t\t\t),\n\t\t\t\t...models.filter((model) => !isModelType(model, \"chat\")),\n\t\t\t];\n\t\t}\n\t\treturn models.map((model) => {\n\t\t\tconst override = config?.modelOverrides?.[model.id];\n\t\t\treturn override && isModelType(model, \"chat\") ? applyModelOverride(model, override) : model;\n\t\t});\n\t};\n\t// Validate eagerly so registration/reload reports structural errors immediately.\n\tgetAllModels();\n\tconst apiKey = composeApiKeyAuth(providerId, base, config, extension);\n\tconst oauth = composeOAuthAuth(providerId, base, config, extension);\n\tif (!apiKey && !oauth) throw new Error(`Provider ${providerId}: no authentication method configured.`);\n\n\tconst supportsBaseApi = (model: Model<Api>) => base?.getModels().some((entry) => entry.api === model.api) ?? false;\n\tconst streamWith = (\n\t\tmodel: Model<Api>,\n\t\tcontext: TranscriptContext,\n\t\toptions: StreamOptions | undefined,\n\t\tsimple: boolean,\n\t): AssistantMessageEventStream =>\n\t\tlazyStream(model, async () => {\n\t\t\tif (extension?.streamSimple && model.api === extension.api) {\n\t\t\t\treturn extension.streamSimple(model, context, options as SimpleStreamOptions);\n\t\t\t}\n\t\t\tif (base && supportsBaseApi(model)) {\n\t\t\t\treturn simple\n\t\t\t\t\t? base.streamSimple(model, context, options as SimpleStreamOptions)\n\t\t\t\t\t: base.stream(model, context, options);\n\t\t\t}\n\t\t\tconst api = getApiProvider(model.api);\n\t\t\tif (!api) throw new Error(`No API provider registered for api: ${model.api}`);\n\t\t\treturn simple\n\t\t\t\t? api.streamSimple(model, context, options as SimpleStreamOptions)\n\t\t\t\t: api.stream(model, context, options);\n\t\t});\n\n\tconst provider: Provider = {\n\t\tid: providerId,\n\t\tname: extension?.name ?? config?.name ?? base?.name ?? extension?.oauth?.name ?? providerId,\n\t\tbaseUrl: extension?.baseUrl ?? config?.baseUrl ?? base?.baseUrl,\n\t\theaders: base?.headers,\n\t\tauth: { ...(apiKey ? { apiKey } : {}), ...(oauth ? { oauth } : {}) },\n\t\tgetModels: () => getAllModels().filter((model) => isModelType(model, \"chat\")),\n\t\tgetAllModels,\n\t\trefreshModels:\n\t\t\tbase?.refreshModels || extension?.refreshModels || extension?.oauth?.modifyModels\n\t\t\t\t? async (context) => {\n\t\t\t\t\t\tawait base?.refreshModels?.(context);\n\t\t\t\t\t\tlet refreshed: NonNullable<ProviderConfigInput[\"models\"]> | undefined;\n\t\t\t\t\t\tif (extension?.refreshModels) refreshed = await extension.refreshModels(context);\n\t\t\t\t\t\tif (context.signal.aborted) return;\n\t\t\t\t\t\tconst oauthCredential = context.credential?.type === \"oauth\" ? context.credential : undefined;\n\t\t\t\t\t\tawait context.publish({\n\t\t\t\t\t\t\tupdate: () => {\n\t\t\t\t\t\t\t\tif (refreshed) {\n\t\t\t\t\t\t\t\t\t// Validate before publishing the new synchronous list.\n\t\t\t\t\t\t\t\t\tapplyExtension(providerId, applyModelsJson(providerId, getAllProviderModels(base), config), {\n\t\t\t\t\t\t\t\t\t\t...extension,\n\t\t\t\t\t\t\t\t\t\tmodels: refreshed,\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\trefreshedExtensionModels = refreshed;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\textensionOAuthCredential = oauthCredential;\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t: undefined,\n\t\tfilterModels: base?.filterModels\n\t\t\t? (models, credential: Credential | undefined) => base.filterModels!(models, credential)\n\t\t\t: undefined,\n\t\tfilterAllModels: base?.filterAllModels\n\t\t\t? (models, credential: Credential | undefined) => base.filterAllModels!(models, credential)\n\t\t\t: undefined,\n\t\tstream: (model, context, options) => streamWith(model, context, options, false),\n\t\tstreamSimple: (model, context, options) => streamWith(model, context, options, true),\n\t};\n\n\tconst fetchDeferred = base?.fetchDeferred;\n\tif (fetchDeferred) {\n\t\tprovider.fetchDeferred = (model, handle, options) => fetchDeferred(model, handle, options);\n\t}\n\tconst cancelDeferred = base?.cancelDeferred;\n\tif (cancelDeferred) {\n\t\tprovider.cancelDeferred = (model, handle, options) => cancelDeferred(model, handle, options);\n\t}\n\tconst extensionImages = extension?.images;\n\tconst generateImages = base?.generateImages;\n\tif (generateImages || Object.keys(extensionImages ?? {}).length > 0) {\n\t\tprovider.generateImages = (model, context, options) => {\n\t\t\tconst implementation = extensionImages?.[model.api];\n\t\t\tif (implementation) return implementation.generateImages(model, context, options);\n\t\t\tif (generateImages) return generateImages(model, context, options);\n\t\t\treturn Promise.resolve(\n\t\t\t\timageErrorResult(model, new Error(`Provider ${providerId} has no image implementation for \"${model.api}\"`)),\n\t\t\t);\n\t\t};\n\t}\n\tconst extensionClassifiers = extension?.classifiers;\n\tconst classify = base?.classify;\n\tif (classify || Object.keys(extensionClassifiers ?? {}).length > 0) {\n\t\tprovider.classify = (model, context, options) => {\n\t\t\tconst implementation = extensionClassifiers?.[model.api];\n\t\t\tif (implementation) return implementation.classify(model, context, options);\n\t\t\tif (classify) return classify(model, context, options);\n\t\t\treturn Promise.resolve(\n\t\t\t\tclassifierErrorResult(\n\t\t\t\t\tmodel,\n\t\t\t\t\tnew Error(`Provider ${providerId} has no classifier implementation for \"${model.api}\"`),\n\t\t\t\t),\n\t\t\t);\n\t\t};\n\t}\n\n\treturn provider;\n}\n\nexport function resolveConfiguredModelHeaders(\n\tmodel: AnyModel,\n\tconfig: ModelsJsonProvider | undefined,\n\textension: ProviderConfigInput | undefined,\n\tenv?: Record<string, string>,\n): Record<string, string> | undefined {\n\treturn resolveHeadersOrThrow(\n\t\trawModelHeaders(model, config, extension),\n\t\t`model \"${model.provider}/${model.id}\"`,\n\t\tenv,\n\t);\n}\n\nexport interface CompatibilityRequestConfig {\n\theaders?: ProviderHeaders;\n\tauthHeader: boolean;\n}\n\nexport function resolveCompatibilityRequestConfig(\n\tmodel: AnyModel,\n\tconfig: ModelsJsonProvider | undefined,\n\textension: ProviderConfigInput | undefined,\n): CompatibilityRequestConfig {\n\tconst configured = resolveHeadersOrThrow(\n\t\t{ ...configuredHeaders(config, extension), ...rawModelHeaders(model, config, extension) },\n\t\t`model \"${model.provider}/${model.id}\"`,\n\t);\n\treturn {\n\t\theaders: model.headers || configured ? { ...model.headers, ...configured } : undefined,\n\t\tauthHeader: extension?.authHeader ?? config?.authHeader ?? false,\n\t};\n}\n\nexport function configuredRequestAuthStatus(\n\tconfig: ModelsJsonProvider | undefined,\n\textension: ProviderConfigInput | undefined,\n): AuthStatus | undefined {\n\tconst value = configuredApiKey(config, extension);\n\tif (value === undefined) return undefined;\n\tif (isCommandConfigValue(value)) return { configured: true, source: \"models_json_command\" };\n\tconst names = getConfigValueEnvVarNames(value);\n\tif (names.length > 0) {\n\t\treturn isConfigValueConfigured(value)\n\t\t\t? { configured: true, source: \"environment\", label: names.join(\", \") }\n\t\t\t: { configured: false };\n\t}\n\treturn { configured: true, source: extension?.apiKey !== undefined ? \"fallback\" : \"models_json_key\" };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"provider-composer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AAE,CAAC;IAC1B,CAAC;IACD,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;AACvG,CAAC","sourcesContent":["import {\n\ttype AnyModel,\n\ttype Api,\n\ttype ApiKeyAuth,\n\ttype AssistantMessageEventStream,\n\ttype AuthContext,\n\ttype AuthInteraction,\n\ttype AuthResult,\n\ttype ClassifierApi,\n\ttype Credential,\n\ttype ImageApi,\n\tisModelType,\n\tlazyStream,\n\ttype Model,\n\ttype ModelAuth,\n\ttype OAuthAuth,\n\ttype OAuthCredentials,\n\ttype OAuthLoginCallbacks,\n\ttype Provider,\n\ttype ProviderClassifier,\n\ttype ProviderHeaders,\n\ttype ProviderImages,\n\ttype RefreshModelsContext,\n\ttype SimpleStreamOptions,\n\ttype StreamOptions,\n\ttype TranscriptContext,\n} from \"@earendil-works/pi-ai\";\nimport { getApiProvider } from \"@earendil-works/pi-ai/compat\";\nimport { classifierErrorResult, imageErrorResult } from \"@earendil-works/pi-ai/utils/model-operations\";\nimport type { ModelConfig, ModelsJsonModel, ModelsJsonModelOverride, ModelsJsonProvider } from \"./model-config.ts\";\nimport {\n\tclearConfigValueCache,\n\tgetConfigValueEnvVarNames,\n\tisCommandConfigValue,\n\tisConfigValueConfigured,\n\tresolveConfigValueOrThrow,\n\tresolveHeadersOrThrow,\n} from \"./resolve-config-value.ts\";\n\nexport interface ExtensionOAuthConfig {\n\tname: string;\n\t/** Whether access through this auth method is backed by a provider subscription. */\n\tisSubscription?: boolean;\n\t/** @deprecated Retained for extension source compatibility; ignored by canonical auth flows. */\n\tusesCallbackServer?: boolean;\n\tlogin(callbacks: OAuthLoginCallbacks): Promise<OAuthCredentials>;\n\trefreshToken(credentials: OAuthCredentials, signal: AbortSignal): Promise<OAuthCredentials>;\n\tgetApiKey(credentials: OAuthCredentials): string;\n\tmodifyModels?(models: Model<Api>[], credentials: OAuthCredentials): Model<Api>[];\n}\n\ninterface ProviderModelConfigBase {\n\tid: string;\n\tname: string;\n\tapi?: string;\n\tbaseUrl?: string;\n\tinput: (\"text\" | \"image\")[];\n\tinputLimits?: AnyModel[\"inputLimits\"];\n\tcost: AnyModel[\"cost\"];\n\theaders?: Record<string, string>;\n}\n\nexport interface ProviderChatModelConfig extends ProviderModelConfigBase {\n\ttype?: \"chat\";\n\tapi?: Api;\n\treasoning: boolean;\n\tthinkingLevelMap?: Model<Api>[\"thinkingLevelMap\"];\n\tpromptCache?: Model<Api>[\"promptCache\"];\n\tcontextWindow: number;\n\tmaxTokens: number;\n\tsamplingParams?: Model<Api>[\"samplingParams\"];\n\tsamplingParamsByThinkingLevel?: Model<Api>[\"samplingParamsByThinkingLevel\"];\n\tcompat?: Model<Api>[\"compat\"];\n}\n\nexport interface ProviderImageModelConfig extends ProviderModelConfigBase {\n\ttype: \"image\";\n\tapi?: ImageApi;\n\toutput: (\"text\" | \"image\")[];\n}\n\nexport interface ProviderClassifierModelConfig extends ProviderModelConfigBase {\n\ttype: \"classifier\";\n\tapi?: ClassifierApi;\n\tcontextWindow: number;\n}\n\nexport type ProviderModelConfig = ProviderChatModelConfig | ProviderImageModelConfig | ProviderClassifierModelConfig;\n\n/** Input type for the extension registerProvider API. */\nexport interface ProviderConfigInput {\n\tname?: string;\n\tbaseUrl?: string;\n\tapiKey?: string;\n\tapi?: Api;\n\tstreamSimple?: (\n\t\tmodel: Model<Api>,\n\t\tcontext: TranscriptContext,\n\t\toptions?: SimpleStreamOptions,\n\t) => AssistantMessageEventStream;\n\timages?: Partial<Record<ImageApi, ProviderImages>>;\n\tclassifiers?: Partial<Record<ClassifierApi, ProviderClassifier>>;\n\theaders?: Record<string, string>;\n\tauthHeader?: boolean;\n\toauth?: ExtensionOAuthConfig;\n\tmodels?: ProviderModelConfig[];\n\trefreshModels?(context: RefreshModelsContext): Promise<ProviderModelConfig[]>;\n}\n\nexport type AuthStatus = {\n\tconfigured: boolean;\n\tsource?: \"stored\" | \"runtime\" | \"environment\" | \"fallback\" | \"models_json_key\" | \"models_json_command\";\n\tlabel?: string;\n};\n\nexport const clearApiKeyCache = clearConfigValueCache;\n\nfunction getAllProviderModels(provider: Provider | undefined): readonly AnyModel[] {\n\treturn provider ? (provider.getAllModels?.() ?? provider.getModels()) : [];\n}\n\nfunction mergeCompat(\n\tbase: Model<Api>[\"compat\"],\n\toverride: Model<Api>[\"compat\"] | ModelsJsonModelOverride[\"compat\"],\n): Model<Api>[\"compat\"] {\n\tif (!override) return base;\n\tconst merged = { ...base, ...override } as NonNullable<Model<Api>[\"compat\"]>;\n\tconst baseNested = base as Record<string, unknown> | undefined;\n\tconst overrideNested = override as Record<string, unknown>;\n\tconst mergedNested = merged as Record<string, unknown>;\n\tfor (const key of [\"openRouterRouting\", \"vercelGatewayRouting\", \"chatTemplateKwargs\", \"chatTemplateArgs\"] as const) {\n\t\tconst baseValue = baseNested?.[key];\n\t\tconst overrideValue = overrideNested[key];\n\t\tif (\n\t\t\t(typeof baseValue === \"object\" && baseValue !== null) ||\n\t\t\t(typeof overrideValue === \"object\" && overrideValue !== null)\n\t\t) {\n\t\t\tmergedNested[key] = { ...(baseValue as object | undefined), ...(overrideValue as object | undefined) };\n\t\t}\n\t}\n\treturn merged;\n}\n\nfunction mergeInputLimits(\n\tbase: Model<Api>[\"inputLimits\"],\n\toverride: ModelsJsonModelOverride[\"inputLimits\"],\n): Model<Api>[\"inputLimits\"] {\n\tif (!override) return base;\n\treturn {\n\t\t...base,\n\t\t...override,\n\t\timages: override.images\n\t\t\t? {\n\t\t\t\t\t...base?.images,\n\t\t\t\t\t...override.images,\n\t\t\t\t\tresize: override.images.resize\n\t\t\t\t\t\t? { ...base?.images?.resize, ...override.images.resize }\n\t\t\t\t\t\t: base?.images?.resize,\n\t\t\t\t}\n\t\t\t: base?.images,\n\t};\n}\n\nfunction mergeSamplingParamsByThinkingLevel(\n\tbase: Model<Api>[\"samplingParamsByThinkingLevel\"],\n\toverride: Model<Api>[\"samplingParamsByThinkingLevel\"],\n): Model<Api>[\"samplingParamsByThinkingLevel\"] {\n\tif (!override) return base;\n\tconst merged = { ...base };\n\tfor (const level of [\"off\", \"minimal\", \"low\", \"medium\", \"high\", \"xhigh\", \"max\"] as const) {\n\t\tconst params = override[level];\n\t\tif (params) merged[level] = { ...base?.[level], ...params };\n\t}\n\treturn merged;\n}\n\nfunction applyModelOverride(model: Model<Api>, override: ModelsJsonModelOverride): Model<Api> {\n\treturn {\n\t\t...model,\n\t\tname: override.name ?? model.name,\n\t\treasoning: override.reasoning ?? model.reasoning,\n\t\tthinkingLevelMap: override.thinkingLevelMap\n\t\t\t? { ...model.thinkingLevelMap, ...override.thinkingLevelMap }\n\t\t\t: model.thinkingLevelMap,\n\t\tinput: (override.input as (\"text\" | \"image\")[] | undefined) ?? model.input,\n\t\tinputLimits: mergeInputLimits(model.inputLimits, override.inputLimits),\n\t\tcost: override.cost\n\t\t\t? {\n\t\t\t\t\tinput: override.cost.input ?? model.cost.input,\n\t\t\t\t\toutput: override.cost.output ?? model.cost.output,\n\t\t\t\t\tcacheRead: override.cost.cacheRead ?? model.cost.cacheRead,\n\t\t\t\t\tcacheWrite: override.cost.cacheWrite ?? model.cost.cacheWrite,\n\t\t\t\t\ttiers: override.cost.tiers ?? model.cost.tiers,\n\t\t\t\t}\n\t\t\t: model.cost,\n\t\tpromptCache: override.promptCache ? { ...model.promptCache, ...override.promptCache } : model.promptCache,\n\t\tcontextWindow: override.contextWindow ?? model.contextWindow,\n\t\tmaxTokens: override.maxTokens ?? model.maxTokens,\n\t\tsamplingParams: override.samplingParams\n\t\t\t? { ...model.samplingParams, ...override.samplingParams }\n\t\t\t: model.samplingParams,\n\t\tsamplingParamsByThinkingLevel: mergeSamplingParamsByThinkingLevel(\n\t\t\tmodel.samplingParamsByThinkingLevel,\n\t\t\toverride.samplingParamsByThinkingLevel,\n\t\t),\n\t\tcompat: mergeCompat(model.compat, override.compat),\n\t};\n}\n\nfunction modelFromJson(\n\tproviderId: string,\n\tdefinition: ModelsJsonModel,\n\tproviderConfig: ModelsJsonProvider,\n\tdefaults: Model<Api> | undefined,\n): Model<Api> {\n\tconst api = definition.api ?? providerConfig.api ?? defaults?.api;\n\tif (!api) {\n\t\tthrow new Error(\n\t\t\t`Provider ${providerId}, model ${definition.id}: no \"api\" specified. Set at provider or model level.`,\n\t\t);\n\t}\n\tconst baseUrl = definition.baseUrl ?? providerConfig.baseUrl ?? defaults?.baseUrl;\n\tif (!baseUrl) throw new Error(`Provider ${providerId}: \"baseUrl\" is required when defining custom models.`);\n\tif (definition.contextWindow !== undefined && definition.contextWindow <= 0) {\n\t\tthrow new Error(`Provider ${providerId}, model ${definition.id}: invalid contextWindow`);\n\t}\n\tif (definition.maxTokens !== undefined && definition.maxTokens <= 0) {\n\t\tthrow new Error(`Provider ${providerId}, model ${definition.id}: invalid maxTokens`);\n\t}\n\treturn {\n\t\tid: definition.id,\n\t\tname: definition.name ?? definition.id,\n\t\tapi: api as Api,\n\t\tprovider: providerId,\n\t\tbaseUrl,\n\t\treasoning: definition.reasoning ?? false,\n\t\tthinkingLevelMap: definition.thinkingLevelMap,\n\t\tinput: (definition.input ?? [\"text\"]) as (\"text\" | \"image\")[],\n\t\tinputLimits: definition.inputLimits,\n\t\tcost: definition.cost ?? { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },\n\t\tpromptCache: definition.promptCache,\n\t\tcontextWindow: definition.contextWindow ?? 128000,\n\t\tmaxTokens: definition.maxTokens ?? 16384,\n\t\tsamplingParams: definition.samplingParams,\n\t\tsamplingParamsByThinkingLevel: definition.samplingParamsByThinkingLevel,\n\t\theaders: undefined,\n\t\tcompat: mergeCompat(providerConfig.compat, definition.compat),\n\t};\n}\n\nfunction findModelDefaults(models: readonly AnyModel[], modelId: string, api?: Api): Model<Api> | undefined {\n\tconst chatModels = models.filter((model) => isModelType(model, \"chat\"));\n\treturn (\n\t\tchatModels.find((model) => model.id === modelId) ??\n\t\t(api ? chatModels.find((model) => model.api === api) : undefined) ??\n\t\tchatModels.find((model) => model.api === \"openai-completions\") ??\n\t\tchatModels[0]\n\t);\n}\n\nfunction findExtensionModelDefaults(\n\tmodels: readonly AnyModel[],\n\tdefinition: ProviderModelConfig,\n): AnyModel | undefined {\n\tconst type = definition.type ?? \"chat\";\n\tconst candidates = models.filter((model) => isModelType(model, type));\n\treturn (\n\t\tcandidates.find((model) => model.id === definition.id) ??\n\t\t(definition.api ? candidates.find((model) => model.api === definition.api) : undefined) ??\n\t\t(type === \"chat\" ? candidates.find((model) => model.api === \"openai-completions\") : undefined) ??\n\t\tcandidates[0]\n\t);\n}\n\nfunction extensionModelFromDefinition(\n\tproviderId: string,\n\tmodels: readonly AnyModel[],\n\tconfig: ProviderConfigInput,\n\tdefinition: ProviderModelConfig,\n): AnyModel {\n\tconst type = definition.type ?? \"chat\";\n\tconst defaults = findExtensionModelDefaults(models, definition);\n\tconst api = definition.api ?? (type === \"chat\" ? config.api : undefined) ?? defaults?.api;\n\tif (!api) {\n\t\tthrow new Error(\n\t\t\t`Provider ${providerId}, model ${definition.id}: no \"api\" specified. Set it at model level${type === \"chat\" ? \" or provider level\" : \"\"}.`,\n\t\t);\n\t}\n\tconst baseUrl = definition.baseUrl ?? config.baseUrl ?? defaults?.baseUrl;\n\tif (!baseUrl) throw new Error(`Provider ${providerId}: \"baseUrl\" is required when defining custom models.`);\n\tif (definition.type === \"image\") {\n\t\treturn { ...definition, api: api as ImageApi, provider: providerId, baseUrl, headers: undefined };\n\t}\n\tif (definition.type === \"classifier\") {\n\t\treturn { ...definition, api: api as ClassifierApi, provider: providerId, baseUrl, headers: undefined };\n\t}\n\treturn { ...definition, api: api as Api, provider: providerId, baseUrl, headers: undefined };\n}\n\nfunction applyModelsJson(\n\tproviderId: string,\n\tbaseModels: readonly AnyModel[],\n\tconfig: ModelsJsonProvider | undefined,\n): AnyModel[] {\n\tif (!config) return [...baseModels];\n\tif (config.oauth && !config.baseUrl) {\n\t\tthrow new Error(`Provider ${providerId}: \"baseUrl\" is required when \"oauth\" is set.`);\n\t}\n\tconst hasOverrides = config.modelOverrides && Object.keys(config.modelOverrides).length > 0;\n\tif (\n\t\t!config.models?.length &&\n\t\t!config.baseUrl &&\n\t\t!config.headers &&\n\t\t!config.compat &&\n\t\t!hasOverrides &&\n\t\t!config.apiKey &&\n\t\t!config.oauth &&\n\t\tconfig.authHeader === undefined\n\t) {\n\t\tthrow new Error(\n\t\t\t`Provider ${providerId}: must specify \"baseUrl\", \"headers\", \"compat\", \"modelOverrides\", or \"models\".`,\n\t\t);\n\t}\n\n\tconst models: AnyModel[] = baseModels.map((model) => {\n\t\tconst baseUrl = config.oauth === \"radius\" ? model.baseUrl : (config.baseUrl ?? model.baseUrl);\n\t\treturn isModelType(model, \"chat\")\n\t\t\t? { ...model, baseUrl, compat: mergeCompat(model.compat, config.compat) }\n\t\t\t: { ...model, baseUrl };\n\t});\n\tfor (const definition of config.models ?? []) {\n\t\tconst existingIndex = models.findIndex((model) => isModelType(model, \"chat\") && model.id === definition.id);\n\t\tconst defaults = findModelDefaults(models, definition.id, definition.api ?? config.api);\n\t\tconst model = modelFromJson(providerId, definition, config, defaults);\n\t\tif (existingIndex >= 0) models[existingIndex] = model;\n\t\telse models.push(model);\n\t}\n\treturn models;\n}\n\nfunction applyExtension(\n\tproviderId: string,\n\tmodels: readonly AnyModel[],\n\tconfig: ProviderConfigInput | undefined,\n): AnyModel[] {\n\tif (!config) return [...models];\n\tif (!config.models) {\n\t\treturn config.baseUrl ? models.map((model) => ({ ...model, baseUrl: config.baseUrl! })) : [...models];\n\t}\n\treturn config.models.map((definition) => extensionModelFromDefinition(providerId, models, config, definition));\n}\n\nfunction adaptOAuth(config: ExtensionOAuthConfig): OAuthAuth {\n\treturn {\n\t\tname: config.name,\n\t\tisSubscription: config.isSubscription,\n\t\tlogin: async (callbacks) => {\n\t\t\tconst credential = await config.login({\n\t\t\t\tonAuth: (info) => callbacks.notify({ type: \"auth_url\", ...info }),\n\t\t\t\tonDeviceCode: (info) => callbacks.notify({ type: \"device_code\", ...info }),\n\t\t\t\tonPrompt: (prompt) => callbacks.prompt({ type: \"text\", ...prompt }),\n\t\t\t\tonProgress: (message) => callbacks.notify({ type: \"progress\", message }),\n\t\t\t\tonManualCodeInput: () => callbacks.prompt({ type: \"manual_code\", message: \"Paste the authorization code\" }),\n\t\t\t\tonSelect: (prompt) => callbacks.prompt({ type: \"select\", ...prompt }),\n\t\t\t\tsignal: callbacks.signal,\n\t\t\t});\n\t\t\treturn { ...credential, type: \"oauth\" };\n\t\t},\n\t\trefresh: async (credential, signal) => ({ ...(await config.refreshToken(credential, signal)), type: \"oauth\" }),\n\t\ttoAuth: async (credential) => ({ apiKey: config.getApiKey(credential) }),\n\t};\n}\n\nfunction withConfiguredAuth(\n\tauth: ModelAuth,\n\theaders: Record<string, string> | undefined,\n\tauthHeader: boolean,\n): ModelAuth {\n\tlet mergedHeaders: ProviderHeaders | undefined =\n\t\tauth.headers || headers ? { ...auth.headers, ...headers } : undefined;\n\tif (authHeader) {\n\t\tif (!auth.apiKey) throw new Error(\"authHeader requires a resolved API key\");\n\t\tmergedHeaders = { ...mergedHeaders, Authorization: `Bearer ${auth.apiKey}` };\n\t}\n\treturn { ...auth, headers: mergedHeaders };\n}\n\nfunction configuredApiKey(\n\tconfig: ModelsJsonProvider | undefined,\n\textension: ProviderConfigInput | undefined,\n): string | undefined {\n\treturn extension?.apiKey ?? config?.apiKey;\n}\n\nfunction configuredHeaders(\n\tconfig: ModelsJsonProvider | undefined,\n\textension: ProviderConfigInput | undefined,\n): Record<string, string> | undefined {\n\tif (!config?.headers && !extension?.headers) return undefined;\n\treturn { ...config?.headers, ...extension?.headers };\n}\n\nasync function configContextEnv(\n\tvalues: readonly string[],\n\tctx: AuthContext,\n\texplicit?: Record<string, string>,\n): Promise<Record<string, string> | undefined> {\n\tconst env = { ...explicit };\n\tfor (const name of new Set(values.flatMap(getConfigValueEnvVarNames))) {\n\t\tif (env[name] !== undefined) continue;\n\t\tconst value = await ctx.env(name);\n\t\tif (value !== undefined) env[name] = value;\n\t}\n\treturn Object.keys(env).length > 0 ? env : undefined;\n}\n\nfunction composeApiKeyAuth(\n\tproviderId: string,\n\tbase: Provider | undefined,\n\tconfig: ModelsJsonProvider | undefined,\n\textension: ProviderConfigInput | undefined,\n): ApiKeyAuth | undefined {\n\tconst inherited = base?.auth.apiKey;\n\tconst rawKey = configuredApiKey(config, extension);\n\tconst oauth = extension?.oauth ?? base?.auth.oauth;\n\t// OAuth-only providers get no fabricated API-key login method.\n\tif (!inherited && rawKey === undefined && oauth) return undefined;\n\tconst rawHeaders = configuredHeaders(config, extension);\n\tconst authHeader = extension?.authHeader ?? config?.authHeader ?? false;\n\treturn {\n\t\tname: inherited?.name ?? \"API key\",\n\t\tlogin:\n\t\t\tinherited?.login ??\n\t\t\t(async (interaction: AuthInteraction) => ({\n\t\t\t\ttype: \"api_key\",\n\t\t\t\tkey: await interaction.prompt({ type: \"secret\", message: \"Enter API key\" }),\n\t\t\t})),\n\t\tcheck: async (input) => {\n\t\t\tif (input.credential) {\n\t\t\t\tif (inherited?.check) return inherited.check(input);\n\t\t\t\tif (input.credential.key) return { type: \"api_key\", source: \"stored credential\" };\n\t\t\t\tconst resolved = await inherited?.resolve(input);\n\t\t\t\treturn resolved ? { type: \"api_key\", source: resolved.source } : undefined;\n\t\t\t}\n\t\t\tif (rawKey !== undefined) {\n\t\t\t\tif (isCommandConfigValue(rawKey)) return { type: \"api_key\", source: \"configured API key\" };\n\t\t\t\tconst envNames = getConfigValueEnvVarNames(rawKey);\n\t\t\t\tfor (const name of envNames) {\n\t\t\t\t\tif ((await input.ctx.env(name)) === undefined) return undefined;\n\t\t\t\t}\n\t\t\t\treturn { type: \"api_key\", source: \"configured API key\" };\n\t\t\t}\n\t\t\tif (inherited?.check) return inherited.check(input);\n\t\t\tconst resolved = await inherited?.resolve(input);\n\t\t\treturn resolved ? { type: \"api_key\", source: resolved.source } : undefined;\n\t\t},\n\t\tresolve: async (input) => {\n\t\t\tlet result: AuthResult | undefined;\n\t\t\tif (input.credential) {\n\t\t\t\tresult = inherited\n\t\t\t\t\t? await inherited.resolve(input)\n\t\t\t\t\t: input.credential.key\n\t\t\t\t\t\t? { auth: { apiKey: input.credential.key }, env: input.credential.env, source: \"stored credential\" }\n\t\t\t\t\t\t: undefined;\n\t\t\t} else if (rawKey !== undefined) {\n\t\t\t\tconst env = await configContextEnv([rawKey], input.ctx);\n\t\t\t\tconst key = resolveConfigValueOrThrow(rawKey, `API key for provider \"${providerId}\"`, env);\n\t\t\t\tresult = inherited\n\t\t\t\t\t? await inherited.resolve({ ...input, credential: { type: \"api_key\", key } })\n\t\t\t\t\t: { auth: { apiKey: key }, source: \"configured API key\" };\n\t\t\t} else {\n\t\t\t\tresult = await inherited?.resolve(input);\n\t\t\t}\n\t\t\tif (!result) return undefined;\n\t\t\tconst explicitEnv = { ...(input.credential?.env ?? {}), ...(result.env ?? {}) };\n\t\t\tconst headerEnv = await configContextEnv(Object.values(rawHeaders ?? {}), input.ctx, explicitEnv);\n\t\t\tconst headers = resolveHeadersOrThrow(rawHeaders, `provider \"${providerId}\"`, headerEnv);\n\t\t\treturn { ...result, auth: withConfiguredAuth(result.auth, headers, authHeader) };\n\t\t},\n\t};\n}\n\nfunction composeOAuthAuth(\n\tproviderId: string,\n\tbase: Provider | undefined,\n\tconfig: ModelsJsonProvider | undefined,\n\textension: ProviderConfigInput | undefined,\n): OAuthAuth | undefined {\n\tconst oauth = extension?.oauth ? adaptOAuth(extension.oauth) : base?.auth.oauth;\n\tif (!oauth) return undefined;\n\tconst rawHeaders = configuredHeaders(config, extension);\n\tconst authHeader = extension?.authHeader ?? config?.authHeader ?? false;\n\treturn {\n\t\t...oauth,\n\t\ttoAuth: async (credential) => {\n\t\t\tconst auth = await oauth.toAuth(credential);\n\t\t\tconst env = credential.env;\n\t\t\tconst headers = resolveHeadersOrThrow(\n\t\t\t\trawHeaders,\n\t\t\t\t`provider \"${providerId}\"`,\n\t\t\t\ttypeof env === \"object\" && env !== null ? (env as Record<string, string>) : undefined,\n\t\t\t);\n\t\t\treturn withConfiguredAuth(auth, headers, authHeader);\n\t\t},\n\t};\n}\n\nfunction rawModelHeaders(\n\tmodel: AnyModel,\n\tconfig: ModelsJsonProvider | undefined,\n\textension: ProviderConfigInput | undefined,\n): Record<string, string> | undefined {\n\t// models.json definitions and overrides are chat-only. Extension definitions\n\t// are matched by operation and id so colliding models cannot share headers.\n\tconst chatDefinition = isModelType(model, \"chat\")\n\t\t? config?.models?.find((entry) => entry.id === model.id)\n\t\t: undefined;\n\tconst extensionModel = extension?.models?.find(\n\t\t(entry) => (entry.type ?? \"chat\") === (model.type ?? \"chat\") && entry.id === model.id,\n\t);\n\tconst headers = {\n\t\t...(isModelType(model, \"chat\") ? config?.modelOverrides?.[model.id]?.headers : undefined),\n\t\t...chatDefinition?.headers,\n\t\t...extensionModel?.headers,\n\t};\n\treturn Object.keys(headers).length > 0 ? headers : undefined;\n}\n\nexport function validateExtensionProvider(\n\tproviderId: string,\n\tbase: Provider | undefined,\n\tmodelsConfig: ModelsJsonProvider | undefined,\n\textension: ProviderConfigInput,\n): void {\n\tif (extension.streamSimple && !extension.api) {\n\t\tthrow new Error(`Provider ${providerId}: \"api\" is required when registering streamSimple.`);\n\t}\n\tapplyExtension(providerId, applyModelsJson(providerId, getAllProviderModels(base), modelsConfig), extension);\n}\n\n/** Compose built-in, models.json, and extension layers without reading credentials. */\nexport function composeModelProvider(\n\tproviderId: string,\n\tbase: Provider | undefined,\n\tmodelConfig: ModelConfig,\n\textension: ProviderConfigInput | undefined,\n): Provider {\n\tconst config = modelConfig.getProvider(providerId);\n\tlet extensionOAuthCredential: OAuthCredentials | undefined;\n\tlet refreshedExtensionModels: ProviderConfigInput[\"models\"];\n\tconst currentExtension = (): ProviderConfigInput | undefined =>\n\t\textension && refreshedExtensionModels ? { ...extension, models: refreshedExtensionModels } : extension;\n\t// models.json modelOverrides are the topmost user-config layer: they apply once,\n\t// after custom-model upserts, extension model replacement, and legacy OAuth projection.\n\tconst getAllModels = (): AnyModel[] => {\n\t\tlet models = applyExtension(\n\t\t\tproviderId,\n\t\t\tapplyModelsJson(providerId, getAllProviderModels(base), config),\n\t\t\tcurrentExtension(),\n\t\t);\n\t\tif (extensionOAuthCredential && extension?.oauth?.modifyModels) {\n\t\t\t// The extension hook is chat-only; other model types pass through untouched.\n\t\t\tmodels = [\n\t\t\t\t...extension.oauth.modifyModels(\n\t\t\t\t\tmodels.filter((model) => isModelType(model, \"chat\")),\n\t\t\t\t\textensionOAuthCredential,\n\t\t\t\t),\n\t\t\t\t...models.filter((model) => !isModelType(model, \"chat\")),\n\t\t\t];\n\t\t}\n\t\treturn models.map((model) => {\n\t\t\tconst override = config?.modelOverrides?.[model.id];\n\t\t\treturn override && isModelType(model, \"chat\") ? applyModelOverride(model, override) : model;\n\t\t});\n\t};\n\t// Validate eagerly so registration/reload reports structural errors immediately.\n\tgetAllModels();\n\tconst apiKey = composeApiKeyAuth(providerId, base, config, extension);\n\tconst oauth = composeOAuthAuth(providerId, base, config, extension);\n\tif (!apiKey && !oauth) throw new Error(`Provider ${providerId}: no authentication method configured.`);\n\n\tconst supportsBaseApi = (model: Model<Api>) => base?.getModels().some((entry) => entry.api === model.api) ?? false;\n\tconst streamWith = (\n\t\tmodel: Model<Api>,\n\t\tcontext: TranscriptContext,\n\t\toptions: StreamOptions | undefined,\n\t\tsimple: boolean,\n\t): AssistantMessageEventStream =>\n\t\tlazyStream(model, async () => {\n\t\t\tif (extension?.streamSimple && model.api === extension.api) {\n\t\t\t\treturn extension.streamSimple(model, context, options as SimpleStreamOptions);\n\t\t\t}\n\t\t\tif (base && supportsBaseApi(model)) {\n\t\t\t\treturn simple\n\t\t\t\t\t? base.streamSimple(model, context, options as SimpleStreamOptions)\n\t\t\t\t\t: base.stream(model, context, options);\n\t\t\t}\n\t\t\tconst api = getApiProvider(model.api);\n\t\t\tif (!api) throw new Error(`No API provider registered for api: ${model.api}`);\n\t\t\treturn simple\n\t\t\t\t? api.streamSimple(model, context, options as SimpleStreamOptions)\n\t\t\t\t: api.stream(model, context, options);\n\t\t});\n\n\tconst provider: Provider = {\n\t\tid: providerId,\n\t\tname: extension?.name ?? config?.name ?? base?.name ?? extension?.oauth?.name ?? providerId,\n\t\tbaseUrl: extension?.baseUrl ?? config?.baseUrl ?? base?.baseUrl,\n\t\theaders: base?.headers,\n\t\tauth: { ...(apiKey ? { apiKey } : {}), ...(oauth ? { oauth } : {}) },\n\t\tgetModels: () => getAllModels().filter((model) => isModelType(model, \"chat\")),\n\t\tgetAllModels,\n\t\trefreshModels:\n\t\t\tbase?.refreshModels || extension?.refreshModels || extension?.oauth?.modifyModels\n\t\t\t\t? async (context) => {\n\t\t\t\t\t\tawait base?.refreshModels?.(context);\n\t\t\t\t\t\tlet refreshed: NonNullable<ProviderConfigInput[\"models\"]> | undefined;\n\t\t\t\t\t\tif (extension?.refreshModels) refreshed = await extension.refreshModels(context);\n\t\t\t\t\t\tif (context.signal.aborted) return;\n\t\t\t\t\t\tconst oauthCredential = context.credential?.type === \"oauth\" ? context.credential : undefined;\n\t\t\t\t\t\tawait context.publish({\n\t\t\t\t\t\t\tupdate: () => {\n\t\t\t\t\t\t\t\tif (refreshed) {\n\t\t\t\t\t\t\t\t\t// Validate before publishing the new synchronous list.\n\t\t\t\t\t\t\t\t\tapplyExtension(providerId, applyModelsJson(providerId, getAllProviderModels(base), config), {\n\t\t\t\t\t\t\t\t\t\t...extension,\n\t\t\t\t\t\t\t\t\t\tmodels: refreshed,\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\trefreshedExtensionModels = refreshed;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\textensionOAuthCredential = oauthCredential;\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t: undefined,\n\t\tfilterModels: base?.filterModels\n\t\t\t? (models, credential: Credential | undefined) => base.filterModels!(models, credential)\n\t\t\t: undefined,\n\t\tfilterAllModels: base?.filterAllModels\n\t\t\t? (models, credential: Credential | undefined) => base.filterAllModels!(models, credential)\n\t\t\t: undefined,\n\t\tstream: (model, context, options) => streamWith(model, context, options, false),\n\t\tstreamSimple: (model, context, options) => streamWith(model, context, options, true),\n\t};\n\n\tconst fetchDeferred = base?.fetchDeferred;\n\tif (fetchDeferred) {\n\t\tprovider.fetchDeferred = (model, handle, options) => fetchDeferred(model, handle, options);\n\t}\n\tconst cancelDeferred = base?.cancelDeferred;\n\tif (cancelDeferred) {\n\t\tprovider.cancelDeferred = (model, handle, options) => cancelDeferred(model, handle, options);\n\t}\n\tconst extensionImages = extension?.images;\n\tconst generateImages = base?.generateImages;\n\tif (generateImages || Object.keys(extensionImages ?? {}).length > 0) {\n\t\tprovider.generateImages = (model, context, options) => {\n\t\t\tconst implementation = extensionImages?.[model.api];\n\t\t\tif (implementation) return implementation.generateImages(model, context, options);\n\t\t\tif (generateImages) return generateImages(model, context, options);\n\t\t\treturn Promise.resolve(\n\t\t\t\timageErrorResult(model, new Error(`Provider ${providerId} has no image implementation for \"${model.api}\"`)),\n\t\t\t);\n\t\t};\n\t}\n\tconst extensionClassifiers = extension?.classifiers;\n\tconst classify = base?.classify;\n\tif (classify || Object.keys(extensionClassifiers ?? {}).length > 0) {\n\t\tprovider.classify = (model, context, options) => {\n\t\t\tconst implementation = extensionClassifiers?.[model.api];\n\t\t\tif (implementation) return implementation.classify(model, context, options);\n\t\t\tif (classify) return classify(model, context, options);\n\t\t\treturn Promise.resolve(\n\t\t\t\tclassifierErrorResult(\n\t\t\t\t\tmodel,\n\t\t\t\t\tnew Error(`Provider ${providerId} has no classifier implementation for \"${model.api}\"`),\n\t\t\t\t),\n\t\t\t);\n\t\t};\n\t}\n\n\treturn provider;\n}\n\nexport function resolveConfiguredModelHeaders(\n\tmodel: AnyModel,\n\tconfig: ModelsJsonProvider | undefined,\n\textension: ProviderConfigInput | undefined,\n\tenv?: Record<string, string>,\n): Record<string, string> | undefined {\n\treturn resolveHeadersOrThrow(\n\t\trawModelHeaders(model, config, extension),\n\t\t`model \"${model.provider}/${model.id}\"`,\n\t\tenv,\n\t);\n}\n\nexport interface CompatibilityRequestConfig {\n\theaders?: ProviderHeaders;\n\tauthHeader: boolean;\n}\n\nexport function resolveCompatibilityRequestConfig(\n\tmodel: AnyModel,\n\tconfig: ModelsJsonProvider | undefined,\n\textension: ProviderConfigInput | undefined,\n): CompatibilityRequestConfig {\n\tconst configured = resolveHeadersOrThrow(\n\t\t{ ...configuredHeaders(config, extension), ...rawModelHeaders(model, config, extension) },\n\t\t`model \"${model.provider}/${model.id}\"`,\n\t);\n\treturn {\n\t\theaders: model.headers || configured ? { ...model.headers, ...configured } : undefined,\n\t\tauthHeader: extension?.authHeader ?? config?.authHeader ?? false,\n\t};\n}\n\nexport function configuredRequestAuthStatus(\n\tconfig: ModelsJsonProvider | undefined,\n\textension: ProviderConfigInput | undefined,\n): AuthStatus | undefined {\n\tconst value = configuredApiKey(config, extension);\n\tif (value === undefined) return undefined;\n\tif (isCommandConfigValue(value)) return { configured: true, source: \"models_json_command\" };\n\tconst names = getConfigValueEnvVarNames(value);\n\tif (names.length > 0) {\n\t\treturn isConfigValueConfigured(value)\n\t\t\t? { configured: true, source: \"environment\", label: names.join(\", \") }\n\t\t\t: { configured: false };\n\t}\n\treturn { configured: true, source: extension?.apiKey !== undefined ? \"fallback\" : \"models_json_key\" };\n}\n"]}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The e logo (Euler's number): 4 cells wide and 2 lines tall
|
|
3
|
-
* half blocks:
|
|
2
|
+
* The e logo (Euler's number): 4 cells wide and 2 lines tall, drawn as a lowercase e on a 4x4 pixel
|
|
3
|
+
* grid (half blocks, one cell = two vertical pixels):
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
* blue
|
|
5
|
+
* . coral coral coral
|
|
6
|
+
* blue . . coral
|
|
7
|
+
* coral coral coral coral the middle bar is the e's eye
|
|
8
|
+
* blue . . blue
|
|
7
9
|
*
|
|
8
|
-
* The
|
|
9
|
-
*
|
|
10
|
-
* terminal's color mode.
|
|
10
|
+
* The top stroke and the eye read as the lowercase e from the founding pitch; the blue pixels are
|
|
11
|
+
* the terminals where the stroke enters and leaves the loop. Brand colors stay fixed across
|
|
12
|
+
* themes; they follow the terminal's color mode.
|
|
11
13
|
*/
|
|
12
14
|
export declare function eLogoLines(): [string, string];
|
|
13
15
|
//# sourceMappingURL=e-logo.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"e-logo.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/e-logo.ts"],"names":[],"mappings":"AAOA
|
|
1
|
+
{"version":3,"file":"e-logo.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/e-logo.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;GAYG;AACH,wBAAgB,UAAU,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAU7C"}
|
|
@@ -4,23 +4,27 @@ const CORAL = rgbColor(228, 138, 122);
|
|
|
4
4
|
const BLUE = rgbColor(79, 142, 179);
|
|
5
5
|
const RESET = "\x1b[0m";
|
|
6
6
|
/**
|
|
7
|
-
* The e logo (Euler's number): 4 cells wide and 2 lines tall
|
|
8
|
-
* half blocks:
|
|
7
|
+
* The e logo (Euler's number): 4 cells wide and 2 lines tall, drawn as a lowercase e on a 4x4 pixel
|
|
8
|
+
* grid (half blocks, one cell = two vertical pixels):
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
* blue
|
|
10
|
+
* . coral coral coral
|
|
11
|
+
* blue . . coral
|
|
12
|
+
* coral coral coral coral the middle bar is the e's eye
|
|
13
|
+
* blue . . blue
|
|
12
14
|
*
|
|
13
|
-
* The
|
|
14
|
-
*
|
|
15
|
-
* terminal's color mode.
|
|
15
|
+
* The top stroke and the eye read as the lowercase e from the founding pitch; the blue pixels are
|
|
16
|
+
* the terminals where the stroke enters and leaves the loop. Brand colors stay fixed across
|
|
17
|
+
* themes; they follow the terminal's color mode.
|
|
16
18
|
*/
|
|
17
19
|
export function eLogoLines() {
|
|
18
20
|
const mode = theme.getColorMode();
|
|
19
21
|
const fg = (color) => foregroundAnsi(color, mode);
|
|
20
|
-
//
|
|
21
|
-
//
|
|
22
|
-
const
|
|
23
|
-
const
|
|
22
|
+
// Line 1 (top two pixel rows): cells [▄ blue][▀ coral][▀ coral][█ coral]
|
|
23
|
+
// Line 2 (bottom two pixel rows): cells [▀▄ coral over blue][▀ coral][▀ coral][▀▄ coral over blue]
|
|
24
|
+
const c = fg(CORAL);
|
|
25
|
+
const b = fg(BLUE);
|
|
26
|
+
const top = `${b}▄${c}███${RESET} `;
|
|
27
|
+
const bottom = `${c}▀${b}▄${c}▀ ${c}▀ ${c}▀${b}▄${RESET}`;
|
|
24
28
|
return [top, bottom];
|
|
25
29
|
}
|
|
26
30
|
//# sourceMappingURL=e-logo.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"e-logo.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/e-logo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE1C,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AACtC,MAAM,IAAI,GAAG,QAAQ,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AACpC,MAAM,KAAK,GAAG,SAAS,CAAC;AAExB
|
|
1
|
+
{"version":3,"file":"e-logo.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/e-logo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE1C,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AACtC,MAAM,IAAI,GAAG,QAAQ,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AACpC,MAAM,KAAK,GAAG,SAAS,CAAC;AAExB;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,UAAU;IACzB,MAAM,IAAI,GAAG,KAAK,CAAC,YAAY,EAAE,CAAC;IAClC,MAAM,EAAE,GAAG,CAAC,KAAmB,EAAE,EAAE,CAAC,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAChE,yEAAyE;IACzE,mGAAmG;IACnG,MAAM,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC;IACpB,MAAM,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;IACnB,MAAM,GAAG,GAAG,GAAG,CAAC,IAAI,CAAC,MAAM,KAAK,GAAG,CAAC;IACpC,MAAM,MAAM,GAAG,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,KAAK,EAAE,CAAC;IAC1D,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;AACtB,CAAC","sourcesContent":["import { foregroundAnsi, rgbColor } from \"@earendil-works/pi-tui\";\nimport { theme } from \"../theme/theme.ts\";\n\nconst CORAL = rgbColor(228, 138, 122);\nconst BLUE = rgbColor(79, 142, 179);\nconst RESET = \"\\x1b[0m\";\n\n/**\n * The e logo (Euler's number): 4 cells wide and 2 lines tall, drawn as a lowercase e on a 4x4 pixel\n * grid (half blocks, one cell = two vertical pixels):\n *\n * . coral coral coral\n * blue . . coral\n * coral coral coral coral the middle bar is the e's eye\n * blue . . blue\n *\n * The top stroke and the eye read as the lowercase e from the founding pitch; the blue pixels are\n * the terminals where the stroke enters and leaves the loop. Brand colors stay fixed across\n * themes; they follow the terminal's color mode.\n */\nexport function eLogoLines(): [string, string] {\n\tconst mode = theme.getColorMode();\n\tconst fg = (color: typeof CORAL) => foregroundAnsi(color, mode);\n\t// Line 1 (top two pixel rows): cells [▄ blue][▀ coral][▀ coral][█ coral]\n\t// Line 2 (bottom two pixel rows): cells [▀▄ coral over blue][▀ coral][▀ coral][▀▄ coral over blue]\n\tconst c = fg(CORAL);\n\tconst b = fg(BLUE);\n\tconst top = `${b}▄${c}███${RESET} `;\n\tconst bottom = `${c}▀${b}▄${c}▀ ${c}▀ ${c}▀${b}▄${RESET}`;\n\treturn [top, bottom];\n}\n"]}
|
|
@@ -28,6 +28,8 @@ export declare class ToolExecutionComponent extends Container {
|
|
|
28
28
|
private resultRendererComponent?;
|
|
29
29
|
private rendererState;
|
|
30
30
|
private imageComponents;
|
|
31
|
+
/** Inputs of imageComponents, so updateDisplay can reuse images and keep their converted PNG data. */
|
|
32
|
+
private imageSources;
|
|
31
33
|
private imageSpacers;
|
|
32
34
|
private toolName;
|
|
33
35
|
private toolCallId;
|
|
@@ -42,7 +44,6 @@ export declare class ToolExecutionComponent extends Container {
|
|
|
42
44
|
private executionStarted;
|
|
43
45
|
private argsComplete;
|
|
44
46
|
private result?;
|
|
45
|
-
private convertedImages;
|
|
46
47
|
private hideComponent;
|
|
47
48
|
constructor(toolName: string, toolCallId: string, args: any, options: ToolExecutionOptions | undefined, toolDefinition: ToolRenderers | ToolDefinition<any, any, any> | undefined, ui: TUI, cwd: string);
|
|
48
49
|
private getCallRenderer;
|
|
@@ -66,7 +67,6 @@ export declare class ToolExecutionComponent extends Container {
|
|
|
66
67
|
details?: any;
|
|
67
68
|
isError: boolean;
|
|
68
69
|
}, isPartial?: boolean): void;
|
|
69
|
-
private maybeConvertImagesForKitty;
|
|
70
70
|
setExpanded(expanded: boolean): void;
|
|
71
71
|
setShowImages(show: boolean): void;
|
|
72
72
|
setImageWidthCells(width: number): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,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CAAC,eAAe,CAAe;IACtC,OAAO,CAAC,YAAY,CAAgB;IACpC,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,IAAI,CAAM;IAClB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,UAAU,CAAU;IAC5B,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,SAAS,CAAQ;IACzB,OAAO,CAAC,cAAc,CAAC,CAAgB;IACvC,OAAO,CAAC,EAAE,CAAM;IAChB,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,gBAAgB,CAAS;IACjC,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,MAAM,CAAC,CAIb;IACF,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"tool-execution.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/tool-execution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAEN,KAAK,SAAS,EACd,SAAS,EAMT,KAAK,GAAG,EACR,KAAK,aAAa,EAClB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AACpH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE/C;;;;;;GAMG;AACH,MAAM,WAAW,aAAa;IAC7B,WAAW,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IACjC,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,iBAAiB,CAAC,GAAG,EAAE,GAAG,CAAC,KAAK,SAAS,CAAC;IAC1F,YAAY,CAAC,EAAE,CACd,MAAM,EAAE,eAAe,CAAC,GAAG,CAAC,EAC5B,OAAO,EAAE,uBAAuB,EAChC,KAAK,EAAE,KAA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, Text, } from "@earendil-works/pi-tui";
|
|
2
2
|
import { formatToolCallWithArgs, getTextOutput as getRenderedTextOutput } from "../../../core/tools/render-utils.js";
|
|
3
|
-
import {
|
|
3
|
+
import { ensurePngTranscoder } from "../../../utils/image-convert.js";
|
|
4
4
|
import { theme } from "../theme/theme.js";
|
|
5
5
|
import { keyHint } from "./keybinding-hints.js";
|
|
6
6
|
const FALLBACK_PREVIEW_LINES = 10;
|
|
@@ -14,6 +14,8 @@ export class ToolExecutionComponent extends Container {
|
|
|
14
14
|
resultRendererComponent;
|
|
15
15
|
rendererState = {};
|
|
16
16
|
imageComponents = [];
|
|
17
|
+
/** Inputs of imageComponents, so updateDisplay can reuse images and keep their converted PNG data. */
|
|
18
|
+
imageSources = [];
|
|
17
19
|
imageSpacers = [];
|
|
18
20
|
toolName;
|
|
19
21
|
toolCallId;
|
|
@@ -28,7 +30,6 @@ export class ToolExecutionComponent extends Container {
|
|
|
28
30
|
executionStarted = false;
|
|
29
31
|
argsComplete = false;
|
|
30
32
|
result;
|
|
31
|
-
convertedImages = new Map();
|
|
32
33
|
hideComponent = false;
|
|
33
34
|
constructor(toolName, toolCallId, args, options = {}, toolDefinition, ui, cwd) {
|
|
34
35
|
super();
|
|
@@ -130,40 +131,6 @@ export class ToolExecutionComponent extends Container {
|
|
|
130
131
|
this.result = result;
|
|
131
132
|
this.isPartial = isPartial;
|
|
132
133
|
this.updateDisplay();
|
|
133
|
-
this.maybeConvertImagesForKitty();
|
|
134
|
-
}
|
|
135
|
-
maybeConvertImagesForKitty() {
|
|
136
|
-
const caps = getCapabilities();
|
|
137
|
-
if (caps.images !== "kitty")
|
|
138
|
-
return;
|
|
139
|
-
if (!this.result)
|
|
140
|
-
return;
|
|
141
|
-
const imageBlocks = this.result.content.filter((c) => c.type === "image");
|
|
142
|
-
for (let i = 0; i < imageBlocks.length; i++) {
|
|
143
|
-
const img = imageBlocks[i];
|
|
144
|
-
if (!img.data || !img.mimeType)
|
|
145
|
-
continue;
|
|
146
|
-
const sourceData = img.data;
|
|
147
|
-
const sourceMimeType = img.mimeType;
|
|
148
|
-
if (sourceMimeType === "image/png")
|
|
149
|
-
continue;
|
|
150
|
-
const cached = this.convertedImages.get(i);
|
|
151
|
-
if (cached?.sourceData === sourceData && cached.sourceMimeType === sourceMimeType)
|
|
152
|
-
continue;
|
|
153
|
-
const index = i;
|
|
154
|
-
convertToPng(sourceData, sourceMimeType).then((converted) => {
|
|
155
|
-
const currentImage = this.result?.content.filter((content) => content.type === "image")[index];
|
|
156
|
-
if (!converted || currentImage?.data !== sourceData || currentImage.mimeType !== sourceMimeType)
|
|
157
|
-
return;
|
|
158
|
-
this.convertedImages.set(index, {
|
|
159
|
-
sourceData,
|
|
160
|
-
sourceMimeType,
|
|
161
|
-
...converted,
|
|
162
|
-
});
|
|
163
|
-
this.updateDisplay();
|
|
164
|
-
this.ui.requestRender();
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
134
|
}
|
|
168
135
|
setExpanded(expanded) {
|
|
169
136
|
this.expanded = expanded;
|
|
@@ -285,10 +252,13 @@ export class ToolExecutionComponent extends Container {
|
|
|
285
252
|
this.contentText.setText(this.formatToolExecution());
|
|
286
253
|
hasContent = true;
|
|
287
254
|
}
|
|
255
|
+
const previousImages = this.imageComponents;
|
|
256
|
+
const previousSources = this.imageSources;
|
|
288
257
|
for (const img of this.imageComponents) {
|
|
289
258
|
this.removeChild(img);
|
|
290
259
|
}
|
|
291
260
|
this.imageComponents = [];
|
|
261
|
+
this.imageSources = [];
|
|
292
262
|
for (const spacer of this.imageSpacers) {
|
|
293
263
|
this.removeChild(spacer);
|
|
294
264
|
}
|
|
@@ -296,20 +266,27 @@ export class ToolExecutionComponent extends Container {
|
|
|
296
266
|
if (this.result) {
|
|
297
267
|
const imageBlocks = this.result.content.filter((c) => c.type === "image");
|
|
298
268
|
const caps = getCapabilities();
|
|
299
|
-
for (
|
|
300
|
-
const img = imageBlocks[i];
|
|
269
|
+
for (const img of imageBlocks) {
|
|
301
270
|
if (caps.images && this.showImages && img.data && img.mimeType) {
|
|
302
|
-
const cached = this.convertedImages.get(i);
|
|
303
|
-
const converted = cached?.sourceData === img.data && cached.sourceMimeType === img.mimeType ? cached : undefined;
|
|
304
|
-
const imageData = converted?.data ?? img.data;
|
|
305
|
-
const imageMimeType = converted?.mimeType ?? img.mimeType;
|
|
306
|
-
if (caps.images === "kitty" && imageMimeType !== "image/png")
|
|
307
|
-
continue;
|
|
308
271
|
const spacer = new Spacer(1);
|
|
309
272
|
this.addChild(spacer);
|
|
310
273
|
this.imageSpacers.push(spacer);
|
|
311
|
-
const
|
|
274
|
+
const source = { data: img.data, mimeType: img.mimeType, widthCells: this.imageWidthCells };
|
|
275
|
+
const index = this.imageComponents.length;
|
|
276
|
+
const previous = previousSources[index];
|
|
277
|
+
const imageComponent = previous?.data === source.data &&
|
|
278
|
+
previous.mimeType === source.mimeType &&
|
|
279
|
+
previous.widthCells === source.widthCells
|
|
280
|
+
? previousImages[index]
|
|
281
|
+
: new Image(source.data, source.mimeType, { fallbackColor: (s) => theme.fg("toolOutput", s) }, { maxWidthCells: source.widthCells });
|
|
282
|
+
if (source.mimeType !== "image/png") {
|
|
283
|
+
ensurePngTranscoder(() => {
|
|
284
|
+
this.invalidate();
|
|
285
|
+
this.ui.requestRender();
|
|
286
|
+
});
|
|
287
|
+
}
|
|
312
288
|
this.imageComponents.push(imageComponent);
|
|
289
|
+
this.imageSources.push(source);
|
|
313
290
|
this.addChild(imageComponent);
|
|
314
291
|
}
|
|
315
292
|
}
|