@bastani/atomic 0.9.16-alpha.7 → 0.9.16-alpha.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/dist/builtin/intercom/CHANGELOG.md +6 -0
- package/dist/builtin/intercom/README.md +4 -4
- package/dist/builtin/intercom/broker/broker.ts +617 -22
- package/dist/builtin/intercom/broker/client-message-validation.ts +9 -0
- package/dist/builtin/intercom/broker/client.ts +200 -10
- package/dist/builtin/intercom/broker/pending-send-registry.ts +4 -0
- package/dist/builtin/intercom/broker/send-handler.ts +90 -36
- package/dist/builtin/intercom/broker/send-signature.ts +20 -8
- package/dist/builtin/intercom/group.ts +85 -0
- package/dist/builtin/intercom/index.bundle.mjs +680 -53
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/intercom/session-target.ts +54 -0
- package/dist/builtin/intercom/skills/intercom/SKILL.md +18 -3
- package/dist/builtin/intercom/source-ownership.ts +31 -0
- package/dist/builtin/intercom/types.ts +115 -0
- package/dist/builtin/mcp/index.bundle.mjs +109 -35
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +173 -51
- package/dist/builtin/web-access/index.bundle.mjs +109 -35
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/builtin/workflows/CHANGELOG.md +15 -0
- package/dist/builtin/workflows/README.md +40 -37
- package/dist/builtin/workflows/builtin/adversarial-verification.js +13 -0
- package/dist/builtin/workflows/builtin/{shared-prompts.ts → chunk-0x6e303p.js} +133 -154
- package/dist/builtin/workflows/builtin/chunk-29wrp38a.js +199 -0
- package/dist/builtin/workflows/builtin/chunk-2dqb5s2q.js +602 -0
- package/dist/builtin/workflows/builtin/chunk-4febxsv4.js +264 -0
- package/dist/builtin/workflows/builtin/chunk-5n10x7j2.js +69730 -0
- package/dist/builtin/workflows/builtin/chunk-5wgwscd0.js +4 -0
- package/dist/builtin/workflows/builtin/chunk-6fqs7c01.js +155 -0
- package/dist/builtin/workflows/builtin/chunk-7430zyas.js +126 -0
- package/dist/builtin/workflows/builtin/chunk-7at6dnkr.js +33 -0
- package/dist/builtin/workflows/builtin/chunk-82ha8p41.js +175 -0
- package/dist/builtin/workflows/builtin/chunk-bfkmzv9h.js +156 -0
- package/dist/builtin/workflows/builtin/chunk-c53y8bdh.js +345 -0
- package/dist/builtin/workflows/builtin/chunk-cdtd3m3w.js +529 -0
- package/dist/builtin/workflows/builtin/chunk-cg9tmks0.js +206 -0
- package/dist/builtin/workflows/builtin/chunk-hdpj1dkw.js +2447 -0
- package/dist/builtin/workflows/builtin/chunk-hzzn6adg.js +221 -0
- package/dist/builtin/workflows/builtin/chunk-nqr34qp3.js +1061 -0
- package/dist/builtin/workflows/builtin/chunk-qwzvgxnq.js +404 -0
- package/dist/builtin/workflows/builtin/chunk-qx2ptjs3.js +215 -0
- package/dist/builtin/workflows/builtin/chunk-v04c5qmd.js +1207 -0
- package/dist/builtin/workflows/builtin/chunk-wpckd35c.js +12 -0
- package/dist/builtin/workflows/builtin/chunk-x2ghn0je.js +4110 -0
- package/dist/builtin/workflows/builtin/chunk-zf28603f.js +1080 -0
- package/dist/builtin/workflows/builtin/classify-and-act.js +12 -0
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize.js +10 -0
- package/dist/builtin/workflows/builtin/generate-and-filter.js +12 -0
- package/dist/builtin/workflows/builtin/goal.js +16 -0
- package/dist/builtin/workflows/builtin/index.js +49 -0
- package/dist/builtin/workflows/builtin/loop-until-done.js +12 -0
- package/dist/builtin/workflows/builtin/open-claude-design.js +11 -0
- package/dist/builtin/workflows/builtin/ralph.js +16 -0
- package/dist/builtin/workflows/builtin/steering-context.d.ts +6 -0
- package/dist/builtin/workflows/builtin/steering-context.js +7 -0
- package/dist/builtin/workflows/builtin/tournament.js +13 -0
- package/dist/builtin/workflows/package.json +10 -7
- package/dist/builtin/workflows/src/authoring/typebox-defaults.d.ts +41 -0
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +1228 -428
- package/dist/builtin/workflows/src/{index.bundle.mjs → index.js} +956 -427
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +403 -0
- package/dist/builtin/workflows/src/shared/authoring-contract-ui.d.ts +327 -0
- package/dist/builtin/workflows/src/shared/budget.d.ts +67 -0
- package/dist/builtin/workflows/src/shared/workflow-authoring-types.d.ts +60 -0
- package/dist/builtin/workflows/src/shared/workflow-heartbeat-contract.d.ts +21 -0
- package/dist/core/agent-session-custom-message-commit.d.ts.map +1 -1
- package/dist/core/agent-session-custom-message-commit.js +12 -5
- package/dist/core/agent-session-custom-message-commit.js.map +1 -1
- package/dist/core/agent-session-persistent-custom-messages.d.ts.map +1 -1
- package/dist/core/agent-session-persistent-custom-messages.js +2 -0
- package/dist/core/agent-session-persistent-custom-messages.js.map +1 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +2 -1
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts +2 -0
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +4 -0
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/builtin-install-layout.d.ts +1 -1
- package/dist/core/builtin-install-layout.d.ts.map +1 -1
- package/dist/core/builtin-install-layout.js +1 -1
- package/dist/core/builtin-install-layout.js.map +1 -1
- package/dist/core/codex-fast-mode.d.ts +10 -7
- package/dist/core/codex-fast-mode.d.ts.map +1 -1
- package/dist/core/codex-fast-mode.js +31 -13
- package/dist/core/codex-fast-mode.js.map +1 -1
- package/dist/core/extensions/context-types.d.ts +35 -0
- package/dist/core/extensions/context-types.d.ts.map +1 -1
- package/dist/core/extensions/context-types.js.map +1 -1
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.js +6 -1
- package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
- package/dist/core/model-runtime.d.ts +2 -0
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +4 -0
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/runtime-credentials.d.ts +1 -0
- package/dist/core/runtime-credentials.d.ts.map +1 -1
- package/dist/core/runtime-credentials.js +8 -0
- package/dist/core/runtime-credentials.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +5 -5
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager-storage.d.ts +2 -0
- package/dist/core/session-manager-storage.d.ts.map +1 -1
- package/dist/core/session-manager-storage.js +4 -2
- package/dist/core/session-manager-storage.js.map +1 -1
- package/dist/core/slash-commands.js +1 -1
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/workflow-stage-admission.d.ts +6 -1
- package/dist/core/workflow-stage-admission.d.ts.map +1 -1
- package/dist/core/workflow-stage-admission.js +8 -9
- package/dist/core/workflow-stage-admission.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +1 -1
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/interactive-autocomplete.js +1 -1
- package/dist/modes/interactive/interactive-autocomplete.js.map +1 -1
- package/dist/modes/interactive/interactive-startup.js +1 -1
- package/dist/modes/interactive/interactive-startup.js.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.d.ts +4 -0
- package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.js +69 -10
- package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
- package/dist/modes/rpc/rpc-client-api.d.ts +18 -2
- package/dist/modes/rpc/rpc-client-api.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client-api.js +33 -5
- package/dist/modes/rpc/rpc-client-api.js.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.js +8 -4
- package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +13 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/docs/intercom.md +15 -6
- package/docs/packages.md +2 -2
- package/docs/providers.md +8 -3
- package/docs/quickstart.md +2 -2
- package/docs/rpc.md +21 -4
- package/docs/settings.md +6 -4
- package/docs/subagents.md +1 -1
- package/docs/usage.md +1 -1
- package/docs/workflows.md +108 -239
- package/npm-shrinkwrap.json +32 -32
- package/package.json +9 -13
- package/dist/builtin/workflows/ambient.d.ts +0 -61
- package/dist/builtin/workflows/builtin/adversarial-verification-prompts.ts +0 -26
- package/dist/builtin/workflows/builtin/adversarial-verification-runner.ts +0 -391
- package/dist/builtin/workflows/builtin/adversarial-verification.ts +0 -34
- package/dist/builtin/workflows/builtin/classify-and-act-prompts.ts +0 -14
- package/dist/builtin/workflows/builtin/classify-and-act-runner.ts +0 -108
- package/dist/builtin/workflows/builtin/classify-and-act.ts +0 -40
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize-prompts.ts +0 -14
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize-runner.ts +0 -96
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize.ts +0 -37
- package/dist/builtin/workflows/builtin/generate-and-filter-prompts.ts +0 -41
- package/dist/builtin/workflows/builtin/generate-and-filter-runner.ts +0 -90
- package/dist/builtin/workflows/builtin/generate-and-filter.ts +0 -31
- package/dist/builtin/workflows/builtin/goal-artifacts.ts +0 -64
- package/dist/builtin/workflows/builtin/goal-convergence.ts +0 -87
- package/dist/builtin/workflows/builtin/goal-ledger.ts +0 -139
- package/dist/builtin/workflows/builtin/goal-models.ts +0 -72
- package/dist/builtin/workflows/builtin/goal-orchestrator-prompts.ts +0 -94
- package/dist/builtin/workflows/builtin/goal-prompts.ts +0 -217
- package/dist/builtin/workflows/builtin/goal-reducer.ts +0 -176
- package/dist/builtin/workflows/builtin/goal-reports.ts +0 -76
- package/dist/builtin/workflows/builtin/goal-reverify.ts +0 -305
- package/dist/builtin/workflows/builtin/goal-review.ts +0 -139
- package/dist/builtin/workflows/builtin/goal-runner.ts +0 -504
- package/dist/builtin/workflows/builtin/goal-schemas.ts +0 -89
- package/dist/builtin/workflows/builtin/goal-types.ts +0 -164
- package/dist/builtin/workflows/builtin/goal.ts +0 -78
- package/dist/builtin/workflows/builtin/index.ts +0 -16
- package/dist/builtin/workflows/builtin/loop-until-done-prompts.ts +0 -87
- package/dist/builtin/workflows/builtin/loop-until-done-runner.ts +0 -282
- package/dist/builtin/workflows/builtin/loop-until-done.ts +0 -51
- package/dist/builtin/workflows/builtin/open-claude-design-live-protocol.ts +0 -305
- package/dist/builtin/workflows/builtin/open-claude-design-phases.ts +0 -337
- package/dist/builtin/workflows/builtin/open-claude-design-runner.ts +0 -347
- package/dist/builtin/workflows/builtin/open-claude-design-setup.ts +0 -313
- package/dist/builtin/workflows/builtin/open-claude-design-utils.ts +0 -311
- package/dist/builtin/workflows/builtin/open-claude-design.ts +0 -57
- package/dist/builtin/workflows/builtin/pattern-artifact-root.ts +0 -28
- package/dist/builtin/workflows/builtin/progress-scoring.ts +0 -230
- package/dist/builtin/workflows/builtin/ralph-core.ts +0 -449
- package/dist/builtin/workflows/builtin/ralph-forked-prompts.ts +0 -100
- package/dist/builtin/workflows/builtin/ralph-models.ts +0 -183
- package/dist/builtin/workflows/builtin/ralph-review-gate.ts +0 -103
- package/dist/builtin/workflows/builtin/ralph-reviewer-prompt.ts +0 -104
- package/dist/builtin/workflows/builtin/ralph-runner.ts +0 -459
- package/dist/builtin/workflows/builtin/ralph.ts +0 -82
- package/dist/builtin/workflows/builtin/review-convergence.ts +0 -229
- package/dist/builtin/workflows/builtin/selection-math.ts +0 -156
- package/dist/builtin/workflows/builtin/steering-context.ts +0 -51
- package/dist/builtin/workflows/builtin/tournament-prompts.ts +0 -70
- package/dist/builtin/workflows/builtin/tournament-runner.ts +0 -400
- package/dist/builtin/workflows/builtin/tournament.ts +0 -73
- package/dist/builtin/workflows/builtin/verification-criteria.ts +0 -330
- package/dist/builtin/workflows/builtin/verification-prompts.ts +0 -206
- package/dist/builtin/workflows/builtin/verification-usage.ts +0 -44
|
@@ -62,6 +62,8 @@ export declare class ModelRuntime implements Models {
|
|
|
62
62
|
getCompatibilityRequestConfig(model: Model<Api>): CompatibilityRequestConfig;
|
|
63
63
|
isUsingOAuth(providerId: string): boolean;
|
|
64
64
|
hasConfiguredAuth(providerId: string): boolean;
|
|
65
|
+
/** Return stored credential metadata synchronously without refreshing auth. */
|
|
66
|
+
getCredentialSnapshot(providerId: string): Credential | undefined;
|
|
65
67
|
getAuth(providerId: string, overrides?: ModelRuntimeAuthOverrides): Promise<AuthResult | undefined>;
|
|
66
68
|
getAuth(model: Model<Api>, overrides?: ModelRuntimeAuthOverrides): Promise<AuthResult | undefined>;
|
|
67
69
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-runtime.d.ts","sourceRoot":"","sources":["../../src/core/model-runtime.ts"],"names":[],"mappings":"AAGA,OAAO,EACN,KAAK,GAAG,EACR,KAAK,gBAAgB,EACrB,KAAK,2BAA2B,EAChC,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,UAAU,EACf,KAAK,QAAQ,EACb,KAAK,OAAO,EACZ,KAAK,UAAU,EACf,KAAK,cAAc,EAEnB,KAAK,cAAc,EACnB,KAAK,KAAK,EACV,KAAK,MAAM,EACX,KAAK,sBAAsB,EAC3B,KAAK,2BAA2B,EAChC,KAAK,0BAA0B,EAC/B,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,yBAAyB,EAG9B,KAAK,QAAQ,EACb,MAAM,gBAAgB,CAAC;AAuBxB,OAAO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AO,GAAE,oBAAyB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAE9E;IAED;;;;;;;OAOG;IACH,OAAO,CAAC,2BAA2B;YAMrB,UAAU;IAwCxB,sBAAsB,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAO/C;IAED,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,mBAAmB,GAAG,IAAI,CA2CtE;IAED,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAM3C;CACD"}
|
|
@@ -306,6 +306,10 @@ export class ModelRuntime {
|
|
|
306
306
|
hasConfiguredAuth(providerId) {
|
|
307
307
|
return this.snapshot.configuredProviders.has(providerId);
|
|
308
308
|
}
|
|
309
|
+
/** Return stored credential metadata synchronously without refreshing auth. */
|
|
310
|
+
getCredentialSnapshot(providerId) {
|
|
311
|
+
return this.credentials.peek(providerId);
|
|
312
|
+
}
|
|
309
313
|
async getAuth(providerOrModel, overrides = {}) {
|
|
310
314
|
if (typeof providerOrModel === "string")
|
|
311
315
|
return this.models.getAuth(providerOrModel, overrides);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-runtime.js","sourceRoot":"","sources":["../../src/core/model-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAYN,YAAY,GAaZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,sBAAsB,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,WAAW,IAAI,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,EAAE,CAAC;gBACxD,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC;gBAC3D,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CACnC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,KAAK,UAAU,IAAI,SAAS,CAAC,GAAG,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAClF,CAAC;YACH,CAAC;YACD,IAAI,CAAC,QAAQ,GAAG,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE,mBAAmB,EAAE,SAAS,EAAE,CAAC;QAC5E,CAAC;QACD,IAAI,CAAC,2BAA2B,EAAE,CAAC;IACpC,CAAC;IAED,kBAAkB,CAAC,UAAkB;QACpC,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QAC3C,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QACjD,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;QACnC,IAAI,CAAC,mBAAmB,EAAE,CAAC;QAC3B,IAAI,CAAC,2BAA2B,EAAE,CAAC;IACpC,CAAC;CACD","sourcesContent":["import { createHash } from \"node:crypto\";\nimport { readFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport {\n\ttype Api,\n\ttype AssistantMessage,\n\ttype AssistantMessageEventStream,\n\ttype AuthCheck,\n\ttype AuthInteraction,\n\ttype AuthOperationOptions,\n\ttype AuthResult,\n\ttype AuthType,\n\ttype Context,\n\ttype Credential,\n\ttype CredentialInfo,\n\tcreateModels,\n\ttype DeferredHandle,\n\ttype Model,\n\ttype Models,\n\ttype ModelsApiStreamOptions,\n\ttype ModelsDeferredCancelOptions,\n\ttype ModelsDeferredFetchOptions,\n\ttype ModelsRefreshOptions,\n\ttype ModelsRefreshResult,\n\ttype ModelsSimpleStreamOptions,\n\ttype ModelsStore,\n\ttype MutableModels,\n\ttype Provider,\n} from \"@bastani/pi-ai\";\nimport * as builtinProviderCatalog from \"@bastani/pi-ai/providers/all\";\nimport { getAgentDir } from \"../config.ts\";\nimport { operationSignal, raceWithAbortSignal } from \"../utils/abort.js\";\nimport { normalizePath } from \"../utils/paths.ts\";\nimport { AuthStorage as DefaultAuthStorage } from \"./auth-storage.ts\";\nimport { ModelConfig } from \"./model-config.ts\";\nimport { POST_LOGOUT_AUTH_CHECK_TIMEOUT_MS } from \"./model-refresh-timeout.ts\";\nimport {\n\taddRuntimeApiKeyProvider,\n\taddStoredCredentialProvider,\n\tcreateEmptyModelRuntimeSnapshot,\n\tcreateModelRuntimeSnapshot,\n\tgetSnapshotProviderAuthStatus,\n\ttype ModelRuntimeSnapshot,\n\tremoveStoredCredentialProvider,\n\treplaceStoredCredentialProviders,\n\tsnapshotModelKey,\n\tupdateSnapshotModels,\n} from \"./model-runtime-snapshot.ts\";\nimport { FileModelsStore, InMemoryCodingAgentModelsStore } from \"./models-store.ts\";\nimport { collectOAuthProviderMetadata } from \"./oauth-provider-metadata.ts\";\nimport { isOfflineModeEnabled } from \"./package-manager-env.ts\";\nimport {\n\ttype AuthStatus,\n\ttype CompatibilityRequestConfig,\n\tcomposeModelProvider,\n\tconfiguredRequestAuthStatus,\n\ttype ProviderConfigInput,\n\tresolveCompatibilityRequestConfig,\n\tvalidateExtensionProvider,\n} from \"./provider-composer.ts\";\nimport { withRemoteCatalog } from \"./remote-catalog-provider.ts\";\nimport { RuntimeCredentials } from \"./runtime-credentials.ts\";\n\nexport type { CreateModelRuntimeOptions, ModelRuntimeAuthOverrides } from \"./model-runtime-types.ts\";\n\nimport { mergeConfiguredAuthHeaders } from \"./model-runtime-auth.ts\";\nimport { configureBuiltinProviders } from \"./model-runtime-providers.ts\";\nimport { canRestoreUnknownModel as canRestoreUnknownModelProvider } from \"./model-runtime-restoration.ts\";\nimport { ModelRuntimeStreaming } from \"./model-runtime-streaming.ts\";\nimport type { CreateModelRuntimeOptions, ModelRuntimeAuthOverrides } from \"./model-runtime-types.ts\";\n\nexport type CredentialSynchronizationOperation =\n\t| \"login\"\n\t| \"logout\"\n\t| \"saveCredential\"\n\t| \"setRuntimeApiKey\"\n\t| \"removeRuntimeApiKey\";\n\n/** Credentials changed successfully, but local model state could not be synchronized. */\nexport class CredentialSynchronizationError extends Error {\n\treadonly providerId: string;\n\treadonly operation: CredentialSynchronizationOperation;\n\treadonly credential: Credential | undefined;\n\n\tconstructor(\n\t\tproviderId: string,\n\t\toperation: CredentialSynchronizationOperation,\n\t\tcredential: Credential | undefined,\n\t\toptions: ErrorOptions,\n\t) {\n\t\tsuper(`Credential ${operation} committed for ${providerId}, but local synchronization failed`, options);\n\t\tthis.name = \"CredentialSynchronizationError\";\n\t\tthis.providerId = providerId;\n\t\tthis.operation = operation;\n\t\t// One call rather than assign-then-redefine: the two-step form is\n\t\t// equivalent (defineProperty with only `enumerable` preserves the existing\n\t\t// value) but reads as a redundant write and trips static analysis. The\n\t\t// non-enumerable descriptor is the load-bearing part — it keeps the\n\t\t// credential out of JSON.stringify, console.log, and structured error\n\t\t// reporting.\n\t\tObject.defineProperty(this, \"credential\", {\n\t\t\tvalue: credential,\n\t\t\tenumerable: false,\n\t\t\twritable: true,\n\t\t\tconfigurable: true,\n\t\t});\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 streaming: ModelRuntimeStreaming;\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\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 = createEmptyModelRuntimeSnapshot();\n\tprivate snapshotGeneration = 0;\n\tprivate catalogInputsGeneration = 0;\n\tprivate observedModelsFileToken: string | undefined;\n\tprivate readonly externalProviderAuthStatuses = new Map<string, AuthStatus>();\n\tprivate availabilityRefreshSeq = 0;\n\tprivate availabilityErrorSeq = 0;\n\tprivate readonly providerAvailabilitySeq = new Map<string, number>();\n\tprivate readonly credentialOperations = new Map<string, Promise<unknown>>();\n\tprivate availabilityError: string | undefined;\n\tprivate refreshSequence = 0;\n\tprivate constructor(\n\t\tcredentials: RuntimeCredentials,\n\t\tconfig: ModelConfig,\n\t\tmodelsPath: string | undefined,\n\t\tmodelsStore: ModelsStore,\n\t\tproviders: readonly Provider[],\n\t\tmodelNetworkEnabled: boolean,\n\t) {\n\t\tthis.credentials = credentials;\n\t\tthis.config = config;\n\t\tthis.modelsPath = modelsPath;\n\t\tthis.modelNetworkEnabled = modelNetworkEnabled;\n\t\tthis.defaultBuiltins = new Map(providers.map((provider) => [provider.id, provider]));\n\t\tfor (const [providerId, provider] of this.defaultBuiltins) this.builtins.set(providerId, provider);\n\t\tthis.models = createModels({ credentials, modelsStore });\n\t\tthis.streaming = new ModelRuntimeStreaming(this.models, (model, overrides) =>\n\t\t\tthis.getRequestAuth(model, overrides),\n\t\t);\n\t\tthis.rebuildProviders();\n\t}\n\tstatic async create(options: CreateModelRuntimeOptions = {}): Promise<ModelRuntime> {\n\t\tconst credentials = new RuntimeCredentials(options.credentials ?? DefaultAuthStorage.create(options.authPath));\n\t\tconst modelsPath =\n\t\t\toptions.modelsPath === null ? undefined : (options.modelsPath ?? join(getAgentDir(), \"models.json\"));\n\t\tconst config = await ModelConfig.load(modelsPath);\n\t\tconst modelsStore =\n\t\t\toptions.modelsStore ??\n\t\t\t(modelsPath\n\t\t\t\t? new FileModelsStore(options.modelsStorePath ?? join(dirname(modelsPath), \"models-store.json\"))\n\t\t\t\t: new InMemoryCodingAgentModelsStore());\n\t\tconst builtinModelDataGeneratedAt = builtinProviderCatalog.getBuiltinModelDataGeneratedAt();\n\t\tconst providers = builtinProviderCatalog\n\t\t\t.builtinProviders()\n\t\t\t.map((provider) =>\n\t\t\t\tprovider.id === \"radius\"\n\t\t\t\t\t? provider\n\t\t\t\t\t: withRemoteCatalog(provider, options.catalogBaseUrl, builtinModelDataGeneratedAt),\n\t\t\t);\n\t\tconst runtime = new ModelRuntime(\n\t\t\tcredentials,\n\t\t\tconfig,\n\t\t\tmodelsPath,\n\t\t\tmodelsStore,\n\t\t\tproviders,\n\t\t\t!isOfflineModeEnabled(),\n\t\t);\n\t\truntime.configureRadiusProviders();\n\t\truntime.rebuildProviders();\n\t\tconst refreshFromNetwork = runtime.modelNetworkEnabled && options.allowModelNetwork === true;\n\t\tconst controller = refreshFromNetwork ? new AbortController() : undefined;\n\t\tconst timeout = controller\n\t\t\t? setTimeout(() => controller.abort(), options.modelRefreshTimeoutMs ?? 15_000)\n\t\t\t: undefined;\n\t\ttry {\n\t\t\tif (options.refreshOnCreate !== false) {\n\t\t\t\tawait runtime.refresh({ allowNetwork: refreshFromNetwork, signal: controller?.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\tprivate configureRadiusProviders(): void {\n\t\tconfigureBuiltinProviders(this.builtins, this.defaultBuiltins, this.config);\n\t}\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]);\n\t}\n\tprivate recomposeProvider(providerId: string): void {\n\t\tconst base = this.nativeExtensionProviders.get(providerId) ?? this.builtins.get(providerId);\n\t\tconst extension = this.extensionProviders.get(providerId);\n\t\tif (!base && !this.config.getProvider(providerId) && !extension) {\n\t\t\tthis.models.deleteProvider(providerId);\n\t\t\tthis.compositionErrors.delete(providerId);\n\t\t\treturn;\n\t\t}\n\t\tif (base && !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.models.setProvider(base);\n\t\t\tthis.compositionErrors.delete(providerId);\n\t\t\treturn;\n\t\t}\n\t\ttry {\n\t\t\tthis.models.setProvider(composeModelProvider(providerId, base, this.config, extension));\n\t\t\tthis.compositionErrors.delete(providerId);\n\t\t} catch (error) {\n\t\t\tthis.compositionErrors.set(providerId, error instanceof Error ? error.message : String(error));\n\t\t\tif (base) this.models.setProvider(base);\n\t\t\telse this.models.deleteProvider(providerId);\n\t\t}\n\t}\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\tprivate updateModelSnapshot(): void {\n\t\tthis.snapshotGeneration += 1;\n\t\tthis.snapshot = updateSnapshotModels(this.snapshot, [...this.models.getModels()]);\n\t}\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\tthis.snapshot = createModelRuntimeSnapshot([...this.models.getModels()], [...available], checks, credentials);\n\t\tif (errorSeq === this.availabilityErrorSeq) this.availabilityError = undefined;\n\t}\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\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\tthrow error;\n\t\t});\n\t}\n\tprivate async refreshProviderAvailability(providerId: string, signal: AbortSignal): Promise<void> {\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\t\tstoredProviders = new Set(this.snapshot.storedProviders),\n\t\t\t\tstoredCredentialTypes = new Map(this.snapshot.storedCredentialTypes),\n\t\t\t\tauthByProvider = 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) {\n\t\t\t\tstoredProviders.add(providerId);\n\t\t\t\tstoredCredentialTypes.set(providerId, credential.type);\n\t\t\t} else {\n\t\t\t\tstoredProviders.delete(providerId);\n\t\t\t\tstoredCredentialTypes.delete(providerId);\n\t\t\t}\n\t\t\tconst all = [...this.models.getModels()];\n\t\t\tconst availableById = new Map(\n\t\t\t\t[...this.snapshot.available.filter((model) => model.provider !== providerId), ...available].map((model) => [\n\t\t\t\t\t`${model.provider}\\0${model.id}`,\n\t\t\t\t\tmodel,\n\t\t\t\t]),\n\t\t\t);\n\t\t\tthis.snapshot = {\n\t\t\t\tall,\n\t\t\t\tavailable: all.flatMap((model) => availableById.get(`${model.provider}\\0${model.id}`) ?? []),\n\t\t\t\tconfiguredProviders,\n\t\t\t\tstoredProviders,\n\t\t\t\tstoredCredentialTypes,\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\tthrow error;\n\t\t}\n\t}\n\n\tgetProviders(): readonly Provider[] {\n\t\treturn this.models.getProviders();\n\t}\n\tgetProvider(providerId: string): Provider | undefined {\n\t\treturn this.models.getProvider(providerId);\n\t}\n\t/** Whether an authenticated provider may reconstruct an absent saved model ID. */\n\tcanRestoreUnknownModel(providerId: string): boolean {\n\t\treturn canRestoreUnknownModelProvider(\n\t\t\tproviderId,\n\t\t\tthis.defaultBuiltins.get(providerId),\n\t\t\tthis.config.getProvider(providerId),\n\t\t\tthis.extensionProviders.get(providerId),\n\t\t\tthis.nativeExtensionProviders.get(providerId),\n\t\t);\n\t}\n\tgetModels(providerId?: string): readonly Model<Api>[] {\n\t\treturn this.models.getModels(providerId);\n\t}\n\tgetModel(providerId: string, modelId: string): Model<Api> | undefined {\n\t\treturn this.models.getModel(providerId, modelId);\n\t}\n\tasync checkAuth(providerId: string): Promise<AuthCheck | undefined> {\n\t\treturn this.models.checkAuth(providerId);\n\t}\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\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\tgetAvailableSnapshot(): readonly Model<Api>[] {\n\t\treturn this.snapshot.available;\n\t}\n\tgetError(): string | undefined {\n\t\tconst errors: string[] = [];\n\t\tconst configError = this.config.getError();\n\t\tif (configError) errors.push(configError);\n\t\tfor (const [providerId, error] of this.compositionErrors) {\n\t\t\terrors.push(`Provider \"${providerId}\": ${error}`);\n\t\t}\n\t\tif (this.availabilityError) errors.push(`Availability refresh: ${this.availabilityError}`);\n\t\treturn errors.length > 0 ? errors.join(\"\\n\\n\") : undefined;\n\t}\n\n\tgetRegisteredProviderConfig(providerId: string): ProviderConfigInput | undefined {\n\t\treturn this.extensionProviders.get(providerId);\n\t}\n\n\tgetRegisteredProviderIds(): readonly string[] {\n\t\treturn [...new Set([...this.extensionProviders.keys(), ...this.nativeExtensionProviders.keys()])];\n\t}\n\n\tgetRegisteredNativeProvider(providerId: string): Provider | undefined {\n\t\treturn this.nativeExtensionProviders.get(providerId);\n\t}\n\tgetOAuthProviderMetadata() {\n\t\treturn collectOAuthProviderMetadata(this.getProviders(), this.extensionProviders);\n\t}\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\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: Model<Api>, overrides?: ModelRuntimeAuthOverrides): Promise<AuthResult | undefined>;\n\tasync getAuth(\n\t\tproviderOrModel: string | Model<Api>,\n\t\toverrides: ModelRuntimeAuthOverrides = {},\n\t): Promise<AuthResult | undefined> {\n\t\tif (typeof providerOrModel === \"string\") return this.models.getAuth(providerOrModel, overrides);\n\t\tconst resolution = await this.models.getAuth(providerOrModel, overrides);\n\t\tif (!resolution) return undefined;\n\t\treturn mergeConfiguredAuthHeaders(\n\t\t\tresolution,\n\t\t\tproviderOrModel,\n\t\t\tthis.config,\n\t\t\tthis.extensionProviders.get(providerOrModel.provider),\n\t\t\toverrides,\n\t\t);\n\t}\n\n\t/**\n\t * Resolve request-owned auth/config headers without copying the model's static\n\t * catalog headers into the per-request override layer. The API provider reads\n\t * static headers from the model itself; duplicating them in auth would make\n\t * them override API-computed defaults that intentionally replace catalog values.\n\t */\n\tasync getRequestAuth(model: Model<Api>, overrides: ModelRuntimeAuthOverrides = {}): Promise<AuthResult | undefined> {\n\t\tconst resolution = await this.getAuth(model.provider, overrides);\n\t\tif (!resolution) return undefined;\n\t\treturn mergeConfiguredAuthHeaders(\n\t\t\tresolution,\n\t\t\tmodel,\n\t\t\tthis.config,\n\t\t\tthis.extensionProviders.get(model.provider),\n\t\t\toverrides,\n\t\t);\n\t}\n\n\t/**\n\t * Monotonic count of changes to any input a catalog refresh reads.\n\t *\n\t * `refresh()` reloads models.json, recomposes every provider from it, the\n\t * extension registrations, and the builtin catalog, resolves credentials as\n\t * it runs, and publishes ONE snapshot at the end. So a pass belongs to the\n\t * inputs it started under, and joining a pass across a bump is unsound in\n\t * both directions: the joiner reads models and credentials the user has\n\t * already replaced, and the pass's late publish overwrites the newer state\n\t * with them.\n\t *\n\t * Every mutation source bumps this counter, which is why callers need only\n\t * this one number rather than a growing tuple of per-input keys:\n\t *\n\t * - credential writes — `login`, `logout`, `saveCredential`,\n\t * `setRuntimeApiKey`, `removeRuntimeApiKey`, an external\n\t * `reloadCredentials`, and an applied external auth status;\n\t * - provider registrations — `registerProvider`, `registerNativeProvider`,\n\t * and `unregisterProvider`, through the refresh they schedule;\n\t * - models.json content — provider `baseUrl`, `apiKey`, `api`, headers,\n\t * model definitions, and overrides, which every pass reloads.\n\t *\n\t * The first two are this runtime's own writes and bump where they happen.\n\t * The third is an external edit nothing here observes, so reading the\n\t * generation samples the file and bumps when its content moved since the\n\t * last sample. That read is synchronous so the answer belongs to the same\n\t * tick as the decision that depends on it, and it hashes content rather\n\t * than trusting an mtime: a same-size rewrite inside one filesystem\n\t * timestamp tick — an edited key, a renamed model — is exactly the change a\n\t * shared pass must not hide.\n\t */\n\tgetCatalogInputsGeneration(): number {\n\t\tthis.observeModelsFile();\n\t\treturn this.catalogInputsGeneration;\n\t}\n\n\t/**\n\t * Record that an input a catalog refresh reads changed. Every pass started\n\t * before this call answers for inputs that no longer exist.\n\t */\n\tprivate markCatalogInputsChanged(): void {\n\t\tthis.catalogInputsGeneration += 1;\n\t}\n\n\t/** Bump the generation when models.json changed since the last observation. */\n\tprivate observeModelsFile(): void {\n\t\tconst token = this.readModelsFileToken();\n\t\tif (this.observedModelsFileToken === token) return;\n\t\tconst first = this.observedModelsFileToken === undefined;\n\t\tthis.observedModelsFileToken = token;\n\t\t// The first observation is a baseline, not a change: no pass can predate it.\n\t\tif (!first) this.markCatalogInputsChanged();\n\t}\n\n\tprivate readModelsFileToken(): string {\n\t\tif (!this.modelsPath) return \"none\";\n\t\ttry {\n\t\t\treturn createHash(\"sha1\")\n\t\t\t\t.update(readFileSync(normalizePath(this.modelsPath)))\n\t\t\t\t.digest(\"hex\");\n\t\t} catch (error) {\n\t\t\tconst code = (error as NodeJS.ErrnoException).code;\n\t\t\t// An absent file is a stable state passes can share; any other read\n\t\t\t// failure keys on its own code rather than pretending the file is empty.\n\t\t\treturn code === \"ENOENT\" ? \"absent\" : `unreadable:${code ?? \"unknown\"}`;\n\t\t}\n\t}\n\n\t/** Reload credentials changed by the authoritative isolated engine and update auth status snapshots. */\n\tasync reloadCredentials(options: { refreshAvailability?: boolean } = {}): Promise<void> {\n\t\tawait this.credentials.reload();\n\t\tthis.markCatalogInputsChanged();\n\t\tif (options.refreshAvailability === false) {\n\t\t\tconst credentials = await this.credentials.list();\n\t\t\tfor (const credential of credentials) this.externalProviderAuthStatuses.delete(credential.providerId);\n\t\t\tthis.snapshotGeneration += 1;\n\t\t\tthis.snapshot = replaceStoredCredentialProviders(this.snapshot, credentials);\n\t\t\treturn;\n\t\t}\n\t\tawait this.queueAvailabilityRefresh();\n\t}\n\n\tprivate assertCredentialRefreshSucceeded(\n\t\tproviderId: string,\n\t\tresult: ModelsRefreshResult,\n\t\tsignal?: AbortSignal,\n\t): void {\n\t\tif (result.aborted) {\n\t\t\tsignal?.throwIfAborted();\n\t\t\tthrow new Error(`Model refresh aborted for ${providerId}`);\n\t\t}\n\t\tconst refreshError = result.errors.get(providerId);\n\t\tif (refreshError) throw refreshError;\n\t\tconst compositionError = this.compositionErrors.get(providerId);\n\t\tif (compositionError) throw new Error(compositionError);\n\t}\n\n\tprivate enqueueCredentialOperation<T>(providerId: string, signal: AbortSignal, task: () => Promise<T>): Promise<T> {\n\t\tconst previous = this.credentialOperations.get(providerId) ?? Promise.resolve();\n\t\tlet markStarted: (() => void) | undefined;\n\t\tconst started = new Promise<void>((resolve) => {\n\t\t\tmarkStarted = resolve;\n\t\t});\n\t\tconst operation = (async () => {\n\t\t\tawait previous.catch(() => {});\n\t\t\tsignal.throwIfAborted();\n\t\t\tmarkStarted?.();\n\t\t\treturn task();\n\t\t})();\n\t\tconst tail = operation.catch(() => {});\n\t\tthis.credentialOperations.set(providerId, tail);\n\t\tvoid tail.then(() => {\n\t\t\tif (this.credentialOperations.get(providerId) === tail) this.credentialOperations.delete(providerId);\n\t\t});\n\t\treturn raceWithAbortSignal(started, signal).then(() => operation);\n\t}\n\tprivate async synchronizeCredentialState(\n\t\tproviderId: string,\n\t\toperation: CredentialSynchronizationOperation,\n\t\tcredential: Credential | undefined,\n\t\tsynchronize: () => void | Promise<void>,\n\t): Promise<void> {\n\t\ttry {\n\t\t\tawait synchronize();\n\t\t} catch (cause) {\n\t\t\tif (cause instanceof CredentialSynchronizationError) throw cause;\n\t\t\tthrow new CredentialSynchronizationError(providerId, operation, credential, { cause });\n\t\t}\n\t}\n\tprivate async refreshRemainingAuthAfterLogout(providerId: string, logoutGeneration: number): Promise<void> {\n\t\t// Environment/runtime auth can remain after stored auth is removed. The\n\t\t// probe is normally synchronous, but its deadline is authoritative because\n\t\t// extension checks are third-party code and need not honor cancellation.\n\t\tlet timeout: number | undefined;\n\t\ttry {\n\t\t\tconst remainingAuth = await Promise.race([\n\t\t\t\tthis.checkAuth(providerId).catch(() => undefined),\n\t\t\t\tnew Promise<undefined>((resolve) => {\n\t\t\t\t\ttimeout = setTimeout(resolve, POST_LOGOUT_AUTH_CHECK_TIMEOUT_MS);\n\t\t\t\t}),\n\t\t\t]);\n\t\t\tif (logoutGeneration === this.snapshotGeneration && !this.snapshot.storedProviders.has(providerId)) {\n\t\t\t\tthis.snapshot = removeStoredCredentialProvider(this.snapshot, providerId, remainingAuth);\n\t\t\t}\n\t\t} finally {\n\t\t\tif (timeout) clearTimeout(timeout);\n\t\t}\n\t}\n\n\tasync saveCredential(providerId: string, credential: Credential): Promise<void> {\n\t\tconst signal = operationSignal(undefined);\n\t\tawait this.enqueueCredentialOperation(providerId, signal, async () => {\n\t\t\tawait this.credentials.modify(providerId, async () => credential);\n\t\t\tthis.markCatalogInputsChanged();\n\t\t\tawait this.synchronizeCredentialState(providerId, \"saveCredential\", credential, async () => {\n\t\t\t\tconst result = await this.refresh({ providers: [providerId] });\n\t\t\t\tthis.assertCredentialRefreshSucceeded(providerId, result);\n\t\t\t});\n\t\t});\n\t}\n\t/**\n\t * Apply a process-scoped API key override. This publishes the provider against\n\t * the current snapshot and deliberately does not refresh the model catalog;\n\t * callers needing catalog freshness call refresh({ providers: [providerId], signal })\n\t * separately.\n\t */\n\tasync setRuntimeApiKey(providerId: string, apiKey: string, options: AuthOperationOptions): Promise<void> {\n\t\tconst signal = operationSignal(options.signal);\n\t\tawait this.enqueueCredentialOperation(providerId, signal, async () => {\n\t\t\tthis.credentials.setRuntimeApiKey(providerId, apiKey);\n\t\t\tthis.markCatalogInputsChanged();\n\t\t\tawait this.synchronizeCredentialState(providerId, \"setRuntimeApiKey\", { type: \"api_key\", key: apiKey }, () => {\n\t\t\t\tthis.snapshot = addRuntimeApiKeyProvider(this.snapshot, providerId);\n\t\t\t});\n\t\t});\n\t}\n\n\tasync removeRuntimeApiKey(providerId: string, options: AuthOperationOptions = {}): Promise<void> {\n\t\tconst signal = operationSignal(options.signal);\n\t\tawait this.enqueueCredentialOperation(providerId, signal, async () => {\n\t\t\tthis.credentials.removeRuntimeApiKey(providerId);\n\t\t\tthis.markCatalogInputsChanged();\n\t\t\tawait this.synchronizeCredentialState(providerId, \"removeRuntimeApiKey\", undefined, async () => {\n\t\t\t\tconst result = await this.refresh({ allowNetwork: this.modelNetworkEnabled, signal });\n\t\t\t\tthis.assertCredentialRefreshSucceeded(providerId, result, signal);\n\t\t\t});\n\t\t});\n\t}\n\n\tlistCredentials(): Promise<readonly CredentialInfo[]> {\n\t\treturn this.credentials.list();\n\t}\n\n\tgetStoredCredentialType(providerId: string): CredentialInfo[\"type\"] | undefined {\n\t\treturn this.snapshot.storedCredentialTypes.get(providerId);\n\t}\n\n\tgetProviderAuthStatus(providerId: string): AuthStatus {\n\t\tconst localStatus = getSnapshotProviderAuthStatus(\n\t\t\tthis.snapshot,\n\t\t\tproviderId,\n\t\t\tthis.credentials.hasRuntimeApiKey(providerId),\n\t\t\tconfiguredRequestAuthStatus(this.config.getProvider(providerId), this.extensionProviders.get(providerId)),\n\t\t);\n\t\tif (localStatus.source === \"stored\" || localStatus.source === \"runtime\") return localStatus;\n\t\treturn this.externalProviderAuthStatuses.get(providerId) ?? localStatus;\n\t}\n\n\t/** Apply authoritative auth state returned by an isolated engine mutation. */\n\tapplyExternalProviderAuthStatus(providerId: string, status: AuthStatus): void {\n\t\tthis.markCatalogInputsChanged();\n\t\tthis.snapshotGeneration += 1;\n\t\tconst remainingAuth =\n\t\t\tstatus.configured && status.source === \"environment\"\n\t\t\t\t? ({ type: \"api_key\", source: status.label ?? \"environment\" } as const)\n\t\t\t\t: undefined;\n\t\tthis.snapshot = removeStoredCredentialProvider(this.snapshot, providerId, remainingAuth);\n\t\tthis.externalProviderAuthStatuses.set(providerId, status);\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\treturn this.streaming.stream(model, context, options);\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.streaming.complete(model, context, options);\n\t}\n\n\tstreamSimple(model: Model<Api>, context: Context, options?: ModelsSimpleStreamOptions): AssistantMessageEventStream {\n\t\treturn this.streaming.streamSimple(model, context, options);\n\t}\n\n\tcompleteSimple(model: Model<Api>, context: Context, options?: ModelsSimpleStreamOptions): Promise<AssistantMessage> {\n\t\treturn this.streaming.completeSimple(model, context, options);\n\t}\n\n\tfetchDeferred(\n\t\tmodel: Model<Api>,\n\t\thandle: DeferredHandle,\n\t\toptions?: ModelsDeferredFetchOptions,\n\t): Promise<AssistantMessage> {\n\t\treturn this.streaming.fetchDeferred(model, handle, options);\n\t}\n\n\tcancelDeferred(model: Model<Api>, handle: DeferredHandle, options?: ModelsDeferredCancelOptions): Promise<void> {\n\t\treturn this.streaming.cancelDeferred(model, handle, options);\n\t}\n\n\tasync login(providerId: string, type: AuthType, interaction: AuthInteraction): Promise<Credential> {\n\t\tconst signal = operationSignal(interaction.signal);\n\t\treturn this.enqueueCredentialOperation(providerId, signal, async () => {\n\t\t\tconst credential = await this.models.login(providerId, type, { ...interaction, signal });\n\t\t\tthis.markCatalogInputsChanged();\n\t\t\tawait this.synchronizeCredentialState(providerId, \"login\", credential, () => {\n\t\t\t\t// Credential acquisition and persistence are the login transaction. Publish\n\t\t\t\t// the provider against the current snapshot immediately; catalog restoration,\n\t\t\t\t// ambient availability checks, and networking belong to /model's bounded\n\t\t\t\t// background refresh and must never keep a successful login dialog open.\n\t\t\t\tthis.updateModelSnapshot();\n\t\t\t\tthis.externalProviderAuthStatuses.delete(providerId);\n\t\t\t\tthis.snapshot = addStoredCredentialProvider(this.snapshot, providerId, credential.type);\n\t\t\t});\n\t\t\treturn credential;\n\t\t});\n\t}\n\n\tasync logout(providerId: string, options: AuthOperationOptions = {}): Promise<void> {\n\t\tconst signal = operationSignal(options.signal);\n\t\tconst logoutGeneration = await this.enqueueCredentialOperation(providerId, signal, async () => {\n\t\t\tawait this.models.logout(providerId, { signal });\n\t\t\tthis.markCatalogInputsChanged();\n\t\t\tlet generation = 0;\n\t\t\tawait this.synchronizeCredentialState(providerId, \"logout\", undefined, () => {\n\t\t\t\t// Reset credential-dependent compatibility projections, then publish the\n\t\t\t\t// persisted deletion without waiting for model stores or remote catalogs.\n\t\t\t\tthis.recomposeProvider(providerId);\n\t\t\t\tthis.updateModelSnapshot();\n\t\t\t\tthis.externalProviderAuthStatuses.delete(providerId);\n\t\t\t\tthis.snapshot = removeStoredCredentialProvider(this.snapshot, providerId);\n\t\t\t\tgeneration = this.snapshotGeneration;\n\t\t\t});\n\t\t\treturn generation;\n\t\t});\n\t\tawait this.refreshRemainingAuthAfterLogout(providerId, logoutGeneration);\n\t}\n\n\t/**\n\t * The network policy a refresh with an omitted `allowNetwork` resolves to.\n\t *\n\t * Callers that share one in-flight refresh key on the effective policy, so\n\t * they need the same answer `runRefresh` computes rather than a second guess\n\t * at the offline setting this runtime was created under.\n\t */\n\tisNetworkRefreshEnabled(): boolean {\n\t\treturn this.modelNetworkEnabled;\n\t}\n\tasync refresh(options: ModelsRefreshOptions = {}): Promise<ModelsRefreshResult> {\n\t\treturn this.runRefresh(options, ++this.refreshSequence);\n\t}\n\n\t/**\n\t * A registration's offline catalog pass must not publish after a newer refresh\n\t * that resolves configured credentials.\n\t *\n\t * The registration is also a catalog-input change: it adds, replaces, or drops\n\t * a provider every later pass composes from, so no pass that predates it can\n\t * answer for the provider set a caller now sees.\n\t */\n\tprivate scheduleRegistrationRefresh(): void {\n\t\tthis.markCatalogInputsChanged();\n\t\tconst sequence = ++this.refreshSequence;\n\t\tvoid this.runRefresh({ allowNetwork: false }, sequence, true);\n\t}\n\n\tprivate async runRefresh(\n\t\toptions: ModelsRefreshOptions,\n\t\tsequence: number,\n\t\tdiscardIfSuperseded = false,\n\t): Promise<ModelsRefreshResult> {\n\t\tconst config = await ModelConfig.load(this.modelsPath);\n\t\tif (discardIfSuperseded && sequence !== this.refreshSequence) {\n\t\t\treturn { aborted: true, errors: new Map<string, Error>() };\n\t\t}\n\t\tthis.config = config;\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 this.rebuildProviders();\n\t\tconst refreshOptions = { ...options, allowNetwork: options.allowNetwork ?? this.isNetworkRefreshEnabled() };\n\t\tconst result = await this.models.refresh(refreshOptions);\n\t\tconst errors = new Map(result.errors);\n\t\tthis.updateModelSnapshot();\n\t\tif (options.providers) {\n\t\t\tawait Promise.all(\n\t\t\t\t[...new Set(options.providers)].map(async (providerId) => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait this.refreshProviderAvailability(providerId, operationSignal(options.signal));\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tif (!options.signal?.aborted)\n\t\t\t\t\t\t\terrors.set(providerId, error instanceof Error ? error : new Error(String(error)));\n\t\t\t\t\t}\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.scheduleRegistrationRefresh();\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\tif (\n\t\t\tthis.snapshot.storedProviders.has(providerId) ||\n\t\t\tconfiguredRequestAuthStatus(this.config.getProvider(providerId), effective)?.configured\n\t\t) {\n\t\t\tconst configuredProviders = new Set(this.snapshot.configuredProviders).add(providerId);\n\t\t\tconst auth = new Map(this.snapshot.auth);\n\t\t\t// Provisional entry until the async refresh lands; never clobber a real check result.\n\t\t\tif (!auth.get(providerId)) {\n\t\t\t\tauth.set(providerId, {\n\t\t\t\t\ttype: effective.oauth && !effective.apiKey ? \"oauth\" : \"api_key\",\n\t\t\t\t\tsource: \"configured provider\",\n\t\t\t\t});\n\t\t\t}\n\t\t\t// A provider that was already configured has an availability result — possibly\n\t\t\t// a credential-filtered subset of its catalog, as with an additive GitHub\n\t\t\t// Copilot override — and keeps it until the refresh this registration schedules\n\t\t\t// republishes it. Only a provider this registration newly configures has no\n\t\t\t// result to keep, so only its catalog is exposed provisionally.\n\t\t\tlet available = this.snapshot.available;\n\t\t\tif (!this.snapshot.configuredProviders.has(providerId)) {\n\t\t\t\tconst preserved = new Set(available.map(snapshotModelKey));\n\t\t\t\tavailable = this.snapshot.all.filter(\n\t\t\t\t\t(model) => model.provider === providerId || preserved.has(snapshotModelKey(model)),\n\t\t\t\t);\n\t\t\t}\n\t\t\tthis.snapshot = { ...this.snapshot, auth, configuredProviders, available };\n\t\t}\n\t\tthis.scheduleRegistrationRefresh();\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.scheduleRegistrationRefresh();\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"model-runtime.js","sourceRoot":"","sources":["../../src/core/model-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW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createHash } from \"node:crypto\";\nimport { readFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport {\n\ttype Api,\n\ttype AssistantMessage,\n\ttype AssistantMessageEventStream,\n\ttype AuthCheck,\n\ttype AuthInteraction,\n\ttype AuthOperationOptions,\n\ttype AuthResult,\n\ttype AuthType,\n\ttype Context,\n\ttype Credential,\n\ttype CredentialInfo,\n\tcreateModels,\n\ttype DeferredHandle,\n\ttype Model,\n\ttype Models,\n\ttype ModelsApiStreamOptions,\n\ttype ModelsDeferredCancelOptions,\n\ttype ModelsDeferredFetchOptions,\n\ttype ModelsRefreshOptions,\n\ttype ModelsRefreshResult,\n\ttype ModelsSimpleStreamOptions,\n\ttype ModelsStore,\n\ttype MutableModels,\n\ttype Provider,\n} from \"@bastani/pi-ai\";\nimport * as builtinProviderCatalog from \"@bastani/pi-ai/providers/all\";\nimport { getAgentDir } from \"../config.ts\";\nimport { operationSignal, raceWithAbortSignal } from \"../utils/abort.js\";\nimport { normalizePath } from \"../utils/paths.ts\";\nimport { AuthStorage as DefaultAuthStorage } from \"./auth-storage.ts\";\nimport { ModelConfig } from \"./model-config.ts\";\nimport { POST_LOGOUT_AUTH_CHECK_TIMEOUT_MS } from \"./model-refresh-timeout.ts\";\nimport {\n\taddRuntimeApiKeyProvider,\n\taddStoredCredentialProvider,\n\tcreateEmptyModelRuntimeSnapshot,\n\tcreateModelRuntimeSnapshot,\n\tgetSnapshotProviderAuthStatus,\n\ttype ModelRuntimeSnapshot,\n\tremoveStoredCredentialProvider,\n\treplaceStoredCredentialProviders,\n\tsnapshotModelKey,\n\tupdateSnapshotModels,\n} from \"./model-runtime-snapshot.ts\";\nimport { FileModelsStore, InMemoryCodingAgentModelsStore } from \"./models-store.ts\";\nimport { collectOAuthProviderMetadata } from \"./oauth-provider-metadata.ts\";\nimport { isOfflineModeEnabled } from \"./package-manager-env.ts\";\nimport {\n\ttype AuthStatus,\n\ttype CompatibilityRequestConfig,\n\tcomposeModelProvider,\n\tconfiguredRequestAuthStatus,\n\ttype ProviderConfigInput,\n\tresolveCompatibilityRequestConfig,\n\tvalidateExtensionProvider,\n} from \"./provider-composer.ts\";\nimport { withRemoteCatalog } from \"./remote-catalog-provider.ts\";\nimport { RuntimeCredentials } from \"./runtime-credentials.ts\";\n\nexport type { CreateModelRuntimeOptions, ModelRuntimeAuthOverrides } from \"./model-runtime-types.ts\";\n\nimport { mergeConfiguredAuthHeaders } from \"./model-runtime-auth.ts\";\nimport { configureBuiltinProviders } from \"./model-runtime-providers.ts\";\nimport { canRestoreUnknownModel as canRestoreUnknownModelProvider } from \"./model-runtime-restoration.ts\";\nimport { ModelRuntimeStreaming } from \"./model-runtime-streaming.ts\";\nimport type { CreateModelRuntimeOptions, ModelRuntimeAuthOverrides } from \"./model-runtime-types.ts\";\n\nexport type CredentialSynchronizationOperation =\n\t| \"login\"\n\t| \"logout\"\n\t| \"saveCredential\"\n\t| \"setRuntimeApiKey\"\n\t| \"removeRuntimeApiKey\";\n\n/** Credentials changed successfully, but local model state could not be synchronized. */\nexport class CredentialSynchronizationError extends Error {\n\treadonly providerId: string;\n\treadonly operation: CredentialSynchronizationOperation;\n\treadonly credential: Credential | undefined;\n\n\tconstructor(\n\t\tproviderId: string,\n\t\toperation: CredentialSynchronizationOperation,\n\t\tcredential: Credential | undefined,\n\t\toptions: ErrorOptions,\n\t) {\n\t\tsuper(`Credential ${operation} committed for ${providerId}, but local synchronization failed`, options);\n\t\tthis.name = \"CredentialSynchronizationError\";\n\t\tthis.providerId = providerId;\n\t\tthis.operation = operation;\n\t\t// One call rather than assign-then-redefine: the two-step form is\n\t\t// equivalent (defineProperty with only `enumerable` preserves the existing\n\t\t// value) but reads as a redundant write and trips static analysis. The\n\t\t// non-enumerable descriptor is the load-bearing part — it keeps the\n\t\t// credential out of JSON.stringify, console.log, and structured error\n\t\t// reporting.\n\t\tObject.defineProperty(this, \"credential\", {\n\t\t\tvalue: credential,\n\t\t\tenumerable: false,\n\t\t\twritable: true,\n\t\t\tconfigurable: true,\n\t\t});\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 streaming: ModelRuntimeStreaming;\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\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 = createEmptyModelRuntimeSnapshot();\n\tprivate snapshotGeneration = 0;\n\tprivate catalogInputsGeneration = 0;\n\tprivate observedModelsFileToken: string | undefined;\n\tprivate readonly externalProviderAuthStatuses = new Map<string, AuthStatus>();\n\tprivate availabilityRefreshSeq = 0;\n\tprivate availabilityErrorSeq = 0;\n\tprivate readonly providerAvailabilitySeq = new Map<string, number>();\n\tprivate readonly credentialOperations = new Map<string, Promise<unknown>>();\n\tprivate availabilityError: string | undefined;\n\tprivate refreshSequence = 0;\n\tprivate constructor(\n\t\tcredentials: RuntimeCredentials,\n\t\tconfig: ModelConfig,\n\t\tmodelsPath: string | undefined,\n\t\tmodelsStore: ModelsStore,\n\t\tproviders: readonly Provider[],\n\t\tmodelNetworkEnabled: boolean,\n\t) {\n\t\tthis.credentials = credentials;\n\t\tthis.config = config;\n\t\tthis.modelsPath = modelsPath;\n\t\tthis.modelNetworkEnabled = modelNetworkEnabled;\n\t\tthis.defaultBuiltins = new Map(providers.map((provider) => [provider.id, provider]));\n\t\tfor (const [providerId, provider] of this.defaultBuiltins) this.builtins.set(providerId, provider);\n\t\tthis.models = createModels({ credentials, modelsStore });\n\t\tthis.streaming = new ModelRuntimeStreaming(this.models, (model, overrides) =>\n\t\t\tthis.getRequestAuth(model, overrides),\n\t\t);\n\t\tthis.rebuildProviders();\n\t}\n\tstatic async create(options: CreateModelRuntimeOptions = {}): Promise<ModelRuntime> {\n\t\tconst credentials = new RuntimeCredentials(options.credentials ?? DefaultAuthStorage.create(options.authPath));\n\t\tconst modelsPath =\n\t\t\toptions.modelsPath === null ? undefined : (options.modelsPath ?? join(getAgentDir(), \"models.json\"));\n\t\tconst config = await ModelConfig.load(modelsPath);\n\t\tconst modelsStore =\n\t\t\toptions.modelsStore ??\n\t\t\t(modelsPath\n\t\t\t\t? new FileModelsStore(options.modelsStorePath ?? join(dirname(modelsPath), \"models-store.json\"))\n\t\t\t\t: new InMemoryCodingAgentModelsStore());\n\t\tconst builtinModelDataGeneratedAt = builtinProviderCatalog.getBuiltinModelDataGeneratedAt();\n\t\tconst providers = builtinProviderCatalog\n\t\t\t.builtinProviders()\n\t\t\t.map((provider) =>\n\t\t\t\tprovider.id === \"radius\"\n\t\t\t\t\t? provider\n\t\t\t\t\t: withRemoteCatalog(provider, options.catalogBaseUrl, builtinModelDataGeneratedAt),\n\t\t\t);\n\t\tconst runtime = new ModelRuntime(\n\t\t\tcredentials,\n\t\t\tconfig,\n\t\t\tmodelsPath,\n\t\t\tmodelsStore,\n\t\t\tproviders,\n\t\t\t!isOfflineModeEnabled(),\n\t\t);\n\t\truntime.configureRadiusProviders();\n\t\truntime.rebuildProviders();\n\t\tconst refreshFromNetwork = runtime.modelNetworkEnabled && options.allowModelNetwork === true;\n\t\tconst controller = refreshFromNetwork ? new AbortController() : undefined;\n\t\tconst timeout = controller\n\t\t\t? setTimeout(() => controller.abort(), options.modelRefreshTimeoutMs ?? 15_000)\n\t\t\t: undefined;\n\t\ttry {\n\t\t\tif (options.refreshOnCreate !== false) {\n\t\t\t\tawait runtime.refresh({ allowNetwork: refreshFromNetwork, signal: controller?.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\tprivate configureRadiusProviders(): void {\n\t\tconfigureBuiltinProviders(this.builtins, this.defaultBuiltins, this.config);\n\t}\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]);\n\t}\n\tprivate recomposeProvider(providerId: string): void {\n\t\tconst base = this.nativeExtensionProviders.get(providerId) ?? this.builtins.get(providerId);\n\t\tconst extension = this.extensionProviders.get(providerId);\n\t\tif (!base && !this.config.getProvider(providerId) && !extension) {\n\t\t\tthis.models.deleteProvider(providerId);\n\t\t\tthis.compositionErrors.delete(providerId);\n\t\t\treturn;\n\t\t}\n\t\tif (base && !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.models.setProvider(base);\n\t\t\tthis.compositionErrors.delete(providerId);\n\t\t\treturn;\n\t\t}\n\t\ttry {\n\t\t\tthis.models.setProvider(composeModelProvider(providerId, base, this.config, extension));\n\t\t\tthis.compositionErrors.delete(providerId);\n\t\t} catch (error) {\n\t\t\tthis.compositionErrors.set(providerId, error instanceof Error ? error.message : String(error));\n\t\t\tif (base) this.models.setProvider(base);\n\t\t\telse this.models.deleteProvider(providerId);\n\t\t}\n\t}\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\tprivate updateModelSnapshot(): void {\n\t\tthis.snapshotGeneration += 1;\n\t\tthis.snapshot = updateSnapshotModels(this.snapshot, [...this.models.getModels()]);\n\t}\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\tthis.snapshot = createModelRuntimeSnapshot([...this.models.getModels()], [...available], checks, credentials);\n\t\tif (errorSeq === this.availabilityErrorSeq) this.availabilityError = undefined;\n\t}\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\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\tthrow error;\n\t\t});\n\t}\n\tprivate async refreshProviderAvailability(providerId: string, signal: AbortSignal): Promise<void> {\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\t\tstoredProviders = new Set(this.snapshot.storedProviders),\n\t\t\t\tstoredCredentialTypes = new Map(this.snapshot.storedCredentialTypes),\n\t\t\t\tauthByProvider = 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) {\n\t\t\t\tstoredProviders.add(providerId);\n\t\t\t\tstoredCredentialTypes.set(providerId, credential.type);\n\t\t\t} else {\n\t\t\t\tstoredProviders.delete(providerId);\n\t\t\t\tstoredCredentialTypes.delete(providerId);\n\t\t\t}\n\t\t\tconst all = [...this.models.getModels()];\n\t\t\tconst availableById = new Map(\n\t\t\t\t[...this.snapshot.available.filter((model) => model.provider !== providerId), ...available].map((model) => [\n\t\t\t\t\t`${model.provider}\\0${model.id}`,\n\t\t\t\t\tmodel,\n\t\t\t\t]),\n\t\t\t);\n\t\t\tthis.snapshot = {\n\t\t\t\tall,\n\t\t\t\tavailable: all.flatMap((model) => availableById.get(`${model.provider}\\0${model.id}`) ?? []),\n\t\t\t\tconfiguredProviders,\n\t\t\t\tstoredProviders,\n\t\t\t\tstoredCredentialTypes,\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\tthrow error;\n\t\t}\n\t}\n\n\tgetProviders(): readonly Provider[] {\n\t\treturn this.models.getProviders();\n\t}\n\tgetProvider(providerId: string): Provider | undefined {\n\t\treturn this.models.getProvider(providerId);\n\t}\n\t/** Whether an authenticated provider may reconstruct an absent saved model ID. */\n\tcanRestoreUnknownModel(providerId: string): boolean {\n\t\treturn canRestoreUnknownModelProvider(\n\t\t\tproviderId,\n\t\t\tthis.defaultBuiltins.get(providerId),\n\t\t\tthis.config.getProvider(providerId),\n\t\t\tthis.extensionProviders.get(providerId),\n\t\t\tthis.nativeExtensionProviders.get(providerId),\n\t\t);\n\t}\n\tgetModels(providerId?: string): readonly Model<Api>[] {\n\t\treturn this.models.getModels(providerId);\n\t}\n\tgetModel(providerId: string, modelId: string): Model<Api> | undefined {\n\t\treturn this.models.getModel(providerId, modelId);\n\t}\n\tasync checkAuth(providerId: string): Promise<AuthCheck | undefined> {\n\t\treturn this.models.checkAuth(providerId);\n\t}\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\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\tgetAvailableSnapshot(): readonly Model<Api>[] {\n\t\treturn this.snapshot.available;\n\t}\n\tgetError(): string | undefined {\n\t\tconst errors: string[] = [];\n\t\tconst configError = this.config.getError();\n\t\tif (configError) errors.push(configError);\n\t\tfor (const [providerId, error] of this.compositionErrors) {\n\t\t\terrors.push(`Provider \"${providerId}\": ${error}`);\n\t\t}\n\t\tif (this.availabilityError) errors.push(`Availability refresh: ${this.availabilityError}`);\n\t\treturn errors.length > 0 ? errors.join(\"\\n\\n\") : undefined;\n\t}\n\n\tgetRegisteredProviderConfig(providerId: string): ProviderConfigInput | undefined {\n\t\treturn this.extensionProviders.get(providerId);\n\t}\n\n\tgetRegisteredProviderIds(): readonly string[] {\n\t\treturn [...new Set([...this.extensionProviders.keys(), ...this.nativeExtensionProviders.keys()])];\n\t}\n\n\tgetRegisteredNativeProvider(providerId: string): Provider | undefined {\n\t\treturn this.nativeExtensionProviders.get(providerId);\n\t}\n\tgetOAuthProviderMetadata() {\n\t\treturn collectOAuthProviderMetadata(this.getProviders(), this.extensionProviders);\n\t}\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\thasConfiguredAuth(providerId: string): boolean {\n\t\treturn this.snapshot.configuredProviders.has(providerId);\n\t}\n\n\t/** Return stored credential metadata synchronously without refreshing auth. */\n\tgetCredentialSnapshot(providerId: string): Credential | undefined {\n\t\treturn this.credentials.peek(providerId);\n\t}\n\n\tgetAuth(providerId: string, overrides?: ModelRuntimeAuthOverrides): Promise<AuthResult | undefined>;\n\tgetAuth(model: Model<Api>, overrides?: ModelRuntimeAuthOverrides): Promise<AuthResult | undefined>;\n\tasync getAuth(\n\t\tproviderOrModel: string | Model<Api>,\n\t\toverrides: ModelRuntimeAuthOverrides = {},\n\t): Promise<AuthResult | undefined> {\n\t\tif (typeof providerOrModel === \"string\") return this.models.getAuth(providerOrModel, overrides);\n\t\tconst resolution = await this.models.getAuth(providerOrModel, overrides);\n\t\tif (!resolution) return undefined;\n\t\treturn mergeConfiguredAuthHeaders(\n\t\t\tresolution,\n\t\t\tproviderOrModel,\n\t\t\tthis.config,\n\t\t\tthis.extensionProviders.get(providerOrModel.provider),\n\t\t\toverrides,\n\t\t);\n\t}\n\n\t/**\n\t * Resolve request-owned auth/config headers without copying the model's static\n\t * catalog headers into the per-request override layer. The API provider reads\n\t * static headers from the model itself; duplicating them in auth would make\n\t * them override API-computed defaults that intentionally replace catalog values.\n\t */\n\tasync getRequestAuth(model: Model<Api>, overrides: ModelRuntimeAuthOverrides = {}): Promise<AuthResult | undefined> {\n\t\tconst resolution = await this.getAuth(model.provider, overrides);\n\t\tif (!resolution) return undefined;\n\t\treturn mergeConfiguredAuthHeaders(\n\t\t\tresolution,\n\t\t\tmodel,\n\t\t\tthis.config,\n\t\t\tthis.extensionProviders.get(model.provider),\n\t\t\toverrides,\n\t\t);\n\t}\n\n\t/**\n\t * Monotonic count of changes to any input a catalog refresh reads.\n\t *\n\t * `refresh()` reloads models.json, recomposes every provider from it, the\n\t * extension registrations, and the builtin catalog, resolves credentials as\n\t * it runs, and publishes ONE snapshot at the end. So a pass belongs to the\n\t * inputs it started under, and joining a pass across a bump is unsound in\n\t * both directions: the joiner reads models and credentials the user has\n\t * already replaced, and the pass's late publish overwrites the newer state\n\t * with them.\n\t *\n\t * Every mutation source bumps this counter, which is why callers need only\n\t * this one number rather than a growing tuple of per-input keys:\n\t *\n\t * - credential writes — `login`, `logout`, `saveCredential`,\n\t * `setRuntimeApiKey`, `removeRuntimeApiKey`, an external\n\t * `reloadCredentials`, and an applied external auth status;\n\t * - provider registrations — `registerProvider`, `registerNativeProvider`,\n\t * and `unregisterProvider`, through the refresh they schedule;\n\t * - models.json content — provider `baseUrl`, `apiKey`, `api`, headers,\n\t * model definitions, and overrides, which every pass reloads.\n\t *\n\t * The first two are this runtime's own writes and bump where they happen.\n\t * The third is an external edit nothing here observes, so reading the\n\t * generation samples the file and bumps when its content moved since the\n\t * last sample. That read is synchronous so the answer belongs to the same\n\t * tick as the decision that depends on it, and it hashes content rather\n\t * than trusting an mtime: a same-size rewrite inside one filesystem\n\t * timestamp tick — an edited key, a renamed model — is exactly the change a\n\t * shared pass must not hide.\n\t */\n\tgetCatalogInputsGeneration(): number {\n\t\tthis.observeModelsFile();\n\t\treturn this.catalogInputsGeneration;\n\t}\n\n\t/**\n\t * Record that an input a catalog refresh reads changed. Every pass started\n\t * before this call answers for inputs that no longer exist.\n\t */\n\tprivate markCatalogInputsChanged(): void {\n\t\tthis.catalogInputsGeneration += 1;\n\t}\n\n\t/** Bump the generation when models.json changed since the last observation. */\n\tprivate observeModelsFile(): void {\n\t\tconst token = this.readModelsFileToken();\n\t\tif (this.observedModelsFileToken === token) return;\n\t\tconst first = this.observedModelsFileToken === undefined;\n\t\tthis.observedModelsFileToken = token;\n\t\t// The first observation is a baseline, not a change: no pass can predate it.\n\t\tif (!first) this.markCatalogInputsChanged();\n\t}\n\n\tprivate readModelsFileToken(): string {\n\t\tif (!this.modelsPath) return \"none\";\n\t\ttry {\n\t\t\treturn createHash(\"sha1\")\n\t\t\t\t.update(readFileSync(normalizePath(this.modelsPath)))\n\t\t\t\t.digest(\"hex\");\n\t\t} catch (error) {\n\t\t\tconst code = (error as NodeJS.ErrnoException).code;\n\t\t\t// An absent file is a stable state passes can share; any other read\n\t\t\t// failure keys on its own code rather than pretending the file is empty.\n\t\t\treturn code === \"ENOENT\" ? \"absent\" : `unreadable:${code ?? \"unknown\"}`;\n\t\t}\n\t}\n\n\t/** Reload credentials changed by the authoritative isolated engine and update auth status snapshots. */\n\tasync reloadCredentials(options: { refreshAvailability?: boolean } = {}): Promise<void> {\n\t\tawait this.credentials.reload();\n\t\tthis.markCatalogInputsChanged();\n\t\tif (options.refreshAvailability === false) {\n\t\t\tconst credentials = await this.credentials.list();\n\t\t\tfor (const credential of credentials) this.externalProviderAuthStatuses.delete(credential.providerId);\n\t\t\tthis.snapshotGeneration += 1;\n\t\t\tthis.snapshot = replaceStoredCredentialProviders(this.snapshot, credentials);\n\t\t\treturn;\n\t\t}\n\t\tawait this.queueAvailabilityRefresh();\n\t}\n\n\tprivate assertCredentialRefreshSucceeded(\n\t\tproviderId: string,\n\t\tresult: ModelsRefreshResult,\n\t\tsignal?: AbortSignal,\n\t): void {\n\t\tif (result.aborted) {\n\t\t\tsignal?.throwIfAborted();\n\t\t\tthrow new Error(`Model refresh aborted for ${providerId}`);\n\t\t}\n\t\tconst refreshError = result.errors.get(providerId);\n\t\tif (refreshError) throw refreshError;\n\t\tconst compositionError = this.compositionErrors.get(providerId);\n\t\tif (compositionError) throw new Error(compositionError);\n\t}\n\n\tprivate enqueueCredentialOperation<T>(providerId: string, signal: AbortSignal, task: () => Promise<T>): Promise<T> {\n\t\tconst previous = this.credentialOperations.get(providerId) ?? Promise.resolve();\n\t\tlet markStarted: (() => void) | undefined;\n\t\tconst started = new Promise<void>((resolve) => {\n\t\t\tmarkStarted = resolve;\n\t\t});\n\t\tconst operation = (async () => {\n\t\t\tawait previous.catch(() => {});\n\t\t\tsignal.throwIfAborted();\n\t\t\tmarkStarted?.();\n\t\t\treturn task();\n\t\t})();\n\t\tconst tail = operation.catch(() => {});\n\t\tthis.credentialOperations.set(providerId, tail);\n\t\tvoid tail.then(() => {\n\t\t\tif (this.credentialOperations.get(providerId) === tail) this.credentialOperations.delete(providerId);\n\t\t});\n\t\treturn raceWithAbortSignal(started, signal).then(() => operation);\n\t}\n\tprivate async synchronizeCredentialState(\n\t\tproviderId: string,\n\t\toperation: CredentialSynchronizationOperation,\n\t\tcredential: Credential | undefined,\n\t\tsynchronize: () => void | Promise<void>,\n\t): Promise<void> {\n\t\ttry {\n\t\t\tawait synchronize();\n\t\t} catch (cause) {\n\t\t\tif (cause instanceof CredentialSynchronizationError) throw cause;\n\t\t\tthrow new CredentialSynchronizationError(providerId, operation, credential, { cause });\n\t\t}\n\t}\n\tprivate async refreshRemainingAuthAfterLogout(providerId: string, logoutGeneration: number): Promise<void> {\n\t\t// Environment/runtime auth can remain after stored auth is removed. The\n\t\t// probe is normally synchronous, but its deadline is authoritative because\n\t\t// extension checks are third-party code and need not honor cancellation.\n\t\tlet timeout: number | undefined;\n\t\ttry {\n\t\t\tconst remainingAuth = await Promise.race([\n\t\t\t\tthis.checkAuth(providerId).catch(() => undefined),\n\t\t\t\tnew Promise<undefined>((resolve) => {\n\t\t\t\t\ttimeout = setTimeout(resolve, POST_LOGOUT_AUTH_CHECK_TIMEOUT_MS);\n\t\t\t\t}),\n\t\t\t]);\n\t\t\tif (logoutGeneration === this.snapshotGeneration && !this.snapshot.storedProviders.has(providerId)) {\n\t\t\t\tthis.snapshot = removeStoredCredentialProvider(this.snapshot, providerId, remainingAuth);\n\t\t\t}\n\t\t} finally {\n\t\t\tif (timeout) clearTimeout(timeout);\n\t\t}\n\t}\n\n\tasync saveCredential(providerId: string, credential: Credential): Promise<void> {\n\t\tconst signal = operationSignal(undefined);\n\t\tawait this.enqueueCredentialOperation(providerId, signal, async () => {\n\t\t\tawait this.credentials.modify(providerId, async () => credential);\n\t\t\tthis.markCatalogInputsChanged();\n\t\t\tawait this.synchronizeCredentialState(providerId, \"saveCredential\", credential, async () => {\n\t\t\t\tconst result = await this.refresh({ providers: [providerId] });\n\t\t\t\tthis.assertCredentialRefreshSucceeded(providerId, result);\n\t\t\t});\n\t\t});\n\t}\n\t/**\n\t * Apply a process-scoped API key override. This publishes the provider against\n\t * the current snapshot and deliberately does not refresh the model catalog;\n\t * callers needing catalog freshness call refresh({ providers: [providerId], signal })\n\t * separately.\n\t */\n\tasync setRuntimeApiKey(providerId: string, apiKey: string, options: AuthOperationOptions): Promise<void> {\n\t\tconst signal = operationSignal(options.signal);\n\t\tawait this.enqueueCredentialOperation(providerId, signal, async () => {\n\t\t\tthis.credentials.setRuntimeApiKey(providerId, apiKey);\n\t\t\tthis.markCatalogInputsChanged();\n\t\t\tawait this.synchronizeCredentialState(providerId, \"setRuntimeApiKey\", { type: \"api_key\", key: apiKey }, () => {\n\t\t\t\tthis.snapshot = addRuntimeApiKeyProvider(this.snapshot, providerId);\n\t\t\t});\n\t\t});\n\t}\n\n\tasync removeRuntimeApiKey(providerId: string, options: AuthOperationOptions = {}): Promise<void> {\n\t\tconst signal = operationSignal(options.signal);\n\t\tawait this.enqueueCredentialOperation(providerId, signal, async () => {\n\t\t\tthis.credentials.removeRuntimeApiKey(providerId);\n\t\t\tthis.markCatalogInputsChanged();\n\t\t\tawait this.synchronizeCredentialState(providerId, \"removeRuntimeApiKey\", undefined, async () => {\n\t\t\t\tconst result = await this.refresh({ allowNetwork: this.modelNetworkEnabled, signal });\n\t\t\t\tthis.assertCredentialRefreshSucceeded(providerId, result, signal);\n\t\t\t});\n\t\t});\n\t}\n\n\tlistCredentials(): Promise<readonly CredentialInfo[]> {\n\t\treturn this.credentials.list();\n\t}\n\n\tgetStoredCredentialType(providerId: string): CredentialInfo[\"type\"] | undefined {\n\t\treturn this.snapshot.storedCredentialTypes.get(providerId);\n\t}\n\n\tgetProviderAuthStatus(providerId: string): AuthStatus {\n\t\tconst localStatus = getSnapshotProviderAuthStatus(\n\t\t\tthis.snapshot,\n\t\t\tproviderId,\n\t\t\tthis.credentials.hasRuntimeApiKey(providerId),\n\t\t\tconfiguredRequestAuthStatus(this.config.getProvider(providerId), this.extensionProviders.get(providerId)),\n\t\t);\n\t\tif (localStatus.source === \"stored\" || localStatus.source === \"runtime\") return localStatus;\n\t\treturn this.externalProviderAuthStatuses.get(providerId) ?? localStatus;\n\t}\n\n\t/** Apply authoritative auth state returned by an isolated engine mutation. */\n\tapplyExternalProviderAuthStatus(providerId: string, status: AuthStatus): void {\n\t\tthis.markCatalogInputsChanged();\n\t\tthis.snapshotGeneration += 1;\n\t\tconst remainingAuth =\n\t\t\tstatus.configured && status.source === \"environment\"\n\t\t\t\t? ({ type: \"api_key\", source: status.label ?? \"environment\" } as const)\n\t\t\t\t: undefined;\n\t\tthis.snapshot = removeStoredCredentialProvider(this.snapshot, providerId, remainingAuth);\n\t\tthis.externalProviderAuthStatuses.set(providerId, status);\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\treturn this.streaming.stream(model, context, options);\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.streaming.complete(model, context, options);\n\t}\n\n\tstreamSimple(model: Model<Api>, context: Context, options?: ModelsSimpleStreamOptions): AssistantMessageEventStream {\n\t\treturn this.streaming.streamSimple(model, context, options);\n\t}\n\n\tcompleteSimple(model: Model<Api>, context: Context, options?: ModelsSimpleStreamOptions): Promise<AssistantMessage> {\n\t\treturn this.streaming.completeSimple(model, context, options);\n\t}\n\n\tfetchDeferred(\n\t\tmodel: Model<Api>,\n\t\thandle: DeferredHandle,\n\t\toptions?: ModelsDeferredFetchOptions,\n\t): Promise<AssistantMessage> {\n\t\treturn this.streaming.fetchDeferred(model, handle, options);\n\t}\n\n\tcancelDeferred(model: Model<Api>, handle: DeferredHandle, options?: ModelsDeferredCancelOptions): Promise<void> {\n\t\treturn this.streaming.cancelDeferred(model, handle, options);\n\t}\n\n\tasync login(providerId: string, type: AuthType, interaction: AuthInteraction): Promise<Credential> {\n\t\tconst signal = operationSignal(interaction.signal);\n\t\treturn this.enqueueCredentialOperation(providerId, signal, async () => {\n\t\t\tconst credential = await this.models.login(providerId, type, { ...interaction, signal });\n\t\t\tthis.markCatalogInputsChanged();\n\t\t\tawait this.synchronizeCredentialState(providerId, \"login\", credential, () => {\n\t\t\t\t// Credential acquisition and persistence are the login transaction. Publish\n\t\t\t\t// the provider against the current snapshot immediately; catalog restoration,\n\t\t\t\t// ambient availability checks, and networking belong to /model's bounded\n\t\t\t\t// background refresh and must never keep a successful login dialog open.\n\t\t\t\tthis.updateModelSnapshot();\n\t\t\t\tthis.externalProviderAuthStatuses.delete(providerId);\n\t\t\t\tthis.snapshot = addStoredCredentialProvider(this.snapshot, providerId, credential.type);\n\t\t\t});\n\t\t\treturn credential;\n\t\t});\n\t}\n\n\tasync logout(providerId: string, options: AuthOperationOptions = {}): Promise<void> {\n\t\tconst signal = operationSignal(options.signal);\n\t\tconst logoutGeneration = await this.enqueueCredentialOperation(providerId, signal, async () => {\n\t\t\tawait this.models.logout(providerId, { signal });\n\t\t\tthis.markCatalogInputsChanged();\n\t\t\tlet generation = 0;\n\t\t\tawait this.synchronizeCredentialState(providerId, \"logout\", undefined, () => {\n\t\t\t\t// Reset credential-dependent compatibility projections, then publish the\n\t\t\t\t// persisted deletion without waiting for model stores or remote catalogs.\n\t\t\t\tthis.recomposeProvider(providerId);\n\t\t\t\tthis.updateModelSnapshot();\n\t\t\t\tthis.externalProviderAuthStatuses.delete(providerId);\n\t\t\t\tthis.snapshot = removeStoredCredentialProvider(this.snapshot, providerId);\n\t\t\t\tgeneration = this.snapshotGeneration;\n\t\t\t});\n\t\t\treturn generation;\n\t\t});\n\t\tawait this.refreshRemainingAuthAfterLogout(providerId, logoutGeneration);\n\t}\n\n\t/**\n\t * The network policy a refresh with an omitted `allowNetwork` resolves to.\n\t *\n\t * Callers that share one in-flight refresh key on the effective policy, so\n\t * they need the same answer `runRefresh` computes rather than a second guess\n\t * at the offline setting this runtime was created under.\n\t */\n\tisNetworkRefreshEnabled(): boolean {\n\t\treturn this.modelNetworkEnabled;\n\t}\n\tasync refresh(options: ModelsRefreshOptions = {}): Promise<ModelsRefreshResult> {\n\t\treturn this.runRefresh(options, ++this.refreshSequence);\n\t}\n\n\t/**\n\t * A registration's offline catalog pass must not publish after a newer refresh\n\t * that resolves configured credentials.\n\t *\n\t * The registration is also a catalog-input change: it adds, replaces, or drops\n\t * a provider every later pass composes from, so no pass that predates it can\n\t * answer for the provider set a caller now sees.\n\t */\n\tprivate scheduleRegistrationRefresh(): void {\n\t\tthis.markCatalogInputsChanged();\n\t\tconst sequence = ++this.refreshSequence;\n\t\tvoid this.runRefresh({ allowNetwork: false }, sequence, true);\n\t}\n\n\tprivate async runRefresh(\n\t\toptions: ModelsRefreshOptions,\n\t\tsequence: number,\n\t\tdiscardIfSuperseded = false,\n\t): Promise<ModelsRefreshResult> {\n\t\tconst config = await ModelConfig.load(this.modelsPath);\n\t\tif (discardIfSuperseded && sequence !== this.refreshSequence) {\n\t\t\treturn { aborted: true, errors: new Map<string, Error>() };\n\t\t}\n\t\tthis.config = config;\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 this.rebuildProviders();\n\t\tconst refreshOptions = { ...options, allowNetwork: options.allowNetwork ?? this.isNetworkRefreshEnabled() };\n\t\tconst result = await this.models.refresh(refreshOptions);\n\t\tconst errors = new Map(result.errors);\n\t\tthis.updateModelSnapshot();\n\t\tif (options.providers) {\n\t\t\tawait Promise.all(\n\t\t\t\t[...new Set(options.providers)].map(async (providerId) => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait this.refreshProviderAvailability(providerId, operationSignal(options.signal));\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tif (!options.signal?.aborted)\n\t\t\t\t\t\t\terrors.set(providerId, error instanceof Error ? error : new Error(String(error)));\n\t\t\t\t\t}\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.scheduleRegistrationRefresh();\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\tif (\n\t\t\tthis.snapshot.storedProviders.has(providerId) ||\n\t\t\tconfiguredRequestAuthStatus(this.config.getProvider(providerId), effective)?.configured\n\t\t) {\n\t\t\tconst configuredProviders = new Set(this.snapshot.configuredProviders).add(providerId);\n\t\t\tconst auth = new Map(this.snapshot.auth);\n\t\t\t// Provisional entry until the async refresh lands; never clobber a real check result.\n\t\t\tif (!auth.get(providerId)) {\n\t\t\t\tauth.set(providerId, {\n\t\t\t\t\ttype: effective.oauth && !effective.apiKey ? \"oauth\" : \"api_key\",\n\t\t\t\t\tsource: \"configured provider\",\n\t\t\t\t});\n\t\t\t}\n\t\t\t// A provider that was already configured has an availability result — possibly\n\t\t\t// a credential-filtered subset of its catalog, as with an additive GitHub\n\t\t\t// Copilot override — and keeps it until the refresh this registration schedules\n\t\t\t// republishes it. Only a provider this registration newly configures has no\n\t\t\t// result to keep, so only its catalog is exposed provisionally.\n\t\t\tlet available = this.snapshot.available;\n\t\t\tif (!this.snapshot.configuredProviders.has(providerId)) {\n\t\t\t\tconst preserved = new Set(available.map(snapshotModelKey));\n\t\t\t\tavailable = this.snapshot.all.filter(\n\t\t\t\t\t(model) => model.provider === providerId || preserved.has(snapshotModelKey(model)),\n\t\t\t\t);\n\t\t\t}\n\t\t\tthis.snapshot = { ...this.snapshot, auth, configuredProviders, available };\n\t\t}\n\t\tthis.scheduleRegistrationRefresh();\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.scheduleRegistrationRefresh();\n\t}\n}\n"]}
|
|
@@ -8,6 +8,7 @@ export declare class RuntimeCredentials implements CredentialStore {
|
|
|
8
8
|
removeRuntimeApiKey(providerId: string): void;
|
|
9
9
|
hasRuntimeApiKey(providerId: string): boolean;
|
|
10
10
|
reload(): Promise<void>;
|
|
11
|
+
peek(providerId: string): Credential | undefined;
|
|
11
12
|
read(providerId: string, options?: AuthOperationOptions): Promise<Credential | undefined>;
|
|
12
13
|
list(options?: AuthOperationOptions): Promise<readonly CredentialInfo[]>;
|
|
13
14
|
modify(providerId: string, fn: (current: Credential | undefined) => Promise<Credential | undefined>, options?: AuthOperationOptions): Promise<Credential | undefined>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-credentials.d.ts","sourceRoot":"","sources":["../../src/core/runtime-credentials.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,UAAU,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"runtime-credentials.d.ts","sourceRoot":"","sources":["../../src/core/runtime-credentials.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,UAAU,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAoBxG,0EAA0E;AAC1E,qBAAa,kBAAmB,YAAW,eAAe;IACzD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAkB;IACxC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA6B;IAEvD,YAAY,KAAK,EAAE,eAAe,EAEjC;IAED,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAEzD;IAED,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAE5C;IAED,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAE5C;IAEK,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAE5B;IAED,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAG/C;IAEK,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAG9F;IAEK,IAAI,CAAC,OAAO,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,SAAS,cAAc,EAAE,CAAC,CAM7E;IAED,MAAM,CACL,UAAU,EAAE,MAAM,EAClB,EAAE,EAAE,CAAC,OAAO,EAAE,UAAU,GAAG,SAAS,KAAK,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,EACxE,OAAO,CAAC,EAAE,oBAAoB,GAC5B,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAEjC;IAEK,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CAG9E;CACD"}
|
|
@@ -2,6 +2,10 @@ function getReloadableStore(store) {
|
|
|
2
2
|
const reloadable = store;
|
|
3
3
|
return typeof reloadable.reload === "function" ? reloadable : undefined;
|
|
4
4
|
}
|
|
5
|
+
function getSnapshotStore(store) {
|
|
6
|
+
const snapshotStore = store;
|
|
7
|
+
return typeof snapshotStore.peek === "function" ? snapshotStore : undefined;
|
|
8
|
+
}
|
|
5
9
|
/** Async credential store overlay for non-persistent runtime API keys. */
|
|
6
10
|
export class RuntimeCredentials {
|
|
7
11
|
constructor(store) {
|
|
@@ -20,6 +24,10 @@ export class RuntimeCredentials {
|
|
|
20
24
|
async reload() {
|
|
21
25
|
await getReloadableStore(this.store)?.reload();
|
|
22
26
|
}
|
|
27
|
+
peek(providerId) {
|
|
28
|
+
const override = this.overrides.get(providerId);
|
|
29
|
+
return override ? { type: "api_key", key: override } : getSnapshotStore(this.store)?.peek(providerId);
|
|
30
|
+
}
|
|
23
31
|
async read(providerId, options) {
|
|
24
32
|
const override = this.overrides.get(providerId);
|
|
25
33
|
return override ? { type: "api_key", key: override } : this.store.read(providerId, options);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-credentials.js","sourceRoot":"","sources":["../../src/core/runtime-credentials.ts"],"names":[],"mappings":"AAMA,SAAS,kBAAkB,CAAC,KAAsB;IACjD,MAAM,UAAU,GAAG,KAA6D,CAAC;IACjF,OAAO,OAAO,UAAU,CAAC,MAAM,KAAK,UAAU,CAAC,CAAC,CAAE,UAAwC,CAAC,CAAC,CAAC,SAAS,CAAC;AACxG,CAAC;AAED,0EAA0E;AAC1E,MAAM,OAAO,kBAAkB;IAI9B,YAAY,KAAsB;QAFjB,cAAS,GAAG,IAAI,GAAG,EAAkB,CAAC;QAGtD,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACpB,CAAC;IAED,gBAAgB,CAAC,UAAkB,EAAE,MAAc;QAClD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IACxC,CAAC;IAED,mBAAmB,CAAC,UAAkB;QACrC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACnC,CAAC;IAED,gBAAgB,CAAC,UAAkB;QAClC,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IACvC,CAAC;IAED,KAAK,CAAC,MAAM;QACX,MAAM,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IAChD,CAAC;IAED,KAAK,CAAC,IAAI,CA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";\n\ninterface ReloadableCredentialStore {\n\treload(): void | Promise<void>;\n}\n\nfunction getReloadableStore(store: CredentialStore): ReloadableCredentialStore | undefined {\n\tconst reloadable = store as CredentialStore & Partial<ReloadableCredentialStore>;\n\treturn typeof reloadable.reload === \"function\" ? (reloadable as ReloadableCredentialStore) : undefined;\n}\n\n/** Async credential store overlay for non-persistent runtime API keys. */\nexport class RuntimeCredentials implements CredentialStore {\n\tprivate readonly store: CredentialStore;\n\tprivate readonly overrides = new Map<string, string>();\n\n\tconstructor(store: CredentialStore) {\n\t\tthis.store = store;\n\t}\n\n\tsetRuntimeApiKey(providerId: string, apiKey: string): void {\n\t\tthis.overrides.set(providerId, apiKey);\n\t}\n\n\tremoveRuntimeApiKey(providerId: string): void {\n\t\tthis.overrides.delete(providerId);\n\t}\n\n\thasRuntimeApiKey(providerId: string): boolean {\n\t\treturn this.overrides.has(providerId);\n\t}\n\n\tasync reload(): Promise<void> {\n\t\tawait getReloadableStore(this.store)?.reload();\n\t}\n\n\tasync read(providerId: string, options?: AuthOperationOptions): Promise<Credential | undefined> {\n\t\tconst override = this.overrides.get(providerId);\n\t\treturn override ? { type: \"api_key\", key: override } : this.store.read(providerId, options);\n\t}\n\n\tasync list(options?: AuthOperationOptions): Promise<readonly CredentialInfo[]> {\n\t\tconst entries = new Map((await this.store.list(options)).map((entry) => [entry.providerId, entry]));\n\t\tfor (const providerId of this.overrides.keys()) {\n\t\t\tentries.set(providerId, { providerId, type: \"api_key\" });\n\t\t}\n\t\treturn [...entries.values()];\n\t}\n\n\tmodify(\n\t\tproviderId: string,\n\t\tfn: (current: Credential | undefined) => Promise<Credential | undefined>,\n\t\toptions?: AuthOperationOptions,\n\t): Promise<Credential | undefined> {\n\t\treturn this.store.modify(providerId, fn, options);\n\t}\n\n\tasync delete(providerId: string, options?: AuthOperationOptions): Promise<void> {\n\t\tthis.overrides.delete(providerId);\n\t\tawait this.store.delete(providerId, options);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":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AC,MAAM,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;CACD","sourcesContent":["import type { AuthOperationOptions, Credential, CredentialInfo, CredentialStore } from \"@bastani/pi-ai\";\n\ninterface ReloadableCredentialStore {\n\treload(): void | Promise<void>;\n}\n\nfunction getReloadableStore(store: CredentialStore): ReloadableCredentialStore | undefined {\n\tconst reloadable = store as CredentialStore & Partial<ReloadableCredentialStore>;\n\treturn typeof reloadable.reload === \"function\" ? (reloadable as ReloadableCredentialStore) : undefined;\n}\n\ninterface SnapshotCredentialStore {\n\tpeek(providerId: string): Credential | undefined;\n}\n\nfunction getSnapshotStore(store: CredentialStore): SnapshotCredentialStore | undefined {\n\tconst snapshotStore = store as CredentialStore & Partial<SnapshotCredentialStore>;\n\treturn typeof snapshotStore.peek === \"function\" ? (snapshotStore as SnapshotCredentialStore) : undefined;\n}\n\n/** Async credential store overlay for non-persistent runtime API keys. */\nexport class RuntimeCredentials implements CredentialStore {\n\tprivate readonly store: CredentialStore;\n\tprivate readonly overrides = new Map<string, string>();\n\n\tconstructor(store: CredentialStore) {\n\t\tthis.store = store;\n\t}\n\n\tsetRuntimeApiKey(providerId: string, apiKey: string): void {\n\t\tthis.overrides.set(providerId, apiKey);\n\t}\n\n\tremoveRuntimeApiKey(providerId: string): void {\n\t\tthis.overrides.delete(providerId);\n\t}\n\n\thasRuntimeApiKey(providerId: string): boolean {\n\t\treturn this.overrides.has(providerId);\n\t}\n\n\tasync reload(): Promise<void> {\n\t\tawait getReloadableStore(this.store)?.reload();\n\t}\n\n\tpeek(providerId: string): Credential | undefined {\n\t\tconst override = this.overrides.get(providerId);\n\t\treturn override ? { type: \"api_key\", key: override } : getSnapshotStore(this.store)?.peek(providerId);\n\t}\n\n\tasync read(providerId: string, options?: AuthOperationOptions): Promise<Credential | undefined> {\n\t\tconst override = this.overrides.get(providerId);\n\t\treturn override ? { type: \"api_key\", key: override } : this.store.read(providerId, options);\n\t}\n\n\tasync list(options?: AuthOperationOptions): Promise<readonly CredentialInfo[]> {\n\t\tconst entries = new Map((await this.store.list(options)).map((entry) => [entry.providerId, entry]));\n\t\tfor (const providerId of this.overrides.keys()) {\n\t\t\tentries.set(providerId, { providerId, type: \"api_key\" });\n\t\t}\n\t\treturn [...entries.values()];\n\t}\n\n\tmodify(\n\t\tproviderId: string,\n\t\tfn: (current: Credential | undefined) => Promise<Credential | undefined>,\n\t\toptions?: AuthOperationOptions,\n\t): Promise<Credential | undefined> {\n\t\treturn this.store.modify(providerId, fn, options);\n\t}\n\n\tasync delete(providerId: string, options?: AuthOperationOptions): Promise<void> {\n\t\tthis.overrides.delete(providerId);\n\t\tawait this.store.delete(providerId, options);\n\t}\n}\n"]}
|
package/dist/core/sdk.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/core/sdk.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/core/sdk.ts"],"names":[],"mappings":"AAkCA,OAAO,KAAK,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAM1F,YAAY,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrE,cAAc,kBAAkB,CAAC;AACjC,YAAY,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AA+B1F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,GAAE,yBAA8B,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAuVnH"}
|
package/dist/core/sdk.js
CHANGED
|
@@ -6,7 +6,7 @@ import { resolvePath } from "../utils/paths.js";
|
|
|
6
6
|
import { AgentSession } from "./agent-session.js";
|
|
7
7
|
import { restoreAnthropicReplayThinkingBlocks } from "./anthropic-thinking-guard.js";
|
|
8
8
|
import { formatNoModelsAvailableMessage } from "./auth-guidance.js";
|
|
9
|
-
import { shouldApplyCodexFastMode, streamWithCodexFastMode, usesChatGptCodexTransport, withChatGptCodexTransportRouting, withCodexFastModePayload, withCodexFastModeStreamOptions, } from "./codex-fast-mode.js";
|
|
9
|
+
import { isGitHubCopilotModel, shouldApplyCodexFastMode, streamWithCodexFastMode, usesChatGptCodexTransport, withChatGptCodexTransportRouting, withCodexFastModePayload, withCodexFastModeStreamOptions, } from "./codex-fast-mode.js";
|
|
10
10
|
import { DEFAULT_THINKING_LEVEL } from "./defaults.js";
|
|
11
11
|
import { convertToLlm, repairOrphanToolResults } from "./messages.js";
|
|
12
12
|
import { findInitialModel, resolveRestoredModelReference } from "./model-resolver.js";
|
|
@@ -228,7 +228,7 @@ export async function createAgentSession(options = {}) {
|
|
|
228
228
|
return filtered;
|
|
229
229
|
};
|
|
230
230
|
const extensionRunnerRef = {};
|
|
231
|
-
const isCodexFastModeEnabled = (requestModel) => shouldApplyCodexFastMode(requestModel, settingsManager.getCodexFastModeSettings(), options.orchestrationContext);
|
|
231
|
+
const isCodexFastModeEnabled = (requestModel) => shouldApplyCodexFastMode(requestModel, settingsManager.getCodexFastModeSettings(), options.orchestrationContext, modelRuntime.getCredentialSnapshot("github-copilot"));
|
|
232
232
|
agent = new Agent({
|
|
233
233
|
initialState: {
|
|
234
234
|
systemPrompt: "",
|
|
@@ -270,7 +270,7 @@ export async function createAgentSession(options = {}) {
|
|
|
270
270
|
const transportHeaders = usesExtensionStream
|
|
271
271
|
? assembledHeaders
|
|
272
272
|
: removeUnownedModelHeaders(assembledHeaders, model.headers, requestHeaders);
|
|
273
|
-
if (fastModeEnabled && !usesExtensionStream && !authResult) {
|
|
273
|
+
if (fastModeEnabled && !isGitHubCopilotModel(model) && !usesExtensionStream && !authResult) {
|
|
274
274
|
throw new Error(`No API key found for "${model.provider}"`);
|
|
275
275
|
}
|
|
276
276
|
const codexFastModeStreamOptions = withCodexFastModeStreamOptions(requestModel, {
|
|
@@ -287,7 +287,7 @@ export async function createAgentSession(options = {}) {
|
|
|
287
287
|
if (usesExtensionStream) {
|
|
288
288
|
return modelRuntime.streamSimple(requestModel, context, codexFastModeStreamOptions);
|
|
289
289
|
}
|
|
290
|
-
if (fastModeEnabled) {
|
|
290
|
+
if (fastModeEnabled && !isGitHubCopilotModel(requestModel)) {
|
|
291
291
|
return streamWithCodexFastMode(requestModel, context, codexFastModeStreamOptions);
|
|
292
292
|
}
|
|
293
293
|
const transportOptions = usesChatGptCodexTransport(requestModel) && codexFastModeStreamOptions
|
|
@@ -297,7 +297,7 @@ export async function createAgentSession(options = {}) {
|
|
|
297
297
|
},
|
|
298
298
|
onPayload: async (payload, model) => {
|
|
299
299
|
const fastModeEnabled = isCodexFastModeEnabled(model);
|
|
300
|
-
const guardedPayload = withCodexFastModePayload(payload, fastModeEnabled);
|
|
300
|
+
const guardedPayload = withCodexFastModePayload(payload, fastModeEnabled, model);
|
|
301
301
|
const sourceMessages = lastConvertedLlmMessages;
|
|
302
302
|
const replayGuardedPayload = sourceMessages
|
|
303
303
|
? restoreAnthropicReplayThinkingBlocks(guardedPayload, sourceMessages, model)
|