@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
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { isDeepStrictEqual } from "node:util";
|
|
2
|
+
import { isAbsolute, relative, resolve } from "node:path";
|
|
3
|
+
|
|
4
|
+
const object = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
5
|
+
const textOutput = (event) => (event.result?.content ?? []).filter((part) => part.type === "text").map((part) => part.text).join("\n");
|
|
6
|
+
|
|
7
|
+
function terminalStatus(entry, finalText, requiredCheckFailed) {
|
|
8
|
+
const pattern = entry.outputContract === "triage"
|
|
9
|
+
? /^\[triage:(bug|performance|other)\]\s*$/gm
|
|
10
|
+
: /^STATUS:\s*(DONE_WITH_CONCERNS|DONE|NEEDS_CONTEXT|BLOCKED)\s*$/gm;
|
|
11
|
+
const matches = [...finalText.matchAll(pattern)];
|
|
12
|
+
const opposing = entry.outputContract === "triage" ? /^STATUS:/m.test(finalText) : /^\[triage:/m.test(finalText);
|
|
13
|
+
const markerCount = finalText.split(/\r?\n/).filter((line) => entry.outputContract === "triage" ? line.startsWith("[triage:") : line.startsWith("STATUS:")).length;
|
|
14
|
+
const valid = !opposing && markerCount === 1 && matches.length === 1 && finalText.trimEnd().endsWith(matches[0][0].trimEnd());
|
|
15
|
+
const status = valid ? (entry.outputContract === "triage" ? `triage:${matches[0][1]}` : matches[0][1]) : null;
|
|
16
|
+
const expected = requiredCheckFailed && entry.outputContract !== "triage" ? ["BLOCKED"] : entry.expectedStatuses;
|
|
17
|
+
return { status, statusSyntaxPassed: valid, statusSemanticPassed: expected.includes(status) };
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function structuredResponse(entry, finalText) {
|
|
21
|
+
if (!entry.responseContract) return { responseFormatPassed: true, findingsPassed: null, reasons: [] };
|
|
22
|
+
const lines = finalText.split(/\r?\n/).filter((line) => line.startsWith("RESULT:"));
|
|
23
|
+
let response;
|
|
24
|
+
try { if (lines.length === 1) response = JSON.parse(lines[0].slice(7).trim()); } catch {}
|
|
25
|
+
const valid = object(response) && typeof response.verdict === "string" && object(response.facts) &&
|
|
26
|
+
Array.isArray(response.findings) && response.findings.every((finding) => object(finding) &&
|
|
27
|
+
typeof finding.file === "string" && Number.isSafeInteger(finding.line) && finding.line > 0);
|
|
28
|
+
if (!valid) return { responseFormatPassed: false, findingsPassed: false, reasons: ["Missing or malformed RESULT record"] };
|
|
29
|
+
const expected = entry.responseContract;
|
|
30
|
+
// A nearby valid source citation is not a semantic failure. The exact faulty
|
|
31
|
+
// expression and explanation remain part of blinded review.
|
|
32
|
+
const locationsValid = response.findings.every(({ file, line }) => typeof entry.files[file] === "string" &&
|
|
33
|
+
Boolean(entry.files[file].split(/\r?\n/)[line - 1]?.trim()));
|
|
34
|
+
const actualFiles = response.findings.map(({ file }) => file).sort();
|
|
35
|
+
const expectedFiles = expected.findings.map(({ file }) => file).sort();
|
|
36
|
+
const factsMatch = Object.keys(response.facts).length === Object.keys(expected.facts).length &&
|
|
37
|
+
Object.entries(expected.facts).every(([key, value]) => isDeepStrictEqual(response.facts[key], value));
|
|
38
|
+
const passed = response.verdict === expected.verdict && factsMatch && locationsValid && isDeepStrictEqual(actualFiles, expectedFiles);
|
|
39
|
+
return { responseFormatPassed: true, findingsPassed: passed,
|
|
40
|
+
reasons: passed ? [] : ["Structured verdict, source locations, or observable facts differ from the fixture oracle"] };
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function outputMatches(requirement, output) {
|
|
44
|
+
if (requirement.outputLine !== undefined && !output.split(/\r?\n/).includes(requirement.outputLine)) return false;
|
|
45
|
+
if (requirement.outputJson !== undefined) {
|
|
46
|
+
return output.split(/\r?\n/).some((line) => {
|
|
47
|
+
try { return isDeepStrictEqual(JSON.parse(line), requirement.outputJson); } catch { return false; }
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function literalShell(command) {
|
|
54
|
+
// Parse only literal words and sequence separators. Never expand input or
|
|
55
|
+
// execute a shell to decide whether it counts as verification.
|
|
56
|
+
if (/[\u0000-\u0008\u000B-\u001F\u007F]/.test(command)) return null;
|
|
57
|
+
const tokens = [];
|
|
58
|
+
let word = "", active = false, quote = null;
|
|
59
|
+
const flush = () => { if (active) tokens.push({ word }); word = ""; active = false; };
|
|
60
|
+
for (let index = 0; index < command.length; index++) {
|
|
61
|
+
const char = command[index], next = command[index + 1];
|
|
62
|
+
if (quote === "'") {
|
|
63
|
+
if (char === "'") quote = null; else word += char;
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
if (quote === '"') {
|
|
67
|
+
if (char === '"') quote = null;
|
|
68
|
+
else if (char === "$" || char === "`") return null;
|
|
69
|
+
else if (char === "\\" && next !== undefined && '"\\$`\n'.includes(next)) {
|
|
70
|
+
if (next !== "\n") word += next;
|
|
71
|
+
index++;
|
|
72
|
+
} else word += char;
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
if (char === "\\") {
|
|
76
|
+
if (next === undefined) return null;
|
|
77
|
+
if (next !== "\n") { word += next; active = true; }
|
|
78
|
+
index++;
|
|
79
|
+
} else if (char === "'" || char === '"') {
|
|
80
|
+
quote = char; active = true;
|
|
81
|
+
} else if (char === " " || char === "\t") flush();
|
|
82
|
+
else if (char === ";" || char === "\n" || (char === "&" && next === "&")) {
|
|
83
|
+
flush();
|
|
84
|
+
tokens.push(char === "&" ? "&&" : char);
|
|
85
|
+
if (char === "&") index++;
|
|
86
|
+
} else if (/[|&<>()$`*?[\]{}~#]/.test(char)) return null;
|
|
87
|
+
else { word += char; active = true; }
|
|
88
|
+
}
|
|
89
|
+
if (quote !== null) return null;
|
|
90
|
+
flush();
|
|
91
|
+
const commands = [[]], separators = [];
|
|
92
|
+
for (const token of tokens) {
|
|
93
|
+
if (typeof token === "object") commands.at(-1).push(token.word);
|
|
94
|
+
else {
|
|
95
|
+
if (!commands.at(-1).length) return null;
|
|
96
|
+
separators.push(token);
|
|
97
|
+
commands.push([]);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return commands.at(-1).length ? { commands, separators } : null;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function literalPath(path, workspace) {
|
|
104
|
+
// Resolving "link/.." lexically could identify a different file than the
|
|
105
|
+
// shell. Such paths need filesystem evidence, not string normalization.
|
|
106
|
+
if (!path || path.split("/").includes("..")) return null;
|
|
107
|
+
return resolve(workspace, path);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function matchingRequirements(shell, requirements, workspace) {
|
|
111
|
+
if (!shell) return [];
|
|
112
|
+
let argv = shell.commands[0];
|
|
113
|
+
if (shell.commands.length === 2) {
|
|
114
|
+
const cd = argv[0] === "cd" && (argv.length === 2 ? argv[1] : argv.length === 3 && argv[1] === "--" ? argv[2] : null);
|
|
115
|
+
if (!cd || shell.separators[0] !== "&&" || literalPath(cd, workspace) !== resolve(workspace)) return [];
|
|
116
|
+
argv = shell.commands[1];
|
|
117
|
+
} else if (shell.commands.length !== 1) return [];
|
|
118
|
+
return requirements.filter((requirement) => {
|
|
119
|
+
const expected = literalShell(requirement.command);
|
|
120
|
+
if (!expected || expected.commands.length !== 1) return false;
|
|
121
|
+
const words = expected.commands[0];
|
|
122
|
+
if (argv.length !== words.length || argv[0] !== words[0]) return false;
|
|
123
|
+
if (words[0] === "node" && words.length === 2 && !words[1].startsWith("-")) {
|
|
124
|
+
return !argv[1].startsWith("-") && literalPath(argv[1], workspace) === literalPath(words[1], workspace);
|
|
125
|
+
}
|
|
126
|
+
return words.every((word, index) => word === argv[index]);
|
|
127
|
+
}).map((requirement) => requirement.id);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function knownReadOnlyShell(shell) {
|
|
131
|
+
// These programs have no execution/write options. Literal-only sequences
|
|
132
|
+
// can be classified without inferring the exit of an intermediate command.
|
|
133
|
+
return shell?.commands.every(([program, ...args]) => ["pwd", "ls", "cat", "head", "tail", "wc", "nl"].includes(program) &&
|
|
134
|
+
args.every((arg) => /^[A-Za-z0-9_./:@=+, -]+$/.test(arg))) ?? false;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** Interpret observable native events; never treat reported commands as execution. */
|
|
138
|
+
function executionEvidence(entry, { stdout, format, workspace }) {
|
|
139
|
+
const matched = [], missing = [], denied = [], unverifiable = [], traceScopeViolations = [];
|
|
140
|
+
const requirements = entry.evidenceRequirements;
|
|
141
|
+
if (format !== "draht-jsonl") return { evidencePassed: requirements.length ? null : true,
|
|
142
|
+
evidence: { matched, missing, denied, unverifiable: ["Runner exposes no native tool-execution evidence"] }, traceScopeViolations, requiredCheckFailed: false };
|
|
143
|
+
const starts = new Map(), seen = new Set(), calls = [];
|
|
144
|
+
let lastEdit = -1;
|
|
145
|
+
try {
|
|
146
|
+
for (const [index, line] of stdout.split(/\r?\n/).entries()) {
|
|
147
|
+
if (!line.trim()) continue;
|
|
148
|
+
const event = JSON.parse(line);
|
|
149
|
+
if (!object(event) || typeof event.type !== "string") throw new Error("Malformed event");
|
|
150
|
+
if (event.type === "tool_execution_start") {
|
|
151
|
+
if (typeof event.toolCallId !== "string" || seen.has(event.toolCallId)) throw new Error("Missing or duplicate tool call ID");
|
|
152
|
+
seen.add(event.toolCallId);
|
|
153
|
+
starts.set(event.toolCallId, { ...event, index });
|
|
154
|
+
}
|
|
155
|
+
if (event.type !== "tool_execution_end") continue;
|
|
156
|
+
const start = starts.get(event.toolCallId);
|
|
157
|
+
if (!start || start.toolName !== event.toolName) throw new Error("Tool completion lacks a matching start");
|
|
158
|
+
if (typeof event.isError !== "boolean") throw new Error("Tool completion lacks an outcome");
|
|
159
|
+
starts.delete(event.toolCallId);
|
|
160
|
+
const output = textOutput(event), args = start.args;
|
|
161
|
+
const exitCode = event.result?.structuredContent?.exit_code;
|
|
162
|
+
// An observed process exit is execution evidence even when assertion
|
|
163
|
+
// text happens to contain approval-related wording.
|
|
164
|
+
const isDenied = event.isError === true && (exitCode === undefined || exitCode === null) &&
|
|
165
|
+
/requires approval|no UI available to request approval|denied by.*rule/i.test(output);
|
|
166
|
+
if (isDenied) { denied.push({ toolCallId: event.toolCallId, tool: event.toolName }); continue; }
|
|
167
|
+
const command = typeof args?.command === "string" ? args.command.trim() : null;
|
|
168
|
+
// Native bash receives its cwd from the runner, not from model args.
|
|
169
|
+
// Unexpected directory fields cannot establish another execution cwd.
|
|
170
|
+
const shell = command && !Object.hasOwn(args, "cwd") && !Object.hasOwn(args, "workdir") ? literalShell(command) : null;
|
|
171
|
+
const requirementIds = matchingRequirements(shell, requirements, workspace);
|
|
172
|
+
calls.push({ startIndex: start.index, endIndex: index, toolCallId: event.toolCallId, tool: event.toolName, requirementIds, exitCode, output, isError: event.isError });
|
|
173
|
+
if (["write", "edit"].includes(event.toolName) && event.isError === false) {
|
|
174
|
+
lastEdit = index;
|
|
175
|
+
if (typeof args?.path !== "string") { unverifiable.push(`Write path unavailable: ${event.toolCallId}`); continue; }
|
|
176
|
+
if (/^(?:@|~|file:)|[\u00A0\u2000-\u200A\u202F\u205F\u3000]/.test(args.path)) {
|
|
177
|
+
unverifiable.push(`Native path alias requires normalized trace audit: ${event.toolCallId}`);
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
const path = relative(resolve(workspace), isAbsolute(args.path) ? args.path : resolve(workspace, args.path));
|
|
181
|
+
if (![...entry.writable, ...entry.allowedNewFiles].includes(path)) traceScopeViolations.push(`${event.toolCallId}: wrote ${args.path}`);
|
|
182
|
+
}
|
|
183
|
+
if (["write", "edit"].includes(event.toolName) && event.isError) {
|
|
184
|
+
unverifiable.push(`Failed write may have partial effects: ${event.toolCallId}`);
|
|
185
|
+
}
|
|
186
|
+
if (event.toolName === "bash" && (!requirementIds.length && !knownReadOnlyShell(shell))) {
|
|
187
|
+
unverifiable.push(`Unrecognized shell effects require trace audit: ${event.toolCallId}`);
|
|
188
|
+
}
|
|
189
|
+
if (!["read", "ls", "grep", "find", "bash", "write", "edit"].includes(event.toolName)) {
|
|
190
|
+
unverifiable.push(`Unrecognized tool effects require trace audit: ${event.toolCallId}`);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
if (starts.size) throw new Error("Incomplete tool executions");
|
|
194
|
+
} catch (error) {
|
|
195
|
+
unverifiable.push(`Invalid native trace: ${error.message}`);
|
|
196
|
+
return { evidencePassed: null, evidence: { matched, missing, denied, unverifiable }, traceScopeViolations, requiredCheckFailed: false };
|
|
197
|
+
}
|
|
198
|
+
let requiredCheckFailed = false;
|
|
199
|
+
for (const requirement of requirements) {
|
|
200
|
+
const attempts = calls.filter((candidate) => candidate.tool === "bash" && candidate.requirementIds.includes(requirement.id));
|
|
201
|
+
// Calls are collected in completion order. An earlier passing attempt must
|
|
202
|
+
// not conceal a later failure or an invocation with missing evidence.
|
|
203
|
+
const latest = attempts.at(-1);
|
|
204
|
+
const fresh = latest && (!requirement.afterEdits || latest.startIndex > lastEdit);
|
|
205
|
+
const successful = fresh && latest.exitCode === 0 && latest.isError === false && outputMatches(requirement, latest.output);
|
|
206
|
+
if (attempts.some((attempt) => Number.isInteger(attempt.exitCode) && attempt.exitCode !== 0 &&
|
|
207
|
+
(!successful || latest.startIndex <= attempt.endIndex))) requiredCheckFailed = true;
|
|
208
|
+
if (latest && attempts.some((attempt) => attempt !== latest && attempt.endIndex >= latest.startIndex)) {
|
|
209
|
+
unverifiable.push(`Overlapping required-check attempts require trace audit: ${requirement.id}`);
|
|
210
|
+
}
|
|
211
|
+
if (fresh && latest.exitCode === requirement.exitCode && (requirement.exitCode !== 0 || latest.isError === false) &&
|
|
212
|
+
outputMatches(requirement, latest.output)) matched.push({ id: requirement.id, toolCallId: latest.toolCallId });
|
|
213
|
+
else missing.push(requirement.id);
|
|
214
|
+
}
|
|
215
|
+
return { evidencePassed: missing.length ? false : unverifiable.length ? null : true,
|
|
216
|
+
evidence: { matched, missing, denied, unverifiable }, traceScopeViolations, requiredCheckFailed };
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export function gradeResponse(entry, input) {
|
|
220
|
+
const structured = structuredResponse(entry, input.finalText);
|
|
221
|
+
const { requiredCheckFailed, ...execution } = executionEvidence(entry, input);
|
|
222
|
+
const auditReasons = [...structured.reasons, ...execution.evidence.unverifiable];
|
|
223
|
+
if (entry.responseContract) auditReasons.push("Natural-language reasoning and any additional claims require blinded semantic audit");
|
|
224
|
+
return { ...terminalStatus(entry, input.finalText, requiredCheckFailed), responseFormatPassed: structured.responseFormatPassed,
|
|
225
|
+
findingsPassed: structured.findingsPassed, ...execution, auditEligible: Boolean(entry.responseContract) || auditReasons.length > 0,
|
|
226
|
+
auditReasons };
|
|
227
|
+
}
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { constants, writeSync } from "node:fs";
|
|
2
|
+
import { dirname, join, resolve } from "node:path";
|
|
3
|
+
import type { ExtensionAPI } from "@draht/coding-agent";
|
|
4
|
+
import * as sdk from "@draht/coding-agent";
|
|
5
|
+
import { createIsolation } from "./isolation.mjs";
|
|
6
|
+
|
|
7
|
+
/** The provider runs on the host; every model-directed filesystem operation runs in a fresh confined child. */
|
|
8
|
+
export default async function isolatedTools(api: ExtensionAPI) {
|
|
9
|
+
try {
|
|
10
|
+
await initializeTools(api);
|
|
11
|
+
} catch (error) {
|
|
12
|
+
// The general extension loader records errors and continues. This
|
|
13
|
+
// benchmark must stop before any provider request or unconfined tool.
|
|
14
|
+
process.stderr.write(
|
|
15
|
+
`Drahtbank isolated tools unavailable: ${error instanceof Error ? error.message : String(error)}\n`,
|
|
16
|
+
);
|
|
17
|
+
process.exit(1);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async function initializeTools(api: ExtensionAPI) {
|
|
22
|
+
if (sdk.DRAHTBANK_TOOL_OPERATIONS_VERSION !== "fixture-operations-v1") {
|
|
23
|
+
throw new Error("Configured Draht runtime must support fixture-operations-v1");
|
|
24
|
+
}
|
|
25
|
+
const isolation = await createIsolation(process.cwd());
|
|
26
|
+
const {
|
|
27
|
+
createBashToolDefinition,
|
|
28
|
+
createEditToolDefinition,
|
|
29
|
+
createFindToolDefinition,
|
|
30
|
+
createGrepToolDefinition,
|
|
31
|
+
createLsToolDefinition,
|
|
32
|
+
createReadToolDefinition,
|
|
33
|
+
createWriteToolDefinition,
|
|
34
|
+
detectSupportedImageMimeType,
|
|
35
|
+
} = sdk;
|
|
36
|
+
const dispose = () => isolation.dispose();
|
|
37
|
+
process.once("exit", dispose);
|
|
38
|
+
api.on("session_shutdown", () => {
|
|
39
|
+
dispose();
|
|
40
|
+
process.off("exit", dispose);
|
|
41
|
+
});
|
|
42
|
+
const workspace = isolation.workspace;
|
|
43
|
+
const readFile = async (path: string) => Buffer.from(await isolation.fs({ op: "read", path }), "base64");
|
|
44
|
+
const writeFile = async (path: string, content: string) => {
|
|
45
|
+
await isolation.fs({ op: "write", path, content });
|
|
46
|
+
};
|
|
47
|
+
const access = async (path: string, mode = constants.R_OK) => {
|
|
48
|
+
await isolation.fs({ op: "access", path, mode });
|
|
49
|
+
};
|
|
50
|
+
const exists = async (path: string) => {
|
|
51
|
+
try {
|
|
52
|
+
await isolation.fs({ op: "access", path });
|
|
53
|
+
return true;
|
|
54
|
+
} catch (error) {
|
|
55
|
+
if (error instanceof Error && "code" in error && error.code === "ENOENT") return false;
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
const stat = async (path: string) => {
|
|
60
|
+
const result = await isolation.fs({ op: "stat", path });
|
|
61
|
+
return { isDirectory: () => result.isDirectory };
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
api.registerTool(
|
|
65
|
+
createReadToolDefinition(workspace, {
|
|
66
|
+
operations: {
|
|
67
|
+
readFile,
|
|
68
|
+
access,
|
|
69
|
+
detectImageMimeType: async (path) => detectSupportedImageMimeType(await readFile(path)),
|
|
70
|
+
},
|
|
71
|
+
}),
|
|
72
|
+
);
|
|
73
|
+
api.registerTool(
|
|
74
|
+
createWriteToolDefinition(workspace, {
|
|
75
|
+
operations: {
|
|
76
|
+
writeFile,
|
|
77
|
+
mkdir: async (path) => {
|
|
78
|
+
await isolation.fs({ op: "mkdir", path });
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
}),
|
|
82
|
+
);
|
|
83
|
+
api.registerTool(
|
|
84
|
+
createEditToolDefinition(workspace, {
|
|
85
|
+
operations: { readFile, writeFile, access: (path) => access(path, constants.R_OK | constants.W_OK) },
|
|
86
|
+
}),
|
|
87
|
+
);
|
|
88
|
+
api.registerTool(
|
|
89
|
+
createLsToolDefinition(workspace, {
|
|
90
|
+
operations: { exists, stat, readdir: (path) => isolation.fs({ op: "readdir", path }) },
|
|
91
|
+
}),
|
|
92
|
+
);
|
|
93
|
+
api.registerTool(
|
|
94
|
+
createGrepToolDefinition(workspace, {
|
|
95
|
+
operations: {
|
|
96
|
+
isDirectory: async (path) => (await isolation.fs({ op: "stat", path })).isDirectory,
|
|
97
|
+
readFile: async (path) => (await readFile(path)).toString("utf8"),
|
|
98
|
+
spawn: (args) => {
|
|
99
|
+
const child = isolation.spawn([isolation.resolveExecutable("rg"), ...args]);
|
|
100
|
+
child.stdin.end();
|
|
101
|
+
return child;
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
}),
|
|
105
|
+
);
|
|
106
|
+
api.registerTool(
|
|
107
|
+
createFindToolDefinition(workspace, {
|
|
108
|
+
operations: {
|
|
109
|
+
exists,
|
|
110
|
+
glob: async (pattern, cwd, { limit }) => {
|
|
111
|
+
const args = ["--glob", "--color=never", "--hidden"];
|
|
112
|
+
let insideGitRepo = false;
|
|
113
|
+
for (let directory = cwd; ; directory = dirname(directory)) {
|
|
114
|
+
if (await exists(join(directory, ".git"))) {
|
|
115
|
+
insideGitRepo = true;
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
if (directory === workspace) break;
|
|
119
|
+
}
|
|
120
|
+
if (!insideGitRepo) args.push("--no-require-git");
|
|
121
|
+
args.push("--max-results", String(limit));
|
|
122
|
+
if (pattern.includes("/")) {
|
|
123
|
+
args.push("--full-path");
|
|
124
|
+
if (!pattern.startsWith("/") && !pattern.startsWith("**/") && pattern !== "**")
|
|
125
|
+
pattern = `**/${pattern}`;
|
|
126
|
+
}
|
|
127
|
+
args.push("--", pattern, cwd);
|
|
128
|
+
const result = await isolation.run([isolation.resolveExecutable("fd"), ...args]);
|
|
129
|
+
if (result.error || result.exitCode !== 0) {
|
|
130
|
+
throw new Error(result.error || result.stderr.trim() || `fd exited with code ${result.exitCode}`);
|
|
131
|
+
}
|
|
132
|
+
return result.stdout.split(/\r?\n/).filter(Boolean);
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
}),
|
|
136
|
+
);
|
|
137
|
+
const bash = createBashToolDefinition(workspace, {
|
|
138
|
+
exposeSessionEnvironment: false,
|
|
139
|
+
operations: {
|
|
140
|
+
exec: async (command, cwd, { signal, timeout, onData }) => {
|
|
141
|
+
if (resolve(cwd) !== workspace) throw new Error("Drahtbank bash cwd must be the isolated fixture");
|
|
142
|
+
if (signal?.aborted) throw new Error("aborted");
|
|
143
|
+
const result = await isolation.run([isolation.shellPath, "--noprofile", "--norc", "-c", command], {
|
|
144
|
+
signal,
|
|
145
|
+
timeoutMs: timeout === undefined ? 300_000 : Math.ceil(timeout * 1000),
|
|
146
|
+
onData,
|
|
147
|
+
});
|
|
148
|
+
if (signal?.aborted) throw new Error("aborted");
|
|
149
|
+
if (result.timedOut) throw new Error(`timeout:${timeout ?? 300}`);
|
|
150
|
+
if (result.error) throw new Error(result.error);
|
|
151
|
+
return { exitCode: result.exitCode };
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
});
|
|
155
|
+
api.registerTool({
|
|
156
|
+
...bash,
|
|
157
|
+
async execute(toolCallId, params, signal, onUpdate, ctx) {
|
|
158
|
+
const captures = new Set<string>();
|
|
159
|
+
const retained = new Map<string, string>();
|
|
160
|
+
const preserveCaptures = () => {
|
|
161
|
+
for (const path of captures) retained.set(path, isolation.retainReadOnlyFile(path));
|
|
162
|
+
};
|
|
163
|
+
const rewrite = (text: string) => {
|
|
164
|
+
for (const [hostPath, artifactPath] of retained) text = text.replaceAll(hostPath, artifactPath);
|
|
165
|
+
return text;
|
|
166
|
+
};
|
|
167
|
+
let result: Awaited<ReturnType<typeof bash.execute>>;
|
|
168
|
+
try {
|
|
169
|
+
result = await bash.execute(
|
|
170
|
+
toolCallId,
|
|
171
|
+
params,
|
|
172
|
+
signal,
|
|
173
|
+
(update) => {
|
|
174
|
+
if (update.details?.fullOutputPath) captures.add(update.details.fullOutputPath);
|
|
175
|
+
// A native spill file is still being written. Publish its
|
|
176
|
+
// readonly copy only after execute closes the capture.
|
|
177
|
+
onUpdate?.({
|
|
178
|
+
...update,
|
|
179
|
+
details: update.details ? { ...update.details, fullOutputPath: undefined } : undefined,
|
|
180
|
+
});
|
|
181
|
+
},
|
|
182
|
+
ctx,
|
|
183
|
+
);
|
|
184
|
+
} catch (error) {
|
|
185
|
+
preserveCaptures();
|
|
186
|
+
throw new Error(rewrite(error instanceof Error ? error.message : String(error)));
|
|
187
|
+
}
|
|
188
|
+
if (result.details?.fullOutputPath) captures.add(result.details.fullOutputPath);
|
|
189
|
+
preserveCaptures();
|
|
190
|
+
const structured = result.structuredContent;
|
|
191
|
+
return {
|
|
192
|
+
...result,
|
|
193
|
+
content: result.content.map((part) =>
|
|
194
|
+
part.type === "text" ? { ...part, text: rewrite(part.text) } : part,
|
|
195
|
+
),
|
|
196
|
+
details: result.details?.fullOutputPath
|
|
197
|
+
? { ...result.details, fullOutputPath: rewrite(result.details.fullOutputPath) }
|
|
198
|
+
: result.details,
|
|
199
|
+
structuredContent:
|
|
200
|
+
structured &&
|
|
201
|
+
typeof structured === "object" &&
|
|
202
|
+
!Array.isArray(structured) &&
|
|
203
|
+
"full_output_path" in structured &&
|
|
204
|
+
typeof structured.full_output_path === "string"
|
|
205
|
+
? { ...structured, full_output_path: rewrite(structured.full_output_path) }
|
|
206
|
+
: structured,
|
|
207
|
+
};
|
|
208
|
+
},
|
|
209
|
+
});
|
|
210
|
+
// JSON mode redirects console and process.stdout.write to stderr. This
|
|
211
|
+
// trusted readiness record must precede agent events on the actual stdout.
|
|
212
|
+
writeSync(
|
|
213
|
+
1,
|
|
214
|
+
`${JSON.stringify({
|
|
215
|
+
type: "drahtbank_isolation",
|
|
216
|
+
schemaVersion: 1,
|
|
217
|
+
policy: "fixture-root-v1",
|
|
218
|
+
toolOperationsVersion: sdk.DRAHTBANK_TOOL_OPERATIONS_VERSION,
|
|
219
|
+
workspace,
|
|
220
|
+
evidence: isolation.evidence,
|
|
221
|
+
})}\n`,
|
|
222
|
+
);
|
|
223
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { constants, readFileSync } from "node:fs";
|
|
2
|
+
import { access, mkdir, readFile, readdir, realpath, stat, writeFile } from "node:fs/promises";
|
|
3
|
+
import { isAbsolute, relative, resolve } from "node:path";
|
|
4
|
+
|
|
5
|
+
const workspace = await realpath(process.cwd());
|
|
6
|
+
const request = JSON.parse(readFileSync(0, "utf8"));
|
|
7
|
+
const path = typeof request.path === "string" ? resolve(workspace, request.path) : "";
|
|
8
|
+
const descendant = relative(workspace, path);
|
|
9
|
+
const artifact = /^\/\.drahtbank\/artifacts\/[a-f0-9-]+\.txt$/.test(path);
|
|
10
|
+
const artifactRead = artifact && ["read", "access", "stat"].includes(request.op);
|
|
11
|
+
if (!artifactRead && (!path || (descendant && (isAbsolute(descendant) || descendant === ".." || descendant.startsWith("../"))))) {
|
|
12
|
+
throw new Error("Drahtbank filesystem operation is outside the fixture workspace");
|
|
13
|
+
}
|
|
14
|
+
try {
|
|
15
|
+
let value = null;
|
|
16
|
+
switch (request.op) {
|
|
17
|
+
case "read":
|
|
18
|
+
value = (await readFile(path)).toString("base64");
|
|
19
|
+
break;
|
|
20
|
+
case "write":
|
|
21
|
+
if (typeof request.content !== "string" || !["utf8", "base64"].includes(request.encoding ?? "utf8")) {
|
|
22
|
+
throw new Error("Invalid filesystem write request");
|
|
23
|
+
}
|
|
24
|
+
await writeFile(path, request.content, request.encoding ?? "utf8");
|
|
25
|
+
break;
|
|
26
|
+
case "mkdir":
|
|
27
|
+
await mkdir(path, { recursive: true });
|
|
28
|
+
break;
|
|
29
|
+
case "access":
|
|
30
|
+
if (!Number.isInteger(request.mode ?? 0) || ((request.mode ?? 0) & ~7) !== 0) {
|
|
31
|
+
throw new Error("Invalid filesystem access mode");
|
|
32
|
+
}
|
|
33
|
+
await access(path, request.mode ?? constants.F_OK);
|
|
34
|
+
break;
|
|
35
|
+
case "stat": {
|
|
36
|
+
const entry = await stat(path);
|
|
37
|
+
value = { isDirectory: entry.isDirectory(), isFile: entry.isFile(), isSymbolicLink: entry.isSymbolicLink() };
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
case "readdir":
|
|
41
|
+
value = await readdir(path);
|
|
42
|
+
break;
|
|
43
|
+
default:
|
|
44
|
+
throw new Error("Unknown Drahtbank filesystem operation");
|
|
45
|
+
}
|
|
46
|
+
process.stdout.write(`${JSON.stringify({ ok: true, value })}\n`);
|
|
47
|
+
} catch (error) {
|
|
48
|
+
process.stdout.write(`${JSON.stringify({
|
|
49
|
+
ok: false,
|
|
50
|
+
message: error instanceof Error ? error.message : "Filesystem operation failed",
|
|
51
|
+
code: typeof error?.code === "string" ? error.code : undefined,
|
|
52
|
+
})}\n`);
|
|
53
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { ChildProcessWithoutNullStreams } from "node:child_process";
|
|
2
|
+
|
|
3
|
+
export const ISOLATION_VERSION: "linux-user-mount-pid-net-ipc-chroot-v1";
|
|
4
|
+
export interface IsolationProcessOptions {
|
|
5
|
+
stdin?: string;
|
|
6
|
+
timeoutMs?: number;
|
|
7
|
+
signal?: AbortSignal;
|
|
8
|
+
onData?: (chunk: Buffer) => void;
|
|
9
|
+
}
|
|
10
|
+
export interface IsolationProcessResult {
|
|
11
|
+
exitCode: number | null;
|
|
12
|
+
signal: NodeJS.Signals | null;
|
|
13
|
+
stdout: string;
|
|
14
|
+
stderr: string;
|
|
15
|
+
error: string | null;
|
|
16
|
+
timedOut: boolean;
|
|
17
|
+
elapsedMs: number;
|
|
18
|
+
}
|
|
19
|
+
export interface IsolationStat {
|
|
20
|
+
isDirectory: boolean;
|
|
21
|
+
isFile: boolean;
|
|
22
|
+
isSymbolicLink: boolean;
|
|
23
|
+
}
|
|
24
|
+
export interface Isolation {
|
|
25
|
+
workspace: string;
|
|
26
|
+
nodePath: string;
|
|
27
|
+
shellPath: string;
|
|
28
|
+
workerPath: string;
|
|
29
|
+
evidence: {
|
|
30
|
+
policy: typeof ISOLATION_VERSION;
|
|
31
|
+
workspace: string;
|
|
32
|
+
runtimeRoots: string[];
|
|
33
|
+
runtimeFiles: Array<{ source: string; target: string }>;
|
|
34
|
+
workerSha256: string;
|
|
35
|
+
network: string;
|
|
36
|
+
hostProc: false;
|
|
37
|
+
inheritedEnvironment: false;
|
|
38
|
+
readonlyArtifactsPath: "/.drahtbank/artifacts";
|
|
39
|
+
};
|
|
40
|
+
retainReadOnlyFile(hostPath: string): string;
|
|
41
|
+
dispose(): void;
|
|
42
|
+
resolveExecutable(name: string): string;
|
|
43
|
+
spawn(argv: string[], options?: { signal?: AbortSignal }): ChildProcessWithoutNullStreams;
|
|
44
|
+
run(argv: string[], options?: IsolationProcessOptions): Promise<IsolationProcessResult>;
|
|
45
|
+
runSync(argv: string[], options?: Omit<IsolationProcessOptions, "signal">): IsolationProcessResult;
|
|
46
|
+
fs(request: { op: "read"; path: string }, options?: IsolationProcessOptions): Promise<string>;
|
|
47
|
+
fs(request: { op: "stat"; path: string }, options?: IsolationProcessOptions): Promise<IsolationStat>;
|
|
48
|
+
fs(request: { op: "readdir"; path: string }, options?: IsolationProcessOptions): Promise<string[]>;
|
|
49
|
+
fs(request: { op: "write"; path: string; content: string; encoding?: "utf8" | "base64" }, options?: IsolationProcessOptions): Promise<null>;
|
|
50
|
+
fs(request: { op: "access"; path: string; mode?: number } | { op: "mkdir"; path: string }, options?: IsolationProcessOptions): Promise<null>;
|
|
51
|
+
}
|
|
52
|
+
export function createIsolation(workspace: string): Promise<Isolation>;
|