@humain/humain-code 0.5.0 → 0.5.4

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 (121) hide show
  1. package/CHANGELOG.md +47 -1
  2. package/README.md +5 -3
  3. package/dist/agent-monitor/client.d.ts +2 -2
  4. package/dist/agent-monitor/client.d.ts.map +1 -1
  5. package/dist/agent-monitor/client.js +3 -2
  6. package/dist/agent-monitor/client.js.map +1 -1
  7. package/dist/bundle/chunks/anthropic.js +10 -9
  8. package/dist/bundle/chunks/{chunk-DR37WKFZ.js → chunk-AO6FF5JL.js} +1 -1
  9. package/dist/bundle/chunks/{chunk-Q3SFYT2X.js → chunk-EY3LZOUP.js} +1356 -1358
  10. package/dist/bundle/chunks/{chunk-T3HXWZG4.js → chunk-L2VKM23Q.js} +76 -2
  11. package/dist/bundle/chunks/{chunk-5C4VL2AR.js → chunk-ODJUBJK2.js} +2 -2
  12. package/dist/bundle/chunks/{chunk-A6YBWW4T.js → chunk-UJLCKIMZ.js} +646 -495
  13. package/dist/bundle/chunks/{chunk-476XBL3W.js → chunk-Y3OPKKDR.js} +3 -77
  14. package/dist/bundle/chunks/{cli-VXU7OWFU.js → cli-ENEFJH2B.js} +1 -1
  15. package/dist/bundle/chunks/{compat-S2IBVV6V.js → compat-CJBWWYHE.js} +1 -1
  16. package/dist/bundle/chunks/{dist-645GFIWH.js → dist-RKNCFFGM.js} +2 -2
  17. package/dist/bundle/chunks/github-copilot.js +28 -26
  18. package/dist/bundle/chunks/openai-chatgpt.js +2 -2
  19. package/dist/bundle/chunks/openai-codex.js +10 -9
  20. package/dist/bundle/chunks/openrouter.js +10 -9
  21. package/dist/bundle/chunks/radius.js +9 -8
  22. package/dist/bundle/chunks/{runtime-5VFZTMWL.js → runtime-K3F2QDQP.js} +1 -1
  23. package/dist/bundle/chunks/{virtual-modules-GU6AW5ZK.js → virtual-modules-5D6QIJPN.js} +2 -2
  24. package/dist/bundle/cli-runtime.js +1 -1
  25. package/dist/bundle/index.js +4 -4
  26. package/dist/bundle/rpc-entry.js +1 -1
  27. package/dist/core/model-resolver.d.ts.map +1 -1
  28. package/dist/core/model-resolver.js +19 -1
  29. package/dist/core/model-resolver.js.map +1 -1
  30. package/dist/core/model-runtime.d.ts.map +1 -1
  31. package/dist/core/model-runtime.js +24 -2
  32. package/dist/core/model-runtime.js.map +1 -1
  33. package/dist/core/safe-credential-error.d.ts +11 -0
  34. package/dist/core/safe-credential-error.d.ts.map +1 -0
  35. package/dist/core/safe-credential-error.js +14 -0
  36. package/dist/core/safe-credential-error.js.map +1 -0
  37. package/dist/core/sdk.d.ts.map +1 -1
  38. package/dist/core/sdk.js +4 -1
  39. package/dist/core/sdk.js.map +1 -1
  40. package/dist/core/settings-schema.d.ts +3 -0
  41. package/dist/core/settings-schema.d.ts.map +1 -1
  42. package/dist/core/settings-schema.js +6 -0
  43. package/dist/core/settings-schema.js.map +1 -1
  44. package/dist/humain/gateway/catalog.d.ts +36 -0
  45. package/dist/humain/gateway/catalog.d.ts.map +1 -0
  46. package/dist/humain/gateway/catalog.js +74 -0
  47. package/dist/humain/gateway/catalog.js.map +1 -0
  48. package/dist/humain/gateway/client.d.ts +58 -0
  49. package/dist/humain/gateway/client.d.ts.map +1 -0
  50. package/dist/humain/gateway/client.js +212 -0
  51. package/dist/humain/gateway/client.js.map +1 -0
  52. package/dist/humain/gateway/constants.d.ts +23 -0
  53. package/dist/humain/gateway/constants.d.ts.map +1 -0
  54. package/dist/humain/gateway/constants.js +32 -0
  55. package/dist/humain/gateway/constants.js.map +1 -0
  56. package/dist/humain/gateway/http.d.ts +18 -0
  57. package/dist/humain/gateway/http.d.ts.map +1 -0
  58. package/dist/humain/gateway/http.js +274 -0
  59. package/dist/humain/gateway/http.js.map +1 -0
  60. package/dist/humain/gateway/login.d.ts +13 -0
  61. package/dist/humain/gateway/login.d.ts.map +1 -0
  62. package/dist/humain/gateway/login.js +121 -0
  63. package/dist/humain/gateway/login.js.map +1 -0
  64. package/dist/humain/gateway/provider.d.ts +34 -0
  65. package/dist/humain/gateway/provider.d.ts.map +1 -0
  66. package/dist/humain/gateway/provider.js +253 -0
  67. package/dist/humain/gateway/provider.js.map +1 -0
  68. package/dist/humain/gateway/secret-store.d.ts +19 -0
  69. package/dist/humain/gateway/secret-store.d.ts.map +1 -0
  70. package/dist/humain/gateway/secret-store.js +252 -0
  71. package/dist/humain/gateway/secret-store.js.map +1 -0
  72. package/dist/humain/gateway/session-store.d.ts +42 -0
  73. package/dist/humain/gateway/session-store.d.ts.map +1 -0
  74. package/dist/humain/gateway/session-store.js +175 -0
  75. package/dist/humain/gateway/session-store.js.map +1 -0
  76. package/dist/humain/index.d.ts.map +1 -1
  77. package/dist/humain/index.js +2 -0
  78. package/dist/humain/index.js.map +1 -1
  79. package/dist/humain/login-menu.d.ts +14 -0
  80. package/dist/humain/login-menu.d.ts.map +1 -0
  81. package/dist/humain/login-menu.js +21 -0
  82. package/dist/humain/login-menu.js.map +1 -0
  83. package/dist/humain/node-http.d.ts.map +1 -1
  84. package/dist/humain/node-http.js +6 -31
  85. package/dist/humain/node-http.js.map +1 -1
  86. package/dist/humain/redact-assistant-message.d.ts +4 -0
  87. package/dist/humain/redact-assistant-message.d.ts.map +1 -0
  88. package/dist/humain/redact-assistant-message.js +34 -0
  89. package/dist/humain/redact-assistant-message.js.map +1 -0
  90. package/dist/main.d.ts.map +1 -1
  91. package/dist/main.js +17 -4
  92. package/dist/main.js.map +1 -1
  93. package/dist/modes/interactive/components/login-dialog.d.ts +1 -1
  94. package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
  95. package/dist/modes/interactive/components/login-dialog.js +3 -2
  96. package/dist/modes/interactive/components/login-dialog.js.map +1 -1
  97. package/dist/modes/interactive/components/model-selector.d.ts +11 -0
  98. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  99. package/dist/modes/interactive/components/model-selector.js +16 -3
  100. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  101. package/dist/modes/interactive/components/radius-login-selector.d.ts +5 -4
  102. package/dist/modes/interactive/components/radius-login-selector.d.ts.map +1 -1
  103. package/dist/modes/interactive/components/radius-login-selector.js +11 -9
  104. package/dist/modes/interactive/components/radius-login-selector.js.map +1 -1
  105. package/dist/modes/interactive/interactive-mode.d.ts +2 -0
  106. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  107. package/dist/modes/interactive/interactive-mode.js +53 -36
  108. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  109. package/dist/utils/sleep.d.ts +1 -1
  110. package/dist/utils/sleep.d.ts.map +1 -1
  111. package/dist/utils/sleep.js +10 -6
  112. package/dist/utils/sleep.js.map +1 -1
  113. package/docs/assets/humain-code-logo.svg +8 -0
  114. package/docs/humain-code.md +13 -1
  115. package/docs/index.md +1 -1
  116. package/docs/models.md +3 -1
  117. package/docs/providers.md +58 -2
  118. package/docs/quickstart.md +8 -1
  119. package/npm-shrinkwrap.json +2 -2
  120. package/package.json +1 -1
  121. package/schemas/settings.schema.json +19 -0
