@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/dist/main.js
CHANGED
|
@@ -8,27 +8,33 @@ import { createInterface } from "node:readline";
|
|
|
8
8
|
import { modelsAreEqual, supportsMax, supportsXhigh } from "@draht/ai";
|
|
9
9
|
import chalk from "chalk";
|
|
10
10
|
import { parseArgs, printHelp } from "./cli/args.js";
|
|
11
|
+
import { runAttachMode } from "./cli/attach-mode.js";
|
|
12
|
+
import { CredentialPrintError, isCredentialPrintHelp, parseCredentialPrintCommand, printCredentialPrintHelp, resolveCredentialForPrint, validateCredentialPrintArgs, } from "./cli/credential-print.js";
|
|
11
13
|
import { processFileArguments } from "./cli/file-processor.js";
|
|
12
14
|
import { buildInitialMessage } from "./cli/initial-message.js";
|
|
13
15
|
import { listModels } from "./cli/list-models.js";
|
|
16
|
+
import { listSessions } from "./cli/list-sessions.js";
|
|
14
17
|
import { createProjectTrustContext } from "./cli/project-trust.js";
|
|
15
18
|
import { selectSession } from "./cli/session-picker.js";
|
|
16
19
|
import { shouldRunFirstTimeSetup, showFirstTimeSetup, showStartupSelector } from "./cli/startup-ui.js";
|
|
17
|
-
import { DISPLAY_VERSION, ENV_SESSION_DIR, expandTildePath, getAgentDir, getPackageDir } from "./config.js";
|
|
20
|
+
import { APP_NAME, DISPLAY_VERSION, ENV_SESSION_DIR, expandTildePath, getAgentDir, getPackageDir } from "./config.js";
|
|
18
21
|
import { createAgentSessionRuntime } from "./core/agent-session-runtime.js";
|
|
19
22
|
import { createAgentSessionFromServices, createAgentSessionServices, } from "./core/agent-session-services.js";
|
|
20
23
|
import { formatNoModelsAvailableMessage } from "./core/auth-guidance.js";
|
|
21
|
-
import {
|
|
24
|
+
import { handleCheckpointCommand } from "./core/checkpoints/checkpoint-cli.js";
|
|
22
25
|
import { exportFromFile } from "./core/export-html/index.js";
|
|
23
26
|
import { applyHttpProxySettings, configureHttpDispatcher } from "./core/http-dispatcher.js";
|
|
24
27
|
import { resolveCliModel, resolveModelScope } from "./core/model-resolver.js";
|
|
28
|
+
import { ModelRuntime } from "./core/model-runtime.js";
|
|
25
29
|
import { restoreStdout, takeOverStdout } from "./core/output-guard.js";
|
|
26
30
|
import { resolveProjectTrusted } from "./core/project-trust.js";
|
|
27
31
|
import { formatMissingSessionCwdPrompt, getMissingSessionCwdIssue, MissingSessionCwdError, } from "./core/session-cwd.js";
|
|
28
32
|
import { assertValidSessionId, SessionManager } from "./core/session-manager.js";
|
|
29
33
|
import { SettingsManager } from "./core/settings-manager.js";
|
|
34
|
+
import { makeSessionAttachable, registerAttachableSessionCleanup, SocketCapReachedError, SocketDirectoryUnsafeError, SocketSessionBusyError, } from "./core/socket-server/index.js";
|
|
30
35
|
import { printTimings, resetTimings, time } from "./core/timings.js";
|
|
31
36
|
import { hasTrustRequiringProjectResources, ProjectTrustStore } from "./core/trust-manager.js";
|
|
37
|
+
import { builtInExtensions } from "./extensions/index.js";
|
|
32
38
|
import { runMigrations, showDeprecationWarnings } from "./migrations.js";
|
|
33
39
|
import { InteractiveMode, runPrintMode, runRpcMode } from "./modes/index.js";
|
|
34
40
|
import { initTheme, stopThemeWatcher } from "./modes/interactive/theme/theme.js";
|
|
@@ -76,6 +82,52 @@ function isTruthyEnvFlag(value) {
|
|
|
76
82
|
return false;
|
|
77
83
|
return value === "1" || value.toLowerCase() === "true" || value.toLowerCase() === "yes";
|
|
78
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* Opt out of default-on socket registration without editing settings (e.g. DRAHT_NO_ATTACHABLE=1).
|
|
87
|
+
*
|
|
88
|
+
* CI and scripted spawns need a way to say no that survives a fresh container and does not
|
|
89
|
+
* require a writable settings file. Overridden by an explicit `--attachable`.
|
|
90
|
+
*/
|
|
91
|
+
const ENV_NO_ATTACHABLE = `${APP_NAME.toUpperCase()}_NO_ATTACHABLE`;
|
|
92
|
+
/**
|
|
93
|
+
* The ONE line an implicit (default-on) registration failure is allowed to print.
|
|
94
|
+
*
|
|
95
|
+
* Exactly one line, on stderr, never stdout — the caller relies on both. It says what was lost
|
|
96
|
+
* (this window is not on the fleet), never what errno said: an `EEXIST` in a startup banner
|
|
97
|
+
* teaches a user nothing they can act on. Three shapes, kept distinct on purpose so a cap
|
|
98
|
+
* refusal is never mistaken for a broken sockets directory and a busy twin is never mistaken
|
|
99
|
+
* for either.
|
|
100
|
+
*/
|
|
101
|
+
function describeAttachableDegradation(error) {
|
|
102
|
+
const tail = "This session runs normally but is not reachable from your other devices.";
|
|
103
|
+
if (error instanceof SocketSessionBusyError) {
|
|
104
|
+
const owner = error.ownerPid === null
|
|
105
|
+
? "another process is claiming it right now"
|
|
106
|
+
: `it is already published by PID ${error.ownerPid}`;
|
|
107
|
+
return `Not registering this session for remote attach: ${owner}. Run \`${APP_NAME} --attach ${error.sessionId}\` to reach that one. ${tail}`;
|
|
108
|
+
}
|
|
109
|
+
if (error instanceof SocketCapReachedError) {
|
|
110
|
+
return `Not registering this session for remote attach: this machine already holds ${error.liveCount} attachable sessions and the limit is ${error.cap}. Close one you are done with. ${tail}`;
|
|
111
|
+
}
|
|
112
|
+
if (error instanceof SocketDirectoryUnsafeError) {
|
|
113
|
+
return `Not registering this session for remote attach: ${error.socketDir} is not a private directory belonging to you. ${tail}`;
|
|
114
|
+
}
|
|
115
|
+
// Node's fs errors carry a `code`. Translate the ones that are actually reachable into a
|
|
116
|
+
// sentence; EINVAL in particular is not exotic — the default socket path is already ~76 of
|
|
117
|
+
// the ~104 bytes a Unix socket address holds, so a long $HOME or a long agent-dir override
|
|
118
|
+
// overflows it.
|
|
119
|
+
const code = typeof error === "object" && error !== null ? error.code : undefined;
|
|
120
|
+
const reason = code === "EACCES" || code === "EPERM"
|
|
121
|
+
? "permission was denied"
|
|
122
|
+
: code === "EEXIST" || code === "ENOTDIR"
|
|
123
|
+
? "something that is not a directory is in the way"
|
|
124
|
+
: code === "EINVAL" || code === "ENAMETOOLONG"
|
|
125
|
+
? "the socket path is too long for this system"
|
|
126
|
+
: code === "ENOENT"
|
|
127
|
+
? "its directory could not be created"
|
|
128
|
+
: "the control socket could not be created";
|
|
129
|
+
return `Not registering this session for remote attach: ${reason}. ${tail}`;
|
|
130
|
+
}
|
|
79
131
|
function resolveAppMode(parsed, stdinIsTTY, stdoutIsTTY) {
|
|
80
132
|
if (parsed.mode === "rpc") {
|
|
81
133
|
return "rpc";
|
|
@@ -94,6 +146,44 @@ function toPrintOutputMode(appMode) {
|
|
|
94
146
|
function isPlainRuntimeMetadataCommand(parsed) {
|
|
95
147
|
return !parsed.print && parsed.mode === undefined && (parsed.help === true || parsed.listModels !== undefined);
|
|
96
148
|
}
|
|
149
|
+
async function runCredentialPrintCommand(args) {
|
|
150
|
+
if (isCredentialPrintHelp(args)) {
|
|
151
|
+
printCredentialPrintHelp();
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
154
|
+
let command;
|
|
155
|
+
try {
|
|
156
|
+
command = parseCredentialPrintCommand(args);
|
|
157
|
+
}
|
|
158
|
+
catch (error) {
|
|
159
|
+
const message = error instanceof CredentialPrintError ? error.message : "Failed to parse auth command";
|
|
160
|
+
console.error(chalk.red(`Error: ${message}`));
|
|
161
|
+
process.exitCode = 1;
|
|
162
|
+
return true;
|
|
163
|
+
}
|
|
164
|
+
if (!command)
|
|
165
|
+
return false;
|
|
166
|
+
const parsed = parseArgs(command.args);
|
|
167
|
+
if (parsed.diagnostics.length > 0) {
|
|
168
|
+
for (const diagnostic of parsed.diagnostics) {
|
|
169
|
+
console.error(chalk.red(`Error: ${diagnostic.message}`));
|
|
170
|
+
}
|
|
171
|
+
process.exitCode = 1;
|
|
172
|
+
return true;
|
|
173
|
+
}
|
|
174
|
+
try {
|
|
175
|
+
validateCredentialPrintArgs(parsed);
|
|
176
|
+
const modelRuntime = await ModelRuntime.create({ allowModelNetwork: false });
|
|
177
|
+
const credential = await resolveCredentialForPrint(parsed, modelRuntime, command.kind, command.minExpiryMs);
|
|
178
|
+
process.stdout.write(`${credential}\n`);
|
|
179
|
+
}
|
|
180
|
+
catch (error) {
|
|
181
|
+
const message = error instanceof CredentialPrintError ? error.message : "Failed to resolve credential";
|
|
182
|
+
console.error(chalk.red(`Error: ${message}`));
|
|
183
|
+
process.exitCode = 1;
|
|
184
|
+
}
|
|
185
|
+
return true;
|
|
186
|
+
}
|
|
97
187
|
async function prepareInitialMessage(parsed, autoResizeImages, stdinContent) {
|
|
98
188
|
if (parsed.fileArgs.length === 0) {
|
|
99
189
|
return buildInitialMessage({ parsed, stdinContent });
|
|
@@ -135,8 +225,31 @@ async function resolveSessionPath(sessionArg, cwd, sessionDir) {
|
|
|
135
225
|
// Not found anywhere
|
|
136
226
|
return { type: "not_found", arg: sessionArg };
|
|
137
227
|
}
|
|
138
|
-
/**
|
|
228
|
+
/**
|
|
229
|
+
* Prompt user for yes/no confirmation.
|
|
230
|
+
*
|
|
231
|
+
* REFUSES OUTRIGHT WHEN STDIN IS NOT A TTY (R35-ALWAYS.9).
|
|
232
|
+
*
|
|
233
|
+
* `createInterface({ input: process.stdin })` has no TTY check, so with stdin at
|
|
234
|
+
* /dev/null this used to print the question, receive EOF, resolve to `false`,
|
|
235
|
+
* and let its one caller print "Aborted." and EXIT 0 — having started nothing.
|
|
236
|
+
* Exit 0 having done nothing is indistinguishable from success to every
|
|
237
|
+
* programmatic caller there is: a script, a supervisor, and now the geist daemon,
|
|
238
|
+
* which resumes sessions by spawning this binary. A daemon that saw a clean exit
|
|
239
|
+
* would report a resume that never happened.
|
|
240
|
+
*
|
|
241
|
+
* So a non-interactive answer to an interactive question is an ERROR, said on
|
|
242
|
+
* stderr with an exit code, not a silent "no". The caller that would have taken
|
|
243
|
+
* this branch — `--session <bare id>` naming a session in another project — is
|
|
244
|
+
* exactly the shape the daemon avoids by passing an absolute `.jsonl` path
|
|
245
|
+
* instead, which never reaches a prompt at all.
|
|
246
|
+
*/
|
|
139
247
|
async function promptConfirm(message) {
|
|
248
|
+
if (!process.stdin.isTTY) {
|
|
249
|
+
console.error(chalk.red(`Error: "${message}" needs an answer and stdin is not a terminal.\n` +
|
|
250
|
+
"Re-run with a terminal, or name the session by its absolute .jsonl path so no question is asked."));
|
|
251
|
+
process.exit(1);
|
|
252
|
+
}
|
|
140
253
|
return new Promise((resolve) => {
|
|
141
254
|
const rl = createInterface({
|
|
142
255
|
input: process.stdin,
|
|
@@ -271,7 +384,7 @@ async function createSessionManager(parsed, cwd, sessionDir, settingsManager) {
|
|
|
271
384
|
}
|
|
272
385
|
return SessionManager.create(cwd, sessionDir, { id: parsed.sessionId });
|
|
273
386
|
}
|
|
274
|
-
function buildSessionOptions(parsed, scopedModels, hasExistingSession,
|
|
387
|
+
function buildSessionOptions(parsed, scopedModels, hasExistingSession, modelRuntime, settingsManager) {
|
|
275
388
|
const options = {};
|
|
276
389
|
const diagnostics = [];
|
|
277
390
|
let cliThinkingFromModel = false;
|
|
@@ -283,7 +396,7 @@ function buildSessionOptions(parsed, scopedModels, hasExistingSession, modelRegi
|
|
|
283
396
|
cliProvider: parsed.provider,
|
|
284
397
|
cliModel: parsed.model,
|
|
285
398
|
cliThinking: parsed.thinking,
|
|
286
|
-
|
|
399
|
+
modelRuntime,
|
|
287
400
|
});
|
|
288
401
|
if (resolved.warning) {
|
|
289
402
|
diagnostics.push({ type: "warning", message: resolved.warning });
|
|
@@ -305,7 +418,7 @@ function buildSessionOptions(parsed, scopedModels, hasExistingSession, modelRegi
|
|
|
305
418
|
// Check if saved default is in scoped models - use it if so, otherwise first scoped model
|
|
306
419
|
const savedProvider = settingsManager.getDefaultProvider();
|
|
307
420
|
const savedModelId = settingsManager.getDefaultModel();
|
|
308
|
-
const savedModel = savedProvider && savedModelId ?
|
|
421
|
+
const savedModel = savedProvider && savedModelId ? modelRuntime.getModel(savedProvider, savedModelId) : undefined;
|
|
309
422
|
const savedInScope = savedModel ? scopedModels.find((sm) => modelsAreEqual(sm.model, savedModel)) : undefined;
|
|
310
423
|
if (savedInScope) {
|
|
311
424
|
options.model = savedInScope.model;
|
|
@@ -335,7 +448,7 @@ function buildSessionOptions(parsed, scopedModels, hasExistingSession, modelRegi
|
|
|
335
448
|
thinkingLevel: sm.thinkingLevel,
|
|
336
449
|
}));
|
|
337
450
|
}
|
|
338
|
-
// API key from CLI - set
|
|
451
|
+
// API key from CLI - set as a non-persistent runtime override
|
|
339
452
|
// (handled by caller before createAgentSession)
|
|
340
453
|
// Tools
|
|
341
454
|
if (parsed.noTools) {
|
|
@@ -363,6 +476,7 @@ async function promptForMissingSessionCwd(issue, settingsManager) {
|
|
|
363
476
|
}
|
|
364
477
|
export async function main(args, options) {
|
|
365
478
|
resetTimings();
|
|
479
|
+
const extensionFactories = [...builtInExtensions, ...(options?.extensionFactories ?? [])];
|
|
366
480
|
const offlineMode = args.includes("--offline") || isTruthyEnvFlag(process.env.DRAHT_OFFLINE);
|
|
367
481
|
if (offlineMode) {
|
|
368
482
|
process.env.DRAHT_OFFLINE = "1";
|
|
@@ -376,7 +490,7 @@ export async function main(args, options) {
|
|
|
376
490
|
const bootstrapSettingsManager = SettingsManager.create(cwd, agentDir, { projectTrusted: false });
|
|
377
491
|
applyHttpProxySettings(bootstrapSettingsManager.getGlobalSettings().httpProxy);
|
|
378
492
|
configureHttpDispatcher();
|
|
379
|
-
if (await handlePackageCommand(args, { extensionFactories
|
|
493
|
+
if (await handlePackageCommand(args, { extensionFactories })) {
|
|
380
494
|
const exitCode = process.exitCode ?? 0;
|
|
381
495
|
if (process.platform === "win32" && exitCode === 0 && args[0] === "update") {
|
|
382
496
|
// We normally prefer process.exit(0) for package commands so bad extensions cannot keep
|
|
@@ -388,13 +502,20 @@ export async function main(args, options) {
|
|
|
388
502
|
process.exit(exitCode);
|
|
389
503
|
return;
|
|
390
504
|
}
|
|
391
|
-
if (await handleConfigCommand(args, { extensionFactories
|
|
505
|
+
if (await handleConfigCommand(args, { extensionFactories })) {
|
|
392
506
|
return;
|
|
393
507
|
}
|
|
394
508
|
if (await handleRlmCommand(args)) {
|
|
395
509
|
process.exit(process.exitCode ?? 0);
|
|
396
510
|
return;
|
|
397
511
|
}
|
|
512
|
+
if (await handleCheckpointCommand(args)) {
|
|
513
|
+
process.exit(process.exitCode ?? 0);
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
516
|
+
if (await runCredentialPrintCommand(args)) {
|
|
517
|
+
return;
|
|
518
|
+
}
|
|
398
519
|
const parsed = parseArgs(args);
|
|
399
520
|
if (parsed.diagnostics.length > 0) {
|
|
400
521
|
for (const d of parsed.diagnostics) {
|
|
@@ -410,6 +531,17 @@ export async function main(args, options) {
|
|
|
410
531
|
console.log(DISPLAY_VERSION);
|
|
411
532
|
process.exit(0);
|
|
412
533
|
}
|
|
534
|
+
// Attachable-session commands are pure socket/filesystem operations. They run before any
|
|
535
|
+
// runtime construction so they never pay for provider discovery, extensions, or sessions.
|
|
536
|
+
if (parsed.listSessions) {
|
|
537
|
+
await listSessions();
|
|
538
|
+
process.exit(0);
|
|
539
|
+
}
|
|
540
|
+
if (parsed.attach !== undefined) {
|
|
541
|
+
// runAttachMode owns its own lifetime: it exits the process on detach or error.
|
|
542
|
+
await runAttachMode(parsed.attach);
|
|
543
|
+
return;
|
|
544
|
+
}
|
|
413
545
|
if (parsed.export) {
|
|
414
546
|
let result;
|
|
415
547
|
try {
|
|
@@ -490,7 +622,6 @@ export async function main(args, options) {
|
|
|
490
622
|
const resolvedSkillPaths = resolveCliPaths(cwd, parsed.skills);
|
|
491
623
|
const resolvedPromptTemplatePaths = resolveCliPaths(cwd, parsed.promptTemplates);
|
|
492
624
|
const resolvedThemePaths = resolveCliPaths(cwd, parsed.themes);
|
|
493
|
-
const authStorage = AuthStorage.create();
|
|
494
625
|
const createRuntime = async ({ cwd, agentDir, sessionManager, sessionStartEvent, projectTrustContext, }) => {
|
|
495
626
|
const isInitialRuntime = sessionStartEvent === undefined;
|
|
496
627
|
const projectTrustDiagnostics = [];
|
|
@@ -506,7 +637,6 @@ export async function main(args, options) {
|
|
|
506
637
|
const services = await createAgentSessionServices({
|
|
507
638
|
cwd,
|
|
508
639
|
agentDir,
|
|
509
|
-
authStorage,
|
|
510
640
|
settingsManager: runtimeSettingsManager,
|
|
511
641
|
extensionFlagValues: parsed.unknownFlags,
|
|
512
642
|
resourceLoaderReloadOptions: shouldResolveProjectTrust
|
|
@@ -542,12 +672,13 @@ export async function main(args, options) {
|
|
|
542
672
|
noPromptTemplates: parsed.noPromptTemplates,
|
|
543
673
|
noThemes: parsed.noThemes,
|
|
544
674
|
noContextFiles: parsed.noContextFiles,
|
|
675
|
+
contextRoot: parsed.contextRoot,
|
|
545
676
|
systemPrompt: parsed.systemPrompt,
|
|
546
677
|
appendSystemPrompt: parsed.appendSystemPrompt,
|
|
547
|
-
extensionFactories
|
|
678
|
+
extensionFactories,
|
|
548
679
|
},
|
|
549
680
|
});
|
|
550
|
-
const { settingsManager,
|
|
681
|
+
const { settingsManager, modelRuntime, resourceLoader } = services;
|
|
551
682
|
const diagnostics = [
|
|
552
683
|
...projectTrustDiagnostics,
|
|
553
684
|
...services.diagnostics,
|
|
@@ -558,8 +689,8 @@ export async function main(args, options) {
|
|
|
558
689
|
})),
|
|
559
690
|
];
|
|
560
691
|
const modelPatterns = parsed.models ?? settingsManager.getEnabledModels();
|
|
561
|
-
const scopedModels = modelPatterns && modelPatterns.length > 0 ? await resolveModelScope(modelPatterns,
|
|
562
|
-
const { options: sessionOptions, cliThinkingFromModel, diagnostics: sessionOptionDiagnostics, } = buildSessionOptions(parsed, scopedModels, sessionManager.buildSessionContext().messages.length > 0,
|
|
692
|
+
const scopedModels = modelPatterns && modelPatterns.length > 0 ? await resolveModelScope(modelPatterns, modelRuntime) : [];
|
|
693
|
+
const { options: sessionOptions, cliThinkingFromModel, diagnostics: sessionOptionDiagnostics, } = buildSessionOptions(parsed, scopedModels, sessionManager.buildSessionContext().messages.length > 0, modelRuntime, settingsManager);
|
|
563
694
|
diagnostics.push(...sessionOptionDiagnostics);
|
|
564
695
|
if (parsed.apiKey) {
|
|
565
696
|
if (!sessionOptions.model) {
|
|
@@ -569,7 +700,8 @@ export async function main(args, options) {
|
|
|
569
700
|
});
|
|
570
701
|
}
|
|
571
702
|
else {
|
|
572
|
-
|
|
703
|
+
await modelRuntime.setRuntimeApiKey(sessionOptions.model.provider, parsed.apiKey, { allowNetwork: false });
|
|
704
|
+
await services.modelRuntime.getAvailable();
|
|
573
705
|
}
|
|
574
706
|
}
|
|
575
707
|
const created = await createAgentSessionFromServices({
|
|
@@ -614,7 +746,7 @@ export async function main(args, options) {
|
|
|
614
746
|
});
|
|
615
747
|
time("createAgentSessionRuntime");
|
|
616
748
|
const { services, session, modelFallbackMessage } = runtime;
|
|
617
|
-
const { settingsManager,
|
|
749
|
+
const { settingsManager, modelRuntime, resourceLoader } = services;
|
|
618
750
|
applyHttpProxySettings(settingsManager.getGlobalSettings().httpProxy);
|
|
619
751
|
configureHttpDispatcher(settingsManager.getHttpIdleTimeoutMs());
|
|
620
752
|
if (parsed.help) {
|
|
@@ -626,7 +758,7 @@ export async function main(args, options) {
|
|
|
626
758
|
}
|
|
627
759
|
if (parsed.listModels !== undefined) {
|
|
628
760
|
const searchPattern = typeof parsed.listModels === "string" ? parsed.listModels : undefined;
|
|
629
|
-
await listModels(
|
|
761
|
+
await listModels(modelRuntime, searchPattern);
|
|
630
762
|
process.exit(0);
|
|
631
763
|
}
|
|
632
764
|
// Read piped stdin content (if any) - skip for RPC mode which uses stdin for JSON-RPC
|
|
@@ -664,54 +796,166 @@ export async function main(args, options) {
|
|
|
664
796
|
console.error(chalk.red("Error: DRAHT_STARTUP_BENCHMARK only supports interactive mode"));
|
|
665
797
|
process.exit(1);
|
|
666
798
|
}
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
}
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
799
|
+
// RPC refreshes catalogs here in the background; interactive mode starts its refresh after TUI initialization.
|
|
800
|
+
if (!offlineMode && appMode === "rpc") {
|
|
801
|
+
void modelRuntime.refresh().catch(() => { });
|
|
802
|
+
}
|
|
803
|
+
// ── DEFAULT-ON (R35-ALWAYS.1) ────────────────────────────────────────────────────────────
|
|
804
|
+
// Interactive sessions register a control socket unless something says otherwise. The lock
|
|
805
|
+
// file records the session's resolved cwd (not process.cwd()), which is what identifies the
|
|
806
|
+
// project a session belongs to when --session/--resume selected a session from elsewhere.
|
|
807
|
+
//
|
|
808
|
+
// `parsed.attachable` is a TRI-STATE and the whole split below hangs off it:
|
|
809
|
+
// true the operator typed --attachable → bind, banner, failure is FATAL
|
|
810
|
+
// false the operator typed --no-attachable → never bind
|
|
811
|
+
// undefined nobody said → bind iff interactive, silently,
|
|
812
|
+
// and a failure only degrades
|
|
813
|
+
//
|
|
814
|
+
// Two things about WHERE this sits, both load-bearing:
|
|
815
|
+
// 1. `appMode` is read HERE, not at its first computation ~300 lines up, because piped
|
|
816
|
+
// stdin DOWNGRADES "interactive" to "print" just above. Reading the earlier value
|
|
817
|
+
// would bind a socket for `echo hi | draht`.
|
|
818
|
+
// 2. The gate is what keeps SUBAGENTS unbound — subagent.ts spawns children with
|
|
819
|
+
// ["--mode","json","-p","--no-session"], which is never "interactive". Defaulting
|
|
820
|
+
// inside the argument parser instead would put a socket under every subagent and a
|
|
821
|
+
// parallel wave would be the first thing to hit the socket cap.
|
|
822
|
+
// Precedence flag ?? env ?? setting mirrors `sessionDir` above. The setting is read
|
|
823
|
+
// global-only; see SettingsManager.getAttachableSessions for why.
|
|
824
|
+
const attachableRequestedExplicitly = parsed.attachable === true;
|
|
825
|
+
const attachableEnabled = parsed.attachable ??
|
|
826
|
+
(appMode === "interactive" &&
|
|
827
|
+
!isTruthyEnvFlag(process.env[ENV_NO_ATTACHABLE]) &&
|
|
828
|
+
settingsManager.getAttachableSessions());
|
|
829
|
+
let attachableSession;
|
|
830
|
+
if (attachableEnabled) {
|
|
831
|
+
try {
|
|
832
|
+
attachableSession = await makeSessionAttachable({
|
|
833
|
+
session,
|
|
834
|
+
enabled: true,
|
|
835
|
+
cwd: session.sessionManager.getCwd(),
|
|
836
|
+
// The banner is stdout, and interactive mode never took stdout over, so an
|
|
837
|
+
// implicit bind must not print it into the scrollback.
|
|
838
|
+
announce: attachableRequestedExplicitly,
|
|
839
|
+
});
|
|
840
|
+
}
|
|
841
|
+
catch (error) {
|
|
842
|
+
// ── THE SPLIT CATCH ───────────────────────────────────────────────────────────
|
|
843
|
+
// An EXPLICIT --attachable that fails stays fatal: the operator asked for a
|
|
844
|
+
// reachable session and would otherwise get an unreachable one without being
|
|
845
|
+
// told. An IMPLICIT default that fails must NEVER prevent a session starting —
|
|
846
|
+
// that is the entire point of the requirement. One line on stderr (never stdout,
|
|
847
|
+
// in any mode), then carry on unattached: everything downstream already tolerates
|
|
848
|
+
// `attachableSession === undefined`.
|
|
849
|
+
//
|
|
850
|
+
// TWO CONSEQUENCES, recorded here because they are decisions and not accidents:
|
|
851
|
+
//
|
|
852
|
+
// (i) THE `--continue` TWIN DEGRADES AND IS THEREFORE NOT ON THE PHONE. Under
|
|
853
|
+
// default-on the commonest failure is not environmental at all. `continueRecent`
|
|
854
|
+
// reopens the most recent session FILE, so a second `draht -c` in the same
|
|
855
|
+
// project reuses the header id and therefore the socket name, and loses the
|
|
856
|
+
// race for the lock. It gets the busy notice below and runs normally, but it is
|
|
857
|
+
// invisible to the fleet. Decoupling socket identity from session identity would
|
|
858
|
+
// make both windows reachable; it ripples through the wire, the history join key
|
|
859
|
+
// and resume, and is NAMED DEBT for a later phase, deliberately not attempted
|
|
860
|
+
// here.
|
|
861
|
+
//
|
|
862
|
+
// (ii) REMOVING THE FATAL EXIT REMOVES THE ONLY GUARD ATTACHABLE SESSIONS HAD
|
|
863
|
+
// AGAINST TWO PROCESSES APPENDING TO ONE SESSION JSONL. The `process.exit(1)`
|
|
864
|
+
// this replaces was never designed as that guard, but it was one: the second
|
|
865
|
+
// `draht -c` died before it could write. It now lives, and both processes
|
|
866
|
+
// append to the same file. That hazard predates and outlives this change for
|
|
867
|
+
// every non-attachable session, and the session store is append-only, but it
|
|
868
|
+
// is strictly more reachable now than it was.
|
|
869
|
+
if (attachableRequestedExplicitly) {
|
|
870
|
+
const message = error instanceof Error ? error.message : "Failed to start attachable session";
|
|
871
|
+
console.error(chalk.red(`Error: ${message}`));
|
|
872
|
+
process.exit(1);
|
|
873
|
+
}
|
|
874
|
+
console.error(chalk.yellow(describeAttachableDegradation(error)));
|
|
875
|
+
attachableSession = undefined;
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
if (attachableSession) {
|
|
879
|
+
// Hand the session the pending-ask registry, so a dialog raised by the agent reaches every
|
|
880
|
+
// attached client and can be answered from one. This only HANDS THE HANDLE OVER: the wrap
|
|
881
|
+
// itself is installed inside `_applyExtensionBindings`, the one mode-agnostic seam every
|
|
882
|
+
// session passes through. Installing it here instead would be silently overwritten —
|
|
883
|
+
// interactive and rpc bind their own UI context later, and `bindExtensions` re-pushes it.
|
|
884
|
+
session.setPermissionRelay(attachableSession.relay ?? undefined);
|
|
885
|
+
}
|
|
886
|
+
// The mode run loops end in process.exit() and never return here, so the finally below
|
|
887
|
+
// is not enough on its own: exit and signal paths need their own synchronous cleanup.
|
|
888
|
+
const releaseAttachableCleanup = attachableSession ? registerAttachableSessionCleanup(attachableSession) : undefined;
|
|
889
|
+
// /new, /resume, /fork and /import dispose this session object and install a new one.
|
|
890
|
+
// Without following that, the socket would keep advertising a dead session id and route
|
|
891
|
+
// client input into a disposed session.
|
|
892
|
+
const releaseAttachableRebind = attachableSession
|
|
893
|
+
? runtime.addSessionReplacedListener(async (nextSession) => {
|
|
894
|
+
await attachableSession.rebind(nextSession, nextSession.sessionManager.getCwd());
|
|
895
|
+
// The rebind swept the old session's pending asks fail-closed and built a fresh
|
|
896
|
+
// registry for the new one. Without re-handing it here the relay would silently
|
|
897
|
+
// die on /new, /resume, /fork and /import: the new session would keep an
|
|
898
|
+
// undecorated UI context, `hasUI()` would stop counting attached clients, and a
|
|
899
|
+
// phone would watch a session it can no longer answer.
|
|
900
|
+
nextSession.setPermissionRelay(attachableSession.relay ?? undefined);
|
|
901
|
+
})
|
|
902
|
+
: undefined;
|
|
903
|
+
try {
|
|
904
|
+
if (appMode === "rpc") {
|
|
689
905
|
printTimings();
|
|
690
|
-
|
|
691
|
-
|
|
906
|
+
await runRpcMode(runtime);
|
|
907
|
+
}
|
|
908
|
+
else if (appMode === "interactive") {
|
|
909
|
+
const interactiveMode = new InteractiveMode(runtime, {
|
|
910
|
+
migratedProviders,
|
|
911
|
+
modelFallbackMessage,
|
|
912
|
+
autoTrustOnReloadCwd,
|
|
913
|
+
initialMessage,
|
|
914
|
+
initialImages,
|
|
915
|
+
initialMessages: parsed.messages,
|
|
916
|
+
verbose: parsed.verbose,
|
|
917
|
+
});
|
|
918
|
+
if (startupBenchmark) {
|
|
919
|
+
await interactiveMode.init();
|
|
920
|
+
time("interactiveMode.init");
|
|
921
|
+
// Give the TUI's stdin handler a brief chance to consume terminal query replies
|
|
922
|
+
// (Kitty keyboard protocol, device attributes, cell size) before restoring the terminal.
|
|
923
|
+
await new Promise((resolve) => setTimeout(resolve, 150));
|
|
924
|
+
interactiveMode.stop();
|
|
925
|
+
stopThemeWatcher();
|
|
926
|
+
printTimings();
|
|
927
|
+
if (process.stdout.writableLength > 0) {
|
|
928
|
+
await new Promise((resolve) => process.stdout.once("drain", resolve));
|
|
929
|
+
}
|
|
930
|
+
if (process.stderr.writableLength > 0) {
|
|
931
|
+
await new Promise((resolve) => process.stderr.once("drain", resolve));
|
|
932
|
+
}
|
|
933
|
+
return;
|
|
692
934
|
}
|
|
693
|
-
|
|
694
|
-
|
|
935
|
+
printTimings();
|
|
936
|
+
await interactiveMode.run();
|
|
937
|
+
}
|
|
938
|
+
else {
|
|
939
|
+
printTimings();
|
|
940
|
+
const exitCode = await runPrintMode(runtime, {
|
|
941
|
+
mode: toPrintOutputMode(appMode),
|
|
942
|
+
messages: parsed.messages,
|
|
943
|
+
initialMessage,
|
|
944
|
+
initialImages,
|
|
945
|
+
});
|
|
946
|
+
stopThemeWatcher();
|
|
947
|
+
restoreStdout();
|
|
948
|
+
if (exitCode !== 0) {
|
|
949
|
+
process.exitCode = exitCode;
|
|
695
950
|
}
|
|
696
951
|
return;
|
|
697
952
|
}
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
mode: toPrintOutputMode(appMode),
|
|
705
|
-
messages: parsed.messages,
|
|
706
|
-
initialMessage,
|
|
707
|
-
initialImages,
|
|
708
|
-
});
|
|
709
|
-
stopThemeWatcher();
|
|
710
|
-
restoreStdout();
|
|
711
|
-
if (exitCode !== 0) {
|
|
712
|
-
process.exitCode = exitCode;
|
|
713
|
-
}
|
|
714
|
-
return;
|
|
953
|
+
}
|
|
954
|
+
finally {
|
|
955
|
+
// Removes the .sock and .lock files so the session stops showing up in --list-sessions.
|
|
956
|
+
releaseAttachableRebind?.();
|
|
957
|
+
releaseAttachableCleanup?.();
|
|
958
|
+
await attachableSession?.stop();
|
|
715
959
|
}
|
|
716
960
|
}
|
|
717
961
|
//# sourceMappingURL=main.js.map
|