@draht/coding-agent 2026.10.20 → 2026.10.23-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +138 -0
- package/agents/advisor.md +2 -2
- package/agents/architect.md +11 -33
- package/agents/debugger.md +13 -54
- package/agents/git-committer.md +18 -42
- package/agents/implementer.md +14 -36
- package/agents/investigator.md +12 -63
- package/agents/reviewer.md +16 -44
- package/agents/security-auditor.md +22 -56
- package/agents/spec-reviewer.md +13 -53
- package/agents/verifier.md +14 -33
- package/bin/drahtbank.mjs +4 -0
- package/dist/agents/advisor.md +2 -2
- package/dist/agents/architect.md +11 -33
- package/dist/agents/debugger.md +13 -54
- package/dist/agents/git-committer.md +18 -42
- package/dist/agents/implementer.md +14 -36
- package/dist/agents/investigator.md +12 -63
- package/dist/agents/reviewer.md +16 -44
- package/dist/agents/security-auditor.md +22 -56
- package/dist/agents/spec-reviewer.md +13 -53
- package/dist/agents/verifier.md +14 -33
- package/dist/bundle/chunks/anthropic-messages-G57VPNTF.js +6 -0
- package/dist/bundle/chunks/anthropic.js +1 -1
- package/dist/bundle/chunks/azure-openai-responses-AYUCZ5WN.js +2 -0
- package/dist/bundle/chunks/bedrock-converse-stream.js +31 -28
- package/dist/bundle/chunks/chunk-2JZLKNZ4.js +3 -0
- package/dist/bundle/chunks/chunk-3GDEPGTR.js +16 -0
- package/dist/bundle/chunks/chunk-5JW3NSTV.js +2 -0
- package/dist/bundle/chunks/{chunk-KVH4HR57.js → chunk-6WESOD4H.js} +1 -1
- package/dist/bundle/chunks/chunk-76YNMQ57.js +2 -0
- package/dist/bundle/chunks/chunk-AC3MSTC6.js +2 -0
- package/dist/bundle/chunks/chunk-ACLWH5WQ.js +2 -0
- package/dist/bundle/chunks/chunk-BL72B6LV.js +82 -0
- package/dist/bundle/chunks/chunk-CLKG6K6Z.js +7 -0
- package/dist/bundle/chunks/chunk-DN7SM3LX.js +479 -0
- package/dist/bundle/chunks/{chunk-D6TMD5Q2.js → chunk-DOUMZTXH.js} +10 -10
- package/dist/bundle/chunks/chunk-DQ4G4IS4.js +20 -0
- package/dist/bundle/chunks/chunk-E4VZJRJ2.js +9 -0
- package/dist/bundle/chunks/chunk-FOYIPAAD.js +6 -0
- package/dist/bundle/chunks/chunk-FXCTQRNN.js +2 -0
- package/dist/bundle/chunks/chunk-GBFVS2SF.js +12 -0
- package/dist/bundle/chunks/chunk-GQXRTK54.js +20 -0
- package/dist/bundle/chunks/chunk-IGO52ZOY.js +132 -0
- package/dist/bundle/chunks/chunk-IT4RIOZD.js +2 -0
- package/dist/bundle/chunks/chunk-JJKPUMH2.js +1424 -0
- package/dist/bundle/chunks/chunk-JNWRE5F4.js +2 -0
- package/dist/bundle/chunks/chunk-KSGHCBHT.js +2 -0
- package/dist/bundle/chunks/chunk-LO6CVU2L.js +6 -0
- package/dist/bundle/chunks/chunk-MBFTIGLS.js +2 -0
- package/dist/bundle/chunks/chunk-N26RGV3K.js +11 -0
- package/dist/bundle/chunks/{chunk-KPO5375S.js → chunk-RCRGGYLW.js} +1 -1
- package/dist/bundle/chunks/chunk-UCJ7FLSO.js +166 -0
- package/dist/bundle/chunks/chunk-USCN7R2E.js +2 -0
- package/dist/bundle/chunks/chunk-WFHH5SX6.js +4 -0
- package/dist/bundle/chunks/chunk-WYWBXNDO.js +6 -0
- package/dist/bundle/chunks/chunk-ZRPAOMVB.js +2 -0
- package/dist/bundle/chunks/{cli-PYJB6AQ3.js → cli-HTUB6WOG.js} +6 -6
- package/dist/bundle/chunks/cloudflare-workers-ai-system-one-RRSO6OXX.js +2 -0
- package/dist/bundle/chunks/codemode-worker.js +188 -21
- package/dist/bundle/chunks/execute-UUPNZJJG.js +31 -0
- package/dist/bundle/chunks/github-copilot.js +1 -1
- package/dist/bundle/chunks/google-generative-ai-VJSS5EBX.js +2 -0
- package/dist/bundle/chunks/google-vertex-K23DBWTT.js +2 -0
- package/dist/bundle/chunks/https-proxy-agent-WQIRL24U.js +13 -0
- package/dist/bundle/chunks/image-resize-worker.js +1 -1
- package/dist/bundle/chunks/lib-ULKZYRGD.js +9 -0
- package/dist/bundle/chunks/{llama-cpp-classify-EJ5XMSQL.js → llama-cpp-classify-3VDXTYVJ.js} +3 -3
- package/dist/bundle/chunks/mistral-conversations-SKVQJGFZ.js +5 -0
- package/dist/bundle/chunks/{multipart-parser-AZP5BX2W.js → multipart-parser-HMCXZ4BD.js} +1 -1
- package/dist/bundle/chunks/node-DXZFQBEO.js +16 -0
- package/dist/bundle/chunks/{node-C2JGH2OB.js → node-LBZLUIBE.js} +1 -1
- package/dist/bundle/chunks/openai-chatgpt.js +1 -1
- package/dist/bundle/chunks/openai-codex-responses-LV4RIZL3.js +10 -0
- package/dist/bundle/chunks/openai-codex.js +1 -1
- package/dist/bundle/chunks/openai-completions-PUIR2V25.js +7 -0
- package/dist/bundle/chunks/openai-decisions-2DJLSYQF.js +5 -0
- package/dist/bundle/chunks/openai-responses-6ESQOXAF.js +4 -0
- package/dist/bundle/chunks/opencode-go.js +1 -1
- package/dist/bundle/chunks/openrouter-images-TVXBMY3V.js +2 -0
- package/dist/bundle/chunks/pi-messages-XS7FDWQI.js +8 -0
- package/dist/bundle/chunks/runtime-IB3XQ7E3.js +2 -0
- package/dist/bundle/chunks/runtime-LB35PK4J.js +3 -0
- package/dist/bundle/chunks/settings-manager-YNY5F4RU.js +2 -0
- package/dist/bundle/chunks/src-KDGO7EGF.js +4 -0
- package/dist/bundle/chunks/typesafe-system-one-67GAWZXE.js +2 -0
- package/dist/bundle/chunks/virtual-modules-U4CBGVMI.js +2 -0
- package/dist/bundle/cli-runtime.js +1 -1
- package/dist/bundle/index.js +1 -1
- package/dist/bundle/rpc-entry.js +1 -1
- package/dist/cli/args.d.ts +2 -1
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +30 -8
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/credential-print.d.ts.map +1 -1
- package/dist/cli/credential-print.js +4 -4
- package/dist/cli/credential-print.js.map +1 -1
- package/dist/config.d.ts +18 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +44 -6
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session.d.ts +65 -8
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +240 -102
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +20 -13
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/bash-executor.d.ts.map +1 -1
- package/dist/core/bash-executor.js +42 -52
- package/dist/core/bash-executor.js.map +1 -1
- package/dist/core/bug-report.d.ts +9 -1
- package/dist/core/bug-report.d.ts.map +1 -1
- package/dist/core/builtins/completion-checks.d.ts +3 -0
- package/dist/core/builtins/completion-checks.d.ts.map +1 -0
- package/dist/core/builtins/completion-checks.js +142 -0
- package/dist/core/builtins/completion-checks.js.map +1 -0
- package/dist/core/builtins/duet.d.ts.map +1 -1
- package/dist/core/builtins/duet.js +7 -5
- package/dist/core/builtins/duet.js.map +1 -1
- package/dist/core/builtins/git-safety.d.ts +3 -0
- package/dist/core/builtins/git-safety.d.ts.map +1 -0
- package/dist/core/builtins/git-safety.js +34 -0
- package/dist/core/builtins/git-safety.js.map +1 -0
- package/dist/core/builtins/index.d.ts.map +1 -1
- package/dist/core/builtins/index.js +4 -0
- package/dist/core/builtins/index.js.map +1 -1
- package/dist/core/client-identity.d.ts +8 -0
- package/dist/core/client-identity.d.ts.map +1 -0
- package/dist/core/client-identity.js +15 -0
- package/dist/core/client-identity.js.map +1 -0
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +1 -2
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +2 -2
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +20 -15
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/compaction/utils.d.ts +6 -0
- package/dist/core/compaction/utils.d.ts.map +1 -1
- package/dist/core/compaction/utils.js +7 -8
- package/dist/core/compaction/utils.js.map +1 -1
- package/dist/core/export-html/index.d.ts.map +1 -1
- package/dist/core/export-html/index.js +2 -0
- package/dist/core/export-html/index.js.map +1 -1
- package/dist/core/export-html/template.html +1 -0
- package/dist/core/export-html/template.js +23 -17
- package/dist/core/export-html/tool-renderer.d.ts +3 -3
- package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
- package/dist/core/export-html/tool-renderer.js +5 -3
- package/dist/core/export-html/tool-renderer.js.map +1 -1
- package/dist/core/export-html/vendor/marked-cjk-friendly.min.js +6 -0
- package/dist/core/export-html/vendor/marked.min.js +30 -29
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +7 -0
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +6 -2
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +16 -4
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +61 -7
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/extensions/virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/virtual-modules.js +2 -0
- package/dist/core/extensions/virtual-modules.js.map +1 -1
- package/dist/core/key-id-schema.d.ts +6 -0
- package/dist/core/key-id-schema.d.ts.map +1 -0
- package/dist/core/key-id-schema.js +16 -0
- package/dist/core/key-id-schema.js.map +1 -0
- package/dist/core/keybindings-schema.d.ts +4 -0
- package/dist/core/keybindings-schema.d.ts.map +1 -0
- package/dist/core/keybindings-schema.js +16 -0
- package/dist/core/keybindings-schema.js.map +1 -0
- package/dist/core/keybindings.d.ts +242 -75
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +30 -23
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/mcp-servers.d.ts +22 -0
- package/dist/core/mcp-servers.d.ts.map +1 -1
- package/dist/core/mcp-servers.js +72 -11
- package/dist/core/mcp-servers.js.map +1 -1
- package/dist/core/model-config.d.ts +1623 -74
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +70 -184
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-registry.d.ts +3 -1
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +4 -0
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts +56 -43
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +253 -358
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +19 -10
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/nested-tool-calls.d.ts +1 -0
- package/dist/core/nested-tool-calls.d.ts.map +1 -1
- package/dist/core/nested-tool-calls.js +1 -0
- package/dist/core/nested-tool-calls.js.map +1 -1
- package/dist/core/package-manager.js +3 -3
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/polyphase/keyword.js +1 -1
- package/dist/core/polyphase/keyword.js.map +1 -1
- package/dist/core/polyphase/model-selection.d.ts.map +1 -1
- package/dist/core/polyphase/model-selection.js +15 -7
- package/dist/core/polyphase/model-selection.js.map +1 -1
- package/dist/core/polyphase/workflow/prelude.d.ts +2 -0
- package/dist/core/polyphase/workflow/prelude.d.ts.map +1 -1
- package/dist/core/polyphase/workflow/prelude.js +12 -16
- package/dist/core/polyphase/workflow/prelude.js.map +1 -1
- package/dist/core/polyphase/workflow/runtime.d.ts.map +1 -1
- package/dist/core/polyphase/workflow/runtime.js +2 -1
- package/dist/core/polyphase/workflow/runtime.js.map +1 -1
- package/dist/core/project-trust.d.ts.map +1 -1
- package/dist/core/project-trust.js +2 -1
- package/dist/core/project-trust.js.map +1 -1
- package/dist/core/prompt-templates.d.ts.map +1 -1
- package/dist/core/prompt-templates.js +7 -2
- package/dist/core/prompt-templates.js.map +1 -1
- package/dist/core/provider-composer.d.ts +2 -1
- package/dist/core/provider-composer.d.ts.map +1 -1
- package/dist/core/provider-composer.js +13 -0
- package/dist/core/provider-composer.js.map +1 -1
- package/dist/core/radius.d.ts +2 -0
- package/dist/core/radius.d.ts.map +1 -1
- package/dist/core/radius.js +2 -0
- package/dist/core/radius.js.map +1 -1
- package/dist/core/remote-catalog-provider.d.ts +12 -1
- package/dist/core/remote-catalog-provider.d.ts.map +1 -1
- package/dist/core/remote-catalog-provider.js +84 -24
- package/dist/core/remote-catalog-provider.js.map +1 -1
- package/dist/core/resource-loader.d.ts +3 -0
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +7 -4
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/sdk.d.ts +13 -4
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +27 -15
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/settings-defaults.d.ts +65 -0
- package/dist/core/settings-defaults.d.ts.map +1 -0
- package/dist/core/settings-defaults.js +66 -0
- package/dist/core/settings-defaults.js.map +1 -0
- package/dist/core/settings-manager.d.ts +17 -178
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +86 -57
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/settings-schema.d.ts +269 -0
- package/dist/core/settings-schema.d.ts.map +1 -0
- package/dist/core/settings-schema.js +318 -0
- package/dist/core/settings-schema.js.map +1 -0
- package/dist/core/skills.d.ts +4 -1
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +6 -1
- package/dist/core/skills.js.map +1 -1
- package/dist/core/system-prompt.d.ts +6 -0
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +10 -5
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +3 -5
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/grep.d.ts +8 -0
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js +19 -7
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/index.d.ts +2 -0
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +2 -0
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/output-accumulator.d.ts.map +1 -1
- package/dist/core/tools/output-accumulator.js +4 -10
- package/dist/core/tools/output-accumulator.js.map +1 -1
- package/dist/core/tools/path-utils.d.ts +1 -1
- package/dist/core/tools/path-utils.d.ts.map +1 -1
- package/dist/core/tools/path-utils.js +6 -6
- package/dist/core/tools/path-utils.js.map +1 -1
- package/dist/core/tools/read.d.ts +13 -0
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +32 -2
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/render-utils.d.ts +20 -0
- package/dist/core/tools/render-utils.d.ts.map +1 -1
- package/dist/core/tools/render-utils.js +67 -0
- package/dist/core/tools/render-utils.js.map +1 -1
- package/dist/core/tools/renderers/bash.d.ts.map +1 -1
- package/dist/core/tools/renderers/bash.js +7 -35
- package/dist/core/tools/renderers/bash.js.map +1 -1
- package/dist/core/tools/renderers/edit.d.ts.map +1 -1
- package/dist/core/tools/renderers/edit.js +5 -4
- package/dist/core/tools/renderers/edit.js.map +1 -1
- package/dist/core/tools/renderers/index.d.ts +2 -2
- package/dist/core/tools/renderers/index.d.ts.map +1 -1
- package/dist/core/tools/renderers/index.js.map +1 -1
- package/dist/core/tools/renderers/read.d.ts.map +1 -1
- package/dist/core/tools/renderers/read.js +7 -11
- package/dist/core/tools/renderers/read.js.map +1 -1
- package/dist/extensions/codemode/execute.d.ts.map +1 -1
- package/dist/extensions/codemode/execute.js +391 -80
- package/dist/extensions/codemode/execute.js.map +1 -1
- package/dist/extensions/codemode/index.d.ts.map +1 -1
- package/dist/extensions/codemode/index.js +3 -1
- package/dist/extensions/codemode/index.js.map +1 -1
- package/dist/extensions/codemode/renderer.d.ts +2 -2
- package/dist/extensions/codemode/renderer.d.ts.map +1 -1
- package/dist/extensions/codemode/renderer.js +9 -3
- package/dist/extensions/codemode/renderer.js.map +1 -1
- package/dist/extensions/codemode/tool.d.ts +22 -21
- package/dist/extensions/codemode/tool.d.ts.map +1 -1
- package/dist/extensions/codemode/tool.js +96 -123
- package/dist/extensions/codemode/tool.js.map +1 -1
- package/dist/extensions/llama/provider.d.ts.map +1 -1
- package/dist/extensions/llama/provider.js +34 -11
- package/dist/extensions/llama/provider.js.map +1 -1
- package/dist/extensions/mcp/cli.d.ts.map +1 -1
- package/dist/extensions/mcp/cli.js +27 -33
- package/dist/extensions/mcp/cli.js.map +1 -1
- package/dist/extensions/mcp/config.d.ts +15 -3
- package/dist/extensions/mcp/config.d.ts.map +1 -1
- package/dist/extensions/mcp/config.js +49 -12
- package/dist/extensions/mcp/config.js.map +1 -1
- package/dist/extensions/mcp/index.d.ts +4 -1
- package/dist/extensions/mcp/index.d.ts.map +1 -1
- package/dist/extensions/mcp/index.js +279 -129
- package/dist/extensions/mcp/index.js.map +1 -1
- package/dist/extensions/mcp/oauth.d.ts +21 -11
- package/dist/extensions/mcp/oauth.d.ts.map +1 -1
- package/dist/extensions/mcp/oauth.js +166 -45
- package/dist/extensions/mcp/oauth.js.map +1 -1
- package/dist/extensions/mcp/resources.d.ts +3 -10
- package/dist/extensions/mcp/resources.d.ts.map +1 -1
- package/dist/extensions/mcp/resources.js +4 -5
- package/dist/extensions/mcp/resources.js.map +1 -1
- package/dist/extensions/mcp/runtime.d.ts +7 -7
- package/dist/extensions/mcp/runtime.d.ts.map +1 -1
- package/dist/extensions/mcp/runtime.js +31 -45
- package/dist/extensions/mcp/runtime.js.map +1 -1
- package/dist/extensions/mcp/tools.d.ts +7 -5
- package/dist/extensions/mcp/tools.d.ts.map +1 -1
- package/dist/extensions/mcp/tools.js +87 -29
- package/dist/extensions/mcp/tools.js.map +1 -1
- package/dist/extensions/mcp/ui.d.ts +3 -3
- package/dist/extensions/mcp/ui.d.ts.map +1 -1
- package/dist/extensions/mcp/ui.js +18 -6
- package/dist/extensions/mcp/ui.js.map +1 -1
- package/dist/extensions/tool-search/tool.d.ts +0 -2
- package/dist/extensions/tool-search/tool.d.ts.map +1 -1
- package/dist/extensions/tool-search/tool.js +2 -4
- package/dist/extensions/tool-search/tool.js.map +1 -1
- package/dist/hooks/checks/checks-runtime.cjs +215 -0
- package/dist/hooks/checks/git-safety.cjs +198 -0
- package/dist/hooks/checks/git-safety.d.cts +1 -0
- package/dist/hooks/gsd/draht-post-task.js +78 -39
- package/dist/hooks/gsd/draht-quality-gate.js +210 -122
- package/dist/hooks/gsd/package.json +3 -0
- package/dist/index.d.ts +5 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +11 -3
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/auth-url.d.ts +14 -0
- package/dist/modes/interactive/components/auth-url.d.ts.map +1 -0
- package/dist/modes/interactive/components/auth-url.js +37 -0
- package/dist/modes/interactive/components/auth-url.js.map +1 -0
- package/dist/modes/interactive/components/bash-execution.d.ts +5 -1
- package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/bash-execution.js +17 -14
- package/dist/modes/interactive/components/bash-execution.js.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts +2 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.js +5 -2
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.d.ts +2 -1
- package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.js +5 -2
- package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/custom-entry.d.ts +3 -1
- package/dist/modes/interactive/components/custom-entry.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-entry.js +8 -2
- package/dist/modes/interactive/components/custom-entry.js.map +1 -1
- package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-message.js +1 -0
- package/dist/modes/interactive/components/custom-message.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts +3 -0
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +38 -10
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts +8 -2
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.js +24 -21
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
- package/dist/modes/interactive/components/radius-login-selector.d.ts +15 -0
- package/dist/modes/interactive/components/radius-login-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/radius-login-selector.js +85 -0
- package/dist/modes/interactive/components/radius-login-selector.js.map +1 -0
- package/dist/modes/interactive/components/settings-selector.d.ts +3 -3
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +9 -8
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts +2 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.js +5 -2
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
- package/dist/modes/interactive/components/status-indicator.d.ts +1 -1
- package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -1
- package/dist/modes/interactive/components/status-indicator.js +2 -2
- package/dist/modes/interactive/components/status-indicator.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +12 -13
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +32 -45
- 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 +2 -9
- package/dist/modes/interactive/components/tree-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message.js +5 -4
- package/dist/modes/interactive/components/user-message.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +43 -48
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +362 -278
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/program-status-reporter.d.ts +34 -0
- package/dist/modes/interactive/program-status-reporter.d.ts.map +1 -0
- package/dist/modes/interactive/program-status-reporter.js +110 -0
- package/dist/modes/interactive/program-status-reporter.js.map +1 -0
- package/dist/modes/interactive/theme/dark.json +1 -1
- package/dist/modes/interactive/theme/light.json +1 -1
- package/dist/modes/interactive/theme/system-theme.d.ts +2 -1
- package/dist/modes/interactive/theme/system-theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/system-theme.js +16 -5
- package/dist/modes/interactive/theme/system-theme.js.map +1 -1
- package/dist/modes/interactive/theme/theme-schema.d.ts +28 -0
- package/dist/modes/interactive/theme/theme-schema.d.ts.map +1 -0
- package/dist/modes/interactive/theme/theme-schema.js +105 -0
- package/dist/modes/interactive/theme/theme-schema.js.map +1 -0
- package/dist/modes/interactive/theme/theme-tokens.d.ts +257 -0
- package/dist/modes/interactive/theme/theme-tokens.d.ts.map +1 -0
- package/dist/modes/interactive/theme/theme-tokens.js +94 -0
- package/dist/modes/interactive/theme/theme-tokens.js.map +1 -0
- package/dist/modes/interactive/theme/theme.d.ts +13 -16
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +22 -29
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js +4 -0
- package/dist/modes/print-mode.js.map +1 -1
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +26 -1
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/prompts/commands/atomic-commit.md +8 -6
- package/dist/prompts/commands/brainstorm.md +5 -149
- package/dist/prompts/commands/create-verification-skill.md +8 -48
- package/dist/prompts/commands/discuss-phase.md +6 -10
- package/dist/prompts/commands/execute-phase.md +18 -45
- package/dist/prompts/commands/fix.md +16 -128
- package/dist/prompts/commands/grill.md +6 -53
- package/dist/prompts/commands/init-project.md +13 -18
- package/dist/prompts/commands/map-codebase.md +3 -3
- package/dist/prompts/commands/new-project.md +12 -17
- package/dist/prompts/commands/next-milestone.md +4 -8
- package/dist/prompts/commands/orchestrate-loop.md +12 -12
- package/dist/prompts/commands/orchestrate.md +12 -11
- package/dist/prompts/commands/pause-work.md +1 -1
- package/dist/prompts/commands/plan-phase.md +15 -37
- package/dist/prompts/commands/quick.md +11 -64
- package/dist/prompts/commands/resolve-conflicts.md +2 -15
- package/dist/prompts/commands/triage.md +3 -14
- package/dist/prompts/commands/verify-work.md +15 -63
- package/dist/prompts/commands/why.md +18 -118
- package/dist/skills/atomic-reasoning/SKILL.md +6 -105
- package/dist/skills/blast-radius/SKILL.md +1 -1
- package/dist/skills/epistemics/SKILL.md +12 -87
- package/dist/skills/explainers/SKILL.md +1 -1
- package/dist/skills/typescript-discipline/SKILL.md +12 -42
- package/dist/skills/typescript-discipline/references/patterns.md +25 -266
- package/dist/skills/unslop/SKILL.md +14 -105
- package/dist/utils/ansi.d.ts +8 -0
- package/dist/utils/ansi.d.ts.map +1 -1
- package/dist/utils/ansi.js +30 -11
- package/dist/utils/ansi.js.map +1 -1
- package/dist/utils/clipboard-command.d.ts.map +1 -1
- package/dist/utils/clipboard-command.js +3 -0
- package/dist/utils/clipboard-command.js.map +1 -1
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js +18 -12
- package/dist/utils/clipboard.js.map +1 -1
- package/dist/utils/draht-user-agent.d.ts +1 -0
- package/dist/utils/draht-user-agent.d.ts.map +1 -1
- package/dist/utils/draht-user-agent.js +3 -2
- package/dist/utils/draht-user-agent.js.map +1 -1
- package/dist/utils/image-convert.d.ts +12 -0
- package/dist/utils/image-convert.d.ts.map +1 -1
- package/dist/utils/image-convert.js +45 -6
- package/dist/utils/image-convert.js.map +1 -1
- package/dist/utils/image-resize-core.d.ts +12 -0
- package/dist/utils/image-resize-core.d.ts.map +1 -1
- package/dist/utils/image-resize-core.js +5 -0
- package/dist/utils/image-resize-core.js.map +1 -1
- package/dist/utils/image-resize-worker.js +3 -2
- package/dist/utils/image-resize-worker.js.map +1 -1
- package/dist/utils/image-resize.d.ts.map +1 -1
- package/dist/utils/image-resize.js +9 -10
- package/dist/utils/image-resize.js.map +1 -1
- package/dist/utils/output-files.d.ts +15 -0
- package/dist/utils/output-files.d.ts.map +1 -0
- package/dist/utils/output-files.js +30 -0
- package/dist/utils/output-files.js.map +1 -0
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +43 -13
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/syntax-highlight.d.ts.map +1 -1
- package/dist/utils/syntax-highlight.js +6 -1
- package/dist/utils/syntax-highlight.js.map +1 -1
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +4 -3
- package/dist/utils/tools-manager.js.map +1 -1
- package/docs/cli-integration.md +1 -1
- package/docs/cli.md +30 -26
- package/docs/codemode.md +230 -0
- package/docs/compaction.md +5 -5
- package/docs/containerization.md +1 -1
- package/docs/custom-provider.md +53 -1
- package/docs/docs.json +17 -1
- package/docs/drahtbank.md +163 -0
- package/docs/environment-variables.md +5 -2
- package/docs/extensions.md +143 -13
- package/docs/index.md +1 -1
- package/docs/json.md +3 -3
- package/docs/keybindings.md +9 -5
- package/docs/llama-cpp.md +9 -2
- package/docs/mcp.md +59 -3
- package/docs/message-types.md +22 -4
- package/docs/models-configuration.md +187 -0
- package/docs/models.md +67 -4
- package/docs/nvidia-rtx-llama-cpp.md +96 -0
- package/docs/providers.md +70 -5
- package/docs/sdk.md +1 -1
- package/docs/settings.md +10 -8
- package/docs/terminal-setup.md +14 -0
- package/docs/themes.md +4 -2
- package/docs/tui.md +71 -1
- package/docs/usage.md +1 -1
- package/docs/windows.md +16 -2
- package/eval/drahtbank/adapters.d.mts +35 -0
- package/eval/drahtbank/adapters.mjs +192 -0
- package/eval/drahtbank/bank.d.mts +141 -0
- package/eval/drahtbank/bank.mjs +515 -0
- package/eval/drahtbank/cases-v2.d.mts +28 -0
- package/eval/drahtbank/cases-v2.mjs +164 -0
- package/eval/drahtbank/cases.d.mts +17 -0
- package/eval/drahtbank/cases.mjs +198 -0
- package/eval/drahtbank/cli.mjs +120 -0
- package/eval/drahtbank/grading-v2.d.mts +26 -0
- package/eval/drahtbank/grading-v2.mjs +227 -0
- package/eval/drahtbank/isolated-tools.ts +223 -0
- package/eval/drahtbank/isolation-worker.mjs +53 -0
- package/eval/drahtbank/isolation.d.mts +52 -0
- package/eval/drahtbank/isolation.mjs +345 -0
- package/eval/drahtbank/runtime-checks.d.mts +15 -0
- package/eval/drahtbank/runtime-checks.mjs +187 -0
- package/examples/extensions/dynamic-resources/dynamic.json +1 -1
- package/examples/extensions/minimal-mode.ts +4 -5
- package/examples/extensions/overlay-test.ts +2 -2
- package/examples/extensions/plan-mode/index.ts +6 -2
- package/examples/extensions/subagent/index.ts +4 -6
- package/hooks/checks/checks-runtime.cjs +215 -0
- package/hooks/checks/git-safety.cjs +198 -0
- package/hooks/checks/git-safety.d.cts +1 -0
- package/hooks/gsd/draht-post-task.js +78 -39
- package/hooks/gsd/draht-quality-gate.js +210 -122
- package/hooks/gsd/package.json +3 -0
- package/package.json +21 -16
- package/prompts/commands/atomic-commit.md +8 -6
- package/prompts/commands/brainstorm.md +5 -149
- package/prompts/commands/create-verification-skill.md +8 -48
- package/prompts/commands/discuss-phase.md +6 -10
- package/prompts/commands/execute-phase.md +18 -45
- package/prompts/commands/fix.md +16 -128
- package/prompts/commands/grill.md +6 -53
- package/prompts/commands/init-project.md +13 -18
- package/prompts/commands/map-codebase.md +3 -3
- package/prompts/commands/new-project.md +12 -17
- package/prompts/commands/next-milestone.md +4 -8
- package/prompts/commands/orchestrate-loop.md +12 -12
- package/prompts/commands/orchestrate.md +12 -11
- package/prompts/commands/pause-work.md +1 -1
- package/prompts/commands/plan-phase.md +15 -37
- package/prompts/commands/quick.md +11 -64
- package/prompts/commands/resolve-conflicts.md +2 -15
- package/prompts/commands/triage.md +3 -14
- package/prompts/commands/verify-work.md +15 -63
- package/prompts/commands/why.md +18 -118
- package/schemas/keybindings.schema.json +433 -0
- package/schemas/models.schema.json +1190 -0
- package/schemas/settings.schema.json +849 -0
- package/schemas/theme.schema.json +365 -0
- package/skills/atomic-reasoning/SKILL.md +6 -105
- package/skills/blast-radius/SKILL.md +1 -1
- package/skills/epistemics/SKILL.md +12 -87
- package/skills/explainers/SKILL.md +1 -1
- package/skills/typescript-discipline/SKILL.md +12 -42
- package/skills/typescript-discipline/references/patterns.md +25 -266
- package/skills/unslop/SKILL.md +14 -105
- package/dist/bundle/chunks/anthropic-messages-GAKYXF65.js +0 -6
- package/dist/bundle/chunks/azure-openai-responses-ZIXMK6JO.js +0 -2
- package/dist/bundle/chunks/chunk-2E5VODES.js +0 -2
- package/dist/bundle/chunks/chunk-2VAF4XJI.js +0 -146
- package/dist/bundle/chunks/chunk-4TVQYRQY.js +0 -2
- package/dist/bundle/chunks/chunk-6MSE6LZ3.js +0 -6
- package/dist/bundle/chunks/chunk-6ZJKIMU7.js +0 -2
- package/dist/bundle/chunks/chunk-736QBNUZ.js +0 -12
- package/dist/bundle/chunks/chunk-7TYCZN4Z.js +0 -137
- package/dist/bundle/chunks/chunk-BXSHCX3G.js +0 -11
- package/dist/bundle/chunks/chunk-GVXA72ZA.js +0 -2
- package/dist/bundle/chunks/chunk-I5OKY6RH.js +0 -11
- package/dist/bundle/chunks/chunk-IWTUBX6V.js +0 -4
- package/dist/bundle/chunks/chunk-KU5HAKZL.js +0 -4
- package/dist/bundle/chunks/chunk-MO3SCGBN.js +0 -18
- package/dist/bundle/chunks/chunk-N2QZNJT6.js +0 -65
- package/dist/bundle/chunks/chunk-PGJAHC3R.js +0 -107
- package/dist/bundle/chunks/chunk-QVFELZW2.js +0 -312
- package/dist/bundle/chunks/chunk-RZKPFWMH.js +0 -42
- package/dist/bundle/chunks/chunk-SDRCE6OP.js +0 -2
- package/dist/bundle/chunks/chunk-SVNWI7EV.js +0 -8
- package/dist/bundle/chunks/chunk-TIA2T6EO.js +0 -3
- package/dist/bundle/chunks/chunk-TOWVIJ2O.js +0 -1623
- package/dist/bundle/chunks/chunk-XBUEMKIY.js +0 -2
- package/dist/bundle/chunks/chunk-ZA4QNPJY.js +0 -82
- package/dist/bundle/chunks/cloudflare-workers-ai-system-one-MJKOAE5S.js +0 -2
- package/dist/bundle/chunks/execute-6N7T7VLY.js +0 -18
- package/dist/bundle/chunks/google-generative-ai-RPUPQ6PM.js +0 -2
- package/dist/bundle/chunks/google-vertex-EZES5QVQ.js +0 -2
- package/dist/bundle/chunks/https-proxy-agent-O2PVUIOI.js +0 -13
- package/dist/bundle/chunks/lib-XOG5PI3Y.js +0 -9
- package/dist/bundle/chunks/mistral-conversations-AOYGU43Y.js +0 -5
- package/dist/bundle/chunks/node-LQ52KV6B.js +0 -16
- package/dist/bundle/chunks/openai-codex-responses-M2Y77JEQ.js +0 -10
- package/dist/bundle/chunks/openai-completions-A4OKYOYV.js +0 -7
- package/dist/bundle/chunks/openai-responses-6IXV53T3.js +0 -3
- package/dist/bundle/chunks/openrouter-images-LYV4NKFM.js +0 -2
- package/dist/bundle/chunks/pi-messages-KKMEUT3Z.js +0 -8
- package/dist/bundle/chunks/runtime-363BOYEO.js +0 -3
- package/dist/bundle/chunks/runtime-D3KV73AE.js +0 -2
- package/dist/bundle/chunks/settings-manager-GEOZJXFQ.js +0 -2
- package/dist/bundle/chunks/src-TIBHS42X.js +0 -4
- package/dist/bundle/chunks/typesafe-system-one-YBEEY5XU.js +0 -2
- package/dist/bundle/chunks/virtual-modules-RLC4Y5MX.js +0 -2
- package/dist/core/provider-attribution.d.ts +0 -4
- package/dist/core/provider-attribution.d.ts.map +0 -1
- package/dist/core/provider-attribution.js +0 -72
- package/dist/core/provider-attribution.js.map +0 -1
- package/dist/experimental/micro/api.d.ts +0 -81
- package/dist/experimental/micro/api.d.ts.map +0 -1
- package/dist/experimental/micro/api.js +0 -2
- package/dist/experimental/micro/api.js.map +0 -1
- package/dist/experimental/micro/main.d.ts +0 -3
- package/dist/experimental/micro/main.d.ts.map +0 -1
- package/dist/experimental/micro/main.js +0 -21
- package/dist/experimental/micro/main.js.map +0 -1
- package/dist/experimental/micro/models.d.ts +0 -11
- package/dist/experimental/micro/models.d.ts.map +0 -1
- package/dist/experimental/micro/models.js +0 -95
- package/dist/experimental/micro/models.js.map +0 -1
- package/dist/experimental/micro/runtime.d.ts +0 -12
- package/dist/experimental/micro/runtime.d.ts.map +0 -1
- package/dist/experimental/micro/runtime.js +0 -465
- package/dist/experimental/micro/runtime.js.map +0 -1
- package/dist/experimental/micro/sessions.d.ts +0 -10
- package/dist/experimental/micro/sessions.d.ts.map +0 -1
- package/dist/experimental/micro/sessions.js +0 -41
- package/dist/experimental/micro/sessions.js.map +0 -1
- package/dist/experimental/micro/tools.d.ts +0 -10
- package/dist/experimental/micro/tools.d.ts.map +0 -1
- package/dist/experimental/micro/tools.js +0 -96
- package/dist/experimental/micro/tools.js.map +0 -1
- package/dist/experimental/micro/tui.d.ts +0 -3
- package/dist/experimental/micro/tui.d.ts.map +0 -1
- package/dist/experimental/micro/tui.js +0 -510
- package/dist/experimental/micro/tui.js.map +0 -1
- package/dist/experimental/mini/main.d.ts +0 -7
- package/dist/experimental/mini/main.d.ts.map +0 -1
- package/dist/experimental/mini/main.js +0 -21
- package/dist/experimental/mini/main.js.map +0 -1
- package/dist/experimental/mini/server/entry.d.ts +0 -3
- package/dist/experimental/mini/server/entry.d.ts.map +0 -1
- package/dist/experimental/mini/server/entry.js +0 -11
- package/dist/experimental/mini/server/entry.js.map +0 -1
- package/dist/experimental/mini/server/run.d.ts +0 -13
- package/dist/experimental/mini/server/run.d.ts.map +0 -1
- package/dist/experimental/mini/server/run.js +0 -150
- package/dist/experimental/mini/server/run.js.map +0 -1
- package/dist/experimental/mini/shared/protocol.d.ts +0 -127
- package/dist/experimental/mini/shared/protocol.d.ts.map +0 -1
- package/dist/experimental/mini/shared/protocol.js +0 -13
- package/dist/experimental/mini/shared/protocol.js.map +0 -1
- package/dist/experimental/mini/shared/rpc.d.ts +0 -49
- package/dist/experimental/mini/shared/rpc.d.ts.map +0 -1
- package/dist/experimental/mini/shared/rpc.js +0 -171
- package/dist/experimental/mini/shared/rpc.js.map +0 -1
- package/dist/experimental/mini/shared/transport.d.ts +0 -35
- package/dist/experimental/mini/shared/transport.d.ts.map +0 -1
- package/dist/experimental/mini/shared/transport.js +0 -94
- package/dist/experimental/mini/shared/transport.js.map +0 -1
- package/dist/experimental/mini/tui/run.d.ts +0 -9
- package/dist/experimental/mini/tui/run.d.ts.map +0 -1
- package/dist/experimental/mini/tui/run.js +0 -62
- package/dist/experimental/mini/tui/run.js.map +0 -1
- package/dist/experimental/mini/tui/session.d.ts +0 -26
- package/dist/experimental/mini/tui/session.d.ts.map +0 -1
- package/dist/experimental/mini/tui/session.js +0 -94
- package/dist/experimental/mini/tui/session.js.map +0 -1
- package/dist/experimental/mini/tui/view.d.ts +0 -10
- package/dist/experimental/mini/tui/view.d.ts.map +0 -1
- package/dist/experimental/mini/tui/view.js +0 -461
- package/dist/experimental/mini/tui/view.js.map +0 -1
- package/dist/experimental/mini/worker/entry.d.ts +0 -3
- package/dist/experimental/mini/worker/entry.d.ts.map +0 -1
- package/dist/experimental/mini/worker/entry.js +0 -10
- package/dist/experimental/mini/worker/entry.js.map +0 -1
- package/dist/experimental/mini/worker/lane-service.d.ts +0 -44
- package/dist/experimental/mini/worker/lane-service.d.ts.map +0 -1
- package/dist/experimental/mini/worker/lane-service.js +0 -97
- package/dist/experimental/mini/worker/lane-service.js.map +0 -1
- package/dist/experimental/mini/worker/models-service.d.ts +0 -19
- package/dist/experimental/mini/worker/models-service.d.ts.map +0 -1
- package/dist/experimental/mini/worker/models-service.js +0 -136
- package/dist/experimental/mini/worker/models-service.js.map +0 -1
- package/dist/experimental/mini/worker/run.d.ts +0 -14
- package/dist/experimental/mini/worker/run.d.ts.map +0 -1
- package/dist/experimental/mini/worker/run.js +0 -88
- package/dist/experimental/mini/worker/run.js.map +0 -1
- package/dist/modes/interactive/theme/theme-json.d.ts +0 -85
- package/dist/modes/interactive/theme/theme-json.d.ts.map +0 -1
- package/dist/modes/interactive/theme/theme-json.js +0 -132
- package/dist/modes/interactive/theme/theme-json.js.map +0 -1
- package/dist/modes/interactive/theme/theme-schema.json +0 -361
- /package/dist/bundle/chunks/{chunk-ZZD35WKM.js → chunk-MOOADNVS.js} +0 -0
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
import { readFileSync } from "node:fs";
|
|
16
16
|
import { basename, dirname } from "node:path";
|
|
17
17
|
import { runToolCall, } from "@draht/agent-core";
|
|
18
|
-
import { contentText, getCurrentSystemMessage, retryDelayMs } from "@draht/ai";
|
|
18
|
+
import { contentText, getCurrentSystemMessage, getCurrentTools, retryDelayMs } from "@draht/ai";
|
|
19
19
|
import { clampThinkingLevel, cleanupSessionResources, getSupportedThinkingLevels, isContextOverflow, isRecoverableLength, isRetryableAssistantError, modelsAreEqual, resetApiProviders, streamSimple, } from "@draht/ai/compat";
|
|
20
20
|
import { getThemeByName, theme } from "../modes/interactive/theme/theme.js";
|
|
21
21
|
import { stripFrontmatter } from "../utils/frontmatter.js";
|
|
@@ -32,6 +32,7 @@ import { exportSessionToHtml } from "./export-html/index.js";
|
|
|
32
32
|
import { createToolHtmlRenderer } from "./export-html/tool-renderer.js";
|
|
33
33
|
import { ExtensionRunner, wrapRegisteredTools, } from "./extensions/index.js";
|
|
34
34
|
import { emitSessionShutdownEvent } from "./extensions/runner.js";
|
|
35
|
+
import { createToolNameMatcher, isMcpToolName } from "./mcp-servers.js";
|
|
35
36
|
import { convertToLlm } from "./messages.js";
|
|
36
37
|
import { ModelRegistry } from "./model-registry.js";
|
|
37
38
|
import { NestedToolCallRunner } from "./nested-tool-calls.js";
|
|
@@ -39,7 +40,7 @@ import { createRelayUIContext, noOpRelayBaseUIContext, } from "./permission-rela
|
|
|
39
40
|
import { expandPromptTemplate } from "./prompt-templates.js";
|
|
40
41
|
import { exportSessionToJsonl } from "./session-export.js";
|
|
41
42
|
import { getLatestCompactionEntry, SessionManager, } from "./session-manager.js";
|
|
42
|
-
import { DEFAULT_TOOL_NAMES } from "./settings-manager.js";
|
|
43
|
+
import { applyToolModifiers, DEFAULT_TOOL_NAMES, } from "./settings-manager.js";
|
|
43
44
|
import { BUILTIN_PATH_PREFIX, createSyntheticSourceInfo, isSyntheticPath } from "./source-info.js";
|
|
44
45
|
import { buildSystemPrompt, buildSystemPromptSections, diffSystemPromptSections, normalizeBuildSystemPromptOptions, } from "./system-prompt.js";
|
|
45
46
|
import { createLocalBashOperations } from "./tools/bash.js";
|
|
@@ -145,10 +146,10 @@ export class AgentSession {
|
|
|
145
146
|
_entryIdsByMessage = new WeakMap();
|
|
146
147
|
_boundaryDispatchedMessages = new WeakSet();
|
|
147
148
|
_lastAssistantMessage;
|
|
148
|
-
_lastAssistantToolResults = [];
|
|
149
149
|
_lastActivityOutcome = "completed";
|
|
150
150
|
_isBeforeSettle = false;
|
|
151
151
|
_abortDuringBeforeSettle = false;
|
|
152
|
+
_beforeSettleAbortController;
|
|
152
153
|
_isEmittingAgentSettled = false;
|
|
153
154
|
_deferredSettledActions = [];
|
|
154
155
|
_resourceLoader;
|
|
@@ -157,9 +158,22 @@ export class AgentSession {
|
|
|
157
158
|
_cwd;
|
|
158
159
|
_extensionRunnerRef;
|
|
159
160
|
_initialActiveToolNames;
|
|
161
|
+
/**
|
|
162
|
+
* Tools of the restored or reloaded loadout that are not registered yet, such as tools of MCP
|
|
163
|
+
* servers that are still connecting. They are activated when they are registered, and dropped when
|
|
164
|
+
* `setActiveToolsByName()` deactivates a tool or the next agent run starts.
|
|
165
|
+
*/
|
|
166
|
+
_pendingToolNames = new Set();
|
|
160
167
|
_usesDefaultTools;
|
|
161
|
-
|
|
162
|
-
|
|
168
|
+
_defaultToolModifiers;
|
|
169
|
+
/** Matches the `--tools` entries: tool names or patterns. */
|
|
170
|
+
_allowedTools;
|
|
171
|
+
/**
|
|
172
|
+
* Whether the allowlist filters MCP tools: it is empty (`--no-tools`) or names an MCP tool
|
|
173
|
+
* (`mcp__*`). Otherwise it keeps MCP tools registered for codemode and tool_search.
|
|
174
|
+
*/
|
|
175
|
+
_allowlistFiltersMcp = false;
|
|
176
|
+
_excludedTools;
|
|
163
177
|
_baseToolsOverride;
|
|
164
178
|
_sessionStartEvent;
|
|
165
179
|
_extensionUIContext;
|
|
@@ -200,8 +214,13 @@ export class AgentSession {
|
|
|
200
214
|
this._extensionRunnerRef = config.extensionRunnerRef;
|
|
201
215
|
this._initialActiveToolNames = config.initialActiveToolNames;
|
|
202
216
|
this._usesDefaultTools = config.usesDefaultTools ?? false;
|
|
203
|
-
this.
|
|
204
|
-
|
|
217
|
+
this._defaultToolModifiers = config.defaultToolModifiers ?? [];
|
|
218
|
+
if (config.allowedToolNames) {
|
|
219
|
+
this._allowedTools = createToolNameMatcher(config.allowedToolNames);
|
|
220
|
+
this._allowlistFiltersMcp =
|
|
221
|
+
config.allowedToolNames.length === 0 || config.allowedToolNames.some((entry) => entry.startsWith("mcp__"));
|
|
222
|
+
}
|
|
223
|
+
this._excludedTools = config.excludedToolNames ? createToolNameMatcher(config.excludedToolNames) : undefined;
|
|
205
224
|
this._baseToolsOverride = config.baseToolsOverride;
|
|
206
225
|
this._sessionStartEvent = config.sessionStartEvent ?? { type: "session_start", reason: "startup" };
|
|
207
226
|
// Always subscribe to agent events for internal handling
|
|
@@ -217,8 +236,8 @@ export class AgentSession {
|
|
|
217
236
|
activeToolNames: this._initialActiveToolNames,
|
|
218
237
|
includeAllExtensionTools: true,
|
|
219
238
|
});
|
|
220
|
-
if (this.
|
|
221
|
-
this._restoreToolsFromTranscript();
|
|
239
|
+
if (this._usesDefaultTools)
|
|
240
|
+
this._restoreToolsFromTranscript(this._defaultToolModifiers);
|
|
222
241
|
}
|
|
223
242
|
get modelRuntime() {
|
|
224
243
|
return this._modelRuntime;
|
|
@@ -692,8 +711,9 @@ export class AgentSession {
|
|
|
692
711
|
this._isAgentRunActive = false;
|
|
693
712
|
this._isEmittingAgentSettled = true;
|
|
694
713
|
try {
|
|
695
|
-
|
|
696
|
-
this.
|
|
714
|
+
const aborted = this._agentRunAbortRequested;
|
|
715
|
+
await this._extensionRunner.emit({ type: "agent_settled", aborted });
|
|
716
|
+
this._emit({ type: "agent_settled", aborted });
|
|
697
717
|
}
|
|
698
718
|
finally {
|
|
699
719
|
this._isEmittingAgentSettled = false;
|
|
@@ -713,6 +733,10 @@ export class AgentSession {
|
|
|
713
733
|
}
|
|
714
734
|
/** Internal handler for agent events - shared by subscribe and reconnect */
|
|
715
735
|
_handleAgentEvent = async (event) => {
|
|
736
|
+
// An abort requested while the run was starting, e.g. during before_agent_start, stops it
|
|
737
|
+
// here. agent_start is awaited before the first request.
|
|
738
|
+
if (event.type === "agent_start" && this._agentRunAbortRequested)
|
|
739
|
+
this.agent.abort();
|
|
716
740
|
// Record the calls a tool made through ctx.executeTool() and their usage on its result message.
|
|
717
741
|
if (this._nestedToolCalls) {
|
|
718
742
|
if (event.type === "message_start" && event.message.role === "toolResult") {
|
|
@@ -795,7 +819,6 @@ export class AgentSession {
|
|
|
795
819
|
// extension and listener dispatch above also picks up messages that turn_end
|
|
796
820
|
// handlers queued.
|
|
797
821
|
if (event.type === "turn_end") {
|
|
798
|
-
this._lastAssistantToolResults = event.toolResults;
|
|
799
822
|
this._flushPendingCustomMessages();
|
|
800
823
|
}
|
|
801
824
|
};
|
|
@@ -838,7 +861,24 @@ export class AgentSession {
|
|
|
838
861
|
}
|
|
839
862
|
return undefined;
|
|
840
863
|
}
|
|
841
|
-
|
|
864
|
+
/**
|
|
865
|
+
* Persistently omit a failed attempt and its tool results from model context. Results are
|
|
866
|
+
* found in the projected context, so the pair stays together whether the attempt comes from
|
|
867
|
+
* the current run or a resumed session. An unpaired result fails the next request (#11227).
|
|
868
|
+
*/
|
|
869
|
+
_omitRecoveryAttempt(message) {
|
|
870
|
+
const toolCallIds = new Set(message.content.flatMap((block) => (block.type === "toolCall" ? [block.id] : [])));
|
|
871
|
+
// A context edit replaces the projected copy, so match it by source entry as well.
|
|
872
|
+
const entryId = this._findPersistedMessageEntryId(message);
|
|
873
|
+
const messages = this.agent.state.messages;
|
|
874
|
+
const index = messages.findIndex((m) => m === message || (entryId !== undefined && this._entryIdsByMessage.get(m) === entryId));
|
|
875
|
+
const toolResults = [];
|
|
876
|
+
for (const m of index < 0 ? [] : messages.slice(index + 1)) {
|
|
877
|
+
if (m.role === "assistant")
|
|
878
|
+
break;
|
|
879
|
+
if (m.role === "toolResult" && toolCallIds.has(m.toolCallId))
|
|
880
|
+
toolResults.push(m);
|
|
881
|
+
}
|
|
842
882
|
const targets = [message, ...toolResults];
|
|
843
883
|
const targetIds = targets.map((target) => this._findPersistedMessageEntryId(target));
|
|
844
884
|
const unresolvedProjectedTarget = targets.some((target, index) => targetIds[index] === undefined && this.agent.state.messages.includes(target));
|
|
@@ -963,6 +1003,7 @@ export class AgentSession {
|
|
|
963
1003
|
toolName: event.toolName,
|
|
964
1004
|
result: event.result,
|
|
965
1005
|
isError: event.isError,
|
|
1006
|
+
...(event.durationMs === undefined ? {} : { durationMs: event.durationMs }),
|
|
966
1007
|
};
|
|
967
1008
|
await this._extensionRunner.emit(extensionEvent);
|
|
968
1009
|
}
|
|
@@ -994,11 +1035,16 @@ export class AgentSession {
|
|
|
994
1035
|
* Call this when completely done with the session.
|
|
995
1036
|
*/
|
|
996
1037
|
dispose() {
|
|
1038
|
+
if (this._isAgentRunActive)
|
|
1039
|
+
this._agentRunAbortRequested = true;
|
|
1040
|
+
if (this._isBeforeSettle)
|
|
1041
|
+
this._abortDuringBeforeSettle = true;
|
|
997
1042
|
try {
|
|
998
1043
|
this.abortRetry();
|
|
999
1044
|
this.abortCompaction();
|
|
1000
1045
|
this.abortBranchSummary();
|
|
1001
1046
|
this.abortBash();
|
|
1047
|
+
this._beforeSettleAbortController?.abort();
|
|
1002
1048
|
this.agent.abort();
|
|
1003
1049
|
}
|
|
1004
1050
|
catch {
|
|
@@ -1088,6 +1134,7 @@ export class AgentSession {
|
|
|
1088
1134
|
exposure: this._getToolExposure(definition.name),
|
|
1089
1135
|
...(definition.namespace ? { namespace: definition.namespace } : {}),
|
|
1090
1136
|
...(definition.annotations ? { annotations: { ...definition.annotations } } : {}),
|
|
1137
|
+
...(definition.reachesTools ? { reachesTools: definition.reachesTools } : {}),
|
|
1091
1138
|
sourceInfo,
|
|
1092
1139
|
}));
|
|
1093
1140
|
}
|
|
@@ -1101,9 +1148,42 @@ export class AgentSession {
|
|
|
1101
1148
|
* Changes take effect on the next agent turn.
|
|
1102
1149
|
*/
|
|
1103
1150
|
setActiveToolsByName(toolNames) {
|
|
1151
|
+
const previous = this.getActiveToolNames();
|
|
1152
|
+
this._setActiveTools(toolNames);
|
|
1153
|
+
// A loadout that deactivates a tool replaces the restored one, whose pending tools are dropped.
|
|
1154
|
+
// One that only adds tools, like activating tool_search, keeps them.
|
|
1155
|
+
const active = new Set(this.getActiveToolNames());
|
|
1156
|
+
if (previous.some((name) => !active.has(name)))
|
|
1157
|
+
this._pendingToolNames.clear();
|
|
1158
|
+
}
|
|
1159
|
+
_setActiveTools(toolNames) {
|
|
1104
1160
|
const tools = this._applyToolLoadout(toolNames);
|
|
1161
|
+
for (const tool of tools)
|
|
1162
|
+
this._pendingToolNames.delete(tool.name);
|
|
1105
1163
|
this._rebuildSystemPrompt(tools.map((tool) => tool.name));
|
|
1106
1164
|
}
|
|
1165
|
+
/**
|
|
1166
|
+
* Whether `--tools` and `--exclude-tools` keep the tool registered. MCP tools stay registered
|
|
1167
|
+
* unless the allowlist filters them (see `_allowlistFiltersMcp`).
|
|
1168
|
+
*/
|
|
1169
|
+
_isAllowedTool(name) {
|
|
1170
|
+
if (this._excludedTools?.(name))
|
|
1171
|
+
return false;
|
|
1172
|
+
if (!this._allowedTools || this._allowedTools(name))
|
|
1173
|
+
return true;
|
|
1174
|
+
return !this._allowlistFiltersMcp && isMcpToolName(name);
|
|
1175
|
+
}
|
|
1176
|
+
/**
|
|
1177
|
+
* Whether the tool may be active, which declares it to the model. MCP tools the allowlist keeps
|
|
1178
|
+
* without matching them are only for codemode and tool_search: they may be declared only when
|
|
1179
|
+
* tool_search can load them (non-`direct` exposure and tool_search registered). This also applies
|
|
1180
|
+
* to tools restored from the transcript or set by extensions.
|
|
1181
|
+
*/
|
|
1182
|
+
_isActivatable(name) {
|
|
1183
|
+
if (!this._allowedTools || this._allowedTools(name) || !isMcpToolName(name))
|
|
1184
|
+
return true;
|
|
1185
|
+
return this._getToolExposure(name) !== "direct" && this._toolRegistry.has("tool_search");
|
|
1186
|
+
}
|
|
1107
1187
|
_getToolExposure(name) {
|
|
1108
1188
|
return this._toolDefinitions.get(name)?.definition.exposure ?? "direct";
|
|
1109
1189
|
}
|
|
@@ -1126,7 +1206,7 @@ export class AgentSession {
|
|
|
1126
1206
|
_applyToolLoadout(toolNames) {
|
|
1127
1207
|
const tools = [...new Set(toolNames)].flatMap((name) => {
|
|
1128
1208
|
const tool = this._toolRegistry.get(name);
|
|
1129
|
-
return tool && this._getToolExposure(name) !== "hidden" ? [tool] : [];
|
|
1209
|
+
return tool && this._getToolExposure(name) !== "hidden" && this._isActivatable(name) ? [tool] : [];
|
|
1130
1210
|
});
|
|
1131
1211
|
const hooks = tools.flatMap((tool) => {
|
|
1132
1212
|
const entry = this._toolDefinitions.get(tool.name);
|
|
@@ -1141,6 +1221,7 @@ export class AgentSession {
|
|
|
1141
1221
|
registered: [...this._toolRegistry.values()],
|
|
1142
1222
|
getExposure: (name) => this._getToolExposure(name),
|
|
1143
1223
|
getNamespace: (name) => this._toolDefinitions.get(name)?.definition.namespace,
|
|
1224
|
+
getPromptGuidelines: (name) => this._toolPromptGuidelines.get(name) ?? [],
|
|
1144
1225
|
};
|
|
1145
1226
|
const descriptions = new Map();
|
|
1146
1227
|
for (const { definition, sourceInfo } of hooks) {
|
|
@@ -1239,8 +1320,8 @@ export class AgentSession {
|
|
|
1239
1320
|
const toolSnippets = {};
|
|
1240
1321
|
for (const name of this._toolRegistry.keys()) {
|
|
1241
1322
|
const snippet = this._toolPromptSnippets.get(name);
|
|
1242
|
-
// Tools without a snippet are not listed.
|
|
1243
|
-
if (snippet
|
|
1323
|
+
// Tools without a snippet are not listed.
|
|
1324
|
+
if (snippet)
|
|
1244
1325
|
toolSnippets[name] = snippet;
|
|
1245
1326
|
}
|
|
1246
1327
|
const loaderSystemPrompt = this._resourceLoader.getSystemPrompt();
|
|
@@ -1255,6 +1336,7 @@ export class AgentSession {
|
|
|
1255
1336
|
customPrompt: loaderSystemPrompt,
|
|
1256
1337
|
appendSystemPrompt,
|
|
1257
1338
|
selectedTools: validToolNames,
|
|
1339
|
+
hiddenTools: [...this._hiddenDeclarations],
|
|
1258
1340
|
toolSnippets,
|
|
1259
1341
|
toolGuidelines: Object.fromEntries(this._toolPromptGuidelines),
|
|
1260
1342
|
});
|
|
@@ -1271,8 +1353,8 @@ export class AgentSession {
|
|
|
1271
1353
|
*/
|
|
1272
1354
|
_preparePromptAndToolLoadout(options, messages = this.agent.state.messages) {
|
|
1273
1355
|
options.selectedTools = this._applyToolLoadout(options.selectedTools).map((tool) => tool.name);
|
|
1274
|
-
// The tool list must match the declarations the request carries
|
|
1275
|
-
options.
|
|
1356
|
+
// The tool list and rules must match the declarations the request carries.
|
|
1357
|
+
options.hiddenTools = [...this._hiddenDeclarations];
|
|
1276
1358
|
const sections = diffSystemPromptSections(getCurrentSystemMessage(messages)?.sections ?? {}, buildSystemPromptSections(options));
|
|
1277
1359
|
return sections ? { role: "system", content: "", sections, timestamp: Date.now() } : undefined;
|
|
1278
1360
|
}
|
|
@@ -1333,22 +1415,67 @@ export class AgentSession {
|
|
|
1333
1415
|
* Restore the active tool loadout declared by the session transcript, if it declares one.
|
|
1334
1416
|
* Tools reachable only from other tools are never declared, but they do not depend on the active
|
|
1335
1417
|
* set, so the transcript's declarations are the whole loadout.
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1418
|
+
* @param modifiers `+name`/`-name` entries applied to the restored loadout.
|
|
1419
|
+
*/
|
|
1420
|
+
_restoreToolsFromTranscript(modifiers = []) {
|
|
1421
|
+
this._pendingToolNames.clear();
|
|
1422
|
+
// All system messages on the branch, including those before a compaction. Compaction snapshots
|
|
1423
|
+
// are derived from these, so replaying them gives the current loadout.
|
|
1424
|
+
const systemMessages = this.sessionManager
|
|
1425
|
+
.getBranch()
|
|
1426
|
+
.flatMap((entry) => (entry.type === "message" && entry.message.role === "system" ? [entry.message] : []));
|
|
1427
|
+
// No recorded loadout: keep the current tools.
|
|
1428
|
+
if (systemMessages.length === 0)
|
|
1340
1429
|
return;
|
|
1341
|
-
|
|
1430
|
+
// Tools the branch ever added or removed. Removed tools stay inactive.
|
|
1431
|
+
const mentioned = new Set(systemMessages
|
|
1432
|
+
.flatMap((message) => [...(message.toolsAdded ?? []), ...(message.toolsRemoved ?? [])])
|
|
1433
|
+
.map((tool) => tool.name));
|
|
1434
|
+
// Extension tools the branch never mentioned were registered after it recorded its loadout, so
|
|
1435
|
+
// they are activated like newly registered tools. Built-in tools follow `defaultTools` instead.
|
|
1436
|
+
const newTools = [...this._toolRegistry.keys()].filter((name) => !mentioned.has(name) && !this._baseToolDefinitions.has(name) && this._isActivatedOnRegistration(name));
|
|
1437
|
+
// The recorded loadout plus the new tools, with `--tools +name`/`-name` applied.
|
|
1438
|
+
const names = applyToolModifiers([...getCurrentTools(systemMessages).map((tool) => tool.name), ...newTools], modifiers);
|
|
1439
|
+
// Recorded tools that are not registered yet, such as MCP tools of servers still connecting, are
|
|
1440
|
+
// activated when they register. Excluded tools never register, so they are not kept pending.
|
|
1441
|
+
this._pendingToolNames = new Set(names.filter((name) => this._isAllowedTool(name)));
|
|
1442
|
+
// Ignores names that are not registered.
|
|
1443
|
+
this._setActiveTools(names);
|
|
1342
1444
|
}
|
|
1343
1445
|
// =========================================================================
|
|
1344
1446
|
// Prompting
|
|
1345
1447
|
// =========================================================================
|
|
1346
|
-
|
|
1448
|
+
/**
|
|
1449
|
+
* Start a run from a user or custom message. The session counts as busy from here on, so
|
|
1450
|
+
* messages sent while before_agent_start handlers run are queued into this run instead of
|
|
1451
|
+
* starting another, and an abort requested meanwhile aborts the run as soon as it exists.
|
|
1452
|
+
* @param onStarted Called once the run's messages are prepared, before the first request.
|
|
1453
|
+
*/
|
|
1454
|
+
async _startRun(trigger, onStarted) {
|
|
1455
|
+
this._isAgentRunActive = true;
|
|
1347
1456
|
this._agentRunAbortRequested = false;
|
|
1457
|
+
let messages;
|
|
1458
|
+
try {
|
|
1459
|
+
messages = await this._prepareRun(trigger);
|
|
1460
|
+
}
|
|
1461
|
+
catch (error) {
|
|
1462
|
+
this._isAgentRunActive = false;
|
|
1463
|
+
this._flushPendingBashMessages();
|
|
1464
|
+
this._flushPendingCustomMessages();
|
|
1465
|
+
this._resolveIdleWaitIfIdle();
|
|
1466
|
+
throw error;
|
|
1467
|
+
}
|
|
1468
|
+
// Messages held while the run was starting go before its starting messages, as they would
|
|
1469
|
+
// have while idle. No run exists yet, so they cannot split a tool call from its result.
|
|
1470
|
+
this._flushPendingBashMessages();
|
|
1471
|
+
this._flushPendingCustomMessages();
|
|
1472
|
+
onStarted?.();
|
|
1348
1473
|
// Compaction before the prompt may have scheduled a retry; the new prompt replaces it.
|
|
1349
1474
|
this._failedResponse = undefined;
|
|
1350
1475
|
this._recordSelection();
|
|
1351
|
-
|
|
1476
|
+
// The run records the loadout in the transcript; restored tools that did not register by now
|
|
1477
|
+
// are dropped, so a tool that never registers does not stay pending.
|
|
1478
|
+
this._pendingToolNames.clear();
|
|
1352
1479
|
try {
|
|
1353
1480
|
await this.agent.prompt(messages);
|
|
1354
1481
|
while (!this._agentRunAbortRequested) {
|
|
@@ -1375,11 +1502,66 @@ export class AgentSession {
|
|
|
1375
1502
|
await this._emitAgentSettled();
|
|
1376
1503
|
}
|
|
1377
1504
|
}
|
|
1505
|
+
/**
|
|
1506
|
+
* Prepare a run and return its starting messages: compact first when needed, emit
|
|
1507
|
+
* before_agent_start, apply the run's prompt options and tool loadout, and build the starting
|
|
1508
|
+
* message followed by pending nextTurn messages (consumed here) and handler messages, with a
|
|
1509
|
+
* system patch first when the prompt changed.
|
|
1510
|
+
*/
|
|
1511
|
+
async _prepareRun(trigger) {
|
|
1512
|
+
// Check if we need to compact before sending (catches aborted responses).
|
|
1513
|
+
// The starting message is sent below, so do not call agent.continue() here.
|
|
1514
|
+
const lastAssistant = this._findLastAssistantMessage();
|
|
1515
|
+
if (lastAssistant) {
|
|
1516
|
+
await this._checkCompaction(lastAssistant, false);
|
|
1517
|
+
}
|
|
1518
|
+
const selectedToolsBefore = this._baseSystemPromptOptions.selectedTools;
|
|
1519
|
+
const result = await this._extensionRunner.emitBeforeAgentStart(trigger, this._baseSystemPromptOptions);
|
|
1520
|
+
// Handlers may edit event.systemPromptOptions.selectedTools or call setActiveTools(),
|
|
1521
|
+
// which updates the live loadout instead. An explicit edit wins; otherwise the live
|
|
1522
|
+
// loadout is authoritative, so a setActiveTools() call is not undone here.
|
|
1523
|
+
const handlerEditedTools = result.systemPromptOptions.selectedTools.length !== selectedToolsBefore.length ||
|
|
1524
|
+
result.systemPromptOptions.selectedTools.some((name, index) => name !== selectedToolsBefore[index]);
|
|
1525
|
+
if (!handlerEditedTools)
|
|
1526
|
+
result.systemPromptOptions.selectedTools = this.getActiveToolNames();
|
|
1527
|
+
const messages = [];
|
|
1528
|
+
if (trigger.messageType === "custom") {
|
|
1529
|
+
messages.push(trigger.message);
|
|
1530
|
+
}
|
|
1531
|
+
else {
|
|
1532
|
+
// Normalize images after before_agent_start so extension-driven model selection
|
|
1533
|
+
// determines the resize profile used for the request and history.
|
|
1534
|
+
const normalized = await this._normalizePromptImages(trigger.images);
|
|
1535
|
+
const text = normalized.hints.length > 0 ? `${trigger.prompt}\n\n${normalized.hints.join("\n")}` : trigger.prompt;
|
|
1536
|
+
messages.push({
|
|
1537
|
+
role: "user",
|
|
1538
|
+
content: [{ type: "text", text }, ...normalized.images],
|
|
1539
|
+
timestamp: Date.now(),
|
|
1540
|
+
});
|
|
1541
|
+
}
|
|
1542
|
+
// Inject any pending "nextTurn" messages as context alongside the starting message
|
|
1543
|
+
messages.push(...this._pendingNextTurnMessages);
|
|
1544
|
+
this._pendingNextTurnMessages = [];
|
|
1545
|
+
for (const msg of result.messages) {
|
|
1546
|
+
messages.push({
|
|
1547
|
+
role: "custom",
|
|
1548
|
+
customType: msg.customType,
|
|
1549
|
+
// Untyped extensions can pass null/missing content; normalize at ingestion.
|
|
1550
|
+
content: msg.content ?? [],
|
|
1551
|
+
display: msg.display,
|
|
1552
|
+
details: msg.details,
|
|
1553
|
+
timestamp: Date.now(),
|
|
1554
|
+
});
|
|
1555
|
+
}
|
|
1556
|
+
const updateMessage = this._preparePromptAndToolLoadout(result.systemPromptOptions);
|
|
1557
|
+
this._runSystemPromptOptions = result.systemPromptOptions;
|
|
1558
|
+
if (updateMessage)
|
|
1559
|
+
messages.unshift(updateMessage);
|
|
1560
|
+
return messages;
|
|
1561
|
+
}
|
|
1378
1562
|
async _handlePostAgentRun() {
|
|
1379
1563
|
const message = this._lastAssistantMessage;
|
|
1380
|
-
const toolResults = this._lastAssistantToolResults;
|
|
1381
1564
|
this._lastAssistantMessage = undefined;
|
|
1382
|
-
this._lastAssistantToolResults = [];
|
|
1383
1565
|
if (this._agentRunAbortRequested) {
|
|
1384
1566
|
this._finishCancelledRetry();
|
|
1385
1567
|
return false;
|
|
@@ -1405,7 +1587,7 @@ export class AgentSession {
|
|
|
1405
1587
|
});
|
|
1406
1588
|
this._retryAttempt = 0;
|
|
1407
1589
|
}
|
|
1408
|
-
if (await this._checkCompaction(message
|
|
1590
|
+
if (await this._checkCompaction(message)) {
|
|
1409
1591
|
return !this._agentRunAbortRequested;
|
|
1410
1592
|
}
|
|
1411
1593
|
// The low-level loop drains both queues before agent_end. Messages queued by
|
|
@@ -1417,6 +1599,7 @@ export class AgentSession {
|
|
|
1417
1599
|
return this.agent.hasQueuedMessages();
|
|
1418
1600
|
this._isBeforeSettle = true;
|
|
1419
1601
|
this._abortDuringBeforeSettle = false;
|
|
1602
|
+
this._beforeSettleAbortController = new AbortController();
|
|
1420
1603
|
try {
|
|
1421
1604
|
const result = await this._extensionRunner.emitBoundary({ type: "agent_before_settle", outcome: this._lastActivityOutcome }, (entries) => this._buildBoundaryContext(entries, "agent_before_settle"));
|
|
1422
1605
|
this._commitBoundaryDrafts(result.entries);
|
|
@@ -1434,6 +1617,7 @@ export class AgentSession {
|
|
|
1434
1617
|
}
|
|
1435
1618
|
finally {
|
|
1436
1619
|
this._isBeforeSettle = false;
|
|
1620
|
+
this._beforeSettleAbortController = undefined;
|
|
1437
1621
|
}
|
|
1438
1622
|
}
|
|
1439
1623
|
async _runInputHandlers(text, images, source, streamingBehavior) {
|
|
@@ -1524,9 +1708,6 @@ export class AgentSession {
|
|
|
1524
1708
|
preflightResult?.("queued");
|
|
1525
1709
|
return;
|
|
1526
1710
|
}
|
|
1527
|
-
// Flush any pending bash and custom messages before the new prompt
|
|
1528
|
-
this._flushPendingBashMessages();
|
|
1529
|
-
this._flushPendingCustomMessages();
|
|
1530
1711
|
// Validate model
|
|
1531
1712
|
if (!this.model) {
|
|
1532
1713
|
throw new Error(formatNoModelSelectedMessage());
|
|
@@ -1542,56 +1723,7 @@ export class AgentSession {
|
|
|
1542
1723
|
}
|
|
1543
1724
|
throw new Error(formatNoApiKeyFoundMessage(this.model.provider));
|
|
1544
1725
|
}
|
|
1545
|
-
|
|
1546
|
-
// The user's new prompt is sent below, so do not call agent.continue() here.
|
|
1547
|
-
const lastAssistant = this._findLastAssistantMessage();
|
|
1548
|
-
if (lastAssistant) {
|
|
1549
|
-
await this._checkCompaction(lastAssistant, false);
|
|
1550
|
-
}
|
|
1551
|
-
// Emit before_agent_start before normalizing images so extension-driven model
|
|
1552
|
-
// selection determines the resize profile used for the request and history.
|
|
1553
|
-
const selectedToolsBefore = this._baseSystemPromptOptions.selectedTools;
|
|
1554
|
-
const result = await this._extensionRunner.emitBeforeAgentStart(expandedText, currentImages, this._baseSystemPromptOptions);
|
|
1555
|
-
// Handlers may edit event.systemPromptOptions.selectedTools or call setActiveTools(),
|
|
1556
|
-
// which updates the live loadout instead. An explicit edit wins; otherwise the live
|
|
1557
|
-
// loadout is authoritative, so a setActiveTools() call is not undone here.
|
|
1558
|
-
const handlerEditedTools = result.systemPromptOptions.selectedTools.length !== selectedToolsBefore.length ||
|
|
1559
|
-
result.systemPromptOptions.selectedTools.some((name, index) => name !== selectedToolsBefore[index]);
|
|
1560
|
-
if (!handlerEditedTools)
|
|
1561
|
-
result.systemPromptOptions.selectedTools = this.getActiveToolNames();
|
|
1562
|
-
const normalized = await this._normalizePromptImages(currentImages);
|
|
1563
|
-
const userText = normalized.hints.length > 0 ? `${expandedText}\n\n${normalized.hints.join("\n")}` : expandedText;
|
|
1564
|
-
// Build messages only after hooks and image normalization have completed.
|
|
1565
|
-
const messages = [];
|
|
1566
|
-
const userContent = [{ type: "text", text: userText }];
|
|
1567
|
-
userContent.push(...normalized.images);
|
|
1568
|
-
messages.push({
|
|
1569
|
-
role: "user",
|
|
1570
|
-
content: userContent,
|
|
1571
|
-
timestamp: Date.now(),
|
|
1572
|
-
});
|
|
1573
|
-
// Inject any pending "nextTurn" messages as context alongside the user message
|
|
1574
|
-
for (const msg of this._pendingNextTurnMessages) {
|
|
1575
|
-
messages.push(msg);
|
|
1576
|
-
}
|
|
1577
|
-
this._pendingNextTurnMessages = [];
|
|
1578
|
-
for (const msg of result.messages) {
|
|
1579
|
-
messages.push({
|
|
1580
|
-
role: "custom",
|
|
1581
|
-
customType: msg.customType,
|
|
1582
|
-
// Untyped extensions can pass null/missing content; normalize at ingestion.
|
|
1583
|
-
content: msg.content ?? [],
|
|
1584
|
-
display: msg.display,
|
|
1585
|
-
details: msg.details,
|
|
1586
|
-
timestamp: Date.now(),
|
|
1587
|
-
});
|
|
1588
|
-
}
|
|
1589
|
-
const updateMessage = this._preparePromptAndToolLoadout(result.systemPromptOptions);
|
|
1590
|
-
this._runSystemPromptOptions = result.systemPromptOptions;
|
|
1591
|
-
if (updateMessage)
|
|
1592
|
-
messages.unshift(updateMessage);
|
|
1593
|
-
preflightResult?.("started");
|
|
1594
|
-
await this._runAgentPrompt(messages);
|
|
1726
|
+
await this._startRun({ messageType: "user", prompt: expandedText, images: currentImages }, () => preflightResult?.("started"));
|
|
1595
1727
|
}
|
|
1596
1728
|
/**
|
|
1597
1729
|
* Try to execute an extension command. Returns true if command was found and executed.
|
|
@@ -1765,10 +1897,10 @@ export class AgentSession {
|
|
|
1765
1897
|
}
|
|
1766
1898
|
else if (options?.triggerTurn) {
|
|
1767
1899
|
if (this._isEmittingAgentSettled) {
|
|
1768
|
-
this._deferredSettledActions.push(async () => await this.
|
|
1900
|
+
this._deferredSettledActions.push(async () => await this.sendCustomMessage(message, options));
|
|
1769
1901
|
return;
|
|
1770
1902
|
}
|
|
1771
|
-
await this.
|
|
1903
|
+
await this._startRun({ messageType: "custom", message: appMessage });
|
|
1772
1904
|
}
|
|
1773
1905
|
else if (this.isStreaming) {
|
|
1774
1906
|
// Appending now would put the message between an assistant tool call and its
|
|
@@ -1878,6 +2010,7 @@ export class AgentSession {
|
|
|
1878
2010
|
this.abortBranchSummary();
|
|
1879
2011
|
if (this._isBeforeSettle)
|
|
1880
2012
|
this._abortDuringBeforeSettle = true;
|
|
2013
|
+
this._beforeSettleAbortController?.abort();
|
|
1881
2014
|
this.agent.abort();
|
|
1882
2015
|
await this.waitForIdle();
|
|
1883
2016
|
}
|
|
@@ -2333,7 +2466,7 @@ export class AgentSession {
|
|
|
2333
2466
|
* @param skipAbortedCheck If false, include aborted messages (for pre-prompt check). Default: true
|
|
2334
2467
|
* @returns Whether the post-run loop should call `agent.continue()` for overflow recovery or queued messages
|
|
2335
2468
|
*/
|
|
2336
|
-
async _checkCompaction(assistantMessage, skipAbortedCheck = true
|
|
2469
|
+
async _checkCompaction(assistantMessage, skipAbortedCheck = true) {
|
|
2337
2470
|
const settings = this.settingsManager.getCompactionSettings(this.model);
|
|
2338
2471
|
if (!settings.enabled)
|
|
2339
2472
|
return false;
|
|
@@ -2410,7 +2543,7 @@ export class AgentSession {
|
|
|
2410
2543
|
}
|
|
2411
2544
|
// Persistently omit the selected final attempt before post-run recovery compaction.
|
|
2412
2545
|
this._overflowRecoveryAttempted = true;
|
|
2413
|
-
this._omitRecoveryAttempt(assistantMessage
|
|
2546
|
+
this._omitRecoveryAttempt(assistantMessage);
|
|
2414
2547
|
const retry = await this._runAutoCompaction("overflow", willRetry);
|
|
2415
2548
|
if (retry)
|
|
2416
2549
|
this._failedResponse = assistantMessage;
|
|
@@ -2796,7 +2929,7 @@ export class AgentSession {
|
|
|
2796
2929
|
getScopedModels: () => this._scopedModels,
|
|
2797
2930
|
isIdle: () => this.isIdle,
|
|
2798
2931
|
isProjectTrusted: () => this.settingsManager.isProjectTrusted(),
|
|
2799
|
-
getSignal: () => this.agent.signal,
|
|
2932
|
+
getSignal: () => this._beforeSettleAbortController?.signal ?? this.agent.signal,
|
|
2800
2933
|
abort: () => {
|
|
2801
2934
|
if (this._extensionAbortHandler) {
|
|
2802
2935
|
this._extensionAbortHandler();
|
|
@@ -2853,9 +2986,7 @@ export class AgentSession {
|
|
|
2853
2986
|
// `direct` or `model-only` (for example from `hidden`) is activated like a new tool.
|
|
2854
2987
|
const previousActivatedOnRegistration = new Set([...this._toolRegistry.keys()].filter((name) => this._isActivatedOnRegistration(name)));
|
|
2855
2988
|
const previousActiveToolNames = this.getActiveToolNames();
|
|
2856
|
-
const
|
|
2857
|
-
const excludedToolNames = this._excludedToolNames;
|
|
2858
|
-
const isAllowedTool = (name) => (!allowedToolNames || allowedToolNames.has(name)) && !excludedToolNames?.has(name);
|
|
2989
|
+
const allowedTools = this._allowedTools;
|
|
2859
2990
|
const registeredTools = this._extensionRunner.getAllRegisteredTools();
|
|
2860
2991
|
const allCustomTools = [
|
|
2861
2992
|
...registeredTools,
|
|
@@ -2863,9 +2994,9 @@ export class AgentSession {
|
|
|
2863
2994
|
definition,
|
|
2864
2995
|
sourceInfo: createSyntheticSourceInfo(`<sdk:${definition.name}>`, { source: "sdk" }),
|
|
2865
2996
|
})),
|
|
2866
|
-
].filter((tool) =>
|
|
2997
|
+
].filter((tool) => this._isAllowedTool(tool.definition.name));
|
|
2867
2998
|
const definitionRegistry = new Map(Array.from(this._baseToolDefinitions.entries())
|
|
2868
|
-
.filter(([name]) =>
|
|
2999
|
+
.filter(([name]) => this._isAllowedTool(name))
|
|
2869
3000
|
.map(([name, definition]) => [
|
|
2870
3001
|
name,
|
|
2871
3002
|
{
|
|
@@ -2895,7 +3026,7 @@ export class AgentSession {
|
|
|
2895
3026
|
const runner = this._extensionRunner;
|
|
2896
3027
|
const wrappedExtensionTools = wrapRegisteredTools(allCustomTools, runner);
|
|
2897
3028
|
const wrappedBuiltInTools = wrapRegisteredTools(Array.from(this._baseToolDefinitions.values())
|
|
2898
|
-
.filter((definition) =>
|
|
3029
|
+
.filter((definition) => this._isAllowedTool(definition.name))
|
|
2899
3030
|
.map((definition) => ({
|
|
2900
3031
|
definition,
|
|
2901
3032
|
sourceInfo: createSyntheticSourceInfo(`${BUILTIN_PATH_PREFIX}${definition.name}`, {
|
|
@@ -2907,11 +3038,12 @@ export class AgentSession {
|
|
|
2907
3038
|
toolRegistry.set(tool.name, tool);
|
|
2908
3039
|
}
|
|
2909
3040
|
this._toolRegistry = toolRegistry;
|
|
2910
|
-
const nextActiveToolNames = (options?.activeToolNames ? [...options.activeToolNames] : [...previousActiveToolNames]).filter((name) =>
|
|
2911
|
-
if (
|
|
3041
|
+
const nextActiveToolNames = (options?.activeToolNames ? [...options.activeToolNames] : [...previousActiveToolNames]).filter((name) => this._isAllowedTool(name));
|
|
3042
|
+
if (allowedTools) {
|
|
2912
3043
|
for (const toolName of this._toolRegistry.keys()) {
|
|
2913
|
-
// Naming a tool activates it even when it is not active by default.
|
|
2914
|
-
|
|
3044
|
+
// Naming or matching a tool activates it even when it is not active by default. MCP tools
|
|
3045
|
+
// kept registered without being named stay inactive.
|
|
3046
|
+
if (allowedTools(toolName) && this._isDeclarable(toolName)) {
|
|
2915
3047
|
nextActiveToolNames.push(toolName);
|
|
2916
3048
|
}
|
|
2917
3049
|
}
|
|
@@ -2929,7 +3061,9 @@ export class AgentSession {
|
|
|
2929
3061
|
}
|
|
2930
3062
|
}
|
|
2931
3063
|
}
|
|
2932
|
-
|
|
3064
|
+
// Pending tools that are registered now become active.
|
|
3065
|
+
nextActiveToolNames.push(...this._pendingToolNames);
|
|
3066
|
+
this._setActiveTools([...new Set(nextActiveToolNames)]);
|
|
2933
3067
|
}
|
|
2934
3068
|
/** Whether activating the tool declares it to the model. */
|
|
2935
3069
|
_isDeclarable(name) {
|
|
@@ -2980,16 +3114,20 @@ export class AgentSession {
|
|
|
2980
3114
|
const previousFlagValues = oldRunner.getFlagValues();
|
|
2981
3115
|
await emitSessionShutdownEvent(oldRunner, { type: "session_shutdown", reason: "reload" });
|
|
2982
3116
|
oldRunner.invalidate();
|
|
2983
|
-
const
|
|
3117
|
+
const getDefaultTools = () => this._usesDefaultTools
|
|
3118
|
+
? applyToolModifiers(this.settingsManager.getDefaultTools() ?? DEFAULT_TOOL_NAMES, this._defaultToolModifiers)
|
|
3119
|
+
: [];
|
|
3120
|
+
const previousDefaultTools = new Set(getDefaultTools());
|
|
2984
3121
|
await this.settingsManager.reload();
|
|
2985
3122
|
this.syncQueueModesFromSettings();
|
|
2986
3123
|
resetApiProviders();
|
|
2987
3124
|
await this._resourceLoader.reload();
|
|
2988
3125
|
// Activate tools newly added to defaultTools. Removed ones stay active, and tools disabled
|
|
2989
3126
|
// during the session stay disabled unless the setting newly adds them.
|
|
2990
|
-
const addedDefaultTools =
|
|
2991
|
-
|
|
2992
|
-
|
|
3127
|
+
const addedDefaultTools = getDefaultTools().filter((name) => !previousDefaultTools.has(name));
|
|
3128
|
+
// Tools the new extensions register later, such as MCP tools, are pending until then.
|
|
3129
|
+
for (const name of this.getActiveToolNames())
|
|
3130
|
+
this._pendingToolNames.add(name);
|
|
2993
3131
|
this._buildRuntime({
|
|
2994
3132
|
activeToolNames: [...this.getActiveToolNames(), ...addedDefaultTools],
|
|
2995
3133
|
flagValues: previousFlagValues,
|
|
@@ -3518,7 +3656,7 @@ export class AgentSession {
|
|
|
3518
3656
|
const themeName = [options.themeName, this.settingsManager.getTheme()].find((candidate) => candidate !== undefined && getThemeByName(candidate) !== undefined);
|
|
3519
3657
|
// Create tool renderer if we have an extension runner (for custom tool HTML rendering)
|
|
3520
3658
|
const toolRenderer = createToolHtmlRenderer({
|
|
3521
|
-
|
|
3659
|
+
getToolRenderers: (name) => this._extensionRunner.resolveToolRenderers(name, () => this.getToolDefinition(name)),
|
|
3522
3660
|
theme,
|
|
3523
3661
|
cwd: this.sessionManager.getCwd(),
|
|
3524
3662
|
});
|