@averyyy/pi-coding-agent 1.0.0-piclient.1 → 1.0.0-piclient.2

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.
Files changed (49) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/bundle/chunks/{anthropic-messages-UID2PALB.js → anthropic-messages-5Z4I6I54.js} +1 -1
  3. package/dist/bundle/chunks/{azure-openai-responses-WK37QQ3X.js → azure-openai-responses-TXH53UDQ.js} +1 -1
  4. package/dist/bundle/chunks/{chunk-2LGHNI5Y.js → chunk-43NAB75E.js} +20 -20
  5. package/dist/bundle/chunks/{chunk-Z772OFUN.js → chunk-4ILNOXGR.js} +1 -1
  6. package/dist/bundle/chunks/{chunk-SQXKOUF6.js → chunk-AV6LYFGH.js} +1 -1
  7. package/dist/bundle/chunks/{chunk-7JGR3GZN.js → chunk-F42GKQ7R.js} +1 -1
  8. package/dist/bundle/chunks/{chunk-CWVWZD3J.js → chunk-JTLRGL3E.js} +1 -1
  9. package/dist/bundle/chunks/{chunk-OSKPX3Z5.js → chunk-PXGUCLIP.js} +1 -1
  10. package/dist/bundle/chunks/{chunk-6D7LHLKG.js → chunk-WGS2XTDX.js} +1 -1
  11. package/dist/bundle/chunks/{cloudflare-workers-ai-system-one-NPQN263E.js → cloudflare-workers-ai-system-one-TF36V7KG.js} +1 -1
  12. package/dist/bundle/chunks/{google-generative-ai-OHRSHIE7.js → google-generative-ai-XQU2LTWM.js} +1 -1
  13. package/dist/bundle/chunks/{google-vertex-KXEB3MVO.js → google-vertex-F6Q2CN55.js} +1 -1
  14. package/dist/bundle/chunks/{mistral-conversations-DKVFNQL6.js → mistral-conversations-XAJWHQFR.js} +1 -1
  15. package/dist/bundle/chunks/{openai-codex-responses-WVERB76N.js → openai-codex-responses-3EHOMZYM.js} +1 -1
  16. package/dist/bundle/chunks/{openai-completions-JXDDPZ23.js → openai-completions-QC2IQHSC.js} +1 -1
  17. package/dist/bundle/chunks/{openai-responses-WDT74L23.js → openai-responses-JPLD2GJS.js} +1 -1
  18. package/dist/bundle/chunks/{typesafe-system-one-A4CZTQWZ.js → typesafe-system-one-7DJTDUKY.js} +1 -1
  19. package/dist/bundle/chunks/{virtual-modules-XLXFDFIX.js → virtual-modules-X5AB6TM6.js} +1 -1
  20. package/dist/bundle/cli-runtime.js +1 -1
  21. package/dist/bundle/index.js +1 -1
  22. package/dist/bundle/rpc-entry.js +1 -1
  23. package/dist/core/agent-session.d.ts.map +1 -1
  24. package/dist/core/agent-session.js +29 -2
  25. package/dist/core/agent-session.js.map +1 -1
  26. package/dist/core/cache-warmer.d.ts.map +1 -1
  27. package/dist/core/cache-warmer.js +11 -3
  28. package/dist/core/cache-warmer.js.map +1 -1
  29. package/dist/core/model-resolver.js +1 -1
  30. package/dist/core/model-resolver.js.map +1 -1
  31. package/dist/core/model-runtime.d.ts +16 -0
  32. package/dist/core/model-runtime.d.ts.map +1 -1
  33. package/dist/core/model-runtime.js +325 -31
  34. package/dist/core/model-runtime.js.map +1 -1
  35. package/dist/core/pi-server-client.d.ts +21 -1
  36. package/dist/core/pi-server-client.d.ts.map +1 -1
  37. package/dist/core/pi-server-client.js +308 -22
  38. package/dist/core/pi-server-client.js.map +1 -1
  39. package/dist/core/pi-server-protocol.d.ts +12 -1
  40. package/dist/core/pi-server-protocol.d.ts.map +1 -1
  41. package/dist/core/pi-server-protocol.js +1 -0
  42. package/dist/core/pi-server-protocol.js.map +1 -1
  43. package/dist/core/sdk.d.ts.map +1 -1
  44. package/dist/core/sdk.js +51 -18
  45. package/dist/core/sdk.js.map +1 -1
  46. package/dist/main.d.ts.map +1 -1
  47. package/dist/main.js +24 -17
  48. package/dist/main.js.map +1 -1
  49. package/package.json +4 -4
