@bastani/atomic 0.9.18-alpha.5 → 0.9.18-alpha.7
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 +88 -0
- package/README.md +3 -3
- package/dist/builtin/intercom/CHANGELOG.md +39 -0
- package/dist/builtin/intercom/README.md +22 -2
- package/dist/builtin/intercom/broker/broker.ts +676 -128
- package/dist/builtin/intercom/broker/client.ts +151 -35
- package/dist/builtin/intercom/broker/delivered-message-cache.ts +497 -37
- package/dist/builtin/intercom/broker/framing.ts +4 -2
- package/dist/builtin/intercom/broker/paths.ts +10 -0
- package/dist/builtin/intercom/broker/pending-send-registry.ts +1 -2
- package/dist/builtin/intercom/broker/send-handler.ts +311 -52
- package/dist/builtin/intercom/broker/send-signature.ts +4 -2
- package/dist/builtin/intercom/broker/socket-writes.ts +103 -0
- package/dist/builtin/intercom/broker/spawn.ts +9 -4
- package/dist/builtin/intercom/index.bundle.mjs +1410 -212
- package/dist/builtin/intercom/package.json +2 -2
- package/dist/builtin/intercom/recoverable-disconnect.ts +52 -0
- package/dist/builtin/intercom/retry-policy.ts +8 -0
- package/dist/builtin/intercom/skills/intercom/SKILL.md +17 -9
- package/dist/builtin/intercom/types.ts +27 -8
- package/dist/builtin/intercom/workflow-stage-path-matching.ts +90 -0
- package/dist/builtin/intercom/workflow-stage-target.ts +57 -0
- package/dist/builtin/mcp/index.bundle.mjs +427 -126
- package/dist/builtin/mcp/package.json +2 -2
- package/dist/builtin/subagents/CHANGELOG.md +19 -0
- package/dist/builtin/subagents/README.md +3 -3
- 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 +11 -11
- 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/debugger.md +3 -3
- package/dist/builtin/subagents/agents/worker.md +2 -2
- package/dist/builtin/subagents/package.json +3 -3
- package/dist/builtin/subagents/skills/qlty/SKILL.md +29 -101
- package/dist/builtin/subagents/skills/qlty/references/manual-configuration.md +52 -0
- package/dist/builtin/subagents/skills/subagent/SKILL.md +11 -11
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +49 -132
- package/dist/builtin/web-access/package.json +2 -2
- package/dist/builtin/workflows/CHANGELOG.md +46 -0
- package/dist/builtin/workflows/README.md +7 -7
- package/dist/builtin/workflows/builtin/adversarial-verification.js +2 -2
- package/dist/builtin/workflows/builtin/{chunk-szz1ajz9.js → chunk-42s7sw0b.js} +9 -2
- package/dist/builtin/workflows/builtin/{chunk-2dqb5s2q.js → chunk-79fjkcvh.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-n58a7v26.js → chunk-b0v2xab1.js} +181 -10
- package/dist/builtin/workflows/builtin/{chunk-fghhy2a5.js → chunk-ed4jfn5t.js} +23 -5
- package/dist/builtin/workflows/builtin/{chunk-h3r2vkzc.js → chunk-hqpe2cyx.js} +60 -21
- package/dist/builtin/workflows/builtin/{chunk-hzzn6adg.js → chunk-k3w87x8y.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-82ha8p41.js → chunk-n8h4yyew.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-qwzvgxnq.js → chunk-reqr3sr3.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-c53y8bdh.js → chunk-wgccch41.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-0x6e303p.js → chunk-zbekjqew.js} +20 -7
- package/dist/builtin/workflows/builtin/{chunk-29wrp38a.js → chunk-ze5x3d1r.js} +1 -1
- package/dist/builtin/workflows/builtin/classify-and-act.js +2 -2
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize.js +2 -2
- package/dist/builtin/workflows/builtin/generate-and-filter.js +2 -2
- package/dist/builtin/workflows/builtin/goal.js +3 -3
- package/dist/builtin/workflows/builtin/index.js +11 -11
- package/dist/builtin/workflows/builtin/loop-until-done.js +2 -2
- package/dist/builtin/workflows/builtin/open-claude-design.js +2 -2
- package/dist/builtin/workflows/builtin/ralph.js +3 -3
- package/dist/builtin/workflows/builtin/steering-context.js +1 -1
- package/dist/builtin/workflows/builtin/tournament.js +2 -2
- package/dist/builtin/workflows/package.json +2 -2
- package/dist/builtin/workflows/skills/prompt-engineer/SKILL.md +39 -52
- package/dist/builtin/workflows/skills/prompt-engineer/references/advanced_patterns.md +9 -37
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_fable_5.md +49 -0
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_fable_5_1.md +57 -0
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_opus_4_8.md +57 -0
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_opus_5.md +47 -0
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_sonnet_5.md +57 -0
- package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_5_5.md +60 -0
- package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_5_6.md +58 -0
- package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_6_astra.md +58 -0
- package/dist/builtin/workflows/skills/prompt-engineer/references/quality_improvement.md +18 -4
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +3194 -737
- package/dist/builtin/workflows/src/index.js +899 -436
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +0 -10
- package/dist/cli/list-models.d.ts.map +1 -1
- package/dist/cli/list-models.js +4 -0
- package/dist/cli/list-models.js.map +1 -1
- package/dist/client/index.d.ts +1 -2
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +1 -2
- package/dist/client/index.js.map +1 -1
- package/dist/config.d.ts +0 -9
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +0 -45
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-compaction.js +8 -6
- package/dist/core/agent-session-compaction.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +1 -0
- 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.map +1 -1
- package/dist/core/agent-session-models.js +3 -4
- package/dist/core/agent-session-models.js.map +1 -1
- package/dist/core/agent-session-queue-pause.d.ts.map +1 -1
- package/dist/core/agent-session-queue-pause.js +6 -0
- package/dist/core/agent-session-queue-pause.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +13 -5
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-tool-hooks.js +1 -1
- package/dist/core/agent-session-tool-hooks.js.map +1 -1
- package/dist/core/agent-session-tree.d.ts.map +1 -1
- package/dist/core/agent-session-tree.js +8 -0
- package/dist/core/agent-session-tree.js.map +1 -1
- package/dist/core/agent-session.d.ts +2 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +2 -0
- package/dist/core/agent-session.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 +4 -4
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/extensions/api-types.d.ts +8 -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 +12 -0
- package/dist/core/extensions/context-types.d.ts.map +1 -1
- package/dist/core/extensions/context-types.js.map +1 -1
- package/dist/core/extensions/runner-shortcuts.d.ts.map +1 -1
- package/dist/core/extensions/runner-shortcuts.js +0 -1
- package/dist/core/extensions/runner-shortcuts.js.map +1 -1
- package/dist/core/fast-model-routing-transport.d.ts +12 -0
- package/dist/core/fast-model-routing-transport.d.ts.map +1 -0
- package/dist/core/{codex-fast-mode-transport.js → fast-model-routing-transport.js} +29 -29
- package/dist/core/fast-model-routing-transport.js.map +1 -0
- package/dist/core/fast-model-routing.d.ts +57 -0
- package/dist/core/fast-model-routing.d.ts.map +1 -0
- package/dist/core/fast-model-routing.js +201 -0
- package/dist/core/fast-model-routing.js.map +1 -0
- package/dist/core/fast-model-variants.d.ts +98 -0
- package/dist/core/fast-model-variants.d.ts.map +1 -0
- package/dist/core/fast-model-variants.js +148 -0
- package/dist/core/fast-model-variants.js.map +1 -0
- package/dist/core/http-dispatcher.d.ts.map +1 -1
- package/dist/core/http-dispatcher.js +4 -2
- package/dist/core/http-dispatcher.js.map +1 -1
- package/dist/core/keybindings.d.ts +0 -10
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +0 -8
- package/dist/core/keybindings.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-config.d.ts +15 -0
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +3 -0
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-resolver-initial.js +1 -1
- package/dist/core/model-resolver-initial.js.map +1 -1
- package/dist/core/model-runtime-streaming.d.ts +14 -1
- package/dist/core/model-runtime-streaming.d.ts.map +1 -1
- package/dist/core/model-runtime-streaming.js +25 -3
- package/dist/core/model-runtime-streaming.js.map +1 -1
- package/dist/core/model-runtime.d.ts +39 -2
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +91 -7
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/provider-composer-internal.d.ts.map +1 -1
- package/dist/core/provider-composer-internal.js +8 -2
- package/dist/core/provider-composer-internal.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +18 -18
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager-archive.d.ts.map +1 -1
- package/dist/core/session-manager-archive.js +25 -2
- package/dist/core/session-manager-archive.js.map +1 -1
- package/dist/core/settings-manager-core.d.ts +0 -2
- package/dist/core/settings-manager-core.d.ts.map +1 -1
- package/dist/core/settings-manager-core.js +2 -9
- package/dist/core/settings-manager-core.js.map +1 -1
- package/dist/core/settings-manager-internals.d.ts +0 -1
- package/dist/core/settings-manager-internals.d.ts.map +1 -1
- package/dist/core/settings-manager-internals.js.map +1 -1
- package/dist/core/settings-manager-ui-accessors.d.ts +0 -8
- package/dist/core/settings-manager-ui-accessors.d.ts.map +1 -1
- package/dist/core/settings-manager-ui-accessors.js +0 -53
- package/dist/core/settings-manager-ui-accessors.js.map +1 -1
- package/dist/core/settings-manager.d.ts +1 -1
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/settings-types.d.ts +0 -5
- package/dist/core/settings-types.d.ts.map +1 -1
- package/dist/core/settings-types.js.map +1 -1
- package/dist/core/skills.d.ts +1 -1
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +4 -2
- package/dist/core/skills.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +0 -1
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/system-prompt.js +7 -7
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/edit.d.ts +1 -1
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +128 -3
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/hashline.d.ts +2 -2
- package/dist/core/tools/hashline.d.ts.map +1 -1
- package/dist/core/tools/hashline.js +40 -10
- package/dist/core/tools/hashline.js.map +1 -1
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +8 -8
- package/dist/core/tools/write.js.map +1 -1
- package/dist/core/workflow-stage-admission.d.ts +6 -0
- package/dist/core/workflow-stage-admission.d.ts.map +1 -1
- package/dist/core/workflow-stage-admission.js +14 -0
- package/dist/core/workflow-stage-admission.js.map +1 -1
- package/dist/index-extensions.d.ts +1 -1
- package/dist/index-extensions.d.ts.map +1 -1
- package/dist/index-extensions.js.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -5
- package/dist/index.js.map +1 -1
- package/dist/modes/interactive/components/atomic-working-status.d.ts +4 -0
- package/dist/modes/interactive/components/atomic-working-status.d.ts.map +1 -1
- package/dist/modes/interactive/components/atomic-working-status.js +26 -1
- package/dist/modes/interactive/components/atomic-working-status.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts +7 -0
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js +43 -0
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +0 -6
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/index.d.ts +1 -2
- package/dist/modes/interactive/components/index.d.ts.map +1 -1
- package/dist/modes/interactive/components/index.js +0 -1
- package/dist/modes/interactive/components/index.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 +6 -11
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +2 -5
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js +3 -19
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-items.js +1 -1
- package/dist/modes/interactive/components/settings-selector-items.js.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.d.ts +1 -2
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.js +4 -11
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
- package/dist/modes/interactive/components/transcript-follow-indicator.js +3 -3
- package/dist/modes/interactive/components/transcript-follow-indicator.js.map +1 -1
- package/dist/modes/interactive/interactive-agent-events.js +8 -8
- package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
- package/dist/modes/interactive/interactive-autocomplete.js +5 -16
- package/dist/modes/interactive/interactive-autocomplete.js.map +1 -1
- package/dist/modes/interactive/interactive-bash-compact.js +2 -9
- package/dist/modes/interactive/interactive-bash-compact.js.map +1 -1
- package/dist/modes/interactive/interactive-deferred-startup.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-deferred-startup.js +3 -0
- package/dist/modes/interactive/interactive-deferred-startup.js.map +1 -1
- package/dist/modes/interactive/interactive-editor-actions.js +2 -2
- package/dist/modes/interactive/interactive-editor-actions.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-custom-ui.js +1 -0
- package/dist/modes/interactive/interactive-extension-custom-ui.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-dialogs.js +7 -0
- package/dist/modes/interactive/interactive-extension-dialogs.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-runtime.js +20 -10
- package/dist/modes/interactive/interactive-extension-runtime.js.map +1 -1
- package/dist/modes/interactive/interactive-hotkeys-debug.js +1 -5
- package/dist/modes/interactive/interactive-hotkeys-debug.js.map +1 -1
- package/dist/modes/interactive/interactive-initial-session-binding.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-initial-session-binding.js +3 -0
- package/dist/modes/interactive/interactive-initial-session-binding.js.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.js +0 -8
- package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.d.ts +5 -1
- package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.js +15 -9
- package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-deps.d.ts +1 -3
- package/dist/modes/interactive/interactive-mode-deps.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-deps.js +1 -3
- package/dist/modes/interactive/interactive-mode-deps.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.d.ts +9 -12
- 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/interactive-model-routing.js +10 -13
- package/dist/modes/interactive/interactive-model-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-render-chat.js +29 -0
- package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
- package/dist/modes/interactive/interactive-selectors.js +2 -32
- package/dist/modes/interactive/interactive-selectors.js.map +1 -1
- package/dist/modes/interactive/interactive-session-routing.js +1 -5
- package/dist/modes/interactive/interactive-session-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-session-runtime.js +1 -5
- package/dist/modes/interactive/interactive-session-runtime.js.map +1 -1
- package/dist/modes/interactive/interactive-slash-commands.js +6 -13
- package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
- package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-startup.js +19 -13
- package/dist/modes/interactive/interactive-startup.js.map +1 -1
- package/dist/modes/interactive/interactive-tui.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-tui.js +27 -3
- package/dist/modes/interactive/interactive-tui.js.map +1 -1
- package/dist/modes/interactive-engine/engine-custom-ui.d.ts.map +1 -1
- package/dist/modes/interactive-engine/engine-custom-ui.js +1 -0
- package/dist/modes/interactive-engine/engine-custom-ui.js.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.js +4 -1
- package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
- package/dist/utils/child-process.d.ts.map +1 -1
- package/dist/utils/child-process.js +13 -6
- package/dist/utils/child-process.js.map +1 -1
- package/dist/utils/exif-orientation.d.ts.map +1 -1
- package/dist/utils/exif-orientation.js +2 -3
- package/dist/utils/exif-orientation.js.map +1 -1
- package/dist/utils/tools-manager.d.ts +1 -0
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +33 -18
- package/dist/utils/tools-manager.js.map +1 -1
- package/docs/custom-provider.md +2 -0
- package/docs/development.md +17 -0
- package/docs/docs.json +14 -2
- package/docs/extensions.md +9 -4
- package/docs/intercom.md +41 -7
- package/docs/keybindings.md +8 -6
- package/docs/models/evals.md +394 -0
- package/docs/models/model-selection.md +54 -27
- package/docs/models/pareto-efficiency.md +33 -16
- package/docs/models.md +37 -1
- package/docs/packages.md +2 -2
- package/docs/providers.md +44 -20
- package/docs/quickstart.md +8 -6
- package/docs/rpc.md +3 -3
- package/docs/sdk.md +2 -16
- package/docs/settings.md +19 -22
- package/docs/skills.md +4 -2
- package/docs/subagents.md +9 -3
- package/docs/tools/edit.md +373 -0
- package/docs/tools.md +3 -7
- package/docs/tui.md +2 -1
- package/docs/usage.md +3 -5
- package/docs/workflows/api-reference.md +1395 -0
- package/docs/workflows/authoring.md +678 -0
- package/docs/workflows/builtins.md +245 -0
- package/docs/workflows/operations.md +811 -0
- package/docs/workflows/reliable-design.md +2099 -0
- package/docs/workflows/verification.md +62 -0
- package/docs/workflows.md +15 -5183
- package/npm-shrinkwrap.json +584 -69
- package/package.json +7 -7
- package/dist/client/remote-session.d.ts +0 -64
- package/dist/client/remote-session.d.ts.map +0 -1
- package/dist/client/remote-session.js +0 -351
- package/dist/client/remote-session.js.map +0 -1
- package/dist/client/transcript.d.ts +0 -12
- package/dist/client/transcript.d.ts.map +0 -1
- package/dist/client/transcript.js +0 -98
- package/dist/client/transcript.js.map +0 -1
- package/dist/core/codex-fast-mode-transport.d.ts +0 -12
- package/dist/core/codex-fast-mode-transport.d.ts.map +0 -1
- package/dist/core/codex-fast-mode-transport.js.map +0 -1
- package/dist/core/codex-fast-mode.d.ts +0 -53
- package/dist/core/codex-fast-mode.d.ts.map +0 -1
- package/dist/core/codex-fast-mode.js +0 -249
- package/dist/core/codex-fast-mode.js.map +0 -1
- package/dist/modes/interactive/components/fast-mode-selector.d.ts +0 -27
- package/dist/modes/interactive/components/fast-mode-selector.d.ts.map +0 -1
- package/dist/modes/interactive/components/fast-mode-selector.js +0 -107
- package/dist/modes/interactive/components/fast-mode-selector.js.map +0 -1
- package/dist/server/create-harness.d.ts +0 -53
- package/dist/server/create-harness.d.ts.map +0 -1
- package/dist/server/create-harness.js +0 -360
- package/dist/server/create-harness.js.map +0 -1
- package/docs/models/artificial-analysis-index.md +0 -83
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-runtime.js","sourceRoot":"","sources":["../../src/core/model-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAYN,YAAY,GAaZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,sBAAsB,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,WAAW,IAAI,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,iCAAiC,EAAE,MAAM,4BAA4B,CAAC;AAC/E,OAAO,EACN,wBAAwB,EACxB,2BAA2B,EAC3B,+BAA+B,EAC/B,0BAA0B,EAC1B,6BAA6B,EAE7B,8BAA8B,EAC9B,gCAAgC,EAChC,gBAAgB,EAChB,oBAAoB,GAC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BAA2B,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.js\";\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}\nexport interface ExtensionProviderTransaction {\n\tregisterNativeProvider(provider: Provider): void;\n\tregisterProvider(providerId: string, config: ProviderConfigInput): void;\n\tunregisterProvider(providerId: string): void;\n\thasConfiguredAuth(providerId: string): boolean;\n\tcommit(): Promise<void>;\n}\n\n/** Configured pi-ai Models collection used by coding-agent and SDK consumers. */\nexport class ModelRuntime implements Models {\n\tprivate readonly models: MutableModels;\n\tprivate readonly credentials: RuntimeCredentials;\n\tprivate readonly streaming: ModelRuntimeStreaming;\n\tprivate readonly defaultBuiltins: ReadonlyMap<string, Provider>;\n\tprivate readonly builtins = new Map<string, Provider>();\n\tprivate readonly nativeExtensionProviders = new Map<string, Provider>();\n\tprivate readonly extensionProviders = new Map<string, ProviderConfigInput>();\n\tprivate readonly compositionErrors = new Map<string, string>();\n\tprivate readonly modelsPath: string | undefined;\n\tprivate readonly modelNetworkEnabled: boolean;\n\tprivate config: ModelConfig;\n\tprivate snapshot: ModelRuntimeSnapshot = createEmptyModelRuntimeSnapshot();\n\tprivate snapshotGeneration = 0;\n\tprivate catalogInputsGeneration = 0;\n\tprivate observedModelsFileToken: string | undefined;\n\tprivate readonly externalProviderAuthStatuses = new Map<string, AuthStatus>();\n\tprivate availabilityRefreshSeq = 0;\n\tprivate availabilityErrorSeq = 0;\n\tprivate readonly providerAvailabilitySeq = new Map<string, number>();\n\tprivate readonly credentialOperations = new Map<string, Promise<unknown>>();\n\tprivate availabilityError: string | undefined;\n\tprivate refreshSequence = 0;\n\tprivate constructor(\n\t\tcredentials: RuntimeCredentials,\n\t\tconfig: ModelConfig,\n\t\tmodelsPath: string | undefined,\n\t\tmodelsStore: ModelsStore,\n\t\tproviders: readonly Provider[],\n\t\tmodelNetworkEnabled: boolean,\n\t) {\n\t\tthis.credentials = credentials;\n\t\tthis.config = config;\n\t\tthis.modelsPath = modelsPath;\n\t\tthis.modelNetworkEnabled = modelNetworkEnabled;\n\t\tthis.defaultBuiltins = new Map(providers.map((provider) => [provider.id, provider]));\n\t\tfor (const [providerId, provider] of this.defaultBuiltins) this.builtins.set(providerId, provider);\n\t\tthis.models = createModels({ credentials, modelsStore });\n\t\tthis.streaming = new ModelRuntimeStreaming(this.models, (model, overrides) =>\n\t\t\tthis.getRequestAuth(model, overrides),\n\t\t);\n\t\tthis.rebuildProviders();\n\t}\n\tstatic async create(options: CreateModelRuntimeOptions = {}): Promise<ModelRuntime> {\n\t\tconst credentials = new RuntimeCredentials(options.credentials ?? DefaultAuthStorage.create(options.authPath));\n\t\tconst modelsPath =\n\t\t\toptions.modelsPath === null ? undefined : (options.modelsPath ?? join(getAgentDir(), \"models.json\"));\n\t\tconst config = await ModelConfig.load(modelsPath);\n\t\tconst modelsStore =\n\t\t\toptions.modelsStore ??\n\t\t\t(modelsPath\n\t\t\t\t? new FileModelsStore(options.modelsStorePath ?? join(dirname(modelsPath), \"models-store.json\"))\n\t\t\t\t: new InMemoryCodingAgentModelsStore());\n\t\tconst builtinModelDataGeneratedAt = builtinProviderCatalog.getBuiltinModelDataGeneratedAt();\n\t\tconst providers = builtinProviderCatalog\n\t\t\t.builtinProviders()\n\t\t\t.map((provider) =>\n\t\t\t\tprovider.id === \"radius\"\n\t\t\t\t\t? provider\n\t\t\t\t\t: withRemoteCatalog(provider, options.catalogBaseUrl, builtinModelDataGeneratedAt),\n\t\t\t);\n\t\tconst runtime = new ModelRuntime(\n\t\t\tcredentials,\n\t\t\tconfig,\n\t\t\tmodelsPath,\n\t\t\tmodelsStore,\n\t\t\tproviders,\n\t\t\t!isOfflineModeEnabled(),\n\t\t);\n\t\truntime.configureRadiusProviders();\n\t\truntime.rebuildProviders();\n\t\tconst refreshFromNetwork = runtime.modelNetworkEnabled && options.allowModelNetwork === true;\n\t\tconst controller = refreshFromNetwork ? new AbortController() : undefined;\n\t\tconst timeout = controller\n\t\t\t? setTimeout(() => controller.abort(), options.modelRefreshTimeoutMs ?? 15_000)\n\t\t\t: undefined;\n\t\ttry {\n\t\t\tif (options.refreshOnCreate !== false) {\n\t\t\t\tawait runtime.refresh({ allowNetwork: refreshFromNetwork, signal: controller?.signal });\n\t\t\t}\n\t\t} finally {\n\t\t\tif (timeout) clearTimeout(timeout);\n\t\t}\n\t\treturn runtime;\n\t}\n\tprivate configureRadiusProviders(): void {\n\t\tconfigureBuiltinProviders(this.builtins, this.defaultBuiltins, this.config);\n\t}\n\tprivate providerIds(): Set<string> {\n\t\treturn new Set([\n\t\t\t...this.builtins.keys(),\n\t\t\t...this.nativeExtensionProviders.keys(),\n\t\t\t...this.config.getProviderIds(),\n\t\t\t...this.extensionProviders.keys(),\n\t\t]);\n\t}\n\tprivate recomposeProvider(providerId: string): void {\n\t\tconst base = this.nativeExtensionProviders.get(providerId) ?? this.builtins.get(providerId);\n\t\tconst extension = this.extensionProviders.get(providerId);\n\t\tif (!base && !this.config.getProvider(providerId) && !extension) {\n\t\t\tthis.models.deleteProvider(providerId);\n\t\t\tthis.compositionErrors.delete(providerId);\n\t\t\treturn;\n\t\t}\n\t\tif (base && !this.config.getProvider(providerId) && !extension) {\n\t\t\t// No overlays: use the builtin untouched so its auth/login/stream behavior is exact.\n\t\t\tthis.models.setProvider(base);\n\t\t\tthis.compositionErrors.delete(providerId);\n\t\t\treturn;\n\t\t}\n\t\ttry {\n\t\t\tthis.models.setProvider(composeModelProvider(providerId, base, this.config, extension));\n\t\t\tthis.compositionErrors.delete(providerId);\n\t\t} catch (error) {\n\t\t\tthis.compositionErrors.set(providerId, error instanceof Error ? error.message : String(error));\n\t\t\tif (base) this.models.setProvider(base);\n\t\t\telse this.models.deleteProvider(providerId);\n\t\t}\n\t}\n\tprivate rebuildProviders(): void {\n\t\tthis.models.clearProviders();\n\t\tthis.compositionErrors.clear();\n\t\tfor (const providerId of this.providerIds()) this.recomposeProvider(providerId);\n\t\tthis.updateModelSnapshot();\n\t}\n\tprivate updateModelSnapshot(): void {\n\t\tthis.snapshotGeneration += 1;\n\t\tthis.snapshot = updateSnapshotModels(this.snapshot, [...this.models.getModels()]);\n\t}\n\tprivate async runAvailabilityRefresh(seq: number, errorSeq: number, signal: AbortSignal): Promise<void> {\n\t\tconst providers = this.models.getProviders();\n\t\tconst [available, checks, credentials] = await Promise.all([\n\t\t\tthis.models.getAvailable(undefined, { signal }),\n\t\t\tPromise.all(\n\t\t\t\tproviders.map(\n\t\t\t\t\tasync (provider): Promise<[string, AuthCheck | undefined]> => [\n\t\t\t\t\t\tprovider.id,\n\t\t\t\t\t\tawait this.models.checkAuth(provider.id, { signal }),\n\t\t\t\t\t],\n\t\t\t\t),\n\t\t\t),\n\t\t\tthis.credentials.list({ signal }),\n\t\t]);\n\t\tif (seq !== this.availabilityRefreshSeq) return;\n\t\tthis.snapshot = createModelRuntimeSnapshot([...this.models.getModels()], [...available], checks, credentials);\n\t\tif (errorSeq === this.availabilityErrorSeq) this.availabilityError = undefined;\n\t}\n\tprivate queueAvailabilityRefresh(signal?: AbortSignal): Promise<void> {\n\t\tconst seq = ++this.availabilityRefreshSeq;\n\t\tfor (const [providerId, providerSeq] of this.providerAvailabilitySeq)\n\t\t\tthis.providerAvailabilitySeq.set(providerId, providerSeq + 1);\n\t\tconst errorSeq = ++this.availabilityErrorSeq;\n\t\tconst effectiveSignal = operationSignal(signal);\n\t\treturn this.runAvailabilityRefresh(seq, errorSeq, effectiveSignal).catch((error) => {\n\t\t\tif (errorSeq === this.availabilityErrorSeq && !effectiveSignal.aborted)\n\t\t\t\tthis.availabilityError = error instanceof Error ? error.message : String(error);\n\t\t\tthrow error;\n\t\t});\n\t}\n\tprivate async refreshProviderAvailability(providerId: string, signal: AbortSignal): Promise<void> {\n\t\t++this.availabilityRefreshSeq;\n\t\tconst providerSeq = (this.providerAvailabilitySeq.get(providerId) ?? 0) + 1;\n\t\tthis.providerAvailabilitySeq.set(providerId, providerSeq);\n\t\tconst errorSeq = ++this.availabilityErrorSeq;\n\t\ttry {\n\t\t\tconst [available, auth, credential] = await Promise.all([\n\t\t\t\tthis.models.getAvailable(providerId, { signal }),\n\t\t\t\tthis.models.checkAuth(providerId, { signal }),\n\t\t\t\tthis.credentials.read(providerId, { signal }),\n\t\t\t]);\n\t\t\tsignal.throwIfAborted();\n\t\t\tif (this.providerAvailabilitySeq.get(providerId) !== providerSeq) return;\n\t\t\tconst configuredProviders = new Set(this.snapshot.configuredProviders),\n\t\t\t\tstoredProviders = new Set(this.snapshot.storedProviders),\n\t\t\t\tstoredCredentialTypes = new Map(this.snapshot.storedCredentialTypes),\n\t\t\t\tauthByProvider = new Map(this.snapshot.auth);\n\t\t\tif (auth) {\n\t\t\t\tconfiguredProviders.add(providerId);\n\t\t\t\tauthByProvider.set(providerId, auth);\n\t\t\t} else {\n\t\t\t\tconfiguredProviders.delete(providerId);\n\t\t\t\tauthByProvider.delete(providerId);\n\t\t\t}\n\t\t\tif (credential) {\n\t\t\t\tstoredProviders.add(providerId);\n\t\t\t\tstoredCredentialTypes.set(providerId, credential.type);\n\t\t\t} else {\n\t\t\t\tstoredProviders.delete(providerId);\n\t\t\t\tstoredCredentialTypes.delete(providerId);\n\t\t\t}\n\t\t\tconst all = [...this.models.getModels()];\n\t\t\tconst availableById = new Map(\n\t\t\t\t[...this.snapshot.available.filter((model) => model.provider !== providerId), ...available].map((model) => [\n\t\t\t\t\t`${model.provider}\\0${model.id}`,\n\t\t\t\t\tmodel,\n\t\t\t\t]),\n\t\t\t);\n\t\t\tthis.snapshot = {\n\t\t\t\tall,\n\t\t\t\tavailable: all.flatMap((model) => availableById.get(`${model.provider}\\0${model.id}`) ?? []),\n\t\t\t\tconfiguredProviders,\n\t\t\t\tstoredProviders,\n\t\t\t\tstoredCredentialTypes,\n\t\t\t\tauth: authByProvider,\n\t\t\t};\n\t\t\tif (errorSeq === this.availabilityErrorSeq) this.availabilityError = undefined;\n\t\t} catch (error) {\n\t\t\tif (\n\t\t\t\tthis.providerAvailabilitySeq.get(providerId) === providerSeq &&\n\t\t\t\terrorSeq === this.availabilityErrorSeq &&\n\t\t\t\t!signal.aborted\n\t\t\t)\n\t\t\t\tthis.availabilityError = error instanceof Error ? error.message : String(error);\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tgetProviders(): readonly Provider[] {\n\t\treturn this.models.getProviders();\n\t}\n\tgetProvider(providerId: string): Provider | undefined {\n\t\treturn this.models.getProvider(providerId);\n\t}\n\t/** Whether an authenticated provider may reconstruct an absent saved model ID. */\n\tcanRestoreUnknownModel(providerId: string): boolean {\n\t\treturn canRestoreUnknownModelProvider(\n\t\t\tproviderId,\n\t\t\tthis.defaultBuiltins.get(providerId),\n\t\t\tthis.config.getProvider(providerId),\n\t\t\tthis.extensionProviders.get(providerId),\n\t\t\tthis.nativeExtensionProviders.get(providerId),\n\t\t);\n\t}\n\tgetModels(providerId?: string): readonly Model<Api>[] {\n\t\treturn this.models.getModels(providerId);\n\t}\n\tgetModel(providerId: string, modelId: string): Model<Api> | undefined {\n\t\treturn this.models.getModel(providerId, modelId);\n\t}\n\tasync checkAuth(providerId: string): Promise<AuthCheck | undefined> {\n\t\treturn this.models.checkAuth(providerId);\n\t}\n\tasync getAvailable(providerId?: string, options?: AuthOperationOptions): Promise<readonly Model<Api>[]> {\n\t\tif (providerId) {\n\t\t\tconst errorSeq = ++this.availabilityErrorSeq;\n\t\t\ttry {\n\t\t\t\tconst available = await this.models.getAvailable(providerId, options);\n\t\t\t\tif (errorSeq === this.availabilityErrorSeq) this.availabilityError = undefined;\n\t\t\t\treturn available;\n\t\t\t} catch (error) {\n\t\t\t\tif (errorSeq === this.availabilityErrorSeq && !options?.signal?.aborted)\n\t\t\t\t\tthis.availabilityError = error instanceof Error ? error.message : String(error);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t\tawait this.queueAvailabilityRefresh(options?.signal);\n\t\treturn this.snapshot.available;\n\t}\n\tgetAvailableSnapshot(): readonly Model<Api>[] {\n\t\treturn this.snapshot.available;\n\t}\n\tgetError(): string | undefined {\n\t\tconst errors: string[] = [];\n\t\tconst configError = this.config.getError();\n\t\tif (configError) errors.push(configError);\n\t\tfor (const [providerId, error] of this.compositionErrors) {\n\t\t\terrors.push(`Provider \"${providerId}\": ${error}`);\n\t\t}\n\t\tif (this.availabilityError) errors.push(`Availability refresh: ${this.availabilityError}`);\n\t\treturn errors.length > 0 ? errors.join(\"\\n\\n\") : undefined;\n\t}\n\n\tgetRegisteredProviderConfig(providerId: string): ProviderConfigInput | undefined {\n\t\treturn this.extensionProviders.get(providerId);\n\t}\n\n\tgetRegisteredProviderIds(): readonly string[] {\n\t\treturn [...new Set([...this.extensionProviders.keys(), ...this.nativeExtensionProviders.keys()])];\n\t}\n\n\tgetRegisteredNativeProvider(providerId: string): Provider | undefined {\n\t\treturn this.nativeExtensionProviders.get(providerId);\n\t}\n\tgetOAuthProviderMetadata() {\n\t\treturn collectOAuthProviderMetadata(this.getProviders(), this.extensionProviders);\n\t}\n\t/** @internal Compatibility fallback for ModelRegistry when provider auth is unconfigured. */\n\tgetCompatibilityRequestConfig(model: Model<Api>): CompatibilityRequestConfig {\n\t\treturn resolveCompatibilityRequestConfig(\n\t\t\tmodel,\n\t\t\tthis.config.getProvider(model.provider),\n\t\t\tthis.extensionProviders.get(model.provider),\n\t\t);\n\t}\n\n\tisUsingOAuth(providerId: string): boolean {\n\t\treturn this.snapshot.auth.get(providerId)?.type === \"oauth\";\n\t}\n\n\thasConfiguredAuth(providerId: string): boolean {\n\t\treturn this.snapshot.configuredProviders.has(providerId);\n\t}\n\n\t/** Return stored credential metadata synchronously without refreshing auth. */\n\tgetCredentialSnapshot(providerId: string): Credential | undefined {\n\t\treturn this.credentials.peek(providerId);\n\t}\n\n\tgetAuth(providerId: string, overrides?: ModelRuntimeAuthOverrides): Promise<AuthResult | undefined>;\n\tgetAuth(model: Model<Api>, overrides?: ModelRuntimeAuthOverrides): Promise<AuthResult | undefined>;\n\tasync getAuth(\n\t\tproviderOrModel: string | Model<Api>,\n\t\toverrides: ModelRuntimeAuthOverrides = {},\n\t): Promise<AuthResult | undefined> {\n\t\tif (typeof providerOrModel === \"string\") return this.models.getAuth(providerOrModel, overrides);\n\t\tconst resolution = await this.models.getAuth(providerOrModel, overrides);\n\t\tif (!resolution) return undefined;\n\t\treturn mergeConfiguredAuthHeaders(\n\t\t\tresolution,\n\t\t\tproviderOrModel,\n\t\t\tthis.config,\n\t\t\tthis.extensionProviders.get(providerOrModel.provider),\n\t\t\toverrides,\n\t\t);\n\t}\n\n\t/**\n\t * Resolve request-owned auth/config headers without copying the model's static\n\t * catalog headers into the per-request override layer. The API provider reads\n\t * static headers from the model itself; duplicating them in auth would make\n\t * them override API-computed defaults that intentionally replace catalog values.\n\t */\n\tasync getRequestAuth(model: Model<Api>, overrides: ModelRuntimeAuthOverrides = {}): Promise<AuthResult | undefined> {\n\t\tconst resolution = await this.getAuth(model.provider, overrides);\n\t\tif (!resolution) return undefined;\n\t\treturn mergeConfiguredAuthHeaders(\n\t\t\tresolution,\n\t\t\tmodel,\n\t\t\tthis.config,\n\t\t\tthis.extensionProviders.get(model.provider),\n\t\t\toverrides,\n\t\t);\n\t}\n\n\t/**\n\t * Monotonic count of changes to any input a catalog refresh reads.\n\t *\n\t * `refresh()` reloads models.json, recomposes every provider from it, the\n\t * extension registrations, and the builtin catalog, resolves credentials as\n\t * it runs, and publishes ONE snapshot at the end. So a pass belongs to the\n\t * inputs it started under, and joining a pass across a bump is unsound in\n\t * both directions: the joiner reads models and credentials the user has\n\t * already replaced, and the pass's late publish overwrites the newer state\n\t * with them.\n\t *\n\t * Every mutation source bumps this counter, which is why callers need only\n\t * this one number rather than a growing tuple of per-input keys:\n\t *\n\t * - credential writes — `login`, `logout`, `saveCredential`,\n\t * `setRuntimeApiKey`, `removeRuntimeApiKey`, an external\n\t * `reloadCredentials`, and an applied external auth status;\n\t * - provider registrations — `registerProvider`, `registerNativeProvider`,\n\t * and `unregisterProvider`, through the refresh they schedule;\n\t * - models.json content — provider `baseUrl`, `apiKey`, `api`, headers,\n\t * model definitions, and overrides, which every pass reloads.\n\t *\n\t * The first two are this runtime's own writes and bump where they happen.\n\t * The third is an external edit nothing here observes, so reading the\n\t * generation samples the file and bumps when its content moved since the\n\t * last sample. That read is synchronous so the answer belongs to the same\n\t * tick as the decision that depends on it, and it hashes content rather\n\t * than trusting an mtime: a same-size rewrite inside one filesystem\n\t * timestamp tick — an edited key, a renamed model — is exactly the change a\n\t * shared pass must not hide.\n\t */\n\tgetCatalogInputsGeneration(): number {\n\t\tthis.observeModelsFile();\n\t\treturn this.catalogInputsGeneration;\n\t}\n\n\t/**\n\t * Record that an input a catalog refresh reads changed. Every pass started\n\t * before this call answers for inputs that no longer exist.\n\t */\n\tprivate markCatalogInputsChanged(): void {\n\t\tthis.catalogInputsGeneration += 1;\n\t}\n\n\t/** Bump the generation when models.json changed since the last observation. */\n\tprivate observeModelsFile(): void {\n\t\tconst token = this.readModelsFileToken();\n\t\tif (this.observedModelsFileToken === token) return;\n\t\tconst first = this.observedModelsFileToken === undefined;\n\t\tthis.observedModelsFileToken = token;\n\t\t// The first observation is a baseline, not a change: no pass can predate it.\n\t\tif (!first) this.markCatalogInputsChanged();\n\t}\n\n\tprivate readModelsFileToken(): string {\n\t\tif (!this.modelsPath) return \"none\";\n\t\ttry {\n\t\t\treturn createHash(\"sha1\")\n\t\t\t\t.update(readFileSync(normalizePath(this.modelsPath)))\n\t\t\t\t.digest(\"hex\");\n\t\t} catch (error) {\n\t\t\tconst code = (error as NodeJS.ErrnoException).code;\n\t\t\t// An absent file is a stable state passes can share; any other read\n\t\t\t// failure keys on its own code rather than pretending the file is empty.\n\t\t\treturn code === \"ENOENT\" ? \"absent\" : `unreadable:${code ?? \"unknown\"}`;\n\t\t}\n\t}\n\n\t/** Reload credentials changed by the authoritative isolated engine and update auth status snapshots. */\n\tasync reloadCredentials(options: { refreshAvailability?: boolean } = {}): Promise<void> {\n\t\tawait this.credentials.reload();\n\t\tthis.markCatalogInputsChanged();\n\t\tif (options.refreshAvailability === false) {\n\t\t\tconst credentials = await this.credentials.list();\n\t\t\tfor (const credential of credentials) this.externalProviderAuthStatuses.delete(credential.providerId);\n\t\t\tthis.snapshotGeneration += 1;\n\t\t\tthis.snapshot = replaceStoredCredentialProviders(this.snapshot, credentials);\n\t\t\treturn;\n\t\t}\n\t\tawait this.queueAvailabilityRefresh();\n\t}\n\n\tprivate assertCredentialRefreshSucceeded(\n\t\tproviderId: string,\n\t\tresult: ModelsRefreshResult,\n\t\tsignal?: AbortSignal,\n\t): void {\n\t\tif (result.aborted) {\n\t\t\tsignal?.throwIfAborted();\n\t\t\tthrow new Error(`Model refresh aborted for ${providerId}`);\n\t\t}\n\t\tconst refreshError = result.errors.get(providerId);\n\t\tif (refreshError) throw refreshError;\n\t\tconst compositionError = this.compositionErrors.get(providerId);\n\t\tif (compositionError) throw new Error(compositionError);\n\t}\n\n\tprivate enqueueCredentialOperation<T>(providerId: string, signal: AbortSignal, task: () => Promise<T>): Promise<T> {\n\t\tconst previous = this.credentialOperations.get(providerId) ?? Promise.resolve();\n\t\tlet markStarted: (() => void) | undefined;\n\t\tconst started = new Promise<void>((resolve) => {\n\t\t\tmarkStarted = resolve;\n\t\t});\n\t\tconst operation = (async () => {\n\t\t\tawait previous.catch(() => {});\n\t\t\tsignal.throwIfAborted();\n\t\t\tmarkStarted?.();\n\t\t\treturn task();\n\t\t})();\n\t\tconst tail = operation.catch(() => {});\n\t\tthis.credentialOperations.set(providerId, tail);\n\t\tvoid tail.then(() => {\n\t\t\tif (this.credentialOperations.get(providerId) === tail) this.credentialOperations.delete(providerId);\n\t\t});\n\t\treturn raceWithAbortSignal(started, signal).then(() => operation);\n\t}\n\tprivate async synchronizeCredentialState(\n\t\tproviderId: string,\n\t\toperation: CredentialSynchronizationOperation,\n\t\tcredential: Credential | undefined,\n\t\tsynchronize: () => void | Promise<void>,\n\t): Promise<void> {\n\t\ttry {\n\t\t\tawait synchronize();\n\t\t} catch (cause) {\n\t\t\tif (cause instanceof CredentialSynchronizationError) throw cause;\n\t\t\tthrow new CredentialSynchronizationError(providerId, operation, credential, { cause });\n\t\t}\n\t}\n\tprivate async refreshRemainingAuthAfterLogout(providerId: string, logoutGeneration: number): Promise<void> {\n\t\t// Environment/runtime auth can remain after stored auth is removed. The\n\t\t// probe is normally synchronous, but its deadline is authoritative because\n\t\t// extension checks are third-party code and need not honor cancellation.\n\t\tlet timeout: number | undefined;\n\t\ttry {\n\t\t\tconst remainingAuth = await Promise.race([\n\t\t\t\tthis.checkAuth(providerId).catch(() => undefined),\n\t\t\t\tnew Promise<undefined>((resolve) => {\n\t\t\t\t\ttimeout = setTimeout(resolve, POST_LOGOUT_AUTH_CHECK_TIMEOUT_MS);\n\t\t\t\t}),\n\t\t\t]);\n\t\t\tif (logoutGeneration === this.snapshotGeneration && !this.snapshot.storedProviders.has(providerId)) {\n\t\t\t\tthis.snapshot = removeStoredCredentialProvider(this.snapshot, providerId, remainingAuth);\n\t\t\t}\n\t\t} finally {\n\t\t\tif (timeout) clearTimeout(timeout);\n\t\t}\n\t}\n\n\tasync saveCredential(providerId: string, credential: Credential): Promise<void> {\n\t\tconst signal = operationSignal(undefined);\n\t\tawait this.enqueueCredentialOperation(providerId, signal, async () => {\n\t\t\tawait this.credentials.modify(providerId, async () => credential);\n\t\t\tthis.markCatalogInputsChanged();\n\t\t\tawait this.synchronizeCredentialState(providerId, \"saveCredential\", credential, async () => {\n\t\t\t\tconst result = await this.refresh({ providers: [providerId] });\n\t\t\t\tthis.assertCredentialRefreshSucceeded(providerId, result);\n\t\t\t});\n\t\t});\n\t}\n\t/**\n\t * Apply a process-scoped API key override. This publishes the provider against\n\t * the current snapshot and deliberately does not refresh the model catalog;\n\t * callers needing catalog freshness call refresh({ providers: [providerId], signal })\n\t * separately.\n\t */\n\tasync setRuntimeApiKey(providerId: string, apiKey: string, options: AuthOperationOptions): Promise<void> {\n\t\tconst signal = operationSignal(options.signal);\n\t\tawait this.enqueueCredentialOperation(providerId, signal, async () => {\n\t\t\tthis.credentials.setRuntimeApiKey(providerId, apiKey);\n\t\t\tthis.markCatalogInputsChanged();\n\t\t\tawait this.synchronizeCredentialState(providerId, \"setRuntimeApiKey\", { type: \"api_key\", key: apiKey }, () => {\n\t\t\t\tthis.snapshot = addRuntimeApiKeyProvider(this.snapshot, providerId);\n\t\t\t});\n\t\t});\n\t}\n\n\tasync removeRuntimeApiKey(providerId: string, options: AuthOperationOptions = {}): Promise<void> {\n\t\tconst signal = operationSignal(options.signal);\n\t\tawait this.enqueueCredentialOperation(providerId, signal, async () => {\n\t\t\tthis.credentials.removeRuntimeApiKey(providerId);\n\t\t\tthis.markCatalogInputsChanged();\n\t\t\tawait this.synchronizeCredentialState(providerId, \"removeRuntimeApiKey\", undefined, async () => {\n\t\t\t\tconst result = await this.refresh({ allowNetwork: this.modelNetworkEnabled, signal });\n\t\t\t\tthis.assertCredentialRefreshSucceeded(providerId, result, signal);\n\t\t\t});\n\t\t});\n\t}\n\n\tlistCredentials(): Promise<readonly CredentialInfo[]> {\n\t\treturn this.credentials.list();\n\t}\n\n\tgetStoredCredentialType(providerId: string): CredentialInfo[\"type\"] | undefined {\n\t\treturn this.snapshot.storedCredentialTypes.get(providerId);\n\t}\n\n\tgetProviderAuthStatus(providerId: string): AuthStatus {\n\t\tconst localStatus = getSnapshotProviderAuthStatus(\n\t\t\tthis.snapshot,\n\t\t\tproviderId,\n\t\t\tthis.credentials.hasRuntimeApiKey(providerId),\n\t\t\tconfiguredRequestAuthStatus(this.config.getProvider(providerId), this.extensionProviders.get(providerId)),\n\t\t);\n\t\tif (localStatus.source === \"stored\" || localStatus.source === \"runtime\") return localStatus;\n\t\treturn this.externalProviderAuthStatuses.get(providerId) ?? localStatus;\n\t}\n\n\t/** Apply authoritative auth state returned by an isolated engine mutation. */\n\tapplyExternalProviderAuthStatus(providerId: string, status: AuthStatus): void {\n\t\tthis.markCatalogInputsChanged();\n\t\tthis.snapshotGeneration += 1;\n\t\tconst remainingAuth =\n\t\t\tstatus.configured && status.source === \"environment\"\n\t\t\t\t? ({ type: \"api_key\", source: status.label ?? \"environment\" } as const)\n\t\t\t\t: undefined;\n\t\tthis.snapshot = removeStoredCredentialProvider(this.snapshot, providerId, remainingAuth);\n\t\tthis.externalProviderAuthStatuses.set(providerId, status);\n\t}\n\n\tstream<TApi extends Api>(\n\t\tmodel: Model<TApi>,\n\t\tcontext: Context,\n\t\toptions?: ModelsApiStreamOptions<TApi>,\n\t): AssistantMessageEventStream {\n\t\treturn this.streaming.stream(model, context, options);\n\t}\n\n\tcomplete<TApi extends Api>(\n\t\tmodel: Model<TApi>,\n\t\tcontext: Context,\n\t\toptions?: ModelsApiStreamOptions<TApi>,\n\t): Promise<AssistantMessage> {\n\t\treturn this.streaming.complete(model, context, options);\n\t}\n\n\tstreamSimple(model: Model<Api>, context: Context, options?: ModelsSimpleStreamOptions): AssistantMessageEventStream {\n\t\treturn this.streaming.streamSimple(model, context, options);\n\t}\n\n\tcompleteSimple(model: Model<Api>, context: Context, options?: ModelsSimpleStreamOptions): Promise<AssistantMessage> {\n\t\treturn this.streaming.completeSimple(model, context, options);\n\t}\n\n\tfetchDeferred(\n\t\tmodel: Model<Api>,\n\t\thandle: DeferredHandle,\n\t\toptions?: ModelsDeferredFetchOptions,\n\t): Promise<AssistantMessage> {\n\t\treturn this.streaming.fetchDeferred(model, handle, options);\n\t}\n\n\tcancelDeferred(model: Model<Api>, handle: DeferredHandle, options?: ModelsDeferredCancelOptions): Promise<void> {\n\t\treturn this.streaming.cancelDeferred(model, handle, options);\n\t}\n\n\tasync login(providerId: string, type: AuthType, interaction: AuthInteraction): Promise<Credential> {\n\t\tconst signal = operationSignal(interaction.signal);\n\t\treturn this.enqueueCredentialOperation(providerId, signal, async () => {\n\t\t\tconst credential = await this.models.login(providerId, type, { ...interaction, signal });\n\t\t\tthis.markCatalogInputsChanged();\n\t\t\tawait this.synchronizeCredentialState(providerId, \"login\", credential, () => {\n\t\t\t\t// Credential acquisition and persistence are the login transaction. Publish\n\t\t\t\t// the provider against the current snapshot immediately; catalog restoration,\n\t\t\t\t// ambient availability checks, and networking belong to /model's bounded\n\t\t\t\t// background refresh and must never keep a successful login dialog open.\n\t\t\t\tthis.updateModelSnapshot();\n\t\t\t\tthis.externalProviderAuthStatuses.delete(providerId);\n\t\t\t\tthis.snapshot = addStoredCredentialProvider(this.snapshot, providerId, credential.type);\n\t\t\t});\n\t\t\treturn credential;\n\t\t});\n\t}\n\n\tasync logout(providerId: string, options: AuthOperationOptions = {}): Promise<void> {\n\t\tconst signal = operationSignal(options.signal);\n\t\tconst logoutGeneration = await this.enqueueCredentialOperation(providerId, signal, async () => {\n\t\t\tawait this.models.logout(providerId, { signal });\n\t\t\tthis.markCatalogInputsChanged();\n\t\t\tlet generation = 0;\n\t\t\tawait this.synchronizeCredentialState(providerId, \"logout\", undefined, () => {\n\t\t\t\t// Reset credential-dependent compatibility projections, then publish the\n\t\t\t\t// persisted deletion without waiting for model stores or remote catalogs.\n\t\t\t\tthis.recomposeProvider(providerId);\n\t\t\t\tthis.updateModelSnapshot();\n\t\t\t\tthis.externalProviderAuthStatuses.delete(providerId);\n\t\t\t\tthis.snapshot = removeStoredCredentialProvider(this.snapshot, providerId);\n\t\t\t\tgeneration = this.snapshotGeneration;\n\t\t\t});\n\t\t\treturn generation;\n\t\t});\n\t\tawait this.refreshRemainingAuthAfterLogout(providerId, logoutGeneration);\n\t}\n\n\t/**\n\t * The network policy a refresh with an omitted `allowNetwork` resolves to.\n\t *\n\t * Callers that share one in-flight refresh key on the effective policy, so\n\t * they need the same answer `runRefresh` computes rather than a second guess\n\t * at the offline setting this runtime was created under.\n\t */\n\tisNetworkRefreshEnabled(): boolean {\n\t\treturn this.modelNetworkEnabled;\n\t}\n\tasync refresh(options: ModelsRefreshOptions = {}): Promise<ModelsRefreshResult> {\n\t\treturn this.runRefresh(options, ++this.refreshSequence);\n\t}\n\n\t/**\n\t * A registration's offline catalog pass must not publish after a newer refresh\n\t * that resolves configured credentials.\n\t *\n\t * The registration is also a catalog-input change: it adds, replaces, or drops\n\t * a provider every later pass composes from, so no pass that predates it can\n\t * answer for the provider set a caller now sees.\n\t */\n\tprivate scheduleRegistrationRefresh(): void {\n\t\tthis.markCatalogInputsChanged();\n\t\tconst sequence = ++this.refreshSequence;\n\t\tvoid this.runRefresh({ allowNetwork: false }, sequence, true);\n\t}\n\n\tprivate async runRefresh(\n\t\toptions: ModelsRefreshOptions,\n\t\tsequence: number,\n\t\tdiscardIfSuperseded = false,\n\t): Promise<ModelsRefreshResult> {\n\t\tconst config = await ModelConfig.load(this.modelsPath);\n\t\tif (discardIfSuperseded && sequence !== this.refreshSequence) {\n\t\t\treturn { aborted: true, errors: new Map<string, Error>() };\n\t\t}\n\t\tthis.config = config;\n\t\tthis.configureRadiusProviders();\n\t\tif (options.providers) {\n\t\t\tfor (const providerId of new Set(options.providers)) this.recomposeProvider(providerId);\n\t\t\tthis.updateModelSnapshot();\n\t\t} else this.rebuildProviders();\n\t\tconst refreshOptions = { ...options, allowNetwork: options.allowNetwork ?? this.isNetworkRefreshEnabled() };\n\t\tconst result = await this.models.refresh(refreshOptions);\n\t\tconst errors = new Map(result.errors);\n\t\tthis.updateModelSnapshot();\n\t\tif (options.providers) {\n\t\t\tawait Promise.all(\n\t\t\t\t[...new Set(options.providers)].map(async (providerId) => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait this.refreshProviderAvailability(providerId, operationSignal(options.signal));\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tif (!options.signal?.aborted)\n\t\t\t\t\t\t\terrors.set(providerId, error instanceof Error ? error : new Error(String(error)));\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t);\n\t\t} else {\n\t\t\ttry {\n\t\t\t\tawait this.queueAvailabilityRefresh(options.signal);\n\t\t\t} catch {\n\t\t\t\t// Availability errors are recorded by the latest pass; refreshed models remain usable.\n\t\t\t}\n\t\t}\n\t\treturn { aborted: result.aborted || (options.signal?.aborted ?? false), errors };\n\t}\n\n\tcreateExtensionProviderTransaction(replacedProviderIds: Iterable<string> = []): ExtensionProviderTransaction {\n\t\tconst nativeProviders = new Map(this.nativeExtensionProviders);\n\t\tconst providers = new Map(this.extensionProviders);\n\t\tfor (const providerId of replacedProviderIds) {\n\t\t\tnativeProviders.delete(providerId);\n\t\t\tproviders.delete(providerId);\n\t\t}\n\t\tconst configuredProviders = new Set(this.snapshot.configuredProviders);\n\t\tfor (const providerId of replacedProviderIds) configuredProviders.delete(providerId);\n\t\treturn {\n\t\t\tregisterNativeProvider: (provider) => {\n\t\t\t\tif (!provider.id.trim()) throw new Error(\"Provider id must not be empty.\");\n\t\t\t\tproviders.delete(provider.id);\n\t\t\t\tif (this.snapshot.storedProviders.has(provider.id)) configuredProviders.add(provider.id);\n\t\t\t\tnativeProviders.set(provider.id, provider);\n\t\t\t},\n\t\t\tregisterProvider: (providerId, config) => {\n\t\t\t\tvalidateExtensionProvider(\n\t\t\t\t\tproviderId,\n\t\t\t\t\tthis.builtins.get(providerId),\n\t\t\t\t\tthis.config.getProvider(providerId),\n\t\t\t\t\tconfig,\n\t\t\t\t);\n\t\t\t\tnativeProviders.delete(providerId);\n\t\t\t\tconst effective: ProviderConfigInput = { ...providers.get(providerId) };\n\t\t\t\tfor (const [key, value] of Object.entries(config)) {\n\t\t\t\t\tif (value !== undefined) (effective as Record<string, unknown>)[key] = value;\n\t\t\t\t}\n\t\t\t\tif (\n\t\t\t\t\tthis.snapshot.storedProviders.has(providerId) ||\n\t\t\t\t\tconfiguredRequestAuthStatus(this.config.getProvider(providerId), effective)?.configured\n\t\t\t\t) {\n\t\t\t\t\tconfiguredProviders.add(providerId);\n\t\t\t\t} else configuredProviders.delete(providerId);\n\t\t\t\tproviders.set(providerId, effective);\n\t\t\t},\n\t\t\tunregisterProvider: (providerId) => {\n\t\t\t\tproviders.delete(providerId);\n\t\t\t\tconfiguredProviders.delete(providerId);\n\t\t\t\tnativeProviders.delete(providerId);\n\t\t\t},\n\t\t\thasConfiguredAuth: (providerId) => configuredProviders.has(providerId),\n\t\t\tcommit: async () => {\n\t\t\t\tconst previous = {\n\t\t\t\t\textensionProviders: new Map(this.extensionProviders),\n\t\t\t\t\tnativeExtensionProviders: new Map(this.nativeExtensionProviders),\n\t\t\t\t\tbuiltins: new Map(this.builtins),\n\t\t\t\t\tconfig: this.config,\n\t\t\t\t\tsnapshot: this.snapshot,\n\t\t\t\t\tcompositionErrors: new Map(this.compositionErrors),\n\t\t\t\t};\n\t\t\t\ttry {\n\t\t\t\t\tthis.extensionProviders.clear();\n\t\t\t\t\tfor (const [providerId, config] of providers) this.extensionProviders.set(providerId, config);\n\t\t\t\t\tthis.nativeExtensionProviders.clear();\n\t\t\t\t\tfor (const [providerId, provider] of nativeProviders)\n\t\t\t\t\t\tthis.nativeExtensionProviders.set(providerId, provider);\n\t\t\t\t\tthis.rebuildProviders();\n\t\t\t\t\tthis.markCatalogInputsChanged();\n\t\t\t\t\tawait this.runRefresh({ allowNetwork: false }, ++this.refreshSequence, true);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthis.extensionProviders.clear();\n\t\t\t\t\tfor (const [providerId, config] of previous.extensionProviders)\n\t\t\t\t\t\tthis.extensionProviders.set(providerId, config);\n\t\t\t\t\tthis.nativeExtensionProviders.clear();\n\t\t\t\t\tfor (const [providerId, provider] of previous.nativeExtensionProviders)\n\t\t\t\t\t\tthis.nativeExtensionProviders.set(providerId, provider);\n\t\t\t\t\tthis.builtins.clear();\n\t\t\t\t\tfor (const [providerId, provider] of previous.builtins) this.builtins.set(providerId, provider);\n\t\t\t\t\tthis.config = previous.config;\n\t\t\t\t\tthis.rebuildProviders();\n\t\t\t\t\tthis.snapshot = previous.snapshot;\n\t\t\t\t\tthis.compositionErrors.clear();\n\t\t\t\t\tfor (const [providerId, message] of previous.compositionErrors)\n\t\t\t\t\t\tthis.compositionErrors.set(providerId, message);\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\t}\n\n\tregisterNativeProvider(provider: Provider): void {\n\t\tif (!provider.id.trim()) throw new Error(\"Provider id must not be empty.\");\n\t\tthis.extensionProviders.delete(provider.id);\n\t\tthis.nativeExtensionProviders.set(provider.id, provider);\n\t\tthis.recomposeProvider(provider.id);\n\t\tthis.updateModelSnapshot();\n\t\tthis.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;AAClD,OAAO,EAAE,WAAW,IAAI,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EACN,6BAA6B,EAC7B,wBAAwB,EACxB,oBAAoB,EAEpB,oBAAoB,EACpB,qBAAqB,GACrB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OA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I,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.js\";\nimport { operationSignal, raceWithAbortSignal } from \"../utils/abort.js\";\nimport { normalizePath } from \"../utils/paths.ts\";\nimport { AuthStorage as DefaultAuthStorage } from \"./auth-storage.ts\";\nimport {\n\tcopilotAdvertisedFastModelIds,\n\tcopilotAdvertisesModelId,\n\tFAST_MODEL_ID_SUFFIX,\n\ttype FastModelVariantDiagnostic,\n\tisGitHubCopilotModel,\n\twithFastModelVariants,\n} from \"./fast-model-variants.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}\nexport interface ExtensionProviderTransaction {\n\tregisterNativeProvider(provider: Provider): void;\n\tregisterProvider(providerId: string, config: ProviderConfigInput): void;\n\tunregisterProvider(providerId: string): void;\n\thasConfiguredAuth(providerId: string): boolean;\n\tcommit(): Promise<void>;\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 fastModelVariantDiagnostics = new Map<string, readonly FastModelVariantDiagnostic[]>();\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(\n\t\t\tthis.models,\n\t\t\t(model, overrides) => this.getRequestAuth(model, overrides),\n\t\t\t(model) => this.ownsExtensionTransport(model),\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\t/**\n\t * Overlay derived selectable `-fast` model variants. Applied last so exact `-fast` IDs owned by the\n\t * provider, models.json, or an extension are already present and win the collision.\n\t */\n\tprivate withDerivedFastModels(provider: Provider): Provider {\n\t\treturn withFastModelVariants(provider, {\n\t\t\tgetCopilotFastModelIds: () => copilotAdvertisedFastModelIds(this.credentials.peek(\"github-copilot\")),\n\t\t\tgetModelOverrides: () => this.config.getProvider(provider.id)?.modelOverrides,\n\t\t\tgetExtensionOwnedApis: () => {\n\t\t\t\tconst ownedApis = new Set<Api>();\n\t\t\t\tconst extension = this.extensionProviders.get(provider.id);\n\t\t\t\tif (extension?.streamSimple !== undefined && extension.api) ownedApis.add(extension.api);\n\t\t\t\tconst native = this.nativeExtensionProviders.get(provider.id);\n\t\t\t\tif (native?.stream !== undefined || native?.streamSimple !== undefined) {\n\t\t\t\t\tfor (const model of native.getModels()) ownedApis.add(model.api);\n\t\t\t\t}\n\t\t\t\treturn ownedApis.size > 0 ? ownedApis : undefined;\n\t\t\t},\n\t\t\tonDiagnostics: (id, diagnostics) => {\n\t\t\t\tif (diagnostics.length === 0) this.fastModelVariantDiagnostics.delete(id);\n\t\t\t\telse this.fastModelVariantDiagnostics.set(id, diagnostics);\n\t\t\t},\n\t\t});\n\t}\n\t/**\n\t * Publish a provider through the fast-variant overlay. Every catalog accessor — `getProvider`,\n\t * `getProviders`, `getModel`, `getModels`, `getAvailable` — then reports the same list. The overlay\n\t * is `{ ...provider, getModels }`, so `auth`, `login`, `stream`, and `streamSimple` stay the same\n\t * function references the caller registered.\n\t */\n\tprivate publishProvider(provider: Provider): void {\n\t\tthis.models.setProvider(this.withDerivedFastModels(provider));\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\tthis.fastModelVariantDiagnostics.delete(providerId);\n\t\t\treturn;\n\t\t}\n\t\tif (base && !this.config.getProvider(providerId) && !extension) {\n\t\t\t// No overlays: keep the builtin's auth/login/stream behavior exact and only add fast variants.\n\t\t\tthis.publishProvider(base);\n\t\t\tthis.compositionErrors.delete(providerId);\n\t\t\treturn;\n\t\t}\n\t\ttry {\n\t\t\tthis.publishProvider(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.publishProvider(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\tthis.fastModelVariantDiagnostics.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/**\n\t * Whether an authenticated provider may reconstruct an absent saved model ID.\n\t *\n\t * Pass `modelId` whenever it is known. GitHub Copilot advertises every model it offers per account,\n\t * so a `-fast` ID that appears in neither the picker list nor the fast-sibling list is definitively\n\t * not restorable. An ID advertised as a fast sibling also requires its corresponding base model in\n\t * the catalog; otherwise reconstruction would invent a route-less fast identity. An ID advertised\n\t * as an ordinary model stays ordinary whatever its name ends in. Every other provider keeps the\n\t * provider-scoped answer, so a provider-owned model whose upstream name merely ends in `-fast`\n\t * (several exist under `vercel-ai-gateway`) still restores.\n\t */\n\tcanRestoreUnknownModel(providerId: string, modelId?: string): boolean {\n\t\tif (\n\t\t\tmodelId !== undefined &&\n\t\t\tisGitHubCopilotModel({ provider: providerId }) &&\n\t\t\tmodelId.endsWith(FAST_MODEL_ID_SUFFIX)\n\t\t) {\n\t\t\tconst credential = this.credentials.peek(providerId);\n\t\t\tif (!copilotAdvertisesModelId(credential, modelId)) return false;\n\t\t\tif (copilotAdvertisedFastModelIds(credential)?.includes(modelId) === true) {\n\t\t\t\tconst baseModelId = modelId.slice(0, -FAST_MODEL_ID_SUFFIX.length);\n\t\t\t\tif (!this.models.getModel(providerId, baseModelId)) return false;\n\t\t\t}\n\t\t}\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\t/**\n\t * Derived fast model variants that were suppressed because a provider, models.json custom model, or\n\t * extension already owns the exact `-fast` model ID. Reported as warnings, not composition errors.\n\t */\n\tgetFastModelVariantDiagnostics(): readonly FastModelVariantDiagnostic[] {\n\t\treturn [...this.fastModelVariantDiagnostics.values()].flat();\n\t}\n\n\t/** Non-fatal catalog warnings, joined for display. */\n\tgetWarning(): string | undefined {\n\t\tconst warnings = this.getFastModelVariantDiagnostics().map((diagnostic) => diagnostic.message);\n\t\treturn warnings.length > 0 ? warnings.join(\"\\n\\n\") : undefined;\n\t}\n\n\tgetRegisteredProviderConfig(providerId: string): ProviderConfigInput | undefined {\n\t\treturn this.extensionProviders.get(providerId);\n\t}\n\n\t/**\n\t * Whether an extension supplies the stream function for this model's api. Such a transport owns its\n\t * own serialization, so Atomic must not attach first-party provider routing to it. This mirrors the\n\t * `usesExtensionStream` check the agent session makes before dispatching.\n\t */\n\tprivate ownsExtensionTransport(model: Model<Api>): boolean {\n\t\tconst extension = this.extensionProviders.get(model.provider);\n\t\treturn extension?.streamSimple !== undefined && model.api === extension.api;\n\t}\n\n\tgetRegisteredProviderIds(): readonly string[] {\n\t\treturn [...new Set([...this.extensionProviders.keys(), ...this.nativeExtensionProviders.keys()])];\n\t}\n\n\tgetRegisteredNativeProvider(providerId: string): Provider | undefined {\n\t\treturn this.nativeExtensionProviders.get(providerId);\n\t}\n\tgetOAuthProviderMetadata() {\n\t\treturn collectOAuthProviderMetadata(this.getProviders(), this.extensionProviders);\n\t}\n\t/** @internal Compatibility fallback for ModelRegistry when provider auth is unconfigured. */\n\tgetCompatibilityRequestConfig(model: Model<Api>): CompatibilityRequestConfig {\n\t\treturn resolveCompatibilityRequestConfig(\n\t\t\tmodel,\n\t\t\tthis.config.getProvider(model.provider),\n\t\t\tthis.extensionProviders.get(model.provider),\n\t\t);\n\t}\n\n\tisUsingOAuth(providerId: string): boolean {\n\t\treturn this.snapshot.auth.get(providerId)?.type === \"oauth\";\n\t}\n\n\thasConfiguredAuth(providerId: string): boolean {\n\t\treturn this.snapshot.configuredProviders.has(providerId);\n\t}\n\n\t/** Return stored credential metadata synchronously without refreshing auth. */\n\tgetCredentialSnapshot(providerId: string): Credential | undefined {\n\t\treturn this.credentials.peek(providerId);\n\t}\n\n\tgetAuth(providerId: string, overrides?: ModelRuntimeAuthOverrides): Promise<AuthResult | undefined>;\n\tgetAuth(model: Model<Api>, overrides?: ModelRuntimeAuthOverrides): Promise<AuthResult | undefined>;\n\tasync getAuth(\n\t\tproviderOrModel: string | Model<Api>,\n\t\toverrides: ModelRuntimeAuthOverrides = {},\n\t): Promise<AuthResult | undefined> {\n\t\tif (typeof providerOrModel === \"string\") return this.models.getAuth(providerOrModel, overrides);\n\t\tconst resolution = await this.models.getAuth(providerOrModel, overrides);\n\t\tif (!resolution) return undefined;\n\t\treturn mergeConfiguredAuthHeaders(\n\t\t\tresolution,\n\t\t\tproviderOrModel,\n\t\t\tthis.config,\n\t\t\tthis.extensionProviders.get(providerOrModel.provider),\n\t\t\toverrides,\n\t\t);\n\t}\n\n\t/**\n\t * Resolve request-owned auth/config headers without copying the model's static\n\t * catalog headers into the per-request override layer. The API provider reads\n\t * static headers from the model itself; duplicating them in auth would make\n\t * them override API-computed defaults that intentionally replace catalog values.\n\t */\n\tasync getRequestAuth(model: Model<Api>, overrides: ModelRuntimeAuthOverrides = {}): Promise<AuthResult | undefined> {\n\t\tconst resolution = await this.getAuth(model.provider, overrides);\n\t\tif (!resolution) return undefined;\n\t\treturn mergeConfiguredAuthHeaders(\n\t\t\tresolution,\n\t\t\tmodel,\n\t\t\tthis.config,\n\t\t\tthis.extensionProviders.get(model.provider),\n\t\t\toverrides,\n\t\t);\n\t}\n\n\t/**\n\t * Monotonic count of changes to any input a catalog refresh reads.\n\t *\n\t * `refresh()` reloads models.json, recomposes every provider from it, the\n\t * extension registrations, and the builtin catalog, resolves credentials as\n\t * it runs, and publishes ONE snapshot at the end. So a pass belongs to the\n\t * inputs it started under, and joining a pass across a bump is unsound in\n\t * both directions: the joiner reads models and credentials the user has\n\t * already replaced, and the pass's late publish overwrites the newer state\n\t * with them.\n\t *\n\t * Every mutation source bumps this counter, which is why callers need only\n\t * this one number rather than a growing tuple of per-input keys:\n\t *\n\t * - credential writes — `login`, `logout`, `saveCredential`,\n\t * `setRuntimeApiKey`, `removeRuntimeApiKey`, an external\n\t * `reloadCredentials`, and an applied external auth status;\n\t * - provider registrations — `registerProvider`, `registerNativeProvider`,\n\t * and `unregisterProvider`, through the refresh they schedule;\n\t * - models.json content — provider `baseUrl`, `apiKey`, `api`, headers,\n\t * model definitions, and overrides, which every pass reloads.\n\t *\n\t * The first two are this runtime's own writes and bump where they happen.\n\t * The third is an external edit nothing here observes, so reading the\n\t * generation samples the file and bumps when its content moved since the\n\t * last sample. That read is synchronous so the answer belongs to the same\n\t * tick as the decision that depends on it, and it hashes content rather\n\t * than trusting an mtime: a same-size rewrite inside one filesystem\n\t * timestamp tick — an edited key, a renamed model — is exactly the change a\n\t * shared pass must not hide.\n\t */\n\tgetCatalogInputsGeneration(): number {\n\t\tthis.observeModelsFile();\n\t\treturn this.catalogInputsGeneration;\n\t}\n\n\t/**\n\t * Record that an input a catalog refresh reads changed. Every pass started\n\t * before this call answers for inputs that no longer exist.\n\t */\n\tprivate markCatalogInputsChanged(): void {\n\t\tthis.catalogInputsGeneration += 1;\n\t}\n\n\t/** Bump the generation when models.json changed since the last observation. */\n\tprivate observeModelsFile(): void {\n\t\tconst token = this.readModelsFileToken();\n\t\tif (this.observedModelsFileToken === token) return;\n\t\tconst first = this.observedModelsFileToken === undefined;\n\t\tthis.observedModelsFileToken = token;\n\t\t// The first observation is a baseline, not a change: no pass can predate it.\n\t\tif (!first) this.markCatalogInputsChanged();\n\t}\n\n\tprivate readModelsFileToken(): string {\n\t\tif (!this.modelsPath) return \"none\";\n\t\ttry {\n\t\t\treturn createHash(\"sha1\")\n\t\t\t\t.update(readFileSync(normalizePath(this.modelsPath)))\n\t\t\t\t.digest(\"hex\");\n\t\t} catch (error) {\n\t\t\tconst code = (error as NodeJS.ErrnoException).code;\n\t\t\t// An absent file is a stable state passes can share; any other read\n\t\t\t// failure keys on its own code rather than pretending the file is empty.\n\t\t\treturn code === \"ENOENT\" ? \"absent\" : `unreadable:${code ?? \"unknown\"}`;\n\t\t}\n\t}\n\n\t/** Reload credentials changed by the authoritative isolated engine and update auth status snapshots. */\n\tasync reloadCredentials(options: { refreshAvailability?: boolean } = {}): Promise<void> {\n\t\tawait this.credentials.reload();\n\t\tthis.markCatalogInputsChanged();\n\t\tif (options.refreshAvailability === false) {\n\t\t\tconst credentials = await this.credentials.list();\n\t\t\tfor (const credential of credentials) this.externalProviderAuthStatuses.delete(credential.providerId);\n\t\t\tthis.snapshotGeneration += 1;\n\t\t\tthis.snapshot = replaceStoredCredentialProviders(this.snapshot, credentials);\n\t\t\treturn;\n\t\t}\n\t\tawait this.queueAvailabilityRefresh();\n\t}\n\n\tprivate assertCredentialRefreshSucceeded(\n\t\tproviderId: string,\n\t\tresult: ModelsRefreshResult,\n\t\tsignal?: AbortSignal,\n\t): void {\n\t\tif (result.aborted) {\n\t\t\tsignal?.throwIfAborted();\n\t\t\tthrow new Error(`Model refresh aborted for ${providerId}`);\n\t\t}\n\t\tconst refreshError = result.errors.get(providerId);\n\t\tif (refreshError) throw refreshError;\n\t\tconst compositionError = this.compositionErrors.get(providerId);\n\t\tif (compositionError) throw new Error(compositionError);\n\t}\n\n\tprivate enqueueCredentialOperation<T>(providerId: string, signal: AbortSignal, task: () => Promise<T>): Promise<T> {\n\t\tconst previous = this.credentialOperations.get(providerId) ?? Promise.resolve();\n\t\tlet markStarted: (() => void) | undefined;\n\t\tconst started = new Promise<void>((resolve) => {\n\t\t\tmarkStarted = resolve;\n\t\t});\n\t\tconst operation = (async () => {\n\t\t\tawait previous.catch(() => {});\n\t\t\tsignal.throwIfAborted();\n\t\t\tmarkStarted?.();\n\t\t\treturn task();\n\t\t})();\n\t\tconst tail = operation.catch(() => {});\n\t\tthis.credentialOperations.set(providerId, tail);\n\t\tvoid tail.then(() => {\n\t\t\tif (this.credentialOperations.get(providerId) === tail) this.credentialOperations.delete(providerId);\n\t\t});\n\t\treturn raceWithAbortSignal(started, signal).then(() => operation);\n\t}\n\tprivate async synchronizeCredentialState(\n\t\tproviderId: string,\n\t\toperation: CredentialSynchronizationOperation,\n\t\tcredential: Credential | undefined,\n\t\tsynchronize: () => void | Promise<void>,\n\t): Promise<void> {\n\t\ttry {\n\t\t\tawait synchronize();\n\t\t} catch (cause) {\n\t\t\tif (cause instanceof CredentialSynchronizationError) throw cause;\n\t\t\tthrow new CredentialSynchronizationError(providerId, operation, credential, { cause });\n\t\t}\n\t}\n\tprivate async refreshRemainingAuthAfterLogout(providerId: string, logoutGeneration: number): Promise<void> {\n\t\t// Environment/runtime auth can remain after stored auth is removed. The\n\t\t// probe is normally synchronous, but its deadline is authoritative because\n\t\t// extension checks are third-party code and need not honor cancellation.\n\t\tlet timeout: number | undefined;\n\t\ttry {\n\t\t\tconst remainingAuth = await Promise.race([\n\t\t\t\tthis.checkAuth(providerId).catch(() => undefined),\n\t\t\t\tnew Promise<undefined>((resolve) => {\n\t\t\t\t\ttimeout = setTimeout(resolve, POST_LOGOUT_AUTH_CHECK_TIMEOUT_MS);\n\t\t\t\t}),\n\t\t\t]);\n\t\t\tif (logoutGeneration === this.snapshotGeneration && !this.snapshot.storedProviders.has(providerId)) {\n\t\t\t\tthis.snapshot = removeStoredCredentialProvider(this.snapshot, providerId, remainingAuth);\n\t\t\t}\n\t\t} finally {\n\t\t\tif (timeout) clearTimeout(timeout);\n\t\t}\n\t}\n\n\tasync saveCredential(providerId: string, credential: Credential): Promise<void> {\n\t\tconst signal = operationSignal(undefined);\n\t\tawait this.enqueueCredentialOperation(providerId, signal, async () => {\n\t\t\tawait this.credentials.modify(providerId, async () => credential);\n\t\t\tthis.markCatalogInputsChanged();\n\t\t\tawait this.synchronizeCredentialState(providerId, \"saveCredential\", credential, async () => {\n\t\t\t\tconst result = await this.refresh({ providers: [providerId] });\n\t\t\t\tthis.assertCredentialRefreshSucceeded(providerId, result);\n\t\t\t});\n\t\t});\n\t}\n\t/**\n\t * Apply a process-scoped API key override. This publishes the provider against\n\t * the current snapshot and deliberately does not refresh the model catalog;\n\t * callers needing catalog freshness call refresh({ providers: [providerId], signal })\n\t * separately.\n\t */\n\tasync setRuntimeApiKey(providerId: string, apiKey: string, options: AuthOperationOptions): Promise<void> {\n\t\tconst signal = operationSignal(options.signal);\n\t\tawait this.enqueueCredentialOperation(providerId, signal, async () => {\n\t\t\tthis.credentials.setRuntimeApiKey(providerId, apiKey);\n\t\t\tthis.markCatalogInputsChanged();\n\t\t\tawait this.synchronizeCredentialState(providerId, \"setRuntimeApiKey\", { type: \"api_key\", key: apiKey }, () => {\n\t\t\t\tthis.snapshot = addRuntimeApiKeyProvider(this.snapshot, providerId);\n\t\t\t});\n\t\t});\n\t}\n\n\tasync removeRuntimeApiKey(providerId: string, options: AuthOperationOptions = {}): Promise<void> {\n\t\tconst signal = operationSignal(options.signal);\n\t\tawait this.enqueueCredentialOperation(providerId, signal, async () => {\n\t\t\tthis.credentials.removeRuntimeApiKey(providerId);\n\t\t\tthis.markCatalogInputsChanged();\n\t\t\tawait this.synchronizeCredentialState(providerId, \"removeRuntimeApiKey\", undefined, async () => {\n\t\t\t\tconst result = await this.refresh({ allowNetwork: this.modelNetworkEnabled, signal });\n\t\t\t\tthis.assertCredentialRefreshSucceeded(providerId, result, signal);\n\t\t\t});\n\t\t});\n\t}\n\n\tlistCredentials(): Promise<readonly CredentialInfo[]> {\n\t\treturn this.credentials.list();\n\t}\n\n\tgetStoredCredentialType(providerId: string): CredentialInfo[\"type\"] | undefined {\n\t\treturn this.snapshot.storedCredentialTypes.get(providerId);\n\t}\n\n\tgetProviderAuthStatus(providerId: string): AuthStatus {\n\t\tconst localStatus = getSnapshotProviderAuthStatus(\n\t\t\tthis.snapshot,\n\t\t\tproviderId,\n\t\t\tthis.credentials.hasRuntimeApiKey(providerId),\n\t\t\tconfiguredRequestAuthStatus(this.config.getProvider(providerId), this.extensionProviders.get(providerId)),\n\t\t);\n\t\tif (localStatus.source === \"stored\" || localStatus.source === \"runtime\") return localStatus;\n\t\treturn this.externalProviderAuthStatuses.get(providerId) ?? localStatus;\n\t}\n\n\t/** Apply authoritative auth state returned by an isolated engine mutation. */\n\tapplyExternalProviderAuthStatus(providerId: string, status: AuthStatus): void {\n\t\tthis.markCatalogInputsChanged();\n\t\tthis.snapshotGeneration += 1;\n\t\tconst remainingAuth =\n\t\t\tstatus.configured && status.source === \"environment\"\n\t\t\t\t? ({ type: \"api_key\", source: status.label ?? \"environment\" } as const)\n\t\t\t\t: undefined;\n\t\tthis.snapshot = removeStoredCredentialProvider(this.snapshot, providerId, remainingAuth);\n\t\tthis.externalProviderAuthStatuses.set(providerId, status);\n\t}\n\n\tstream<TApi extends Api>(\n\t\tmodel: Model<TApi>,\n\t\tcontext: Context,\n\t\toptions?: ModelsApiStreamOptions<TApi>,\n\t): AssistantMessageEventStream {\n\t\treturn this.streaming.stream(model, context, options);\n\t}\n\n\tcomplete<TApi extends Api>(\n\t\tmodel: Model<TApi>,\n\t\tcontext: Context,\n\t\toptions?: ModelsApiStreamOptions<TApi>,\n\t): Promise<AssistantMessage> {\n\t\treturn this.streaming.complete(model, context, options);\n\t}\n\n\tstreamSimple(model: Model<Api>, context: Context, options?: ModelsSimpleStreamOptions): AssistantMessageEventStream {\n\t\treturn this.streaming.streamSimple(model, context, options);\n\t}\n\n\tcompleteSimple(model: Model<Api>, context: Context, options?: ModelsSimpleStreamOptions): Promise<AssistantMessage> {\n\t\treturn this.streaming.completeSimple(model, context, options);\n\t}\n\n\tfetchDeferred(\n\t\tmodel: Model<Api>,\n\t\thandle: DeferredHandle,\n\t\toptions?: ModelsDeferredFetchOptions,\n\t): Promise<AssistantMessage> {\n\t\treturn this.streaming.fetchDeferred(model, handle, options);\n\t}\n\n\tcancelDeferred(model: Model<Api>, handle: DeferredHandle, options?: ModelsDeferredCancelOptions): Promise<void> {\n\t\treturn this.streaming.cancelDeferred(model, handle, options);\n\t}\n\n\tasync login(providerId: string, type: AuthType, interaction: AuthInteraction): Promise<Credential> {\n\t\tconst signal = operationSignal(interaction.signal);\n\t\treturn this.enqueueCredentialOperation(providerId, signal, async () => {\n\t\t\tconst credential = await this.models.login(providerId, type, { ...interaction, signal });\n\t\t\tthis.markCatalogInputsChanged();\n\t\t\tawait this.synchronizeCredentialState(providerId, \"login\", credential, () => {\n\t\t\t\t// Credential acquisition and persistence are the login transaction. Publish\n\t\t\t\t// the provider against the current snapshot immediately; catalog restoration,\n\t\t\t\t// ambient availability checks, and networking belong to /model's bounded\n\t\t\t\t// background refresh and must never keep a successful login dialog open.\n\t\t\t\tthis.updateModelSnapshot();\n\t\t\t\tthis.externalProviderAuthStatuses.delete(providerId);\n\t\t\t\tthis.snapshot = addStoredCredentialProvider(this.snapshot, providerId, credential.type);\n\t\t\t});\n\t\t\treturn credential;\n\t\t});\n\t}\n\n\tasync logout(providerId: string, options: AuthOperationOptions = {}): Promise<void> {\n\t\tconst signal = operationSignal(options.signal);\n\t\tconst logoutGeneration = await this.enqueueCredentialOperation(providerId, signal, async () => {\n\t\t\tawait this.models.logout(providerId, { signal });\n\t\t\tthis.markCatalogInputsChanged();\n\t\t\tlet generation = 0;\n\t\t\tawait this.synchronizeCredentialState(providerId, \"logout\", undefined, () => {\n\t\t\t\t// Reset credential-dependent compatibility projections, then publish the\n\t\t\t\t// persisted deletion without waiting for model stores or remote catalogs.\n\t\t\t\tthis.recomposeProvider(providerId);\n\t\t\t\tthis.updateModelSnapshot();\n\t\t\t\tthis.externalProviderAuthStatuses.delete(providerId);\n\t\t\t\tthis.snapshot = removeStoredCredentialProvider(this.snapshot, providerId);\n\t\t\t\tgeneration = this.snapshotGeneration;\n\t\t\t});\n\t\t\treturn generation;\n\t\t});\n\t\tawait this.refreshRemainingAuthAfterLogout(providerId, logoutGeneration);\n\t}\n\n\t/**\n\t * The network policy a refresh with an omitted `allowNetwork` resolves to.\n\t *\n\t * Callers that share one in-flight refresh key on the effective policy, so\n\t * they need the same answer `runRefresh` computes rather than a second guess\n\t * at the offline setting this runtime was created under.\n\t */\n\tisNetworkRefreshEnabled(): boolean {\n\t\treturn this.modelNetworkEnabled;\n\t}\n\tasync refresh(options: ModelsRefreshOptions = {}): Promise<ModelsRefreshResult> {\n\t\treturn this.runRefresh(options, ++this.refreshSequence);\n\t}\n\n\t/**\n\t * A registration's offline catalog pass must not publish after a newer refresh\n\t * that resolves configured credentials.\n\t *\n\t * The registration is also a catalog-input change: it adds, replaces, or drops\n\t * a provider every later pass composes from, so no pass that predates it can\n\t * answer for the provider set a caller now sees.\n\t */\n\tprivate scheduleRegistrationRefresh(): void {\n\t\tthis.markCatalogInputsChanged();\n\t\tconst sequence = ++this.refreshSequence;\n\t\tvoid this.runRefresh({ allowNetwork: false }, sequence, true);\n\t}\n\n\tprivate async runRefresh(\n\t\toptions: ModelsRefreshOptions,\n\t\tsequence: number,\n\t\tdiscardIfSuperseded = false,\n\t): Promise<ModelsRefreshResult> {\n\t\tconst config = await ModelConfig.load(this.modelsPath);\n\t\tif (discardIfSuperseded && sequence !== this.refreshSequence) {\n\t\t\treturn { aborted: true, errors: new Map<string, Error>() };\n\t\t}\n\t\tthis.config = config;\n\t\tthis.configureRadiusProviders();\n\t\tif (options.providers) {\n\t\t\tfor (const providerId of new Set(options.providers)) this.recomposeProvider(providerId);\n\t\t\tthis.updateModelSnapshot();\n\t\t} else this.rebuildProviders();\n\t\tconst refreshOptions = { ...options, allowNetwork: options.allowNetwork ?? this.isNetworkRefreshEnabled() };\n\t\tconst result = await this.models.refresh(refreshOptions);\n\t\tconst errors = new Map(result.errors);\n\t\tthis.updateModelSnapshot();\n\t\tif (options.providers) {\n\t\t\tawait Promise.all(\n\t\t\t\t[...new Set(options.providers)].map(async (providerId) => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait this.refreshProviderAvailability(providerId, operationSignal(options.signal));\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tif (!options.signal?.aborted)\n\t\t\t\t\t\t\terrors.set(providerId, error instanceof Error ? error : new Error(String(error)));\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t);\n\t\t} else {\n\t\t\ttry {\n\t\t\t\tawait this.queueAvailabilityRefresh(options.signal);\n\t\t\t} catch {\n\t\t\t\t// Availability errors are recorded by the latest pass; refreshed models remain usable.\n\t\t\t}\n\t\t}\n\t\treturn { aborted: result.aborted || (options.signal?.aborted ?? false), errors };\n\t}\n\n\tcreateExtensionProviderTransaction(replacedProviderIds: Iterable<string> = []): ExtensionProviderTransaction {\n\t\tconst nativeProviders = new Map(this.nativeExtensionProviders);\n\t\tconst providers = new Map(this.extensionProviders);\n\t\tfor (const providerId of replacedProviderIds) {\n\t\t\tnativeProviders.delete(providerId);\n\t\t\tproviders.delete(providerId);\n\t\t}\n\t\tconst configuredProviders = new Set(this.snapshot.configuredProviders);\n\t\tfor (const providerId of replacedProviderIds) configuredProviders.delete(providerId);\n\t\treturn {\n\t\t\tregisterNativeProvider: (provider) => {\n\t\t\t\tif (!provider.id.trim()) throw new Error(\"Provider id must not be empty.\");\n\t\t\t\tproviders.delete(provider.id);\n\t\t\t\tif (this.snapshot.storedProviders.has(provider.id)) configuredProviders.add(provider.id);\n\t\t\t\tnativeProviders.set(provider.id, provider);\n\t\t\t},\n\t\t\tregisterProvider: (providerId, config) => {\n\t\t\t\tvalidateExtensionProvider(\n\t\t\t\t\tproviderId,\n\t\t\t\t\tthis.builtins.get(providerId),\n\t\t\t\t\tthis.config.getProvider(providerId),\n\t\t\t\t\tconfig,\n\t\t\t\t);\n\t\t\t\tnativeProviders.delete(providerId);\n\t\t\t\tconst effective: ProviderConfigInput = { ...providers.get(providerId) };\n\t\t\t\tfor (const [key, value] of Object.entries(config)) {\n\t\t\t\t\tif (value !== undefined) (effective as Record<string, unknown>)[key] = value;\n\t\t\t\t}\n\t\t\t\tif (\n\t\t\t\t\tthis.snapshot.storedProviders.has(providerId) ||\n\t\t\t\t\tconfiguredRequestAuthStatus(this.config.getProvider(providerId), effective)?.configured\n\t\t\t\t) {\n\t\t\t\t\tconfiguredProviders.add(providerId);\n\t\t\t\t} else configuredProviders.delete(providerId);\n\t\t\t\tproviders.set(providerId, effective);\n\t\t\t},\n\t\t\tunregisterProvider: (providerId) => {\n\t\t\t\tproviders.delete(providerId);\n\t\t\t\tconfiguredProviders.delete(providerId);\n\t\t\t\tnativeProviders.delete(providerId);\n\t\t\t},\n\t\t\thasConfiguredAuth: (providerId) => configuredProviders.has(providerId),\n\t\t\tcommit: async () => {\n\t\t\t\tconst previous = {\n\t\t\t\t\textensionProviders: new Map(this.extensionProviders),\n\t\t\t\t\tnativeExtensionProviders: new Map(this.nativeExtensionProviders),\n\t\t\t\t\tbuiltins: new Map(this.builtins),\n\t\t\t\t\tconfig: this.config,\n\t\t\t\t\tsnapshot: this.snapshot,\n\t\t\t\t\tcompositionErrors: new Map(this.compositionErrors),\n\t\t\t\t};\n\t\t\t\ttry {\n\t\t\t\t\tthis.extensionProviders.clear();\n\t\t\t\t\tfor (const [providerId, config] of providers) this.extensionProviders.set(providerId, config);\n\t\t\t\t\tthis.nativeExtensionProviders.clear();\n\t\t\t\t\tfor (const [providerId, provider] of nativeProviders)\n\t\t\t\t\t\tthis.nativeExtensionProviders.set(providerId, provider);\n\t\t\t\t\tthis.rebuildProviders();\n\t\t\t\t\tthis.markCatalogInputsChanged();\n\t\t\t\t\tawait this.runRefresh({ allowNetwork: false }, ++this.refreshSequence, true);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthis.extensionProviders.clear();\n\t\t\t\t\tfor (const [providerId, config] of previous.extensionProviders)\n\t\t\t\t\t\tthis.extensionProviders.set(providerId, config);\n\t\t\t\t\tthis.nativeExtensionProviders.clear();\n\t\t\t\t\tfor (const [providerId, provider] of previous.nativeExtensionProviders)\n\t\t\t\t\t\tthis.nativeExtensionProviders.set(providerId, provider);\n\t\t\t\t\tthis.builtins.clear();\n\t\t\t\t\tfor (const [providerId, provider] of previous.builtins) this.builtins.set(providerId, provider);\n\t\t\t\t\tthis.config = previous.config;\n\t\t\t\t\tthis.rebuildProviders();\n\t\t\t\t\tthis.snapshot = previous.snapshot;\n\t\t\t\t\tthis.compositionErrors.clear();\n\t\t\t\t\tfor (const [providerId, message] of previous.compositionErrors)\n\t\t\t\t\t\tthis.compositionErrors.set(providerId, message);\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\t}\n\n\tregisterNativeProvider(provider: Provider): void {\n\t\tif (!provider.id.trim()) throw new Error(\"Provider id must not be empty.\");\n\t\tthis.extensionProviders.delete(provider.id);\n\t\tthis.nativeExtensionProviders.set(provider.id, provider);\n\t\tthis.recomposeProvider(provider.id);\n\t\tthis.updateModelSnapshot();\n\t\tthis.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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider-composer-internal.d.ts","sourceRoot":"","sources":["../../src/core/provider-composer-internal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,GAAG,EACH,UAAU,EACV,2BAA2B,EAG3B,OAAO,EACP,KAAK,EAEL,SAAS,EACT,gBAAgB,EAChB,mBAAmB,EACnB,QAAQ,EAGR,oBAAoB,EACpB,mBAAmB,EACnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAmB,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACtG,OAAO,EACN,qBAAqB,EAKrB,MAAM,2BAA2B,CAAC;AAEnC,MAAM,WAAW,oBAAoB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,KAAK,CAAC,SAAS,EAAE,mBAAmB,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACtF;;;;;;OAMG;IACH,YAAY,CAAC,WAAW,EAAE,gBAAgB,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC5F,SAAS,CAAC,WAAW,EAAE,gBAAgB,GAAG,MAAM,CAAC;IACjD,YAAY,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,CAAC,EAAE,EAAE,WAAW,EAAE,gBAAgB,GAAG,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;CACjF;AAED,yDAAyD;AACzD,MAAM,WAAW,mBAAmB;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,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AU,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,QAAQ,GAAG,SAAS,GAAG,aAAa,GAAG,UAAU,GAAG,iBAAiB,GAAG,qBAAqB,CAAC;IACvG,KAAK,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,eAAO,MAAM,gBAAgB,8BAAwB,CAAC;AAwBtD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,uBAAuB,GAAG,KAAK,CAAC,GAAG,CAAC,CAyBnG;
|
|
1
|
+
{"version":3,"file":"provider-composer-internal.d.ts","sourceRoot":"","sources":["../../src/core/provider-composer-internal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,GAAG,EACH,UAAU,EACV,2BAA2B,EAG3B,OAAO,EACP,KAAK,EAEL,SAAS,EACT,gBAAgB,EAChB,mBAAmB,EACnB,QAAQ,EAGR,oBAAoB,EACpB,mBAAmB,EACnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAmB,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACtG,OAAO,EACN,qBAAqB,EAKrB,MAAM,2BAA2B,CAAC;AAEnC,MAAM,WAAW,oBAAoB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,KAAK,CAAC,SAAS,EAAE,mBAAmB,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACtF;;;;;;OAMG;IACH,YAAY,CAAC,WAAW,EAAE,gBAAgB,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC5F,SAAS,CAAC,WAAW,EAAE,gBAAgB,GAAG,MAAM,CAAC;IACjD,YAAY,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,CAAC,EAAE,EAAE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,GAAG,SAAS,EAC1B,MAAM,EAAE,kBAAkB,GAAG,SAAS,EACtC,SAAS,EAAE,mBAAmB,GAAG,SAAS,GACxC,UAAU,GAAG,SAAS,CA2DxB;AAED,wBAAgB,gBAAgB,CAC/B,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,QAAQ,GAAG,SAAS,EAC1B,MAAM,EAAE,kBAAkB,GAAG,SAAS,EACtC,SAAS,EAAE,mBAAmB,GAAG,SAAS,GACxC,SAAS,GAAG,SAAS,CAkBvB;AAED,wBAAgB,eAAe,CAC9B,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,EACjB,MAAM,EAAE,kBAAkB,GAAG,SAAS,EACtC,SAAS,EAAE,mBAAmB,GAAG,SAAS,GACxC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CASpC"}
|
|
@@ -74,6 +74,12 @@ function modelFromJson(providerId, definition, providerConfig, defaults) {
|
|
|
74
74
|
compat: mergeCompat(providerConfig.compat, definition.compat),
|
|
75
75
|
};
|
|
76
76
|
}
|
|
77
|
+
function findModelDefaults(models, modelId, api) {
|
|
78
|
+
return (models.find((model) => model.id === modelId) ??
|
|
79
|
+
(api ? models.find((model) => model.api === api) : undefined) ??
|
|
80
|
+
models.find((model) => model.api === "openai-completions") ??
|
|
81
|
+
models[0]);
|
|
82
|
+
}
|
|
77
83
|
export function applyModelsJson(providerId, baseModels, config) {
|
|
78
84
|
if (!config)
|
|
79
85
|
return [...baseModels];
|
|
@@ -98,7 +104,7 @@ export function applyModelsJson(providerId, baseModels, config) {
|
|
|
98
104
|
}));
|
|
99
105
|
for (const definition of config.models ?? []) {
|
|
100
106
|
const existingIndex = models.findIndex((model) => model.id === definition.id);
|
|
101
|
-
const defaults =
|
|
107
|
+
const defaults = findModelDefaults(models, definition.id, definition.api ?? config.api);
|
|
102
108
|
const model = modelFromJson(providerId, definition, config, defaults);
|
|
103
109
|
if (existingIndex >= 0)
|
|
104
110
|
models[existingIndex] = model;
|
|
@@ -114,7 +120,7 @@ export function applyExtension(providerId, models, config) {
|
|
|
114
120
|
return config.baseUrl ? models.map((model) => ({ ...model, baseUrl: config.baseUrl })) : [...models];
|
|
115
121
|
}
|
|
116
122
|
return config.models.map((definition) => {
|
|
117
|
-
const defaults = models
|
|
123
|
+
const defaults = findModelDefaults(models, definition.id, definition.api ?? config.api);
|
|
118
124
|
const api = definition.api ?? config.api ?? defaults?.api;
|
|
119
125
|
if (!api) {
|
|
120
126
|
throw new Error(`Provider ${providerId}, model ${definition.id}: no "api" specified. Set at provider or model level.`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider-composer-internal.js","sourceRoot":"","sources":["../../src/core/provider-composer-internal.ts"],"names":[],"mappings":"AAmBA,OAAO,EACN,qBAAqB,EACrB,yBAAyB,EACzB,oBAAoB,EACpB,yBAAyB,EACzB,qBAAqB,GACrB,MAAM,2BAA2B,CAAC;AAqDnC,MAAM,CAAC,MAAM,gBAAgB,GAAG,qBAAqB,CAAC;AAEtD,SAAS,WAAW,CACnB,IAA0B,EAC1B,QAAkE;IAElE,IAAI,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC3B,MAAM,MAAM,GAAG,EAAE,GAAG,IAAI,EAAE,GAAG,QAAQ,EAAuC,CAAC;IAC7E,MAAM,UAAU,GAAG,IAA2C,CAAC;IAC/D,MAAM,cAAc,GAAG,QAAmC,CAAC;IAC3D,MAAM,YAAY,GAAG,MAAiC,CAAC;IACvD,KAAK,MAAM,GAAG,IAAI,CAAC,mBAAmB,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,kBAAkB,CAAU,EAAE,CAAC;QACpH,MAAM,SAAS,GAAG,UAAU,EAAE,CAAC,GAAG,CAAC,CAAC;QACpC,MAAM,aAAa,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC;QAC1C,IACC,CAAC,OAAO,SAAS,KAAK,QAAQ,IAAI,SAAS,KAAK,IAAI,CAAC;YACrD,CAAC,OAAO,aAAa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KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;YAC5C,MAAM,GAAG,GAAG,UAAU,CAAC,GAAG,CAAC;YAC3B,MAAM,OAAO,GAAG,qBAAqB,CACpC,UAAU,EACV,aAAa,UAAU,GAAG,EAC1B,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,CAAC,CAAC,CAAE,GAA8B,CAAC,CAAC,CAAC,SAAS,CACrF,CAAC;YACF,OAAO,kBAAkB,CAAC,IAAI,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;QACtD,CAAC;KACD,CAAC;AACH,CAAC;AAED,MAAM,UAAU,eAAe,CAC9B,KAAiB,EACjB,MAAsC,EACtC,SAA0C;IAE1C,MAAM,UAAU,GAAG,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,KAAK,CAAC,EAAE,CAAC,CAAC;IAC1E,MAAM,cAAc,GAAG,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,KAAK,CAAC,EAAE,CAAC,CAAC;IACjF,MAAM,OAAO,GAAG;QACf,GAAG,MAAM,EAAE,cAAc,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,OAAO;QAC9C,GAAG,UAAU,EAAE,OAAO;QACtB,GAAG,cAAc,EAAE,OAAO;KAC1B,CAAC;IACF,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;AAC9D,CAAC","sourcesContent":["import type {\n\tApi,\n\tApiKeyAuth,\n\tAssistantMessageEventStream,\n\tAuthContext,\n\tAuthResult,\n\tContext,\n\tModel,\n\tModelAuth,\n\tOAuthAuth,\n\tOAuthCredentials,\n\tOAuthLoginCallbacks,\n\tProvider,\n\tProviderAuthInteraction,\n\tProviderHeaders,\n\tRefreshModelsContext,\n\tSimpleStreamOptions,\n} from \"@bastani/pi-ai\";\nimport type { ModelsJsonModel, ModelsJsonModelOverride, ModelsJsonProvider } from \"./model-config.ts\";\nimport {\n\tclearConfigValueCache,\n\tgetConfigValueEnvVarNames,\n\tisCommandConfigValue,\n\tresolveConfigValueOrThrow,\n\tresolveHeadersOrThrow,\n} from \"./resolve-config-value.ts\";\n\nexport interface ExtensionOAuthConfig {\n\tname: string;\n\tloginLabel?: string;\n\tusesCallbackServer?: boolean;\n\tlogin(callbacks: OAuthLoginCallbacks, signal: AbortSignal): Promise<OAuthCredentials>;\n\t/**\n\t * Refresh expired credentials. `signal` is the caller's cancellation signal,\n\t * forwarded by pi through `oauth.refresh(credential, signal)`; honor it by\n\t * passing it into whatever performs the network call. It is a required\n\t * parameter rather than an optional one so the contract cannot be satisfied\n\t * by ignoring cancellation.\n\t */\n\trefreshToken(credentials: OAuthCredentials, signal: AbortSignal): Promise<OAuthCredentials>;\n\tgetApiKey(credentials: OAuthCredentials): string;\n\tmodifyModels?(models: Model<Api>[], credentials: OAuthCredentials): Model<Api>[];\n}\n\n/** Input type for the extension registerProvider API. */\nexport interface ProviderConfigInput {\n\tname?: string;\n\tbaseUrl?: string;\n\tapiKey?: string;\n\tapi?: Api;\n\tstreamSimple?: (model: Model<Api>, context: Context, options?: SimpleStreamOptions) => AssistantMessageEventStream;\n\theaders?: Record<string, string>;\n\tauthHeader?: boolean;\n\toauth?: ExtensionOAuthConfig;\n\tmodels?: Array<{\n\t\tid: string;\n\t\tname: string;\n\t\tapi?: Api;\n\t\tbaseUrl?: string;\n\t\treasoning: boolean;\n\t\tthinkingLevelMap?: Model<Api>[\"thinkingLevelMap\"];\n\t\tinput: Model<Api>[\"input\"];\n\t\tcost: Model<Api>[\"cost\"];\n\t\tcontextWindow: number;\n\t\tmaxTokens: number;\n\t\tsamplingParams?: Record<string, unknown>;\n\t\theaders?: Record<string, string>;\n\t\tcompat?: Model<Api>[\"compat\"];\n\t}>;\n\trefreshModels?(context: RefreshModelsContext): Promise<NonNullable<ProviderConfigInput[\"models\"]>>;\n}\n\nexport type AuthStatus = {\n\tconfigured: boolean;\n\tsource?: \"stored\" | \"runtime\" | \"environment\" | \"fallback\" | \"models_json_key\" | \"models_json_command\";\n\tlabel?: string;\n};\n\nexport const clearApiKeyCache = clearConfigValueCache;\n\nfunction mergeCompat(\n\tbase: Model<Api>[\"compat\"],\n\toverride: Model<Api>[\"compat\"] | ModelsJsonModelOverride[\"compat\"],\n): Model<Api>[\"compat\"] {\n\tif (!override) return base;\n\tconst merged = { ...base, ...override } as NonNullable<Model<Api>[\"compat\"]>;\n\tconst baseNested = base as Record<string, unknown> | undefined;\n\tconst overrideNested = override as Record<string, unknown>;\n\tconst mergedNested = merged as Record<string, unknown>;\n\tfor (const key of [\"openRouterRouting\", \"vercelGatewayRouting\", \"chatTemplateKwargs\", \"chatTemplateArgs\"] as const) {\n\t\tconst baseValue = baseNested?.[key];\n\t\tconst overrideValue = overrideNested[key];\n\t\tif (\n\t\t\t(typeof baseValue === \"object\" && baseValue !== null) ||\n\t\t\t(typeof overrideValue === \"object\" && overrideValue !== null)\n\t\t) {\n\t\t\tmergedNested[key] = { ...(baseValue as object | undefined), ...(overrideValue as object | undefined) };\n\t\t}\n\t}\n\treturn merged;\n}\n\nexport function applyModelOverride(model: Model<Api>, override: ModelsJsonModelOverride): Model<Api> {\n\treturn {\n\t\t...model,\n\t\tname: override.name ?? model.name,\n\t\treasoning: override.reasoning ?? model.reasoning,\n\t\tthinkingLevelMap: override.thinkingLevelMap\n\t\t\t? { ...model.thinkingLevelMap, ...override.thinkingLevelMap }\n\t\t\t: model.thinkingLevelMap,\n\t\tinput: (override.input as Model<Api>[\"input\"] | undefined) ?? model.input,\n\t\tcost: override.cost\n\t\t\t? {\n\t\t\t\t\tinput: override.cost.input ?? model.cost.input,\n\t\t\t\t\toutput: override.cost.output ?? model.cost.output,\n\t\t\t\t\tcacheRead: override.cost.cacheRead ?? model.cost.cacheRead,\n\t\t\t\t\tcacheWrite: override.cost.cacheWrite ?? model.cost.cacheWrite,\n\t\t\t\t\ttiers: override.cost.tiers ?? model.cost.tiers,\n\t\t\t\t}\n\t\t\t: model.cost,\n\t\tcontextWindow: override.contextWindow ?? model.contextWindow,\n\t\tmaxTokens: override.maxTokens ?? model.maxTokens,\n\t\tsamplingParams: override.samplingParams\n\t\t\t? { ...model.samplingParams, ...override.samplingParams }\n\t\t\t: model.samplingParams,\n\t\tcompat: mergeCompat(model.compat, override.compat),\n\t};\n}\n\nfunction modelFromJson(\n\tproviderId: string,\n\tdefinition: ModelsJsonModel,\n\tproviderConfig: ModelsJsonProvider,\n\tdefaults: Model<Api> | undefined,\n): Model<Api> {\n\tconst api = definition.api ?? providerConfig.api ?? defaults?.api;\n\tif (!api) {\n\t\tthrow new Error(\n\t\t\t`Provider ${providerId}, model ${definition.id}: no \"api\" specified. Set at provider or model level.`,\n\t\t);\n\t}\n\tconst baseUrl = definition.baseUrl ?? providerConfig.baseUrl ?? defaults?.baseUrl;\n\tif (!baseUrl) throw new Error(`Provider ${providerId}: \"baseUrl\" is required when defining custom models.`);\n\tif (definition.contextWindow !== undefined && definition.contextWindow <= 0) {\n\t\tthrow new Error(`Provider ${providerId}, model ${definition.id}: invalid contextWindow`);\n\t}\n\tif (definition.maxTokens !== undefined && definition.maxTokens <= 0) {\n\t\tthrow new Error(`Provider ${providerId}, model ${definition.id}: invalid maxTokens`);\n\t}\n\treturn {\n\t\tid: definition.id,\n\t\tname: definition.name ?? definition.id,\n\t\tapi: api as Api,\n\t\tprovider: providerId,\n\t\tbaseUrl,\n\t\treasoning: definition.reasoning ?? false,\n\t\tthinkingLevelMap: definition.thinkingLevelMap,\n\t\tinput: (definition.input ?? [\"text\"]) as Model<Api>[\"input\"],\n\t\tcost: definition.cost ?? { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },\n\t\tcontextWindow: definition.contextWindow ?? 128000,\n\t\tmaxTokens: definition.maxTokens ?? 16384,\n\t\tsamplingParams: definition.samplingParams,\n\t\theaders: undefined,\n\t\tcompat: mergeCompat(providerConfig.compat, definition.compat),\n\t};\n}\n\nexport function applyModelsJson(\n\tproviderId: string,\n\tbaseModels: readonly Model<Api>[],\n\tconfig: ModelsJsonProvider | undefined,\n): Model<Api>[] {\n\tif (!config) return [...baseModels];\n\tif (config.oauth && !config.baseUrl) {\n\t\tthrow new Error(`Provider ${providerId}: \"baseUrl\" is required when \"oauth\" is set.`);\n\t}\n\tconst hasOverrides = config.modelOverrides && Object.keys(config.modelOverrides).length > 0;\n\tif (\n\t\t!config.models?.length &&\n\t\t!config.baseUrl &&\n\t\t!config.headers &&\n\t\t!config.compat &&\n\t\t!hasOverrides &&\n\t\t!config.apiKey &&\n\t\t!config.oauth &&\n\t\tconfig.authHeader === undefined\n\t) {\n\t\tthrow new Error(\n\t\t\t`Provider ${providerId}: must specify \"baseUrl\", \"headers\", \"compat\", \"modelOverrides\", or \"models\".`,\n\t\t);\n\t}\n\n\tconst models: Model<Api>[] = baseModels.map((model) => ({\n\t\t...model,\n\t\tbaseUrl: config.oauth === \"radius\" ? model.baseUrl : (config.baseUrl ?? model.baseUrl),\n\t\tcompat: mergeCompat(model.compat, config.compat),\n\t}));\n\tfor (const definition of config.models ?? []) {\n\t\tconst existingIndex = models.findIndex((model) => model.id === definition.id);\n\t\tconst defaults = existingIndex >= 0 ? models[existingIndex] : models[0];\n\t\tconst model = modelFromJson(providerId, definition, config, defaults);\n\t\tif (existingIndex >= 0) models[existingIndex] = model;\n\t\telse models.push(model);\n\t}\n\treturn models;\n}\n\nexport function applyExtension(\n\tproviderId: string,\n\tmodels: readonly Model<Api>[],\n\tconfig: ProviderConfigInput | undefined,\n): Model<Api>[] {\n\tif (!config) return [...models];\n\tif (!config.models) {\n\t\treturn config.baseUrl ? models.map((model) => ({ ...model, baseUrl: config.baseUrl! })) : [...models];\n\t}\n\treturn config.models.map((definition) => {\n\t\tconst defaults = models.find((model) => model.id === definition.id) ?? models[0];\n\t\tconst api = definition.api ?? config.api ?? defaults?.api;\n\t\tif (!api) {\n\t\t\tthrow new Error(\n\t\t\t\t`Provider ${providerId}, model ${definition.id}: no \"api\" specified. Set at provider or model level.`,\n\t\t\t);\n\t\t}\n\t\tconst baseUrl = definition.baseUrl ?? config.baseUrl ?? defaults?.baseUrl;\n\t\tif (!baseUrl) throw new Error(`Provider ${providerId}: \"baseUrl\" is required when defining custom models.`);\n\t\treturn {\n\t\t\t...definition,\n\t\t\tapi,\n\t\t\tprovider: providerId,\n\t\t\tbaseUrl,\n\t\t\theaders: undefined,\n\t\t};\n\t});\n}\n\nfunction adaptOAuth(config: ExtensionOAuthConfig): OAuthAuth {\n\treturn {\n\t\tname: config.name,\n\t\tlogin: async (callbacks) => {\n\t\t\tconst legacyCallbacks: OAuthLoginCallbacks & {\n\t\t\t\tonInfo(message: string, links: readonly { label?: string; url: string }[]): void;\n\t\t\t} = {\n\t\t\t\tonAuth: (info) => callbacks.notify({ type: \"auth_url\", ...info }),\n\t\t\t\tonDeviceCode: (info) => callbacks.notify({ type: \"device_code\", ...info }),\n\t\t\t\tonPrompt: (prompt) => callbacks.prompt({ type: \"text\", ...prompt }),\n\t\t\t\tonProgress: (message) => callbacks.notify({ type: \"progress\", message }),\n\t\t\t\tonInfo: (message, links) => callbacks.notify({ type: \"info\", message, links }),\n\t\t\t\tonManualCodeInput: () => callbacks.prompt({ type: \"manual_code\", message: \"Paste the authorization code\" }),\n\t\t\t\tonSelect: (prompt) => callbacks.prompt({ type: \"select\", ...prompt }),\n\t\t\t\tsignal: callbacks.signal,\n\t\t\t};\n\t\t\tconst credential = await config.login(legacyCallbacks, callbacks.signal);\n\t\t\treturn { ...credential, type: \"oauth\" };\n\t\t},\n\t\trefresh: async (credential, signal) => ({ ...(await config.refreshToken(credential, signal)), type: \"oauth\" }),\n\t\ttoAuth: async (credential) => ({ apiKey: config.getApiKey(credential) }),\n\t};\n}\n\nfunction withConfiguredAuth(\n\tauth: ModelAuth,\n\theaders: Record<string, string> | undefined,\n\tauthHeader: boolean,\n): ModelAuth {\n\tlet mergedHeaders: ProviderHeaders | undefined =\n\t\tauth.headers || headers ? { ...auth.headers, ...headers } : undefined;\n\tif (authHeader) {\n\t\tif (!auth.apiKey) throw new Error(\"authHeader requires a resolved API key\");\n\t\tmergedHeaders = { ...mergedHeaders, Authorization: `Bearer ${auth.apiKey}` };\n\t}\n\treturn { ...auth, headers: mergedHeaders };\n}\n\nexport function configuredApiKey(\n\tconfig: ModelsJsonProvider | undefined,\n\textension: ProviderConfigInput | undefined,\n): string | undefined {\n\treturn extension?.apiKey ?? config?.apiKey;\n}\n\nexport function configuredHeaders(\n\tconfig: ModelsJsonProvider | undefined,\n\textension: ProviderConfigInput | undefined,\n): Record<string, string> | undefined {\n\tif (!config?.headers && !extension?.headers) return undefined;\n\treturn { ...config?.headers, ...extension?.headers };\n}\n\nasync function configContextEnv(\n\tvalues: readonly string[],\n\tctx: AuthContext,\n\texplicit?: Record<string, string>,\n): Promise<Record<string, string> | undefined> {\n\tconst env = { ...explicit };\n\tfor (const name of new Set(values.flatMap(getConfigValueEnvVarNames))) {\n\t\tif (env[name] !== undefined) continue;\n\t\tconst value = await ctx.env(name);\n\t\tif (value !== undefined) env[name] = value;\n\t}\n\treturn Object.keys(env).length > 0 ? env : undefined;\n}\n\nexport function composeApiKeyAuth(\n\tproviderId: string,\n\tbase: Provider | undefined,\n\tconfig: ModelsJsonProvider | undefined,\n\textension: ProviderConfigInput | undefined,\n): ApiKeyAuth | undefined {\n\tconst inherited = base?.auth.apiKey;\n\tconst rawKey = configuredApiKey(config, extension);\n\tconst oauth = extension?.oauth ?? base?.auth.oauth;\n\t// OAuth-only providers get no fabricated API-key login method.\n\tif (!inherited && rawKey === undefined && oauth) return undefined;\n\tconst rawHeaders = configuredHeaders(config, extension);\n\tconst authHeader = extension?.authHeader ?? config?.authHeader ?? false;\n\treturn {\n\t\tname: inherited?.name ?? \"API key\",\n\t\tlogin:\n\t\t\tinherited?.login ??\n\t\t\t(async (interaction: ProviderAuthInteraction) => ({\n\t\t\t\ttype: \"api_key\",\n\t\t\t\tkey: await interaction.prompt({ type: \"secret\", message: \"Enter API key\" }),\n\t\t\t})),\n\t\tcheck: async (input) => {\n\t\t\tif (input.credential) {\n\t\t\t\tif (inherited?.check) return inherited.check(input);\n\t\t\t\tif (input.credential.key) return { type: \"api_key\", source: \"stored credential\" };\n\t\t\t\tconst resolved = await inherited?.resolve(input);\n\t\t\t\treturn resolved ? { type: \"api_key\", source: resolved.source } : undefined;\n\t\t\t}\n\t\t\tif (rawKey !== undefined) {\n\t\t\t\tif (isCommandConfigValue(rawKey)) return { type: \"api_key\", source: \"configured API key\" };\n\t\t\t\tconst envNames = getConfigValueEnvVarNames(rawKey);\n\t\t\t\tfor (const name of envNames) {\n\t\t\t\t\tif ((await input.ctx.env(name)) === undefined) return undefined;\n\t\t\t\t}\n\t\t\t\treturn { type: \"api_key\", source: \"configured API key\" };\n\t\t\t}\n\t\t\tif (inherited?.check) return inherited.check(input);\n\t\t\tconst resolved = await inherited?.resolve(input);\n\t\t\treturn resolved ? { type: \"api_key\", source: resolved.source } : undefined;\n\t\t},\n\t\tresolve: async (input) => {\n\t\t\tlet result: AuthResult | undefined;\n\t\t\tif (input.credential) {\n\t\t\t\tresult = inherited\n\t\t\t\t\t? await inherited.resolve(input)\n\t\t\t\t\t: input.credential.key\n\t\t\t\t\t\t? { auth: { apiKey: input.credential.key }, env: input.credential.env, source: \"stored credential\" }\n\t\t\t\t\t\t: undefined;\n\t\t\t} else if (rawKey !== undefined) {\n\t\t\t\tconst env = await configContextEnv([rawKey], input.ctx);\n\t\t\t\tconst key = resolveConfigValueOrThrow(rawKey, `API key for provider \"${providerId}\"`, env);\n\t\t\t\tresult = inherited\n\t\t\t\t\t? await inherited.resolve({ ...input, credential: { type: \"api_key\", key } })\n\t\t\t\t\t: { auth: { apiKey: key }, source: \"configured API key\" };\n\t\t\t} else {\n\t\t\t\tresult = await inherited?.resolve(input);\n\t\t\t}\n\t\t\tif (!result) return undefined;\n\t\t\tconst explicitEnv = { ...(input.credential?.env ?? {}), ...(result.env ?? {}) };\n\t\t\tconst headerEnv = await configContextEnv(Object.values(rawHeaders ?? {}), input.ctx, explicitEnv);\n\t\t\tconst headers = resolveHeadersOrThrow(rawHeaders, `provider \"${providerId}\"`, headerEnv);\n\t\t\treturn { ...result, auth: withConfiguredAuth(result.auth, headers, authHeader) };\n\t\t},\n\t};\n}\n\nexport function composeOAuthAuth(\n\tproviderId: string,\n\tbase: Provider | undefined,\n\tconfig: ModelsJsonProvider | undefined,\n\textension: ProviderConfigInput | undefined,\n): OAuthAuth | undefined {\n\tconst oauth = extension?.oauth ? adaptOAuth(extension.oauth) : base?.auth.oauth;\n\tif (!oauth) return undefined;\n\tconst rawHeaders = configuredHeaders(config, extension);\n\tconst authHeader = extension?.authHeader ?? config?.authHeader ?? false;\n\treturn {\n\t\t...oauth,\n\t\ttoAuth: async (credential) => {\n\t\t\tconst auth = await oauth.toAuth(credential);\n\t\t\tconst env = credential.env;\n\t\t\tconst headers = resolveHeadersOrThrow(\n\t\t\t\trawHeaders,\n\t\t\t\t`provider \"${providerId}\"`,\n\t\t\t\ttypeof env === \"object\" && env !== null ? (env as Record<string, string>) : undefined,\n\t\t\t);\n\t\t\treturn withConfiguredAuth(auth, headers, authHeader);\n\t\t},\n\t};\n}\n\nexport function rawModelHeaders(\n\tmodel: Model<Api>,\n\tconfig: ModelsJsonProvider | undefined,\n\textension: ProviderConfigInput | undefined,\n): Record<string, string> | undefined {\n\tconst definition = config?.models?.find((entry) => entry.id === model.id);\n\tconst extensionModel = extension?.models?.find((entry) => entry.id === model.id);\n\tconst headers = {\n\t\t...config?.modelOverrides?.[model.id]?.headers,\n\t\t...definition?.headers,\n\t\t...extensionModel?.headers,\n\t};\n\treturn Object.keys(headers).length > 0 ? headers : undefined;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"provider-composer-internal.js","sourceRoot":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vider,\n\tProviderAuthInteraction,\n\tProviderHeaders,\n\tRefreshModelsContext,\n\tSimpleStreamOptions,\n} from \"@bastani/pi-ai\";\nimport type { ModelsJsonModel, ModelsJsonModelOverride, ModelsJsonProvider } from \"./model-config.ts\";\nimport {\n\tclearConfigValueCache,\n\tgetConfigValueEnvVarNames,\n\tisCommandConfigValue,\n\tresolveConfigValueOrThrow,\n\tresolveHeadersOrThrow,\n} from \"./resolve-config-value.ts\";\n\nexport interface ExtensionOAuthConfig {\n\tname: string;\n\tloginLabel?: string;\n\tusesCallbackServer?: boolean;\n\tlogin(callbacks: OAuthLoginCallbacks, signal: AbortSignal): Promise<OAuthCredentials>;\n\t/**\n\t * Refresh expired credentials. `signal` is the caller's cancellation signal,\n\t * forwarded by pi through `oauth.refresh(credential, signal)`; honor it by\n\t * passing it into whatever performs the network call. It is a required\n\t * parameter rather than an optional one so the contract cannot be satisfied\n\t * by ignoring cancellation.\n\t */\n\trefreshToken(credentials: OAuthCredentials, signal: AbortSignal): Promise<OAuthCredentials>;\n\tgetApiKey(credentials: OAuthCredentials): string;\n\tmodifyModels?(models: Model<Api>[], credentials: OAuthCredentials): Model<Api>[];\n}\n\n/** Input type for the extension registerProvider API. */\nexport interface ProviderConfigInput {\n\tname?: string;\n\tbaseUrl?: string;\n\tapiKey?: string;\n\tapi?: Api;\n\tstreamSimple?: (model: Model<Api>, context: Context, options?: SimpleStreamOptions) => AssistantMessageEventStream;\n\theaders?: Record<string, string>;\n\tauthHeader?: boolean;\n\toauth?: ExtensionOAuthConfig;\n\tmodels?: Array<{\n\t\tid: string;\n\t\tname: string;\n\t\tapi?: Api;\n\t\tbaseUrl?: string;\n\t\treasoning: boolean;\n\t\tthinkingLevelMap?: Model<Api>[\"thinkingLevelMap\"];\n\t\tinput: Model<Api>[\"input\"];\n\t\tcost: Model<Api>[\"cost\"];\n\t\tcontextWindow: number;\n\t\tmaxTokens: number;\n\t\tsamplingParams?: Record<string, unknown>;\n\t\theaders?: Record<string, string>;\n\t\tcompat?: Model<Api>[\"compat\"];\n\t}>;\n\trefreshModels?(context: RefreshModelsContext): Promise<NonNullable<ProviderConfigInput[\"models\"]>>;\n}\n\nexport type AuthStatus = {\n\tconfigured: boolean;\n\tsource?: \"stored\" | \"runtime\" | \"environment\" | \"fallback\" | \"models_json_key\" | \"models_json_command\";\n\tlabel?: string;\n};\n\nexport const clearApiKeyCache = clearConfigValueCache;\n\nfunction mergeCompat(\n\tbase: Model<Api>[\"compat\"],\n\toverride: Model<Api>[\"compat\"] | ModelsJsonModelOverride[\"compat\"],\n): Model<Api>[\"compat\"] {\n\tif (!override) return base;\n\tconst merged = { ...base, ...override } as NonNullable<Model<Api>[\"compat\"]>;\n\tconst baseNested = base as Record<string, unknown> | undefined;\n\tconst overrideNested = override as Record<string, unknown>;\n\tconst mergedNested = merged as Record<string, unknown>;\n\tfor (const key of [\"openRouterRouting\", \"vercelGatewayRouting\", \"chatTemplateKwargs\", \"chatTemplateArgs\"] as const) {\n\t\tconst baseValue = baseNested?.[key];\n\t\tconst overrideValue = overrideNested[key];\n\t\tif (\n\t\t\t(typeof baseValue === \"object\" && baseValue !== null) ||\n\t\t\t(typeof overrideValue === \"object\" && overrideValue !== null)\n\t\t) {\n\t\t\tmergedNested[key] = { ...(baseValue as object | undefined), ...(overrideValue as object | undefined) };\n\t\t}\n\t}\n\treturn merged;\n}\n\nexport function applyModelOverride(model: Model<Api>, override: ModelsJsonModelOverride): Model<Api> {\n\treturn {\n\t\t...model,\n\t\tname: override.name ?? model.name,\n\t\treasoning: override.reasoning ?? model.reasoning,\n\t\tthinkingLevelMap: override.thinkingLevelMap\n\t\t\t? { ...model.thinkingLevelMap, ...override.thinkingLevelMap }\n\t\t\t: model.thinkingLevelMap,\n\t\tinput: (override.input as Model<Api>[\"input\"] | undefined) ?? model.input,\n\t\tcost: override.cost\n\t\t\t? {\n\t\t\t\t\tinput: override.cost.input ?? model.cost.input,\n\t\t\t\t\toutput: override.cost.output ?? model.cost.output,\n\t\t\t\t\tcacheRead: override.cost.cacheRead ?? model.cost.cacheRead,\n\t\t\t\t\tcacheWrite: override.cost.cacheWrite ?? model.cost.cacheWrite,\n\t\t\t\t\ttiers: override.cost.tiers ?? model.cost.tiers,\n\t\t\t\t}\n\t\t\t: model.cost,\n\t\tcontextWindow: override.contextWindow ?? model.contextWindow,\n\t\tmaxTokens: override.maxTokens ?? model.maxTokens,\n\t\tsamplingParams: override.samplingParams\n\t\t\t? { ...model.samplingParams, ...override.samplingParams }\n\t\t\t: model.samplingParams,\n\t\tcompat: mergeCompat(model.compat, override.compat),\n\t};\n}\n\nfunction modelFromJson(\n\tproviderId: string,\n\tdefinition: ModelsJsonModel,\n\tproviderConfig: ModelsJsonProvider,\n\tdefaults: Model<Api> | undefined,\n): Model<Api> {\n\tconst api = definition.api ?? providerConfig.api ?? defaults?.api;\n\tif (!api) {\n\t\tthrow new Error(\n\t\t\t`Provider ${providerId}, model ${definition.id}: no \"api\" specified. Set at provider or model level.`,\n\t\t);\n\t}\n\tconst baseUrl = definition.baseUrl ?? providerConfig.baseUrl ?? defaults?.baseUrl;\n\tif (!baseUrl) throw new Error(`Provider ${providerId}: \"baseUrl\" is required when defining custom models.`);\n\tif (definition.contextWindow !== undefined && definition.contextWindow <= 0) {\n\t\tthrow new Error(`Provider ${providerId}, model ${definition.id}: invalid contextWindow`);\n\t}\n\tif (definition.maxTokens !== undefined && definition.maxTokens <= 0) {\n\t\tthrow new Error(`Provider ${providerId}, model ${definition.id}: invalid maxTokens`);\n\t}\n\treturn {\n\t\tid: definition.id,\n\t\tname: definition.name ?? definition.id,\n\t\tapi: api as Api,\n\t\tprovider: providerId,\n\t\tbaseUrl,\n\t\treasoning: definition.reasoning ?? false,\n\t\tthinkingLevelMap: definition.thinkingLevelMap,\n\t\tinput: (definition.input ?? [\"text\"]) as Model<Api>[\"input\"],\n\t\tcost: definition.cost ?? { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },\n\t\tcontextWindow: definition.contextWindow ?? 128000,\n\t\tmaxTokens: definition.maxTokens ?? 16384,\n\t\tsamplingParams: definition.samplingParams,\n\t\theaders: undefined,\n\t\tcompat: mergeCompat(providerConfig.compat, definition.compat),\n\t};\n}\n\nfunction findModelDefaults(models: readonly Model<Api>[], modelId: string, api?: Api): Model<Api> | undefined {\n\treturn (\n\t\tmodels.find((model) => model.id === modelId) ??\n\t\t(api ? models.find((model) => model.api === api) : undefined) ??\n\t\tmodels.find((model) => model.api === \"openai-completions\") ??\n\t\tmodels[0]\n\t);\n}\n\nexport function applyModelsJson(\n\tproviderId: string,\n\tbaseModels: readonly Model<Api>[],\n\tconfig: ModelsJsonProvider | undefined,\n): Model<Api>[] {\n\tif (!config) return [...baseModels];\n\tif (config.oauth && !config.baseUrl) {\n\t\tthrow new Error(`Provider ${providerId}: \"baseUrl\" is required when \"oauth\" is set.`);\n\t}\n\tconst hasOverrides = config.modelOverrides && Object.keys(config.modelOverrides).length > 0;\n\tif (\n\t\t!config.models?.length &&\n\t\t!config.baseUrl &&\n\t\t!config.headers &&\n\t\t!config.compat &&\n\t\t!hasOverrides &&\n\t\t!config.apiKey &&\n\t\t!config.oauth &&\n\t\tconfig.authHeader === undefined\n\t) {\n\t\tthrow new Error(\n\t\t\t`Provider ${providerId}: must specify \"baseUrl\", \"headers\", \"compat\", \"modelOverrides\", or \"models\".`,\n\t\t);\n\t}\n\n\tconst models: Model<Api>[] = baseModels.map((model) => ({\n\t\t...model,\n\t\tbaseUrl: config.oauth === \"radius\" ? model.baseUrl : (config.baseUrl ?? model.baseUrl),\n\t\tcompat: mergeCompat(model.compat, config.compat),\n\t}));\n\tfor (const definition of config.models ?? []) {\n\t\tconst existingIndex = models.findIndex((model) => model.id === definition.id);\n\t\tconst defaults = findModelDefaults(models, definition.id, definition.api ?? config.api);\n\t\tconst model = modelFromJson(providerId, definition, config, defaults);\n\t\tif (existingIndex >= 0) models[existingIndex] = model;\n\t\telse models.push(model);\n\t}\n\treturn models;\n}\n\nexport function applyExtension(\n\tproviderId: string,\n\tmodels: readonly Model<Api>[],\n\tconfig: ProviderConfigInput | undefined,\n): Model<Api>[] {\n\tif (!config) return [...models];\n\tif (!config.models) {\n\t\treturn config.baseUrl ? models.map((model) => ({ ...model, baseUrl: config.baseUrl! })) : [...models];\n\t}\n\treturn config.models.map((definition) => {\n\t\tconst defaults = findModelDefaults(models, definition.id, definition.api ?? config.api);\n\t\tconst api = definition.api ?? config.api ?? defaults?.api;\n\t\tif (!api) {\n\t\t\tthrow new Error(\n\t\t\t\t`Provider ${providerId}, model ${definition.id}: no \"api\" specified. Set at provider or model level.`,\n\t\t\t);\n\t\t}\n\t\tconst baseUrl = definition.baseUrl ?? config.baseUrl ?? defaults?.baseUrl;\n\t\tif (!baseUrl) throw new Error(`Provider ${providerId}: \"baseUrl\" is required when defining custom models.`);\n\t\treturn {\n\t\t\t...definition,\n\t\t\tapi,\n\t\t\tprovider: providerId,\n\t\t\tbaseUrl,\n\t\t\theaders: undefined,\n\t\t};\n\t});\n}\n\nfunction adaptOAuth(config: ExtensionOAuthConfig): OAuthAuth {\n\treturn {\n\t\tname: config.name,\n\t\tlogin: async (callbacks) => {\n\t\t\tconst legacyCallbacks: OAuthLoginCallbacks & {\n\t\t\t\tonInfo(message: string, links: readonly { label?: string; url: string }[]): void;\n\t\t\t} = {\n\t\t\t\tonAuth: (info) => callbacks.notify({ type: \"auth_url\", ...info }),\n\t\t\t\tonDeviceCode: (info) => callbacks.notify({ type: \"device_code\", ...info }),\n\t\t\t\tonPrompt: (prompt) => callbacks.prompt({ type: \"text\", ...prompt }),\n\t\t\t\tonProgress: (message) => callbacks.notify({ type: \"progress\", message }),\n\t\t\t\tonInfo: (message, links) => callbacks.notify({ type: \"info\", message, links }),\n\t\t\t\tonManualCodeInput: () => callbacks.prompt({ type: \"manual_code\", message: \"Paste the authorization code\" }),\n\t\t\t\tonSelect: (prompt) => callbacks.prompt({ type: \"select\", ...prompt }),\n\t\t\t\tsignal: callbacks.signal,\n\t\t\t};\n\t\t\tconst credential = await config.login(legacyCallbacks, callbacks.signal);\n\t\t\treturn { ...credential, type: \"oauth\" };\n\t\t},\n\t\trefresh: async (credential, signal) => ({ ...(await config.refreshToken(credential, signal)), type: \"oauth\" }),\n\t\ttoAuth: async (credential) => ({ apiKey: config.getApiKey(credential) }),\n\t};\n}\n\nfunction withConfiguredAuth(\n\tauth: ModelAuth,\n\theaders: Record<string, string> | undefined,\n\tauthHeader: boolean,\n): ModelAuth {\n\tlet mergedHeaders: ProviderHeaders | undefined =\n\t\tauth.headers || headers ? { ...auth.headers, ...headers } : undefined;\n\tif (authHeader) {\n\t\tif (!auth.apiKey) throw new Error(\"authHeader requires a resolved API key\");\n\t\tmergedHeaders = { ...mergedHeaders, Authorization: `Bearer ${auth.apiKey}` };\n\t}\n\treturn { ...auth, headers: mergedHeaders };\n}\n\nexport function configuredApiKey(\n\tconfig: ModelsJsonProvider | undefined,\n\textension: ProviderConfigInput | undefined,\n): string | undefined {\n\treturn extension?.apiKey ?? config?.apiKey;\n}\n\nexport function configuredHeaders(\n\tconfig: ModelsJsonProvider | undefined,\n\textension: ProviderConfigInput | undefined,\n): Record<string, string> | undefined {\n\tif (!config?.headers && !extension?.headers) return undefined;\n\treturn { ...config?.headers, ...extension?.headers };\n}\n\nasync function configContextEnv(\n\tvalues: readonly string[],\n\tctx: AuthContext,\n\texplicit?: Record<string, string>,\n): Promise<Record<string, string> | undefined> {\n\tconst env = { ...explicit };\n\tfor (const name of new Set(values.flatMap(getConfigValueEnvVarNames))) {\n\t\tif (env[name] !== undefined) continue;\n\t\tconst value = await ctx.env(name);\n\t\tif (value !== undefined) env[name] = value;\n\t}\n\treturn Object.keys(env).length > 0 ? env : undefined;\n}\n\nexport function composeApiKeyAuth(\n\tproviderId: string,\n\tbase: Provider | undefined,\n\tconfig: ModelsJsonProvider | undefined,\n\textension: ProviderConfigInput | undefined,\n): ApiKeyAuth | undefined {\n\tconst inherited = base?.auth.apiKey;\n\tconst rawKey = configuredApiKey(config, extension);\n\tconst oauth = extension?.oauth ?? base?.auth.oauth;\n\t// OAuth-only providers get no fabricated API-key login method.\n\tif (!inherited && rawKey === undefined && oauth) return undefined;\n\tconst rawHeaders = configuredHeaders(config, extension);\n\tconst authHeader = extension?.authHeader ?? config?.authHeader ?? false;\n\treturn {\n\t\tname: inherited?.name ?? \"API key\",\n\t\tlogin:\n\t\t\tinherited?.login ??\n\t\t\t(async (interaction: ProviderAuthInteraction) => ({\n\t\t\t\ttype: \"api_key\",\n\t\t\t\tkey: await interaction.prompt({ type: \"secret\", message: \"Enter API key\" }),\n\t\t\t})),\n\t\tcheck: async (input) => {\n\t\t\tif (input.credential) {\n\t\t\t\tif (inherited?.check) return inherited.check(input);\n\t\t\t\tif (input.credential.key) return { type: \"api_key\", source: \"stored credential\" };\n\t\t\t\tconst resolved = await inherited?.resolve(input);\n\t\t\t\treturn resolved ? { type: \"api_key\", source: resolved.source } : undefined;\n\t\t\t}\n\t\t\tif (rawKey !== undefined) {\n\t\t\t\tif (isCommandConfigValue(rawKey)) return { type: \"api_key\", source: \"configured API key\" };\n\t\t\t\tconst envNames = getConfigValueEnvVarNames(rawKey);\n\t\t\t\tfor (const name of envNames) {\n\t\t\t\t\tif ((await input.ctx.env(name)) === undefined) return undefined;\n\t\t\t\t}\n\t\t\t\treturn { type: \"api_key\", source: \"configured API key\" };\n\t\t\t}\n\t\t\tif (inherited?.check) return inherited.check(input);\n\t\t\tconst resolved = await inherited?.resolve(input);\n\t\t\treturn resolved ? { type: \"api_key\", source: resolved.source } : undefined;\n\t\t},\n\t\tresolve: async (input) => {\n\t\t\tlet result: AuthResult | undefined;\n\t\t\tif (input.credential) {\n\t\t\t\tresult = inherited\n\t\t\t\t\t? await inherited.resolve(input)\n\t\t\t\t\t: input.credential.key\n\t\t\t\t\t\t? { auth: { apiKey: input.credential.key }, env: input.credential.env, source: \"stored credential\" }\n\t\t\t\t\t\t: undefined;\n\t\t\t} else if (rawKey !== undefined) {\n\t\t\t\tconst env = await configContextEnv([rawKey], input.ctx);\n\t\t\t\tconst key = resolveConfigValueOrThrow(rawKey, `API key for provider \"${providerId}\"`, env);\n\t\t\t\tresult = inherited\n\t\t\t\t\t? await inherited.resolve({ ...input, credential: { type: \"api_key\", key } })\n\t\t\t\t\t: { auth: { apiKey: key }, source: \"configured API key\" };\n\t\t\t} else {\n\t\t\t\tresult = await inherited?.resolve(input);\n\t\t\t}\n\t\t\tif (!result) return undefined;\n\t\t\tconst explicitEnv = { ...(input.credential?.env ?? {}), ...(result.env ?? {}) };\n\t\t\tconst headerEnv = await configContextEnv(Object.values(rawHeaders ?? {}), input.ctx, explicitEnv);\n\t\t\tconst headers = resolveHeadersOrThrow(rawHeaders, `provider \"${providerId}\"`, headerEnv);\n\t\t\treturn { ...result, auth: withConfiguredAuth(result.auth, headers, authHeader) };\n\t\t},\n\t};\n}\n\nexport function composeOAuthAuth(\n\tproviderId: string,\n\tbase: Provider | undefined,\n\tconfig: ModelsJsonProvider | undefined,\n\textension: ProviderConfigInput | undefined,\n): OAuthAuth | undefined {\n\tconst oauth = extension?.oauth ? adaptOAuth(extension.oauth) : base?.auth.oauth;\n\tif (!oauth) return undefined;\n\tconst rawHeaders = configuredHeaders(config, extension);\n\tconst authHeader = extension?.authHeader ?? config?.authHeader ?? false;\n\treturn {\n\t\t...oauth,\n\t\ttoAuth: async (credential) => {\n\t\t\tconst auth = await oauth.toAuth(credential);\n\t\t\tconst env = credential.env;\n\t\t\tconst headers = resolveHeadersOrThrow(\n\t\t\t\trawHeaders,\n\t\t\t\t`provider \"${providerId}\"`,\n\t\t\t\ttypeof env === \"object\" && env !== null ? (env as Record<string, string>) : undefined,\n\t\t\t);\n\t\t\treturn withConfiguredAuth(auth, headers, authHeader);\n\t\t},\n\t};\n}\n\nexport function rawModelHeaders(\n\tmodel: Model<Api>,\n\tconfig: ModelsJsonProvider | undefined,\n\textension: ProviderConfigInput | undefined,\n): Record<string, string> | undefined {\n\tconst definition = config?.models?.find((entry) => entry.id === model.id);\n\tconst extensionModel = extension?.models?.find((entry) => entry.id === model.id);\n\tconst headers = {\n\t\t...config?.modelOverrides?.[model.id]?.headers,\n\t\t...definition?.headers,\n\t\t...extensionModel?.headers,\n\t};\n\treturn Object.keys(headers).length > 0 ? headers : undefined;\n}\n"]}
|
package/dist/core/sdk.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/core/sdk.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/core/sdk.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAM1F,YAAY,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrE,cAAc,kBAAkB,CAAC;AACjC,YAAY,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AA+B1F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,GAAE,yBAA8B,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAkVnH"}
|