@draht/coding-agent 2026.7.13 → 2026.9.5-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 +241 -0
- package/README.md +47 -2
- package/agents/debugger.md +12 -1
- package/agents/git-committer.md +1 -0
- package/agents/implementer.md +20 -0
- package/agents/investigator.md +75 -0
- package/agents/reviewer.md +7 -0
- package/agents/spec-reviewer.md +66 -0
- package/agents/verifier.md +4 -3
- package/bin/draht-tools.cjs +472 -41
- package/dist/agents/debugger.md +12 -1
- package/dist/agents/git-committer.md +1 -0
- package/dist/agents/implementer.md +20 -0
- package/dist/agents/investigator.md +75 -0
- package/dist/agents/reviewer.md +7 -0
- package/dist/agents/spec-reviewer.md +66 -0
- package/dist/agents/verifier.md +4 -3
- package/dist/bun/cli.js +2 -0
- package/dist/bun/cli.js.map +1 -1
- package/dist/cli/args.d.ts +10 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +80 -3
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/attach-mode.d.ts +61 -0
- package/dist/cli/attach-mode.d.ts.map +1 -1
- package/dist/cli/attach-mode.js +243 -5
- package/dist/cli/attach-mode.js.map +1 -1
- package/dist/cli/config-selector.js +1 -1
- package/dist/cli/config-selector.js.map +1 -1
- package/dist/cli/credential-print.d.ts +23 -0
- package/dist/cli/credential-print.d.ts.map +1 -0
- package/dist/cli/credential-print.js +117 -0
- package/dist/cli/credential-print.js.map +1 -0
- package/dist/cli/list-models.d.ts +2 -2
- package/dist/cli/list-models.d.ts.map +1 -1
- package/dist/cli/list-models.js +3 -3
- package/dist/cli/list-models.js.map +1 -1
- package/dist/cli/startup-ui.js +1 -1
- package/dist/cli/startup-ui.js.map +1 -1
- package/dist/config.d.ts +9 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +31 -4
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts +17 -1
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +90 -30
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +4 -7
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +24 -9
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +87 -27
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +337 -154
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts +20 -104
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +104 -260
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/builtins/checkpoints.d.ts +20 -0
- package/dist/core/builtins/checkpoints.d.ts.map +1 -0
- package/dist/core/builtins/checkpoints.js +161 -0
- package/dist/core/builtins/checkpoints.js.map +1 -0
- package/dist/core/builtins/duet.d.ts +26 -0
- package/dist/core/builtins/duet.d.ts.map +1 -0
- package/dist/core/builtins/duet.js +660 -0
- package/dist/core/builtins/duet.js.map +1 -0
- package/dist/core/builtins/index.d.ts.map +1 -1
- package/dist/core/builtins/index.js +7 -1
- package/dist/core/builtins/index.js.map +1 -1
- package/dist/core/builtins/subagent.d.ts +24 -4
- package/dist/core/builtins/subagent.d.ts.map +1 -1
- package/dist/core/builtins/subagent.js +278 -35
- package/dist/core/builtins/subagent.js.map +1 -1
- package/dist/core/cache-stats.d.ts +2 -2
- package/dist/core/cache-stats.d.ts.map +1 -1
- package/dist/core/cache-stats.js +1 -1
- package/dist/core/cache-stats.js.map +1 -1
- package/dist/core/checkpoints/checkpoint-cli.d.ts +17 -0
- package/dist/core/checkpoints/checkpoint-cli.d.ts.map +1 -0
- package/dist/core/checkpoints/checkpoint-cli.js +78 -0
- package/dist/core/checkpoints/checkpoint-cli.js.map +1 -0
- package/dist/core/checkpoints/checkpoint-manager.d.ts +294 -0
- package/dist/core/checkpoints/checkpoint-manager.d.ts.map +1 -0
- package/dist/core/checkpoints/checkpoint-manager.js +865 -0
- package/dist/core/checkpoints/checkpoint-manager.js.map +1 -0
- package/dist/core/checkpoints/rewind.d.ts +141 -0
- package/dist/core/checkpoints/rewind.d.ts.map +1 -0
- package/dist/core/checkpoints/rewind.js +246 -0
- package/dist/core/checkpoints/rewind.js.map +1 -0
- package/dist/core/compaction/branch-summarization.d.ts +9 -3
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +16 -14
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +24 -3
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +96 -30
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/compaction/utils.d.ts +1 -1
- package/dist/core/compaction/utils.d.ts.map +1 -1
- package/dist/core/compaction/utils.js +6 -17
- package/dist/core/compaction/utils.js.map +1 -1
- package/dist/core/context-windows.d.ts +7 -0
- package/dist/core/context-windows.d.ts.map +1 -0
- package/dist/core/context-windows.js +35 -0
- package/dist/core/context-windows.js.map +1 -0
- 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 +101 -23
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +19 -3
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +117 -2
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +236 -9
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/extensions/wrapper.d.ts.map +1 -1
- package/dist/core/extensions/wrapper.js +22 -3
- package/dist/core/extensions/wrapper.js.map +1 -1
- package/dist/core/footer-data-provider.d.ts +10 -0
- package/dist/core/footer-data-provider.d.ts.map +1 -1
- package/dist/core/footer-data-provider.js +1 -1
- package/dist/core/footer-data-provider.js.map +1 -1
- package/dist/core/http-dispatcher.d.ts.map +1 -1
- package/dist/core/http-dispatcher.js +7 -0
- package/dist/core/http-dispatcher.js.map +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/keybindings.d.ts +18 -3
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +12 -3
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/model-config.d.ts +542 -0
- package/dist/core/model-config.d.ts.map +1 -0
- package/dist/core/model-config.js +247 -0
- package/dist/core/model-config.js.map +1 -0
- package/dist/core/model-registry.d.ts +19 -124
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +56 -727
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts +7 -6
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +74 -27
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-runtime.d.ts +89 -0
- package/dist/core/model-runtime.d.ts.map +1 -0
- package/dist/core/model-runtime.js +451 -0
- package/dist/core/model-runtime.js.map +1 -0
- package/dist/core/models-store.d.ts +17 -0
- package/dist/core/models-store.d.ts.map +1 -0
- package/dist/core/models-store.js +46 -0
- package/dist/core/models-store.js.map +1 -0
- package/dist/core/multi-agent/permission-gate.d.ts.map +1 -1
- package/dist/core/multi-agent/permission-gate.js +4 -3
- package/dist/core/multi-agent/permission-gate.js.map +1 -1
- package/dist/core/multi-agent/worktree.d.ts +2 -0
- package/dist/core/multi-agent/worktree.d.ts.map +1 -1
- package/dist/core/multi-agent/worktree.js +2 -2
- package/dist/core/multi-agent/worktree.js.map +1 -1
- package/dist/core/package-manager.d.ts +7 -1
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +41 -45
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/permission-relay/index.d.ts +19 -0
- package/dist/core/permission-relay/index.d.ts.map +1 -0
- package/dist/core/permission-relay/index.js +49 -0
- package/dist/core/permission-relay/index.js.map +1 -0
- package/dist/core/permission-relay/relay-ui-context.d.ts +39 -0
- package/dist/core/permission-relay/relay-ui-context.d.ts.map +1 -0
- package/dist/core/permission-relay/relay-ui-context.js +788 -0
- package/dist/core/permission-relay/relay-ui-context.js.map +1 -0
- package/dist/core/permission-relay/types.d.ts +222 -0
- package/dist/core/permission-relay/types.d.ts.map +1 -0
- package/dist/core/permission-relay/types.js +15 -0
- package/dist/core/permission-relay/types.js.map +1 -0
- package/dist/core/pi-manifest.d.ts +14 -0
- package/dist/core/pi-manifest.d.ts.map +1 -0
- package/dist/core/pi-manifest.js +35 -0
- package/dist/core/pi-manifest.js.map +1 -0
- package/dist/core/project-trust.js +2 -2
- package/dist/core/project-trust.js.map +1 -1
- package/dist/core/prompt-templates.d.ts +1 -0
- package/dist/core/prompt-templates.d.ts.map +1 -1
- package/dist/core/prompt-templates.js +4 -4
- package/dist/core/prompt-templates.js.map +1 -1
- package/dist/core/provider-composer.d.ts +55 -0
- package/dist/core/provider-composer.d.ts.map +1 -0
- package/dist/core/provider-composer.js +375 -0
- package/dist/core/provider-composer.js.map +1 -0
- package/dist/core/radius.d.ts +2 -0
- package/dist/core/radius.d.ts.map +1 -0
- package/dist/core/radius.js +2 -0
- package/dist/core/radius.js.map +1 -0
- package/dist/core/remote-catalog-provider.d.ts +5 -0
- package/dist/core/remote-catalog-provider.d.ts.map +1 -0
- package/dist/core/remote-catalog-provider.js +115 -0
- package/dist/core/remote-catalog-provider.js.map +1 -0
- package/dist/core/resource-loader.d.ts +36 -0
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +159 -27
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/runtime-credentials.d.ts +15 -0
- package/dist/core/runtime-credentials.d.ts.map +1 -0
- package/dist/core/runtime-credentials.js +35 -0
- package/dist/core/runtime-credentials.js.map +1 -0
- package/dist/core/sandbox/bash-operations.d.ts +149 -0
- package/dist/core/sandbox/bash-operations.d.ts.map +1 -0
- package/dist/core/sandbox/bash-operations.js +163 -0
- package/dist/core/sandbox/bash-operations.js.map +1 -0
- package/dist/core/sandbox/env.d.ts +83 -0
- package/dist/core/sandbox/env.d.ts.map +1 -0
- package/dist/core/sandbox/env.js +123 -0
- package/dist/core/sandbox/env.js.map +1 -0
- package/dist/core/sandbox/executor.d.ts +104 -0
- package/dist/core/sandbox/executor.d.ts.map +1 -0
- package/dist/core/sandbox/executor.js +92 -0
- package/dist/core/sandbox/executor.js.map +1 -0
- package/dist/core/sandbox/index.d.ts +36 -0
- package/dist/core/sandbox/index.d.ts.map +1 -0
- package/dist/core/sandbox/index.js +36 -0
- package/dist/core/sandbox/index.js.map +1 -0
- package/dist/core/sandbox/linux.d.ts +121 -0
- package/dist/core/sandbox/linux.d.ts.map +1 -0
- package/dist/core/sandbox/linux.js +260 -0
- package/dist/core/sandbox/linux.js.map +1 -0
- package/dist/core/sandbox/policy.d.ts +142 -0
- package/dist/core/sandbox/policy.d.ts.map +1 -0
- package/dist/core/sandbox/policy.js +297 -0
- package/dist/core/sandbox/policy.js.map +1 -0
- package/dist/core/sandbox/real-path.d.ts +112 -0
- package/dist/core/sandbox/real-path.d.ts.map +1 -0
- package/dist/core/sandbox/real-path.js +158 -0
- package/dist/core/sandbox/real-path.js.map +1 -0
- package/dist/core/sandbox/seatbelt-profile.d.ts +95 -0
- package/dist/core/sandbox/seatbelt-profile.d.ts.map +1 -0
- package/dist/core/sandbox/seatbelt-profile.js +239 -0
- package/dist/core/sandbox/seatbelt-profile.js.map +1 -0
- package/dist/core/sandbox/seatbelt.d.ts +95 -0
- package/dist/core/sandbox/seatbelt.d.ts.map +1 -0
- package/dist/core/sandbox/seatbelt.js +154 -0
- package/dist/core/sandbox/seatbelt.js.map +1 -0
- package/dist/core/sandbox/self-test.d.ts +109 -0
- package/dist/core/sandbox/self-test.d.ts.map +1 -0
- package/dist/core/sandbox/self-test.js +369 -0
- package/dist/core/sandbox/self-test.js.map +1 -0
- package/dist/core/sandbox/spawn.d.ts +33 -0
- package/dist/core/sandbox/spawn.d.ts.map +1 -0
- package/dist/core/sandbox/spawn.js +87 -0
- package/dist/core/sandbox/spawn.js.map +1 -0
- package/dist/core/sdk.d.ts +3 -6
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +25 -22
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager.d.ts +74 -7
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +169 -34
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-manager.d.ts +22 -1
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +36 -16
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/skills.d.ts +3 -1
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +19 -6
- package/dist/core/skills.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +1 -0
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/soak/soak-log.d.ts +298 -0
- package/dist/core/soak/soak-log.d.ts.map +1 -0
- package/dist/core/soak/soak-log.js +660 -0
- package/dist/core/soak/soak-log.js.map +1 -0
- package/dist/core/soak/soak-reader.d.ts +60 -0
- package/dist/core/soak/soak-reader.d.ts.map +1 -0
- package/dist/core/soak/soak-reader.js +106 -0
- package/dist/core/soak/soak-reader.js.map +1 -0
- package/dist/core/socket-server/discovery.d.ts +78 -1
- package/dist/core/socket-server/discovery.d.ts.map +1 -1
- package/dist/core/socket-server/discovery.js +356 -37
- package/dist/core/socket-server/discovery.js.map +1 -1
- package/dist/core/socket-server/index.d.ts +10 -4
- package/dist/core/socket-server/index.d.ts.map +1 -1
- package/dist/core/socket-server/index.js +6 -3
- package/dist/core/socket-server/index.js.map +1 -1
- package/dist/core/socket-server/permission-delivery.d.ts +125 -0
- package/dist/core/socket-server/permission-delivery.d.ts.map +1 -0
- package/dist/core/socket-server/permission-delivery.js +152 -0
- package/dist/core/socket-server/permission-delivery.js.map +1 -0
- package/dist/core/socket-server/permission-registry.d.ts +301 -0
- package/dist/core/socket-server/permission-registry.d.ts.map +1 -0
- package/dist/core/socket-server/permission-registry.js +410 -0
- package/dist/core/socket-server/permission-registry.js.map +1 -0
- package/dist/core/socket-server/permission-relay.d.ts +81 -0
- package/dist/core/socket-server/permission-relay.d.ts.map +1 -0
- package/dist/core/socket-server/permission-relay.js +528 -0
- package/dist/core/socket-server/permission-relay.js.map +1 -0
- package/dist/core/socket-server/safe-text.d.ts +83 -0
- package/dist/core/socket-server/safe-text.d.ts.map +1 -0
- package/dist/core/socket-server/safe-text.js +277 -0
- package/dist/core/socket-server/safe-text.js.map +1 -0
- package/dist/core/socket-server/session-integration.d.ts +65 -2
- package/dist/core/socket-server/session-integration.d.ts.map +1 -1
- package/dist/core/socket-server/session-integration.js +434 -32
- package/dist/core/socket-server/session-integration.js.map +1 -1
- package/dist/core/socket-server/socket-client.d.ts +21 -2
- package/dist/core/socket-server/socket-client.d.ts.map +1 -1
- package/dist/core/socket-server/socket-client.js +52 -1
- package/dist/core/socket-server/socket-client.js.map +1 -1
- package/dist/core/socket-server/socket-server.d.ts +152 -1
- package/dist/core/socket-server/socket-server.d.ts.map +1 -1
- package/dist/core/socket-server/socket-server.js +775 -26
- package/dist/core/socket-server/socket-server.js.map +1 -1
- package/dist/core/socket-server/types.d.ts +106 -2
- package/dist/core/socket-server/types.d.ts.map +1 -1
- package/dist/core/socket-server/types.js +13 -1
- package/dist/core/socket-server/types.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +10 -21
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/bash.d.ts +3 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +39 -7
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +17 -2
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/find.d.ts +3 -0
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js +11 -18
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/read.js +1 -1
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.js +3 -1
- package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
- package/dist/core/trust-manager.d.ts +6 -4
- package/dist/core/trust-manager.d.ts.map +1 -1
- package/dist/core/trust-manager.js +55 -21
- package/dist/core/trust-manager.js.map +1 -1
- package/dist/core/usage-totals.d.ts +19 -0
- package/dist/core/usage-totals.d.ts.map +1 -0
- package/dist/core/usage-totals.js +52 -0
- package/dist/core/usage-totals.js.map +1 -0
- package/dist/extensions/index.d.ts +3 -0
- package/dist/extensions/index.d.ts.map +1 -0
- package/dist/extensions/index.js +7 -0
- package/dist/extensions/index.js.map +1 -0
- package/dist/extensions/llama/client.d.ts +61 -0
- package/dist/extensions/llama/client.d.ts.map +1 -0
- package/dist/extensions/llama/client.js +300 -0
- package/dist/extensions/llama/client.js.map +1 -0
- package/dist/extensions/llama/huggingface.d.ts +23 -0
- package/dist/extensions/llama/huggingface.d.ts.map +1 -0
- package/dist/extensions/llama/huggingface.js +139 -0
- package/dist/extensions/llama/huggingface.js.map +1 -0
- package/dist/extensions/llama/index.d.ts +3 -0
- package/dist/extensions/llama/index.d.ts.map +1 -0
- package/dist/extensions/llama/index.js +208 -0
- package/dist/extensions/llama/index.js.map +1 -0
- package/dist/extensions/llama/provider.d.ts +10 -0
- package/dist/extensions/llama/provider.d.ts.map +1 -0
- package/dist/extensions/llama/provider.js +111 -0
- package/dist/extensions/llama/provider.js.map +1 -0
- package/dist/extensions/llama/ui.d.ts +42 -0
- package/dist/extensions/llama/ui.d.ts.map +1 -0
- package/dist/extensions/llama/ui.js +400 -0
- package/dist/extensions/llama/ui.js.map +1 -0
- package/dist/extensions/stub-provider/index.d.ts +9 -0
- package/dist/extensions/stub-provider/index.d.ts.map +1 -0
- package/dist/extensions/stub-provider/index.js +13 -0
- package/dist/extensions/stub-provider/index.js.map +1 -0
- package/dist/extensions/stub-provider/provider.d.ts +77 -0
- package/dist/extensions/stub-provider/provider.d.ts.map +1 -0
- package/dist/extensions/stub-provider/provider.js +193 -0
- package/dist/extensions/stub-provider/provider.js.map +1 -0
- package/dist/hooks/gsd/draht-quality-gate.js +3 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +305 -61
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +22 -10
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/config-selector.js +3 -2
- package/dist/modes/interactive/components/config-selector.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js +1 -1
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/custom-message.d.ts +3 -1
- package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-message.js +9 -2
- package/dist/modes/interactive/components/custom-message.js.map +1 -1
- package/dist/modes/interactive/components/extension-editor.d.ts +1 -2
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-editor.js +16 -46
- package/dist/modes/interactive/components/extension-editor.js.map +1 -1
- package/dist/modes/interactive/components/extension-selector.d.ts +49 -0
- package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-selector.js +202 -5
- package/dist/modes/interactive/components/extension-selector.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +24 -23
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts +5 -5
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +17 -8
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts +11 -4
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +74 -41
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts +4 -4
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.js +14 -25
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js +22 -13
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +10 -2
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +2 -0
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +10 -0
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +10 -1
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector.d.ts +25 -2
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector.js +68 -17
- package/dist/modes/interactive/components/tree-selector.js.map +1 -1
- package/dist/modes/interactive/external-editor.d.ts +12 -0
- package/dist/modes/interactive/external-editor.d.ts.map +1 -0
- package/dist/modes/interactive/external-editor.js +37 -0
- package/dist/modes/interactive/external-editor.js.map +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts +107 -10
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +763 -285
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +4 -0
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +7 -0
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +185 -9
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +79 -1
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +67 -5
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/prompts/commands/atomic-commit.md +1 -12
- package/dist/prompts/commands/brainstorm.md +12 -15
- package/dist/prompts/commands/create-verification-skill.md +108 -0
- package/dist/prompts/commands/discuss-phase.md +3 -14
- package/dist/prompts/commands/execute-phase.md +3 -11
- package/dist/prompts/commands/fix.md +41 -18
- package/dist/prompts/commands/grill.md +66 -0
- package/dist/prompts/commands/init-project.md +5 -15
- package/dist/prompts/commands/map-codebase.md +1 -13
- package/dist/prompts/commands/new-project.md +5 -15
- package/dist/prompts/commands/next-milestone.md +1 -13
- package/dist/prompts/commands/orchestrate.md +1 -1
- package/dist/prompts/commands/pause-work.md +1 -13
- package/dist/prompts/commands/plan-phase.md +2 -11
- package/dist/prompts/commands/progress.md +0 -13
- package/dist/prompts/commands/quick.md +3 -11
- package/dist/prompts/commands/resolve-conflicts.md +71 -0
- package/dist/prompts/commands/resume-work.md +0 -13
- package/dist/prompts/commands/review.md +4 -13
- package/dist/prompts/commands/triage.md +159 -0
- package/dist/prompts/commands/verify-work.md +4 -14
- package/dist/prompts/commands/why.md +135 -0
- package/dist/skills/atomic-reasoning/SKILL.md +115 -0
- package/dist/skills/blast-radius/SKILL.md +55 -0
- package/dist/skills/epistemics/SKILL.md +99 -0
- package/dist/skills/hexagon-animation/SKILL.md +49 -0
- package/dist/skills/hexagon-animation/generate.mjs +81 -0
- package/dist/skills/hexagon-animation/template.html +361 -0
- package/dist/skills/typescript-discipline/SKILL.md +50 -0
- package/dist/skills/typescript-discipline/references/patterns.md +294 -0
- package/dist/skills/unslop/SKILL.md +101 -0
- package/dist/utils/canonical-path.d.ts +28 -0
- package/dist/utils/canonical-path.d.ts.map +1 -0
- package/dist/utils/canonical-path.js +90 -0
- package/dist/utils/canonical-path.js.map +1 -0
- package/dist/utils/child-process.d.ts +12 -1
- package/dist/utils/child-process.d.ts.map +1 -1
- package/dist/utils/child-process.js +25 -8
- package/dist/utils/child-process.js.map +1 -1
- package/dist/utils/clipboard-native.d.ts +1 -0
- package/dist/utils/clipboard-native.d.ts.map +1 -1
- package/dist/utils/clipboard-native.js.map +1 -1
- package/dist/utils/clipboard.d.ts +2 -0
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js +53 -9
- package/dist/utils/clipboard.js.map +1 -1
- package/dist/utils/exif-orientation.d.ts.map +1 -1
- package/dist/utils/exif-orientation.js +2 -3
- package/dist/utils/exif-orientation.js.map +1 -1
- package/dist/utils/paths.d.ts +2 -7
- package/dist/utils/paths.d.ts.map +1 -1
- package/dist/utils/paths.js +13 -15
- package/dist/utils/paths.js.map +1 -1
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +6 -4
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +3 -5
- package/dist/utils/tools-manager.js.map +1 -1
- package/dist/utils/version-check.d.ts.map +1 -1
- package/dist/utils/version-check.js +3 -1
- package/dist/utils/version-check.js.map +1 -1
- package/docs/attachable-sessions.md +79 -0
- package/docs/compaction.md +29 -24
- package/docs/containerization.md +23 -23
- package/docs/custom-provider.md +66 -32
- package/docs/development.md +9 -9
- package/docs/docs.json +6 -2
- package/docs/duet.md +42 -0
- package/docs/environment-variables.md +88 -0
- package/docs/extensions.md +278 -65
- package/docs/index.md +12 -10
- package/docs/json.md +12 -8
- package/docs/keybindings.md +8 -5
- package/docs/llama-cpp.md +99 -0
- package/docs/models.md +19 -8
- package/docs/packages.md +43 -42
- package/docs/prompt-templates.md +5 -4
- package/docs/providers.md +45 -11
- package/docs/quickstart.md +33 -33
- package/docs/rpc.md +190 -19
- package/docs/sdk.md +18 -15
- package/docs/security.md +18 -18
- package/docs/session-format.md +53 -15
- package/docs/sessions.md +17 -14
- package/docs/settings.md +26 -19
- package/docs/shell-aliases.md +2 -2
- package/docs/skills.md +12 -11
- package/docs/terminal-setup.md +12 -12
- package/docs/termux.md +6 -6
- package/docs/themes.md +11 -11
- package/docs/tmux.md +4 -4
- package/docs/tui.md +46 -31
- package/docs/usage.md +53 -63
- package/docs/windows.md +2 -2
- package/examples/extensions/custom-compaction.ts +4 -0
- package/examples/extensions/custom-provider-anthropic/index.ts +9 -3
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/custom-provider-qwen-cli/package.json +1 -1
- package/examples/extensions/gondolin/package.json +2 -2
- package/examples/extensions/handoff.ts +9 -1
- package/examples/extensions/kimi-deferred-tools.ts +61 -0
- package/examples/extensions/message-renderer.ts +2 -2
- package/examples/extensions/overlay-qa-tests.ts +3 -3
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/summarize.ts +3 -0
- package/examples/extensions/with-deps/package.json +1 -1
- package/examples/sdk/02-custom-model.ts +5 -8
- package/examples/sdk/09-api-keys-and-oauth.ts +15 -31
- package/examples/sdk/12-full-control.ts +9 -12
- package/hooks/gsd/draht-quality-gate.js +3 -3
- package/package.json +14 -11
- package/prompts/commands/atomic-commit.md +1 -12
- package/prompts/commands/brainstorm.md +12 -15
- package/prompts/commands/create-verification-skill.md +108 -0
- package/prompts/commands/discuss-phase.md +3 -14
- package/prompts/commands/execute-phase.md +3 -11
- package/prompts/commands/fix.md +41 -18
- package/prompts/commands/grill.md +66 -0
- package/prompts/commands/init-project.md +5 -15
- package/prompts/commands/map-codebase.md +1 -13
- package/prompts/commands/new-project.md +5 -15
- package/prompts/commands/next-milestone.md +1 -13
- package/prompts/commands/orchestrate.md +1 -1
- package/prompts/commands/pause-work.md +1 -13
- package/prompts/commands/plan-phase.md +2 -11
- package/prompts/commands/progress.md +0 -13
- package/prompts/commands/quick.md +3 -11
- package/prompts/commands/resolve-conflicts.md +71 -0
- package/prompts/commands/resume-work.md +0 -13
- package/prompts/commands/review.md +4 -13
- package/prompts/commands/triage.md +159 -0
- package/prompts/commands/verify-work.md +4 -14
- package/prompts/commands/why.md +135 -0
- package/skills/atomic-reasoning/SKILL.md +115 -0
- package/skills/blast-radius/SKILL.md +55 -0
- package/skills/epistemics/SKILL.md +99 -0
- package/skills/hexagon-animation/SKILL.md +49 -0
- package/skills/hexagon-animation/generate.mjs +81 -0
- package/skills/hexagon-animation/template.html +361 -0
- package/skills/typescript-discipline/SKILL.md +50 -0
- package/skills/typescript-discipline/references/patterns.md +294 -0
- package/skills/unslop/SKILL.md +101 -0
- package/dist/core/provider-display-names.d.ts +0 -2
- package/dist/core/provider-display-names.d.ts.map +0 -1
- package/dist/core/provider-display-names.js +0 -36
- package/dist/core/provider-display-names.js.map +0 -1
- package/dist/prompts/agents/build.md +0 -86
- package/dist/prompts/agents/plan.md +0 -79
- package/dist/prompts/agents/verify.md +0 -69
- package/prompts/agents/build.md +0 -86
- package/prompts/agents/plan.md +0 -79
- package/prompts/agents/verify.md +0 -69
|
@@ -16,9 +16,11 @@ import * as os from "node:os";
|
|
|
16
16
|
import * as path from "node:path";
|
|
17
17
|
import { Text } from "@draht/tui";
|
|
18
18
|
import { Type } from "@sinclair/typebox";
|
|
19
|
-
import { getAgentDir, getPackageDir, isBunBinary } from "../../config.js";
|
|
19
|
+
import { CONFIG_DIR_NAME, getAgentDir, getPackageDir, isBunBinary } from "../../config.js";
|
|
20
|
+
import { comparablePath, realPathStrict } from "../../utils/canonical-path.js";
|
|
20
21
|
import { parseFrontmatter } from "../../utils/frontmatter.js";
|
|
21
|
-
import { AgentFSM, isPermissionMode, loadRules, MailboxSystem, PERMISSION_MODES, PermissionGate, TaskBoard, WorktreeIsolator, } from "../multi-agent/index.js";
|
|
22
|
+
import { AgentFSM, isPermissionMode, loadRules, MailboxSystem, PERMISSION_MODES, PermissionGate, parseRules, TaskBoard, WorktreeIsolator, } from "../multi-agent/index.js";
|
|
23
|
+
import { boundedSafeText } from "../socket-server/safe-text.js";
|
|
22
24
|
const MAX_PARALLEL = 8;
|
|
23
25
|
const MAX_CONCURRENCY = 4;
|
|
24
26
|
// ─── Multi-agent coordination primitives ───────────────────────────────────
|
|
@@ -87,9 +89,14 @@ function loadAgentsFromDir(dir, source) {
|
|
|
87
89
|
return agents;
|
|
88
90
|
}
|
|
89
91
|
function findProjectAgentsDir(cwd) {
|
|
90
|
-
|
|
92
|
+
// The gate's own chain, from the raw spelling: `resolvePath` first would collapse `..`
|
|
93
|
+
// lexically, and a cwd that will not resolve has unknown ancestors to load from.
|
|
94
|
+
const realCwd = realPathStrict(cwd);
|
|
95
|
+
if (realCwd === undefined)
|
|
96
|
+
return null;
|
|
97
|
+
let dir = realCwd;
|
|
91
98
|
while (true) {
|
|
92
|
-
const candidate = path.join(dir,
|
|
99
|
+
const candidate = path.join(dir, CONFIG_DIR_NAME, "agents");
|
|
93
100
|
try {
|
|
94
101
|
if (fs.statSync(candidate).isDirectory())
|
|
95
102
|
return candidate;
|
|
@@ -101,12 +108,12 @@ function findProjectAgentsDir(cwd) {
|
|
|
101
108
|
dir = parent;
|
|
102
109
|
}
|
|
103
110
|
}
|
|
104
|
-
function discoverAgents(cwd, scope) {
|
|
111
|
+
export function discoverAgents(cwd, scope, projectTrusted) {
|
|
105
112
|
// Shipped agents (bundled with the package) — lowest priority
|
|
106
113
|
const shippedDir = path.join(getPackageDir(), "agents");
|
|
107
114
|
const shippedAgents = loadAgentsFromDir(shippedDir, "user");
|
|
108
115
|
const userDir = path.join(getAgentDir(), "agents");
|
|
109
|
-
const projectDir = findProjectAgentsDir(cwd);
|
|
116
|
+
const projectDir = projectTrusted ? findProjectAgentsDir(cwd) : null;
|
|
110
117
|
const userAgents = scope !== "project" ? loadAgentsFromDir(userDir, "user") : [];
|
|
111
118
|
const projectAgents = scope !== "user" && projectDir ? loadAgentsFromDir(projectDir, "project") : [];
|
|
112
119
|
// Priority: shipped < user < project
|
|
@@ -135,6 +142,14 @@ function cleanTemp(file, dir) {
|
|
|
135
142
|
}
|
|
136
143
|
catch { }
|
|
137
144
|
}
|
|
145
|
+
function getFinalAssistant(messages) {
|
|
146
|
+
for (let index = messages.length - 1; index >= 0; index--) {
|
|
147
|
+
const message = messages[index];
|
|
148
|
+
if (message.role === "assistant")
|
|
149
|
+
return message;
|
|
150
|
+
}
|
|
151
|
+
return undefined;
|
|
152
|
+
}
|
|
138
153
|
function getFinalText(messages) {
|
|
139
154
|
for (let i = messages.length - 1; i >= 0; i--) {
|
|
140
155
|
const msg = messages[i];
|
|
@@ -147,12 +162,42 @@ function getFinalText(messages) {
|
|
|
147
162
|
}
|
|
148
163
|
return "";
|
|
149
164
|
}
|
|
165
|
+
function getCombinedUsage(messages) {
|
|
166
|
+
const usages = messages
|
|
167
|
+
.filter((message) => message.role === "assistant")
|
|
168
|
+
.map((message) => message.usage)
|
|
169
|
+
.filter((usage) => usage !== undefined);
|
|
170
|
+
if (usages.length === 0)
|
|
171
|
+
return undefined;
|
|
172
|
+
return usages.reduce((total, usage) => ({
|
|
173
|
+
input: total.input + usage.input,
|
|
174
|
+
output: total.output + usage.output,
|
|
175
|
+
cacheRead: total.cacheRead + usage.cacheRead,
|
|
176
|
+
cacheWrite: total.cacheWrite + usage.cacheWrite,
|
|
177
|
+
...(total.cacheWrite1h !== undefined || usage.cacheWrite1h !== undefined
|
|
178
|
+
? { cacheWrite1h: (total.cacheWrite1h ?? 0) + (usage.cacheWrite1h ?? 0) }
|
|
179
|
+
: {}),
|
|
180
|
+
...(total.reasoning !== undefined || usage.reasoning !== undefined
|
|
181
|
+
? { reasoning: (total.reasoning ?? 0) + (usage.reasoning ?? 0) }
|
|
182
|
+
: {}),
|
|
183
|
+
totalTokens: total.totalTokens + usage.totalTokens,
|
|
184
|
+
cost: {
|
|
185
|
+
input: total.cost.input + usage.cost.input,
|
|
186
|
+
output: total.cost.output + usage.cost.output,
|
|
187
|
+
cacheRead: total.cost.cacheRead + usage.cost.cacheRead,
|
|
188
|
+
cacheWrite: total.cost.cacheWrite + usage.cost.cacheWrite,
|
|
189
|
+
total: total.cost.total + usage.cost.total,
|
|
190
|
+
},
|
|
191
|
+
}));
|
|
192
|
+
}
|
|
150
193
|
async function runAgent(cwd, agent, task, signal, step, onProgress) {
|
|
151
194
|
const args = ["--mode", "json", "-p", "--no-session"];
|
|
152
195
|
if (agent.model)
|
|
153
196
|
args.push("--model", agent.model);
|
|
154
197
|
if (agent.tools?.length)
|
|
155
198
|
args.push("--tools", agent.tools.join(","));
|
|
199
|
+
if (agent.disableExtensions)
|
|
200
|
+
args.push("--no-extensions");
|
|
156
201
|
let tmpFile = null;
|
|
157
202
|
let tmpDir = null;
|
|
158
203
|
if (agent.systemPrompt.trim()) {
|
|
@@ -161,16 +206,18 @@ async function runAgent(cwd, agent, task, signal, step, onProgress) {
|
|
|
161
206
|
tmpDir = tmp.dir;
|
|
162
207
|
args.push("--append-system-prompt", tmpFile);
|
|
163
208
|
}
|
|
164
|
-
args.push(`Task: ${task}`);
|
|
165
209
|
const messages = [];
|
|
166
210
|
let stderr = "";
|
|
167
211
|
try {
|
|
168
|
-
const
|
|
212
|
+
const processExitCode = await new Promise((resolve) => {
|
|
213
|
+
let closed = false;
|
|
169
214
|
const proc = spawn(DRAHT_BIN, [...DRAHT_ARGS_PREFIX, ...args], {
|
|
170
215
|
cwd,
|
|
171
216
|
shell: false,
|
|
172
|
-
stdio: ["
|
|
217
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
173
218
|
});
|
|
219
|
+
proc.stdin.on("error", () => { });
|
|
220
|
+
proc.stdin.end(`Task: ${task}`);
|
|
174
221
|
let buf = "";
|
|
175
222
|
const processLine = (line) => {
|
|
176
223
|
if (!line.trim())
|
|
@@ -212,18 +259,19 @@ async function runAgent(cwd, agent, task, signal, step, onProgress) {
|
|
|
212
259
|
stderr += d.toString();
|
|
213
260
|
});
|
|
214
261
|
proc.on("close", (code) => {
|
|
262
|
+
closed = true;
|
|
215
263
|
if (buf.trim())
|
|
216
264
|
processLine(buf);
|
|
217
|
-
resolve(code ??
|
|
265
|
+
resolve(code ?? 1);
|
|
218
266
|
});
|
|
219
267
|
proc.on("error", () => resolve(1));
|
|
220
268
|
if (signal) {
|
|
221
269
|
const kill = () => {
|
|
222
270
|
proc.kill("SIGTERM");
|
|
223
271
|
setTimeout(() => {
|
|
224
|
-
if (!
|
|
272
|
+
if (!closed)
|
|
225
273
|
proc.kill("SIGKILL");
|
|
226
|
-
}, 5000);
|
|
274
|
+
}, 5000).unref();
|
|
227
275
|
};
|
|
228
276
|
if (signal.aborted)
|
|
229
277
|
kill();
|
|
@@ -231,7 +279,17 @@ async function runAgent(cwd, agent, task, signal, step, onProgress) {
|
|
|
231
279
|
signal.addEventListener("abort", kill, { once: true });
|
|
232
280
|
}
|
|
233
281
|
});
|
|
234
|
-
|
|
282
|
+
const finalAssistant = getFinalAssistant(messages);
|
|
283
|
+
const failedResponse = finalAssistant?.stopReason === "error" || finalAssistant?.stopReason === "aborted";
|
|
284
|
+
return {
|
|
285
|
+
agent: agent.name,
|
|
286
|
+
task,
|
|
287
|
+
exitCode: processExitCode === 0 && !failedResponse ? 0 : 1,
|
|
288
|
+
output: getFinalText(messages),
|
|
289
|
+
stderr: stderr || (failedResponse ? (finalAssistant.errorMessage ?? finalAssistant.stopReason) : ""),
|
|
290
|
+
usage: getCombinedUsage(messages),
|
|
291
|
+
step,
|
|
292
|
+
};
|
|
235
293
|
}
|
|
236
294
|
finally {
|
|
237
295
|
if (tmpFile && tmpDir)
|
|
@@ -270,9 +328,11 @@ async function runAgentWithLifecycle(cwd, agent, task, opts) {
|
|
|
270
328
|
fsm.transition("WORKING");
|
|
271
329
|
const effectiveCwd = worktree ? worktreeIsolator.create(cwd, taskId) : cwd;
|
|
272
330
|
const result = await runner(effectiveCwd, agent, task, opts.signal, opts.step, opts.onProgress);
|
|
273
|
-
|
|
331
|
+
// effectiveCwd === cwd means create() fell back to cwd outside a git repo,
|
|
332
|
+
// where merge(taskId) would fabricate a failure for the unknown taskId.
|
|
333
|
+
if (worktree && effectiveCwd !== cwd) {
|
|
274
334
|
if (result.exitCode === 0)
|
|
275
|
-
worktreeIsolator.merge(taskId);
|
|
335
|
+
result.merge = worktreeIsolator.merge(taskId);
|
|
276
336
|
worktreeIsolator.cleanup(taskId);
|
|
277
337
|
}
|
|
278
338
|
fsm.transition("RESPOND");
|
|
@@ -301,16 +361,18 @@ export async function runSingleTask(cwd, agent, task, opts = {}) {
|
|
|
301
361
|
}
|
|
302
362
|
/**
|
|
303
363
|
* Parallel-mode orchestration: every task is posted to the shared TaskBoard
|
|
304
|
-
* up front (with `{ agentType: agent.name }` requirements), then
|
|
305
|
-
*
|
|
306
|
-
*
|
|
364
|
+
* up front (with `{ agentType: agent.name }` requirements), then atomically
|
|
365
|
+
* assigned to its corresponding worker. Direct assignment keeps concurrent
|
|
366
|
+
* orchestration calls from claiming one another's same-role tasks.
|
|
307
367
|
*/
|
|
308
368
|
export async function runParallelTasks(cwd, items, opts = {}) {
|
|
309
369
|
const postedIds = items.map((item) => taskBoard.post({ requirements: { agentType: item.agent.name }, description: item.task }));
|
|
310
370
|
return runParallel(items, MAX_CONCURRENCY, async (item, i) => {
|
|
311
371
|
const workerId = `parallel-${i}-${randomUUID()}`;
|
|
312
|
-
const
|
|
313
|
-
const
|
|
372
|
+
const taskId = postedIds[i];
|
|
373
|
+
const assignment = taskBoard.assign(taskId, workerId);
|
|
374
|
+
if (!assignment.ok)
|
|
375
|
+
throw new Error(assignment.error);
|
|
314
376
|
const result = await runAgentWithLifecycle(cwd, item.agent, item.task, {
|
|
315
377
|
signal: opts.signal,
|
|
316
378
|
onProgress: opts.makeOnProgress?.(item.agent.name),
|
|
@@ -369,6 +431,110 @@ export async function runChainTasks(cwd, steps, opts = {}) {
|
|
|
369
431
|
}
|
|
370
432
|
return results;
|
|
371
433
|
}
|
|
434
|
+
/** Grapheme budget for every attacker-influenced string that travels in a permission ask. */
|
|
435
|
+
const PERMISSION_DETAIL_MAX_GRAPHEMES = 512;
|
|
436
|
+
/**
|
|
437
|
+
* Byte budget for the same strings, stated HERE and not left to the default, because this is the
|
|
438
|
+
* producer whose output has to fit a frame: one grapheme cluster admits unboundedly many combining
|
|
439
|
+
* marks, so 512 clusters of Zalgo weighed 383,246 bytes until this bound existed — accepted by the
|
|
440
|
+
* schema, then refused by the attach bridge, which closed the renderer's socket with 1008.
|
|
441
|
+
*
|
|
442
|
+
* 512 × 4 bytes: four is the widest a single code point is in UTF-8, so every ordinary cluster
|
|
443
|
+
* survives untouched. A `tool_permission` detail carries FIVE such fields — `toolCallId`,
|
|
444
|
+
* `toolName`, `cwd`, `reason`, and exactly one of `command` / `path` / `operation` — so at maximum
|
|
445
|
+
* it is 5 × 2048 = 10,240 bytes of free text plus a fixed option pair and a handful of keys: ~10 KiB
|
|
446
|
+
* against the 64 KiB `maxFrameBytes` a permission frame must fit into, which is never split.
|
|
447
|
+
*/
|
|
448
|
+
const PERMISSION_DETAIL_MAX_BYTES = 512 * 4;
|
|
449
|
+
/**
|
|
450
|
+
* The vocabulary this phase offers for a tool permission ask.
|
|
451
|
+
*
|
|
452
|
+
* Frozen and shared: the same object identity is handed to every surface, so no renderer can
|
|
453
|
+
* quietly widen or reorder it. Each option states its OWN decision — nothing may infer approval
|
|
454
|
+
* from an option's position, id, or the array's length.
|
|
455
|
+
*/
|
|
456
|
+
const TOOL_PERMISSION_OPTIONS = Object.freeze([
|
|
457
|
+
Object.freeze({ id: "approve", label: "Yes", decision: "approve" }),
|
|
458
|
+
Object.freeze({ id: "deny", label: "No", decision: "deny" }),
|
|
459
|
+
]);
|
|
460
|
+
/**
|
|
461
|
+
* Neutralize-and-bound a single wire-bound string — in clusters AND bytes — RECORDING the verdict.
|
|
462
|
+
*
|
|
463
|
+
* `verdict` is a required parameter and not an optional convenience: this function used to return
|
|
464
|
+
* `boundedSafeText(...).value` and nothing else, and every caller silently dropped `.truncated`.
|
|
465
|
+
* Making the accumulator part of the signature is what stops a new field being added tomorrow that
|
|
466
|
+
* elides in silence — there is no way to call this and not answer the question.
|
|
467
|
+
*/
|
|
468
|
+
function safeField(raw, verdict) {
|
|
469
|
+
const bounded = boundedSafeText(raw, PERMISSION_DETAIL_MAX_GRAPHEMES, PERMISSION_DETAIL_MAX_BYTES);
|
|
470
|
+
if (bounded.truncated)
|
|
471
|
+
verdict.truncated = true;
|
|
472
|
+
// `bounded.originalLength` is deliberately NOT carried: `PermissionRequestFrameSchema` in
|
|
473
|
+
// packages/geist-protocol/src/wire.ts has no field for it, so putting it on the detail would
|
|
474
|
+
// produce a number that reaches no wire. The elision marker inside `value` already names the
|
|
475
|
+
// count, which is how a surface recovers the original length today.
|
|
476
|
+
return bounded.value;
|
|
477
|
+
}
|
|
478
|
+
/**
|
|
479
|
+
* Build the canonical detail for a tool permission ask.
|
|
480
|
+
*
|
|
481
|
+
* Neutralization happens HERE, at construction, not at any protocol layer: three renderers
|
|
482
|
+
* (TUI, `draht --attach`, RPC) inherit this object, and the attach client is a bare `JSON.parse`
|
|
483
|
+
* cast that never passes through a schema. Constructing it safe is what makes all three safe.
|
|
484
|
+
*/
|
|
485
|
+
function buildPermissionAskDetail(event, ctx, reason) {
|
|
486
|
+
const input = (event.input ?? {});
|
|
487
|
+
const verdict = { truncated: false };
|
|
488
|
+
const detail = {
|
|
489
|
+
kind: "tool_permission",
|
|
490
|
+
toolCallId: safeField(event.toolCallId, verdict),
|
|
491
|
+
toolName: safeField(event.toolName, verdict),
|
|
492
|
+
// `ctx.cwd` is the raw, un-normalised `config.cwd`; a symlinked worktree would otherwise
|
|
493
|
+
// read as a different project on the answering surface.
|
|
494
|
+
cwd: safeField(comparablePath(ctx.cwd), verdict),
|
|
495
|
+
reason: safeField(reason, verdict),
|
|
496
|
+
options: TOOL_PERMISSION_OPTIONS,
|
|
497
|
+
truncated: false,
|
|
498
|
+
};
|
|
499
|
+
const command = typeof input.command === "string" ? input.command : undefined;
|
|
500
|
+
const filePath = typeof input.file_path === "string" ? input.file_path : undefined;
|
|
501
|
+
const plainPath = typeof input.path === "string" ? input.path : undefined;
|
|
502
|
+
if (command !== undefined) {
|
|
503
|
+
detail.command = safeField(command, verdict);
|
|
504
|
+
}
|
|
505
|
+
else if (filePath !== undefined || plainPath !== undefined) {
|
|
506
|
+
detail.path = safeField((filePath ?? plainPath), verdict);
|
|
507
|
+
}
|
|
508
|
+
else {
|
|
509
|
+
// Every extension tool takes `Record<string, unknown>`, so there is always SOMETHING to
|
|
510
|
+
// show. Serializing the whole argument object beats an empty ask that asks the human to
|
|
511
|
+
// approve an unknown action.
|
|
512
|
+
detail.operation = safeField(serializeToolInput(input), verdict);
|
|
513
|
+
}
|
|
514
|
+
// Set LAST: the command/path/operation branch above is the field most likely to be elided, and
|
|
515
|
+
// it is assigned after the literal. Reading `verdict` any earlier reports on a partial detail.
|
|
516
|
+
detail.truncated = verdict.truncated;
|
|
517
|
+
return detail;
|
|
518
|
+
}
|
|
519
|
+
/** JSON-serialize a tool's argument object, degrading to a readable form rather than throwing. */
|
|
520
|
+
function serializeToolInput(input) {
|
|
521
|
+
try {
|
|
522
|
+
return JSON.stringify(input) ?? String(input);
|
|
523
|
+
}
|
|
524
|
+
catch {
|
|
525
|
+
// Cyclic or otherwise unserializable input must not crash the permission gate.
|
|
526
|
+
return Object.keys(input).join(", ");
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
const PERMISSION_RULES_FILE = "permissions.yml";
|
|
530
|
+
export function loadPermissionRules(projectDir, projectTrusted, globalDir) {
|
|
531
|
+
if (projectTrusted) {
|
|
532
|
+
return loadRules(projectDir, globalDir);
|
|
533
|
+
}
|
|
534
|
+
// Not loadRules(projectDir=undefined): that default is process.cwd(), i.e. the untrusted project itself.
|
|
535
|
+
const globalRulesPath = path.join(globalDir ?? getAgentDir(), PERMISSION_RULES_FILE);
|
|
536
|
+
return fs.existsSync(globalRulesPath) ? parseRules(fs.readFileSync(globalRulesPath, "utf-8")) : [];
|
|
537
|
+
}
|
|
372
538
|
/**
|
|
373
539
|
* Permission-gate hook point: builds a `tool_call` handler that consults a
|
|
374
540
|
* `PermissionGate` before a tool executes. `deny` blocks the call outright;
|
|
@@ -384,11 +550,36 @@ export function createPermissionGateToolCallHandler(gate) {
|
|
|
384
550
|
return { block: true, reason: decision.reason };
|
|
385
551
|
}
|
|
386
552
|
if (decision.action === "approve") {
|
|
553
|
+
// No answering surface at all: keep today's loud, operator-facing block verbatim rather
|
|
554
|
+
// than letting a no-op UI resolve `false` and be recorded as a user's denial.
|
|
387
555
|
if (!ctx.hasUI) {
|
|
388
556
|
return { block: true, reason: `${decision.reason} (no UI available to request approval)` };
|
|
389
557
|
}
|
|
390
|
-
const
|
|
558
|
+
const detail = buildPermissionAskDetail(event, ctx, decision.reason);
|
|
559
|
+
// Both positional strings are unchanged so every existing renderer keeps working; the
|
|
560
|
+
// canonical facts ride alongside them for surfaces that can render structure.
|
|
561
|
+
//
|
|
562
|
+
// `signal` is the turn's OWN abort signal, read live off the context (it is the active
|
|
563
|
+
// run's controller, minted fresh per run, so it is never a stale aborted one). A
|
|
564
|
+
// permission ask that inherits "wait forever" with no way to be dismissed is its own
|
|
565
|
+
// hazard: this ask parks the agent loop inside `beforeToolCall`, and before this the
|
|
566
|
+
// only things that could end it were a human answering and the relay's own backstop
|
|
567
|
+
// clock. Aborting the turn now takes the dialog down on every surface, and — because
|
|
568
|
+
// nobody answered — it is recorded as `cancelled` by the system rather than as this
|
|
569
|
+
// human's refusal.
|
|
570
|
+
const approved = await ctx.ui.confirm("Approve tool call?", `${event.toolName}: ${decision.reason}`, {
|
|
571
|
+
detail,
|
|
572
|
+
signal: ctx.signal,
|
|
573
|
+
});
|
|
391
574
|
if (!approved) {
|
|
575
|
+
// The turn being aborted is NOT a refusal, and saying so in the transcript would put the
|
|
576
|
+
// same fabrication in front of the model that the durable record was just cleared of:
|
|
577
|
+
// the JSONL reads `cancelled` by `system`, so the reason the model sees must not read
|
|
578
|
+
// `User denied approval`. This branch became reachable the moment `signal` started being
|
|
579
|
+
// passed above — before that, an abort could not end an ask at all.
|
|
580
|
+
if (ctx.signal?.aborted) {
|
|
581
|
+
return { block: true, reason: "the turn was aborted before this call was approved" };
|
|
582
|
+
}
|
|
392
583
|
return { block: true, reason: "User denied approval" };
|
|
393
584
|
}
|
|
394
585
|
return undefined;
|
|
@@ -414,11 +605,32 @@ const Params = Type.Object({
|
|
|
414
605
|
worktree: Type.Optional(Type.Boolean({ description: "Opt-in: run each task in an isolated git worktree, merged back on success" })),
|
|
415
606
|
});
|
|
416
607
|
// ─── Rendering helpers ──────────────────────────────────────────────────────
|
|
608
|
+
/**
|
|
609
|
+
* Human-readable recovery notice for a failed worktree merge-back, or
|
|
610
|
+
* `undefined` when no merge was attempted or it succeeded. The branch name,
|
|
611
|
+
* the literal `git merge <branch>` command, and the word "resolve-conflicts"
|
|
612
|
+
* are the contract callers (and tests) rely on.
|
|
613
|
+
*/
|
|
614
|
+
export function describeMergeFailure(result) {
|
|
615
|
+
if (!result.merge || result.merge.success)
|
|
616
|
+
return undefined;
|
|
617
|
+
const branch = result.merge.branch ?? "agent/<taskId>";
|
|
618
|
+
const conflicts = result.merge.conflicts?.length ? ` Conflicting paths: ${result.merge.conflicts.join(", ")}.` : "";
|
|
619
|
+
return (`Worktree merge-back FAILED: the agent's work is committed on the unmerged branch "${branch}" ` +
|
|
620
|
+
`and is NOT in the working tree.${conflicts} To integrate it, run \`git merge ${branch}\`, ` +
|
|
621
|
+
`then invoke the resolve-conflicts skill (/resolve-conflicts) to resolve the conflicts and finish the merge.`);
|
|
622
|
+
}
|
|
417
623
|
function truncateTask(task, maxLen = 120) {
|
|
418
624
|
const oneLine = task.replace(/\n/g, " ").trim();
|
|
419
625
|
return oneLine.length > maxLen ? `${oneLine.slice(0, maxLen)}...` : oneLine;
|
|
420
626
|
}
|
|
421
627
|
export default function (pi) {
|
|
628
|
+
// Autocomplete gets no ctx, so the last trust answer a ctx gave for this cwd stands in; unseen cwds count as untrusted.
|
|
629
|
+
let lastProjectTrust;
|
|
630
|
+
const noteProjectTrust = (ctx) => {
|
|
631
|
+
lastProjectTrust = { cwd: ctx.cwd, trusted: ctx.isProjectTrusted() };
|
|
632
|
+
};
|
|
633
|
+
const rememberedProjectTrust = (cwd) => lastProjectTrust?.cwd === cwd ? lastProjectTrust.trusted : false;
|
|
422
634
|
pi.registerTool({
|
|
423
635
|
name: "subagent",
|
|
424
636
|
label: "Subagent",
|
|
@@ -487,7 +699,8 @@ export default function (pi) {
|
|
|
487
699
|
},
|
|
488
700
|
async execute(_id, params, signal, onUpdate, ctx) {
|
|
489
701
|
const scope = params.agentScope ?? "both";
|
|
490
|
-
|
|
702
|
+
noteProjectTrust(ctx);
|
|
703
|
+
const agents = discoverAgents(ctx.cwd, scope, ctx.isProjectTrusted());
|
|
491
704
|
const available = agents.map((a) => a.name).join(", ") || "none";
|
|
492
705
|
const find = (name) => agents.find((a) => a.name === name);
|
|
493
706
|
const notFound = (name) => ({
|
|
@@ -530,6 +743,10 @@ export default function (pi) {
|
|
|
530
743
|
emitProgress(agentName, `step ${i + 1}/${total}`);
|
|
531
744
|
},
|
|
532
745
|
});
|
|
746
|
+
const mergeNotices = results
|
|
747
|
+
.map(describeMergeFailure)
|
|
748
|
+
.filter((notice) => notice !== undefined);
|
|
749
|
+
const noticeBlock = mergeNotices.length > 0 ? `\n\n${mergeNotices.join("\n\n")}` : "";
|
|
533
750
|
const last = results[results.length - 1];
|
|
534
751
|
if (last.exitCode !== 0) {
|
|
535
752
|
const failedIndex = results.length - 1;
|
|
@@ -537,7 +754,7 @@ export default function (pi) {
|
|
|
537
754
|
content: [
|
|
538
755
|
{
|
|
539
756
|
type: "text",
|
|
540
|
-
text: `Chain failed at step ${failedIndex + 1} (${params.chain[failedIndex].agent}):\n${last.output || last.stderr}`,
|
|
757
|
+
text: `Chain failed at step ${failedIndex + 1} (${params.chain[failedIndex].agent}):\n${last.output || last.stderr}${noticeBlock}`,
|
|
541
758
|
},
|
|
542
759
|
],
|
|
543
760
|
isError: true,
|
|
@@ -545,7 +762,10 @@ export default function (pi) {
|
|
|
545
762
|
};
|
|
546
763
|
}
|
|
547
764
|
return {
|
|
548
|
-
content: [{ type: "text", text: last.output || "(no output)" }],
|
|
765
|
+
content: [{ type: "text", text: `${last.output || "(no output)"}${noticeBlock}` }],
|
|
766
|
+
// A merge-back failure means a step's work did not land in the
|
|
767
|
+
// caller's tree, even though every step's agent succeeded.
|
|
768
|
+
...(mergeNotices.length > 0 ? { isError: true } : {}),
|
|
549
769
|
details: {},
|
|
550
770
|
};
|
|
551
771
|
}
|
|
@@ -572,12 +792,21 @@ export default function (pi) {
|
|
|
572
792
|
worktree,
|
|
573
793
|
makeOnProgress: (agentName) => makeProgressFn(agentName),
|
|
574
794
|
});
|
|
575
|
-
const ok = results.filter((r) => r.exitCode === 0).length;
|
|
795
|
+
const ok = results.filter((r) => r.exitCode === 0 && describeMergeFailure(r) === undefined).length;
|
|
576
796
|
const summary = results
|
|
577
|
-
.map((r) => `[${r.agent}] ${r.exitCode
|
|
797
|
+
.map((r) => `[${r.agent}] ${r.exitCode !== 0 ? "fail" : describeMergeFailure(r) ? "merge-failed" : "ok"} ${r.output.slice(0, 200)}`)
|
|
578
798
|
.join("\n\n");
|
|
799
|
+
const notices = results
|
|
800
|
+
.map(describeMergeFailure)
|
|
801
|
+
.filter((notice) => notice !== undefined);
|
|
802
|
+
const noticeBlock = notices.length > 0 ? `\n\n${notices.join("\n\n")}` : "";
|
|
579
803
|
return {
|
|
580
|
-
content: [
|
|
804
|
+
content: [
|
|
805
|
+
{
|
|
806
|
+
type: "text",
|
|
807
|
+
text: `Parallel: ${ok}/${results.length} succeeded\n\n${summary}${noticeBlock}`,
|
|
808
|
+
},
|
|
809
|
+
],
|
|
581
810
|
details: {},
|
|
582
811
|
};
|
|
583
812
|
}
|
|
@@ -592,9 +821,13 @@ export default function (pi) {
|
|
|
592
821
|
worktree,
|
|
593
822
|
onProgress: makeProgressFn(params.agent),
|
|
594
823
|
});
|
|
595
|
-
const
|
|
824
|
+
const mergeNotice = describeMergeFailure(result);
|
|
825
|
+
// A merge-back failure means the delegated change did NOT land in
|
|
826
|
+
// the caller's tree — a plain success would mislead the orchestrator.
|
|
827
|
+
const isError = result.exitCode !== 0 || mergeNotice !== undefined;
|
|
828
|
+
const baseText = result.output || result.stderr || "(no output)";
|
|
596
829
|
return {
|
|
597
|
-
content: [{ type: "text", text:
|
|
830
|
+
content: [{ type: "text", text: mergeNotice ? `${baseText}\n\n${mergeNotice}` : baseText }],
|
|
598
831
|
...(isError ? { isError: true } : {}),
|
|
599
832
|
details: {},
|
|
600
833
|
};
|
|
@@ -609,8 +842,9 @@ export default function (pi) {
|
|
|
609
842
|
// ── Permission gate hook point ────────────────────────────────────────────
|
|
610
843
|
// Prepares the wiring point for the multi-agent permission gate: every tool
|
|
611
844
|
// call in this process is offered to the gate before it runs. Rules are
|
|
612
|
-
// (re)loaded per call so project-local `.draht/permissions.yml` edits
|
|
613
|
-
// per-session cwd changes take effect
|
|
845
|
+
// (re)loaded per call so project-local `.draht/permissions.yml` edits — read
|
|
846
|
+
// only for a trusted project — and per-session cwd changes take effect
|
|
847
|
+
// without an extension reload.
|
|
614
848
|
//
|
|
615
849
|
// The session permission mode (default/auto/yolo) is session-scoped state,
|
|
616
850
|
// settable via /permissions and /yolo below and seeded from
|
|
@@ -626,7 +860,13 @@ export default function (pi) {
|
|
|
626
860
|
auto: "auto-approve bash unless the command looks dangerous (deny rules still block)",
|
|
627
861
|
yolo: "no approval prompts this session (deny rules still block)",
|
|
628
862
|
};
|
|
629
|
-
pi.on("tool_call", (event, ctx) =>
|
|
863
|
+
pi.on("tool_call", (event, ctx) => {
|
|
864
|
+
noteProjectTrust(ctx);
|
|
865
|
+
return createPermissionGateToolCallHandler(new PermissionGate(loadPermissionRules(ctx.cwd, ctx.isProjectTrusted()), {
|
|
866
|
+
cwd: ctx.cwd,
|
|
867
|
+
mode: permissionMode,
|
|
868
|
+
}))(event, ctx);
|
|
869
|
+
});
|
|
630
870
|
// /permissions command — show or set the session permission mode
|
|
631
871
|
pi.registerCommand("permissions", {
|
|
632
872
|
description: `Show or set the session permission mode. Usage: /permissions [${PERMISSION_MODES.join("|")}]`,
|
|
@@ -665,7 +905,8 @@ export default function (pi) {
|
|
|
665
905
|
pi.registerCommand("agent", {
|
|
666
906
|
description: "Select an agent to handle your next prompts, or clear selection. Usage: /agent [name]",
|
|
667
907
|
handler: async (args, ctx) => {
|
|
668
|
-
|
|
908
|
+
noteProjectTrust(ctx);
|
|
909
|
+
const agents = discoverAgents(ctx.cwd, "both", ctx.isProjectTrusted());
|
|
669
910
|
if (args.trim()) {
|
|
670
911
|
// Direct selection: /agent architect
|
|
671
912
|
const name = args.trim();
|
|
@@ -708,13 +949,15 @@ export default function (pi) {
|
|
|
708
949
|
}
|
|
709
950
|
},
|
|
710
951
|
getArgumentCompletions: (partial) => {
|
|
711
|
-
const
|
|
952
|
+
const cwd = process.cwd();
|
|
953
|
+
const agents = discoverAgents(cwd, "both", rememberedProjectTrust(cwd));
|
|
712
954
|
const names = ["none", ...agents.map((a) => a.name)];
|
|
713
955
|
return names.filter((n) => n.startsWith(partial)).map((n) => ({ value: n, label: n }));
|
|
714
956
|
},
|
|
715
957
|
});
|
|
716
958
|
// Intercept user input when an agent is selected
|
|
717
|
-
pi.on("input", (event) => {
|
|
959
|
+
pi.on("input", (event, ctx) => {
|
|
960
|
+
noteProjectTrust(ctx);
|
|
718
961
|
if (!selectedAgent)
|
|
719
962
|
return { action: "continue" };
|
|
720
963
|
// Don't intercept slash commands
|