@draht/coding-agent 2026.9.5-1 → 2026.10.4-3
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 +458 -0
- package/dist/bun/cli.d.ts +1 -1
- package/dist/bun/cli.d.ts.map +1 -1
- package/dist/bun/cli.js +6 -3
- package/dist/bun/cli.js.map +1 -1
- package/dist/bun/sandbox-env-setup.d.ts +2 -0
- package/dist/bun/sandbox-env-setup.d.ts.map +1 -0
- package/dist/bun/sandbox-env-setup.js +4 -0
- package/dist/bun/sandbox-env-setup.js.map +1 -0
- package/dist/bundle/chunks/anthropic-messages-E2P6C3P7.js +6 -0
- package/dist/bundle/chunks/anthropic.js +75 -0
- package/dist/bundle/chunks/azure-openai-responses-JZMSTDIM.js +2 -0
- package/dist/bundle/chunks/bedrock-converse-stream.js +79 -0
- package/dist/bundle/chunks/chunk-2E5VODES.js +2 -0
- package/dist/bundle/chunks/chunk-2FBJKY7F.js +2 -0
- package/dist/bundle/chunks/chunk-2JZLKNZ4.js +3 -0
- package/dist/bundle/chunks/chunk-2N4I6WXC.js +2 -0
- package/dist/bundle/chunks/chunk-3HF756LN.js +1472 -0
- package/dist/bundle/chunks/chunk-5QJFWTKA.js +4 -0
- package/dist/bundle/chunks/chunk-63BK6WK2.js +2 -0
- package/dist/bundle/chunks/chunk-A4OX5CPR.js +146 -0
- package/dist/bundle/chunks/chunk-AFL4IDSI.js +82 -0
- package/dist/bundle/chunks/chunk-D3HO453P.js +42 -0
- package/dist/bundle/chunks/chunk-EBVYI75P.js +2 -0
- package/dist/bundle/chunks/chunk-FBU742QF.js +2 -0
- package/dist/bundle/chunks/chunk-FHX2S5IG.js +31 -0
- package/dist/bundle/chunks/chunk-GBFVS2SF.js +12 -0
- package/dist/bundle/chunks/chunk-GVXA72ZA.js +2 -0
- package/dist/bundle/chunks/chunk-HJ72RANT.js +2 -0
- package/dist/bundle/chunks/chunk-HTJ3L72O.js +2 -0
- package/dist/bundle/chunks/chunk-HZ2UHMBT.js +2 -0
- package/dist/bundle/chunks/chunk-I5OKY6RH.js +11 -0
- package/dist/bundle/chunks/chunk-JTLUBTZT.js +2 -0
- package/dist/bundle/chunks/chunk-KPO5375S.js +2 -0
- package/dist/bundle/chunks/chunk-KY2BG6BC.js +11 -0
- package/dist/bundle/chunks/chunk-LO6CVU2L.js +6 -0
- package/dist/bundle/chunks/chunk-QMN7OD6G.js +2 -0
- package/dist/bundle/chunks/chunk-SDRCE6OP.js +2 -0
- package/dist/bundle/chunks/chunk-SPZUYYP5.js +170 -0
- package/dist/bundle/chunks/chunk-UTRX2VHB.js +44 -0
- package/dist/bundle/chunks/chunk-V5HG6S2T.js +4 -0
- package/dist/bundle/chunks/chunk-VPYAVQLP.js +137 -0
- package/dist/bundle/chunks/chunk-VXUJMEMO.js +2 -0
- package/dist/bundle/chunks/chunk-XBUEMKIY.js +2 -0
- package/dist/bundle/chunks/chunk-XHCO4PPH.js +8 -0
- package/dist/bundle/chunks/chunk-XO3IECI5.js +18 -0
- package/dist/bundle/chunks/chunk-XOGEYN4Q.js +2 -0
- package/dist/bundle/chunks/cli-L74YA5GF.js +51 -0
- package/dist/bundle/chunks/cloudflare-workers-ai-system-one-MJKOAE5S.js +2 -0
- package/dist/bundle/chunks/codemode-worker.js +315 -0
- package/dist/bundle/chunks/execute-EMOVNTD6.js +328 -0
- package/dist/bundle/chunks/github-copilot.js +2 -0
- package/dist/bundle/chunks/google-antigravity.js +75 -0
- package/dist/bundle/chunks/google-gemini-cli.js +75 -0
- package/dist/bundle/chunks/google-generative-ai-HPNDIAZD.js +2 -0
- package/dist/bundle/chunks/google-vertex-KPAWJ4SP.js +2 -0
- package/dist/bundle/chunks/https-proxy-agent-WQIRL24U.js +13 -0
- package/dist/bundle/chunks/image-resize-worker.js +2 -0
- package/dist/bundle/chunks/jiti-loader-RKXLMQV2.js +2 -0
- package/dist/bundle/chunks/kimi-coding.js +2 -0
- package/dist/bundle/chunks/lib-ULKZYRGD.js +9 -0
- package/dist/bundle/chunks/llama-cpp-classify-EJ5XMSQL.js +22 -0
- package/dist/bundle/chunks/meta.js +2 -0
- package/dist/bundle/chunks/mistral-conversations-FMSPWQ7A.js +5 -0
- package/dist/bundle/chunks/multipart-parser-HMCXZ4BD.js +3 -0
- package/dist/bundle/chunks/node-4JNG6XQO.js +16 -0
- package/dist/bundle/chunks/node-6IIDYB3K.js +2 -0
- package/dist/bundle/chunks/openai-chatgpt.js +75 -0
- package/dist/bundle/chunks/openai-codex-responses-TU7NGPXE.js +10 -0
- package/dist/bundle/chunks/openai-codex.js +75 -0
- package/dist/bundle/chunks/openai-completions-GANCQQO5.js +7 -0
- package/dist/bundle/chunks/openai-responses-ASDPAX3E.js +3 -0
- package/dist/bundle/chunks/opencode-go.js +2 -0
- package/dist/bundle/chunks/openrouter-images-NROSQXMZ.js +2 -0
- package/dist/bundle/chunks/openrouter.js +75 -0
- package/dist/bundle/chunks/pi-messages-2QEJYOAO.js +8 -0
- package/dist/bundle/chunks/radius.js +75 -0
- package/dist/bundle/chunks/runtime-RYUR6LRB.js +2 -0
- package/dist/bundle/chunks/settings-manager-CHEMMAGQ.js +2 -0
- package/dist/bundle/chunks/src-KDGO7EGF.js +4 -0
- package/dist/bundle/chunks/typesafe-system-one-YBEEY5XU.js +2 -0
- package/dist/bundle/chunks/virtual-modules-OC56AAJ7.js +2 -0
- package/dist/bundle/chunks/xai.js +75 -0
- package/dist/bundle/cli-runtime.js +3 -0
- package/dist/bundle/cli.js +5 -0
- package/dist/bundle/index.js +2 -0
- package/dist/bundle/rpc-entry.js +3 -0
- package/dist/cli/args.d.ts +4 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +72 -21
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/auth-check.d.ts +19 -0
- package/dist/cli/auth-check.d.ts.map +1 -0
- package/dist/cli/auth-check.js +50 -0
- package/dist/cli/auth-check.js.map +1 -0
- package/dist/cli/auth-command.d.ts +24 -0
- package/dist/cli/auth-command.d.ts.map +1 -0
- package/dist/cli/auth-command.js +103 -0
- package/dist/cli/auth-command.js.map +1 -0
- package/dist/cli/config-selector.d.ts.map +1 -1
- package/dist/cli/config-selector.js +3 -2
- package/dist/cli/config-selector.js.map +1 -1
- package/dist/cli/credential-print.d.ts +5 -3
- package/dist/cli/credential-print.d.ts.map +1 -1
- package/dist/cli/credential-print.js +42 -30
- package/dist/cli/credential-print.js.map +1 -1
- package/dist/cli/file-processor.d.ts +1 -1
- package/dist/cli/file-processor.d.ts.map +1 -1
- package/dist/cli/file-processor.js +2 -1
- package/dist/cli/file-processor.js.map +1 -1
- package/dist/cli/list-models.d.ts +1 -1
- package/dist/cli/list-models.d.ts.map +1 -1
- package/dist/cli/list-models.js +2 -2
- package/dist/cli/list-models.js.map +1 -1
- package/dist/cli/session-picker.d.ts +1 -1
- package/dist/cli/session-picker.d.ts.map +1 -1
- package/dist/cli/session-picker.js.map +1 -1
- package/dist/cli/setup.d.ts +2 -0
- package/dist/cli/setup.d.ts.map +1 -0
- package/dist/cli/setup.js +12 -0
- package/dist/cli/setup.js.map +1 -0
- package/dist/cli/startup-ui.d.ts +2 -2
- package/dist/cli/startup-ui.d.ts.map +1 -1
- package/dist/cli/startup-ui.js +42 -33
- package/dist/cli/startup-ui.js.map +1 -1
- package/dist/cli.js +3 -12
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +20 -4
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +42 -6
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +12 -3
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +1 -0
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +14 -0
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +237 -39
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +1386 -565
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts +20 -8
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +199 -56
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/bug-report-upload.d.ts +11 -0
- package/dist/core/bug-report-upload.d.ts.map +1 -0
- package/dist/core/bug-report-upload.js +20 -0
- package/dist/core/bug-report-upload.js.map +1 -0
- package/dist/core/bug-report.d.ts +176 -0
- package/dist/core/bug-report.d.ts.map +1 -0
- package/dist/core/bug-report.js +292 -0
- package/dist/core/bug-report.js.map +1 -0
- package/dist/core/builtins/duet.js +2 -2
- package/dist/core/builtins/duet.js.map +1 -1
- package/dist/core/cache-stats.d.ts.map +1 -1
- package/dist/core/cache-stats.js +12 -1
- package/dist/core/cache-stats.js.map +1 -1
- package/dist/core/cache-warmer.d.ts +103 -0
- package/dist/core/cache-warmer.d.ts.map +1 -0
- package/dist/core/cache-warmer.js +356 -0
- package/dist/core/cache-warmer.js.map +1 -0
- package/dist/core/checkpoints/checkpoint-manager.d.ts +8 -4
- package/dist/core/checkpoints/checkpoint-manager.d.ts.map +1 -1
- package/dist/core/checkpoints/checkpoint-manager.js +46 -10
- package/dist/core/checkpoints/checkpoint-manager.js.map +1 -1
- package/dist/core/checkpoints/rewind.d.ts +4 -2
- package/dist/core/checkpoints/rewind.d.ts.map +1 -1
- package/dist/core/checkpoints/rewind.js +4 -3
- package/dist/core/checkpoints/rewind.js.map +1 -1
- package/dist/core/compaction/branch-summarization.js +2 -2
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +9 -6
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +196 -118
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/compaction/utils.d.ts +2 -1
- package/dist/core/compaction/utils.d.ts.map +1 -1
- package/dist/core/compaction/utils.js +25 -18
- package/dist/core/compaction/utils.js.map +1 -1
- package/dist/core/context-windows.d.ts.map +1 -1
- package/dist/core/context-windows.js +13 -3
- package/dist/core/context-windows.js.map +1 -1
- package/dist/core/crash-log.d.ts +27 -0
- package/dist/core/crash-log.d.ts.map +1 -0
- package/dist/core/crash-log.js +140 -0
- package/dist/core/crash-log.js.map +1 -0
- package/dist/core/defaults.d.ts +1 -0
- package/dist/core/defaults.d.ts.map +1 -1
- package/dist/core/defaults.js +9 -0
- package/dist/core/defaults.js.map +1 -1
- package/dist/core/experimental.js +1 -1
- package/dist/core/experimental.js.map +1 -1
- package/dist/core/export-html/template.css +10 -0
- package/dist/core/export-html/template.js +72 -18
- package/dist/core/extensions/index.d.ts +2 -2
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/jiti-loader.d.ts +2 -0
- package/dist/core/extensions/jiti-loader.d.ts.map +1 -0
- package/dist/core/extensions/jiti-loader.js +5 -0
- package/dist/core/extensions/jiti-loader.js.map +1 -0
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +228 -89
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +47 -8
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +376 -104
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +521 -88
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js +3 -0
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/extensions/virtual-modules.d.ts +3 -0
- package/dist/core/extensions/virtual-modules.d.ts.map +1 -0
- package/dist/core/extensions/virtual-modules.js +37 -0
- package/dist/core/extensions/virtual-modules.js.map +1 -0
- package/dist/core/extensions/wrapper.d.ts +2 -2
- package/dist/core/extensions/wrapper.d.ts.map +1 -1
- package/dist/core/extensions/wrapper.js +3 -22
- package/dist/core/extensions/wrapper.js.map +1 -1
- package/dist/core/footer-data-provider.d.ts +1 -1
- package/dist/core/footer-data-provider.js +19 -18
- package/dist/core/footer-data-provider.js.map +1 -1
- package/dist/core/index.d.ts +2 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/keybindings.d.ts +83 -13
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +33 -7
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/mcp-servers.d.ts +119 -0
- package/dist/core/mcp-servers.d.ts.map +1 -0
- package/dist/core/mcp-servers.js +191 -0
- package/dist/core/mcp-servers.js.map +1 -0
- package/dist/core/messages.d.ts +1 -1
- package/dist/core/messages.d.ts.map +1 -1
- package/dist/core/messages.js +1 -0
- package/dist/core/messages.js.map +1 -1
- package/dist/core/model-config.d.ts +202 -20
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +53 -18
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-registry.d.ts +19 -2
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +39 -2
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts +7 -5
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +29 -17
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-runtime.d.ts +79 -20
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +460 -134
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/models-store.d.ts +12 -7
- package/dist/core/models-store.d.ts.map +1 -1
- package/dist/core/models-store.js +87 -18
- package/dist/core/models-store.js.map +1 -1
- package/dist/core/multi-agent/fsm.js +8 -3
- package/dist/core/multi-agent/fsm.js.map +1 -1
- package/dist/core/multi-agent/mailbox.js +1 -3
- package/dist/core/multi-agent/mailbox.js.map +1 -1
- package/dist/core/multi-agent/permission-gate.d.ts +5 -2
- package/dist/core/multi-agent/permission-gate.d.ts.map +1 -1
- package/dist/core/multi-agent/permission-gate.js +597 -34
- package/dist/core/multi-agent/permission-gate.js.map +1 -1
- package/dist/core/multi-agent/task-board.js +2 -4
- package/dist/core/multi-agent/task-board.js.map +1 -1
- package/dist/core/multi-agent/worktree.js +1 -3
- package/dist/core/multi-agent/worktree.js.map +1 -1
- package/dist/core/nested-tool-calls.d.ts +102 -0
- package/dist/core/nested-tool-calls.d.ts.map +1 -0
- package/dist/core/nested-tool-calls.js +178 -0
- package/dist/core/nested-tool-calls.js.map +1 -0
- package/dist/core/package-manager.d.ts +10 -0
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +149 -33
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/pi-manifest.d.ts.map +1 -1
- package/dist/core/pi-manifest.js +13 -12
- package/dist/core/pi-manifest.js.map +1 -1
- package/dist/core/prompt-templates.d.ts +6 -1
- package/dist/core/prompt-templates.d.ts.map +1 -1
- package/dist/core/prompt-templates.js +63 -37
- package/dist/core/prompt-templates.js.map +1 -1
- package/dist/core/provider-attribution.js +5 -5
- package/dist/core/provider-attribution.js.map +1 -1
- package/dist/core/provider-composer.d.ts +44 -20
- package/dist/core/provider-composer.d.ts.map +1 -1
- package/dist/core/provider-composer.js +151 -51
- package/dist/core/provider-composer.js.map +1 -1
- package/dist/core/radius.d.ts +13 -0
- package/dist/core/radius.d.ts.map +1 -1
- package/dist/core/radius.js +19 -0
- package/dist/core/radius.js.map +1 -1
- package/dist/core/remote-catalog-provider.d.ts +10 -3
- package/dist/core/remote-catalog-provider.d.ts.map +1 -1
- package/dist/core/remote-catalog-provider.js +105 -81
- package/dist/core/remote-catalog-provider.js.map +1 -1
- package/dist/core/resource-loader.d.ts +7 -1
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +219 -42
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/runtime-credentials.d.ts +5 -5
- package/dist/core/runtime-credentials.d.ts.map +1 -1
- package/dist/core/runtime-credentials.js +13 -9
- package/dist/core/runtime-credentials.js.map +1 -1
- package/dist/core/sandbox/executor.js +1 -0
- package/dist/core/sandbox/executor.js.map +1 -1
- package/dist/core/sdk.d.ts +7 -5
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +100 -52
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-cwd.js +1 -0
- package/dist/core/session-cwd.js.map +1 -1
- package/dist/core/session-export.d.ts +8 -0
- package/dist/core/session-export.d.ts.map +1 -0
- package/dist/core/session-export.js +33 -0
- package/dist/core/session-export.js.map +1 -0
- package/dist/core/session-manager.d.ts +75 -15
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +314 -144
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-diagnostics.d.ts +9 -0
- package/dist/core/settings-diagnostics.d.ts.map +1 -0
- package/dist/core/settings-diagnostics.js +21 -0
- package/dist/core/settings-diagnostics.js.map +1 -0
- package/dist/core/settings-manager.d.ts +84 -4
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +239 -25
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +51 -33
- package/dist/core/skills.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +3 -1
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/soak/soak-log.js +6 -0
- package/dist/core/soak/soak-log.js.map +1 -1
- package/dist/core/socket-server/socket-server.js +11 -0
- package/dist/core/socket-server/socket-server.js.map +1 -1
- package/dist/core/socket-server/types.d.ts +2 -1
- package/dist/core/socket-server/types.d.ts.map +1 -1
- package/dist/core/socket-server/types.js.map +1 -1
- package/dist/core/source-info.d.ts +8 -0
- package/dist/core/source-info.d.ts.map +1 -1
- package/dist/core/source-info.js +16 -0
- package/dist/core/source-info.js.map +1 -1
- package/dist/core/system-prompt.d.ts +49 -6
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +126 -89
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/bash.d.ts +32 -2
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +82 -143
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit-diff.d.ts +0 -5
- package/dist/core/tools/edit-diff.d.ts.map +1 -1
- package/dist/core/tools/edit-diff.js +2 -5
- package/dist/core/tools/edit-diff.js.map +1 -1
- package/dist/core/tools/edit.d.ts +5 -12
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +19 -171
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/find.d.ts +4 -0
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js +11 -58
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/grep.d.ts +4 -0
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js +10 -62
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/index.d.ts +4 -1
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +18 -1
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/ls.d.ts +4 -0
- package/dist/core/tools/ls.d.ts.map +1 -1
- package/dist/core/tools/ls.js +9 -50
- package/dist/core/tools/ls.js.map +1 -1
- package/dist/core/tools/output-accumulator.d.ts +11 -0
- package/dist/core/tools/output-accumulator.d.ts.map +1 -1
- package/dist/core/tools/output-accumulator.js +54 -12
- package/dist/core/tools/output-accumulator.js.map +1 -1
- package/dist/core/tools/powershell.d.ts +16 -0
- package/dist/core/tools/powershell.d.ts.map +1 -0
- package/dist/core/tools/powershell.js +39 -0
- package/dist/core/tools/powershell.js.map +1 -0
- package/dist/core/tools/read.d.ts +8 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +16 -123
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/render-utils.d.ts +6 -0
- package/dist/core/tools/render-utils.d.ts.map +1 -1
- package/dist/core/tools/render-utils.js +26 -0
- package/dist/core/tools/render-utils.js.map +1 -1
- package/dist/core/tools/renderers/bash.d.ts +12 -0
- package/dist/core/tools/renderers/bash.d.ts.map +1 -0
- package/dist/core/tools/renderers/bash.js +117 -0
- package/dist/core/tools/renderers/bash.js.map +1 -0
- package/dist/core/tools/renderers/edit.d.ts +23 -0
- package/dist/core/tools/renderers/edit.d.ts.map +1 -0
- package/dist/core/tools/renderers/edit.js +167 -0
- package/dist/core/tools/renderers/edit.js.map +1 -0
- package/dist/core/tools/renderers/find.d.ts +10 -0
- package/dist/core/tools/renderers/find.d.ts.map +1 -0
- package/dist/core/tools/renderers/find.js +64 -0
- package/dist/core/tools/renderers/find.js.map +1 -0
- package/dist/core/tools/renderers/grep.d.ts +10 -0
- package/dist/core/tools/renderers/grep.d.ts.map +1 -0
- package/dist/core/tools/renderers/grep.js +69 -0
- package/dist/core/tools/renderers/grep.js.map +1 -0
- package/dist/core/tools/renderers/index.d.ts +28 -0
- package/dist/core/tools/renderers/index.d.ts.map +1 -0
- package/dist/core/tools/renderers/index.js +47 -0
- package/dist/core/tools/renderers/index.js.map +1 -0
- package/dist/core/tools/renderers/ls.d.ts +10 -0
- package/dist/core/tools/renderers/ls.d.ts.map +1 -0
- package/dist/core/tools/renderers/ls.js +58 -0
- package/dist/core/tools/renderers/ls.js.map +1 -0
- package/dist/core/tools/renderers/read.d.ts +11 -0
- package/dist/core/tools/renderers/read.d.ts.map +1 -0
- package/dist/core/tools/renderers/read.js +130 -0
- package/dist/core/tools/renderers/read.js.map +1 -0
- package/dist/core/tools/renderers/write.d.ts +10 -0
- package/dist/core/tools/renderers/write.d.ts.map +1 -0
- package/dist/core/tools/renderers/write.js +153 -0
- package/dist/core/tools/renderers/write.js.map +1 -0
- package/dist/core/tools/tool-definition-wrapper.d.ts +5 -3
- package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.js +3 -1
- package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
- package/dist/core/tools/truncate.d.ts +14 -0
- package/dist/core/tools/truncate.d.ts.map +1 -1
- package/dist/core/tools/truncate.js +29 -0
- package/dist/core/tools/truncate.js.map +1 -1
- package/dist/core/tools/write.d.ts +4 -0
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +12 -147
- package/dist/core/tools/write.js.map +1 -1
- package/dist/core/trust-manager.d.ts.map +1 -1
- package/dist/core/trust-manager.js +4 -1
- package/dist/core/trust-manager.js.map +1 -1
- package/dist/core/usage-totals.d.ts +3 -1
- package/dist/core/usage-totals.d.ts.map +1 -1
- package/dist/core/usage-totals.js +28 -1
- package/dist/core/usage-totals.js.map +1 -1
- package/dist/core/virtual-models.d.ts +117 -0
- package/dist/core/virtual-models.d.ts.map +1 -0
- package/dist/core/virtual-models.js +124 -0
- package/dist/core/virtual-models.js.map +1 -0
- package/dist/experimental/micro/api.d.ts +81 -0
- package/dist/experimental/micro/api.d.ts.map +1 -0
- package/dist/experimental/micro/api.js +2 -0
- package/dist/experimental/micro/api.js.map +1 -0
- package/dist/experimental/micro/main.d.ts +3 -0
- package/dist/experimental/micro/main.d.ts.map +1 -0
- package/dist/experimental/micro/main.js +21 -0
- package/dist/experimental/micro/main.js.map +1 -0
- package/dist/experimental/micro/models.d.ts +11 -0
- package/dist/experimental/micro/models.d.ts.map +1 -0
- package/dist/experimental/micro/models.js +95 -0
- package/dist/experimental/micro/models.js.map +1 -0
- package/dist/experimental/micro/runtime.d.ts +12 -0
- package/dist/experimental/micro/runtime.d.ts.map +1 -0
- package/dist/experimental/micro/runtime.js +465 -0
- package/dist/experimental/micro/runtime.js.map +1 -0
- package/dist/experimental/micro/sessions.d.ts +10 -0
- package/dist/experimental/micro/sessions.d.ts.map +1 -0
- package/dist/experimental/micro/sessions.js +41 -0
- package/dist/experimental/micro/sessions.js.map +1 -0
- package/dist/experimental/micro/tools.d.ts +10 -0
- package/dist/experimental/micro/tools.d.ts.map +1 -0
- package/dist/experimental/micro/tools.js +96 -0
- package/dist/experimental/micro/tools.js.map +1 -0
- package/dist/experimental/micro/tui.d.ts +3 -0
- package/dist/experimental/micro/tui.d.ts.map +1 -0
- package/dist/experimental/micro/tui.js +510 -0
- package/dist/experimental/micro/tui.js.map +1 -0
- package/dist/experimental/mini/main.d.ts +7 -0
- package/dist/experimental/mini/main.d.ts.map +1 -0
- package/dist/experimental/mini/main.js +21 -0
- package/dist/experimental/mini/main.js.map +1 -0
- package/dist/experimental/mini/server/entry.d.ts +3 -0
- package/dist/experimental/mini/server/entry.d.ts.map +1 -0
- package/dist/experimental/mini/server/entry.js +11 -0
- package/dist/experimental/mini/server/entry.js.map +1 -0
- package/dist/experimental/mini/server/run.d.ts +13 -0
- package/dist/experimental/mini/server/run.d.ts.map +1 -0
- package/dist/experimental/mini/server/run.js +150 -0
- package/dist/experimental/mini/server/run.js.map +1 -0
- package/dist/experimental/mini/shared/protocol.d.ts +127 -0
- package/dist/experimental/mini/shared/protocol.d.ts.map +1 -0
- package/dist/experimental/mini/shared/protocol.js +13 -0
- package/dist/experimental/mini/shared/protocol.js.map +1 -0
- package/dist/experimental/mini/shared/rpc.d.ts +49 -0
- package/dist/experimental/mini/shared/rpc.d.ts.map +1 -0
- package/dist/experimental/mini/shared/rpc.js +171 -0
- package/dist/experimental/mini/shared/rpc.js.map +1 -0
- package/dist/experimental/mini/shared/transport.d.ts +35 -0
- package/dist/experimental/mini/shared/transport.d.ts.map +1 -0
- package/dist/experimental/mini/shared/transport.js +94 -0
- package/dist/experimental/mini/shared/transport.js.map +1 -0
- package/dist/experimental/mini/tui/run.d.ts +9 -0
- package/dist/experimental/mini/tui/run.d.ts.map +1 -0
- package/dist/experimental/mini/tui/run.js +62 -0
- package/dist/experimental/mini/tui/run.js.map +1 -0
- package/dist/experimental/mini/tui/session.d.ts +26 -0
- package/dist/experimental/mini/tui/session.d.ts.map +1 -0
- package/dist/experimental/mini/tui/session.js +94 -0
- package/dist/experimental/mini/tui/session.js.map +1 -0
- package/dist/experimental/mini/tui/view.d.ts +10 -0
- package/dist/experimental/mini/tui/view.d.ts.map +1 -0
- package/dist/experimental/mini/tui/view.js +461 -0
- package/dist/experimental/mini/tui/view.js.map +1 -0
- package/dist/experimental/mini/worker/entry.d.ts +3 -0
- package/dist/experimental/mini/worker/entry.d.ts.map +1 -0
- package/dist/experimental/mini/worker/entry.js +10 -0
- package/dist/experimental/mini/worker/entry.js.map +1 -0
- package/dist/experimental/mini/worker/lane-service.d.ts +44 -0
- package/dist/experimental/mini/worker/lane-service.d.ts.map +1 -0
- package/dist/experimental/mini/worker/lane-service.js +97 -0
- package/dist/experimental/mini/worker/lane-service.js.map +1 -0
- package/dist/experimental/mini/worker/models-service.d.ts +19 -0
- package/dist/experimental/mini/worker/models-service.d.ts.map +1 -0
- package/dist/experimental/mini/worker/models-service.js +136 -0
- package/dist/experimental/mini/worker/models-service.js.map +1 -0
- package/dist/experimental/mini/worker/run.d.ts +14 -0
- package/dist/experimental/mini/worker/run.d.ts.map +1 -0
- package/dist/experimental/mini/worker/run.js +88 -0
- package/dist/experimental/mini/worker/run.js.map +1 -0
- package/dist/extensions/codemode/execute.d.ts +16 -0
- package/dist/extensions/codemode/execute.d.ts.map +1 -0
- package/dist/extensions/codemode/execute.js +429 -0
- package/dist/extensions/codemode/execute.js.map +1 -0
- package/dist/extensions/codemode/execute.lazy.d.ts +3 -0
- package/dist/extensions/codemode/execute.lazy.d.ts.map +1 -0
- package/dist/extensions/codemode/execute.lazy.js +3 -0
- package/dist/extensions/codemode/execute.lazy.js.map +1 -0
- package/dist/extensions/codemode/index.d.ts +21 -0
- package/dist/extensions/codemode/index.d.ts.map +1 -0
- package/dist/extensions/codemode/index.js +31 -0
- package/dist/extensions/codemode/index.js.map +1 -0
- package/dist/extensions/codemode/renderer.d.ts +12 -0
- package/dist/extensions/codemode/renderer.d.ts.map +1 -0
- package/dist/extensions/codemode/renderer.js +137 -0
- package/dist/extensions/codemode/renderer.js.map +1 -0
- package/dist/extensions/codemode/tool.d.ts +123 -0
- package/dist/extensions/codemode/tool.d.ts.map +1 -0
- package/dist/extensions/codemode/tool.js +315 -0
- package/dist/extensions/codemode/tool.js.map +1 -0
- package/dist/extensions/codemode/worker.d.ts +7 -0
- package/dist/extensions/codemode/worker.d.ts.map +1 -0
- package/dist/extensions/codemode/worker.js +7 -0
- package/dist/extensions/codemode/worker.js.map +1 -0
- package/dist/extensions/index.d.ts.map +1 -1
- package/dist/extensions/index.js +9 -1
- package/dist/extensions/index.js.map +1 -1
- package/dist/extensions/llama/client.d.ts +8 -0
- package/dist/extensions/llama/client.d.ts.map +1 -1
- package/dist/extensions/llama/client.js +13 -0
- package/dist/extensions/llama/client.js.map +1 -1
- package/dist/extensions/llama/huggingface.js +2 -0
- package/dist/extensions/llama/huggingface.js.map +1 -1
- package/dist/extensions/llama/index.d.ts.map +1 -1
- package/dist/extensions/llama/index.js +13 -2
- package/dist/extensions/llama/index.js.map +1 -1
- package/dist/extensions/llama/provider.d.ts +4 -2
- package/dist/extensions/llama/provider.d.ts.map +1 -1
- package/dist/extensions/llama/provider.js +119 -17
- package/dist/extensions/llama/provider.js.map +1 -1
- package/dist/extensions/llama/ui.js +28 -12
- package/dist/extensions/llama/ui.js.map +1 -1
- package/dist/extensions/mcp/cli.d.ts +21 -0
- package/dist/extensions/mcp/cli.d.ts.map +1 -0
- package/dist/extensions/mcp/cli.js +500 -0
- package/dist/extensions/mcp/cli.js.map +1 -0
- package/dist/extensions/mcp/cli.lazy.d.ts +3 -0
- package/dist/extensions/mcp/cli.lazy.d.ts.map +1 -0
- package/dist/extensions/mcp/cli.lazy.js +3 -0
- package/dist/extensions/mcp/cli.lazy.js.map +1 -0
- package/dist/extensions/mcp/config.d.ts +72 -0
- package/dist/extensions/mcp/config.d.ts.map +1 -0
- package/dist/extensions/mcp/config.js +158 -0
- package/dist/extensions/mcp/config.js.map +1 -0
- package/dist/extensions/mcp/index.d.ts +76 -0
- package/dist/extensions/mcp/index.d.ts.map +1 -0
- package/dist/extensions/mcp/index.js +1055 -0
- package/dist/extensions/mcp/index.js.map +1 -0
- package/dist/extensions/mcp/log.d.ts +16 -0
- package/dist/extensions/mcp/log.d.ts.map +1 -0
- package/dist/extensions/mcp/log.js +66 -0
- package/dist/extensions/mcp/log.js.map +1 -0
- package/dist/extensions/mcp/oauth.d.ts +96 -0
- package/dist/extensions/mcp/oauth.d.ts.map +1 -0
- package/dist/extensions/mcp/oauth.js +333 -0
- package/dist/extensions/mcp/oauth.js.map +1 -0
- package/dist/extensions/mcp/resources.d.ts +43 -0
- package/dist/extensions/mcp/resources.d.ts.map +1 -0
- package/dist/extensions/mcp/resources.js +262 -0
- package/dist/extensions/mcp/resources.js.map +1 -0
- package/dist/extensions/mcp/runtime.d.ts +98 -0
- package/dist/extensions/mcp/runtime.d.ts.map +1 -0
- package/dist/extensions/mcp/runtime.js +394 -0
- package/dist/extensions/mcp/runtime.js.map +1 -0
- package/dist/extensions/mcp/runtime.lazy.d.ts +3 -0
- package/dist/extensions/mcp/runtime.lazy.d.ts.map +1 -0
- package/dist/extensions/mcp/runtime.lazy.js +3 -0
- package/dist/extensions/mcp/runtime.lazy.js.map +1 -0
- package/dist/extensions/mcp/tools.d.ts +84 -0
- package/dist/extensions/mcp/tools.d.ts.map +1 -0
- package/dist/extensions/mcp/tools.js +251 -0
- package/dist/extensions/mcp/tools.js.map +1 -0
- package/dist/extensions/mcp/ui.d.ts +60 -0
- package/dist/extensions/mcp/ui.d.ts.map +1 -0
- package/dist/extensions/mcp/ui.js +174 -0
- package/dist/extensions/mcp/ui.js.map +1 -0
- package/dist/extensions/stub-provider/provider.d.ts +2 -2
- package/dist/extensions/stub-provider/provider.d.ts.map +1 -1
- package/dist/extensions/stub-provider/provider.js +2 -1
- package/dist/extensions/stub-provider/provider.js.map +1 -1
- package/dist/extensions/tool-search/index.d.ts +12 -0
- package/dist/extensions/tool-search/index.d.ts.map +1 -0
- package/dist/extensions/tool-search/index.js +15 -0
- package/dist/extensions/tool-search/index.js.map +1 -0
- package/dist/extensions/tool-search/tool.d.ts +73 -0
- package/dist/extensions/tool-search/tool.d.ts.map +1 -0
- package/dist/extensions/tool-search/tool.js +189 -0
- package/dist/extensions/tool-search/tool.js.map +1 -0
- package/dist/index.d.ts +20 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -6
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts +4 -0
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +123 -51
- package/dist/main.js.map +1 -1
- package/dist/migrations.d.ts +1 -1
- package/dist/migrations.js +7 -6
- package/dist/migrations.js.map +1 -1
- package/dist/modes/index.d.ts +1 -0
- package/dist/modes/index.d.ts.map +1 -1
- package/dist/modes/index.js.map +1 -1
- package/dist/modes/interactive/bug-report.d.ts +19 -0
- package/dist/modes/interactive/bug-report.d.ts.map +1 -0
- package/dist/modes/interactive/bug-report.js +211 -0
- package/dist/modes/interactive/bug-report.js.map +1 -0
- package/dist/modes/interactive/chat-viewport.d.ts +20 -0
- package/dist/modes/interactive/chat-viewport.d.ts.map +1 -0
- package/dist/modes/interactive/chat-viewport.js +28 -0
- package/dist/modes/interactive/chat-viewport.js.map +1 -0
- package/dist/modes/interactive/components/armin.js +10 -6
- package/dist/modes/interactive/components/armin.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts +6 -2
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +38 -15
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/bash-execution.js +9 -4
- package/dist/modes/interactive/components/bash-execution.js.map +1 -1
- package/dist/modes/interactive/components/bordered-loader.js +3 -0
- package/dist/modes/interactive/components/bordered-loader.js.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts +1 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.js +15 -6
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.d.ts +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.js +15 -6
- package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/config-selector.js +35 -8
- package/dist/modes/interactive/components/config-selector.js.map +1 -1
- package/dist/modes/interactive/components/countdown-timer.js +5 -0
- package/dist/modes/interactive/components/countdown-timer.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts +10 -1
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js +54 -2
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/custom-entry.js +4 -1
- package/dist/modes/interactive/components/custom-entry.js.map +1 -1
- package/dist/modes/interactive/components/custom-message.js +7 -1
- package/dist/modes/interactive/components/custom-message.js.map +1 -1
- package/dist/modes/interactive/components/daxnuts.js +8 -6
- package/dist/modes/interactive/components/daxnuts.js.map +1 -1
- package/dist/modes/interactive/components/dynamic-border.js +1 -0
- package/dist/modes/interactive/components/dynamic-border.js.map +1 -1
- package/dist/modes/interactive/components/extension-editor.d.ts +4 -1
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-editor.js +14 -3
- package/dist/modes/interactive/components/extension-editor.js.map +1 -1
- package/dist/modes/interactive/components/extension-input.d.ts +2 -0
- package/dist/modes/interactive/components/extension-input.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-input.js +14 -2
- package/dist/modes/interactive/components/extension-input.js.map +1 -1
- package/dist/modes/interactive/components/extension-selector.d.ts +1 -0
- package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-selector.js +16 -1
- package/dist/modes/interactive/components/extension-selector.js.map +1 -1
- package/dist/modes/interactive/components/first-time-setup.d.ts +4 -4
- package/dist/modes/interactive/components/first-time-setup.d.ts.map +1 -1
- package/dist/modes/interactive/components/first-time-setup.js +12 -4
- package/dist/modes/interactive/components/first-time-setup.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts +7 -0
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +51 -6
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/index.d.ts +1 -1
- package/dist/modes/interactive/components/index.d.ts.map +1 -1
- package/dist/modes/interactive/components/index.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +9 -3
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/markdown-transform.d.ts +3 -0
- package/dist/modes/interactive/components/markdown-transform.d.ts.map +1 -0
- package/dist/modes/interactive/components/markdown-transform.js +19 -0
- package/dist/modes/interactive/components/markdown-transform.js.map +1 -0
- package/dist/modes/interactive/components/mermaid.d.ts +11 -0
- package/dist/modes/interactive/components/mermaid.d.ts.map +1 -0
- package/dist/modes/interactive/components/mermaid.js +75 -0
- package/dist/modes/interactive/components/mermaid.js.map +1 -0
- package/dist/modes/interactive/components/model-selector.d.ts +10 -4
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +101 -40
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.js +11 -3
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +4 -0
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js +60 -32
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts +5 -5
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +128 -78
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +23 -4
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +230 -67
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-submenu.d.ts +72 -0
- package/dist/modes/interactive/components/settings-submenu.d.ts.map +1 -0
- package/dist/modes/interactive/components/settings-submenu.js +165 -0
- package/dist/modes/interactive/components/settings-submenu.js.map +1 -0
- package/dist/modes/interactive/components/show-images-selector.js +1 -0
- package/dist/modes/interactive/components/show-images-selector.js.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.js +14 -5
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
- package/dist/modes/interactive/components/status-indicator.d.ts +3 -1
- package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -1
- package/dist/modes/interactive/components/status-indicator.js +12 -3
- package/dist/modes/interactive/components/status-indicator.js.map +1 -1
- package/dist/modes/interactive/components/theme-selector.js +2 -0
- package/dist/modes/interactive/components/theme-selector.js.map +1 -1
- package/dist/modes/interactive/components/themed-text.d.ts +17 -0
- package/dist/modes/interactive/components/themed-text.d.ts.map +1 -0
- package/dist/modes/interactive/components/themed-text.js +29 -0
- package/dist/modes/interactive/components/themed-text.js.map +1 -0
- package/dist/modes/interactive/components/thinking-selector.d.ts +15 -3
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.js +76 -18
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +21 -4
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +78 -52
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector.js +44 -18
- package/dist/modes/interactive/components/tree-selector.js.map +1 -1
- package/dist/modes/interactive/components/trust-selector.js +8 -2
- package/dist/modes/interactive/components/trust-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message-selector.js +6 -3
- package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message.d.ts +3 -1
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message.js +12 -2
- package/dist/modes/interactive/components/user-message.js.map +1 -1
- package/dist/modes/interactive/components/visual-truncate.d.ts +27 -3
- package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -1
- package/dist/modes/interactive/components/visual-truncate.js +39 -6
- package/dist/modes/interactive/components/visual-truncate.js.map +1 -1
- package/dist/modes/interactive/external-editor.d.ts.map +1 -1
- package/dist/modes/interactive/external-editor.js +2 -1
- package/dist/modes/interactive/external-editor.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +69 -5
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +1314 -593
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/model-catalog-refresh.d.ts +7 -0
- package/dist/modes/interactive/model-catalog-refresh.d.ts.map +1 -0
- package/dist/modes/interactive/model-catalog-refresh.js +34 -0
- package/dist/modes/interactive/model-catalog-refresh.js.map +1 -0
- package/dist/modes/interactive/session-share.d.ts +23 -0
- package/dist/modes/interactive/session-share.d.ts.map +1 -0
- package/dist/modes/interactive/session-share.js +130 -0
- package/dist/modes/interactive/session-share.js.map +1 -0
- package/dist/modes/interactive/theme/dark.json +54 -63
- package/dist/modes/interactive/theme/light.json +52 -60
- package/dist/modes/interactive/theme/system-theme.d.ts +54 -0
- package/dist/modes/interactive/theme/system-theme.d.ts.map +1 -0
- package/dist/modes/interactive/theme/system-theme.js +535 -0
- package/dist/modes/interactive/theme/system-theme.js.map +1 -0
- package/dist/modes/interactive/theme/theme-controller.d.ts +59 -7
- package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme-controller.js +164 -51
- package/dist/modes/interactive/theme/theme-controller.js.map +1 -1
- package/dist/modes/interactive/theme/theme-json.d.ts +85 -0
- package/dist/modes/interactive/theme/theme-json.d.ts.map +1 -0
- package/dist/modes/interactive/theme/theme-json.js +132 -0
- package/dist/modes/interactive/theme/theme-json.js.map +1 -0
- package/dist/modes/interactive/theme/theme-schema.json +24 -3
- package/dist/modes/interactive/theme/theme.d.ts +80 -42
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +274 -417
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/interactive/tui-renderer.d.ts +22 -0
- package/dist/modes/interactive/tui-renderer.d.ts.map +1 -0
- package/dist/modes/interactive/tui-renderer.js +67 -0
- package/dist/modes/interactive/tui-renderer.js.map +1 -0
- package/dist/modes/json-event.d.ts +34 -0
- package/dist/modes/json-event.d.ts.map +1 -0
- package/dist/modes/json-event.js +29 -0
- package/dist/modes/json-event.js.map +1 -0
- package/dist/modes/print-mode.d.ts +1 -1
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js +12 -2
- package/dist/modes/print-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +17 -9
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +27 -15
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +14 -12
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +22 -1
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/package-manager-cli.d.ts +1 -0
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +217 -63
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/prompts/commands/plan-phase.md +1 -0
- package/dist/prompts/commands/review.md +2 -0
- package/dist/prompts/commands/verify-work.md +1 -0
- package/dist/prompts/commands/why.md +4 -0
- package/dist/rpc-entry.js +1 -0
- package/dist/rpc-entry.js.map +1 -1
- package/dist/skills/blast-radius/SKILL.md +1 -0
- package/dist/skills/explainers/SKILL.md +65 -0
- package/dist/skills/unslop/SKILL.md +19 -1
- package/dist/utils/abort.d.ts +5 -0
- package/dist/utils/abort.d.ts.map +1 -0
- package/dist/utils/abort.js +48 -0
- package/dist/utils/abort.js.map +1 -0
- package/dist/utils/changelog.js +1 -1
- package/dist/utils/changelog.js.map +1 -1
- package/dist/utils/child-process.d.ts +1 -1
- package/dist/utils/child-process.js +1 -1
- package/dist/utils/child-process.js.map +1 -1
- package/dist/utils/clipboard-command.d.ts +7 -0
- package/dist/utils/clipboard-command.d.ts.map +1 -0
- package/dist/utils/clipboard-command.js +45 -0
- package/dist/utils/clipboard-command.js.map +1 -0
- package/dist/utils/clipboard-image.d.ts.map +1 -1
- package/dist/utils/clipboard-image.js +60 -91
- package/dist/utils/clipboard-image.js.map +1 -1
- package/dist/utils/clipboard.d.ts +2 -0
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js +116 -121
- package/dist/utils/clipboard.js.map +1 -1
- package/dist/utils/draht-user-agent.d.ts +2 -0
- package/dist/utils/draht-user-agent.d.ts.map +1 -0
- package/dist/utils/draht-user-agent.js +5 -0
- package/dist/utils/draht-user-agent.js.map +1 -0
- package/dist/utils/exif-orientation.d.ts +2 -1
- package/dist/utils/exif-orientation.d.ts.map +1 -1
- package/dist/utils/exif-orientation.js.map +1 -1
- package/dist/utils/frontmatter.d.ts.map +1 -1
- package/dist/utils/frontmatter.js +2 -1
- package/dist/utils/frontmatter.js.map +1 -1
- package/dist/utils/management-http.d.ts +25 -0
- package/dist/utils/management-http.d.ts.map +1 -0
- package/dist/utils/management-http.js +54 -0
- package/dist/utils/management-http.js.map +1 -0
- package/dist/utils/mime.js +1 -1
- package/dist/utils/mime.js.map +1 -1
- package/dist/utils/paths.d.ts +4 -3
- package/dist/utils/paths.d.ts.map +1 -1
- package/dist/utils/paths.js +15 -4
- package/dist/utils/paths.js.map +1 -1
- package/dist/utils/photon.d.ts +2 -1
- package/dist/utils/photon.d.ts.map +1 -1
- package/dist/utils/photon.js.map +1 -1
- package/dist/utils/shell.d.ts +4 -3
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +20 -35
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/syntax-highlight.d.ts +1 -0
- package/dist/utils/syntax-highlight.d.ts.map +1 -1
- package/dist/utils/syntax-highlight.js +62 -1
- package/dist/utils/syntax-highlight.js.map +1 -1
- package/dist/utils/text.d.ts +8 -0
- package/dist/utils/text.d.ts.map +1 -0
- package/dist/utils/text.js +9 -0
- package/dist/utils/text.js.map +1 -0
- package/dist/utils/tool-result-images.d.ts +21 -0
- package/dist/utils/tool-result-images.d.ts.map +1 -0
- package/dist/utils/tool-result-images.js +48 -0
- package/dist/utils/tool-result-images.js.map +1 -0
- package/dist/utils/tools-manager.d.ts +11 -1
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +53 -36
- package/dist/utils/tools-manager.js.map +1 -1
- package/dist/utils/version-check.d.ts +4 -1
- package/dist/utils/version-check.d.ts.map +1 -1
- package/dist/utils/version-check.js +30 -9
- package/dist/utils/version-check.js.map +1 -1
- package/dist/utils/wsl.d.ts +3 -0
- package/dist/utils/wsl.d.ts.map +1 -0
- package/dist/utils/wsl.js +15 -0
- package/dist/utils/wsl.js.map +1 -0
- package/dist/utils/zip.d.ts +7 -0
- package/dist/utils/zip.d.ts.map +1 -0
- package/dist/utils/zip.js +60 -0
- package/dist/utils/zip.js.map +1 -0
- package/docs/cli-integration.md +106 -0
- package/docs/cli.md +374 -0
- package/docs/compaction.md +91 -29
- package/docs/configuration.md +47 -0
- package/docs/containerization.md +100 -66
- package/docs/custom-provider.md +109 -707
- package/docs/docs.json +155 -99
- package/docs/environment-variables.md +30 -17
- package/docs/extensions.md +169 -2811
- package/docs/how-pi-works.md +53 -0
- package/docs/images/interactive-mode.png +0 -0
- package/docs/index.md +25 -69
- package/docs/json.md +197 -56
- package/docs/keybindings.md +89 -93
- package/docs/llama-cpp.md +18 -3
- package/docs/mcp.md +231 -0
- package/docs/message-types.md +261 -0
- package/docs/models.md +94 -478
- package/docs/packages.md +67 -163
- package/docs/prompt-templates.md +31 -68
- package/docs/providers.md +118 -215
- package/docs/quickstart.md +55 -108
- package/docs/rpc-commands.md +860 -0
- package/docs/rpc-extension-ui.md +200 -0
- package/docs/rpc.md +139 -1518
- package/docs/sdk.md +79 -1127
- package/docs/security.md +76 -32
- package/docs/session-format.md +73 -219
- package/docs/sessions.md +36 -116
- package/docs/settings.md +124 -257
- package/docs/shell-aliases.md +85 -5
- package/docs/skills.md +52 -189
- package/docs/slash-commands.md +61 -0
- package/docs/terminal-setup.md +132 -61
- package/docs/termux.md +74 -84
- package/docs/themes.md +91 -252
- package/docs/tmux.md +31 -39
- package/docs/tui.md +74 -891
- package/docs/usage.md +54 -255
- package/docs/virtual-models.md +114 -0
- package/docs/windows.md +57 -7
- package/examples/extensions/antigravity-image-gen.ts +9 -9
- package/examples/extensions/bash-spawn-hook.ts +1 -1
- package/examples/extensions/border-status-editor.ts +1 -1
- package/examples/extensions/built-in-tool-renderer.ts +16 -40
- package/examples/extensions/custom-compaction.ts +1 -16
- package/examples/extensions/custom-provider-anthropic/index.ts +20 -13
- package/examples/extensions/custom-provider-gitlab-duo/index.ts +4 -3
- package/examples/extensions/custom-provider-gitlab-duo/test.ts +5 -5
- package/examples/extensions/debug-provider.ts +90 -0
- package/examples/extensions/doom-overlay/wad-finder.ts +7 -3
- package/examples/extensions/dynamic-resources/dynamic.json +3 -1
- package/examples/extensions/git-checkpoint.ts +2 -2
- package/examples/extensions/handoff.ts +2 -11
- package/examples/extensions/jev-router.ts +113 -0
- package/examples/extensions/minimal-mode.ts +24 -96
- package/examples/extensions/notify.ts +3 -1
- package/examples/extensions/prompt-customizer.ts +19 -67
- package/examples/extensions/qna.ts +3 -7
- package/examples/extensions/subagent/agents.ts +40 -9
- package/examples/extensions/subagent/index.ts +27 -4
- package/examples/extensions/summarize.ts +7 -18
- package/examples/extensions/titlebar-spinner.ts +1 -1
- package/examples/rpc-client.ts +35 -0
- package/examples/rpc-extension-ui.ts +38 -9
- package/examples/sdk/02-custom-model.ts +1 -2
- package/examples/sdk/06-extensions.ts +1 -1
- package/examples/sdk/09-api-keys-and-oauth.ts +1 -1
- package/examples/sdk/12-full-control.ts +1 -1
- package/examples/sdk/14-codemode-mcp.ts +61 -0
- package/package.json +25 -30
- package/prompts/commands/plan-phase.md +1 -0
- package/prompts/commands/review.md +2 -0
- package/prompts/commands/verify-work.md +1 -0
- package/prompts/commands/why.md +4 -0
- package/skills/blast-radius/SKILL.md +1 -0
- package/skills/explainers/SKILL.md +65 -0
- package/skills/unslop/SKILL.md +19 -1
- package/dist/utils/clipboard-native.d.ts +0 -11
- package/dist/utils/clipboard-native.d.ts.map +0 -1
- package/dist/utils/clipboard-native.js +0 -20
- package/dist/utils/clipboard-native.js.map +0 -1
- package/dist/utils/pi-user-agent.d.ts +0 -2
- package/dist/utils/pi-user-agent.d.ts.map +0 -1
- package/dist/utils/pi-user-agent.js +0 -5
- package/dist/utils/pi-user-agent.js.map +0 -1
- package/docs/development.md +0 -71
- package/docs/tree.md +0 -231
- package/examples/extensions/kimi-deferred-tools.ts +0 -61
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Presentation for the codemode tool.
|
|
3
|
+
*
|
|
4
|
+
* The call shows the script; the result lists the nested tool calls with their status as they
|
|
5
|
+
* run and the cost of its model calls, followed by the script output without the "Script completed"
|
|
6
|
+
* header. Nested calls are not
|
|
7
|
+
* separate tool rows because they never reach the model as tool calls.
|
|
8
|
+
*/
|
|
9
|
+
import { Container, Spacer, Text } from "@draht/tui";
|
|
10
|
+
import { getTextOutput, replaceTabs, str } from "../../core/tools/render-utils.js";
|
|
11
|
+
import { keyHint } from "../../modes/interactive/components/keybinding-hints.js";
|
|
12
|
+
import { VisualLinePreview } from "../../modes/interactive/components/visual-truncate.js";
|
|
13
|
+
import { highlightCode } from "../../modes/interactive/theme/theme.js";
|
|
14
|
+
const CODE_PREVIEW_LINES = 10;
|
|
15
|
+
const CALL_PREVIEW_COUNT = 8;
|
|
16
|
+
const OUTPUT_PREVIEW_LINES = 5;
|
|
17
|
+
const COLLAPSED_ARGS_CHARS = 80;
|
|
18
|
+
const SCRIPT_HEADER = /^Script (completed|failed)\nWall time [\d.]+ seconds\nOutput:\n$/;
|
|
19
|
+
function expandHint(theme, hidden, noun) {
|
|
20
|
+
return `${theme.fg("muted", `... (${hidden} more ${noun},`)} ${keyHint("app.tools.expand", "to expand")}${theme.fg("muted", ")")}`;
|
|
21
|
+
}
|
|
22
|
+
function formatDuration(ms) {
|
|
23
|
+
if (ms === undefined)
|
|
24
|
+
return "";
|
|
25
|
+
return ms < 1000 ? `${Math.round(ms)}ms` : `${(ms / 1000).toFixed(1)}s`;
|
|
26
|
+
}
|
|
27
|
+
/** Cents for larger amounts, two significant digits for the fractions of a cent classifier calls cost. */
|
|
28
|
+
function formatCost(cost) {
|
|
29
|
+
return `$${cost >= 0.01 ? cost.toFixed(2) : cost.toPrecision(2)}`;
|
|
30
|
+
}
|
|
31
|
+
function statusIcon(call, theme) {
|
|
32
|
+
switch (call.status) {
|
|
33
|
+
case "running":
|
|
34
|
+
return theme.fg("warning", "…");
|
|
35
|
+
case "ok":
|
|
36
|
+
return theme.fg("success", "✓");
|
|
37
|
+
case "error":
|
|
38
|
+
return theme.fg("error", "✗");
|
|
39
|
+
case "cancelled":
|
|
40
|
+
return theme.fg("muted", "⊘");
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function formatCall(call, theme, expanded) {
|
|
44
|
+
const args = !expanded && call.args.length > COLLAPSED_ARGS_CHARS
|
|
45
|
+
? `${call.args.slice(0, COLLAPSED_ARGS_CHARS - 3)}...`
|
|
46
|
+
: call.args;
|
|
47
|
+
const duration = formatDuration(call.durationMs);
|
|
48
|
+
let line = `${statusIcon(call, theme)} ${theme.fg("toolTitle", call.name)}`;
|
|
49
|
+
if (args)
|
|
50
|
+
line += ` ${theme.fg("muted", args)}`;
|
|
51
|
+
if (duration)
|
|
52
|
+
line += ` ${theme.fg("dim", duration)}`;
|
|
53
|
+
if (call.cost)
|
|
54
|
+
line += ` ${theme.fg("dim", formatCost(call.cost))}`;
|
|
55
|
+
if (expanded && call.error)
|
|
56
|
+
line += `\n ${theme.fg("error", call.error.split("\n").join("\n "))}`;
|
|
57
|
+
return line;
|
|
58
|
+
}
|
|
59
|
+
export const codemodeRenderers = {
|
|
60
|
+
renderCall(args, theme, context) {
|
|
61
|
+
// The code includes the `// @options:` line, so options show as part of the script.
|
|
62
|
+
const code = str(args?.code);
|
|
63
|
+
const title = theme.fg("toolTitle", theme.bold("codemode"));
|
|
64
|
+
const component = context.lastComponent ?? new Container();
|
|
65
|
+
component.clear();
|
|
66
|
+
if (code === null) {
|
|
67
|
+
component.addChild(new Text(`${title} ${theme.fg("error", "[invalid arg]")}`, 0, 0));
|
|
68
|
+
return component;
|
|
69
|
+
}
|
|
70
|
+
component.addChild(new Text(title, 0, 0));
|
|
71
|
+
if (code) {
|
|
72
|
+
const highlighted = highlightCode(replaceTabs(code.replace(/\r/g, "").trimEnd()), "javascript").join("\n");
|
|
73
|
+
component.addChild(context.expanded
|
|
74
|
+
? new Text(highlighted, 0, 0)
|
|
75
|
+
: new VisualLinePreview({
|
|
76
|
+
text: highlighted,
|
|
77
|
+
maxVisualLines: CODE_PREVIEW_LINES,
|
|
78
|
+
keep: "start",
|
|
79
|
+
formatHint: (hidden) => expandHint(theme, hidden, "lines"),
|
|
80
|
+
}));
|
|
81
|
+
}
|
|
82
|
+
return component;
|
|
83
|
+
},
|
|
84
|
+
renderResult(result, options, theme, context) {
|
|
85
|
+
const component = context.lastComponent ?? new Container();
|
|
86
|
+
component.clear();
|
|
87
|
+
const calls = result.details?.calls ?? [];
|
|
88
|
+
if (calls.length > 0) {
|
|
89
|
+
const shown = options.expanded ? calls : calls.slice(-CALL_PREVIEW_COUNT);
|
|
90
|
+
const lines = shown.map((call) => formatCall(call, theme, options.expanded));
|
|
91
|
+
if (shown.length < calls.length) {
|
|
92
|
+
lines.unshift(`${theme.fg("muted", `... (${calls.length - shown.length} earlier calls,`)} ${keyHint("app.tools.expand", "to expand")}${theme.fg("muted", ")")}`);
|
|
93
|
+
}
|
|
94
|
+
// Collapsed rows hide earlier calls, so the total covers every call.
|
|
95
|
+
const priced = calls.filter((call) => call.cost);
|
|
96
|
+
if (priced.length > 1) {
|
|
97
|
+
const total = priced.reduce((sum, call) => sum + (call.cost ?? 0), 0);
|
|
98
|
+
lines.push(theme.fg("muted", `Model calls: ${formatCost(total)}`));
|
|
99
|
+
}
|
|
100
|
+
component.addChild(new Spacer(1));
|
|
101
|
+
component.addChild(new Text(lines.join("\n"), 0, 0));
|
|
102
|
+
}
|
|
103
|
+
// Drop the "Script completed\nWall time ...\nOutput:\n" header. Rejected input (invalid options)
|
|
104
|
+
// has no header.
|
|
105
|
+
const [first, ...rest] = result.content;
|
|
106
|
+
const hasHeader = first?.type === "text" && SCRIPT_HEADER.test(first.text);
|
|
107
|
+
const output = options.isPartial
|
|
108
|
+
? ""
|
|
109
|
+
: getTextOutput({ ...result, content: hasHeader ? rest : result.content }, context.showImages).trim();
|
|
110
|
+
if (output) {
|
|
111
|
+
const color = context.isError ? "error" : "toolOutput";
|
|
112
|
+
const styled = replaceTabs(output)
|
|
113
|
+
.split("\n")
|
|
114
|
+
.map((line) => theme.fg(color, line))
|
|
115
|
+
.join("\n");
|
|
116
|
+
component.addChild(new Spacer(1));
|
|
117
|
+
if (options.expanded) {
|
|
118
|
+
component.addChild(new Text(styled, 0, 0));
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
// Limit wrapped lines, not logical ones: script output is often one long JSON line.
|
|
122
|
+
component.addChild(new VisualLinePreview({
|
|
123
|
+
text: styled,
|
|
124
|
+
maxVisualLines: OUTPUT_PREVIEW_LINES,
|
|
125
|
+
keep: "start",
|
|
126
|
+
formatHint: (hidden) => expandHint(theme, hidden, "lines"),
|
|
127
|
+
}));
|
|
128
|
+
// The collapsed preview hides the truncation notice at the end, so name the file here.
|
|
129
|
+
const fullOutputPath = result.details?.fullOutputPath;
|
|
130
|
+
if (fullOutputPath)
|
|
131
|
+
component.addChild(new Text(theme.fg("muted", `Full output: ${fullOutputPath}`), 0, 0));
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return component;
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
//# sourceMappingURL=renderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderer.js","sourceRoot":"","sources":["../../../src/extensions/codemode/renderer.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAErD,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,kCAAkC,CAAC;AACnF,OAAO,EAAE,OAAO,EAAE,MAAM,wDAAwD,CAAC;AACjF,OAAO,EAAE,iBAAiB,EAAE,MAAM,uDAAuD,CAAC;AAC1F,OAAO,EAAE,aAAa,EAAc,MAAM,wCAAwC,CAAC;AAGnF,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAC9B,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAC7B,MAAM,oBAAoB,GAAG,CAAC,CAAC;AAC/B,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAChC,MAAM,aAAa,GAAG,kEAAkE,CAAC;AAEzF,SAAS,UAAU,C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,QAAQ,EAAE,CAAC;gBACtB,SAAS,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;YAC5C,CAAC;iBAAM,CAAC;gBACP,oFAAoF;gBACpF,SAAS,CAAC,QAAQ,CACjB,IAAI,iBAAiB,CAAC;oBACrB,IAAI,EAAE,MAAM;oBACZ,cAAc,EAAE,oBAAoB;oBACpC,IAAI,EAAE,OAAO;oBACb,UAAU,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC;iBAC1D,CAAC,CACF,CAAC;gBACF,uFAAuF;gBACvF,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO,EAAE,cAAc,CAAC;gBACtD,IAAI,cAAc;oBAAE,SAAS,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,gBAAgB,cAAc,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;YAC7G,CAAC;QACF,CAAC;QACD,OAAO,SAAS,CAAC;IAClB,CAAC;CACD,CAAC","sourcesContent":["/**\n * Presentation for the codemode tool.\n *\n * The call shows the script; the result lists the nested tool calls with their status as they\n * run and the cost of its model calls, followed by the script output without the \"Script completed\"\n * header. Nested calls are not\n * separate tool rows because they never reach the model as tool calls.\n */\n\nimport { Container, Spacer, Text } from \"@draht/tui\";\nimport type { ToolDefinition } from \"../../core/extensions/types.ts\";\nimport { getTextOutput, replaceTabs, str } from \"../../core/tools/render-utils.ts\";\nimport { keyHint } from \"../../modes/interactive/components/keybinding-hints.ts\";\nimport { VisualLinePreview } from \"../../modes/interactive/components/visual-truncate.ts\";\nimport { highlightCode, type Theme } from \"../../modes/interactive/theme/theme.ts\";\nimport type { CodemodeNestedCall, CodemodeToolDetails } from \"./tool.ts\";\n\nconst CODE_PREVIEW_LINES = 10;\nconst CALL_PREVIEW_COUNT = 8;\nconst OUTPUT_PREVIEW_LINES = 5;\nconst COLLAPSED_ARGS_CHARS = 80;\nconst SCRIPT_HEADER = /^Script (completed|failed)\\nWall time [\\d.]+ seconds\\nOutput:\\n$/;\n\nfunction expandHint(theme: Theme, hidden: number, noun: string): string {\n\treturn `${theme.fg(\"muted\", `... (${hidden} more ${noun},`)} ${keyHint(\"app.tools.expand\", \"to expand\")}${theme.fg(\"muted\", \")\")}`;\n}\n\nfunction formatDuration(ms: number | undefined): string {\n\tif (ms === undefined) return \"\";\n\treturn ms < 1000 ? `${Math.round(ms)}ms` : `${(ms / 1000).toFixed(1)}s`;\n}\n\n/** Cents for larger amounts, two significant digits for the fractions of a cent classifier calls cost. */\nfunction formatCost(cost: number): string {\n\treturn `$${cost >= 0.01 ? cost.toFixed(2) : cost.toPrecision(2)}`;\n}\n\nfunction statusIcon(call: CodemodeNestedCall, theme: Theme): string {\n\tswitch (call.status) {\n\t\tcase \"running\":\n\t\t\treturn theme.fg(\"warning\", \"…\");\n\t\tcase \"ok\":\n\t\t\treturn theme.fg(\"success\", \"✓\");\n\t\tcase \"error\":\n\t\t\treturn theme.fg(\"error\", \"✗\");\n\t\tcase \"cancelled\":\n\t\t\treturn theme.fg(\"muted\", \"⊘\");\n\t}\n}\n\nfunction formatCall(call: CodemodeNestedCall, theme: Theme, expanded: boolean): string {\n\tconst args =\n\t\t!expanded && call.args.length > COLLAPSED_ARGS_CHARS\n\t\t\t? `${call.args.slice(0, COLLAPSED_ARGS_CHARS - 3)}...`\n\t\t\t: call.args;\n\tconst duration = formatDuration(call.durationMs);\n\tlet line = `${statusIcon(call, theme)} ${theme.fg(\"toolTitle\", call.name)}`;\n\tif (args) line += ` ${theme.fg(\"muted\", args)}`;\n\tif (duration) line += ` ${theme.fg(\"dim\", duration)}`;\n\tif (call.cost) line += ` ${theme.fg(\"dim\", formatCost(call.cost))}`;\n\tif (expanded && call.error) line += `\\n ${theme.fg(\"error\", call.error.split(\"\\n\").join(\"\\n \"))}`;\n\treturn line;\n}\n\nexport const codemodeRenderers: Pick<\n\tToolDefinition<any, CodemodeToolDetails | undefined>,\n\t\"renderCall\" | \"renderResult\"\n> = {\n\trenderCall(args, theme, context) {\n\t\t// The code includes the `// @options:` line, so options show as part of the script.\n\t\tconst code = str((args as { code?: unknown } | undefined)?.code);\n\t\tconst title = theme.fg(\"toolTitle\", theme.bold(\"codemode\"));\n\t\tconst component = (context.lastComponent as Container | undefined) ?? new Container();\n\t\tcomponent.clear();\n\t\tif (code === null) {\n\t\t\tcomponent.addChild(new Text(`${title} ${theme.fg(\"error\", \"[invalid arg]\")}`, 0, 0));\n\t\t\treturn component;\n\t\t}\n\t\tcomponent.addChild(new Text(title, 0, 0));\n\t\tif (code) {\n\t\t\tconst highlighted = highlightCode(replaceTabs(code.replace(/\\r/g, \"\").trimEnd()), \"javascript\").join(\"\\n\");\n\t\t\tcomponent.addChild(\n\t\t\t\tcontext.expanded\n\t\t\t\t\t? new Text(highlighted, 0, 0)\n\t\t\t\t\t: new VisualLinePreview({\n\t\t\t\t\t\t\ttext: highlighted,\n\t\t\t\t\t\t\tmaxVisualLines: CODE_PREVIEW_LINES,\n\t\t\t\t\t\t\tkeep: \"start\",\n\t\t\t\t\t\t\tformatHint: (hidden) => expandHint(theme, hidden, \"lines\"),\n\t\t\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t\treturn component;\n\t},\n\trenderResult(result, options, theme, context) {\n\t\tconst component = (context.lastComponent as Container | undefined) ?? new Container();\n\t\tcomponent.clear();\n\t\tconst calls = result.details?.calls ?? [];\n\t\tif (calls.length > 0) {\n\t\t\tconst shown = options.expanded ? calls : calls.slice(-CALL_PREVIEW_COUNT);\n\t\t\tconst lines = shown.map((call) => formatCall(call, theme, options.expanded));\n\t\t\tif (shown.length < calls.length) {\n\t\t\t\tlines.unshift(\n\t\t\t\t\t`${theme.fg(\"muted\", `... (${calls.length - shown.length} earlier calls,`)} ${keyHint(\"app.tools.expand\", \"to expand\")}${theme.fg(\"muted\", \")\")}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\t// Collapsed rows hide earlier calls, so the total covers every call.\n\t\t\tconst priced = calls.filter((call) => call.cost);\n\t\t\tif (priced.length > 1) {\n\t\t\t\tconst total = priced.reduce((sum, call) => sum + (call.cost ?? 0), 0);\n\t\t\t\tlines.push(theme.fg(\"muted\", `Model calls: ${formatCost(total)}`));\n\t\t\t}\n\t\t\tcomponent.addChild(new Spacer(1));\n\t\t\tcomponent.addChild(new Text(lines.join(\"\\n\"), 0, 0));\n\t\t}\n\n\t\t// Drop the \"Script completed\\nWall time ...\\nOutput:\\n\" header. Rejected input (invalid options)\n\t\t// has no header.\n\t\tconst [first, ...rest] = result.content;\n\t\tconst hasHeader = first?.type === \"text\" && SCRIPT_HEADER.test(first.text);\n\t\tconst output = options.isPartial\n\t\t\t? \"\"\n\t\t\t: getTextOutput({ ...result, content: hasHeader ? rest : result.content }, context.showImages).trim();\n\t\tif (output) {\n\t\t\tconst color = context.isError ? \"error\" : \"toolOutput\";\n\t\t\tconst styled = replaceTabs(output)\n\t\t\t\t.split(\"\\n\")\n\t\t\t\t.map((line) => theme.fg(color, line))\n\t\t\t\t.join(\"\\n\");\n\t\t\tcomponent.addChild(new Spacer(1));\n\t\t\tif (options.expanded) {\n\t\t\t\tcomponent.addChild(new Text(styled, 0, 0));\n\t\t\t} else {\n\t\t\t\t// Limit wrapped lines, not logical ones: script output is often one long JSON line.\n\t\t\t\tcomponent.addChild(\n\t\t\t\t\tnew VisualLinePreview({\n\t\t\t\t\t\ttext: styled,\n\t\t\t\t\t\tmaxVisualLines: OUTPUT_PREVIEW_LINES,\n\t\t\t\t\t\tkeep: \"start\",\n\t\t\t\t\t\tformatHint: (hidden) => expandHint(theme, hidden, \"lines\"),\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t\t// The collapsed preview hides the truncation notice at the end, so name the file here.\n\t\t\t\tconst fullOutputPath = result.details?.fullOutputPath;\n\t\t\t\tif (fullOutputPath) component.addChild(new Text(theme.fg(\"muted\", `Full output: ${fullOutputPath}`), 0, 0));\n\t\t\t}\n\t\t}\n\t\treturn component;\n\t},\n};\n"]}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `codemode` tool: the model writes JavaScript that calls other tools. Scripts use `tools`,
|
|
3
|
+
* `ALL_TOOLS`, `text()`, `image()`, `exit()`, `store()`/`load()`, `console.*`, and `return <value>`,
|
|
4
|
+
* may start with a `// @options:` line, and reach the model catalog and classifiers through
|
|
5
|
+
* `models.*`. Results start with a "Script completed" or "Script failed" header.
|
|
6
|
+
*
|
|
7
|
+
* Scripts can call the agent loop's nested tools: active `direct` tools and every `codemode` or
|
|
8
|
+
* `deferred` tool. Nested calls run through the agent loop's tool pipeline (`ctx.executeTool`), so
|
|
9
|
+
* validation, `tool_call`/`tool_result` hooks, and permission checks apply exactly as for direct
|
|
10
|
+
* calls. Only the script's output reaches the model; nested results do not.
|
|
11
|
+
*
|
|
12
|
+
* Nested results are handed to the script as follows:
|
|
13
|
+
* - A tool that declares `outputSchema` resolves to its `structuredContent`, also for error
|
|
14
|
+
* results that carry one (MCP tools resolve to their `CallToolResult`, including `isError`).
|
|
15
|
+
* - Any other tool resolves to its text content as one string.
|
|
16
|
+
* - A failed, blocked, or invalid call rejects with an Error carrying the tool's error text.
|
|
17
|
+
*
|
|
18
|
+
* A script that fails returns a normal error result that keeps its partial output, followed by
|
|
19
|
+
* "Script error:" and the error. `store(key, value)` and `load(key)` keep JSON values across
|
|
20
|
+
* calls; successful scripts append their writes to the session as `codemode-store` custom entries,
|
|
21
|
+
* so each branch sees the values written on its own path.
|
|
22
|
+
*/
|
|
23
|
+
import type { AgentTool } from "@draht/agent-core";
|
|
24
|
+
import type { CodemodeTool } from "@draht/codemode";
|
|
25
|
+
import { type Static, Type } from "typebox";
|
|
26
|
+
import type { ToolDefinition, ToolInfo, ToolNamespace } from "../../core/extensions/types.ts";
|
|
27
|
+
import type { ModelRegistry } from "../../core/model-registry.ts";
|
|
28
|
+
import type { CodemodeMode } from "../../core/settings-manager.ts";
|
|
29
|
+
export declare const CODEMODE_TOOL_NAME = "codemode";
|
|
30
|
+
/** Custom entry type holding one script's `store()` writes: {@link CodemodeStoreEntryData}. */
|
|
31
|
+
export declare const CODEMODE_STORE_ENTRY_TYPE = "codemode-store";
|
|
32
|
+
export interface CodemodeStoreEntryData {
|
|
33
|
+
set: Record<string, unknown>;
|
|
34
|
+
delete: string[];
|
|
35
|
+
}
|
|
36
|
+
/** The part of the model registry that scripts reach through `models`. */
|
|
37
|
+
export type CodemodeModelRuntime = Pick<ModelRegistry, "getModelsOfType" | "getAvailableOfType" | "getModelOfType" | "classify">;
|
|
38
|
+
export interface CodemodeToolOptions {
|
|
39
|
+
/** Namespace of a tool, for `searchTools()` ranking and its `namespace` filter. */
|
|
40
|
+
getToolNamespace?: (toolName: string) => ToolNamespace | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Expose the `models` namespace to scripts, backed by the session's model registry
|
|
43
|
+
* (`ctx.modelRegistry`). Without it, `models` is not declared.
|
|
44
|
+
*/
|
|
45
|
+
models?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Persists `store()` writes as a session custom entry. Without it, writes last only for the
|
|
48
|
+
* current script; `load()` still reads entries already on the branch.
|
|
49
|
+
*/
|
|
50
|
+
appendEntry?: (customType: string, data: CodemodeStoreEntryData) => void;
|
|
51
|
+
/** How the tool presents the loadout while active (the `codemode.mode` setting). Default: `on`. */
|
|
52
|
+
getMode?: () => CodemodeMode;
|
|
53
|
+
/** Token budget for tool declarations in the description. Default: {@link DEFAULT_CODEMODE_INLINE_BUDGET}. */
|
|
54
|
+
getInlineBudget?: () => number | undefined;
|
|
55
|
+
}
|
|
56
|
+
export declare const codemodeSchema: Type.TObject<{
|
|
57
|
+
code: Type.TString;
|
|
58
|
+
}>;
|
|
59
|
+
export type CodemodeToolInput = Static<typeof codemodeSchema>;
|
|
60
|
+
/**
|
|
61
|
+
* Whether a registered tool is this package's `codemode` tool rather than another extension's tool
|
|
62
|
+
* with the same name. Compares the parameter schema, which the definition passes through by reference.
|
|
63
|
+
*/
|
|
64
|
+
export declare function isCodemodeTool(tool: Pick<ToolInfo, "name" | "parameters">): boolean;
|
|
65
|
+
export type CodemodeNestedCallStatus = "running" | "ok" | "error" | "cancelled";
|
|
66
|
+
export interface CodemodeNestedCall {
|
|
67
|
+
/** Tool call id of the nested call, `<codemode call id>/<n>`. */
|
|
68
|
+
id: string;
|
|
69
|
+
name: string;
|
|
70
|
+
/** Compact JSON of the arguments, truncated for display. */
|
|
71
|
+
args: string;
|
|
72
|
+
status: CodemodeNestedCallStatus;
|
|
73
|
+
durationMs?: number;
|
|
74
|
+
/** Error text, truncated for display. */
|
|
75
|
+
error?: string;
|
|
76
|
+
/** Cost in USD of a `models.*` call that reported usage. */
|
|
77
|
+
cost?: number;
|
|
78
|
+
}
|
|
79
|
+
export interface CodemodeToolDetails {
|
|
80
|
+
calls: CodemodeNestedCall[];
|
|
81
|
+
/** Temp file with the full text output, when the output was truncated. */
|
|
82
|
+
fullOutputPath?: string;
|
|
83
|
+
}
|
|
84
|
+
export declare const codemodeToolSystemPromptContribution: {
|
|
85
|
+
readonly snippet: "Run JavaScript that calls other tools (chains, loops, Promise.all, filtering large results)";
|
|
86
|
+
readonly guidelines: readonly ["Use codemode to batch or chain several tool calls, or to filter large tool output down to what you need, instead of issuing many individual tool calls. Batch independent calls in one codemode call using await Promise.allSettled([...])."];
|
|
87
|
+
};
|
|
88
|
+
/** Declarations of the `models` globals; codemode-execute.ts implements them. */
|
|
89
|
+
export declare const MODEL_GLOBAL_DECLARATIONS: readonly Omit<CodemodeTool, "execute">[];
|
|
90
|
+
/** Default for {@link CodemodeDescriptionOptions.inlineBudget}, in estimated tokens. */
|
|
91
|
+
export declare const DEFAULT_CODEMODE_INLINE_BUDGET = 3000;
|
|
92
|
+
/** What a script sees of a tool. Tools without an output schema resolve to their text output. */
|
|
93
|
+
export declare function toCodemodeDeclaration(tool: AgentTool<any>): Omit<CodemodeTool, "execute">;
|
|
94
|
+
/** Tools a script may call: every given tool except the codemode tool itself. */
|
|
95
|
+
export declare function getCodemodeCallableTools(tools: readonly AgentTool<any>[]): AgentTool<any>[];
|
|
96
|
+
export interface CodemodeDescriptionOptions {
|
|
97
|
+
/** Declare the `models` namespace; only for tools created with model access. */
|
|
98
|
+
models?: boolean;
|
|
99
|
+
/** Namespace of each tool, by tool name. Tools of one namespace are listed under one heading. */
|
|
100
|
+
namespaces?: ReadonlyMap<string, ToolNamespace>;
|
|
101
|
+
/** Tools that are callable but never listed with their declaration (`deferred` exposure). */
|
|
102
|
+
deferred?: ReadonlySet<string>;
|
|
103
|
+
/**
|
|
104
|
+
* Estimated tokens (characters / 4) the tool sections may use. Tools that do not fit are left
|
|
105
|
+
* out, like deferred tools. Unset lists every tool that is not deferred.
|
|
106
|
+
*/
|
|
107
|
+
inlineBudget?: number;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Model-facing description: the helper list, guidance for finding tools that are not listed, the
|
|
111
|
+
* shared MCP types when listed tools need them, the `models` API, and one section per listed tool,
|
|
112
|
+
* grouped by namespace. Deferred tools are never listed and do not affect the description at all, so
|
|
113
|
+
* it stays the same while MCP servers connect or change their tools. Tool sections are limited to
|
|
114
|
+
* `inlineBudget`.
|
|
115
|
+
*/
|
|
116
|
+
export declare function createCodemodeDescription(tools: readonly AgentTool<any>[], options?: CodemodeDescriptionOptions): string;
|
|
117
|
+
export declare function createCodemodeToolDefinition(options?: CodemodeToolOptions): ToolDefinition<typeof codemodeSchema, CodemodeToolDetails | undefined>;
|
|
118
|
+
/**
|
|
119
|
+
* Create the codemode tool as an AgentTool. The description lists the given tools; the script can
|
|
120
|
+
* call whatever tools the agent loop provides at execution time.
|
|
121
|
+
*/
|
|
122
|
+
export declare function createCodemodeTool(tools?: readonly AgentTool<any>[], options?: CodemodeToolOptions): AgentTool<typeof codemodeSchema>;
|
|
123
|
+
//# sourceM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BAAwB,CAAC,KAAK,EAAE,SAAS,SAAS,CAAC,GAAG,CAAC,EAAE,GAAG,SAAS,CAAC,GAAG,CAAC,EAAE,CAE3F;AAED,MAAM,WAAW,0BAA0B;IAC1C,gFAAgF;IAChF,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,iGAAiG;IACjG,UAAU,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAChD,6FAA6F;IAC7F,QAAQ,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC/B;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB;AA6CD;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CACxC,KAAK,EAAE,SAAS,SAAS,CAAC,GAAG,CAAC,EAAE,EAChC,OAAO,GAAE,0BAA+B,GACtC,MAAM,CAsDR;AAgDD,wBAAgB,4BAA4B,CAC3C,OAAO,GAAE,mBAAwB,GAC/B,cAAc,CAAC,OAAO,cAAc,EAAE,mBAAmB,GAAG,SAAS,CAAC,CAmBxE;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CACjC,KAAK,GAAE,SAAS,SAAS,CAAC,GAAG,CAAC,EAAO,EACrC,OAAO,GAAE,mBAAwB,GAC/B,SAAS,CAAC,OAAO,cAAc,CAAC,CASlC"}
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `codemode` tool: the model writes JavaScript that calls other tools. Scripts use `tools`,
|
|
3
|
+
* `ALL_TOOLS`, `text()`, `image()`, `exit()`, `store()`/`load()`, `console.*`, and `return <value>`,
|
|
4
|
+
* may start with a `// @options:` line, and reach the model catalog and classifiers through
|
|
5
|
+
* `models.*`. Results start with a "Script completed" or "Script failed" header.
|
|
6
|
+
*
|
|
7
|
+
* Scripts can call the agent loop's nested tools: active `direct` tools and every `codemode` or
|
|
8
|
+
* `deferred` tool. Nested calls run through the agent loop's tool pipeline (`ctx.executeTool`), so
|
|
9
|
+
* validation, `tool_call`/`tool_result` hooks, and permission checks apply exactly as for direct
|
|
10
|
+
* calls. Only the script's output reaches the model; nested results do not.
|
|
11
|
+
*
|
|
12
|
+
* Nested results are handed to the script as follows:
|
|
13
|
+
* - A tool that declares `outputSchema` resolves to its `structuredContent`, also for error
|
|
14
|
+
* results that carry one (MCP tools resolve to their `CallToolResult`, including `isError`).
|
|
15
|
+
* - Any other tool resolves to its text content as one string.
|
|
16
|
+
* - A failed, blocked, or invalid call rejects with an Error carrying the tool's error text.
|
|
17
|
+
*
|
|
18
|
+
* A script that fails returns a normal error result that keeps its partial output, followed by
|
|
19
|
+
* "Script error:" and the error. `store(key, value)` and `load(key)` keep JSON values across
|
|
20
|
+
* calls; successful scripts append their writes to the session as `codemode-store` custom entries,
|
|
21
|
+
* so each branch sees the values written on its own path.
|
|
22
|
+
*/
|
|
23
|
+
import { MCP_TYPESCRIPT_PREAMBLE, mcpStructuredContentSchema, renderDeclarations, renderToolSample, toCodemodeIdentifier, } from "@draht/codemode/declarations";
|
|
24
|
+
import { CODEMODE_SOURCE_GRAMMAR } from "@draht/codemode/source";
|
|
25
|
+
import { Type } from "typebox";
|
|
26
|
+
import { wrapToolDefinition } from "../../core/tools/tool-definition-wrapper.js";
|
|
27
|
+
import { loadCodemodeExecutor } from "./execute.lazy.js";
|
|
28
|
+
import { codemodeRenderers } from "./renderer.js";
|
|
29
|
+
export const CODEMODE_TOOL_NAME = "codemode";
|
|
30
|
+
/** Custom entry type holding one script's `store()` writes: {@link CodemodeStoreEntryData}. */
|
|
31
|
+
export const CODEMODE_STORE_ENTRY_TYPE = "codemode-store";
|
|
32
|
+
const TEXT_OUTPUT_SCHEMA = { type: "string" };
|
|
33
|
+
export const codemodeSchema = Type.Object({
|
|
34
|
+
code: Type.String({
|
|
35
|
+
description: 'Raw JavaScript source. Top-level await and return work. May start with a `// @options: {"max_output_tokens": 1000}` line.',
|
|
36
|
+
}),
|
|
37
|
+
});
|
|
38
|
+
/**
|
|
39
|
+
* Whether a registered tool is this package's `codemode` tool rather than another extension's tool
|
|
40
|
+
* with the same name. Compares the parameter schema, which the definition passes through by reference.
|
|
41
|
+
*/
|
|
42
|
+
export function isCodemodeTool(tool) {
|
|
43
|
+
return tool.name === CODEMODE_TOOL_NAME && tool.parameters === codemodeSchema;
|
|
44
|
+
}
|
|
45
|
+
export const codemodeToolSystemPromptContribution = {
|
|
46
|
+
snippet: "Run JavaScript that calls other tools (chains, loops, Promise.all, filtering large results)",
|
|
47
|
+
guidelines: [
|
|
48
|
+
"Use codemode to batch or chain several tool calls, or to filter large tool output down to what you need, instead of issuing many individual tool calls. Batch independent calls in one codemode call using await Promise.allSettled([...]).",
|
|
49
|
+
],
|
|
50
|
+
};
|
|
51
|
+
const DESCRIPTION_INTRO = `Run JavaScript code to orchestrate/compose tool calls
|
|
52
|
+
- Evaluates the provided JavaScript code in a fresh QuickJS sandbox as the body of an async function: top-level \`await\` and \`return\` work.
|
|
53
|
+
- All nested tools are available on the global \`tools\` object, for example \`await tools.read(...)\`. Tool names are exposed as normalized JavaScript identifiers, for example \`await tools.mcp__ologs__get_profile(...)\`.
|
|
54
|
+
- Nested tool methods take an object as their input argument.
|
|
55
|
+
- Nested tools return either an object or a string, based on the description.
|
|
56
|
+
- A nested tool call that fails, is blocked, or gets invalid arguments rejects with an Error carrying the tool's error text.
|
|
57
|
+
- Runs raw JavaScript -- no Node, no file system, no network access, no timers.
|
|
58
|
+
- Accepts raw JavaScript source text, not JSON, quoted strings, or markdown code fences.
|
|
59
|
+
- You may optionally start the tool input with a first line like \`// @options: {"max_output_tokens": 1000, "timeout_ms": 60000}\`.
|
|
60
|
+
- \`max_output_tokens\` sets the token budget for the script's output. Defaults to 10000 tokens.
|
|
61
|
+
- \`timeout_ms\` sets a hard deadline for the whole script. By default there is none.
|
|
62
|
+
- When the JS code is fully evaluated, calls that are still running are cancelled and unawaited promises are silently discarded.
|
|
63
|
+
- Tool calls are real and have side effects. If the script fails partway, earlier calls are not undone.
|
|
64
|
+
- Scripts have a 256 MB memory limit; exceeding it throws \`InternalError: out of memory\`. Filter or aggregate large data instead of accumulating it.
|
|
65
|
+
|
|
66
|
+
- Global helpers:
|
|
67
|
+
- \`exit()\`: Immediately ends the current script successfully (like an early return from the top level).
|
|
68
|
+
- \`text(value: string | number | boolean | undefined | null)\`: Appends a text item. Non-string values are stringified with \`JSON.stringify(...)\` when possible.
|
|
69
|
+
- \`image(imageUrlOrItem: string | { image_url: string } | ImageContent)\`: Appends an image item. \`image_url\` should be a base64-encoded \`data:\` URL. To forward an MCP tool image, pass an individual \`ImageContent\` block from \`result.content\`, for example \`image(result.content[0])\`.
|
|
70
|
+
- \`store(key: string, value: any)\`: stores a serializable value under a string key for later \`codemode\` calls in the same session. Storing \`undefined\` deletes the key. Writes are kept only if the script succeeds.
|
|
71
|
+
- \`load(key: string)\`: returns the stored value for a string key, or \`undefined\` if it is missing.
|
|
72
|
+
- \`ALL_TOOLS\`: metadata for the enabled nested tools as \`{ name, description }\` entries.
|
|
73
|
+
- \`searchTools(query: string, options?: { limit?: number; namespace?: string })\`: resolves to the nested tools that best match the query (BM25, default limit 8), as \`{ name, description }\` entries like \`ALL_TOOLS\`.
|
|
74
|
+
- \`describeTool(name: string)\`: resolves to the description and declaration of a nested tool, or \`undefined\`.
|
|
75
|
+
- \`describeNamespace(name: string)\`: resolves to \`{ name, description?, instructions?, tools }\` for a namespace of nested tools, such as an MCP server: its usage instructions and the names of its tools, or \`undefined\`.
|
|
76
|
+
- \`console.log(...)\` and the other \`console\` methods append a text item like \`text()\`.
|
|
77
|
+
- \`return value\` at the top level appends the value like \`text()\`.`;
|
|
78
|
+
const MODEL_TYPES = `type ModelType = "chat" | "image" | "classifier";
|
|
79
|
+
/** A model catalog entry. \`provider\` and \`id\` identify it; the other fields depend on the type. */
|
|
80
|
+
interface ModelInfo {
|
|
81
|
+
type?: ModelType;
|
|
82
|
+
provider: string;
|
|
83
|
+
id: string;
|
|
84
|
+
name: string;
|
|
85
|
+
api: string;
|
|
86
|
+
input: ("text" | "image")[];
|
|
87
|
+
contextWindow?: number;
|
|
88
|
+
[key: string]: unknown;
|
|
89
|
+
}
|
|
90
|
+
type ClassifierQuestion =
|
|
91
|
+
| { type: "choice"; instructions: string; criteria: Record<string, string> }
|
|
92
|
+
| { type: "score"; instructions: string; criteria: string[] }
|
|
93
|
+
| { type: "bool"; instructions: string; criteria: { true: string; false: string } };
|
|
94
|
+
type ClassifierAnswer =
|
|
95
|
+
| { type: "choice"; choice: string; probabilities: Record<string, number>; confidence: number }
|
|
96
|
+
| { type: "score"; score: number; confidence: number }
|
|
97
|
+
| { type: "bool"; probability: number };
|
|
98
|
+
interface ClassifierContext {
|
|
99
|
+
state: Record<string, unknown>;
|
|
100
|
+
questions: Record<string, ClassifierQuestion>;
|
|
101
|
+
}
|
|
102
|
+
interface ClassifierResult {
|
|
103
|
+
api: string;
|
|
104
|
+
provider: string;
|
|
105
|
+
model: string;
|
|
106
|
+
answers: Record<string, ClassifierAnswer>;
|
|
107
|
+
/** Set when the service reports token counts. Cost is in USD. */
|
|
108
|
+
usage?: { input: number; output: number; totalTokens: number; cost: { total: number } };
|
|
109
|
+
stopReason: "stop" | "error" | "aborted";
|
|
110
|
+
errorMessage?: string;
|
|
111
|
+
timestamp: number;
|
|
112
|
+
}`;
|
|
113
|
+
/** Declarations of the `models` globals; codemode-execute.ts implements them. */
|
|
114
|
+
export const MODEL_GLOBAL_DECLARATIONS = [
|
|
115
|
+
{
|
|
116
|
+
name: "models.getModelsOfType",
|
|
117
|
+
description: "Every known model of a type, optionally for one provider.",
|
|
118
|
+
signature: "(type: ModelType, provider?: string): Promise<ModelInfo[]>",
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
name: "models.getAvailableOfType",
|
|
122
|
+
description: "Models of a type whose provider has working credentials.",
|
|
123
|
+
signature: "(type: ModelType, provider?: string): Promise<ModelInfo[]>",
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
name: "models.getModelOfType",
|
|
127
|
+
description: "One catalog entry, or undefined.",
|
|
128
|
+
signature: "(type: ModelType, provider: string, id: string): Promise<ModelInfo | undefined>",
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
name: "models.classify",
|
|
132
|
+
description: "Run a classifier model on one state. Only `provider` and `id` of `model` are used. Provider errors do not throw: check `stopReason` and `errorMessage`.",
|
|
133
|
+
signature: "(model: ModelInfo, context: ClassifierContext): Promise<ClassifierResult>",
|
|
134
|
+
},
|
|
135
|
+
];
|
|
136
|
+
const DEFERRED_TOOLS_GUIDANCE = `Some nested tools may be omitted from this description, such as deferred tools and MCP tools. They are still available on the global \`tools\` object and listed in \`ALL_TOOLS\`.
|
|
137
|
+
To find one, call \`await searchTools(query)\` (pass \`{ namespace }\` to search one namespace), or filter \`ALL_TOOLS\` by \`name\` and \`description\`. \`await describeNamespace(name)\` returns a namespace's usage instructions and the names of its tools.`;
|
|
138
|
+
/** Default for {@link CodemodeDescriptionOptions.inlineBudget}, in estimated tokens. */
|
|
139
|
+
export const DEFAULT_CODEMODE_INLINE_BUDGET = 3000;
|
|
140
|
+
/** Characters per token when estimating the cost of a tool section. */
|
|
141
|
+
const CHARS_PER_TOKEN = 4;
|
|
142
|
+
/** What a script sees of a tool. Tools without an output schema resolve to their text output. */
|
|
143
|
+
export function toCodemodeDeclaration(tool) {
|
|
144
|
+
return {
|
|
145
|
+
name: tool.name,
|
|
146
|
+
description: tool.description,
|
|
147
|
+
inputSchema: tool.parameters,
|
|
148
|
+
outputSchema: tool.outputSchema ?? TEXT_OUTPUT_SCHEMA,
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
/** Tools a script may call: every given tool except the codemode tool itself. */
|
|
152
|
+
export function getCodemodeCallableTools(tools) {
|
|
153
|
+
return tools.filter((tool) => tool.name !== CODEMODE_TOOL_NAME);
|
|
154
|
+
}
|
|
155
|
+
/** `### \`id\` (\`raw name\`)` followed by the tool's description and declaration. */
|
|
156
|
+
function renderToolSection(declaration) {
|
|
157
|
+
const id = toCodemodeIdentifier(declaration.name);
|
|
158
|
+
const heading = id === declaration.name ? `### \`${id}\`` : `### \`${id}\` (\`${declaration.name}\`)`;
|
|
159
|
+
return `${heading}\n${renderToolSample(declaration).trim()}`;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Pick the tool sections that fit the budget, like OpenCode's catalog: in each round every group
|
|
163
|
+
* (tools without a namespace first, then namespaces by name) places its cheapest remaining tool; a
|
|
164
|
+
* group whose next tool does not fit drops out while the others continue. Every namespace is
|
|
165
|
+
* represented before any namespace is complete.
|
|
166
|
+
*/
|
|
167
|
+
function selectCatalog(groups, budget) {
|
|
168
|
+
if (budget === undefined)
|
|
169
|
+
return new Set(groups.flatMap((group) => group.entries.map((entry) => entry.name)));
|
|
170
|
+
const queues = groups.map((group) => [...group.entries].sort((a, b) => a.cost - b.cost));
|
|
171
|
+
const shown = new Set();
|
|
172
|
+
let remaining = budget;
|
|
173
|
+
let active = queues.filter((queue) => queue.length > 0);
|
|
174
|
+
while (active.length > 0) {
|
|
175
|
+
active = active.filter((queue) => {
|
|
176
|
+
const next = queue[0];
|
|
177
|
+
if (next.cost > remaining)
|
|
178
|
+
return false;
|
|
179
|
+
remaining -= next.cost;
|
|
180
|
+
shown.add(next.name);
|
|
181
|
+
queue.shift();
|
|
182
|
+
return queue.length > 0;
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
return shown;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Model-facing description: the helper list, guidance for finding tools that are not listed, the
|
|
189
|
+
* shared MCP types when listed tools need them, the `models` API, and one section per listed tool,
|
|
190
|
+
* grouped by namespace. Deferred tools are never listed and do not affect the description at all, so
|
|
191
|
+
* it stays the same while MCP servers connect or change their tools. Tool sections are limited to
|
|
192
|
+
* `inlineBudget`.
|
|
193
|
+
*/
|
|
194
|
+
export function createCodemodeDescription(tools, options = {}) {
|
|
195
|
+
const declarations = getCodemodeCallableTools(tools)
|
|
196
|
+
.filter((tool) => !options.deferred?.has(tool.name))
|
|
197
|
+
.map(toCodemodeDeclaration);
|
|
198
|
+
const groups = new Map([["", { namespace: undefined, entries: [] }]]);
|
|
199
|
+
for (const declaration of declarations) {
|
|
200
|
+
const namespace = options.namespaces?.get(declaration.name);
|
|
201
|
+
const key = namespace ? `ns:${namespace.name}` : "";
|
|
202
|
+
const group = groups.get(key) ?? { namespace, entries: [] };
|
|
203
|
+
groups.set(key, group);
|
|
204
|
+
const section = renderToolSection(declaration);
|
|
205
|
+
group.entries.push({ name: declaration.name, section, cost: Math.ceil(section.length / CHARS_PER_TOKEN) });
|
|
206
|
+
}
|
|
207
|
+
const ordered = [...groups.values()].sort((a, b) => a.namespace === undefined ? -1 : b.namespace === undefined ? 1 : a.namespace.name.localeCompare(b.namespace.name));
|
|
208
|
+
const shown = selectCatalog(ordered, options.inlineBudget);
|
|
209
|
+
const sections = [DESCRIPTION_INTRO, DEFERRED_TOOLS_GUIDANCE];
|
|
210
|
+
if (declarations.some((declaration) => shown.has(declaration.name) && mcpStructuredContentSchema(declaration.outputSchema) !== undefined)) {
|
|
211
|
+
sections.push(`Shared MCP Types:\n\`\`\`ts\n${MCP_TYPESCRIPT_PREAMBLE}\n\`\`\``);
|
|
212
|
+
}
|
|
213
|
+
if (options.models) {
|
|
214
|
+
const noop = () => undefined;
|
|
215
|
+
const models = renderDeclarations({
|
|
216
|
+
globals: MODEL_GLOBAL_DECLARATIONS.map((global) => ({ ...global, execute: noop })),
|
|
217
|
+
});
|
|
218
|
+
sections.push(`Model API:\n\`\`\`ts\n${MODEL_TYPES}\n\n${models}\n\`\`\``);
|
|
219
|
+
}
|
|
220
|
+
if (declarations.length === 0)
|
|
221
|
+
return sections.join("\n\n");
|
|
222
|
+
const toolSections = ["Nested tools:"];
|
|
223
|
+
for (const { namespace, entries } of ordered) {
|
|
224
|
+
const visible = entries.filter((entry) => shown.has(entry.name));
|
|
225
|
+
if (namespace) {
|
|
226
|
+
// Only tools that did not fit the budget are counted as not listed here.
|
|
227
|
+
const listing = visible.length === entries.length
|
|
228
|
+
? ""
|
|
229
|
+
: visible.length === 0
|
|
230
|
+
? " (tools not listed)"
|
|
231
|
+
: " (some tools not listed)";
|
|
232
|
+
const description = namespace.description?.trim();
|
|
233
|
+
toolSections.push(`## ${namespace.name}${listing}${description ? `\n${description}` : ""}`);
|
|
234
|
+
}
|
|
235
|
+
for (const entry of visible)
|
|
236
|
+
toolSections.push(entry.section);
|
|
237
|
+
}
|
|
238
|
+
sections.push(toolSections.join("\n\n"));
|
|
239
|
+
return sections.join("\n\n");
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* How the codemode tool presents tools that are both declared and callable from scripts:
|
|
243
|
+
* - `on`: their descriptions get the codemode declaration appended, and the codemode description
|
|
244
|
+
* lists only the callable tools without `direct` exposure.
|
|
245
|
+
* - `only`: the codemode description lists every callable tool, and requests leave out the
|
|
246
|
+
* declarations of active `direct` tools.
|
|
247
|
+
*
|
|
248
|
+
* Listing by exposure, not by the active set, keeps the codemode description unchanged when
|
|
249
|
+
* `tool_search` loads a tool, so loads do not redeclare codemode.
|
|
250
|
+
*/
|
|
251
|
+
function prepareCodemodeLoadout(loadout, options) {
|
|
252
|
+
const mode = options.getMode?.() ?? "on";
|
|
253
|
+
const isDirect = (tool) => loadout.getExposure(tool.name) === "direct";
|
|
254
|
+
const callable = getCodemodeCallableTools(loadout.callable);
|
|
255
|
+
const callableNames = new Set(callable.map((tool) => tool.name));
|
|
256
|
+
const descriptions = {};
|
|
257
|
+
if (mode === "on") {
|
|
258
|
+
for (const tool of loadout.declared) {
|
|
259
|
+
if (callableNames.has(tool.name))
|
|
260
|
+
descriptions[tool.name] = renderToolSample(toCodemodeDeclaration(tool));
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
const listed = mode === "only" ? callable : callable.filter((tool) => !isDirect(tool));
|
|
264
|
+
const namespaces = new Map(listed.flatMap((tool) => {
|
|
265
|
+
const namespace = loadout.getNamespace(tool.name);
|
|
266
|
+
return namespace ? [[tool.name, namespace]] : [];
|
|
267
|
+
}));
|
|
268
|
+
descriptions[CODEMODE_TOOL_NAME] = createCodemodeDescription(listed, {
|
|
269
|
+
models: options.models === true,
|
|
270
|
+
namespaces,
|
|
271
|
+
deferred: new Set(listed.filter((tool) => loadout.getExposure(tool.name) === "deferred").map((tool) => tool.name)),
|
|
272
|
+
inlineBudget: options.getInlineBudget?.() ?? DEFAULT_CODEMODE_INLINE_BUDGET,
|
|
273
|
+
});
|
|
274
|
+
const declaredNames = new Set(loadout.declared.map((tool) => tool.name));
|
|
275
|
+
return {
|
|
276
|
+
descriptions,
|
|
277
|
+
hiddenDeclarations: mode === "only"
|
|
278
|
+
? callable.filter((tool) => isDirect(tool) && declaredNames.has(tool.name)).map((tool) => tool.name)
|
|
279
|
+
: [],
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
export function createCodemodeToolDefinition(options = {}) {
|
|
283
|
+
return {
|
|
284
|
+
name: CODEMODE_TOOL_NAME,
|
|
285
|
+
label: CODEMODE_TOOL_NAME,
|
|
286
|
+
// Replaced with the declarations of the callable tools when the tool is activated.
|
|
287
|
+
description: createCodemodeDescription([], { models: options.models === true }),
|
|
288
|
+
promptSnippet: codemodeToolSystemPromptContribution.snippet,
|
|
289
|
+
promptGuidelines: [...codemodeToolSystemPromptContribution.guidelines],
|
|
290
|
+
parameters: codemodeSchema,
|
|
291
|
+
// Scripts must not start other scripts.
|
|
292
|
+
exposure: "model-only",
|
|
293
|
+
prepareLoadout: (loadout) => prepareCodemodeLoadout(loadout, options),
|
|
294
|
+
// Capable models write the script as raw text instead of a JSON-escaped string.
|
|
295
|
+
constrainedSampling: { type: "grammar", variants: { openai_lark: CODEMODE_SOURCE_GRAMMAR } },
|
|
296
|
+
// The sandbox (worker, QuickJS wasm) loads on the first call, not at startup.
|
|
297
|
+
execute: async (toolCallId, params, signal, onUpdate, ctx) => (await loadCodemodeExecutor()).executeCodemode(toolCallId, params, signal, onUpdate, ctx, options),
|
|
298
|
+
...codemodeRenderers,
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Create the codemode tool as an AgentTool. The description lists the given tools; the script can
|
|
303
|
+
* call whatever tools the agent loop provides at execution time.
|
|
304
|
+
*/
|
|
305
|
+
export function createCodemodeTool(tools = [], options = {}) {
|
|
306
|
+
const definition = createCodemodeToolDefinition(options);
|
|
307
|
+
const tool = wrapToolDefinition(definition);
|
|
308
|
+
Object.assign(tool, {
|
|
309
|
+
description: createCodemodeDescription(tools, { models: options.models === true }),
|
|
310
|
+
promptSnippet: definition.promptSnippet,
|
|
311
|
+
promptGuidelines: definition.promptGuidelines,
|
|
312
|
+
});
|
|
313
|
+
return tool;
|
|
314
|
+
}
|
|
315
|
+
//# sourceMappingURL=tool.js.map
|