@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
package/docs/extensions.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
>
|
|
1
|
+
> draht can create extensions. Ask it to build one for your use case.
|
|
2
2
|
|
|
3
3
|
# Extensions
|
|
4
4
|
|
|
5
|
-
Extensions are TypeScript modules that extend
|
|
5
|
+
Extensions are TypeScript modules that extend draht's behavior. They can subscribe to lifecycle events, register custom tools callable by the LLM, add commands, and more.
|
|
6
6
|
|
|
7
|
-
> **Placement for /reload:** Put extensions in `~/.
|
|
7
|
+
> **Placement for /reload:** Put extensions in `~/.draht/agent/extensions/` (global) or `.draht/extensions/` (project-local) for auto-discovery. Use `draht -e ./path.ts` only for quick tests. Extensions in auto-discovered locations can be hot-reloaded with `/reload`.
|
|
8
8
|
|
|
9
9
|
**Key capabilities:**
|
|
10
10
|
- **Custom tools** - Register tools the LLM can call via `pi.registerTool()`
|
|
@@ -47,6 +47,7 @@ See [examples/extensions/](../examples/extensions/) for working implementations.
|
|
|
47
47
|
- [ExtensionAPI Methods](#extensionapi-methods)
|
|
48
48
|
- [State Management](#state-management)
|
|
49
49
|
- [Custom Tools](#custom-tools)
|
|
50
|
+
- [Dynamic Tool Loading](#dynamic-tool-loading)
|
|
50
51
|
- [Custom UI](#custom-ui)
|
|
51
52
|
- [Error Handling](#error-handling)
|
|
52
53
|
- [Mode Behavior](#mode-behavior)
|
|
@@ -54,7 +55,7 @@ See [examples/extensions/](../examples/extensions/) for working implementations.
|
|
|
54
55
|
|
|
55
56
|
## Quick Start
|
|
56
57
|
|
|
57
|
-
Create `~/.
|
|
58
|
+
Create `~/.draht/agent/extensions/my-extension.ts`:
|
|
58
59
|
|
|
59
60
|
```typescript
|
|
60
61
|
import type { ExtensionAPI } from "@draht/coding-agent";
|
|
@@ -102,21 +103,21 @@ export default function (pi: ExtensionAPI) {
|
|
|
102
103
|
Test with `--extension` (or `-e`) flag:
|
|
103
104
|
|
|
104
105
|
```bash
|
|
105
|
-
|
|
106
|
+
draht -e ./my-extension.ts
|
|
106
107
|
```
|
|
107
108
|
|
|
108
109
|
## Extension Locations
|
|
109
110
|
|
|
110
111
|
> **Security:** Extensions run with your full system permissions and can execute arbitrary code. Only install from sources you trust.
|
|
111
112
|
|
|
112
|
-
Extensions are auto-discovered from trusted locations. Project-local `.
|
|
113
|
+
Extensions are auto-discovered from trusted locations. Project-local `.draht/extensions` entries load only after the project is trusted.
|
|
113
114
|
|
|
114
115
|
| Location | Scope |
|
|
115
116
|
|----------|-------|
|
|
116
|
-
| `~/.
|
|
117
|
-
| `~/.
|
|
118
|
-
| `.
|
|
119
|
-
| `.
|
|
117
|
+
| `~/.draht/agent/extensions/*.ts` | Global (all projects) |
|
|
118
|
+
| `~/.draht/agent/extensions/*/index.ts` | Global (subdirectory) |
|
|
119
|
+
| `.draht/extensions/*.ts` | Project-local |
|
|
120
|
+
| `.draht/extensions/*/index.ts` | Project-local (subdirectory) |
|
|
120
121
|
|
|
121
122
|
Additional paths via `settings.json`:
|
|
122
123
|
|
|
@@ -133,7 +134,7 @@ Additional paths via `settings.json`:
|
|
|
133
134
|
}
|
|
134
135
|
```
|
|
135
136
|
|
|
136
|
-
To share extensions via npm or git as
|
|
137
|
+
To share extensions via npm or git as draht packages, see [packages.md](packages.md).
|
|
137
138
|
|
|
138
139
|
## Available Imports
|
|
139
140
|
|
|
@@ -146,7 +147,7 @@ To share extensions via npm or git as pi packages, see [packages.md](packages.md
|
|
|
146
147
|
|
|
147
148
|
npm dependencies work too. Add a `package.json` next to your extension (or in a parent directory), run `npm install`, and imports from `node_modules/` are resolved automatically.
|
|
148
149
|
|
|
149
|
-
For distributed
|
|
150
|
+
For distributed draht packages installed with `draht install` (npm or git), runtime deps must be in `dependencies`. Package installation uses production installs (`npm install --omit=dev`) by default, so `devDependencies` are not available at runtime; when `npmCommand` is configured, git packages use plain `install` for compatibility with wrappers.
|
|
150
151
|
|
|
151
152
|
Node.js built-ins (`node:fs`, `node:path`, etc.) are also available.
|
|
152
153
|
|
|
@@ -177,7 +178,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
177
178
|
|
|
178
179
|
Extensions are loaded via [jiti](https://github.com/unjs/jiti), so TypeScript works without compilation.
|
|
179
180
|
|
|
180
|
-
If the factory returns a `Promise`,
|
|
181
|
+
If the factory returns a `Promise`, draht awaits it before continuing startup. That means async initialization completes before `session_start`, before `resources_discover`, and before provider registrations queued via `pi.registerProvider()` are flushed.
|
|
181
182
|
|
|
182
183
|
### Async factory functions
|
|
183
184
|
|
|
@@ -214,21 +215,21 @@ export default async function (pi: ExtensionAPI) {
|
|
|
214
215
|
}
|
|
215
216
|
```
|
|
216
217
|
|
|
217
|
-
This pattern makes the fetched models available during normal startup and to `
|
|
218
|
+
This pattern makes the fetched models available during normal startup and to `draht --list-models`.
|
|
218
219
|
|
|
219
220
|
### Extension Styles
|
|
220
221
|
|
|
221
222
|
**Single file** - simplest, for small extensions:
|
|
222
223
|
|
|
223
224
|
```
|
|
224
|
-
~/.
|
|
225
|
+
~/.draht/agent/extensions/
|
|
225
226
|
└── my-extension.ts
|
|
226
227
|
```
|
|
227
228
|
|
|
228
229
|
**Directory with index.ts** - for multi-file extensions:
|
|
229
230
|
|
|
230
231
|
```
|
|
231
|
-
~/.
|
|
232
|
+
~/.draht/agent/extensions/
|
|
232
233
|
└── my-extension/
|
|
233
234
|
├── index.ts # Entry point (exports default function)
|
|
234
235
|
├── tools.ts # Helper module
|
|
@@ -238,7 +239,7 @@ This pattern makes the fetched models available during normal startup and to `pi
|
|
|
238
239
|
**Package with dependencies** - for extensions that need npm packages:
|
|
239
240
|
|
|
240
241
|
```
|
|
241
|
-
~/.
|
|
242
|
+
~/.draht/agent/extensions/
|
|
242
243
|
└── my-extension/
|
|
243
244
|
├── package.json # Declares dependencies and entry points
|
|
244
245
|
├── package-lock.json
|
|
@@ -255,12 +256,14 @@ This pattern makes the fetched models available during normal startup and to `pi
|
|
|
255
256
|
"zod": "^3.0.0",
|
|
256
257
|
"chalk": "^5.0.0"
|
|
257
258
|
},
|
|
258
|
-
"
|
|
259
|
+
"draht": {
|
|
259
260
|
"extensions": ["./src/index.ts"]
|
|
260
261
|
}
|
|
261
262
|
}
|
|
262
263
|
```
|
|
263
264
|
|
|
265
|
+
The manifest key is `draht`. Upstream's `pi` key is still read as a fallback, so extension packages written for pi work unchanged.
|
|
266
|
+
|
|
264
267
|
Run `npm install` in the extension directory, then imports from `node_modules/` work automatically.
|
|
265
268
|
|
|
266
269
|
## Events
|
|
@@ -268,7 +271,7 @@ Run `npm install` in the extension directory, then imports from `node_modules/`
|
|
|
268
271
|
### Lifecycle Overview
|
|
269
272
|
|
|
270
273
|
```
|
|
271
|
-
|
|
274
|
+
draht starts
|
|
272
275
|
│
|
|
273
276
|
├─► project_trust (user/global and CLI extensions only, before project resources load)
|
|
274
277
|
├─► session_start { reason: "startup" }
|
|
@@ -343,7 +346,7 @@ exit (Ctrl+C, Ctrl+D, SIGHUP, SIGTERM)
|
|
|
343
346
|
|
|
344
347
|
#### project_trust
|
|
345
348
|
|
|
346
|
-
Fired before
|
|
349
|
+
Fired before draht decides whether to trust a project with dynamic configs (`.draht` or `.agents/skills`). It runs during startup and when session replacement (for example `/resume`) enters a cwd whose trust has not been resolved in the current process. Only user/global extensions and CLI `-e` extensions participate; project-local extensions are not loaded until after trust is resolved.
|
|
347
350
|
|
|
348
351
|
```typescript
|
|
349
352
|
pi.on("project_trust", async (event, ctx) => {
|
|
@@ -356,7 +359,7 @@ pi.on("project_trust", async (event, ctx) => {
|
|
|
356
359
|
});
|
|
357
360
|
```
|
|
358
361
|
|
|
359
|
-
A `project_trust` handler must return `{ trusted: "yes" | "no" | "undecided" }`. A user/global or CLI extension that returns `"yes"` or `"no"` owns the decision; the first yes/no decision wins and suppresses the built-in trust prompt. Use `remember: true` to persist a yes/no decision; otherwise it applies only to the current process. Return `"undecided"` to let later handlers or the built-in trust flow decide. Check `ctx.hasUI` before prompting. If no handler returns yes/no, normal trust resolution continues: saved `trust.json` decisions apply first, then `defaultProjectTrust` controls whether
|
|
362
|
+
A `project_trust` handler must return `{ trusted: "yes" | "no" | "undecided" }`. A user/global or CLI extension that returns `"yes"` or `"no"` owns the decision; the first yes/no decision wins and suppresses the built-in trust prompt. Use `remember: true` to persist a yes/no decision; otherwise it applies only to the current process. Return `"undecided"` to let later handlers or the built-in trust flow decide. Check `ctx.hasUI` before prompting. If no handler returns yes/no, normal trust resolution continues: saved `trust.json` decisions apply first, then `defaultProjectTrust` controls whether draht asks, trusts, or declines by default.
|
|
360
363
|
|
|
361
364
|
### Resource Events
|
|
362
365
|
|
|
@@ -420,7 +423,7 @@ pi.on("session_before_switch", async (event, ctx) => {
|
|
|
420
423
|
});
|
|
421
424
|
```
|
|
422
425
|
|
|
423
|
-
After a successful switch or new-session action,
|
|
426
|
+
After a successful switch or new-session action, draht emits `session_shutdown` for the old extension instance, reloads and rebinds extensions for the new session, then emits `session_start` with `reason: "new" | "resume"` and `previousSessionFile`.
|
|
424
427
|
Do cleanup work in `session_shutdown`, then reestablish any in-memory state in `session_start`.
|
|
425
428
|
|
|
426
429
|
#### session_before_fork
|
|
@@ -437,7 +440,7 @@ pi.on("session_before_fork", async (event, ctx) => {
|
|
|
437
440
|
});
|
|
438
441
|
```
|
|
439
442
|
|
|
440
|
-
After a successful fork or clone,
|
|
443
|
+
After a successful fork or clone, draht emits `session_shutdown` for the old extension instance, reloads and rebinds extensions for the new session, then emits `session_start` with `reason: "fork"` and `previousSessionFile`.
|
|
441
444
|
Do cleanup work in `session_shutdown`, then reestablish any in-memory state in `session_start`.
|
|
442
445
|
|
|
443
446
|
#### session_before_compact / session_compact
|
|
@@ -457,6 +460,7 @@ pi.on("session_before_compact", async (event, ctx) => {
|
|
|
457
460
|
summary: "...",
|
|
458
461
|
firstKeptEntryId: preparation.firstKeptEntryId,
|
|
459
462
|
tokensBefore: preparation.tokensBefore,
|
|
463
|
+
// usage: summaryResponse.usage, // Optional; included in session totals
|
|
460
464
|
}
|
|
461
465
|
};
|
|
462
466
|
});
|
|
@@ -476,7 +480,13 @@ pi.on("session_before_tree", async (event, ctx) => {
|
|
|
476
480
|
const { preparation, signal } = event;
|
|
477
481
|
return { cancel: true };
|
|
478
482
|
// OR provide custom summary:
|
|
479
|
-
return {
|
|
483
|
+
return {
|
|
484
|
+
summary: {
|
|
485
|
+
summary: "...",
|
|
486
|
+
// usage: summaryResponse.usage, // Optional; included in session totals
|
|
487
|
+
details: {},
|
|
488
|
+
},
|
|
489
|
+
};
|
|
480
490
|
});
|
|
481
491
|
|
|
482
492
|
pi.on("session_tree", async (event, ctx) => {
|
|
@@ -531,13 +541,13 @@ pi.on("before_agent_start", async (event, ctx) => {
|
|
|
531
541
|
});
|
|
532
542
|
```
|
|
533
543
|
|
|
534
|
-
The `systemPromptOptions` field gives extensions access to the same structured data
|
|
544
|
+
The `systemPromptOptions` field gives extensions access to the same structured data draht uses to build the system prompt. This lets you inspect what draht has loaded — custom prompts, guidelines, tool snippets, context files, skills — without re-discovering resources or re-parsing flags. Use it when your extension needs to make deep, informed changes to the system prompt while respecting user-provided configuration.
|
|
535
545
|
|
|
536
546
|
Inside `before_agent_start`, `event.systemPrompt` and `ctx.getSystemPrompt()` both reflect the chained system prompt as of the current handler. Later `before_agent_start` handlers can still modify it again.
|
|
537
547
|
|
|
538
548
|
#### agent_start / agent_end / agent_settled
|
|
539
549
|
|
|
540
|
-
`agent_start` fires when a low-level agent run begins. `agent_end` fires when that run ends, but
|
|
550
|
+
`agent_start` fires when a low-level agent run begins. `agent_end` fires when that run ends, but draht may still auto-retry, auto-compact and retry, or continue with queued follow-up messages. Use `agent_settled` for status integrations that need to know draht will not continue running automatically.
|
|
541
551
|
|
|
542
552
|
```typescript
|
|
543
553
|
pi.on("agent_start", async (_event, ctx) => {});
|
|
@@ -641,7 +651,7 @@ pi.on("context", async (event, ctx) => {
|
|
|
641
651
|
|
|
642
652
|
Fired after the provider-specific payload is built, right before the request is sent. Handlers run in extension load order. Returning `undefined` keeps the payload unchanged. Returning any other value replaces the payload for later handlers and for the actual request.
|
|
643
653
|
|
|
644
|
-
This hook can rewrite provider-level system instructions or remove them entirely. Those payload-level changes are not reflected by `ctx.getSystemPrompt()`, which reports
|
|
654
|
+
This hook can rewrite provider-level system instructions or remove them entirely. Those payload-level changes are not reflected by `ctx.getSystemPrompt()`, which reports draht's system prompt string rather than the final serialized provider payload.
|
|
645
655
|
|
|
646
656
|
```typescript
|
|
647
657
|
pi.on("before_provider_request", (event, ctx) => {
|
|
@@ -714,7 +724,7 @@ Use this to update extension UI when `pi.setThinkingLevel()`, model changes, or
|
|
|
714
724
|
|
|
715
725
|
Fired after `tool_execution_start`, before the tool executes. **Can block.** Use `isToolCallEventType` to narrow and get typed inputs.
|
|
716
726
|
|
|
717
|
-
Before `tool_call` runs,
|
|
727
|
+
Before `tool_call` runs, draht waits for previously emitted Agent events to finish draining through `AgentSession`. This means `ctx.sessionManager` is up to date through the current assistant tool-calling message.
|
|
718
728
|
|
|
719
729
|
In the default parallel tool execution mode, sibling tool calls from the same assistant message are preflighted sequentially, then executed concurrently. `tool_call` is not guaranteed to see sibling tool results from that same assistant message in `ctx.sessionManager`.
|
|
720
730
|
|
|
@@ -782,7 +792,7 @@ In parallel tool mode, `tool_result` and `tool_execution_end` may interleave in
|
|
|
782
792
|
`tool_result` handlers chain like middleware:
|
|
783
793
|
- Handlers run in extension load order
|
|
784
794
|
- Each handler sees the latest result after previous handler changes
|
|
785
|
-
- Handlers can return partial patches (`content`, `details`, or `
|
|
795
|
+
- Handlers can return partial patches (`content`, `details`, `isError`, or `usage`); omitted fields keep their current values
|
|
786
796
|
|
|
787
797
|
Use `ctx.signal` for nested async work inside the handler. This lets Esc cancel model calls, `fetch()`, and other abort-aware operations started by the extension.
|
|
788
798
|
|
|
@@ -791,7 +801,7 @@ import { isBashToolResult } from "@draht/coding-agent";
|
|
|
791
801
|
|
|
792
802
|
pi.on("tool_result", async (event, ctx) => {
|
|
793
803
|
// event.toolName, event.toolCallId, event.input
|
|
794
|
-
// event.content, event.details, event.isError
|
|
804
|
+
// event.content, event.details, event.isError, event.usage
|
|
795
805
|
|
|
796
806
|
if (isBashToolResult(event)) {
|
|
797
807
|
// event.details is typed as BashToolDetails
|
|
@@ -804,7 +814,7 @@ pi.on("tool_result", async (event, ctx) => {
|
|
|
804
814
|
});
|
|
805
815
|
|
|
806
816
|
// Modify result:
|
|
807
|
-
return { content: [...], details: {...}, isError: false };
|
|
817
|
+
return { content: [...], details: {...}, isError: false, usage: nestedModelUsage };
|
|
808
818
|
});
|
|
809
819
|
```
|
|
810
820
|
|
|
@@ -825,7 +835,7 @@ pi.on("user_bash", (event, ctx) => {
|
|
|
825
835
|
// Option 1: Provide custom operations (e.g., SSH)
|
|
826
836
|
return { operations: remoteBashOps };
|
|
827
837
|
|
|
828
|
-
// Option 2: Wrap
|
|
838
|
+
// Option 2: Wrap draht's built-in local bash backend
|
|
829
839
|
const local = createLocalBashOperations();
|
|
830
840
|
return {
|
|
831
841
|
operations: {
|
|
@@ -930,9 +940,11 @@ ctx.sessionManager.buildContextEntries() // Active branch entries with compac
|
|
|
930
940
|
ctx.sessionManager.getLeafId() // Current leaf entry ID
|
|
931
941
|
```
|
|
932
942
|
|
|
933
|
-
### ctx.modelRegistry / ctx.model
|
|
943
|
+
### ctx.modelRegistry / ctx.model / ctx.thinkingLevel / ctx.scopedModels
|
|
934
944
|
|
|
935
|
-
Access to models and API
|
|
945
|
+
Access to models, providers, and resolved authentication. `ctx.modelRegistry.getProvider(id)` returns the effective @draht/ai provider, while `getProviderAuth(id)` resolves its current API key, headers, base URL, and provider-scoped environment without requiring a loaded model. `ctx.model` is the active model, and `ctx.thinkingLevel` is its current effective thinking level.
|
|
946
|
+
|
|
947
|
+
`ctx.scopedModels` is the read-only list of models scoped to the current session — the same set the `/scoped-models` command shows. It is resolved at session start from the `--models` CLI flag and the `enabledModels` setting (matched against the available catalogue with minimatch on `provider/modelId` or a bare `modelId`). It is empty when no scoping is configured, meaning every available model is usable. Each entry is `{ model, thinkingLevel? }`, where `thinkingLevel` is set only when a pattern pinned it (e.g. `anthropic/*:high`). Use it to populate a model picker that mirrors the built-in one instead of enumerating the whole catalogue via `ctx.modelRegistry.getAvailable()`.
|
|
936
948
|
|
|
937
949
|
### ctx.signal
|
|
938
950
|
|
|
@@ -944,7 +956,7 @@ Use this for abort-aware nested work started by extension handlers, for example:
|
|
|
944
956
|
- file or process helpers that accept `AbortSignal`
|
|
945
957
|
|
|
946
958
|
`ctx.signal` is typically defined during active turn events such as `tool_call`, `tool_result`, `message_update`, and `turn_end`.
|
|
947
|
-
It is usually `undefined` in idle or non-turn contexts such as session events, extension commands, and shortcuts fired while
|
|
959
|
+
It is usually `undefined` in idle or non-turn contexts such as session events, extension commands, and shortcuts fired while draht is idle.
|
|
948
960
|
|
|
949
961
|
```typescript
|
|
950
962
|
pi.on("tool_result", async (event, ctx) => {
|
|
@@ -961,11 +973,11 @@ pi.on("tool_result", async (event, ctx) => {
|
|
|
961
973
|
|
|
962
974
|
### ctx.isIdle() / ctx.abort() / ctx.hasPendingMessages()
|
|
963
975
|
|
|
964
|
-
Control flow helpers. `ctx.isIdle()` is false while
|
|
976
|
+
Control flow helpers. `ctx.isIdle()` is false while draht is processing an agent run, automatic retry, auto-compaction retry, or queued continuation.
|
|
965
977
|
|
|
966
978
|
### ctx.shutdown()
|
|
967
979
|
|
|
968
|
-
Request a graceful shutdown of
|
|
980
|
+
Request a graceful shutdown of draht.
|
|
969
981
|
|
|
970
982
|
- **Interactive mode:** Deferred until the agent becomes idle (after processing all queued steering and follow-up messages).
|
|
971
983
|
- **RPC mode:** Deferred until the next idle state (after completing the current command response, when waiting for the next command).
|
|
@@ -1010,7 +1022,7 @@ ctx.compact({
|
|
|
1010
1022
|
|
|
1011
1023
|
### ctx.getSystemPrompt()
|
|
1012
1024
|
|
|
1013
|
-
Returns
|
|
1025
|
+
Returns draht's current system prompt string.
|
|
1014
1026
|
|
|
1015
1027
|
- During `before_agent_start`, this reflects chained system-prompt changes made so far for the current turn.
|
|
1016
1028
|
- It does not include later `context` message mutations.
|
|
@@ -1030,7 +1042,7 @@ Command handlers receive `ExtensionCommandContext`, which extends `ExtensionCont
|
|
|
1030
1042
|
|
|
1031
1043
|
### ctx.getSystemPromptOptions()
|
|
1032
1044
|
|
|
1033
|
-
Returns the base inputs
|
|
1045
|
+
Returns the base inputs draht currently uses to build the system prompt.
|
|
1034
1046
|
|
|
1035
1047
|
```typescript
|
|
1036
1048
|
const options = ctx.getSystemPromptOptions();
|
|
@@ -1440,7 +1452,7 @@ Labels persist in the session and survive restarts. Use them to mark important p
|
|
|
1440
1452
|
|
|
1441
1453
|
Register a command.
|
|
1442
1454
|
|
|
1443
|
-
If multiple extensions register the same command name,
|
|
1455
|
+
If multiple extensions register the same command name, draht keeps them all and assigns numeric invocation suffixes in load order, for example `/review:1` and `/review:2`.
|
|
1444
1456
|
|
|
1445
1457
|
```typescript
|
|
1446
1458
|
pi.registerCommand("stats", {
|
|
@@ -1594,9 +1606,9 @@ Typical `sourceInfo.source` values:
|
|
|
1594
1606
|
- `sdk` for tools passed via `createAgentSession({ customTools })`
|
|
1595
1607
|
- extension source metadata for tools registered by extensions
|
|
1596
1608
|
|
|
1597
|
-
### pi.setModel(model)
|
|
1609
|
+
### pi.setModel(model, options?)
|
|
1598
1610
|
|
|
1599
|
-
Set the current model. Returns `false` if no API key is available for the model. See [models.md](models.md) for configuring custom models.
|
|
1611
|
+
Set the current model. Returns `false` if no API key is available for the model. See [models.md](models.md) for configuring custom models. Pass `{ persistDefault: false }` for session-scoped orchestration that must not replace the user's global default model.
|
|
1600
1612
|
|
|
1601
1613
|
```typescript
|
|
1602
1614
|
const model = ctx.modelRegistry.find("anthropic", "claude-sonnet-4-5");
|
|
@@ -1608,9 +1620,9 @@ if (model) {
|
|
|
1608
1620
|
}
|
|
1609
1621
|
```
|
|
1610
1622
|
|
|
1611
|
-
### pi.getThinkingLevel() / pi.setThinkingLevel(level)
|
|
1623
|
+
### pi.getThinkingLevel() / pi.setThinkingLevel(level, options?)
|
|
1612
1624
|
|
|
1613
|
-
Get or set the thinking level. Level is clamped to model capabilities (non-reasoning models always use "off"). Changes emit `thinking_level_select`.
|
|
1625
|
+
Get or set the thinking level. Level is clamped to model capabilities (non-reasoning models always use "off"). Changes emit `thinking_level_select`. Pass `{ persistDefault: false }` when the change should remain session-scoped.
|
|
1614
1626
|
|
|
1615
1627
|
```typescript
|
|
1616
1628
|
const current = pi.getThinkingLevel(); // "off" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max"
|
|
@@ -1632,9 +1644,39 @@ Register or override a model provider dynamically. Useful for proxies, custom en
|
|
|
1632
1644
|
|
|
1633
1645
|
Calls made during the extension factory function are queued and applied once the runner initialises. Calls made after that — for example from a command handler following a user setup flow — take effect immediately without requiring a `/reload`.
|
|
1634
1646
|
|
|
1635
|
-
|
|
1647
|
+
Dynamic providers can implement `refreshModels`. draht calls it during model refresh, publishes the returned list synchronously through the provider, and passes the canonical credential/store/network/signal context. The extension decides whether to persist the catalog through `context.store`; live servers such as llama.cpp can ignore it.
|
|
1648
|
+
|
|
1649
|
+
Extensions that need native provider auth, filtering, refresh, or stream behavior can register a complete `Provider` from `@draht/ai`. The provider becomes the composition base and `models.json` overrides still apply above it.
|
|
1636
1650
|
|
|
1637
1651
|
```typescript
|
|
1652
|
+
import { createProvider, openAICompletionsApi } from "@draht/ai";
|
|
1653
|
+
|
|
1654
|
+
const provider = createProvider({
|
|
1655
|
+
id: "local-server",
|
|
1656
|
+
name: "Local Server",
|
|
1657
|
+
baseUrl: "http://localhost:8080/v1",
|
|
1658
|
+
auth: {
|
|
1659
|
+
apiKey: {
|
|
1660
|
+
name: "Local server setup",
|
|
1661
|
+
async login(interaction) {
|
|
1662
|
+
return {
|
|
1663
|
+
type: "api_key",
|
|
1664
|
+
key: await interaction.prompt({ type: "secret", message: "API key" }),
|
|
1665
|
+
};
|
|
1666
|
+
},
|
|
1667
|
+
async resolve({ credential }) {
|
|
1668
|
+
return credential?.key
|
|
1669
|
+
? { auth: { apiKey: credential.key }, source: "stored API key" }
|
|
1670
|
+
: undefined;
|
|
1671
|
+
},
|
|
1672
|
+
},
|
|
1673
|
+
},
|
|
1674
|
+
models: [],
|
|
1675
|
+
api: openAICompletionsApi(),
|
|
1676
|
+
});
|
|
1677
|
+
|
|
1678
|
+
pi.registerProvider(provider);
|
|
1679
|
+
|
|
1638
1680
|
// Register a new provider with custom models
|
|
1639
1681
|
pi.registerProvider("my-proxy", {
|
|
1640
1682
|
name: "My Proxy",
|
|
@@ -1654,6 +1696,26 @@ pi.registerProvider("my-proxy", {
|
|
|
1654
1696
|
]
|
|
1655
1697
|
});
|
|
1656
1698
|
|
|
1699
|
+
// Register a live llama.cpp catalog without persisting discovered models
|
|
1700
|
+
pi.registerProvider("llama.cpp", {
|
|
1701
|
+
baseUrl: "http://localhost:8080/v1",
|
|
1702
|
+
apiKey: "local",
|
|
1703
|
+
api: "openai-completions",
|
|
1704
|
+
async refreshModels({ signal }) {
|
|
1705
|
+
const response = await fetch("http://localhost:8080/v1/models", { signal });
|
|
1706
|
+
const { data } = await response.json();
|
|
1707
|
+
return data.map(({ id }) => ({
|
|
1708
|
+
id,
|
|
1709
|
+
name: id,
|
|
1710
|
+
reasoning: false,
|
|
1711
|
+
input: ["text"],
|
|
1712
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
1713
|
+
contextWindow: 128000,
|
|
1714
|
+
maxTokens: 16384
|
|
1715
|
+
}));
|
|
1716
|
+
}
|
|
1717
|
+
});
|
|
1718
|
+
|
|
1657
1719
|
// Override baseUrl for an existing provider (keeps all models)
|
|
1658
1720
|
pi.registerProvider("anthropic", {
|
|
1659
1721
|
baseUrl: "https://proxy.example.com"
|
|
@@ -1683,7 +1745,9 @@ pi.registerProvider("corporate-ai", {
|
|
|
1683
1745
|
});
|
|
1684
1746
|
```
|
|
1685
1747
|
|
|
1686
|
-
|
|
1748
|
+
The object form accepts a complete `@draht/ai` `Provider`, including native `auth`, `getModels`, `refreshModels`, `filterModels`, `stream`, and `streamSimple` behavior.
|
|
1749
|
+
|
|
1750
|
+
**Legacy config options:**
|
|
1687
1751
|
- `name` - Display name for the provider in UI such as `/login`.
|
|
1688
1752
|
- `baseUrl` - API endpoint URL. Required when defining models.
|
|
1689
1753
|
- `apiKey` - API key literal, environment interpolation (`$ENV_VAR` or `${ENV_VAR}`), or leading `!command`. Required when defining models (unless `oauth` provided). `$$` escapes `$`, and `$!` escapes a literal `!` without triggering command execution.
|
|
@@ -1691,6 +1755,7 @@ pi.registerProvider("corporate-ai", {
|
|
|
1691
1755
|
- `headers` - Custom headers to include in requests.
|
|
1692
1756
|
- `authHeader` - If true, adds `Authorization: Bearer` header automatically.
|
|
1693
1757
|
- `models` - Array of model definitions. If provided, replaces all existing models for this provider. Model definitions can set `baseUrl` to override the provider endpoint for that model.
|
|
1758
|
+
- `refreshModels` - Async dynamic discovery callback. Its returned models replace extension-provided models. Use the scoped `context.store` only when results should persist.
|
|
1694
1759
|
- `oauth` - OAuth provider config for `/login` support. When provided, the provider appears in the login menu.
|
|
1695
1760
|
- `streamSimple` - Custom streaming implementation for non-standard APIs.
|
|
1696
1761
|
|
|
@@ -1834,6 +1899,7 @@ pi.registerTool({
|
|
|
1834
1899
|
return {
|
|
1835
1900
|
content: [{ type: "text", text: "Done" }], // Sent to LLM
|
|
1836
1901
|
details: { data: result }, // For rendering & state
|
|
1902
|
+
// usage: nestedModelResponse.usage, // Optional nested LLM usage
|
|
1837
1903
|
// Optional: stop after this tool batch when every finalized tool result
|
|
1838
1904
|
// in the batch also returns terminate: true.
|
|
1839
1905
|
terminate: true,
|
|
@@ -1846,6 +1912,8 @@ pi.registerTool({
|
|
|
1846
1912
|
});
|
|
1847
1913
|
```
|
|
1848
1914
|
|
|
1915
|
+
**Usage accounting:** If a tool makes nested LLM calls, return their combined `Usage` as `usage`. draht persists it on the tool result and includes it in footer, `/session`, and RPC session totals. `tool_result` handlers can inspect or replace this value.
|
|
1916
|
+
|
|
1849
1917
|
**Signaling errors:** To mark a tool execution as failed (sets `isError: true` on the result and reports it to the LLM), throw an error from `execute`. Returning a value never sets the error flag regardless of what properties you include in the return object.
|
|
1850
1918
|
|
|
1851
1919
|
**Early termination:** Return `terminate: true` from `execute()` to hint that the automatic follow-up LLM call should be skipped after the current tool batch. This only takes effect when every finalized tool result in that batch is terminating. See [examples/extensions/structured-output.ts](../examples/extensions/structured-output.ts) for a minimal example where the agent ends on a final structured-output tool call.
|
|
@@ -1862,7 +1930,7 @@ async execute(toolCallId, params) {
|
|
|
1862
1930
|
|
|
1863
1931
|
**Important:** Use `StringEnum` from `@draht/ai` for string enums. `Type.Union`/`Type.Literal` doesn't work with Google's API.
|
|
1864
1932
|
|
|
1865
|
-
**Argument preparation:** `prepareArguments(args)` is optional. If defined, it runs before schema validation and before `execute()`. Use it to mimic an older accepted input shape when
|
|
1933
|
+
**Argument preparation:** `prepareArguments(args)` is optional. If defined, it runs before schema validation and before `execute()`. Use it to mimic an older accepted input shape when draht resumes an older session whose stored tool call arguments no longer match the current schema. Return the object you want validated against `parameters`. Keep the public schema strict. Do not add deprecated compatibility fields to `parameters` just to keep old resumed sessions working.
|
|
1866
1934
|
|
|
1867
1935
|
Example: an older session may contain an `edit` tool call with top-level `oldText` and `newText`, while the current schema only accepts `edits: [{ oldText, newText }]`.
|
|
1868
1936
|
|
|
@@ -1915,13 +1983,13 @@ Extensions can override built-in tools (`read`, `bash`, `edit`, `write`, `grep`,
|
|
|
1915
1983
|
|
|
1916
1984
|
```bash
|
|
1917
1985
|
# Extension's read tool replaces built-in read
|
|
1918
|
-
|
|
1986
|
+
draht -e ./tool-override.ts
|
|
1919
1987
|
```
|
|
1920
1988
|
|
|
1921
1989
|
Alternatively, use `--no-builtin-tools` to start without any built-in tools while keeping extension tools enabled:
|
|
1922
1990
|
```bash
|
|
1923
1991
|
# No built-in tools, only extension tools
|
|
1924
|
-
|
|
1992
|
+
draht --no-builtin-tools -e ./my-extension.ts
|
|
1925
1993
|
```
|
|
1926
1994
|
|
|
1927
1995
|
See [examples/extensions/tool-override.ts](../examples/extensions/tool-override.ts) for a complete example that overrides `read` with logging and access control.
|
|
@@ -1933,13 +2001,13 @@ See [examples/extensions/tool-override.ts](../examples/extensions/tool-override.
|
|
|
1933
2001
|
**Your implementation must match the exact result shape**, including the `details` type. The UI and session logic depend on these shapes for rendering and state tracking.
|
|
1934
2002
|
|
|
1935
2003
|
Built-in tool implementations:
|
|
1936
|
-
- [read.ts](https://github.com/
|
|
1937
|
-
- [bash.ts](https://github.com/
|
|
1938
|
-
- [edit.ts](https://github.com/
|
|
1939
|
-
- [write.ts](https://github.com/
|
|
1940
|
-
- [grep.ts](https://github.com/
|
|
1941
|
-
- [find.ts](https://github.com/
|
|
1942
|
-
- [ls.ts](https://github.com/
|
|
2004
|
+
- [read.ts](https://github.com/draht-dev/draht/blob/main/packages/coding-agent/src/core/tools/read.ts) - `ReadToolDetails`
|
|
2005
|
+
- [bash.ts](https://github.com/draht-dev/draht/blob/main/packages/coding-agent/src/core/tools/bash.ts) - `BashToolDetails`
|
|
2006
|
+
- [edit.ts](https://github.com/draht-dev/draht/blob/main/packages/coding-agent/src/core/tools/edit.ts)
|
|
2007
|
+
- [write.ts](https://github.com/draht-dev/draht/blob/main/packages/coding-agent/src/core/tools/write.ts)
|
|
2008
|
+
- [grep.ts](https://github.com/draht-dev/draht/blob/main/packages/coding-agent/src/core/tools/grep.ts) - `GrepToolDetails`
|
|
2009
|
+
- [find.ts](https://github.com/draht-dev/draht/blob/main/packages/coding-agent/src/core/tools/find.ts) - `FindToolDetails`
|
|
2010
|
+
- [ls.ts](https://github.com/draht-dev/draht/blob/main/packages/coding-agent/src/core/tools/ls.ts) - `LsToolDetails`
|
|
1943
2011
|
|
|
1944
2012
|
### Remote Execution
|
|
1945
2013
|
|
|
@@ -1972,7 +2040,7 @@ pi.registerTool({
|
|
|
1972
2040
|
|
|
1973
2041
|
**Operations interfaces:** `ReadOperations`, `WriteOperations`, `EditOperations`, `BashOperations`, `LsOperations`, `GrepOperations`, `FindOperations`
|
|
1974
2042
|
|
|
1975
|
-
For `user_bash`, extensions can reuse
|
|
2043
|
+
For `user_bash`, extensions can reuse draht's local shell backend via `createLocalBashOperations()` instead of reimplementing local process spawning, shell resolution, and process-tree termination.
|
|
1976
2044
|
|
|
1977
2045
|
The bash tool also supports a spawn hook to adjust the command, cwd, or env before execution:
|
|
1978
2046
|
|
|
@@ -1988,7 +2056,15 @@ const bashTool = createBashTool(cwd, {
|
|
|
1988
2056
|
});
|
|
1989
2057
|
```
|
|
1990
2058
|
|
|
1991
|
-
|
|
2059
|
+
`createBashTool()` exposes the current session to commands through `DRAHT_SESSION_ID`, `DRAHT_SESSION_FILE`, `DRAHT_PROVIDER`, `DRAHT_MODEL`, and `DRAHT_REASONING_LEVEL`. Injection happens before `spawnHook`, so hooks receive these values in `env` and preserve them when they spread the existing environment as above. Set `exposeSessionEnvironment: false` to disable them:
|
|
2060
|
+
|
|
2061
|
+
```typescript
|
|
2062
|
+
const bashTool = createBashTool(cwd, {
|
|
2063
|
+
exposeSessionEnvironment: false,
|
|
2064
|
+
});
|
|
2065
|
+
```
|
|
2066
|
+
|
|
2067
|
+
See [Bash tool session environment](environment-variables.md#bash-tool-session-environment) for variable semantics. See [examples/extensions/ssh.ts](../examples/extensions/ssh.ts) for a complete SSH example with `--ssh` flag.
|
|
1992
2068
|
|
|
1993
2069
|
### Output Truncation
|
|
1994
2070
|
|
|
@@ -2062,7 +2138,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
2062
2138
|
|
|
2063
2139
|
### Custom Rendering
|
|
2064
2140
|
|
|
2065
|
-
Tools can provide `renderCall` and `renderResult` for custom TUI display. See [tui.md](tui.md) for the full component API and [tool-execution.ts](https://github.com/
|
|
2141
|
+
Tools can provide `renderCall` and `renderResult` for custom TUI display. See [tui.md](tui.md) for the full component API and [tool-execution.ts](https://github.com/draht-dev/draht/blob/main/packages/coding-agent/src/modes/interactive/components/tool-execution.ts) for how tool rows are composed.
|
|
2066
2142
|
|
|
2067
2143
|
By default, tool output is wrapped in a `Box` that handles padding and background. A defined `renderCall` or `renderResult` must return a `Component`. If a slot renderer is not defined, `tool-execution.ts` uses fallback rendering for that slot.
|
|
2068
2144
|
|
|
@@ -2185,6 +2261,143 @@ If a slot renderer is not defined or throws:
|
|
|
2185
2261
|
- `renderCall`: Shows the tool name
|
|
2186
2262
|
- `renderResult`: Shows raw text from `content`
|
|
2187
2263
|
|
|
2264
|
+
### Dynamic Tool Loading
|
|
2265
|
+
|
|
2266
|
+
Extensions can register many tools while keeping only a small initial set active. A tool can then add more tools with `pi.setActiveTools()` during execution. draht detects purely additive changes, records the newly available tool names on that tool result, and applies the updated active set before the next model request.
|
|
2267
|
+
|
|
2268
|
+
This works with every model. Models with native deferred-loading support preserve the stable prompt prefix and load the new definitions at the tool-result position. Other models use the fallback described below.
|
|
2269
|
+
|
|
2270
|
+
The lifecycle is:
|
|
2271
|
+
|
|
2272
|
+
1. Register every tool with `pi.registerTool()` so it appears in `pi.getAllTools()`.
|
|
2273
|
+
2. Keep loader tools, such as `search_tools`, active and leave searchable tools inactive.
|
|
2274
|
+
3. During loader execution, call `pi.setActiveTools([...currentTools, ...matchingTools])`. The change must be additive: do not remove currently active tools in the same call.
|
|
2275
|
+
4. draht records which tools were added on the loader's tool result.
|
|
2276
|
+
5. Before the next model response, draht exposes the added definitions using native deferred loading when supported, or the normal active tool list otherwise.
|
|
2277
|
+
|
|
2278
|
+
You do not need to return provider-specific tool references or mark the loader as a special search tool. The active-tool change is the signal. Names passed to `pi.setActiveTools()` must already be registered; unknown names are ignored.
|
|
2279
|
+
|
|
2280
|
+
#### Models with native deferred loading
|
|
2281
|
+
|
|
2282
|
+
- **Anthropic**
|
|
2283
|
+
- **Models:** Sonnet, Opus, Fable version 4.5 or newer (without Haiku)
|
|
2284
|
+
- **Native representation:** Deferred definitions use `defer_loading`; the load point uses `tool_reference` content.
|
|
2285
|
+
- **OpenAI**
|
|
2286
|
+
- **Models:** `gpt-5.4` and newer family
|
|
2287
|
+
- **Native representation:** draht adds completed client `tool_search_call` and `tool_search_output` items at the load point.
|
|
2288
|
+
|
|
2289
|
+
For a verified custom model or proxy, native handling can be enabled with `compat.supportsToolReferences: true` for `anthropic-messages`, or `compat.supportsToolSearch: true` for `openai-responses` and `openai-codex-responses`. Leave these disabled unless the endpoint and model accept the corresponding native protocol.
|
|
2290
|
+
|
|
2291
|
+
#### Fallback behavior
|
|
2292
|
+
|
|
2293
|
+
For all other models and providers, dynamic activation still works: draht sends the complete current active tool list normally on the next request. The model can call the newly activated tools, but adding their definitions may invalidate the provider's cached prompt prefix.
|
|
2294
|
+
|
|
2295
|
+
draht also uses this safe fallback when the active set is not purely additive, such as replacing one group of tools with another. Tool removals therefore work, but they do not use deferred loading.
|
|
2296
|
+
|
|
2297
|
+
For the best cache behavior, keep the loader tool active for the whole session and add tools instead of replacing the active set. Also note that activating a tool with `promptSnippet` or `promptGuidelines` rebuilds the system prompt; that system-prompt change can invalidate the prefix even when the provider supports deferred schemas. Lazily loaded tools should usually rely on their tool `description` and omit active-only prompt metadata.
|
|
2298
|
+
|
|
2299
|
+
#### Search tool example
|
|
2300
|
+
|
|
2301
|
+
The following extension registers two searchable tools, removes them from the initial active set, and keeps only `search_tools` as their loader. The example uses simple keyword matching, but the search implementation could use BM25, embeddings, a remote catalog, or project-specific routing.
|
|
2302
|
+
|
|
2303
|
+
```typescript
|
|
2304
|
+
import type { ExtensionAPI } from "@draht/coding-agent";
|
|
2305
|
+
import { Type } from "typebox";
|
|
2306
|
+
|
|
2307
|
+
const SEARCHABLE_TOOL_NAMES = new Set(["lookup_weather", "search_issues"]);
|
|
2308
|
+
|
|
2309
|
+
export default function (pi: ExtensionAPI) {
|
|
2310
|
+
pi.registerTool({
|
|
2311
|
+
name: "lookup_weather",
|
|
2312
|
+
label: "Lookup Weather",
|
|
2313
|
+
description: "Look up the current weather for a city",
|
|
2314
|
+
parameters: Type.Object({ city: Type.String() }),
|
|
2315
|
+
async execute(_toolCallId, params) {
|
|
2316
|
+
return {
|
|
2317
|
+
content: [{ type: "text", text: `Weather for ${params.city}: sunny` }],
|
|
2318
|
+
details: {},
|
|
2319
|
+
};
|
|
2320
|
+
},
|
|
2321
|
+
});
|
|
2322
|
+
|
|
2323
|
+
pi.registerTool({
|
|
2324
|
+
name: "search_issues",
|
|
2325
|
+
label: "Search Issues",
|
|
2326
|
+
description: "Search project issues by keyword",
|
|
2327
|
+
parameters: Type.Object({ query: Type.String() }),
|
|
2328
|
+
async execute(_toolCallId, params) {
|
|
2329
|
+
return {
|
|
2330
|
+
content: [{ type: "text", text: `No open issues matching ${params.query}` }],
|
|
2331
|
+
details: {},
|
|
2332
|
+
};
|
|
2333
|
+
},
|
|
2334
|
+
});
|
|
2335
|
+
|
|
2336
|
+
pi.registerTool({
|
|
2337
|
+
name: "search_tools",
|
|
2338
|
+
label: "Search Tools",
|
|
2339
|
+
description: "Search for and enable tools relevant to a task",
|
|
2340
|
+
promptSnippet: "Search for additional tools when the active tools cannot perform the task",
|
|
2341
|
+
promptGuidelines: [
|
|
2342
|
+
"Use search_tools when a task requires a capability that is not currently available.",
|
|
2343
|
+
],
|
|
2344
|
+
parameters: Type.Object({
|
|
2345
|
+
query: Type.String({ description: "Capability or task to search for" }),
|
|
2346
|
+
limit: Type.Optional(Type.Integer({ minimum: 1, maximum: 10 })),
|
|
2347
|
+
}),
|
|
2348
|
+
async execute(_toolCallId, params) {
|
|
2349
|
+
const terms = params.query.toLowerCase().split(/[^a-z0-9]+/).filter(Boolean);
|
|
2350
|
+
const matches = pi.getAllTools()
|
|
2351
|
+
.filter((tool) => SEARCHABLE_TOOL_NAMES.has(tool.name))
|
|
2352
|
+
.map((tool) => ({
|
|
2353
|
+
tool,
|
|
2354
|
+
score: terms.reduce(
|
|
2355
|
+
(score, term) =>
|
|
2356
|
+
score + (`${tool.name} ${tool.description}`.toLowerCase().includes(term) ? 1 : 0),
|
|
2357
|
+
0,
|
|
2358
|
+
),
|
|
2359
|
+
}))
|
|
2360
|
+
.filter((match) => match.score > 0)
|
|
2361
|
+
.sort((a, b) => b.score - a.score)
|
|
2362
|
+
.slice(0, params.limit ?? 3)
|
|
2363
|
+
.map((match) => match.tool.name);
|
|
2364
|
+
|
|
2365
|
+
if (matches.length === 0) {
|
|
2366
|
+
return {
|
|
2367
|
+
content: [{ type: "text", text: `No tools found for: ${params.query}` }],
|
|
2368
|
+
details: { matches: [] },
|
|
2369
|
+
};
|
|
2370
|
+
}
|
|
2371
|
+
|
|
2372
|
+
const active = pi.getActiveTools();
|
|
2373
|
+
const added = matches.filter((name) => !active.includes(name));
|
|
2374
|
+
pi.setActiveTools([...new Set([...active, ...added])]);
|
|
2375
|
+
|
|
2376
|
+
return {
|
|
2377
|
+
content: [{
|
|
2378
|
+
type: "text",
|
|
2379
|
+
text: added.length > 0
|
|
2380
|
+
? `Loaded tools: ${added.join(", ")}`
|
|
2381
|
+
: `Matching tools already active: ${matches.join(", ")}`,
|
|
2382
|
+
}],
|
|
2383
|
+
details: { matches, added },
|
|
2384
|
+
};
|
|
2385
|
+
},
|
|
2386
|
+
});
|
|
2387
|
+
|
|
2388
|
+
pi.on("session_start", () => {
|
|
2389
|
+
// Keep searchable tools registered but initially inactive. Preserve built-ins
|
|
2390
|
+
// and tools owned by other extensions, and keep the loader itself active.
|
|
2391
|
+
const initialTools = pi.getActiveTools().filter(
|
|
2392
|
+
(name) => !SEARCHABLE_TOOL_NAMES.has(name),
|
|
2393
|
+
);
|
|
2394
|
+
pi.setActiveTools([...new Set([...initialTools, "search_tools"])]);
|
|
2395
|
+
});
|
|
2396
|
+
}
|
|
2397
|
+
```
|
|
2398
|
+
|
|
2399
|
+
When `search_tools` adds a match, the model receives that definition on the immediately following request. On a native-capable model the definition is anchored after the search result without changing the initial tool-schema prefix. On other models it appears in the normal tool list on that same following request.
|
|
2400
|
+
|
|
2188
2401
|
## Custom UI
|
|
2189
2402
|
|
|
2190
2403
|
Extensions can interact with users via `ctx.ui` methods and customize how messages/tools render.
|
|
@@ -2311,7 +2524,7 @@ ctx.ui.setFooter((tui, theme) => ({
|
|
|
2311
2524
|
ctx.ui.setFooter(undefined); // Restore built-in footer
|
|
2312
2525
|
|
|
2313
2526
|
// Terminal title
|
|
2314
|
-
ctx.ui.setTitle("
|
|
2527
|
+
ctx.ui.setTitle("draht - my-project");
|
|
2315
2528
|
|
|
2316
2529
|
// Editor text
|
|
2317
2530
|
ctx.ui.setEditorText("Prefill text");
|
|
@@ -2505,8 +2718,8 @@ class VimEditor extends CustomEditor {
|
|
|
2505
2718
|
|
|
2506
2719
|
export default function (pi: ExtensionAPI) {
|
|
2507
2720
|
pi.on("session_start", (_event, ctx) => {
|
|
2508
|
-
ctx.ui.setEditorComponent((
|
|
2509
|
-
new VimEditor(theme, keybindings)
|
|
2721
|
+
ctx.ui.setEditorComponent((tui, theme, keybindings) =>
|
|
2722
|
+
new VimEditor(tui, theme, keybindings)
|
|
2510
2723
|
);
|
|
2511
2724
|
});
|
|
2512
2725
|
}
|
|
@@ -2515,7 +2728,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
2515
2728
|
**Key points:**
|
|
2516
2729
|
- Extend `CustomEditor` (not base `Editor`) to get app keybindings (escape to abort, ctrl+d, model switching)
|
|
2517
2730
|
- Call `super.handleInput(data)` for keys you don't handle
|
|
2518
|
-
- Factory receives `theme
|
|
2731
|
+
- Factory receives `tui`, `theme`, and `keybindings` from the app
|
|
2519
2732
|
- Use `ctx.ui.getEditorComponent()` before `setEditorComponent()` to wrap the previously configured custom editor
|
|
2520
2733
|
- Pass `undefined` to restore default: `ctx.ui.setEditorComponent(undefined)`
|
|
2521
2734
|
|
|
@@ -2538,7 +2751,7 @@ Register a custom renderer for messages with your `customType`. Use message rend
|
|
|
2538
2751
|
import { Text } from "@draht/tui";
|
|
2539
2752
|
|
|
2540
2753
|
pi.registerMessageRenderer("my-extension", (message, options, theme) => {
|
|
2541
|
-
const { expanded } = options;
|
|
2754
|
+
const { expanded, outputPad } = options;
|
|
2542
2755
|
let text = theme.fg("accent", `[${message.customType}] `);
|
|
2543
2756
|
text += message.content;
|
|
2544
2757
|
|
|
@@ -2546,7 +2759,7 @@ pi.registerMessageRenderer("my-extension", (message, options, theme) => {
|
|
|
2546
2759
|
text += "\n" + theme.fg("dim", JSON.stringify(message.details, null, 2));
|
|
2547
2760
|
}
|
|
2548
2761
|
|
|
2549
|
-
return new Text(text,
|
|
2762
|
+
return new Text(text, outputPad, 0);
|
|
2550
2763
|
});
|
|
2551
2764
|
```
|
|
2552
2765
|
|