@bastani/atomic 0.9.14 → 0.9.15
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 +45 -0
- package/README.md +1 -1
- package/dist/builtin/intercom/package.json +2 -2
- package/dist/builtin/mcp/CHANGELOG.md +14 -0
- package/dist/builtin/mcp/package.json +4 -4
- package/dist/builtin/mcp/sampling-handler.ts +2 -2
- package/dist/builtin/mcp/types.ts +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +40 -0
- package/dist/builtin/subagents/README.md +5 -22
- package/dist/builtin/subagents/agents/code-simplifier.md +2 -2
- package/dist/builtin/subagents/agents/codebase-analyzer.md +2 -2
- package/dist/builtin/subagents/agents/codebase-locator.md +2 -2
- package/dist/builtin/subagents/agents/codebase-online-researcher.md +2 -2
- package/dist/builtin/subagents/agents/codebase-pattern-finder.md +2 -2
- package/dist/builtin/subagents/agents/codebase-research-analyzer.md +2 -2
- package/dist/builtin/subagents/agents/codebase-research-locator.md +2 -2
- package/dist/builtin/subagents/agents/worker.md +2 -2
- package/dist/builtin/subagents/package.json +4 -4
- package/dist/builtin/subagents/skills/subagent/SKILL.md +6 -6
- package/dist/builtin/subagents/src/agents/agent-loaders.ts +0 -4
- package/dist/builtin/subagents/src/agents/agent-management-helpers.ts +1 -12
- package/dist/builtin/subagents/src/agents/agent-management.ts +0 -1
- package/dist/builtin/subagents/src/agents/agent-serializer.ts +7 -6
- package/dist/builtin/subagents/src/agents/agent-types.ts +0 -1
- package/dist/builtin/subagents/src/extension/schemas.ts +2 -2
- package/dist/builtin/subagents/src/extension/startup-maintenance.ts +2 -2
- package/dist/builtin/subagents/src/intercom/result-intercom.ts +0 -127
- package/dist/builtin/subagents/src/runs/foreground/inprocess-run-sync.ts +1 -3
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-context.ts +15 -106
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel-task.ts +0 -3
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel.ts +2 -13
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-single.ts +2 -12
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-status.ts +1 -20
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-types.ts +0 -6
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor.ts +10 -21
- package/dist/builtin/subagents/src/runs/inprocess/attempt-handles.ts +104 -0
- package/dist/builtin/subagents/src/runs/inprocess/index.ts +10 -21
- package/dist/builtin/subagents/src/runs/inprocess/prompt-behavior.ts +2 -3
- package/dist/builtin/subagents/src/runs/inprocess/runner.ts +11 -32
- package/dist/builtin/subagents/src/runs/inprocess/runtime-support/temp-cleanup.ts +69 -0
- package/dist/builtin/subagents/src/shared/model-resolution.ts +1 -1
- package/dist/builtin/subagents/src/shared/types-config.ts +0 -4
- package/dist/builtin/subagents/src/shared/types-depth.ts +15 -103
- package/dist/builtin/subagents/src/shared/types-foreground-state.ts +56 -0
- package/dist/builtin/subagents/src/shared/types-results.ts +1 -59
- package/dist/builtin/subagents/src/shared/types-runtime.ts +0 -2
- package/dist/builtin/subagents/src/shared/types.ts +1 -1
- package/dist/builtin/subagents/src/shared/utils.ts +1 -1
- package/dist/builtin/subagents/src/slash/slash-live-state.ts +1 -1
- package/dist/builtin/web-access/package.json +2 -2
- package/dist/builtin/web-access/summary-review.ts +2 -2
- package/dist/builtin/web-access/web-search-summary.ts +2 -2
- package/dist/builtin/workflows/CHANGELOG.md +30 -0
- package/dist/builtin/workflows/README.md +2 -2
- package/dist/builtin/workflows/package.json +2 -2
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +60473 -401
- package/dist/builtin/workflows/src/extension/public-types.ts +1 -1
- package/dist/builtin/workflows/src/extension/wiring.ts +1 -1
- package/dist/builtin/workflows/src/extension/workflow-heartbeat-delivery.ts +48 -4
- package/dist/builtin/workflows/src/extension/workflow-tool.ts +1 -1
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-factory.ts +5 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-controller.ts +35 -2
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-options.ts +1 -1
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-pause.ts +6 -0
- package/dist/builtin/workflows/src/tui/chat-surface-message.ts +15 -13
- package/dist/builtin/workflows/src/tui/store-widget-installer.ts +25 -2
- package/dist/bun/cli.js +1 -1
- package/dist/bun/cli.js.map +1 -1
- package/dist/bun/register-bedrock.js +2 -2
- package/dist/bun/register-bedrock.js.map +1 -1
- package/dist/cli/auth-check.d.ts +1 -1
- package/dist/cli/auth-check.d.ts.map +1 -1
- package/dist/cli/auth-check.js +1 -1
- package/dist/cli/auth-check.js.map +1 -1
- package/dist/cli/credential-print.d.ts +1 -1
- package/dist/cli/credential-print.d.ts.map +1 -1
- package/dist/cli/credential-print.js +2 -2
- package/dist/cli/credential-print.js.map +1 -1
- package/dist/cli/file-processor.d.ts +1 -1
- package/dist/cli/file-processor.d.ts.map +1 -1
- package/dist/cli/file-processor.js.map +1 -1
- package/dist/cli/initial-message.d.ts +1 -1
- package/dist/cli/initial-message.d.ts.map +1 -1
- package/dist/cli/initial-message.js.map +1 -1
- package/dist/cli/list-models.js.map +1 -1
- package/dist/core/agent-session-auto-compaction.d.ts +1 -1
- package/dist/core/agent-session-auto-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-auto-compaction.js +1 -1
- package/dist/core/agent-session-auto-compaction.js.map +1 -1
- package/dist/core/agent-session-events.d.ts +1 -1
- package/dist/core/agent-session-events.d.ts.map +1 -1
- package/dist/core/agent-session-events.js +1 -1
- package/dist/core/agent-session-events.js.map +1 -1
- package/dist/core/agent-session-export.js.map +1 -1
- package/dist/core/agent-session-extension-bindings.js +1 -1
- package/dist/core/agent-session-extension-bindings.js.map +1 -1
- package/dist/core/agent-session-message-queue.d.ts +1 -1
- package/dist/core/agent-session-message-queue.d.ts.map +1 -1
- package/dist/core/agent-session-message-queue.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +2 -2
- package/dist/core/agent-session-methods.d.ts.map +1 -1
- package/dist/core/agent-session-methods.js.map +1 -1
- package/dist/core/agent-session-models.d.ts +2 -2
- package/dist/core/agent-session-models.d.ts.map +1 -1
- package/dist/core/agent-session-models.js +2 -2
- package/dist/core/agent-session-models.js.map +1 -1
- package/dist/core/agent-session-prompt.d.ts +1 -1
- package/dist/core/agent-session-prompt.d.ts.map +1 -1
- package/dist/core/agent-session-prompt.js.map +1 -1
- package/dist/core/agent-session-retry.d.ts +1 -1
- package/dist/core/agent-session-retry.d.ts.map +1 -1
- package/dist/core/agent-session-retry.js +1 -1
- package/dist/core/agent-session-retry.js.map +1 -1
- package/dist/core/agent-session-runtime-auth.js +1 -1
- package/dist/core/agent-session-runtime-auth.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts +1 -1
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +1 -1
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +1 -1
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session-state.d.ts +1 -1
- package/dist/core/agent-session-state.d.ts.map +1 -1
- package/dist/core/agent-session-state.js.map +1 -1
- package/dist/core/agent-session-tree.js.map +1 -1
- package/dist/core/agent-session-types.d.ts +1 -1
- package/dist/core/agent-session-types.d.ts.map +1 -1
- package/dist/core/agent-session-types.js.map +1 -1
- package/dist/core/agent-session.d.ts +1 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/anthropic-thinking-guard.d.ts +1 -1
- package/dist/core/anthropic-thinking-guard.d.ts.map +1 -1
- package/dist/core/anthropic-thinking-guard.js +1 -1
- package/dist/core/anthropic-thinking-guard.js.map +1 -1
- package/dist/core/auth-storage.d.ts +1 -1
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/cache-stats.d.ts +1 -1
- package/dist/core/cache-stats.d.ts.map +1 -1
- package/dist/core/cache-stats.js.map +1 -1
- package/dist/core/cloudflare-gateway-binding.d.ts +1 -1
- package/dist/core/cloudflare-gateway-binding.d.ts.map +1 -1
- package/dist/core/cloudflare-gateway-binding.js +1 -1
- package/dist/core/cloudflare-gateway-binding.js.map +1 -1
- package/dist/core/codex-fast-mode.d.ts +2 -2
- package/dist/core/codex-fast-mode.d.ts.map +1 -1
- package/dist/core/codex-fast-mode.js +3 -2
- package/dist/core/codex-fast-mode.js.map +1 -1
- package/dist/core/compaction/branch-summarization.d.ts +2 -2
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +2 -2
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction-runner.d.ts +2 -2
- package/dist/core/compaction/compaction-runner.d.ts.map +1 -1
- package/dist/core/compaction/compaction-runner.js.map +1 -1
- package/dist/core/compaction/compaction-types.d.ts +2 -2
- package/dist/core/compaction/compaction-types.d.ts.map +1 -1
- package/dist/core/compaction/compaction-types.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +1 -1
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/compaction/fallback-planner.d.ts +1 -1
- package/dist/core/compaction/fallback-planner.d.ts.map +1 -1
- package/dist/core/compaction/fallback-planner.js.map +1 -1
- package/dist/core/compaction/planner-outcome.d.ts +1 -1
- package/dist/core/compaction/planner-outcome.d.ts.map +1 -1
- package/dist/core/compaction/planner-outcome.js +1 -1
- package/dist/core/compaction/planner-outcome.js.map +1 -1
- package/dist/core/compaction/range-planner-diagnostics.d.ts +1 -1
- package/dist/core/compaction/range-planner-diagnostics.d.ts.map +1 -1
- package/dist/core/compaction/range-planner-diagnostics.js +1 -1
- package/dist/core/compaction/range-planner-diagnostics.js.map +1 -1
- package/dist/core/compaction/range-planner.d.ts +2 -2
- package/dist/core/compaction/range-planner.d.ts.map +1 -1
- package/dist/core/compaction/range-planner.js +2 -2
- package/dist/core/compaction/range-planner.js.map +1 -1
- package/dist/core/compaction/session-summarization.d.ts +2 -2
- package/dist/core/compaction/session-summarization.d.ts.map +1 -1
- package/dist/core/compaction/session-summarization.js +2 -2
- package/dist/core/compaction/session-summarization.js.map +1 -1
- package/dist/core/compaction/transcript-serialization.d.ts +1 -1
- package/dist/core/compaction/transcript-serialization.d.ts.map +1 -1
- package/dist/core/compaction/transcript-serialization.js.map +1 -1
- package/dist/core/compaction/utils.d.ts +1 -1
- package/dist/core/compaction/utils.d.ts.map +1 -1
- package/dist/core/compaction/utils.js.map +1 -1
- package/dist/core/experimental.d.ts +1 -1
- package/dist/core/experimental.d.ts.map +1 -1
- package/dist/core/experimental.js.map +1 -1
- package/dist/core/export-html/tool-renderer.js.map +1 -1
- package/dist/core/extensions/agent-events.d.ts +2 -2
- package/dist/core/extensions/agent-events.d.ts.map +1 -1
- package/dist/core/extensions/agent-events.js.map +1 -1
- package/dist/core/extensions/api-types.d.ts +2 -2
- package/dist/core/extensions/api-types.d.ts.map +1 -1
- package/dist/core/extensions/api-types.js.map +1 -1
- package/dist/core/extensions/context-types.d.ts +1 -7
- 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/event-results.d.ts +1 -1
- package/dist/core/extensions/event-results.d.ts.map +1 -1
- package/dist/core/extensions/event-results.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-api.js.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.js +21 -9
- package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
- package/dist/core/extensions/provider-types.d.ts +2 -2
- package/dist/core/extensions/provider-types.d.ts.map +1 -1
- package/dist/core/extensions/provider-types.js.map +1 -1
- package/dist/core/extensions/reactive-widget.d.ts +6 -0
- package/dist/core/extensions/reactive-widget.d.ts.map +1 -1
- package/dist/core/extensions/reactive-widget.js +62 -6
- package/dist/core/extensions/reactive-widget.js.map +1 -1
- package/dist/core/extensions/runner-context.d.ts +1 -1
- package/dist/core/extensions/runner-context.d.ts.map +1 -1
- package/dist/core/extensions/runner-context.js.map +1 -1
- package/dist/core/extensions/runner-events.d.ts +1 -1
- package/dist/core/extensions/runner-events.d.ts.map +1 -1
- package/dist/core/extensions/runner-events.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +2 -2
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/runtime-types.d.ts +2 -2
- package/dist/core/extensions/runtime-types.d.ts.map +1 -1
- package/dist/core/extensions/runtime-types.js.map +1 -1
- package/dist/core/extensions/tool-events.d.ts +1 -1
- package/dist/core/extensions/tool-events.d.ts.map +1 -1
- package/dist/core/extensions/tool-events.js.map +1 -1
- package/dist/core/extensions/tool-types.d.ts +2 -2
- package/dist/core/extensions/tool-types.d.ts.map +1 -1
- package/dist/core/extensions/tool-types.js.map +1 -1
- package/dist/core/extensions/ui-types.d.ts +2 -0
- package/dist/core/extensions/ui-types.d.ts.map +1 -1
- package/dist/core/extensions/ui-types.js.map +1 -1
- package/dist/core/fallback-models.d.ts +1 -1
- package/dist/core/fallback-models.d.ts.map +1 -1
- package/dist/core/fallback-models.js.map +1 -1
- package/dist/core/http-dispatcher.d.ts.map +1 -1
- package/dist/core/http-dispatcher.js +14 -0
- package/dist/core/http-dispatcher.js.map +1 -1
- package/dist/core/messages.d.ts +1 -1
- package/dist/core/messages.d.ts.map +1 -1
- package/dist/core/messages.js.map +1 -1
- package/dist/core/model-capabilities.d.ts +1 -1
- package/dist/core/model-capabilities.d.ts.map +1 -1
- package/dist/core/model-capabilities.js.map +1 -1
- package/dist/core/model-fallback-failures.d.ts.map +1 -1
- package/dist/core/model-fallback-failures.js +18 -1
- package/dist/core/model-fallback-failures.js.map +1 -1
- package/dist/core/model-registry.d.ts +1 -1
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver-cli.js.map +1 -1
- package/dist/core/model-resolver-defaults.d.ts +1 -1
- package/dist/core/model-resolver-defaults.d.ts.map +1 -1
- package/dist/core/model-resolver-defaults.js +1 -1
- package/dist/core/model-resolver-defaults.js.map +1 -1
- package/dist/core/model-resolver-initial.d.ts +1 -1
- package/dist/core/model-resolver-initial.d.ts.map +1 -1
- package/dist/core/model-resolver-initial.js.map +1 -1
- package/dist/core/model-resolver-patterns.d.ts +1 -1
- package/dist/core/model-resolver-patterns.d.ts.map +1 -1
- package/dist/core/model-resolver-patterns.js.map +1 -1
- package/dist/core/model-resolver-scope.d.ts +1 -1
- package/dist/core/model-resolver-scope.d.ts.map +1 -1
- package/dist/core/model-resolver-scope.js +1 -1
- package/dist/core/model-resolver-scope.js.map +1 -1
- package/dist/core/model-resolver-types.d.ts +1 -1
- package/dist/core/model-resolver-types.d.ts.map +1 -1
- package/dist/core/model-resolver-types.js.map +1 -1
- package/dist/core/model-runtime-auth.d.ts +1 -1
- package/dist/core/model-runtime-auth.d.ts.map +1 -1
- package/dist/core/model-runtime-auth.js.map +1 -1
- package/dist/core/model-runtime-providers.d.ts +2 -2
- package/dist/core/model-runtime-providers.d.ts.map +1 -1
- package/dist/core/model-runtime-providers.js +2 -2
- package/dist/core/model-runtime-providers.js.map +1 -1
- package/dist/core/model-runtime-restoration.d.ts +1 -1
- package/dist/core/model-runtime-restoration.d.ts.map +1 -1
- package/dist/core/model-runtime-restoration.js.map +1 -1
- package/dist/core/model-runtime-snapshot.d.ts +1 -1
- package/dist/core/model-runtime-snapshot.d.ts.map +1 -1
- package/dist/core/model-runtime-snapshot.js.map +1 -1
- package/dist/core/model-runtime-streaming.d.ts +1 -1
- package/dist/core/model-runtime-streaming.d.ts.map +1 -1
- package/dist/core/model-runtime-streaming.js +1 -1
- package/dist/core/model-runtime-streaming.js.map +1 -1
- package/dist/core/model-runtime-types.d.ts +1 -1
- package/dist/core/model-runtime-types.d.ts.map +1 -1
- package/dist/core/model-runtime-types.js.map +1 -1
- package/dist/core/model-runtime.d.ts +8 -1
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +15 -3
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/models-store.d.ts +1 -1
- package/dist/core/models-store.d.ts.map +1 -1
- package/dist/core/models-store.js.map +1 -1
- package/dist/core/oauth-login.d.ts +1 -1
- package/dist/core/oauth-login.d.ts.map +1 -1
- package/dist/core/oauth-login.js.map +1 -1
- package/dist/core/oauth-provider-metadata.d.ts +1 -1
- package/dist/core/oauth-provider-metadata.d.ts.map +1 -1
- package/dist/core/oauth-provider-metadata.js.map +1 -1
- package/dist/core/openai-responses-payload-sanitizer.d.ts +1 -1
- package/dist/core/openai-responses-payload-sanitizer.d.ts.map +1 -1
- package/dist/core/openai-responses-payload-sanitizer.js.map +1 -1
- package/dist/core/provider-attribution.d.ts +1 -1
- package/dist/core/provider-attribution.d.ts.map +1 -1
- package/dist/core/provider-attribution.js.map +1 -1
- package/dist/core/provider-composer-internal.d.ts +1 -1
- package/dist/core/provider-composer-internal.d.ts.map +1 -1
- package/dist/core/provider-composer-internal.js.map +1 -1
- package/dist/core/provider-composer.d.ts +1 -1
- package/dist/core/provider-composer.d.ts.map +1 -1
- package/dist/core/provider-composer.js +2 -2
- package/dist/core/provider-composer.js.map +1 -1
- package/dist/core/provider-context-usage.d.ts.map +1 -1
- package/dist/core/provider-context-usage.js.map +1 -1
- package/dist/core/remote-catalog-provider.d.ts +1 -1
- package/dist/core/remote-catalog-provider.d.ts.map +1 -1
- package/dist/core/remote-catalog-provider.js.map +1 -1
- package/dist/core/runtime-credentials.d.ts +1 -1
- package/dist/core/runtime-credentials.d.ts.map +1 -1
- package/dist/core/runtime-credentials.js.map +1 -1
- package/dist/core/sdk-types.d.ts +1 -1
- package/dist/core/sdk-types.d.ts.map +1 -1
- package/dist/core/sdk-types.js.map +1 -1
- package/dist/core/sdk.d.ts +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +30 -6
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager-core.d.ts +2 -2
- package/dist/core/session-manager-core.d.ts.map +1 -1
- package/dist/core/session-manager-core.js.map +1 -1
- package/dist/core/session-manager-entries.d.ts +1 -1
- package/dist/core/session-manager-entries.d.ts.map +1 -1
- package/dist/core/session-manager-entries.js.map +1 -1
- package/dist/core/session-manager-list.js.map +1 -1
- package/dist/core/session-manager-types.d.ts +1 -1
- package/dist/core/session-manager-types.d.ts.map +1 -1
- package/dist/core/session-manager-types.js.map +1 -1
- package/dist/core/session-manager-validation.js +1 -1
- package/dist/core/session-manager-validation.js.map +1 -1
- package/dist/core/settings-manager-basic-accessors.d.ts +1 -0
- package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -1
- package/dist/core/settings-manager-basic-accessors.js +11 -0
- package/dist/core/settings-manager-basic-accessors.js.map +1 -1
- package/dist/core/settings-types.d.ts +2 -1
- package/dist/core/settings-types.d.ts.map +1 -1
- package/dist/core/settings-types.js.map +1 -1
- package/dist/core/summarization-retry.d.ts +1 -1
- package/dist/core/summarization-retry.d.ts.map +1 -1
- package/dist/core/summarization-retry.js.map +1 -1
- package/dist/core/tools/bash-session-environment.d.ts +1 -1
- package/dist/core/tools/bash-session-environment.d.ts.map +1 -1
- package/dist/core/tools/bash-session-environment.js.map +1 -1
- package/dist/core/tools/oversized-tool-result.d.ts +1 -1
- package/dist/core/tools/oversized-tool-result.d.ts.map +1 -1
- package/dist/core/tools/oversized-tool-result.js.map +1 -1
- package/dist/core/tools/read-url.d.ts +1 -1
- package/dist/core/tools/read-url.d.ts.map +1 -1
- package/dist/core/tools/read-url.js.map +1 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/render-utils.d.ts +1 -1
- package/dist/core/tools/render-utils.d.ts.map +1 -1
- package/dist/core/tools/render-utils.js.map +1 -1
- package/dist/core/tools/resource-selectors.d.ts +1 -1
- package/dist/core/tools/resource-selectors.d.ts.map +1 -1
- package/dist/core/tools/resource-selectors.js +2 -7
- package/dist/core/tools/resource-selectors.js.map +1 -1
- package/dist/core/typebox-compat.js +1 -1
- package/dist/core/typebox-compat.js.map +1 -1
- package/dist/core/usage-totals.d.ts +1 -1
- package/dist/core/usage-totals.d.ts.map +1 -1
- package/dist/core/usage-totals.js.map +1 -1
- package/dist/extensions/llama/provider.d.ts +1 -1
- package/dist/extensions/llama/provider.d.ts.map +1 -1
- package/dist/extensions/llama/provider.js +1 -1
- package/dist/extensions/llama/provider.js.map +1 -1
- package/dist/main-app-mode.d.ts +1 -1
- package/dist/main-app-mode.d.ts.map +1 -1
- package/dist/main-app-mode.js.map +1 -1
- package/dist/main-session-options.js +1 -1
- package/dist/main-session-options.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/chat-message-renderer.d.ts +1 -1
- package/dist/modes/interactive/components/chat-message-renderer.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-message-renderer.js.map +1 -1
- package/dist/modes/interactive/components/custom-message.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +1 -1
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-handlers.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-types.d.ts +1 -1
- package/dist/modes/interactive/components/settings-selector-types.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector-types.js.map +1 -1
- package/dist/modes/interactive/interactive-auth-routing.js +1 -1
- package/dist/modes/interactive/interactive-auth-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-deferred-startup.js +1 -1
- package/dist/modes/interactive/interactive-deferred-startup.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-context.js +26 -0
- package/dist/modes/interactive/interactive-extension-context.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-runtime.js +7 -2
- package/dist/modes/interactive/interactive-extension-runtime.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.d.ts +1 -0
- package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.js +1 -0
- package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-deps.d.ts +1 -1
- package/dist/modes/interactive/interactive-mode-deps.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-deps.js +1 -1
- package/dist/modes/interactive/interactive-mode-deps.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-helpers.js +1 -1
- package/dist/modes/interactive/interactive-mode-helpers.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.d.ts +2 -0
- package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
- package/dist/modes/interactive/model-catalog-refresh.d.ts +1 -1
- package/dist/modes/interactive/model-catalog-refresh.d.ts.map +1 -1
- package/dist/modes/interactive/model-catalog-refresh.js.map +1 -1
- package/dist/modes/interactive/streaming-assistant-message.d.ts +1 -1
- package/dist/modes/interactive/streaming-assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/streaming-assistant-message.js.map +1 -1
- package/dist/modes/interactive-engine/engine-custom-ui.d.ts +3 -0
- package/dist/modes/interactive-engine/engine-custom-ui.d.ts.map +1 -1
- package/dist/modes/interactive-engine/engine-custom-ui.js +26 -3
- package/dist/modes/interactive-engine/engine-custom-ui.js.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
- package/dist/modes/interactive-engine/remote-component.d.ts +2 -1
- package/dist/modes/interactive-engine/remote-component.d.ts.map +1 -1
- package/dist/modes/interactive-engine/remote-component.js +14 -0
- package/dist/modes/interactive-engine/remote-component.js.map +1 -1
- package/dist/modes/interactive-engine/remote-model-catalog.js.map +1 -1
- package/dist/modes/json-event.d.ts +1 -1
- package/dist/modes/json-event.d.ts.map +1 -1
- package/dist/modes/json-event.js.map +1 -1
- package/dist/modes/print-mode.d.ts +1 -1
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-client-api.d.ts +2 -2
- package/dist/modes/rpc/rpc-client-api.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client-api.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +1 -1
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-extension-ui.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-extension-ui.js +4 -1
- package/dist/modes/rpc/rpc-extension-ui.js.map +1 -1
- package/dist/modes/rpc/rpc-provider-auth.d.ts +1 -1
- package/dist/modes/rpc/rpc-provider-auth.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-provider-auth.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +2 -2
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/utils/tool-result-images.d.ts +1 -1
- package/dist/utils/tool-result-images.d.ts.map +1 -1
- package/dist/utils/tool-result-images.js.map +1 -1
- package/docs/custom-provider.md +11 -8
- package/docs/development.md +0 -2
- package/docs/extensions.md +2 -2
- package/docs/json.md +1 -1
- package/docs/models/artificial-analysis-index.md +2 -2
- package/docs/models/model-selection.md +8 -8
- package/docs/models/pareto-efficiency.md +10 -10
- package/docs/models.md +9 -3
- package/docs/packages.md +1 -1
- package/docs/providers.md +5 -3
- package/docs/quickstart.md +1 -1
- package/docs/rpc.md +1 -1
- package/docs/sdk.md +2 -2
- package/docs/session-format.md +2 -2
- package/docs/settings.md +2 -1
- package/docs/subagents.md +5 -6
- package/docs/tui.md +3 -0
- package/docs/workflows.md +3 -1
- package/examples/extensions/README.md +1 -1
- package/examples/extensions/custom-footer.ts +1 -1
- package/examples/extensions/custom-provider-anthropic/index.ts +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/index.ts +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/test.ts +1 -1
- package/examples/extensions/handoff.ts +2 -2
- package/examples/extensions/hello.ts +1 -1
- package/examples/extensions/plan-mode/index.ts +1 -1
- package/examples/extensions/preset.ts +1 -1
- package/examples/extensions/qna.ts +1 -1
- package/examples/extensions/subagent/display.ts +1 -1
- package/examples/extensions/subagent/runner.ts +1 -1
- package/examples/extensions/subagent/types.ts +1 -1
- package/examples/extensions/summarize.ts +2 -2
- package/examples/extensions/tool-override.ts +1 -1
- package/examples/sdk/02-custom-model.ts +1 -1
- package/examples/sdk/12-full-control.ts +1 -1
- package/examples/sdk/README.md +1 -1
- package/npm-shrinkwrap.json +54 -31
- package/package.json +3 -3
- package/dist/builtin/subagents/src/extension/fanout-child.ts +0 -259
- package/dist/builtin/subagents/src/runs/inprocess/nested-routing.ts +0 -218
- package/dist/builtin/subagents/src/runs/inprocess/runtime-support/nested-api.ts +0 -55
- package/dist/builtin/subagents/src/runs/inprocess/runtime-support/nested-control.ts +0 -178
- package/dist/builtin/subagents/src/runs/inprocess/runtime-support/nested-core.ts +0 -187
- package/dist/builtin/subagents/src/runs/inprocess/runtime-support/nested-paths.ts +0 -57
- package/dist/builtin/subagents/src/runs/inprocess/runtime-support/nested-projection.ts +0 -42
- package/dist/builtin/subagents/src/runs/inprocess/runtime-support/nested-registry.ts +0 -352
- package/dist/builtin/subagents/src/runs/inprocess/runtime-support/nested-rendering.ts +0 -136
- package/dist/builtin/subagents/src/runs/inprocess/runtime-support/nested-sanitize.ts +0 -252
- package/dist/builtin/subagents/src/shared/types-nested.ts +0 -127
- package/dist/core/copilot-env-routing.d.ts +0 -36
- package/dist/core/copilot-env-routing.d.ts.map +0 -1
- package/dist/core/copilot-env-routing.js +0 -94
- package/dist/core/copilot-env-routing.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-runtime-streaming.d.ts","sourceRoot":"","sources":["../../src/core/model-runtime-streaming.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,GAAG,EAER,KAAK,gBAAgB,EACrB,KAAK,2BAA2B,EAChC,KAAK,UAAU,EACf,KAAK,OAAO,EAGZ,KAAK,cAAc,EAEnB,KAAK,KAAK,EACV,KAAK,sBAAsB,EAC3B,KAAK,2BAA2B,EAChC,KAAK,0BAA0B,EAG/B,KAAK,yBAAyB,EAC9B,KAAK,aAAa,EAElB,KAAK,eAAe,EAGpB,MAAM,
|
|
1
|
+
{"version":3,"file":"model-runtime-streaming.d.ts","sourceRoot":"","sources":["../../src/core/model-runtime-streaming.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,GAAG,EAER,KAAK,gBAAgB,EACrB,KAAK,2BAA2B,EAChC,KAAK,UAAU,EACf,KAAK,OAAO,EAGZ,KAAK,cAAc,EAEnB,KAAK,KAAK,EACV,KAAK,sBAAsB,EAC3B,KAAK,2BAA2B,EAChC,KAAK,0BAA0B,EAG/B,KAAK,yBAAyB,EAC9B,KAAK,aAAa,EAElB,KAAK,eAAe,EAGpB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,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c,EACtB,OAAO,CAAC,EAAE,0BAA0B,GAClC,OAAO,CAAC,gBAAgB,CAAC,CAQ3B;IAEK,cAAc,CACnB,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,EACjB,MAAM,EAAE,cAAc,EACtB,OAAO,CAAC,EAAE,2BAA2B,GACnC,OAAO,CAAC,IAAI,CAAC,CAMf;CACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-runtime-streaming.js","sourceRoot":"","sources":["../../src/core/model-runtime-streaming.ts"],"names":[],"mappings":"AAAA,OAAO,EAUN,UAAU,EAKV,WAAW,GAQX,MAAM,
|
|
1
|
+
{"version":3,"file":"model-runtime-streaming.js","sourceRoot":"","sources":["../../src/core/model-runtime-streaming.ts"],"names":[],"mappings":"AAAA,OAAO,EAUN,UAAU,EAKV,WAAW,GAQX,MAAM,gBAAgB,CAAC;AAGxB,MAAM,UAAU,YAAY,CAC3B,IAAiC,EACjC,QAAqC;IAErC,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ;QAAE,OAAO,SAAS,CAAC;IACzC,MAAM,MAAM,GAAG,EAAE,GAAG,IAAI,EAAE,CAAC;IAC3B,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,IAAI,EAAE,CAAC,EAAE,CAAC;QAC5D,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QACrC,KAAK,MAAM,YAAY,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;YAChD,IAAI,YAAY,CAAC,WAAW,EAAE,KAAK,SAAS;gBAAE,OAAO,MAAM,CAAC,YAAY,CAAC,CAAC;QAC3E,CAAC;QACD,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;IACtB,CAAC;IACD,OAAO,MAAM,CAAC;AACf,CAAC;AAID,sGAAsG;AACtG,MAAM,OAAO,qBAAqB;IAGjC,YAAY,MAAqB,EAA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AC,MAAM,EAAE,CAAC;IAC5D,CAAC;IAED,KAAK,CAAC,aAAa,CAClB,KAAiB,EACjB,MAAsB,EACtB,OAAoC;QAEpC,OAAO,UAAU,CAAC,KAAK,EAAE,KAAK,IAAI,EAAE;YACnC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;YAC3D,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,aAAa,EAAE,CAAC;gBACtC,MAAM,IAAI,WAAW,CAAC,UAAU,EAAE,YAAY,KAAK,CAAC,QAAQ,sCAAsC,CAAC,CAAC;YACrG,CAAC;YACD,OAAO,QAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,OAA+B,CAAC,CAAC;QAC1G,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IACb,CAAC;IAED,KAAK,CAAC,cAAc,CACnB,KAAiB,EACjB,MAAsB,EACtB,OAAqC;QAErC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAC3D,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,cAAc,EAAE,CAAC;YACvC,MAAM,IAAI,WAAW,CAAC,UAAU,EAAE,YAAY,KAAK,CAAC,QAAQ,sCAAsC,CAAC,CAAC;QACrG,CAAC;QACD,MAAM,QAAQ,CAAC,QAAQ,CAAC,cAAc,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,OAAgC,CAAC,CAAC;IAC3G,CAAC;CACD","sourcesContent":["import {\n\ttype Api,\n\ttype ApiStreamOptions,\n\ttype AssistantMessage,\n\ttype AssistantMessageEventStream,\n\ttype AuthResult,\n\ttype Context,\n\ttype DeferredCancelOptions,\n\ttype DeferredFetchOptions,\n\ttype DeferredHandle,\n\tlazyStream,\n\ttype Model,\n\ttype ModelsApiStreamOptions,\n\ttype ModelsDeferredCancelOptions,\n\ttype ModelsDeferredFetchOptions,\n\tModelsError,\n\ttype ModelsRequestTransforms,\n\ttype ModelsSimpleStreamOptions,\n\ttype MutableModels,\n\ttype Provider,\n\ttype ProviderHeaders,\n\ttype SimpleStreamOptions,\n\ttype StreamOptions,\n} from \"@bastani/pi-ai\";\nimport type { ModelRuntimeAuthOverrides } from \"./model-runtime-types.ts\";\n\nexport function mergeHeaders(\n\tbase: ProviderHeaders | undefined,\n\toverride: ProviderHeaders | undefined,\n): ProviderHeaders | undefined {\n\tif (!base && !override) return undefined;\n\tconst merged = { ...base };\n\tfor (const [name, value] of Object.entries(override ?? {})) {\n\t\tconst lowerName = name.toLowerCase();\n\t\tfor (const existingName of Object.keys(merged)) {\n\t\t\tif (existingName.toLowerCase() === lowerName) delete merged[existingName];\n\t\t}\n\t\tmerged[name] = value;\n\t}\n\treturn merged;\n}\n\ntype ResolveAuth = (model: Model<Api>, overrides?: ModelRuntimeAuthOverrides) => Promise<AuthResult | undefined>;\n\n/** Streaming request preparation split from ModelRuntime solely for Atomic's 500-line source gate. */\nexport class ModelRuntimeStreaming {\n\tprivate readonly models: MutableModels;\n\tprivate readonly resolveAuth: ResolveAuth;\n\tconstructor(models: MutableModels, resolveAuth: ResolveAuth) {\n\t\tthis.models = models;\n\t\tthis.resolveAuth = resolveAuth;\n\t}\n\n\tprivate async prepareRequest(\n\t\tmodel: Model<Api>,\n\t\toptions: (StreamOptions & ModelsRequestTransforms) | undefined,\n\t): Promise<{ provider: Provider; model: Model<Api>; options: StreamOptions }> {\n\t\tconst provider = this.models.getProvider(model.provider);\n\t\tif (!provider) throw new ModelsError(\"provider\", `Unknown provider: ${model.provider}`);\n\t\tconst resolution = await this.resolveAuth(model, { apiKey: options?.apiKey, env: options?.env });\n\t\tif (!resolution) throw new ModelsError(\"auth\", `Provider is not configured: ${model.provider}`);\n\n\t\tconst { transformHeaders, ...providerOptions } = options ?? {};\n\t\tlet headers = mergeHeaders(resolution.auth.headers, providerOptions.headers);\n\t\tif (transformHeaders) headers = await transformHeaders(headers ?? {});\n\t\tconst env =\n\t\t\tresolution.env || providerOptions.env\n\t\t\t\t? { ...(resolution.env ?? {}), ...(providerOptions.env ?? {}) }\n\t\t\t\t: undefined;\n\t\treturn {\n\t\t\tprovider,\n\t\t\tmodel: resolution.auth.baseUrl ? { ...model, baseUrl: resolution.auth.baseUrl } : model,\n\t\t\toptions: {\n\t\t\t\t...providerOptions,\n\t\t\t\tapiKey: providerOptions.apiKey ?? resolution.auth.apiKey,\n\t\t\t\theaders,\n\t\t\t\tenv,\n\t\t\t},\n\t\t};\n\t}\n\n\tstream<TApi extends Api>(\n\t\tmodel: Model<TApi>,\n\t\tcontext: Context,\n\t\toptions?: ModelsApiStreamOptions<TApi>,\n\t): AssistantMessageEventStream {\n\t\treturn lazyStream(model, async () => {\n\t\t\tconst prepared = await this.prepareRequest(\n\t\t\t\tmodel,\n\t\t\t\toptions as (StreamOptions & ModelsRequestTransforms) | undefined,\n\t\t\t);\n\t\t\treturn prepared.provider.stream(\n\t\t\t\tprepared.model as Model<TApi>,\n\t\t\t\tcontext,\n\t\t\t\tprepared.options as ApiStreamOptions<TApi>,\n\t\t\t);\n\t\t});\n\t}\n\n\tcomplete<TApi extends Api>(\n\t\tmodel: Model<TApi>,\n\t\tcontext: Context,\n\t\toptions?: ModelsApiStreamOptions<TApi>,\n\t): Promise<AssistantMessage> {\n\t\treturn this.stream(model, context, options).result();\n\t}\n\n\tstreamSimple(model: Model<Api>, context: Context, options?: ModelsSimpleStreamOptions): AssistantMessageEventStream {\n\t\treturn lazyStream(model, async () => {\n\t\t\tconst prepared = await this.prepareRequest(model, options);\n\t\t\treturn prepared.provider.streamSimple(prepared.model, context, prepared.options as SimpleStreamOptions);\n\t\t});\n\t}\n\n\tcompleteSimple(model: Model<Api>, context: Context, options?: ModelsSimpleStreamOptions): Promise<AssistantMessage> {\n\t\treturn this.streamSimple(model, context, options).result();\n\t}\n\n\tasync fetchDeferred(\n\t\tmodel: Model<Api>,\n\t\thandle: DeferredHandle,\n\t\toptions?: ModelsDeferredFetchOptions,\n\t): Promise<AssistantMessage> {\n\t\treturn lazyStream(model, async () => {\n\t\t\tconst prepared = await this.prepareRequest(model, options);\n\t\t\tif (!prepared.provider.fetchDeferred) {\n\t\t\t\tthrow new ModelsError(\"provider\", `Provider ${model.provider} does not support deferred responses`);\n\t\t\t}\n\t\t\treturn prepared.provider.fetchDeferred(prepared.model, handle, prepared.options as DeferredFetchOptions);\n\t\t}).result();\n\t}\n\n\tasync cancelDeferred(\n\t\tmodel: Model<Api>,\n\t\thandle: DeferredHandle,\n\t\toptions?: ModelsDeferredCancelOptions,\n\t): Promise<void> {\n\t\tconst prepared = await this.prepareRequest(model, options);\n\t\tif (!prepared.provider.cancelDeferred) {\n\t\t\tthrow new ModelsError(\"provider\", `Provider ${model.provider} does not support deferred responses`);\n\t\t}\n\t\tawait prepared.provider.cancelDeferred(prepared.model, handle, prepared.options as DeferredCancelOptions);\n\t}\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CredentialStore, ModelsStore } from "@
|
|
1
|
+
import type { CredentialStore, ModelsStore } from "@bastani/pi-ai";
|
|
2
2
|
export interface CreateModelRuntimeOptions {
|
|
3
3
|
/** Credential storage. Defaults to the file at authPath. */
|
|
4
4
|
credentials?: CredentialStore;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-runtime-types.d.ts","sourceRoot":"","sources":["../../src/core/model-runtime-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"model-runtime-types.d.ts","sourceRoot":"","sources":["../../src/core/model-runtime-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAEnE,MAAM,WAAW,yBAAyB;IACzC,4DAA4D;IAC5D,WAAW,CAAC,EAAE,eAAe,CAAC;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,oFAAoF;IACpF,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,yDAAyD;IACzD,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,yFAAyF;IACzF,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,yBAAyB;IACzC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,kFAAkF;IAClF,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-runtime-types.js","sourceRoot":"","sources":["../../src/core/model-runtime-types.ts"],"names":[],"mappings":"","sourcesContent":["import type { CredentialStore, ModelsStore } from \"@
|
|
1
|
+
{"version":3,"file":"model-runtime-types.js","sourceRoot":"","sources":["../../src/core/model-runtime-types.ts"],"names":[],"mappings":"","sourcesContent":["import type { CredentialStore, ModelsStore } from \"@bastani/pi-ai\";\n\nexport interface CreateModelRuntimeOptions {\n\t/** Credential storage. Defaults to the file at authPath. */\n\tcredentials?: CredentialStore;\n\tauthPath?: string;\n\tmodelsPath?: string | null;\n\tmodelsStore?: ModelsStore;\n\tmodelsStorePath?: string;\n\t/** Allow create() to refresh model catalogs over the network. Defaults to false. */\n\tallowModelNetwork?: boolean;\n\t/** Timeout for the create-time network model refresh. */\n\tmodelRefreshTimeoutMs?: number;\n\t/** Skip the initial catalog and availability refresh. Static models remain available. */\n\trefreshOnCreate?: boolean;\n\tcatalogBaseUrl?: string;\n}\n\nexport interface ModelRuntimeAuthOverrides {\n\tapiKey?: string;\n\tenv?: Record<string, string>;\n\t/** Require this much remaining OAuth-token validity; defaults to five minutes. */\n\tminOAuthValidityMs?: number;\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Api, type AssistantMessage, type AssistantMessageEventStream, type AuthCheck, type AuthInteraction, type AuthOperationOptions, type AuthResult, type AuthType, type Context, type Credential, type CredentialInfo, type DeferredHandle, type Model, type Models, type ModelsApiStreamOptions, type ModelsDeferredCancelOptions, type ModelsDeferredFetchOptions, type ModelsRefreshOptions, type ModelsRefreshResult, type ModelsSimpleStreamOptions, type Provider } from "@
|
|
1
|
+
import { type Api, type AssistantMessage, type AssistantMessageEventStream, type AuthCheck, type AuthInteraction, type AuthOperationOptions, type AuthResult, type AuthType, type Context, type Credential, type CredentialInfo, type DeferredHandle, type Model, type Models, type ModelsApiStreamOptions, type ModelsDeferredCancelOptions, type ModelsDeferredFetchOptions, type ModelsRefreshOptions, type ModelsRefreshResult, type ModelsSimpleStreamOptions, type Provider } from "@bastani/pi-ai";
|
|
2
2
|
import { type AuthStatus, type CompatibilityRequestConfig, type ProviderConfigInput } from "./provider-composer.ts";
|
|
3
3
|
export type { CreateModelRuntimeOptions, ModelRuntimeAuthOverrides } from "./model-runtime-types.ts";
|
|
4
4
|
import type { CreateModelRuntimeOptions, ModelRuntimeAuthOverrides } from "./model-runtime-types.ts";
|
|
@@ -64,6 +64,13 @@ export declare class ModelRuntime implements Models {
|
|
|
64
64
|
hasConfiguredAuth(providerId: string): boolean;
|
|
65
65
|
getAuth(providerId: string, overrides?: ModelRuntimeAuthOverrides): Promise<AuthResult | undefined>;
|
|
66
66
|
getAuth(model: Model<Api>, overrides?: ModelRuntimeAuthOverrides): Promise<AuthResult | undefined>;
|
|
67
|
+
/**
|
|
68
|
+
* Resolve request-owned auth/config headers without copying the model's static
|
|
69
|
+
* catalog headers into the per-request override layer. The API provider reads
|
|
70
|
+
* static headers from the model itself; duplicating them in auth would make
|
|
71
|
+
* them override API-computed defaults that intentionally replace catalog values.
|
|
72
|
+
*/
|
|
73
|
+
getRequestAuth(model: Model<Api>, overrides?: ModelRuntimeAuthOverrides): Promise<AuthResult | undefined>;
|
|
67
74
|
/**
|
|
68
75
|
* Monotonic count of changes to any input a catalog refresh reads.
|
|
69
76
|
*
|
|
@@ -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,
|
|
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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|
|
4
|
-
import { createModels, } from "@
|
|
5
|
-
import * as builtinProviderCatalog from "@
|
|
4
|
+
import { createModels, } from "@bastani/pi-ai";
|
|
5
|
+
import * as builtinProviderCatalog from "@bastani/pi-ai/providers/all";
|
|
6
6
|
import { getAgentDir } from "../config.js";
|
|
7
7
|
import { operationSignal, raceWithAbortSignal } from "../utils/abort.js";
|
|
8
8
|
import { normalizePath } from "../utils/paths.js";
|
|
@@ -65,7 +65,7 @@ export class ModelRuntime {
|
|
|
65
65
|
for (const [providerId, provider] of this.defaultBuiltins)
|
|
66
66
|
this.builtins.set(providerId, provider);
|
|
67
67
|
this.models = createModels({ credentials, modelsStore });
|
|
68
|
-
this.streaming = new ModelRuntimeStreaming(this.models, (model, overrides) => this.
|
|
68
|
+
this.streaming = new ModelRuntimeStreaming(this.models, (model, overrides) => this.getRequestAuth(model, overrides));
|
|
69
69
|
this.rebuildProviders();
|
|
70
70
|
}
|
|
71
71
|
static async create(options = {}) {
|
|
@@ -314,6 +314,18 @@ export class ModelRuntime {
|
|
|
314
314
|
return undefined;
|
|
315
315
|
return mergeConfiguredAuthHeaders(resolution, providerOrModel, this.config, this.extensionProviders.get(providerOrModel.provider), overrides);
|
|
316
316
|
}
|
|
317
|
+
/**
|
|
318
|
+
* Resolve request-owned auth/config headers without copying the model's static
|
|
319
|
+
* catalog headers into the per-request override layer. The API provider reads
|
|
320
|
+
* static headers from the model itself; duplicating them in auth would make
|
|
321
|
+
* them override API-computed defaults that intentionally replace catalog values.
|
|
322
|
+
*/
|
|
323
|
+
async getRequestAuth(model, overrides = {}) {
|
|
324
|
+
const resolution = await this.getAuth(model.provider, overrides);
|
|
325
|
+
if (!resolution)
|
|
326
|
+
return undefined;
|
|
327
|
+
return mergeConfiguredAuthHeaders(resolution, model, this.config, this.extensionProviders.get(model.provider), overrides);
|
|
328
|
+
}
|
|
317
329
|
/**
|
|
318
330
|
* Monotonic count of changes to any input a catalog refresh reads.
|
|
319
331
|
*
|
|
@@ -1 +1 @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EAAgE;YAChE,IAAI,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC;YACxC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,mBAAmB,CAAC,GAAG,CAAC,UAAU,CAAC,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 \"@earendil-works/pi-ai\";\nimport * as builtinProviderCatalog from \"@earendil-works/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) => this.getAuth(model, overrides));\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\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,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;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,CAAC,GAAG,CAAC,UAAU,CAAC,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,4 +1,4 @@
|
|
|
1
|
-
import type { ModelsStore, ModelsStoreEntry } from "@
|
|
1
|
+
import type { ModelsStore, ModelsStoreEntry } from "@bastani/pi-ai";
|
|
2
2
|
export declare class InMemoryCodingAgentModelsStore implements ModelsStore {
|
|
3
3
|
private readonly entries;
|
|
4
4
|
read(providerId: string): Promise<ModelsStoreEntry | undefined>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"models-store.d.ts","sourceRoot":"","sources":["../../src/core/models-store.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"models-store.d.ts","sourceRoot":"","sources":["../../src/core/models-store.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAMpE,qBAAa,8BAA+B,YAAW,WAAW;IACjE,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAuC;IAEzD,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC,CAEpE;IAEK,KAAK,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAEtE;IAEK,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE9C;CACD;AAED,8EAA8E;AAC9E,qBAAa,eAAgB,YAAW,WAAW;IAClD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqB;IAE7C,YAAY,IAAI,GAAE,MAAiD,EAElE;IAED,OAAO,CAAC,KAAK;IAIP,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC,CAIpE;IAEK,KAAK,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAMtE;IAEK,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAM9C;CACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"models-store.js","sourceRoot":"","sources":["../../src/core/models-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,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AAI,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;YAClD,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YACpC,OAAO,CAAC,UAAU,CAAC,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;YAC7C,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;QACtE,CAAC,CAAC,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,UAAkB;QAC9B,MAAM,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;YAClD,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YACpC,OAAO,OAAO,CAAC,UAAU,CAAC,CAAC;YAC3B,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;QACtE,CAAC,CAAC,CAAC;IACJ,CAAC;CACD","sourcesContent":["import { join } from \"node:path\";\nimport type { ModelsStore, ModelsStoreEntry } from \"@
|
|
1
|
+
{"version":3,"file":"models-store.js","sourceRoot":"","sources":["../../src/core/models-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAA2B,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAI7F,MAAM,OAAO,8BAA8B;IAA3C;QACkB,YAAO,GAAG,IAAI,GAAG,EAA4B,CAAC;IAahE,CAAC;IAXA,KAAK,CAAC,IAAI,CAAC,UAAkB;QAC5B,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,C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QACtE,CAAC,CAAC,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,UAAkB;QAC9B,MAAM,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;YAClD,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YACpC,OAAO,OAAO,CAAC,UAAU,CAAC,CAAC;YAC3B,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;QACtE,CAAC,CAAC,CAAC;IACJ,CAAC;CACD","sourcesContent":["import { join } from \"node:path\";\nimport type { ModelsStore, ModelsStoreEntry } from \"@bastani/pi-ai\";\nimport { getAgentDir } from \"../config.ts\";\nimport { type AuthStorageBackend, FileAuthStorageBackend } from \"./auth-storage-backends.ts\";\n\ntype StoredModels = Record<string, ModelsStoreEntry>;\n\nexport class InMemoryCodingAgentModelsStore implements ModelsStore {\n\tprivate readonly entries = new Map<string, ModelsStoreEntry>();\n\n\tasync read(providerId: string): Promise<ModelsStoreEntry | undefined> {\n\t\treturn this.entries.get(providerId);\n\t}\n\n\tasync write(providerId: string, entry: ModelsStoreEntry): Promise<void> {\n\t\tthis.entries.set(providerId, entry);\n\t}\n\n\tasync delete(providerId: string): Promise<void> {\n\t\tthis.entries.delete(providerId);\n\t}\n}\n\n/** Locked JSON-backed storage for dynamically refreshed provider catalogs. */\nexport class FileModelsStore implements ModelsStore {\n\tprivate readonly storage: AuthStorageBackend;\n\n\tconstructor(path: string = join(getAgentDir(), \"models-store.json\")) {\n\t\tthis.storage = new FileAuthStorageBackend(path);\n\t}\n\n\tprivate parse(content: string | undefined): StoredModels {\n\t\treturn content ? (JSON.parse(content) as StoredModels) : {};\n\t}\n\n\tasync read(providerId: string): Promise<ModelsStoreEntry | undefined> {\n\t\treturn this.storage.withLock((content) => ({\n\t\t\tresult: structuredClone(this.parse(content)[providerId]),\n\t\t}));\n\t}\n\n\tasync write(providerId: string, entry: ModelsStoreEntry): Promise<void> {\n\t\tawait this.storage.withLockAsync(async (content) => {\n\t\t\tconst current = this.parse(content);\n\t\t\tcurrent[providerId] = structuredClone(entry);\n\t\t\treturn { result: undefined, next: JSON.stringify(current, null, 2) };\n\t\t});\n\t}\n\n\tasync delete(providerId: string): Promise<void> {\n\t\tawait this.storage.withLockAsync(async (content) => {\n\t\t\tconst current = this.parse(content);\n\t\t\tdelete current[providerId];\n\t\t\treturn { result: undefined, next: JSON.stringify(current, null, 2) };\n\t\t});\n\t}\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AuthInfoLink, AuthInteraction, OAuthLoginCallbacks } from "@
|
|
1
|
+
import type { AuthInfoLink, AuthInteraction, OAuthLoginCallbacks } from "@bastani/pi-ai";
|
|
2
2
|
export interface AtomicOAuthLoginCallbacks extends OAuthLoginCallbacks {
|
|
3
3
|
onManualCodeCancel?(): void;
|
|
4
4
|
onInfo?(message: string, links: readonly AuthInfoLink[]): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth-login.d.ts","sourceRoot":"","sources":["../../src/core/oauth-login.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"oauth-login.d.ts","sourceRoot":"","sources":["../../src/core/oauth-login.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAGzF,MAAM,WAAW,yBAA0B,SAAQ,mBAAmB;IACrE,kBAAkB,CAAC,IAAI,IAAI,CAAC;IAC5B,MAAM,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,YAAY,EAAE,GAAG,IAAI,CAAC;CAC/D;AAED,6FAA6F;AAC7F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KAAK,CAAC,GAAG,EAAE,YAAY,EAAE,KAAK,CAAC,YAAY,EAAE,CAAC,CAAC;oBACvE,MAAM;gBACP,KAAK,aAAa;oBACjB,SAAS,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;oBAC9B,MAAM;gBACP,KAAK,UAAU;oBACd,SAAS,CAAC,UAAU,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;oBACtC,MAAM;gBACP,KAAK,MAAM;oBACV,SAAS,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;oBACrD,MAAM;YACR,CAAC;QACF,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import type { AuthInfoLink, AuthInteraction, OAuthLoginCallbacks } from \"@bastani/pi-ai\";\nimport { CredentialSynchronizationError } from \"./model-runtime.js\";\n\nexport interface AtomicOAuthLoginCallbacks extends OAuthLoginCallbacks {\n\tonManualCodeCancel?(): void;\n\tonInfo?(message: string, links: readonly AuthInfoLink[]): void;\n}\n\n/** JSON-safe provider-owned OAuth metadata transported across isolated-engine boundaries. */\nexport interface OAuthProviderMetadata {\n\tid: string;\n\tname: string;\n\tloginLabel?: string;\n\tusesCallbackServer?: boolean;\n}\n\n/** Marks failures after credential acquisition so presentation never mistakes nested AbortErrors for cancellation. */\nexport class OAuthLoginTransactionError extends Error {\n\tconstructor(cause: unknown) {\n\t\tsuper(cause instanceof Error ? cause.message : String(cause), { cause });\n\t\tthis.name = \"OAuthLoginTransactionError\";\n\t}\n}\n\nexport function isOAuthLoginCancelled(\n\terror: unknown,\n\tsignal?: AbortSignal,\n\toptions: { includeActiveSignal?: boolean } = {},\n): boolean {\n\tif (error instanceof OAuthLoginTransactionError || error instanceof CredentialSynchronizationError) return false;\n\tif (options.includeActiveSignal !== false && signal?.aborted) return true;\n\tconst reason = signal?.reason;\n\tconst seen = new Set<object>();\n\tlet current: unknown = error;\n\twhile (current !== undefined && current !== null) {\n\t\tif (current === reason && reason !== undefined) return true;\n\t\tif (current === \"Login cancelled\") return true;\n\t\tif (typeof current !== \"object\") return false;\n\t\tif (seen.has(current)) return false;\n\t\tseen.add(current);\n\t\tconst candidate = current as { name?: unknown; message?: unknown; cause?: unknown };\n\t\tif (candidate.name === \"AbortError\" || candidate.message === \"Login cancelled\") return true;\n\t\tcurrent = candidate.cause;\n\t}\n\treturn false;\n}\n\nexport function normalizeOAuthLoginError(\n\terror: unknown,\n\tsignal?: AbortSignal,\n\toptions?: { includeActiveSignal?: boolean },\n): unknown {\n\tif (error instanceof Error && error.message === \"Login cancelled\" && error.cause !== undefined) return error;\n\tif (!isOAuthLoginCancelled(error, signal, options)) return error;\n\treturn new Error(\"Login cancelled\", { cause: error });\n}\n\nfunction abortable<T>(promise: Promise<T>, signal: AbortSignal | undefined, onAbort?: () => void): Promise<T> {\n\tif (!signal) return promise;\n\tif (signal.aborted) {\n\t\tonAbort?.();\n\t\treturn Promise.reject(signal.reason ?? new Error(\"Authentication prompt cancelled\"));\n\t}\n\treturn new Promise<T>((resolve, reject) => {\n\t\tconst abort = () => {\n\t\t\tonAbort?.();\n\t\t\treject(signal.reason ?? new Error(\"Authentication prompt cancelled\"));\n\t\t};\n\t\tsignal.addEventListener(\"abort\", abort, { once: true });\n\t\tpromise.then(resolve, reject).finally(() => signal.removeEventListener(\"abort\", abort));\n\t});\n}\n\nexport function createAuthInteraction(callbacks: AtomicOAuthLoginCallbacks): AuthInteraction {\n\treturn {\n\t\tsignal: callbacks.signal,\n\t\tprompt: async (prompt) => {\n\t\t\tswitch (prompt.type) {\n\t\t\t\tcase \"select\":\n\t\t\t\t\treturn (\n\t\t\t\t\t\t(await callbacks.onSelect({\n\t\t\t\t\t\t\tmessage: prompt.message,\n\t\t\t\t\t\t\toptions: prompt.options.map(({ id, label }) => ({ id, label })),\n\t\t\t\t\t\t})) ?? \"\"\n\t\t\t\t\t);\n\t\t\t\tcase \"manual_code\":\n\t\t\t\t\treturn abortable(\n\t\t\t\t\t\tcallbacks.onManualCodeInput\n\t\t\t\t\t\t\t? callbacks.onManualCodeInput()\n\t\t\t\t\t\t\t: callbacks.onPrompt({ message: prompt.message, placeholder: prompt.placeholder }),\n\t\t\t\t\t\tprompt.signal,\n\t\t\t\t\t\tcallbacks.onManualCodeCancel,\n\t\t\t\t\t);\n\t\t\t\tdefault:\n\t\t\t\t\treturn callbacks.onPrompt({ message: prompt.message, placeholder: prompt.placeholder });\n\t\t\t}\n\t\t},\n\t\tnotify: (event) => {\n\t\t\tswitch (event.type) {\n\t\t\t\tcase \"auth_url\":\n\t\t\t\t\tcallbacks.onAuth({ url: event.url, instructions: event.instructions });\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"device_code\":\n\t\t\t\t\tcallbacks.onDeviceCode(event);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"progress\":\n\t\t\t\t\tcallbacks.onProgress?.(event.message);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"info\":\n\t\t\t\t\tcallbacks.onInfo?.(event.message, event.links ?? []);\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t},\n\t};\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Provider } from "@
|
|
1
|
+
import type { Provider } from "@bastani/pi-ai";
|
|
2
2
|
import type { OAuthProviderMetadata } from "./oauth-login.ts";
|
|
3
3
|
import type { ProviderConfigInput } from "./provider-composer.ts";
|
|
4
4
|
export declare function collectOAuthProviderMetadata(providers: readonly Provider[], extensions: ReadonlyMap<string, ProviderConfigInput>): OAuthProviderMetadata[];
|