@bastani/atomic 0.9.28-alpha.2 → 0.9.28-alpha.4
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 +50 -0
- package/dist/builtin/intercom/package.json +2 -2
- package/dist/builtin/mcp/native-client-licenses/NOTICE +2 -0
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +6 -0
- package/dist/builtin/subagents/package.json +3 -3
- package/dist/builtin/subagents/skills/agent-browser/SKILL.md +1 -1
- package/dist/builtin/subagents/skills/cua-driver/BROWSER.md +60 -39
- package/dist/builtin/subagents/skills/cua-driver/EMBEDDING.md +119 -36
- package/dist/builtin/subagents/skills/cua-driver/LINUX.md +225 -183
- package/dist/builtin/subagents/skills/cua-driver/MACOS.md +120 -89
- package/dist/builtin/subagents/skills/cua-driver/README.md +16 -7
- package/dist/builtin/subagents/skills/cua-driver/RECORDING.md +85 -115
- package/dist/builtin/subagents/skills/cua-driver/RUNTIME.md +113 -0
- package/dist/builtin/subagents/skills/cua-driver/SKILL.md +55 -1071
- package/dist/builtin/subagents/skills/cua-driver/VISUAL.md +125 -0
- package/dist/builtin/subagents/skills/cua-driver/WINDOWS.md +145 -185
- package/dist/builtin/subagents/skills/cua-driver/WORKFLOW.md +173 -0
- package/dist/builtin/web-access/package.json +2 -2
- package/dist/builtin/workflows/CHANGELOG.md +21 -0
- package/dist/builtin/workflows/README.md +1 -1
- package/dist/builtin/workflows/package.json +2 -2
- package/dist/builtin/workflows/skills/impeccable/SKILL.md +8 -2
- package/dist/builtin/workflows/skills/impeccable/reference/adapt.md +6 -0
- package/dist/builtin/workflows/skills/impeccable/reference/audit.md +2 -1
- package/dist/builtin/workflows/skills/impeccable/reference/component-review.md +63 -0
- package/dist/builtin/workflows/skills/impeccable/reference/degraded/asset-producer.md +5 -0
- package/dist/builtin/workflows/skills/impeccable/reference/degraded/finish-reviewer.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/generate.md +101 -0
- package/dist/builtin/workflows/skills/impeccable/reference/harden.md +9 -0
- package/dist/builtin/workflows/skills/impeccable/reference/hooks.md +3 -1
- package/dist/builtin/workflows/skills/impeccable/reference/mode-operate.md +21 -0
- package/dist/builtin/workflows/skills/impeccable/reference/mode-persuade.md +19 -0
- package/dist/builtin/workflows/skills/impeccable/reference/mode-read.md +21 -0
- package/dist/builtin/workflows/skills/impeccable/reference/new-work.md +19 -12
- package/dist/builtin/workflows/skills/impeccable/reference/region-map.md +26 -0
- package/dist/builtin/workflows/skills/impeccable/reference/routing.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/visualize.md +5 -5
- package/dist/builtin/workflows/skills/impeccable/scripts/VERSION +1 -1
- package/dist/builtin/workflows/skills/impeccable/scripts/command-metadata.json +4 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/impeccable.cmd +2 -2
- package/dist/builtin/workflows/skills/impeccable/scripts/live-browser-session.js +5 -1
- package/dist/builtin/workflows/skills/impeccable/scripts/live-browser.js +524 -4
- package/dist/builtin/workflows/skills/prompt-engineer/SKILL.md +1 -0
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_haiku_5_5.md +81 -0
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +14733 -14704
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +8 -1
- package/dist/cli/args.js.map +1 -1
- package/dist/codemode-worker.js +2 -2
- package/dist/config.d.ts +2 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +4 -2
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session-compaction.d.ts +3 -3
- package/dist/core/agent-session-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-compaction.js +5 -1
- package/dist/core/agent-session-compaction.js.map +1 -1
- package/dist/core/agent-session-events.d.ts.map +1 -1
- package/dist/core/agent-session-events.js +1 -0
- package/dist/core/agent-session-events.js.map +1 -1
- package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
- package/dist/core/agent-session-extension-bindings.js +7 -2
- package/dist/core/agent-session-extension-bindings.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +7 -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-prompt.d.ts.map +1 -1
- package/dist/core/agent-session-prompt.js +3 -2
- package/dist/core/agent-session-prompt.js.map +1 -1
- package/dist/core/agent-session-tool-registry.js.map +1 -1
- package/dist/core/agent-session-types.d.ts +2 -0
- package/dist/core/agent-session-types.d.ts.map +1 -1
- package/dist/core/agent-session-types.js.map +1 -1
- package/dist/core/agent-session.d.ts +2 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +6 -1
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/bash-executor.d.ts.map +1 -1
- package/dist/core/bash-executor.js +22 -4
- package/dist/core/bash-executor.js.map +1 -1
- package/dist/core/child-session-options.d.ts.map +1 -1
- package/dist/core/child-session-options.js +17 -2
- package/dist/core/child-session-options.js.map +1 -1
- package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
- package/dist/core/export-html/tool-renderer.js +2 -0
- package/dist/core/export-html/tool-renderer.js.map +1 -1
- package/dist/core/extensions/agent-events.d.ts +2 -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/context-types.d.ts +2 -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/loader-virtual-modules.d.ts +3 -4
- package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.js +14 -9
- package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
- package/dist/core/extensions/mcp-server-registry.d.ts +4 -1
- package/dist/core/extensions/mcp-server-registry.d.ts.map +1 -1
- package/dist/core/extensions/mcp-server-registry.js +7 -4
- package/dist/core/extensions/mcp-server-registry.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +3 -0
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +19 -0
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/tool-events.d.ts +1 -1
- package/dist/core/extensions/tool-events.js.map +1 -1
- package/dist/core/extensions/tool-types.d.ts +2 -0
- 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/ts-source-specifiers.d.ts +18 -0
- package/dist/core/extensions/ts-source-specifiers.d.ts.map +1 -0
- package/dist/core/extensions/ts-source-specifiers.js +142 -0
- package/dist/core/extensions/ts-source-specifiers.js.map +1 -0
- package/dist/core/fast-model-variants.d.ts.map +1 -1
- package/dist/core/fast-model-variants.js +3 -2
- package/dist/core/fast-model-variants.js.map +1 -1
- package/dist/core/model-resolver-defaults.d.ts.map +1 -1
- package/dist/core/model-resolver-defaults.js +2 -0
- package/dist/core/model-resolver-defaults.js.map +1 -1
- package/dist/core/nested-tool-calls.d.ts +1 -0
- package/dist/core/nested-tool-calls.d.ts.map +1 -1
- package/dist/core/nested-tool-calls.js +1 -0
- package/dist/core/nested-tool-calls.js.map +1 -1
- package/dist/core/sdk-exports.d.ts +2 -2
- package/dist/core/sdk-exports.js.map +1 -1
- package/dist/core/sdk-types.d.ts +3 -0
- package/dist/core/sdk-types.d.ts.map +1 -1
- package/dist/core/sdk-types.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +17 -8
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/settings-manager-basic-accessors.js.map +1 -1
- package/dist/core/settings-manager-core.js.map +1 -1
- package/dist/core/settings-merge.d.ts +3 -0
- package/dist/core/settings-merge.d.ts.map +1 -1
- package/dist/core/settings-merge.js +18 -4
- package/dist/core/settings-merge.js.map +1 -1
- package/dist/core/settings-storage.js.map +1 -1
- package/dist/core/settings-types.js.map +1 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +7 -3
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit.js +1 -1
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/extensions/codemode/execute.d.ts.map +1 -1
- package/dist/extensions/codemode/execute.js +69 -8
- package/dist/extensions/codemode/execute.js.map +1 -1
- package/dist/extensions/codemode/index.d.ts.map +1 -1
- package/dist/extensions/codemode/index.js +7 -0
- package/dist/extensions/codemode/index.js.map +1 -1
- package/dist/extensions/codemode/tool.d.ts +2 -0
- package/dist/extensions/codemode/tool.d.ts.map +1 -1
- package/dist/extensions/codemode/tool.js +4 -2
- package/dist/extensions/codemode/tool.js.map +1 -1
- package/dist/extensions/llama/provider.d.ts.map +1 -1
- package/dist/extensions/llama/provider.js +19 -8
- package/dist/extensions/llama/provider.js.map +1 -1
- package/dist/extensions/mcp/cli.js +18 -24
- package/dist/extensions/mcp/cli.js.map +1 -1
- package/dist/extensions/mcp/client/auth-provider.d.ts +4 -0
- package/dist/extensions/mcp/client/auth-provider.d.ts.map +1 -1
- package/dist/extensions/mcp/client/auth-provider.js.map +1 -1
- package/dist/extensions/mcp/client/oauth/discovery.d.ts +3 -0
- package/dist/extensions/mcp/client/oauth/discovery.d.ts.map +1 -1
- package/dist/extensions/mcp/client/oauth/discovery.js +8 -5
- package/dist/extensions/mcp/client/oauth/discovery.js.map +1 -1
- package/dist/extensions/mcp/client/oauth/flow.d.ts +4 -0
- package/dist/extensions/mcp/client/oauth/flow.d.ts.map +1 -1
- package/dist/extensions/mcp/client/oauth/flow.js +12 -2
- package/dist/extensions/mcp/client/oauth/flow.js.map +1 -1
- package/dist/extensions/mcp/client/transports/streamable-http.d.ts +3 -0
- package/dist/extensions/mcp/client/transports/streamable-http.d.ts.map +1 -1
- package/dist/extensions/mcp/client/transports/streamable-http.js +17 -14
- package/dist/extensions/mcp/client/transports/streamable-http.js.map +1 -1
- package/dist/extensions/mcp/index.d.ts.map +1 -1
- package/dist/extensions/mcp/index.js +150 -72
- package/dist/extensions/mcp/index.js.map +1 -1
- package/dist/extensions/mcp/oauth.d.ts +5 -3
- package/dist/extensions/mcp/oauth.d.ts.map +1 -1
- package/dist/extensions/mcp/oauth.js +36 -10
- package/dist/extensions/mcp/oauth.js.map +1 -1
- package/dist/extensions/mcp/ui.d.ts +3 -3
- package/dist/extensions/mcp/ui.d.ts.map +1 -1
- package/dist/extensions/mcp/ui.js +10 -2
- package/dist/extensions/mcp/ui.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/main-deferred-startup.d.ts +1 -0
- package/dist/main-deferred-startup.d.ts.map +1 -1
- package/dist/main-deferred-startup.js +9 -21
- package/dist/main-deferred-startup.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +8 -6
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/bash-execution.d.ts +5 -1
- package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/bash-execution.js +17 -14
- package/dist/modes/interactive/components/bash-execution.js.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts +2 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.js +5 -2
- package/dist/modes/interactive/components/branch-summary-message.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 +19 -8
- package/dist/modes/interactive/components/chat-message-renderer.js.map +1 -1
- package/dist/modes/interactive/components/compaction-boundary-message.d.ts +3 -2
- package/dist/modes/interactive/components/compaction-boundary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/compaction-boundary-message.js +7 -4
- package/dist/modes/interactive/components/compaction-boundary-message.js.map +1 -1
- package/dist/modes/interactive/components/custom-entry.d.ts +3 -1
- package/dist/modes/interactive/components/custom-entry.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-entry.js +8 -2
- package/dist/modes/interactive/components/custom-entry.js.map +1 -1
- package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-message.js +1 -0
- package/dist/modes/interactive/components/custom-message.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-items.js +1 -1
- package/dist/modes/interactive/components/settings-selector-items.js.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts +2 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.js +5 -2
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +4 -0
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +10 -0
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/interactive-agent-events.js +3 -1
- package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
- package/dist/modes/interactive/interactive-auth-login.js +6 -0
- package/dist/modes/interactive/interactive-auth-login.js.map +1 -1
- package/dist/modes/interactive/interactive-bash-compact.js +2 -2
- package/dist/modes/interactive/interactive-bash-compact.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-dialogs.js +11 -2
- package/dist/modes/interactive/interactive-extension-dialogs.js.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.js +1 -47
- package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.d.ts +3 -1
- package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.js +6 -1
- package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.d.ts +2 -2
- package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
- package/dist/modes/interactive/interactive-prompt-restore.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-prompt-restore.js +0 -5
- package/dist/modes/interactive/interactive-prompt-restore.js.map +1 -1
- package/dist/modes/interactive/interactive-render-chat.js +7 -10
- package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
- package/dist/modes/interactive/interactive-selectors.js +8 -1
- 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.js +1 -0
- package/dist/modes/interactive/interactive-startup.js.map +1 -1
- package/dist/modes/interactive/program-status-reporter.d.ts +24 -0
- package/dist/modes/interactive/program-status-reporter.d.ts.map +1 -0
- package/dist/modes/interactive/program-status-reporter.js +96 -0
- package/dist/modes/interactive/program-status-reporter.js.map +1 -0
- package/dist/modes/interactive-engine/engine-custom-ui.d.ts.map +1 -1
- package/dist/modes/interactive-engine/engine-custom-ui.js +1 -0
- package/dist/modes/interactive-engine/engine-custom-ui.js.map +1 -1
- package/dist/modes/interactive-engine/engine-render-service.d.ts.map +1 -1
- package/dist/modes/interactive-engine/engine-render-service.js +3 -1
- package/dist/modes/interactive-engine/engine-render-service.js.map +1 -1
- package/dist/modes/interactive-engine/protocol.d.ts +1 -0
- package/dist/modes/interactive-engine/protocol.d.ts.map +1 -1
- package/dist/modes/interactive-engine/protocol.js +1 -0
- package/dist/modes/interactive-engine/protocol.js.map +1 -1
- package/dist/modes/interactive-engine/remote-renderer.d.ts +3 -0
- package/dist/modes/interactive-engine/remote-renderer.d.ts.map +1 -1
- package/dist/modes/interactive-engine/remote-renderer.js +7 -0
- package/dist/modes/interactive-engine/remote-renderer.js.map +1 -1
- package/dist/modes/rpc/rpc-client-process.d.ts +7 -0
- package/dist/modes/rpc/rpc-client-process.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client-process.js +20 -3
- package/dist/modes/rpc/rpc-client-process.js.map +1 -1
- package/dist/modes/rpc/rpc-command-timeouts.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-command-timeouts.js +1 -0
- package/dist/modes/rpc/rpc-command-timeouts.js.map +1 -1
- package/dist/utils/ansi.d.ts +8 -0
- package/dist/utils/ansi.d.ts.map +1 -1
- package/dist/utils/ansi.js +29 -10
- package/dist/utils/ansi.js.map +1 -1
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js +13 -3
- package/dist/utils/clipboard.js.map +1 -1
- package/dist/utils/image-resize-core.d.ts +8 -0
- package/dist/utils/image-resize-core.d.ts.map +1 -1
- package/dist/utils/image-resize-core.js +1 -0
- package/dist/utils/image-resize-core.js.map +1 -1
- package/dist/utils/image-resize-worker.js +3 -2
- package/dist/utils/image-resize-worker.js.map +1 -1
- package/dist/utils/image-resize.d.ts +2 -2
- package/dist/utils/image-resize.d.ts.map +1 -1
- package/dist/utils/image-resize.js +7 -10
- package/dist/utils/image-resize.js.map +1 -1
- package/docs/codemode.md +30 -6
- package/docs/compaction.md +1 -1
- package/docs/computer-use.md +9 -9
- package/docs/custom-provider/streaming.md +4 -0
- package/docs/environment-variables.md +2 -0
- package/docs/extensions/api-reference.md +1 -1
- package/docs/extensions/authoring.md +2 -0
- package/docs/extensions/events.md +5 -1
- package/docs/getting-started/first-session.md +1 -1
- package/docs/json.md +6 -1
- package/docs/llama-cpp.md +9 -2
- package/docs/mcp-servers.md +3 -3
- package/docs/models/evals.md +34 -3
- package/docs/models.md +10 -0
- package/docs/providers.md +35 -4
- package/docs/reference/cli.md +2 -2
- package/docs/sdk/reference.md +3 -3
- package/docs/sdk.md +7 -1
- package/docs/settings.md +3 -3
- package/docs/skills.md +1 -1
- package/docs/terminal-setup.md +14 -0
- package/docs/tools.md +1 -1
- package/docs/workflows/authoring.md +3 -3
- package/docs/workflows/operations.md +2 -2
- package/examples/extensions/sandbox/package-lock.json +3 -3
- package/npm-shrinkwrap.json +67 -67
- package/package.json +8 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-types.d.ts","sourceRoot":"","sources":["../../../src/core/extensions/tool-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACjH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wCAAwC,CAAC;AACpE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAEpE,YAAY,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAEzF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE/D,yCAAyC;AACzC,MAAM,WAAW,uBAAuB;IACvC,0CAA0C;IAC1C,QAAQ,EAAE,OAAO,CAAC;IAClB,iDAAiD;IACjD,SAAS,EAAE,OAAO,CAAC;CACnB;AAED,wCAAwC;AACxC,MAAM,WAAW,iBAAiB,CAAC,MAAM,GAAG,OAAO,EAAE,KAAK,GAAG,OAAO;IACnE,6FAA6F;IAC7F,IAAI,EAAE,KAAK,CAAC;IACZ,mGAAmG;IACnG,UAAU,EAAE,MAAM,CAAC;IACnB,gEAAgE;IAChE,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,kEAAkE;IAClE,aAAa,EAAE,SAAS,GAAG,SAAS,CAAC;IACrC,iFAAiF;IACjF,KAAK,EAAE,MAAM,CAAC;IACd,iDAAiD;IACjD,GAAG,EAAE,MAAM,CAAC;IACZ,8C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EAAE,MAAM,CAAC,CAAC;IAE7C,+CAA+C;IAC/C,YAAY,CAAC,EAAE,gBAAgB,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;CAC3D;AAED,KAAK,iBAAiB,GAAG,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;AAEnE,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,iBAAiB,EAAE,aAAa,GAAG,YAAY,GAAG,cAAc,CAAC,CAAC;AAEnG,oGAAoG;AACpG,MAAM,MAAM,oBAAoB,GAAG,CAClC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,aAAa,GAAG,SAAS,KACjC,aAAa,GAAG,SAAS,CAAC;AAE/B;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,OAAO,SAAS,OAAO,EAAE,QAAQ,GAAG,OAAO,EAAE,MAAM,GAAG,OAAO,EACvF,IAAI,EAAE,cAAc,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,GAC7C,cAAc,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG,iBAAiB,CAE/D;AAED,8DAA8D;AAC9D,YAAY,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAEvE,0FAA0F;AAC1F,MAAM,MAAM,QAAQ,GAAG,IAAI,CAC1B,cAAc,EACZ,MAAM,GACN,aAAa,GACb,YAAY,GACZ,qBAAqB,GACrB,kBAAkB,GAClB,UAAU,GACV,WAAW,GACX,aAAa,CACf,GAAG;IACH,UAAU,EAAE,UAAU,CAAC;CACvB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-types.js","sourceRoot":"","sources":["../../../src/core/extensions/tool-types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tool-types.js","sourceRoot":"","sources":["../../../src/core/extensions/tool-types.ts"],"names":[],"mappings":"AA6KA;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CACzB,IAA+C;IAE/C,OAAO,IAAqE,CAAC;AAC9E,CAAC","sourcesContent":["import type { ConstrainedSamplingConfig } from \"@bastani/pi-ai/compat\";\nimport type { AgentToolResult, AgentToolUpdateCallback, ToolExecutionMode } from \"@earendil-works/pi-agent-core\";\nimport type { Component } from \"@earendil-works/pi-tui\";\nimport type { Static, TSchema } from \"typebox\";\nimport type { Theme } from \"../../modes/interactive/theme/theme.js\";\nimport type { SourceInfo } from \"../source-info.ts\";\nimport type { ToolConcurrency } from \"../tools/tool-concurrency.ts\";\n\nexport type { ToolConcurrency, ToolConcurrencyMode } from \"../tools/tool-concurrency.ts\";\n\nimport type { ExtensionToolContext } from \"./context-types.ts\";\n\n/** Rendering options for tool results */\nexport interface ToolRenderResultOptions {\n\t/** Whether the result view is expanded */\n\texpanded: boolean;\n\t/** Whether this is a partial/streaming result */\n\tisPartial: boolean;\n}\n\n/** Context passed to tool renderers. */\nexport interface ToolRenderContext<TState = unknown, TArgs = unknown> {\n\t/** Current tool call arguments. Shared across call/result renders for the same tool call. */\n\targs: TArgs;\n\t/** Unique id for this tool execution. Stable across call/result renders for the same tool call. */\n\ttoolCallId: string;\n\t/** Invalidate just this tool execution component for redraw. */\n\tinvalidate: () => void;\n\t/** Previously returned component for this render slot, if any. */\n\tlastComponent: Component | undefined;\n\t/** Shared renderer state for this tool row. Initialized by tool-execution.ts. */\n\tstate: TState;\n\t/** Working directory for this tool execution. */\n\tcwd: string;\n\t/** Whether the tool execution has started. */\n\texecutionStarted: boolean;\n\t/** Whether the tool call arguments are complete. */\n\targsComplete: boolean;\n\t/** Whether the tool result is partial/streaming. */\n\tisPartial: boolean;\n\t/** Whether the result view is expanded. */\n\texpanded: boolean;\n\t/** Whether inline images are currently shown in the TUI. */\n\tshowImages: boolean;\n\t/** Whether the current result is an error. */\n\tisError: boolean;\n\tdurationMs: number | undefined;\n\toutputPad: number;\n}\n\ntype ToolRenderCall<TParams extends TSchema, TState> = {\n\tbivarianceHack(args: Static<TParams>, theme: Theme, context: ToolRenderContext<TState, Static<TParams>>): Component;\n}[\"bivarianceHack\"];\n\ntype ToolRenderResult<TParams extends TSchema, TDetails, TState> = {\n\tbivarianceHack(\n\t\tresult: AgentToolResult<TDetails>,\n\t\toptions: ToolRenderResultOptions,\n\t\ttheme: Theme,\n\t\tcontext: ToolRenderContext<TState, Static<TParams>>,\n\t): Component;\n}[\"bivarianceHack\"];\n\n/** How the model reaches a registered tool. */\nexport type ToolExposure = \"direct\" | \"model-only\" | \"codemode\" | \"deferred\" | \"hidden\";\n\nexport interface ToolAnnotations {\n\treadOnlyHint?: boolean;\n\tdestructiveHint?: boolean;\n\tidempotentHint?: boolean;\n\topenWorldHint?: boolean;\n}\n\nexport interface ToolNamespace {\n\tname: string;\n\tdescription?: string;\n\tinstructions?: string;\n}\n\nexport interface ToolLoadout {\n\treadonly declared: readonly import(\"@earendil-works/pi-agent-core\").AgentTool[];\n\treadonly callable: readonly import(\"@earendil-works/pi-agent-core\").AgentTool[];\n\treadonly registered: readonly import(\"@earendil-works/pi-agent-core\").AgentTool[];\n\tgetExposure(name: string): ToolExposure;\n\tgetNamespace(name: string): ToolNamespace | undefined;\n\t/** A tool's prompt guidelines, omitted from system prompt rules when its declaration is hidden. */\n\tgetPromptGuidelines(name: string): readonly string[];\n}\n\nexport interface ToolLoadoutChanges {\n\tdescriptions?: Readonly<Record<string, string>>;\n\thiddenDeclarations?: readonly string[];\n}\n\n/**\n * Tool definition for registerTool().\n */\nexport interface ToolDefinition<TParams extends TSchema = TSchema, TDetails = unknown, TState = unknown> {\n\t/** Tool name (used in LLM tool calls) */\n\tname: string;\n\t/** Human-readable label for UI */\n\tlabel: string;\n\t/** Description for LLM */\n\tdescription: string;\n\t/** Optional one-line snippet for the Available tools section in the default system prompt. Custom tools are omitted from that section when this is not provided. */\n\tpromptSnippet?: string;\n\t/** Optional guideline bullets appended to the default system prompt Guidelines section when this tool is active. */\n\tpromptGuidelines?: string[];\n\t/** Parameter schema (TypeBox) */\n\tparameters: TParams;\n\t/** Optional provider-side constrained sampling request. `false` explicitly disables it. */\n\tconstrainedSampling?: false | ConstrainedSamplingConfig;\n\t/** Optional per-tool character cap for model-visible result persistence. Use Infinity to opt out for self-bounded tools. */\n\tmaxResultSizeChars?: number;\n\t/** Marks a terminating tool created by createStructuredOutputTool() so print mode can emit custom-named final JSON without treating every terminating tool as printable. */\n\tstructuredOutput?: true;\n\t/** Controls whether ToolExecutionComponent renders the standard colored shell or the tool renders its own framing. */\n\trenderShell?: \"default\" | \"self\";\n\n\t/** Optional compatibility shim to prepare raw tool call arguments before schema validation. Must return an object conforming to TParams. */\n\tprepareArguments?: (args: unknown) => Static<TParams>;\n\t/** Schema of successful machine-readable results. */\n\toutputSchema?: TSchema;\n\t/** Direct and model-only tools activate by default; other exposures do not. */\n\texposure?: ToolExposure;\n\tnamespace?: ToolNamespace;\n\tannotations?: ToolAnnotations;\n\tdefaultActive?: boolean;\n\tprepareLoadout?: (loadout: ToolLoadout) => ToolLoadoutChanges | undefined;\n\n\t/**\n\t * Per-tool execution mode override.\n\t * - \"sequential\": this tool must execute one at a time with other tool calls.\n\t * - \"parallel\": this tool can execute concurrently with other tool calls.\n\t *\n\t * If omitted, the default execution mode applies.\n\t */\n\texecutionMode?: ToolExecutionMode;\n\n\t/**\n\t * Ordering against the other calls of the same assistant message.\n\t * - \"shared\": may overlap other shared calls, but starts after the latest earlier exclusive call (default)\n\t * - \"exclusive\": starts after every earlier call finishes; later calls start after it finishes\n\t * - function: resolved per call from its arguments; a throwing resolver means \"exclusive\"\n\t */\n\tconcurrency?: ToolConcurrency<Static<TParams>>;\n\n\t/** Execute the tool. */\n\texecute(\n\t\ttoolCallId: string,\n\t\tparams: Static<TParams>,\n\t\tsignal: AbortSignal | undefined,\n\t\tonUpdate: AgentToolUpdateCallback<TDetails> | undefined,\n\t\tctx: ExtensionToolContext,\n\t): Promise<AgentToolResult<TDetails>>;\n\n\t/** Custom rendering for tool call display */\n\trenderCall?: ToolRenderCall<TParams, TState>;\n\n\t/** Custom rendering for tool result display */\n\trenderResult?: ToolRenderResult<TParams, TDetails, TState>;\n}\n\ntype AnyToolDefinition = ToolDefinition<TSchema, unknown, unknown>;\n\nexport type ToolRenderers = Pick<AnyToolDefinition, \"renderShell\" | \"renderCall\" | \"renderResult\">;\n\n/** Chooses renderers for any tool. `next()` resolves later extensions, then the registered tool. */\nexport type ToolRendererResolver = (\n\ttoolName: string,\n\tnext: () => ToolRenderers | undefined,\n) => ToolRenderers | undefined;\n\n/**\n * Preserve parameter inference for standalone tool definitions.\n *\n * Use this when assigning a tool to a variable or passing it through arrays such\n * as `customTools`, where contextual typing would otherwise widen params to\n * `unknown`.\n */\nexport function defineTool<TParams extends TSchema, TDetails = unknown, TState = unknown>(\n\ttool: ToolDefinition<TParams, TDetails, TState>,\n): ToolDefinition<TParams, TDetails, TState> & AnyToolDefinition {\n\treturn tool as ToolDefinition<TParams, TDetails, TState> & AnyToolDefinition;\n}\n\n/** Public constrained-sampling shape inherited from pi-ai. */\nexport type { ConstrainedSamplingConfig } from \"@bastani/pi-ai/compat\";\n\n/** Tool info with name, description, parameter schema, constraint, and source metadata */\nexport type ToolInfo = Pick<\n\tToolDefinition,\n\t| \"name\"\n\t| \"description\"\n\t| \"parameters\"\n\t| \"constrainedSampling\"\n\t| \"promptGuidelines\"\n\t| \"exposure\"\n\t| \"namespace\"\n\t| \"annotations\"\n> & {\n\tsourceInfo: SourceInfo;\n};\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { createJiti } from "jiti";
|
|
2
|
+
type CreateJiti = typeof createJiti;
|
|
3
|
+
type JitiTransform = NonNullable<NonNullable<Parameters<CreateJiti>[1]>["transform"]>;
|
|
4
|
+
/**
|
|
5
|
+
* jiti tries a `./x.js` import of `x.ts` against every resolution condition,
|
|
6
|
+
* base URL, and extension before its `.js` -> `.ts` fallback, and each miss
|
|
7
|
+
* throws. Naming the TypeScript source that fallback would select resolves it
|
|
8
|
+
* on the first probe.
|
|
9
|
+
*/
|
|
10
|
+
export declare function typeScriptSourceSpecifier(specifier: string, importer: string): string | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* A jiti `transform` that runs jiti's own Babel transform plus the specifier
|
|
13
|
+
* rewrite. Use it with jiti's `fsCache: false`: jiti keys its cache on the
|
|
14
|
+
* importer source alone, while a rewrite also depends on which siblings exist.
|
|
15
|
+
*/
|
|
16
|
+
export declare function createTypeScriptSourceSpecifierTransform(createJitiImpl: CreateJiti, id: string, cacheDir: () => string | undefined): JitiTransform;
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=ts-source-specifiers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ts-source-specifiers.d.ts","sourceRoot":"","sources":["../../../src/core/extensions/ts-source-specifiers.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAEvC,KAAK,UAAU,GAAG,OAAO,UAAU,CAAC;AACpC,KAAK,aAAa,GAAG,WAAW,CAAC,WAAW,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC;AAatF;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAQjG;AA0GD;;;;GAIG;AACH,wBAAgB,wCAAwC,CACvD,cAAc,EAAE,UAAU,EAC1B,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,MAAM,MAAM,GAAG,SAAS,GAChC,aAAa,CAmBf"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import * as crypto from "node:crypto";
|
|
2
|
+
import * as fs from "node:fs";
|
|
3
|
+
import * as path from "node:path";
|
|
4
|
+
const TRANSFORM_CACHE_FORMAT = 1;
|
|
5
|
+
const RELATIVE_SCRIPT_SPECIFIER = /["'](\.\.?\/[^"'\r\n]*?\.[cm]?jsx?)["']/g;
|
|
6
|
+
const SCRIPT_EXTENSION = /\.[cm]?jsx?$/;
|
|
7
|
+
const TYPESCRIPT_EXTENSION_FOR = {
|
|
8
|
+
".js": ".ts",
|
|
9
|
+
".mjs": ".mts",
|
|
10
|
+
".cjs": ".cts",
|
|
11
|
+
".jsx": ".tsx",
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* jiti tries a `./x.js` import of `x.ts` against every resolution condition,
|
|
15
|
+
* base URL, and extension before its `.js` -> `.ts` fallback, and each miss
|
|
16
|
+
* throws. Naming the TypeScript source that fallback would select resolves it
|
|
17
|
+
* on the first probe.
|
|
18
|
+
*/
|
|
19
|
+
export function typeScriptSourceSpecifier(specifier, importer) {
|
|
20
|
+
const scriptExtension = SCRIPT_EXTENSION.exec(specifier)?.[0];
|
|
21
|
+
if (!scriptExtension || !(specifier.startsWith("./") || specifier.startsWith("../")))
|
|
22
|
+
return undefined;
|
|
23
|
+
const typeScriptSpecifier = specifier.slice(0, -scriptExtension.length) + TYPESCRIPT_EXTENSION_FOR[scriptExtension];
|
|
24
|
+
const directory = path.dirname(importer);
|
|
25
|
+
if (fs.existsSync(path.resolve(directory, specifier)))
|
|
26
|
+
return undefined;
|
|
27
|
+
if (!fs.existsSync(path.resolve(directory, typeScriptSpecifier)))
|
|
28
|
+
return undefined;
|
|
29
|
+
return typeScriptSpecifier;
|
|
30
|
+
}
|
|
31
|
+
/** Every rewrite this source can receive; part of the cache key, so a sibling change re-transforms. */
|
|
32
|
+
function planRewrites(source, importer) {
|
|
33
|
+
const rewrites = new Map();
|
|
34
|
+
for (const [, specifier] of source.matchAll(RELATIVE_SCRIPT_SPECIFIER)) {
|
|
35
|
+
if (!specifier || rewrites.has(specifier))
|
|
36
|
+
continue;
|
|
37
|
+
const rewritten = typeScriptSourceSpecifier(specifier, importer);
|
|
38
|
+
if (rewritten !== undefined)
|
|
39
|
+
rewrites.set(specifier, rewritten);
|
|
40
|
+
}
|
|
41
|
+
return rewrites;
|
|
42
|
+
}
|
|
43
|
+
function rewriteSource(literal, rewrites) {
|
|
44
|
+
if (literal?.type !== "StringLiteral" || typeof literal.value !== "string")
|
|
45
|
+
return;
|
|
46
|
+
const rewritten = rewrites.get(literal.value);
|
|
47
|
+
if (rewritten === undefined)
|
|
48
|
+
return;
|
|
49
|
+
literal.value = rewritten;
|
|
50
|
+
literal.extra = undefined;
|
|
51
|
+
}
|
|
52
|
+
function isModuleLoadCall(nodePath) {
|
|
53
|
+
const callee = nodePath.node.callee;
|
|
54
|
+
if (callee?.type === "Import")
|
|
55
|
+
return true;
|
|
56
|
+
return callee?.type === "Identifier" && callee.name === "require" && !nodePath.scope.hasBinding("require");
|
|
57
|
+
}
|
|
58
|
+
function typeScriptSourceSpecifierPlugin(_babel, options) {
|
|
59
|
+
return {
|
|
60
|
+
name: "atomic-typescript-source-specifiers",
|
|
61
|
+
visitor: {
|
|
62
|
+
"ImportDeclaration|ExportNamedDeclaration|ExportAllDeclaration"(nodePath) {
|
|
63
|
+
rewriteSource(nodePath.node.source, options.rewrites);
|
|
64
|
+
},
|
|
65
|
+
ImportExpression(nodePath) {
|
|
66
|
+
rewriteSource(nodePath.node.source, options.rewrites);
|
|
67
|
+
},
|
|
68
|
+
CallExpression(nodePath) {
|
|
69
|
+
if (isModuleLoadCall(nodePath))
|
|
70
|
+
rewriteSource(nodePath.node.arguments?.[0], options.rewrites);
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function cacheFile(cacheDir, options, rewrites) {
|
|
76
|
+
const key = crypto
|
|
77
|
+
.createHash("sha256")
|
|
78
|
+
.update(JSON.stringify([
|
|
79
|
+
TRANSFORM_CACHE_FORMAT,
|
|
80
|
+
options.filename,
|
|
81
|
+
options.async,
|
|
82
|
+
options.ts,
|
|
83
|
+
options.jsx,
|
|
84
|
+
options.interopDefault,
|
|
85
|
+
options.retainLines,
|
|
86
|
+
options.babel?.sourceMaps,
|
|
87
|
+
[...rewrites],
|
|
88
|
+
options.source,
|
|
89
|
+
]))
|
|
90
|
+
.digest("hex")
|
|
91
|
+
.slice(0, 32);
|
|
92
|
+
const name = path.basename(options.filename ?? "module").replace(/[^\w.-]/g, "_");
|
|
93
|
+
return path.join(cacheDir, `${name}.${key}.${options.async ? "mjs" : "cjs"}`);
|
|
94
|
+
}
|
|
95
|
+
function readCached(file) {
|
|
96
|
+
try {
|
|
97
|
+
return fs.readFileSync(file, "utf8");
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
return undefined;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function writeCached(file, code) {
|
|
104
|
+
const temporary = `${file}.${process.pid}.${crypto.randomUUID()}.tmp`;
|
|
105
|
+
try {
|
|
106
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
107
|
+
fs.writeFileSync(temporary, code, "utf8");
|
|
108
|
+
fs.renameSync(temporary, file);
|
|
109
|
+
}
|
|
110
|
+
catch {
|
|
111
|
+
fs.rmSync(temporary, { force: true });
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* A jiti `transform` that runs jiti's own Babel transform plus the specifier
|
|
116
|
+
* rewrite. Use it with jiti's `fsCache: false`: jiti keys its cache on the
|
|
117
|
+
* importer source alone, while a rewrite also depends on which siblings exist.
|
|
118
|
+
*/
|
|
119
|
+
export function createTypeScriptSourceSpecifierTransform(createJitiImpl, id, cacheDir) {
|
|
120
|
+
const babelHost = createJitiImpl(id, { fsCache: false, moduleCache: false });
|
|
121
|
+
return (options) => {
|
|
122
|
+
if (!options.filename)
|
|
123
|
+
return { code: babelHost.transform(options) };
|
|
124
|
+
const rewrites = planRewrites(options.source, options.filename);
|
|
125
|
+
const directory = cacheDir();
|
|
126
|
+
const cached = directory ? cacheFile(directory, options, rewrites) : undefined;
|
|
127
|
+
const hit = cached ? readCached(cached) : undefined;
|
|
128
|
+
if (hit !== undefined)
|
|
129
|
+
return { code: hit };
|
|
130
|
+
const plugins = Array.isArray(options.babel?.plugins)
|
|
131
|
+
? options.babel.plugins
|
|
132
|
+
: [];
|
|
133
|
+
const code = babelHost.transform({
|
|
134
|
+
...options,
|
|
135
|
+
babel: { ...options.babel, plugins: [...plugins, [typeScriptSourceSpecifierPlugin, { rewrites }]] },
|
|
136
|
+
});
|
|
137
|
+
if (cached && !code.includes("__JITI_ERROR__"))
|
|
138
|
+
writeCached(cached, code);
|
|
139
|
+
return { code };
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
//# sourceMappingURL=ts-source-specifiers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ts-source-specifiers.js","sourceRoot":"","sources":["../../../src/core/extensions/ts-source-specifiers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAOlC,MAAM,sBAAsB,GAAG,CAAC,CAAC;AACjC,MAAM,yBAAyB,GAAG,0CAA0C,CAAC;AAC7E,MAAM,gBAAgB,GAAG,cAAc,CAAC;AACxC,MAAM,wBAAwB,GAAqC;IAClE,KAAK,EAAE,KAAK;IACZ,MAAM,EAAE,MAAM;IACd,MAAM,EAAE,MAAM;IACd,MAAM,EAAE,MAAM;CACd,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,yBAAyB,CAAC,SAAiB,EAAE,QAAgB;IAC5E,MAAM,eAAe,GAAG,gBAAgB,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC9D,IAAI,CAAC,eAAe,IAAI,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,SAAS,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QAAE,OAAO,SAAS,CAAC;IACvG,MAAM,mBAAmB,GAAG,SAAS,CAAC,KAA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AI,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAAC;YAAE,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAC1E,OAAO,EAAE,IAAI,EAAE,CAAC;IACjB,CAAC,CAAC;AACH,CAAC","sourcesContent":["import * as crypto from \"node:crypto\";\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport type { createJiti } from \"jiti\";\n\ntype CreateJiti = typeof createJiti;\ntype JitiTransform = NonNullable<NonNullable<Parameters<CreateJiti>[1]>[\"transform\"]>;\ntype JitiTransformOptions = Parameters<JitiTransform>[0];\n\nconst TRANSFORM_CACHE_FORMAT = 1;\nconst RELATIVE_SCRIPT_SPECIFIER = /[\"'](\\.\\.?\\/[^\"'\\r\\n]*?\\.[cm]?jsx?)[\"']/g;\nconst SCRIPT_EXTENSION = /\\.[cm]?jsx?$/;\nconst TYPESCRIPT_EXTENSION_FOR: Readonly<Record<string, string>> = {\n\t\".js\": \".ts\",\n\t\".mjs\": \".mts\",\n\t\".cjs\": \".cts\",\n\t\".jsx\": \".tsx\",\n};\n\n/**\n * jiti tries a `./x.js` import of `x.ts` against every resolution condition,\n * base URL, and extension before its `.js` -> `.ts` fallback, and each miss\n * throws. Naming the TypeScript source that fallback would select resolves it\n * on the first probe.\n */\nexport function typeScriptSourceSpecifier(specifier: string, importer: string): string | undefined {\n\tconst scriptExtension = SCRIPT_EXTENSION.exec(specifier)?.[0];\n\tif (!scriptExtension || !(specifier.startsWith(\"./\") || specifier.startsWith(\"../\"))) return undefined;\n\tconst typeScriptSpecifier = specifier.slice(0, -scriptExtension.length) + TYPESCRIPT_EXTENSION_FOR[scriptExtension];\n\tconst directory = path.dirname(importer);\n\tif (fs.existsSync(path.resolve(directory, specifier))) return undefined;\n\tif (!fs.existsSync(path.resolve(directory, typeScriptSpecifier))) return undefined;\n\treturn typeScriptSpecifier;\n}\n\n/** Every rewrite this source can receive; part of the cache key, so a sibling change re-transforms. */\nfunction planRewrites(source: string, importer: string): ReadonlyMap<string, string> {\n\tconst rewrites = new Map<string, string>();\n\tfor (const [, specifier] of source.matchAll(RELATIVE_SCRIPT_SPECIFIER)) {\n\t\tif (!specifier || rewrites.has(specifier)) continue;\n\t\tconst rewritten = typeScriptSourceSpecifier(specifier, importer);\n\t\tif (rewritten !== undefined) rewrites.set(specifier, rewritten);\n\t}\n\treturn rewrites;\n}\n\ninterface StringLiteralNode {\n\ttype: string;\n\tvalue?: string;\n\textra?: object;\n}\n\ninterface ModuleSourceNode {\n\tsource?: StringLiteralNode | null;\n}\n\ninterface CallNode {\n\tcallee?: { type: string; name?: string };\n\targuments?: StringLiteralNode[];\n}\n\ninterface NodePath<Node> {\n\tnode: Node;\n\tscope: { hasBinding(name: string): boolean };\n}\n\nfunction rewriteSource(literal: StringLiteralNode | null | undefined, rewrites: ReadonlyMap<string, string>): void {\n\tif (literal?.type !== \"StringLiteral\" || typeof literal.value !== \"string\") return;\n\tconst rewritten = rewrites.get(literal.value);\n\tif (rewritten === undefined) return;\n\tliteral.value = rewritten;\n\tliteral.extra = undefined;\n}\n\nfunction isModuleLoadCall(nodePath: NodePath<CallNode>): boolean {\n\tconst callee = nodePath.node.callee;\n\tif (callee?.type === \"Import\") return true;\n\treturn callee?.type === \"Identifier\" && callee.name === \"require\" && !nodePath.scope.hasBinding(\"require\");\n}\n\nfunction typeScriptSourceSpecifierPlugin(_babel: object, options: { rewrites: ReadonlyMap<string, string> }) {\n\treturn {\n\t\tname: \"atomic-typescript-source-specifiers\",\n\t\tvisitor: {\n\t\t\t\"ImportDeclaration|ExportNamedDeclaration|ExportAllDeclaration\"(nodePath: NodePath<ModuleSourceNode>) {\n\t\t\t\trewriteSource(nodePath.node.source, options.rewrites);\n\t\t\t},\n\t\t\tImportExpression(nodePath: NodePath<ModuleSourceNode>) {\n\t\t\t\trewriteSource(nodePath.node.source, options.rewrites);\n\t\t\t},\n\t\t\tCallExpression(nodePath: NodePath<CallNode>) {\n\t\t\t\tif (isModuleLoadCall(nodePath)) rewriteSource(nodePath.node.arguments?.[0], options.rewrites);\n\t\t\t},\n\t\t},\n\t};\n}\n\nfunction cacheFile(cacheDir: string, options: JitiTransformOptions, rewrites: ReadonlyMap<string, string>): string {\n\tconst key = crypto\n\t\t.createHash(\"sha256\")\n\t\t.update(\n\t\t\tJSON.stringify([\n\t\t\t\tTRANSFORM_CACHE_FORMAT,\n\t\t\t\toptions.filename,\n\t\t\t\toptions.async,\n\t\t\t\toptions.ts,\n\t\t\t\toptions.jsx,\n\t\t\t\toptions.interopDefault,\n\t\t\t\toptions.retainLines,\n\t\t\t\toptions.babel?.sourceMaps,\n\t\t\t\t[...rewrites],\n\t\t\t\toptions.source,\n\t\t\t]),\n\t\t)\n\t\t.digest(\"hex\")\n\t\t.slice(0, 32);\n\tconst name = path.basename(options.filename ?? \"module\").replace(/[^\\w.-]/g, \"_\");\n\treturn path.join(cacheDir, `${name}.${key}.${options.async ? \"mjs\" : \"cjs\"}`);\n}\n\nfunction readCached(file: string): string | undefined {\n\ttry {\n\t\treturn fs.readFileSync(file, \"utf8\");\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nfunction writeCached(file: string, code: string): void {\n\tconst temporary = `${file}.${process.pid}.${crypto.randomUUID()}.tmp`;\n\ttry {\n\t\tfs.mkdirSync(path.dirname(file), { recursive: true });\n\t\tfs.writeFileSync(temporary, code, \"utf8\");\n\t\tfs.renameSync(temporary, file);\n\t} catch {\n\t\tfs.rmSync(temporary, { force: true });\n\t}\n}\n\n/**\n * A jiti `transform` that runs jiti's own Babel transform plus the specifier\n * rewrite. Use it with jiti's `fsCache: false`: jiti keys its cache on the\n * importer source alone, while a rewrite also depends on which siblings exist.\n */\nexport function createTypeScriptSourceSpecifierTransform(\n\tcreateJitiImpl: CreateJiti,\n\tid: string,\n\tcacheDir: () => string | undefined,\n): JitiTransform {\n\tconst babelHost = createJitiImpl(id, { fsCache: false, moduleCache: false });\n\treturn (options: JitiTransformOptions) => {\n\t\tif (!options.filename) return { code: babelHost.transform(options) };\n\t\tconst rewrites = planRewrites(options.source, options.filename);\n\t\tconst directory = cacheDir();\n\t\tconst cached = directory ? cacheFile(directory, options, rewrites) : undefined;\n\t\tconst hit = cached ? readCached(cached) : undefined;\n\t\tif (hit !== undefined) return { code: hit };\n\t\tconst plugins: ReadonlyArray<string | object> = Array.isArray(options.babel?.plugins)\n\t\t\t? options.babel.plugins\n\t\t\t: [];\n\t\tconst code = babelHost.transform({\n\t\t\t...options,\n\t\t\tbabel: { ...options.babel, plugins: [...plugins, [typeScriptSourceSpecifierPlugin, { rewrites }]] },\n\t\t});\n\t\tif (cached && !code.includes(\"__JITI_ERROR__\")) writeCached(cached, code);\n\t\treturn { code };\n\t};\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fast-model-variants.d.ts","sourceRoot":"","sources":["../../src/core/fast-model-variants.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,GAAG,EACR,KAAK,UAAU,EAEf,KAAK,KAAK,EAEV,KAAK,QAAQ,EACb,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAGjE,oEAAoE;AACpE,eAAO,MAAM,oBAAoB,UAAU,CAAC;AAE5C,qEAAqE;AACrE,eAAO,MAAM,uBAAuB,EAAG,UAAmB,CAAC;AAE3D,wGAAwG;AACxG,eAAO,MAAM,yBAAyB,eAAe,CAAC;AACtD,eAAO,MAAM,4BAA4B,EAAG,WAAoB,CAAC;AAEjE,2EAA2E;AAC3E,eAAO,MAAM,gBAAgB,EAAG,MAAe,CAAC;AAEhD;;;;GAIG;AACH,eAAO,MAAM,6BAA6B,EAAE,WAAW,CAAC,MAAM,CAI5D,CAAC;AAEH,oGAAoG;AACpG,MAAM,WAAW,0BAA0B;IAC1C,QAAQ,EAAE,MAAM,CAAC;IACjB,mDAAmD;IACnD,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,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AU,CAAC,GAAG,OAAO,CAEjF;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,KAAK,GAAG,IAAI,GAAG,UAAU,CAAC,GAAG,OAAO,CAMjG;AAOD,yFAAyF;AACzF,wBAAgB,6BAA6B,CAAC,UAAU,EAAE,UAAU,GAAG,SAAS,GAAG,SAAS,MAAM,EAAE,GAAG,SAAS,CAG/G;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,UAAU,GAAG,SAAS,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAMrG;AA+BD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,uBAAuB,CACtC,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,SAAS,KAAK,CAAC,GAAG,CAAC,EAAE,EAC7B,OAAO,GAAE,8BAAmC,GAC1C,0BAA0B,CAkD5B;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,GAAE,wBAA6B,GAAG,QAAQ,CAgB1G"}
|
|
@@ -41,7 +41,8 @@ export function isNativeFastRouteApi(api) {
|
|
|
41
41
|
* because selecting it would send an ordinary request under a name that promises otherwise.
|
|
42
42
|
*/
|
|
43
43
|
export function usesOpenAIFastServiceTier(model) {
|
|
44
|
-
return isNativeFastRouteApi(model.api) &&
|
|
44
|
+
return (isNativeFastRouteApi(model.api) &&
|
|
45
|
+
(model.provider === "openai" || model.provider === "openai-api" || model.provider === "openai-codex"));
|
|
45
46
|
}
|
|
46
47
|
/**
|
|
47
48
|
* xAI Priority Processing keeps the base upstream Grok model ID and adds the same
|
|
@@ -68,7 +69,7 @@ export function isGitHubCopilotModel(model) {
|
|
|
68
69
|
*/
|
|
69
70
|
export function usesAnthropicFastMode(model) {
|
|
70
71
|
return (model.api === "anthropic-messages" &&
|
|
71
|
-
model.provider === "anthropic" &&
|
|
72
|
+
(model.provider === "anthropic" || model.provider === "anthropic-api") &&
|
|
72
73
|
ANTHROPIC_FAST_MODE_MODEL_IDS.has(model.id));
|
|
73
74
|
}
|
|
74
75
|
function advertisedModelIds(value) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fast-model-variants.js","sourceRoot":"","sources":["../../src/core/fast-model-variants.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,kBAAkB,GAIlB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAErE,oEAAoE;AACpE,MAAM,CAAC,MAAM,oBAAoB,GAAG,OAAO,CAAC;AAE5C,qEAAqE;AACrE,MAAM,CAAC,MAAM,uBAAuB,GAAG,UAAmB,CAAC;AAE3D,wGAAwG;AACxG,MAAM,CAAC,MAAM,yBAAyB,GAAG,YAAY,CAAC;AACtD,MAAM,CAAC,MAAM,4BAA4B,GAAG,WAAoB,CAAC;AAEjE,2EAA2E;AAC3E,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAe,CAAC;AAEhD;;;;GAIG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAwB,IAAI,GAAG,CAAC;IACzE,iBAAiB;IACjB,eAAe;IACf,iBAAiB;CACjB,CAAC,CAAC;AA6CH,oEAAoE;AACpE,MAAM,UAAU,WAAW,CAAC,WAAmB;IAC9C,OAAO,GAAG,WAAW,GAAG,oBAAoB,EAAE,CAAC;AAChD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,GAAQ;IAC5C,OAAO,GAAG,KAAK,kBAAkB,IAAI,GAAG,KAAK,wBAAwB,CAAC;AACvE,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,yBAAyB,CAAC,KAA2C;IACpF,OAAO,oBAAoB,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,KAAK,QAAQ,IAAI,KAAK,CAAC,QAAQ,KA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AAC,OAAO,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;IACzE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC;AACzC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,QAAkB,EAAE,OAAO,GAA6B,EAAE;IAC/F,OAAO;QACN,GAAG,QAAQ;QACX,SAAS,EAAE,GAAG,EAAE;YACf,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,uBAAuB,CAAC,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC,SAAS,EAAE,EAAE;gBAC1F,mBAAmB,EAAE,oBAAoB,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,EAAE,EAAE,CAAC;oBACnE,CAAC,CAAC,OAAO,CAAC,sBAAsB,EAAE,EAAE;oBACpC,CAAC,CAAC,SAAS;gBACZ,cAAc,EAAE,OAAO,CAAC,iBAAiB,EAAE,EAAE;gBAC7C,kBAAkB,EAAE,OAAO,CAAC,qBAAqB,EAAE,EAAE;gBACrD,cAAc,EAAE,OAAO,CAAC,iBAAiB,EAAE,EAAE;aAC7C,CAAC,CAAC;YACH,OAAO,CAAC,aAAa,EAAE,CAAC,QAAQ,CAAC,EAAE,EAAE,WAAW,CAAC,CAAC;YAClD,OAAO,MAAM,CAAC;QACf,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import {\n\ttype Api,\n\ttype Credential,\n\tgetServiceTierCost,\n\ttype Model,\n\ttype ModelFastRoute,\n\ttype Provider,\n} from \"@bastani/pi-ai\";\nimport type { ModelsJsonModelOverride } from \"./model-config.ts\";\nimport { applyModelOverride } from \"./provider-composer-internal.ts\";\n\n/** Canonical suffix every selectable fast model variant carries. */\nexport const FAST_MODEL_ID_SUFFIX = \"-fast\";\n\n/** Service tier OpenAI-style providers use to route fast traffic. */\nexport const FAST_MODEL_SERVICE_TIER = \"priority\" as const;\n\n/** Codex's Ultrafast tier, offered only for models that advertise it; access depends on the account. */\nexport const ULTRAFAST_MODEL_ID_SUFFIX = \"-ultrafast\";\nexport const ULTRAFAST_MODEL_SERVICE_TIER = \"ultrafast\" as const;\n\n/** Inference speed Anthropic's Messages API uses to route fast traffic. */\nexport const FAST_MODEL_SPEED = \"fast\" as const;\n\n/**\n * Claude models Anthropic's fast mode accepts. Requesting `speed: \"fast\"` on any other model is an\n * error, so the list is explicit rather than a family-name pattern.\n * https://platform.claude.com/docs/en/build-with-claude/fast-mode#supported-models\n */\nexport const ANTHROPIC_FAST_MODE_MODEL_IDS: ReadonlySet<string> = new Set([\n\t\"claude-opus-5-5\",\n\t\"claude-opus-5\",\n\t\"claude-opus-4-8\",\n]);\n\n/** A derived fast variant that was suppressed because something already owns its exact model ID. */\nexport interface FastModelVariantDiagnostic {\n\tprovider: string;\n\t/** The exact selectable model ID that collided. */\n\tmodelId: string;\n\tmessage: string;\n}\n\nexport interface FastModelVariantDerivation {\n\tmodels: readonly Model<Api>[];\n\tdiagnostics: readonly FastModelVariantDiagnostic[];\n}\n\nexport interface DeriveFastModelVariantsOptions {\n\t/** Exact fast model IDs the stored GitHub Copilot credential advertises for this account. */\n\tcopilotFastModelIds?: readonly string[];\n\t/** `models.json` `modelOverrides` for this provider, applied to derived entries by their exact `-fast` ID. */\n\tmodelOverrides?: Readonly<Record<string, ModelsJsonModelOverride>>;\n\t/** APIs whose transport a registered extension owns for this provider. No variant is derived for them. */\n\textensionOwnedApis?: ReadonlySet<Api>;\n\t/** IDs explicitly declared in this provider's models.json models array. Never derive siblings for them. */\n\tcustomModelIds?: ReadonlySet<string>;\n}\n\nexport interface FastModelVariantsOptions {\n\t/**\n\t * Synchronous read of the exact fast model IDs the stored GitHub Copilot credential advertises.\n\t * Read per call so a credential that lands after provider composition still takes effect.\n\t */\n\tgetCopilotFastModelIds?: () => readonly string[] | undefined;\n\t/** Synchronous read of this provider's `models.json` `modelOverrides`, so a reload takes effect. */\n\tgetModelOverrides?: () => Readonly<Record<string, ModelsJsonModelOverride>> | undefined;\n\t/** Read current custom model IDs per pass so models.json reloads update eligibility. */\n\tgetCustomModelIds?: () => ReadonlySet<string>;\n\t/**\n\t * Synchronous read of the APIs a registered extension supplies a stream function for. Read per call\n\t * because extensions register after initial composition on some paths.\n\t */\n\tgetExtensionOwnedApis?: () => ReadonlySet<Api> | undefined;\n\t/** Called after every derivation pass with the complete diagnostic list for this provider. */\n\tonDiagnostics?: (providerId: string, diagnostics: readonly FastModelVariantDiagnostic[]) => void;\n}\n\n/** Canonical selectable ID of the fast variant of `baseModelId`. */\nexport function fastModelId(baseModelId: string): string {\n\treturn `${baseModelId}${FAST_MODEL_ID_SUFFIX}`;\n}\n\n/**\n * The two pi-ai adapters that serialize `service_tier`. `azure-openai-responses` and\n * `openai-completions` have no such option, and `streamSimple` drops it, so a service-tier route on\n * any other API would silently degrade to an ordinary request.\n */\nexport function isNativeFastRouteApi(api: Api): api is \"openai-responses\" | \"openai-codex-responses\" {\n\treturn api === \"openai-responses\" || api === \"openai-codex-responses\";\n}\n\n/**\n * OpenAI-style fast routing keeps the base upstream model ID and adds a priority service tier.\n *\n * Eligibility requires both a first-party provider ID and an adapter that serializes\n * `service_tier`. A renamed provider, proxy, Azure (`azure`), OpenRouter\n * (`openai-completions`), and generic OpenAI-compatible providers do not qualify. An `openai` or\n * `openai-codex` model on an adapter that cannot carry `service_tier` must not offer a fast variant,\n * because selecting it would send an ordinary request under a name that promises otherwise.\n */\nexport function usesOpenAIFastServiceTier(model: Pick<Model<Api>, \"api\" | \"provider\">): boolean {\n\treturn 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
|
+
{"version":3,"file":"fast-model-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ACzE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC;AACzC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,QAAkB,EAAE,OAAO,GAA6B,EAAE;IAC/F,OAAO;QACN,GAAG,QAAQ;QACX,SAAS,EAAE,GAAG,EAAE;YACf,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,uBAAuB,CAAC,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC,SAAS,EAAE,EAAE;gBAC1F,mBAAmB,EAAE,oBAAoB,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,EAAE,EAAE,CAAC;oBACnE,CAAC,CAAC,OAAO,CAAC,sBAAsB,EAAE,EAAE;oBACpC,CAAC,CAAC,SAAS;gBACZ,cAAc,EAAE,OAAO,CAAC,iBAAiB,EAAE,EAAE;gBAC7C,kBAAkB,EAAE,OAAO,CAAC,qBAAqB,EAAE,EAAE;gBACrD,cAAc,EAAE,OAAO,CAAC,iBAAiB,EAAE,EAAE;aAC7C,CAAC,CAAC;YACH,OAAO,CAAC,aAAa,EAAE,CAAC,QAAQ,CAAC,EAAE,EAAE,WAAW,CAAC,CAAC;YAClD,OAAO,MAAM,CAAC;QACf,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import {\n\ttype Api,\n\ttype Credential,\n\tgetServiceTierCost,\n\ttype Model,\n\ttype ModelFastRoute,\n\ttype Provider,\n} from \"@bastani/pi-ai\";\nimport type { ModelsJsonModelOverride } from \"./model-config.ts\";\nimport { applyModelOverride } from \"./provider-composer-internal.ts\";\n\n/** Canonical suffix every selectable fast model variant carries. */\nexport const FAST_MODEL_ID_SUFFIX = \"-fast\";\n\n/** Service tier OpenAI-style providers use to route fast traffic. */\nexport const FAST_MODEL_SERVICE_TIER = \"priority\" as const;\n\n/** Codex's Ultrafast tier, offered only for models that advertise it; access depends on the account. */\nexport const ULTRAFAST_MODEL_ID_SUFFIX = \"-ultrafast\";\nexport const ULTRAFAST_MODEL_SERVICE_TIER = \"ultrafast\" as const;\n\n/** Inference speed Anthropic's Messages API uses to route fast traffic. */\nexport const FAST_MODEL_SPEED = \"fast\" as const;\n\n/**\n * Claude models Anthropic's fast mode accepts. Requesting `speed: \"fast\"` on any other model is an\n * error, so the list is explicit rather than a family-name pattern.\n * https://platform.claude.com/docs/en/build-with-claude/fast-mode#supported-models\n */\nexport const ANTHROPIC_FAST_MODE_MODEL_IDS: ReadonlySet<string> = new Set([\n\t\"claude-opus-5-5\",\n\t\"claude-opus-5\",\n\t\"claude-opus-4-8\",\n]);\n\n/** A derived fast variant that was suppressed because something already owns its exact model ID. */\nexport interface FastModelVariantDiagnostic {\n\tprovider: string;\n\t/** The exact selectable model ID that collided. */\n\tmodelId: string;\n\tmessage: string;\n}\n\nexport interface FastModelVariantDerivation {\n\tmodels: readonly Model<Api>[];\n\tdiagnostics: readonly FastModelVariantDiagnostic[];\n}\n\nexport interface DeriveFastModelVariantsOptions {\n\t/** Exact fast model IDs the stored GitHub Copilot credential advertises for this account. */\n\tcopilotFastModelIds?: readonly string[];\n\t/** `models.json` `modelOverrides` for this provider, applied to derived entries by their exact `-fast` ID. */\n\tmodelOverrides?: Readonly<Record<string, ModelsJsonModelOverride>>;\n\t/** APIs whose transport a registered extension owns for this provider. No variant is derived for them. */\n\textensionOwnedApis?: ReadonlySet<Api>;\n\t/** IDs explicitly declared in this provider's models.json models array. Never derive siblings for them. */\n\tcustomModelIds?: ReadonlySet<string>;\n}\n\nexport interface FastModelVariantsOptions {\n\t/**\n\t * Synchronous read of the exact fast model IDs the stored GitHub Copilot credential advertises.\n\t * Read per call so a credential that lands after provider composition still takes effect.\n\t */\n\tgetCopilotFastModelIds?: () => readonly string[] | undefined;\n\t/** Synchronous read of this provider's `models.json` `modelOverrides`, so a reload takes effect. */\n\tgetModelOverrides?: () => Readonly<Record<string, ModelsJsonModelOverride>> | undefined;\n\t/** Read current custom model IDs per pass so models.json reloads update eligibility. */\n\tgetCustomModelIds?: () => ReadonlySet<string>;\n\t/**\n\t * Synchronous read of the APIs a registered extension supplies a stream function for. Read per call\n\t * because extensions register after initial composition on some paths.\n\t */\n\tgetExtensionOwnedApis?: () => ReadonlySet<Api> | undefined;\n\t/** Called after every derivation pass with the complete diagnostic list for this provider. */\n\tonDiagnostics?: (providerId: string, diagnostics: readonly FastModelVariantDiagnostic[]) => void;\n}\n\n/** Canonical selectable ID of the fast variant of `baseModelId`. */\nexport function fastModelId(baseModelId: string): string {\n\treturn `${baseModelId}${FAST_MODEL_ID_SUFFIX}`;\n}\n\n/**\n * The two pi-ai adapters that serialize `service_tier`. `azure-openai-responses` and\n * `openai-completions` have no such option, and `streamSimple` drops it, so a service-tier route on\n * any other API would silently degrade to an ordinary request.\n */\nexport function isNativeFastRouteApi(api: Api): api is \"openai-responses\" | \"openai-codex-responses\" {\n\treturn api === \"openai-responses\" || api === \"openai-codex-responses\";\n}\n\n/**\n * OpenAI-style fast routing keeps the base upstream model ID and adds a priority service tier.\n *\n * Eligibility requires both a first-party provider ID and an adapter that serializes\n * `service_tier`. A renamed provider, proxy, Azure (`azure`), OpenRouter\n * (`openai-completions`), and generic OpenAI-compatible providers do not qualify. An `openai` or\n * `openai-codex` model on an adapter that cannot carry `service_tier` must not offer a fast variant,\n * because selecting it would send an ordinary request under a name that promises otherwise.\n */\nexport function usesOpenAIFastServiceTier(model: Pick<Model<Api>, \"api\" | \"provider\">): boolean {\n\treturn (\n\t\tisNativeFastRouteApi(model.api) &&\n\t\t(model.provider === \"openai\" || model.provider === \"openai-api\" || model.provider === \"openai-codex\")\n\t);\n}\n\n/**\n * xAI Priority Processing keeps the base upstream Grok model ID and adds the same\n * `service_tier: \"priority\"` field on the Responses API. xAI has no `-fast` model slugs for current\n * Grok models; priority is billed at twice the standard token rates, and only when the response\n * confirms the tier. https://docs.x.ai/developers/advanced-api-usage/priority-processing\n *\n * Eligibility requires the first-party `xai` provider on `openai-responses`. OpenRouter, Vercel AI\n * Gateway, and renamed or proxied xAI-compatible providers do not qualify.\n */\nexport function usesXaiFastServiceTier(model: Pick<Model<Api>, \"api\" | \"provider\">): boolean {\n\treturn model.api === \"openai-responses\" && model.provider === \"xai\";\n}\n\n/** GitHub Copilot advertises real fast sibling model IDs per account; it never uses a service tier. */\nexport function isGitHubCopilotModel(model: Pick<Model<Api>, \"provider\">): boolean {\n\treturn model.provider === \"github-copilot\";\n}\n\n/**\n * Anthropic fast mode keeps the base upstream model ID and adds `speed: \"fast\"` with the fast-mode beta.\n *\n * Eligibility requires the first-party `anthropic` provider on the Messages API and a supported model.\n * Fast mode is not offered through Amazon Bedrock, Google Vertex, GitHub Copilot, OpenRouter, or a\n * renamed or proxied Anthropic-compatible provider.\n */\nexport function usesAnthropicFastMode(model: Pick<Model<Api>, \"api\" | \"id\" | \"provider\">): boolean {\n\treturn (\n\t\tmodel.api === \"anthropic-messages\" &&\n\t\t(model.provider === \"anthropic\" || model.provider === \"anthropic-api\") &&\n\t\tANTHROPIC_FAST_MODE_MODEL_IDS.has(model.id)\n\t);\n}\n\nfunction advertisedModelIds(value: unknown): readonly string[] | undefined {\n\tif (!Array.isArray(value) || !value.every((entry) => typeof entry === \"string\")) return undefined;\n\treturn value;\n}\n\n/** Read the exact fast model IDs a stored GitHub Copilot OAuth credential advertises. */\nexport function copilotAdvertisedFastModelIds(credential: Credential | undefined): readonly string[] | undefined {\n\tif (credential?.type !== \"oauth\") return undefined;\n\treturn advertisedModelIds(credential.fastModelIds);\n}\n\n/**\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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-resolver-defaults.d.ts","sourceRoot":"","sources":["../../src/core/model-resolver-defaults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAExD,gDAAgD;AAChD,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"model-resolver-defaults.d.ts","sourceRoot":"","sources":["../../src/core/model-resolver-defaults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAExD,gDAAgD;AAChD,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CA4C1D,CAAC;AAEF,wBAAgB,2BAA2B,CAAC,eAAe,EAAE,KAAK,CAAC,GAAG,CAAC,EAAE,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,SAAS,CASjG"}
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
export const defaultModelPerProvider = {
|
|
3
3
|
"amazon-bedrock": "us.anthropic.claude-opus-4-6-v1",
|
|
4
4
|
anthropic: "claude-opus-4-8",
|
|
5
|
+
"anthropic-api": "claude-opus-4-8",
|
|
5
6
|
openai: "gpt-5.5",
|
|
7
|
+
"openai-api": "gpt-5.5",
|
|
6
8
|
azure: "gpt-5.4",
|
|
7
9
|
"openai-codex": "gpt-6.1-sol",
|
|
8
10
|
radius: "balanced",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-resolver-defaults.js","sourceRoot":"","sources":["../../src/core/model-resolver-defaults.ts"],"names":[],"mappings":"AAEA,gDAAgD;AAChD,MAAM,CAAC,MAAM,uBAAuB,GAA2B;IAC9D,gBAAgB,EAAE,iCAAiC;IACnD,SAAS,EAAE,iBAAiB;IAC5B,MAAM,EAAE,SAAS;IACjB,KAAK,EAAE,SAAS;IAChB,cAAc,EAAE,aAAa;IAC7B,MAAM,EAAE,UAAU;IAClB,MAAM,EAAE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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\tazure: \"gpt-5.4\",\n\t\"openai-codex\": \"gpt-6.1-sol\",\n\tradius: \"balanced\",\n\tnvidia: \"nvidia/nemotron-3-ultra-550b-a55b\",\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"]}
|
|
1
|
+
{"version":3,"file":"model-resolver-defaults.js","sourceRoot":"","sources":["../../src/core/model-resolver-defaults.ts"],"names":[],"mappings":"AAEA,gDAAgD;AAChD,MAAM,CAAC,MAAM,uBAAuB,GAA2B;IAC9D,gBAAgB,EAAE,iCAAiC;IACnD,SAAS,EAAE,iBAAiB;IAC5B,eAAe,EAAE,iBAAiB;IAClC,MAAM,EAAE,SAAS;IACjB,YAAY,EAAE,SAAS;IACvB,KAAK,EAAE,SAAS;IAChB,cAAc,EAAE,aAAa;IAC7B,MAAM,EAAE,UAAU;IAClB,MAAM,EAAE,mCAAmC;IAC3C,QAAQ,EAAE,iBAAiB;IAC3B,MAAM,EAAE,wBAAwB;IAChC,eAAe,EAAE,wBAAwB;IACzC,gBAAgB,EAAE,SAAS;IAC3B,UAAU,EAAE,sBAAsB;IAClC,mBAAmB,EAAE,aAAa;IAClC,GAAG,EAAE,UAAU;IACf,IAAI,EAAE,qBAAqB;IAC3B,QAAQ,EAAE,cAAc;IACxB,UAAU,EAAE,aAAa;IACzB,GAAG,EAAE,SAAS;IACd,eAAe,EAAE,SAAS;IAC1B,OAAO,EAAE,wBAAwB;IACjC,OAAO,EAAE,cAAc;IACvB,YAAY,EAAE,cAAc;IAC5B,UAAU,EAAE,WAAW;IACvB,eAAe,EAAE,WAAW;IAC5B,WAAW,EAAE,sBAAsB;IACnC,SAAS,EAAE,mCAAmC;IAC9C,QAAQ,EAAE,oBAAoB;IAC9B,OAAO,EAAE,iBAAiB;IAC1B,QAAQ,EAAE,WAAW;IACrB,aAAa,EAAE,SAAS;IACxB,aAAa,EAAE,iBAAiB;IAChC,IAAI,EAAE,gBAAgB;IACtB,uBAAuB,EAAE,0BAA0B;IACnD,uBAAuB,EAAE,qCAAqC;IAC9D,iBAAiB,EAAE,aAAa;IAChC,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\t\"anthropic-api\": \"claude-opus-4-8\",\n\topenai: \"gpt-5.5\",\n\t\"openai-api\": \"gpt-5.5\",\n\tazure: \"gpt-5.4\",\n\t\"openai-codex\": \"gpt-6.1-sol\",\n\tradius: \"balanced\",\n\tnvidia: \"nvidia/nemotron-3-ultra-550b-a55b\",\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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nested-tool-calls.d.ts","sourceRoot":"","sources":["../../src/core/nested-tool-calls.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAc,oBAAoB,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC/F,OAAO,KAAK,EACX,aAAa,EACb,oBAAoB,EACpB,eAAe,EACf,uBAAuB,EACvB,MAAM,+BAA+B,CAAC;AAGvC,eAAO,MAAM,kBAAkB;aAC9B,QAAQ,EAAE,GAAG;aACb,uBAAuB;aACvB,qBAAqB;aACrB,aAAa,EAAE,GAAG;CACT,CAAC;AAEX,MAAM,WAAW,iBAAiB;IACjC,KAAK,EAAE,eAAe,GAAG,SAAS,CAAC;IACnC,KAAK,EAAE,KAAK,GAAG,SAAS,CAAC;CACzB;AAED,wEAAwE;AACxE,qBAAa,kBAAkB;IAC9B,OAAO,CAAC,KAAK,CAA8B;IAC3C,OAAO,CAAC,SAAS,CAA2C;IAC5D,OAAO,CAAC,QAAQ,CAAQ;IACxB,OAAO,CAAC,aAAa,CAAK;IAC1B,OAAO,CAAC,KAAK,CAAoB;IACjC,KAAK,CAAC,QAAQ,EAAE,aAAa,GAAG,oBAAoB,GAAG,SAAS,CAqB/D;IACD,MAAM,CAAC,MAAM,EAAE,oBAAoB,GAAG,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAM1F;IACD,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAE3B;IACD,IAAI,UAAU,IAAI,KAAK,GAAG,SA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AEnC;IACK,OAAO,CACZ,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,OAAO,EACb,OAAO,GAAE,qBAA0B,GACjC,OAAO,CAAC,oBAAoB,CAAC,CAiD/B;IACD,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS,CAI5D;IACD,KAAK,IAAI,IAAI,CAEZ;CACD"}
|
|
@@ -116,6 +116,7 @@ export class NestedToolCallRunner {
|
|
|
116
116
|
toolName: name,
|
|
117
117
|
result: outcome.result,
|
|
118
118
|
isError: outcome.isError,
|
|
119
|
+
...(outcome.durationMs === undefined ? {} : { durationMs: outcome.durationMs }),
|
|
119
120
|
parentToolCallId: callerId,
|
|
120
121
|
});
|
|
121
122
|
return outcome;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nested-tool-calls.js","sourceRoot":"","sources":["../../src/core/nested-tool-calls.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,MAAM,CAAC,MAAM,kBAAkB,GAAG;IACjC,QAAQ,EAAE,GAAG;IACb,uBAAuB,EAAE,CAAC,GAAG,IAAI;IACjC,qBAAqB,EAAE,EAAE,GAAG,IAAI;IAChC,aAAa,EAAE,GAAG;CACT,CAAC;AACX,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;AAMlC,wEAAwE;AACxE,MAAM,OAAO,kBAAkB;IACtB,KAAK,GAA2B,EAAE,CAAC;IACnC,SAAS,GAAG,IAAI,GAAG,EAAgC,CAAC;IACpD,QAAQ,GAAG,IAAI,CAAC;IAChB,aAAa,GAAG,CAAC,CAAC;IAClB,KAAK,CAAoB;IACjC,KAAK,CAAC,QAAuB;QAC5B,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,kBAAkB,CAAC,QAAQ,EAAE,CAAC;YACtD,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;YACtB,OA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,OAAO,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IACnG,CAAC;IACD,KAAK;QACJ,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;CACD","sourcesContent":["import type { JsonObject, NestedToolCallRecord, NestedToolCalls, Usage } from \"@bastani/pi-ai\";\nimport type {\n\tAgentToolCall,\n\tAgentToolCallOutcome,\n\tAgentToolResult,\n\tAgentToolUpdateCallback,\n} from \"@earendil-works/pi-agent-core\";\nimport { combineUsage } from \"./usage-totals.ts\";\n\nexport const NESTED_CALL_LIMITS = {\n\tmaxCalls: 256,\n\tmaxArgumentBytesPerCall: 8 * 1024,\n\tmaxArgumentBytesTotal: 32 * 1024,\n\tmaxErrorChars: 500,\n} as const;\nconst encoder = new TextEncoder();\nexport interface NestedCallSummary {\n\tcalls: NestedToolCalls | undefined;\n\tusage: Usage | undefined;\n}\n\n/** Bounded session record. Tool output is deliberately not retained. */\nexport class NestedCallRecorder {\n\tprivate calls: NestedToolCallRecord[] = [];\n\tprivate startedAt = new Map<NestedToolCallRecord, number>();\n\tprivate complete = true;\n\tprivate argumentBytes = 0;\n\tprivate usage: Usage | undefined;\n\tstart(toolCall: AgentToolCall): NestedToolCallRecord | undefined {\n\t\tif (this.calls.length >= NESTED_CALL_LIMITS.maxCalls) {\n\t\t\tthis.complete = false;\n\t\t\treturn undefined;\n\t\t}\n\t\tconst record: NestedToolCallRecord = { id: toolCall.id, name: toolCall.name, status: \"unfinished\" };\n\t\tconst json = JSON.stringify(toolCall.arguments ?? {});\n\t\tconst bytes = encoder.encode(json).length;\n\t\tif (\n\t\t\tbytes > NESTED_CALL_LIMITS.maxArgumentBytesPerCall ||\n\t\t\tthis.argumentBytes + bytes > NESTED_CALL_LIMITS.maxArgumentBytesTotal\n\t\t) {\n\t\t\trecord.argumentsBytes = bytes;\n\t\t\tthis.complete = false;\n\t\t} else {\n\t\t\trecord.arguments = JSON.parse(json) as JsonObject;\n\t\t\tthis.argumentBytes += bytes;\n\t\t}\n\t\tthis.calls.push(record);\n\t\tthis.startedAt.set(record, performance.now());\n\t\treturn record;\n\t}\n\tfinish(record: NestedToolCallRecord | undefined, isError: boolean, errorText: string): void {\n\t\tif (!record) return;\n\t\trecord.status = isError ? \"error\" : \"ok\";\n\t\trecord.durationMs = Math.round(performance.now() - (this.startedAt.get(record) ?? performance.now()));\n\t\tthis.startedAt.delete(record);\n\t\tif (isError && errorText) record.error = errorText.slice(0, NESTED_CALL_LIMITS.maxErrorChars);\n\t}\n\taddUsage(usage: Usage): void {\n\t\tthis.usage = this.usage ? combineUsage(this.usage, usage) : usage;\n\t}\n\tget totalUsage(): Usage | undefined {\n\t\treturn this.usage;\n\t}\n\tsnapshot(): NestedToolCalls | undefined {\n\t\tif (this.calls.length === 0 && this.complete) return undefined;\n\t\tconst calls = this.calls.map((call) => ({ ...call }));\n\t\treturn { calls, complete: this.complete && calls.every((call) => call.status !== \"unfinished\") };\n\t}\n}\n\nexport interface NestedToolCallOptions {\n\tsignal?: AbortSignal;\n\tonUpdate?: AgentToolUpdateCallback;\n}\nexport type NestedToolExecutionEvent =\n\t| { type: \"tool_execution_start\"; toolCallId: string; toolName: string; args: unknown; parentToolCallId: string }\n\t| {\n\t\t\ttype: \"tool_execution_update\";\n\t\t\ttoolCallId: string;\n\t\t\ttoolName: string;\n\t\t\targs: unknown;\n\t\t\tpartialResult: AgentToolResult<unknown>;\n\t\t\tparentToolCallId: string;\n\t }\n\t| {\n\t\t\ttype: \"tool_execution_end\";\n\t\t\ttoolCallId: string;\n\t\t\ttoolName: string;\n\t\t\tresult: AgentToolResult<unknown>;\n\t\t\tisError: boolean;\n\t\t\tparentToolCallId: string;\n\t };\nexport interface NestedToolCallHost {\n\trunToolCall(\n\t\ttoolCall: AgentToolCall,\n\t\tparentToolCallId: string,\n\t\tsignal: AbortSignal | undefined,\n\t\tonUpdate: (partialResult: AgentToolResult<unknown>) => Promise<void>,\n\t): Promise<AgentToolCallOutcome>;\n\temit(event: NestedToolExecutionEvent): Promise<void>;\n}\ninterface CallScope {\n\trecorder: NestedCallRecorder;\n\tnextId: number;\n}\nfunction textOf(result: AgentToolResult<unknown>): string {\n\treturn result.content\n\t\t.filter((block) => block.type === \"text\")\n\t\t.map((block) => block.text)\n\t\t.join(\"\\n\");\n}\n\n/** Nested execution retains Atomic's session scheduler rather than maintaining a competing lock. */\nexport class NestedToolCallRunner {\n\tprivate scopes = new Map<string, CallScope>();\n\tprivate host: NestedToolCallHost;\n\tconstructor(host: NestedToolCallHost) {\n\t\tthis.host = host;\n\t}\n\tasync execute(\n\t\tcallerId: string,\n\t\tname: string,\n\t\targs: unknown,\n\t\toptions: NestedToolCallOptions = {},\n\t): Promise<AgentToolCallOutcome> {\n\t\tlet scope = this.scopes.get(callerId);\n\t\tif (!scope) {\n\t\t\tscope = { recorder: new NestedCallRecorder(), nextId: 1 };\n\t\t\tthis.scopes.set(callerId, scope);\n\t\t}\n\t\tconst toolCall: AgentToolCall = {\n\t\t\ttype: \"toolCall\",\n\t\t\tid: `${callerId}/${scope.nextId++}`,\n\t\t\tname,\n\t\t\targuments: (args ?? {}) as AgentToolCall[\"arguments\"],\n\t\t};\n\t\tconst record = scope.recorder.start(toolCall);\n\t\tawait this.host.emit({\n\t\t\ttype: \"tool_execution_start\",\n\t\t\ttoolCallId: toolCall.id,\n\t\t\ttoolName: name,\n\t\t\targs: toolCall.arguments,\n\t\t\tparentToolCallId: callerId,\n\t\t});\n\t\tthis.scopes.set(toolCall.id, { recorder: scope.recorder, nextId: 1 });\n\t\tlet outcome: AgentToolCallOutcome;\n\t\ttry {\n\t\t\toutcome = await this.host.runToolCall(toolCall, callerId, options.signal, async (partialResult) => {\n\t\t\t\toptions.onUpdate?.(partialResult);\n\t\t\t\tawait this.host.emit({\n\t\t\t\t\ttype: \"tool_execution_update\",\n\t\t\t\t\ttoolCallId: toolCall.id,\n\t\t\t\t\ttoolName: name,\n\t\t\t\t\targs: toolCall.arguments,\n\t\t\t\t\tpartialResult,\n\t\t\t\t\tparentToolCallId: callerId,\n\t\t\t\t});\n\t\t\t});\n\t\t} finally {\n\t\t\tthis.scopes.delete(toolCall.id);\n\t\t}\n\t\tscope.recorder.finish(record, outcome.isError, textOf(outcome.result));\n\t\tif (outcome.result.usage) scope.recorder.addUsage(outcome.result.usage);\n\t\tawait this.host.emit({\n\t\t\ttype: \"tool_execution_end\",\n\t\t\ttoolCallId: toolCall.id,\n\t\t\ttoolName: name,\n\t\t\tresult: outcome.result,\n\t\t\tisError: outcome.isError,\n\t\t\tparentToolCallId: callerId,\n\t\t});\n\t\treturn outcome;\n\t}\n\ttakeRecord(toolCallId: string): NestedCallSummary | undefined {\n\t\tconst scope = this.scopes.get(toolCallId);\n\t\tthis.scopes.delete(toolCallId);\n\t\treturn scope ? { calls: scope.recorder.snapshot(), usage: scope.recorder.totalUsage } : undefined;\n\t}\n\tclear(): void {\n\t\tthis.scopes.clear();\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"nested-tool-calls.js","sourceRoot":"","sources":["../../src/core/nested-tool-calls.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,MAAM,CAAC,MAAM,kBAAkB,GAAG;IACjC,QAAQ,EAAE,GAAG;IACb,uBAAuB,EAAE,CAAC,GAAG,IAAI;IACjC,qBAAqB,EAAE,EAAE,GAAG,IAAI;IAChC,aAAa,EAAE,GAAG;CACT,CAAC;AACX,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;AAMlC,wEAAwE;AACxE,MAAM,OAAO,kBAAkB;IACtB,KAAK,GAA2B,EAAE,CAAC;IACnC,SAAS,GAAG,IAAI,GAAG,EAAgC,CAAC;IACpD,QAAQ,GAAG,IAAI,CAAC;IAChB,aAAa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CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,CAAC;YAC/E,gBAAgB,EAAE,QAAQ;SAC1B,CAAC,CAAC;QACH,OAAO,OAAO,CAAC;IAChB,CAAC;IACD,UAAU,CAAC,UAAkB;QAC5B,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QAC1C,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QAC/B,OAAO,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IACnG,CAAC;IACD,KAAK;QACJ,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;CACD","sourcesContent":["import type { JsonObject, NestedToolCallRecord, NestedToolCalls, Usage } from \"@bastani/pi-ai\";\nimport type {\n\tAgentToolCall,\n\tAgentToolCallOutcome,\n\tAgentToolResult,\n\tAgentToolUpdateCallback,\n} from \"@earendil-works/pi-agent-core\";\nimport { combineUsage } from \"./usage-totals.ts\";\n\nexport const NESTED_CALL_LIMITS = {\n\tmaxCalls: 256,\n\tmaxArgumentBytesPerCall: 8 * 1024,\n\tmaxArgumentBytesTotal: 32 * 1024,\n\tmaxErrorChars: 500,\n} as const;\nconst encoder = new TextEncoder();\nexport interface NestedCallSummary {\n\tcalls: NestedToolCalls | undefined;\n\tusage: Usage | undefined;\n}\n\n/** Bounded session record. Tool output is deliberately not retained. */\nexport class NestedCallRecorder {\n\tprivate calls: NestedToolCallRecord[] = [];\n\tprivate startedAt = new Map<NestedToolCallRecord, number>();\n\tprivate complete = true;\n\tprivate argumentBytes = 0;\n\tprivate usage: Usage | undefined;\n\tstart(toolCall: AgentToolCall): NestedToolCallRecord | undefined {\n\t\tif (this.calls.length >= NESTED_CALL_LIMITS.maxCalls) {\n\t\t\tthis.complete = false;\n\t\t\treturn undefined;\n\t\t}\n\t\tconst record: NestedToolCallRecord = { id: toolCall.id, name: toolCall.name, status: \"unfinished\" };\n\t\tconst json = JSON.stringify(toolCall.arguments ?? {});\n\t\tconst bytes = encoder.encode(json).length;\n\t\tif (\n\t\t\tbytes > NESTED_CALL_LIMITS.maxArgumentBytesPerCall ||\n\t\t\tthis.argumentBytes + bytes > NESTED_CALL_LIMITS.maxArgumentBytesTotal\n\t\t) {\n\t\t\trecord.argumentsBytes = bytes;\n\t\t\tthis.complete = false;\n\t\t} else {\n\t\t\trecord.arguments = JSON.parse(json) as JsonObject;\n\t\t\tthis.argumentBytes += bytes;\n\t\t}\n\t\tthis.calls.push(record);\n\t\tthis.startedAt.set(record, performance.now());\n\t\treturn record;\n\t}\n\tfinish(record: NestedToolCallRecord | undefined, isError: boolean, errorText: string): void {\n\t\tif (!record) return;\n\t\trecord.status = isError ? \"error\" : \"ok\";\n\t\trecord.durationMs = Math.round(performance.now() - (this.startedAt.get(record) ?? performance.now()));\n\t\tthis.startedAt.delete(record);\n\t\tif (isError && errorText) record.error = errorText.slice(0, NESTED_CALL_LIMITS.maxErrorChars);\n\t}\n\taddUsage(usage: Usage): void {\n\t\tthis.usage = this.usage ? combineUsage(this.usage, usage) : usage;\n\t}\n\tget totalUsage(): Usage | undefined {\n\t\treturn this.usage;\n\t}\n\tsnapshot(): NestedToolCalls | undefined {\n\t\tif (this.calls.length === 0 && this.complete) return undefined;\n\t\tconst calls = this.calls.map((call) => ({ ...call }));\n\t\treturn { calls, complete: this.complete && calls.every((call) => call.status !== \"unfinished\") };\n\t}\n}\n\nexport interface NestedToolCallOptions {\n\tsignal?: AbortSignal;\n\tonUpdate?: AgentToolUpdateCallback;\n}\nexport type NestedToolExecutionEvent =\n\t| { type: \"tool_execution_start\"; toolCallId: string; toolName: string; args: unknown; parentToolCallId: string }\n\t| {\n\t\t\ttype: \"tool_execution_update\";\n\t\t\ttoolCallId: string;\n\t\t\ttoolName: string;\n\t\t\targs: unknown;\n\t\t\tpartialResult: AgentToolResult<unknown>;\n\t\t\tparentToolCallId: string;\n\t }\n\t| {\n\t\t\ttype: \"tool_execution_end\";\n\t\t\ttoolCallId: string;\n\t\t\ttoolName: string;\n\t\t\tresult: AgentToolResult<unknown>;\n\t\t\tisError: boolean;\n\t\t\tdurationMs?: number;\n\t\t\tparentToolCallId: string;\n\t };\nexport interface NestedToolCallHost {\n\trunToolCall(\n\t\ttoolCall: AgentToolCall,\n\t\tparentToolCallId: string,\n\t\tsignal: AbortSignal | undefined,\n\t\tonUpdate: (partialResult: AgentToolResult<unknown>) => Promise<void>,\n\t): Promise<AgentToolCallOutcome>;\n\temit(event: NestedToolExecutionEvent): Promise<void>;\n}\ninterface CallScope {\n\trecorder: NestedCallRecorder;\n\tnextId: number;\n}\nfunction textOf(result: AgentToolResult<unknown>): string {\n\treturn result.content\n\t\t.filter((block) => block.type === \"text\")\n\t\t.map((block) => block.text)\n\t\t.join(\"\\n\");\n}\n\n/** Nested execution retains Atomic's session scheduler rather than maintaining a competing lock. */\nexport class NestedToolCallRunner {\n\tprivate scopes = new Map<string, CallScope>();\n\tprivate host: NestedToolCallHost;\n\tconstructor(host: NestedToolCallHost) {\n\t\tthis.host = host;\n\t}\n\tasync execute(\n\t\tcallerId: string,\n\t\tname: string,\n\t\targs: unknown,\n\t\toptions: NestedToolCallOptions = {},\n\t): Promise<AgentToolCallOutcome> {\n\t\tlet scope = this.scopes.get(callerId);\n\t\tif (!scope) {\n\t\t\tscope = { recorder: new NestedCallRecorder(), nextId: 1 };\n\t\t\tthis.scopes.set(callerId, scope);\n\t\t}\n\t\tconst toolCall: AgentToolCall = {\n\t\t\ttype: \"toolCall\",\n\t\t\tid: `${callerId}/${scope.nextId++}`,\n\t\t\tname,\n\t\t\targuments: (args ?? {}) as AgentToolCall[\"arguments\"],\n\t\t};\n\t\tconst record = scope.recorder.start(toolCall);\n\t\tawait this.host.emit({\n\t\t\ttype: \"tool_execution_start\",\n\t\t\ttoolCallId: toolCall.id,\n\t\t\ttoolName: name,\n\t\t\targs: toolCall.arguments,\n\t\t\tparentToolCallId: callerId,\n\t\t});\n\t\tthis.scopes.set(toolCall.id, { recorder: scope.recorder, nextId: 1 });\n\t\tlet outcome: AgentToolCallOutcome;\n\t\ttry {\n\t\t\toutcome = await this.host.runToolCall(toolCall, callerId, options.signal, async (partialResult) => {\n\t\t\t\toptions.onUpdate?.(partialResult);\n\t\t\t\tawait this.host.emit({\n\t\t\t\t\ttype: \"tool_execution_update\",\n\t\t\t\t\ttoolCallId: toolCall.id,\n\t\t\t\t\ttoolName: name,\n\t\t\t\t\targs: toolCall.arguments,\n\t\t\t\t\tpartialResult,\n\t\t\t\t\tparentToolCallId: callerId,\n\t\t\t\t});\n\t\t\t});\n\t\t} finally {\n\t\t\tthis.scopes.delete(toolCall.id);\n\t\t}\n\t\tscope.recorder.finish(record, outcome.isError, textOf(outcome.result));\n\t\tif (outcome.result.usage) scope.recorder.addUsage(outcome.result.usage);\n\t\tawait this.host.emit({\n\t\t\ttype: \"tool_execution_end\",\n\t\t\ttoolCallId: toolCall.id,\n\t\t\ttoolName: name,\n\t\t\tresult: outcome.result,\n\t\t\tisError: outcome.isError,\n\t\t\t...(outcome.durationMs === undefined ? {} : { durationMs: outcome.durationMs }),\n\t\t\tparentToolCallId: callerId,\n\t\t});\n\t\treturn outcome;\n\t}\n\ttakeRecord(toolCallId: string): NestedCallSummary | undefined {\n\t\tconst scope = this.scopes.get(toolCallId);\n\t\tthis.scopes.delete(toolCallId);\n\t\treturn scope ? { calls: scope.recorder.snapshot(), usage: scope.recorder.totalUsage } : undefined;\n\t}\n\tclear(): void {\n\t\tthis.scopes.clear();\n\t}\n}\n"]}
|
|
@@ -4,6 +4,6 @@ export type { AgentSettledEvent, BeforeProviderHeadersEvent, EntryRenderer, Entr
|
|
|
4
4
|
export { isPowerShellToolResult } from "./extensions/index.js";
|
|
5
5
|
export type { PromptTemplate } from "./prompt-templates.ts";
|
|
6
6
|
export type { Skill } from "./skills.ts";
|
|
7
|
-
export type { JsonObject, JsonPrimitive, JsonValue, PowerShellOperations, PowerShellSpawnContext, PowerShellSpawnHook, PowerShellToolDetails, PowerShellToolInput, PowerShellToolOptions, ShellToolPresentation, StructuredOutputCapture, StructuredOutputFileCapture, StructuredOutputToolOptions, Tool, } from "./tools/index.
|
|
8
|
-
export { BASH_SHELL_PRESENTATION, createBashTool, createCodingTools, createEditTool, createFindTool, createKillTool, createLocalPowerShellOperations, createLsTool, createPowerShellTool, createPowerShellToolDefinition, createReadOnlyTools, createReadTool, createSearchTool, createStructuredOutputCapture, createStructuredOutputTool, createWriteTool, STRUCTURED_OUTPUT_TOOL_NAME, withFileMutationQueue, } from "./tools/index.
|
|
7
|
+
export type { JsonObject, JsonPrimitive, JsonValue, PowerShellOperations, PowerShellSpawnContext, PowerShellSpawnHook, PowerShellToolDetails, PowerShellToolInput, PowerShellToolOptions, ShellToolPresentation, StructuredOutputCapture, StructuredOutputFileCapture, StructuredOutputToolOptions, Tool, } from "./tools/index.js";
|
|
8
|
+
export { BASH_SHELL_PRESENTATION, createBashTool, createCodingTools, createEditTool, createFindTool, createKillTool, createLocalPowerShellOperations, createLsTool, createPowerShellTool, createPowerShellToolDefinition, createReadOnlyTools, createReadTool, createSearchTool, createStructuredOutputCapture, createStructuredOutputTool, createWriteTool, STRUCTURED_OUTPUT_TOOL_NAME, withFileMutationQueue, } from "./tools/index.js";
|
|
9
9
|
//# sourceMappingURL=sdk-exports.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk-exports.js","sourceRoot":"","sources":["../../src/core/sdk-exports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,cAAc,4BAA4B,CAAC;AAsB3C,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAmB/D,OAAO,EACN,uBAAuB,EACvB,cAAc;AACd,kCAAkC;AAClC,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,cAAc,EACd,+BAA+B,EAC/B,YAAY,EACZ,oBAAoB,EACpB,8BAA8B,EAC9B,mBAAmB,EACnB,cAAc,EACd,gBAAgB,EAChB,6BAA6B,EAC7B,0BAA0B,EAC1B,eAAe,EACf,2BAA2B,EAC3B,qBAAqB,GACrB,MAAM,kBAAkB,CAAC","sourcesContent":["export { getPowerShellConfig } from \"../utils/shell.ts\";\nexport * from \"./agent-session-runtime.ts\";\nexport type {\n\tAgentSettledEvent,\n\tBeforeProviderHeadersEvent,\n\tEntryRenderer,\n\tEntryRenderOptions,\n\tExtensionAPI,\n\tExtensionCommandContext,\n\tExtensionContext,\n\tExtensionFactory,\n\tInlineExtension,\n\tMessageEndEvent,\n\tMessageStartEvent,\n\tMessageUpdateEvent,\n\tPowerShellToolCallEvent,\n\tSlashCommandInfo,\n\tSlashCommandSource,\n\tToolDefinition,\n\tToolExecutionEndEvent,\n\tToolExecutionStartEvent,\n\tToolExecutionUpdateEvent,\n} from \"./extensions/index.js\";\nexport { isPowerShellToolResult } from \"./extensions/index.js\";\nexport type { PromptTemplate } from \"./prompt-templates.ts\";\nexport type { Skill } from \"./skills.ts\";\nexport type {\n\tJsonObject,\n\tJsonPrimitive,\n\tJsonValue,\n\tPowerShellOperations,\n\tPowerShellSpawnContext,\n\tPowerShellSpawnHook,\n\tPowerShellToolDetails,\n\tPowerShellToolInput,\n\tPowerShellToolOptions,\n\tShellToolPresentation,\n\tStructuredOutputCapture,\n\tStructuredOutputFileCapture,\n\tStructuredOutputToolOptions,\n\tTool,\n} from \"./tools/index.
|
|
1
|
+
{"version":3,"file":"sdk-exports.js","sourceRoot":"","sources":["../../src/core/sdk-exports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,cAAc,4BAA4B,CAAC;AAsB3C,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAmB/D,OAAO,EACN,uBAAuB,EACvB,cAAc;AACd,kCAAkC;AAClC,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,cAAc,EACd,+BAA+B,EAC/B,YAAY,EACZ,oBAAoB,EACpB,8BAA8B,EAC9B,mBAAmB,EACnB,cAAc,EACd,gBAAgB,EAChB,6BAA6B,EAC7B,0BAA0B,EAC1B,eAAe,EACf,2BAA2B,EAC3B,qBAAqB,GACrB,MAAM,kBAAkB,CAAC","sourcesContent":["export { getPowerShellConfig } from \"../utils/shell.ts\";\nexport * from \"./agent-session-runtime.ts\";\nexport type {\n\tAgentSettledEvent,\n\tBeforeProviderHeadersEvent,\n\tEntryRenderer,\n\tEntryRenderOptions,\n\tExtensionAPI,\n\tExtensionCommandContext,\n\tExtensionContext,\n\tExtensionFactory,\n\tInlineExtension,\n\tMessageEndEvent,\n\tMessageStartEvent,\n\tMessageUpdateEvent,\n\tPowerShellToolCallEvent,\n\tSlashCommandInfo,\n\tSlashCommandSource,\n\tToolDefinition,\n\tToolExecutionEndEvent,\n\tToolExecutionStartEvent,\n\tToolExecutionUpdateEvent,\n} from \"./extensions/index.js\";\nexport { isPowerShellToolResult } from \"./extensions/index.js\";\nexport type { PromptTemplate } from \"./prompt-templates.ts\";\nexport type { Skill } from \"./skills.ts\";\nexport type {\n\tJsonObject,\n\tJsonPrimitive,\n\tJsonValue,\n\tPowerShellOperations,\n\tPowerShellSpawnContext,\n\tPowerShellSpawnHook,\n\tPowerShellToolDetails,\n\tPowerShellToolInput,\n\tPowerShellToolOptions,\n\tShellToolPresentation,\n\tStructuredOutputCapture,\n\tStructuredOutputFileCapture,\n\tStructuredOutputToolOptions,\n\tTool,\n} from \"./tools/index.js\";\nexport {\n\tBASH_SHELL_PRESENTATION,\n\tcreateBashTool,\n\t// Tool factories (for custom cwd)\n\tcreateCodingTools,\n\tcreateEditTool,\n\tcreateFindTool,\n\tcreateKillTool,\n\tcreateLocalPowerShellOperations,\n\tcreateLsTool,\n\tcreatePowerShellTool,\n\tcreatePowerShellToolDefinition,\n\tcreateReadOnlyTools,\n\tcreateReadTool,\n\tcreateSearchTool,\n\tcreateStructuredOutputCapture,\n\tcreateStructuredOutputTool,\n\tcreateWriteTool,\n\tSTRUCTURED_OUTPUT_TOOL_NAME,\n\twithFileMutationQueue,\n} from \"./tools/index.js\";\n"]}
|
package/dist/core/sdk-types.d.ts
CHANGED
|
@@ -56,6 +56,9 @@ export interface CreateAgentSessionOptions {
|
|
|
56
56
|
* an entry starts with `mcp__`; only matching tools are declared directly.
|
|
57
57
|
* `excludedTools` applies afterwards. `noTools: "all"` overrides this selection.
|
|
58
58
|
* Intercom follows the same selection and suppression rules as other extension tools.
|
|
59
|
+
* A list of only `+name`/`-name` entries changes the resolved defaults instead
|
|
60
|
+
* of allowlisting tools, and is reapplied on reload. Modifiers take exact names;
|
|
61
|
+
* mixing them with plain names or patterns throws. Total suppression still wins.
|
|
59
62
|
*/
|
|
60
63
|
tools?: string[];
|
|
61
64
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk-types.d.ts","sourceRoot":"","sources":["../../src/core/sdk-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACjF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EACX,oBAAoB,EACpB,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACd,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM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