@bastani/atomic 0.9.70-alpha.1 → 0.9.71-alpha.1
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 +127 -0
- package/dist/builtin/intercom/package.json +2 -2
- package/dist/builtin/mcp/CHANGELOG.md +16 -0
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +12 -0
- package/dist/builtin/subagents/package.json +3 -3
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +8 -5
- package/dist/builtin/web-access/index.bundle.mjs +14750 -6455
- package/dist/builtin/web-access/package.json +3 -3
- package/dist/builtin/workflows/CHANGELOG.md +20 -0
- package/dist/builtin/workflows/package.json +2 -2
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +27 -10
- package/dist/builtin/workflows/src/extension/local-worker-entry.mjs +19 -5
- package/dist/builtin/workflows/src/index.js +19 -5
- package/dist/builtin/workflows/src/local-worker-entry.mjs +19 -5
- package/dist/cli/list-models.d.ts +7 -2
- package/dist/cli/list-models.d.ts.map +1 -1
- package/dist/cli/list-models.js +22 -50
- package/dist/cli/list-models.js.map +1 -1
- package/dist/core/agent-session-events.d.ts.map +1 -1
- package/dist/core/agent-session-events.js +2 -0
- package/dist/core/agent-session-events.js.map +1 -1
- package/dist/core/agent-session-message-queue.d.ts +9 -8
- package/dist/core/agent-session-message-queue.d.ts.map +1 -1
- package/dist/core/agent-session-message-queue.js +24 -7
- package/dist/core/agent-session-message-queue.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +4 -7
- 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 +6 -10
- package/dist/core/agent-session-models.js.map +1 -1
- package/dist/core/agent-session-prompt.d.ts.map +1 -1
- package/dist/core/agent-session-prompt.js +9 -8
- package/dist/core/agent-session-prompt.js.map +1 -1
- package/dist/core/agent-session-retry.d.ts.map +1 -1
- package/dist/core/agent-session-retry.js +5 -0
- package/dist/core/agent-session-retry.js.map +1 -1
- package/dist/core/agent-session-transfer.d.ts.map +1 -1
- package/dist/core/agent-session-transfer.js +2 -0
- package/dist/core/agent-session-transfer.js.map +1 -1
- package/dist/core/agent-session-typed-queue.d.ts +19 -0
- package/dist/core/agent-session-typed-queue.d.ts.map +1 -0
- package/dist/core/agent-session-typed-queue.js +34 -0
- package/dist/core/agent-session-typed-queue.js.map +1 -0
- package/dist/core/agent-session-types.d.ts +20 -0
- package/dist/core/agent-session-types.d.ts.map +1 -1
- package/dist/core/agent-session-types.js.map +1 -1
- package/dist/core/agent-session.d.ts +1 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/cache-warmer.d.ts.map +1 -1
- package/dist/core/cache-warmer.js +2 -0
- package/dist/core/cache-warmer.js.map +1 -1
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +13 -2
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/extensions/api-types.d.ts +6 -3
- 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/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader-api.d.ts.map +1 -1
- package/dist/core/extensions/loader-api.js +6 -2
- package/dist/core/extensions/loader-api.js.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.js +2 -0
- package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
- package/dist/core/extensions/message-types.d.ts +18 -1
- package/dist/core/extensions/message-types.d.ts.map +1 -1
- package/dist/core/extensions/message-types.js.map +1 -1
- package/dist/core/extensions/runner-registries.d.ts.map +1 -1
- package/dist/core/extensions/runner-registries.js +8 -1
- package/dist/core/extensions/runner-registries.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +1 -0
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +1 -0
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/runtime-types.d.ts +2 -2
- package/dist/core/extensions/runtime-types.d.ts.map +1 -1
- package/dist/core/extensions/runtime-types.js.map +1 -1
- package/dist/core/fast-model-variants.d.ts +0 -9
- package/dist/core/fast-model-variants.d.ts.map +1 -1
- package/dist/core/fast-model-variants.js +0 -14
- package/dist/core/fast-model-variants.js.map +1 -1
- package/dist/core/model-config.d.ts +14 -0
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-label.d.ts +38 -0
- package/dist/core/model-label.d.ts.map +1 -0
- package/dist/core/model-label.js +46 -0
- package/dist/core/model-label.js.map +1 -0
- package/dist/core/model-resolver-initial.d.ts +5 -0
- package/dist/core/model-resolver-initial.d.ts.map +1 -1
- package/dist/core/model-resolver-initial.js +26 -1
- package/dist/core/model-resolver-initial.js.map +1 -1
- package/dist/core/model-resolver.d.ts +1 -1
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +1 -1
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-runtime.d.ts +5 -7
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +14 -19
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/model-switch-thinking-level.d.ts +23 -0
- package/dist/core/model-switch-thinking-level.d.ts.map +1 -0
- package/dist/core/model-switch-thinking-level.js +19 -0
- package/dist/core/model-switch-thinking-level.js.map +1 -0
- package/dist/core/package-manager-git.d.ts +2 -0
- package/dist/core/package-manager-git.d.ts.map +1 -1
- package/dist/core/package-manager-git.js +32 -4
- package/dist/core/package-manager-git.js.map +1 -1
- package/dist/core/package-manager-operations.d.ts.map +1 -1
- package/dist/core/package-manager-operations.js +37 -5
- package/dist/core/package-manager-operations.js.map +1 -1
- package/dist/core/package-manager-types.d.ts +7 -1
- package/dist/core/package-manager-types.d.ts.map +1 -1
- package/dist/core/package-manager-types.js.map +1 -1
- package/dist/core/remote-catalog-provider.d.ts +14 -0
- package/dist/core/remote-catalog-provider.d.ts.map +1 -1
- package/dist/core/remote-catalog-provider.js +73 -0
- package/dist/core/remote-catalog-provider.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +11 -4
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/skills.js +1 -1
- package/dist/core/skills.js.map +1 -1
- package/dist/core/storage/index.d.ts +1 -0
- package/dist/core/storage/index.d.ts.map +1 -1
- package/dist/core/storage/index.js +1 -0
- package/dist/core/storage/index.js.map +1 -1
- package/dist/core/storage/node-sqlite.d.ts.map +1 -1
- package/dist/core/storage/node-sqlite.js +13 -8
- package/dist/core/storage/node-sqlite.js.map +1 -1
- package/dist/core/storage/write-ahead-log.d.ts +25 -0
- package/dist/core/storage/write-ahead-log.d.ts.map +1 -0
- package/dist/core/storage/write-ahead-log.js +78 -0
- package/dist/core/storage/write-ahead-log.js.map +1 -0
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +3 -4
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tasks/completion.d.ts +3 -2
- package/dist/core/tasks/completion.d.ts.map +1 -1
- package/dist/core/tasks/completion.js +7 -2
- package/dist/core/tasks/completion.js.map +1 -1
- package/dist/core/tasks/heartbeat-notice.d.ts +2 -0
- package/dist/core/tasks/heartbeat-notice.d.ts.map +1 -1
- package/dist/core/tasks/heartbeat-notice.js +8 -4
- package/dist/core/tasks/heartbeat-notice.js.map +1 -1
- package/dist/core/tasks/heartbeat.d.ts.map +1 -1
- package/dist/core/tasks/heartbeat.js +1 -0
- package/dist/core/tasks/heartbeat.js.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.d.ts +4 -4
- package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +13 -16
- package/dist/core/tools/write.js.map +1 -1
- package/dist/extensions/codemode/renderer.d.ts.map +1 -1
- package/dist/extensions/codemode/renderer.js +6 -2
- package/dist/extensions/codemode/renderer.js.map +1 -1
- package/dist/extensions/llama/huggingface-ui.d.ts +1 -0
- package/dist/extensions/llama/huggingface-ui.d.ts.map +1 -1
- package/dist/extensions/llama/huggingface-ui.js +13 -4
- package/dist/extensions/llama/huggingface-ui.js.map +1 -1
- package/dist/extensions/llama/ui.d.ts.map +1 -1
- package/dist/extensions/llama/ui.js +3 -0
- package/dist/extensions/llama/ui.js.map +1 -1
- package/dist/extensions/mcp/client/transports/stdio.d.ts.map +1 -1
- package/dist/extensions/mcp/client/transports/stdio.js +13 -2
- package/dist/extensions/mcp/client/transports/stdio.js.map +1 -1
- package/dist/extensions/mcp/client/transports/streamable-http.d.ts.map +1 -1
- package/dist/extensions/mcp/client/transports/streamable-http.js +41 -3
- package/dist/extensions/mcp/client/transports/streamable-http.js.map +1 -1
- package/dist/extensions/mcp/ui.d.ts +1 -0
- package/dist/extensions/mcp/ui.d.ts.map +1 -1
- package/dist/extensions/mcp/ui.js +33 -24
- package/dist/extensions/mcp/ui.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 +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/main-deferred-startup.d.ts +23 -1
- package/dist/main-deferred-startup.d.ts.map +1 -1
- package/dist/main-deferred-startup.js +28 -0
- package/dist/main-deferred-startup.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +8 -14
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts +1 -3
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +17 -9
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts +5 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.js +15 -3
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/chat-message-renderer.d.ts +4 -0
- package/dist/modes/interactive/components/chat-message-renderer.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-message-renderer.js +23 -7
- package/dist/modes/interactive/components/chat-message-renderer.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js +7 -0
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/custom-message.d.ts +5 -2
- package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-message.js +12 -2
- package/dist/modes/interactive/components/custom-message.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +7 -9
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +1 -2
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/markdown-transform.d.ts +2 -1
- package/dist/modes/interactive/components/markdown-transform.d.ts.map +1 -1
- package/dist/modes/interactive/components/markdown-transform.js +2 -1
- package/dist/modes/interactive/components/markdown-transform.js.map +1 -1
- package/dist/modes/interactive/components/mermaid.d.ts.map +1 -1
- package/dist/modes/interactive/components/mermaid.js +2 -1
- package/dist/modes/interactive/components/mermaid.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts +9 -1
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +46 -16
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts +1 -0
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.js +13 -4
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +4 -0
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js +32 -11
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts +1 -0
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +3 -0
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-items.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector-items.js +6 -5
- package/dist/modes/interactive/components/settings-selector-items.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-submenus.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector-submenus.js +2 -0
- package/dist/modes/interactive/components/settings-selector-submenus.js.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts +5 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.js +15 -3
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
- package/dist/modes/interactive/components/task-row.d.ts +1 -0
- package/dist/modes/interactive/components/task-row.d.ts.map +1 -1
- package/dist/modes/interactive/components/task-row.js +3 -1
- package/dist/modes/interactive/components/task-row.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector-component.d.ts +1 -0
- package/dist/modes/interactive/components/tree-selector-component.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector-component.js +3 -0
- package/dist/modes/interactive/components/tree-selector-component.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector-content.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector-content.js +2 -1
- package/dist/modes/interactive/components/tree-selector-content.js.map +1 -1
- package/dist/modes/interactive/components/user-message-selector.d.ts +1 -0
- package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message-selector.js +9 -1
- package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message.js +1 -1
- package/dist/modes/interactive/components/user-message.js.map +1 -1
- package/dist/modes/interactive/interactive-agent-events.js +3 -4
- package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
- package/dist/modes/interactive/interactive-autocomplete.js +6 -4
- package/dist/modes/interactive/interactive-autocomplete.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-context.js +1 -1
- package/dist/modes/interactive/interactive-extension-context.js.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.js +11 -1
- package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.d.ts +11 -2
- package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.js +11 -2
- package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.d.ts +4 -1
- 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.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-model-routing.js +18 -4
- package/dist/modes/interactive/interactive-model-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-prompt-turn.js +5 -1
- package/dist/modes/interactive/interactive-prompt-turn.js.map +1 -1
- package/dist/modes/interactive/interactive-queueing.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-queueing.js +17 -6
- package/dist/modes/interactive/interactive-queueing.js.map +1 -1
- package/dist/modes/interactive/interactive-render-chat.js +51 -5
- package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
- package/dist/modes/interactive/interactive-slash-commands.js +2 -2
- 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 +9 -12
- 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 +6 -5
- package/dist/modes/interactive/interactive-tui.js.map +1 -1
- package/dist/modes/interactive/theme/global-theme.d.ts +1 -0
- package/dist/modes/interactive/theme/global-theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/global-theme.js +3 -0
- package/dist/modes/interactive/theme/global-theme.js.map +1 -1
- package/dist/modes/interactive/theme/theme.d.ts +1 -1
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +1 -1
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/interactive/theme/tui-theme.d.ts +5 -0
- package/dist/modes/interactive/theme/tui-theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/tui-theme.js +21 -2
- package/dist/modes/interactive/theme/tui-theme.js.map +1 -1
- package/dist/modes/interactive-engine/extension-ui-bridge.d.ts +2 -5
- package/dist/modes/interactive-engine/extension-ui-bridge.d.ts.map +1 -1
- package/dist/modes/interactive-engine/extension-ui-bridge.js.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.d.ts +2 -6
- package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js +39 -14
- package/dist/modes/print-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-client-api.d.ts +2 -5
- package/dist/modes/rpc/rpc-client-api.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client-api.js.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.d.ts +2 -1
- package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.js +11 -4
- package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
- package/dist/modes/rpc/rpc-input.d.ts +3 -2
- package/dist/modes/rpc/rpc-input.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-input.js +5 -1
- package/dist/modes/rpc/rpc-input.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +45 -16
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-session-binding.d.ts +3 -1
- package/dist/modes/rpc/rpc-session-binding.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-session-binding.js +5 -1
- package/dist/modes/rpc/rpc-session-binding.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +2 -5
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +26 -4
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/utils/ansi.d.ts +0 -2
- package/dist/utils/ansi.d.ts.map +1 -1
- package/dist/utils/ansi.js +0 -5
- package/dist/utils/ansi.js.map +1 -1
- package/dist/utils/syntax-highlight.d.ts +5 -0
- package/dist/utils/syntax-highlight.d.ts.map +1 -1
- package/dist/utils/syntax-highlight.js +7 -0
- package/dist/utils/syntax-highlight.js.map +1 -1
- package/docs/extensions/api-reference.md +21 -7
- package/docs/extensions/events.md +2 -0
- package/docs/extensions/examples.md +0 -1
- package/docs/extensions.md +7 -0
- package/docs/keybindings.md +1 -1
- package/docs/models/reference.md +8 -6
- package/docs/models-configuration.md +1 -0
- package/docs/models.md +2 -0
- package/docs/packages.md +2 -0
- package/docs/providers.md +14 -5
- package/docs/rpc/protocol.md +8 -2
- package/docs/rpc.md +4 -0
- package/docs/sdk.md +2 -0
- package/docs/storage.md +2 -0
- package/docs/tmux.md +6 -0
- package/docs/tui/reference.md +2 -0
- package/docs/windows.md +26 -0
- package/examples/extensions/README.md +2 -1
- package/examples/extensions/preset.ts +2 -0
- package/examples/extensions/tools.ts +2 -0
- package/npm-shrinkwrap.json +90 -72
- package/package.json +14 -15
- package/schemas/models.schema.json +4 -0
- package/examples/extensions/sandbox/index.ts +0 -323
- package/examples/extensions/sandbox/package-lock.json +0 -92
- package/examples/extensions/sandbox/package.json +0 -19
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fast-model-variants.js","sourceRoot":"","sources":["../../src/core/fast-model-variants.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,kBAAkB,GAIlB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAErE,oEAAoE;AACpE,MAAM,CAAC,MAAM,oBAAoB,GAAG,OAAO,CAAC;AAE5C,qEAAqE;AACrE,MAAM,CAAC,MAAM,uBAAuB,GAAG,UAAmB,CAAC;AAE3D,wGAAwG;AACxG,MAAM,CAAC,MAAM,yBAAyB,GAAG,YAAY,CAAC;AACtD,MAAM,CAAC,MAAM,4BAA4B,GAAG,WAAoB,CAAC;AAEjE,2EAA2E;AAC3E,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAe,CAAC;AAEhD;;;;GAIG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAwB,IAAI,GAAG,CAAC;IACzE,iBAAiB;IACjB,eAAe;IACf,iBAAiB;CACjB,CAAC,CAAC;AA6CH,oEAAoE;AACpE,MAAM,UAAU,WAAW,CAAC,WAAmB;IAC9C,OAAO,GAAG,WAAW,GAAG,oBAAoB,EAAE,CAAC;AAChD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,GAAQ;IAC5C,OAAO,GAAG,KAAK,kBAAkB,IAAI,GAAG,KAAK,wBAAwB,CAAC;AACvE,CAA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n\ttype Model,\n\ttype ModelFastRoute,\n\ttype Provider,\n} from \"@bastani/pi-ai\";\nimport type { ModelsJsonModelOverride } from \"./model-config.ts\";\nimport { applyModelOverride } from \"./provider-composer-internal.ts\";\n\n/** Canonical suffix every selectable fast model variant carries. */\nexport const FAST_MODEL_ID_SUFFIX = \"-fast\";\n\n/** Service tier OpenAI-style providers use to route fast traffic. */\nexport const FAST_MODEL_SERVICE_TIER = \"priority\" as const;\n\n/** Codex's Ultrafast tier, offered only for models that advertise it; access depends on the account. */\nexport const ULTRAFAST_MODEL_ID_SUFFIX = \"-ultrafast\";\nexport const ULTRAFAST_MODEL_SERVICE_TIER = \"ultrafast\" as const;\n\n/** Inference speed Anthropic's Messages API uses to route fast traffic. */\nexport const FAST_MODEL_SPEED = \"fast\" as const;\n\n/**\n * Claude models Anthropic's fast mode accepts. Requesting `speed: \"fast\"` on any other model is an\n * error, so the list is explicit rather than a family-name pattern.\n * https://platform.claude.com/docs/en/build-with-claude/fast-mode#supported-models\n */\nexport const ANTHROPIC_FAST_MODE_MODEL_IDS: ReadonlySet<string> = new Set([\n\t\"claude-opus-5-5\",\n\t\"claude-opus-5\",\n\t\"claude-opus-4-8\",\n]);\n\n/** A derived fast variant that was suppressed because something already owns its exact model ID. */\nexport interface FastModelVariantDiagnostic {\n\tprovider: string;\n\t/** The exact selectable model ID that collided. */\n\tmodelId: string;\n\tmessage: string;\n}\n\nexport interface FastModelVariantDerivation {\n\tmodels: readonly Model<Api>[];\n\tdiagnostics: readonly FastModelVariantDiagnostic[];\n}\n\nexport interface DeriveFastModelVariantsOptions {\n\t/** Exact fast model IDs the stored GitHub Copilot credential advertises for this account. */\n\tcopilotFastModelIds?: readonly string[];\n\t/** `models.json` `modelOverrides` for this provider, applied to derived entries by their exact `-fast` ID. */\n\tmodelOverrides?: Readonly<Record<string, ModelsJsonModelOverride>>;\n\t/** APIs whose transport a registered extension owns for this provider. No variant is derived for them. */\n\textensionOwnedApis?: ReadonlySet<Api>;\n\t/** IDs explicitly declared in this provider's models.json models array. Never derive siblings for them. */\n\tcustomModelIds?: ReadonlySet<string>;\n}\n\nexport interface FastModelVariantsOptions {\n\t/**\n\t * Synchronous read of the exact fast model IDs the stored GitHub Copilot credential advertises.\n\t * Read per call so a credential that lands after provider composition still takes effect.\n\t */\n\tgetCopilotFastModelIds?: () => readonly string[] | undefined;\n\t/** Synchronous read of this provider's `models.json` `modelOverrides`, so a reload takes effect. */\n\tgetModelOverrides?: () => Readonly<Record<string, ModelsJsonModelOverride>> | undefined;\n\t/** Read current custom model IDs per pass so models.json reloads update eligibility. */\n\tgetCustomModelIds?: () => ReadonlySet<string>;\n\t/**\n\t * Synchronous read of the APIs a registered extension supplies a stream function for. Read per call\n\t * because extensions register after initial composition on some paths.\n\t */\n\tgetExtensionOwnedApis?: () => ReadonlySet<Api> | undefined;\n\t/** Called after every derivation pass with the complete diagnostic list for this provider. */\n\tonDiagnostics?: (providerId: string, diagnostics: readonly FastModelVariantDiagnostic[]) => void;\n}\n\n/** Canonical selectable ID of the fast variant of `baseModelId`. */\nexport function fastModelId(baseModelId: string): string {\n\treturn `${baseModelId}${FAST_MODEL_ID_SUFFIX}`;\n}\n\n/**\n * The two pi-ai adapters that serialize `service_tier`. `azure-openai-responses` and\n * `openai-completions` have no such option, and `streamSimple` drops it, so a service-tier route on\n * any other API would silently degrade to an ordinary request.\n */\nexport function isNativeFastRouteApi(api: Api): api is \"openai-responses\" | \"openai-codex-responses\" {\n\treturn api === \"openai-responses\" || api === \"openai-codex-responses\";\n}\n\n/**\n * OpenAI-style fast routing keeps the base upstream model ID and adds a priority service tier.\n *\n * Eligibility requires both a first-party provider ID and an adapter that serializes\n * `service_tier`. A renamed provider, proxy, Azure (`azure`), OpenRouter\n * (`openai-completions`), and generic OpenAI-compatible providers do not qualify. An `openai` or\n * `openai-codex` model on an adapter that cannot carry `service_tier` must not offer a fast variant,\n * because selecting it would send an ordinary request under a name that promises otherwise.\n */\nexport function usesOpenAIFastServiceTier(model: Pick<Model<Api>, \"api\" | \"provider\">): boolean {\n\treturn (\n\t\tisNativeFastRouteApi(model.api) &&\n\t\t(model.provider === \"openai\" || model.provider === \"openai-api\" || model.provider === \"openai-codex\")\n\t);\n}\n\n/**\n * xAI Priority Processing keeps the base upstream Grok model ID and adds the same\n * `service_tier: \"priority\"` field on the Responses API. xAI has no `-fast` model slugs for current\n * Grok models; priority is billed at twice the standard token rates, and only when the response\n * confirms the tier. https://docs.x.ai/developers/advanced-api-usage/priority-processing\n *\n * Eligibility requires the first-party `xai` provider on `openai-responses`. OpenRouter, Vercel AI\n * Gateway, and renamed or proxied xAI-compatible providers do not qualify.\n */\nexport function usesXaiFastServiceTier(model: Pick<Model<Api>, \"api\" | \"provider\">): boolean {\n\treturn model.api === \"openai-responses\" && model.provider === \"xai\";\n}\n\n/** GitHub Copilot advertises real fast sibling model IDs per account; it never uses a service tier. */\nexport function isGitHubCopilotModel(model: Pick<Model<Api>, \"provider\">): boolean {\n\treturn model.provider === \"github-copilot\";\n}\n\n/**\n * Anthropic fast mode keeps the base upstream model ID and adds `speed: \"fast\"` with the fast-mode beta.\n *\n * Eligibility requires the first-party `anthropic` provider on the Messages API and a supported model.\n * Fast mode is not offered through Amazon Bedrock, Google Vertex, GitHub Copilot, OpenRouter, or a\n * renamed or proxied Anthropic-compatible provider.\n */\nexport function usesAnthropicFastMode(model: Pick<Model<Api>, \"api\" | \"id\" | \"provider\">): boolean {\n\treturn (\n\t\tmodel.api === \"anthropic-messages\" &&\n\t\t(model.provider === \"anthropic\" || model.provider === \"anthropic-api\") &&\n\t\tANTHROPIC_FAST_MODE_MODEL_IDS.has(model.id)\n\t);\n}\n\nfunction advertisedModelIds(value: unknown): readonly string[] | undefined {\n\tif (!Array.isArray(value) || !value.every((entry) => typeof entry === \"string\")) return undefined;\n\treturn value;\n}\n\n/** Read the exact fast model IDs a stored GitHub Copilot OAuth credential advertises. */\nexport function copilotAdvertisedFastModelIds(credential: Credential | undefined): readonly string[] | undefined {\n\tif (credential?.type !== \"oauth\") return undefined;\n\treturn advertisedModelIds(credential.fastModelIds);\n}\n\n/**\n * Whether a stored GitHub Copilot OAuth credential advertises this exact model ID at all — as a\n * selectable picker/policy model or as a fast sibling.\n *\n * Copilot's per-account advertisement is the authority the provider's own `filterModels` uses, so\n * restoration consults the same lists. An ID the account advertises as an ordinary model is ordinary,\n * whatever its name ends in.\n */\nexport function copilotAdvertisesModelId(credential: Credential | undefined, modelId: string): boolean {\n\tif (credential?.type !== \"oauth\") return false;\n\treturn (\n\t\tadvertisedModelIds(credential.availableModelIds)?.includes(modelId) === true ||\n\t\tadvertisedModelIds(credential.fastModelIds)?.includes(modelId) === true\n\t);\n}\n\n/** A model without tier metadata keeps offering Fast; one that lists its tiers must advertise it, as in Codex. */\nfunction advertisesFastServiceTier(model: Model<Api>): boolean {\n\treturn model.serviceTiers === undefined || getServiceTierCost(model, FAST_MODEL_SERVICE_TIER) !== undefined;\n}\n\nfunction fastRouteForBaseModel(\n\tmodel: Model<Api>,\n\tentitledCopilotFastModelIds: ReadonlySet<string>,\n): ModelFastRoute | undefined {\n\tif (usesOpenAIFastServiceTier(model)) {\n\t\treturn advertisesFastServiceTier(model)\n\t\t\t? { baseModelId: model.id, upstreamModelId: model.id, serviceTier: FAST_MODEL_SERVICE_TIER }\n\t\t\t: undefined;\n\t}\n\tif (usesXaiFastServiceTier(model)) {\n\t\treturn { baseModelId: model.id, upstreamModelId: model.id, serviceTier: FAST_MODEL_SERVICE_TIER };\n\t}\n\tif (usesAnthropicFastMode(model)) {\n\t\treturn { baseModelId: model.id, upstreamModelId: model.id, speed: FAST_MODEL_SPEED };\n\t}\n\tif (isGitHubCopilotModel(model)) {\n\t\tconst advertisedId = fastModelId(model.id);\n\t\treturn entitledCopilotFastModelIds.has(advertisedId)\n\t\t\t? { baseModelId: model.id, upstreamModelId: advertisedId }\n\t\t\t: undefined;\n\t}\n\treturn undefined;\n}\n\n/**\n * Add a selectable `<base-model-id>-fast` entry for every eligible model, carrying the explicit\n * {@link ModelFastRoute} metadata that gives it fast semantics. The input list is preserved verbatim\n * and in order; each derived entry is appended directly after the model it derives from.\n *\n * A model whose exact `-fast` ID is already owned by the provider, a `models.json` custom model, or an\n * extension wins: derivation is suppressed for it and a diagnostic is recorded. The owning model keeps\n * whatever semantics it declares, because fast behavior comes only from `fastRoute`, never from the\n * `-fast` suffix. For the same reason a base model whose ID already ends in `-fast` is never used to\n * derive a `-fast-fast` variant: that is not a canonical ID this scheme defines.\n *\n * A derived entry is a real catalog model, so a `modelOverrides` entry keyed on its exact `-fast` ID\n * applies to it after derivation. Without that pass the derived entry would inherit the *base* model's\n * overrides and its own would be silently inert.\n *\n * No variant is derived for an API whose transport a registered extension owns, because Atomic cannot\n * enforce the route through a transport it does not serialize.\n */\nexport function deriveFastModelVariants(\n\tproviderId: string,\n\tmodels: readonly Model<Api>[],\n\toptions: DeriveFastModelVariantsOptions = {},\n): FastModelVariantDerivation {\n\tconst ownedModelIds = new Set(models.map((model) => model.id));\n\tconst entitledCopilotFastModelIds = new Set(options.copilotFastModelIds ?? []);\n\tconst derived: Model<Api>[] = [];\n\tconst diagnostics: FastModelVariantDiagnostic[] = [];\n\tlet changed = false;\n\tfor (const model of models) {\n\t\tderived.push(model);\n\t\tif (\n\t\t\tmodel.fastRoute !== undefined ||\n\t\t\tmodel.id.endsWith(FAST_MODEL_ID_SUFFIX) ||\n\t\t\tmodel.id.endsWith(ULTRAFAST_MODEL_ID_SUFFIX)\n\t\t)\n\t\t\tcontinue;\n\t\tif (options.customModelIds?.has(model.id)) continue;\n\t\t// An extension that supplies this API's stream function owns its serialization, so Atomic cannot\n\t\t// guarantee the route reaches the wire. Publishing a `-fast` choice it may not honor is the same\n\t\t// hazard as publishing one for an adapter that cannot carry the tier.\n\t\tif (options.extensionOwnedApis?.has(model.api) === true) continue;\n\t\tconst fastRoute = fastRouteForBaseModel(model, entitledCopilotFastModelIds);\n\t\tconst routes: Array<{ suffix: string; label: string; route: ModelFastRoute }> = [];\n\t\tif (fastRoute) routes.push({ suffix: FAST_MODEL_ID_SUFFIX, label: \"fast\", route: fastRoute });\n\t\tif (usesOpenAIFastServiceTier(model) && getServiceTierCost(model, ULTRAFAST_MODEL_SERVICE_TIER)) {\n\t\t\troutes.push({\n\t\t\t\tsuffix: ULTRAFAST_MODEL_ID_SUFFIX,\n\t\t\t\tlabel: \"ultrafast\",\n\t\t\t\troute: { baseModelId: model.id, upstreamModelId: model.id, serviceTier: ULTRAFAST_MODEL_SERVICE_TIER },\n\t\t\t});\n\t\t}\n\t\tfor (const { suffix, label, route } of routes) {\n\t\t\tconst variantId = `${model.id}${suffix}`;\n\t\t\tif (ownedModelIds.has(variantId)) {\n\t\t\t\tdiagnostics.push({\n\t\t\t\t\tprovider: providerId,\n\t\t\t\t\tmodelId: variantId,\n\t\t\t\t\tmessage:\n\t\t\t\t\t\t`Model \"${providerId}/${variantId}\" is already defined by the provider, models.json, or an extension, ` +\n\t\t\t\t\t\t`so Atomic did not derive a ${label} variant of \"${providerId}/${model.id}\". ` +\n\t\t\t\t\t\t`That model routes exactly as declared. Rename or remove it to get the derived ${label} variant instead.`,\n\t\t\t\t});\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst override = options.modelOverrides?.[variantId];\n\t\t\tconst variant: Model<Api> = { ...model, id: variantId, name: `${model.name} (${label})`, fastRoute: route };\n\t\t\tderived.push(override ? applyModelOverride(variant, override) : variant);\n\t\t\tchanged = true;\n\t\t}\n\t}\n\tif (!changed && diagnostics.length === 0) return { models, diagnostics };\n\treturn { models: derived, diagnostics };\n}\n\n/**\n * Overlay derived fast model variants onto a composed provider. Apply this after built-in,\n * `models.json`, extension, and `modelOverrides` composition so exact user-owned `-fast` IDs are\n * already present and win the collision.\n */\nexport function withFastModelVariants(provider: Provider, options: FastModelVariantsOptions = {}): Provider {\n\treturn {\n\t\t...provider,\n\t\tgetModels: () => {\n\t\t\tconst { models, diagnostics } = deriveFastModelVariants(provider.id, provider.getModels(), {\n\t\t\t\tcopilotFastModelIds: isGitHubCopilotModel({ provider: provider.id })\n\t\t\t\t\t? options.getCopilotFastModelIds?.()\n\t\t\t\t\t: undefined,\n\t\t\t\tmodelOverrides: options.getModelOverrides?.(),\n\t\t\t\textensionOwnedApis: options.getExtensionOwnedApis?.(),\n\t\t\t\tcustomModelIds: options.getCustomModelIds?.(),\n\t\t\t});\n\t\t\toptions.onDiagnostics?.(provider.id, diagnostics);\n\t\t\treturn models;\n\t\t},\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"fast-model-variants.js","sourceRoot":"","sources":["../../src/core/fast-model-variants.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,kBAAkB,GAIlB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAErE,oEAAoE;AACpE,MAAM,CAAC,MAAM,oBAAoB,GAAG,OAAO,CAAC;AAE5C,qEAAqE;AACrE,MAAM,CAAC,MAAM,uBAAuB,GAAG,UAAmB,CAAC;AAE3D,wGAAwG;AACxG,MAAM,CAAC,MAAM,yBAAyB,GAAG,YAAY,CAAC;AACtD,MAAM,CAAC,MAAM,4BAA4B,GAAG,WAAoB,CAAC;AAEjE,2EAA2E;AAC3E,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAe,CAAC;AAEhD;;;;GAIG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAwB,IAAI,GAAG,CAAC;IACzE,iBAAiB;IACjB,eAAe;IACf,iBAAiB;CACjB,CAAC,CAAC;AA6CH,oEAAoE;AACpE,MAAM,UAAU,WAAW,CAAC,WAAmB;IAC9C,OAAO,GAAG,WAAW,GAAG,oBAAoB,EAAE,CAAC;AAChD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,GAAQ;IAC5C,OAAO,GAAG,KAAK,kBAAkB,IAAI,GAAG,KAAK,wBAAwB,CAAC;AACvE,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,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E,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC;AACzC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,QAAkB,EAAE,OAAO,GAA6B,EAAE;IAC/F,OAAO;QACN,GAAG,QAAQ;QACX,SAAS,EAAE,GAAG,EAAE;YACf,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,uBAAuB,CAAC,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC,SAAS,EAAE,EAAE;gBAC1F,mBAAmB,EAAE,oBAAoB,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,EAAE,EAAE,CAAC;oBACnE,CAAC,CAAC,OAAO,CAAC,sBAAsB,EAAE,EAAE;oBACpC,CAAC,CAAC,SAAS;gBACZ,cAAc,EAAE,OAAO,CAAC,iBAAiB,EAAE,EAAE;gBAC7C,kBAAkB,EAAE,OAAO,CAAC,qBAAqB,EAAE,EAAE;gBACrD,cAAc,EAAE,OAAO,CAAC,iBAAiB,EAAE,EAAE;aAC7C,CAAC,CAAC;YACH,OAAO,CAAC,aAAa,EAAE,CAAC,QAAQ,CAAC,EAAE,EAAE,WAAW,CAAC,CAAC;YAClD,OAAO,MAAM,CAAC;QACf,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import {\n\ttype Api,\n\ttype Credential,\n\tgetServiceTierCost,\n\ttype Model,\n\ttype ModelFastRoute,\n\ttype Provider,\n} from \"@bastani/pi-ai\";\nimport type { ModelsJsonModelOverride } from \"./model-config.ts\";\nimport { applyModelOverride } from \"./provider-composer-internal.ts\";\n\n/** Canonical suffix every selectable fast model variant carries. */\nexport const FAST_MODEL_ID_SUFFIX = \"-fast\";\n\n/** Service tier OpenAI-style providers use to route fast traffic. */\nexport const FAST_MODEL_SERVICE_TIER = \"priority\" as const;\n\n/** Codex's Ultrafast tier, offered only for models that advertise it; access depends on the account. */\nexport const ULTRAFAST_MODEL_ID_SUFFIX = \"-ultrafast\";\nexport const ULTRAFAST_MODEL_SERVICE_TIER = \"ultrafast\" as const;\n\n/** Inference speed Anthropic's Messages API uses to route fast traffic. */\nexport const FAST_MODEL_SPEED = \"fast\" as const;\n\n/**\n * Claude models Anthropic's fast mode accepts. Requesting `speed: \"fast\"` on any other model is an\n * error, so the list is explicit rather than a family-name pattern.\n * https://platform.claude.com/docs/en/build-with-claude/fast-mode#supported-models\n */\nexport const ANTHROPIC_FAST_MODE_MODEL_IDS: ReadonlySet<string> = new Set([\n\t\"claude-opus-5-5\",\n\t\"claude-opus-5\",\n\t\"claude-opus-4-8\",\n]);\n\n/** A derived fast variant that was suppressed because something already owns its exact model ID. */\nexport interface FastModelVariantDiagnostic {\n\tprovider: string;\n\t/** The exact selectable model ID that collided. */\n\tmodelId: string;\n\tmessage: string;\n}\n\nexport interface FastModelVariantDerivation {\n\tmodels: readonly Model<Api>[];\n\tdiagnostics: readonly FastModelVariantDiagnostic[];\n}\n\nexport interface DeriveFastModelVariantsOptions {\n\t/** Exact fast model IDs the stored GitHub Copilot credential advertises for this account. */\n\tcopilotFastModelIds?: readonly string[];\n\t/** `models.json` `modelOverrides` for this provider, applied to derived entries by their exact `-fast` ID. */\n\tmodelOverrides?: Readonly<Record<string, ModelsJsonModelOverride>>;\n\t/** APIs whose transport a registered extension owns for this provider. No variant is derived for them. */\n\textensionOwnedApis?: ReadonlySet<Api>;\n\t/** IDs explicitly declared in this provider's models.json models array. Never derive siblings for them. */\n\tcustomModelIds?: ReadonlySet<string>;\n}\n\nexport interface FastModelVariantsOptions {\n\t/**\n\t * Synchronous read of the exact fast model IDs the stored GitHub Copilot credential advertises.\n\t * Read per call so a credential that lands after provider composition still takes effect.\n\t */\n\tgetCopilotFastModelIds?: () => readonly string[] | undefined;\n\t/** Synchronous read of this provider's `models.json` `modelOverrides`, so a reload takes effect. */\n\tgetModelOverrides?: () => Readonly<Record<string, ModelsJsonModelOverride>> | undefined;\n\t/** Read current custom model IDs per pass so models.json reloads update eligibility. */\n\tgetCustomModelIds?: () => ReadonlySet<string>;\n\t/**\n\t * Synchronous read of the APIs a registered extension supplies a stream function for. Read per call\n\t * because extensions register after initial composition on some paths.\n\t */\n\tgetExtensionOwnedApis?: () => ReadonlySet<Api> | undefined;\n\t/** Called after every derivation pass with the complete diagnostic list for this provider. */\n\tonDiagnostics?: (providerId: string, diagnostics: readonly FastModelVariantDiagnostic[]) => void;\n}\n\n/** Canonical selectable ID of the fast variant of `baseModelId`. */\nexport function fastModelId(baseModelId: string): string {\n\treturn `${baseModelId}${FAST_MODEL_ID_SUFFIX}`;\n}\n\n/**\n * The two pi-ai adapters that serialize `service_tier`. `azure-openai-responses` and\n * `openai-completions` have no such option, and `streamSimple` drops it, so a service-tier route on\n * any other API would silently degrade to an ordinary request.\n */\nexport function isNativeFastRouteApi(api: Api): api is \"openai-responses\" | \"openai-codex-responses\" {\n\treturn api === \"openai-responses\" || api === \"openai-codex-responses\";\n}\n\n/**\n * OpenAI-style fast routing keeps the base upstream model ID and adds a priority service tier.\n *\n * Eligibility requires both a first-party provider ID and an adapter that serializes\n * `service_tier`. A renamed provider, proxy, Azure (`azure`), OpenRouter\n * (`openai-completions`), and generic OpenAI-compatible providers do not qualify. An `openai` or\n * `openai-codex` model on an adapter that cannot carry `service_tier` must not offer a fast variant,\n * because selecting it would send an ordinary request under a name that promises otherwise.\n */\nexport function usesOpenAIFastServiceTier(model: Pick<Model<Api>, \"api\" | \"provider\">): boolean {\n\treturn (\n\t\tisNativeFastRouteApi(model.api) &&\n\t\t(model.provider === \"openai\" || model.provider === \"openai-api\" || model.provider === \"openai-codex\")\n\t);\n}\n\n/**\n * xAI Priority Processing keeps the base upstream Grok model ID and adds the same\n * `service_tier: \"priority\"` field on the Responses API. xAI has no `-fast` model slugs for current\n * Grok models; priority is billed at twice the standard token rates, and only when the response\n * confirms the tier. https://docs.x.ai/developers/advanced-api-usage/priority-processing\n *\n * Eligibility requires the first-party `xai` provider on `openai-responses`. OpenRouter, Vercel AI\n * Gateway, and renamed or proxied xAI-compatible providers do not qualify.\n */\nexport function usesXaiFastServiceTier(model: Pick<Model<Api>, \"api\" | \"provider\">): boolean {\n\treturn model.api === \"openai-responses\" && model.provider === \"xai\";\n}\n\n/** GitHub Copilot advertises real fast sibling model IDs per account; it never uses a service tier. */\nexport function isGitHubCopilotModel(model: Pick<Model<Api>, \"provider\">): boolean {\n\treturn model.provider === \"github-copilot\";\n}\n\n/**\n * Anthropic fast mode keeps the base upstream model ID and adds `speed: \"fast\"` with the fast-mode beta.\n *\n * Eligibility requires the first-party `anthropic` provider on the Messages API and a supported model.\n * Fast mode is not offered through Amazon Bedrock, Google Vertex, GitHub Copilot, OpenRouter, or a\n * renamed or proxied Anthropic-compatible provider.\n */\nexport function usesAnthropicFastMode(model: Pick<Model<Api>, \"api\" | \"id\" | \"provider\">): boolean {\n\treturn (\n\t\tmodel.api === \"anthropic-messages\" &&\n\t\t(model.provider === \"anthropic\" || model.provider === \"anthropic-api\") &&\n\t\tANTHROPIC_FAST_MODE_MODEL_IDS.has(model.id)\n\t);\n}\n\nfunction advertisedModelIds(value: unknown): readonly string[] | undefined {\n\tif (!Array.isArray(value) || !value.every((entry) => typeof entry === \"string\")) return undefined;\n\treturn value;\n}\n\n/** Read the exact fast model IDs a stored GitHub Copilot OAuth credential advertises. */\nexport function copilotAdvertisedFastModelIds(credential: Credential | undefined): readonly string[] | undefined {\n\tif (credential?.type !== \"oauth\") return undefined;\n\treturn advertisedModelIds(credential.fastModelIds);\n}\n\n/** A model without tier metadata keeps offering Fast; one that lists its tiers must advertise it, as in Codex. */\nfunction advertisesFastServiceTier(model: Model<Api>): boolean {\n\treturn model.serviceTiers === undefined || getServiceTierCost(model, FAST_MODEL_SERVICE_TIER) !== undefined;\n}\n\nfunction fastRouteForBaseModel(\n\tmodel: Model<Api>,\n\tentitledCopilotFastModelIds: ReadonlySet<string>,\n): ModelFastRoute | undefined {\n\tif (usesOpenAIFastServiceTier(model)) {\n\t\treturn advertisesFastServiceTier(model)\n\t\t\t? { baseModelId: model.id, upstreamModelId: model.id, serviceTier: FAST_MODEL_SERVICE_TIER }\n\t\t\t: undefined;\n\t}\n\tif (usesXaiFastServiceTier(model)) {\n\t\treturn { baseModelId: model.id, upstreamModelId: model.id, serviceTier: FAST_MODEL_SERVICE_TIER };\n\t}\n\tif (usesAnthropicFastMode(model)) {\n\t\treturn { baseModelId: model.id, upstreamModelId: model.id, speed: FAST_MODEL_SPEED };\n\t}\n\tif (isGitHubCopilotModel(model)) {\n\t\tconst advertisedId = fastModelId(model.id);\n\t\treturn entitledCopilotFastModelIds.has(advertisedId)\n\t\t\t? { baseModelId: model.id, upstreamModelId: advertisedId }\n\t\t\t: undefined;\n\t}\n\treturn undefined;\n}\n\n/**\n * Add a selectable `<base-model-id>-fast` entry for every eligible model, carrying the explicit\n * {@link ModelFastRoute} metadata that gives it fast semantics. The input list is preserved verbatim\n * and in order; each derived entry is appended directly after the model it derives from.\n *\n * A model whose exact `-fast` ID is already owned by the provider, a `models.json` custom model, or an\n * extension wins: derivation is suppressed for it and a diagnostic is recorded. The owning model keeps\n * whatever semantics it declares, because fast behavior comes only from `fastRoute`, never from the\n * `-fast` suffix. For the same reason a base model whose ID already ends in `-fast` is never used to\n * derive a `-fast-fast` variant: that is not a canonical ID this scheme defines.\n *\n * A derived entry is a real catalog model, so a `modelOverrides` entry keyed on its exact `-fast` ID\n * applies to it after derivation. Without that pass the derived entry would inherit the *base* model's\n * overrides and its own would be silently inert.\n *\n * No variant is derived for an API whose transport a registered extension owns, because Atomic cannot\n * enforce the route through a transport it does not serialize.\n */\nexport function deriveFastModelVariants(\n\tproviderId: string,\n\tmodels: readonly Model<Api>[],\n\toptions: DeriveFastModelVariantsOptions = {},\n): FastModelVariantDerivation {\n\tconst ownedModelIds = new Set(models.map((model) => model.id));\n\tconst entitledCopilotFastModelIds = new Set(options.copilotFastModelIds ?? []);\n\tconst derived: Model<Api>[] = [];\n\tconst diagnostics: FastModelVariantDiagnostic[] = [];\n\tlet changed = false;\n\tfor (const model of models) {\n\t\tderived.push(model);\n\t\tif (\n\t\t\tmodel.fastRoute !== undefined ||\n\t\t\tmodel.id.endsWith(FAST_MODEL_ID_SUFFIX) ||\n\t\t\tmodel.id.endsWith(ULTRAFAST_MODEL_ID_SUFFIX)\n\t\t)\n\t\t\tcontinue;\n\t\tif (options.customModelIds?.has(model.id)) continue;\n\t\t// An extension that supplies this API's stream function owns its serialization, so Atomic cannot\n\t\t// guarantee the route reaches the wire. Publishing a `-fast` choice it may not honor is the same\n\t\t// hazard as publishing one for an adapter that cannot carry the tier.\n\t\tif (options.extensionOwnedApis?.has(model.api) === true) continue;\n\t\tconst fastRoute = fastRouteForBaseModel(model, entitledCopilotFastModelIds);\n\t\tconst routes: Array<{ suffix: string; label: string; route: ModelFastRoute }> = [];\n\t\tif (fastRoute) routes.push({ suffix: FAST_MODEL_ID_SUFFIX, label: \"fast\", route: fastRoute });\n\t\tif (usesOpenAIFastServiceTier(model) && getServiceTierCost(model, ULTRAFAST_MODEL_SERVICE_TIER)) {\n\t\t\troutes.push({\n\t\t\t\tsuffix: ULTRAFAST_MODEL_ID_SUFFIX,\n\t\t\t\tlabel: \"ultrafast\",\n\t\t\t\troute: { baseModelId: model.id, upstreamModelId: model.id, serviceTier: ULTRAFAST_MODEL_SERVICE_TIER },\n\t\t\t});\n\t\t}\n\t\tfor (const { suffix, label, route } of routes) {\n\t\t\tconst variantId = `${model.id}${suffix}`;\n\t\t\tif (ownedModelIds.has(variantId)) {\n\t\t\t\tdiagnostics.push({\n\t\t\t\t\tprovider: providerId,\n\t\t\t\t\tmodelId: variantId,\n\t\t\t\t\tmessage:\n\t\t\t\t\t\t`Model \"${providerId}/${variantId}\" is already defined by the provider, models.json, or an extension, ` +\n\t\t\t\t\t\t`so Atomic did not derive a ${label} variant of \"${providerId}/${model.id}\". ` +\n\t\t\t\t\t\t`That model routes exactly as declared. Rename or remove it to get the derived ${label} variant instead.`,\n\t\t\t\t});\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst override = options.modelOverrides?.[variantId];\n\t\t\tconst variant: Model<Api> = { ...model, id: variantId, name: `${model.name} (${label})`, fastRoute: route };\n\t\t\tderived.push(override ? applyModelOverride(variant, override) : variant);\n\t\t\tchanged = true;\n\t\t}\n\t}\n\tif (!changed && diagnostics.length === 0) return { models, diagnostics };\n\treturn { models: derived, diagnostics };\n}\n\n/**\n * Overlay derived fast model variants onto a composed provider. Apply this after built-in,\n * `models.json`, extension, and `modelOverrides` composition so exact user-owned `-fast` IDs are\n * already present and win the collision.\n */\nexport function withFastModelVariants(provider: Provider, options: FastModelVariantsOptions = {}): Provider {\n\treturn {\n\t\t...provider,\n\t\tgetModels: () => {\n\t\t\tconst { models, diagnostics } = deriveFastModelVariants(provider.id, provider.getModels(), {\n\t\t\t\tcopilotFastModelIds: isGitHubCopilotModel({ provider: provider.id })\n\t\t\t\t\t? options.getCopilotFastModelIds?.()\n\t\t\t\t\t: undefined,\n\t\t\t\tmodelOverrides: options.getModelOverrides?.(),\n\t\t\t\textensionOwnedApis: options.getExtensionOwnedApis?.(),\n\t\t\t\tcustomModelIds: options.getCustomModelIds?.(),\n\t\t\t});\n\t\t\toptions.onDiagnostics?.(provider.id, diagnostics);\n\t\t\treturn models;\n\t\t},\n\t};\n}\n"]}
|
|
@@ -74,6 +74,7 @@ export declare const ModelsJsonCompatSchema: Type.TObject<{
|
|
|
74
74
|
allowEmptySignature: Type.TOptional<Type.TBoolean>;
|
|
75
75
|
supportsStrictTools: Type.TOptional<Type.TBoolean>;
|
|
76
76
|
supportsMidConvoToolChanges: Type.TOptional<Type.TBoolean>;
|
|
77
|
+
supportsMessageThreads: Type.TOptional<Type.TBoolean>;
|
|
77
78
|
allowedFallbackModels: Type.TOptional<Type.TArray<Type.TObject<{
|
|
78
79
|
provider: Type.TString;
|
|
79
80
|
model: Type.TString;
|
|
@@ -239,6 +240,7 @@ declare const ModelDefinitionSchema: Type.TObject<{
|
|
|
239
240
|
allowEmptySignature: Type.TOptional<Type.TBoolean>;
|
|
240
241
|
supportsStrictTools: Type.TOptional<Type.TBoolean>;
|
|
241
242
|
supportsMidConvoToolChanges: Type.TOptional<Type.TBoolean>;
|
|
243
|
+
supportsMessageThreads: Type.TOptional<Type.TBoolean>;
|
|
242
244
|
allowedFallbackModels: Type.TOptional<Type.TArray<Type.TObject<{
|
|
243
245
|
provider: Type.TString;
|
|
244
246
|
model: Type.TString;
|
|
@@ -402,6 +404,7 @@ declare const ModelOverrideSchema: Type.TObject<{
|
|
|
402
404
|
allowEmptySignature: Type.TOptional<Type.TBoolean>;
|
|
403
405
|
supportsStrictTools: Type.TOptional<Type.TBoolean>;
|
|
404
406
|
supportsMidConvoToolChanges: Type.TOptional<Type.TBoolean>;
|
|
407
|
+
supportsMessageThreads: Type.TOptional<Type.TBoolean>;
|
|
405
408
|
allowedFallbackModels: Type.TOptional<Type.TArray<Type.TObject<{
|
|
406
409
|
provider: Type.TString;
|
|
407
410
|
model: Type.TString;
|
|
@@ -516,6 +519,7 @@ declare const ProviderConfigSchema: Type.TObject<{
|
|
|
516
519
|
allowEmptySignature: Type.TOptional<Type.TBoolean>;
|
|
517
520
|
supportsStrictTools: Type.TOptional<Type.TBoolean>;
|
|
518
521
|
supportsMidConvoToolChanges: Type.TOptional<Type.TBoolean>;
|
|
522
|
+
supportsMessageThreads: Type.TOptional<Type.TBoolean>;
|
|
519
523
|
allowedFallbackModels: Type.TOptional<Type.TArray<Type.TObject<{
|
|
520
524
|
provider: Type.TString;
|
|
521
525
|
model: Type.TString;
|
|
@@ -682,6 +686,7 @@ declare const ProviderConfigSchema: Type.TObject<{
|
|
|
682
686
|
allowEmptySignature: Type.TOptional<Type.TBoolean>;
|
|
683
687
|
supportsStrictTools: Type.TOptional<Type.TBoolean>;
|
|
684
688
|
supportsMidConvoToolChanges: Type.TOptional<Type.TBoolean>;
|
|
689
|
+
supportsMessageThreads: Type.TOptional<Type.TBoolean>;
|
|
685
690
|
allowedFallbackModels: Type.TOptional<Type.TArray<Type.TObject<{
|
|
686
691
|
provider: Type.TString;
|
|
687
692
|
model: Type.TString;
|
|
@@ -845,6 +850,7 @@ declare const ProviderConfigSchema: Type.TObject<{
|
|
|
845
850
|
allowEmptySignature: Type.TOptional<Type.TBoolean>;
|
|
846
851
|
supportsStrictTools: Type.TOptional<Type.TBoolean>;
|
|
847
852
|
supportsMidConvoToolChanges: Type.TOptional<Type.TBoolean>;
|
|
853
|
+
supportsMessageThreads: Type.TOptional<Type.TBoolean>;
|
|
848
854
|
allowedFallbackModels: Type.TOptional<Type.TArray<Type.TObject<{
|
|
849
855
|
provider: Type.TString;
|
|
850
856
|
model: Type.TString;
|
|
@@ -962,6 +968,7 @@ export declare const ModelsConfigSchema: Type.TObject<{
|
|
|
962
968
|
allowEmptySignature: Type.TOptional<Type.TBoolean>;
|
|
963
969
|
supportsStrictTools: Type.TOptional<Type.TBoolean>;
|
|
964
970
|
supportsMidConvoToolChanges: Type.TOptional<Type.TBoolean>;
|
|
971
|
+
supportsMessageThreads: Type.TOptional<Type.TBoolean>;
|
|
965
972
|
allowedFallbackModels: Type.TOptional<Type.TArray<Type.TObject<{
|
|
966
973
|
provider: Type.TString;
|
|
967
974
|
model: Type.TString;
|
|
@@ -1128,6 +1135,7 @@ export declare const ModelsConfigSchema: Type.TObject<{
|
|
|
1128
1135
|
allowEmptySignature: Type.TOptional<Type.TBoolean>;
|
|
1129
1136
|
supportsStrictTools: Type.TOptional<Type.TBoolean>;
|
|
1130
1137
|
supportsMidConvoToolChanges: Type.TOptional<Type.TBoolean>;
|
|
1138
|
+
supportsMessageThreads: Type.TOptional<Type.TBoolean>;
|
|
1131
1139
|
allowedFallbackModels: Type.TOptional<Type.TArray<Type.TObject<{
|
|
1132
1140
|
provider: Type.TString;
|
|
1133
1141
|
model: Type.TString;
|
|
@@ -1291,6 +1299,7 @@ export declare const ModelsConfigSchema: Type.TObject<{
|
|
|
1291
1299
|
allowEmptySignature: Type.TOptional<Type.TBoolean>;
|
|
1292
1300
|
supportsStrictTools: Type.TOptional<Type.TBoolean>;
|
|
1293
1301
|
supportsMidConvoToolChanges: Type.TOptional<Type.TBoolean>;
|
|
1302
|
+
supportsMessageThreads: Type.TOptional<Type.TBoolean>;
|
|
1294
1303
|
allowedFallbackModels: Type.TOptional<Type.TArray<Type.TObject<{
|
|
1295
1304
|
provider: Type.TString;
|
|
1296
1305
|
model: Type.TString;
|
|
@@ -1408,6 +1417,7 @@ export declare const ModelsJsonSchemas: {
|
|
|
1408
1417
|
allowEmptySignature: Type.TOptional<Type.TBoolean>;
|
|
1409
1418
|
supportsStrictTools: Type.TOptional<Type.TBoolean>;
|
|
1410
1419
|
supportsMidConvoToolChanges: Type.TOptional<Type.TBoolean>;
|
|
1420
|
+
supportsMessageThreads: Type.TOptional<Type.TBoolean>;
|
|
1411
1421
|
allowedFallbackModels: Type.TOptional<Type.TArray<Type.TObject<{
|
|
1412
1422
|
provider: Type.TString;
|
|
1413
1423
|
model: Type.TString;
|
|
@@ -1574,6 +1584,7 @@ export declare const ModelsJsonSchemas: {
|
|
|
1574
1584
|
allowEmptySignature: Type.TOptional<Type.TBoolean>;
|
|
1575
1585
|
supportsStrictTools: Type.TOptional<Type.TBoolean>;
|
|
1576
1586
|
supportsMidConvoToolChanges: Type.TOptional<Type.TBoolean>;
|
|
1587
|
+
supportsMessageThreads: Type.TOptional<Type.TBoolean>;
|
|
1577
1588
|
allowedFallbackModels: Type.TOptional<Type.TArray<Type.TObject<{
|
|
1578
1589
|
provider: Type.TString;
|
|
1579
1590
|
model: Type.TString;
|
|
@@ -1737,6 +1748,7 @@ export declare const ModelsJsonSchemas: {
|
|
|
1737
1748
|
allowEmptySignature: Type.TOptional<Type.TBoolean>;
|
|
1738
1749
|
supportsStrictTools: Type.TOptional<Type.TBoolean>;
|
|
1739
1750
|
supportsMidConvoToolChanges: Type.TOptional<Type.TBoolean>;
|
|
1751
|
+
supportsMessageThreads: Type.TOptional<Type.TBoolean>;
|
|
1740
1752
|
allowedFallbackModels: Type.TOptional<Type.TArray<Type.TObject<{
|
|
1741
1753
|
provider: Type.TString;
|
|
1742
1754
|
model: Type.TString;
|
|
@@ -1904,6 +1916,7 @@ export declare const ModelsJsonSchemas: {
|
|
|
1904
1916
|
allowEmptySignature: Type.TOptional<Type.TBoolean>;
|
|
1905
1917
|
supportsStrictTools: Type.TOptional<Type.TBoolean>;
|
|
1906
1918
|
supportsMidConvoToolChanges: Type.TOptional<Type.TBoolean>;
|
|
1919
|
+
supportsMessageThreads: Type.TOptional<Type.TBoolean>;
|
|
1907
1920
|
allowedFallbackModels: Type.TOptional<Type.TArray<Type.TObject<{
|
|
1908
1921
|
provider: Type.TString;
|
|
1909
1922
|
model: Type.TString;
|
|
@@ -2067,6 +2080,7 @@ export declare const ModelsJsonSchemas: {
|
|
|
2067
2080
|
allowEmptySignature: Type.TOptional<Type.TBoolean>;
|
|
2068
2081
|
supportsStrictTools: Type.TOptional<Type.TBoolean>;
|
|
2069
2082
|
supportsMidConvoToolChanges: Type.TOptional<Type.TBoolean>;
|
|
2083
|
+
supportsMessageThreads: Type.TOptional<Type.TBoolean>;
|
|
2070
2084
|
allowedFallbackModels: Type.TOptional<Type.TArray<Type.TObject<{
|
|
2071
2085
|
provider: Type.TString;
|
|
2072
2086
|
model: Type.TString;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-config.d.ts","sourceRoot":"","sources":["../../src/core/model-config.ts"],"names":[],"mappings":"AAAA,wDAAwD;AAWxD,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAoC5C,uGAAuG;AACvG,eAAO,MAAM,sBAAsB
|
|
1
|
+
{"version":3,"file":"model-config.d.ts","sourceRoot":"","sources":["../../src/core/model-config.ts"],"names":[],"mappings":"AAAA,wDAAwD;AAWxD,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAoC5C,uGAAuG;AACvG,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IACL,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACb,CAAC;AAIF,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,OAAO,qBAAqB,CAAC,CAAC;AACnE,MAAM,MAAM,uBAAuB,GAAG,MAAM,CAAC,OAAO,mBAAmB,CAAC,CAAC;AACzE,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAqBrE,yCAAyC;AACzC,qBAAa,WAAW;IACvB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA0C;IACpE,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAqB;IAE3C,OAAO,eAGN;IAED,OAAa,IAAI,CAAC,cAAc,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC,CAsC1E;IAED,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS,CAE9D;IAED,cAAc,IAAI,SAAS,MAAM,EAAE,CAElC;IAED,QAAQ,IAAI,MAAM,GAAG,SAAS,CAE7B;CACD"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How Atomic shows a model (#4269): its raw ID, exactly as `--model`, settings, workflow `model:` fields and extension
|
|
3
|
+
* configs take it, followed by the reasoning level it runs at. A display name never replaces the ID; it is secondary
|
|
4
|
+
* metadata at most, such as a dim picker column or a search target.
|
|
5
|
+
*
|
|
6
|
+
* Split on whitespace, `anthropic/claude-sonnet-4-5 high` gives the `anthropic/claude-sonnet-4-5` and `high` that
|
|
7
|
+
* `--model anthropic/claude-sonnet-4-5:high` takes.
|
|
8
|
+
*/
|
|
9
|
+
import type { Api, Model } from "@bastani/pi-ai/compat";
|
|
10
|
+
/** Between a model's ID and its level in the TUI and in notices. */
|
|
11
|
+
export declare const MODEL_LABEL_SEPARATOR = " ";
|
|
12
|
+
/** Between a model's ID and its level in machine-readable output such as `--list-models`. */
|
|
13
|
+
export declare const MODEL_LABEL_FIELD_SEPARATOR = "\t";
|
|
14
|
+
export type ModelLabelSubject = Pick<Model<Api>, "provider" | "id"> & {
|
|
15
|
+
readonly reasoning?: boolean;
|
|
16
|
+
};
|
|
17
|
+
export interface ModelLabelOptions {
|
|
18
|
+
/** The reasoning level the model runs at. A model without reasoning shows none. */
|
|
19
|
+
readonly thinkingLevel?: string;
|
|
20
|
+
/** Show the bare ID where the provider is already clear from context. */
|
|
21
|
+
readonly omitProvider?: boolean;
|
|
22
|
+
/** Defaults to {@link MODEL_LABEL_SEPARATOR}. */
|
|
23
|
+
readonly separator?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* A model's label: `provider/id` (or `id` with `omitProvider`), followed by its level when it has reasoning.
|
|
27
|
+
*
|
|
28
|
+
* A string is a resolved `provider/id`, shown whole: an ID may itself end in a level word such as `:high`. Since a
|
|
29
|
+
* string cannot say whether the model reasons, any `thinkingLevel` given is shown. Use
|
|
30
|
+
* {@link formatModelReferenceLabel} for a configured `provider/id[:level]` reference.
|
|
31
|
+
*/
|
|
32
|
+
export declare function formatModelLabel(model: ModelLabelSubject | string, options?: ModelLabelOptions): string;
|
|
33
|
+
/**
|
|
34
|
+
* The label of a configured model reference (`provider/id[:level]`, as `--model`, `fallbackModels` and a launch's
|
|
35
|
+
* requested model are written): its ID, then the level its suffix names, else `thinkingLevel`.
|
|
36
|
+
*/
|
|
37
|
+
export declare function formatModelReferenceLabel(reference: string, options?: ModelLabelOptions): string;
|
|
38
|
+
//# sourceMappingURL=model-label.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-label.d.ts","sourceRoot":"","sources":["../../src/core/model-label.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAGxD,oEAAoE;AACpE,eAAO,MAAM,qBAAqB,OAAO,CAAC;AAE1C,6FAA6F;AAC7F,eAAO,MAAM,2BAA2B,OAAO,CAAC;AAEhD,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC,GAAG;IAAE,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAEvG,MAAM,WAAW,iBAAiB;IACjC,mFAAmF;IACnF,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,yEAAyE;IACzE,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC;IAChC,iDAAiD;IACjD,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,EAAE,OAAO,GAAE,iBAAsB,GAAG,MAAM,CAY3G;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,GAAE,iBAAsB,GAAG,MAAM,CAMpG"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How Atomic shows a model (#4269): its raw ID, exactly as `--model`, settings, workflow `model:` fields and extension
|
|
3
|
+
* configs take it, followed by the reasoning level it runs at. A display name never replaces the ID; it is secondary
|
|
4
|
+
* metadata at most, such as a dim picker column or a search target.
|
|
5
|
+
*
|
|
6
|
+
* Split on whitespace, `anthropic/claude-sonnet-4-5 high` gives the `anthropic/claude-sonnet-4-5` and `high` that
|
|
7
|
+
* `--model anthropic/claude-sonnet-4-5:high` takes.
|
|
8
|
+
*/
|
|
9
|
+
import { splitFallbackModel } from "./fallback-models.js";
|
|
10
|
+
/** Between a model's ID and its level in the TUI and in notices. */
|
|
11
|
+
export const MODEL_LABEL_SEPARATOR = " ";
|
|
12
|
+
/** Between a model's ID and its level in machine-readable output such as `--list-models`. */
|
|
13
|
+
export const MODEL_LABEL_FIELD_SEPARATOR = "\t";
|
|
14
|
+
/**
|
|
15
|
+
* A model's label: `provider/id` (or `id` with `omitProvider`), followed by its level when it has reasoning.
|
|
16
|
+
*
|
|
17
|
+
* A string is a resolved `provider/id`, shown whole: an ID may itself end in a level word such as `:high`. Since a
|
|
18
|
+
* string cannot say whether the model reasons, any `thinkingLevel` given is shown. Use
|
|
19
|
+
* {@link formatModelReferenceLabel} for a configured `provider/id[:level]` reference.
|
|
20
|
+
*/
|
|
21
|
+
export function formatModelLabel(model, options = {}) {
|
|
22
|
+
let reference;
|
|
23
|
+
let level;
|
|
24
|
+
if (typeof model === "string") {
|
|
25
|
+
const slash = model.indexOf("/");
|
|
26
|
+
reference = options.omitProvider && slash >= 0 ? model.slice(slash + 1) : model;
|
|
27
|
+
level = options.thinkingLevel;
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
reference = options.omitProvider ? model.id : `${model.provider}/${model.id}`;
|
|
31
|
+
level = model.reasoning ? options.thinkingLevel : undefined;
|
|
32
|
+
}
|
|
33
|
+
return level ? `${reference}${options.separator ?? MODEL_LABEL_SEPARATOR}${level}` : reference;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The label of a configured model reference (`provider/id[:level]`, as `--model`, `fallbackModels` and a launch's
|
|
37
|
+
* requested model are written): its ID, then the level its suffix names, else `thinkingLevel`.
|
|
38
|
+
*/
|
|
39
|
+
export function formatModelReferenceLabel(reference, options = {}) {
|
|
40
|
+
const parsed = splitFallbackModel(reference);
|
|
41
|
+
return formatModelLabel(parsed.modelId, {
|
|
42
|
+
...options,
|
|
43
|
+
thinkingLevel: parsed.thinkingLevel ?? options.thinkingLev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AAC,SAAS,CAAC;AAChG,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,yBAAyB,CAAC,SAAiB,EAAE,OAAO,GAAsB,EAAE;IAC3F,MAAM,MAAM,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAC;IAC7C,OAAO,gBAAgB,CAAC,MAAM,CAAC,OAAO,EAAE;QACvC,GAAG,OAAO;QACV,aAAa,EAAE,MAAM,CAAC,aAAa,IAAI,OAAO,CAAC,aAAa;KAC5D,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/**\n * How Atomic shows a model (#4269): its raw ID, exactly as `--model`, settings, workflow `model:` fields and extension\n * configs take it, followed by the reasoning level it runs at. A display name never replaces the ID; it is secondary\n * metadata at most, such as a dim picker column or a search target.\n *\n * Split on whitespace, `anthropic/claude-sonnet-4-5 high` gives the `anthropic/claude-sonnet-4-5` and `high` that\n * `--model anthropic/claude-sonnet-4-5:high` takes.\n */\n\nimport type { Api, Model } from \"@bastani/pi-ai/compat\";\nimport { splitFallbackModel } from \"./fallback-models.ts\";\n\n/** Between a model's ID and its level in the TUI and in notices. */\nexport const MODEL_LABEL_SEPARATOR = \" \";\n\n/** Between a model's ID and its level in machine-readable output such as `--list-models`. */\nexport const MODEL_LABEL_FIELD_SEPARATOR = \"\\t\";\n\nexport type ModelLabelSubject = Pick<Model<Api>, \"provider\" | \"id\"> & { readonly reasoning?: boolean };\n\nexport interface ModelLabelOptions {\n\t/** The reasoning level the model runs at. A model without reasoning shows none. */\n\treadonly thinkingLevel?: string;\n\t/** Show the bare ID where the provider is already clear from context. */\n\treadonly omitProvider?: boolean;\n\t/** Defaults to {@link MODEL_LABEL_SEPARATOR}. */\n\treadonly separator?: string;\n}\n\n/**\n * A model's label: `provider/id` (or `id` with `omitProvider`), followed by its level when it has reasoning.\n *\n * A string is a resolved `provider/id`, shown whole: an ID may itself end in a level word such as `:high`. Since a\n * string cannot say whether the model reasons, any `thinkingLevel` given is shown. Use\n * {@link formatModelReferenceLabel} for a configured `provider/id[:level]` reference.\n */\nexport function formatModelLabel(model: ModelLabelSubject | string, options: ModelLabelOptions = {}): string {\n\tlet reference: string;\n\tlet level: string | undefined;\n\tif (typeof model === \"string\") {\n\t\tconst slash = model.indexOf(\"/\");\n\t\treference = options.omitProvider && slash >= 0 ? model.slice(slash + 1) : model;\n\t\tlevel = options.thinkingLevel;\n\t} else {\n\t\treference = options.omitProvider ? model.id : `${model.provider}/${model.id}`;\n\t\tlevel = model.reasoning ? options.thinkingLevel : undefined;\n\t}\n\treturn level ? `${reference}${options.separator ?? MODEL_LABEL_SEPARATOR}${level}` : reference;\n}\n\n/**\n * The label of a configured model reference (`provider/id[:level]`, as `--model`, `fallbackModels` and a launch's\n * requested model are written): its ID, then the level its suffix names, else `thinkingLevel`.\n */\nexport function formatModelReferenceLabel(reference: string, options: ModelLabelOptions = {}): string {\n\tconst parsed = splitFallbackModel(reference);\n\treturn formatModelLabel(parsed.modelId, {\n\t\t...options,\n\t\tthinkingLevel: parsed.thinkingLevel ?? options.thinkingLevel,\n\t});\n}\n"]}
|
|
@@ -2,6 +2,11 @@ import type { Api, Model } from "@bastani/pi-ai/compat";
|
|
|
2
2
|
import type { ThinkingLevel } from "@earendil-works/pi-agent-core";
|
|
3
3
|
import type { InitialModelResult, ScopedModel } from "./model-resolver-types.ts";
|
|
4
4
|
import type { ModelRuntime } from "./model-runtime.js";
|
|
5
|
+
/**
|
|
6
|
+
* Explain a saved GitHub Copilot model an authenticated catalog lacks. Copilot models beyond the
|
|
7
|
+
* built-in catalog come from the account's model list, which is cached only after a catalog refresh.
|
|
8
|
+
*/
|
|
9
|
+
export declare function uncachedCopilotModelHint(provider: string, modelId: string, modelRuntime: Pick<ModelRuntime, "getModel" | "hasConfiguredAuth">): string | undefined;
|
|
5
10
|
/**
|
|
6
11
|
* Resolve a model reference persisted in a session. Exact unauthenticated
|
|
7
12
|
* models are authoritative failures; only an absent id may be reconstructed
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-resolver-initial.d.ts","sourceRoot":"","sources":["../../src/core/model-resolver-initial.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"model-resolver-initial.d.ts","sourceRoot":"","sources":["../../src/core/model-resolver-initial.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AASnE,OAAO,KAAK,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACjF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAKvD;;;GAGG;AACH,wBAAgB,wBAAwB,CACvC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,IAAI,CAAC,YAAY,EAAE,UAAU,GAAG,mBAAmB,CAAC,GAChE,MAAM,GAAG,SAAS,CAKpB;AAUD;;;;GAIG;AACH,wBAAsB,6BAA6B,CAClD,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,YAAY,GACxB,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,CAMjC;AAED;;;;;;;GAOG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE;IAC/C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,WAAW,EAAE,CAAC;IAC5B,YAAY,EAAE,OAAO,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,oBAAoB,CAAC,EAAE,aAAa,CAAC;IACrC,mBAAmB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IACpD,YAAY,EAAE,YAAY,CAAC;CAC3B,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAyF9B;AAED;;GAEG;AACH,wBAAsB,uBAAuB,CAC5C,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,SAAS,EACpC,mBAAmB,EAAE,OAAO,EAC5B,YAAY,EAAE,YAAY,GACxB,OAAO,CAAC;IACV,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC;IAC9B,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;CACpC,CAAC,CA2CD"}
|
|
@@ -1,11 +1,25 @@
|
|
|
1
1
|
import { normalizeProviderId } from "@bastani/pi-ai";
|
|
2
2
|
import chalk from "chalk";
|
|
3
|
+
import { APP_NAME } from "../config.js";
|
|
3
4
|
import { normalizeProviderKeys } from "./azure-provider-compat.js";
|
|
4
5
|
import { DEFAULT_THINKING_LEVEL } from "./defaults.js";
|
|
6
|
+
import { formatModelLabel } from "./model-label.js";
|
|
5
7
|
import { resolveCliModel } from "./model-resolver-cli.js";
|
|
6
8
|
import { findPreferredAvailableModel } from "./model-resolver-defaults.js";
|
|
7
9
|
import { buildFallbackModel } from "./model-resolver-patterns.js";
|
|
8
10
|
const CONFIGURED_DEFAULT_MODEL_UNAVAILABLE_MESSAGE = "Configured default model is unavailable or unsupported. Update defaultProvider/defaultModel or use /model.";
|
|
11
|
+
/**
|
|
12
|
+
* Explain a saved GitHub Copilot model an authenticated catalog lacks. Copilot models beyond the
|
|
13
|
+
* built-in catalog come from the account's model list, which is cached only after a catalog refresh.
|
|
14
|
+
*/
|
|
15
|
+
export function uncachedCopilotModelHint(provider, modelId, modelRuntime) {
|
|
16
|
+
provider = normalizeProviderId(provider);
|
|
17
|
+
if (provider !== "github-copilot" || modelRuntime.getModel(provider, modelId))
|
|
18
|
+
return undefined;
|
|
19
|
+
if (!modelRuntime.hasConfiguredAuth(provider))
|
|
20
|
+
return undefined;
|
|
21
|
+
return `it is not in the cached GitHub Copilot model list; run "${APP_NAME} update --models" to refresh it`;
|
|
22
|
+
}
|
|
9
23
|
async function buildConfiguredProviderFallbackModel(provider, modelId, modelRuntime) {
|
|
10
24
|
return buildFallbackModel(provider, modelId, await [...modelRuntime.getAvailableSnapshot()]);
|
|
11
25
|
}
|
|
@@ -83,6 +97,15 @@ export async function findInitialModel(options) {
|
|
|
83
97
|
fallbackReason: "configured-provider-unsupported",
|
|
84
98
|
};
|
|
85
99
|
}
|
|
100
|
+
const uncachedHint = uncachedCopilotModelHint(defaultProvider, defaultModelId, modelRuntime);
|
|
101
|
+
if (uncachedHint) {
|
|
102
|
+
return {
|
|
103
|
+
model: undefined,
|
|
104
|
+
thinkingLevel: DEFAULT_THINKING_LEVEL,
|
|
105
|
+
fallbackMessage: `Configured default model ${formatModelLabel({ provider: defaultProvider, id: defaultModelId })} is unavailable: ${uncachedHint}, or choose another model with /model.`,
|
|
106
|
+
fallbackReason: "configured-provider-unsupported",
|
|
107
|
+
};
|
|
108
|
+
}
|
|
86
109
|
}
|
|
87
110
|
const availableModels = await [...modelRuntime.getAvailableSnapshot()];
|
|
88
111
|
if (availableModels.length > 0) {
|
|
@@ -110,7 +133,9 @@ export async function restoreModelFromSession(savedProvider, savedModelId, curre
|
|
|
110
133
|
}
|
|
111
134
|
return { model: restoredModel, fallbackMessage: undefined };
|
|
112
135
|
}
|
|
113
|
-
const reason =
|
|
136
|
+
const reason = exactRestoredModel
|
|
137
|
+
? "no auth configured"
|
|
138
|
+
: (uncachedCopilotModelHint(savedProvider, savedModelId, modelRuntime) ?? "model no longer exists");
|
|
114
139
|
if (shouldPrintMessages) {
|
|
115
140
|
console.error(chalk.yellow(`Warning: Could not restore model ${savedProvider}/${savedModelId} (${reason}).`));
|
|
116
141
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"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AC,EAAE,GAAG;SAC3I,CAAC;IACH,CAAC;IAED,MAAM,eAAe,GAAG,MAAM,CAAC,GAAG,YAAY,CAAC,oBAAoB,EAAE,CAAC,CAAC;IACvE,MAAM,aAAa,GAAG,2BAA2B,CAAC,eAAe,CAAC,CAAC;IACnE,IAAI,aAAa,EAAE,CAAC;QACnB,IAAI,mBAAmB,EAAE,CAAC;YACzB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,oBAAoB,aAAa,CAAC,QAAQ,IAAI,aAAa,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;QAC1F,CAAC;QAED,OAAO;YACN,KAAK,EAAE,aAAa;YACpB,eAAe,EAAE,2BAA2B,aAAa,IAAI,YAAY,KAAK,MAAM,YAAY,aAAa,CAAC,QAAQ,IAAI,aAAa,CAAC,EAAE,GAAG;SAC7I,CAAC;IACH,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,SAAS,EAAE,CAAC;AACzD,CAAC","sourcesContent":["import { normalizeProviderId } from \"@bastani/pi-ai\";\nimport type { Api, Model } from \"@bastani/pi-ai/compat\";\nimport type { ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport chalk from \"chalk\";\nimport { normalizeProviderKeys } from \"./azure-provider-compat.js\";\nimport { DEFAULT_THINKING_LEVEL } from \"./defaults.ts\";\nimport { resolveCliModel } from \"./model-resolver-cli.ts\";\nimport { findPreferredAvailableModel } from \"./model-resolver-defaults.ts\";\nimport { buildFallbackModel } from \"./model-resolver-patterns.ts\";\nimport type { InitialModelResult, ScopedModel } from \"./model-resolver-types.ts\";\nimport type { ModelRuntime } from \"./model-runtime.js\";\n\nconst CONFIGURED_DEFAULT_MODEL_UNAVAILABLE_MESSAGE =\n\t\"Configured default model is unavailable or unsupported. Update defaultProvider/defaultModel or use /model.\";\n\nasync function buildConfiguredProviderFallbackModel(\n\tprovider: string,\n\tmodelId: string,\n\tmodelRuntime: ModelRuntime,\n): Promise<Model<Api> | undefined> {\n\treturn buildFallbackModel(provider, modelId, await [...modelRuntime.getAvailableSnapshot()]);\n}\n\n/**\n * Resolve a model reference persisted in a session. Exact unauthenticated\n * models are authoritative failures; only an absent id may be reconstructed\n * from an authenticated model for the same dynamic/custom provider.\n */\nexport async function resolveRestoredModelReference(\n\tprovider: string,\n\tmodelId: string,\n\tmodelRuntime: ModelRuntime,\n): Promise<Model<Api> | undefined> {\n\tprovider = normalizeProviderId(provider);\n\tconst found = modelRuntime.getModel(provider, modelId);\n\tif (found) return modelRuntime.hasConfiguredAuth(found.provider) ? found : undefined;\n\tif (!modelRuntime.canRestoreUnknownModel(provider, modelId)) return undefined;\n\treturn buildConfiguredProviderFallbackModel(provider, modelId, modelRuntime);\n}\n\n/**\n * Find the initial model to use based on priority:\n * 1. CLI args (provider + model)\n * 2. First model from scoped models (if not continuing/resuming)\n * 3. Restored from session (if continuing/resuming)\n * 4. Saved default from settings\n * 5. First available model with valid API key\n */\nexport async function findInitialModel(options: {\n\tcliProvider?: string;\n\tcliModel?: string;\n\tscopedModels: ScopedModel[];\n\tisContinuing: boolean;\n\tdefaultProvider?: string;\n\tdefaultModelId?: string;\n\tdefaultThinkingLevel?: ThinkingLevel;\n\tmodelThinkingLevels?: Record<string, ThinkingLevel>;\n\tmodelRuntime: ModelRuntime;\n}): Promise<InitialModelResult> {\n\tconst {\n\t\tcliProvider,\n\t\tcliModel,\n\t\tscopedModels,\n\t\tisContinuing,\n\t\tdefaultProvider: configuredDefaultProvider,\n\t\tdefaultModelId,\n\t\tdefaultThinkingLevel,\n\t\tmodelThinkingLevels: configuredThinkingLevels,\n\t\tmodelRuntime,\n\t} = options;\n\tconst defaultProvider = configuredDefaultProvider ? normalizeProviderId(configuredDefaultProvider) : undefined;\n\tconst modelThinkingLevels = configuredThinkingLevels ? normalizeProviderKeys(configuredThinkingLevels) : undefined;\n\n\tlet model: Model<Api> | undefined;\n\tlet thinkingLevel: ThinkingLevel = DEFAULT_THINKING_LEVEL;\n\n\tif (cliProvider && cliModel) {\n\t\tconst resolved = resolveCliModel({\n\t\t\tcliProvider,\n\t\t\tcliModel,\n\t\t\tmodelRuntime,\n\t\t});\n\t\tif (resolved.error) {\n\t\t\tconsole.error(chalk.red(resolved.error));\n\t\t\tprocess.exit(1);\n\t\t}\n\t\tif (resolved.model) {\n\t\t\treturn {\n\t\t\t\tmodel: resolved.model,\n\t\t\t\tthinkingLevel: DEFAULT_THINKING_LEVEL,\n\t\t\t\tfallbackMessage: undefined,\n\t\t\t};\n\t\t}\n\t}\n\n\tif (scopedModels.length > 0 && !isContinuing) {\n\t\tconst scopedModel = scopedModels[0];\n\t\tconst perModel = modelThinkingLevels?.[`${scopedModel.model.provider}/${scopedModel.model.id}`];\n\t\treturn {\n\t\t\tmodel: scopedModel.model,\n\t\t\tthinkingLevel: scopedModel.thinkingLevel ?? perModel ?? defaultThinkingLevel ?? DEFAULT_THINKING_LEVEL,\n\t\t\tfallbackMessage: undefined,\n\t\t};\n\t}\n\n\tif (defaultProvider && defaultModelId) {\n\t\tconst found = modelRuntime.getModel(defaultProvider, defaultModelId);\n\t\tif (found && modelRuntime.hasConfiguredAuth(found.provider)) {\n\t\t\tmodel = found;\n\t\t\tconst perModel = modelThinkingLevels?.[`${defaultProvider}/${defaultModelId}`];\n\t\t\tif (perModel) thinkingLevel = perModel;\n\t\t\telse if (defaultThinkingLevel) thinkingLevel = defaultThinkingLevel;\n\t\t\treturn { model, thinkingLevel, fallbackMessage: undefined };\n\t\t}\n\t\tif (!modelRuntime.getProvider(defaultProvider)) {\n\t\t\treturn {\n\t\t\t\tmodel: undefined,\n\t\t\t\tthinkingLevel: DEFAULT_THINKING_LEVEL,\n\t\t\t\tfallbackMessage: CONFIGURED_DEFAULT_MODEL_UNAVAILABLE_MESSAGE,\n\t\t\t\tfallbackReason: \"configured-provider-unsupported\",\n\t\t\t};\n\t\t}\n\t}\n\n\tconst availableModels = await [...modelRuntime.getAvailableSnapshot()];\n\tif (availableModels.length > 0) {\n\t\treturn {\n\t\t\tmodel: findPreferredAvailableModel(availableModels),\n\t\t\tthinkingLevel: DEFAULT_THINKING_LEVEL,\n\t\t\tfallbackMessage: undefined,\n\t\t};\n\t}\n\n\treturn {\n\t\tmodel: undefined,\n\t\tthinkingLevel: DEFAULT_THINKING_LEVEL,\n\t\tfallbackMessage: undefined,\n\t};\n}\n\n/**\n * Restore model from session, with fallback to available models\n */\nexport async function restoreModelFromSession(\n\tsavedProvider: string,\n\tsavedModelId: string,\n\tcurrentModel: Model<Api> | undefined,\n\tshouldPrintMessages: boolean,\n\tmodelRuntime: ModelRuntime,\n): Promise<{\n\tmodel: Model<Api> | undefined;\n\tfallbackMessage: string | undefined;\n}> {\n\tconst exactRestoredModel = modelRuntime.getModel(savedProvider, savedModelId);\n\tconst restoredModel = await resolveRestoredModelReference(savedProvider, savedModelId, modelRuntime);\n\n\tif (restoredModel) {\n\t\tif (shouldPrintMessages) {\n\t\t\tconsole.log(chalk.dim(`Restored model: ${savedProvider}/${savedModelId}`));\n\t\t}\n\t\treturn { model: restoredModel, fallbackMessage: undefined };\n\t}\n\n\tconst reason = !exactRestoredModel ? \"model no longer exists\" : \"no auth configured\";\n\n\tif (shouldPrintMessages) {\n\t\tconsole.error(chalk.yellow(`Warning: Could not restore model ${savedProvider}/${savedModelId} (${reason}).`));\n\t}\n\n\tif (currentModel) {\n\t\tif (shouldPrintMessages) {\n\t\t\tconsole.log(chalk.dim(`Falling back to: ${currentModel.provider}/${currentModel.id}`));\n\t\t}\n\t\treturn {\n\t\t\tmodel: currentModel,\n\t\t\tfallbackMessage: `Could not restore model ${savedProvider}/${savedModelId} (${reason}). Using ${currentModel.provider}/${currentModel.id}.`,\n\t\t};\n\t}\n\n\tconst availableModels = await [...modelRuntime.getAvailableSnapshot()];\n\tconst fallbackModel = findPreferredAvailableModel(availableModels);\n\tif (fallbackModel) {\n\t\tif (shouldPrintMessages) {\n\t\t\tconsole.log(chalk.dim(`Falling back to: ${fallbackModel.provider}/${fallbackModel.id}`));\n\t\t}\n\n\t\treturn {\n\t\t\tmodel: fallbackModel,\n\t\t\tfallbackMessage: `Could not restore model ${savedProvider}/${savedModelId} (${reason}). Using ${fallbackModel.provider}/${fallbackModel.id}.`,\n\t\t};\n\t}\n\n\treturn { model: undefined, fallbackMessage: undefined };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"model-resolver-initial.js","sourceRoot":"","sources":["../../src/core/model-resolver-initial.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAGrD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,2BAA2B,EAAE,MAAM,8BAA8B,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAIlE,MAAM,4CAA4C,GACjD,4GAA4G,CAAC;AAE9G;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CACvC,QAAgB,EAChB,OAAe,EACf,YAAkE;IAElE,QAAQ,GAAG,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IACzC,IAAI,QAAQ,KAAK,gBAAgB,IAAI,YAAY,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;QAAE,OAAO,SAAS,CAAC;IAChG,IAAI,CAAC,YAAY,CAAC,iBAAiB,CAAC,QAAQ,CAAC;QAAE,OAAO,SAAS,CAAC;IAChE,OAAO,2DAA2D,QAAQ,iCAAiC,CAAC;AAC7G,CAAC;AAED,KAAK,UAAU,oCAAoC,CAClD,QAAgB,EAChB,OAAe,EACf,YA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CAAC,CAAC;IACvE,MAAM,aAAa,GAAG,2BAA2B,CAAC,eAAe,CAAC,CAAC;IACnE,IAAI,aAAa,EAAE,CAAC;QACnB,IAAI,mBAAmB,EAAE,CAAC;YACzB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,oBAAoB,aAAa,CAAC,QAAQ,IAAI,aAAa,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;QAC1F,CAAC;QAED,OAAO;YACN,KAAK,EAAE,aAAa;YACpB,eAAe,EAAE,2BAA2B,aAAa,IAAI,YAAY,KAAK,MAAM,YAAY,aAAa,CAAC,QAAQ,IAAI,aAAa,CAAC,EAAE,GAAG;SAC7I,CAAC;IACH,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,SAAS,EAAE,CAAC;AACzD,CAAC","sourcesContent":["import { normalizeProviderId } from \"@bastani/pi-ai\";\nimport type { Api, Model } from \"@bastani/pi-ai/compat\";\nimport type { ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport chalk from \"chalk\";\nimport { APP_NAME } from \"../config.js\";\nimport { normalizeProviderKeys } from \"./azure-provider-compat.js\";\nimport { DEFAULT_THINKING_LEVEL } from \"./defaults.ts\";\nimport { formatModelLabel } from \"./model-label.ts\";\nimport { resolveCliModel } from \"./model-resolver-cli.ts\";\nimport { findPreferredAvailableModel } from \"./model-resolver-defaults.ts\";\nimport { buildFallbackModel } from \"./model-resolver-patterns.ts\";\nimport type { InitialModelResult, ScopedModel } from \"./model-resolver-types.ts\";\nimport type { ModelRuntime } from \"./model-runtime.js\";\n\nconst CONFIGURED_DEFAULT_MODEL_UNAVAILABLE_MESSAGE =\n\t\"Configured default model is unavailable or unsupported. Update defaultProvider/defaultModel or use /model.\";\n\n/**\n * Explain a saved GitHub Copilot model an authenticated catalog lacks. Copilot models beyond the\n * built-in catalog come from the account's model list, which is cached only after a catalog refresh.\n */\nexport function uncachedCopilotModelHint(\n\tprovider: string,\n\tmodelId: string,\n\tmodelRuntime: Pick<ModelRuntime, \"getModel\" | \"hasConfiguredAuth\">,\n): string | undefined {\n\tprovider = normalizeProviderId(provider);\n\tif (provider !== \"github-copilot\" || modelRuntime.getModel(provider, modelId)) return undefined;\n\tif (!modelRuntime.hasConfiguredAuth(provider)) return undefined;\n\treturn `it is not in the cached GitHub Copilot model list; run \"${APP_NAME} update --models\" to refresh it`;\n}\n\nasync function buildConfiguredProviderFallbackModel(\n\tprovider: string,\n\tmodelId: string,\n\tmodelRuntime: ModelRuntime,\n): Promise<Model<Api> | undefined> {\n\treturn buildFallbackModel(provider, modelId, await [...modelRuntime.getAvailableSnapshot()]);\n}\n\n/**\n * Resolve a model reference persisted in a session. Exact unauthenticated\n * models are authoritative failures; only an absent id may be reconstructed\n * from an authenticated model for the same dynamic/custom provider.\n */\nexport async function resolveRestoredModelReference(\n\tprovider: string,\n\tmodelId: string,\n\tmodelRuntime: ModelRuntime,\n): Promise<Model<Api> | undefined> {\n\tprovider = normalizeProviderId(provider);\n\tconst found = modelRuntime.getModel(provider, modelId);\n\tif (found) return modelRuntime.hasConfiguredAuth(found.provider) ? found : undefined;\n\tif (!modelRuntime.canRestoreUnknownModel(provider, modelId)) return undefined;\n\treturn buildConfiguredProviderFallbackModel(provider, modelId, modelRuntime);\n}\n\n/**\n * Find the initial model to use based on priority:\n * 1. CLI args (provider + model)\n * 2. First model from scoped models (if not continuing/resuming)\n * 3. Restored from session (if continuing/resuming)\n * 4. Saved default from settings\n * 5. First available model with valid API key\n */\nexport async function findInitialModel(options: {\n\tcliProvider?: string;\n\tcliModel?: string;\n\tscopedModels: ScopedModel[];\n\tisContinuing: boolean;\n\tdefaultProvider?: string;\n\tdefaultModelId?: string;\n\tdefaultThinkingLevel?: ThinkingLevel;\n\tmodelThinkingLevels?: Record<string, ThinkingLevel>;\n\tmodelRuntime: ModelRuntime;\n}): Promise<InitialModelResult> {\n\tconst {\n\t\tcliProvider,\n\t\tcliModel,\n\t\tscopedModels,\n\t\tisContinuing,\n\t\tdefaultProvider: configuredDefaultProvider,\n\t\tdefaultModelId,\n\t\tdefaultThinkingLevel,\n\t\tmodelThinkingLevels: configuredThinkingLevels,\n\t\tmodelRuntime,\n\t} = options;\n\tconst defaultProvider = configuredDefaultProvider ? normalizeProviderId(configuredDefaultProvider) : undefined;\n\tconst modelThinkingLevels = configuredThinkingLevels ? normalizeProviderKeys(configuredThinkingLevels) : undefined;\n\n\tlet model: Model<Api> | undefined;\n\tlet thinkingLevel: ThinkingLevel = DEFAULT_THINKING_LEVEL;\n\n\tif (cliProvider && cliModel) {\n\t\tconst resolved = resolveCliModel({\n\t\t\tcliProvider,\n\t\t\tcliModel,\n\t\t\tmodelRuntime,\n\t\t});\n\t\tif (resolved.error) {\n\t\t\tconsole.error(chalk.red(resolved.error));\n\t\t\tprocess.exit(1);\n\t\t}\n\t\tif (resolved.model) {\n\t\t\treturn {\n\t\t\t\tmodel: resolved.model,\n\t\t\t\tthinkingLevel: DEFAULT_THINKING_LEVEL,\n\t\t\t\tfallbackMessage: undefined,\n\t\t\t};\n\t\t}\n\t}\n\n\tif (scopedModels.length > 0 && !isContinuing) {\n\t\tconst scopedModel = scopedModels[0];\n\t\tconst perModel = modelThinkingLevels?.[`${scopedModel.model.provider}/${scopedModel.model.id}`];\n\t\treturn {\n\t\t\tmodel: scopedModel.model,\n\t\t\tthinkingLevel: scopedModel.thinkingLevel ?? perModel ?? defaultThinkingLevel ?? DEFAULT_THINKING_LEVEL,\n\t\t\tfallbackMessage: undefined,\n\t\t};\n\t}\n\n\tif (defaultProvider && defaultModelId) {\n\t\tconst found = modelRuntime.getModel(defaultProvider, defaultModelId);\n\t\tif (found && modelRuntime.hasConfiguredAuth(found.provider)) {\n\t\t\tmodel = found;\n\t\t\tconst perModel = modelThinkingLevels?.[`${defaultProvider}/${defaultModelId}`];\n\t\t\tif (perModel) thinkingLevel = perModel;\n\t\t\telse if (defaultThinkingLevel) thinkingLevel = defaultThinkingLevel;\n\t\t\treturn { model, thinkingLevel, fallbackMessage: undefined };\n\t\t}\n\t\tif (!modelRuntime.getProvider(defaultProvider)) {\n\t\t\treturn {\n\t\t\t\tmodel: undefined,\n\t\t\t\tthinkingLevel: DEFAULT_THINKING_LEVEL,\n\t\t\t\tfallbackMessage: CONFIGURED_DEFAULT_MODEL_UNAVAILABLE_MESSAGE,\n\t\t\t\tfallbackReason: \"configured-provider-unsupported\",\n\t\t\t};\n\t\t}\n\t\tconst uncachedHint = uncachedCopilotModelHint(defaultProvider, defaultModelId, modelRuntime);\n\t\tif (uncachedHint) {\n\t\t\treturn {\n\t\t\t\tmodel: undefined,\n\t\t\t\tthinkingLevel: DEFAULT_THINKING_LEVEL,\n\t\t\t\tfallbackMessage: `Configured default model ${formatModelLabel({ provider: defaultProvider, id: defaultModelId })} is unavailable: ${uncachedHint}, or choose another model with /model.`,\n\t\t\t\tfallbackReason: \"configured-provider-unsupported\",\n\t\t\t};\n\t\t}\n\t}\n\n\tconst availableModels = await [...modelRuntime.getAvailableSnapshot()];\n\tif (availableModels.length > 0) {\n\t\treturn {\n\t\t\tmodel: findPreferredAvailableModel(availableModels),\n\t\t\tthinkingLevel: DEFAULT_THINKING_LEVEL,\n\t\t\tfallbackMessage: undefined,\n\t\t};\n\t}\n\n\treturn {\n\t\tmodel: undefined,\n\t\tthinkingLevel: DEFAULT_THINKING_LEVEL,\n\t\tfallbackMessage: undefined,\n\t};\n}\n\n/**\n * Restore model from session, with fallback to available models\n */\nexport async function restoreModelFromSession(\n\tsavedProvider: string,\n\tsavedModelId: string,\n\tcurrentModel: Model<Api> | undefined,\n\tshouldPrintMessages: boolean,\n\tmodelRuntime: ModelRuntime,\n): Promise<{\n\tmodel: Model<Api> | undefined;\n\tfallbackMessage: string | undefined;\n}> {\n\tconst exactRestoredModel = modelRuntime.getModel(savedProvider, savedModelId);\n\tconst restoredModel = await resolveRestoredModelReference(savedProvider, savedModelId, modelRuntime);\n\n\tif (restoredModel) {\n\t\tif (shouldPrintMessages) {\n\t\t\tconsole.log(chalk.dim(`Restored model: ${savedProvider}/${savedModelId}`));\n\t\t}\n\t\treturn { model: restoredModel, fallbackMessage: undefined };\n\t}\n\n\tconst reason = exactRestoredModel\n\t\t? \"no auth configured\"\n\t\t: (uncachedCopilotModelHint(savedProvider, savedModelId, modelRuntime) ?? \"model no longer exists\");\n\n\tif (shouldPrintMessages) {\n\t\tconsole.error(chalk.yellow(`Warning: Could not restore model ${savedProvider}/${savedModelId} (${reason}).`));\n\t}\n\n\tif (currentModel) {\n\t\tif (shouldPrintMessages) {\n\t\t\tconsole.log(chalk.dim(`Falling back to: ${currentModel.provider}/${currentModel.id}`));\n\t\t}\n\t\treturn {\n\t\t\tmodel: currentModel,\n\t\t\tfallbackMessage: `Could not restore model ${savedProvider}/${savedModelId} (${reason}). Using ${currentModel.provider}/${currentModel.id}.`,\n\t\t};\n\t}\n\n\tconst availableModels = await [...modelRuntime.getAvailableSnapshot()];\n\tconst fallbackModel = findPreferredAvailableModel(availableModels);\n\tif (fallbackModel) {\n\t\tif (shouldPrintMessages) {\n\t\t\tconsole.log(chalk.dim(`Falling back to: ${fallbackModel.provider}/${fallbackModel.id}`));\n\t\t}\n\n\t\treturn {\n\t\t\tmodel: fallbackModel,\n\t\t\tfallbackMessage: `Could not restore model ${savedProvider}/${savedModelId} (${reason}). Using ${fallbackModel.provider}/${fallbackModel.id}.`,\n\t\t};\n\t}\n\n\treturn { model: undefined, fallbackMessage: undefined };\n}\n"]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export { resolveCliModel } from "./model-resolver-cli.ts";
|
|
5
5
|
export { defaultModelPerProvider } from "./model-resolver-defaults.ts";
|
|
6
|
-
export { findInitialModel, resolveRestoredModelReference, restoreModelFromSession } from "./model-resolver-initial.ts";
|
|
6
|
+
export { findInitialModel, resolveRestoredModelReference, restoreModelFromSession, uncachedCopilotModelHint, } from "./model-resolver-initial.ts";
|
|
7
7
|
export type { ModelReferenceRequest, ModelReferenceResult, ModelReferenceTarget, } from "./model-resolver-patterns.ts";
|
|
8
8
|
export { findExactModelReferenceMatch, resolveModelReference } from "./model-resolver-patterns.ts";
|
|
9
9
|
export type { ModelScopeDiagnostic, ResolveModelScopeResult } from "./model-resolver-scope.ts";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-resolver.d.ts","sourceRoot":"","sources":["../../src/core/model-resolver.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,
|
|
1
|
+
{"version":3,"file":"model-resolver.d.ts","sourceRoot":"","sources":["../../src/core/model-resolver.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EACN,gBAAgB,EAChB,6BAA6B,EAC7B,uBAAuB,EACvB,wBAAwB,GACxB,MAAM,6BAA6B,CAAC;AACrC,YAAY,EACX,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,GACpB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,4BAA4B,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACnG,YAAY,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAC/F,OAAO,EACN,iBAAiB,EACjB,2BAA2B,EAC3B,gCAAgC,GAChC,MAAM,2BAA2B,CAAC;AACnC,YAAY,EACX,kBAAkB,EAClB,qBAAqB,EACrB,WAAW,GACX,MAAM,2BAA2B,CAAC"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export { resolveCliModel } from "./model-resolver-cli.js";
|
|
5
5
|
export { defaultModelPerProvider } from "./model-resolver-defaults.js";
|
|
6
|
-
export { findInitialModel, resolveRestoredModelReference, restoreModelFromSession } from "./model-resolver-initial.js";
|
|
6
|
+
export { findInitialModel, resolveRestoredModelReference, restoreModelFromSession, uncachedCopilotModelHint, } from "./model-resolver-initial.js";
|
|
7
7
|
export { findExactModelReferenceMatch, resolveModelReference } from "./model-resolver-patterns.js";
|
|
8
8
|
export { resolveModelScope, resolveModelScopeFromModels, resolveModelScopeWithDiagnostics, } from "./model-resolver-scope.js";
|
|
9
9
|
//# sourceMappingURL=model-resolver.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-resolver.js","sourceRoot":"","sources":["../../src/core/model-resolver.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,
|
|
1
|
+
{"version":3,"file":"model-resolver.js","sourceRoot":"","sources":["../../src/core/model-resolver.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EACN,gBAAgB,EAChB,6BAA6B,EAC7B,uBAAuB,EACvB,wBAAwB,GACxB,MAAM,6BAA6B,CAAC;AAMrC,OAAO,EAAE,4BAA4B,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAEnG,OAAO,EACN,iBAAiB,EACjB,2BAA2B,EAC3B,gCAAgC,GAChC,MAAM,2BAA2B,CAAC","sourcesContent":["/**\n * Model resolution, scoping, and initial selection\n */\n\nexport { resolveCliModel } from \"./model-resolver-cli.ts\";\nexport { defaultModelPerProvider } from \"./model-resolver-defaults.ts\";\nexport {\n\tfindInitialModel,\n\tresolveRestoredModelReference,\n\trestoreModelFromSession,\n\tuncachedCopilotModelHint,\n} from \"./model-resolver-initial.ts\";\nexport type {\n\tModelReferenceRequest,\n\tModelReferenceResult,\n\tModelReferenceTarget,\n} from \"./model-resolver-patterns.ts\";\nexport { findExactModelReferenceMatch, resolveModelReference } from \"./model-resolver-patterns.ts\";\nexport type { ModelScopeDiagnostic, ResolveModelScopeResult } from \"./model-resolver-scope.ts\";\nexport {\n\tresolveModelScope,\n\tresolveModelScopeFromModels,\n\tresolveModelScopeWithDiagnostics,\n} from \"./model-resolver-scope.ts\";\nexport type {\n\tInitialModelResult,\n\tResolveCliModelResult,\n\tScopedModel,\n} from \"./model-resolver-types.ts\";\n"]}
|
|
@@ -80,13 +80,11 @@ export declare class ModelRuntime implements Models {
|
|
|
80
80
|
/**
|
|
81
81
|
* Whether an authenticated provider may reconstruct an absent saved model ID.
|
|
82
82
|
*
|
|
83
|
-
* Pass `modelId` whenever it is known. GitHub Copilot
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
* provider-scoped answer, so a provider-owned model whose upstream name merely ends in `-fast`
|
|
89
|
-
* (several exist under `vercel-ai-gateway`) still restores.
|
|
83
|
+
* Pass `modelId` whenever it is known. GitHub Copilot fast models come only from the account's
|
|
84
|
+
* model list, which Atomic caches after a catalog refresh, so an absent Copilot `-fast` ID is never
|
|
85
|
+
* reconstructed from another model's metadata: restoring it fails and asks for a refresh instead.
|
|
86
|
+
* Every other provider keeps the provider-scoped answer, so a provider-owned model whose upstream
|
|
87
|
+
* name merely ends in `-fast` (several exist under `vercel-ai-gateway`) still restores.
|
|
90
88
|
*/
|
|
91
89
|
canRestoreUnknownModel(providerId: string, modelId?: string): boolean;
|
|
92
90
|
private resolveModelMetadata;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-runtime.d.ts","sourceRoot":"","sources":["../../src/core/model-runtime.ts"],"names":[],"mappings":"AAIA,OAAO,EACN,KAAK,QAAQ,EACb,KAAK,GAAG,EACR,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,2BAA2B,EAChC,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,UAAU,EACf,KAAK,QAAQ,EACb,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,OAAO,EACZ,KAAK,UAAU,EACf,KAAK,cAAc,EAEnB,KAAK,cAAc,EACnB,KAAK,QAAQ,EACb,KAAK,UAAU,EACf,KAAK,aAAa,EAElB,KAAK,YAAY,EACjB,KAAK,KAAK,EACV,KAAK,MAAM,EACX,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,2BAA2B,EAChC,KAAK,0BAA0B,EAC/B,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EAExB,KAAK,SAAS,EACd,KAAK,YAAY,EAIjB,KAAK,QAAQ,EAEb,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"model-runtime.d.ts","sourceRoot":"","sources":["../../src/core/model-runtime.ts"],"names":[],"mappings":"AAIA,OAAO,EACN,KAAK,QAAQ,EACb,KAAK,GAAG,EACR,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,2BAA2B,EAChC,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,UAAU,EACf,KAAK,QAAQ,EACb,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,OAAO,EACZ,KAAK,UAAU,EACf,KAAK,cAAc,EAEnB,KAAK,cAAc,EACnB,KAAK,QAAQ,EACb,KAAK,UAAU,EACf,KAAK,aAAa,EAElB,KAAK,YAAY,EACjB,KAAK,KAAK,EACV,KAAK,MAAM,EACX,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,2BAA2B,EAChC,KAAK,0BAA0B,EAC/B,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,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