@draht/ai 2026.11.19 → 2026.11.21

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 (76) hide show
  1. package/dist/api/bedrock-converse-stream.d.ts.map +1 -1
  2. package/dist/api/bedrock-converse-stream.js +9 -1
  3. package/dist/api/bedrock-converse-stream.js.map +1 -1
  4. package/dist/api/classifier-shared.d.ts +2 -0
  5. package/dist/api/classifier-shared.d.ts.map +1 -1
  6. package/dist/api/classifier-shared.js +10 -5
  7. package/dist/api/classifier-shared.js.map +1 -1
  8. package/dist/api/google-generative-ai.js +1 -1
  9. package/dist/api/google-generative-ai.js.map +1 -1
  10. package/dist/api/google-shared.d.ts +5 -2
  11. package/dist/api/google-shared.d.ts.map +1 -1
  12. package/dist/api/google-shared.js +10 -6
  13. package/dist/api/google-shared.js.map +1 -1
  14. package/dist/api/google-vertex.js +1 -1
  15. package/dist/api/google-vertex.js.map +1 -1
  16. package/dist/api/mistral-conversations.js +4 -3
  17. package/dist/api/mistral-conversations.js.map +1 -1
  18. package/dist/api/openai-codex-responses.d.ts.map +1 -1
  19. package/dist/api/openai-codex-responses.js +39 -20
  20. package/dist/api/openai-codex-responses.js.map +1 -1
  21. package/dist/api/openai-completions.js +4 -2
  22. package/dist/api/openai-completions.js.map +1 -1
  23. package/dist/api/openai-responses-shared.d.ts +0 -1
  24. package/dist/api/openai-responses-shared.d.ts.map +1 -1
  25. package/dist/api/openai-responses-shared.js +43 -17
  26. package/dist/api/openai-responses-shared.js.map +1 -1
  27. package/dist/models.d.ts.map +1 -1
  28. package/dist/models.js +25 -14
  29. package/dist/models.js.map +1 -1
  30. package/dist/providers/compat-schema.d.ts +14 -0
  31. package/dist/providers/compat-schema.d.ts.map +1 -1
  32. package/dist/providers/compat-schema.js +19 -3
  33. package/dist/providers/compat-schema.js.map +1 -1
  34. package/dist/providers/data/.manifest.json +1 -1
  35. package/dist/providers/data/amazon-bedrock.json +1 -1
  36. package/dist/providers/data/ant-ling.json +1 -1
  37. package/dist/providers/data/azure.json +1 -1
  38. package/dist/providers/data/baseten.json +1 -1
  39. package/dist/providers/data/cerebras.json +1 -1
  40. package/dist/providers/data/cloudflare-ai-gateway.json +1 -1
  41. package/dist/providers/data/cloudflare-workers-ai.json +1 -1
  42. package/dist/providers/data/deepseek.json +1 -1
  43. package/dist/providers/data/fireworks.json +1 -1
  44. package/dist/providers/data/github-copilot.json +1 -1
  45. package/dist/providers/data/google-vertex.json +1 -1
  46. package/dist/providers/data/google.json +1 -1
  47. package/dist/providers/data/huggingface.json +1 -1
  48. package/dist/providers/data/kimi-coding.json +1 -1
  49. package/dist/providers/data/mistral.json +1 -1
  50. package/dist/providers/data/moonshotai-cn.json +1 -1
  51. package/dist/providers/data/moonshotai.json +1 -1
  52. package/dist/providers/data/nvidia.json +1 -1
  53. package/dist/providers/data/openai-codex.json +1 -1
  54. package/dist/providers/data/openai.json +1 -1
  55. package/dist/providers/data/opencode-go.json +1 -1
  56. package/dist/providers/data/opencode.json +1 -1
  57. package/dist/providers/data/openrouter.json +1 -1
  58. package/dist/providers/data/qwen-token-plan-cn.json +1 -1
  59. package/dist/providers/data/qwen-token-plan-individual-cn.json +1 -1
  60. package/dist/providers/data/qwen-token-plan-individual.json +1 -1
  61. package/dist/providers/data/qwen-token-plan.json +1 -1
  62. package/dist/providers/data/radius.json +1 -1
  63. package/dist/providers/data/together.json +1 -1
  64. package/dist/providers/data/vercel-ai-gateway.json +1 -1
  65. package/dist/providers/data/zai-coding-cn.json +1 -1
  66. package/dist/providers/data/zai.json +1 -1
  67. package/dist/types.d.ts +3 -3
  68. package/dist/types.d.ts.map +1 -1
  69. package/dist/types.js.map +1 -1
  70. package/dist/utils/retry.d.ts.map +1 -1
  71. package/dist/utils/retry.js +39 -6
  72. package/dist/utils/retry.js.map +1 -1
  73. package/dist/utils/version.d.ts +1 -1
  74. package/dist/utils/version.js +1 -1
  75. package/dist/utils/version.js.map +1 -1
  76. package/package.json +5 -4
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C;IACb,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAmB,KAAkB;IAC/D,OAAO,CACN,KAAK,CAAC,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC;QAC7B,KAAK,CAAC,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC;QAC7B,KAAK,CAAC,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC;QAC7B,KAAK,CAAC,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,CAC7B,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,CAA8B,EAAE,CAA8B;IAC5F,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;QAAE,OAAO,KAAK,CAAC;IAC3B,OAAO,YAAY,CAAC,CAAC,CAAC,KAAK,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,QAAQ,KAAK,CAAC,CAAC,QAAQ,CAAC;AAC1F,CAAC","sourcesContent":["import { lazyStream } from \"./api/lazy.ts\";\nimport { defaultProviderAuthContext as defaultAuthContext } from \"./auth/context.ts\";\nimport { InMemoryCredentialStore } from \"./auth/credential-store.ts\";\nimport {\n\ttype AuthResolutionOverrides,\n\tModelsError,\n\trefreshStoredOAuthCredential,\n\tresolveProviderAuth,\n} from \"./auth/resolve.ts\";\nimport type {\n\tAuthCheck,\n\tAuthContext,\n\tAuthInteraction,\n\tAuthOperationOptions,\n\tAuthResult,\n\tAuthType,\n\tCredential,\n\tCredentialStore,\n\tLoginOptions,\n\tProviderAuth,\n} from \"./auth/types.ts\";\nimport { InMemoryModelsStore, type ModelsStore, type ModelsStoreEntry } from \"./models-store.ts\";\nimport { observeModelRequest } from \"./telemetry.ts\";\nimport type {\n\tAnyModel,\n\tApi,\n\tApiStreamOptions,\n\tAssistantImages,\n\tAssistantMessage,\n\tAssistantMessageEventStream,\n\tClassifierApi,\n\tClassifierContext,\n\tClassifierModel,\n\tClassifierOptions,\n\tClassifierResult,\n\tContext,\n\tDeferredCancelOptions,\n\tDeferredFetchOptions,\n\tDeferredHandle,\n\tImageApi,\n\tImageModel,\n\tImagesContext,\n\tImagesOptions,\n\tModel,\n\tModelCostRates,\n\tModelThinkingLevel,\n\tModelType,\n\tModelTypeMap,\n\tProviderClassifier,\n\tProviderHeaders,\n\tProviderImages,\n\tProviderRequestOptions,\n\tProviderStreams,\n\tSimpleStreamOptions,\n\tTranscriptContext,\n\tUsage,\n} from \"./types.ts\";\nimport { operationSignal, raceWithAbortSignal } from \"./utils/abort.ts\";\nimport { type ClientIdentity, getOpenCodeSessionHeaders, mergeClientIdentity } from \"./utils/identity.ts\";\nimport {\n\tassertChatModel,\n\tassertClassifierInputSupported,\n\tassertClassifierModel,\n\tassertImageModel,\n\tclassifierErrorResult,\n\tgetModelType,\n\timageErrorResult,\n\tisModelType,\n} from \"./utils/model-operations.ts\";\nimport { normalizeContext } from \"./utils/transcript.ts\";\n\nexport { ModelsError, type ModelsErrorCode } from \"./auth/resolve.ts\";\nexport { AI_TELEMETRY_SCHEMA } from \"./telemetry.ts\";\nexport { getModelType, isModelType } from \"./utils/model-operations.ts\";\n\nexport interface ModelsPublication {\n\t/** Provider-selected persisted catalog. Omit to leave storage unchanged; null deletes it. */\n\tpersist?: ModelsStoreEntry | null;\n\t/** Optional synchronous update of provider-private in-memory catalog state. */\n\tupdate?: () => void;\n}\n\nexport interface RefreshModelsContext {\n\t/** Effective configured credential. OAuth credentials are refreshed before network access. */\n\tcredential?: Credential;\n\t/** Immutable provider-scoped catalog snapshot captured before this refresh phase. */\n\tstored?: Readonly<ModelsStoreEntry>;\n\t/**\n\t * Generation-checked publication. Persistence policy remains provider-owned;\n\t * the update runs synchronously only after the selected persistence mutation.\n\t */\n\tpublish(publication: ModelsPublication): Promise<boolean>;\n\t/** False during offline/cache-only initialization. */\n\tallowNetwork: boolean;\n\t/** Bypass provider freshness checks and fetch immediately when network access is allowed. */\n\tforce?: boolean;\n\t/** Always present, including when the public refresh caller omits its optional signal. */\n\tsignal: AbortSignal;\n\t/**\n\t * Base URL of the registered provider, including configuration overrides that wrappers apply\n\t * outside the provider receiving this context.\n\t */\n\tbaseUrl?: string;\n}\n\nexport interface ModelsRefreshOptions {\n\tallowNetwork?: boolean;\n\t/** Restrict refresh to these provider IDs. Unknown and static providers are ignored. */\n\tproviders?: readonly string[];\n\t/** Bypass provider freshness checks and fetch immediately when network access is allowed. */\n\tforce?: boolean;\n\tsignal?: AbortSignal;\n}\n\nexport interface ModelsRefreshResult {\n\taborted: boolean;\n\terrors: ReadonlyMap<string, Error>;\n}\n\nexport interface ModelsRequestTransforms {\n\t/** Transform fully assembled model/auth/request headers before provider dispatch. */\n\ttransformHeaders?: (headers: ProviderHeaders) => ProviderHeaders | Promise<ProviderHeaders>;\n}\n\nexport type ModelsApiStreamOptions<TApi extends Api> = ApiStreamOptions<TApi> & ModelsRequestTransforms;\nexport type ModelsSimpleStreamOptions = SimpleStreamOptions & ModelsRequestTransforms;\nexport type ModelsDeferredFetchOptions = DeferredFetchOptions & ModelsRequestTransforms;\nexport type ModelsDeferredCancelOptions = DeferredCancelOptions & ModelsRequestTransforms;\nexport type ModelsImagesOptions = ImagesOptions & ModelsRequestTransforms;\nexport type ModelsClassifierOptions = ClassifierOptions & ModelsRequestTransforms;\n\nconst KNOWN_MODEL_TYPES: Record<ModelType, true> = { chat: true, image: true, classifier: true };\n\n/** Models from stores and remote sources may have types that only newer versions know. */\nfunction hasKnownModelType(model: AnyModel): boolean {\n\treturn Object.hasOwn(KNOWN_MODEL_TYPES, getModelType(model));\n}\n\n/** Drops stored models whose type this version does not know. */\nfunction withKnownModelTypes(entry: ModelsStoreEntry): ModelsStoreEntry {\n\treturn { ...entry, models: entry.models.filter(hasKnownModelType) };\n}\n\n/** Any model a provider with chat APIs `TApi` can list. */\ntype ProviderModel<TApi extends Api> = Model<TApi> | ImageModel<ImageApi> | ClassifierModel<ClassifierApi>;\n\n/**\n * A provider is the concrete runtime unit. It owns id/name/base metadata,\n * auth methods, model listing, and the operations its models support\n * (streaming, image generation, classification).\n *\n * `TApi` lets concrete provider factories declare which chat APIs their models\n * use (e.g. `openaiProvider(): Provider<\"openai-responses\" | \"openai-completions\">`),\n * giving typed chat model lists to direct factory users. Other model types use\n * their operation-specific API unions. Inside a `Models` collection providers\n * are held as `Provider<Api>`.\n */\nexport interface Provider<TApi extends Api = Api> {\n\treadonly id: string;\n\treadonly name: string;\n\n\treadonly baseUrl?: string;\n\treadonly headers?: ProviderHeaders;\n\n\t/**\n\t * Required: at least one of `apiKey`/`oauth`. Every provider has auth\n\t * semantics — even providers with only ambient credentials (env vars, AWS\n\t * profiles, ADC files) and keyless local servers provide `apiKey` auth\n\t * whose `resolve()` reports whether the provider is configured.\n\t * `Models.getAuth()` returns undefined when the provider is unconfigured.\n\t */\n\treadonly auth: ProviderAuth;\n\n\t/**\n\t * Current known chat models, sync. Static providers return their catalog;\n\t * dynamic providers return the list as of the last `refreshModels()` (empty\n\t * before the first). Must not throw; `Models` treats a throwing\n\t * implementation as having no models.\n\t */\n\tgetModels(): readonly Model<TApi>[];\n\n\t/**\n\t * Current known models of every type, sync, with the same contract as\n\t * `getModels()`. Providers with only chat models may omit it; `Models` then\n\t * uses `getModels()`. Model ids are unique within each type; one upstream\n\t * model may have separate entries for different operations.\n\t */\n\tgetAllModels?(): readonly ProviderModel<TApi>[];\n\n\t/**\n\t * Dynamic providers only: restore `context.stored` and optionally fetch a newer list using\n\t * the effective credential. Implementations retain their previous list on failure, publish\n\t * persistence and synchronous state changes through `context.publish()`, and honor the\n\t * shared abort signal for blocking work.\n\t */\n\trefreshModels?(context: RefreshModelsContext): Promise<void>;\n\n\t/**\n\t * What the network phase of `refreshModels` needs. \"credential\" (the default) receives the\n\t * effective credential, so an expired OAuth token is refreshed first. \"configured\" is for catalogs\n\t * served by a source other than the provider, such as a remote catalog service: the phase still runs only when the\n\t * provider is configured, but OAuth is never refreshed for it and `context.credential` is undefined.\n\t */\n\treadonly refreshModelsAuth?: \"credential\" | \"configured\";\n\n\t/**\n\t * Optional provider policy for credential-specific model availability.\n\t * `getModels()` remains the complete synchronous chat catalog; `Models.getAvailable()`\n\t * applies this filter after confirming that provider auth is configured.\n\t */\n\tfilterModels?(models: readonly Model<TApi>[], credential: Credential | undefined): readonly Model<TApi>[];\n\n\t/**\n\t * Optional credential-specific availability policy across every model type.\n\t * Without it, `Models.getAllAvailable()` applies `filterModels` to chat models\n\t * and keeps every other model.\n\t */\n\tfilterAllModels?(\n\t\tmodels: readonly ProviderModel<TApi>[],\n\t\tcredential: Credential | undefined,\n\t): readonly ProviderModel<TApi>[];\n\n\t/** Stream a normalized transcript. `Models` normalizes the caller's `Context` before dispatching here. */\n\tstream<T extends TApi>(\n\t\tmodel: Model<T>,\n\t\tcontext: TranscriptContext,\n\t\toptions?: ApiStreamOptions<T>,\n\t): AssistantMessageEventStream;\n\n\tstreamSimple(\n\t\tmodel: Model<TApi>,\n\t\tcontext: TranscriptContext,\n\t\toptions?: SimpleStreamOptions,\n\t): AssistantMessageEventStream;\n\tfetchDeferred?(\n\t\tmodel: Model<TApi>,\n\t\thandle: DeferredHandle,\n\t\toptions?: DeferredFetchOptions,\n\t): AssistantMessageEventStream;\n\tcancelDeferred?(model: Model<TApi>, handle: DeferredHandle, options?: DeferredCancelOptions): Promise<void>;\n\n\t/** Present when the provider supports dedicated image models. Never rejects. */\n\tgenerateImages?(\n\t\tmodel: ImageModel<ImageApi>,\n\t\tcontext: ImagesContext,\n\t\toptions?: ImagesOptions,\n\t): Promise<AssistantImages>;\n\n\t/** Present when the provider supports structured classifier models. Never rejects. */\n\tclassify?(\n\t\tmodel: ClassifierModel<ClassifierApi>,\n\t\tcontext: ClassifierContext,\n\t\toptions?: ClassifierOptions,\n\t): Promise<ClassifierResult>;\n}\n\n/**\n * Runtime collection of providers plus auth application and request\n * convenience. Providers own request behavior; `Models` resolves auth and\n * delegates each request to the provider that owns the model.\n *\n * Read accessors come in three flavors: the unqualified ones (`getModels`,\n * `getModel`, `getAvailable`) return chat models, the `*OfType` accessors\n * return one model type, and `getAllModels`/`getAllAvailable` return every type.\n */\nexport interface Models {\n\tgetProviders(): readonly Provider[];\n\tgetProvider(id: string): Provider | undefined;\n\n\t/**\n\t * Sync read of last-known chat models from one provider or all providers.\n\t * Best-effort: a provider whose `getModels()` throws yields no models.\n\t */\n\tgetModels(provider?: string): readonly Model<Api>[];\n\n\t/**\n\t * Sync runtime chat model lookup against last-known lists. Dynamic model lists\n\t * are typed as `Model<Api>`; narrow with the `hasApi()` type guard.\n\t */\n\tgetModel(provider: string, id: string): Model<Api> | undefined;\n\n\t/** Sync read of last-known models of one type from one provider or all providers. */\n\tgetModelsOfType<TType extends ModelType>(type: TType, provider?: string): readonly ModelTypeMap[TType][];\n\n\t/** Sync runtime lookup of a model of one type against last-known lists. */\n\tgetModelOfType<TType extends ModelType>(type: TType, provider: string, id: string): ModelTypeMap[TType] | undefined;\n\n\t/** Sync read of last-known models of every type from one provider or all providers. */\n\tgetAllModels(provider?: string): readonly AnyModel[];\n\n\t/**\n\t * Refresh selected configured dynamic providers concurrently (all when `providers` is omitted).\n\t * Provider errors and cancellation are returned without rejecting; static, unknown, and\n\t * unconfigured providers are skipped.\n\t */\n\trefresh(options?: ModelsRefreshOptions): Promise<ModelsRefreshResult>;\n\n\t/** Check whether a provider has complete auth configuration without refreshing OAuth. */\n\tcheckAuth(providerId: string, options?: AuthOperationOptions): Promise<AuthCheck | undefined>;\n\n\t/** Return chat models whose providers have complete auth configuration. */\n\tgetAvailable(providerId?: string, options?: AuthOperationOptions): Promise<readonly Model<Api>[]>;\n\n\t/** Return models of one type whose providers have complete auth configuration. */\n\tgetAvailableOfType<TType extends ModelType>(\n\t\ttype: TType,\n\t\tproviderId?: string,\n\t\toptions?: AuthOperationOptions,\n\t): Promise<readonly ModelTypeMap[TType][]>;\n\n\t/** Return models of every type whose providers have complete auth configuration. */\n\tgetAllAvailable(providerId?: string, options?: AuthOperationOptions): Promise<readonly AnyModel[]>;\n\n\t/**\n\t * Resolve provider-scoped auth by provider id, or provider auth plus static\n\t * model headers when passed a model. Includes a source label for status UI.\n\t * Resolves `undefined` when the provider is unknown or unconfigured.\n\t * Rejects with `ModelsError`: code \"oauth\" when a token refresh fails (the\n\t * stored credential is preserved for retry; re-login fixes it), code \"auth\"\n\t * when api-key resolution or the credential store fails. Request paths\n\t * surface rejections as stream errors.\n\t */\n\tgetAuth(providerId: string, overrides?: AuthResolutionOverrides): Promise<AuthResult | undefined>;\n\tgetAuth(model: AnyModel, overrides?: AuthResolutionOverrides): Promise<AuthResult | undefined>;\n\n\t/** Run a provider-owned login flow and persist its returned credential. */\n\tlogin(providerId: string, type: AuthType, interaction: AuthInteraction, options?: LoginOptions): Promise<Credential>;\n\n\t/** Remove the stored credential for a provider. */\n\tlogout(providerId: string, options?: AuthOperationOptions): Promise<void>;\n\n\tstream<TApi extends Api>(\n\t\tmodel: Model<TApi>,\n\t\tcontext: Context,\n\t\toptions?: ModelsApiStreamOptions<TApi>,\n\t): AssistantMessageEventStream;\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\n\tstreamSimple(model: Model<Api>, context: Context, options?: ModelsSimpleStreamOptions): AssistantMessageEventStream;\n\tcompleteSimple(model: Model<Api>, context: Context, options?: ModelsSimpleStreamOptions): Promise<AssistantMessage>;\n\tstreamDeferred(\n\t\tmodel: Model<Api>,\n\t\thandle: DeferredHandle,\n\t\toptions?: ModelsDeferredFetchOptions,\n\t): AssistantMessageEventStream;\n\tfetchDeferred(\n\t\tmodel: Model<Api>,\n\t\thandle: DeferredHandle,\n\t\toptions?: ModelsDeferredFetchOptions,\n\t): Promise<AssistantMessage>;\n\tcancelDeferred(model: Model<Api>, handle: DeferredHandle, options?: ModelsDeferredCancelOptions): Promise<void>;\n\n\t/**\n\t * Generate images through the owning provider with auth resolved like\n\t * `stream()`. Never rejects: unknown providers, unconfigured auth, and\n\t * providers without `generateImages` return an error `AssistantImages`.\n\t */\n\tgenerateImages(\n\t\tmodel: ImageModel<ImageApi>,\n\t\tcontext: ImagesContext,\n\t\toptions?: ModelsImagesOptions,\n\t): Promise<AssistantImages>;\n\n\t/** Classify structured state through the owning provider. Never rejects. */\n\tclassify(\n\t\tmodel: ClassifierModel<ClassifierApi>,\n\t\tcontext: ClassifierContext,\n\t\toptions?: ModelsClassifierOptions,\n\t): Promise<ClassifierResult>;\n}\n\nexport interface MutableModels extends Models {\n\t/** Upsert/replace by provider.id. Provider ids are unique. */\n\tsetProvider(provider: Provider): void;\n\tdeleteProvider(id: string): void;\n\tclearProviders(): void;\n}\n\nexport interface CreateModelsOptions {\n\tcredentials?: CredentialStore;\n\tmodelsStore?: ModelsStore;\n\tauthContext?: AuthContext;\n\t/** Default identity of every request; a request's `identity` overrides it field by field. */\n\tidentity?: ClientIdentity;\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\nclass ModelsImpl implements MutableModels {\n\tprivate providers = new Map<string, Provider>();\n\tprivate credentials: CredentialStore;\n\tprivate modelsStore: ModelsStore;\n\tprivate authContext: AuthContext;\n\tprivate identity: ClientIdentity | undefined;\n\tprivate refreshGenerations = new Map<string, number>();\n\tprivate refreshControllers = new Map<string, AbortController>();\n\tprivate publicationChains = new Map<string, Promise<unknown>>();\n\n\tconstructor(options?: CreateModelsOptions) {\n\t\tthis.credentials = options?.credentials ?? new InMemoryCredentialStore();\n\t\tthis.modelsStore = options?.modelsStore ?? new InMemoryModelsStore();\n\t\tthis.authContext = options?.authContext ?? defaultAuthContext();\n\t\tthis.identity = options?.identity;\n\t}\n\n\tsetProvider(provider: Provider): void {\n\t\tthis.supersedeProviderRefresh(provider.id);\n\t\tthis.providers.set(provider.id, provider);\n\t}\n\n\tdeleteProvider(id: string): void {\n\t\tthis.supersedeProviderRefresh(id);\n\t\tthis.providers.delete(id);\n\t}\n\n\tclearProviders(): void {\n\t\tfor (const id of new Set([...this.providers.keys(), ...this.refreshControllers.keys()])) {\n\t\t\tthis.supersedeProviderRefresh(id);\n\t\t}\n\t\tthis.providers.clear();\n\t}\n\n\tgetProviders(): readonly Provider[] {\n\t\treturn Array.from(this.providers.values());\n\t}\n\n\tgetProvider(id: string): Provider | undefined {\n\t\treturn this.providers.get(id);\n\t}\n\n\tgetModels(provider?: string): readonly Model<Api>[] {\n\t\tif (provider !== undefined) {\n\t\t\tconst entry = this.providers.get(provider);\n\t\t\tif (!entry) return [];\n\t\t\ttry {\n\t\t\t\treturn entry.getModels();\n\t\t\t} catch {\n\t\t\t\treturn [];\n\t\t\t}\n\t\t}\n\n\t\tconst models: Model<Api>[] = [];\n\t\tfor (const entry of this.providers.values()) {\n\t\t\ttry {\n\t\t\t\tmodels.push(...entry.getModels());\n\t\t\t} catch {\n\t\t\t\t// Best-effort: ill-behaved providers yield no models.\n\t\t\t}\n\t\t}\n\t\treturn models;\n\t}\n\n\tgetAllModels(provider?: string): readonly AnyModel[] {\n\t\tif (provider !== undefined) {\n\t\t\tconst entry = this.providers.get(provider);\n\t\t\tif (!entry) return [];\n\t\t\ttry {\n\t\t\t\treturn entry.getAllModels?.() ?? entry.getModels();\n\t\t\t} catch {\n\t\t\t\treturn [];\n\t\t\t}\n\t\t}\n\n\t\tconst models: AnyModel[] = [];\n\t\tfor (const entry of this.providers.values()) {\n\t\t\ttry {\n\t\t\t\tmodels.push(...(entry.getAllModels?.() ?? entry.getModels()));\n\t\t\t} catch {\n\t\t\t\t// Best-effort: ill-behaved providers yield no models.\n\t\t\t}\n\t\t}\n\t\treturn models;\n\t}\n\n\tgetModelsOfType<TType extends ModelType>(type: TType, provider?: string): readonly ModelTypeMap[TType][] {\n\t\treturn this.getAllModels(provider).filter((model): model is ModelTypeMap[TType] => isModelType(model, type));\n\t}\n\n\tgetModel(provider: string, id: string): Model<Api> | undefined {\n\t\treturn this.getModels(provider).find((model) => model.id === id);\n\t}\n\n\tgetModelOfType<TType extends ModelType>(type: TType, provider: string, id: string): ModelTypeMap[TType] | undefined {\n\t\treturn this.getModelsOfType(type, provider).find((model) => model.id === id);\n\t}\n\n\tprivate supersedeProviderRefresh(providerId: string): number {\n\t\tconst generation = (this.refreshGenerations.get(providerId) ?? 0) + 1;\n\t\tthis.refreshGenerations.set(providerId, generation);\n\t\tconst previous = this.refreshControllers.get(providerId);\n\t\tif (previous) {\n\t\t\tthis.refreshControllers.delete(providerId);\n\t\t\tprevious.abort();\n\t\t}\n\t\treturn generation;\n\t}\n\n\tprivate beginProviderRefresh(providerId: string): { generation: number; controller: AbortController } {\n\t\tconst generation = this.supersedeProviderRefresh(providerId);\n\t\tconst controller = new AbortController();\n\t\tthis.refreshControllers.set(providerId, controller);\n\t\treturn { generation, controller };\n\t}\n\n\tprivate publishProviderModels(\n\t\tproviderId: string,\n\t\tgeneration: number,\n\t\tsignal: AbortSignal,\n\t\tpublication: ModelsPublication,\n\t): Promise<boolean> {\n\t\tconst previous = this.publicationChains.get(providerId) ?? Promise.resolve();\n\t\tconst queued = (async () => {\n\t\t\tawait previous.catch(() => {});\n\t\t\tif (signal.aborted || this.refreshGenerations.get(providerId) !== generation) return false;\n\n\t\t\tif (publication.persist === null) {\n\t\t\t\tawait this.modelsStore.delete(providerId, { signal });\n\t\t\t} else if (publication.persist !== undefined) {\n\t\t\t\tawait this.modelsStore.write(providerId, structuredClone(publication.persist), { signal });\n\t\t\t}\n\n\t\t\tif (signal.aborted || this.refreshGenerations.get(providerId) !== generation) return false;\n\t\t\tpublication.update?.();\n\t\t\treturn true;\n\t\t})();\n\t\tconst tail = queued.catch(() => {});\n\t\tthis.publicationChains.set(providerId, tail);\n\t\tvoid tail.then(() => {\n\t\t\tif (this.publicationChains.get(providerId) === tail) this.publicationChains.delete(providerId);\n\t\t});\n\t\treturn raceWithAbortSignal(queued, signal);\n\t}\n\n\tprivate async runProviderRefreshPhase(\n\t\tprovider: Provider & Required<Pick<Provider, \"refreshModels\">>,\n\t\tcredential: Credential | undefined,\n\t\tallowNetwork: boolean,\n\t\tforce: boolean | undefined,\n\t\tgeneration: number,\n\t\tsignal: AbortSignal,\n\t): Promise<void> {\n\t\tconst stored = await this.modelsStore.read(provider.id, { signal });\n\t\tawait provider.refreshModels({\n\t\t\tcredential,\n\t\t\tstored: stored ? withKnownModelTypes(structuredClone(stored)) : undefined,\n\t\t\tpublish: (publication) => this.publishProviderModels(provider.id, generation, signal, publication),\n\t\t\tallowNetwork,\n\t\t\tforce: allowNetwork ? force : undefined,\n\t\t\tsignal,\n\t\t\tbaseUrl: provider.baseUrl,\n\t\t});\n\t}\n\n\tasync refresh(options: ModelsRefreshOptions = {}): Promise<ModelsRefreshResult> {\n\t\tconst allowNetwork = options.allowNetwork ?? true;\n\t\tconst callerSignal = operationSignal(options.signal);\n\t\tconst errors = new Map<string, Error>();\n\t\tif (callerSignal.aborted) return { aborted: true, errors };\n\t\tconst selected = options.providers ? new Set(options.providers) : undefined;\n\t\tconst refreshable = Array.from(this.providers.values()).filter(\n\t\t\t(provider): provider is Provider & Required<Pick<Provider, \"refreshModels\">> =>\n\t\t\t\tprovider.refreshModels !== undefined && (!selected || selected.has(provider.id)),\n\t\t);\n\n\t\tconst refresh = Promise.all(\n\t\t\trefreshable.map(async (provider) => {\n\t\t\t\tconst { generation, controller } = this.beginProviderRefresh(provider.id);\n\t\t\t\tconst signal = AbortSignal.any([callerSignal, controller.signal]);\n\t\t\t\tconst operation = (async () => {\n\t\t\t\t\tlet storedCredential: Credential | undefined;\n\t\t\t\t\tlet credentialError: unknown;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tstoredCredential = await this.readCredential(provider.id, signal);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tcredentialError = error;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Restore cached provider state before auth resolution or network access.\n\t\t\t\t\tawait this.runProviderRefreshPhase(provider, storedCredential, false, undefined, generation, signal);\n\t\t\t\t\tif (credentialError !== undefined) throw credentialError;\n\t\t\t\t\tif (!allowNetwork || signal.aborted) return;\n\n\t\t\t\t\tconst network = await this.resolveNetworkRefresh(provider, storedCredential, signal);\n\t\t\t\t\tif (!network) return;\n\t\t\t\t\tawait this.runProviderRefreshPhase(\n\t\t\t\t\t\tprovider,\n\t\t\t\t\t\tnetwork.credential,\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t\toptions.force,\n\t\t\t\t\t\tgeneration,\n\t\t\t\t\t\tsignal,\n\t\t\t\t\t);\n\t\t\t\t})();\n\n\t\t\t\ttry {\n\t\t\t\t\tawait raceWithAbortSignal(operation, signal);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (!signal.aborted) {\n\t\t\t\t\t\terrors.set(\n\t\t\t\t\t\t\tprovider.id,\n\t\t\t\t\t\t\terror instanceof Error\n\t\t\t\t\t\t\t\t? error\n\t\t\t\t\t\t\t\t: new ModelsError(\"model_source\", `Model refresh failed for ${provider.id}`, { cause: error }),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} finally {\n\t\t\t\t\tif (this.refreshControllers.get(provider.id) === controller) {\n\t\t\t\t\t\tthis.refreshControllers.delete(provider.id);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}),\n\t\t);\n\n\t\ttry {\n\t\t\tawait raceWithAbortSignal(refresh, callerSignal);\n\t\t} catch (error) {\n\t\t\tif (!callerSignal.aborted) throw error;\n\t\t}\n\n\t\treturn { aborted: callerSignal.aborted, errors: new Map(errors) };\n\t}\n\n\t/** The credential for the network refresh phase, or undefined when the provider is not configured. */\n\tprivate async resolveNetworkRefresh(\n\t\tprovider: Provider,\n\t\tstored: Credential | undefined,\n\t\tsignal: AbortSignal,\n\t): Promise<{ credential?: Credential } | undefined> {\n\t\tif (provider.refreshModelsAuth === \"configured\") {\n\t\t\treturn (await this.checkProviderAuth(provider, stored, signal)) ? {} : undefined;\n\t\t}\n\t\tconst credential = await this.resolveRefreshCredential(provider, stored, signal);\n\t\treturn credential ? { credential } : undefined;\n\t}\n\n\tprivate async resolveRefreshCredential(\n\t\tprovider: Provider,\n\t\tstored: Credential | undefined,\n\t\tsignal: AbortSignal,\n\t): Promise<Credential | undefined> {\n\t\tif (stored?.type === \"oauth\") {\n\t\t\tconst oauth = provider.auth.oauth;\n\t\t\tif (!oauth) return undefined;\n\t\t\tif (Date.now() < stored.expires) return stored;\n\t\t\tif (signal.aborted) return undefined;\n\t\t\t// A refresh that has started survives cancellation or a superseding model refresh, so a\n\t\t\t// rotated refresh token is always persisted. A newer refresh then sees the fresh credential.\n\t\t\treturn refreshStoredOAuthCredential(\n\t\t\t\tthis.credentials,\n\t\t\t\tprovider.id,\n\t\t\t\toauth,\n\t\t\t\t(current) => Date.now() >= current.expires,\n\t\t\t\tsignal,\n\t\t\t);\n\t\t}\n\n\t\tconst apiKey = provider.auth.apiKey;\n\t\tif (!apiKey) return undefined;\n\t\tconst credential = stored?.type === \"api_key\" ? stored : undefined;\n\t\tconst result = await apiKey.resolve({ ctx: this.authContext, credential, signal });\n\t\tif (!result) return undefined;\n\t\treturn { type: \"api_key\", key: result.auth.apiKey, env: result.env };\n\t}\n\n\tprivate async readCredential(providerId: string, signal: AbortSignal): Promise<Credential | undefined> {\n\t\ttry {\n\t\t\treturn await this.credentials.read(providerId, { signal });\n\t\t} catch (error) {\n\t\t\tthrow new ModelsError(\"auth\", `Credential store read failed for ${providerId}`, { cause: error });\n\t\t}\n\t}\n\n\tprivate async checkProviderAuth(\n\t\tprovider: Provider,\n\t\tcredential: Credential | undefined,\n\t\tsignal: AbortSignal,\n\t): Promise<AuthCheck | undefined> {\n\t\tif (credential?.type === \"oauth\") {\n\t\t\treturn provider.auth.oauth ? { source: \"OAuth\", type: \"oauth\" } : undefined;\n\t\t}\n\t\tconst apiKey = provider.auth.apiKey;\n\t\tif (!apiKey) return undefined;\n\t\tif (apiKey.check) {\n\t\t\ttry {\n\t\t\t\treturn await apiKey.check({\n\t\t\t\t\tctx: this.authContext,\n\t\t\t\t\tcredential: credential?.type === \"api_key\" ? credential : undefined,\n\t\t\t\t\tsignal,\n\t\t\t\t});\n\t\t\t} catch (error) {\n\t\t\t\tthrow new ModelsError(\"auth\", `API key auth check failed for provider ${provider.id}`, { cause: error });\n\t\t\t}\n\t\t}\n\n\t\tconst resolution = await resolveProviderAuth(provider, this.credentials, this.authContext, { signal });\n\t\treturn resolution ? { source: resolution.source, type: \"api_key\" } : undefined;\n\t}\n\n\tcheckAuth(providerId: string, options?: AuthOperationOptions): Promise<AuthCheck | undefined> {\n\t\tconst signal = operationSignal(options?.signal);\n\t\tconst check = (async () => {\n\t\t\tsignal.throwIfAborted();\n\t\t\tconst provider = this.providers.get(providerId);\n\t\t\tif (!provider) return undefined;\n\t\t\treturn this.checkProviderAuth(provider, await this.readCredential(providerId, signal), signal);\n\t\t})();\n\t\treturn raceWithAbortSignal(check, signal);\n\t}\n\n\tprivate async getAuthenticatedProviders(providerId: string | undefined, signal: AbortSignal) {\n\t\tsignal.throwIfAborted();\n\t\tconst providers = providerId\n\t\t\t? [this.providers.get(providerId)].filter((entry) => entry !== undefined)\n\t\t\t: this.getProviders();\n\t\tconst checks = await Promise.all(\n\t\t\tproviders.map(async (provider) => {\n\t\t\t\tconst credential = await this.readCredential(provider.id, signal);\n\t\t\t\treturn { provider, credential, auth: await this.checkProviderAuth(provider, credential, signal) };\n\t\t\t}),\n\t\t);\n\t\treturn checks.filter((entry) => entry.auth !== undefined);\n\t}\n\n\tgetAvailable(providerId?: string, options?: AuthOperationOptions): Promise<readonly Model<Api>[]> {\n\t\tconst signal = operationSignal(options?.signal);\n\t\tconst available = (async () => {\n\t\t\tconst providers = await this.getAuthenticatedProviders(providerId, signal);\n\t\t\treturn providers.flatMap(({ provider, credential }) => {\n\t\t\t\tconst models = provider.getModels();\n\t\t\t\treturn provider.filterModels?.(models, credential) ?? models;\n\t\t\t});\n\t\t})();\n\t\treturn raceWithAbortSignal(available, signal);\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\treturn (await this.getAllAvailable(providerId, options)).filter((model): model is ModelTypeMap[TType] =>\n\t\t\tisModelType(model, type),\n\t\t);\n\t}\n\n\tgetAllAvailable(providerId?: string, options?: AuthOperationOptions): Promise<readonly AnyModel[]> {\n\t\tconst signal = operationSignal(options?.signal);\n\t\tconst available = (async () => {\n\t\t\tconst providers = await this.getAuthenticatedProviders(providerId, signal);\n\t\t\treturn providers.flatMap(({ provider, credential }) => {\n\t\t\t\tconst models = provider.getAllModels?.() ?? provider.getModels();\n\t\t\t\tif (provider.filterAllModels) return provider.filterAllModels(models, credential);\n\t\t\t\tif (!provider.filterModels) return models;\n\t\t\t\tconst availableChatIds = new Set(\n\t\t\t\t\tprovider.filterModels(provider.getModels(), credential).map((model) => model.id),\n\t\t\t\t);\n\t\t\t\treturn models.filter((model) => !isModelType(model, \"chat\") || availableChatIds.has(model.id));\n\t\t\t});\n\t\t})();\n\t\treturn raceWithAbortSignal(available, signal);\n\t}\n\n\tgetAuth(providerId: string, overrides?: AuthResolutionOverrides): Promise<AuthResult | undefined>;\n\tgetAuth(model: AnyModel, overrides?: AuthResolutionOverrides): Promise<AuthResult | undefined>;\n\tasync getAuth(\n\t\tproviderOrModel: string | AnyModel,\n\t\toverrides?: AuthResolutionOverrides,\n\t): Promise<AuthResult | undefined> {\n\t\tconst signal = operationSignal(overrides?.signal);\n\t\tconst providerId = typeof providerOrModel === \"string\" ? providerOrModel : providerOrModel.provider;\n\t\tconst provider = this.providers.get(providerId);\n\t\tif (!provider) return undefined;\n\t\tconst result = await resolveProviderAuth(provider, this.credentials, this.authContext, { ...overrides, signal });\n\t\tif (!result || typeof providerOrModel === \"string\" || !providerOrModel.headers) return result;\n\t\treturn {\n\t\t\t...result,\n\t\t\tauth: {\n\t\t\t\t...result.auth,\n\t\t\t\theaders: mergeHeaders(result.auth.headers, providerOrModel.headers),\n\t\t\t},\n\t\t};\n\t}\n\n\tasync login(\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\tsignal.throwIfAborted();\n\t\tconst provider = this.providers.get(providerId);\n\t\tif (!provider) throw new ModelsError(\"provider\", `Unknown provider: ${providerId}`);\n\t\tconst method = type === \"oauth\" ? provider.auth.oauth : provider.auth.apiKey;\n\t\tif (!method?.login) {\n\t\t\tthrow new ModelsError(\"auth\", `${provider.name} does not support ${type} login`);\n\t\t}\n\t\tconst loginOperation: Promise<Credential> = method.login({ ...interaction, signal }, options);\n\t\tconst credential = await raceWithAbortSignal(loginOperation, signal);\n\t\tlet mutationStarted = false;\n\t\tlet markMutationStarted: (() => void) | undefined;\n\t\tconst started = new Promise<void>((resolve) => {\n\t\t\tmarkMutationStarted = resolve;\n\t\t});\n\t\tconst mutation = this.credentials.modify(\n\t\t\tproviderId,\n\t\t\tasync () => {\n\t\t\t\tmutationStarted = true;\n\t\t\t\tmarkMutationStarted?.();\n\t\t\t\treturn credential;\n\t\t\t},\n\t\t\t{ signal },\n\t\t);\n\t\tvoid mutation.catch(() => {});\n\t\ttry {\n\t\t\tawait new Promise<void>((resolve, reject) => {\n\t\t\t\tconst onAbort = () => {\n\t\t\t\t\tif (!mutationStarted) reject(signal.reason);\n\t\t\t\t};\n\t\t\t\tsignal.addEventListener(\"abort\", onAbort, { once: true });\n\t\t\t\tvoid Promise.race([started, mutation]).then(\n\t\t\t\t\t() => {\n\t\t\t\t\t\tsignal.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\tresolve();\n\t\t\t\t\t},\n\t\t\t\t\t(error: unknown) => {\n\t\t\t\t\t\tsignal.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\treject(error);\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\tif (signal.aborted) onAbort();\n\t\t\t});\n\t\t\tawait mutation;\n\t\t} catch (error) {\n\t\t\tsignal.throwIfAborted();\n\t\t\tthrow new ModelsError(\"auth\", `Credential store modify failed for ${providerId}`, { cause: error });\n\t\t}\n\t\treturn credential;\n\t}\n\n\tasync logout(providerId: string, options?: AuthOperationOptions): Promise<void> {\n\t\tconst signal = operationSignal(options?.signal);\n\t\tsignal.throwIfAborted();\n\t\ttry {\n\t\t\tawait this.credentials.delete(providerId, { signal });\n\t\t} catch (error) {\n\t\t\tsignal.throwIfAborted();\n\t\t\tthrow new ModelsError(\"auth\", `Credential store delete failed for ${providerId}`, { cause: error });\n\t\t}\n\t}\n\n\tprivate requireProvider(model: AnyModel): Provider {\n\t\tconst provider = this.providers.get(model.provider);\n\t\tif (!provider) {\n\t\t\tthrow new ModelsError(\"provider\", `Unknown provider: ${model.provider}`);\n\t\t}\n\t\treturn provider;\n\t}\n\n\tprivate requireChatProvider(model: Model<Api>): Provider {\n\t\tassertChatModel(model);\n\t\treturn this.requireProvider(model);\n\t}\n\n\tprivate async applyAuth<\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\trequestModel: TModel;\n\t\trequestOptions: Omit<TOptions, \"transformHeaders\"> & ProviderRequestOptions<TModel>;\n\t}> {\n\t\tthis.requireProvider(model);\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) {\n\t\t\tthrow new ModelsError(\"auth\", `Provider is not configured: ${model.provider}`);\n\t\t}\n\t\tconst auth = resolution.auth;\n\n\t\t// Explicit request options win per-field; the Models-only transform runs last.\n\t\tconst apiKey = options?.apiKey ?? auth.apiKey;\n\t\tconst requestModel: TModel = auth.baseUrl ? { ...model, baseUrl: auth.baseUrl } : model;\n\t\tconst sessionId =\n\t\t\toptions && \"sessionId\" in options && typeof options.sessionId === \"string\" ? options.sessionId : undefined;\n\t\tlet headers = mergeHeaders(\n\t\t\tmergeHeaders(getOpenCodeSessionHeaders(requestModel, sessionId), auth.headers),\n\t\t\toptions?.headers,\n\t\t);\n\t\tif (options?.transformHeaders) headers = await options.transformHeaders(headers ?? {});\n\t\tconst env = resolution.env || options?.env ? { ...(resolution.env ?? {}), ...(options?.env ?? {}) } : undefined;\n\t\tconst identity = mergeClientIdentity(this.identity, options?.identity);\n\t\tconst { transformHeaders: _transformHeaders, ...providerOptions } = options ?? {};\n\t\tconst requestOptions = {\n\t\t\t...providerOptions,\n\t\t\tapiKey,\n\t\t\theaders,\n\t\t\tenv,\n\t\t\t...(identity === undefined ? {} : { identity }),\n\t\t} as Omit<TOptions, \"transformHeaders\"> & ProviderRequestOptions<TModel>;\n\n\t\treturn { requestModel, requestOptions };\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(\n\t\t\tmodel,\n\t\t\tasync () => {\n\t\t\t\tconst provider = this.requireChatProvider(model);\n\t\t\t\tconst { requestModel, requestOptions } = await this.applyAuth(\n\t\t\t\t\tmodel,\n\t\t\t\t\toptions as ModelsApiStreamOptions<Api> | undefined,\n\t\t\t\t);\n\t\t\t\treturn provider.stream(requestModel, transcript, requestOptions as ApiStreamOptions<TApi>);\n\t\t\t},\n\t\t\tobserveModelRequest(model, options, false),\n\t\t\toptions?.signal,\n\t\t);\n\t}\n\n\tasync complete<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\treturn lazyStream(\n\t\t\tmodel,\n\t\t\tasync () => {\n\t\t\t\tconst provider = this.requireChatProvider(model);\n\t\t\t\tconst { requestModel, requestOptions } = await this.applyAuth(model, options);\n\t\t\t\treturn provider.streamSimple(requestModel, transcript, requestOptions as SimpleStreamOptions);\n\t\t\t},\n\t\t\tobserveModelRequest(model, options, false),\n\t\t\toptions?.signal,\n\t\t);\n\t}\n\n\tasync completeSimple(\n\t\tmodel: Model<Api>,\n\t\tcontext: Context,\n\t\toptions?: ModelsSimpleStreamOptions,\n\t): 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(\n\t\t\tmodel,\n\t\t\tasync () => {\n\t\t\t\tconst provider = this.requireChatProvider(model);\n\t\t\t\tif (!provider.fetchDeferred) {\n\t\t\t\t\tthrow new ModelsError(\"provider\", `Provider ${model.provider} does not support deferred responses`);\n\t\t\t\t}\n\t\t\t\tconst { requestModel, requestOptions } = await this.applyAuth(model, options);\n\t\t\t\treturn provider.fetchDeferred(requestModel, handle, requestOptions as DeferredFetchOptions);\n\t\t\t},\n\t\t\tobserveModelRequest(model, options, true),\n\t\t\toptions?.signal,\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\tconst provider = this.requireChatProvider(model);\n\t\tif (!provider.cancelDeferred) {\n\t\t\tthrow new ModelsError(\"provider\", `Provider ${model.provider} does not support deferred responses`);\n\t\t}\n\t\tconst { requestModel, requestOptions } = await this.applyAuth(model, options);\n\t\tawait provider.cancelDeferred(requestModel, handle, requestOptions);\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 provider = this.requireProvider(model);\n\t\t\tif (!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\tconst { requestModel, requestOptions } = await this.applyAuth(model, options);\n\t\t\treturn await provider.generateImages(requestModel, context, requestOptions);\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\tassertClassifierInputSupported(model, context);\n\t\t\tconst provider = this.requireProvider(model);\n\t\t\tif (!provider.classify) {\n\t\t\t\tthrow new ModelsError(\"provider\", `Provider ${model.provider} does not support classification`);\n\t\t\t}\n\t\t\tconst { requestModel, requestOptions } = await this.applyAuth(model, options);\n\t\t\treturn await provider.classify(requestModel, context, requestOptions);\n\t\t} catch (error) {\n\t\t\treturn classifierErrorResult(model, error, options?.signal?.aborted);\n\t\t}\n\t}\n}\n\nexport function createModels(options?: CreateModelsOptions): MutableModels {\n\treturn new ModelsImpl(options);\n}\n\nexport interface CreateProviderOptions<TApi extends Api = Api> {\n\tid: string;\n\t/** Display name. Default: `id`. */\n\tname?: string;\n\tbaseUrl?: string;\n\theaders?: ProviderHeaders;\n\t/** Required — every provider has auth semantics, even ambient/keyless ones. */\n\tauth: ProviderAuth;\n\t/**\n\t * Static baseline models of every type (empty for purely dynamic providers).\n\t * Models without `type` are chat models.\n\t */\n\tmodels: readonly ProviderModel<TApi>[];\n\t/**\n\t * Fetch a dynamic model overlay of every type. createProvider restores and\n\t * publishes it transactionally and drops models of unknown types.\n\t */\n\tfetchModels?: (context: RefreshModelsContext) => Promise<readonly ProviderModel<TApi>[]>;\n\t/** Credential-specific chat model availability. See `Provider.filterModels`. */\n\tfilterModels?: (models: readonly Model<TApi>[], credential: Credential | undefined) => readonly Model<TApi>[];\n\t/** Credential-specific availability across every model type. See `Provider.filterAllModels`. */\n\tfilterAllModels?: (\n\t\tmodels: readonly ProviderModel<TApi>[],\n\t\tcredential: Credential | undefined,\n\t) => readonly ProviderModel<TApi>[];\n\t/**\n\t * Chat implementation: a single one for all chat models, or a map keyed by\n\t * `model.api` for mixed-API providers. Optional when `images` or\n\t * `classifiers` is given.\n\t */\n\tapi?: ProviderStreams | Partial<Record<TApi, ProviderStreams>>;\n\t/** Image-generation implementations keyed by `model.api`. */\n\timages?: Partial<Record<ImageApi, ProviderImages>>;\n\t/** Classifier implementations keyed by `model.api`. */\n\tclassifiers?: Partial<Record<ClassifierApi, ProviderClassifier>>;\n}\n\n/**\n * Builds a provider from parts. Built-in provider factories and models.json\n * custom providers both go through this. A single `api` streams all chat\n * models; an `api` map dispatches on `model.api`, and a model whose api has\n * no entry produces a stream error. One-shot operation maps dispatch on\n * `model.api` the same way. At least one concrete implementation across\n * `api`/`images`/`classifiers` is required; empty maps are rejected.\n */\nexport function createProvider<TApi extends Api = Api>(input: CreateProviderOptions<TApi>): Provider<TApi> {\n\tconst single =\n\t\tinput.api && typeof (input.api as ProviderStreams).stream === \"function\"\n\t\t\t? (input.api as ProviderStreams)\n\t\t\t: undefined;\n\tconst byApi = single || !input.api ? undefined : (input.api as Partial<Record<string, ProviderStreams>>);\n\tconst images = input.images as Partial<Record<string, ProviderImages>> | undefined;\n\tconst classifiers = input.classifiers as Partial<Record<string, ProviderClassifier>> | undefined;\n\tconst streams = single ? [single] : Object.values(byApi ?? {}).filter((entry) => entry !== undefined);\n\tconst imageImplementations = Object.values(images ?? {}).filter((entry) => entry !== undefined);\n\tconst classifierImplementations = Object.values(classifiers ?? {}).filter((entry) => entry !== undefined);\n\tif (streams.length === 0 && imageImplementations.length === 0 && classifierImplementations.length === 0) {\n\t\tthrow new Error(`Provider ${input.id}: at least one of \"api\", \"images\", or \"classifiers\" is required.`);\n\t}\n\n\tconst baselineModels = input.models;\n\tlet dynamicModels: readonly ProviderModel<TApi>[] = [];\n\tconst fetchModels = input.fetchModels;\n\tconst currentModels = (): readonly ProviderModel<TApi>[] => {\n\t\tconst merged = [...baselineModels];\n\t\tfor (const model of dynamicModels) {\n\t\t\tconst index = merged.findIndex(\n\t\t\t\t(entry) => getModelType(entry) === getModelType(model) && entry.id === model.id,\n\t\t\t);\n\t\t\tif (index >= 0) merged[index] = model;\n\t\t\telse merged.push(model);\n\t\t}\n\t\treturn merged;\n\t};\n\tconst apiFor = (model: Model<Api>): ProviderStreams | undefined => single ?? byApi?.[model.api];\n\n\tconst dispatch = (\n\t\tmodel: Model<Api>,\n\t\trun: (streams: ProviderStreams) => AssistantMessageEventStream,\n\t\tsignal?: AbortSignal,\n\t): AssistantMessageEventStream => {\n\t\tconst streams = apiFor(model);\n\t\tif (!streams) {\n\t\t\treturn lazyStream(\n\t\t\t\tmodel,\n\t\t\t\tasync () => {\n\t\t\t\t\tthrow new ModelsError(\"stream\", `Provider ${input.id} has no API implementation for \"${model.api}\"`);\n\t\t\t\t},\n\t\t\t\tundefined,\n\t\t\t\tsignal,\n\t\t\t);\n\t\t}\n\t\treturn run(streams);\n\t};\n\n\tconst provider: Provider<TApi> = {\n\t\tid: input.id,\n\t\tname: input.name ?? input.id,\n\t\tbaseUrl: input.baseUrl,\n\t\theaders: input.headers,\n\t\tauth: input.auth,\n\t\tgetModels: () => currentModels().filter((model): model is Model<TApi> => isModelType(model, \"chat\")),\n\t\tgetAllModels: currentModels,\n\t\trefreshModels: fetchModels\n\t\t\t? async (context) => {\n\t\t\t\t\tif (context.stored) {\n\t\t\t\t\t\tconst restored = context.stored.models\n\t\t\t\t\t\t\t.filter((model) => model.provider === input.id)\n\t\t\t\t\t\t\t.map((model) => model as ProviderModel<TApi>);\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t!(await context.publish({\n\t\t\t\t\t\t\t\tupdate: () => {\n\t\t\t\t\t\t\t\t\tdynamicModels = restored;\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t}))\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (!context.allowNetwork || context.signal.aborted) return;\n\t\t\t\t\tconst fetched = await fetchModels(context);\n\t\t\t\t\tif (context.signal.aborted) return;\n\t\t\t\t\tconst refreshed = fetched.filter(hasKnownModelType);\n\t\t\t\t\tawait context.publish({\n\t\t\t\t\t\tpersist: { models: refreshed, checkedAt: Date.now() },\n\t\t\t\t\t\tupdate: () => {\n\t\t\t\t\t\t\tdynamicModels = refreshed;\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t: undefined,\n\t\tfilterModels: input.filterModels,\n\t\tfilterAllModels: input.filterAllModels,\n\t\tstream: (model, context, options) =>\n\t\t\tdispatch(model, (streams) => streams.stream(model, context, options), options?.signal),\n\t\tstreamSimple: (model, context, options) =>\n\t\t\tdispatch(model, (streams) => streams.streamSimple(model, context, options), options?.signal),\n\t};\n\n\tif (streams.some((entry) => entry.fetchDeferred !== undefined)) {\n\t\tprovider.fetchDeferred = (model, handle, options) =>\n\t\t\tlazyStream(\n\t\t\t\tmodel,\n\t\t\t\tasync () => {\n\t\t\t\t\tconst implementation = apiFor(model);\n\t\t\t\t\tif (!implementation?.fetchDeferred) {\n\t\t\t\t\t\tthrow new ModelsError(\n\t\t\t\t\t\t\t\"provider\",\n\t\t\t\t\t\t\t`Provider ${input.id} does not support deferred responses for \"${model.api}\"`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\treturn implementation.fetchDeferred(model, handle, options);\n\t\t\t\t},\n\t\t\t\tundefined,\n\t\t\t\toptions?.signal,\n\t\t\t);\n\t}\n\tif (streams.some((entry) => entry.cancelDeferred !== undefined)) {\n\t\tprovider.cancelDeferred = async (model, handle, options) => {\n\t\t\tconst implementation = apiFor(model);\n\t\t\tif (!implementation?.cancelDeferred) {\n\t\t\t\tthrow new ModelsError(\n\t\t\t\t\t\"provider\",\n\t\t\t\t\t`Provider ${input.id} cannot cancel deferred responses for \"${model.api}\"`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait implementation.cancelDeferred(model, handle, options);\n\t\t};\n\t}\n\tif (images && imageImplementations.length > 0) {\n\t\tprovider.generateImages = async (model, context, options) => {\n\t\t\tconst implementation = images[model.api];\n\t\t\tif (!implementation) {\n\t\t\t\treturn imageErrorResult(\n\t\t\t\t\tmodel,\n\t\t\t\t\tnew ModelsError(\n\t\t\t\t\t\t\"provider\",\n\t\t\t\t\t\t`Provider ${input.id} has no image generation implementation for \"${model.api}\"`,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn implementation.generateImages(model, context, options);\n\t\t};\n\t}\n\tif (classifiers && classifierImplementations.length > 0) {\n\t\tprovider.classify = async (model, context, options) => {\n\t\t\tconst implementation = classifiers[model.api];\n\t\t\tif (!implementation) {\n\t\t\t\treturn classifierErrorResult(\n\t\t\t\t\tmodel,\n\t\t\t\t\tnew ModelsError(\"provider\", `Provider ${input.id} has no classifier implementation for \"${model.api}\"`),\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn implementation.classify(model, context, options);\n\t\t};\n\t}\n\n\treturn provider;\n}\n\n/**\n * Runtime-checked narrowing for dynamically looked-up models:\n *\n * ```ts\n * const model = models.getModel(\"anthropic\", \"claude-opus-5-5\");\n * if (model && hasApi(model, \"anthropic-messages\")) {\n * // model: Model<\"anthropic-messages\">, stream options fully typed\n * }\n * ```\n *\n * Non-chat models never match, even when their api id equals `api`.\n */\nexport function hasApi<TApi extends Api>(model: AnyModel, api: TApi): model is Model<TApi> {\n\treturn isModelType(model, \"chat\") && model.api === api;\n}\n\nexport function calculateCost(model: AnyModel, usage: Usage): Usage[\"cost\"] {\n\tconst inputTokens = usage.input + usage.cacheRead + usage.cacheWrite;\n\tlet rates: ModelCostRates = model.cost;\n\tlet matchedThreshold = -1;\n\tfor (const tier of model.cost.tiers ?? []) {\n\t\tif (inputTokens > tier.inputTokensAbove && tier.inputTokensAbove > matchedThreshold) {\n\t\t\trates = tier;\n\t\t\tmatchedThreshold = tier.inputTokensAbove;\n\t\t}\n\t}\n\n\t// Anthropic charges 2x base input for 1h cache writes.\n\tconst longWrite = usage.cacheWrite1h ?? 0;\n\tconst shortWrite = usage.cacheWrite - longWrite;\n\tusage.cost.input = (rates.input / 1000000) * usage.input;\n\tusage.cost.output = (rates.output / 1000000) * usage.output;\n\tusage.cost.cacheRead = (rates.cacheRead / 1000000) * usage.cacheRead;\n\tusage.cost.cacheWrite = (rates.cacheWrite * shortWrite + rates.input * 2 * longWrite) / 1000000;\n\tusage.cost.total = usage.cost.input + usage.cost.output + usage.cost.cacheRead + usage.cost.cacheWrite;\n\tusage.cost.totalFromProvider = false;\n\treturn usage.cost;\n}\n\nconst EXTENDED_THINKING_LEVELS: ModelThinkingLevel[] = [\"off\", \"minimal\", \"low\", \"medium\", \"high\", \"xhigh\", \"max\"];\n\nexport function getSupportedThinkingLevels<TApi extends Api>(model: Model<TApi>): ModelThinkingLevel[] {\n\tif (!model.reasoning) return [\"off\"];\n\n\treturn EXTENDED_THINKING_LEVELS.filter((level) => {\n\t\tconst mapped = model.thinkingLevelMap?.[level];\n\t\tif (mapped === null) return false;\n\t\tif (level === \"xhigh\" || level === \"max\") return mapped !== undefined;\n\t\treturn true;\n\t});\n}\n\nexport function clampThinkingLevel<TApi extends Api>(\n\tmodel: Model<TApi>,\n\tlevel: ModelThinkingLevel,\n): ModelThinkingLevel {\n\tconst availableLevels = getSupportedThinkingLevels(model);\n\tif (availableLevels.includes(level)) return level;\n\n\tconst requestedIndex = EXTENDED_THINKING_LEVELS.indexOf(level);\n\tif (requestedIndex === -1) return availableLevels[0] ?? \"off\";\n\n\tfor (let i = requestedIndex; i < EXTENDED_THINKING_LEVELS.length; i++) {\n\t\tconst candidate = EXTENDED_THINKING_LEVELS[i];\n\t\tif (availableLevels.includes(candidate)) return candidate;\n\t}\n\tfor (let i = requestedIndex - 1; i >= 0; i--) {\n\t\tconst candidate = EXTENDED_THINKING_LEVELS[i];\n\t\tif (availableLevels.includes(candidate)) return candidate;\n\t}\n\treturn availableLevels[0] ?? \"off\";\n}\n\n/**\n * Check if a model supports xhigh thinking level.\n */\nexport function supportsXhigh<TApi extends Api>(model: Model<TApi>): boolean {\n\tif (model.id.includes(\"gpt-5.2\") || model.id.includes(\"gpt-5.3\") || model.id.includes(\"gpt-5.4\")) {\n\t\treturn true;\n\t}\n\tif (\n\t\tmodel.id.includes(\"opus-4-6\") ||\n\t\tmodel.id.includes(\"opus-4.6\") ||\n\t\tmodel.id.includes(\"opus-4-7\") ||\n\t\tmodel.id.includes(\"opus-4.7\") ||\n\t\tmodel.id.includes(\"sonnet-4-6\") ||\n\t\tmodel.id.includes(\"sonnet-4.6\") ||\n\t\tmodel.id.includes(\"haiku-4-5\") ||\n\t\tmodel.id.includes(\"haiku-4.5\")\n\t) {\n\t\treturn true;\n\t}\n\treturn false;\n}\n\n/**\n * Check if a model supports the max thinking level.\n * Currently Anthropic Opus 4.6 and Opus 4.7 only.\n */\nexport function supportsMax<TApi extends Api>(model: Model<TApi>): boolean {\n\treturn (\n\t\tmodel.id.includes(\"opus-4-6\") ||\n\t\tmodel.id.includes(\"opus-4.6\") ||\n\t\tmodel.id.includes(\"opus-4-7\") ||\n\t\tmodel.id.includes(\"opus-4.7\")\n\t);\n}\n\n/**\n * Check if two models are equal by comparing their type, id, and provider.\n * Returns false if either model is null or undefined.\n */\nexport function modelsAreEqual(a: AnyModel | null | undefined, b: AnyModel | null | undefined): boolean {\n\tif (!a || !b) return false;\n\treturn getModelType(a) === getModelType(b) && a.id === b.id && a.provider === b.provider;\n}\n"]}
1
+ {"version":3,"file":"models.js","sourceRoot":"","sources":["../src/models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,0BAA0B,IAAI,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACrF,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,EAEN,WAAW,EACX,4BAA4B,EAC5B,mBAAmB,GACnB,MAAM,mBAAmB,CAAC;AAa3B,OAAO,EAAE,mBAAmB,EAA2C,MAAM,mBAAmB,CAAC;AACjG,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAmCrD,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,EAAuB,yBAAyB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1G,OAAO,EACN,eAAe,EACf,8BAA8B,EAC9B,qBAAqB,EACrB,gBAAgB,EAChB,qBAAqB,EACrB,YAAY,EACZ,gBAAgB,EAChB,WAAW,GACX,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,WAAW,EAAwB,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,mBAA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AC7B,KAAK,CAAC,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC;QAC7B,KAAK,CAAC,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC;QAC7B,KAAK,CAAC,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,CAC7B,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,CAA8B,EAAE,CAA8B;IAC5F,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;QAAE,OAAO,KAAK,CAAC;IAC3B,OAAO,YAAY,CAAC,CAAC,CAAC,KAAK,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,QAAQ,KAAK,CAAC,CAAC,QAAQ,CAAC;AAC1F,CAAC","sourcesContent":["import { lazyStream } from \"./api/lazy.ts\";\nimport { defaultProviderAuthContext as defaultAuthContext } from \"./auth/context.ts\";\nimport { InMemoryCredentialStore } from \"./auth/credential-store.ts\";\nimport {\n\ttype AuthResolutionOverrides,\n\tModelsError,\n\trefreshStoredOAuthCredential,\n\tresolveProviderAuth,\n} from \"./auth/resolve.ts\";\nimport type {\n\tAuthCheck,\n\tAuthContext,\n\tAuthInteraction,\n\tAuthOperationOptions,\n\tAuthResult,\n\tAuthType,\n\tCredential,\n\tCredentialStore,\n\tLoginOptions,\n\tProviderAuth,\n} from \"./auth/types.ts\";\nimport { InMemoryModelsStore, type ModelsStore, type ModelsStoreEntry } from \"./models-store.ts\";\nimport { observeModelRequest } from \"./telemetry.ts\";\nimport type {\n\tAnyModel,\n\tApi,\n\tApiStreamOptions,\n\tAssistantImages,\n\tAssistantMessage,\n\tAssistantMessageEventStream,\n\tClassifierApi,\n\tClassifierContext,\n\tClassifierModel,\n\tClassifierOptions,\n\tClassifierResult,\n\tContext,\n\tDeferredCancelOptions,\n\tDeferredFetchOptions,\n\tDeferredHandle,\n\tImageApi,\n\tImageModel,\n\tImagesContext,\n\tImagesOptions,\n\tModel,\n\tModelCostRates,\n\tModelThinkingLevel,\n\tModelType,\n\tModelTypeMap,\n\tProviderClassifier,\n\tProviderHeaders,\n\tProviderImages,\n\tProviderRequestOptions,\n\tProviderStreams,\n\tSimpleStreamOptions,\n\tTranscriptContext,\n\tUsage,\n} from \"./types.ts\";\nimport { operationSignal, raceWithAbortSignal } from \"./utils/abort.ts\";\nimport { type ClientIdentity, getOpenCodeSessionHeaders, mergeClientIdentity } from \"./utils/identity.ts\";\nimport {\n\tassertChatModel,\n\tassertClassifierInputSupported,\n\tassertClassifierModel,\n\tassertImageModel,\n\tclassifierErrorResult,\n\tgetModelType,\n\timageErrorResult,\n\tisModelType,\n} from \"./utils/model-operations.ts\";\nimport { normalizeContext } from \"./utils/transcript.ts\";\n\nexport { ModelsError, type ModelsErrorCode } from \"./auth/resolve.ts\";\nexport { AI_TELEMETRY_SCHEMA } from \"./telemetry.ts\";\nexport { getModelType, isModelType } from \"./utils/model-operations.ts\";\n\nexport interface ModelsPublication {\n\t/** Provider-selected persisted catalog. Omit to leave storage unchanged; null deletes it. */\n\tpersist?: ModelsStoreEntry | null;\n\t/** Optional synchronous update of provider-private in-memory catalog state. */\n\tupdate?: () => void;\n}\n\nexport interface RefreshModelsContext {\n\t/** Effective configured credential. OAuth credentials are refreshed before network access. */\n\tcredential?: Credential;\n\t/** Immutable provider-scoped catalog snapshot captured before this refresh phase. */\n\tstored?: Readonly<ModelsStoreEntry>;\n\t/**\n\t * Generation-checked publication. Persistence policy remains provider-owned;\n\t * the update runs synchronously only after the selected persistence mutation.\n\t */\n\tpublish(publication: ModelsPublication): Promise<boolean>;\n\t/** False during offline/cache-only initialization. */\n\tallowNetwork: boolean;\n\t/** Bypass provider freshness checks and fetch immediately when network access is allowed. */\n\tforce?: boolean;\n\t/** Always present, including when the public refresh caller omits its optional signal. */\n\tsignal: AbortSignal;\n\t/**\n\t * Base URL of the registered provider, including configuration overrides that wrappers apply\n\t * outside the provider receiving this context.\n\t */\n\tbaseUrl?: string;\n}\n\nexport interface ModelsRefreshOptions {\n\tallowNetwork?: boolean;\n\t/** Restrict refresh to these provider IDs. Unknown and static providers are ignored. */\n\tproviders?: readonly string[];\n\t/** Bypass provider freshness checks and fetch immediately when network access is allowed. */\n\tforce?: boolean;\n\tsignal?: AbortSignal;\n}\n\nexport interface ModelsRefreshResult {\n\taborted: boolean;\n\terrors: ReadonlyMap<string, Error>;\n}\n\nexport interface ModelsRequestTransforms {\n\t/** Transform fully assembled model/auth/request headers before provider dispatch. */\n\ttransformHeaders?: (headers: ProviderHeaders) => ProviderHeaders | Promise<ProviderHeaders>;\n}\n\nexport type ModelsApiStreamOptions<TApi extends Api> = ApiStreamOptions<TApi> & ModelsRequestTransforms;\nexport type ModelsSimpleStreamOptions = SimpleStreamOptions & ModelsRequestTransforms;\nexport type ModelsDeferredFetchOptions = DeferredFetchOptions & ModelsRequestTransforms;\nexport type ModelsDeferredCancelOptions = DeferredCancelOptions & ModelsRequestTransforms;\nexport type ModelsImagesOptions = ImagesOptions & ModelsRequestTransforms;\nexport type ModelsClassifierOptions = ClassifierOptions & ModelsRequestTransforms;\n\nconst KNOWN_MODEL_TYPES: Record<ModelType, true> = { chat: true, image: true, classifier: true };\n\n/** Models from stores and remote sources may have types that only newer versions know. */\nfunction hasKnownModelType(model: AnyModel): boolean {\n\treturn Object.hasOwn(KNOWN_MODEL_TYPES, getModelType(model));\n}\n\n/** Drops stored models whose type this version does not know. */\nfunction withKnownModelTypes(entry: ModelsStoreEntry): ModelsStoreEntry {\n\treturn { ...entry, models: entry.models.filter(hasKnownModelType) };\n}\n\n/** Any model a provider with chat APIs `TApi` can list. */\ntype ProviderModel<TApi extends Api> = Model<TApi> | ImageModel<ImageApi> | ClassifierModel<ClassifierApi>;\n\n/**\n * A provider is the concrete runtime unit. It owns id/name/base metadata,\n * auth methods, model listing, and the operations its models support\n * (streaming, image generation, classification).\n *\n * `TApi` lets concrete provider factories declare which chat APIs their models\n * use (e.g. `openaiProvider(): Provider<\"openai-responses\" | \"openai-completions\">`),\n * giving typed chat model lists to direct factory users. Other model types use\n * their operation-specific API unions. Inside a `Models` collection providers\n * are held as `Provider<Api>`.\n */\nexport interface Provider<TApi extends Api = Api> {\n\treadonly id: string;\n\treadonly name: string;\n\n\treadonly baseUrl?: string;\n\treadonly headers?: ProviderHeaders;\n\n\t/**\n\t * Required: at least one of `apiKey`/`oauth`. Every provider has auth\n\t * semantics — even providers with only ambient credentials (env vars, AWS\n\t * profiles, ADC files) and keyless local servers provide `apiKey` auth\n\t * whose `resolve()` reports whether the provider is configured.\n\t * `Models.getAuth()` returns undefined when the provider is unconfigured.\n\t */\n\treadonly auth: ProviderAuth;\n\n\t/**\n\t * Current known chat models, sync. Static providers return their catalog;\n\t * dynamic providers return the list as of the last `refreshModels()` (empty\n\t * before the first). Must not throw; `Models` treats a throwing\n\t * implementation as having no models.\n\t */\n\tgetModels(): readonly Model<TApi>[];\n\n\t/**\n\t * Current known models of every type, sync, with the same contract as\n\t * `getModels()`. Providers with only chat models may omit it; `Models` then\n\t * uses `getModels()`. Model ids are unique within each type; one upstream\n\t * model may have separate entries for different operations.\n\t */\n\tgetAllModels?(): readonly ProviderModel<TApi>[];\n\n\t/**\n\t * Dynamic providers only: restore `context.stored` and optionally fetch a newer list using\n\t * the effective credential. Implementations retain their previous list on failure, publish\n\t * persistence and synchronous state changes through `context.publish()`, and honor the\n\t * shared abort signal for blocking work.\n\t */\n\trefreshModels?(context: RefreshModelsContext): Promise<void>;\n\n\t/**\n\t * What the network phase of `refreshModels` needs. \"credential\" (the default) receives the\n\t * effective credential, so an expired OAuth token is refreshed first. \"configured\" is for catalogs\n\t * served by a source other than the provider, such as a remote catalog service: the phase still runs only when the\n\t * provider is configured, but OAuth is never refreshed for it and `context.credential` is undefined.\n\t */\n\treadonly refreshModelsAuth?: \"credential\" | \"configured\";\n\n\t/**\n\t * Optional provider policy for credential-specific model availability.\n\t * `getModels()` remains the complete synchronous chat catalog; `Models.getAvailable()`\n\t * applies this filter after confirming that provider auth is configured.\n\t */\n\tfilterModels?(models: readonly Model<TApi>[], credential: Credential | undefined): readonly Model<TApi>[];\n\n\t/**\n\t * Optional credential-specific availability policy across every model type.\n\t * Without it, `Models.getAllAvailable()` applies `filterModels` to chat models\n\t * and keeps every other model.\n\t */\n\tfilterAllModels?(\n\t\tmodels: readonly ProviderModel<TApi>[],\n\t\tcredential: Credential | undefined,\n\t): readonly ProviderModel<TApi>[];\n\n\t/** Stream a normalized transcript. `Models` normalizes the caller's `Context` before dispatching here. */\n\tstream<T extends TApi>(\n\t\tmodel: Model<T>,\n\t\tcontext: TranscriptContext,\n\t\toptions?: ApiStreamOptions<T>,\n\t): AssistantMessageEventStream;\n\n\tstreamSimple(\n\t\tmodel: Model<TApi>,\n\t\tcontext: TranscriptContext,\n\t\toptions?: SimpleStreamOptions,\n\t): AssistantMessageEventStream;\n\tfetchDeferred?(\n\t\tmodel: Model<TApi>,\n\t\thandle: DeferredHandle,\n\t\toptions?: DeferredFetchOptions,\n\t): AssistantMessageEventStream;\n\tcancelDeferred?(model: Model<TApi>, handle: DeferredHandle, options?: DeferredCancelOptions): Promise<void>;\n\n\t/** Present when the provider supports dedicated image models. Never rejects. */\n\tgenerateImages?(\n\t\tmodel: ImageModel<ImageApi>,\n\t\tcontext: ImagesContext,\n\t\toptions?: ImagesOptions,\n\t): Promise<AssistantImages>;\n\n\t/** Present when the provider supports structured classifier models. Never rejects. */\n\tclassify?(\n\t\tmodel: ClassifierModel<ClassifierApi>,\n\t\tcontext: ClassifierContext,\n\t\toptions?: ClassifierOptions,\n\t): Promise<ClassifierResult>;\n}\n\n/**\n * Runtime collection of providers plus auth application and request\n * convenience. Providers own request behavior; `Models` resolves auth and\n * delegates each request to the provider that owns the model.\n *\n * Read accessors come in three flavors: the unqualified ones (`getModels`,\n * `getModel`, `getAvailable`) return chat models, the `*OfType` accessors\n * return one model type, and `getAllModels`/`getAllAvailable` return every type.\n */\nexport interface Models {\n\tgetProviders(): readonly Provider[];\n\tgetProvider(id: string): Provider | undefined;\n\n\t/**\n\t * Sync read of last-known chat models from one provider or all providers.\n\t * Best-effort: a provider whose `getModels()` throws yields no models.\n\t */\n\tgetModels(provider?: string): readonly Model<Api>[];\n\n\t/**\n\t * Sync runtime chat model lookup against last-known lists. Dynamic model lists\n\t * are typed as `Model<Api>`; narrow with the `hasApi()` type guard.\n\t */\n\tgetModel(provider: string, id: string): Model<Api> | undefined;\n\n\t/** Sync read of last-known models of one type from one provider or all providers. */\n\tgetModelsOfType<TType extends ModelType>(type: TType, provider?: string): readonly ModelTypeMap[TType][];\n\n\t/** Sync runtime lookup of a model of one type against last-known lists. */\n\tgetModelOfType<TType extends ModelType>(type: TType, provider: string, id: string): ModelTypeMap[TType] | undefined;\n\n\t/** Sync read of last-known models of every type from one provider or all providers. */\n\tgetAllModels(provider?: string): readonly AnyModel[];\n\n\t/**\n\t * Refresh selected configured dynamic providers concurrently (all when `providers` is omitted).\n\t * Provider errors and cancellation are returned without rejecting; static, unknown, and\n\t * unconfigured providers are skipped.\n\t */\n\trefresh(options?: ModelsRefreshOptions): Promise<ModelsRefreshResult>;\n\n\t/** Check whether a provider has complete auth configuration without refreshing OAuth. */\n\tcheckAuth(providerId: string, options?: AuthOperationOptions): Promise<AuthCheck | undefined>;\n\n\t/** Return chat models whose providers have complete auth configuration. */\n\tgetAvailable(providerId?: string, options?: AuthOperationOptions): Promise<readonly Model<Api>[]>;\n\n\t/** Return models of one type whose providers have complete auth configuration. */\n\tgetAvailableOfType<TType extends ModelType>(\n\t\ttype: TType,\n\t\tproviderId?: string,\n\t\toptions?: AuthOperationOptions,\n\t): Promise<readonly ModelTypeMap[TType][]>;\n\n\t/** Return models of every type whose providers have complete auth configuration. */\n\tgetAllAvailable(providerId?: string, options?: AuthOperationOptions): Promise<readonly AnyModel[]>;\n\n\t/**\n\t * Resolve provider-scoped auth by provider id, or provider auth plus static\n\t * model headers when passed a model. Includes a source label for status UI.\n\t * Resolves `undefined` when the provider is unknown or unconfigured.\n\t * Rejects with `ModelsError`: code \"oauth\" when a token refresh fails (the\n\t * stored credential is preserved for retry; re-login fixes it), code \"auth\"\n\t * when api-key resolution or the credential store fails. Request paths\n\t * surface rejections as stream errors.\n\t */\n\tgetAuth(providerId: string, overrides?: AuthResolutionOverrides): Promise<AuthResult | undefined>;\n\tgetAuth(model: AnyModel, overrides?: AuthResolutionOverrides): Promise<AuthResult | undefined>;\n\n\t/** Run a provider-owned login flow and persist its returned credential. */\n\tlogin(providerId: string, type: AuthType, interaction: AuthInteraction, options?: LoginOptions): Promise<Credential>;\n\n\t/** Remove the stored credential for a provider. */\n\tlogout(providerId: string, options?: AuthOperationOptions): Promise<void>;\n\n\tstream<TApi extends Api>(\n\t\tmodel: Model<TApi>,\n\t\tcontext: Context,\n\t\toptions?: ModelsApiStreamOptions<TApi>,\n\t): AssistantMessageEventStream;\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\n\tstreamSimple(model: Model<Api>, context: Context, options?: ModelsSimpleStreamOptions): AssistantMessageEventStream;\n\tcompleteSimple(model: Model<Api>, context: Context, options?: ModelsSimpleStreamOptions): Promise<AssistantMessage>;\n\tstreamDeferred(\n\t\tmodel: Model<Api>,\n\t\thandle: DeferredHandle,\n\t\toptions?: ModelsDeferredFetchOptions,\n\t): AssistantMessageEventStream;\n\tfetchDeferred(\n\t\tmodel: Model<Api>,\n\t\thandle: DeferredHandle,\n\t\toptions?: ModelsDeferredFetchOptions,\n\t): Promise<AssistantMessage>;\n\tcancelDeferred(model: Model<Api>, handle: DeferredHandle, options?: ModelsDeferredCancelOptions): Promise<void>;\n\n\t/**\n\t * Generate images through the owning provider with auth resolved like\n\t * `stream()`. Never rejects: unknown providers, unconfigured auth, and\n\t * providers without `generateImages` return an error `AssistantImages`.\n\t */\n\tgenerateImages(\n\t\tmodel: ImageModel<ImageApi>,\n\t\tcontext: ImagesContext,\n\t\toptions?: ModelsImagesOptions,\n\t): Promise<AssistantImages>;\n\n\t/** Classify structured state through the owning provider. Never rejects. */\n\tclassify(\n\t\tmodel: ClassifierModel<ClassifierApi>,\n\t\tcontext: ClassifierContext,\n\t\toptions?: ModelsClassifierOptions,\n\t): Promise<ClassifierResult>;\n}\n\nexport interface MutableModels extends Models {\n\t/** Upsert/replace by provider.id. Provider ids are unique. */\n\tsetProvider(provider: Provider): void;\n\tdeleteProvider(id: string): void;\n\tclearProviders(): void;\n}\n\nexport interface CreateModelsOptions {\n\tcredentials?: CredentialStore;\n\tmodelsStore?: ModelsStore;\n\tauthContext?: AuthContext;\n\t/** Default identity of every request; a request's `identity` overrides it field by field. */\n\tidentity?: ClientIdentity;\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\nclass ModelsImpl implements MutableModels {\n\tprivate providers = new Map<string, Provider>();\n\tprivate credentials: CredentialStore;\n\tprivate modelsStore: ModelsStore;\n\tprivate authContext: AuthContext;\n\tprivate identity: ClientIdentity | undefined;\n\tprivate refreshGenerations = new Map<string, number>();\n\tprivate refreshControllers = new Map<string, AbortController>();\n\tprivate publicationChains = new Map<string, Promise<unknown>>();\n\n\tconstructor(options?: CreateModelsOptions) {\n\t\tthis.credentials = options?.credentials ?? new InMemoryCredentialStore();\n\t\tthis.modelsStore = options?.modelsStore ?? new InMemoryModelsStore();\n\t\tthis.authContext = options?.authContext ?? defaultAuthContext();\n\t\tthis.identity = options?.identity;\n\t}\n\n\tsetProvider(provider: Provider): void {\n\t\tthis.supersedeProviderRefresh(provider.id);\n\t\tthis.providers.set(provider.id, provider);\n\t}\n\n\tdeleteProvider(id: string): void {\n\t\tthis.supersedeProviderRefresh(id);\n\t\tthis.providers.delete(id);\n\t}\n\n\tclearProviders(): void {\n\t\tfor (const id of new Set([...this.providers.keys(), ...this.refreshControllers.keys()])) {\n\t\t\tthis.supersedeProviderRefresh(id);\n\t\t}\n\t\tthis.providers.clear();\n\t}\n\n\tgetProviders(): readonly Provider[] {\n\t\treturn Array.from(this.providers.values());\n\t}\n\n\tgetProvider(id: string): Provider | undefined {\n\t\treturn this.providers.get(id);\n\t}\n\n\tgetModels(provider?: string): readonly Model<Api>[] {\n\t\tif (provider !== undefined) {\n\t\t\tconst entry = this.providers.get(provider);\n\t\t\tif (!entry) return [];\n\t\t\ttry {\n\t\t\t\treturn entry.getModels();\n\t\t\t} catch {\n\t\t\t\treturn [];\n\t\t\t}\n\t\t}\n\n\t\tconst models: Model<Api>[] = [];\n\t\tfor (const entry of this.providers.values()) {\n\t\t\ttry {\n\t\t\t\tmodels.push(...entry.getModels());\n\t\t\t} catch {\n\t\t\t\t// Best-effort: ill-behaved providers yield no models.\n\t\t\t}\n\t\t}\n\t\treturn models;\n\t}\n\n\tgetAllModels(provider?: string): readonly AnyModel[] {\n\t\tif (provider !== undefined) {\n\t\t\tconst entry = this.providers.get(provider);\n\t\t\tif (!entry) return [];\n\t\t\ttry {\n\t\t\t\treturn entry.getAllModels?.() ?? entry.getModels();\n\t\t\t} catch {\n\t\t\t\treturn [];\n\t\t\t}\n\t\t}\n\n\t\tconst models: AnyModel[] = [];\n\t\tfor (const entry of this.providers.values()) {\n\t\t\ttry {\n\t\t\t\tmodels.push(...(entry.getAllModels?.() ?? entry.getModels()));\n\t\t\t} catch {\n\t\t\t\t// Best-effort: ill-behaved providers yield no models.\n\t\t\t}\n\t\t}\n\t\treturn models;\n\t}\n\n\tgetModelsOfType<TType extends ModelType>(type: TType, provider?: string): readonly ModelTypeMap[TType][] {\n\t\treturn this.getAllModels(provider).filter((model): model is ModelTypeMap[TType] => isModelType(model, type));\n\t}\n\n\tgetModel(provider: string, id: string): Model<Api> | undefined {\n\t\treturn this.getModels(provider).find((model) => model.id === id);\n\t}\n\n\tgetModelOfType<TType extends ModelType>(type: TType, provider: string, id: string): ModelTypeMap[TType] | undefined {\n\t\treturn this.getModelsOfType(type, provider).find((model) => model.id === id);\n\t}\n\n\tprivate supersedeProviderRefresh(providerId: string): number {\n\t\tconst generation = (this.refreshGenerations.get(providerId) ?? 0) + 1;\n\t\tthis.refreshGenerations.set(providerId, generation);\n\t\tconst previous = this.refreshControllers.get(providerId);\n\t\tif (previous) {\n\t\t\tthis.refreshControllers.delete(providerId);\n\t\t\tprevious.abort();\n\t\t}\n\t\treturn generation;\n\t}\n\n\tprivate beginProviderRefresh(providerId: string): { generation: number; controller: AbortController } {\n\t\tconst generation = this.supersedeProviderRefresh(providerId);\n\t\tconst controller = new AbortController();\n\t\tthis.refreshControllers.set(providerId, controller);\n\t\treturn { generation, controller };\n\t}\n\n\tprivate publishProviderModels(\n\t\tproviderId: string,\n\t\tgeneration: number,\n\t\tsignal: AbortSignal,\n\t\tpublication: ModelsPublication,\n\t): Promise<boolean> {\n\t\tconst previous = this.publicationChains.get(providerId) ?? Promise.resolve();\n\t\tconst queued = (async () => {\n\t\t\tawait previous.catch(() => {});\n\t\t\tif (signal.aborted || this.refreshGenerations.get(providerId) !== generation) return false;\n\n\t\t\tif (publication.persist === null) {\n\t\t\t\tawait this.modelsStore.delete(providerId, { signal });\n\t\t\t} else if (publication.persist !== undefined) {\n\t\t\t\tawait this.modelsStore.write(providerId, structuredClone(publication.persist), { signal });\n\t\t\t}\n\n\t\t\tif (signal.aborted || this.refreshGenerations.get(providerId) !== generation) return false;\n\t\t\tpublication.update?.();\n\t\t\treturn true;\n\t\t})();\n\t\tconst tail = queued.catch(() => {});\n\t\tthis.publicationChains.set(providerId, tail);\n\t\tvoid tail.then(() => {\n\t\t\tif (this.publicationChains.get(providerId) === tail) this.publicationChains.delete(providerId);\n\t\t});\n\t\treturn raceWithAbortSignal(queued, signal);\n\t}\n\n\tprivate async runProviderRefreshPhase(\n\t\tprovider: Provider & Required<Pick<Provider, \"refreshModels\">>,\n\t\tcredential: Credential | undefined,\n\t\tallowNetwork: boolean,\n\t\tforce: boolean | undefined,\n\t\tgeneration: number,\n\t\tsignal: AbortSignal,\n\t): Promise<void> {\n\t\tconst stored = await this.modelsStore.read(provider.id, { signal });\n\t\tawait provider.refreshModels({\n\t\t\tcredential,\n\t\t\tstored: stored ? withKnownModelTypes(structuredClone(stored)) : undefined,\n\t\t\tpublish: (publication) => this.publishProviderModels(provider.id, generation, signal, publication),\n\t\t\tallowNetwork,\n\t\t\tforce: allowNetwork ? force : undefined,\n\t\t\tsignal,\n\t\t\tbaseUrl: provider.baseUrl,\n\t\t});\n\t}\n\n\tasync refresh(options: ModelsRefreshOptions = {}): Promise<ModelsRefreshResult> {\n\t\tconst allowNetwork = options.allowNetwork ?? true;\n\t\tconst callerSignal = operationSignal(options.signal);\n\t\tconst errors = new Map<string, Error>();\n\t\tif (callerSignal.aborted) return { aborted: true, errors };\n\t\tconst selected = options.providers ? new Set(options.providers) : undefined;\n\t\tconst refreshable = Array.from(this.providers.values()).filter(\n\t\t\t(provider): provider is Provider & Required<Pick<Provider, \"refreshModels\">> =>\n\t\t\t\tprovider.refreshModels !== undefined && (!selected || selected.has(provider.id)),\n\t\t);\n\n\t\tconst refresh = Promise.all(\n\t\t\trefreshable.map(async (provider) => {\n\t\t\t\tconst { generation, controller } = this.beginProviderRefresh(provider.id);\n\t\t\t\tconst signal = AbortSignal.any([callerSignal, controller.signal]);\n\t\t\t\tconst operation = (async () => {\n\t\t\t\t\tlet storedCredential: Credential | undefined;\n\t\t\t\t\tlet credentialError: unknown;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tstoredCredential = await this.readCredential(provider.id, signal);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tcredentialError = error;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Restore cached provider state before auth resolution or network access.\n\t\t\t\t\tawait this.runProviderRefreshPhase(provider, storedCredential, false, undefined, generation, signal);\n\t\t\t\t\tif (credentialError !== undefined) throw credentialError;\n\t\t\t\t\tif (!allowNetwork || signal.aborted) return;\n\n\t\t\t\t\tconst network = await this.resolveNetworkRefresh(provider, storedCredential, signal);\n\t\t\t\t\tif (!network) return;\n\t\t\t\t\tawait this.runProviderRefreshPhase(\n\t\t\t\t\t\tprovider,\n\t\t\t\t\t\tnetwork.credential,\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t\toptions.force,\n\t\t\t\t\t\tgeneration,\n\t\t\t\t\t\tsignal,\n\t\t\t\t\t);\n\t\t\t\t})();\n\n\t\t\t\ttry {\n\t\t\t\t\tawait raceWithAbortSignal(operation, signal);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (!signal.aborted) {\n\t\t\t\t\t\terrors.set(\n\t\t\t\t\t\t\tprovider.id,\n\t\t\t\t\t\t\terror instanceof Error\n\t\t\t\t\t\t\t\t? error\n\t\t\t\t\t\t\t\t: new ModelsError(\"model_source\", `Model refresh failed for ${provider.id}`, { cause: error }),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} finally {\n\t\t\t\t\tif (this.refreshControllers.get(provider.id) === controller) {\n\t\t\t\t\t\tthis.refreshControllers.delete(provider.id);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}),\n\t\t);\n\n\t\ttry {\n\t\t\tawait raceWithAbortSignal(refresh, callerSignal);\n\t\t} catch (error) {\n\t\t\tif (!callerSignal.aborted) throw error;\n\t\t}\n\n\t\treturn { aborted: callerSignal.aborted, errors: new Map(errors) };\n\t}\n\n\t/** The credential for the network refresh phase, or undefined when the provider is not configured. */\n\tprivate async resolveNetworkRefresh(\n\t\tprovider: Provider,\n\t\tstored: Credential | undefined,\n\t\tsignal: AbortSignal,\n\t): Promise<{ credential?: Credential } | undefined> {\n\t\tif (provider.refreshModelsAuth === \"configured\") {\n\t\t\treturn (await this.checkProviderAuth(provider, stored, signal)) ? {} : undefined;\n\t\t}\n\t\tconst credential = await this.resolveRefreshCredential(provider, stored, signal);\n\t\treturn credential ? { credential } : undefined;\n\t}\n\n\tprivate async resolveRefreshCredential(\n\t\tprovider: Provider,\n\t\tstored: Credential | undefined,\n\t\tsignal: AbortSignal,\n\t): Promise<Credential | undefined> {\n\t\tif (stored?.type === \"oauth\") {\n\t\t\tconst oauth = provider.auth.oauth;\n\t\t\tif (!oauth) return undefined;\n\t\t\tif (Date.now() < stored.expires) return stored;\n\t\t\tif (signal.aborted) return undefined;\n\t\t\t// A refresh that has started survives cancellation or a superseding model refresh, so a\n\t\t\t// rotated refresh token is always persisted. A newer refresh then sees the fresh credential.\n\t\t\treturn refreshStoredOAuthCredential(\n\t\t\t\tthis.credentials,\n\t\t\t\tprovider.id,\n\t\t\t\toauth,\n\t\t\t\t(current) => Date.now() >= current.expires,\n\t\t\t\tsignal,\n\t\t\t);\n\t\t}\n\n\t\tconst apiKey = provider.auth.apiKey;\n\t\tif (!apiKey) return undefined;\n\t\tconst credential = stored?.type === \"api_key\" ? stored : undefined;\n\t\tconst result = await apiKey.resolve({ ctx: this.authContext, credential, signal });\n\t\tif (!result) return undefined;\n\t\treturn { type: \"api_key\", key: result.auth.apiKey, env: result.env };\n\t}\n\n\tprivate async readCredential(providerId: string, signal: AbortSignal): Promise<Credential | undefined> {\n\t\ttry {\n\t\t\treturn await this.credentials.read(providerId, { signal });\n\t\t} catch (error) {\n\t\t\tthrow new ModelsError(\"auth\", `Credential store read failed for ${providerId}`, { cause: error });\n\t\t}\n\t}\n\n\tprivate async checkProviderAuth(\n\t\tprovider: Provider,\n\t\tcredential: Credential | undefined,\n\t\tsignal: AbortSignal,\n\t): Promise<AuthCheck | undefined> {\n\t\tif (credential?.type === \"oauth\") {\n\t\t\treturn provider.auth.oauth ? { source: \"OAuth\", type: \"oauth\" } : undefined;\n\t\t}\n\t\tconst apiKey = provider.auth.apiKey;\n\t\tif (!apiKey) return undefined;\n\t\tif (apiKey.check) {\n\t\t\ttry {\n\t\t\t\treturn await apiKey.check({\n\t\t\t\t\tctx: this.authContext,\n\t\t\t\t\tcredential: credential?.type === \"api_key\" ? credential : undefined,\n\t\t\t\t\tsignal,\n\t\t\t\t});\n\t\t\t} catch (error) {\n\t\t\t\tthrow new ModelsError(\"auth\", `API key auth check failed for provider ${provider.id}`, { cause: error });\n\t\t\t}\n\t\t}\n\n\t\tconst resolution = await resolveProviderAuth(provider, this.credentials, this.authContext, { signal });\n\t\treturn resolution ? { source: resolution.source, type: \"api_key\" } : undefined;\n\t}\n\n\tcheckAuth(providerId: string, options?: AuthOperationOptions): Promise<AuthCheck | undefined> {\n\t\tconst signal = operationSignal(options?.signal);\n\t\tconst check = (async () => {\n\t\t\tsignal.throwIfAborted();\n\t\t\tconst provider = this.providers.get(providerId);\n\t\t\tif (!provider) return undefined;\n\t\t\treturn this.checkProviderAuth(provider, await this.readCredential(providerId, signal), signal);\n\t\t})();\n\t\treturn raceWithAbortSignal(check, signal);\n\t}\n\n\tprivate async getAuthenticatedProviders(providerId: string | undefined, signal: AbortSignal) {\n\t\tsignal.throwIfAborted();\n\t\tconst providers = providerId\n\t\t\t? [this.providers.get(providerId)].filter((entry) => entry !== undefined)\n\t\t\t: this.getProviders();\n\t\tconst checks = await Promise.all(\n\t\t\tproviders.map(async (provider) => {\n\t\t\t\tconst credential = await this.readCredential(provider.id, signal);\n\t\t\t\treturn { provider, credential, auth: await this.checkProviderAuth(provider, credential, signal) };\n\t\t\t}),\n\t\t);\n\t\treturn checks.filter((entry) => entry.auth !== undefined);\n\t}\n\n\tgetAvailable(providerId?: string, options?: AuthOperationOptions): Promise<readonly Model<Api>[]> {\n\t\tconst signal = operationSignal(options?.signal);\n\t\tconst available = (async () => {\n\t\t\tconst providers = await this.getAuthenticatedProviders(providerId, signal);\n\t\t\treturn providers.flatMap(({ provider, credential }) => {\n\t\t\t\tconst models = provider.getModels();\n\t\t\t\treturn provider.filterModels?.(models, credential) ?? models;\n\t\t\t});\n\t\t})();\n\t\treturn raceWithAbortSignal(available, signal);\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\treturn (await this.getAllAvailable(providerId, options)).filter((model): model is ModelTypeMap[TType] =>\n\t\t\tisModelType(model, type),\n\t\t);\n\t}\n\n\tgetAllAvailable(providerId?: string, options?: AuthOperationOptions): Promise<readonly AnyModel[]> {\n\t\tconst signal = operationSignal(options?.signal);\n\t\tconst available = (async () => {\n\t\t\tconst providers = await this.getAuthenticatedProviders(providerId, signal);\n\t\t\treturn providers.flatMap(({ provider, credential }) => {\n\t\t\t\tconst models = provider.getAllModels?.() ?? provider.getModels();\n\t\t\t\tif (provider.filterAllModels) return provider.filterAllModels(models, credential);\n\t\t\t\tif (!provider.filterModels) return models;\n\t\t\t\tconst availableChatIds = new Set(\n\t\t\t\t\tprovider.filterModels(provider.getModels(), credential).map((model) => model.id),\n\t\t\t\t);\n\t\t\t\treturn models.filter((model) => !isModelType(model, \"chat\") || availableChatIds.has(model.id));\n\t\t\t});\n\t\t})();\n\t\treturn raceWithAbortSignal(available, signal);\n\t}\n\n\tgetAuth(providerId: string, overrides?: AuthResolutionOverrides): Promise<AuthResult | undefined>;\n\tgetAuth(model: AnyModel, overrides?: AuthResolutionOverrides): Promise<AuthResult | undefined>;\n\tasync getAuth(\n\t\tproviderOrModel: string | AnyModel,\n\t\toverrides?: AuthResolutionOverrides,\n\t): Promise<AuthResult | undefined> {\n\t\tconst signal = operationSignal(overrides?.signal);\n\t\tconst providerId = typeof providerOrModel === \"string\" ? providerOrModel : providerOrModel.provider;\n\t\tconst provider = this.providers.get(providerId);\n\t\tif (!provider) return undefined;\n\t\tconst result = await resolveProviderAuth(provider, this.credentials, this.authContext, { ...overrides, signal });\n\t\tif (!result || typeof providerOrModel === \"string\" || !providerOrModel.headers) return result;\n\t\treturn {\n\t\t\t...result,\n\t\t\tauth: {\n\t\t\t\t...result.auth,\n\t\t\t\theaders: mergeHeaders(result.auth.headers, providerOrModel.headers),\n\t\t\t},\n\t\t};\n\t}\n\n\tasync login(\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\tsignal.throwIfAborted();\n\t\tconst provider = this.providers.get(providerId);\n\t\tif (!provider) throw new ModelsError(\"provider\", `Unknown provider: ${providerId}`);\n\t\tconst method = type === \"oauth\" ? provider.auth.oauth : provider.auth.apiKey;\n\t\tif (!method?.login) {\n\t\t\tthrow new ModelsError(\"auth\", `${provider.name} does not support ${type} login`);\n\t\t}\n\t\tconst loginOperation: Promise<Credential> = method.login({ ...interaction, signal }, options);\n\t\tconst credential = await raceWithAbortSignal(loginOperation, signal);\n\t\tlet mutationStarted = false;\n\t\tlet markMutationStarted: (() => void) | undefined;\n\t\tconst started = new Promise<void>((resolve) => {\n\t\t\tmarkMutationStarted = resolve;\n\t\t});\n\t\tconst mutation = this.credentials.modify(\n\t\t\tproviderId,\n\t\t\tasync () => {\n\t\t\t\tmutationStarted = true;\n\t\t\t\tmarkMutationStarted?.();\n\t\t\t\treturn credential;\n\t\t\t},\n\t\t\t{ signal },\n\t\t);\n\t\tvoid mutation.catch(() => {});\n\t\ttry {\n\t\t\tawait new Promise<void>((resolve, reject) => {\n\t\t\t\tconst onAbort = () => {\n\t\t\t\t\tif (!mutationStarted) reject(signal.reason);\n\t\t\t\t};\n\t\t\t\tsignal.addEventListener(\"abort\", onAbort, { once: true });\n\t\t\t\tvoid Promise.race([started, mutation]).then(\n\t\t\t\t\t() => {\n\t\t\t\t\t\tsignal.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\tresolve();\n\t\t\t\t\t},\n\t\t\t\t\t(error: unknown) => {\n\t\t\t\t\t\tsignal.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\treject(error);\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\tif (signal.aborted) onAbort();\n\t\t\t});\n\t\t\tawait mutation;\n\t\t} catch (error) {\n\t\t\tsignal.throwIfAborted();\n\t\t\tthrow new ModelsError(\"auth\", `Credential store modify failed for ${providerId}`, { cause: error });\n\t\t}\n\t\treturn credential;\n\t}\n\n\tasync logout(providerId: string, options?: AuthOperationOptions): Promise<void> {\n\t\tconst signal = operationSignal(options?.signal);\n\t\tsignal.throwIfAborted();\n\t\ttry {\n\t\t\tawait this.credentials.delete(providerId, { signal });\n\t\t} catch (error) {\n\t\t\tsignal.throwIfAborted();\n\t\t\tthrow new ModelsError(\"auth\", `Credential store delete failed for ${providerId}`, { cause: error });\n\t\t}\n\t}\n\n\tprivate requireProvider(model: AnyModel): Provider {\n\t\tconst provider = this.providers.get(model.provider);\n\t\tif (!provider) {\n\t\t\tthrow new ModelsError(\"provider\", `Unknown provider: ${model.provider}`);\n\t\t}\n\t\treturn provider;\n\t}\n\n\tprivate requireChatProvider(model: Model<Api>): Provider {\n\t\tassertChatModel(model);\n\t\treturn this.requireProvider(model);\n\t}\n\n\tprivate async applyAuth<\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\trequestModel: TModel;\n\t\trequestOptions: Omit<TOptions, \"transformHeaders\"> & ProviderRequestOptions<TModel>;\n\t}> {\n\t\tthis.requireProvider(model);\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) {\n\t\t\tthrow new ModelsError(\"auth\", `Provider is not configured: ${model.provider}`);\n\t\t}\n\t\tconst auth = resolution.auth;\n\n\t\t// Explicit request options win per-field; the Models-only transform runs last.\n\t\tconst apiKey = options?.apiKey ?? auth.apiKey;\n\t\tconst requestModel: TModel = auth.baseUrl ? { ...model, baseUrl: auth.baseUrl } : model;\n\t\tconst sessionId =\n\t\t\toptions && \"sessionId\" in options && typeof options.sessionId === \"string\" ? options.sessionId : undefined;\n\t\tlet headers = mergeHeaders(\n\t\t\tmergeHeaders(getOpenCodeSessionHeaders(requestModel, sessionId), auth.headers),\n\t\t\toptions?.headers,\n\t\t);\n\t\tif (options?.transformHeaders) headers = await options.transformHeaders(headers ?? {});\n\t\tconst env = resolution.env || options?.env ? { ...(resolution.env ?? {}), ...(options?.env ?? {}) } : undefined;\n\t\tconst identity = mergeClientIdentity(this.identity, options?.identity);\n\t\tconst { transformHeaders: _transformHeaders, ...providerOptions } = options ?? {};\n\t\tconst requestOptions = {\n\t\t\t...providerOptions,\n\t\t\tapiKey,\n\t\t\theaders,\n\t\t\tenv,\n\t\t\t...(identity === undefined ? {} : { identity }),\n\t\t} as Omit<TOptions, \"transformHeaders\"> & ProviderRequestOptions<TModel>;\n\n\t\treturn { requestModel, requestOptions };\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(\n\t\t\tmodel,\n\t\t\tasync () => {\n\t\t\t\tconst provider = this.requireChatProvider(model);\n\t\t\t\tconst { requestModel, requestOptions } = await this.applyAuth(\n\t\t\t\t\tmodel,\n\t\t\t\t\toptions as ModelsApiStreamOptions<Api> | undefined,\n\t\t\t\t);\n\t\t\t\treturn provider.stream(requestModel, transcript, requestOptions as ApiStreamOptions<TApi>);\n\t\t\t},\n\t\t\tobserveModelRequest(model, options, false),\n\t\t\toptions?.signal,\n\t\t);\n\t}\n\n\tasync complete<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\treturn lazyStream(\n\t\t\tmodel,\n\t\t\tasync () => {\n\t\t\t\tconst provider = this.requireChatProvider(model);\n\t\t\t\tconst { requestModel, requestOptions } = await this.applyAuth(model, options);\n\t\t\t\treturn provider.streamSimple(requestModel, transcript, requestOptions as SimpleStreamOptions);\n\t\t\t},\n\t\t\tobserveModelRequest(model, options, false),\n\t\t\toptions?.signal,\n\t\t);\n\t}\n\n\tasync completeSimple(\n\t\tmodel: Model<Api>,\n\t\tcontext: Context,\n\t\toptions?: ModelsSimpleStreamOptions,\n\t): 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(\n\t\t\tmodel,\n\t\t\tasync () => {\n\t\t\t\tconst provider = this.requireChatProvider(model);\n\t\t\t\tif (!provider.fetchDeferred) {\n\t\t\t\t\tthrow new ModelsError(\"provider\", `Provider ${model.provider} does not support deferred responses`);\n\t\t\t\t}\n\t\t\t\tconst { requestModel, requestOptions } = await this.applyAuth(model, options);\n\t\t\t\treturn provider.fetchDeferred(requestModel, handle, requestOptions as DeferredFetchOptions);\n\t\t\t},\n\t\t\tobserveModelRequest(model, options, true),\n\t\t\toptions?.signal,\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\tconst provider = this.requireChatProvider(model);\n\t\tif (!provider.cancelDeferred) {\n\t\t\tthrow new ModelsError(\"provider\", `Provider ${model.provider} does not support deferred responses`);\n\t\t}\n\t\tconst { requestModel, requestOptions } = await this.applyAuth(model, options);\n\t\tawait provider.cancelDeferred(requestModel, handle, requestOptions);\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 provider = this.requireProvider(model);\n\t\t\tif (!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\tconst { requestModel, requestOptions } = await this.applyAuth(model, options);\n\t\t\treturn await provider.generateImages(requestModel, context, requestOptions);\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\tassertClassifierInputSupported(model, context);\n\t\t\tconst provider = this.requireProvider(model);\n\t\t\tif (!provider.classify) {\n\t\t\t\tthrow new ModelsError(\"provider\", `Provider ${model.provider} does not support classification`);\n\t\t\t}\n\t\t\tconst { requestModel, requestOptions } = await this.applyAuth(model, options);\n\t\t\treturn await provider.classify(requestModel, context, requestOptions);\n\t\t} catch (error) {\n\t\t\treturn classifierErrorResult(model, error, options?.signal?.aborted);\n\t\t}\n\t}\n}\n\nexport function createModels(options?: CreateModelsOptions): MutableModels {\n\treturn new ModelsImpl(options);\n}\n\nexport interface CreateProviderOptions<TApi extends Api = Api> {\n\tid: string;\n\t/** Display name. Default: `id`. */\n\tname?: string;\n\tbaseUrl?: string;\n\theaders?: ProviderHeaders;\n\t/** Required — every provider has auth semantics, even ambient/keyless ones. */\n\tauth: ProviderAuth;\n\t/**\n\t * Static baseline models of every type (empty for purely dynamic providers).\n\t * Models without `type` are chat models.\n\t */\n\tmodels: readonly ProviderModel<TApi>[];\n\t/**\n\t * Fetch a dynamic model overlay of every type. createProvider restores and\n\t * publishes it transactionally and drops models of unknown types.\n\t */\n\tfetchModels?: (context: RefreshModelsContext) => Promise<readonly ProviderModel<TApi>[]>;\n\t/** Credential-specific chat model availability. See `Provider.filterModels`. */\n\tfilterModels?: (models: readonly Model<TApi>[], credential: Credential | undefined) => readonly Model<TApi>[];\n\t/** Credential-specific availability across every model type. See `Provider.filterAllModels`. */\n\tfilterAllModels?: (\n\t\tmodels: readonly ProviderModel<TApi>[],\n\t\tcredential: Credential | undefined,\n\t) => readonly ProviderModel<TApi>[];\n\t/**\n\t * Chat implementation: a single one for all chat models, or a map keyed by\n\t * `model.api` for mixed-API providers. Optional when `images` or\n\t * `classifiers` is given.\n\t */\n\tapi?: ProviderStreams | Partial<Record<TApi, ProviderStreams>>;\n\t/** Image-generation implementations keyed by `model.api`. */\n\timages?: Partial<Record<ImageApi, ProviderImages>>;\n\t/** Classifier implementations keyed by `model.api`. */\n\tclassifiers?: Partial<Record<ClassifierApi, ProviderClassifier>>;\n}\n\n/**\n * Builds a provider from parts. Built-in provider factories and models.json\n * custom providers both go through this. A single `api` streams all chat\n * models; an `api` map dispatches on `model.api`, and a model whose api has\n * no entry produces a stream error. One-shot operation maps dispatch on\n * `model.api` the same way. At least one concrete implementation across\n * `api`/`images`/`classifiers` is required; empty maps are rejected.\n */\nexport function createProvider<TApi extends Api = Api>(input: CreateProviderOptions<TApi>): Provider<TApi> {\n\tconst single =\n\t\tinput.api && typeof (input.api as ProviderStreams).stream === \"function\"\n\t\t\t? (input.api as ProviderStreams)\n\t\t\t: undefined;\n\tconst byApi = single || !input.api ? undefined : (input.api as Partial<Record<string, ProviderStreams>>);\n\tconst images = input.images as Partial<Record<string, ProviderImages>> | undefined;\n\tconst classifiers = input.classifiers as Partial<Record<string, ProviderClassifier>> | undefined;\n\tconst streams = single ? [single] : Object.values(byApi ?? {}).filter((entry) => entry !== undefined);\n\tconst imageImplementations = Object.values(images ?? {}).filter((entry) => entry !== undefined);\n\tconst classifierImplementations = Object.values(classifiers ?? {}).filter((entry) => entry !== undefined);\n\tif (streams.length === 0 && imageImplementations.length === 0 && classifierImplementations.length === 0) {\n\t\tthrow new Error(`Provider ${input.id}: at least one of \"api\", \"images\", or \"classifiers\" is required.`);\n\t}\n\n\tconst baselineModels = input.models;\n\tconst fetchModels = input.fetchModels;\n\tconst chatModelsOf = (models: readonly ProviderModel<TApi>[]): readonly Model<TApi>[] =>\n\t\tmodels.filter((model): model is Model<TApi> => isModelType(model, \"chat\"));\n\t// Merged once per publish, not per read: getModels() is on hot paths such as Models.getModel() (#12311).\n\tlet allModels: readonly ProviderModel<TApi>[] = baselineModels;\n\tlet chatModels = chatModelsOf(allModels);\n\tconst setDynamicModels = (dynamicModels: readonly ProviderModel<TApi>[]): void => {\n\t\tconst merged = [...baselineModels];\n\t\tconst indexByKey = new Map<string, number>();\n\t\tconst keyOf = (model: ProviderModel<TApi>) => `${getModelType(model)}\\0${model.id}`;\n\t\tmerged.forEach((model, index) => {\n\t\t\tconst key = keyOf(model);\n\t\t\tif (!indexByKey.has(key)) indexByKey.set(key, index);\n\t\t});\n\t\tfor (const model of dynamicModels) {\n\t\t\tconst key = keyOf(model);\n\t\t\tconst index = indexByKey.get(key);\n\t\t\tif (index !== undefined) {\n\t\t\t\tmerged[index] = model;\n\t\t\t} else {\n\t\t\t\tindexByKey.set(key, merged.length);\n\t\t\t\tmerged.push(model);\n\t\t\t}\n\t\t}\n\t\tallModels = merged;\n\t\tchatModels = chatModelsOf(merged);\n\t};\n\tconst apiFor = (model: Model<Api>): ProviderStreams | undefined => single ?? byApi?.[model.api];\n\n\tconst dispatch = (\n\t\tmodel: Model<Api>,\n\t\trun: (streams: ProviderStreams) => AssistantMessageEventStream,\n\t\tsignal?: AbortSignal,\n\t): AssistantMessageEventStream => {\n\t\tconst streams = apiFor(model);\n\t\tif (!streams) {\n\t\t\treturn lazyStream(\n\t\t\t\tmodel,\n\t\t\t\tasync () => {\n\t\t\t\t\tthrow new ModelsError(\"stream\", `Provider ${input.id} has no API implementation for \"${model.api}\"`);\n\t\t\t\t},\n\t\t\t\tundefined,\n\t\t\t\tsignal,\n\t\t\t);\n\t\t}\n\t\treturn run(streams);\n\t};\n\n\tconst provider: Provider<TApi> = {\n\t\tid: input.id,\n\t\tname: input.name ?? input.id,\n\t\tbaseUrl: input.baseUrl,\n\t\theaders: input.headers,\n\t\tauth: input.auth,\n\t\tgetModels: () => chatModels,\n\t\tgetAllModels: () => allModels,\n\t\trefreshModels: fetchModels\n\t\t\t? async (context) => {\n\t\t\t\t\tif (context.stored) {\n\t\t\t\t\t\tconst restored = context.stored.models\n\t\t\t\t\t\t\t.filter((model) => model.provider === input.id)\n\t\t\t\t\t\t\t.map((model) => model as ProviderModel<TApi>);\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t!(await context.publish({\n\t\t\t\t\t\t\t\tupdate: () => setDynamicModels(restored),\n\t\t\t\t\t\t\t}))\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (!context.allowNetwork || context.signal.aborted) return;\n\t\t\t\t\tconst fetched = await fetchModels(context);\n\t\t\t\t\tif (context.signal.aborted) return;\n\t\t\t\t\tconst refreshed = fetched.filter(hasKnownModelType);\n\t\t\t\t\tawait context.publish({\n\t\t\t\t\t\tpersist: { models: refreshed, checkedAt: Date.now() },\n\t\t\t\t\t\tupdate: () => setDynamicModels(refreshed),\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t: undefined,\n\t\tfilterModels: input.filterModels,\n\t\tfilterAllModels: input.filterAllModels,\n\t\tstream: (model, context, options) =>\n\t\t\tdispatch(model, (streams) => streams.stream(model, context, options), options?.signal),\n\t\tstreamSimple: (model, context, options) =>\n\t\t\tdispatch(model, (streams) => streams.streamSimple(model, context, options), options?.signal),\n\t};\n\n\tif (streams.some((entry) => entry.fetchDeferred !== undefined)) {\n\t\tprovider.fetchDeferred = (model, handle, options) =>\n\t\t\tlazyStream(\n\t\t\t\tmodel,\n\t\t\t\tasync () => {\n\t\t\t\t\tconst implementation = apiFor(model);\n\t\t\t\t\tif (!implementation?.fetchDeferred) {\n\t\t\t\t\t\tthrow new ModelsError(\n\t\t\t\t\t\t\t\"provider\",\n\t\t\t\t\t\t\t`Provider ${input.id} does not support deferred responses for \"${model.api}\"`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\treturn implementation.fetchDeferred(model, handle, options);\n\t\t\t\t},\n\t\t\t\tundefined,\n\t\t\t\toptions?.signal,\n\t\t\t);\n\t}\n\tif (streams.some((entry) => entry.cancelDeferred !== undefined)) {\n\t\tprovider.cancelDeferred = async (model, handle, options) => {\n\t\t\tconst implementation = apiFor(model);\n\t\t\tif (!implementation?.cancelDeferred) {\n\t\t\t\tthrow new ModelsError(\n\t\t\t\t\t\"provider\",\n\t\t\t\t\t`Provider ${input.id} cannot cancel deferred responses for \"${model.api}\"`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait implementation.cancelDeferred(model, handle, options);\n\t\t};\n\t}\n\tif (images && imageImplementations.length > 0) {\n\t\tprovider.generateImages = async (model, context, options) => {\n\t\t\tconst implementation = images[model.api];\n\t\t\tif (!implementation) {\n\t\t\t\treturn imageErrorResult(\n\t\t\t\t\tmodel,\n\t\t\t\t\tnew ModelsError(\n\t\t\t\t\t\t\"provider\",\n\t\t\t\t\t\t`Provider ${input.id} has no image generation implementation for \"${model.api}\"`,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn implementation.generateImages(model, context, options);\n\t\t};\n\t}\n\tif (classifiers && classifierImplementations.length > 0) {\n\t\tprovider.classify = async (model, context, options) => {\n\t\t\tconst implementation = classifiers[model.api];\n\t\t\tif (!implementation) {\n\t\t\t\treturn classifierErrorResult(\n\t\t\t\t\tmodel,\n\t\t\t\t\tnew ModelsError(\"provider\", `Provider ${input.id} has no classifier implementation for \"${model.api}\"`),\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn implementation.classify(model, context, options);\n\t\t};\n\t}\n\n\treturn provider;\n}\n\n/**\n * Runtime-checked narrowing for dynamically looked-up models:\n *\n * ```ts\n * const model = models.getModel(\"anthropic\", \"claude-opus-5-5\");\n * if (model && hasApi(model, \"anthropic-messages\")) {\n * // model: Model<\"anthropic-messages\">, stream options fully typed\n * }\n * ```\n *\n * Non-chat models never match, even when their api id equals `api`.\n */\nexport function hasApi<TApi extends Api>(model: AnyModel, api: TApi): model is Model<TApi> {\n\treturn isModelType(model, \"chat\") && model.api === api;\n}\n\nexport function calculateCost(model: AnyModel, usage: Usage): Usage[\"cost\"] {\n\tconst inputTokens = usage.input + usage.cacheRead + usage.cacheWrite;\n\tlet rates: ModelCostRates = model.cost;\n\tlet matchedThreshold = -1;\n\tfor (const tier of model.cost.tiers ?? []) {\n\t\tif (inputTokens > tier.inputTokensAbove && tier.inputTokensAbove > matchedThreshold) {\n\t\t\trates = tier;\n\t\t\tmatchedThreshold = tier.inputTokensAbove;\n\t\t}\n\t}\n\n\t// Anthropic charges 2x base input for 1h cache writes.\n\tconst longWrite = usage.cacheWrite1h ?? 0;\n\tconst shortWrite = usage.cacheWrite - longWrite;\n\tusage.cost.input = (rates.input / 1000000) * usage.input;\n\tusage.cost.output = (rates.output / 1000000) * usage.output;\n\tusage.cost.cacheRead = (rates.cacheRead / 1000000) * usage.cacheRead;\n\tusage.cost.cacheWrite = (rates.cacheWrite * shortWrite + rates.input * 2 * longWrite) / 1000000;\n\tusage.cost.total = usage.cost.input + usage.cost.output + usage.cost.cacheRead + usage.cost.cacheWrite;\n\tusage.cost.totalFromProvider = false;\n\treturn usage.cost;\n}\n\nconst EXTENDED_THINKING_LEVELS: ModelThinkingLevel[] = [\"off\", \"minimal\", \"low\", \"medium\", \"high\", \"xhigh\", \"max\"];\n\nexport function getSupportedThinkingLevels<TApi extends Api>(model: Model<TApi>): ModelThinkingLevel[] {\n\tif (!model.reasoning) return [\"off\"];\n\n\treturn EXTENDED_THINKING_LEVELS.filter((level) => {\n\t\tconst mapped = model.thinkingLevelMap?.[level];\n\t\tif (mapped === null) return false;\n\t\tif (level === \"xhigh\" || level === \"max\") return mapped !== undefined;\n\t\treturn true;\n\t});\n}\n\nexport function clampThinkingLevel<TApi extends Api>(\n\tmodel: Model<TApi>,\n\tlevel: ModelThinkingLevel,\n): ModelThinkingLevel {\n\tconst availableLevels = getSupportedThinkingLevels(model);\n\tif (availableLevels.includes(level)) return level;\n\n\tconst requestedIndex = EXTENDED_THINKING_LEVELS.indexOf(level);\n\tif (requestedIndex === -1) return availableLevels[0] ?? \"off\";\n\n\tfor (let i = requestedIndex; i < EXTENDED_THINKING_LEVELS.length; i++) {\n\t\tconst candidate = EXTENDED_THINKING_LEVELS[i];\n\t\tif (availableLevels.includes(candidate)) return candidate;\n\t}\n\tfor (let i = requestedIndex - 1; i >= 0; i--) {\n\t\tconst candidate = EXTENDED_THINKING_LEVELS[i];\n\t\tif (availableLevels.includes(candidate)) return candidate;\n\t}\n\treturn availableLevels[0] ?? \"off\";\n}\n\n/**\n * Check if a model supports xhigh thinking level.\n */\nexport function supportsXhigh<TApi extends Api>(model: Model<TApi>): boolean {\n\tif (model.id.includes(\"gpt-5.2\") || model.id.includes(\"gpt-5.3\") || model.id.includes(\"gpt-5.4\")) {\n\t\treturn true;\n\t}\n\tif (\n\t\tmodel.id.includes(\"opus-4-6\") ||\n\t\tmodel.id.includes(\"opus-4.6\") ||\n\t\tmodel.id.includes(\"opus-4-7\") ||\n\t\tmodel.id.includes(\"opus-4.7\") ||\n\t\tmodel.id.includes(\"sonnet-4-6\") ||\n\t\tmodel.id.includes(\"sonnet-4.6\") ||\n\t\tmodel.id.includes(\"haiku-4-5\") ||\n\t\tmodel.id.includes(\"haiku-4.5\")\n\t) {\n\t\treturn true;\n\t}\n\treturn false;\n}\n\n/**\n * Check if a model supports the max thinking level.\n * Currently Anthropic Opus 4.6 and Opus 4.7 only.\n */\nexport function supportsMax<TApi extends Api>(model: Model<TApi>): boolean {\n\treturn (\n\t\tmodel.id.includes(\"opus-4-6\") ||\n\t\tmodel.id.includes(\"opus-4.6\") ||\n\t\tmodel.id.includes(\"opus-4-7\") ||\n\t\tmodel.id.includes(\"opus-4.7\")\n\t);\n}\n\n/**\n * Check if two models are equal by comparing their type, id, and provider.\n * Returns false if either model is null or undefined.\n */\nexport function modelsAreEqual(a: AnyModel | null | undefined, b: AnyModel | null | undefined): boolean {\n\tif (!a || !b) return false;\n\treturn getModelType(a) === getModelType(b) && a.id === b.id && a.provider === b.provider;\n}\n"]}
@@ -185,6 +185,10 @@ export declare const BedrockCompatSchema: import("@draht/schema").Schema<{
185
185
  }>;
186
186
  export declare const MistralConversationsCompatSchema: import("@draht/schema").Schema<{
187
187
  supportsMidConvoSystemMessages?: boolean | undefined;
188
+ supportsStrictMode?: boolean | undefined;
189
+ }>;
190
+ export declare const GoogleCompatSchema: import("@draht/schema").Schema<{
191
+ supportsStrictMode?: boolean | undefined;
188
192
  }>;
189
193
  export declare const SystemOneCompatSchema: import("@draht/schema").Schema<{
190
194
  imageInput?: "assets" | "images" | "state-image-urls" | undefined;
@@ -345,6 +349,13 @@ export declare const CompatSchemasByApi: {
345
349
  }>;
346
350
  readonly "mistral-conversations": import("@draht/schema").Schema<{
347
351
  supportsMidConvoSystemMessages?: boolean | undefined;
352
+ supportsStrictMode?: boolean | undefined;
353
+ }>;
354
+ readonly "google-generative-ai": import("@draht/schema").Schema<{
355
+ supportsStrictMode?: boolean | undefined;
356
+ }>;
357
+ readonly "google-vertex": import("@draht/schema").Schema<{
358
+ supportsStrictMode?: boolean | undefined;
348
359
  }>;
349
360
  readonly "typesafe-system-one": import("@draht/schema").Schema<{
350
361
  imageInput?: "assets" | "images" | "state-image-urls" | undefined;
@@ -491,6 +502,9 @@ export interface BedrockCompat extends Static<typeof BedrockCompatSchema> {
491
502
  /** Compatibility settings for the Mistral chat API. */
492
503
  export interface MistralConversationsCompat extends Static<typeof MistralConversationsCompatSchema> {
493
504
  }
505
+ /** Compatibility settings for the Google Generative AI and Vertex APIs. */
506
+ export interface GoogleCompat extends Static<typeof GoogleCompatSchema> {
507
+ }
494
508
  /** Compatibility settings for System One classifier APIs. */
495
509
  export interface SystemOneCompat extends Static<typeof SystemOneCompatSchema> {
496
510
  }
@@ -1 +1 @@
1
- {"version":3,"file":"compat-schema.d.ts","sourceRoot":"","sources":["../../src/providers/compat-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+D,KAAK,MAAM,EAAc,MAAM,eAAe,CAAC;AAQrH,eAAO,MAAM,2BAA2B,8EAEtC,CAAC;AAeH,eAAO,MAAM,8BAA8B,wGAGzC,CAAC;AAEH,eAAO,MAAM,4BAA4B;;;SAavC,CAAC;AAWH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuFnC,CAAC;AAEF,eAAO,MAAM,0BAA0B;;;EAkBtC,CAAC;AAEF,eAAO,MAAM,mCAAmC;;;;;;;;;;;;;;;;EAO/C,CAAC;AA2LF,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAIxC,CAAC;AAmEH,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;EAGtC,CAAC;AAyFH,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAGxC,CAAC;AASH,eAAO,MAAM,mBAAmB;;EAG9B,CAAC;AAUH,eAAO,MAAM,gCAAgC;;EAG3C,CAAC;AAeH,eAAO,MAAM,qBAAqB;;;EAGhC,CAAC;AAq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OAAO,6BAA6B,CAAC;CAAG;AAChG,wDAAwD;AACxD,MAAM,WAAW,qBAAsB,SAAQ,MAAM,CAAC,OAAO,2BAA2B,CAAC;CAAG;AAC5F,qEAAqE;AACrE,MAAM,WAAW,uBAAwB,SAAQ,MAAM,CAAC,OAAO,6BAA6B,CAAC;CAAG;AAChG,wDAAwD;AACxD,MAAM,WAAW,aAAc,SAAQ,MAAM,CAAC,OAAO,mBAAmB,CAAC;CAAG;AAC5E,uDAAuD;AACvD,MAAM,WAAW,0BAA2B,SAAQ,MAAM,CAAC,OAAO,gCAAgC,CAAC;CAAG;AACtG,2EAA2E;AAC3E,MAAM,WAAW,YAAa,SAAQ,MAAM,CAAC,OAAO,kBAAkB,CAAC;CAAG;AAC1E,6DAA6D;AAC7D,MAAM,WAAW,eAAgB,SAAQ,MAAM,CAAC,OAAO,qBAAqB,CAAC;CAAG"}
@@ -118,7 +118,7 @@ const OpenAICompletionsCompatProperties = {
118
118
  description: "Whether the provider supports the store field. Default: auto-detected from URL.",
119
119
  })),
120
120
  supportsDeveloperRole: optionalCompatBoolean({
121
- description: "Whether the provider supports the developer role instead of system. Default: auto-detected from URL.",
121
+ description: "Whether to send system messages of reasoning models (the system prompt and mid-conversation system messages) with the developer role instead of system. Default: true only for api.openai.com.",
122
122
  }),
123
123
  supportsReasoningEffort: opt(bool({
124
124
  description: "Whether the provider supports reasoning_effort. Default: auto-detected from URL.",
@@ -262,7 +262,7 @@ const OpenAIResponsesCompatProperties = {
262
262
  default: false,
263
263
  })),
264
264
  supportsMidConvoEffort: opt(bool({
265
- description: "Whether thinking level changes are sent as configuration_update input items instead of changing reasoning.effort, so a change keeps the prompt cache. Only used by the openai-responses API, and ignored with Sign in with ChatGPT on the openai provider.",
265
+ description: "Whether thinking level changes are sent as configuration_update input items instead of changing reasoning.effort, so a change keeps the prompt cache. Used by the openai-responses and openai-codex-responses APIs, and ignored with Sign in with ChatGPT on the openai provider.",
266
266
  default: false,
267
267
  })),
268
268
  supportsMaxOutputTokens: opt(bool({
@@ -348,11 +348,24 @@ const MistralConversationsCompatProperties = {
348
348
  description: "Whether the exact model accepts system messages after the conversation has started. When false, later system messages are folded into the leading system message.",
349
349
  default: false,
350
350
  }),
351
+ supportsStrictMode: optionalCompatBoolean({
352
+ description: "Whether the model supports strict (schema-constrained) function tools.",
353
+ default: false,
354
+ }),
351
355
  };
352
356
  export const MistralConversationsCompatSchema = openObject(MistralConversationsCompatProperties, {
353
357
  description: "Compatibility settings for the Mistral chat API.",
354
358
  additionalProperties: true,
355
359
  });
360
+ const GoogleCompatProperties = {
361
+ supportsStrictMode: optionalCompatBoolean({
362
+ description: "Whether the model enforces strict tools through Gemini's VALIDATED function-calling mode. Default: true for model IDs containing gemini-3 or a later version, such as gemini-3-pro or vendor-gemini-4-argon, false otherwise. Set true for Gemini 3+ models served under IDs without the version.",
363
+ }),
364
+ };
365
+ export const GoogleCompatSchema = openObject(GoogleCompatProperties, {
366
+ description: "Compatibility settings for the Google Generative AI and Vertex APIs.",
367
+ additionalProperties: true,
368
+ });
356
369
  const SystemOneCompatProperties = {
357
370
  imageInput: opt(union([stringLiteral("assets"), stringLiteral("images"), stringLiteral("state-image-urls")], {
358
371
  description: 'How the service takes classifier images. "assets" sends TypeSafe\'s assets map (PNG and JPEG) and references the images from the state, as TypeSafe and Jev on Workers AI expect. "images" sends Clef\'s images list of data URLs (PNG, JPEG, and WebP, at most four), as Clef on Workers AI expects. "state-image-urls" places image_url parts before the state, as OpenRouter expects; OpenRouter drops assets without an error. Auto-detected from the provider, baseUrl, and model ID. Classifier models read it from the provider-level compat; models and modelOverrides entries apply to chat models only.',
@@ -380,7 +393,7 @@ const ProviderCompatPropertyOverrides = {
380
393
  description: "Controls the prompt_cache_key request field for openai-completions and openai-responses: auto keeps each API's default, enabled sends it whenever caching is active, disabled never sends it. Default: auto.",
381
394
  }),
382
395
  supportsMidConvoEffort: optionalCompatBoolean({
383
- description: "Whether thinking level changes are sent inside the conversation instead of changing the request's effort, so a change keeps the prompt cache. Used by the anthropic-messages and openai-responses APIs.",
396
+ description: "Whether thinking level changes are sent inside the conversation instead of changing the request's effort, so a change keeps the prompt cache. Used by the anthropic-messages, openai-responses, and openai-codex-responses APIs.",
384
397
  default: false,
385
398
  }),
386
399
  supportsLongCacheRetention: optionalCompatBoolean({
@@ -432,6 +445,8 @@ export const CompatSchemasByApi = {
432
445
  "anthropic-messages": AnthropicMessagesCompatSchema,
433
446
  "bedrock-converse-stream": BedrockCompatSchema,
434
447
  "mistral-conversations": MistralConversationsCompatSchema,
448
+ "google-generative-ai": GoogleCompatSchema,
449
+ "google-vertex": GoogleCompatSchema,
435
450
  "typesafe-system-one": SystemOneCompatSchema,
436
451
  "cloudflare-workers-ai-system-one": SystemOneCompatSchema,
437
452
  };
@@ -441,6 +456,7 @@ const ProviderCompatProperties = mergeCompatProperties([
441
456
  AnthropicMessagesCompatProperties,
442
457
  BedrockCompatProperties,
443
458
  MistralConversationsCompatProperties,
459
+ GoogleCompatProperties,
444
460
  SystemOneCompatProperties,
445
461
  ], ProviderCompatPropertyOverrides);
446
462
  export const ProviderCompatSchema = openObject(ProviderCompatProperties, {