@@ -1 +1 @@
1
- {"version":3,"file":"model-runtime.js","sourceRoot":"","sources":["../../src/core/model-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,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Aa,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC;IAC9G,CAAC;IAED,gDAAgD;IAChD,gBAAgB,CAAC,UAAkB,EAAE,OAAe;QACnD,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QACxD,OAAO,KAAK,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;IAC5D,CAAC;CACD","sourcesContent":["import { dirname, join } from \"node:path\";\nimport {\n\ttype AnyModel,\n\ttype Api,\n\ttype ApiStreamOptions,\n\ttype AssistantImages,\n\ttype AssistantMessage,\n\ttype AssistantMessageEventStream,\n\ttype AuthCheck,\n\ttype AuthInteraction,\n\ttype AuthOperationOptions,\n\ttype AuthResult,\n\ttype AuthType,\n\ttype ClassifierApi,\n\ttype ClassifierContext,\n\ttype ClassifierModel,\n\ttype ClassifierOptions,\n\ttype ClassifierResult,\n\ttype Context,\n\ttype Credential,\n\ttype CredentialInfo,\n\ttype CredentialStore,\n\tclampThinkingLevel,\n\tcreateModels,\n\ttype DeferredCancelOptions,\n\ttype DeferredFetchOptions,\n\ttype DeferredHandle,\n\ttype ImageApi,\n\ttype ImageModel,\n\ttype ImagesContext,\n\ttype ImagesOptions,\n\ttype LoginOptions,\n\tlazyStream,\n\ttype Message,\n\ttype Model,\n\ttype Models,\n\ttype ModelsApiStreamOptions,\n\ttype ModelsClassifierOptions,\n\ttype ModelsDeferredCancelOptions,\n\ttype ModelsDeferredFetchOptions,\n\tModelsError,\n\ttype ModelsImagesOptions,\n\ttype ModelsRefreshOptions,\n\ttype ModelsRefreshResult,\n\ttype ModelsRequestTransforms,\n\ttype ModelsSimpleStreamOptions,\n\ttype ModelsStore,\n\ttype ModelThinkingLevel,\n\ttype ModelType,\n\ttype ModelTypeMap,\n\ttype MutableModels,\n\tnormalizeContext,\n\ttype Provider,\n\ttype ProviderHeaders,\n\ttype ProviderRequestOptions,\n\ttype SimpleStreamOptions,\n\ttype StreamOptions,\n} from \"@earendil-works/pi-ai\";\nimport * as builtinProviderCatalog from \"@earendil-works/pi-ai/providers/all\";\nimport {\n\tassertChatModel,\n\tassertClassifierModel,\n\tassertImageModel,\n\tclassifierErrorResult,\n\timageErrorResult,\n} from \"@earendil-works/pi-ai/utils/model-operations\";\nimport { getAgentDir } from \"../config.ts\";\nimport { operationSignal, raceWithAbortSignal } from \"../utils/abort.ts\";\nimport { AuthStorage as DefaultAuthStorage } from \"./auth-storage.ts\";\nimport { ModelConfig } from \"./model-config.ts\";\nimport { FileModelsStore, InMemoryCodingAgentModelsStore } from \"./models-store.ts\";\nimport {\n\ttype AuthStatus,\n\ttype CompatibilityRequestConfig,\n\tcomposeModelProvider,\n\tconfiguredRequestAuthStatus,\n\ttype ProviderConfigInput,\n\tresolveCompatibilityRequestConfig,\n\tresolveConfiguredModelHeaders,\n\tvalidateExtensionProvider,\n} from \"./provider-composer.ts\";\nimport { withRemoteCatalog } from \"./remote-catalog-provider.ts\";\nimport { RuntimeCredentials } from \"./runtime-credentials.ts\";\nimport {\n\tcreateVirtualModel,\n\tfindLatestResponse,\n\tisVirtualModel,\n\ttype ModelRoute,\n\ttype ModelRouteReason,\n\ttype VirtualModelDefinition,\n\twithVirtualModels,\n} from \"./virtual-models.ts\";\n\ninterface RegisteredVirtualModel {\n\tmodel: Model<Api>;\n\troute: VirtualModelDefinition[\"route\"];\n}\n\ninterface ModelRuntimeSnapshot {\n\tall: readonly Model<Api>[];\n\tavailable: readonly Model<Api>[];\n\tconfiguredProviders: ReadonlySet<string>;\n\tstoredProviders: ReadonlySet<string>;\n\tauth: ReadonlyMap<string, AuthCheck | undefined>;\n}\n\nexport interface CreateModelRuntimeOptions {\n\t/** Credential storage. Defaults to the file at authPath. */\n\tcredentials?: CredentialStore;\n\tauthPath?: string;\n\tmodelsPath?: string | null;\n\tmodelsStore?: ModelsStore;\n\tmodelsStorePath?: string;\n\t/** Allow create() to refresh model catalogs over the network. Defaults to false. */\n\tallowModelNetwork?: boolean;\n\t/** Timeout for the create-time network model refresh. */\n\tmodelRefreshTimeoutMs?: number;\n\tcatalogBaseUrl?: string;\n\t/** Optional caller cancellation for initial cache restoration and availability checks. */\n\tsignal?: AbortSignal;\n\t/** Skip initial catalog and availability refresh. Static models remain available. */\n\trefreshOnCreate?: boolean;\n}\n\nexport interface ModelRuntimeAuthOverrides extends AuthOperationOptions {\n\tapiKey?: string;\n\tenv?: Record<string, string>;\n\t/** Require this much remaining OAuth-token validity; defaults to five minutes. */\n\tminOAuthValidityMs?: number;\n}\n\nexport type CredentialSynchronizationOperation = \"login\" | \"logout\" | \"setRuntimeApiKey\" | \"removeRuntimeApiKey\";\n\n/** Credentials changed successfully, but the local model/auth snapshot could not be synchronized. */\nexport class CredentialSynchronizationError extends Error {\n\treadonly providerId: string;\n\treadonly operation: CredentialSynchronizationOperation;\n\treadonly credential: Credential | undefined;\n\n\tconstructor(\n\t\tproviderId: string,\n\t\toperation: CredentialSynchronizationOperation,\n\t\tcredential: Credential | undefined,\n\t\toptions: ErrorOptions,\n\t) {\n\t\tsuper(`Credential ${operation} committed for ${providerId}, but local synchronization failed`, options);\n\t\tthis.name = \"CredentialSynchronizationError\";\n\t\tthis.providerId = providerId;\n\t\tthis.operation = operation;\n\t\tthis.credential = credential;\n\t}\n}\n\nfunction mergeHeaders(\n\tbase: ProviderHeaders | undefined,\n\toverride: ProviderHeaders | undefined,\n): ProviderHeaders | undefined {\n\tif (!base && !override) return undefined;\n\tconst merged = { ...base };\n\tfor (const [name, value] of Object.entries(override ?? {})) {\n\t\tconst lowerName = name.toLowerCase();\n\t\tfor (const existingName of Object.keys(merged)) {\n\t\t\tif (existingName.toLowerCase() === lowerName) delete merged[existingName];\n\t\t}\n\t\tmerged[name] = value;\n\t}\n\treturn merged;\n}\n\n/** Configured pi-ai Models collection used by coding-agent and SDK consumers. */\nexport class ModelRuntime implements Models {\n\tprivate readonly models: MutableModels;\n\tprivate readonly credentials: RuntimeCredentials;\n\tprivate readonly defaultBuiltins: ReadonlyMap<string, Provider>;\n\tprivate readonly builtins = new Map<string, Provider>();\n\tprivate readonly nativeExtensionProviders = new Map<string, Provider>();\n\tprivate readonly extensionProviders = new Map<string, ProviderConfigInput>();\n\t/** Virtual models by provider id, then model id. */\n\tprivate readonly virtualModels = new Map<string, Map<string, RegisteredVirtualModel>>();\n\tprivate readonly compositionErrors = new Map<string, string>();\n\tprivate readonly modelsPath: string | undefined;\n\tprivate readonly modelNetworkEnabled: boolean;\n\tprivate config: ModelConfig;\n\tprivate snapshot: ModelRuntimeSnapshot = {\n\t\tall: [],\n\t\tavailable: [],\n\t\tconfiguredProviders: new Set(),\n\t\tstoredProviders: new Set(),\n\t\tauth: new Map(),\n\t};\n\tprivate availabilityRefreshSeq = 0;\n\tprivate availabilityErrorSeq = 0;\n\tprivate readonly providerAvailabilitySeq = new Map<string, number>();\n\tprivate availabilityError: string | undefined;\n\tprivate readonly credentialOperations = new Map<string, Promise<unknown>>();\n\n\tprivate constructor(\n\t\tcredentials: RuntimeCredentials,\n\t\tconfig: ModelConfig,\n\t\tmodelsPath: string | undefined,\n\t\tmodelsStore: ModelsStore,\n\t\tproviders: readonly Provider[],\n\t\tmodelNetworkEnabled: boolean,\n\t) {\n\t\tthis.credentials = credentials;\n\t\tthis.config = config;\n\t\tthis.modelsPath = modelsPath;\n\t\tthis.modelNetworkEnabled = modelNetworkEnabled;\n\t\tthis.defaultBuiltins = new Map(providers.map((provider) => [provider.id, provider]));\n\t\tfor (const [providerId, provider] of this.defaultBuiltins) this.builtins.set(providerId, provider);\n\t\tthis.models = createModels({ credentials, modelsStore });\n\t\tthis.rebuildProviders();\n\t}\n\n\tstatic async create(options: CreateModelRuntimeOptions = {}): Promise<ModelRuntime> {\n\t\tconst credentials = new RuntimeCredentials(options.credentials ?? DefaultAuthStorage.create(options.authPath));\n\t\tconst modelsPath =\n\t\t\toptions.modelsPath === null ? undefined : (options.modelsPath ?? join(getAgentDir(), \"models.json\"));\n\t\tconst config = await ModelConfig.load(modelsPath);\n\t\tconst modelsStore =\n\t\t\toptions.modelsStore ??\n\t\t\t(modelsPath\n\t\t\t\t? new FileModelsStore(options.modelsStorePath ?? join(dirname(modelsPath), \"models-store.json\"))\n\t\t\t\t: new InMemoryCodingAgentModelsStore());\n\t\tconst builtinModelDataGeneratedAt = builtinProviderCatalog.getBuiltinModelDataGeneratedAt();\n\t\tconst providers = builtinProviderCatalog\n\t\t\t.builtinProviders()\n\t\t\t.map((provider) =>\n\t\t\t\tprovider.refreshModels !== undefined\n\t\t\t\t\t? provider\n\t\t\t\t\t: withRemoteCatalog(provider, options.catalogBaseUrl, builtinModelDataGeneratedAt),\n\t\t\t);\n\t\tconst runtime = new ModelRuntime(\n\t\t\tcredentials,\n\t\t\tconfig,\n\t\t\tmodelsPath,\n\t\t\tmodelsStore,\n\t\t\tproviders,\n\t\t\tprocess.env.PI_OFFLINE === undefined,\n\t\t);\n\t\truntime.configureRadiusProviders();\n\t\truntime.rebuildProviders();\n\t\tconst refreshFromNetwork = runtime.modelNetworkEnabled && options.allowModelNetwork === true;\n\t\tconst controller =\n\t\t\trefreshFromNetwork && options.modelRefreshTimeoutMs !== undefined ? new AbortController() : undefined;\n\t\tconst timeout = controller ? setTimeout(() => controller.abort(), options.modelRefreshTimeoutMs) : undefined;\n\t\tconst signal = controller\n\t\t\t? options.signal\n\t\t\t\t? AbortSignal.any([options.signal, controller.signal])\n\t\t\t\t: controller.signal\n\t\t\t: options.signal;\n\t\ttry {\n\t\t\tif (options.refreshOnCreate !== false) {\n\t\t\t\tawait runtime.refresh({ allowNetwork: refreshFromNetwork, signal });\n\t\t\t}\n\t\t} finally {\n\t\t\tif (timeout) clearTimeout(timeout);\n\t\t}\n\t\treturn runtime;\n\t}\n\n\tprivate configureRadiusProviders(): void {\n\t\tthis.builtins.clear();\n\t\tfor (const [providerId, provider] of this.defaultBuiltins) this.builtins.set(providerId, provider);\n\t\tfor (const providerId of this.config.getProviderIds()) {\n\t\t\tconst config = this.config.getProvider(providerId);\n\t\t\tif (config?.oauth !== \"radius\" || !config.baseUrl) continue;\n\t\t\tthis.builtins.set(\n\t\t\t\tproviderId,\n\t\t\t\tbuiltinProviderCatalog.radiusProvider({\n\t\t\t\t\tid: providerId,\n\t\t\t\t\tname: config.name ?? providerId,\n\t\t\t\t\tgateway: config.baseUrl.replace(/\\/v1\\/?$/u, \"\"),\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate providerIds(): Set<string> {\n\t\treturn new Set([\n\t\t\t...this.builtins.keys(),\n\t\t\t...this.nativeExtensionProviders.keys(),\n\t\t\t...this.config.getProviderIds(),\n\t\t\t...this.extensionProviders.keys(),\n\t\t\t...this.virtualModels.keys(),\n\t\t]);\n\t}\n\n\t/** Returns the provider without virtual models, or undefined when only virtual models define it. */\n\tprivate recomposeProvider(providerId: string): Provider | undefined {\n\t\tconst provider = this.composeProvider(providerId);\n\t\tconst virtualModels = [...(this.virtualModels.get(providerId)?.values() ?? [])].map((entry) => entry.model);\n\t\tif (virtualModels.length > 0) this.models.setProvider(withVirtualModels(providerId, provider, virtualModels));\n\t\telse if (provider) this.models.setProvider(provider);\n\t\telse this.models.deleteProvider(providerId);\n\t\treturn provider;\n\t}\n\n\t/** The provider without virtual models, or undefined when nothing defines it. */\n\tprivate composeProvider(providerId: string): Provider | undefined {\n\t\tconst base = this.nativeExtensionProviders.get(providerId) ?? this.builtins.get(providerId);\n\t\tconst extension = this.extensionProviders.get(providerId);\n\t\tif (!this.config.getProvider(providerId) && !extension) {\n\t\t\t// No overlays: use the builtin untouched so its auth/login/stream behavior is exact.\n\t\t\tthis.compositionErrors.delete(providerId);\n\t\t\treturn base;\n\t\t}\n\t\ttry {\n\t\t\tconst provider = composeModelProvider(providerId, base, this.config, extension);\n\t\t\tthis.compositionErrors.delete(providerId);\n\t\t\treturn provider;\n\t\t} catch (error) {\n\t\t\tthis.compositionErrors.set(providerId, error instanceof Error ? error.message : String(error));\n\t\t\treturn base;\n\t\t}\n\t}\n\n\tprivate rebuildProviders(): void {\n\t\tthis.models.clearProviders();\n\t\tthis.compositionErrors.clear();\n\t\tfor (const providerId of this.providerIds()) this.recomposeProvider(providerId);\n\t\tthis.updateModelSnapshot();\n\t}\n\n\tprivate updateModelSnapshot(): void {\n\t\tconst all = [...this.models.getModels()];\n\t\tthis.snapshot = {\n\t\t\t...this.snapshot,\n\t\t\tall,\n\t\t\tavailable: all.filter((model) => this.snapshot.configuredProviders.has(model.provider)),\n\t\t};\n\t}\n\n\tprivate async runAvailabilityRefresh(seq: number, errorSeq: number, signal: AbortSignal): Promise<void> {\n\t\tconst providers = this.models.getProviders();\n\t\tconst [available, checks, credentials] = await Promise.all([\n\t\t\tthis.models.getAvailable(undefined, { signal }),\n\t\t\tPromise.all(\n\t\t\t\tproviders.map(\n\t\t\t\t\tasync (provider): Promise<[string, AuthCheck | undefined]> => [\n\t\t\t\t\t\tprovider.id,\n\t\t\t\t\t\tawait this.models.checkAuth(provider.id, { signal }),\n\t\t\t\t\t],\n\t\t\t\t),\n\t\t\t),\n\t\t\tthis.credentials.list({ signal }),\n\t\t]);\n\t\tif (seq !== this.availabilityRefreshSeq) return;\n\t\tconst auth = new Map(checks);\n\t\tconst configuredProviders = new Set(\n\t\t\tchecks\n\t\t\t\t.filter((entry): entry is [string, AuthCheck] => entry[1] !== undefined)\n\t\t\t\t.map(([providerId]) => providerId),\n\t\t);\n\t\tthis.snapshot = {\n\t\t\tall: [...this.models.getModels()],\n\t\t\tavailable: [...available],\n\t\t\tconfiguredProviders,\n\t\t\tstoredProviders: new Set(credentials.map((entry) => entry.providerId)),\n\t\t\tauth,\n\t\t};\n\t\tif (errorSeq === this.availabilityErrorSeq) this.availabilityError = undefined;\n\t}\n\n\tprivate queueAvailabilityRefresh(signal?: AbortSignal): Promise<void> {\n\t\tconst seq = ++this.availabilityRefreshSeq;\n\t\tfor (const [providerId, providerSeq] of this.providerAvailabilitySeq) {\n\t\t\tthis.providerAvailabilitySeq.set(providerId, providerSeq + 1);\n\t\t}\n\t\tconst errorSeq = ++this.availabilityErrorSeq;\n\t\tconst effectiveSignal = operationSignal(signal);\n\t\treturn this.runAvailabilityRefresh(seq, errorSeq, effectiveSignal).catch((error) => {\n\t\t\tif (errorSeq === this.availabilityErrorSeq && !effectiveSignal.aborted) {\n\t\t\t\tthis.availabilityError = error instanceof Error ? error.message : String(error);\n\t\t\t}\n\t\t\tthrow error;\n\t\t});\n\t}\n\n\tprivate async refreshProviderAvailability(providerId: string, signal: AbortSignal): Promise<void> {\n\t\t// Invalidate any full availability pass that started before this credential change.\n\t\t++this.availabilityRefreshSeq;\n\t\tconst providerSeq = (this.providerAvailabilitySeq.get(providerId) ?? 0) + 1;\n\t\tthis.providerAvailabilitySeq.set(providerId, providerSeq);\n\t\tconst errorSeq = ++this.availabilityErrorSeq;\n\t\ttry {\n\t\t\tconst [available, auth, credential] = await Promise.all([\n\t\t\t\tthis.models.getAvailable(providerId, { signal }),\n\t\t\t\tthis.models.checkAuth(providerId, { signal }),\n\t\t\t\tthis.credentials.read(providerId, { signal }),\n\t\t\t]);\n\t\t\tsignal.throwIfAborted();\n\t\t\tif (this.providerAvailabilitySeq.get(providerId) !== providerSeq) return;\n\t\t\tconst configuredProviders = new Set(this.snapshot.configuredProviders);\n\t\t\tconst storedProviders = new Set(this.snapshot.storedProviders);\n\t\t\tconst authByProvider = new Map(this.snapshot.auth);\n\t\t\tif (auth) {\n\t\t\t\tconfiguredProviders.add(providerId);\n\t\t\t\tauthByProvider.set(providerId, auth);\n\t\t\t} else {\n\t\t\t\tconfiguredProviders.delete(providerId);\n\t\t\t\tauthByProvider.delete(providerId);\n\t\t\t}\n\t\t\tif (credential) storedProviders.add(providerId);\n\t\t\telse storedProviders.delete(providerId);\n\t\t\tconst all = [...this.models.getModels()];\n\t\t\tconst availableById = new Map(\n\t\t\t\t[...this.snapshot.available.filter((model) => model.provider !== providerId), ...available].map((model) => [\n\t\t\t\t\t`${model.provider}\\0${model.id}`,\n\t\t\t\t\tmodel,\n\t\t\t\t]),\n\t\t\t);\n\t\t\tthis.snapshot = {\n\t\t\t\tall,\n\t\t\t\tavailable: all.flatMap((model) => availableById.get(`${model.provider}\\0${model.id}`) ?? []),\n\t\t\t\tconfiguredProviders,\n\t\t\t\tstoredProviders,\n\t\t\t\tauth: authByProvider,\n\t\t\t};\n\t\t\tif (errorSeq === this.availabilityErrorSeq) this.availabilityError = undefined;\n\t\t} catch (error) {\n\t\t\tif (\n\t\t\t\tthis.providerAvailabilitySeq.get(providerId) === providerSeq &&\n\t\t\t\terrorSeq === this.availabilityErrorSeq &&\n\t\t\t\t!signal.aborted\n\t\t\t) {\n\t\t\t\tthis.availabilityError = error instanceof Error ? error.message : String(error);\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tgetProviders(): readonly Provider[] {\n\t\treturn this.models.getProviders();\n\t}\n\n\tgetProvider(providerId: string): Provider | undefined {\n\t\treturn this.models.getProvider(providerId);\n\t}\n\n\tgetModels(providerId?: string): readonly Model<Api>[] {\n\t\treturn this.models.getModels(providerId);\n\t}\n\n\tgetModel(providerId: string, modelId: string): Model<Api> | undefined {\n\t\treturn this.models.getModel(providerId, modelId);\n\t}\n\n\tgetModelsOfType<TType extends ModelType>(type: TType, providerId?: string): readonly ModelTypeMap[TType][] {\n\t\treturn this.models.getModelsOfType(type, providerId);\n\t}\n\n\tgetModelOfType<TType extends ModelType>(\n\t\ttype: TType,\n\t\tproviderId: string,\n\t\tmodelId: string,\n\t): ModelTypeMap[TType] | undefined {\n\t\treturn this.models.getModelOfType(type, providerId, modelId);\n\t}\n\n\tgetAllModels(providerId?: string): readonly AnyModel[] {\n\t\treturn this.models.getAllModels(providerId);\n\t}\n\n\tgetAvailableOfType<TType extends ModelType>(\n\t\ttype: TType,\n\t\tproviderId?: string,\n\t\toptions?: AuthOperationOptions,\n\t): Promise<readonly ModelTypeMap[TType][]> {\n\t\treturn this.models.getAvailableOfType(type, providerId, options);\n\t}\n\n\tgetAllAvailable(providerId?: string, options?: AuthOperationOptions): Promise<readonly AnyModel[]> {\n\t\treturn this.models.getAllAvailable(providerId, options);\n\t}\n\n\tasync checkAuth(providerId: string, options?: AuthOperationOptions): Promise<AuthCheck | undefined> {\n\t\treturn this.models.checkAuth(providerId, options);\n\t}\n\n\tasync getAvailable(providerId?: string, options?: AuthOperationOptions): Promise<readonly Model<Api>[]> {\n\t\tif (providerId) {\n\t\t\tconst errorSeq = ++this.availabilityErrorSeq;\n\t\t\ttry {\n\t\t\t\tconst available = await this.models.getAvailable(providerId, options);\n\t\t\t\tif (errorSeq === this.availabilityErrorSeq) this.availabilityError = undefined;\n\t\t\t\treturn available;\n\t\t\t} catch (error) {\n\t\t\t\tif (errorSeq === this.availabilityErrorSeq && !options?.signal?.aborted) {\n\t\t\t\t\tthis.availabilityError = error instanceof Error ? error.message : String(error);\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t\tawait this.queueAvailabilityRefresh(options?.signal);\n\t\treturn this.snapshot.available;\n\t}\n\n\tgetAvailableSnapshot(): readonly Model<Api>[] {\n\t\treturn this.snapshot.available;\n\t}\n\n\tgetError(): string | undefined {\n\t\tconst errors: string[] = [];\n\t\tconst configError = this.config.getError();\n\t\tif (configError) errors.push(configError);\n\t\tfor (const [providerId, error] of this.compositionErrors) {\n\t\t\terrors.push(`Provider \"${providerId}\": ${error}`);\n\t\t}\n\t\tif (this.availabilityError) errors.push(`Availability refresh: ${this.availabilityError}`);\n\t\treturn errors.length > 0 ? errors.join(\"\\n\\n\") : undefined;\n\t}\n\n\tgetRegisteredProviderConfig(providerId: string): ProviderConfigInput | undefined {\n\t\treturn this.extensionProviders.get(providerId);\n\t}\n\n\tgetRegisteredProviderIds(): readonly string[] {\n\t\treturn [...new Set([...this.extensionProviders.keys(), ...this.nativeExtensionProviders.keys()])];\n\t}\n\n\tgetRegisteredNativeProvider(providerId: string): Provider | undefined {\n\t\treturn this.nativeExtensionProviders.get(providerId);\n\t}\n\n\t/** @internal Compatibility fallback for ModelRegistry when provider auth is unconfigured. */\n\tgetCompatibilityRequestConfig(model: Model<Api>): CompatibilityRequestConfig {\n\t\treturn resolveCompatibilityRequestConfig(\n\t\t\tmodel,\n\t\t\tthis.config.getProvider(model.provider),\n\t\t\tthis.extensionProviders.get(model.provider),\n\t\t);\n\t}\n\n\tisUsingOAuth(providerId: string): boolean {\n\t\treturn this.snapshot.auth.get(providerId)?.type === \"oauth\";\n\t}\n\n\tisUsingSubscription(providerId: string): boolean {\n\t\treturn this.isUsingOAuth(providerId) && this.models.getProvider(providerId)?.auth.oauth?.isSubscription === true;\n\t}\n\n\thasConfiguredAuth(providerId: string): boolean {\n\t\treturn this.snapshot.configuredProviders.has(providerId);\n\t}\n\n\tgetAuth(providerId: string, overrides?: ModelRuntimeAuthOverrides): Promise<AuthResult | undefined>;\n\tgetAuth(model: AnyModel, overrides?: ModelRuntimeAuthOverrides): Promise<AuthResult | undefined>;\n\tasync getAuth(\n\t\tproviderOrModel: string | AnyModel,\n\t\toverrides: ModelRuntimeAuthOverrides = {},\n\t): Promise<AuthResult | undefined> {\n\t\tif (typeof providerOrModel === \"string\") return this.models.getAuth(providerOrModel, overrides);\n\t\tconst resolution = await this.models.getAuth(providerOrModel, overrides);\n\t\tif (!resolution) return undefined;\n\t\tconst configuredHeaders = resolveConfiguredModelHeaders(\n\t\t\tproviderOrModel,\n\t\t\tthis.config.getProvider(providerOrModel.provider),\n\t\t\tthis.extensionProviders.get(providerOrModel.provider),\n\t\t\t{ ...(resolution.env ?? {}), ...(overrides.env ?? {}) },\n\t\t);\n\t\treturn {\n\t\t\t...resolution,\n\t\t\tauth: {\n\t\t\t\t...resolution.auth,\n\t\t\t\theaders: mergeHeaders(resolution.auth.headers, configuredHeaders),\n\t\t\t},\n\t\t};\n\t}\n\n\tprivate enqueueCredentialOperation<T>(providerId: string, signal: AbortSignal, task: () => Promise<T>): Promise<T> {\n\t\tconst previous = this.credentialOperations.get(providerId) ?? Promise.resolve();\n\t\tlet markStarted: (() => void) | undefined;\n\t\tconst started = new Promise<void>((resolve) => {\n\t\t\tmarkStarted = resolve;\n\t\t});\n\t\tconst operation = (async () => {\n\t\t\tawait previous.catch(() => {});\n\t\t\tsignal.throwIfAborted();\n\t\t\tmarkStarted?.();\n\t\t\treturn task();\n\t\t})();\n\t\tconst tail = operation.catch(() => {});\n\t\tthis.credentialOperations.set(providerId, tail);\n\t\tvoid tail.then(() => {\n\t\t\tif (this.credentialOperations.get(providerId) === tail) this.credentialOperations.delete(providerId);\n\t\t});\n\t\treturn raceWithAbortSignal(started, signal).then(() => operation);\n\t}\n\n\tprivate async synchronizeCredentialState(\n\t\tproviderId: string,\n\t\toperation: CredentialSynchronizationOperation,\n\t\tcredential: Credential | undefined,\n\t\tsignal: AbortSignal,\n\t): Promise<void> {\n\t\ttry {\n\t\t\tsignal.throwIfAborted();\n\t\t\tthis.recomposeProvider(providerId);\n\t\t\tconst compositionError = this.compositionErrors.get(providerId);\n\t\t\tif (compositionError) throw new Error(compositionError);\n\t\t\tconst result = await this.models.refresh({ allowNetwork: false, providers: [providerId], signal });\n\t\t\tif (result.aborted) signal.throwIfAborted();\n\t\t\tconst refreshError = result.errors.get(providerId);\n\t\t\tif (refreshError) throw refreshError;\n\t\t\tthis.updateModelSnapshot();\n\t\t\tawait this.refreshProviderAvailability(providerId, signal);\n\t\t} catch (cause) {\n\t\t\tthrow new CredentialSynchronizationError(providerId, operation, credential, { cause });\n\t\t}\n\t}\n\n\tsetRuntimeApiKey(providerId: string, apiKey: string, options: AuthOperationOptions = {}): Promise<void> {\n\t\tconst signal = operationSignal(options.signal);\n\t\treturn this.enqueueCredentialOperation(providerId, signal, async () => {\n\t\t\tthis.credentials.setRuntimeApiKey(providerId, apiKey);\n\t\t\tawait this.synchronizeCredentialState(\n\t\t\t\tproviderId,\n\t\t\t\t\"setRuntimeApiKey\",\n\t\t\t\t{ type: \"api_key\", key: apiKey },\n\t\t\t\tsignal,\n\t\t\t);\n\t\t});\n\t}\n\n\tremoveRuntimeApiKey(providerId: string, options: AuthOperationOptions = {}): Promise<void> {\n\t\tconst signal = operationSignal(options.signal);\n\t\treturn this.enqueueCredentialOperation(providerId, signal, async () => {\n\t\t\tthis.credentials.removeRuntimeApiKey(providerId);\n\t\t\tawait this.synchronizeCredentialState(providerId, \"removeRuntimeApiKey\", undefined, signal);\n\t\t});\n\t}\n\n\tlistCredentials(options?: AuthOperationOptions): Promise<readonly CredentialInfo[]> {\n\t\treturn this.credentials.list(options);\n\t}\n\n\tgetProviderAuthStatus(providerId: string): AuthStatus {\n\t\tif (this.credentials.hasRuntimeApiKey(providerId)) return { configured: true, source: \"runtime\" };\n\t\tif (this.snapshot.storedProviders.has(providerId)) return { configured: true, source: \"stored\" };\n\t\tconst configured = configuredRequestAuthStatus(\n\t\t\tthis.config.getProvider(providerId),\n\t\t\tthis.extensionProviders.get(providerId),\n\t\t);\n\t\tif (configured) return configured;\n\t\tconst check = this.snapshot.auth.get(providerId);\n\t\treturn check ? { configured: true, source: \"environment\", label: check.source } : { configured: false };\n\t}\n\n\tprivate async prepareRequest<\n\t\tTModel extends AnyModel,\n\t\tTOptions extends ProviderRequestOptions<TModel> & ModelsRequestTransforms,\n\t>(\n\t\tmodel: TModel,\n\t\toptions: TOptions | undefined,\n\t): Promise<{\n\t\tprovider: Provider;\n\t\tmodel: TModel;\n\t\toptions: Omit<TOptions, \"transformHeaders\"> & ProviderRequestOptions<TModel>;\n\t}> {\n\t\tconst provider = this.models.getProvider(model.provider);\n\t\tif (!provider) throw new ModelsError(\"provider\", `Unknown provider: ${model.provider}`);\n\t\tconst resolution = await this.getAuth(model, {\n\t\t\tapiKey: options?.apiKey,\n\t\t\tenv: options?.env,\n\t\t\tsignal: options?.signal,\n\t\t});\n\t\tif (!resolution) throw new ModelsError(\"auth\", `Provider is not configured: ${model.provider}`);\n\n\t\tconst { transformHeaders, ...rawProviderOptions } = options ?? {};\n\t\tconst providerOptions = rawProviderOptions as Omit<TOptions, \"transformHeaders\"> & ProviderRequestOptions<TModel>;\n\t\tlet headers = mergeHeaders(resolution.auth.headers, providerOptions.headers);\n\t\tif (transformHeaders) headers = await transformHeaders(headers ?? {});\n\t\tconst env =\n\t\t\tresolution.env || providerOptions.env\n\t\t\t\t? { ...(resolution.env ?? {}), ...(providerOptions.env ?? {}) }\n\t\t\t\t: undefined;\n\t\tconst requestModel: TModel = resolution.auth.baseUrl ? { ...model, baseUrl: resolution.auth.baseUrl } : model;\n\t\treturn {\n\t\t\tprovider,\n\t\t\tmodel: requestModel,\n\t\t\toptions: {\n\t\t\t\t...providerOptions,\n\t\t\t\tapiKey: providerOptions.apiKey ?? resolution.auth.apiKey,\n\t\t\t\theaders,\n\t\t\t\tenv,\n\t\t\t} as Omit<TOptions, \"transformHeaders\"> & ProviderRequestOptions<TModel>,\n\t\t};\n\t}\n\n\tstream<TApi extends Api>(\n\t\tmodel: Model<TApi>,\n\t\tcontext: Context,\n\t\toptions?: ModelsApiStreamOptions<TApi>,\n\t): AssistantMessageEventStream {\n\t\tconst transcript = normalizeContext(context);\n\t\treturn lazyStream(model, async () => {\n\t\t\tassertChatModel(model);\n\t\t\tconst prepared = await this.prepareRequest(\n\t\t\t\tmodel,\n\t\t\t\toptions as (StreamOptions & ModelsRequestTransforms) | undefined,\n\t\t\t);\n\t\t\treturn prepared.provider.stream(prepared.model, transcript, prepared.options as ApiStreamOptions<TApi>);\n\t\t});\n\t}\n\n\tcomplete<TApi extends Api>(\n\t\tmodel: Model<TApi>,\n\t\tcontext: Context,\n\t\toptions?: ModelsApiStreamOptions<TApi>,\n\t): Promise<AssistantMessage> {\n\t\treturn this.stream(model, context, options).result();\n\t}\n\n\tstreamSimple(model: Model<Api>, context: Context, options?: ModelsSimpleStreamOptions): AssistantMessageEventStream {\n\t\tconst transcript = normalizeContext(context);\n\t\tif (isVirtualModel(model)) {\n\t\t\t// Requests outside the agent loop are routed here. Callers sized them before routing, so\n\t\t\t// cap the output budget to the routed model.\n\t\t\treturn lazyStream(model, async () => {\n\t\t\t\tconst route = await this.resolveModel(model, transcript.messages, {\n\t\t\t\t\treason: \"direct\",\n\t\t\t\t\tthinkingLevel: options?.reasoning ?? \"off\",\n\t\t\t\t\tsignal: options?.signal,\n\t\t\t\t});\n\t\t\t\tconst { maxTokens: limit } = route.model;\n\t\t\t\tconst maxTokens = options?.maxTokens && limit > 0 ? Math.min(options.maxTokens, limit) : options?.maxTokens;\n\t\t\t\tconst reasoning = route.thinkingLevel === \"off\" ? undefined : route.thinkingLevel;\n\t\t\t\t// Caller credentials were resolved for the virtual model's provider. Another provider\n\t\t\t\t// resolves its own, so they are not sent to the wrong vendor.\n\t\t\t\tconst { apiKey, headers, env, ...rest } = options ?? {};\n\t\t\t\tconst auth = route.model.provider === model.provider ? { apiKey, headers, env } : {};\n\t\t\t\treturn this.streamSimple(route.model, context, { ...rest, ...auth, maxTokens, reasoning });\n\t\t\t});\n\t\t}\n\t\treturn lazyStream(model, async () => {\n\t\t\tassertChatModel(model);\n\t\t\tconst prepared = await this.prepareRequest(model, options);\n\t\t\treturn prepared.provider.streamSimple(prepared.model, transcript, prepared.options as SimpleStreamOptions);\n\t\t});\n\t}\n\n\tcompleteSimple(model: Model<Api>, context: Context, options?: ModelsSimpleStreamOptions): Promise<AssistantMessage> {\n\t\treturn this.streamSimple(model, context, options).result();\n\t}\n\n\tstreamDeferred(\n\t\tmodel: Model<Api>,\n\t\thandle: DeferredHandle,\n\t\toptions?: ModelsDeferredFetchOptions,\n\t): AssistantMessageEventStream {\n\t\treturn lazyStream(model, async () => {\n\t\t\tassertChatModel(model);\n\t\t\tconst prepared = await this.prepareRequest(model, options);\n\t\t\tif (!prepared.provider.fetchDeferred) {\n\t\t\t\tthrow new ModelsError(\"provider\", `Provider ${model.provider} does not support deferred responses`);\n\t\t\t}\n\t\t\treturn prepared.provider.fetchDeferred(prepared.model, handle, prepared.options as DeferredFetchOptions);\n\t\t});\n\t}\n\n\tasync fetchDeferred(\n\t\tmodel: Model<Api>,\n\t\thandle: DeferredHandle,\n\t\toptions?: ModelsDeferredFetchOptions,\n\t): Promise<AssistantMessage> {\n\t\treturn this.streamDeferred(model, handle, options).result();\n\t}\n\n\tasync cancelDeferred(\n\t\tmodel: Model<Api>,\n\t\thandle: DeferredHandle,\n\t\toptions?: ModelsDeferredCancelOptions,\n\t): Promise<void> {\n\t\tassertChatModel(model);\n\t\tconst prepared = await this.prepareRequest(model, options);\n\t\tif (!prepared.provider.cancelDeferred) {\n\t\t\tthrow new ModelsError(\"provider\", `Provider ${model.provider} does not support deferred responses`);\n\t\t}\n\t\tawait prepared.provider.cancelDeferred(prepared.model, handle, prepared.options as DeferredCancelOptions);\n\t}\n\n\tasync generateImages(\n\t\tmodel: ImageModel<ImageApi>,\n\t\tcontext: ImagesContext,\n\t\toptions?: ModelsImagesOptions,\n\t): Promise<AssistantImages> {\n\t\ttry {\n\t\t\tassertImageModel(model);\n\t\t\tconst prepared = await this.prepareRequest(model, options);\n\t\t\tif (!prepared.provider.generateImages) {\n\t\t\t\tthrow new ModelsError(\"provider\", `Provider ${model.provider} does not support image generation`);\n\t\t\t}\n\t\t\treturn await prepared.provider.generateImages(prepared.model, context, prepared.options as ImagesOptions);\n\t\t} catch (error) {\n\t\t\treturn imageErrorResult(model, error, options?.signal?.aborted);\n\t\t}\n\t}\n\n\tasync classify(\n\t\tmodel: ClassifierModel<ClassifierApi>,\n\t\tcontext: ClassifierContext,\n\t\toptions?: ModelsClassifierOptions,\n\t): Promise<ClassifierResult> {\n\t\ttry {\n\t\t\tassertClassifierModel(model);\n\t\t\tconst prepared = await this.prepareRequest(model, options);\n\t\t\tif (!prepared.provider.classify) {\n\t\t\t\tthrow new ModelsError(\"provider\", `Provider ${model.provider} does not support classification`);\n\t\t\t}\n\t\t\treturn await prepared.provider.classify(prepared.model, context, prepared.options as ClassifierOptions);\n\t\t} catch (error) {\n\t\t\treturn classifierErrorResult(model, error, options?.signal?.aborted);\n\t\t}\n\t}\n\n\tlogin(\n\t\tproviderId: string,\n\t\ttype: AuthType,\n\t\tinteraction: AuthInteraction,\n\t\toptions?: LoginOptions,\n\t): Promise<Credential> {\n\t\tconst signal = operationSignal(interaction.signal);\n\t\treturn this.enqueueCredentialOperation(providerId, signal, async () => {\n\t\t\tconst credential = await this.models.login(providerId, type, { ...interaction, signal }, options);\n\t\t\tawait this.synchronizeCredentialState(providerId, \"login\", credential, signal);\n\t\t\treturn credential;\n\t\t});\n\t}\n\n\tlogout(providerId: string, options: AuthOperationOptions = {}): Promise<void> {\n\t\tconst signal = operationSignal(options.signal);\n\t\treturn this.enqueueCredentialOperation(providerId, signal, async () => {\n\t\t\tawait this.models.logout(providerId, { signal });\n\t\t\tawait this.synchronizeCredentialState(providerId, \"logout\", undefined, signal);\n\t\t});\n\t}\n\n\tasync refresh(options: ModelsRefreshOptions = {}): Promise<ModelsRefreshResult> {\n\t\tthis.config = await ModelConfig.load(this.modelsPath);\n\t\tthis.configureRadiusProviders();\n\t\tif (options.providers) {\n\t\t\tfor (const providerId of new Set(options.providers)) this.recomposeProvider(providerId);\n\t\t\tthis.updateModelSnapshot();\n\t\t} else {\n\t\t\tthis.rebuildProviders();\n\t\t}\n\t\tconst refreshOptions = {\n\t\t\t...options,\n\t\t\tallowNetwork: options.allowNetwork ?? this.modelNetworkEnabled,\n\t\t};\n\t\t// Published pi-ai builds before ModelsStore returned void and accepted a provider ID.\n\t\t// The fallback keeps source-mode CLI tests working without rebuilding workspace dependencies.\n\t\tconst result = ((await this.models.refresh(refreshOptions)) as ModelsRefreshResult | undefined) ?? {\n\t\t\taborted: refreshOptions.signal?.aborted ?? false,\n\t\t\terrors: new Map(),\n\t\t};\n\t\tconst errors = new Map(result.errors);\n\t\tthis.updateModelSnapshot();\n\t\tif (options.providers) {\n\t\t\tawait Promise.all(\n\t\t\t\t[...new Set(options.providers)].map(async (providerId) => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait this.refreshProviderAvailability(providerId, operationSignal(options.signal));\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tif (!options.signal?.aborted) {\n\t\t\t\t\t\t\terrors.set(providerId, error instanceof Error ? error : new Error(String(error)));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t);\n\t\t} else {\n\t\t\ttry {\n\t\t\t\tawait this.queueAvailabilityRefresh(options.signal);\n\t\t\t} catch {\n\t\t\t\t// Availability errors are recorded by the latest pass; refreshed models remain usable.\n\t\t\t}\n\t\t}\n\t\treturn { aborted: result.aborted || (options.signal?.aborted ?? false), errors };\n\t}\n\n\tregisterNativeProvider(provider: Provider): void {\n\t\tif (!provider.id.trim()) throw new Error(\"Provider id must not be empty.\");\n\t\tthis.extensionProviders.delete(provider.id);\n\t\tthis.nativeExtensionProviders.set(provider.id, provider);\n\t\tthis.recomposeProvider(provider.id);\n\t\tthis.updateModelSnapshot();\n\t\tthis.markProvisionallyConfigured(\n\t\t\tprovider.id,\n\t\t\tconfiguredRequestAuthStatus(this.config.getProvider(provider.id), undefined),\n\t\t\tprovider.auth.oauth && !provider.auth.apiKey ? \"oauth\" : \"api_key\",\n\t\t);\n\t\tvoid this.refresh({ allowNetwork: false });\n\t}\n\n\t/**\n\t * Mark a newly registered provider as configured when it has a stored credential or a configured\n\t * API key. Availability checks run asynchronously, and callers such as initial model selection\n\t * read the snapshot before they finish. The next availability pass replaces this entry.\n\t */\n\tprivate markProvisionallyConfigured(\n\t\tproviderId: string,\n\t\tconfiguredStatus: AuthStatus | undefined,\n\t\ttype: AuthType,\n\t): void {\n\t\tif (!this.snapshot.storedProviders.has(providerId) && !configuredStatus?.configured) return;\n\t\tconst configuredProviders = new Set(this.snapshot.configuredProviders).add(providerId);\n\t\tconst auth = new Map(this.snapshot.auth);\n\t\t// Never clobber a real check result.\n\t\tif (!auth.get(providerId)) auth.set(providerId, { type, source: \"configured provider\" });\n\t\tthis.snapshot = {\n\t\t\t...this.snapshot,\n\t\t\tauth,\n\t\t\tconfiguredProviders,\n\t\t\tavailable: this.snapshot.all.filter((model) => configuredProviders.has(model.provider)),\n\t\t};\n\t}\n\n\tregisterProvider(providerId: string, config: ProviderConfigInput): void {\n\t\t// Validate the incoming registration on its own, like the legacy registry:\n\t\t// a broken re-registration must throw without touching the stored config.\n\t\tvalidateExtensionProvider(providerId, this.builtins.get(providerId), this.config.getProvider(providerId), config);\n\t\tthis.nativeExtensionProviders.delete(providerId);\n\t\t// Re-registration merges defined values over the previous registration and\n\t\t// preserves undefined ones, matching the legacy ModelRegistry contract.\n\t\tconst previous = this.extensionProviders.get(providerId);\n\t\tconst effective: ProviderConfigInput = { ...previous };\n\t\tfor (const [key, value] of Object.entries(config)) {\n\t\t\tif (value !== undefined) (effective as Record<string, unknown>)[key] = value;\n\t\t}\n\t\tthis.extensionProviders.set(providerId, effective);\n\t\tthis.recomposeProvider(providerId);\n\t\tthis.updateModelSnapshot();\n\t\tthis.markProvisionallyConfigured(\n\t\t\tproviderId,\n\t\t\tconfiguredRequestAuthStatus(this.config.getProvider(providerId), effective),\n\t\t\teffective.oauth && !effective.apiKey ? \"oauth\" : \"api_key\",\n\t\t);\n\t\tvoid this.refresh({ allowNetwork: false });\n\t}\n\n\tunregisterProvider(providerId: string): void {\n\t\tthis.extensionProviders.delete(providerId);\n\t\tthis.nativeExtensionProviders.delete(providerId);\n\t\tthis.recomposeProvider(providerId);\n\t\tthis.updateModelSnapshot();\n\t\tvoid this.refresh({ allowNetwork: false });\n\t}\n\n\t/**\n\t * Register a virtual model under `definition.provider`, which may also list physical models or\n\t * several virtual models. Re-registering the same provider and id replaces the virtual model.\n\t * Throws when the id belongs to a physical model of that provider.\n\t */\n\tregisterVirtualModel(definition: VirtualModelDefinition): void {\n\t\tconst { provider: providerId, id } = definition;\n\t\tif (!providerId.trim() || !id.trim()) throw new Error(\"Virtual model provider and id must not be empty.\");\n\t\tconst existing = this.models.getModel(providerId, id);\n\t\tif (existing && !isVirtualModel(existing)) {\n\t\t\tthrow new Error(`Virtual model ${providerId}/${id} conflicts with a physical model.`);\n\t\t}\n\t\tconst models = this.virtualModels.get(providerId) ?? new Map<string, RegisteredVirtualModel>();\n\t\tmodels.set(id, { model: createVirtualModel(definition), route: (request) => definition.route(request) });\n\t\tthis.virtualModels.set(providerId, models);\n\t\tif (!this.recomposeProvider(providerId) && !this.snapshot.configuredProviders.has(providerId)) {\n\t\t\t// A provider of only virtual models needs no credentials. Mark it configured now: session\n\t\t\t// restore checks auth before the refresh below lands.\n\t\t\tconst auth = new Map(this.snapshot.auth).set(providerId, { type: \"api_key\", source: \"virtual\" });\n\t\t\tconst configuredProviders = new Set(this.snapshot.configuredProviders).add(providerId);\n\t\t\tthis.snapshot = { ...this.snapshot, auth, configuredProviders };\n\t\t}\n\t\tthis.updateModelSnapshot();\n\t\tvoid this.refresh({ allowNetwork: false });\n\t}\n\n\tunregisterVirtualModel(providerId: string, id: string): void {\n\t\tconst models = this.virtualModels.get(providerId);\n\t\tif (!models?.delete(id)) return;\n\t\tif (models.size === 0) this.virtualModels.delete(providerId);\n\t\tthis.recomposeProvider(providerId);\n\t\tthis.updateModelSnapshot();\n\t\tvoid this.refresh({ allowNetwork: false });\n\t}\n\n\t/**\n\t * Ask a virtual model's router for the model and thinking level of one request. The router must\n\t * return a physical catalog model whose provider has credentials; the thinking level is clamped\n\t * to that model. Throws when routing fails.\n\t *\n\t * `previous` reports the latest successful response in `messages`. A retry passes the failed\n\t * response as `options.failed`; `messages` no longer contains it. `options.state` is the router\n\t * state stored by the caller, which also stores the returned state.\n\t */\n\tasync resolveModel(\n\t\tmodel: Model<Api>,\n\t\tmessages: readonly Message[],\n\t\toptions: {\n\t\t\treason: ModelRouteReason;\n\t\t\tthinkingLevel: ModelThinkingLevel;\n\t\t\tsignal?: AbortSignal;\n\t\t\tfailed?: AssistantMessage;\n\t\t\tstate?: unknown;\n\t\t},\n\t): Promise<ModelRoute> {\n\t\tconst name = `Virtual model ${model.provider}/${model.id}`;\n\t\tconst virtual = this.virtualModels.get(model.provider)?.get(model.id);\n\t\tif (!virtual) throw new Error(`${name} is not registered.`);\n\t\tconst { failed, ...request } = options;\n\t\tconst latest = findLatestResponse(messages);\n\t\tconst previousModel = latest && this.getPhysicalModel(latest.provider, latest.model);\n\t\t// A failed routing attempt names the virtual model; there is no physical request to report.\n\t\tconst failedModel = failed && this.getPhysicalModel(failed.provider, failed.model);\n\t\tconst route = await virtual.route({\n\t\t\t...request,\n\t\t\tmodel,\n\t\t\tprevious: previousModel && { model: previousModel, thinkingLevel: latest?.thinkingLevel },\n\t\t\tfailed: failedModel && failed && { model: failedModel, thinkingLevel: failed.thinkingLevel, message: failed },\n\t\t\tmessages,\n\t\t});\n\t\tconst target = this.getPhysicalModel(route.model.provider, route.model.id);\n\t\tconst routed = `${name} routed to ${route.model.provider}/${route.model.id}`;\n\t\tif (!target) throw new Error(`${routed}, which is not a physical model.`);\n\t\tif (!this.hasConfiguredAuth(target.provider)) throw new Error(`${routed}, which has no credentials.`);\n\t\treturn { model: target, thinkingLevel: clampThinkingLevel(target, route.thinkingLevel), state: route.state };\n\t}\n\n\t/** A catalog chat model that is not virtual. */\n\tgetPhysicalModel(providerId: string, modelId: string): Model<Api> | undefined {\n\t\tconst model = this.models.getModel(providerId, modelId);\n\t\treturn model && !isVirtualModel(model) ? model : undefined;\n\t}\n}\n"]}
1
+ {"version":3,"file":"model-runtime.js","sourceRoot":"","sources":["../../src/core/model-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAqBN,kBAAkB,EAClB,YAAY,EAQZ,WAAW,EAEX,UAAU,EAQV,WAAW,EAYX,gBAAgB,GAMhB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,sBAAsB,MAAM,qCAAqC,CAAC;AAC9E,OAAO,EACN,eAAe,EACf,qBAAqB,EACrB,gBAAgB,EAChB,qBAAqB,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AE,CAAC;QAC7E,IAAI,CAAC,MAAM;YAAE,MAAM,IAAI,KAAK,CAAC,GAAG,MAAM,kCAAkC,CAAC,CAAC;QAC1E,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,QAAQ,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,GAAG,MAAM,6BAA6B,CAAC,CAAC;QACtG,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,kBAAkB,CAAC,MAAM,EAAE,KAAK,CAAC,aAAa,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC;IAC9G,CAAC;IAED,gDAAgD;IAChD,gBAAgB,CAAC,UAAkB,EAAE,OAAe;QACnD,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QACjD,OAAO,KAAK,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;IAC5D,CAAC;CACD","sourcesContent":["import { dirname, join } from \"node:path\";\nimport {\n\ttype AnyModel,\n\ttype Api,\n\ttype ApiStreamOptions,\n\ttype AssistantImages,\n\ttype AssistantMessage,\n\ttype AssistantMessageEventStream,\n\ttype AuthCheck,\n\ttype AuthInteraction,\n\ttype AuthOperationOptions,\n\ttype AuthResult,\n\ttype AuthType,\n\ttype ClassifierApi,\n\ttype ClassifierContext,\n\ttype ClassifierModel,\n\ttype ClassifierOptions,\n\ttype ClassifierResult,\n\ttype Context,\n\ttype Credential,\n\ttype CredentialInfo,\n\ttype CredentialStore,\n\tclampThinkingLevel,\n\tcreateModels,\n\ttype DeferredCancelOptions,\n\ttype DeferredFetchOptions,\n\ttype DeferredHandle,\n\ttype ImageApi,\n\ttype ImageModel,\n\ttype ImagesContext,\n\ttype ImagesOptions,\n\tisModelType,\n\ttype LoginOptions,\n\tlazyStream,\n\ttype Message,\n\ttype Model,\n\ttype Models,\n\ttype ModelsApiStreamOptions,\n\ttype ModelsClassifierOptions,\n\ttype ModelsDeferredCancelOptions,\n\ttype ModelsDeferredFetchOptions,\n\tModelsError,\n\ttype ModelsImagesOptions,\n\ttype ModelsRefreshOptions,\n\ttype ModelsRefreshResult,\n\ttype ModelsRequestTransforms,\n\ttype ModelsSimpleStreamOptions,\n\ttype ModelsStore,\n\ttype ModelsStreamRequestTransforms,\n\ttype ModelThinkingLevel,\n\ttype ModelType,\n\ttype ModelTypeMap,\n\ttype MutableModels,\n\tnormalizeContext,\n\ttype Provider,\n\ttype ProviderHeaders,\n\ttype ProviderRequestOptions,\n\ttype SimpleStreamOptions,\n\ttype TranscriptContext,\n} from \"@earendil-works/pi-ai\";\nimport * as builtinProviderCatalog from \"@earendil-works/pi-ai/providers/all\";\nimport {\n\tassertChatModel,\n\tassertClassifierModel,\n\tassertImageModel,\n\tclassifierErrorResult,\n\timageErrorResult,\n} from \"@earendil-works/pi-ai/utils/model-operations\";\nimport { getAgentDir } from \"../config.ts\";\nimport { operationSignal, raceWithAbortSignal } from \"../utils/abort.ts\";\nimport { AuthStorage as DefaultAuthStorage } from \"./auth-storage.ts\";\nimport { ModelConfig } from \"./model-config.ts\";\nimport { FileModelsStore, InMemoryCodingAgentModelsStore } from \"./models-store.ts\";\nimport {\n\tcancelDeferredPiServer,\n\tclassifyPiServer,\n\tfetchDeferredPiServer,\n\tfetchPiServerModels,\n\tgenerateImagesPiServer,\n\tstreamPiServer,\n\tstreamRawPiServer,\n} from \"./pi-server-client.ts\";\nimport {\n\ttype AuthStatus,\n\ttype CompatibilityRequestConfig,\n\tcomposeModelProvider,\n\tconfiguredRequestAuthStatus,\n\ttype ProviderConfigInput,\n\tresolveCompatibilityRequestConfig,\n\tresolveConfiguredModelHeaders,\n\tvalidateExtensionProvider,\n} from \"./provider-composer.ts\";\nimport { withRemoteCatalog } from \"./remote-catalog-provider.ts\";\nimport { RuntimeCredentials } from \"./runtime-credentials.ts\";\nimport {\n\tcreateVirtualModel,\n\tfindLatestResponse,\n\tisVirtualModel,\n\ttype ModelRoute,\n\ttype ModelRouteReason,\n\ttype VirtualModelDefinition,\n\twithVirtualModels,\n} from \"./virtual-models.ts\";\n\ninterface RegisteredVirtualModel {\n\tmodel: Model<Api>;\n\troute: VirtualModelDefinition[\"route\"];\n}\n\ninterface ModelRuntimeSnapshot {\n\tall: readonly Model<Api>[];\n\tavailable: readonly Model<Api>[];\n\tconfiguredProviders: ReadonlySet<string>;\n\tstoredProviders: ReadonlySet<string>;\n\tauth: ReadonlyMap<string, AuthCheck | undefined>;\n}\n\nexport interface CreateModelRuntimeOptions {\n\t/** Credential storage. Defaults to the file at authPath. */\n\tcredentials?: CredentialStore;\n\tauthPath?: string;\n\tmodelsPath?: string | null;\n\tmodelsStore?: ModelsStore;\n\tmodelsStorePath?: string;\n\t/** Allow create() to refresh model catalogs over the network. Defaults to false. */\n\tallowModelNetwork?: boolean;\n\t/** Timeout for the create-time network model refresh. */\n\tmodelRefreshTimeoutMs?: number;\n\tcatalogBaseUrl?: string;\n\t/** Optional caller cancellation for initial cache restoration and availability checks. */\n\tsignal?: AbortSignal;\n\t/** Skip initial catalog and availability refresh. Static models remain available. */\n\trefreshOnCreate?: boolean;\n}\n\nexport interface ModelRuntimeAuthOverrides extends AuthOperationOptions {\n\tapiKey?: string;\n\tenv?: Record<string, string>;\n\t/** Require this much remaining OAuth-token validity; defaults to five minutes. */\n\tminOAuthValidityMs?: number;\n}\n\nexport type CredentialSynchronizationOperation = \"login\" | \"logout\" | \"setRuntimeApiKey\" | \"removeRuntimeApiKey\";\n\n/** Credentials changed successfully, but the local model/auth snapshot could not be synchronized. */\nexport class CredentialSynchronizationError extends Error {\n\treadonly providerId: string;\n\treadonly operation: CredentialSynchronizationOperation;\n\treadonly credential: Credential | undefined;\n\n\tconstructor(\n\t\tproviderId: string,\n\t\toperation: CredentialSynchronizationOperation,\n\t\tcredential: Credential | undefined,\n\t\toptions: ErrorOptions,\n\t) {\n\t\tsuper(`Credential ${operation} committed for ${providerId}, but local synchronization failed`, options);\n\t\tthis.name = \"CredentialSynchronizationError\";\n\t\tthis.providerId = providerId;\n\t\tthis.operation = operation;\n\t\tthis.credential = credential;\n\t}\n}\n\nfunction mergeHeaders(\n\tbase: ProviderHeaders | undefined,\n\toverride: ProviderHeaders | undefined,\n): ProviderHeaders | undefined {\n\tif (!base && !override) return undefined;\n\tconst merged = { ...base };\n\tfor (const [name, value] of Object.entries(override ?? {})) {\n\t\tconst lowerName = name.toLowerCase();\n\t\tfor (const existingName of Object.keys(merged)) {\n\t\t\tif (existingName.toLowerCase() === lowerName) delete merged[existingName];\n\t\t}\n\t\tmerged[name] = value;\n\t}\n\treturn merged;\n}\n\n/** Configured pi-ai Models collection used by coding-agent and SDK consumers. */\nexport class ModelRuntime implements Models {\n\tprivate readonly models: MutableModels;\n\tprivate readonly credentials: RuntimeCredentials;\n\tprivate readonly defaultBuiltins: ReadonlyMap<string, Provider>;\n\tprivate readonly nativeCatalogProviders: ReadonlySet<string>;\n\tprivate readonly builtins = new Map<string, Provider>();\n\tprivate readonly nativeExtensionProviders = new Map<string, Provider>();\n\tprivate readonly extensionProviders = new Map<string, ProviderConfigInput>();\n\t/** Virtual models by provider id, then model id. */\n\tprivate readonly virtualModels = new Map<string, Map<string, RegisteredVirtualModel>>();\n\tprivate readonly compositionErrors = new Map<string, string>();\n\tprivate readonly modelsPath: string | undefined;\n\tprivate readonly modelNetworkEnabled: boolean;\n\tprivate readonly piServerMode = process.env.PI_SERVER_MODE === \"true\";\n\tprivate remoteCatalog: { models: readonly AnyModel[]; available: readonly AnyModel[] } = {\n\t\tmodels: [],\n\t\tavailable: [],\n\t};\n\tprivate remoteProviderCapabilities: readonly { id: string; fetchDeferred: boolean; cancelDeferred: boolean }[] = [];\n\tprivate remoteCatalogError: string | undefined;\n\tprivate registrationRefresh: Promise<void> = Promise.resolve();\n\tprivate readonly registrationRefreshErrors = new Map<string, string>();\n\tprivate remoteCatalogRefreshSeq = 0;\n\tprivate remoteCatalogLoaded = false;\n\tprivate localOperationAvailable: readonly AnyModel[] = [];\n\tprivate remoteProjection: { models: readonly AnyModel[]; available: readonly AnyModel[] } | undefined;\n\tprivate config: ModelConfig;\n\tprivate snapshot: ModelRuntimeSnapshot = {\n\t\tall: [],\n\t\tavailable: [],\n\t\tconfiguredProviders: new Set(),\n\t\tstoredProviders: new Set(),\n\t\tauth: new Map(),\n\t};\n\tprivate availabilityRefreshSeq = 0;\n\tprivate availabilityErrorSeq = 0;\n\tprivate readonly providerAvailabilitySeq = new Map<string, number>();\n\tprivate availabilityError: string | undefined;\n\tprivate readonly credentialOperations = new Map<string, Promise<unknown>>();\n\n\tprivate constructor(\n\t\tcredentials: RuntimeCredentials,\n\t\tconfig: ModelConfig,\n\t\tmodelsPath: string | undefined,\n\t\tmodelsStore: ModelsStore,\n\t\tproviders: readonly Provider[],\n\t\tmodelNetworkEnabled: boolean,\n\t\tnativeCatalogProviders: ReadonlySet<string>,\n\t) {\n\t\tthis.credentials = credentials;\n\t\tthis.config = config;\n\t\tthis.modelsPath = modelsPath;\n\t\tthis.modelNetworkEnabled = modelNetworkEnabled;\n\t\tthis.nativeCatalogProviders = nativeCatalogProviders;\n\t\tthis.defaultBuiltins = new Map(providers.map((provider) => [provider.id, provider]));\n\t\tfor (const [providerId, provider] of this.defaultBuiltins) this.builtins.set(providerId, provider);\n\t\tthis.models = createModels({ credentials, modelsStore });\n\t\tthis.rebuildProviders();\n\t}\n\n\tstatic async create(options: CreateModelRuntimeOptions = {}): Promise<ModelRuntime> {\n\t\tconst credentials = new RuntimeCredentials(options.credentials ?? DefaultAuthStorage.create(options.authPath));\n\t\tconst modelsPath =\n\t\t\toptions.modelsPath === null ? undefined : (options.modelsPath ?? join(getAgentDir(), \"models.json\"));\n\t\tconst config = await ModelConfig.load(modelsPath);\n\t\tconst modelsStore =\n\t\t\toptions.modelsStore ??\n\t\t\t(modelsPath\n\t\t\t\t? new FileModelsStore(options.modelsStorePath ?? join(dirname(modelsPath), \"models-store.json\"))\n\t\t\t\t: new InMemoryCodingAgentModelsStore());\n\t\tconst builtinModelDataGeneratedAt = builtinProviderCatalog.getBuiltinModelDataGeneratedAt();\n\t\tconst builtinProviders = builtinProviderCatalog.builtinProviders();\n\t\tconst providers = builtinProviders.map((provider) =>\n\t\t\tprovider.refreshModels !== undefined\n\t\t\t\t? provider\n\t\t\t\t: withRemoteCatalog(provider, options.catalogBaseUrl, builtinModelDataGeneratedAt),\n\t\t);\n\t\tconst runtime = new ModelRuntime(\n\t\t\tcredentials,\n\t\t\tconfig,\n\t\t\tmodelsPath,\n\t\t\tmodelsStore,\n\t\t\tproviders,\n\t\t\tprocess.env.PI_OFFLINE === undefined,\n\t\t\tnew Set(\n\t\t\t\tbuiltinProviders.filter((provider) => provider.refreshModels !== undefined).map((provider) => provider.id),\n\t\t\t),\n\t\t);\n\t\truntime.configureRadiusProviders();\n\t\truntime.rebuildProviders();\n\t\tconst refreshFromNetwork = runtime.modelNetworkEnabled && options.allowModelNetwork === true;\n\t\tconst controller =\n\t\t\trefreshFromNetwork && options.modelRefreshTimeoutMs !== undefined ? new AbortController() : undefined;\n\t\tconst timeout = controller ? setTimeout(() => controller.abort(), options.modelRefreshTimeoutMs) : undefined;\n\t\tconst signal = controller\n\t\t\t? options.signal\n\t\t\t\t? AbortSignal.any([options.signal, controller.signal])\n\t\t\t\t: controller.signal\n\t\t\t: options.signal;\n\t\ttry {\n\t\t\tif (options.refreshOnCreate !== false) {\n\t\t\t\tconst result = await runtime.refresh({ allowNetwork: refreshFromNetwork, signal });\n\t\t\t\tconst remoteError = result.errors.get(\"pi-server\");\n\t\t\t\tif (remoteError) throw remoteError;\n\t\t\t\tif (runtime.piServerMode && result.aborted) signal?.throwIfAborted();\n\t\t\t}\n\t\t} finally {\n\t\t\tif (timeout) clearTimeout(timeout);\n\t\t}\n\t\treturn runtime;\n\t}\n\n\tprivate configureRadiusProviders(): void {\n\t\tthis.builtins.clear();\n\t\tfor (const [providerId, provider] of this.defaultBuiltins) this.builtins.set(providerId, provider);\n\t\tfor (const providerId of this.config.getProviderIds()) {\n\t\t\tconst config = this.config.getProvider(providerId);\n\t\t\tif (config?.oauth !== \"radius\" || !config.baseUrl) continue;\n\t\t\tthis.builtins.set(\n\t\t\t\tproviderId,\n\t\t\t\tbuiltinProviderCatalog.radiusProvider({\n\t\t\t\t\tid: providerId,\n\t\t\t\t\tname: config.name ?? providerId,\n\t\t\t\t\tgateway: config.baseUrl.replace(/\\/v1\\/?$/u, \"\"),\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate providerIds(): Set<string> {\n\t\treturn new Set([\n\t\t\t...this.builtins.keys(),\n\t\t\t...this.nativeExtensionProviders.keys(),\n\t\t\t...this.config.getProviderIds(),\n\t\t\t...this.extensionProviders.keys(),\n\t\t\t...this.virtualModels.keys(),\n\t\t]);\n\t}\n\n\t/** Returns the provider without virtual models, or undefined when only virtual models define it. */\n\tprivate recomposeProvider(providerId: string): Provider | undefined {\n\t\tconst provider = this.composeProvider(providerId);\n\t\tconst virtualModels = [...(this.virtualModels.get(providerId)?.values() ?? [])].map((entry) => entry.model);\n\t\tif (virtualModels.length > 0) this.models.setProvider(withVirtualModels(providerId, provider, virtualModels));\n\t\telse if (provider) this.models.setProvider(provider);\n\t\telse this.models.deleteProvider(providerId);\n\t\treturn provider;\n\t}\n\n\t/** The provider without virtual models, or undefined when nothing defines it. */\n\tprivate composeProvider(providerId: string): Provider | undefined {\n\t\tconst base = this.nativeExtensionProviders.get(providerId) ?? this.builtins.get(providerId);\n\t\tconst extension = this.extensionProviders.get(providerId);\n\t\tif (!this.config.getProvider(providerId) && !extension) {\n\t\t\t// No overlays: use the builtin untouched so its auth/login/stream behavior is exact.\n\t\t\tthis.compositionErrors.delete(providerId);\n\t\t\treturn base;\n\t\t}\n\t\ttry {\n\t\t\tconst provider = composeModelProvider(providerId, base, this.config, extension);\n\t\t\tthis.compositionErrors.delete(providerId);\n\t\t\treturn provider;\n\t\t} catch (error) {\n\t\t\tthis.compositionErrors.set(providerId, error instanceof Error ? error.message : String(error));\n\t\t\treturn base;\n\t\t}\n\t}\n\n\tprivate rebuildProviders(): void {\n\t\tthis.models.clearProviders();\n\t\tthis.compositionErrors.clear();\n\t\tfor (const providerId of this.providerIds()) this.recomposeProvider(providerId);\n\t\tthis.updateModelSnapshot();\n\t}\n\n\tprivate updateModelSnapshot(): void {\n\t\tthis.remoteProjection = undefined;\n\t\tconst all = [...this.models.getModels()];\n\t\tthis.snapshot = {\n\t\t\t...this.snapshot,\n\t\t\tall,\n\t\t\tavailable: all.filter((model) => this.snapshot.configuredProviders.has(model.provider)),\n\t\t};\n\t}\n\n\tprivate async runAvailabilityRefresh(seq: number, errorSeq: number, signal: AbortSignal): Promise<void> {\n\t\tconst providers = this.models.getProviders();\n\t\tconst [allAvailable, checks, credentials] = await Promise.all([\n\t\t\tthis.models.getAllAvailable(undefined, { signal }),\n\t\t\tPromise.all(\n\t\t\t\tproviders.map(\n\t\t\t\t\tasync (provider): Promise<[string, AuthCheck | undefined]> => [\n\t\t\t\t\t\tprovider.id,\n\t\t\t\t\t\tawait this.models.checkAuth(provider.id, { signal }),\n\t\t\t\t\t],\n\t\t\t\t),\n\t\t\t),\n\t\t\tthis.credentials.list({ signal }),\n\t\t]);\n\t\tif (seq !== this.availabilityRefreshSeq) return;\n\t\tthis.localOperationAvailable = allAvailable;\n\t\tthis.remoteProjection = undefined;\n\t\tconst auth = new Map(checks);\n\t\tconst configuredProviders = new Set(\n\t\t\tchecks\n\t\t\t\t.filter((entry): entry is [string, AuthCheck] => entry[1] !== undefined)\n\t\t\t\t.map(([providerId]) => providerId),\n\t\t);\n\t\tthis.snapshot = {\n\t\t\tall: [...this.models.getModels()],\n\t\t\tavailable: allAvailable.filter((model) => isModelType(model, \"chat\")),\n\t\t\tconfiguredProviders,\n\t\t\tstoredProviders: new Set(credentials.map((entry) => entry.providerId)),\n\t\t\tauth,\n\t\t};\n\t\tif (errorSeq === this.availabilityErrorSeq) this.availabilityError = undefined;\n\t}\n\n\tprivate queueAvailabilityRefresh(signal?: AbortSignal): Promise<void> {\n\t\tconst seq = ++this.availabilityRefreshSeq;\n\t\tfor (const [providerId, providerSeq] of this.providerAvailabilitySeq) {\n\t\t\tthis.providerAvailabilitySeq.set(providerId, providerSeq + 1);\n\t\t}\n\t\tconst errorSeq = ++this.availabilityErrorSeq;\n\t\tconst effectiveSignal = operationSignal(signal);\n\t\treturn this.runAvailabilityRefresh(seq, errorSeq, effectiveSignal).catch((error) => {\n\t\t\tif (errorSeq === this.availabilityErrorSeq && !effectiveSignal.aborted) {\n\t\t\t\tthis.availabilityError = error instanceof Error ? error.message : String(error);\n\t\t\t}\n\t\t\tthrow error;\n\t\t});\n\t}\n\n\tprivate async refreshProviderAvailability(providerId: string, signal: AbortSignal): Promise<void> {\n\t\t// Invalidate any full availability pass that started before this credential change.\n\t\t++this.availabilityRefreshSeq;\n\t\tconst providerSeq = (this.providerAvailabilitySeq.get(providerId) ?? 0) + 1;\n\t\tthis.providerAvailabilitySeq.set(providerId, providerSeq);\n\t\tconst errorSeq = ++this.availabilityErrorSeq;\n\t\ttry {\n\t\t\tconst [allAvailable, auth, credential] = await Promise.all([\n\t\t\t\tthis.models.getAllAvailable(providerId, { signal }),\n\t\t\t\tthis.models.checkAuth(providerId, { signal }),\n\t\t\t\tthis.credentials.read(providerId, { signal }),\n\t\t\t]);\n\t\t\tsignal.throwIfAborted();\n\t\t\tif (this.providerAvailabilitySeq.get(providerId) !== providerSeq) return;\n\t\t\tthis.localOperationAvailable = [\n\t\t\t\t...this.localOperationAvailable.filter((model) => model.provider !== providerId),\n\t\t\t\t...allAvailable,\n\t\t\t];\n\t\t\tthis.remoteProjection = undefined;\n\t\t\tconst available = allAvailable.filter((model) => isModelType(model, \"chat\"));\n\t\t\tconst configuredProviders = new Set(this.snapshot.configuredProviders);\n\t\t\tconst storedProviders = new Set(this.snapshot.storedProviders);\n\t\t\tconst authByProvider = new Map(this.snapshot.auth);\n\t\t\tif (auth) {\n\t\t\t\tconfiguredProviders.add(providerId);\n\t\t\t\tauthByProvider.set(providerId, auth);\n\t\t\t} else {\n\t\t\t\tconfiguredProviders.delete(providerId);\n\t\t\t\tauthByProvider.delete(providerId);\n\t\t\t}\n\t\t\tif (credential) storedProviders.add(providerId);\n\t\t\telse storedProviders.delete(providerId);\n\t\t\tconst all = [...this.models.getModels()];\n\t\t\tconst availableById = new Map(\n\t\t\t\t[...this.snapshot.available.filter((model) => model.provider !== providerId), ...available].map((model) => [\n\t\t\t\t\t`${model.provider}\\0${model.id}`,\n\t\t\t\t\tmodel,\n\t\t\t\t]),\n\t\t\t);\n\t\t\tthis.snapshot = {\n\t\t\t\tall,\n\t\t\t\tavailable: all.flatMap((model) => availableById.get(`${model.provider}\\0${model.id}`) ?? []),\n\t\t\t\tconfiguredProviders,\n\t\t\t\tstoredProviders,\n\t\t\t\tauth: authByProvider,\n\t\t\t};\n\t\t\tif (errorSeq === this.availabilityErrorSeq) this.availabilityError = undefined;\n\t\t} catch (error) {\n\t\t\tif (\n\t\t\t\tthis.providerAvailabilitySeq.get(providerId) === providerSeq &&\n\t\t\t\terrorSeq === this.availabilityErrorSeq &&\n\t\t\t\t!signal.aborted\n\t\t\t) {\n\t\t\t\tthis.availabilityError = error instanceof Error ? error.message : String(error);\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tgetProviders(): readonly Provider[] {\n\t\tif (this.piServerMode) {\n\t\t\tconst ids = new Set([\n\t\t\t\t...this.models.getProviders().map((provider) => provider.id),\n\t\t\t\t...this.getAllModels().map((model) => model.provider),\n\t\t\t]);\n\t\t\treturn [...ids].flatMap((id) => this.getProvider(id) ?? []);\n\t\t}\n\t\treturn this.models.getProviders();\n\t}\n\n\tgetProvider(providerId: string): Provider | undefined {\n\t\tconst local = this.models.getProvider(providerId);\n\t\tif (!this.piServerMode) return local;\n\t\tconst catalog = this.getAllModels(providerId);\n\t\tif (!local && catalog.length === 0) return undefined;\n\t\tconst capabilities = this.remoteProviderCapabilities.find((provider) => provider.id === providerId);\n\t\treturn {\n\t\t\t...local,\n\t\t\tid: providerId,\n\t\t\tname: local?.name ?? providerId,\n\t\t\tauth: local?.auth ?? {},\n\t\t\tgetModels: () => this.getModels(providerId),\n\t\t\tgetAllModels: () => this.getAllModels(providerId),\n\t\t\tstream: <TApi extends Api>(model: Model<TApi>, context: TranscriptContext, options?: ApiStreamOptions<TApi>) =>\n\t\t\t\tthis.stream(model, context, options as ModelsApiStreamOptions<TApi> | undefined),\n\t\t\tstreamSimple: (model, context, options) => this.streamSimple(model, context, options),\n\t\t\tgenerateImages:\n\t\t\t\tlocal?.generateImages || catalog.some((model) => isModelType(model, \"image\"))\n\t\t\t\t\t? (model, context, options) => this.generateImages(model, context, options)\n\t\t\t\t\t: undefined,\n\t\t\tclassify:\n\t\t\t\tlocal?.classify || catalog.some((model) => isModelType(model, \"classifier\"))\n\t\t\t\t\t? (model, context, options) => this.classify(model, context, options)\n\t\t\t\t\t: undefined,\n\t\t\tfetchDeferred:\n\t\t\t\tlocal?.fetchDeferred || capabilities?.fetchDeferred\n\t\t\t\t\t? (model, handle, options) => this.streamDeferred(model, handle, options)\n\t\t\t\t\t: undefined,\n\t\t\tcancelDeferred:\n\t\t\t\tlocal?.cancelDeferred || capabilities?.cancelDeferred\n\t\t\t\t\t? (model, handle, options) => this.cancelDeferred(model, handle, options)\n\t\t\t\t\t: undefined,\n\t\t};\n\t}\n\n\tgetModels(providerId?: string): readonly Model<Api>[] {\n\t\tif (this.piServerMode) return this.getModelsOfType(\"chat\", providerId);\n\t\treturn this.models.getModels(providerId);\n\t}\n\n\tgetModel(providerId: string, modelId: string): Model<Api> | undefined {\n\t\tif (this.piServerMode) return this.getModelOfType(\"chat\", providerId, modelId);\n\t\treturn this.models.getModel(providerId, modelId);\n\t}\n\n\tgetModelsOfType<TType extends ModelType>(type: TType, providerId?: string): readonly ModelTypeMap[TType][] {\n\t\tif (this.piServerMode) return this.getRemoteModels(false, providerId).filter((model) => isModelType(model, type));\n\t\treturn this.models.getModelsOfType(type, providerId);\n\t}\n\n\tgetModelOfType<TType extends ModelType>(\n\t\ttype: TType,\n\t\tproviderId: string,\n\t\tmodelId: string,\n\t): ModelTypeMap[TType] | undefined {\n\t\tif (this.piServerMode) return this.getModelsOfType(type, providerId).find((model) => model.id === modelId);\n\t\treturn this.models.getModelOfType(type, providerId, modelId);\n\t}\n\n\tgetAllModels(providerId?: string): readonly AnyModel[] {\n\t\tif (this.piServerMode) return this.getRemoteModels(false, providerId);\n\t\treturn this.models.getAllModels(providerId);\n\t}\n\n\tasync getAvailableOfType<TType extends ModelType>(\n\t\ttype: TType,\n\t\tproviderId?: string,\n\t\toptions?: AuthOperationOptions,\n\t): Promise<readonly ModelTypeMap[TType][]> {\n\t\tif (this.piServerMode) {\n\t\t\toptions?.signal?.throwIfAborted();\n\t\t\tawait raceWithAbortSignal(this.registrationRefresh, options?.signal);\n\t\t\tif (!this.remoteCatalogLoaded) await this.refreshRemoteCatalog(options?.signal);\n\t\t\treturn this.getRemoteModels(true, providerId).filter((model) => isModelType(model, type));\n\t\t}\n\t\treturn this.models.getAvailableOfType(type, providerId, options);\n\t}\n\n\tasync getAllAvailable(providerId?: string, options?: AuthOperationOptions): Promise<readonly AnyModel[]> {\n\t\tif (this.piServerMode) {\n\t\t\toptions?.signal?.throwIfAborted();\n\t\t\tawait raceWithAbortSignal(this.registrationRefresh, options?.signal);\n\t\t\tif (!this.remoteCatalogLoaded) await this.refreshRemoteCatalog(options?.signal);\n\t\t\treturn this.getRemoteModels(true, providerId);\n\t\t}\n\t\treturn this.models.getAllAvailable(providerId, options);\n\t}\n\n\tprivate getRemoteModels(available: boolean, providerId?: string): readonly AnyModel[] {\n\t\tif (this.remoteProjection) {\n\t\t\tconst models = available ? this.remoteProjection.available : this.remoteProjection.models;\n\t\t\treturn providerId === undefined ? models : models.filter((model) => model.provider === providerId);\n\t\t}\n\t\tconst catalog = new Map(\n\t\t\tthis.remoteCatalog.models.map((model) => [`${model.type ?? \"chat\"}\\0${model.provider}\\0${model.id}`, model]),\n\t\t);\n\t\tfor (const model of this.localOperationAvailable) {\n\t\t\tconst key = `${model.type ?? \"chat\"}\\0${model.provider}\\0${model.id}`;\n\t\t\tif (!catalog.has(key)) catalog.set(key, model);\n\t\t}\n\t\tconst localAvailableKeys = new Set(\n\t\t\tthis.localOperationAvailable.map((model) => `${model.type ?? \"chat\"}\\0${model.provider}\\0${model.id}`),\n\t\t);\n\t\tfor (const id of this.nativeCatalogProviders) {\n\t\t\tfor (const model of this.models.getAllModels(id)) {\n\t\t\t\tconst key = `${model.type ?? \"chat\"}\\0${model.provider}\\0${model.id}`;\n\t\t\t\tif (!catalog.has(key) || localAvailableKeys.has(key)) catalog.set(key, model);\n\t\t\t}\n\t\t}\n\t\tconst availableKeys = new Set(\n\t\t\tthis.remoteCatalog.available.map((model) => `${model.type ?? \"chat\"}\\0${model.provider}\\0${model.id}`),\n\t\t);\n\t\tfor (const model of this.localOperationAvailable) {\n\t\t\tavailableKeys.add(`${model.type ?? \"chat\"}\\0${model.provider}\\0${model.id}`);\n\t\t}\n\t\tconst overlayProviders = new Set([...this.config.getProviderIds(), ...this.getRegisteredProviderIds()]);\n\t\tfor (const id of overlayProviders) {\n\t\t\tconst native = this.nativeExtensionProviders.get(id);\n\t\t\tconst base = native ?? this.builtins.get(id);\n\t\t\tconst baseModels = native\n\t\t\t\t? (native.getAllModels?.() ?? native.getModels())\n\t\t\t\t: [...catalog.values()].filter((model) => model.provider === id);\n\t\t\tconst provider = composeModelProvider(\n\t\t\t\tid,\n\t\t\t\tbase && {\n\t\t\t\t\t...base,\n\t\t\t\t\tgetModels: () => baseModels.filter((model) => isModelType(model, \"chat\")),\n\t\t\t\t\tgetAllModels: () => baseModels,\n\t\t\t\t},\n\t\t\t\tthis.config,\n\t\t\t\tthis.extensionProviders.get(id),\n\t\t\t);\n\t\t\tfor (const [key, model] of catalog) if (model.provider === id) catalog.delete(key);\n\t\t\tfor (const model of provider.getAllModels?.() ?? provider.getModels()) {\n\t\t\t\tcatalog.set(`${model.type ?? \"chat\"}\\0${model.provider}\\0${model.id}`, model);\n\t\t\t}\n\t\t}\n\t\tconst models = [...catalog.values()];\n\t\tconst availableProviders = new Set(\n\t\t\tmodels\n\t\t\t\t.filter((model) => availableKeys.has(`${model.type ?? \"chat\"}\\0${model.provider}\\0${model.id}`))\n\t\t\t\t.map((model) => model.provider),\n\t\t);\n\t\tconst virtualModels = [...this.virtualModels.values()].flatMap((models) =>\n\t\t\t[...models.values()].map((entry) => entry.model),\n\t\t);\n\t\tconst virtualIds = new Set(virtualModels.map((model) => `${model.provider}\\0${model.id}`));\n\t\tconst physical = models.filter(\n\t\t\t(model) => !isModelType(model, \"chat\") || !virtualIds.has(`${model.provider}\\0${model.id}`),\n\t\t);\n\t\tconst eligibleVirtual = virtualModels.filter(\n\t\t\t(model) =>\n\t\t\t\t!models.some((entry) => entry.provider === model.provider) || availableProviders.has(model.provider),\n\t\t);\n\t\tthis.remoteProjection = {\n\t\t\tmodels: [...physical, ...virtualModels],\n\t\t\tavailable: [\n\t\t\t\t...physical.filter((model) => availableKeys.has(`${model.type ?? \"chat\"}\\0${model.provider}\\0${model.id}`)),\n\t\t\t\t...eligibleVirtual,\n\t\t\t],\n\t\t};\n\t\treturn this.getRemoteModels(available, providerId);\n\t}\n\n\tprivate async refreshRemoteCatalog(signal?: AbortSignal): Promise<void> {\n\t\tconst seq = ++this.remoteCatalogRefreshSeq;\n\t\tconst catalog = await fetchPiServerModels({ signal });\n\t\tif (seq !== this.remoteCatalogRefreshSeq) return;\n\t\tthis.remoteCatalog = catalog;\n\t\tthis.remoteProviderCapabilities = catalog.providers;\n\t\tthis.remoteCatalogLoaded = true;\n\t\tthis.remoteCatalogError = undefined;\n\t\tthis.remoteProjection = undefined;\n\t}\n\n\tasync checkAuth(providerId: string, options?: AuthOperationOptions): Promise<AuthCheck | undefined> {\n\t\treturn this.models.checkAuth(providerId, options);\n\t}\n\n\tasync getAvailable(providerId?: string, options?: AuthOperationOptions): Promise<readonly Model<Api>[]> {\n\t\tif (this.piServerMode) return this.getAvailableOfType(\"chat\", providerId, options);\n\t\tif (providerId) {\n\t\t\tconst errorSeq = ++this.availabilityErrorSeq;\n\t\t\ttry {\n\t\t\t\tconst available = await this.models.getAvailable(providerId, options);\n\t\t\t\tif (errorSeq === this.availabilityErrorSeq) this.availabilityError = undefined;\n\t\t\t\treturn available;\n\t\t\t} catch (error) {\n\t\t\t\tif (errorSeq === this.availabilityErrorSeq && !options?.signal?.aborted) {\n\t\t\t\t\tthis.availabilityError = error instanceof Error ? error.message : String(error);\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t\tawait this.queueAvailabilityRefresh(options?.signal);\n\t\treturn this.snapshot.available;\n\t}\n\n\tgetAvailableSnapshot(): readonly Model<Api>[] {\n\t\tif (this.piServerMode) return this.getRemoteModels(true).filter((model) => isModelType(model, \"chat\"));\n\t\treturn this.snapshot.available;\n\t}\n\n\tgetError(): string | undefined {\n\t\tconst errors: string[] = [];\n\t\tconst configError = this.config.getError();\n\t\tif (configError) errors.push(configError);\n\t\tfor (const [providerId, error] of this.compositionErrors) {\n\t\t\terrors.push(`Provider \"${providerId}\": ${error}`);\n\t\t}\n\t\tif (this.availabilityError) errors.push(`Availability refresh: ${this.availabilityError}`);\n\t\tif (this.remoteCatalogError) errors.push(`pi-server model catalog: ${this.remoteCatalogError}`);\n\t\tfor (const [providerId, error] of this.registrationRefreshErrors)\n\t\t\terrors.push(`Provider \"${providerId}\" refresh: ${error}`);\n\t\treturn errors.length > 0 ? errors.join(\"\\n\\n\") : undefined;\n\t}\n\n\tgetRegisteredProviderConfig(providerId: string): ProviderConfigInput | undefined {\n\t\treturn this.extensionProviders.get(providerId);\n\t}\n\n\tgetRegisteredProviderIds(): readonly string[] {\n\t\treturn [...new Set([...this.extensionProviders.keys(), ...this.nativeExtensionProviders.keys()])];\n\t}\n\n\tgetRegisteredNativeProvider(providerId: string): Provider | undefined {\n\t\treturn this.nativeExtensionProviders.get(providerId);\n\t}\n\n\t/** @internal Compatibility fallback for ModelRegistry when provider auth is unconfigured. */\n\tgetCompatibilityRequestConfig(model: Model<Api>): CompatibilityRequestConfig {\n\t\treturn resolveCompatibilityRequestConfig(\n\t\t\tmodel,\n\t\t\tthis.config.getProvider(model.provider),\n\t\t\tthis.extensionProviders.get(model.provider),\n\t\t);\n\t}\n\n\tisUsingOAuth(providerId: string): boolean {\n\t\treturn this.snapshot.auth.get(providerId)?.type === \"oauth\";\n\t}\n\n\tisUsingSubscription(providerId: string): boolean {\n\t\treturn this.isUsingOAuth(providerId) && this.models.getProvider(providerId)?.auth.oauth?.isSubscription === true;\n\t}\n\n\thasConfiguredAuth(providerId: string): boolean {\n\t\tif (this.piServerMode) return this.getRemoteModels(true, providerId).length > 0;\n\t\treturn this.snapshot.configuredProviders.has(providerId);\n\t}\n\n\tgetAuth(providerId: string, overrides?: ModelRuntimeAuthOverrides): Promise<AuthResult | undefined>;\n\tgetAuth(model: AnyModel, overrides?: ModelRuntimeAuthOverrides): Promise<AuthResult | undefined>;\n\tasync getAuth(\n\t\tproviderOrModel: string | AnyModel,\n\t\toverrides: ModelRuntimeAuthOverrides = {},\n\t): Promise<AuthResult | undefined> {\n\t\tif (typeof providerOrModel === \"string\") return this.models.getAuth(providerOrModel, overrides);\n\t\tconst resolution = await this.models.getAuth(providerOrModel, overrides);\n\t\tif (!resolution) return undefined;\n\t\tconst configuredHeaders = resolveConfiguredModelHeaders(\n\t\t\tproviderOrModel,\n\t\t\tthis.config.getProvider(providerOrModel.provider),\n\t\t\tthis.extensionProviders.get(providerOrModel.provider),\n\t\t\t{ ...(resolution.env ?? {}), ...(overrides.env ?? {}) },\n\t\t);\n\t\treturn {\n\t\t\t...resolution,\n\t\t\tauth: {\n\t\t\t\t...resolution.auth,\n\t\t\t\theaders: mergeHeaders(resolution.auth.headers, configuredHeaders),\n\t\t\t},\n\t\t};\n\t}\n\n\tprivate enqueueCredentialOperation<T>(providerId: string, signal: AbortSignal, task: () => Promise<T>): Promise<T> {\n\t\tconst previous = this.credentialOperations.get(providerId) ?? Promise.resolve();\n\t\tlet markStarted: (() => void) | undefined;\n\t\tconst started = new Promise<void>((resolve) => {\n\t\t\tmarkStarted = resolve;\n\t\t});\n\t\tconst operation = (async () => {\n\t\t\tawait previous.catch(() => {});\n\t\t\tsignal.throwIfAborted();\n\t\t\tmarkStarted?.();\n\t\t\treturn task();\n\t\t})();\n\t\tconst tail = operation.catch(() => {});\n\t\tthis.credentialOperations.set(providerId, tail);\n\t\tvoid tail.then(() => {\n\t\t\tif (this.credentialOperations.get(providerId) === tail) this.credentialOperations.delete(providerId);\n\t\t});\n\t\treturn raceWithAbortSignal(started, signal).then(() => operation);\n\t}\n\n\tprivate async synchronizeCredentialState(\n\t\tproviderId: string,\n\t\toperation: CredentialSynchronizationOperation,\n\t\tcredential: Credential | undefined,\n\t\tsignal: AbortSignal,\n\t): Promise<void> {\n\t\ttry {\n\t\t\tsignal.throwIfAborted();\n\t\t\tthis.recomposeProvider(providerId);\n\t\t\tconst compositionError = this.compositionErrors.get(providerId);\n\t\t\tif (compositionError) throw new Error(compositionError);\n\t\t\tconst result = await this.models.refresh({ allowNetwork: false, providers: [providerId], signal });\n\t\t\tif (result.aborted) signal.throwIfAborted();\n\t\t\tconst refreshError = result.errors.get(providerId);\n\t\t\tif (refreshError) throw refreshError;\n\t\t\tthis.updateModelSnapshot();\n\t\t\tawait this.refreshProviderAvailability(providerId, signal);\n\t\t} catch (cause) {\n\t\t\tthrow new CredentialSynchronizationError(providerId, operation, credential, { cause });\n\t\t}\n\t}\n\n\tsetRuntimeApiKey(providerId: string, apiKey: string, options: AuthOperationOptions = {}): Promise<void> {\n\t\tconst signal = operationSignal(options.signal);\n\t\treturn this.enqueueCredentialOperation(providerId, signal, async () => {\n\t\t\tthis.credentials.setRuntimeApiKey(providerId, apiKey);\n\t\t\tawait this.synchronizeCredentialState(\n\t\t\t\tproviderId,\n\t\t\t\t\"setRuntimeApiKey\",\n\t\t\t\t{ type: \"api_key\", key: apiKey },\n\t\t\t\tsignal,\n\t\t\t);\n\t\t});\n\t}\n\n\tremoveRuntimeApiKey(providerId: string, options: AuthOperationOptions = {}): Promise<void> {\n\t\tconst signal = operationSignal(options.signal);\n\t\treturn this.enqueueCredentialOperation(providerId, signal, async () => {\n\t\t\tthis.credentials.removeRuntimeApiKey(providerId);\n\t\t\tawait this.synchronizeCredentialState(providerId, \"removeRuntimeApiKey\", undefined, signal);\n\t\t});\n\t}\n\n\tlistCredentials(options?: AuthOperationOptions): Promise<readonly CredentialInfo[]> {\n\t\treturn this.credentials.list(options);\n\t}\n\n\tgetProviderAuthStatus(providerId: string): AuthStatus {\n\t\tif (this.credentials.hasRuntimeApiKey(providerId)) return { configured: true, source: \"runtime\" };\n\t\tif (this.snapshot.storedProviders.has(providerId)) return { configured: true, source: \"stored\" };\n\t\tconst configured = configuredRequestAuthStatus(\n\t\t\tthis.config.getProvider(providerId),\n\t\t\tthis.extensionProviders.get(providerId),\n\t\t);\n\t\tif (configured) return configured;\n\t\tconst check = this.snapshot.auth.get(providerId);\n\t\treturn check ? { configured: true, source: \"environment\", label: check.source } : { configured: false };\n\t}\n\n\tprivate async prepareRequest<\n\t\tTModel extends AnyModel,\n\t\tTOptions extends ProviderRequestOptions<TModel> & ModelsRequestTransforms,\n\t>(\n\t\tmodel: TModel,\n\t\toptions: TOptions | undefined,\n\t): Promise<{\n\t\tprovider: Provider;\n\t\tmodel: TModel;\n\t\toptions: Omit<TOptions, \"transformHeaders\"> & ProviderRequestOptions<TModel>;\n\t}> {\n\t\tconst provider = this.models.getProvider(model.provider);\n\t\tif (!provider) throw new ModelsError(\"provider\", `Unknown provider: ${model.provider}`);\n\t\tconst resolution = await this.getAuth(model, {\n\t\t\tapiKey: options?.apiKey,\n\t\t\tenv: options?.env,\n\t\t\tsignal: options?.signal,\n\t\t});\n\t\tif (!resolution) throw new ModelsError(\"auth\", `Provider is not configured: ${model.provider}`);\n\n\t\tconst { transformHeaders, ...rawProviderOptions } = options ?? {};\n\t\tconst providerOptions = rawProviderOptions as Omit<TOptions, \"transformHeaders\"> & ProviderRequestOptions<TModel>;\n\t\tlet headers = mergeHeaders(resolution.auth.headers, providerOptions.headers);\n\t\tif (transformHeaders) headers = await transformHeaders(headers ?? {});\n\t\tconst env =\n\t\t\tresolution.env || providerOptions.env\n\t\t\t\t? { ...(resolution.env ?? {}), ...(providerOptions.env ?? {}) }\n\t\t\t\t: undefined;\n\t\tconst requestModel: TModel = resolution.auth.baseUrl ? { ...model, baseUrl: resolution.auth.baseUrl } : model;\n\t\treturn {\n\t\t\tprovider,\n\t\t\tmodel: requestModel,\n\t\t\toptions: {\n\t\t\t\t...providerOptions,\n\t\t\t\tapiKey: providerOptions.apiKey ?? resolution.auth.apiKey,\n\t\t\t\theaders,\n\t\t\t\tenv,\n\t\t\t} as Omit<TOptions, \"transformHeaders\"> & ProviderRequestOptions<TModel>,\n\t\t};\n\t}\n\n\tprivate async prepareRemoteRequest<\n\t\tTModel extends AnyModel,\n\t\tTOptions extends ProviderRequestOptions<TModel> & ModelsRequestTransforms,\n\t>(model: TModel, options: TOptions | undefined): Promise<{ model: TModel; options: TOptions }> {\n\t\tif (options?.fetch !== undefined)\n\t\t\tthrow new ModelsError(\"stream\", \"pi-server does not support custom fetch implementations\");\n\t\tif (\n\t\t\toptions &&\n\t\t\t\"transformPreparedStreamOptions\" in options &&\n\t\t\toptions.transformPreparedStreamOptions !== undefined\n\t\t)\n\t\t\tthrow new ModelsError(\"stream\", \"pi-server does not support client prepared stream option transforms\");\n\t\tconst resolution = this.models.getProvider(model.provider)\n\t\t\t? await this.getAuth(model, { apiKey: options?.apiKey, env: options?.env, signal: options?.signal })\n\t\t\t: undefined;\n\t\tlet headers = mergeHeaders(mergeHeaders(model.headers, resolution?.auth.headers), options?.headers);\n\t\tconst { transformHeaders, ...remoteOptions } = options ?? {};\n\t\tif (transformHeaders) headers = await transformHeaders(headers ?? {});\n\t\treturn {\n\t\t\tmodel: resolution?.auth.baseUrl ? { ...model, baseUrl: resolution.auth.baseUrl } : model,\n\t\t\toptions: {\n\t\t\t\t...remoteOptions,\n\t\t\t\tapiKey: options?.apiKey ?? resolution?.auth.apiKey,\n\t\t\t\theaders,\n\t\t\t\tenv: resolution?.env || options?.env ? { ...resolution?.env, ...options?.env } : undefined,\n\t\t\t} as TOptions,\n\t\t};\n\t}\n\n\tprivate async prepareStreamRequest<TOptions extends ProviderRequestOptions<Model<Api>>>(\n\t\tmodel: Model<Api>,\n\t\toptions: (TOptions & ModelsStreamRequestTransforms<TOptions>) | undefined,\n\t): Promise<{ provider: Provider; model: Model<Api>; options: TOptions }> {\n\t\tconst { transformPreparedStreamOptions, ...authOptions } = options ?? {};\n\t\tconst prepared = await this.prepareRequest(model, authOptions);\n\t\treturn {\n\t\t\tprovider: prepared.provider,\n\t\t\tmodel: prepared.model,\n\t\t\toptions: transformPreparedStreamOptions\n\t\t\t\t? await transformPreparedStreamOptions(prepared.options as TOptions, prepared.model)\n\t\t\t\t: (prepared.options as TOptions),\n\t\t};\n\t}\n\n\tstream<TApi extends Api>(\n\t\tmodel: Model<TApi>,\n\t\tcontext: Context,\n\t\toptions?: ModelsApiStreamOptions<TApi>,\n\t): AssistantMessageEventStream {\n\t\tconst transcript = normalizeContext(context);\n\t\treturn lazyStream(model, async () => {\n\t\t\tassertChatModel(model);\n\t\t\tif (this.piServerMode) {\n\t\t\t\tif (isVirtualModel(model))\n\t\t\t\t\tthrow new ModelsError(\n\t\t\t\t\t\t\"stream\",\n\t\t\t\t\t\t`Virtual model ${model.provider}/${model.id} must be routed before streaming`,\n\t\t\t\t\t);\n\t\t\t\tconst prepared = await this.prepareRemoteRequest(model, options);\n\t\t\t\treturn streamRawPiServer(prepared.model, transcript, prepared.options);\n\t\t\t}\n\t\t\tconst prepared = await this.prepareStreamRequest(model, options);\n\t\t\treturn prepared.provider.stream(prepared.model, transcript, prepared.options as ApiStreamOptions<TApi>);\n\t\t});\n\t}\n\n\tcomplete<TApi extends Api>(\n\t\tmodel: Model<TApi>,\n\t\tcontext: Context,\n\t\toptions?: ModelsApiStreamOptions<TApi>,\n\t): Promise<AssistantMessage> {\n\t\treturn this.stream(model, context, options).result();\n\t}\n\n\tstreamSimple(model: Model<Api>, context: Context, options?: ModelsSimpleStreamOptions): AssistantMessageEventStream {\n\t\tconst transcript = normalizeContext(context);\n\t\tif (isVirtualModel(model)) {\n\t\t\t// Requests outside the agent loop are routed here. Callers sized them before routing, so\n\t\t\t// cap the output budget to the routed model.\n\t\t\treturn lazyStream(model, async () => {\n\t\t\t\tconst route = await this.resolveModel(model, transcript.messages, {\n\t\t\t\t\treason: \"direct\",\n\t\t\t\t\tthinkingLevel: options?.reasoning ?? \"off\",\n\t\t\t\t\tsignal: options?.signal,\n\t\t\t\t});\n\t\t\t\tconst { maxTokens: limit } = route.model;\n\t\t\t\tconst maxTokens = options?.maxTokens && limit > 0 ? Math.min(options.maxTokens, limit) : options?.maxTokens;\n\t\t\t\tconst reasoning = route.thinkingLevel === \"off\" ? undefined : route.thinkingLevel;\n\t\t\t\t// Caller credentials were resolved for the virtual model's provider. Another provider\n\t\t\t\t// resolves its own, so they are not sent to the wrong vendor.\n\t\t\t\tconst { apiKey, headers, env, ...rest } = options ?? {};\n\t\t\t\tconst auth = route.model.provider === model.provider ? { apiKey, headers, env } : {};\n\t\t\t\treturn this.streamSimple(route.model, context, { ...rest, ...auth, maxTokens, reasoning });\n\t\t\t});\n\t\t}\n\t\treturn lazyStream(model, async () => {\n\t\t\tassertChatModel(model);\n\t\t\tif (this.piServerMode) {\n\t\t\t\tconst prepared = await this.prepareRemoteRequest(model, options);\n\t\t\t\treturn streamPiServer(prepared.model, transcript, prepared.options);\n\t\t\t}\n\t\t\tconst prepared = await this.prepareStreamRequest(model, options);\n\t\t\treturn prepared.provider.streamSimple(prepared.model, transcript, prepared.options as SimpleStreamOptions);\n\t\t});\n\t}\n\n\tcompleteSimple(model: Model<Api>, context: Context, options?: ModelsSimpleStreamOptions): Promise<AssistantMessage> {\n\t\treturn this.streamSimple(model, context, options).result();\n\t}\n\n\tstreamDeferred(\n\t\tmodel: Model<Api>,\n\t\thandle: DeferredHandle,\n\t\toptions?: ModelsDeferredFetchOptions,\n\t): AssistantMessageEventStream {\n\t\treturn lazyStream(model, async () => {\n\t\t\tassertChatModel(model);\n\t\t\tif (this.piServerMode) {\n\t\t\t\tconst prepared = await this.prepareRemoteRequest(model, options);\n\t\t\t\treturn fetchDeferredPiServer(prepared.model, handle, prepared.options);\n\t\t\t}\n\t\t\tconst prepared = await this.prepareStreamRequest(model, options);\n\t\t\tif (!prepared.provider.fetchDeferred) {\n\t\t\t\tthrow new ModelsError(\"provider\", `Provider ${model.provider} does not support deferred responses`);\n\t\t\t}\n\t\t\treturn prepared.provider.fetchDeferred(prepared.model, handle, prepared.options as DeferredFetchOptions);\n\t\t});\n\t}\n\n\tasync fetchDeferred(\n\t\tmodel: Model<Api>,\n\t\thandle: DeferredHandle,\n\t\toptions?: ModelsDeferredFetchOptions,\n\t): Promise<AssistantMessage> {\n\t\treturn this.streamDeferred(model, handle, options).result();\n\t}\n\n\tasync cancelDeferred(\n\t\tmodel: Model<Api>,\n\t\thandle: DeferredHandle,\n\t\toptions?: ModelsDeferredCancelOptions,\n\t): Promise<void> {\n\t\tassertChatModel(model);\n\t\tif (this.piServerMode) {\n\t\t\tconst prepared = await this.prepareRemoteRequest(model, options);\n\t\t\tawait cancelDeferredPiServer(prepared.model, handle, prepared.options);\n\t\t\treturn;\n\t\t}\n\t\tconst prepared = await this.prepareRequest(model, options);\n\t\tif (!prepared.provider.cancelDeferred) {\n\t\t\tthrow new ModelsError(\"provider\", `Provider ${model.provider} does not support deferred responses`);\n\t\t}\n\t\tawait prepared.provider.cancelDeferred(prepared.model, handle, prepared.options as DeferredCancelOptions);\n\t}\n\n\tasync generateImages(\n\t\tmodel: ImageModel<ImageApi>,\n\t\tcontext: ImagesContext,\n\t\toptions?: ModelsImagesOptions,\n\t): Promise<AssistantImages> {\n\t\ttry {\n\t\t\tassertImageModel(model);\n\t\t\tif (this.piServerMode) {\n\t\t\t\tconst prepared = await this.prepareRemoteRequest(model, options);\n\t\t\t\treturn await generateImagesPiServer(prepared.model, context, prepared.options);\n\t\t\t}\n\t\t\tconst prepared = await this.prepareRequest(model, options);\n\t\t\tif (!prepared.provider.generateImages) {\n\t\t\t\tthrow new ModelsError(\"provider\", `Provider ${model.provider} does not support image generation`);\n\t\t\t}\n\t\t\treturn await prepared.provider.generateImages(prepared.model, context, prepared.options as ImagesOptions);\n\t\t} catch (error) {\n\t\t\treturn imageErrorResult(model, error, options?.signal?.aborted);\n\t\t}\n\t}\n\n\tasync classify(\n\t\tmodel: ClassifierModel<ClassifierApi>,\n\t\tcontext: ClassifierContext,\n\t\toptions?: ModelsClassifierOptions,\n\t): Promise<ClassifierResult> {\n\t\ttry {\n\t\t\tassertClassifierModel(model);\n\t\t\tif (this.piServerMode) {\n\t\t\t\tconst prepared = await this.prepareRemoteRequest(model, options);\n\t\t\t\treturn await classifyPiServer(prepared.model, context, prepared.options);\n\t\t\t}\n\t\t\tconst prepared = await this.prepareRequest(model, options);\n\t\t\tif (!prepared.provider.classify) {\n\t\t\t\tthrow new ModelsError(\"provider\", `Provider ${model.provider} does not support classification`);\n\t\t\t}\n\t\t\treturn await prepared.provider.classify(prepared.model, context, prepared.options as ClassifierOptions);\n\t\t} catch (error) {\n\t\t\treturn classifierErrorResult(model, error, options?.signal?.aborted);\n\t\t}\n\t}\n\n\tlogin(\n\t\tproviderId: string,\n\t\ttype: AuthType,\n\t\tinteraction: AuthInteraction,\n\t\toptions?: LoginOptions,\n\t): Promise<Credential> {\n\t\tconst signal = operationSignal(interaction.signal);\n\t\treturn this.enqueueCredentialOperation(providerId, signal, async () => {\n\t\t\tconst credential = await this.models.login(providerId, type, { ...interaction, signal }, options);\n\t\t\tawait this.synchronizeCredentialState(providerId, \"login\", credential, signal);\n\t\t\treturn credential;\n\t\t});\n\t}\n\n\tlogout(providerId: string, options: AuthOperationOptions = {}): Promise<void> {\n\t\tconst signal = operationSignal(options.signal);\n\t\treturn this.enqueueCredentialOperation(providerId, signal, async () => {\n\t\t\tawait this.models.logout(providerId, { signal });\n\t\t\tawait this.synchronizeCredentialState(providerId, \"logout\", undefined, signal);\n\t\t});\n\t}\n\n\tasync refresh(options: ModelsRefreshOptions = {}): Promise<ModelsRefreshResult> {\n\t\tif (options.signal?.aborted) return { aborted: true, errors: new Map() };\n\t\ttry {\n\t\t\tawait raceWithAbortSignal(this.registrationRefresh, options.signal);\n\t\t} catch (error) {\n\t\t\tif (options.signal?.aborted) return { aborted: true, errors: new Map() };\n\t\t\tthrow error;\n\t\t}\n\t\tif (this.piServerMode) {\n\t\t\tthis.config = await ModelConfig.load(this.modelsPath);\n\t\t\tthis.configureRadiusProviders();\n\t\t\tthis.rebuildProviders();\n\t\t\tlet result = await this.models.refresh({ ...options, allowNetwork: false });\n\t\t\tconst nativeProviders = [\n\t\t\t\t...new Set([...this.nativeCatalogProviders, ...this.nativeExtensionProviders.keys()]),\n\t\t\t].filter((id) => options.providers === undefined || options.providers.includes(id));\n\t\t\tif ((options.allowNetwork ?? this.modelNetworkEnabled) && nativeProviders.length > 0) {\n\t\t\t\tconst nativeResult = await this.models.refresh({\n\t\t\t\t\t...options,\n\t\t\t\t\tproviders: nativeProviders,\n\t\t\t\t\tallowNetwork: true,\n\t\t\t\t});\n\t\t\t\tresult = {\n\t\t\t\t\taborted: result.aborted || nativeResult.aborted,\n\t\t\t\t\terrors: new Map([...result.errors, ...nativeResult.errors]),\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst errors = new Map(result.errors);\n\t\t\ttry {\n\t\t\t\tawait this.queueAvailabilityRefresh(options.signal);\n\t\t\t} catch (error) {\n\t\t\t\tif (!options.signal?.aborted)\n\t\t\t\t\terrors.set(\"availability\", error instanceof Error ? error : new Error(String(error)));\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tif (!options.signal?.aborted) await this.refreshRemoteCatalog(options.signal);\n\t\t\t} catch (error) {\n\t\t\t\tif (!options.signal?.aborted) {\n\t\t\t\t\tconst remoteError = error instanceof Error ? error : new Error(String(error));\n\t\t\t\t\tthis.remoteCatalogError = remoteError.message;\n\t\t\t\t\terrors.set(\"pi-server\", remoteError);\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (const id of this.registrationRefreshErrors.keys()) {\n\t\t\t\tif (!errors.has(id) && (options.providers === undefined || options.providers.includes(id)))\n\t\t\t\t\tthis.registrationRefreshErrors.delete(id);\n\t\t\t}\n\t\t\treturn { aborted: result.aborted || options.signal?.aborted === true, errors };\n\t\t}\n\t\tthis.config = await ModelConfig.load(this.modelsPath);\n\t\tthis.configureRadiusProviders();\n\t\tif (options.providers) {\n\t\t\tfor (const providerId of new Set(options.providers)) this.recomposeProvider(providerId);\n\t\t\tthis.updateModelSnapshot();\n\t\t} else {\n\t\t\tthis.rebuildProviders();\n\t\t}\n\t\tconst refreshOptions = {\n\t\t\t...options,\n\t\t\tallowNetwork: options.allowNetwork ?? this.modelNetworkEnabled,\n\t\t};\n\t\tconst result = await this.models.refresh(refreshOptions);\n\t\tconst errors = new Map(result.errors);\n\t\tthis.updateModelSnapshot();\n\t\tif (options.providers) {\n\t\t\tawait Promise.all(\n\t\t\t\t[...new Set(options.providers)].map(async (providerId) => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait this.refreshProviderAvailability(providerId, operationSignal(options.signal));\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tif (!options.signal?.aborted) {\n\t\t\t\t\t\t\terrors.set(providerId, error instanceof Error ? error : new Error(String(error)));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t);\n\t\t} else {\n\t\t\ttry {\n\t\t\t\tawait this.queueAvailabilityRefresh(options.signal);\n\t\t\t} catch {\n\t\t\t\t// Availability errors are recorded by the latest pass; refreshed models remain usable.\n\t\t\t}\n\t\t}\n\t\treturn { aborted: result.aborted || (options.signal?.aborted ?? false), errors };\n\t}\n\n\tprivate queueRegistrationRefresh(providerId: string): void {\n\t\tthis.registrationRefresh = this.registrationRefresh\n\t\t\t.then(async () => {\n\t\t\t\tconst result = await this.models.refresh({ allowNetwork: false, providers: [providerId] });\n\t\t\t\tconst error = result.errors.get(providerId);\n\t\t\t\tif (error) throw error;\n\t\t\t\tthis.updateModelSnapshot();\n\t\t\t\tawait this.refreshProviderAvailability(providerId, operationSignal());\n\t\t\t\tthis.registrationRefreshErrors.delete(providerId);\n\t\t\t})\n\t\t\t.catch((error: unknown) => {\n\t\t\t\tthis.registrationRefreshErrors.set(providerId, error instanceof Error ? error.message : String(error));\n\t\t\t});\n\t}\n\n\tregisterNativeProvider(provider: Provider): void {\n\t\tif (!provider.id.trim()) throw new Error(\"Provider id must not be empty.\");\n\t\tthis.extensionProviders.delete(provider.id);\n\t\tthis.nativeExtensionProviders.set(provider.id, provider);\n\t\tthis.recomposeProvider(provider.id);\n\t\tthis.updateModelSnapshot();\n\t\tthis.markProvisionallyConfigured(\n\t\t\tprovider.id,\n\t\t\tconfiguredRequestAuthStatus(this.config.getProvider(provider.id), undefined),\n\t\t\tprovider.auth.oauth && !provider.auth.apiKey ? \"oauth\" : \"api_key\",\n\t\t);\n\t\tthis.queueRegistrationRefresh(provider.id);\n\t}\n\n\t/**\n\t * Mark a newly registered provider as configured when it has a stored credential or a configured\n\t * API key. Availability checks run asynchronously, and callers such as initial model selection\n\t * read the snapshot before they finish. The next availability pass replaces this entry.\n\t */\n\tprivate markProvisionallyConfigured(\n\t\tproviderId: string,\n\t\tconfiguredStatus: AuthStatus | undefined,\n\t\ttype: AuthType,\n\t): void {\n\t\tif (!this.snapshot.storedProviders.has(providerId) && !configuredStatus?.configured) return;\n\t\tconst configuredProviders = new Set(this.snapshot.configuredProviders).add(providerId);\n\t\tconst auth = new Map(this.snapshot.auth);\n\t\t// Never clobber a real check result.\n\t\tif (!auth.get(providerId)) auth.set(providerId, { type, source: \"configured provider\" });\n\t\tthis.snapshot = {\n\t\t\t...this.snapshot,\n\t\t\tauth,\n\t\t\tconfiguredProviders,\n\t\t\tavailable: this.snapshot.all.filter((model) => configuredProviders.has(model.provider)),\n\t\t};\n\t}\n\n\tregisterProvider(providerId: string, config: ProviderConfigInput): void {\n\t\t// Validate the incoming registration on its own, like the legacy registry:\n\t\t// a broken re-registration must throw without touching the stored config.\n\t\tvalidateExtensionProvider(providerId, this.builtins.get(providerId), this.config.getProvider(providerId), config);\n\t\tthis.nativeExtensionProviders.delete(providerId);\n\t\t// Re-registration merges defined values over the previous registration and\n\t\t// preserves undefined ones, matching the legacy ModelRegistry contract.\n\t\tconst previous = this.extensionProviders.get(providerId);\n\t\tconst effective: ProviderConfigInput = { ...previous };\n\t\tfor (const [key, value] of Object.entries(config)) {\n\t\t\tif (value !== undefined) (effective as Record<string, unknown>)[key] = value;\n\t\t}\n\t\tthis.extensionProviders.set(providerId, effective);\n\t\tthis.recomposeProvider(providerId);\n\t\tthis.updateModelSnapshot();\n\t\tthis.markProvisionallyConfigured(\n\t\t\tproviderId,\n\t\t\tconfiguredRequestAuthStatus(this.config.getProvider(providerId), effective),\n\t\t\teffective.oauth && !effective.apiKey ? \"oauth\" : \"api_key\",\n\t\t);\n\t\tthis.queueRegistrationRefresh(providerId);\n\t}\n\n\tunregisterProvider(providerId: string): void {\n\t\tthis.extensionProviders.delete(providerId);\n\t\tthis.nativeExtensionProviders.delete(providerId);\n\t\tthis.recomposeProvider(providerId);\n\t\tthis.updateModelSnapshot();\n\t\tthis.queueRegistrationRefresh(providerId);\n\t}\n\n\t/**\n\t * Register a virtual model under `definition.provider`, which may also list physical models or\n\t * several virtual models. Re-registering the same provider and id replaces the virtual model.\n\t * Throws when the id belongs to a physical model of that provider.\n\t */\n\tregisterVirtualModel(definition: VirtualModelDefinition): void {\n\t\tconst { provider: providerId, id } = definition;\n\t\tif (!providerId.trim() || !id.trim()) throw new Error(\"Virtual model provider and id must not be empty.\");\n\t\tconst existing = this.getModel(providerId, id);\n\t\tif (existing && !isVirtualModel(existing)) {\n\t\t\tthrow new Error(`Virtual model ${providerId}/${id} conflicts with a physical model.`);\n\t\t}\n\t\tconst models = this.virtualModels.get(providerId) ?? new Map<string, RegisteredVirtualModel>();\n\t\tmodels.set(id, { model: createVirtualModel(definition), route: (request) => definition.route(request) });\n\t\tthis.virtualModels.set(providerId, models);\n\t\tif (!this.recomposeProvider(providerId) && !this.snapshot.configuredProviders.has(providerId)) {\n\t\t\t// A provider of only virtual models needs no credentials. Mark it configured now: session\n\t\t\t// restore checks auth before the refresh below lands.\n\t\t\tconst auth = new Map(this.snapshot.auth).set(providerId, { type: \"api_key\", source: \"virtual\" });\n\t\t\tconst configuredProviders = new Set(this.snapshot.configuredProviders).add(providerId);\n\t\t\tthis.snapshot = { ...this.snapshot, auth, configuredProviders };\n\t\t}\n\t\tthis.updateModelSnapshot();\n\t\tthis.queueRegistrationRefresh(providerId);\n\t}\n\n\tunregisterVirtualModel(providerId: string, id: string): void {\n\t\tconst models = this.virtualModels.get(providerId);\n\t\tif (!models?.delete(id)) return;\n\t\tif (models.size === 0) this.virtualModels.delete(providerId);\n\t\tthis.recomposeProvider(providerId);\n\t\tthis.updateModelSnapshot();\n\t\tthis.queueRegistrationRefresh(providerId);\n\t}\n\n\t/**\n\t * Ask a virtual model's router for the model and thinking level of one request. The router must\n\t * return a physical catalog model whose provider has credentials; the thinking level is clamped\n\t * to that model. Throws when routing fails.\n\t *\n\t * `previous` reports the latest successful response in `messages`. A retry passes the failed\n\t * response as `options.failed`; `messages` no longer contains it. `options.state` is the router\n\t * state stored by the caller, which also stores the returned state.\n\t */\n\tasync resolveModel(\n\t\tmodel: Model<Api>,\n\t\tmessages: readonly Message[],\n\t\toptions: {\n\t\t\treason: ModelRouteReason;\n\t\t\tthinkingLevel: ModelThinkingLevel;\n\t\t\tsignal?: AbortSignal;\n\t\t\tfailed?: AssistantMessage;\n\t\t\tstate?: unknown;\n\t\t},\n\t): Promise<ModelRoute> {\n\t\tconst name = `Virtual model ${model.provider}/${model.id}`;\n\t\tconst virtual = this.virtualModels.get(model.provider)?.get(model.id);\n\t\tif (!virtual) throw new Error(`${name} is not registered.`);\n\t\tconst { failed, ...request } = options;\n\t\tconst latest = findLatestResponse(messages);\n\t\tconst previousModel = latest && this.getPhysicalModel(latest.provider, latest.model);\n\t\t// A failed routing attempt names the virtual model; there is no physical request to report.\n\t\tconst failedModel = failed && this.getPhysicalModel(failed.provider, failed.model);\n\t\tconst route = await virtual.route({\n\t\t\t...request,\n\t\t\tmodel,\n\t\t\tprevious: previousModel && { model: previousModel, thinkingLevel: latest?.thinkingLevel },\n\t\t\tfailed: failedModel && failed && { model: failedModel, thinkingLevel: failed.thinkingLevel, message: failed },\n\t\t\tmessages,\n\t\t});\n\t\tconst target = this.getPhysicalModel(route.model.provider, route.model.id);\n\t\tconst routed = `${name} routed to ${route.model.provider}/${route.model.id}`;\n\t\tif (!target) throw new Error(`${routed}, which is not a physical model.`);\n\t\tif (!this.hasConfiguredAuth(target.provider)) throw new Error(`${routed}, which has no credentials.`);\n\t\treturn { model: target, thinkingLevel: clampThinkingLevel(target, route.thinkingLevel), state: route.state };\n\t}\n\n\t/** A catalog chat model that is not virtual. */\n\tgetPhysicalModel(providerId: string, modelId: string): Model<Api> | undefined {\n\t\tconst model = this.getModel(providerId, modelId);\n\t\treturn model && !isVirtualModel(model) ? model : undefined;\n\t}\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import type { CompactionPreparationOptions, LegacyCompactResult, SessionTreeEntry } from "@earendil-works/pi-agent-core";
2
- import { type AssistantMessage, type AssistantMessageEvent, type Context, EventStream, type Message, type Model, type SimpleStreamOptions } from "@earendil-works/pi-ai";
2
+ import { type AnyModel, type AssistantImages, type AssistantMessage, type AssistantMessageEvent, type AuthOperationOptions, type CacheRetention, type ClassifierApi, type ClassifierContext, type ClassifierModel, type ClassifierOptions, type ClassifierResult, type Context, type DeferredCancelOptions, type DeferredFetchOptions, type DeferredHandle, EventStream, type ImageApi, type ImageModel, type ImagesContext, type ImagesOptions, type Message, type Model, type ModelsApiStreamOptions, type SimpleStreamOptions, type StreamOptions } from "@earendil-works/pi-ai";
3
3
  declare class PiServerEventStream extends EventStream<AssistantMessageEvent, AssistantMessage> {
4
4
  constructor();
5
5
  }
@@ -28,6 +28,11 @@ export interface PiServerHistorySnapshot {
28
28
  messages: Message[];
29
29
  }
30
30
  export interface PiServerStreamOptions extends SimpleStreamOptions {
31
+ requireCacheRetention?: boolean;
32
+ onCacheRetentionResolved?: (retention: CacheRetention) => void | Promise<void>;
33
+ requestKind?: "api" | "simple" | "deferred";
34
+ deferredHandle?: DeferredHandle;
35
+ apiOptions?: StreamOptions;
31
36
  ownerSessionId?: string;
32
37
  sessionTree?: PiServerTreeSnapshot;
33
38
  ephemeralMessages?: Message[];
@@ -39,6 +44,9 @@ interface PiServerSyncOptions {
39
44
  onHistoryReconciled?: (snapshot: PiServerHistorySnapshot) => void | Promise<void>;
40
45
  }
41
46
  export declare function syncPiServerTree(sessionId: string, context: Context, tree: PiServerTreeSnapshot, options?: PiServerSyncOptions): Promise<void>;
47
+ export declare function streamRawPiServer<TApi extends string>(model: Model<TApi>, context: Context, options?: ModelsApiStreamOptions<TApi>): Promise<PiServerEventStream>;
48
+ export declare function fetchDeferredPiServer(model: Model<string>, handle: DeferredHandle, options?: DeferredFetchOptions): Promise<PiServerEventStream>;
49
+ export declare function cancelDeferredPiServer(model: Model<string>, handle: DeferredHandle, options?: DeferredCancelOptions): Promise<void>;
42
50
  export interface PiServerCompactOptions extends SimpleStreamOptions {
43
51
  ownerSessionId?: string;
44
52
  customInstructions?: string;
@@ -55,4 +63,16 @@ export interface PiServerCompactOptions extends SimpleStreamOptions {
55
63
  export declare function compactPiServer(model: Model<any>, context: Context, options?: PiServerCompactOptions): Promise<PiServerCompactionResult>;
56
64
  export declare function streamPiServer(model: Model<any>, context: Context, options?: PiServerStreamOptions): Promise<PiServerEventStream>;
57
65
  export { getServerUrl, getAuthToken };
66
+ export interface PiServerModelCatalog {
67
+ models: AnyModel[];
68
+ available: AnyModel[];
69
+ providers: {
70
+ id: string;
71
+ fetchDeferred: boolean;
72
+ cancelDeferred: boolean;
73
+ }[];
74
+ }
75
+ export declare function fetchPiServerModels(options?: AuthOperationOptions): Promise<PiServerModelCatalog>;
76
+ export declare function generateImagesPiServer(model: ImageModel<ImageApi>, context: ImagesContext, options?: ImagesOptions): Promise<AssistantImages>;
77
+ export declare function classifyPiServer(model: ClassifierModel<ClassifierApi>, context: ClassifierContext, options?: ClassifierOptions): Promise<ClassifierResult>;
58
78
  //# sourceMappingURL=pi-server-client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pi-server-client.d.ts","sourceRoot":"","sources":["../../src/core/pi-server-client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACX,4BAA4B,EAC5B,mBAAmB,EAEnB,gBAAgB,EAChB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACN,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAC1B,KAAK,OAAO,EACZ,WAAW,EACX,KAAK,OAAO,EACZ,KAAK,KAAK,EAEV,KAAK,mBAAmB,EACxB,MAAM,uBAAuB,CAAC;AAQ/B,cAAM,mBAAoB,SAAQ,WAAW,CAAC,qBAAqB,EAAE,gBAAgB,CAAC;IACrF,cASC;CACD;AAED,iBAAS,YAAY,IAAI,MAAM,CAE9B;AAED,iBAAS,YAAY,IAAI,MAAM,CAE9B;AAwCD,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAEtD;AAuBD,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAM5D;AAED,wBAAgB,uBAAuB,IAAI,IAAI,CAO9C;AAsFD,6GAA6G;AAC7G,wBAAsB,wBAAwB,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA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