@@ -1 +1 @@
1
- {"version":3,"file":"model-runtime.js","sourceRoot":"","sources":["../../src/core/model-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAqBN,kBAAkB,EAClB,qBAAqB,EACrB,YAAY,EAIZ,0BAA0B,EAC1B,yBAAyB,EAMzB,UAAU,EAQV,WAAW,EAWX,gBAAgB,GAShB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,KAAK,sBAAsB,MAAM,qCAAqC,CAAC;AAC9E,OAAO,EAAE,eAAe,EAAqB,eAAe,EAAE,MAAM,+CAA+C,CAAC;AACpH,OAAO,EAAE,4BAA4B,EAAE,MAAM,4CAA4C,CAAC;AAC1F,OAAO,EACN,e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e;QACnD,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QACxD,OAAO,KAAK,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;IAC5D,CAAC;CACD","sourcesContent":["import { AsyncLocalStorage } from \"node:async_hooks\";\nimport { dirname, join } from \"node:path\";\nimport {\n\ttype AnyModel,\n\ttype Api,\n\ttype ApiStreamOptions,\n\ttype AssistantImages,\n\ttype AssistantMessage,\n\ttype AssistantMessageEventStream,\n\ttype AuthCheck,\n\ttype AuthInteraction,\n\ttype AuthOperationOptions,\n\ttype AuthResult,\n\ttype AuthType,\n\ttype ClassifierApi,\n\ttype ClassifierContext,\n\ttype ClassifierModel,\n\ttype ClassifierOptions,\n\ttype ClassifierResult,\n\ttype Context,\n\ttype Credential,\n\ttype CredentialInfo,\n\ttype CredentialStore,\n\tclampThinkingLevel,\n\tcommitLoginCredential,\n\tcreateModels,\n\ttype DeferredCancelOptions,\n\ttype DeferredFetchOptions,\n\ttype DeferredHandle,\n\tdefaultProviderAuthContext,\n\tgetOpenCodeSessionHeaders,\n\ttype ImageApi,\n\ttype ImageModel,\n\ttype ImagesContext,\n\ttype ImagesOptions,\n\ttype LoginOptions,\n\tlazyStream,\n\ttype Message,\n\ttype Model,\n\ttype Models,\n\ttype ModelsApiStreamOptions,\n\ttype ModelsClassifierOptions,\n\ttype ModelsDeferredCancelOptions,\n\ttype ModelsDeferredFetchOptions,\n\tModelsError,\n\ttype ModelsImagesOptions,\n\ttype ModelsRefreshOptions,\n\ttype ModelsRefreshResult,\n\ttype ModelsRequestTransforms,\n\ttype ModelsSimpleStreamOptions,\n\ttype ModelsStore,\n\ttype ModelThinkingLevel,\n\ttype ModelType,\n\ttype ModelTypeMap,\n\ttype MutableModels,\n\tnormalizeContext,\n\ttype Provider,\n\ttype ProviderHeaders,\n\ttype ProviderRequestObservation,\n\ttype ProviderRequestOptions,\n\ttype ProviderResponse,\n\ttype SimpleStreamOptions,\n\ttype StreamOptions,\n\ttype Usage,\n} from \"@earendil-works/pi-ai\";\nimport { findEnvKeys } from \"@earendil-works/pi-ai/compat\";\nimport * as builtinProviderCatalog from \"@earendil-works/pi-ai/providers/all\";\nimport { getModelListing, type ModelListing, setModelListing } from \"@earendil-works/pi-ai/providers/model-listing\";\nimport { personalizeOpenRouterCatalog } from \"@earendil-works/pi-ai/providers/openrouter\";\nimport {\n\tassertChatModel,\n\tassertClassifierInputSupported,\n\tassertClassifierModel,\n\tassertImageModel,\n\tclassifierErrorResult,\n\timageErrorResult,\n} from \"@earendil-works/pi-ai/utils/model-operations\";\nimport { getAgentDir } from \"../config.ts\";\nimport {\n\tFileNodeAccountMetadataStore,\n\tInMemoryNodeAccountMetadataStore,\n\ttype NodeAccountMetadataStore,\n} from \"../humain/node-account-fallback.ts\";\nimport { operationSignal, raceWithAbortSignal } from \"../utils/abort.ts\";\nimport {\n\tANTHROPIC_PROVIDER_ID,\n\tAnthropicRateLimitStore,\n\tisOfficialAnthropicBaseUrl,\n\tparseAnthropicRateLimits,\n} from \"./anthropic-account-reporting.ts\";\nimport { AccountSourceReplacementError, AuthStorage as DefaultAuthStorage } from \"./auth-storage.ts\";\nimport { filterBedrockCatalog } from \"./model-catalog-filter.ts\";\nimport { ModelConfig } from \"./model-config.ts\";\nimport { FileModelsStore, InMemoryCodingAgentModelsStore } from \"./models-store.ts\";\nimport {\n\ttype AccountRemoveResult,\n\tOAUTH_ACCOUNT_IDENTITY_FIELDS,\n\tOAuthAccountPool,\n\tsameCredential,\n} from \"./oauth-account-pool.ts\";\nimport {\n\ttype AuthStatus,\n\ttype CompatibilityRequestConfig,\n\tcomposeModelProvider,\n\tconfiguredRequestAuthStatus,\n\ttype ProviderConfigInput,\n\tresolveCompatibilityRequestConfig,\n\tresolveConfiguredModelHeaders,\n\tvalidateExtensionProvider,\n} from \"./provider-composer.ts\";\nimport { withPersonalizedCatalog, withRemoteCatalog } from \"./remote-catalog-provider.ts\";\nimport { isCommandConfigValue, resolveConfigValue } from \"./resolve-config-value.ts\";\nimport { RuntimeCredentials } from \"./runtime-credentials.ts\";\nimport {\n\tcreateVirtualModel,\n\tfindLatestResponse,\n\tisVirtualModel,\n\ttype ModelRoute,\n\ttype ModelRouteReason,\n\ttype VirtualModelDefinition,\n\twithVirtualModels,\n} from \"./virtual-models.ts\";\n\ninterface RegisteredVirtualModel {\n\tmodel: Model<Api>;\n\troute: VirtualModelDefinition[\"route\"];\n}\n\n/**\n * Every provider's chat models as they were when taken (what `getModels()` returned then, in its order), without building the\n * catalogs not yet built: such a provider is held as its listing, whose models are built when first needed. Every model of a\n * listing has the listing's provider as its `provider`.\n */\nclass ChatModelsSnapshot {\n\tprivate readonly parts: readonly (\n\t\t| { provider: string; listing: ModelListing; models?: undefined }\n\t\t| { provider: string; models: readonly Model<Api>[] }\n\t)[];\n\n\tconstructor(providers: readonly Provider[]) {\n\t\tthis.parts = providers.map((provider) => {\n\t\t\tconst listing = getModelListing(provider);\n\t\t\tif (listing) return { provider: provider.id, listing };\n\t\t\ttry {\n\t\t\t\treturn { provider: provider.id, models: provider.getModels() };\n\t\t\t} catch {\n\t\t\t\t// As in Models.getModels(): a provider whose getModels() throws has no models.\n\t\t\t\treturn { provider: provider.id, models: [] };\n\t\t\t}\n\t\t});\n\t}\n\n\t/** The models whose `provider` is one of `providers`, in order. */\n\tofProviders(providers: ReadonlySet<string>): Model<Api>[] {\n\t\tconst models: Model<Api>[] = [];\n\t\tfor (const part of this.parts) {\n\t\t\tif (part.models) {\n\t\t\t\tfor (const model of part.models) if (providers.has(model.provider)) models.push(model);\n\t\t\t} else if (providers.has(part.provider)) {\n\t\t\t\tmodels.push(...part.listing.models());\n\t\t\t}\n\t\t}\n\t\treturn models;\n\t}\n}\n\ninterface ModelRuntimeSnapshot {\n\tall: ChatModelsSnapshot;\n\tavailable: readonly Model<Api>[];\n\tconfiguredProviders: ReadonlySet<string>;\n\tstoredProviders: ReadonlySet<string>;\n\tauth: ReadonlyMap<string, AuthCheck | undefined>;\n}\n\nexport interface CreateModelRuntimeOptions {\n\t/** Credential storage. Defaults to the file at authPath. */\n\tcredentials?: CredentialStore;\n\tauthPath?: string;\n\t/**\n\t * Multi-account OAuth pool. Defaults to `oauth-accounts.json` next to auth.json, or an\n\t * in-memory pool when a custom `credentials` store is supplied.\n\t */\n\toauthAccountPool?: OAuthAccountPool;\n\t/**\n\t * HUMAIN Node fallback policy and labels. Defaults to `humain-node-accounts.json` next to auth.json, or an\n\t * in-memory store when a custom `credentials` store is supplied.\n\t */\n\tnodeAccountMetadata?: NodeAccountMetadataStore;\n\tmodelsPath?: string | null;\n\tmodelsStore?: ModelsStore;\n\tmodelsStorePath?: string;\n\t/** Allow create() to refresh model catalogs over the network. Defaults to false. */\n\tallowModelNetwork?: boolean;\n\t/** Timeout for the create-time network model refresh. */\n\tmodelRefreshTimeoutMs?: number;\n\tcatalogBaseUrl?: string;\n\t/** Optional caller cancellation for initial cache restoration and availability checks. */\n\tsignal?: AbortSignal;\n\t/** Skip initial catalog and availability refresh. Static models remain available. */\n\trefreshOnCreate?: boolean;\n}\n\ntype OAuthAccountObserver = (providerId: string, accountKey: string | undefined) => void;\n\nexport interface ModelRuntimeSimpleStreamOptions extends ModelsSimpleStreamOptions {\n\t/** @internal Reports the account derived from the credential used for this request, before streaming. */\n\tonOAuthAccount?: OAuthAccountObserver;\n}\n\nexport interface ModelRuntimeAuthOverrides extends AuthOperationOptions {\n\t/** @internal Scoped to this auth resolution, never catalog checks or background requests. */\n\tonOAuthAccount?: OAuthAccountObserver;\n\tapiKey?: string;\n\tenv?: Record<string, string>;\n\t/** Require this much remaining OAuth-token validity; defaults to five minutes. */\n\tminOAuthValidityMs?: number;\n}\n\nexport type CredentialSynchronizationOperation =\n\t| \"login\"\n\t| \"logout\"\n\t| \"switchAccount\"\n\t| \"setRuntimeApiKey\"\n\t| \"removeRuntimeApiKey\";\n\n/** Secret-free account metadata, safe for display and host serialization. */\nexport interface AccountInfo {\n\tkey: string;\n\tlabel: string;\n\ttype: AuthType;\n\tactive: boolean;\n\teffective: boolean;\n\texhaustedUntil?: number;\n}\n\nexport interface AccountSource {\n\tsource: \"runtime\" | \"auth_json\" | \"configuration\" | \"environment\";\n\tlabel: string;\n\ttype: AuthType;\n\treadOnly: true;\n\t/** Selected source for the next dispatch, not proof that its credential is valid. */\n\teffective: boolean;\n}\n\n/** Credentials changed successfully, but the local model/auth snapshot could not be synchronized. */\nexport class CredentialSynchronizationError extends Error {\n\treadonly providerId: string;\n\treadonly operation: CredentialSynchronizationOperation;\n\n\tconstructor(providerId: string, operation: CredentialSynchronizationOperation) {\n\t\tsuper(\n\t\t\t`Credential ${operation} committed, but local synchronization failed. Refresh local models or restart before retrying requests.`,\n\t\t);\n\t\tthis.name = \"CredentialSynchronizationError\";\n\t\tthis.providerId = providerId;\n\t\tthis.operation = operation;\n\t}\n}\n\n/** Only prompt/login cancellation creates this marker; backend failures are never relayed. */\nclass LoginCancellationError extends Error {\n\tconstructor() {\n\t\tsuper(\"Login cancelled\");\n\t\tthis.name = \"AbortError\";\n\t}\n}\n\nfunction mergeHeaders(\n\tbase: ProviderHeaders | undefined,\n\toverride: ProviderHeaders | undefined,\n): ProviderHeaders | undefined {\n\tif (!base && !override) return undefined;\n\tconst merged = { ...base };\n\tfor (const [name, value] of Object.entries(override ?? {})) {\n\t\tconst lowerName = name.toLowerCase();\n\t\tfor (const existingName of Object.keys(merged)) {\n\t\t\tif (existingName.toLowerCase() === lowerName) delete merged[existingName];\n\t\t}\n\t\tmerged[name] = value;\n\t}\n\treturn merged;\n}\n\nconst CREDENTIAL_HEADERS = [\"x-api-key\", \"authorization\"] as const;\n\nfunction headerValue(headers: ProviderHeaders | undefined, lowerName: string): string | null | undefined {\n\tfor (const [name, value] of Object.entries(headers ?? {})) if (name.toLowerCase() === lowerName) return value;\n\treturn undefined;\n}\n\n/** True when the final request headers replace or add a credential header the resolved auth did not supply. */\nfunction overridesCredentialHeaders(\n\tresolved: ProviderHeaders | undefined,\n\tfinal: ProviderHeaders | undefined,\n): boolean {\n\treturn CREDENTIAL_HEADERS.some((name) => headerValue(final, name) !== headerValue(resolved, name));\n}\n\n/** Why a request was made. `bug-report` is internal: it is never written to the trace payload. */\nexport type ModelRequestPurpose = \"chat\" | \"compaction\" | \"branch-summary\" | \"cache-warming\" | \"bug-report\";\n\n/** Outcome of one observed submission. Carries no hidden reasoning and no credentials. */\nexport interface ModelResponseObservation {\n\tpurpose: ModelRequestPurpose | undefined;\n\trequestId: string;\n\tsubmissionId: string;\n\tsubmissionNumber: number;\n\toperation: ProviderRequestObservation[\"operation\"];\n\tprovider: string;\n\tapi: string;\n\tmodel: string;\n\t/** `pending` on a superseded submission: its transport outcome was never observed. */\n\tstopReason: \"pending\" | \"stop\" | \"length\" | \"toolUse\" | \"error\" | \"aborted\" | \"deferred\";\n\t/** Final assistant message for chat requests. */\n\tmessage?: AssistantMessage;\n\terrorMessage?: string;\n\tusage?: Usage;\n\t/** True when a later submission of the same request (a transport retry) replaced this one; its outcome is unknown. */\n\tsuperseded: boolean;\n}\n\n/** Read-only, per-session receiver of actual provider submissions. Failures never affect requests. */\nexport interface ModelRequestObserver {\n\tonRequest(\n\t\tobservation: Readonly<ProviderRequestObservation>,\n\t\tpurpose: ModelRequestPurpose | undefined,\n\t): void | Promise<void>;\n\tonResponse(response: Readonly<ModelResponseObservation>): void | Promise<void>;\n\t/** No submission could be observed, or a direct call could not be attributed to one session. */\n\tonUnattributed?(): void | Promise<void>;\n}\n\ninterface ModelRequestScope {\n\tobserver: ModelRequestObserver;\n\tpurpose: ModelRequestPurpose | undefined;\n}\n\nfunction swallow(fn: () => void | Promise<void>): void {\n\ttry {\n\t\tconst result = fn();\n\t\tif (result) result.catch(() => {});\n\t} catch {\n\t\t// Observation is best effort.\n\t}\n}\n\ntype SubmissionLink = Pick<\n\tProviderRequestObservation,\n\t\"requestId\" | \"submissionId\" | \"submissionNumber\" | \"operation\" | \"provider\" | \"api\" | \"model\"\n>;\n\n/**\n * Collects the submissions of one logical request and reports their outcome once. Only the latest\n * submission is held (without its body); a newer submission settles the previous one at once as\n * superseded, so every submission is answered with O(1) storage however many a request makes.\n */\nclass RequestTracker {\n\tprivate readonly scope: ModelRequestScope;\n\tprivate latest: SubmissionLink | undefined;\n\tprivate settled = false;\n\n\tconstructor(scope: ModelRequestScope) {\n\t\tthis.scope = scope;\n\t}\n\n\t/** Wraps a caller `onRequest` so the observer sees the same submissions. */\n\thook(caller: ProviderRequestOptions[\"onRequest\"]): NonNullable<ProviderRequestOptions[\"onRequest\"]> {\n\t\treturn async (value) => {\n\t\t\tconst previous = this.latest;\n\t\t\tthis.latest = {\n\t\t\t\trequestId: value.requestId,\n\t\t\t\tsubmissionId: value.submissionId,\n\t\t\t\tsubmissionNumber: value.submissionNumber,\n\t\t\t\toperation: value.operation,\n\t\t\t\tprovider: value.provider,\n\t\t\t\tapi: value.api,\n\t\t\t\tmodel: value.model,\n\t\t\t};\n\t\t\ttry {\n\t\t\t\tawait this.scope.observer.onRequest(value, this.scope.purpose);\n\t\t\t} catch {\n\t\t\t\t// Observation is best effort.\n\t\t\t}\n\t\t\t// The transport outcome of a replaced submission is not visible here: report it as unknown.\n\t\t\tif (previous) this.report(previous, { stopReason: \"pending\" }, true);\n\t\t\tawait caller?.(value);\n\t\t};\n\t}\n\n\tsettleMessage(message: AssistantMessage): void {\n\t\tthis.settle({\n\t\t\tstopReason: message.stopReason,\n\t\t\tmessage,\n\t\t\terrorMessage: message.errorMessage,\n\t\t\tusage: message.usage,\n\t\t});\n\t}\n\n\tsettleResult(result: { stopReason: string; errorMessage?: string; usage?: Usage }): void {\n\t\tconst stopReason = result.stopReason === \"error\" || result.stopReason === \"aborted\" ? result.stopReason : \"stop\";\n\t\tthis.settle({ stopReason, errorMessage: result.errorMessage, usage: result.usage });\n\t}\n\n\tsettleFailure(aborted: boolean): void {\n\t\tthis.settle({ stopReason: aborted ? \"aborted\" : \"error\" });\n\t}\n\n\tprivate settle(outcome: Pick<ModelResponseObservation, \"stopReason\" | \"message\" | \"errorMessage\" | \"usage\">): void {\n\t\tif (this.settled) return;\n\t\tthis.settled = true;\n\t\tif (this.latest) this.report(this.latest, outcome, false);\n\t\telse swallow(() => this.scope.observer.onUnattributed?.());\n\t}\n\n\tprivate report(\n\t\tsubmission: SubmissionLink,\n\t\toutcome: Pick<ModelResponseObservation, \"stopReason\" | \"message\" | \"errorMessage\" | \"usage\">,\n\t\tsuperseded: boolean,\n\t): void {\n\t\tconst response: ModelResponseObservation = {\n\t\t\tpurpose: this.scope.purpose,\n\t\t\trequestId: submission.requestId,\n\t\t\tsubmissionId: submission.submissionId,\n\t\t\tsubmissionNumber: submission.submissionNumber,\n\t\t\toperation: submission.operation,\n\t\t\tprovider: submission.provider,\n\t\t\tapi: submission.api,\n\t\t\tmodel: submission.model,\n\t\t\t...outcome,\n\t\t\tsuperseded,\n\t\t};\n\t\tswallow(() => this.scope.observer.onResponse(response));\n\t}\n}\n\n/** Configured pi-ai Models collection used by coding-agent and SDK consumers. */\nexport class ModelRuntime implements Models {\n\tprivate readonly models: MutableModels;\n\tprivate readonly credentials: RuntimeCredentials;\n\tprivate readonly oauthAccountPool: OAuthAccountPool;\n\t/** Secret-free HUMAIN Node fallback policy and user labels; keys stay in the credential pool. */\n\treadonly nodeAccountMetadata: NodeAccountMetadataStore;\n\t/** Latest Anthropic API rate-limit headers per account, observed from this runtime's own responses. */\n\treadonly anthropicRateLimits = new AnthropicRateLimitStore();\n\tprivate readonly defaultBuiltins: ReadonlyMap<string, Provider>;\n\tprivate readonly builtins = new Map<string, Provider>();\n\tprivate readonly nativeExtensionProviders = new Map<string, Provider>();\n\tprivate readonly extensionProviders = new Map<string, ProviderConfigInput>();\n\t/** Virtual models by provider id, then model id. */\n\tprivate readonly virtualModels = new Map<string, Map<string, RegisteredVirtualModel>>();\n\tprivate readonly compositionErrors = new Map<string, string>();\n\tprivate readonly modelsPath: string | undefined;\n\tprivate readonly modelNetworkEnabled: boolean;\n\tprivate config: ModelConfig;\n\tprivate snapshot: ModelRuntimeSnapshot = {\n\t\tall: new ChatModelsSnapshot([]),\n\t\tavailable: [],\n\t\tconfiguredProviders: new Set(),\n\t\tstoredProviders: new Set(),\n\t\tauth: new Map(),\n\t};\n\tprivate availabilityRefreshSeq = 0;\n\tprivate availabilityErrorSeq = 0;\n\tprivate readonly providerAvailabilitySeq = new Map<string, number>();\n\tprivate availabilityError: string | undefined;\n\tprivate readonly credentialOperations = new Map<string, Promise<unknown>>();\n\tprivate readonly oauthAccountObserver = new AsyncLocalStorage<OAuthAccountObserver | undefined>();\n\tprivate readonly requestScope = new AsyncLocalStorage<ModelRequestScope>();\n\t/** Observers of sessions that own this runtime; they attribute direct calls made outside any request scope. */\n\tprivate readonly ownerObservers = new Set<ModelRequestObserver>();\n\n\tprivate constructor(\n\t\tcredentials: RuntimeCredentials,\n\t\toauthAccountPool: OAuthAccountPool,\n\t\tnodeAccountMetadata: NodeAccountMetadataStore,\n\t\tconfig: ModelConfig,\n\t\tmodelsPath: string | undefined,\n\t\tmodelsStore: ModelsStore,\n\t\tproviders: readonly Provider[],\n\t\tmodelNetworkEnabled: boolean,\n\t) {\n\t\tthis.credentials = credentials;\n\t\tthis.oauthAccountPool = oauthAccountPool;\n\t\tthis.nodeAccountMetadata = nodeAccountMetadata;\n\t\tthis.config = config;\n\t\tthis.modelsPath = modelsPath;\n\t\tthis.modelNetworkEnabled = modelNetworkEnabled;\n\t\tthis.defaultBuiltins = new Map(providers.map((provider) => [provider.id, provider]));\n\t\tfor (const [providerId, provider] of this.defaultBuiltins) this.builtins.set(providerId, provider);\n\t\tthis.models = createModels({ credentials, modelsStore });\n\t\tthis.rebuildProviders();\n\t}\n\n\tstatic async create(options: CreateModelRuntimeOptions = {}): Promise<ModelRuntime> {\n\t\tconst credentials = new RuntimeCredentials(options.credentials ?? DefaultAuthStorage.create(options.authPath));\n\t\tconst oauthAccountPool =\n\t\t\toptions.oauthAccountPool ??\n\t\t\t(options.credentials\n\t\t\t\t? OAuthAccountPool.inMemory(credentials.accountStore)\n\t\t\t\t: OAuthAccountPool.create(\n\t\t\t\t\t\tcredentials.accountStore,\n\t\t\t\t\t\tjoin(dirname(options.authPath ?? join(getAgentDir(), \"auth.json\")), \"oauth-accounts.json\"),\n\t\t\t\t\t));\n\t\tconst nodeAccountMetadata =\n\t\t\toptions.nodeAccountMetadata ??\n\t\t\t(options.credentials\n\t\t\t\t? new InMemoryNodeAccountMetadataStore()\n\t\t\t\t: new FileNodeAccountMetadataStore(\n\t\t\t\t\t\tjoin(dirname(options.authPath ?? join(getAgentDir(), \"auth.json\")), \"humain-node-accounts.json\"),\n\t\t\t\t\t));\n\t\tconst modelsPath =\n\t\t\toptions.modelsPath === null ? undefined : (options.modelsPath ?? join(getAgentDir(), \"models.json\"));\n\t\tconst config = await ModelConfig.load(modelsPath);\n\t\tconst modelsStore =\n\t\t\toptions.modelsStore ??\n\t\t\t(modelsPath\n\t\t\t\t? new FileModelsStore(options.modelsStorePath ?? join(dirname(modelsPath), \"models-store.json\"))\n\t\t\t\t: new InMemoryCodingAgentModelsStore());\n\t\tconst builtinModelDataGeneratedAt = builtinProviderCatalog.getBuiltinModelDataGeneratedAt();\n\t\tconst providers = builtinProviderCatalog\n\t\t\t.builtinProviders()\n\t\t\t.map((provider) => {\n\t\t\t\tif (provider.id === \"radius\") return provider;\n\t\t\t\t// OpenRouter narrows the catalog to the models, limits and prices of the user's key.\n\t\t\t\tif (provider.id === \"openrouter\") {\n\t\t\t\t\treturn withPersonalizedCatalog(\n\t\t\t\t\t\tprovider,\n\t\t\t\t\t\tpersonalizeOpenRouterCatalog,\n\t\t\t\t\t\toptions.catalogBaseUrl,\n\t\t\t\t\t\tbuiltinModelDataGeneratedAt,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn withRemoteCatalog(provider, options.catalogBaseUrl, builtinModelDataGeneratedAt);\n\t\t\t})\n\t\t\t.map((provider) => {\n\t\t\t\tif (provider.id !== \"amazon-bedrock\") return provider;\n\t\t\t\tconst getModels = provider.getModels.bind(provider);\n\t\t\t\tconst filtered: Provider = { ...provider, getModels: () => filterBedrockCatalog(getModels()) };\n\t\t\t\t// The filter keeps or drops models by id alone: the listing is filtered as the models are.\n\t\t\t\treturn setModelListing(filtered, () => {\n\t\t\t\t\tconst listing = getModelListing(provider);\n\t\t\t\t\treturn listing && { entries: filterBedrockCatalog(listing.entries), models: filtered.getModels };\n\t\t\t\t});\n\t\t\t});\n\t\tconst runtime = new ModelRuntime(\n\t\t\tcredentials,\n\t\t\toauthAccountPool,\n\t\t\tnodeAccountMetadata,\n\t\t\tconfig,\n\t\t\tmodelsPath,\n\t\t\tmodelsStore,\n\t\t\tproviders,\n\t\t\tprocess.env.PI_OFFLINE === undefined,\n\t\t);\n\t\truntime.configureRadiusProviders();\n\t\truntime.rebuildProviders();\n\t\tconst refreshFromNetwork = runtime.modelNetworkEnabled && options.allowModelNetwork === true;\n\t\tconst controller =\n\t\t\trefreshFromNetwork && options.modelRefreshTimeoutMs !== undefined ? new AbortController() : undefined;\n\t\tconst timeout = controller ? setTimeout(() => controller.abort(), options.modelRefreshTimeoutMs) : undefined;\n\t\tconst signal = controller\n\t\t\t? options.signal\n\t\t\t\t? AbortSignal.any([options.signal, controller.signal])\n\t\t\t\t: controller.signal\n\t\t\t: options.signal;\n\t\ttry {\n\t\t\tif (options.refreshOnCreate !== false) {\n\t\t\t\tawait runtime.refresh({ allowNetwork: refreshFromNetwork, signal });\n\t\t\t}\n\t\t} finally {\n\t\t\tif (timeout) clearTimeout(timeout);\n\t\t}\n\t\treturn runtime;\n\t}\n\n\tprivate configureRadiusProviders(): void {\n\t\tthis.builtins.clear();\n\t\tfor (const [providerId, provider] of this.defaultBuiltins) this.builtins.set(providerId, provider);\n\t\tfor (const providerId of this.config.getProviderIds()) {\n\t\t\tconst config = this.config.getProvider(providerId);\n\t\t\tif (config?.oauth !== \"radius\" || !config.baseUrl) continue;\n\t\t\tthis.builtins.set(\n\t\t\t\tproviderId,\n\t\t\t\tbuiltinProviderCatalog.radiusProvider({\n\t\t\t\t\tid: providerId,\n\t\t\t\t\tname: config.name ?? providerId,\n\t\t\t\t\tgateway: config.baseUrl.replace(/\\/v1\\/?$/u, \"\"),\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate providerIds(): Set<string> {\n\t\treturn new Set([\n\t\t\t...this.builtins.keys(),\n\t\t\t...this.nativeExtensionProviders.keys(),\n\t\t\t...this.config.getProviderIds(),\n\t\t\t...this.extensionProviders.keys(),\n\t\t\t...this.virtualModels.keys(),\n\t\t]);\n\t}\n\n\t/** Returns the provider without virtual models, or undefined when only virtual models define it. */\n\tprivate recomposeProvider(providerId: string): Provider | undefined {\n\t\tconst composed = this.composeProvider(providerId);\n\t\tlet provider = composed;\n\t\tif (provider?.auth.apiKey) {\n\t\t\tconst apiKey = provider.auth.apiKey;\n\t\t\tconst withCredentialEnv = (input: Parameters<typeof apiKey.resolve>[0]) => {\n\t\t\t\tconst env = input.credential?.env;\n\t\t\t\tconst ctx = input.ctx;\n\t\t\t\treturn env\n\t\t\t\t\t? { ...input, ctx: { ...ctx, env: async (name: string) => env[name] || (await ctx.env(name)) } }\n\t\t\t\t\t: input;\n\t\t\t};\n\t\t\tprovider = {\n\t\t\t\t...provider,\n\t\t\t\tauth: {\n\t\t\t\t\t...provider.auth,\n\t\t\t\t\tapiKey: {\n\t\t\t\t\t\t...apiKey,\n\t\t\t\t\t\tresolve: async (input) => {\n\t\t\t\t\t\t\tif (input.purpose !== \"catalog\") {\n\t\t\t\t\t\t\t\tconst result = await apiKey.resolve(withCredentialEnv(input));\n\t\t\t\t\t\t\t\tconst key =\n\t\t\t\t\t\t\t\t\t!this.credentials.hasRuntimeApiKey(providerId) &&\n\t\t\t\t\t\t\t\t\tinput.credential?.key &&\n\t\t\t\t\t\t\t\t\tinput.credential.key === result?.auth.apiKey\n\t\t\t\t\t\t\t\t\t\t? this.oauthAccountPool.getAccountKeyForApiKey(providerId, input.credential.key)\n\t\t\t\t\t\t\t\t\t\t: undefined;\n\t\t\t\t\t\t\t\tthis.oauthAccountObserver.getStore()?.(providerId, key);\n\t\t\t\t\t\t\t\treturn result;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// Models restores caches first. Evaluate commands only when it authorizes online auth.\n\t\t\t\t\t\t\tconst credential = await this.credentials.authResolution.run(providerId, () =>\n\t\t\t\t\t\t\t\tthis.credentials.read(providerId, { signal: input.signal }),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif (credential?.type === \"oauth\") return undefined;\n\t\t\t\t\t\t\treturn apiKey.resolve(withCredentialEnv({ ...input, credential }));\n\t\t\t\t\t\t},\n\t\t\t\t\t\tcheck: apiKey.check ? (input) => apiKey.check!(withCredentialEnv(input)) : undefined,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t\tconst oauth = provider?.auth.oauth;\n\t\tif (provider && oauth && this.oauthAccountPool.isPooled(providerId)) {\n\t\t\tprovider = {\n\t\t\t\t...provider,\n\t\t\t\tauth: {\n\t\t\t\t\t...provider.auth,\n\t\t\t\t\toauth: {\n\t\t\t\t\t\t...oauth,\n\t\t\t\t\t\trefresh: async (credential, signal) => {\n\t\t\t\t\t\t\tconst refreshed = { ...(await oauth.refresh(credential, signal)) };\n\t\t\t\t\t\t\tfor (const field of OAUTH_ACCOUNT_IDENTITY_FIELDS) {\n\t\t\t\t\t\t\t\tif (refreshed[field] === undefined && credential[field] !== undefined) {\n\t\t\t\t\t\t\t\t\trefreshed[field] = credential[field];\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn refreshed;\n\t\t\t\t\t\t},\n\t\t\t\t\t\ttoAuth: async (credential) => {\n\t\t\t\t\t\t\tconst auth = await oauth.toAuth(credential);\n\t\t\t\t\t\t\tthis.oauthAccountObserver.getStore()?.(\n\t\t\t\t\t\t\t\tproviderId,\n\t\t\t\t\t\t\t\tthis.oauthAccountPool.getAccountIdentity(providerId, credential)?.key,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn auth;\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t\tif (providerId === \"openrouter\" && provider?.refreshModels && !this.nativeExtensionProviders.has(providerId)) {\n\t\t\tconst refreshModels = provider.refreshModels.bind(provider);\n\t\t\tprovider = {\n\t\t\t\t...provider,\n\t\t\t\trefreshModels: async (context) => {\n\t\t\t\t\tlet credential = context.credential;\n\t\t\t\t\tif (!context.allowNetwork && credential?.type !== \"oauth\") {\n\t\t\t\t\t\tconst stored = this.credentials.getRuntimeApiKey(providerId)\n\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t: await this.credentials.readStored(providerId, { signal: context.signal });\n\t\t\t\t\t\tconst command =\n\t\t\t\t\t\t\tthis.credentials.isExternalCredential(stored) &&\n\t\t\t\t\t\t\tstored?.type === \"api_key\" &&\n\t\t\t\t\t\t\tstored.key !== undefined &&\n\t\t\t\t\t\t\tisCommandConfigValue(stored.key);\n\t\t\t\t\t\tconst configuredKey =\n\t\t\t\t\t\t\tthis.extensionProviders.get(providerId)?.apiKey ?? this.config.getProvider(providerId)?.apiKey;\n\t\t\t\t\t\t// Cache identity checks must not execute commands, resolve headers or refresh OAuth.\n\t\t\t\t\t\tlet key = credential?.key || credential?.env?.OPENROUTER_API_KEY || process.env.OPENROUTER_API_KEY;\n\t\t\t\t\t\tif (command) key = undefined;\n\t\t\t\t\t\telse if (!credential && configuredKey !== undefined) {\n\t\t\t\t\t\t\tkey = isCommandConfigValue(configuredKey) ? undefined : resolveConfigValue(configuredKey);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcredential = key ? { ...credential, type: \"api_key\", key } : undefined;\n\t\t\t\t\t}\n\t\t\t\t\tawait refreshModels({ ...context, credential });\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t\t// The wrappers above change auth and refresh only: the provider's models are still named by its listing.\n\t\tif (provider && composed && provider !== composed) setModelListing(provider, () => getModelListing(composed));\n\t\tconst virtualModels = [...(this.virtualModels.get(providerId)?.values() ?? [])].map((entry) => entry.model);\n\t\tif (virtualModels.length > 0) this.models.setProvider(withVirtualModels(providerId, provider, virtualModels));\n\t\telse if (provider) this.models.setProvider(provider);\n\t\telse this.models.deleteProvider(providerId);\n\t\treturn provider;\n\t}\n\n\t/** The provider without virtual models, or undefined when nothing defines it. */\n\tprivate composeProvider(providerId: string): Provider | undefined {\n\t\tconst base = this.nativeExtensionProviders.get(providerId) ?? this.builtins.get(providerId);\n\t\tconst extension = this.extensionProviders.get(providerId);\n\t\tif (!this.config.getProvider(providerId) && !extension) {\n\t\t\t// No overlays: use the builtin untouched so its auth/login/stream behavior is exact.\n\t\t\tthis.compositionErrors.delete(providerId);\n\t\t\treturn base;\n\t\t}\n\t\ttry {\n\t\t\tconst provider = composeModelProvider(providerId, base, this.config, extension);\n\t\t\tthis.compositionErrors.delete(providerId);\n\t\t\treturn provider;\n\t\t} catch (error) {\n\t\t\tthis.compositionErrors.set(providerId, error instanceof Error ? error.message : String(error));\n\t\t\treturn base;\n\t\t}\n\t}\n\n\tprivate rebuildProviders(): void {\n\t\tthis.models.clearProviders();\n\t\tthis.compositionErrors.clear();\n\t\tfor (const providerId of this.providerIds()) this.recomposeProvider(providerId);\n\t\tthis.updateModelSnapshot();\n\t}\n\n\tprivate updateModelSnapshot(): void {\n\t\tconst all = new ChatModelsSnapshot(this.models.getProviders());\n\t\tthis.snapshot = {\n\t\t\t...this.snapshot,\n\t\t\tall,\n\t\t\tavailable: all.ofProviders(this.snapshot.configuredProviders),\n\t\t};\n\t}\n\n\tprivate async runAvailabilityRefresh(seq: number, errorSeq: number, signal: AbortSignal): Promise<void> {\n\t\tconst providers = this.models.getProviders();\n\t\tconst [available, checks, credentials] = await Promise.all([\n\t\t\tthis.models.getAvailable(undefined, { signal }),\n\t\t\tPromise.all(\n\t\t\t\tproviders.map(\n\t\t\t\t\tasync (provider): Promise<[string, AuthCheck | undefined]> => [\n\t\t\t\t\t\tprovider.id,\n\t\t\t\t\t\tawait this.models.checkAuth(provider.id, { signal }),\n\t\t\t\t\t],\n\t\t\t\t),\n\t\t\t),\n\t\t\tthis.credentials.list({ signal }),\n\t\t]);\n\t\tif (seq !== this.availabilityRefreshSeq) return;\n\t\tconst auth = new Map(checks);\n\t\tconst configuredProviders = new Set(\n\t\t\tchecks\n\t\t\t\t.filter((entry): entry is [string, AuthCheck] => entry[1] !== undefined)\n\t\t\t\t.map(([providerId]) => providerId),\n\t\t);\n\t\tthis.snapshot = {\n\t\t\tall: new ChatModelsSnapshot(this.models.getProviders()),\n\t\t\tavailable: [...available],\n\t\t\tconfiguredProviders,\n\t\t\tstoredProviders: new Set(credentials.map((entry) => entry.providerId)),\n\t\t\tauth,\n\t\t};\n\t\tif (errorSeq === this.availabilityErrorSeq) this.availabilityError = undefined;\n\t}\n\n\tprivate queueAvailabilityRefresh(signal?: AbortSignal): Promise<void> {\n\t\tconst seq = ++this.availabilityRefreshSeq;\n\t\tfor (const [providerId, providerSeq] of this.providerAvailabilitySeq) {\n\t\t\tthis.providerAvailabilitySeq.set(providerId, providerSeq + 1);\n\t\t}\n\t\tconst errorSeq = ++this.availabilityErrorSeq;\n\t\tconst effectiveSignal = operationSignal(signal);\n\t\treturn this.runAvailabilityRefresh(seq, errorSeq, effectiveSignal).catch((error) => {\n\t\t\tif (errorSeq === this.availabilityErrorSeq && !effectiveSignal.aborted) {\n\t\t\t\tthis.availabilityError = error instanceof Error ? error.message : String(error);\n\t\t\t}\n\t\t\tthrow error;\n\t\t});\n\t}\n\n\tprivate async refreshProviderAvailability(providerId: string, signal: AbortSignal): Promise<void> {\n\t\t// Invalidate any full availability pass that started before this credential change.\n\t\t++this.availabilityRefreshSeq;\n\t\tconst providerSeq = (this.providerAvailabilitySeq.get(providerId) ?? 0) + 1;\n\t\tthis.providerAvailabilitySeq.set(providerId, providerSeq);\n\t\tconst errorSeq = ++this.availabilityErrorSeq;\n\t\ttry {\n\t\t\tconst [available, auth, credential] = await Promise.all([\n\t\t\t\tthis.models.getAvailable(providerId, { signal }),\n\t\t\t\tthis.models.checkAuth(providerId, { signal }),\n\t\t\t\tthis.credentials.read(providerId, { signal }),\n\t\t\t]);\n\t\t\tsignal.throwIfAborted();\n\t\t\tif (this.providerAvailabilitySeq.get(providerId) !== providerSeq) return;\n\t\t\tconst configuredProviders = new Set(this.snapshot.configuredProviders);\n\t\t\tconst storedProviders = new Set(this.snapshot.storedProviders);\n\t\t\tconst authByProvider = new Map(this.snapshot.auth);\n\t\t\tif (auth) {\n\t\t\t\tconfiguredProviders.add(providerId);\n\t\t\t\tauthByProvider.set(providerId, auth);\n\t\t\t} else {\n\t\t\t\tconfiguredProviders.delete(providerId);\n\t\t\t\tauthByProvider.delete(providerId);\n\t\t\t}\n\t\t\tif (credential) storedProviders.add(providerId);\n\t\t\telse storedProviders.delete(providerId);\n\t\t\tconst all = new ChatModelsSnapshot(this.models.getProviders());\n\t\t\tconst availableById = new Map(\n\t\t\t\t[...this.snapshot.available.filter((model) => model.provider !== providerId), ...available].map((model) => [\n\t\t\t\t\t`${model.provider}\\0${model.id}`,\n\t\t\t\t\tmodel,\n\t\t\t\t]),\n\t\t\t);\n\t\t\t// (Only the providers of these models have models to look up.)\n\t\t\tconst availableProviders = new Set(Array.from(availableById.values(), (model) => model.provider));\n\t\t\tthis.snapshot = {\n\t\t\t\tall,\n\t\t\t\tavailable: all\n\t\t\t\t\t.ofProviders(availableProviders)\n\t\t\t\t\t.flatMap((model) => availableById.get(`${model.provider}\\0${model.id}`) ?? []),\n\t\t\t\tconfiguredProviders,\n\t\t\t\tstoredProviders,\n\t\t\t\tauth: authByProvider,\n\t\t\t};\n\t\t\tif (errorSeq === this.availabilityErrorSeq) this.availabilityError = undefined;\n\t\t} catch (error) {\n\t\t\tif (\n\t\t\t\tthis.providerAvailabilitySeq.get(providerId) === providerSeq &&\n\t\t\t\terrorSeq === this.availabilityErrorSeq &&\n\t\t\t\t!signal.aborted\n\t\t\t) {\n\t\t\t\tthis.availabilityError = error instanceof Error ? error.message : String(error);\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tgetProviders(): readonly Provider[] {\n\t\treturn this.models.getProviders();\n\t}\n\n\tgetProvider(providerId: string): Provider | undefined {\n\t\treturn this.models.getProvider(providerId);\n\t}\n\n\tgetModels(providerId?: string): readonly Model<Api>[] {\n\t\treturn this.models.getModels(providerId);\n\t}\n\n\tgetModel(providerId: string, modelId: string): Model<Api> | undefined {\n\t\treturn this.models.getModel(providerId, modelId);\n\t}\n\n\t/**\n\t * Every chat model in `getModels()` order, for choosing models by provider, id and name without building every catalog:\n\t * a provider whose catalog is not built yet is listed by stand-ins that have only `provider`, `id` and `name`.\n\t * `model()` returns the model a stand-in stands for (building that provider's catalog), and a model as it is.\n\t */\n\tgetModelChoices(): { models: readonly Model<Api>[]; model(choice: Model<Api>): Model<Api> } {\n\t\tconst models: Model<Api>[] = [];\n\t\tconst standIns = new Map<Model<Api>, { listing: ModelListing; index: number }>();\n\t\tfor (const provider of this.models.getProviders()) {\n\t\t\tconst listing = getModelListing(provider);\n\t\t\tif (!listing) {\n\t\t\t\ttry {\n\t\t\t\t\tmodels.push(...provider.getModels());\n\t\t\t\t} catch {\n\t\t\t\t\t// As in Models.getModels(): a provider whose getModels() throws has no models.\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tlisting.entries.forEach((entry, index) => {\n\t\t\t\tconst standIn = entry as Model<Api>;\n\t\t\t\tmodels.push(standIn);\n\t\t\t\tstandIns.set(standIn, { listing, index });\n\t\t\t});\n\t\t}\n\t\treturn {\n\t\t\tmodels,\n\t\t\tmodel: (choice) => {\n\t\t\t\tconst standIn = standIns.get(choice);\n\t\t\t\treturn standIn ? standIn.listing.models()[standIn.index] : choice;\n\t\t\t},\n\t\t};\n\t}\n\n\tgetModelsOfType<TType extends ModelType>(type: TType, providerId?: string): readonly ModelTypeMap[TType][] {\n\t\treturn this.models.getModelsOfType(type, providerId);\n\t}\n\n\tgetModelOfType<TType extends ModelType>(\n\t\ttype: TType,\n\t\tproviderId: string,\n\t\tmodelId: string,\n\t): ModelTypeMap[TType] | undefined {\n\t\treturn this.models.getModelOfType(type, providerId, modelId);\n\t}\n\n\tgetAllModels(providerId?: string): readonly AnyModel[] {\n\t\treturn this.models.getAllModels(providerId);\n\t}\n\n\tgetAvailableOfType<TType extends ModelType>(\n\t\ttype: TType,\n\t\tproviderId?: string,\n\t\toptions?: AuthOperationOptions,\n\t): Promise<readonly ModelTypeMap[TType][]> {\n\t\treturn this.models.getAvailableOfType(type, providerId, options);\n\t}\n\n\tgetAllAvailable(providerId?: string, options?: AuthOperationOptions): Promise<readonly AnyModel[]> {\n\t\treturn this.models.getAllAvailable(providerId, options);\n\t}\n\n\tasync checkAuth(providerId: string, options?: AuthOperationOptions): Promise<AuthCheck | undefined> {\n\t\treturn this.models.checkAuth(providerId, options);\n\t}\n\n\tasync getAvailable(providerId?: string, options?: AuthOperationOptions): Promise<readonly Model<Api>[]> {\n\t\tif (providerId) {\n\t\t\tconst errorSeq = ++this.availabilityErrorSeq;\n\t\t\ttry {\n\t\t\t\tconst available = await this.models.getAvailable(providerId, options);\n\t\t\t\tif (errorSeq === this.availabilityErrorSeq) this.availabilityError = undefined;\n\t\t\t\treturn available;\n\t\t\t} catch (error) {\n\t\t\t\tif (errorSeq === this.availabilityErrorSeq && !options?.signal?.aborted) {\n\t\t\t\t\tthis.availabilityError = error instanceof Error ? error.message : String(error);\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t\tawait this.queueAvailabilityRefresh(options?.signal);\n\t\treturn this.snapshot.available;\n\t}\n\n\tgetAvailableSnapshot(): readonly Model<Api>[] {\n\t\treturn this.snapshot.available;\n\t}\n\n\tgetError(): string | undefined {\n\t\tconst errors: string[] = [];\n\t\tconst configError = this.config.getError();\n\t\tif (configError) errors.push(configError);\n\t\tfor (const [providerId, error] of this.compositionErrors) {\n\t\t\terrors.push(`Provider \"${providerId}\": ${error}`);\n\t\t}\n\t\tif (this.availabilityError) errors.push(`Availability refresh: ${this.availabilityError}`);\n\t\tconst poolError = this.oauthAccountPool.getError();\n\t\tif (poolError) errors.push(poolError);\n\t\treturn errors.length > 0 ? errors.join(\"\\n\\n\") : undefined;\n\t}\n\n\tgetRegisteredProviderConfig(providerId: string): ProviderConfigInput | undefined {\n\t\treturn this.extensionProviders.get(providerId);\n\t}\n\n\tgetRegisteredProviderIds(): readonly string[] {\n\t\treturn [...new Set([...this.extensionProviders.keys(), ...this.nativeExtensionProviders.keys()])];\n\t}\n\n\tgetRegisteredNativeProvider(providerId: string): Provider | undefined {\n\t\treturn this.nativeExtensionProviders.get(providerId);\n\t}\n\n\t/** @internal Compatibility fallback for ModelRegistry when provider auth is unconfigured. */\n\tgetCompatibilityRequestConfig(model: Model<Api>): CompatibilityRequestConfig {\n\t\treturn resolveCompatibilityRequestConfig(\n\t\t\tmodel,\n\t\t\tthis.config.getProvider(model.provider),\n\t\t\tthis.extensionProviders.get(model.provider),\n\t\t);\n\t}\n\n\tisUsingOAuth(providerId: string): boolean {\n\t\treturn this.snapshot.auth.get(providerId)?.type === \"oauth\";\n\t}\n\n\tisUsingSubscription(providerId: string): boolean {\n\t\tconst auth = this.models.getProvider(providerId)?.auth;\n\t\treturn this.isUsingOAuth(providerId)\n\t\t\t? auth?.oauth?.isSubscription === true\n\t\t\t: this.hasConfiguredAuth(providerId) && auth?.apiKey?.isSubscription === true;\n\t}\n\n\thasConfiguredAuth(providerId: string): boolean {\n\t\treturn this.snapshot.configuredProviders.has(providerId);\n\t}\n\n\tgetAuth(providerId: string, overrides?: ModelRuntimeAuthOverrides): Promise<AuthResult | undefined>;\n\tgetAuth(model: AnyModel, overrides?: ModelRuntimeAuthOverrides): Promise<AuthResult | undefined>;\n\tasync getAuth(\n\t\tproviderOrModel: string | AnyModel,\n\t\toverrides: ModelRuntimeAuthOverrides = {},\n\t): Promise<AuthResult | undefined> {\n\t\tconst providerId = typeof providerOrModel === \"string\" ? providerOrModel : providerOrModel.provider;\n\t\tconst resolution = await this.credentials.authResolution.run(providerId, () =>\n\t\t\tthis.oauthAccountObserver.run(overrides.onOAuthAccount, () =>\n\t\t\t\ttypeof providerOrModel === \"string\"\n\t\t\t\t\t? this.models.getAuth(providerOrModel, overrides)\n\t\t\t\t\t: this.models.getAuth(providerOrModel, overrides),\n\t\t\t),\n\t\t);\n\t\tif (typeof providerOrModel === \"string\") return resolution;\n\t\tif (!resolution) return undefined;\n\t\tconst configuredHeaders = resolveConfiguredModelHeaders(\n\t\t\tproviderOrModel,\n\t\t\tthis.config.getProvider(providerOrModel.provider),\n\t\t\tthis.extensionProviders.get(providerOrModel.provider),\n\t\t\t{ ...(resolution.env ?? {}), ...(overrides.env ?? {}) },\n\t\t);\n\t\treturn {\n\t\t\t...resolution,\n\t\t\tauth: {\n\t\t\t\t...resolution.auth,\n\t\t\t\theaders: mergeHeaders(resolution.auth.headers, configuredHeaders),\n\t\t\t},\n\t\t};\n\t}\n\n\tprivate protectCredentialOperation<T>(operation: Promise<T>, signal?: AbortSignal, mutation = true): Promise<T> {\n\t\treturn operation.catch((error: unknown) => {\n\t\t\tif (error instanceof CredentialSynchronizationError)\n\t\t\t\tthrow new CredentialSynchronizationError(error.providerId, error.operation);\n\t\t\tif (error instanceof AccountSourceReplacementError) throw new AccountSourceReplacementError();\n\t\t\tif (error instanceof LoginCancellationError) throw new LoginCancellationError();\n\t\t\t// Backends can reject after writing. Never claim rollback or attach arbitrary errors, causes or abort reasons.\n\t\t\tconst safe = new ModelsError(\n\t\t\t\t\"auth\",\n\t\t\t\tmutation\n\t\t\t\t\t? \"Credential operation failed. Stored state may have changed. Inspect accounts and refresh local models before retrying.\"\n\t\t\t\t\t: \"Could not read account metadata. Check credential storage and provider configuration.\",\n\t\t\t);\n\t\t\tif (signal?.aborted) safe.name = \"AbortError\";\n\t\t\tthrow safe;\n\t\t});\n\t}\n\n\tprivate enqueueCredentialOperation<T>(providerId: string, signal: AbortSignal, task: () => Promise<T>): Promise<T> {\n\t\tconst previous = this.credentialOperations.get(providerId) ?? Promise.resolve();\n\t\tlet markStarted: (() => void) | undefined;\n\t\tconst started = new Promise<void>((resolve) => {\n\t\t\tmarkStarted = resolve;\n\t\t});\n\t\tconst operation = (async () => {\n\t\t\tawait previous.catch(() => {});\n\t\t\tsignal.throwIfAborted();\n\t\t\tmarkStarted?.();\n\t\t\treturn task();\n\t\t})();\n\t\tconst tail = operation.catch(() => {});\n\t\tthis.credentialOperations.set(providerId, tail);\n\t\tvoid tail.then(() => {\n\t\t\tif (this.credentialOperations.get(providerId) === tail) this.credentialOperations.delete(providerId);\n\t\t});\n\t\treturn this.protectCredentialOperation(\n\t\t\traceWithAbortSignal(started, signal).then(() => operation),\n\t\t\tsignal,\n\t\t);\n\t}\n\n\tprivate async synchronizeCredentialState(\n\t\tproviderId: string,\n\t\toperation: CredentialSynchronizationOperation,\n\t\tsignal: AbortSignal,\n\t): Promise<void> {\n\t\ttry {\n\t\t\tsignal.throwIfAborted();\n\t\t\tthis.recomposeProvider(providerId);\n\t\t\tconst compositionError = this.compositionErrors.get(providerId);\n\t\t\tif (compositionError) throw new Error(compositionError);\n\t\t\tconst result = await this.models.refresh({ allowNetwork: false, providers: [providerId], signal });\n\t\t\tif (result.aborted) signal.throwIfAborted();\n\t\t\tconst refreshError = result.errors.get(providerId);\n\t\t\tif (refreshError) throw refreshError;\n\t\t\tthis.updateModelSnapshot();\n\t\t\tawait this.refreshProviderAvailability(providerId, signal);\n\t\t} catch {\n\t\t\t// Adapter failures may contain credentials, including nested causes and custom properties.\n\t\t\tconst error = new CredentialSynchronizationError(providerId, operation);\n\t\t\tif (this.compositionErrors.has(providerId)) this.compositionErrors.set(providerId, error.message);\n\t\t\tif (this.availabilityError) this.availabilityError = error.message;\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tsetRuntimeApiKey(providerId: string, apiKey: string, options: AuthOperationOptions = {}): Promise<void> {\n\t\tconst signal = operationSignal(options.signal);\n\t\treturn this.enqueueCredentialOperation(providerId, signal, async () => {\n\t\t\tthis.credentials.setRuntimeApiKey(providerId, apiKey);\n\t\t\tawait this.synchronizeCredentialState(providerId, \"setRuntimeApiKey\", signal);\n\t\t});\n\t}\n\n\tremoveRuntimeApiKey(providerId: string, options: AuthOperationOptions = {}): Promise<void> {\n\t\tconst signal = operationSignal(options.signal);\n\t\treturn this.enqueueCredentialOperation(providerId, signal, async () => {\n\t\t\tthis.credentials.removeRuntimeApiKey(providerId);\n\t\t\tawait this.synchronizeCredentialState(providerId, \"removeRuntimeApiKey\", signal);\n\t\t});\n\t}\n\n\t/**\n\t * Raw stored credential for host-owned reporting: no command or environment resolution, so reading it runs nothing.\n\t * Sensitive; callers must never display, log or persist it.\n\t */\n\treadStoredCredential(providerId: string, options?: AuthOperationOptions): Promise<Credential | undefined> {\n\t\treturn this.protectCredentialOperation(this.credentials.readStored(providerId, options), options?.signal, false);\n\t}\n\n\tlistCredentials(options?: AuthOperationOptions): Promise<readonly CredentialInfo[]> {\n\t\treturn this.protectCredentialOperation(this.credentials.list(options), options?.signal, false);\n\t}\n\n\t/** Global account management. Lists contain metadata only, never resolved credentials. */\n\treadonly accounts = {\n\t\tlist: (providerId: string, options?: AuthOperationOptions): Promise<AccountInfo[]> =>\n\t\t\tthis.protectCredentialOperation(\n\t\t\t\t(async () => {\n\t\t\t\t\tconst { storedEffective } = await this.readAccountSources(providerId, options);\n\t\t\t\t\tconst accounts = await this.oauthAccountPool.listAccounts(providerId, options);\n\t\t\t\t\tconst current = await this.oauthAccountPool.getCurrentAccount(providerId, options);\n\t\t\t\t\treturn accounts.map(({ key, label, credential, exhaustedUntil }) => ({\n\t\t\t\t\t\tkey,\n\t\t\t\t\t\tlabel,\n\t\t\t\t\t\ttype: credential.type,\n\t\t\t\t\t\texhaustedUntil,\n\t\t\t\t\t\tactive: key === current?.key,\n\t\t\t\t\t\teffective: key === current?.key && storedEffective,\n\t\t\t\t\t}));\n\t\t\t\t})(),\n\t\t\t\toptions?.signal,\n\t\t\t\tfalse,\n\t\t\t),\n\t\tsources: (providerId: string, options?: AuthOperationOptions): Promise<AccountSource[]> =>\n\t\t\tthis.protectCredentialOperation(\n\t\t\t\tthis.readAccountSources(providerId, options).then((result) => result.sources),\n\t\t\t\toptions?.signal,\n\t\t\t\tfalse,\n\t\t\t),\n\t\tswitch: (\n\t\t\tproviderId: string,\n\t\t\taccountKey: string,\n\t\t\toptions: AuthOperationOptions = {},\n\t\t): Promise<AccountInfo | undefined> => {\n\t\t\tconst signal = operationSignal(options.signal);\n\t\t\treturn this.enqueueCredentialOperation(providerId, signal, async () => {\n\t\t\t\tconst account = await this.oauthAccountPool.setActiveAccount(providerId, accountKey, { signal });\n\t\t\t\tif (!account) return undefined;\n\t\t\t\tawait this.synchronizeCredentialState(providerId, \"switchAccount\", signal);\n\t\t\t\treturn (await this.accounts.list(providerId, { signal })).find((entry) => entry.key === accountKey);\n\t\t\t});\n\t\t},\n\t\trename: (\n\t\t\tproviderId: string,\n\t\t\taccountKey: string,\n\t\t\tlabel: string,\n\t\t\toptions?: AuthOperationOptions,\n\t\t): Promise<AccountInfo | undefined> =>\n\t\t\tthis.protectCredentialOperation(\n\t\t\t\t(async () => {\n\t\t\t\t\tconst account = await this.oauthAccountPool.renameAccount(providerId, accountKey, label, options);\n\t\t\t\t\treturn account\n\t\t\t\t\t\t? (await this.accounts.list(providerId, options)).find((entry) => entry.key === accountKey)\n\t\t\t\t\t\t: undefined;\n\t\t\t\t})(),\n\t\t\t\toptions?.signal,\n\t\t\t),\n\t\tremove: (\n\t\t\tproviderId: string,\n\t\t\taccountKey: string,\n\t\t\toptions?: AuthOperationOptions,\n\t\t): Promise<AccountRemoveResult[\"status\"]> => this.logoutWithStatus(providerId, { ...options, accountKey }),\n\t};\n\n\t/** Enumerate raw source metadata without OAuth refresh, configuration commands or custom resolve callbacks. */\n\tprivate async readAccountSources(\n\t\tproviderId: string,\n\t\toptions?: AuthOperationOptions,\n\t): Promise<{ sources: AccountSource[]; storedEffective: boolean }> {\n\t\tconst signal = operationSignal(options?.signal);\n\t\tconst provider = this.models.getProvider(providerId);\n\t\tconst stored = await this.credentials.readStored(providerId, { signal });\n\t\tconst runtimeKey = this.credentials.getRuntimeApiKey(providerId);\n\t\tconst extensionKey = this.extensionProviders.get(providerId)?.apiKey;\n\t\tconst modelsKey = this.config.getProvider(providerId)?.apiKey;\n\t\tconst configKey = extensionKey ?? modelsKey;\n\t\tconst external = this.credentials.isExternalCredential(stored);\n\t\tconst sources: AccountSource[] = [];\n\t\tconst add = (source: AccountSource[\"source\"], label: string, effective = false) =>\n\t\t\tsources.push({ source, label, type: \"api_key\", readOnly: true, effective });\n\t\tif (runtimeKey) add(\"runtime\", \"runtime API key\", provider?.auth.apiKey !== undefined);\n\t\tif (stored?.type === \"api_key\" && (external || !stored.key?.trim()))\n\t\t\tadd(\n\t\t\t\t\"auth_json\",\n\t\t\t\tstored.key\n\t\t\t\t\t? isCommandConfigValue(stored.key)\n\t\t\t\t\t\t? \"command in auth.json\"\n\t\t\t\t\t\t: \"environment reference in auth.json\"\n\t\t\t\t\t: \"provider configuration in auth.json\",\n\t\t\t);\n\t\tif (extensionKey !== undefined) add(\"configuration\", \"extension API key\");\n\t\tif (modelsKey !== undefined) add(\"configuration\", \"API key in models.json\");\n\t\tconst env = stored?.type === \"api_key\" ? stored.env : undefined;\n\t\tconst ambientNames =\n\t\t\tproviderId === \"amazon-bedrock\"\n\t\t\t\t? [\n\t\t\t\t\t\t\"AWS_BEARER_TOKEN_BEDROCK\",\n\t\t\t\t\t\t\"AWS_PROFILE\",\n\t\t\t\t\t\t\"AWS_ACCESS_KEY_ID\",\n\t\t\t\t\t\t\"AWS_SECRET_ACCESS_KEY\",\n\t\t\t\t\t\t\"AWS_SESSION_TOKEN\",\n\t\t\t\t\t\t\"AWS_CONTAINER_CREDENTIALS_RELATIVE_URI\",\n\t\t\t\t\t\t\"AWS_CONTAINER_CREDENTIALS_FULL_URI\",\n\t\t\t\t\t\t\"AWS_WEB_IDENTITY_TOKEN_FILE\",\n\t\t\t\t\t\t\"AWS_ROLE_ARN\",\n\t\t\t\t\t\t\"AWS_REGION\",\n\t\t\t\t\t\t\"AWS_DEFAULT_REGION\",\n\t\t\t\t\t\t\"AWS_SHARED_CREDENTIALS_FILE\",\n\t\t\t\t\t\t\"AWS_CONFIG_FILE\",\n\t\t\t\t\t]\n\t\t\t\t: providerId === \"google-vertex\"\n\t\t\t\t\t? [\"GOOGLE_APPLICATION_CREDENTIALS\", \"GOOGLE_CLOUD_PROJECT\", \"GCLOUD_PROJECT\", \"GOOGLE_CLOUD_LOCATION\"]\n\t\t\t\t\t: [];\n\t\tconst authEnvironmentNames = new Set([\n\t\t\t...(findEnvKeys(providerId) ?? []),\n\t\t\t...(findEnvKeys(providerId, env) ?? []),\n\t\t\t...ambientNames.filter((name) => !!(env?.[name] || process.env[name])),\n\t\t]);\n\t\tfor (const name of authEnvironmentNames) add(\"environment\", name);\n\t\tlet storedEffective = false;\n\t\tif (!runtimeKey && provider) {\n\t\t\tif (stored?.type === \"oauth\") {\n\t\t\t\tstoredEffective = provider.auth.oauth !== undefined;\n\t\t\t} else if (provider.auth.apiKey) {\n\t\t\t\tif (\n\t\t\t\t\texternal &&\n\t\t\t\t\tstored?.type === \"api_key\" &&\n\t\t\t\t\tstored.key !== undefined &&\n\t\t\t\t\tisCommandConfigValue(stored.key)\n\t\t\t\t) {\n\t\t\t\t\t// A command owns this dispatch branch; listing never runs it to validate its result.\n\t\t\t\t\tsources.find((entry) => entry.source === \"auth_json\")!.effective = true;\n\t\t\t\t} else if (!stored && configKey !== undefined) {\n\t\t\t\t\tconst configured = isCommandConfigValue(configKey) || resolveConfigValue(configKey) !== undefined;\n\t\t\t\t\tsources.find((entry) => entry.source === \"configuration\")!.effective = configured;\n\t\t\t\t} else {\n\t\t\t\t\t// Builtin resolvers only read environment/files. Never call an extension resolver for a list;\n\t\t\t\t\t// extensions can supply the side-effect-free ApiKeyAuth.check contract instead.\n\t\t\t\t\tconst base = this.nativeExtensionProviders.get(providerId) ?? this.builtins.get(providerId);\n\t\t\t\t\tconst method = base?.auth.apiKey;\n\t\t\t\t\tconst check =\n\t\t\t\t\t\tmethod?.check ?? (this.nativeExtensionProviders.has(providerId) ? undefined : method?.resolve);\n\t\t\t\t\tconst credential =\n\t\t\t\t\t\tstored?.type === \"api_key\"\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t...stored,\n\t\t\t\t\t\t\t\t\tkey:\n\t\t\t\t\t\t\t\t\t\texternal && stored.key !== undefined\n\t\t\t\t\t\t\t\t\t\t\t? resolveConfigValue(stored.key, stored.env)\n\t\t\t\t\t\t\t\t\t\t\t: stored.key,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: undefined;\n\t\t\t\t\tconst ctx = defaultProviderAuthContext();\n\t\t\t\t\tconst usedEnvironment = new Set<string>();\n\t\t\t\t\tconst result = check\n\t\t\t\t\t\t? await check({\n\t\t\t\t\t\t\t\tctx: {\n\t\t\t\t\t\t\t\t\t...ctx,\n\t\t\t\t\t\t\t\t\tenv: async (name) => {\n\t\t\t\t\t\t\t\t\t\tconst value = env?.[name] || (await ctx.env(name));\n\t\t\t\t\t\t\t\t\t\tif (value && authEnvironmentNames.has(name)) usedEnvironment.add(name);\n\t\t\t\t\t\t\t\t\t\treturn value;\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tcredential,\n\t\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t: undefined;\n\t\t\t\t\t// Native check labels are display text, not a source contract. Attribute by the inputs used,\n\t\t\t\t\t// never by arbitrary labels (which may themselves contain credential material).\n\t\t\t\t\tconst native = this.nativeExtensionProviders.has(providerId);\n\t\t\t\t\tconst source = native ? undefined : result?.source;\n\t\t\t\t\tstoredEffective =\n\t\t\t\t\t\t!!stored &&\n\t\t\t\t\t\t(native\n\t\t\t\t\t\t\t? check\n\t\t\t\t\t\t\t\t? !!result && usedEnvironment.size === 0\n\t\t\t\t\t\t\t\t: !!credential?.key\n\t\t\t\t\t\t\t: source === \"stored credential\" || source === \"stored\" || (!check && !!credential?.key));\n\t\t\t\t\tif (result && !storedEffective) {\n\t\t\t\t\t\tconst selectedNames =\n\t\t\t\t\t\t\tsource && sources.some((entry) => entry.label === source) ? [source] : [...usedEnvironment];\n\t\t\t\t\t\tlet marked = false;\n\t\t\t\t\t\tfor (const name of selectedNames) {\n\t\t\t\t\t\t\tconst entry = sources.find((entry) => entry.source === \"environment\" && entry.label === name);\n\t\t\t\t\t\t\tif (entry) {\n\t\t\t\t\t\t\t\tentry.effective = true;\n\t\t\t\t\t\t\t\tmarked = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (!marked) add(\"environment\", \"ambient credentials\", true);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tconst storedSource = sources.find((entry) => entry.source === \"auth_json\");\n\t\tif (storedSource && storedEffective) storedSource.effective = true;\n\t\tsignal.throwIfAborted();\n\t\treturn { sources, storedEffective };\n\t}\n\n\t/** Request-boundary return. External overrides/references never authorize a stored-account switch. */\n\tasync prepareAccountRequest(\n\t\tproviderId: string,\n\t\tautoSwitch: () => boolean,\n\t\tskipKeys: ReadonlySet<string>,\n\t\tsignal?: AbortSignal,\n\t): Promise<void> {\n\t\tif (!autoSwitch() || this.credentials.hasRuntimeApiKey(providerId)) return;\n\t\tconst stored = await this.credentials.readStored(providerId, { signal });\n\t\tif (!stored || this.credentials.isExternalCredential(stored)) return;\n\t\tconst returned = await this.oauthAccountPool.returnToPreferred(providerId, {\n\t\t\tsignal,\n\t\t\tskipKeys,\n\t\t\tcanActivate: () => autoSwitch() && !this.credentials.hasRuntimeApiKey(providerId),\n\t\t});\n\t\tif (returned) await this.synchronizeCredentialState(providerId, \"switchAccount\", operationSignal(signal));\n\t}\n\n\t/** Low-level pool APIs contain credentials; never serialize them into UI, events or logs. */\n\tget oauthAccounts(): OAuthAccountPool {\n\t\treturn this.oauthAccountPool;\n\t}\n\n\tgetProviderAuthStatus(providerId: string): AuthStatus {\n\t\tif (this.credentials.hasRuntimeApiKey(providerId)) return { configured: true, source: \"runtime\" };\n\t\tif (this.snapshot.storedProviders.has(providerId)) return { configured: true, source: \"stored\" };\n\t\tconst configured = configuredRequestAuthStatus(\n\t\t\tthis.config.getProvider(providerId),\n\t\t\tthis.extensionProviders.get(providerId),\n\t\t);\n\t\tif (configured) return configured;\n\t\tconst check = this.snapshot.auth.get(providerId);\n\t\treturn check ? { configured: true, source: \"environment\", label: check.source } : { configured: false };\n\t}\n\n\tprivate async prepareRequest<\n\t\tTModel extends AnyModel,\n\t\tTOptions extends ProviderRequestOptions<TModel> &\n\t\t\tModelsRequestTransforms & { onOAuthAccount?: OAuthAccountObserver },\n\t>(\n\t\tmodel: TModel,\n\t\toptions: TOptions | undefined,\n\t): Promise<{\n\t\tprovider: Provider;\n\t\tmodel: TModel;\n\t\toptions: Omit<TOptions, \"transformHeaders\"> & ProviderRequestOptions<TModel>;\n\t\ttracker: RequestTracker | undefined;\n\t}> {\n\t\tconst provider = this.models.getProvider(model.provider);\n\t\tif (!provider) throw new ModelsError(\"provider\", `Unknown provider: ${model.provider}`);\n\t\tlet resolvedAccount: { provider: string; key: string | undefined } | undefined;\n\t\t// Anthropic rate-limit headers are only recorded for a credential whose account is identified for this request.\n\t\tconst observesAnthropicLimits = model.provider === ANTHROPIC_PROVIDER_ID;\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\tonOAuthAccount:\n\t\t\t\toptions?.onOAuthAccount || observesAnthropicLimits\n\t\t\t\t\t? (provider, key) => {\n\t\t\t\t\t\t\tresolvedAccount = { provider, key };\n\t\t\t\t\t\t}\n\t\t\t\t\t: undefined,\n\t\t});\n\t\tif (!resolution) throw new ModelsError(\"auth\", `Provider is not configured: ${model.provider}`);\n\n\t\tconst { transformHeaders, onOAuthAccount: _onOAuthAccount, ...rawProviderOptions } = options ?? {};\n\t\tconst providerOptions = rawProviderOptions as Omit<TOptions, \"transformHeaders\"> & ProviderRequestOptions<TModel>;\n\t\tconst requestModel: TModel = resolution.auth.baseUrl ? { ...model, baseUrl: resolution.auth.baseUrl } : model;\n\t\tconst sessionId =\n\t\t\t\"sessionId\" in providerOptions && typeof providerOptions.sessionId === \"string\"\n\t\t\t\t? providerOptions.sessionId\n\t\t\t\t: undefined;\n\t\tlet headers = mergeHeaders(\n\t\t\tmergeHeaders(getOpenCodeSessionHeaders(requestModel, sessionId), resolution.auth.headers),\n\t\t\tproviderOptions.headers,\n\t\t);\n\t\tif (transformHeaders) headers = await transformHeaders(headers ?? {});\n\t\tconst env =\n\t\t\tresolution.env || providerOptions.env\n\t\t\t\t? { ...(resolution.env ?? {}), ...(providerOptions.env ?? {}) }\n\t\t\t\t: undefined;\n\t\tconst apiKey = providerOptions.apiKey ?? resolution.auth.apiKey;\n\t\tlet attributedAccountKey: string | undefined;\n\t\tif ((options?.onOAuthAccount || observesAnthropicLimits) && this.oauthAccountPool.isPooled(model.provider)) {\n\t\t\t// OAuth-only providers still resolve stored auth even with an explicit request key. That\n\t\t\t// credential is not necessarily dispatched: preserve the key override and attribute it,\n\t\t\t// failing closed if its account is unknown. A resolved/refreshed key keeps its identity.\n\t\t\tattributedAccountKey =\n\t\t\t\tresolvedAccount?.provider === model.provider && apiKey === resolution.auth.apiKey\n\t\t\t\t\t? resolvedAccount.key\n\t\t\t\t\t: apiKey\n\t\t\t\t\t\t? this.oauthAccountPool.getAccountKeyForAccessToken(model.provider, apiKey)\n\t\t\t\t\t\t: undefined;\n\t\t\toptions?.onOAuthAccount?.(model.provider, attributedAccountKey);\n\t\t}\n\t\tconst callerOnResponse = providerOptions.onResponse;\n\t\tconst onResponse =\n\t\t\tobservesAnthropicLimits &&\n\t\t\tattributedAccountKey !== undefined &&\n\t\t\t!overridesCredentialHeaders(resolution.auth.headers, headers) &&\n\t\t\tisOfficialAnthropicBaseUrl(requestModel.baseUrl)\n\t\t\t\t? async (response: ProviderResponse, responseModel: TModel) => {\n\t\t\t\t\t\tthis.observeAnthropicLimits(attributedAccountKey, response);\n\t\t\t\t\t\tawait callerOnResponse?.(response, responseModel);\n\t\t\t\t\t}\n\t\t\t\t: callerOnResponse;\n\t\t// The one request boundary: every chat, image, classifier and deferred call is prepared here, so\n\t\t// the scope bound by the owning session observes it exactly once per real submission.\n\t\tconst scope = this.currentScope();\n\t\tconst tracker = scope ? new RequestTracker(scope) : undefined;\n\t\t// Payload hooks may run from a shared queue; rebind the scope so they see this request's purpose.\n\t\tconst callerOnPayload = providerOptions.onPayload;\n\t\tconst onPayload =\n\t\t\tscope && callerOnPayload\n\t\t\t\t? (payload: unknown, payloadModel: TModel) =>\n\t\t\t\t\t\tthis.requestScope.run(scope, () => callerOnPayload(payload, payloadModel))\n\t\t\t\t: callerOnPayload;\n\t\treturn {\n\t\t\tprovider,\n\t\t\tmodel: requestModel,\n\t\t\toptions: {\n\t\t\t\t...providerOptions,\n\t\t\t\tapiKey,\n\t\t\t\theaders,\n\t\t\t\tenv,\n\t\t\t\t...(onPayload ? { onPayload } : {}),\n\t\t\t\t...(onResponse ? { onResponse } : {}),\n\t\t\t\t...(tracker ? { onRequest: tracker.hook(providerOptions.onRequest) } : {}),\n\t\t\t} as Omit<TOptions, \"transformHeaders\"> & ProviderRequestOptions<TModel>,\n\t\t\ttracker,\n\t\t};\n\t}\n\n\tprivate observeAnthropicLimits(accountKey: string, response: ProviderResponse): void {\n\t\ttry {\n\t\t\tconst snapshot = parseAnthropicRateLimits(response.headers, Date.now());\n\t\t\tif (snapshot) this.anthropicRateLimits.record(accountKey, snapshot);\n\t\t} catch {\n\t\t\t// Observation is best effort and never affects the request.\n\t\t}\n\t}\n\n\t/**\n\t * Run `fn` so every request it starts (including background work it schedules) is reported to\n\t * `observer`. The binding follows async context, so concurrent sessions sharing this runtime keep\n\t * their own observers.\n\t */\n\tobserveRequests<T>(observer: ModelRequestObserver, purpose: ModelRequestPurpose | undefined, fn: () => T): T {\n\t\treturn this.requestScope.run({ observer, purpose }, fn);\n\t}\n\n\t/** Register a session observer that owns direct calls on this runtime; returns the unregister function. */\n\taddOwnerObserver(observer: ModelRequestObserver): () => void {\n\t\tthis.ownerObservers.add(observer);\n\t\treturn () => {\n\t\t\tthis.ownerObservers.delete(observer);\n\t\t};\n\t}\n\n\t/**\n\t * The active request scope, else the sole owning session's chat scope for a direct SDK call. With\n\t * several owners the call cannot be attributed: nothing is observed and the first owner is told of the gap.\n\t */\n\tprivate currentScope(): ModelRequestScope | undefined {\n\t\tconst scope = this.requestScope.getStore();\n\t\tif (scope || this.ownerObservers.size === 0) return scope;\n\t\tif (this.ownerObservers.size === 1) {\n\t\t\tconst [observer] = this.ownerObservers;\n\t\t\treturn { observer, purpose: \"chat\" };\n\t\t}\n\t\t// One content-free notice is enough; the recorder is process-wide.\n\t\tconst [first] = this.ownerObservers;\n\t\tif (first?.onUnattributed) swallow(() => first.onUnattributed?.());\n\t\treturn undefined;\n\t}\n\n\t/** Purpose of the request scope the caller runs in; undefined outside a scope or for purpose-less requests. */\n\tcurrentRequestPurpose(): ModelRequestPurpose | undefined {\n\t\treturn this.requestScope.getStore()?.purpose;\n\t}\n\n\t/** Change the purpose of requests started by `fn`, keeping the current observer. No-op outside a scope. */\n\twithRequestPurpose<T>(purpose: ModelRequestPurpose | undefined, fn: () => T): T {\n\t\tconst scope = this.currentScope();\n\t\treturn scope ? this.requestScope.run({ observer: scope.observer, purpose }, fn) : fn();\n\t}\n\n\t/** Report the outcome of a stream once it ends. */\n\tprivate trackStream(\n\t\tstream: AssistantMessageEventStream,\n\t\ttracker: () => RequestTracker | undefined,\n\t): AssistantMessageEventStream {\n\t\tstream.result().then(\n\t\t\t(message) => tracker()?.settleMessage(message),\n\t\t\t() => tracker()?.settleFailure(false),\n\t\t);\n\t\treturn stream;\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\tlet tracker: RequestTracker | undefined;\n\t\treturn this.trackStream(\n\t\t\tlazyStream(model, async () => {\n\t\t\t\tassertChatModel(model);\n\t\t\t\tconst prepared = await this.prepareRequest(\n\t\t\t\t\tmodel,\n\t\t\t\t\toptions as (StreamOptions & ModelsRequestTransforms) | undefined,\n\t\t\t\t);\n\t\t\t\ttracker = prepared.tracker;\n\t\t\t\treturn prepared.provider.stream(prepared.model, transcript, prepared.options as ApiStreamOptions<TApi>);\n\t\t\t}),\n\t\t\t() => tracker,\n\t\t);\n\t}\n\n\tcomplete<TApi extends Api>(\n\t\tmodel: Model<TApi>,\n\t\tcontext: Context,\n\t\toptions?: ModelsApiStreamOptions<TApi>,\n\t): Promise<AssistantMessage> {\n\t\treturn this.stream(model, context, options).result();\n\t}\n\n\tstreamSimple(\n\t\tmodel: Model<Api>,\n\t\tcontext: Context,\n\t\toptions?: ModelRuntimeSimpleStreamOptions,\n\t): AssistantMessageEventStream {\n\t\tconst transcript = normalizeContext(context);\n\t\tif (isVirtualModel(model)) {\n\t\t\t// Requests outside the agent loop are routed here. Callers sized them before routing, so\n\t\t\t// cap the output budget to the routed model.\n\t\t\treturn lazyStream(model, async () => {\n\t\t\t\tconst route = await this.resolveModel(model, transcript.messages, {\n\t\t\t\t\treason: \"direct\",\n\t\t\t\t\tthinkingLevel: options?.reasoning ?? \"off\",\n\t\t\t\t\tsignal: options?.signal,\n\t\t\t\t});\n\t\t\t\tconst { maxTokens: limit } = route.model;\n\t\t\t\tconst maxTokens = options?.maxTokens && limit > 0 ? Math.min(options.maxTokens, limit) : options?.maxTokens;\n\t\t\t\tconst reasoning = route.thinkingLevel === \"off\" ? undefined : route.thinkingLevel;\n\t\t\t\t// Caller credentials were resolved for the virtual model's provider. Another provider\n\t\t\t\t// resolves its own, so they are not sent to the wrong vendor.\n\t\t\t\tconst { apiKey, headers, env, ...rest } = options ?? {};\n\t\t\t\tconst auth = route.model.provider === model.provider ? { apiKey, headers, env } : {};\n\t\t\t\treturn this.streamSimple(route.model, context, { ...rest, ...auth, maxTokens, reasoning });\n\t\t\t});\n\t\t}\n\t\tlet tracker: RequestTracker | undefined;\n\t\treturn this.trackStream(\n\t\t\tlazyStream(model, async () => {\n\t\t\t\tassertChatModel(model);\n\t\t\t\tconst prepared = await this.prepareRequest(model, options);\n\t\t\t\ttracker = prepared.tracker;\n\t\t\t\treturn prepared.provider.streamSimple(prepared.model, transcript, prepared.options as SimpleStreamOptions);\n\t\t\t}),\n\t\t\t() => tracker,\n\t\t);\n\t}\n\n\tcompleteSimple(model: Model<Api>, context: Context, options?: ModelsSimpleStreamOptions): Promise<AssistantMessage> {\n\t\treturn this.streamSimple(model, context, options).result();\n\t}\n\n\tstreamDeferred(\n\t\tmodel: Model<Api>,\n\t\thandle: DeferredHandle,\n\t\toptions?: ModelsDeferredFetchOptions,\n\t): AssistantMessageEventStream {\n\t\tlet tracker: RequestTracker | undefined;\n\t\treturn this.trackStream(\n\t\t\tlazyStream(model, async () => {\n\t\t\t\tassertChatModel(model);\n\t\t\t\tconst prepared = await this.prepareRequest(model, options);\n\t\t\t\ttracker = prepared.tracker;\n\t\t\t\tif (!prepared.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\treturn prepared.provider.fetchDeferred(prepared.model, handle, prepared.options as DeferredFetchOptions);\n\t\t\t}),\n\t\t\t() => tracker,\n\t\t);\n\t}\n\n\tasync fetchDeferred(\n\t\tmodel: Model<Api>,\n\t\thandle: DeferredHandle,\n\t\toptions?: ModelsDeferredFetchOptions,\n\t): Promise<AssistantMessage> {\n\t\treturn this.streamDeferred(model, handle, options).result();\n\t}\n\n\tasync cancelDeferred(\n\t\tmodel: Model<Api>,\n\t\thandle: DeferredHandle,\n\t\toptions?: ModelsDeferredCancelOptions,\n\t): Promise<void> {\n\t\tassertChatModel(model);\n\t\tconst prepared = await this.prepareRequest(model, options);\n\t\tif (!prepared.provider.cancelDeferred) {\n\t\t\tthrow new ModelsError(\"provider\", `Provider ${model.provider} does not support deferred responses`);\n\t\t}\n\t\tawait prepared.provider.cancelDeferred(prepared.model, handle, prepared.options as DeferredCancelOptions);\n\t}\n\n\tasync generateImages(\n\t\tmodel: ImageModel<ImageApi>,\n\t\tcontext: ImagesContext,\n\t\toptions?: ModelsImagesOptions,\n\t): Promise<AssistantImages> {\n\t\tlet tracker: RequestTracker | undefined;\n\t\ttry {\n\t\t\tassertImageModel(model);\n\t\t\tconst prepared = await this.prepareRequest(model, options);\n\t\t\ttracker = prepared.tracker;\n\t\t\tif (!prepared.provider.generateImages) {\n\t\t\t\tthrow new ModelsError(\"provider\", `Provider ${model.provider} does not support image generation`);\n\t\t\t}\n\t\t\tconst result = await prepared.provider.generateImages(\n\t\t\t\tprepared.model,\n\t\t\t\tcontext,\n\t\t\t\tprepared.options as ImagesOptions,\n\t\t\t);\n\t\t\ttracker?.settleResult(result);\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\ttracker?.settleFailure(options?.signal?.aborted === true);\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\tlet tracker: RequestTracker | undefined;\n\t\ttry {\n\t\t\tassertClassifierModel(model);\n\t\t\tassertClassifierInputSupported(model, context);\n\t\t\tconst prepared = await this.prepareRequest(model, options);\n\t\t\ttracker = prepared.tracker;\n\t\t\tif (!prepared.provider.classify) {\n\t\t\t\tthrow new ModelsError(\"provider\", `Provider ${model.provider} does not support classification`);\n\t\t\t}\n\t\t\tconst result = await prepared.provider.classify(\n\t\t\t\tprepared.model,\n\t\t\t\tcontext,\n\t\t\t\tprepared.options as ClassifierOptions,\n\t\t\t);\n\t\t\ttracker?.settleResult(result);\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\ttracker?.settleFailure(options?.signal?.aborted === true);\n\t\t\treturn classifierErrorResult(model, error, options?.signal?.aborted);\n\t\t}\n\t}\n\n\tlogin(\n\t\tproviderId: string,\n\t\ttype: AuthType,\n\t\tinteraction: AuthInteraction,\n\t\toptions?: LoginOptions & { accountKey?: string },\n\t): Promise<Credential> {\n\t\tconst signal = operationSignal(interaction.signal);\n\t\treturn this.enqueueCredentialOperation(providerId, signal, async () => {\n\t\t\tconst provider = this.models.getProvider(providerId);\n\t\t\tif (!provider) throw new ModelsError(\"provider\", `Unknown provider: ${providerId}`);\n\t\t\tconst method = type === \"oauth\" ? provider.auth.oauth : provider.auth.apiKey;\n\t\t\tif (!method?.login) throw new ModelsError(\"auth\", `${provider.name} does not support ${type} login`);\n\t\t\tif (options?.accountKey !== undefined) {\n\t\t\t\tconst selected = (await this.oauthAccountPool.listAccounts(providerId, { signal })).find(\n\t\t\t\t\t(account) => account.key === options.accountKey,\n\t\t\t\t);\n\t\t\t\tif (!selected || selected.credential.type !== type)\n\t\t\t\t\tthrow new ModelsError(\"auth\", \"Account is no longer available for reauthentication\");\n\t\t\t}\n\t\t\tawait this.oauthAccountPool.adoptCurrentAccount(providerId, { signal });\n\t\t\tlet promptCancelled = false;\n\t\t\tlet login: Credential;\n\t\t\ttry {\n\t\t\t\tlogin = await raceWithAbortSignal<Credential>(\n\t\t\t\t\tmethod.login(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t...interaction,\n\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t\tprompt: async (prompt) => {\n\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\treturn await interaction.prompt(prompt);\n\t\t\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t\t\t// A callback winner aborts only its pending prompt, not the whole login.\n\t\t\t\t\t\t\t\t\tif (signal.aborted || !prompt.signal?.aborted) promptCancelled = true;\n\t\t\t\t\t\t\t\t\tthrow new LoginCancellationError();\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\toptions,\n\t\t\t\t\t),\n\t\t\t\t\tsignal,\n\t\t\t\t);\n\t\t\t} catch (error) {\n\t\t\t\tif (promptCancelled || signal.aborted) throw new LoginCancellationError();\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tif (promptCancelled) throw new LoginCancellationError();\n\t\t\t// Login returns credentials, not configuration expressions. Ambient-only entries stay external.\n\t\t\tconst poolable = login.type === \"oauth\" || !!login.key?.trim();\n\t\t\tif (options?.accountKey !== undefined && !poolable)\n\t\t\t\tthrow new ModelsError(\"auth\", \"Reauthentication must return a literal account credential\");\n\t\t\tconst account = poolable\n\t\t\t\t? await this.oauthAccountPool.addAccount(providerId, login, { signal, key: options?.accountKey })\n\t\t\t\t: undefined;\n\t\t\tconst credential = account?.credential ?? login;\n\t\t\tif (!account) await commitLoginCredential(this.credentials.accountStore, providerId, login, signal);\n\t\t\tawait this.synchronizeCredentialState(providerId, \"login\", signal);\n\t\t\treturn credential;\n\t\t});\n\t}\n\n\t/**\n\t * Remove the selected account, or without a key the account whose credential is stored. Removing the active\n\t * account promotes the next account of the same credential type; otherwise the credential is deleted.\n\t * Literal legacy credentials are adopted first, including OAuth credentials without identity. An unknown\n\t * explicit account key leaves stored credentials unchanged, and so does a stored credential that changed while\n\t * the account was being removed. `logoutWithStatus` reports which of these happened.\n\t */\n\tasync logout(providerId: string, options: AuthOperationOptions & { accountKey?: string } = {}): Promise<void> {\n\t\tawait this.logoutWithStatus(providerId, options);\n\t}\n\n\tprivate async deleteObservedStoredCredential(\n\t\tproviderId: string,\n\t\tobserved: Credential | undefined,\n\t\tsignal: AbortSignal,\n\t): Promise<AccountRemoveResult[\"status\"]> {\n\t\tlet status: AccountRemoveResult[\"status\"] = \"changed\";\n\t\tawait this.credentials.deleteStored(providerId, {\n\t\t\tsignal,\n\t\t\tifCurrent: (latest) => {\n\t\t\t\tif (!sameCredential(latest, observed)) return false;\n\t\t\t\tstatus = \"removed\";\n\t\t\t\treturn true;\n\t\t\t},\n\t\t});\n\t\treturn status;\n\t}\n\n\t/** Capture a non-pooled raw credential before confirmation, without exposing it to the UI. */\n\tprepareStoredCredentialRemoval(\n\t\tproviderId: string,\n\t\toptions?: AuthOperationOptions,\n\t): Promise<((options?: AuthOperationOptions) => Promise<AccountRemoveResult[\"status\"]>) | undefined> {\n\t\treturn this.protectCredentialOperation(\n\t\t\t(async () => {\n\t\t\t\tconst observed = structuredClone(await this.credentials.readStored(providerId, options));\n\t\t\t\tif (!observed || (await this.oauthAccountPool.getCurrentAccount(providerId, options))) return undefined;\n\t\t\t\treturn (removalOptions?: AuthOperationOptions) => {\n\t\t\t\t\tconst signal = operationSignal(removalOptions?.signal);\n\t\t\t\t\treturn this.enqueueCredentialOperation(providerId, signal, async () => {\n\t\t\t\t\t\tconst status = await this.deleteObservedStoredCredential(providerId, observed, signal);\n\t\t\t\t\t\tif (status === \"removed\") await this.synchronizeCredentialState(providerId, \"logout\", signal);\n\t\t\t\t\t\treturn status;\n\t\t\t\t\t});\n\t\t\t\t};\n\t\t\t})(),\n\t\t\toptions?.signal,\n\t\t\tfalse,\n\t\t);\n\t}\n\n\t/**\n\t * `logout`, resolving `removed`, `unmatched` (unknown explicit account key; nothing changed), or `changed` (the stored\n\t * credential changed concurrently; nothing removed).\n\t */\n\tlogoutWithStatus(\n\t\tproviderId: string,\n\t\toptions: AuthOperationOptions & { accountKey?: string } = {},\n\t): Promise<AccountRemoveResult[\"status\"]> {\n\t\tconst signal = operationSignal(options.signal);\n\t\treturn this.enqueueCredentialOperation(providerId, signal, async () => {\n\t\t\t// Raw stored credential (`read` resolves configured API-key values), observed before the pool's read.\n\t\t\tconst observed =\n\t\t\t\toptions.accountKey === undefined\n\t\t\t\t\t? structuredClone(await this.credentials.modify(providerId, async () => undefined, { signal }))\n\t\t\t\t\t: undefined;\n\t\t\t// A stored-only removal never goes through the pool: another session may select an account after\n\t\t\t// this observation, and adopting/removing that replacement would silently retarget the logout.\n\t\t\tif (\n\t\t\t\tthis.credentials.isExternalCredential(observed) ||\n\t\t\t\t(observed?.type === \"api_key\" && !observed.key?.trim()) ||\n\t\t\t\t(providerId === \"openai-codex\" &&\n\t\t\t\t\tobserved?.type === \"oauth\" &&\n\t\t\t\t\t!this.oauthAccountPool.getAccountIdentity(providerId, observed))\n\t\t\t) {\n\t\t\t\tconst status = await this.deleteObservedStoredCredential(providerId, observed, signal);\n\t\t\t\tif (status === \"removed\") await this.synchronizeCredentialState(providerId, \"logout\", signal);\n\t\t\t\treturn status;\n\t\t\t}\n\t\t\tconst stored =\n\t\t\t\toptions.accountKey === undefined ? observed : await this.credentials.readStored(providerId, { signal });\n\t\t\t// Keep Codex's fail-closed handling of legacy unstamped credentials with no identifiable account.\n\t\t\t// Generalized login always stamps even opaque Codex credentials, so they use the account API normally.\n\t\t\tconst legacyUnmatchedCodex =\n\t\t\t\tproviderId === \"openai-codex\" &&\n\t\t\t\tstored?.type === \"oauth\" &&\n\t\t\t\t!this.oauthAccountPool.getAccountIdentity(providerId, stored);\n\t\t\t// A generalized list can give an unstamped legacy credential a temporary local key.\n\t\t\tconst selectedLegacyCurrent =\n\t\t\t\tlegacyUnmatchedCodex &&\n\t\t\t\toptions.accountKey?.startsWith(\"account-\") &&\n\t\t\t\t(await this.oauthAccountPool.getCurrentAccount(providerId, { signal }))?.key === options.accountKey;\n\t\t\t// Removal already reconciles legacy credentials under the pool lock; separate adoption can retarget logout.\n\t\t\tconst removal =\n\t\t\t\tlegacyUnmatchedCodex && !selectedLegacyCurrent\n\t\t\t\t\t? await this.oauthAccountPool.remove(providerId, options.accountKey, { signal })\n\t\t\t\t\t: await this.oauthAccountPool.removeAccount(providerId, options.accountKey, {\n\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t\tifCurrent:\n\t\t\t\t\t\t\t\toptions.accountKey === undefined ? (latest) => sameCredential(latest, observed) : undefined,\n\t\t\t\t\t\t});\n\t\t\tlet status = removal.status;\n\t\t\tif (status === \"unmatched\") {\n\t\t\t\tif (options.accountKey !== undefined) return status;\n\t\t\t\t// Unlike Models.logout, delete only the observed credential, never one written since.\n\t\t\t\tstatus = await this.deleteObservedStoredCredential(providerId, observed, signal);\n\t\t\t}\n\t\t\tif (status === \"removed\") await this.synchronizeCredentialState(providerId, \"logout\", signal);\n\t\t\treturn status;\n\t\t});\n\t}\n\n\t/**\n\t * Provider and virtual-model registration changes each queue an un-awaited\n\t * offline refresh after recomposing a provider, unless batched without refresh\n\t * (e.g. the always-loaded llama.cpp builtin extension registers itself\n\t * on every startup). Left unbounded, that background refresh can still be\n\t * running when a caller later does an explicit `await refresh(...)` (startup's\n\t * HUMAIN Node discovery, or the provider-registration refresh in\n\t * createAgentSessionServices) and can finish after it, recomposing every\n\t * provider back to its static definition and clobbering the just-discovered\n\t * dynamic model list or the auth snapshot `hasConfiguredAuth()` reads.\n\t *\n\t * Every non-registration refresh() call waits for these to settle before doing\n\t * its own snapshot work, so it always lands last. Registration-triggered\n\t * refreshes never wait on this set (or on each other via it), so they can't\n\t * deadlock on one another, and unrelated explicit refreshes (e.g. two\n\t * provider-scoped catalog refreshes) remain fully concurrent with each other,\n\t * exactly as before.\n\t */\n\tprivate readonly pendingRegistrationRefreshes = new Set<Promise<void>>();\n\tprivate registeringWithoutRefresh = false;\n\n\t/** Runs synchronous registrations without background refreshes; the caller must refresh afterward. */\n\tregisterWithoutRefresh(register: () => void): void {\n\t\tconst previous = this.registeringWithoutRefresh;\n\t\tthis.registeringWithoutRefresh = true;\n\t\ttry {\n\t\t\tregister();\n\t\t} finally {\n\t\t\tthis.registeringWithoutRefresh = previous;\n\t\t}\n\t}\n\n\tprivate queueRegistrationRefresh(): void {\n\t\tif (this.registeringWithoutRefresh) return;\n\t\tconst p = this.refreshInternal({ allowNetwork: false }, { fromRegistration: true }).then(\n\t\t\t() => {},\n\t\t\t() => {},\n\t\t);\n\t\tthis.pendingRegistrationRefreshes.add(p);\n\t\tvoid p.finally(() => this.pendingRegistrationRefreshes.delete(p));\n\t}\n\n\trefresh(options: ModelsRefreshOptions = {}): Promise<ModelsRefreshResult> {\n\t\treturn this.refreshInternal(options, { fromRegistration: false });\n\t}\n\n\tprivate async refreshInternal(\n\t\toptions: ModelsRefreshOptions,\n\t\t{ fromRegistration }: { fromRegistration: boolean },\n\t): Promise<ModelsRefreshResult> {\n\t\tif (!fromRegistration && this.pendingRegistrationRefreshes.size > 0) {\n\t\t\tawait Promise.allSettled([...this.pendingRegistrationRefreshes]);\n\t\t}\n\t\tthis.config = await ModelConfig.load(this.modelsPath);\n\t\tthis.configureRadiusProviders();\n\t\tif (options.providers) {\n\t\t\tfor (const providerId of new Set(options.providers)) this.recomposeProvider(providerId);\n\t\t\tthis.updateModelSnapshot();\n\t\t} else {\n\t\t\tthis.rebuildProviders();\n\t\t}\n\t\tconst refreshOptions = {\n\t\t\t...options,\n\t\t\tallowNetwork: options.allowNetwork ?? this.modelNetworkEnabled,\n\t\t};\n\t\t// Published pi-ai builds before ModelsStore returned void and accepted a provider ID.\n\t\t// The fallback keeps source-mode CLI tests working without rebuilding workspace dependencies.\n\t\tconst result = ((await this.models.refresh(refreshOptions)) as ModelsRefreshResult | undefined) ?? {\n\t\t\taborted: refreshOptions.signal?.aborted ?? false,\n\t\t\terrors: new Map(),\n\t\t};\n\t\tconst errors = new Map(result.errors);\n\t\tthis.updateModelSnapshot();\n\t\tif (options.providers) {\n\t\t\tawait Promise.all(\n\t\t\t\t[...new Set(options.providers)].map(async (providerId) => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait this.refreshProviderAvailability(providerId, operationSignal(options.signal));\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tif (!options.signal?.aborted) {\n\t\t\t\t\t\t\terrors.set(providerId, error instanceof Error ? error : new Error(String(error)));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t);\n\t\t} else {\n\t\t\ttry {\n\t\t\t\tawait this.queueAvailabilityRefresh(options.signal);\n\t\t\t} catch {\n\t\t\t\t// Availability errors are recorded by the latest pass; refreshed models remain usable.\n\t\t\t}\n\t\t}\n\t\treturn { aborted: result.aborted || (options.signal?.aborted ?? false), errors };\n\t}\n\n\tregisterNativeProvider(provider: Provider): void {\n\t\tif (!provider.id.trim()) throw new Error(\"Provider id must not be empty.\");\n\t\tthis.extensionProviders.delete(provider.id);\n\t\tthis.nativeExtensionProviders.set(provider.id, provider);\n\t\tthis.recomposeProvider(provider.id);\n\t\tthis.updateModelSnapshot();\n\t\tthis.markProvisionallyConfigured(\n\t\t\tprovider.id,\n\t\t\tconfiguredRequestAuthStatus(this.config.getProvider(provider.id), undefined),\n\t\t\tprovider.auth.oauth && !provider.auth.apiKey ? \"oauth\" : \"api_key\",\n\t\t);\n\t\tthis.queueRegistrationRefresh();\n\t}\n\n\t/**\n\t * Mark a newly registered provider as configured when it has a stored credential or a configured\n\t * API key. Availability checks run asynchronously, and callers such as initial model selection\n\t * read the snapshot before they finish. The next availability pass replaces this entry.\n\t */\n\tprivate markProvisionallyConfigured(\n\t\tproviderId: string,\n\t\tconfiguredStatus: AuthStatus | undefined,\n\t\ttype: AuthType,\n\t): void {\n\t\tif (!this.snapshot.storedProviders.has(providerId) && !configuredStatus?.configured) return;\n\t\tconst configuredProviders = new Set(this.snapshot.configuredProviders).add(providerId);\n\t\tconst auth = new Map(this.snapshot.auth);\n\t\t// Never clobber a real check result.\n\t\tif (!auth.get(providerId)) auth.set(providerId, { type, source: \"configured provider\" });\n\t\tthis.snapshot = {\n\t\t\t...this.snapshot,\n\t\t\tauth,\n\t\t\tconfiguredProviders,\n\t\t\tavailable: this.snapshot.all.ofProviders(configuredProviders),\n\t\t};\n\t}\n\n\tregisterProvider(providerId: string, config: ProviderConfigInput): void {\n\t\t// Validate the incoming registration on its own, like the legacy registry:\n\t\t// a broken re-registration must throw without touching the stored config.\n\t\tvalidateExtensionProvider(providerId, this.builtins.get(providerId), this.config.getProvider(providerId), config);\n\t\tthis.nativeExtensionProviders.delete(providerId);\n\t\t// Re-registration merges defined values over the previous registration and\n\t\t// preserves undefined ones, matching the legacy ModelRegistry contract.\n\t\tconst previous = this.extensionProviders.get(providerId);\n\t\tconst effective: ProviderConfigInput = { ...previous };\n\t\tfor (const [key, value] of Object.entries(config)) {\n\t\t\tif (value !== undefined) (effective as Record<string, unknown>)[key] = value;\n\t\t}\n\t\tthis.extensionProviders.set(providerId, effective);\n\t\tthis.recomposeProvider(providerId);\n\t\tthis.updateModelSnapshot();\n\t\tthis.markProvisionallyConfigured(\n\t\t\tproviderId,\n\t\t\tconfiguredRequestAuthStatus(this.config.getProvider(providerId), effective),\n\t\t\teffective.oauth && !effective.apiKey ? \"oauth\" : \"api_key\",\n\t\t);\n\t\tthis.queueRegistrationRefresh();\n\t}\n\n\tunregisterProvider(providerId: string): void {\n\t\tthis.extensionProviders.delete(providerId);\n\t\tthis.nativeExtensionProviders.delete(providerId);\n\t\tthis.recomposeProvider(providerId);\n\t\tthis.updateModelSnapshot();\n\t\tthis.queueRegistrationRefresh();\n\t}\n\n\t/**\n\t * Register a virtual model under `definition.provider`, which may also list physical models or\n\t * several virtual models. Re-registering the same provider and id replaces the virtual model.\n\t * Throws when the id belongs to a physical model of that provider.\n\t */\n\tregisterVirtualModel(definition: VirtualModelDefinition): void {\n\t\tconst { provider: providerId, id } = definition;\n\t\tif (!providerId.trim() || !id.trim()) throw new Error(\"Virtual model provider and id must not be empty.\");\n\t\tconst existing = this.models.getModel(providerId, id);\n\t\tif (existing && !isVirtualModel(existing)) {\n\t\t\tthrow new Error(`Virtual model ${providerId}/${id} conflicts with a physical model.`);\n\t\t}\n\t\tconst models = this.virtualModels.get(providerId) ?? new Map<string, RegisteredVirtualModel>();\n\t\tmodels.set(id, { model: createVirtualModel(definition), route: (request) => definition.route(request) });\n\t\tthis.virtualModels.set(providerId, models);\n\t\tif (!this.recomposeProvider(providerId) && !this.snapshot.configuredProviders.has(providerId)) {\n\t\t\t// A provider of only virtual models needs no credentials. Mark it configured now: session\n\t\t\t// restore checks auth before the refresh below lands.\n\t\t\tconst auth = new Map(this.snapshot.auth).set(providerId, { type: \"api_key\", source: \"virtual\" });\n\t\t\tconst configuredProviders = new Set(this.snapshot.configuredProviders).add(providerId);\n\t\t\tthis.snapshot = { ...this.snapshot, auth, configuredProviders };\n\t\t}\n\t\tthis.updateModelSnapshot();\n\t\tthis.queueRegistrationRefresh();\n\t}\n\n\tunregisterVirtualModel(providerId: string, id: string): void {\n\t\tconst models = this.virtualModels.get(providerId);\n\t\tif (!models?.delete(id)) return;\n\t\tif (models.size === 0) this.virtualModels.delete(providerId);\n\t\tthis.recomposeProvider(providerId);\n\t\tthis.updateModelSnapshot();\n\t\tthis.queueRegistrationRefresh();\n\t}\n\n\t/**\n\t * Ask a virtual model's router for the model and thinking level of one request. The router must\n\t * return a physical catalog model whose provider has credentials; the thinking level is clamped\n\t * to that model. Throws when routing fails.\n\t *\n\t * `previous` reports the latest successful response in `messages`. A retry passes the failed\n\t * response as `options.failed`; `messages` no longer contains it. `options.state` is the router\n\t * state stored by the caller, which also stores the returned state.\n\t */\n\tasync resolveModel(\n\t\tmodel: Model<Api>,\n\t\tmessages: readonly Message[],\n\t\toptions: {\n\t\t\treason: ModelRouteReason;\n\t\t\tthinkingLevel: ModelThinkingLevel;\n\t\t\tsignal?: AbortSignal;\n\t\t\tfailed?: AssistantMessage;\n\t\t\tstate?: unknown;\n\t\t},\n\t): Promise<ModelRoute> {\n\t\tconst name = `Virtual model ${model.provider}/${model.id}`;\n\t\tconst virtual = this.virtualModels.get(model.provider)?.get(model.id);\n\t\tif (!virtual) throw new Error(`${name} is not registered.`);\n\t\tconst { failed, ...request } = options;\n\t\tconst latest = findLatestResponse(messages);\n\t\tconst previousModel = latest && this.getPhysicalModel(latest.provider, latest.model);\n\t\t// A failed routing attempt names the virtual model; there is no physical request to report.\n\t\tconst failedModel = failed && this.getPhysicalModel(failed.provider, failed.model);\n\t\tconst route = await virtual.route({\n\t\t\t...request,\n\t\t\tmodel,\n\t\t\tprevious: previousModel && { model: previousModel, thinkingLevel: latest?.thinkingLevel },\n\t\t\tfailed: failedModel && failed && { model: failedModel, thinkingLevel: failed.thinkingLevel, message: failed },\n\t\t\tmessages,\n\t\t});\n\t\tconst target = this.getPhysicalModel(route.model.provider, route.model.id);\n\t\tconst routed = `${name} routed to ${route.model.provider}/${route.model.id}`;\n\t\tif (!target) throw new Error(`${routed}, which is not a physical model.`);\n\t\tif (!this.hasConfiguredAuth(target.provider)) throw new Error(`${routed}, which has no credentials.`);\n\t\treturn { model: target, thinkingLevel: clampThinkingLevel(target, route.thinkingLevel), state: route.state };\n\t}\n\n\t/** A catalog chat model that is not virtual. */\n\tgetPhysicalModel(providerId: string, modelId: string): Model<Api> | undefined {\n\t\tconst model = this.models.getModel(providerId, modelId);\n\t\treturn model && !isVirtualModel(model) ? model : undefined;\n\t}\n}\n"]}
1
+ {"version":3,"file":"model-runtime.js","sourceRoot":"","sources":["../../src/core/model-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAqBN,kBAAkB,EAClB,qBAAqB,EACrB,YAAY,EAIZ,0BAA0B,EAC1B,yBAAyB,EAMzB,UAAU,EAQV,WAAW,EAWX,gBAAgB,GAShB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,KAAK,sBAA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AgD;IAChD,gBAAgB,CAAC,UAAkB,EAAE,OAAe;QACnD,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QACxD,OAAO,KAAK,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;IAC5D,CAAC;CACD","sourcesContent":["import { AsyncLocalStorage } from \"node:async_hooks\";\nimport { dirname, join } from \"node:path\";\nimport {\n\ttype AnyModel,\n\ttype Api,\n\ttype ApiStreamOptions,\n\ttype AssistantImages,\n\ttype AssistantMessage,\n\ttype AssistantMessageEventStream,\n\ttype AuthCheck,\n\ttype AuthInteraction,\n\ttype AuthOperationOptions,\n\ttype AuthResult,\n\ttype AuthType,\n\ttype ClassifierApi,\n\ttype ClassifierContext,\n\ttype ClassifierModel,\n\ttype ClassifierOptions,\n\ttype ClassifierResult,\n\ttype Context,\n\ttype Credential,\n\ttype CredentialInfo,\n\ttype CredentialStore,\n\tclampThinkingLevel,\n\tcommitLoginCredential,\n\tcreateModels,\n\ttype DeferredCancelOptions,\n\ttype DeferredFetchOptions,\n\ttype DeferredHandle,\n\tdefaultProviderAuthContext,\n\tgetOpenCodeSessionHeaders,\n\ttype ImageApi,\n\ttype ImageModel,\n\ttype ImagesContext,\n\ttype ImagesOptions,\n\ttype LoginOptions,\n\tlazyStream,\n\ttype Message,\n\ttype Model,\n\ttype Models,\n\ttype ModelsApiStreamOptions,\n\ttype ModelsClassifierOptions,\n\ttype ModelsDeferredCancelOptions,\n\ttype ModelsDeferredFetchOptions,\n\tModelsError,\n\ttype ModelsImagesOptions,\n\ttype ModelsRefreshOptions,\n\ttype ModelsRefreshResult,\n\ttype ModelsRequestTransforms,\n\ttype ModelsSimpleStreamOptions,\n\ttype ModelsStore,\n\ttype ModelThinkingLevel,\n\ttype ModelType,\n\ttype ModelTypeMap,\n\ttype MutableModels,\n\tnormalizeContext,\n\ttype Provider,\n\ttype ProviderHeaders,\n\ttype ProviderRequestObservation,\n\ttype ProviderRequestOptions,\n\ttype ProviderResponse,\n\ttype SimpleStreamOptions,\n\ttype StreamOptions,\n\ttype Usage,\n} from \"@earendil-works/pi-ai\";\nimport { findEnvKeys } from \"@earendil-works/pi-ai/compat\";\nimport * as builtinProviderCatalog from \"@earendil-works/pi-ai/providers/all\";\nimport { getModelListing, type ModelListing, setModelListing } from \"@earendil-works/pi-ai/providers/model-listing\";\nimport { personalizeOpenRouterCatalog } from \"@earendil-works/pi-ai/providers/openrouter\";\nimport {\n\tassertChatModel,\n\tassertClassifierInputSupported,\n\tassertClassifierModel,\n\tassertImageModel,\n\tclassifierErrorResult,\n\timageErrorResult,\n} from \"@earendil-works/pi-ai/utils/model-operations\";\nimport { getAgentDir } from \"../config.ts\";\nimport { describeGatewayCredential, HUMAIN_GATEWAY_PROVIDER } from \"../humain/gateway/constants.ts\";\nimport {\n\tFileNodeAccountMetadataStore,\n\tInMemoryNodeAccountMetadataStore,\n\ttype NodeAccountMetadataStore,\n} from \"../humain/node-account-fallback.ts\";\nimport { operationSignal, raceWithAbortSignal } from \"../utils/abort.ts\";\nimport {\n\tANTHROPIC_PROVIDER_ID,\n\tAnthropicRateLimitStore,\n\tisOfficialAnthropicBaseUrl,\n\tparseAnthropicRateLimits,\n} from \"./anthropic-account-reporting.ts\";\nimport { AccountSourceReplacementError, AuthStorage as DefaultAuthStorage } from \"./auth-storage.ts\";\nimport { filterBedrockCatalog } from \"./model-catalog-filter.ts\";\nimport { ModelConfig } from \"./model-config.ts\";\nimport { FileModelsStore, InMemoryCodingAgentModelsStore } from \"./models-store.ts\";\nimport {\n\ttype AccountRemoveResult,\n\tOAUTH_ACCOUNT_IDENTITY_FIELDS,\n\tOAuthAccountPool,\n\tsameCredential,\n} from \"./oauth-account-pool.ts\";\nimport {\n\ttype AuthStatus,\n\ttype CompatibilityRequestConfig,\n\tcomposeModelProvider,\n\tconfiguredRequestAuthStatus,\n\ttype ProviderConfigInput,\n\tresolveCompatibilityRequestConfig,\n\tresolveConfiguredModelHeaders,\n\tvalidateExtensionProvider,\n} from \"./provider-composer.ts\";\nimport { withPersonalizedCatalog, withRemoteCatalog } from \"./remote-catalog-provider.ts\";\nimport { isCommandConfigValue, resolveConfigValue } from \"./resolve-config-value.ts\";\nimport { RuntimeCredentials } from \"./runtime-credentials.ts\";\nimport { SafeCredentialError } from \"./safe-credential-error.ts\";\nimport {\n\tcreateVirtualModel,\n\tfindLatestResponse,\n\tisVirtualModel,\n\ttype ModelRoute,\n\ttype ModelRouteReason,\n\ttype VirtualModelDefinition,\n\twithVirtualModels,\n} from \"./virtual-models.ts\";\n\ninterface RegisteredVirtualModel {\n\tmodel: Model<Api>;\n\troute: VirtualModelDefinition[\"route\"];\n}\n\n/**\n * Every provider's chat models as they were when taken (what `getModels()` returned then, in its order), without building the\n * catalogs not yet built: such a provider is held as its listing, whose models are built when first needed. Every model of a\n * listing has the listing's provider as its `provider`.\n */\nclass ChatModelsSnapshot {\n\tprivate readonly parts: readonly (\n\t\t| { provider: string; listing: ModelListing; models?: undefined }\n\t\t| { provider: string; models: readonly Model<Api>[] }\n\t)[];\n\n\tconstructor(providers: readonly Provider[]) {\n\t\tthis.parts = providers.map((provider) => {\n\t\t\tconst listing = getModelListing(provider);\n\t\t\tif (listing) return { provider: provider.id, listing };\n\t\t\ttry {\n\t\t\t\treturn { provider: provider.id, models: provider.getModels() };\n\t\t\t} catch {\n\t\t\t\t// As in Models.getModels(): a provider whose getModels() throws has no models.\n\t\t\t\treturn { provider: provider.id, models: [] };\n\t\t\t}\n\t\t});\n\t}\n\n\t/** The models whose `provider` is one of `providers`, in order. */\n\tofProviders(providers: ReadonlySet<string>): Model<Api>[] {\n\t\tconst models: Model<Api>[] = [];\n\t\tfor (const part of this.parts) {\n\t\t\tif (part.models) {\n\t\t\t\tfor (const model of part.models) if (providers.has(model.provider)) models.push(model);\n\t\t\t} else if (providers.has(part.provider)) {\n\t\t\t\tmodels.push(...part.listing.models());\n\t\t\t}\n\t\t}\n\t\treturn models;\n\t}\n}\n\ninterface ModelRuntimeSnapshot {\n\tall: ChatModelsSnapshot;\n\tavailable: readonly Model<Api>[];\n\tconfiguredProviders: ReadonlySet<string>;\n\tstoredProviders: ReadonlySet<string>;\n\tauth: ReadonlyMap<string, AuthCheck | undefined>;\n}\n\nexport interface CreateModelRuntimeOptions {\n\t/** Credential storage. Defaults to the file at authPath. */\n\tcredentials?: CredentialStore;\n\tauthPath?: string;\n\t/**\n\t * Multi-account OAuth pool. Defaults to `oauth-accounts.json` next to auth.json, or an\n\t * in-memory pool when a custom `credentials` store is supplied.\n\t */\n\toauthAccountPool?: OAuthAccountPool;\n\t/**\n\t * HUMAIN Node fallback policy and labels. Defaults to `humain-node-accounts.json` next to auth.json, or an\n\t * in-memory store when a custom `credentials` store is supplied.\n\t */\n\tnodeAccountMetadata?: NodeAccountMetadataStore;\n\tmodelsPath?: string | null;\n\tmodelsStore?: ModelsStore;\n\tmodelsStorePath?: string;\n\t/** Allow create() to refresh model catalogs over the network. Defaults to false. */\n\tallowModelNetwork?: boolean;\n\t/** Timeout for the create-time network model refresh. */\n\tmodelRefreshTimeoutMs?: number;\n\tcatalogBaseUrl?: string;\n\t/** Optional caller cancellation for initial cache restoration and availability checks. */\n\tsignal?: AbortSignal;\n\t/** Skip initial catalog and availability refresh. Static models remain available. */\n\trefreshOnCreate?: boolean;\n}\n\ntype OAuthAccountObserver = (providerId: string, accountKey: string | undefined) => void;\n\nexport interface ModelRuntimeSimpleStreamOptions extends ModelsSimpleStreamOptions {\n\t/** @internal Reports the account derived from the credential used for this request, before streaming. */\n\tonOAuthAccount?: OAuthAccountObserver;\n}\n\nexport interface ModelRuntimeAuthOverrides extends AuthOperationOptions {\n\t/** @internal Scoped to this auth resolution, never catalog checks or background requests. */\n\tonOAuthAccount?: OAuthAccountObserver;\n\tapiKey?: string;\n\tenv?: Record<string, string>;\n\t/** Require this much remaining OAuth-token validity; defaults to five minutes. */\n\tminOAuthValidityMs?: number;\n}\n\nexport type CredentialSynchronizationOperation =\n\t| \"login\"\n\t| \"logout\"\n\t| \"switchAccount\"\n\t| \"setRuntimeApiKey\"\n\t| \"removeRuntimeApiKey\";\n\n/** Secret-free account metadata, safe for display and host serialization. */\nexport interface AccountInfo {\n\tkey: string;\n\tlabel: string;\n\ttype: AuthType;\n\tactive: boolean;\n\teffective: boolean;\n\texhaustedUntil?: number;\n}\n\nexport interface AccountSource {\n\tsource: \"runtime\" | \"auth_json\" | \"configuration\" | \"environment\";\n\tlabel: string;\n\ttype: AuthType;\n\treadOnly: true;\n\t/** Selected source for the next dispatch, not proof that its credential is valid. */\n\teffective: boolean;\n}\n\n/** Credentials changed successfully, but the local model/auth snapshot could not be synchronized. */\nexport class CredentialSynchronizationError extends Error {\n\treadonly providerId: string;\n\treadonly operation: CredentialSynchronizationOperation;\n\n\tconstructor(providerId: string, operation: CredentialSynchronizationOperation) {\n\t\tsuper(\n\t\t\t`Credential ${operation} committed, but local synchronization failed. Refresh local models or restart before retrying requests.`,\n\t\t);\n\t\tthis.name = \"CredentialSynchronizationError\";\n\t\tthis.providerId = providerId;\n\t\tthis.operation = operation;\n\t}\n}\n\n/** Only prompt/login cancellation creates this marker; backend failures are never relayed. */\nclass LoginCancellationError extends Error {\n\tconstructor() {\n\t\tsuper(\"Login cancelled\");\n\t\tthis.name = \"AbortError\";\n\t}\n}\n\n/** Providers whose origin, headers and models are fixed; overlays would bypass their request safeguards. */\nconst OVERLAY_REJECTING_PROVIDERS: ReadonlySet<string> = new Set([HUMAIN_GATEWAY_PROVIDER]);\n\nfunction rejectsConfigOverlays(providerId: string): boolean {\n\treturn OVERLAY_REJECTING_PROVIDERS.has(providerId);\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\nconst CREDENTIAL_HEADERS = [\"x-api-key\", \"authorization\"] as const;\n\nfunction headerValue(headers: ProviderHeaders | undefined, lowerName: string): string | null | undefined {\n\tfor (const [name, value] of Object.entries(headers ?? {})) if (name.toLowerCase() === lowerName) return value;\n\treturn undefined;\n}\n\n/** True when the final request headers replace or add a credential header the resolved auth did not supply. */\nfunction overridesCredentialHeaders(\n\tresolved: ProviderHeaders | undefined,\n\tfinal: ProviderHeaders | undefined,\n): boolean {\n\treturn CREDENTIAL_HEADERS.some((name) => headerValue(final, name) !== headerValue(resolved, name));\n}\n\n/** Why a request was made. `bug-report` is internal: it is never written to the trace payload. */\nexport type ModelRequestPurpose = \"chat\" | \"compaction\" | \"branch-summary\" | \"cache-warming\" | \"bug-report\";\n\n/** Outcome of one observed submission. Carries no hidden reasoning and no credentials. */\nexport interface ModelResponseObservation {\n\tpurpose: ModelRequestPurpose | undefined;\n\trequestId: string;\n\tsubmissionId: string;\n\tsubmissionNumber: number;\n\toperation: ProviderRequestObservation[\"operation\"];\n\tprovider: string;\n\tapi: string;\n\tmodel: string;\n\t/** `pending` on a superseded submission: its transport outcome was never observed. */\n\tstopReason: \"pending\" | \"stop\" | \"length\" | \"toolUse\" | \"error\" | \"aborted\" | \"deferred\";\n\t/** Final assistant message for chat requests. */\n\tmessage?: AssistantMessage;\n\terrorMessage?: string;\n\tusage?: Usage;\n\t/** True when a later submission of the same request (a transport retry) replaced this one; its outcome is unknown. */\n\tsuperseded: boolean;\n}\n\n/** Read-only, per-session receiver of actual provider submissions. Failures never affect requests. */\nexport interface ModelRequestObserver {\n\tonRequest(\n\t\tobservation: Readonly<ProviderRequestObservation>,\n\t\tpurpose: ModelRequestPurpose | undefined,\n\t): void | Promise<void>;\n\tonResponse(response: Readonly<ModelResponseObservation>): void | Promise<void>;\n\t/** No submission could be observed, or a direct call could not be attributed to one session. */\n\tonUnattributed?(): void | Promise<void>;\n}\n\ninterface ModelRequestScope {\n\tobserver: ModelRequestObserver;\n\tpurpose: ModelRequestPurpose | undefined;\n}\n\nfunction swallow(fn: () => void | Promise<void>): void {\n\ttry {\n\t\tconst result = fn();\n\t\tif (result) result.catch(() => {});\n\t} catch {\n\t\t// Observation is best effort.\n\t}\n}\n\ntype SubmissionLink = Pick<\n\tProviderRequestObservation,\n\t\"requestId\" | \"submissionId\" | \"submissionNumber\" | \"operation\" | \"provider\" | \"api\" | \"model\"\n>;\n\n/**\n * Collects the submissions of one logical request and reports their outcome once. Only the latest\n * submission is held (without its body); a newer submission settles the previous one at once as\n * superseded, so every submission is answered with O(1) storage however many a request makes.\n */\nclass RequestTracker {\n\tprivate readonly scope: ModelRequestScope;\n\tprivate latest: SubmissionLink | undefined;\n\tprivate settled = false;\n\n\tconstructor(scope: ModelRequestScope) {\n\t\tthis.scope = scope;\n\t}\n\n\t/** Wraps a caller `onRequest` so the observer sees the same submissions. */\n\thook(caller: ProviderRequestOptions[\"onRequest\"]): NonNullable<ProviderRequestOptions[\"onRequest\"]> {\n\t\treturn async (value) => {\n\t\t\tconst previous = this.latest;\n\t\t\tthis.latest = {\n\t\t\t\trequestId: value.requestId,\n\t\t\t\tsubmissionId: value.submissionId,\n\t\t\t\tsubmissionNumber: value.submissionNumber,\n\t\t\t\toperation: value.operation,\n\t\t\t\tprovider: value.provider,\n\t\t\t\tapi: value.api,\n\t\t\t\tmodel: value.model,\n\t\t\t};\n\t\t\ttry {\n\t\t\t\tawait this.scope.observer.onRequest(value, this.scope.purpose);\n\t\t\t} catch {\n\t\t\t\t// Observation is best effort.\n\t\t\t}\n\t\t\t// The transport outcome of a replaced submission is not visible here: report it as unknown.\n\t\t\tif (previous) this.report(previous, { stopReason: \"pending\" }, true);\n\t\t\tawait caller?.(value);\n\t\t};\n\t}\n\n\tsettleMessage(message: AssistantMessage): void {\n\t\tthis.settle({\n\t\t\tstopReason: message.stopReason,\n\t\t\tmessage,\n\t\t\terrorMessage: message.errorMessage,\n\t\t\tusage: message.usage,\n\t\t});\n\t}\n\n\tsettleResult(result: { stopReason: string; errorMessage?: string; usage?: Usage }): void {\n\t\tconst stopReason = result.stopReason === \"error\" || result.stopReason === \"aborted\" ? result.stopReason : \"stop\";\n\t\tthis.settle({ stopReason, errorMessage: result.errorMessage, usage: result.usage });\n\t}\n\n\tsettleFailure(aborted: boolean): void {\n\t\tthis.settle({ stopReason: aborted ? \"aborted\" : \"error\" });\n\t}\n\n\tprivate settle(outcome: Pick<ModelResponseObservation, \"stopReason\" | \"message\" | \"errorMessage\" | \"usage\">): void {\n\t\tif (this.settled) return;\n\t\tthis.settled = true;\n\t\tif (this.latest) this.report(this.latest, outcome, false);\n\t\telse swallow(() => this.scope.observer.onUnattributed?.());\n\t}\n\n\tprivate report(\n\t\tsubmission: SubmissionLink,\n\t\toutcome: Pick<ModelResponseObservation, \"stopReason\" | \"message\" | \"errorMessage\" | \"usage\">,\n\t\tsuperseded: boolean,\n\t): void {\n\t\tconst response: ModelResponseObservation = {\n\t\t\tpurpose: this.scope.purpose,\n\t\t\trequestId: submission.requestId,\n\t\t\tsubmissionId: submission.submissionId,\n\t\t\tsubmissionNumber: submission.submissionNumber,\n\t\t\toperation: submission.operation,\n\t\t\tprovider: submission.provider,\n\t\t\tapi: submission.api,\n\t\t\tmodel: submission.model,\n\t\t\t...outcome,\n\t\t\tsuperseded,\n\t\t};\n\t\tswallow(() => this.scope.observer.onResponse(response));\n\t}\n}\n\n/** Configured pi-ai Models collection used by coding-agent and SDK consumers. */\nexport class ModelRuntime implements Models {\n\tprivate readonly models: MutableModels;\n\tprivate readonly credentials: RuntimeCredentials;\n\tprivate readonly oauthAccountPool: OAuthAccountPool;\n\t/** Secret-free HUMAIN Node fallback policy and user labels; keys stay in the credential pool. */\n\treadonly nodeAccountMetadata: NodeAccountMetadataStore;\n\t/** Latest Anthropic API rate-limit headers per account, observed from this runtime's own responses. */\n\treadonly anthropicRateLimits = new AnthropicRateLimitStore();\n\tprivate readonly defaultBuiltins: ReadonlyMap<string, Provider>;\n\tprivate readonly builtins = new Map<string, Provider>();\n\tprivate readonly nativeExtensionProviders = new Map<string, Provider>();\n\tprivate readonly extensionProviders = new Map<string, ProviderConfigInput>();\n\t/** Virtual models by provider id, then model id. */\n\tprivate readonly virtualModels = new Map<string, Map<string, RegisteredVirtualModel>>();\n\tprivate readonly compositionErrors = new Map<string, string>();\n\tprivate readonly modelsPath: string | undefined;\n\tprivate readonly modelNetworkEnabled: boolean;\n\tprivate config: ModelConfig;\n\tprivate snapshot: ModelRuntimeSnapshot = {\n\t\tall: new ChatModelsSnapshot([]),\n\t\tavailable: [],\n\t\tconfiguredProviders: new Set(),\n\t\tstoredProviders: new Set(),\n\t\tauth: new Map(),\n\t};\n\tprivate availabilityRefreshSeq = 0;\n\tprivate availabilityErrorSeq = 0;\n\tprivate readonly providerAvailabilitySeq = new Map<string, number>();\n\tprivate availabilityError: string | undefined;\n\tprivate readonly credentialOperations = new Map<string, Promise<unknown>>();\n\tprivate readonly oauthAccountObserver = new AsyncLocalStorage<OAuthAccountObserver | undefined>();\n\tprivate readonly requestScope = new AsyncLocalStorage<ModelRequestScope>();\n\t/** Observers of sessions that own this runtime; they attribute direct calls made outside any request scope. */\n\tprivate readonly ownerObservers = new Set<ModelRequestObserver>();\n\n\tprivate constructor(\n\t\tcredentials: RuntimeCredentials,\n\t\toauthAccountPool: OAuthAccountPool,\n\t\tnodeAccountMetadata: NodeAccountMetadataStore,\n\t\tconfig: ModelConfig,\n\t\tmodelsPath: string | undefined,\n\t\tmodelsStore: ModelsStore,\n\t\tproviders: readonly Provider[],\n\t\tmodelNetworkEnabled: boolean,\n\t) {\n\t\tthis.credentials = credentials;\n\t\tthis.oauthAccountPool = oauthAccountPool;\n\t\tthis.nodeAccountMetadata = nodeAccountMetadata;\n\t\tthis.config = config;\n\t\tthis.modelsPath = modelsPath;\n\t\tthis.modelNetworkEnabled = modelNetworkEnabled;\n\t\tthis.defaultBuiltins = new Map(providers.map((provider) => [provider.id, provider]));\n\t\tfor (const [providerId, provider] of this.defaultBuiltins) this.builtins.set(providerId, provider);\n\t\tthis.models = createModels({ credentials, modelsStore });\n\t\tthis.rebuildProviders();\n\t}\n\n\tstatic async create(options: CreateModelRuntimeOptions = {}): Promise<ModelRuntime> {\n\t\tconst credentials = new RuntimeCredentials(options.credentials ?? DefaultAuthStorage.create(options.authPath));\n\t\tconst oauthAccountPool =\n\t\t\toptions.oauthAccountPool ??\n\t\t\t(options.credentials\n\t\t\t\t? OAuthAccountPool.inMemory(credentials.accountStore)\n\t\t\t\t: OAuthAccountPool.create(\n\t\t\t\t\t\tcredentials.accountStore,\n\t\t\t\t\t\tjoin(dirname(options.authPath ?? join(getAgentDir(), \"auth.json\")), \"oauth-accounts.json\"),\n\t\t\t\t\t));\n\t\tconst nodeAccountMetadata =\n\t\t\toptions.nodeAccountMetadata ??\n\t\t\t(options.credentials\n\t\t\t\t? new InMemoryNodeAccountMetadataStore()\n\t\t\t\t: new FileNodeAccountMetadataStore(\n\t\t\t\t\t\tjoin(dirname(options.authPath ?? join(getAgentDir(), \"auth.json\")), \"humain-node-accounts.json\"),\n\t\t\t\t\t));\n\t\tconst modelsPath =\n\t\t\toptions.modelsPath === null ? undefined : (options.modelsPath ?? join(getAgentDir(), \"models.json\"));\n\t\tconst config = await ModelConfig.load(modelsPath);\n\t\tconst modelsStore =\n\t\t\toptions.modelsStore ??\n\t\t\t(modelsPath\n\t\t\t\t? new FileModelsStore(options.modelsStorePath ?? join(dirname(modelsPath), \"models-store.json\"))\n\t\t\t\t: new InMemoryCodingAgentModelsStore());\n\t\tconst builtinModelDataGeneratedAt = builtinProviderCatalog.getBuiltinModelDataGeneratedAt();\n\t\tconst providers = builtinProviderCatalog\n\t\t\t.builtinProviders()\n\t\t\t.map((provider) => {\n\t\t\t\tif (provider.id === \"radius\") return provider;\n\t\t\t\t// OpenRouter narrows the catalog to the models, limits and prices of the user's key.\n\t\t\t\tif (provider.id === \"openrouter\") {\n\t\t\t\t\treturn withPersonalizedCatalog(\n\t\t\t\t\t\tprovider,\n\t\t\t\t\t\tpersonalizeOpenRouterCatalog,\n\t\t\t\t\t\toptions.catalogBaseUrl,\n\t\t\t\t\t\tbuiltinModelDataGeneratedAt,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn withRemoteCatalog(provider, options.catalogBaseUrl, builtinModelDataGeneratedAt);\n\t\t\t})\n\t\t\t.map((provider) => {\n\t\t\t\tif (provider.id !== \"amazon-bedrock\") return provider;\n\t\t\t\tconst getModels = provider.getModels.bind(provider);\n\t\t\t\tconst filtered: Provider = { ...provider, getModels: () => filterBedrockCatalog(getModels()) };\n\t\t\t\t// The filter keeps or drops models by id alone: the listing is filtered as the models are.\n\t\t\t\treturn setModelListing(filtered, () => {\n\t\t\t\t\tconst listing = getModelListing(provider);\n\t\t\t\t\treturn listing && { entries: filterBedrockCatalog(listing.entries), models: filtered.getModels };\n\t\t\t\t});\n\t\t\t});\n\t\tconst runtime = new ModelRuntime(\n\t\t\tcredentials,\n\t\t\toauthAccountPool,\n\t\t\tnodeAccountMetadata,\n\t\t\tconfig,\n\t\t\tmodelsPath,\n\t\t\tmodelsStore,\n\t\t\tproviders,\n\t\t\tprocess.env.PI_OFFLINE === undefined,\n\t\t);\n\t\truntime.configureRadiusProviders();\n\t\truntime.rebuildProviders();\n\t\tconst refreshFromNetwork = runtime.modelNetworkEnabled && options.allowModelNetwork === true;\n\t\tconst controller =\n\t\t\trefreshFromNetwork && options.modelRefreshTimeoutMs !== undefined ? new AbortController() : undefined;\n\t\tconst timeout = controller ? setTimeout(() => controller.abort(), options.modelRefreshTimeoutMs) : undefined;\n\t\tconst signal = controller\n\t\t\t? options.signal\n\t\t\t\t? AbortSignal.any([options.signal, controller.signal])\n\t\t\t\t: controller.signal\n\t\t\t: options.signal;\n\t\ttry {\n\t\t\tif (options.refreshOnCreate !== false) {\n\t\t\t\tawait runtime.refresh({ allowNetwork: refreshFromNetwork, signal });\n\t\t\t}\n\t\t} finally {\n\t\t\tif (timeout) clearTimeout(timeout);\n\t\t}\n\t\treturn runtime;\n\t}\n\n\tprivate configureRadiusProviders(): void {\n\t\tthis.builtins.clear();\n\t\tfor (const [providerId, provider] of this.defaultBuiltins) this.builtins.set(providerId, provider);\n\t\tfor (const providerId of this.config.getProviderIds()) {\n\t\t\tconst config = this.config.getProvider(providerId);\n\t\t\tif (config?.oauth !== \"radius\" || !config.baseUrl) continue;\n\t\t\tthis.builtins.set(\n\t\t\t\tproviderId,\n\t\t\t\tbuiltinProviderCatalog.radiusProvider({\n\t\t\t\t\tid: providerId,\n\t\t\t\t\tname: config.name ?? providerId,\n\t\t\t\t\tgateway: config.baseUrl.replace(/\\/v1\\/?$/u, \"\"),\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate providerIds(): Set<string> {\n\t\treturn new Set([\n\t\t\t...this.builtins.keys(),\n\t\t\t...this.nativeExtensionProviders.keys(),\n\t\t\t...this.config.getProviderIds(),\n\t\t\t...this.extensionProviders.keys(),\n\t\t\t...this.virtualModels.keys(),\n\t\t]);\n\t}\n\n\t/** Returns the provider without virtual models, or undefined when only virtual models define it. */\n\tprivate recomposeProvider(providerId: string): Provider | undefined {\n\t\tconst composed = this.composeProvider(providerId);\n\t\tlet provider = composed;\n\t\tif (provider?.auth.apiKey) {\n\t\t\tconst apiKey = provider.auth.apiKey;\n\t\t\tconst withCredentialEnv = (input: Parameters<typeof apiKey.resolve>[0]) => {\n\t\t\t\tconst env = input.credential?.env;\n\t\t\t\tconst ctx = input.ctx;\n\t\t\t\treturn env\n\t\t\t\t\t? { ...input, ctx: { ...ctx, env: async (name: string) => env[name] || (await ctx.env(name)) } }\n\t\t\t\t\t: input;\n\t\t\t};\n\t\t\tprovider = {\n\t\t\t\t...provider,\n\t\t\t\tauth: {\n\t\t\t\t\t...provider.auth,\n\t\t\t\t\tapiKey: {\n\t\t\t\t\t\t...apiKey,\n\t\t\t\t\t\tresolve: async (input) => {\n\t\t\t\t\t\t\tif (input.purpose !== \"catalog\") {\n\t\t\t\t\t\t\t\tconst result = await apiKey.resolve(withCredentialEnv(input));\n\t\t\t\t\t\t\t\tconst key =\n\t\t\t\t\t\t\t\t\t!this.credentials.hasRuntimeApiKey(providerId) &&\n\t\t\t\t\t\t\t\t\tinput.credential?.key &&\n\t\t\t\t\t\t\t\t\tinput.credential.key === result?.auth.apiKey\n\t\t\t\t\t\t\t\t\t\t? this.oauthAccountPool.getAccountKeyForApiKey(providerId, input.credential.key)\n\t\t\t\t\t\t\t\t\t\t: undefined;\n\t\t\t\t\t\t\t\tthis.oauthAccountObserver.getStore()?.(providerId, key);\n\t\t\t\t\t\t\t\treturn result;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// Models restores caches first. Evaluate commands only when it authorizes online auth.\n\t\t\t\t\t\t\tconst credential = await this.credentials.authResolution.run(providerId, () =>\n\t\t\t\t\t\t\t\tthis.credentials.read(providerId, { signal: input.signal }),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif (credential?.type === \"oauth\") return undefined;\n\t\t\t\t\t\t\treturn apiKey.resolve(withCredentialEnv({ ...input, credential }));\n\t\t\t\t\t\t},\n\t\t\t\t\t\tcheck: apiKey.check ? (input) => apiKey.check!(withCredentialEnv(input)) : undefined,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t\tconst oauth = provider?.auth.oauth;\n\t\tif (provider && oauth && this.oauthAccountPool.isPooled(providerId)) {\n\t\t\tprovider = {\n\t\t\t\t...provider,\n\t\t\t\tauth: {\n\t\t\t\t\t...provider.auth,\n\t\t\t\t\toauth: {\n\t\t\t\t\t\t...oauth,\n\t\t\t\t\t\trefresh: async (credential, signal) => {\n\t\t\t\t\t\t\tconst refreshed = { ...(await oauth.refresh(credential, signal)) };\n\t\t\t\t\t\t\tfor (const field of OAUTH_ACCOUNT_IDENTITY_FIELDS) {\n\t\t\t\t\t\t\t\tif (refreshed[field] === undefined && credential[field] !== undefined) {\n\t\t\t\t\t\t\t\t\trefreshed[field] = credential[field];\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn refreshed;\n\t\t\t\t\t\t},\n\t\t\t\t\t\ttoAuth: async (credential) => {\n\t\t\t\t\t\t\tconst auth = await oauth.toAuth(credential);\n\t\t\t\t\t\t\tthis.oauthAccountObserver.getStore()?.(\n\t\t\t\t\t\t\t\tproviderId,\n\t\t\t\t\t\t\t\tthis.oauthAccountPool.getAccountIdentity(providerId, credential)?.key,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn auth;\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t\tif (providerId === \"openrouter\" && provider?.refreshModels && !this.nativeExtensionProviders.has(providerId)) {\n\t\t\tconst refreshModels = provider.refreshModels.bind(provider);\n\t\t\tprovider = {\n\t\t\t\t...provider,\n\t\t\t\trefreshModels: async (context) => {\n\t\t\t\t\tlet credential = context.credential;\n\t\t\t\t\tif (!context.allowNetwork && credential?.type !== \"oauth\") {\n\t\t\t\t\t\tconst stored = this.credentials.getRuntimeApiKey(providerId)\n\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t: await this.credentials.readStored(providerId, { signal: context.signal });\n\t\t\t\t\t\tconst command =\n\t\t\t\t\t\t\tthis.credentials.isExternalCredential(stored) &&\n\t\t\t\t\t\t\tstored?.type === \"api_key\" &&\n\t\t\t\t\t\t\tstored.key !== undefined &&\n\t\t\t\t\t\t\tisCommandConfigValue(stored.key);\n\t\t\t\t\t\tconst configuredKey =\n\t\t\t\t\t\t\tthis.extensionProviders.get(providerId)?.apiKey ?? this.config.getProvider(providerId)?.apiKey;\n\t\t\t\t\t\t// Cache identity checks must not execute commands, resolve headers or refresh OAuth.\n\t\t\t\t\t\tlet key = credential?.key || credential?.env?.OPENROUTER_API_KEY || process.env.OPENROUTER_API_KEY;\n\t\t\t\t\t\tif (command) key = undefined;\n\t\t\t\t\t\telse if (!credential && configuredKey !== undefined) {\n\t\t\t\t\t\t\tkey = isCommandConfigValue(configuredKey) ? undefined : resolveConfigValue(configuredKey);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcredential = key ? { ...credential, type: \"api_key\", key } : undefined;\n\t\t\t\t\t}\n\t\t\t\t\tawait refreshModels({ ...context, credential });\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t\t// The wrappers above change auth and refresh only: the provider's models are still named by its listing.\n\t\tif (provider && composed && provider !== composed) setModelListing(provider, () => getModelListing(composed));\n\t\tconst virtualModels = [...(this.virtualModels.get(providerId)?.values() ?? [])].map((entry) => entry.model);\n\t\tif (virtualModels.length > 0) this.models.setProvider(withVirtualModels(providerId, provider, virtualModels));\n\t\telse if (provider) this.models.setProvider(provider);\n\t\telse this.models.deleteProvider(providerId);\n\t\treturn provider;\n\t}\n\n\t/** The provider without virtual models, or undefined when nothing defines it. */\n\tprivate composeProvider(providerId: string): Provider | undefined {\n\t\tconst base = this.nativeExtensionProviders.get(providerId) ?? this.builtins.get(providerId);\n\t\tconst extension = this.extensionProviders.get(providerId);\n\t\t// HUMAIN Gateway origin, headers and models are fixed; overlays would bypass its request safeguards.\n\t\tif (rejectsConfigOverlays(providerId) && (this.config.getProvider(providerId) || extension)) {\n\t\t\tthis.compositionErrors.set(providerId, \"HUMAIN Gateway does not accept models.json overrides.\");\n\t\t\treturn base;\n\t\t}\n\t\tif (!this.config.getProvider(providerId) && !extension) {\n\t\t\t// No overlays: use the builtin untouched so its auth/login/stream behavior is exact.\n\t\t\tthis.compositionErrors.delete(providerId);\n\t\t\treturn base;\n\t\t}\n\t\ttry {\n\t\t\tconst provider = composeModelProvider(providerId, base, this.config, extension);\n\t\t\tthis.compositionErrors.delete(providerId);\n\t\t\treturn provider;\n\t\t} catch (error) {\n\t\t\tthis.compositionErrors.set(providerId, error instanceof Error ? error.message : String(error));\n\t\t\treturn base;\n\t\t}\n\t}\n\n\tprivate rebuildProviders(): void {\n\t\tthis.models.clearProviders();\n\t\tthis.compositionErrors.clear();\n\t\tfor (const providerId of this.providerIds()) this.recomposeProvider(providerId);\n\t\tthis.updateModelSnapshot();\n\t}\n\n\tprivate updateModelSnapshot(): void {\n\t\tconst all = new ChatModelsSnapshot(this.models.getProviders());\n\t\tthis.snapshot = {\n\t\t\t...this.snapshot,\n\t\t\tall,\n\t\t\tavailable: all.ofProviders(this.snapshot.configuredProviders),\n\t\t};\n\t}\n\n\tprivate async runAvailabilityRefresh(seq: number, errorSeq: number, signal: AbortSignal): Promise<void> {\n\t\tconst providers = this.models.getProviders();\n\t\tconst [available, checks, credentials] = await Promise.all([\n\t\t\tthis.models.getAvailable(undefined, { signal }),\n\t\t\tPromise.all(\n\t\t\t\tproviders.map(\n\t\t\t\t\tasync (provider): Promise<[string, AuthCheck | undefined]> => [\n\t\t\t\t\t\tprovider.id,\n\t\t\t\t\t\tawait this.models.checkAuth(provider.id, { signal }),\n\t\t\t\t\t],\n\t\t\t\t),\n\t\t\t),\n\t\t\tthis.credentials.list({ signal }),\n\t\t]);\n\t\tif (seq !== this.availabilityRefreshSeq) return;\n\t\tconst auth = new Map(checks);\n\t\tconst configuredProviders = new Set(\n\t\t\tchecks\n\t\t\t\t.filter((entry): entry is [string, AuthCheck] => entry[1] !== undefined)\n\t\t\t\t.map(([providerId]) => providerId),\n\t\t);\n\t\tthis.snapshot = {\n\t\t\tall: new ChatModelsSnapshot(this.models.getProviders()),\n\t\t\tavailable: [...available],\n\t\t\tconfiguredProviders,\n\t\t\tstoredProviders: new Set(credentials.map((entry) => entry.providerId)),\n\t\t\tauth,\n\t\t};\n\t\tif (errorSeq === this.availabilityErrorSeq) this.availabilityError = undefined;\n\t}\n\n\tprivate queueAvailabilityRefresh(signal?: AbortSignal): Promise<void> {\n\t\tconst seq = ++this.availabilityRefreshSeq;\n\t\tfor (const [providerId, providerSeq] of this.providerAvailabilitySeq) {\n\t\t\tthis.providerAvailabilitySeq.set(providerId, providerSeq + 1);\n\t\t}\n\t\tconst errorSeq = ++this.availabilityErrorSeq;\n\t\tconst effectiveSignal = operationSignal(signal);\n\t\treturn this.runAvailabilityRefresh(seq, errorSeq, effectiveSignal).catch((error) => {\n\t\t\tif (errorSeq === this.availabilityErrorSeq && !effectiveSignal.aborted) {\n\t\t\t\tthis.availabilityError = error instanceof Error ? error.message : String(error);\n\t\t\t}\n\t\t\tthrow error;\n\t\t});\n\t}\n\n\tprivate async refreshProviderAvailability(providerId: string, signal: AbortSignal): Promise<void> {\n\t\t// Invalidate any full availability pass that started before this credential change.\n\t\t++this.availabilityRefreshSeq;\n\t\tconst providerSeq = (this.providerAvailabilitySeq.get(providerId) ?? 0) + 1;\n\t\tthis.providerAvailabilitySeq.set(providerId, providerSeq);\n\t\tconst errorSeq = ++this.availabilityErrorSeq;\n\t\ttry {\n\t\t\tconst [available, auth, credential] = await Promise.all([\n\t\t\t\tthis.models.getAvailable(providerId, { signal }),\n\t\t\t\tthis.models.checkAuth(providerId, { signal }),\n\t\t\t\tthis.credentials.read(providerId, { signal }),\n\t\t\t]);\n\t\t\tsignal.throwIfAborted();\n\t\t\tif (this.providerAvailabilitySeq.get(providerId) !== providerSeq) return;\n\t\t\tconst configuredProviders = new Set(this.snapshot.configuredProviders);\n\t\t\tconst storedProviders = new Set(this.snapshot.storedProviders);\n\t\t\tconst authByProvider = new Map(this.snapshot.auth);\n\t\t\tif (auth) {\n\t\t\t\tconfiguredProviders.add(providerId);\n\t\t\t\tauthByProvider.set(providerId, auth);\n\t\t\t} else {\n\t\t\t\tconfiguredProviders.delete(providerId);\n\t\t\t\tauthByProvider.delete(providerId);\n\t\t\t}\n\t\t\tif (credential) storedProviders.add(providerId);\n\t\t\telse storedProviders.delete(providerId);\n\t\t\tconst all = new ChatModelsSnapshot(this.models.getProviders());\n\t\t\tconst availableById = new Map(\n\t\t\t\t[...this.snapshot.available.filter((model) => model.provider !== providerId), ...available].map((model) => [\n\t\t\t\t\t`${model.provider}\\0${model.id}`,\n\t\t\t\t\tmodel,\n\t\t\t\t]),\n\t\t\t);\n\t\t\t// (Only the providers of these models have models to look up.)\n\t\t\tconst availableProviders = new Set(Array.from(availableById.values(), (model) => model.provider));\n\t\t\tthis.snapshot = {\n\t\t\t\tall,\n\t\t\t\tavailable: all\n\t\t\t\t\t.ofProviders(availableProviders)\n\t\t\t\t\t.flatMap((model) => availableById.get(`${model.provider}\\0${model.id}`) ?? []),\n\t\t\t\tconfiguredProviders,\n\t\t\t\tstoredProviders,\n\t\t\t\tauth: authByProvider,\n\t\t\t};\n\t\t\tif (errorSeq === this.availabilityErrorSeq) this.availabilityError = undefined;\n\t\t} catch (error) {\n\t\t\tif (\n\t\t\t\tthis.providerAvailabilitySeq.get(providerId) === providerSeq &&\n\t\t\t\terrorSeq === this.availabilityErrorSeq &&\n\t\t\t\t!signal.aborted\n\t\t\t) {\n\t\t\t\tthis.availabilityError = error instanceof Error ? error.message : String(error);\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tgetProviders(): readonly Provider[] {\n\t\treturn this.models.getProviders();\n\t}\n\n\tgetProvider(providerId: string): Provider | undefined {\n\t\treturn this.models.getProvider(providerId);\n\t}\n\n\tgetModels(providerId?: string): readonly Model<Api>[] {\n\t\treturn this.models.getModels(providerId);\n\t}\n\n\tgetModel(providerId: string, modelId: string): Model<Api> | undefined {\n\t\treturn this.models.getModel(providerId, modelId);\n\t}\n\n\t/**\n\t * Every chat model in `getModels()` order, for choosing models by provider, id and name without building every catalog:\n\t * a provider whose catalog is not built yet is listed by stand-ins that have only `provider`, `id` and `name`.\n\t * `model()` returns the model a stand-in stands for (building that provider's catalog), and a model as it is.\n\t */\n\tgetModelChoices(): { models: readonly Model<Api>[]; model(choice: Model<Api>): Model<Api> } {\n\t\tconst models: Model<Api>[] = [];\n\t\tconst standIns = new Map<Model<Api>, { listing: ModelListing; index: number }>();\n\t\tfor (const provider of this.models.getProviders()) {\n\t\t\tconst listing = getModelListing(provider);\n\t\t\tif (!listing) {\n\t\t\t\ttry {\n\t\t\t\t\tmodels.push(...provider.getModels());\n\t\t\t\t} catch {\n\t\t\t\t\t// As in Models.getModels(): a provider whose getModels() throws has no models.\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tlisting.entries.forEach((entry, index) => {\n\t\t\t\tconst standIn = entry as Model<Api>;\n\t\t\t\tmodels.push(standIn);\n\t\t\t\tstandIns.set(standIn, { listing, index });\n\t\t\t});\n\t\t}\n\t\treturn {\n\t\t\tmodels,\n\t\t\tmodel: (choice) => {\n\t\t\t\tconst standIn = standIns.get(choice);\n\t\t\t\treturn standIn ? standIn.listing.models()[standIn.index] : choice;\n\t\t\t},\n\t\t};\n\t}\n\n\tgetModelsOfType<TType extends ModelType>(type: TType, providerId?: string): readonly ModelTypeMap[TType][] {\n\t\treturn this.models.getModelsOfType(type, providerId);\n\t}\n\n\tgetModelOfType<TType extends ModelType>(\n\t\ttype: TType,\n\t\tproviderId: string,\n\t\tmodelId: string,\n\t): ModelTypeMap[TType] | undefined {\n\t\treturn this.models.getModelOfType(type, providerId, modelId);\n\t}\n\n\tgetAllModels(providerId?: string): readonly AnyModel[] {\n\t\treturn this.models.getAllModels(providerId);\n\t}\n\n\tgetAvailableOfType<TType extends ModelType>(\n\t\ttype: TType,\n\t\tproviderId?: string,\n\t\toptions?: AuthOperationOptions,\n\t): Promise<readonly ModelTypeMap[TType][]> {\n\t\treturn this.models.getAvailableOfType(type, providerId, options);\n\t}\n\n\tgetAllAvailable(providerId?: string, options?: AuthOperationOptions): Promise<readonly AnyModel[]> {\n\t\treturn this.models.getAllAvailable(providerId, options);\n\t}\n\n\tasync checkAuth(providerId: string, options?: AuthOperationOptions): Promise<AuthCheck | undefined> {\n\t\treturn this.models.checkAuth(providerId, options);\n\t}\n\n\tasync getAvailable(providerId?: string, options?: AuthOperationOptions): Promise<readonly Model<Api>[]> {\n\t\tif (providerId) {\n\t\t\tconst errorSeq = ++this.availabilityErrorSeq;\n\t\t\ttry {\n\t\t\t\tconst available = await this.models.getAvailable(providerId, options);\n\t\t\t\tif (errorSeq === this.availabilityErrorSeq) this.availabilityError = undefined;\n\t\t\t\treturn available;\n\t\t\t} catch (error) {\n\t\t\t\tif (errorSeq === this.availabilityErrorSeq && !options?.signal?.aborted) {\n\t\t\t\t\tthis.availabilityError = error instanceof Error ? error.message : String(error);\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t\tawait this.queueAvailabilityRefresh(options?.signal);\n\t\treturn this.snapshot.available;\n\t}\n\n\tgetAvailableSnapshot(): readonly Model<Api>[] {\n\t\treturn this.snapshot.available;\n\t}\n\n\tgetError(): string | undefined {\n\t\tconst errors: string[] = [];\n\t\tconst configError = this.config.getError();\n\t\tif (configError) errors.push(configError);\n\t\tfor (const [providerId, error] of this.compositionErrors) {\n\t\t\terrors.push(`Provider \"${providerId}\": ${error}`);\n\t\t}\n\t\tif (this.availabilityError) errors.push(`Availability refresh: ${this.availabilityError}`);\n\t\tconst poolError = this.oauthAccountPool.getError();\n\t\tif (poolError) errors.push(poolError);\n\t\treturn errors.length > 0 ? errors.join(\"\\n\\n\") : undefined;\n\t}\n\n\tgetRegisteredProviderConfig(providerId: string): ProviderConfigInput | undefined {\n\t\treturn this.extensionProviders.get(providerId);\n\t}\n\n\tgetRegisteredProviderIds(): readonly string[] {\n\t\treturn [...new Set([...this.extensionProviders.keys(), ...this.nativeExtensionProviders.keys()])];\n\t}\n\n\tgetRegisteredNativeProvider(providerId: string): Provider | undefined {\n\t\treturn this.nativeExtensionProviders.get(providerId);\n\t}\n\n\t/** @internal Compatibility fallback for ModelRegistry when provider auth is unconfigured. */\n\tgetCompatibilityRequestConfig(model: Model<Api>): CompatibilityRequestConfig {\n\t\tif (rejectsConfigOverlays(model.provider)) return resolveCompatibilityRequestConfig(model, undefined, undefined);\n\t\treturn resolveCompatibilityRequestConfig(\n\t\t\tmodel,\n\t\t\tthis.config.getProvider(model.provider),\n\t\t\tthis.extensionProviders.get(model.provider),\n\t\t);\n\t}\n\n\tisUsingOAuth(providerId: string): boolean {\n\t\treturn this.snapshot.auth.get(providerId)?.type === \"oauth\";\n\t}\n\n\tisUsingSubscription(providerId: string): boolean {\n\t\tconst auth = this.models.getProvider(providerId)?.auth;\n\t\treturn this.isUsingOAuth(providerId)\n\t\t\t? auth?.oauth?.isSubscription === true\n\t\t\t: this.hasConfiguredAuth(providerId) && auth?.apiKey?.isSubscription === true;\n\t}\n\n\thasConfiguredAuth(providerId: string): boolean {\n\t\treturn this.snapshot.configuredProviders.has(providerId);\n\t}\n\n\tgetAuth(providerId: string, overrides?: ModelRuntimeAuthOverrides): Promise<AuthResult | undefined>;\n\tgetAuth(model: AnyModel, overrides?: ModelRuntimeAuthOverrides): Promise<AuthResult | undefined>;\n\tasync getAuth(\n\t\tproviderOrModel: string | AnyModel,\n\t\toverrides: ModelRuntimeAuthOverrides = {},\n\t): Promise<AuthResult | undefined> {\n\t\tconst providerId = typeof providerOrModel === \"string\" ? providerOrModel : providerOrModel.provider;\n\t\tconst resolution = await this.credentials.authResolution.run(providerId, () =>\n\t\t\tthis.oauthAccountObserver.run(overrides.onOAuthAccount, () =>\n\t\t\t\ttypeof providerOrModel === \"string\"\n\t\t\t\t\t? this.models.getAuth(providerOrModel, overrides)\n\t\t\t\t\t: this.models.getAuth(providerOrModel, overrides),\n\t\t\t),\n\t\t);\n\t\tif (typeof providerOrModel === \"string\") return resolution;\n\t\tif (!resolution) return undefined;\n\t\t// Rejected HUMAIN Gateway overlays must not reach requests either.\n\t\tif (rejectsConfigOverlays(providerOrModel.provider)) return resolution;\n\t\tconst configuredHeaders = resolveConfiguredModelHeaders(\n\t\t\tproviderOrModel,\n\t\t\tthis.config.getProvider(providerOrModel.provider),\n\t\t\tthis.extensionProviders.get(providerOrModel.provider),\n\t\t\t{ ...(resolution.env ?? {}), ...(overrides.env ?? {}) },\n\t\t);\n\t\treturn {\n\t\t\t...resolution,\n\t\t\tauth: {\n\t\t\t\t...resolution.auth,\n\t\t\t\theaders: mergeHeaders(resolution.auth.headers, configuredHeaders),\n\t\t\t},\n\t\t};\n\t}\n\n\tprivate protectCredentialOperation<T>(operation: Promise<T>, signal?: AbortSignal, mutation = true): Promise<T> {\n\t\treturn operation.catch((error: unknown) => {\n\t\t\tif (error instanceof CredentialSynchronizationError)\n\t\t\t\tthrow new CredentialSynchronizationError(error.providerId, error.operation);\n\t\t\tif (error instanceof AccountSourceReplacementError) throw new AccountSourceReplacementError();\n\t\t\tif (error instanceof LoginCancellationError) throw new LoginCancellationError();\n\t\t\t// Fixed-text errors stay readable; a fresh instance drops any cause or extra properties.\n\t\t\tif (error instanceof SafeCredentialError && !signal?.aborted) throw new SafeCredentialError(error.message);\n\t\t\t// Backends can reject after writing. Never claim rollback or attach arbitrary errors, causes or abort reasons.\n\t\t\tconst safe = new ModelsError(\n\t\t\t\t\"auth\",\n\t\t\t\tmutation\n\t\t\t\t\t? \"Credential operation failed. Stored state may have changed. Inspect accounts and refresh local models before retrying.\"\n\t\t\t\t\t: \"Could not read account metadata. Check credential storage and provider configuration.\",\n\t\t\t);\n\t\t\tif (signal?.aborted) safe.name = \"AbortError\";\n\t\t\tthrow safe;\n\t\t});\n\t}\n\n\tprivate enqueueCredentialOperation<T>(providerId: string, signal: AbortSignal, task: () => Promise<T>): Promise<T> {\n\t\tconst previous = this.credentialOperations.get(providerId) ?? Promise.resolve();\n\t\tlet markStarted: (() => void) | undefined;\n\t\tconst started = new Promise<void>((resolve) => {\n\t\t\tmarkStarted = resolve;\n\t\t});\n\t\tconst operation = (async () => {\n\t\t\tawait previous.catch(() => {});\n\t\t\tsignal.throwIfAborted();\n\t\t\tmarkStarted?.();\n\t\t\treturn task();\n\t\t})();\n\t\tconst tail = operation.catch(() => {});\n\t\tthis.credentialOperations.set(providerId, tail);\n\t\tvoid tail.then(() => {\n\t\t\tif (this.credentialOperations.get(providerId) === tail) this.credentialOperations.delete(providerId);\n\t\t});\n\t\treturn this.protectCredentialOperation(\n\t\t\traceWithAbortSignal(started, signal).then(() => operation),\n\t\t\tsignal,\n\t\t);\n\t}\n\n\tprivate async synchronizeCredentialState(\n\t\tproviderId: string,\n\t\toperation: CredentialSynchronizationOperation,\n\t\tsignal: AbortSignal,\n\t): Promise<void> {\n\t\ttry {\n\t\t\tsignal.throwIfAborted();\n\t\t\tthis.recomposeProvider(providerId);\n\t\t\tconst compositionError = this.compositionErrors.get(providerId);\n\t\t\t// The rejected Gateway overlay leaves the native provider intact, so credentials still sync.\n\t\t\tif (compositionError && !rejectsConfigOverlays(providerId)) throw new Error(compositionError);\n\t\t\tconst result = await this.models.refresh({ allowNetwork: false, providers: [providerId], signal });\n\t\t\tif (result.aborted) signal.throwIfAborted();\n\t\t\tconst refreshError = result.errors.get(providerId);\n\t\t\tif (refreshError) throw refreshError;\n\t\t\tthis.updateModelSnapshot();\n\t\t\tawait this.refreshProviderAvailability(providerId, signal);\n\t\t} catch {\n\t\t\t// Adapter failures may contain credentials, including nested causes and custom properties.\n\t\t\tconst error = new CredentialSynchronizationError(providerId, operation);\n\t\t\tif (this.compositionErrors.has(providerId)) this.compositionErrors.set(providerId, error.message);\n\t\t\tif (this.availabilityError) this.availabilityError = error.message;\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tsetRuntimeApiKey(providerId: string, apiKey: string, options: AuthOperationOptions = {}): Promise<void> {\n\t\tconst signal = operationSignal(options.signal);\n\t\treturn this.enqueueCredentialOperation(providerId, signal, async () => {\n\t\t\tthis.credentials.setRuntimeApiKey(providerId, apiKey);\n\t\t\tawait this.synchronizeCredentialState(providerId, \"setRuntimeApiKey\", signal);\n\t\t});\n\t}\n\n\tremoveRuntimeApiKey(providerId: string, options: AuthOperationOptions = {}): Promise<void> {\n\t\tconst signal = operationSignal(options.signal);\n\t\treturn this.enqueueCredentialOperation(providerId, signal, async () => {\n\t\t\tthis.credentials.removeRuntimeApiKey(providerId);\n\t\t\tawait this.synchronizeCredentialState(providerId, \"removeRuntimeApiKey\", signal);\n\t\t});\n\t}\n\n\t/**\n\t * Raw stored credential for host-owned reporting: no command or environment resolution, so reading it runs nothing.\n\t * Sensitive; callers must never display, log or persist it.\n\t */\n\treadStoredCredential(providerId: string, options?: AuthOperationOptions): Promise<Credential | undefined> {\n\t\treturn this.protectCredentialOperation(this.credentials.readStored(providerId, options), options?.signal, false);\n\t}\n\n\tlistCredentials(options?: AuthOperationOptions): Promise<readonly CredentialInfo[]> {\n\t\treturn this.protectCredentialOperation(this.credentials.list(options), options?.signal, false);\n\t}\n\n\t/** Global account management. Lists contain metadata only, never resolved credentials. */\n\treadonly accounts = {\n\t\tlist: (providerId: string, options?: AuthOperationOptions): Promise<AccountInfo[]> =>\n\t\t\tthis.protectCredentialOperation(\n\t\t\t\t(async () => {\n\t\t\t\t\tconst { storedEffective } = await this.readAccountSources(providerId, options);\n\t\t\t\t\tconst accounts = await this.oauthAccountPool.listAccounts(providerId, options);\n\t\t\t\t\tconst current = await this.oauthAccountPool.getCurrentAccount(providerId, options);\n\t\t\t\t\treturn accounts.map(({ key, label, credential, exhaustedUntil }) => ({\n\t\t\t\t\t\tkey,\n\t\t\t\t\t\tlabel,\n\t\t\t\t\t\ttype: credential.type,\n\t\t\t\t\t\texhaustedUntil,\n\t\t\t\t\t\tactive: key === current?.key,\n\t\t\t\t\t\teffective: key === current?.key && storedEffective,\n\t\t\t\t\t}));\n\t\t\t\t})(),\n\t\t\t\toptions?.signal,\n\t\t\t\tfalse,\n\t\t\t),\n\t\tsources: (providerId: string, options?: AuthOperationOptions): Promise<AccountSource[]> =>\n\t\t\tthis.protectCredentialOperation(\n\t\t\t\tthis.readAccountSources(providerId, options).then((result) => result.sources),\n\t\t\t\toptions?.signal,\n\t\t\t\tfalse,\n\t\t\t),\n\t\tswitch: (\n\t\t\tproviderId: string,\n\t\t\taccountKey: string,\n\t\t\toptions: AuthOperationOptions = {},\n\t\t): Promise<AccountInfo | undefined> => {\n\t\t\tconst signal = operationSignal(options.signal);\n\t\t\treturn this.enqueueCredentialOperation(providerId, signal, async () => {\n\t\t\t\tconst account = await this.oauthAccountPool.setActiveAccount(providerId, accountKey, { signal });\n\t\t\t\tif (!account) return undefined;\n\t\t\t\tawait this.synchronizeCredentialState(providerId, \"switchAccount\", signal);\n\t\t\t\treturn (await this.accounts.list(providerId, { signal })).find((entry) => entry.key === accountKey);\n\t\t\t});\n\t\t},\n\t\trename: (\n\t\t\tproviderId: string,\n\t\t\taccountKey: string,\n\t\t\tlabel: string,\n\t\t\toptions?: AuthOperationOptions,\n\t\t): Promise<AccountInfo | undefined> =>\n\t\t\tthis.protectCredentialOperation(\n\t\t\t\t(async () => {\n\t\t\t\t\tconst account = await this.oauthAccountPool.renameAccount(providerId, accountKey, label, options);\n\t\t\t\t\treturn account\n\t\t\t\t\t\t? (await this.accounts.list(providerId, options)).find((entry) => entry.key === accountKey)\n\t\t\t\t\t\t: undefined;\n\t\t\t\t})(),\n\t\t\t\toptions?.signal,\n\t\t\t),\n\t\tremove: (\n\t\t\tproviderId: string,\n\t\t\taccountKey: string,\n\t\t\toptions?: AuthOperationOptions,\n\t\t): Promise<AccountRemoveResult[\"status\"]> => this.logoutWithStatus(providerId, { ...options, accountKey }),\n\t};\n\n\t/** Enumerate raw source metadata without OAuth refresh, configuration commands or custom resolve callbacks. */\n\tprivate async readAccountSources(\n\t\tproviderId: string,\n\t\toptions?: AuthOperationOptions,\n\t): Promise<{ sources: AccountSource[]; storedEffective: boolean }> {\n\t\tconst signal = operationSignal(options?.signal);\n\t\tconst provider = this.models.getProvider(providerId);\n\t\tconst stored = await this.credentials.readStored(providerId, { signal });\n\t\tconst runtimeKey = this.credentials.getRuntimeApiKey(providerId);\n\t\tconst extensionKey = this.extensionProviders.get(providerId)?.apiKey;\n\t\tconst modelsKey = this.config.getProvider(providerId)?.apiKey;\n\t\tconst configKey = extensionKey ?? modelsKey;\n\t\tconst external = this.credentials.isExternalCredential(stored);\n\t\tconst sources: AccountSource[] = [];\n\t\tconst add = (source: AccountSource[\"source\"], label: string, effective = false) =>\n\t\t\tsources.push({ source, label, type: \"api_key\", readOnly: true, effective });\n\t\tif (runtimeKey) add(\"runtime\", \"runtime API key\", provider?.auth.apiKey !== undefined);\n\t\tif (stored?.type === \"api_key\" && (external || !stored.key?.trim()))\n\t\t\tadd(\n\t\t\t\t\"auth_json\",\n\t\t\t\tstored.key\n\t\t\t\t\t? isCommandConfigValue(stored.key)\n\t\t\t\t\t\t? \"command in auth.json\"\n\t\t\t\t\t\t: \"environment reference in auth.json\"\n\t\t\t\t\t: ((providerId === HUMAIN_GATEWAY_PROVIDER ? describeGatewayCredential(stored.env) : undefined) ??\n\t\t\t\t\t\t\t\"provider configuration in auth.json\"),\n\t\t\t);\n\t\tif (extensionKey !== undefined) add(\"configuration\", \"extension API key\");\n\t\tif (modelsKey !== undefined) add(\"configuration\", \"API key in models.json\");\n\t\tconst env = stored?.type === \"api_key\" ? stored.env : undefined;\n\t\tconst ambientNames =\n\t\t\tproviderId === \"amazon-bedrock\"\n\t\t\t\t? [\n\t\t\t\t\t\t\"AWS_BEARER_TOKEN_BEDROCK\",\n\t\t\t\t\t\t\"AWS_PROFILE\",\n\t\t\t\t\t\t\"AWS_ACCESS_KEY_ID\",\n\t\t\t\t\t\t\"AWS_SECRET_ACCESS_KEY\",\n\t\t\t\t\t\t\"AWS_SESSION_TOKEN\",\n\t\t\t\t\t\t\"AWS_CONTAINER_CREDENTIALS_RELATIVE_URI\",\n\t\t\t\t\t\t\"AWS_CONTAINER_CREDENTIALS_FULL_URI\",\n\t\t\t\t\t\t\"AWS_WEB_IDENTITY_TOKEN_FILE\",\n\t\t\t\t\t\t\"AWS_ROLE_ARN\",\n\t\t\t\t\t\t\"AWS_REGION\",\n\t\t\t\t\t\t\"AWS_DEFAULT_REGION\",\n\t\t\t\t\t\t\"AWS_SHARED_CREDENTIALS_FILE\",\n\t\t\t\t\t\t\"AWS_CONFIG_FILE\",\n\t\t\t\t\t]\n\t\t\t\t: providerId === \"google-vertex\"\n\t\t\t\t\t? [\"GOOGLE_APPLICATION_CREDENTIALS\", \"GOOGLE_CLOUD_PROJECT\", \"GCLOUD_PROJECT\", \"GOOGLE_CLOUD_LOCATION\"]\n\t\t\t\t\t: [];\n\t\tconst authEnvironmentNames = new Set([\n\t\t\t...(findEnvKeys(providerId) ?? []),\n\t\t\t...(findEnvKeys(providerId, env) ?? []),\n\t\t\t...ambientNames.filter((name) => !!(env?.[name] || process.env[name])),\n\t\t]);\n\t\tfor (const name of authEnvironmentNames) add(\"environment\", name);\n\t\tlet storedEffective = false;\n\t\tif (!runtimeKey && provider) {\n\t\t\tif (stored?.type === \"oauth\") {\n\t\t\t\tstoredEffective = provider.auth.oauth !== undefined;\n\t\t\t} else if (provider.auth.apiKey) {\n\t\t\t\tif (\n\t\t\t\t\texternal &&\n\t\t\t\t\tstored?.type === \"api_key\" &&\n\t\t\t\t\tstored.key !== undefined &&\n\t\t\t\t\tisCommandConfigValue(stored.key)\n\t\t\t\t) {\n\t\t\t\t\t// A command owns this dispatch branch; listing never runs it to validate its result.\n\t\t\t\t\tsources.find((entry) => entry.source === \"auth_json\")!.effective = true;\n\t\t\t\t} else if (!stored && configKey !== undefined) {\n\t\t\t\t\tconst configured = isCommandConfigValue(configKey) || resolveConfigValue(configKey) !== undefined;\n\t\t\t\t\tsources.find((entry) => entry.source === \"configuration\")!.effective = configured;\n\t\t\t\t} else {\n\t\t\t\t\t// Builtin resolvers only read environment/files. Never call an extension resolver for a list;\n\t\t\t\t\t// extensions can supply the side-effect-free ApiKeyAuth.check contract instead.\n\t\t\t\t\tconst base = this.nativeExtensionProviders.get(providerId) ?? this.builtins.get(providerId);\n\t\t\t\t\tconst method = base?.auth.apiKey;\n\t\t\t\t\tconst check =\n\t\t\t\t\t\tmethod?.check ?? (this.nativeExtensionProviders.has(providerId) ? undefined : method?.resolve);\n\t\t\t\t\tconst credential =\n\t\t\t\t\t\tstored?.type === \"api_key\"\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t...stored,\n\t\t\t\t\t\t\t\t\tkey:\n\t\t\t\t\t\t\t\t\t\texternal && stored.key !== undefined\n\t\t\t\t\t\t\t\t\t\t\t? resolveConfigValue(stored.key, stored.env)\n\t\t\t\t\t\t\t\t\t\t\t: stored.key,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: undefined;\n\t\t\t\t\tconst ctx = defaultProviderAuthContext();\n\t\t\t\t\tconst usedEnvironment = new Set<string>();\n\t\t\t\t\tconst result = check\n\t\t\t\t\t\t? await check({\n\t\t\t\t\t\t\t\tctx: {\n\t\t\t\t\t\t\t\t\t...ctx,\n\t\t\t\t\t\t\t\t\tenv: async (name) => {\n\t\t\t\t\t\t\t\t\t\tconst value = env?.[name] || (await ctx.env(name));\n\t\t\t\t\t\t\t\t\t\tif (value && authEnvironmentNames.has(name)) usedEnvironment.add(name);\n\t\t\t\t\t\t\t\t\t\treturn value;\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tcredential,\n\t\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t: undefined;\n\t\t\t\t\t// Native check labels are display text, not a source contract. Attribute by the inputs used,\n\t\t\t\t\t// never by arbitrary labels (which may themselves contain credential material).\n\t\t\t\t\tconst native = this.nativeExtensionProviders.has(providerId);\n\t\t\t\t\tconst source = native ? undefined : result?.source;\n\t\t\t\t\tstoredEffective =\n\t\t\t\t\t\t!!stored &&\n\t\t\t\t\t\t(native\n\t\t\t\t\t\t\t? check\n\t\t\t\t\t\t\t\t? !!result && usedEnvironment.size === 0\n\t\t\t\t\t\t\t\t: !!credential?.key\n\t\t\t\t\t\t\t: source === \"stored credential\" || source === \"stored\" || (!check && !!credential?.key));\n\t\t\t\t\tif (result && !storedEffective) {\n\t\t\t\t\t\tconst selectedNames =\n\t\t\t\t\t\t\tsource && sources.some((entry) => entry.label === source) ? [source] : [...usedEnvironment];\n\t\t\t\t\t\tlet marked = false;\n\t\t\t\t\t\tfor (const name of selectedNames) {\n\t\t\t\t\t\t\tconst entry = sources.find((entry) => entry.source === \"environment\" && entry.label === name);\n\t\t\t\t\t\t\tif (entry) {\n\t\t\t\t\t\t\t\tentry.effective = true;\n\t\t\t\t\t\t\t\tmarked = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (!marked) add(\"environment\", \"ambient credentials\", true);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tconst storedSource = sources.find((entry) => entry.source === \"auth_json\");\n\t\tif (storedSource && storedEffective) storedSource.effective = true;\n\t\tsignal.throwIfAborted();\n\t\treturn { sources, storedEffective };\n\t}\n\n\t/** Request-boundary return. External overrides/references never authorize a stored-account switch. */\n\tasync prepareAccountRequest(\n\t\tproviderId: string,\n\t\tautoSwitch: () => boolean,\n\t\tskipKeys: ReadonlySet<string>,\n\t\tsignal?: AbortSignal,\n\t): Promise<void> {\n\t\tif (!autoSwitch() || this.credentials.hasRuntimeApiKey(providerId)) return;\n\t\tconst stored = await this.credentials.readStored(providerId, { signal });\n\t\tif (!stored || this.credentials.isExternalCredential(stored)) return;\n\t\tconst returned = await this.oauthAccountPool.returnToPreferred(providerId, {\n\t\t\tsignal,\n\t\t\tskipKeys,\n\t\t\tcanActivate: () => autoSwitch() && !this.credentials.hasRuntimeApiKey(providerId),\n\t\t});\n\t\tif (returned) await this.synchronizeCredentialState(providerId, \"switchAccount\", operationSignal(signal));\n\t}\n\n\t/** Low-level pool APIs contain credentials; never serialize them into UI, events or logs. */\n\tget oauthAccounts(): OAuthAccountPool {\n\t\treturn this.oauthAccountPool;\n\t}\n\n\tgetProviderAuthStatus(providerId: string): AuthStatus {\n\t\tif (this.credentials.hasRuntimeApiKey(providerId)) return { configured: true, source: \"runtime\" };\n\t\tif (this.snapshot.storedProviders.has(providerId)) return { configured: true, source: \"stored\" };\n\t\tconst configured = configuredRequestAuthStatus(\n\t\t\tthis.config.getProvider(providerId),\n\t\t\tthis.extensionProviders.get(providerId),\n\t\t);\n\t\tif (configured) return configured;\n\t\tconst check = this.snapshot.auth.get(providerId);\n\t\treturn check ? { configured: true, source: \"environment\", label: check.source } : { configured: false };\n\t}\n\n\tprivate async prepareRequest<\n\t\tTModel extends AnyModel,\n\t\tTOptions extends ProviderRequestOptions<TModel> &\n\t\t\tModelsRequestTransforms & { onOAuthAccount?: OAuthAccountObserver },\n\t>(\n\t\tmodel: TModel,\n\t\toptions: TOptions | undefined,\n\t): Promise<{\n\t\tprovider: Provider;\n\t\tmodel: TModel;\n\t\toptions: Omit<TOptions, \"transformHeaders\"> & ProviderRequestOptions<TModel>;\n\t\ttracker: RequestTracker | undefined;\n\t}> {\n\t\tconst provider = this.models.getProvider(model.provider);\n\t\tif (!provider) throw new ModelsError(\"provider\", `Unknown provider: ${model.provider}`);\n\t\tlet resolvedAccount: { provider: string; key: string | undefined } | undefined;\n\t\t// Anthropic rate-limit headers are only recorded for a credential whose account is identified for this request.\n\t\tconst observesAnthropicLimits = model.provider === ANTHROPIC_PROVIDER_ID;\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\tonOAuthAccount:\n\t\t\t\toptions?.onOAuthAccount || observesAnthropicLimits\n\t\t\t\t\t? (provider, key) => {\n\t\t\t\t\t\t\tresolvedAccount = { provider, key };\n\t\t\t\t\t\t}\n\t\t\t\t\t: undefined,\n\t\t});\n\t\tif (!resolution) throw new ModelsError(\"auth\", `Provider is not configured: ${model.provider}`);\n\n\t\tconst { transformHeaders, onOAuthAccount: _onOAuthAccount, ...rawProviderOptions } = options ?? {};\n\t\tconst providerOptions = rawProviderOptions as Omit<TOptions, \"transformHeaders\"> & ProviderRequestOptions<TModel>;\n\t\tconst requestModel: TModel = resolution.auth.baseUrl ? { ...model, baseUrl: resolution.auth.baseUrl } : model;\n\t\tconst sessionId =\n\t\t\t\"sessionId\" in providerOptions && typeof providerOptions.sessionId === \"string\"\n\t\t\t\t? providerOptions.sessionId\n\t\t\t\t: undefined;\n\t\tlet headers = mergeHeaders(\n\t\t\tmergeHeaders(getOpenCodeSessionHeaders(requestModel, sessionId), resolution.auth.headers),\n\t\t\tproviderOptions.headers,\n\t\t);\n\t\tif (transformHeaders) headers = await transformHeaders(headers ?? {});\n\t\tconst env =\n\t\t\tresolution.env || providerOptions.env\n\t\t\t\t? { ...(resolution.env ?? {}), ...(providerOptions.env ?? {}) }\n\t\t\t\t: undefined;\n\t\tconst apiKey = providerOptions.apiKey ?? resolution.auth.apiKey;\n\t\tlet attributedAccountKey: string | undefined;\n\t\tif ((options?.onOAuthAccount || observesAnthropicLimits) && this.oauthAccountPool.isPooled(model.provider)) {\n\t\t\t// OAuth-only providers still resolve stored auth even with an explicit request key. That\n\t\t\t// credential is not necessarily dispatched: preserve the key override and attribute it,\n\t\t\t// failing closed if its account is unknown. A resolved/refreshed key keeps its identity.\n\t\t\tattributedAccountKey =\n\t\t\t\tresolvedAccount?.provider === model.provider && apiKey === resolution.auth.apiKey\n\t\t\t\t\t? resolvedAccount.key\n\t\t\t\t\t: apiKey\n\t\t\t\t\t\t? this.oauthAccountPool.getAccountKeyForAccessToken(model.provider, apiKey)\n\t\t\t\t\t\t: undefined;\n\t\t\toptions?.onOAuthAccount?.(model.provider, attributedAccountKey);\n\t\t}\n\t\tconst callerOnResponse = providerOptions.onResponse;\n\t\tconst onResponse =\n\t\t\tobservesAnthropicLimits &&\n\t\t\tattributedAccountKey !== undefined &&\n\t\t\t!overridesCredentialHeaders(resolution.auth.headers, headers) &&\n\t\t\tisOfficialAnthropicBaseUrl(requestModel.baseUrl)\n\t\t\t\t? async (response: ProviderResponse, responseModel: TModel) => {\n\t\t\t\t\t\tthis.observeAnthropicLimits(attributedAccountKey, response);\n\t\t\t\t\t\tawait callerOnResponse?.(response, responseModel);\n\t\t\t\t\t}\n\t\t\t\t: callerOnResponse;\n\t\t// The one request boundary: every chat, image, classifier and deferred call is prepared here, so\n\t\t// the scope bound by the owning session observes it exactly once per real submission.\n\t\tconst scope = this.currentScope();\n\t\tconst tracker = scope ? new RequestTracker(scope) : undefined;\n\t\t// Payload hooks may run from a shared queue; rebind the scope so they see this request's purpose.\n\t\tconst callerOnPayload = providerOptions.onPayload;\n\t\tconst onPayload =\n\t\t\tscope && callerOnPayload\n\t\t\t\t? (payload: unknown, payloadModel: TModel) =>\n\t\t\t\t\t\tthis.requestScope.run(scope, () => callerOnPayload(payload, payloadModel))\n\t\t\t\t: callerOnPayload;\n\t\treturn {\n\t\t\tprovider,\n\t\t\tmodel: requestModel,\n\t\t\toptions: {\n\t\t\t\t...providerOptions,\n\t\t\t\tapiKey,\n\t\t\t\theaders,\n\t\t\t\tenv,\n\t\t\t\t...(onPayload ? { onPayload } : {}),\n\t\t\t\t...(onResponse ? { onResponse } : {}),\n\t\t\t\t...(tracker ? { onRequest: tracker.hook(providerOptions.onRequest) } : {}),\n\t\t\t} as Omit<TOptions, \"transformHeaders\"> & ProviderRequestOptions<TModel>,\n\t\t\ttracker,\n\t\t};\n\t}\n\n\tprivate observeAnthropicLimits(accountKey: string, response: ProviderResponse): void {\n\t\ttry {\n\t\t\tconst snapshot = parseAnthropicRateLimits(response.headers, Date.now());\n\t\t\tif (snapshot) this.anthropicRateLimits.record(accountKey, snapshot);\n\t\t} catch {\n\t\t\t// Observation is best effort and never affects the request.\n\t\t}\n\t}\n\n\t/**\n\t * Run `fn` so every request it starts (including background work it schedules) is reported to\n\t * `observer`. The binding follows async context, so concurrent sessions sharing this runtime keep\n\t * their own observers.\n\t */\n\tobserveRequests<T>(observer: ModelRequestObserver, purpose: ModelRequestPurpose | undefined, fn: () => T): T {\n\t\treturn this.requestScope.run({ observer, purpose }, fn);\n\t}\n\n\t/** Register a session observer that owns direct calls on this runtime; returns the unregister function. */\n\taddOwnerObserver(observer: ModelRequestObserver): () => void {\n\t\tthis.ownerObservers.add(observer);\n\t\treturn () => {\n\t\t\tthis.ownerObservers.delete(observer);\n\t\t};\n\t}\n\n\t/**\n\t * The active request scope, else the sole owning session's chat scope for a direct SDK call. With\n\t * several owners the call cannot be attributed: nothing is observed and the first owner is told of the gap.\n\t */\n\tprivate currentScope(): ModelRequestScope | undefined {\n\t\tconst scope = this.requestScope.getStore();\n\t\tif (scope || this.ownerObservers.size === 0) return scope;\n\t\tif (this.ownerObservers.size === 1) {\n\t\t\tconst [observer] = this.ownerObservers;\n\t\t\treturn { observer, purpose: \"chat\" };\n\t\t}\n\t\t// One content-free notice is enough; the recorder is process-wide.\n\t\tconst [first] = this.ownerObservers;\n\t\tif (first?.onUnattributed) swallow(() => first.onUnattributed?.());\n\t\treturn undefined;\n\t}\n\n\t/** Purpose of the request scope the caller runs in; undefined outside a scope or for purpose-less requests. */\n\tcurrentRequestPurpose(): ModelRequestPurpose | undefined {\n\t\treturn this.requestScope.getStore()?.purpose;\n\t}\n\n\t/** Change the purpose of requests started by `fn`, keeping the current observer. No-op outside a scope. */\n\twithRequestPurpose<T>(purpose: ModelRequestPurpose | undefined, fn: () => T): T {\n\t\tconst scope = this.currentScope();\n\t\treturn scope ? this.requestScope.run({ observer: scope.observer, purpose }, fn) : fn();\n\t}\n\n\t/** Report the outcome of a stream once it ends. */\n\tprivate trackStream(\n\t\tstream: AssistantMessageEventStream,\n\t\ttracker: () => RequestTracker | undefined,\n\t): AssistantMessageEventStream {\n\t\tstream.result().then(\n\t\t\t(message) => tracker()?.settleMessage(message),\n\t\t\t() => tracker()?.settleFailure(false),\n\t\t);\n\t\treturn stream;\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\tlet tracker: RequestTracker | undefined;\n\t\treturn this.trackStream(\n\t\t\tlazyStream(model, async () => {\n\t\t\t\tassertChatModel(model);\n\t\t\t\tconst prepared = await this.prepareRequest(\n\t\t\t\t\tmodel,\n\t\t\t\t\toptions as (StreamOptions & ModelsRequestTransforms) | undefined,\n\t\t\t\t);\n\t\t\t\ttracker = prepared.tracker;\n\t\t\t\treturn prepared.provider.stream(prepared.model, transcript, prepared.options as ApiStreamOptions<TApi>);\n\t\t\t}),\n\t\t\t() => tracker,\n\t\t);\n\t}\n\n\tcomplete<TApi extends Api>(\n\t\tmodel: Model<TApi>,\n\t\tcontext: Context,\n\t\toptions?: ModelsApiStreamOptions<TApi>,\n\t): Promise<AssistantMessage> {\n\t\treturn this.stream(model, context, options).result();\n\t}\n\n\tstreamSimple(\n\t\tmodel: Model<Api>,\n\t\tcontext: Context,\n\t\toptions?: ModelRuntimeSimpleStreamOptions,\n\t): AssistantMessageEventStream {\n\t\tconst transcript = normalizeContext(context);\n\t\tif (isVirtualModel(model)) {\n\t\t\t// Requests outside the agent loop are routed here. Callers sized them before routing, so\n\t\t\t// cap the output budget to the routed model.\n\t\t\treturn lazyStream(model, async () => {\n\t\t\t\tconst route = await this.resolveModel(model, transcript.messages, {\n\t\t\t\t\treason: \"direct\",\n\t\t\t\t\tthinkingLevel: options?.reasoning ?? \"off\",\n\t\t\t\t\tsignal: options?.signal,\n\t\t\t\t});\n\t\t\t\tconst { maxTokens: limit } = route.model;\n\t\t\t\tconst maxTokens = options?.maxTokens && limit > 0 ? Math.min(options.maxTokens, limit) : options?.maxTokens;\n\t\t\t\tconst reasoning = route.thinkingLevel === \"off\" ? undefined : route.thinkingLevel;\n\t\t\t\t// Caller credentials were resolved for the virtual model's provider. Another provider\n\t\t\t\t// resolves its own, so they are not sent to the wrong vendor.\n\t\t\t\tconst { apiKey, headers, env, ...rest } = options ?? {};\n\t\t\t\tconst auth = route.model.provider === model.provider ? { apiKey, headers, env } : {};\n\t\t\t\treturn this.streamSimple(route.model, context, { ...rest, ...auth, maxTokens, reasoning });\n\t\t\t});\n\t\t}\n\t\tlet tracker: RequestTracker | undefined;\n\t\treturn this.trackStream(\n\t\t\tlazyStream(model, async () => {\n\t\t\t\tassertChatModel(model);\n\t\t\t\tconst prepared = await this.prepareRequest(model, options);\n\t\t\t\ttracker = prepared.tracker;\n\t\t\t\treturn prepared.provider.streamSimple(prepared.model, transcript, prepared.options as SimpleStreamOptions);\n\t\t\t}),\n\t\t\t() => tracker,\n\t\t);\n\t}\n\n\tcompleteSimple(model: Model<Api>, context: Context, options?: ModelsSimpleStreamOptions): Promise<AssistantMessage> {\n\t\treturn this.streamSimple(model, context, options).result();\n\t}\n\n\tstreamDeferred(\n\t\tmodel: Model<Api>,\n\t\thandle: DeferredHandle,\n\t\toptions?: ModelsDeferredFetchOptions,\n\t): AssistantMessageEventStream {\n\t\tlet tracker: RequestTracker | undefined;\n\t\treturn this.trackStream(\n\t\t\tlazyStream(model, async () => {\n\t\t\t\tassertChatModel(model);\n\t\t\t\tconst prepared = await this.prepareRequest(model, options);\n\t\t\t\ttracker = prepared.tracker;\n\t\t\t\tif (!prepared.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\treturn prepared.provider.fetchDeferred(prepared.model, handle, prepared.options as DeferredFetchOptions);\n\t\t\t}),\n\t\t\t() => tracker,\n\t\t);\n\t}\n\n\tasync fetchDeferred(\n\t\tmodel: Model<Api>,\n\t\thandle: DeferredHandle,\n\t\toptions?: ModelsDeferredFetchOptions,\n\t): Promise<AssistantMessage> {\n\t\treturn this.streamDeferred(model, handle, options).result();\n\t}\n\n\tasync cancelDeferred(\n\t\tmodel: Model<Api>,\n\t\thandle: DeferredHandle,\n\t\toptions?: ModelsDeferredCancelOptions,\n\t): Promise<void> {\n\t\tassertChatModel(model);\n\t\tconst prepared = await this.prepareRequest(model, options);\n\t\tif (!prepared.provider.cancelDeferred) {\n\t\t\tthrow new ModelsError(\"provider\", `Provider ${model.provider} does not support deferred responses`);\n\t\t}\n\t\tawait prepared.provider.cancelDeferred(prepared.model, handle, prepared.options as DeferredCancelOptions);\n\t}\n\n\tasync generateImages(\n\t\tmodel: ImageModel<ImageApi>,\n\t\tcontext: ImagesContext,\n\t\toptions?: ModelsImagesOptions,\n\t): Promise<AssistantImages> {\n\t\tlet tracker: RequestTracker | undefined;\n\t\ttry {\n\t\t\tassertImageModel(model);\n\t\t\tconst prepared = await this.prepareRequest(model, options);\n\t\t\ttracker = prepared.tracker;\n\t\t\tif (!prepared.provider.generateImages) {\n\t\t\t\tthrow new ModelsError(\"provider\", `Provider ${model.provider} does not support image generation`);\n\t\t\t}\n\t\t\tconst result = await prepared.provider.generateImages(\n\t\t\t\tprepared.model,\n\t\t\t\tcontext,\n\t\t\t\tprepared.options as ImagesOptions,\n\t\t\t);\n\t\t\ttracker?.settleResult(result);\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\ttracker?.settleFailure(options?.signal?.aborted === true);\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\tlet tracker: RequestTracker | undefined;\n\t\ttry {\n\t\t\tassertClassifierModel(model);\n\t\t\tassertClassifierInputSupported(model, context);\n\t\t\tconst prepared = await this.prepareRequest(model, options);\n\t\t\ttracker = prepared.tracker;\n\t\t\tif (!prepared.provider.classify) {\n\t\t\t\tthrow new ModelsError(\"provider\", `Provider ${model.provider} does not support classification`);\n\t\t\t}\n\t\t\tconst result = await prepared.provider.classify(\n\t\t\t\tprepared.model,\n\t\t\t\tcontext,\n\t\t\t\tprepared.options as ClassifierOptions,\n\t\t\t);\n\t\t\ttracker?.settleResult(result);\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\ttracker?.settleFailure(options?.signal?.aborted === true);\n\t\t\treturn classifierErrorResult(model, error, options?.signal?.aborted);\n\t\t}\n\t}\n\n\tlogin(\n\t\tproviderId: string,\n\t\ttype: AuthType,\n\t\tinteraction: AuthInteraction,\n\t\toptions?: LoginOptions & { accountKey?: string },\n\t): Promise<Credential> {\n\t\tconst signal = operationSignal(interaction.signal);\n\t\treturn this.enqueueCredentialOperation(providerId, signal, async () => {\n\t\t\tconst provider = this.models.getProvider(providerId);\n\t\t\tif (!provider) throw new ModelsError(\"provider\", `Unknown provider: ${providerId}`);\n\t\t\tconst method = type === \"oauth\" ? provider.auth.oauth : provider.auth.apiKey;\n\t\t\tif (!method?.login) throw new ModelsError(\"auth\", `${provider.name} does not support ${type} login`);\n\t\t\tif (options?.accountKey !== undefined) {\n\t\t\t\tconst selected = (await this.oauthAccountPool.listAccounts(providerId, { signal })).find(\n\t\t\t\t\t(account) => account.key === options.accountKey,\n\t\t\t\t);\n\t\t\t\tif (!selected || selected.credential.type !== type)\n\t\t\t\t\tthrow new ModelsError(\"auth\", \"Account is no longer available for reauthentication\");\n\t\t\t}\n\t\t\tawait this.oauthAccountPool.adoptCurrentAccount(providerId, { signal });\n\t\t\tlet promptCancelled = false;\n\t\t\tlet login: Credential;\n\t\t\ttry {\n\t\t\t\tlogin = await raceWithAbortSignal<Credential>(\n\t\t\t\t\tmethod.login(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t...interaction,\n\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t\tprompt: async (prompt) => {\n\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\treturn await interaction.prompt(prompt);\n\t\t\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t\t\t// A callback winner aborts only its pending prompt, not the whole login.\n\t\t\t\t\t\t\t\t\tif (signal.aborted || !prompt.signal?.aborted) promptCancelled = true;\n\t\t\t\t\t\t\t\t\tthrow new LoginCancellationError();\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\toptions,\n\t\t\t\t\t),\n\t\t\t\t\tsignal,\n\t\t\t\t);\n\t\t\t} catch (error) {\n\t\t\t\tif (promptCancelled || signal.aborted) throw new LoginCancellationError();\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tif (promptCancelled) throw new LoginCancellationError();\n\t\t\t// Login returns credentials, not configuration expressions. Ambient-only entries stay external.\n\t\t\tconst poolable = login.type === \"oauth\" || !!login.key?.trim();\n\t\t\tif (options?.accountKey !== undefined && !poolable)\n\t\t\t\tthrow new ModelsError(\"auth\", \"Reauthentication must return a literal account credential\");\n\t\t\tconst account = poolable\n\t\t\t\t? await this.oauthAccountPool.addAccount(providerId, login, { signal, key: options?.accountKey })\n\t\t\t\t: undefined;\n\t\t\tconst credential = account?.credential ?? login;\n\t\t\tif (!account) await commitLoginCredential(this.credentials.accountStore, providerId, login, signal);\n\t\t\tawait this.synchronizeCredentialState(providerId, \"login\", signal);\n\t\t\treturn credential;\n\t\t});\n\t}\n\n\t/**\n\t * Remove the selected account, or without a key the account whose credential is stored. Removing the active\n\t * account promotes the next account of the same credential type; otherwise the credential is deleted.\n\t * Literal legacy credentials are adopted first, including OAuth credentials without identity. An unknown\n\t * explicit account key leaves stored credentials unchanged, and so does a stored credential that changed while\n\t * the account was being removed. `logoutWithStatus` reports which of these happened.\n\t */\n\tasync logout(providerId: string, options: AuthOperationOptions & { accountKey?: string } = {}): Promise<void> {\n\t\tawait this.logoutWithStatus(providerId, options);\n\t}\n\n\tprivate async deleteObservedStoredCredential(\n\t\tproviderId: string,\n\t\tobserved: Credential | undefined,\n\t\tsignal: AbortSignal,\n\t): Promise<AccountRemoveResult[\"status\"]> {\n\t\tlet status: AccountRemoveResult[\"status\"] = \"changed\";\n\t\tawait this.credentials.deleteStored(providerId, {\n\t\t\tsignal,\n\t\t\tifCurrent: (latest) => {\n\t\t\t\tif (!sameCredential(latest, observed)) return false;\n\t\t\t\tstatus = \"removed\";\n\t\t\t\treturn true;\n\t\t\t},\n\t\t});\n\t\treturn status;\n\t}\n\n\t/** Capture a non-pooled raw credential before confirmation, without exposing it to the UI. */\n\tprepareStoredCredentialRemoval(\n\t\tproviderId: string,\n\t\toptions?: AuthOperationOptions,\n\t): Promise<((options?: AuthOperationOptions) => Promise<AccountRemoveResult[\"status\"]>) | undefined> {\n\t\treturn this.protectCredentialOperation(\n\t\t\t(async () => {\n\t\t\t\tconst observed = structuredClone(await this.credentials.readStored(providerId, options));\n\t\t\t\tif (!observed || (await this.oauthAccountPool.getCurrentAccount(providerId, options))) return undefined;\n\t\t\t\treturn (removalOptions?: AuthOperationOptions) => {\n\t\t\t\t\tconst signal = operationSignal(removalOptions?.signal);\n\t\t\t\t\treturn this.enqueueCredentialOperation(providerId, signal, async () => {\n\t\t\t\t\t\tconst status = await this.deleteObservedStoredCredential(providerId, observed, signal);\n\t\t\t\t\t\tif (status === \"removed\") await this.synchronizeCredentialState(providerId, \"logout\", signal);\n\t\t\t\t\t\treturn status;\n\t\t\t\t\t});\n\t\t\t\t};\n\t\t\t})(),\n\t\t\toptions?.signal,\n\t\t\tfalse,\n\t\t);\n\t}\n\n\t/**\n\t * `logout`, resolving `removed`, `unmatched` (unknown explicit account key; nothing changed), or `changed` (the stored\n\t * credential changed concurrently; nothing removed).\n\t */\n\tlogoutWithStatus(\n\t\tproviderId: string,\n\t\toptions: AuthOperationOptions & { accountKey?: string } = {},\n\t): Promise<AccountRemoveResult[\"status\"]> {\n\t\tconst signal = operationSignal(options.signal);\n\t\treturn this.enqueueCredentialOperation(providerId, signal, async () => {\n\t\t\t// Raw stored credential (`read` resolves configured API-key values), observed before the pool's read.\n\t\t\tconst observed =\n\t\t\t\toptions.accountKey === undefined\n\t\t\t\t\t? structuredClone(await this.credentials.modify(providerId, async () => undefined, { signal }))\n\t\t\t\t\t: undefined;\n\t\t\t// A stored-only removal never goes through the pool: another session may select an account after\n\t\t\t// this observation, and adopting/removing that replacement would silently retarget the logout.\n\t\t\tif (\n\t\t\t\tthis.credentials.isExternalCredential(observed) ||\n\t\t\t\t(observed?.type === \"api_key\" && !observed.key?.trim()) ||\n\t\t\t\t(providerId === \"openai-codex\" &&\n\t\t\t\t\tobserved?.type === \"oauth\" &&\n\t\t\t\t\t!this.oauthAccountPool.getAccountIdentity(providerId, observed))\n\t\t\t) {\n\t\t\t\tconst status = await this.deleteObservedStoredCredential(providerId, observed, signal);\n\t\t\t\tif (status === \"removed\") await this.synchronizeCredentialState(providerId, \"logout\", signal);\n\t\t\t\treturn status;\n\t\t\t}\n\t\t\tconst stored =\n\t\t\t\toptions.accountKey === undefined ? observed : await this.credentials.readStored(providerId, { signal });\n\t\t\t// Keep Codex's fail-closed handling of legacy unstamped credentials with no identifiable account.\n\t\t\t// Generalized login always stamps even opaque Codex credentials, so they use the account API normally.\n\t\t\tconst legacyUnmatchedCodex =\n\t\t\t\tproviderId === \"openai-codex\" &&\n\t\t\t\tstored?.type === \"oauth\" &&\n\t\t\t\t!this.oauthAccountPool.getAccountIdentity(providerId, stored);\n\t\t\t// A generalized list can give an unstamped legacy credential a temporary local key.\n\t\t\tconst selectedLegacyCurrent =\n\t\t\t\tlegacyUnmatchedCodex &&\n\t\t\t\toptions.accountKey?.startsWith(\"account-\") &&\n\t\t\t\t(await this.oauthAccountPool.getCurrentAccount(providerId, { signal }))?.key === options.accountKey;\n\t\t\t// Removal already reconciles legacy credentials under the pool lock; separate adoption can retarget logout.\n\t\t\tconst removal =\n\t\t\t\tlegacyUnmatchedCodex && !selectedLegacyCurrent\n\t\t\t\t\t? await this.oauthAccountPool.remove(providerId, options.accountKey, { signal })\n\t\t\t\t\t: await this.oauthAccountPool.removeAccount(providerId, options.accountKey, {\n\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t\tifCurrent:\n\t\t\t\t\t\t\t\toptions.accountKey === undefined ? (latest) => sameCredential(latest, observed) : undefined,\n\t\t\t\t\t\t});\n\t\t\tlet status = removal.status;\n\t\t\tif (status === \"unmatched\") {\n\t\t\t\tif (options.accountKey !== undefined) return status;\n\t\t\t\t// Unlike Models.logout, delete only the observed credential, never one written since.\n\t\t\t\tstatus = await this.deleteObservedStoredCredential(providerId, observed, signal);\n\t\t\t}\n\t\t\tif (status === \"removed\") await this.synchronizeCredentialState(providerId, \"logout\", signal);\n\t\t\treturn status;\n\t\t});\n\t}\n\n\t/**\n\t * Provider and virtual-model registration changes each queue an un-awaited\n\t * offline refresh after recomposing a provider, unless batched without refresh\n\t * (e.g. the always-loaded llama.cpp builtin extension registers itself\n\t * on every startup). Left unbounded, that background refresh can still be\n\t * running when a caller later does an explicit `await refresh(...)` (startup's\n\t * HUMAIN Node discovery, or the provider-registration refresh in\n\t * createAgentSessionServices) and can finish after it, recomposing every\n\t * provider back to its static definition and clobbering the just-discovered\n\t * dynamic model list or the auth snapshot `hasConfiguredAuth()` reads.\n\t *\n\t * Every non-registration refresh() call waits for these to settle before doing\n\t * its own snapshot work, so it always lands last. Registration-triggered\n\t * refreshes never wait on this set (or on each other via it), so they can't\n\t * deadlock on one another, and unrelated explicit refreshes (e.g. two\n\t * provider-scoped catalog refreshes) remain fully concurrent with each other,\n\t * exactly as before.\n\t */\n\tprivate readonly pendingRegistrationRefreshes = new Set<Promise<void>>();\n\tprivate registeringWithoutRefresh = false;\n\n\t/** Runs synchronous registrations without background refreshes; the caller must refresh afterward. */\n\tregisterWithoutRefresh(register: () => void): void {\n\t\tconst previous = this.registeringWithoutRefresh;\n\t\tthis.registeringWithoutRefresh = true;\n\t\ttry {\n\t\t\tregister();\n\t\t} finally {\n\t\t\tthis.registeringWithoutRefresh = previous;\n\t\t}\n\t}\n\n\tprivate queueRegistrationRefresh(): void {\n\t\tif (this.registeringWithoutRefresh) return;\n\t\tconst p = this.refreshInternal({ allowNetwork: false }, { fromRegistration: true }).then(\n\t\t\t() => {},\n\t\t\t() => {},\n\t\t);\n\t\tthis.pendingRegistrationRefreshes.add(p);\n\t\tvoid p.finally(() => this.pendingRegistrationRefreshes.delete(p));\n\t}\n\n\trefresh(options: ModelsRefreshOptions = {}): Promise<ModelsRefreshResult> {\n\t\treturn this.refreshInternal(options, { fromRegistration: false });\n\t}\n\n\tprivate async refreshInternal(\n\t\toptions: ModelsRefreshOptions,\n\t\t{ fromRegistration }: { fromRegistration: boolean },\n\t): Promise<ModelsRefreshResult> {\n\t\tif (!fromRegistration && this.pendingRegistrationRefreshes.size > 0) {\n\t\t\tawait Promise.allSettled([...this.pendingRegistrationRefreshes]);\n\t\t}\n\t\tthis.config = await ModelConfig.load(this.modelsPath);\n\t\tthis.configureRadiusProviders();\n\t\tif (options.providers) {\n\t\t\tfor (const providerId of new Set(options.providers)) this.recomposeProvider(providerId);\n\t\t\tthis.updateModelSnapshot();\n\t\t} else {\n\t\t\tthis.rebuildProviders();\n\t\t}\n\t\tconst refreshOptions = {\n\t\t\t...options,\n\t\t\tallowNetwork: options.allowNetwork ?? this.modelNetworkEnabled,\n\t\t};\n\t\t// Published pi-ai builds before ModelsStore returned void and accepted a provider ID.\n\t\t// The fallback keeps source-mode CLI tests working without rebuilding workspace dependencies.\n\t\tconst result = ((await this.models.refresh(refreshOptions)) as ModelsRefreshResult | undefined) ?? {\n\t\t\taborted: refreshOptions.signal?.aborted ?? false,\n\t\t\terrors: new Map(),\n\t\t};\n\t\tconst errors = new Map(result.errors);\n\t\tthis.updateModelSnapshot();\n\t\tif (options.providers) {\n\t\t\tawait Promise.all(\n\t\t\t\t[...new Set(options.providers)].map(async (providerId) => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait this.refreshProviderAvailability(providerId, operationSignal(options.signal));\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tif (!options.signal?.aborted) {\n\t\t\t\t\t\t\terrors.set(providerId, error instanceof Error ? error : new Error(String(error)));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t);\n\t\t} else {\n\t\t\ttry {\n\t\t\t\tawait this.queueAvailabilityRefresh(options.signal);\n\t\t\t} catch {\n\t\t\t\t// Availability errors are recorded by the latest pass; refreshed models remain usable.\n\t\t\t}\n\t\t}\n\t\treturn { aborted: result.aborted || (options.signal?.aborted ?? false), errors };\n\t}\n\n\tregisterNativeProvider(provider: Provider): void {\n\t\tif (!provider.id.trim()) throw new Error(\"Provider id must not be empty.\");\n\t\tthis.extensionProviders.delete(provider.id);\n\t\tthis.nativeExtensionProviders.set(provider.id, provider);\n\t\tthis.recomposeProvider(provider.id);\n\t\tthis.updateModelSnapshot();\n\t\tthis.markProvisionallyConfigured(\n\t\t\tprovider.id,\n\t\t\tconfiguredRequestAuthStatus(this.config.getProvider(provider.id), undefined),\n\t\t\tprovider.auth.oauth && !provider.auth.apiKey ? \"oauth\" : \"api_key\",\n\t\t);\n\t\tthis.queueRegistrationRefresh();\n\t}\n\n\t/**\n\t * Mark a newly registered provider as configured when it has a stored credential or a configured\n\t * API key. Availability checks run asynchronously, and callers such as initial model selection\n\t * read the snapshot before they finish. The next availability pass replaces this entry.\n\t */\n\tprivate markProvisionallyConfigured(\n\t\tproviderId: string,\n\t\tconfiguredStatus: AuthStatus | undefined,\n\t\ttype: AuthType,\n\t): void {\n\t\tif (!this.snapshot.storedProviders.has(providerId) && !configuredStatus?.configured) return;\n\t\tconst configuredProviders = new Set(this.snapshot.configuredProviders).add(providerId);\n\t\tconst auth = new Map(this.snapshot.auth);\n\t\t// Never clobber a real check result.\n\t\tif (!auth.get(providerId)) auth.set(providerId, { type, source: \"configured provider\" });\n\t\tthis.snapshot = {\n\t\t\t...this.snapshot,\n\t\t\tauth,\n\t\t\tconfiguredProviders,\n\t\t\tavailable: this.snapshot.all.ofProviders(configuredProviders),\n\t\t};\n\t}\n\n\tregisterProvider(providerId: string, config: ProviderConfigInput): void {\n\t\t// Validate the incoming registration on its own, like the legacy registry:\n\t\t// a broken re-registration must throw without touching the stored config.\n\t\tvalidateExtensionProvider(providerId, this.builtins.get(providerId), this.config.getProvider(providerId), config);\n\t\tthis.nativeExtensionProviders.delete(providerId);\n\t\t// Re-registration merges defined values over the previous registration and\n\t\t// preserves undefined ones, matching the legacy ModelRegistry contract.\n\t\tconst previous = this.extensionProviders.get(providerId);\n\t\tconst effective: ProviderConfigInput = { ...previous };\n\t\tfor (const [key, value] of Object.entries(config)) {\n\t\t\tif (value !== undefined) (effective as Record<string, unknown>)[key] = value;\n\t\t}\n\t\tthis.extensionProviders.set(providerId, effective);\n\t\tthis.recomposeProvider(providerId);\n\t\tthis.updateModelSnapshot();\n\t\tthis.markProvisionallyConfigured(\n\t\t\tproviderId,\n\t\t\tconfiguredRequestAuthStatus(this.config.getProvider(providerId), effective),\n\t\t\teffective.oauth && !effective.apiKey ? \"oauth\" : \"api_key\",\n\t\t);\n\t\tthis.queueRegistrationRefresh();\n\t}\n\n\tunregisterProvider(providerId: string): void {\n\t\tthis.extensionProviders.delete(providerId);\n\t\tthis.nativeExtensionProviders.delete(providerId);\n\t\tthis.recomposeProvider(providerId);\n\t\tthis.updateModelSnapshot();\n\t\tthis.queueRegistrationRefresh();\n\t}\n\n\t/**\n\t * Register a virtual model under `definition.provider`, which may also list physical models or\n\t * several virtual models. Re-registering the same provider and id replaces the virtual model.\n\t * Throws when the id belongs to a physical model of that provider.\n\t */\n\tregisterVirtualModel(definition: VirtualModelDefinition): void {\n\t\tconst { provider: providerId, id } = definition;\n\t\tif (!providerId.trim() || !id.trim()) throw new Error(\"Virtual model provider and id must not be empty.\");\n\t\tconst existing = this.models.getModel(providerId, id);\n\t\tif (existing && !isVirtualModel(existing)) {\n\t\t\tthrow new Error(`Virtual model ${providerId}/${id} conflicts with a physical model.`);\n\t\t}\n\t\tconst models = this.virtualModels.get(providerId) ?? new Map<string, RegisteredVirtualModel>();\n\t\tmodels.set(id, { model: createVirtualModel(definition), route: (request) => definition.route(request) });\n\t\tthis.virtualModels.set(providerId, models);\n\t\tif (!this.recomposeProvider(providerId) && !this.snapshot.configuredProviders.has(providerId)) {\n\t\t\t// A provider of only virtual models needs no credentials. Mark it configured now: session\n\t\t\t// restore checks auth before the refresh below lands.\n\t\t\tconst auth = new Map(this.snapshot.auth).set(providerId, { type: \"api_key\", source: \"virtual\" });\n\t\t\tconst configuredProviders = new Set(this.snapshot.configuredProviders).add(providerId);\n\t\t\tthis.snapshot = { ...this.snapshot, auth, configuredProviders };\n\t\t}\n\t\tthis.updateModelSnapshot();\n\t\tthis.queueRegistrationRefresh();\n\t}\n\n\tunregisterVirtualModel(providerId: string, id: string): void {\n\t\tconst models = this.virtualModels.get(providerId);\n\t\tif (!models?.delete(id)) return;\n\t\tif (models.size === 0) this.virtualModels.delete(providerId);\n\t\tthis.recomposeProvider(providerId);\n\t\tthis.updateModelSnapshot();\n\t\tthis.queueRegistrationRefresh();\n\t}\n\n\t/**\n\t * Ask a virtual model's router for the model and thinking level of one request. The router must\n\t * return a physical catalog model whose provider has credentials; the thinking level is clamped\n\t * to that model. Throws when routing fails.\n\t *\n\t * `previous` reports the latest successful response in `messages`. A retry passes the failed\n\t * response as `options.failed`; `messages` no longer contains it. `options.state` is the router\n\t * state stored by the caller, which also stores the returned state.\n\t */\n\tasync resolveModel(\n\t\tmodel: Model<Api>,\n\t\tmessages: readonly Message[],\n\t\toptions: {\n\t\t\treason: ModelRouteReason;\n\t\t\tthinkingLevel: ModelThinkingLevel;\n\t\t\tsignal?: AbortSignal;\n\t\t\tfailed?: AssistantMessage;\n\t\t\tstate?: unknown;\n\t\t},\n\t): Promise<ModelRoute> {\n\t\tconst name = `Virtual model ${model.provider}/${model.id}`;\n\t\tconst virtual = this.virtualModels.get(model.provider)?.get(model.id);\n\t\tif (!virtual) throw new Error(`${name} is not registered.`);\n\t\tconst { failed, ...request } = options;\n\t\tconst latest = findLatestResponse(messages);\n\t\tconst previousModel = latest && this.getPhysicalModel(latest.provider, latest.model);\n\t\t// A failed routing attempt names the virtual model; there is no physical request to report.\n\t\tconst failedModel = failed && this.getPhysicalModel(failed.provider, failed.model);\n\t\tconst route = await virtual.route({\n\t\t\t...request,\n\t\t\tmodel,\n\t\t\tprevious: previousModel && { model: previousModel, thinkingLevel: latest?.thinkingLevel },\n\t\t\tfailed: failedModel && failed && { model: failedModel, thinkingLevel: failed.thinkingLevel, message: failed },\n\t\t\tmessages,\n\t\t});\n\t\tconst target = this.getPhysicalModel(route.model.provider, route.model.id);\n\t\tconst routed = `${name} routed to ${route.model.provider}/${route.model.id}`;\n\t\tif (!target) throw new Error(`${routed}, which is not a physical model.`);\n\t\tif (!this.hasConfiguredAuth(target.provider)) throw new Error(`${routed}, which has no credentials.`);\n\t\treturn { model: target, thinkingLevel: clampThinkingLevel(target, route.thinkingLevel), state: route.state };\n\t}\n\n\t/** A catalog chat model that is not virtual. */\n\tgetPhysicalModel(providerId: string, modelId: string): Model<Api> | undefined {\n\t\tconst model = this.models.getModel(providerId, modelId);\n\t\treturn model && !isVirtualModel(model) ? model : undefined;\n\t}\n}\n"]}