@bastani/atomic 0.9.24 → 0.9.25-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 +33 -0
- package/dist/builtin/intercom/index.bundle.mjs +5 -0
- package/dist/builtin/intercom/package.json +2 -2
- package/dist/builtin/mcp/CHANGELOG.md +11 -0
- package/dist/builtin/mcp/index.bundle.mjs +219 -71
- package/dist/builtin/mcp/package.json +6 -2
- package/dist/builtin/subagents/package.json +3 -3
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +1 -0
- package/dist/builtin/web-access/index.bundle.mjs +7 -6
- package/dist/builtin/web-access/package.json +2 -2
- package/dist/builtin/workflows/CHANGELOG.md +6 -0
- package/dist/builtin/workflows/package.json +2 -2
- package/dist/builtin/workflows/skills/prompt-engineer/SKILL.md +1 -0
- package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_6_1_sol.md +66 -0
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +1 -0
- package/dist/cli/startup-ui.d.ts +3 -4
- package/dist/cli/startup-ui.d.ts.map +1 -1
- package/dist/cli/startup-ui.js +3 -4
- package/dist/cli/startup-ui.js.map +1 -1
- package/dist/config.d.ts +3 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +17 -0
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session-events.d.ts.map +1 -1
- package/dist/core/agent-session-events.js +5 -0
- package/dist/core/agent-session-events.js.map +1 -1
- package/dist/core/agent-session-export.d.ts.map +1 -1
- package/dist/core/agent-session-export.js +3 -0
- package/dist/core/agent-session-export.js.map +1 -1
- package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
- package/dist/core/agent-session-extension-bindings.js +4 -0
- package/dist/core/agent-session-extension-bindings.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +2 -1
- 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-nested-tools.d.ts +10 -0
- package/dist/core/agent-session-nested-tools.d.ts.map +1 -0
- package/dist/core/agent-session-nested-tools.js +76 -0
- package/dist/core/agent-session-nested-tools.js.map +1 -0
- package/dist/core/agent-session-runtime-auth.js +3 -1
- package/dist/core/agent-session-runtime-auth.js.map +1 -1
- package/dist/core/agent-session-state.d.ts +2 -0
- package/dist/core/agent-session-state.d.ts.map +1 -1
- package/dist/core/agent-session-state.js +11 -11
- package/dist/core/agent-session-state.js.map +1 -1
- package/dist/core/agent-session-tool-hooks.d.ts.map +1 -1
- package/dist/core/agent-session-tool-hooks.js +18 -3
- package/dist/core/agent-session-tool-hooks.js.map +1 -1
- package/dist/core/agent-session-tool-registry.d.ts.map +1 -1
- package/dist/core/agent-session-tool-registry.js +15 -3
- package/dist/core/agent-session-tool-registry.js.map +1 -1
- package/dist/core/agent-session-types.d.ts +6 -2
- package/dist/core/agent-session-types.d.ts.map +1 -1
- package/dist/core/agent-session-types.js.map +1 -1
- package/dist/core/compaction/utils.d.ts +1 -1
- package/dist/core/compaction/utils.d.ts.map +1 -1
- package/dist/core/compaction/utils.js +18 -18
- package/dist/core/compaction/utils.js.map +1 -1
- package/dist/core/execution-model-router.d.ts.map +1 -1
- package/dist/core/execution-model-router.js +24 -8
- package/dist/core/execution-model-router.js.map +1 -1
- package/dist/core/export-html/template.js +12 -0
- package/dist/core/extensions/agent-events.d.ts +3 -0
- package/dist/core/extensions/agent-events.d.ts.map +1 -1
- package/dist/core/extensions/agent-events.js.map +1 -1
- package/dist/core/extensions/api-types.d.ts +2 -0
- package/dist/core/extensions/api-types.d.ts.map +1 -1
- package/dist/core/extensions/api-types.js.map +1 -1
- package/dist/core/extensions/context-types.d.ts +9 -0
- package/dist/core/extensions/context-types.d.ts.map +1 -1
- package/dist/core/extensions/context-types.js.map +1 -1
- package/dist/core/extensions/event-results.d.ts +3 -0
- package/dist/core/extensions/event-results.d.ts.map +1 -1
- package/dist/core/extensions/event-results.js.map +1 -1
- package/dist/core/extensions/index.d.ts +2 -0
- 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 +4 -0
- package/dist/core/extensions/loader-api.js.map +1 -1
- package/dist/core/extensions/loader-core.d.ts.map +1 -1
- package/dist/core/extensions/loader-core.js +3 -5
- package/dist/core/extensions/loader-core.js.map +1 -1
- package/dist/core/extensions/loader-host-modules.d.ts.map +1 -1
- package/dist/core/extensions/loader-host-modules.js +7 -1
- package/dist/core/extensions/loader-host-modules.js.map +1 -1
- package/dist/core/extensions/loader-runtime.d.ts.map +1 -1
- package/dist/core/extensions/loader-runtime.js +3 -0
- package/dist/core/extensions/loader-runtime.js.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.js +4 -0
- package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
- package/dist/core/extensions/provider-types.d.ts +2 -0
- package/dist/core/extensions/provider-types.d.ts.map +1 -1
- package/dist/core/extensions/provider-types.js.map +1 -1
- package/dist/core/extensions/runner-events.d.ts.map +1 -1
- package/dist/core/extensions/runner-events.js +16 -1
- package/dist/core/extensions/runner-events.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +5 -0
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +34 -0
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/runtime-types.d.ts +5 -0
- package/dist/core/extensions/runtime-types.d.ts.map +1 -1
- package/dist/core/extensions/runtime-types.js.map +1 -1
- package/dist/core/extensions/tool-events.d.ts +4 -0
- package/dist/core/extensions/tool-events.d.ts.map +1 -1
- package/dist/core/extensions/tool-events.js.map +1 -1
- package/dist/core/extensions/tool-types.d.ts +34 -3
- package/dist/core/extensions/tool-types.d.ts.map +1 -1
- package/dist/core/extensions/tool-types.js.map +1 -1
- package/dist/core/extensions/wrapper.d.ts.map +1 -1
- package/dist/core/extensions/wrapper.js +14 -2
- package/dist/core/extensions/wrapper.js.map +1 -1
- package/dist/core/fast-model-routing-transport.d.ts.map +1 -1
- package/dist/core/fast-model-routing-transport.js +2 -1
- package/dist/core/fast-model-routing-transport.js.map +1 -1
- package/dist/core/fast-model-routing.d.ts +1 -2
- package/dist/core/fast-model-routing.d.ts.map +1 -1
- package/dist/core/fast-model-routing.js +13 -11
- package/dist/core/fast-model-routing.js.map +1 -1
- package/dist/core/fast-model-variants.d.ts +4 -1
- package/dist/core/fast-model-variants.d.ts.map +1 -1
- package/dist/core/fast-model-variants.js +42 -17
- package/dist/core/fast-model-variants.js.map +1 -1
- package/dist/core/model-registry.d.ts +4 -1
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +9 -0
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver-defaults.js +1 -1
- package/dist/core/model-resolver-defaults.js.map +1 -1
- package/dist/core/model-routing-candidates.d.ts +4 -0
- package/dist/core/model-routing-candidates.d.ts.map +1 -1
- package/dist/core/model-routing-candidates.js +8 -3
- package/dist/core/model-routing-candidates.js.map +1 -1
- package/dist/core/model-routing-evals.d.ts.map +1 -1
- package/dist/core/model-routing-evals.js +4 -5
- package/dist/core/model-routing-evals.js.map +1 -1
- package/dist/core/model-runtime.d.ts +3 -2
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +19 -25
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/nested-tool-calls.d.ts +64 -0
- package/dist/core/nested-tool-calls.d.ts.map +1 -0
- package/dist/core/nested-tool-calls.js +132 -0
- package/dist/core/nested-tool-calls.js.map +1 -0
- package/dist/core/package-manager-resolver.d.ts.map +1 -1
- package/dist/core/package-manager-resolver.js +21 -3
- package/dist/core/package-manager-resolver.js.map +1 -1
- package/dist/core/package-manager-resource-accumulator.d.ts.map +1 -1
- package/dist/core/package-manager-resource-accumulator.js +2 -0
- package/dist/core/package-manager-resource-accumulator.js.map +1 -1
- package/dist/core/package-manager-types.d.ts +2 -0
- package/dist/core/package-manager-types.d.ts.map +1 -1
- package/dist/core/package-manager-types.js.map +1 -1
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +1 -0
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/resource-loader-core.d.ts.map +1 -1
- package/dist/core/resource-loader-core.js +12 -6
- package/dist/core/resource-loader-core.js.map +1 -1
- package/dist/core/resource-loader-extensions.d.ts +1 -0
- package/dist/core/resource-loader-extensions.d.ts.map +1 -1
- package/dist/core/resource-loader-extensions.js +64 -4
- package/dist/core/resource-loader-extensions.js.map +1 -1
- package/dist/core/resource-loader-paths.d.ts.map +1 -1
- package/dist/core/resource-loader-paths.js +2 -1
- package/dist/core/resource-loader-paths.js.map +1 -1
- package/dist/core/resource-loader-reload.d.ts.map +1 -1
- package/dist/core/resource-loader-reload.js +5 -4
- package/dist/core/resource-loader-reload.js.map +1 -1
- package/dist/core/resource-loader-source-info.d.ts.map +1 -1
- package/dist/core/resource-loader-source-info.js +7 -5
- package/dist/core/resource-loader-source-info.js.map +1 -1
- package/dist/core/sdk-types.d.ts +1 -1
- package/dist/core/sdk-types.js.map +1 -1
- package/dist/core/session-manager-core.d.ts +2 -0
- package/dist/core/session-manager-core.d.ts.map +1 -1
- package/dist/core/session-manager-core.js +5 -1
- package/dist/core/session-manager-core.js.map +1 -1
- package/dist/core/session-manager-entries.d.ts +1 -1
- package/dist/core/session-manager-entries.d.ts.map +1 -1
- package/dist/core/session-manager-entries.js.map +1 -1
- package/dist/core/settings-manager-basic-accessors.d.ts +4 -0
- package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -1
- package/dist/core/settings-manager-basic-accessors.js +27 -1
- package/dist/core/settings-manager-basic-accessors.js.map +1 -1
- package/dist/core/settings-manager-core.d.ts +2 -0
- package/dist/core/settings-manager-core.d.ts.map +1 -1
- package/dist/core/settings-manager-core.js +4 -0
- package/dist/core/settings-manager-core.js.map +1 -1
- package/dist/core/settings-manager-ui-accessors.d.ts +3 -1
- package/dist/core/settings-manager-ui-accessors.d.ts.map +1 -1
- package/dist/core/settings-manager-ui-accessors.js +13 -0
- package/dist/core/settings-manager-ui-accessors.js.map +1 -1
- package/dist/core/settings-manager.d.ts +1 -1
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/settings-merge.d.ts +1 -0
- package/dist/core/settings-merge.d.ts.map +1 -1
- package/dist/core/settings-merge.js +30 -1
- package/dist/core/settings-merge.js.map +1 -1
- package/dist/core/settings-types.d.ts +8 -1
- package/dist/core/settings-types.d.ts.map +1 -1
- package/dist/core/settings-types.js.map +1 -1
- package/dist/core/source-info.d.ts +3 -0
- package/dist/core/source-info.d.ts.map +1 -1
- package/dist/core/source-info.js +11 -0
- package/dist/core/source-info.js.map +1 -1
- package/dist/core/tool-loadout.d.ts +6 -0
- package/dist/core/tool-loadout.d.ts.map +1 -0
- package/dist/core/tool-loadout.js +63 -0
- package/dist/core/tool-loadout.js.map +1 -0
- package/dist/core/tools/ask-user-question/ask-user-question.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/ask-user-question.js +1 -0
- package/dist/core/tools/ask-user-question/ask-user-question.js.map +1 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +31 -11
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/output-accumulator.d.ts +4 -0
- package/dist/core/tools/output-accumulator.d.ts.map +1 -1
- package/dist/core/tools/output-accumulator.js +32 -0
- package/dist/core/tools/output-accumulator.js.map +1 -1
- package/dist/core/tools/powershell.d.ts +27 -21
- package/dist/core/tools/powershell.d.ts.map +1 -1
- package/dist/core/tools/render-utils.d.ts +4 -0
- package/dist/core/tools/render-utils.d.ts.map +1 -1
- package/dist/core/tools/render-utils.js +19 -0
- package/dist/core/tools/render-utils.js.map +1 -1
- package/dist/core/tools/tool-concurrency.d.ts +1 -1
- package/dist/core/tools/tool-concurrency.d.ts.map +1 -1
- package/dist/core/tools/tool-concurrency.js +28 -3
- package/dist/core/tools/tool-concurrency.js.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.d.ts +1 -1
- package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.js +4 -1
- package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
- package/dist/core/usage-totals.d.ts +2 -0
- package/dist/core/usage-totals.d.ts.map +1 -1
- package/dist/core/usage-totals.js +23 -0
- package/dist/core/usage-totals.js.map +1 -1
- package/dist/extensions/codemode/execute.d.ts +10 -0
- package/dist/extensions/codemode/execute.d.ts.map +1 -0
- package/dist/extensions/codemode/execute.js +313 -0
- package/dist/extensions/codemode/execute.js.map +1 -0
- package/dist/extensions/codemode/index.d.ts +11 -0
- package/dist/extensions/codemode/index.d.ts.map +1 -0
- package/dist/extensions/codemode/index.js +14 -0
- package/dist/extensions/codemode/index.js.map +1 -0
- package/dist/extensions/codemode/renderer.d.ts +4 -0
- package/dist/extensions/codemode/renderer.d.ts.map +1 -0
- package/dist/extensions/codemode/renderer.js +78 -0
- package/dist/extensions/codemode/renderer.js.map +1 -0
- package/dist/extensions/codemode/tool.d.ts +51 -0
- package/dist/extensions/codemode/tool.d.ts.map +1 -0
- package/dist/extensions/codemode/tool.js +134 -0
- package/dist/extensions/codemode/tool.js.map +1 -0
- package/dist/extensions/codemode/worker.d.ts +2 -0
- package/dist/extensions/codemode/worker.d.ts.map +1 -0
- package/dist/extensions/codemode/worker.js +2 -0
- package/dist/extensions/codemode/worker.js.map +1 -0
- package/dist/extensions/index.d.ts.map +1 -1
- package/dist/extensions/index.js +5 -1
- package/dist/extensions/index.js.map +1 -1
- package/dist/extensions/llama/provider.d.ts.map +1 -1
- package/dist/extensions/llama/provider.js +31 -10
- package/dist/extensions/llama/provider.js.map +1 -1
- package/dist/extensions/tool-search/index.d.ts +5 -0
- package/dist/extensions/tool-search/index.d.ts.map +1 -0
- package/dist/extensions/tool-search/index.js +6 -0
- package/dist/extensions/tool-search/index.js.map +1 -0
- package/dist/extensions/tool-search/tool.d.ts +41 -0
- package/dist/extensions/tool-search/tool.d.ts.map +1 -0
- package/dist/extensions/tool-search/tool.js +161 -0
- package/dist/extensions/tool-search/tool.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/modes/interactive/components/chat-message-renderer.d.ts +1 -0
- package/dist/modes/interactive/components/chat-message-renderer.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-message-renderer.js +2 -0
- package/dist/modes/interactive/components/chat-message-renderer.js.map +1 -1
- package/dist/modes/interactive/components/config-selector-list.d.ts.map +1 -1
- package/dist/modes/interactive/components/config-selector-list.js +9 -1
- package/dist/modes/interactive/components/config-selector-list.js.map +1 -1
- package/dist/modes/interactive/components/config-selector-project-scope.d.ts.map +1 -1
- package/dist/modes/interactive/components/config-selector-project-scope.js +4 -1
- package/dist/modes/interactive/components/config-selector-project-scope.js.map +1 -1
- package/dist/modes/interactive/components/first-time-setup.d.ts +2 -2
- package/dist/modes/interactive/components/first-time-setup.d.ts.map +1 -1
- package/dist/modes/interactive/components/first-time-setup.js +1 -0
- package/dist/modes/interactive/components/first-time-setup.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +42 -7
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-handlers.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector-handlers.js +3 -0
- package/dist/modes/interactive/components/settings-selector-handlers.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 +13 -0
- 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 +3 -1
- package/dist/modes/interactive/components/settings-selector-submenus.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-types.d.ts +3 -1
- package/dist/modes/interactive/components/settings-selector-types.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector-types.js.map +1 -1
- package/dist/modes/interactive/components/themed-text.d.ts +8 -0
- package/dist/modes/interactive/components/themed-text.d.ts.map +1 -0
- package/dist/modes/interactive/components/themed-text.js +14 -0
- package/dist/modes/interactive/components/themed-text.js.map +1 -0
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +5 -3
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/interactive-agent-events.js +2 -0
- package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.d.ts +2 -1
- package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.js +5 -0
- package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
- package/dist/modes/interactive/interactive-resource-rendering.js +7 -10
- package/dist/modes/interactive/interactive-resource-rendering.js.map +1 -1
- package/dist/modes/interactive/interactive-selectors.js +5 -0
- package/dist/modes/interactive/interactive-selectors.js.map +1 -1
- package/dist/modes/interactive/interactive-session-runtime.js +1 -0
- package/dist/modes/interactive/interactive-session-runtime.js.map +1 -1
- package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-startup.js +8 -3
- package/dist/modes/interactive/interactive-startup.js.map +1 -1
- package/dist/modes/interactive/interactive-tui.d.ts +2 -1
- package/dist/modes/interactive/interactive-tui.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-tui.js +1 -0
- package/dist/modes/interactive/interactive-tui.js.map +1 -1
- package/dist/modes/interactive/theme/color-utils.d.ts.map +1 -1
- package/dist/modes/interactive/theme/color-utils.js +3 -0
- package/dist/modes/interactive/theme/color-utils.js.map +1 -1
- package/dist/modes/interactive/theme/export-colors.d.ts.map +1 -1
- package/dist/modes/interactive/theme/export-colors.js +4 -1
- package/dist/modes/interactive/theme/export-colors.js.map +1 -1
- package/dist/modes/interactive/theme/system-theme.d.ts +23 -0
- package/dist/modes/interactive/theme/system-theme.d.ts.map +1 -0
- package/dist/modes/interactive/theme/system-theme.js +462 -0
- package/dist/modes/interactive/theme/system-theme.js.map +1 -0
- package/dist/modes/interactive/theme/terminal-colors.d.ts +10 -0
- package/dist/modes/interactive/theme/terminal-colors.d.ts.map +1 -0
- package/dist/modes/interactive/theme/terminal-colors.js +36 -0
- package/dist/modes/interactive/theme/terminal-colors.js.map +1 -0
- package/dist/modes/interactive/theme/terminal-detection.d.ts +4 -6
- package/dist/modes/interactive/theme/terminal-detection.d.ts.map +1 -1
- package/dist/modes/interactive/theme/terminal-detection.js +12 -46
- package/dist/modes/interactive/theme/terminal-detection.js.map +1 -1
- package/dist/modes/interactive/theme/theme-class.d.ts +1 -0
- package/dist/modes/interactive/theme/theme-class.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme-class.js +2 -2
- package/dist/modes/interactive/theme/theme-class.js.map +1 -1
- package/dist/modes/interactive/theme/theme-controller.d.ts +16 -8
- package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme-controller.js +106 -64
- package/dist/modes/interactive/theme/theme-controller.js.map +1 -1
- package/dist/modes/interactive/theme/theme-loading.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme-loading.js +23 -2
- package/dist/modes/interactive/theme/theme-loading.js.map +1 -1
- package/dist/modes/interactive/theme/theme-schema.js +1 -1
- package/dist/modes/interactive/theme/theme-schema.js.map +1 -1
- package/dist/modes/interactive/theme/theme-schema.json +2 -2
- package/dist/modes/interactive/theme/theme.d.ts +2 -0
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +2 -0
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/interactive-engine/engine-session-stats.d.ts +26 -0
- package/dist/modes/interactive-engine/engine-session-stats.d.ts.map +1 -0
- package/dist/modes/interactive-engine/engine-session-stats.js +71 -0
- package/dist/modes/interactive-engine/engine-session-stats.js.map +1 -0
- package/dist/modes/interactive-engine/extension-ui-bridge.d.ts +2 -0
- package/dist/modes/interactive-engine/extension-ui-bridge.d.ts.map +1 -1
- package/dist/modes/interactive-engine/extension-ui-bridge.js +4 -0
- package/dist/modes/interactive-engine/extension-ui-bridge.js.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.d.ts +3 -0
- package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.js +27 -5
- package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
- package/dist/modes/rpc/rpc-provider-auth.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-provider-auth.js +3 -1
- package/dist/modes/rpc/rpc-provider-auth.js.map +1 -1
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +8 -2
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/utils/paths.d.ts.map +1 -1
- package/dist/utils/paths.js +2 -1
- package/dist/utils/paths.js.map +1 -1
- package/dist/utils/shell.d.ts +1 -3
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +3 -30
- package/dist/utils/shell.js.map +1 -1
- package/docs/extensions/api-reference.md +5 -1
- package/docs/extensions/authoring.md +31 -1
- package/docs/extensions/events.md +3 -1
- package/docs/extensions.md +14 -0
- package/docs/models/evals.md +45 -2
- package/docs/models/reference.md +33 -2
- package/docs/models.md +1 -0
- package/docs/packages.md +2 -0
- package/docs/providers.md +34 -7
- package/docs/reference/cli.md +4 -0
- package/docs/rpc/protocol.md +10 -0
- package/docs/sdk/reference.md +5 -1
- package/docs/sdk/structured-decisions.md +2 -2
- package/docs/session-format.md +5 -0
- package/docs/settings.md +19 -5
- package/docs/skills.md +1 -1
- package/docs/themes/reference.md +2 -1
- package/docs/themes.md +4 -2
- package/docs/tools.md +39 -0
- package/npm-shrinkwrap.json +115 -113
- package/package.json +12 -9
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
import { getServiceTierCost, } from "@bastani/pi-ai";
|
|
1
2
|
import { applyModelOverride } from "./provider-composer-internal.js";
|
|
2
3
|
/** Canonical suffix every selectable fast model variant carries. */
|
|
3
4
|
export const FAST_MODEL_ID_SUFFIX = "-fast";
|
|
4
5
|
/** Service tier OpenAI-style providers use to route fast traffic. */
|
|
5
6
|
export const FAST_MODEL_SERVICE_TIER = "priority";
|
|
7
|
+
/** Codex's Ultrafast tier, offered only for models that advertise it; access depends on the account. */
|
|
8
|
+
export const ULTRAFAST_MODEL_ID_SUFFIX = "-ultrafast";
|
|
9
|
+
export const ULTRAFAST_MODEL_SERVICE_TIER = "ultrafast";
|
|
6
10
|
/** Inference speed Anthropic's Messages API uses to route fast traffic. */
|
|
7
11
|
export const FAST_MODEL_SPEED = "fast";
|
|
8
12
|
/**
|
|
@@ -92,8 +96,17 @@ export function copilotAdvertisesModelId(credential, modelId) {
|
|
|
92
96
|
return (advertisedModelIds(credential.availableModelIds)?.includes(modelId) === true ||
|
|
93
97
|
advertisedModelIds(credential.fastModelIds)?.includes(modelId) === true);
|
|
94
98
|
}
|
|
99
|
+
/** A model without tier metadata keeps offering Fast; one that lists its tiers must advertise it, as in Codex. */
|
|
100
|
+
function advertisesFastServiceTier(model) {
|
|
101
|
+
return model.serviceTiers === undefined || getServiceTierCost(model, FAST_MODEL_SERVICE_TIER) !== undefined;
|
|
102
|
+
}
|
|
95
103
|
function fastRouteForBaseModel(model, entitledCopilotFastModelIds) {
|
|
96
|
-
if (usesOpenAIFastServiceTier(model)
|
|
104
|
+
if (usesOpenAIFastServiceTier(model)) {
|
|
105
|
+
return advertisesFastServiceTier(model)
|
|
106
|
+
? { baseModelId: model.id, upstreamModelId: model.id, serviceTier: FAST_MODEL_SERVICE_TIER }
|
|
107
|
+
: undefined;
|
|
108
|
+
}
|
|
109
|
+
if (usesXaiFastServiceTier(model)) {
|
|
97
110
|
return { baseModelId: model.id, upstreamModelId: model.id, serviceTier: FAST_MODEL_SERVICE_TIER };
|
|
98
111
|
}
|
|
99
112
|
if (usesAnthropicFastMode(model)) {
|
|
@@ -133,7 +146,9 @@ export function deriveFastModelVariants(providerId, models, options = {}) {
|
|
|
133
146
|
let changed = false;
|
|
134
147
|
for (const model of models) {
|
|
135
148
|
derived.push(model);
|
|
136
|
-
if (model.fastRoute !== undefined ||
|
|
149
|
+
if (model.fastRoute !== undefined ||
|
|
150
|
+
model.id.endsWith(FAST_MODEL_ID_SUFFIX) ||
|
|
151
|
+
model.id.endsWith(ULTRAFAST_MODEL_ID_SUFFIX))
|
|
137
152
|
continue;
|
|
138
153
|
if (options.customModelIds?.has(model.id))
|
|
139
154
|
continue;
|
|
@@ -143,23 +158,33 @@ export function deriveFastModelVariants(providerId, models, options = {}) {
|
|
|
143
158
|
if (options.extensionOwnedApis?.has(model.api) === true)
|
|
144
159
|
continue;
|
|
145
160
|
const fastRoute = fastRouteForBaseModel(model, entitledCopilotFastModelIds);
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
if (
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
`so Atomic did not derive a fast variant of "${providerId}/${model.id}". ` +
|
|
155
|
-
`That model routes exactly as declared. Rename or remove it to get the derived fast variant instead.`,
|
|
161
|
+
const routes = [];
|
|
162
|
+
if (fastRoute)
|
|
163
|
+
routes.push({ suffix: FAST_MODEL_ID_SUFFIX, label: "fast", route: fastRoute });
|
|
164
|
+
if (usesOpenAIFastServiceTier(model) && getServiceTierCost(model, ULTRAFAST_MODEL_SERVICE_TIER)) {
|
|
165
|
+
routes.push({
|
|
166
|
+
suffix: ULTRAFAST_MODEL_ID_SUFFIX,
|
|
167
|
+
label: "ultrafast",
|
|
168
|
+
route: { baseModelId: model.id, upstreamModelId: model.id, serviceTier: ULTRAFAST_MODEL_SERVICE_TIER },
|
|
156
169
|
});
|
|
157
|
-
continue;
|
|
158
170
|
}
|
|
159
|
-
const
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
171
|
+
for (const { suffix, label, route } of routes) {
|
|
172
|
+
const variantId = `${model.id}${suffix}`;
|
|
173
|
+
if (ownedModelIds.has(variantId)) {
|
|
174
|
+
diagnostics.push({
|
|
175
|
+
provider: providerId,
|
|
176
|
+
modelId: variantId,
|
|
177
|
+
message: `Model "${providerId}/${variantId}" is already defined by the provider, models.json, or an extension, ` +
|
|
178
|
+
`so Atomic did not derive a ${label} variant of "${providerId}/${model.id}". ` +
|
|
179
|
+
`That model routes exactly as declared. Rename or remove it to get the derived ${label} variant instead.`,
|
|
180
|
+
});
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
const override = options.modelOverrides?.[variantId];
|
|
184
|
+
const variant = { ...model, id: variantId, name: `${model.name} (${label})`, fastRoute: route };
|
|
185
|
+
derived.push(override ? applyModelOverride(variant, override) : variant);
|
|
186
|
+
changed = true;
|
|
187
|
+
}
|
|
163
188
|
}
|
|
164
189
|
if (!changed && diagnostics.length === 0)
|
|
165
190
|
return { models, diagnostics };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fast-model-variants.js","sourceRoot":"","sources":["../../src/core/fast-model-variants.ts"],"names":[],"mappings":"AAEA,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,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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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 type { Api, Credential, Model, ModelFastRoute, Provider } 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/** 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 OpenAI (`azure-openai-responses`), 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 isNativeFastRouteApi(model.api) && (model.provider === \"openai\" || model.provider === \"openai-codex\");\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\tmodel.provider === \"anthropic\" &&\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\nfunction fastRouteForBaseModel(\n\tmodel: Model<Api>,\n\tentitledCopilotFastModelIds: ReadonlySet<string>,\n): ModelFastRoute | undefined {\n\tif (usesOpenAIFastServiceTier(model) || 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 (model.fastRoute !== undefined || model.id.endsWith(FAST_MODEL_ID_SUFFIX)) continue;\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\tif (!fastRoute) continue;\n\t\tconst variantId = fastModelId(model.id);\n\t\tif (ownedModelIds.has(variantId)) {\n\t\t\tdiagnostics.push({\n\t\t\t\tprovider: providerId,\n\t\t\t\tmodelId: variantId,\n\t\t\t\tmessage:\n\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`so Atomic did not derive a fast variant of \"${providerId}/${model.id}\". ` +\n\t\t\t\t\t`That model routes exactly as declared. Rename or remove it to get the derived fast variant instead.`,\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tconst override = options.modelOverrides?.[variantId];\n\t\tconst variant: Model<Api> = { ...model, id: variantId, name: `${model.name} (fast)`, fastRoute };\n\t\tderived.push(override ? applyModelOverride(variant, override) : variant);\n\t\tchanged = true;\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,2E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AAC,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 OpenAI (`azure-openai-responses`), 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 isNativeFastRouteApi(model.api) && (model.provider === \"openai\" || model.provider === \"openai-codex\");\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\tmodel.provider === \"anthropic\" &&\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,4 +1,4 @@
|
|
|
1
|
-
import type { Api, AssistantMessage, AssistantMessageEventStream, AuthOperationOptions, AuthResult, ClassifierApi, ClassifierContext, ClassifierModel, ClassifierResult, Context, Model, ModelsApiStreamOptions, ModelsClassifierOptions, ModelsRefreshOptions, ModelsRefreshResult, ModelsSimpleStreamOptions, Provider, ProviderHeaders } from "@bastani/pi-ai";
|
|
1
|
+
import type { Api, AssistantMessage, AssistantMessageEventStream, AuthOperationOptions, AuthResult, ClassifierApi, ClassifierContext, ClassifierModel, ClassifierResult, Context, Model, ModelsApiStreamOptions, ModelsClassifierOptions, ModelsRefreshOptions, ModelsRefreshResult, ModelsSimpleStreamOptions, ModelType, ModelTypeMap, Provider, ProviderHeaders } from "@bastani/pi-ai";
|
|
2
2
|
import type { ModelRuntime } from "./model-runtime.js";
|
|
3
3
|
import type { AuthStatus, ProviderConfigInput } from "./provider-composer.ts";
|
|
4
4
|
export type { ProviderConfigInput } from "./provider-composer.ts";
|
|
@@ -30,6 +30,9 @@ export declare class ModelRegistry {
|
|
|
30
30
|
getAll(): Model<Api>[];
|
|
31
31
|
getAvailable(): Model<Api>[];
|
|
32
32
|
find(provider: string, modelId: string): Model<Api> | undefined;
|
|
33
|
+
getModelsOfType<T extends ModelType>(type: T, provider?: string): readonly ModelTypeMap[T][];
|
|
34
|
+
getAvailableOfType<T extends ModelType>(type: T, provider?: string, options?: AuthOperationOptions): Promise<readonly ModelTypeMap[T][]>;
|
|
35
|
+
getModelOfType<T extends ModelType>(type: T, provider: string, id: string): ModelTypeMap[T] | undefined;
|
|
33
36
|
getClassifierModel(provider: string, modelId: string): ClassifierModel<ClassifierApi> | undefined;
|
|
34
37
|
hasConfiguredAuth(model: Model<Api>): boolean;
|
|
35
38
|
/** Boolean-only access to configured credential screening, without resolving request auth. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-registry.d.ts","sourceRoot":"","sources":["../../src/core/model-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,GAAG,EACH,gBAAgB,EAChB,2BAA2B,EAC3B,oBAAoB,EACpB,UAAU,EACV,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,OAAO,EACP,KAAK,EACL,sBAAsB,EACtB,uBAAuB,EACvB,oBAAoB,EACpB,mBAAmB,EACnB,yBAAyB,EACzB,QAAQ,EACR,eAAe,EACf,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAE9E,YAAY,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAClE,MAAM,MAAM,mBAAmB,GAC5B;IACA,EAAE,EAAE,IAAI,CAAC;IACT,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,G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,CAAC;IAU1E,kBAAkB,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAE7C;IAED,2BAA2B,CAAC,YAAY,EAAE,MAAM,GAAG,mBAAmB,GAAG,SAAS,CAEjF;IAED,2BAA2B,CAAC,YAAY,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAEtE;IAED,wBAAwB,IAAI,SAAS,MAAM,EAAE,CAE5C;CACD"}
|
|
@@ -28,6 +28,15 @@ export class ModelRegistry {
|
|
|
28
28
|
find(provider, modelId) {
|
|
29
29
|
return this.runtime.getModel(provider, modelId);
|
|
30
30
|
}
|
|
31
|
+
getModelsOfType(type, provider) {
|
|
32
|
+
return this.runtime.getModelsOfType(type, provider);
|
|
33
|
+
}
|
|
34
|
+
getAvailableOfType(type, provider, options) {
|
|
35
|
+
return this.runtime.getAvailableOfType(type, provider, options);
|
|
36
|
+
}
|
|
37
|
+
getModelOfType(type, provider, id) {
|
|
38
|
+
return this.runtime.getModelOfType(type, provider, id);
|
|
39
|
+
}
|
|
31
40
|
getClassifierModel(provider, modelId) {
|
|
32
41
|
return this.runtime.getModelOfType("classifier", provider, modelId);
|
|
33
42
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-registry.js","sourceRoot":"","sources":["../../src/core/model-registry.ts"],"names":[],"mappings":"AAiCA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D;;;GAGG;AACH,MAAM,OAAO,aAAa;IACR,OAAO,CAAe;IAEvC,YAAY,OAAqB;QAChC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACxB,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,OAAO,CAAC,OAA8B;QAC3C,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC;IAED,QAAQ;QACP,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;IAChC,CAAC;IAED,MAAM;QACL,OAAO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AM;gBAAE,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;YACrF,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;YACtD,OAAO;QACR,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,sBAAsB,CAAC,cAAc,CAAC,CAAC;IACrD,CAAC;IAED,kBAAkB,CAAC,YAAoB;QACtC,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAAC;IAC/C,CAAC;IAED,2BAA2B,CAAC,YAAoB;QAC/C,OAAO,IAAI,CAAC,OAAO,CAAC,2BAA2B,CAAC,YAAY,CAAC,CAAC;IAC/D,CAAC;IAED,2BAA2B,CAAC,YAAoB;QAC/C,OAAO,IAAI,CAAC,OAAO,CAAC,2BAA2B,CAAC,YAAY,CAAC,CAAC;IAC/D,CAAC;IAED,wBAAwB;QACvB,OAAO,IAAI,CAAC,OAAO,CAAC,wBAAwB,EAAE,CAAC;IAChD,CAAC;CACD","sourcesContent":["import type {\n\tApi,\n\tAssistantMessage,\n\tAssistantMessageEventStream,\n\tAuthOperationOptions,\n\tAuthResult,\n\tClassifierApi,\n\tClassifierContext,\n\tClassifierModel,\n\tClassifierResult,\n\tContext,\n\tModel,\n\tModelsApiStreamOptions,\n\tModelsClassifierOptions,\n\tModelsRefreshOptions,\n\tModelsRefreshResult,\n\tModelsSimpleStreamOptions,\n\tProvider,\n\tProviderHeaders,\n} from \"@bastani/pi-ai\";\nimport type { ModelRuntime } from \"./model-runtime.js\";\nimport type { AuthStatus, ProviderConfigInput } from \"./provider-composer.ts\";\n\nexport type { ProviderConfigInput } from \"./provider-composer.ts\";\nexport type ResolvedRequestAuth =\n\t| {\n\t\t\tok: true;\n\t\t\tapiKey?: string;\n\t\t\theaders?: ProviderHeaders;\n\t\t\tbaseUrl?: string;\n\t\t\tenv?: Record<string, string>;\n\t }\n\t| { ok: false; error: string };\nexport { clearApiKeyCache } from \"./provider-composer.ts\";\n\n/**\n * Compatibility facade exposed to extensions.\n * Coding-agent internals use ModelRuntime directly.\n */\nexport class ModelRegistry {\n\tprivate readonly runtime: ModelRuntime;\n\n\tconstructor(runtime: ModelRuntime) {\n\t\tthis.runtime = runtime;\n\t}\n\n\t/**\n\t * Reload models.json asynchronously. Await before making synchronous registry reads.\n\t * Returns pi's refresh result so callers can react to per-provider failures\n\t * (`errors`) and cancellation (`aborted`); pi reports both without rejecting.\n\t */\n\tasync refresh(options?: ModelsRefreshOptions): Promise<ModelsRefreshResult> {\n\t\treturn this.runtime.refresh(options);\n\t}\n\n\tgetError(): string | undefined {\n\t\treturn this.runtime.getError();\n\t}\n\n\tgetAll(): Model<Api>[] {\n\t\treturn [...this.runtime.getModels()];\n\t}\n\n\tgetAvailable(): Model<Api>[] {\n\t\treturn [...this.runtime.getAvailableSnapshot()];\n\t}\n\n\tfind(provider: string, modelId: string): Model<Api> | undefined {\n\t\treturn this.runtime.getModel(provider, modelId);\n\t}\n\n\tgetClassifierModel(provider: string, modelId: string): ClassifierModel<ClassifierApi> | undefined {\n\t\treturn this.runtime.getModelOfType(\"classifier\", provider, modelId);\n\t}\n\n\thasConfiguredAuth(model: Model<Api>): boolean {\n\t\treturn this.runtime.hasConfiguredAuth(model.provider);\n\t}\n\n\t/** Boolean-only access to configured credential screening, without resolving request auth. */\n\tcontainsConfiguredCredential(serialized: string): Promise<boolean> {\n\t\treturn this.runtime.containsConfiguredCredential(serialized);\n\t}\n\n\tasync getApiKeyAndHeaders(model: Model<Api>): Promise<ResolvedRequestAuth> {\n\t\ttry {\n\t\t\tconst resolution = await this.runtime.getAuth(model);\n\t\t\tif (!resolution) {\n\t\t\t\tconst compatibility = this.runtime.getCompatibilityRequestConfig(model);\n\t\t\t\tif (compatibility.authHeader) {\n\t\t\t\t\treturn { ok: false, error: `No API key found for \"${model.provider}\"` };\n\t\t\t\t}\n\t\t\t\treturn { ok: true, headers: compatibility.headers };\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tok: true,\n\t\t\t\tapiKey: resolution.auth.apiKey,\n\t\t\t\theaders: resolution.auth.headers,\n\t\t\t\t...(resolution.auth.baseUrl === undefined ? {} : { baseUrl: resolution.auth.baseUrl }),\n\t\t\t\tenv: resolution.env,\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tconst cause = error instanceof Error ? error.cause : undefined;\n\t\t\tconst message =\n\t\t\t\tcause instanceof Error ? cause.message : error instanceof Error ? error.message : String(error);\n\t\t\treturn {\n\t\t\t\tok: false,\n\t\t\t\terror:\n\t\t\t\t\tmessage === \"authHeader requires a resolved API key\"\n\t\t\t\t\t\t? `No API key found for \"${model.provider}\"`\n\t\t\t\t\t\t: message,\n\t\t\t};\n\t\t}\n\t}\n\n\tgetProviderAuthStatus(provider: string): AuthStatus {\n\t\treturn this.runtime.getProviderAuthStatus(provider);\n\t}\n\n\tgetProvider(provider: string): Provider | undefined {\n\t\treturn this.runtime.getProvider(provider);\n\t}\n\n\t/** Stream through the configured provider with request-time authentication. */\n\tstream<TApi extends Api>(\n\t\tmodel: Model<TApi>,\n\t\tcontext: Context,\n\t\toptions?: ModelsApiStreamOptions<TApi>,\n\t): AssistantMessageEventStream {\n\t\treturn this.runtime.stream(model, context, options);\n\t}\n\n\t/** Stream with provider-neutral options and request-time authentication. */\n\tstreamSimple(model: Model<Api>, context: Context, options?: ModelsSimpleStreamOptions): AssistantMessageEventStream {\n\t\treturn this.runtime.streamSimple(model, context, options);\n\t}\n\n\t/** Complete through the active runtime so provider composition and request auth apply. */\n\tcomplete<TApi extends Api>(\n\t\tmodel: Model<TApi>,\n\t\tcontext: Context,\n\t\toptions?: ModelsApiStreamOptions<TApi>,\n\t): Promise<AssistantMessage> {\n\t\treturn this.runtime.complete(model, context, options);\n\t}\n\n\tclassify(\n\t\tmodel: ClassifierModel<ClassifierApi>,\n\t\tcontext: ClassifierContext,\n\t\toptions?: ModelsClassifierOptions,\n\t): Promise<ClassifierResult> {\n\t\treturn this.runtime.classify(model, context, options);\n\t}\n\n\tgetProviderDisplayName(provider: string): string {\n\t\treturn this.runtime.getProvider(provider)?.name ?? provider;\n\t}\n\n\tgetProviderAuth(provider: string, options?: AuthOperationOptions): Promise<AuthResult | undefined> {\n\t\treturn this.runtime.getAuth(provider, options);\n\t}\n\n\tasync getApiKeyForProvider(provider: string): Promise<string | undefined> {\n\t\ttry {\n\t\t\treturn (await this.runtime.getAuth(provider))?.auth.apiKey;\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\tisUsingOAuth(model: Model<Api>): boolean {\n\t\treturn this.runtime.isUsingOAuth(model.provider);\n\t}\n\n\tregisterProvider(provider: Provider): void;\n\tregisterProvider(providerName: string, config: ProviderConfigInput): void;\n\tregisterProvider(providerOrName: Provider | string, config?: ProviderConfigInput): void {\n\t\tif (typeof providerOrName === \"string\") {\n\t\t\tif (!config) throw new Error(\"Provider config is required when registering by name\");\n\t\t\tthis.runtime.registerProvider(providerOrName, config);\n\t\t\treturn;\n\t\t}\n\t\tthis.runtime.registerNativeProvider(providerOrName);\n\t}\n\n\tunregisterProvider(providerName: string): void {\n\t\tthis.runtime.unregisterProvider(providerName);\n\t}\n\n\tgetRegisteredProviderConfig(providerName: string): ProviderConfigInput | undefined {\n\t\treturn this.runtime.getRegisteredProviderConfig(providerName);\n\t}\n\n\tgetRegisteredNativeProvider(providerName: string): Provider | undefined {\n\t\treturn this.runtime.getRegisteredNativeProvider(providerName);\n\t}\n\n\tgetRegisteredProviderIds(): readonly string[] {\n\t\treturn this.runtime.getRegisteredProviderIds();\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"model-registry.js","sourceRoot":"","sources":["../../src/core/model-registry.ts"],"names":[],"mappings":"AAmCA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D;;;GAGG;AACH,MAAM,OAAO,aAAa;IACR,OAAO,CAAe;IAEvC,YAAY,OAAqB;QAChC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACxB,C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B;QACvB,OAAO,IAAI,CAAC,OAAO,CAAC,wBAAwB,EAAE,CAAC;IAChD,CAAC;CACD","sourcesContent":["import type {\n\tApi,\n\tAssistantMessage,\n\tAssistantMessageEventStream,\n\tAuthOperationOptions,\n\tAuthResult,\n\tClassifierApi,\n\tClassifierContext,\n\tClassifierModel,\n\tClassifierResult,\n\tContext,\n\tModel,\n\tModelsApiStreamOptions,\n\tModelsClassifierOptions,\n\tModelsRefreshOptions,\n\tModelsRefreshResult,\n\tModelsSimpleStreamOptions,\n\tModelType,\n\tModelTypeMap,\n\tProvider,\n\tProviderHeaders,\n} from \"@bastani/pi-ai\";\nimport type { ModelRuntime } from \"./model-runtime.js\";\nimport type { AuthStatus, ProviderConfigInput } from \"./provider-composer.ts\";\n\nexport type { ProviderConfigInput } from \"./provider-composer.ts\";\nexport type ResolvedRequestAuth =\n\t| {\n\t\t\tok: true;\n\t\t\tapiKey?: string;\n\t\t\theaders?: ProviderHeaders;\n\t\t\tbaseUrl?: string;\n\t\t\tenv?: Record<string, string>;\n\t }\n\t| { ok: false; error: string };\nexport { clearApiKeyCache } from \"./provider-composer.ts\";\n\n/**\n * Compatibility facade exposed to extensions.\n * Coding-agent internals use ModelRuntime directly.\n */\nexport class ModelRegistry {\n\tprivate readonly runtime: ModelRuntime;\n\n\tconstructor(runtime: ModelRuntime) {\n\t\tthis.runtime = runtime;\n\t}\n\n\t/**\n\t * Reload models.json asynchronously. Await before making synchronous registry reads.\n\t * Returns pi's refresh result so callers can react to per-provider failures\n\t * (`errors`) and cancellation (`aborted`); pi reports both without rejecting.\n\t */\n\tasync refresh(options?: ModelsRefreshOptions): Promise<ModelsRefreshResult> {\n\t\treturn this.runtime.refresh(options);\n\t}\n\n\tgetError(): string | undefined {\n\t\treturn this.runtime.getError();\n\t}\n\n\tgetAll(): Model<Api>[] {\n\t\treturn [...this.runtime.getModels()];\n\t}\n\n\tgetAvailable(): Model<Api>[] {\n\t\treturn [...this.runtime.getAvailableSnapshot()];\n\t}\n\n\tfind(provider: string, modelId: string): Model<Api> | undefined {\n\t\treturn this.runtime.getModel(provider, modelId);\n\t}\n\n\tgetModelsOfType<T extends ModelType>(type: T, provider?: string): readonly ModelTypeMap[T][] {\n\t\treturn this.runtime.getModelsOfType(type, provider);\n\t}\n\tgetAvailableOfType<T extends ModelType>(\n\t\ttype: T,\n\t\tprovider?: string,\n\t\toptions?: AuthOperationOptions,\n\t): Promise<readonly ModelTypeMap[T][]> {\n\t\treturn this.runtime.getAvailableOfType(type, provider, options);\n\t}\n\tgetModelOfType<T extends ModelType>(type: T, provider: string, id: string): ModelTypeMap[T] | undefined {\n\t\treturn this.runtime.getModelOfType(type, provider, id);\n\t}\n\n\tgetClassifierModel(provider: string, modelId: string): ClassifierModel<ClassifierApi> | undefined {\n\t\treturn this.runtime.getModelOfType(\"classifier\", provider, modelId);\n\t}\n\n\thasConfiguredAuth(model: Model<Api>): boolean {\n\t\treturn this.runtime.hasConfiguredAuth(model.provider);\n\t}\n\n\t/** Boolean-only access to configured credential screening, without resolving request auth. */\n\tcontainsConfiguredCredential(serialized: string): Promise<boolean> {\n\t\treturn this.runtime.containsConfiguredCredential(serialized);\n\t}\n\n\tasync getApiKeyAndHeaders(model: Model<Api>): Promise<ResolvedRequestAuth> {\n\t\ttry {\n\t\t\tconst resolution = await this.runtime.getAuth(model);\n\t\t\tif (!resolution) {\n\t\t\t\tconst compatibility = this.runtime.getCompatibilityRequestConfig(model);\n\t\t\t\tif (compatibility.authHeader) {\n\t\t\t\t\treturn { ok: false, error: `No API key found for \"${model.provider}\"` };\n\t\t\t\t}\n\t\t\t\treturn { ok: true, headers: compatibility.headers };\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tok: true,\n\t\t\t\tapiKey: resolution.auth.apiKey,\n\t\t\t\theaders: resolution.auth.headers,\n\t\t\t\t...(resolution.auth.baseUrl === undefined ? {} : { baseUrl: resolution.auth.baseUrl }),\n\t\t\t\tenv: resolution.env,\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tconst cause = error instanceof Error ? error.cause : undefined;\n\t\t\tconst message =\n\t\t\t\tcause instanceof Error ? cause.message : error instanceof Error ? error.message : String(error);\n\t\t\treturn {\n\t\t\t\tok: false,\n\t\t\t\terror:\n\t\t\t\t\tmessage === \"authHeader requires a resolved API key\"\n\t\t\t\t\t\t? `No API key found for \"${model.provider}\"`\n\t\t\t\t\t\t: message,\n\t\t\t};\n\t\t}\n\t}\n\n\tgetProviderAuthStatus(provider: string): AuthStatus {\n\t\treturn this.runtime.getProviderAuthStatus(provider);\n\t}\n\n\tgetProvider(provider: string): Provider | undefined {\n\t\treturn this.runtime.getProvider(provider);\n\t}\n\n\t/** Stream through the configured provider with request-time authentication. */\n\tstream<TApi extends Api>(\n\t\tmodel: Model<TApi>,\n\t\tcontext: Context,\n\t\toptions?: ModelsApiStreamOptions<TApi>,\n\t): AssistantMessageEventStream {\n\t\treturn this.runtime.stream(model, context, options);\n\t}\n\n\t/** Stream with provider-neutral options and request-time authentication. */\n\tstreamSimple(model: Model<Api>, context: Context, options?: ModelsSimpleStreamOptions): AssistantMessageEventStream {\n\t\treturn this.runtime.streamSimple(model, context, options);\n\t}\n\n\t/** Complete through the active runtime so provider composition and request auth apply. */\n\tcomplete<TApi extends Api>(\n\t\tmodel: Model<TApi>,\n\t\tcontext: Context,\n\t\toptions?: ModelsApiStreamOptions<TApi>,\n\t): Promise<AssistantMessage> {\n\t\treturn this.runtime.complete(model, context, options);\n\t}\n\n\tclassify(\n\t\tmodel: ClassifierModel<ClassifierApi>,\n\t\tcontext: ClassifierContext,\n\t\toptions?: ModelsClassifierOptions,\n\t): Promise<ClassifierResult> {\n\t\treturn this.runtime.classify(model, context, options);\n\t}\n\n\tgetProviderDisplayName(provider: string): string {\n\t\treturn this.runtime.getProvider(provider)?.name ?? provider;\n\t}\n\n\tgetProviderAuth(provider: string, options?: AuthOperationOptions): Promise<AuthResult | undefined> {\n\t\treturn this.runtime.getAuth(provider, options);\n\t}\n\n\tasync getApiKeyForProvider(provider: string): Promise<string | undefined> {\n\t\ttry {\n\t\t\treturn (await this.runtime.getAuth(provider))?.auth.apiKey;\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\tisUsingOAuth(model: Model<Api>): boolean {\n\t\treturn this.runtime.isUsingOAuth(model.provider);\n\t}\n\n\tregisterProvider(provider: Provider): void;\n\tregisterProvider(providerName: string, config: ProviderConfigInput): void;\n\tregisterProvider(providerOrName: Provider | string, config?: ProviderConfigInput): void {\n\t\tif (typeof providerOrName === \"string\") {\n\t\t\tif (!config) throw new Error(\"Provider config is required when registering by name\");\n\t\t\tthis.runtime.registerProvider(providerOrName, config);\n\t\t\treturn;\n\t\t}\n\t\tthis.runtime.registerNativeProvider(providerOrName);\n\t}\n\n\tunregisterProvider(providerName: string): void {\n\t\tthis.runtime.unregisterProvider(providerName);\n\t}\n\n\tgetRegisteredProviderConfig(providerName: string): ProviderConfigInput | undefined {\n\t\treturn this.runtime.getRegisteredProviderConfig(providerName);\n\t}\n\n\tgetRegisteredNativeProvider(providerName: string): Provider | undefined {\n\t\treturn this.runtime.getRegisteredNativeProvider(providerName);\n\t}\n\n\tgetRegisteredProviderIds(): readonly string[] {\n\t\treturn this.runtime.getRegisteredProviderIds();\n\t}\n}\n"]}
|
|
@@ -4,7 +4,7 @@ export const defaultModelPerProvider = {
|
|
|
4
4
|
anthropic: "claude-opus-4-8",
|
|
5
5
|
openai: "gpt-5.5",
|
|
6
6
|
"azure-openai-responses": "gpt-5.4",
|
|
7
|
-
"openai-codex": "gpt-
|
|
7
|
+
"openai-codex": "gpt-6.1-sol",
|
|
8
8
|
radius: "balanced",
|
|
9
9
|
nvidia: "nvidia/nemotron-3-super-120b-a12b",
|
|
10
10
|
deepseek: "deepseek-v4-pro",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-resolver-defaults.js","sourceRoot":"","sources":["../../src/core/model-resolver-defaults.ts"],"names":[],"mappings":"AAEA,gDAAgD;AAChD,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oBAAoB,EAAE,aAAa;IACnC,4BAA4B,EAAE,aAAa;IAC3C,MAAM,EAAE,eAAe;IACvB,sBAAsB,EAAE,eAAe;IACvC,uBAAuB,EAAE,eAAe;IACxC,uBAAuB,EAAE,eAAe;CACxC,CAAC;AAEF,MAAM,UAAU,2BAA2B,CAAC,eAA6B;IACxE,KAAK,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,uBAAuB,CAAC,EAAE,CAAC;QAC7E,MAAM,KAAK,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,QAAQ,IAAI,CAAC,CAAC,EAAE,KAAK,SAAS,CAAC,CAAC;QACzF,IAAI,KAAK,EAAE,CAAC;YACX,OAAO,KAAK,CAAC;QACd,CAAC;IACF,CAAC;IAED,OAAO,eAAe,CAAC,CAAC,CAAC,CAAC;AAC3B,CAAC","sourcesContent":["import type { Api, Model } from \"@bastani/pi-ai/compat\";\n\n/** Default model IDs for each known provider */\nexport const defaultModelPerProvider: Record<string, string> = {\n\t\"amazon-bedrock\": \"us.anthropic.claude-opus-4-6-v1\",\n\tanthropic: \"claude-opus-4-8\",\n\topenai: \"gpt-5.5\",\n\t\"azure-openai-responses\": \"gpt-5.4\",\n\t\"openai-codex\": \"gpt-6.1-sol\",\n\tradius: \"balanced\",\n\tnvidia: \"nvidia/nemotron-3-super-120b-a12b\",\n\tdeepseek: \"deepseek-v4-pro\",\n\tgoogle: \"gemini-3.1-pro-preview\",\n\t\"google-vertex\": \"gemini-3.1-pro-preview\",\n\t\"github-copilot\": \"gpt-5.4\",\n\topenrouter: \"moonshotai/kimi-k2.6\",\n\t\"vercel-ai-gateway\": \"zai/glm-5.1\",\n\txai: \"grok-4.7\",\n\tgroq: \"openai/gpt-oss-120b\",\n\tcerebras: \"gpt-oss-120b\",\n\t\"ant-ling\": \"Ring-2.6-1T\",\n\tzai: \"glm-5.3\",\n\t\"zai-coding-cn\": \"glm-5.3\",\n\tmistral: \"devstral-medium-latest\",\n\tminimax: \"MiniMax-M2.7\",\n\t\"minimax-cn\": \"MiniMax-M2.7\",\n\tmoonshotai: \"kimi-k2.6\",\n\t\"moonshotai-cn\": \"kimi-k2.6\",\n\thuggingface: \"moonshotai/Kimi-K2.6\",\n\tfireworks: \"accounts/fireworks/models/kimi-k3\",\n\ttogether: \"moonshotai/Kimi-K3\",\n\tbaseten: \"zai-org/GLM-5.3\",\n\topencode: \"kimi-k2.6\",\n\t\"opencode-go\": \"kimi-k3\",\n\t\"kimi-coding\": \"kimi-for-coding\",\n\tmeta: \"muse-spark-1.3\",\n\t\"cloudflare-workers-ai\": \"@cf/moonshotai/kimi-k2.6\",\n\t\"cloudflare-ai-gateway\": \"workers-ai/@cf/moonshotai/kimi-k2.6\",\n\t\"qwen-token-plan\": \"qwen3.7-max\",\n\t\"qwen-token-plan-cn\": \"qwen3.7-max\",\n\t\"qwen-token-plan-individual\": \"qwen3.8-max\",\n\txiaomi: \"mimo-v2.5-pro\",\n\t\"xiaomi-token-plan-cn\": \"mimo-v2.5-pro\",\n\t\"xiaomi-token-plan-ams\": \"mimo-v2.5-pro\",\n\t\"xiaomi-token-plan-sgp\": \"mimo-v2.5-pro\",\n};\n\nexport function findPreferredAvailableModel(availableModels: Model<Api>[]): Model<Api> | undefined {\n\tfor (const [provider, defaultId] of Object.entries(defaultModelPerProvider)) {\n\t\tconst match = availableModels.find((m) => m.provider === provider && m.id === defaultId);\n\t\tif (match) {\n\t\t\treturn match;\n\t\t}\n\t}\n\n\treturn availableModels[0];\n}\n"]}
|
|
@@ -12,6 +12,10 @@ export interface CandidateModel {
|
|
|
12
12
|
readonly input: readonly string[];
|
|
13
13
|
/** `provider/id` of the base model when this entry is its derived fast route (`fastRoute` metadata). */
|
|
14
14
|
readonly fastRouteOf?: string;
|
|
15
|
+
/** Explicit provider tier, used to avoid claiming measured latency for ultrafast. */
|
|
16
|
+
readonly fastRouteServiceTier?: "priority" | "ultrafast";
|
|
17
|
+
/** True when `cost` already holds the route tier's published rates rather than the base model's. */
|
|
18
|
+
readonly fastRoutePriced?: boolean;
|
|
15
19
|
}
|
|
16
20
|
export interface RankedCandidate extends CandidateModel {
|
|
17
21
|
/** Identity shared by one model's providers and its derived fast route, which collapse onto it. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-routing-candidates.d.ts","sourceRoot":"","sources":["../../src/core/model-routing-candidates.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,KAAK,YAAY,EAEjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,KAAK,iBAAiB,EAA6B,MAAM,0BAA0B,CAAC;AAE7F,2DAA2D;AAC3D,MAAM,WAAW,cAAc;IAC9B,mDAAmD;IACnD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE;QAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IACnE,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,wGAAwG;IACxG,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"model-routing-candidates.d.ts","sourceRoot":"","sources":["../../src/core/model-routing-candidates.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,KAAK,YAAY,EAEjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,KAAK,iBAAiB,EAA6B,MAAM,0BAA0B,CAAC;AAE7F,2DAA2D;AAC3D,MAAM,WAAW,cAAc;IAC9B,mDAAmD;IACnD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE;QAAE,QAAQ,CAAC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@ -14,6 +14,7 @@ const WORK_METRICS = {
|
|
|
14
14
|
coding: [
|
|
15
15
|
percent("aa:TB4", "Terminal-Bench 4.0"),
|
|
16
16
|
percent("dswe:Pass@1", "DeepSWE"),
|
|
17
|
+
percent("pub:DSWE", "DeepSWE"),
|
|
17
18
|
percent("fc:Main", "FrontierCode"),
|
|
18
19
|
percent("aa:TB21", "Terminal-Bench 2.1"),
|
|
19
20
|
],
|
|
@@ -193,7 +194,7 @@ export function rankCandidates(catalog, candidates, needs) {
|
|
|
193
194
|
const measured = candidates.map((candidate) => ({
|
|
194
195
|
candidate,
|
|
195
196
|
base: baseKey(candidate),
|
|
196
|
-
...measure(catalog, candidate.model),
|
|
197
|
+
...measure(catalog, candidate.fastRouteOf ?? candidate.model),
|
|
197
198
|
}));
|
|
198
199
|
const rankOf = (key, value, own) => {
|
|
199
200
|
const cohort = cohorts.get(key);
|
|
@@ -236,7 +237,9 @@ export function rankCandidates(catalog, candidates, needs) {
|
|
|
236
237
|
score: qualityWeight * quality +
|
|
237
238
|
priceWeight * cheapness +
|
|
238
239
|
0.1 * recency +
|
|
239
|
-
(needs.latencySensitive && candidate.fastRouteOf
|
|
240
|
+
(needs.latencySensitive && candidate.fastRouteOf && candidate.fastRouteServiceTier !== "ultrafast"
|
|
241
|
+
? FAST_ROUTE_BONUS
|
|
242
|
+
: 0),
|
|
240
243
|
values,
|
|
241
244
|
conditions,
|
|
242
245
|
...(released ? { released } : {}),
|
|
@@ -327,7 +330,9 @@ export function describeOption(option, needs, eligible) {
|
|
|
327
330
|
overall: quote([OVERALL], option.overallStanding),
|
|
328
331
|
...(option.fastRouteOf
|
|
329
332
|
? {
|
|
330
|
-
route:
|
|
333
|
+
route: option.fastRouteServiceTier === "ultrafast"
|
|
334
|
+
? `ultrafast request for ${fastBase?.name ?? option.fastRouteOf}; base-model evidence only, no separate latency or benchmark score; account access required`
|
|
335
|
+
: `faster route of ${fastBase?.name ?? option.fastRouteOf} with the same results; ${option.fastRoutePriced ? "the listed prices are its Fast rates" : "billed above the listed prices"}`,
|
|
331
336
|
}
|
|
332
337
|
: {}),
|
|
333
338
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-routing-candidates.js","sourceRoot":"","sources":["../../src/core/model-routing-candidates.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,qBAAqB,EACrB,oBAAoB,EAEpB,mBAAmB,GACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAA0B,UAAU,EAAiB,MAAM,0BAA0B,CAAC;AAmB7F,MAAM,OAAO,GAAG,CAAC,GAAW,EAAE,KAAa,EAAU,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC;AACpF,MAAM,MAAM,GAAG,CAAC,GAAW,EAAE,KAAa,EAAU,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;AAElF,MAAM,OAAO,GAAW,MAAM,CAAC,QAAQ,EAAE,uBAAuB,CAAC,CAAC;AAElE,wFAAwF;AACxF,MAAM,YAAY,GAAwC;IACzD,YAAY,EAAE;QACb,OAAO,CAAC,UAAU,EAAE,aAAa,CAAC;QAClC,OAAO,CAAC,SAAS,EAAE,gBAAgB,CAAC;QACpC,OAAO,CAAC,SAAS,EAAE,mBAAmB,CAAC;QACvC,OAAO,CAAC,SAAS,EAAE,UAAU,CAAC;KAC9B;IACD,MAAM,EAAE;QACP,OAAO,CAAC,QAAQ,EAAE,oBAAoB,CAAC;QACvC,OAAO,CAAC,aAAa,EAAE,SAAS,CAAC;QACjC,OAAO,CAAC,SAAS,EAAE,cAAc,CAAC;QAClC,OAAO,CAAC,SAAS,EAAE,oBAAoB,CAAC;KACxC;IACD,WAAW,EAAE;QACZ,OAAO,CAAC,SAAS,EAAE,cAAc,CAAC;QAClC,OAAO,CAAC,QAAQ,EAAE,oBAAoB,CAAC;QACvC,OAAO,CAAC,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AAC,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,YAAY,CAAC;QAClE,OAAO,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,eAAe,CAAC;QACjD,GAAG,CAAC,MAAM,CAAC,WAAW;YACrB,CAAC,CAAC;gBACA,KAAK,EAAE,mBAAmB,QAAQ,EAAE,IAAI,IAAI,MAAM,CAAC,WAAW,wDAAwD;aACtH;YACF,CAAC,CAAC,EAAE,CAAC;KACN,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import {\n\tcandidateEvidenceRows,\n\tcatalogModelIdentity,\n\ttype EvalsCatalog,\n\tmodelEvidenceTokens,\n} from \"./model-routing-evals.js\";\nimport { type ResolvedTaskNeeds, taskDemand, type WorkKind } from \"./model-routing-needs.js\";\n\n/** What ranking needs to know about one eligible model. */\nexport interface CandidateModel {\n\t/** `provider/id`, as used in router selections. */\n\treadonly model: string;\n\treadonly name: string;\n\treadonly cost: { readonly input: number; readonly output: number };\n\treadonly input: readonly string[];\n\t/** `provider/id` of the base model when this entry is its derived fast route (`fastRoute` metadata). */\n\treadonly fastRouteOf?: string;\n}\n\ninterface Metric {\n\treadonly key: string;\n\treadonly label: string;\n\treadonly unit: \"%\" | \"\";\n}\n\nconst percent = (key: string, label: string): Metric => ({ key, label, unit: \"%\" });\nconst points = (key: string, label: string): Metric => ({ key, label, unit: \"\" });\n\nconst OVERALL: Metric = points(\"aa:idx\", \"AA Intelligence Index\");\n\n/** evals.md columns that measure each kind of work, in the order results are quoted. */\nconst WORK_METRICS: Record<WorkKind, readonly Metric[]> = {\n\tcomputer_use: [\n\t\tpercent(\"pub:OSW2\", \"OSWorld 2.0\"),\n\t\tpercent(\"pub:SSP\", \"ScreenSpot-Pro\"),\n\t\tpercent(\"pub:ALE\", \"Agents' Last Exam\"),\n\t\tpercent(\"aa:MMMU\", \"MMMU-Pro\"),\n\t],\n\tcoding: [\n\t\tpercent(\"aa:TB4\", \"Terminal-Bench 4.0\"),\n\t\tpercent(\"dswe:Pass@1\", \"DeepSWE\"),\n\t\tpercent(\"fc:Main\", \"FrontierCode\"),\n\t\tpercent(\"aa:TB21\", \"Terminal-Bench 2.1\"),\n\t],\n\tcode_review: [\n\t\tpercent(\"fc:Main\", \"FrontierCode\"),\n\t\tpercent(\"aa:TB4\", \"Terminal-Bench 4.0\"),\n\t\tpercent(\"pub:XGym\", \"ExploitGym\"),\n\t\tpercent(\"pub:SECPro\", \"SEC-Bench Pro\"),\n\t],\n\tcodebase_lookup: [\n\t\tpercent(\"aa:TB4\", \"Terminal-Bench 4.0\"),\n\t\tpercent(\"aa:tau2\", \"τ²-Bench\"),\n\t\tpercent(\"aa:IF\", \"IFBench\"),\n\t],\n\tresearch: [\n\t\tpercent(\"aa:HLE\", \"Humanity's Last Exam\"),\n\t\tpercent(\"pub:BComp\", \"BrowseComp\"),\n\t\tpercent(\"aa:GPQA\", \"GPQA Diamond\"),\n\t\tpercent(\"aa:LCR\", \"AA-LCR\"),\n\t],\n\tbusiness_workflow: [\n\t\tpercent(\"aa:Auto\", \"AutomationBench-AA\"),\n\t\tpercent(\"pub:ABench\", \"AutomationBench\"),\n\t\tpercent(\"aa:tau2\", \"τ²-Bench\"),\n\t\tpercent(\"aa:Ent\", \"EnterpriseOps-Gym\"),\n\t],\n\tmath_science: [\n\t\tpercent(\"pub:FMT4\", \"FrontierMath Tier 4\"),\n\t\tpercent(\"pub:TBSci\", \"Terminal-Bench-Science\"),\n\t\tpercent(\"aa:Crit\", \"CritPt\"),\n\t\tpercent(\"aa:Sci\", \"SciCode\"),\n\t],\n\twriting: [\n\t\tpercent(\"aa:IF\", \"IFBench\"),\n\t\tpoints(\"aa:Gn\", \"GDPval\"),\n\t\tpoints(\"aa:Brief\", \"AA-Briefcase\"),\n\t\tpercent(\"aa:LCR\", \"AA-LCR\"),\n\t],\n};\n\n/** When speed matters, a fast route edges out its standard route for the model's single slot. */\nconst FAST_ROUTE_BONUS = 0.02;\n\n/** A standing is stated only when enough benchmarked models share the measurement. */\nconst MIN_RANKED_MODELS = 4;\n\nexport interface RankedCandidate extends CandidateModel {\n\t/** Identity shared by one model's providers and its derived fast route, which collapse onto it. */\n\treadonly baseKey: string;\n\treadonly score: number;\n\treadonly values: ReadonlyMap<string, number>;\n\t/** How each quoted value was measured, for example its effort, harness or reporter. */\n\treadonly conditions: ReadonlyMap<string, string>;\n\treadonly released?: string;\n\treadonly workStanding?: number;\n\treadonly overallStanding?: number;\n}\n\nfunction sectionKind(intro: readonly string[]): \"aa\" | \"dswe\" | \"fc\" | \"pub\" {\n\tconst heading = intro.find((line) => line.startsWith(\"## \")) ?? \"\";\n\tif (/DeepSWE/u.test(heading)) return \"dswe\";\n\tif (/FrontierCode/u.test(heading)) return \"fc\";\n\tif (/Published/u.test(heading)) return \"pub\";\n\treturn \"aa\";\n}\n\nconst cells = (line: string) =>\n\tline\n\t\t.split(\"|\")\n\t\t.slice(1, -1)\n\t\t.map((cell) => cell.trim());\n\nconst nameWords = (text: string) => new Set(text.match(/\\p{Lu}[\\p{L}]{2,}/gu) ?? []);\n\n/**\n * The parts of a published result's setting that apply to this row: a clause\n * naming other models (for example \"Fable values are Mythos\" on a GPT row) is a\n * footnote for them and is dropped.\n */\nfunction ownSetting(setting: string, rowModel: string, modelWords: ReadonlySet<string>): string {\n\tconst own = nameWords(rowModel);\n\treturn setting\n\t\t.split(\";\")\n\t\t.map((clause) => clause.trim())\n\t\t.filter((clause) => {\n\t\t\tconst named = [...nameWords(clause)].filter((word) => modelWords.has(word));\n\t\t\treturn named.length === 0 || named.some((word) => own.has(word));\n\t\t})\n\t\t.join(\", \");\n}\n\n/** Parenthetical measurement setting in an Artificial Analysis model name, for example \"Max Effort\". */\nfunction nameCondition(name: string | undefined): string | undefined {\n\tconst setting = /\\(([^)]+)\\)\\s*$/u.exec(name ?? \"\")?.[1];\n\treturn setting && /^(?:minimal|low|medium|high|xhigh|max)$/u.test(setting) ? `${setting} effort` : setting;\n}\n\ninterface Reading {\n\treadonly key: string;\n\treadonly value: number;\n\treadonly condition?: string;\n}\n\ninterface CatalogReadings {\n\t/** Readings of each catalog row, indexed by the row's `order`. */\n\treadonly rows: readonly (readonly Reading[])[];\n\t/** Per measurement, the best value of each catalog model. */\n\treadonly cohorts: ReadonlyMap<string, ReadonlyMap<string, number>>;\n}\n\nconst readingsByCatalog = new WeakMap<EvalsCatalog, CatalogReadings>();\n\n/** Every measured value in the catalog, read once per parsed catalog. */\nfunction catalogReadings(catalog: EvalsCatalog): CatalogReadings {\n\tconst cached = readingsByCatalog.get(catalog);\n\tif (cached) return cached;\n\tconst kinds = catalog.sections.map((section) => sectionKind(section.intro));\n\tconst headers = catalog.sections.map((section) =>\n\t\tcells(section.intro.find((line) => line.startsWith(\"| slug |\")) ?? \"\"),\n\t);\n\tconst modelColumn = headers.map((header) => header.indexOf(\"Model\"));\n\tconst modelWords = catalog.sections.map((_, section) => {\n\t\tconst words = new Set<string>();\n\t\tfor (const row of catalog.rows)\n\t\t\tif (row.section === section)\n\t\t\t\tfor (const word of nameWords(cells(row.line)[modelColumn[section]!] ?? \"\")) words.add(word);\n\t\treturn words;\n\t});\n\tconst rows = catalog.rows.map((row) => {\n\t\tconst header = headers[row.section]!;\n\t\tconst rowCells = cells(row.line);\n\t\tconst column = (name: string) => (header.includes(name) ? rowCells[header.indexOf(name)] : undefined);\n\t\tconst readings: Reading[] = [];\n\t\tconst read = (key: string, raw: string | undefined, condition: string | undefined) => {\n\t\t\tconst value = Number.parseFloat(raw ?? \"\");\n\t\t\tif (Number.isFinite(value)) readings.push({ key, value, ...(condition ? { condition } : {}) });\n\t\t};\n\t\tif (kinds[row.section] === \"pub\") {\n\t\t\tconst reporter = column(\"Source\");\n\t\t\tconst setting = ownSetting(column(\"Setting\") ?? \"\", column(\"Model\") ?? \"\", modelWords[row.section]!);\n\t\t\tconst condition = [setting, reporter ? `reported by ${reporter}` : undefined].filter(Boolean).join(\", \");\n\t\t\t// Each reporter's results form their own cohort: a vendor harness and an\n\t\t\t// official leaderboard are not ranked against each other.\n\t\t\tread(`pub:${column(\"Benchmark\")}@${reporter ?? \"\"}`, column(\"Score\"), condition);\n\t\t} else {\n\t\t\tconst effort = column(\"Effort\");\n\t\t\tconst condition = effort ? `${effort} effort` : nameCondition(column(\"Model\"));\n\t\t\tfor (const [index, name] of header.entries())\n\t\t\t\tif (index > 1 && name !== \"Effort\" && name !== \"Release date\")\n\t\t\t\t\tread(`${kinds[row.section]}:${name}`, rowCells[index], condition);\n\t\t}\n\t\treturn readings;\n\t});\n\tconst cohorts = new Map<string, Map<string, number>>();\n\tfor (const row of catalog.rows) {\n\t\tconst identity = catalogModelIdentity(row.tokens);\n\t\tfor (const { key, value } of rows[row.order]!) {\n\t\t\tconst cohort = cohorts.get(key) ?? new Map<string, number>();\n\t\t\tcohort.set(identity, Math.max(cohort.get(identity) ?? value, value));\n\t\t\tcohorts.set(key, cohort);\n\t\t}\n\t}\n\tconst readings = { rows, cohorts };\n\treadingsByCatalog.set(catalog, readings);\n\treturn readings;\n}\n\n/**\n * Best value per metric across every evals row describing the model, with the\n * conditions it was measured under, the catalog models those rows belong to,\n * and the model's newest release date.\n */\nfunction measure(\n\tcatalog: EvalsCatalog,\n\tmodel: string,\n): { values: Map<string, number>; conditions: Map<string, string>; identities: Set<string>; released?: string } {\n\tconst readings = catalogReadings(catalog);\n\tconst values = new Map<string, number>();\n\tconst conditions = new Map<string, string>();\n\tconst identities = new Set<string>();\n\tlet released: string | undefined;\n\tfor (const row of candidateEvidenceRows(catalog, model)) {\n\t\tidentities.add(catalogModelIdentity(row.tokens));\n\t\tfor (const { key, value, condition } of readings.rows[row.order]!) {\n\t\t\tif (value <= (values.get(key) ?? Number.NEGATIVE_INFINITY)) continue;\n\t\t\tvalues.set(key, value);\n\t\t\tif (condition) conditions.set(key, condition);\n\t\t\telse conditions.delete(key);\n\t\t}\n\t\tif (row.releaseDate && (!released || row.releaseDate > released)) released = row.releaseDate;\n\t}\n\treturn { values, conditions, identities, ...(released ? { released } : {}) };\n}\n\n/** Value keys measuring `metric`: the column itself, or one per reporter for published results. */\nconst cohortKeys = (values: ReadonlyMap<string, number>, metric: Metric) =>\n\t[...values.keys()].filter((key) => key === metric.key || key.startsWith(`${metric.key}@`));\n\nconst baseKey = (candidate: CandidateModel) => modelEvidenceTokens(candidate.fastRouteOf ?? candidate.model).join(\"-\");\n\nconst blended = (candidate: CandidateModel) => (3 * candidate.cost.input + candidate.cost.output) / 4;\n\n/**\n * Rank every eligible model for the task in code. Quality is the model's\n * standing among every benchmarked model in the catalog on the benchmarks for\n * this kind of work (overall intelligence when it has none), so it does not\n * depend on which other models are eligible. It is weighed against price by how\n * demanding the task is, with a small preference for newer releases.\n */\nexport function rankCandidates(\n\tcatalog: EvalsCatalog,\n\tcandidates: readonly CandidateModel[],\n\tneeds: ResolvedTaskNeeds,\n): RankedCandidate[] {\n\tconst { cohorts } = catalogReadings(catalog);\n\tconst measured = candidates.map((candidate) => ({\n\t\tcandidate,\n\t\tbase: baseKey(candidate),\n\t\t...measure(catalog, candidate.model),\n\t}));\n\tconst rankOf = (key: string, value: number, own: ReadonlySet<string>): number | undefined => {\n\t\tconst cohort = cohorts.get(key);\n\t\tif (cohort === undefined || cohort.size < MIN_RANKED_MODELS) return undefined;\n\t\tconst others = [...cohort].filter(([identity]) => !own.has(identity)).map(([, other]) => other);\n\t\treturn others.length ? others.filter((other) => other < value).length / others.length : undefined;\n\t};\n\tconst standingOf = (values: ReadonlyMap<string, number>, own: ReadonlySet<string>, metrics: readonly Metric[]) => {\n\t\tconst ranks = metrics\n\t\t\t.flatMap((metric) => cohortKeys(values, metric))\n\t\t\t.map((key) => rankOf(key, values.get(key)!, own))\n\t\t\t.filter((rank): rank is number => rank !== undefined);\n\t\treturn ranks.length ? ranks.reduce((a, b) => a + b, 0) / ranks.length : undefined;\n\t};\n\tconst logPrices = measured\n\t\t.map((entry) => blended(entry.candidate))\n\t\t.filter((price) => price > 0)\n\t\t.map(Math.log);\n\tconst [low, high] = [Math.min(...logPrices), Math.max(...logPrices)];\n\tconst newest = measured\n\t\t.map((entry) => entry.released ?? \"\")\n\t\t.sort()\n\t\t.at(-1);\n\tconst demand = taskDemand(needs);\n\tconst qualityWeight = 0.25 + 0.65 * demand;\n\tconst priceWeight = 0.65 - 0.65 * demand;\n\n\treturn measured\n\t\t.map(({ candidate, base, values, conditions, identities, released }) => {\n\t\t\tconst workStanding = standingOf(values, identities, WORK_METRICS[needs.work]);\n\t\t\tconst overallStanding = standingOf(values, identities, [OVERALL]);\n\t\t\tconst quality = workStanding ?? (overallStanding !== undefined ? 0.8 * overallStanding : 0.2);\n\t\t\tconst price = blended(candidate);\n\t\t\tconst cheapness = price > 0 && high > low ? 1 - (Math.log(price) - low) / (high - low) : 1;\n\t\t\tconst ageDays = released && newest ? (Date.parse(newest) - Date.parse(released)) / 86_400_000 : 365;\n\t\t\tconst recency = 1 - Math.min(1, ageDays / 365);\n\t\t\treturn {\n\t\t\t\t...candidate,\n\t\t\t\tbaseKey: base,\n\t\t\t\tscore:\n\t\t\t\t\tqualityWeight * quality +\n\t\t\t\t\tpriceWeight * cheapness +\n\t\t\t\t\t0.1 * recency +\n\t\t\t\t\t(needs.latencySensitive && candidate.fastRouteOf ? FAST_ROUTE_BONUS : 0),\n\t\t\t\tvalues,\n\t\t\t\tconditions,\n\t\t\t\t...(released ? { released } : {}),\n\t\t\t\t...(workStanding !== undefined ? { workStanding } : {}),\n\t\t\t\t...(overallStanding !== undefined ? { overallStanding } : {}),\n\t\t\t};\n\t\t})\n\t\t.sort(\n\t\t\t(a, b) =>\n\t\t\t\tb.score - a.score ||\n\t\t\t\tNumber(a.fastRouteOf !== undefined) - Number(b.fastRouteOf !== undefined) ||\n\t\t\t\ta.model.localeCompare(b.model),\n\t\t);\n}\n\n/** The best `size` candidates with at most one per base model. */\nexport function distinctTop(ranked: readonly RankedCandidate[], size: number): RankedCandidate[] {\n\tconst seen = new Set<string>();\n\tconst top: RankedCandidate[] = [];\n\tfor (const candidate of ranked) {\n\t\tif (seen.has(candidate.baseKey)) continue;\n\t\tseen.add(candidate.baseKey);\n\t\ttop.push(candidate);\n\t\tif (top.length === size) break;\n\t}\n\treturn top;\n}\n\nfunction standingLabel(fraction: number): string {\n\tif (fraction >= 0.9) return \"top 10%\";\n\tif (fraction >= 0.75) return \"top quarter\";\n\tif (fraction >= 0.5) return \"above median\";\n\tif (fraction >= 0.25) return \"below median\";\n\treturn \"bottom quarter\";\n}\n\nconst money = (value: number) => `$${Number(value.toPrecision(3))}`;\n\n/**\n * One shortlisted option described with its own evidence, so the router compares\n * options directly: release date, price tier, image input, and results for this\n * kind of work and overall, with standings among catalog models measured on the same benchmark by the same source.\n */\nexport function describeOption(\n\toption: RankedCandidate,\n\tneeds: ResolvedTaskNeeds,\n\teligible: readonly RankedCandidate[],\n): string {\n\tconst prices = eligible.map(blended).sort((a, b) => a - b);\n\tconst position = prices.filter((other) => other < blended(option)).length / Math.max(1, prices.length - 1);\n\tconst tier = position < 1 / 3 ? \"low\" : position < 2 / 3 ? \"mid\" : \"high\";\n\tconst newest = eligible\n\t\t.map((candidate) => candidate.released ?? \"\")\n\t\t.sort()\n\t\t.at(-1);\n\tconst quote = (metrics: readonly Metric[], standing: number | undefined) => {\n\t\tconst present = metrics\n\t\t\t.map((metric) => {\n\t\t\t\tconst keys = cohortKeys(option.values, metric);\n\t\t\t\tconst best = keys.sort((a, b) => option.values.get(b)! - option.values.get(a)!)[0];\n\t\t\t\treturn best === undefined ? undefined : { metric, key: best };\n\t\t\t})\n\t\t\t.filter((entry) => entry !== undefined)\n\t\t\t.slice(0, 2);\n\t\tif (present.length === 0) return \"no published results\";\n\t\tconst results = present\n\t\t\t.map(({ metric, key }) => {\n\t\t\t\tconst condition = option.conditions.get(key);\n\t\t\t\treturn `${metric.label} ${option.values.get(key)}${metric.unit}${condition ? ` measured with ${condition}` : \"\"}`;\n\t\t\t})\n\t\t\t.join(\"; \");\n\t\treturn `${standing === undefined ? \"measured\" : `${standingLabel(standing)} of models with the same benchmark and source`} (${results})`;\n\t};\n\tlet released = \"unknown\";\n\tif (option.released) {\n\t\tconst months = newest ? Math.round((Date.parse(newest) - Date.parse(option.released)) / (30.44 * 86_400_000)) : 0;\n\t\treleased =\n\t\t\tmonths <= 1\n\t\t\t\t? `${option.released}, among the newest`\n\t\t\t\t: `${option.released}, ${months} months older than the newest`;\n\t}\n\tconst fastBase = option.fastRouteOf\n\t\t? eligible.find((candidate) => candidate.model === option.fastRouteOf)\n\t\t: undefined;\n\treturn JSON.stringify({\n\t\tmodel: option.name,\n\t\tid: option.model,\n\t\treleased,\n\t\tprice: `${tier}: ${money(option.cost.input)} / ${money(option.cost.output)} per million tokens`,\n\t\treads_images: option.input.includes(\"image\"),\n\t\t[needs.work]: quote(WORK_METRICS[needs.work], option.workStanding),\n\t\toverall: quote([OVERALL], option.overallStanding),\n\t\t...(option.fastRouteOf\n\t\t\t? {\n\t\t\t\t\troute: `faster route of ${fastBase?.name ?? option.fastRouteOf} with the same results; billed above the listed prices`,\n\t\t\t\t}\n\t\t\t: {}),\n\t});\n}\n"]}
|
|
1
|
+
{"version":3,"file":"model-routing-candidates.js","sourceRoot":"","sources":["../../src/core/model-routing-candidates.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,qBAAqB,EACrB,oBAAoB,EAEpB,mBAAmB,GACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAA0B,UAAU,EAAiB,MAAM,0BAA0B,CAAC;AAuB7F,MAAM,OAAO,GAAG,CAAC,GAAW,EAAE,KAAa,EAAU,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC;AACpF,MAAM,MAAM,GAAG,CAAC,GAAW,EAAE,KAAa,EAAU,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;AAElF,MAAM,OAAO,GAAW,MAAM,CAAC,QA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C,CAAC;AACJ,CAAC","sourcesContent":["import {\n\tcandidateEvidenceRows,\n\tcatalogModelIdentity,\n\ttype EvalsCatalog,\n\tmodelEvidenceTokens,\n} from \"./model-routing-evals.js\";\nimport { type ResolvedTaskNeeds, taskDemand, type WorkKind } from \"./model-routing-needs.js\";\n\n/** What ranking needs to know about one eligible model. */\nexport interface CandidateModel {\n\t/** `provider/id`, as used in router selections. */\n\treadonly model: string;\n\treadonly name: string;\n\treadonly cost: { readonly input: number; readonly output: number };\n\treadonly input: readonly string[];\n\t/** `provider/id` of the base model when this entry is its derived fast route (`fastRoute` metadata). */\n\treadonly fastRouteOf?: string;\n\t/** Explicit provider tier, used to avoid claiming measured latency for ultrafast. */\n\treadonly fastRouteServiceTier?: \"priority\" | \"ultrafast\";\n\t/** True when `cost` already holds the route tier's published rates rather than the base model's. */\n\treadonly fastRoutePriced?: boolean;\n}\n\ninterface Metric {\n\treadonly key: string;\n\treadonly label: string;\n\treadonly unit: \"%\" | \"\";\n}\n\nconst percent = (key: string, label: string): Metric => ({ key, label, unit: \"%\" });\nconst points = (key: string, label: string): Metric => ({ key, label, unit: \"\" });\n\nconst OVERALL: Metric = points(\"aa:idx\", \"AA Intelligence Index\");\n\n/** evals.md columns that measure each kind of work, in the order results are quoted. */\nconst WORK_METRICS: Record<WorkKind, readonly Metric[]> = {\n\tcomputer_use: [\n\t\tpercent(\"pub:OSW2\", \"OSWorld 2.0\"),\n\t\tpercent(\"pub:SSP\", \"ScreenSpot-Pro\"),\n\t\tpercent(\"pub:ALE\", \"Agents' Last Exam\"),\n\t\tpercent(\"aa:MMMU\", \"MMMU-Pro\"),\n\t],\n\tcoding: [\n\t\tpercent(\"aa:TB4\", \"Terminal-Bench 4.0\"),\n\t\tpercent(\"dswe:Pass@1\", \"DeepSWE\"),\n\t\tpercent(\"pub:DSWE\", \"DeepSWE\"),\n\t\tpercent(\"fc:Main\", \"FrontierCode\"),\n\t\tpercent(\"aa:TB21\", \"Terminal-Bench 2.1\"),\n\t],\n\tcode_review: [\n\t\tpercent(\"fc:Main\", \"FrontierCode\"),\n\t\tpercent(\"aa:TB4\", \"Terminal-Bench 4.0\"),\n\t\tpercent(\"pub:XGym\", \"ExploitGym\"),\n\t\tpercent(\"pub:SECPro\", \"SEC-Bench Pro\"),\n\t],\n\tcodebase_lookup: [\n\t\tpercent(\"aa:TB4\", \"Terminal-Bench 4.0\"),\n\t\tpercent(\"aa:tau2\", \"τ²-Bench\"),\n\t\tpercent(\"aa:IF\", \"IFBench\"),\n\t],\n\tresearch: [\n\t\tpercent(\"aa:HLE\", \"Humanity's Last Exam\"),\n\t\tpercent(\"pub:BComp\", \"BrowseComp\"),\n\t\tpercent(\"aa:GPQA\", \"GPQA Diamond\"),\n\t\tpercent(\"aa:LCR\", \"AA-LCR\"),\n\t],\n\tbusiness_workflow: [\n\t\tpercent(\"aa:Auto\", \"AutomationBench-AA\"),\n\t\tpercent(\"pub:ABench\", \"AutomationBench\"),\n\t\tpercent(\"aa:tau2\", \"τ²-Bench\"),\n\t\tpercent(\"aa:Ent\", \"EnterpriseOps-Gym\"),\n\t],\n\tmath_science: [\n\t\tpercent(\"pub:FMT4\", \"FrontierMath Tier 4\"),\n\t\tpercent(\"pub:TBSci\", \"Terminal-Bench-Science\"),\n\t\tpercent(\"aa:Crit\", \"CritPt\"),\n\t\tpercent(\"aa:Sci\", \"SciCode\"),\n\t],\n\twriting: [\n\t\tpercent(\"aa:IF\", \"IFBench\"),\n\t\tpoints(\"aa:Gn\", \"GDPval\"),\n\t\tpoints(\"aa:Brief\", \"AA-Briefcase\"),\n\t\tpercent(\"aa:LCR\", \"AA-LCR\"),\n\t],\n};\n\n/** When speed matters, a fast route edges out its standard route for the model's single slot. */\nconst FAST_ROUTE_BONUS = 0.02;\n\n/** A standing is stated only when enough benchmarked models share the measurement. */\nconst MIN_RANKED_MODELS = 4;\n\nexport interface RankedCandidate extends CandidateModel {\n\t/** Identity shared by one model's providers and its derived fast route, which collapse onto it. */\n\treadonly baseKey: string;\n\treadonly score: number;\n\treadonly values: ReadonlyMap<string, number>;\n\t/** How each quoted value was measured, for example its effort, harness or reporter. */\n\treadonly conditions: ReadonlyMap<string, string>;\n\treadonly released?: string;\n\treadonly workStanding?: number;\n\treadonly overallStanding?: number;\n}\n\nfunction sectionKind(intro: readonly string[]): \"aa\" | \"dswe\" | \"fc\" | \"pub\" {\n\tconst heading = intro.find((line) => line.startsWith(\"## \")) ?? \"\";\n\tif (/DeepSWE/u.test(heading)) return \"dswe\";\n\tif (/FrontierCode/u.test(heading)) return \"fc\";\n\tif (/Published/u.test(heading)) return \"pub\";\n\treturn \"aa\";\n}\n\nconst cells = (line: string) =>\n\tline\n\t\t.split(\"|\")\n\t\t.slice(1, -1)\n\t\t.map((cell) => cell.trim());\n\nconst nameWords = (text: string) => new Set(text.match(/\\p{Lu}[\\p{L}]{2,}/gu) ?? []);\n\n/**\n * The parts of a published result's setting that apply to this row: a clause\n * naming other models (for example \"Fable values are Mythos\" on a GPT row) is a\n * footnote for them and is dropped.\n */\nfunction ownSetting(setting: string, rowModel: string, modelWords: ReadonlySet<string>): string {\n\tconst own = nameWords(rowModel);\n\treturn setting\n\t\t.split(\";\")\n\t\t.map((clause) => clause.trim())\n\t\t.filter((clause) => {\n\t\t\tconst named = [...nameWords(clause)].filter((word) => modelWords.has(word));\n\t\t\treturn named.length === 0 || named.some((word) => own.has(word));\n\t\t})\n\t\t.join(\", \");\n}\n\n/** Parenthetical measurement setting in an Artificial Analysis model name, for example \"Max Effort\". */\nfunction nameCondition(name: string | undefined): string | undefined {\n\tconst setting = /\\(([^)]+)\\)\\s*$/u.exec(name ?? \"\")?.[1];\n\treturn setting && /^(?:minimal|low|medium|high|xhigh|max)$/u.test(setting) ? `${setting} effort` : setting;\n}\n\ninterface Reading {\n\treadonly key: string;\n\treadonly value: number;\n\treadonly condition?: string;\n}\n\ninterface CatalogReadings {\n\t/** Readings of each catalog row, indexed by the row's `order`. */\n\treadonly rows: readonly (readonly Reading[])[];\n\t/** Per measurement, the best value of each catalog model. */\n\treadonly cohorts: ReadonlyMap<string, ReadonlyMap<string, number>>;\n}\n\nconst readingsByCatalog = new WeakMap<EvalsCatalog, CatalogReadings>();\n\n/** Every measured value in the catalog, read once per parsed catalog. */\nfunction catalogReadings(catalog: EvalsCatalog): CatalogReadings {\n\tconst cached = readingsByCatalog.get(catalog);\n\tif (cached) return cached;\n\tconst kinds = catalog.sections.map((section) => sectionKind(section.intro));\n\tconst headers = catalog.sections.map((section) =>\n\t\tcells(section.intro.find((line) => line.startsWith(\"| slug |\")) ?? \"\"),\n\t);\n\tconst modelColumn = headers.map((header) => header.indexOf(\"Model\"));\n\tconst modelWords = catalog.sections.map((_, section) => {\n\t\tconst words = new Set<string>();\n\t\tfor (const row of catalog.rows)\n\t\t\tif (row.section === section)\n\t\t\t\tfor (const word of nameWords(cells(row.line)[modelColumn[section]!] ?? \"\")) words.add(word);\n\t\treturn words;\n\t});\n\tconst rows = catalog.rows.map((row) => {\n\t\tconst header = headers[row.section]!;\n\t\tconst rowCells = cells(row.line);\n\t\tconst column = (name: string) => (header.includes(name) ? rowCells[header.indexOf(name)] : undefined);\n\t\tconst readings: Reading[] = [];\n\t\tconst read = (key: string, raw: string | undefined, condition: string | undefined) => {\n\t\t\tconst value = Number.parseFloat(raw ?? \"\");\n\t\t\tif (Number.isFinite(value)) readings.push({ key, value, ...(condition ? { condition } : {}) });\n\t\t};\n\t\tif (kinds[row.section] === \"pub\") {\n\t\t\tconst reporter = column(\"Source\");\n\t\t\tconst setting = ownSetting(column(\"Setting\") ?? \"\", column(\"Model\") ?? \"\", modelWords[row.section]!);\n\t\t\tconst condition = [setting, reporter ? `reported by ${reporter}` : undefined].filter(Boolean).join(\", \");\n\t\t\t// Each reporter's results form their own cohort: a vendor harness and an\n\t\t\t// official leaderboard are not ranked against each other.\n\t\t\tread(`pub:${column(\"Benchmark\")}@${reporter ?? \"\"}`, column(\"Score\"), condition);\n\t\t} else {\n\t\t\tconst effort = column(\"Effort\");\n\t\t\tconst condition = effort ? `${effort} effort` : nameCondition(column(\"Model\"));\n\t\t\tfor (const [index, name] of header.entries())\n\t\t\t\tif (index > 1 && name !== \"Effort\" && name !== \"Release date\")\n\t\t\t\t\tread(`${kinds[row.section]}:${name}`, rowCells[index], condition);\n\t\t}\n\t\treturn readings;\n\t});\n\tconst cohorts = new Map<string, Map<string, number>>();\n\tfor (const row of catalog.rows) {\n\t\tconst identity = catalogModelIdentity(row.tokens);\n\t\tfor (const { key, value } of rows[row.order]!) {\n\t\t\tconst cohort = cohorts.get(key) ?? new Map<string, number>();\n\t\t\tcohort.set(identity, Math.max(cohort.get(identity) ?? value, value));\n\t\t\tcohorts.set(key, cohort);\n\t\t}\n\t}\n\tconst readings = { rows, cohorts };\n\treadingsByCatalog.set(catalog, readings);\n\treturn readings;\n}\n\n/**\n * Best value per metric across every evals row describing the model, with the\n * conditions it was measured under, the catalog models those rows belong to,\n * and the model's newest release date.\n */\nfunction measure(\n\tcatalog: EvalsCatalog,\n\tmodel: string,\n): { values: Map<string, number>; conditions: Map<string, string>; identities: Set<string>; released?: string } {\n\tconst readings = catalogReadings(catalog);\n\tconst values = new Map<string, number>();\n\tconst conditions = new Map<string, string>();\n\tconst identities = new Set<string>();\n\tlet released: string | undefined;\n\tfor (const row of candidateEvidenceRows(catalog, model)) {\n\t\tidentities.add(catalogModelIdentity(row.tokens));\n\t\tfor (const { key, value, condition } of readings.rows[row.order]!) {\n\t\t\tif (value <= (values.get(key) ?? Number.NEGATIVE_INFINITY)) continue;\n\t\t\tvalues.set(key, value);\n\t\t\tif (condition) conditions.set(key, condition);\n\t\t\telse conditions.delete(key);\n\t\t}\n\t\tif (row.releaseDate && (!released || row.releaseDate > released)) released = row.releaseDate;\n\t}\n\treturn { values, conditions, identities, ...(released ? { released } : {}) };\n}\n\n/** Value keys measuring `metric`: the column itself, or one per reporter for published results. */\nconst cohortKeys = (values: ReadonlyMap<string, number>, metric: Metric) =>\n\t[...values.keys()].filter((key) => key === metric.key || key.startsWith(`${metric.key}@`));\n\nconst baseKey = (candidate: CandidateModel) => modelEvidenceTokens(candidate.fastRouteOf ?? candidate.model).join(\"-\");\n\nconst blended = (candidate: CandidateModel) => (3 * candidate.cost.input + candidate.cost.output) / 4;\n\n/**\n * Rank every eligible model for the task in code. Quality is the model's\n * standing among every benchmarked model in the catalog on the benchmarks for\n * this kind of work (overall intelligence when it has none), so it does not\n * depend on which other models are eligible. It is weighed against price by how\n * demanding the task is, with a small preference for newer releases.\n */\nexport function rankCandidates(\n\tcatalog: EvalsCatalog,\n\tcandidates: readonly CandidateModel[],\n\tneeds: ResolvedTaskNeeds,\n): RankedCandidate[] {\n\tconst { cohorts } = catalogReadings(catalog);\n\tconst measured = candidates.map((candidate) => ({\n\t\tcandidate,\n\t\tbase: baseKey(candidate),\n\t\t...measure(catalog, candidate.fastRouteOf ?? candidate.model),\n\t}));\n\tconst rankOf = (key: string, value: number, own: ReadonlySet<string>): number | undefined => {\n\t\tconst cohort = cohorts.get(key);\n\t\tif (cohort === undefined || cohort.size < MIN_RANKED_MODELS) return undefined;\n\t\tconst others = [...cohort].filter(([identity]) => !own.has(identity)).map(([, other]) => other);\n\t\treturn others.length ? others.filter((other) => other < value).length / others.length : undefined;\n\t};\n\tconst standingOf = (values: ReadonlyMap<string, number>, own: ReadonlySet<string>, metrics: readonly Metric[]) => {\n\t\tconst ranks = metrics\n\t\t\t.flatMap((metric) => cohortKeys(values, metric))\n\t\t\t.map((key) => rankOf(key, values.get(key)!, own))\n\t\t\t.filter((rank): rank is number => rank !== undefined);\n\t\treturn ranks.length ? ranks.reduce((a, b) => a + b, 0) / ranks.length : undefined;\n\t};\n\tconst logPrices = measured\n\t\t.map((entry) => blended(entry.candidate))\n\t\t.filter((price) => price > 0)\n\t\t.map(Math.log);\n\tconst [low, high] = [Math.min(...logPrices), Math.max(...logPrices)];\n\tconst newest = measured\n\t\t.map((entry) => entry.released ?? \"\")\n\t\t.sort()\n\t\t.at(-1);\n\tconst demand = taskDemand(needs);\n\tconst qualityWeight = 0.25 + 0.65 * demand;\n\tconst priceWeight = 0.65 - 0.65 * demand;\n\n\treturn measured\n\t\t.map(({ candidate, base, values, conditions, identities, released }) => {\n\t\t\tconst workStanding = standingOf(values, identities, WORK_METRICS[needs.work]);\n\t\t\tconst overallStanding = standingOf(values, identities, [OVERALL]);\n\t\t\tconst quality = workStanding ?? (overallStanding !== undefined ? 0.8 * overallStanding : 0.2);\n\t\t\tconst price = blended(candidate);\n\t\t\tconst cheapness = price > 0 && high > low ? 1 - (Math.log(price) - low) / (high - low) : 1;\n\t\t\tconst ageDays = released && newest ? (Date.parse(newest) - Date.parse(released)) / 86_400_000 : 365;\n\t\t\tconst recency = 1 - Math.min(1, ageDays / 365);\n\t\t\treturn {\n\t\t\t\t...candidate,\n\t\t\t\tbaseKey: base,\n\t\t\t\tscore:\n\t\t\t\t\tqualityWeight * quality +\n\t\t\t\t\tpriceWeight * cheapness +\n\t\t\t\t\t0.1 * recency +\n\t\t\t\t\t(needs.latencySensitive && candidate.fastRouteOf && candidate.fastRouteServiceTier !== \"ultrafast\"\n\t\t\t\t\t\t? FAST_ROUTE_BONUS\n\t\t\t\t\t\t: 0),\n\t\t\t\tvalues,\n\t\t\t\tconditions,\n\t\t\t\t...(released ? { released } : {}),\n\t\t\t\t...(workStanding !== undefined ? { workStanding } : {}),\n\t\t\t\t...(overallStanding !== undefined ? { overallStanding } : {}),\n\t\t\t};\n\t\t})\n\t\t.sort(\n\t\t\t(a, b) =>\n\t\t\t\tb.score - a.score ||\n\t\t\t\tNumber(a.fastRouteOf !== undefined) - Number(b.fastRouteOf !== undefined) ||\n\t\t\t\ta.model.localeCompare(b.model),\n\t\t);\n}\n\n/** The best `size` candidates with at most one per base model. */\nexport function distinctTop(ranked: readonly RankedCandidate[], size: number): RankedCandidate[] {\n\tconst seen = new Set<string>();\n\tconst top: RankedCandidate[] = [];\n\tfor (const candidate of ranked) {\n\t\tif (seen.has(candidate.baseKey)) continue;\n\t\tseen.add(candidate.baseKey);\n\t\ttop.push(candidate);\n\t\tif (top.length === size) break;\n\t}\n\treturn top;\n}\n\nfunction standingLabel(fraction: number): string {\n\tif (fraction >= 0.9) return \"top 10%\";\n\tif (fraction >= 0.75) return \"top quarter\";\n\tif (fraction >= 0.5) return \"above median\";\n\tif (fraction >= 0.25) return \"below median\";\n\treturn \"bottom quarter\";\n}\n\nconst money = (value: number) => `$${Number(value.toPrecision(3))}`;\n\n/**\n * One shortlisted option described with its own evidence, so the router compares\n * options directly: release date, price tier, image input, and results for this\n * kind of work and overall, with standings among catalog models measured on the same benchmark by the same source.\n */\nexport function describeOption(\n\toption: RankedCandidate,\n\tneeds: ResolvedTaskNeeds,\n\teligible: readonly RankedCandidate[],\n): string {\n\tconst prices = eligible.map(blended).sort((a, b) => a - b);\n\tconst position = prices.filter((other) => other < blended(option)).length / Math.max(1, prices.length - 1);\n\tconst tier = position < 1 / 3 ? \"low\" : position < 2 / 3 ? \"mid\" : \"high\";\n\tconst newest = eligible\n\t\t.map((candidate) => candidate.released ?? \"\")\n\t\t.sort()\n\t\t.at(-1);\n\tconst quote = (metrics: readonly Metric[], standing: number | undefined) => {\n\t\tconst present = metrics\n\t\t\t.map((metric) => {\n\t\t\t\tconst keys = cohortKeys(option.values, metric);\n\t\t\t\tconst best = keys.sort((a, b) => option.values.get(b)! - option.values.get(a)!)[0];\n\t\t\t\treturn best === undefined ? undefined : { metric, key: best };\n\t\t\t})\n\t\t\t.filter((entry) => entry !== undefined)\n\t\t\t.slice(0, 2);\n\t\tif (present.length === 0) return \"no published results\";\n\t\tconst results = present\n\t\t\t.map(({ metric, key }) => {\n\t\t\t\tconst condition = option.conditions.get(key);\n\t\t\t\treturn `${metric.label} ${option.values.get(key)}${metric.unit}${condition ? ` measured with ${condition}` : \"\"}`;\n\t\t\t})\n\t\t\t.join(\"; \");\n\t\treturn `${standing === undefined ? \"measured\" : `${standingLabel(standing)} of models with the same benchmark and source`} (${results})`;\n\t};\n\tlet released = \"unknown\";\n\tif (option.released) {\n\t\tconst months = newest ? Math.round((Date.parse(newest) - Date.parse(option.released)) / (30.44 * 86_400_000)) : 0;\n\t\treleased =\n\t\t\tmonths <= 1\n\t\t\t\t? `${option.released}, among the newest`\n\t\t\t\t: `${option.released}, ${months} months older than the newest`;\n\t}\n\tconst fastBase = option.fastRouteOf\n\t\t? eligible.find((candidate) => candidate.model === option.fastRouteOf)\n\t\t: undefined;\n\treturn JSON.stringify({\n\t\tmodel: option.name,\n\t\tid: option.model,\n\t\treleased,\n\t\tprice: `${tier}: ${money(option.cost.input)} / ${money(option.cost.output)} per million tokens`,\n\t\treads_images: option.input.includes(\"image\"),\n\t\t[needs.work]: quote(WORK_METRICS[needs.work], option.workStanding),\n\t\toverall: quote([OVERALL], option.overallStanding),\n\t\t...(option.fastRouteOf\n\t\t\t? {\n\t\t\t\t\troute:\n\t\t\t\t\t\toption.fastRouteServiceTier === \"ultrafast\"\n\t\t\t\t\t\t\t? `ultrafast request for ${fastBase?.name ?? option.fastRouteOf}; base-model evidence only, no separate latency or benchmark score; account access required`\n\t\t\t\t\t\t\t: `faster route of ${fastBase?.name ?? option.fastRouteOf} with the same results; ${option.fastRoutePriced ? \"the listed prices are its Fast rates\" : \"billed above the listed prices\"}`,\n\t\t\t\t}\n\t\t\t: {}),\n\t});\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-routing-evals.d.ts","sourceRoot":"","sources":["../../src/core/model-routing-evals.ts"],"names":[],"mappings":"AAEA,oEAAoE;AACpE,eAAO,MAAM,gCAAgC,QAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"model-routing-evals.d.ts","sourceRoot":"","sources":["../../src/core/model-routing-evals.ts"],"names":[],"mappings":"AAEA,oEAAoE;AACpE,eAAO,MAAM,gCAAgC,QAAS,CAAC;AA0CvD,kHAAkH;AAClH,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,CAexD;AAWD,iH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,QAAQ,SAA2B,GACjC,MAAM,CAeR;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAE9F"}
|
|
@@ -4,7 +4,6 @@ export const MODEL_SELECTION_EVALS_JSON_BYTES = 14_200;
|
|
|
4
4
|
const VENDOR_OR_REGION_PREFIX = /^(?:[a-z][a-z-]*\.)+/u;
|
|
5
5
|
const SNAPSHOT_TOKEN = /^\d{4}$/u;
|
|
6
6
|
const DEPLOYMENT_TOKENS = new Set([
|
|
7
|
-
"fast",
|
|
8
7
|
"highspeed",
|
|
9
8
|
"ultraspeed",
|
|
10
9
|
"lightning",
|
|
@@ -75,10 +74,10 @@ export function catalogModelIdentity(slug) {
|
|
|
75
74
|
}
|
|
76
75
|
/**
|
|
77
76
|
* The candidate's own tokens first, then the same model without trailing
|
|
78
|
-
* deployment, reasoning-mode or snapshot suffixes (`
|
|
79
|
-
* `
|
|
80
|
-
*
|
|
81
|
-
*
|
|
77
|
+
* deployment, reasoning-mode or snapshot suffixes (`grok-4.20-reasoning`,
|
|
78
|
+
* `qwen3.8-max-0902`). Fast is part of the owned identity, not a deployment
|
|
79
|
+
* alias: only explicit route metadata at the caller permits base-model reuse.
|
|
80
|
+
* A fallback applies only when the more specific form matched no row.
|
|
82
81
|
*/
|
|
83
82
|
function candidateForms(tokens) {
|
|
84
83
|
const forms = [[...tokens]];
|