@draht/coding-agent 2026.7.30 → 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 +154 -0
- package/README.md +46 -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/cli/args.d.ts +10 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +69 -2
- 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/credential-print.d.ts +1 -1
- package/dist/cli/credential-print.d.ts.map +1 -1
- package/dist/cli/credential-print.js +5 -4
- package/dist/cli/credential-print.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 +87 -30
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +1 -1
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +1 -0
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +35 -16
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +149 -64
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts +5 -1
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +72 -15
- 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/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 +1 -1
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +9 -4
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +5 -0
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +25 -4
- package/dist/core/compaction/compaction.js.map +1 -1
- 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 +83 -20
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +13 -2
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +37 -2
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +189 -6
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.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 +5 -0
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +1 -0
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/model-registry.d.ts +3 -2
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +8 -8
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +34 -7
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-runtime.d.ts +7 -1
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +30 -10
- package/dist/core/model-runtime.js.map +1 -1
- 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 +21 -44
- 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/resource-loader.d.ts +21 -0
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +101 -24
- package/dist/core/resource-loader.js.map +1 -1
- 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.map +1 -1
- package/dist/core/sdk.js +3 -1
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager.d.ts +60 -1
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +53 -6
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-manager.d.ts +21 -0
- 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 +8 -9
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/bash.d.ts +1 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +5 -2
- 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/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/extensions/index.d.ts.map +1 -1
- package/dist/extensions/index.js +5 -1
- package/dist/extensions/index.js.map +1 -1
- package/dist/extensions/llama/provider.d.ts.map +1 -1
- package/dist/extensions/llama/provider.js +5 -1
- package/dist/extensions/llama/provider.js.map +1 -1
- 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 +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +242 -45
- package/dist/main.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/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/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 +20 -2
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector.js +21 -5
- package/dist/modes/interactive/components/tree-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +97 -3
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +394 -24
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +165 -7
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +68 -1
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.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.d.ts +1 -1
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js +22 -2
- 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/docs/attachable-sessions.md +79 -0
- package/docs/compaction.md +21 -21
- package/docs/containerization.md +23 -23
- package/docs/custom-provider.md +16 -16
- package/docs/development.md +9 -9
- package/docs/docs.json +6 -2
- package/docs/duet.md +42 -0
- package/docs/extensions.md +58 -58
- package/docs/index.md +10 -10
- package/docs/json.md +7 -7
- package/docs/keybindings.md +6 -5
- package/docs/llama-cpp.md +6 -6
- package/docs/models.md +6 -6
- package/docs/packages.md +43 -43
- package/docs/prompt-templates.md +4 -4
- package/docs/providers.md +12 -12
- package/docs/quickstart.md +32 -32
- package/docs/rpc.md +83 -12
- package/docs/sdk.md +15 -15
- package/docs/security.md +18 -18
- package/docs/session-format.md +35 -13
- package/docs/sessions.md +17 -14
- package/docs/settings.md +25 -18
- 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 +5 -5
- package/docs/usage.md +50 -50
- package/docs/windows.md +2 -2
- package/examples/extensions/overlay-qa-tests.ts +3 -3
- package/hooks/gsd/draht-quality-gate.js +3 -3
- package/package.json +11 -10
- 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/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
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* macOS Seatbelt backend (R44-SBX.1) -- `sandbox-exec -p <generated profile>`.
|
|
3
|
+
*
|
|
4
|
+
* This is the platform this machine can and does exercise for real: every claim
|
|
5
|
+
* in `seatbelt-profile.ts`'s doc comment was measured here, and the tests in
|
|
6
|
+
* `test/sandbox-backend.test.ts` run against the actual `/usr/bin/sandbox-exec`,
|
|
7
|
+
* not a stub.
|
|
8
|
+
*
|
|
9
|
+
* ## Flow
|
|
10
|
+
*
|
|
11
|
+
* 1. Render the policy to SBPL (`buildSeatbeltProfile`).
|
|
12
|
+
* 2. `sandbox-exec -p <profile> <shell> -c <command>` with a constructed env.
|
|
13
|
+
*
|
|
14
|
+
* There is no step where the profile touches the filesystem, and that is the
|
|
15
|
+
* point. This backend used to stage the SBPL at
|
|
16
|
+
* `mkdtemp(os.tmpdir())/policy.sb` and pass `-f <path>` -- but `os.tmpdir()` is
|
|
17
|
+
* in the write allowlist of *every* production policy (R44-SBX.2), so the file
|
|
18
|
+
* describing the sandbox sat inside the sandbox's own writable area. A confined
|
|
19
|
+
* command could therefore watch that directory and overwrite the profile of a
|
|
20
|
+
* later command with `(allow default)`; a reviewer demonstrated the write
|
|
21
|
+
* succeeding. Passing the profile inline through `-p` removes the artifact
|
|
22
|
+
* rather than trying to protect it: there is no path to race, no directory to
|
|
23
|
+
* watch, and no window between write and read.
|
|
24
|
+
*
|
|
25
|
+
* The profile is visible in the wrapper's argv, which is a disclosure of the
|
|
26
|
+
* policy (which directories are writable), never of a secret -- and a sandboxed
|
|
27
|
+
* process cannot read another process's argv anyway, since the profile denies
|
|
28
|
+
* `process-info*` against other processes.
|
|
29
|
+
*
|
|
30
|
+
* Regenerating per invocation rather than caching by policy hash is deliberate
|
|
31
|
+
* for v1: the policy is resolved per invocation anyway (R44-SBX.2). Profile
|
|
32
|
+
* generation is string building; Phase 46 owns the spawn-overhead budget and can
|
|
33
|
+
* revisit with numbers.
|
|
34
|
+
*
|
|
35
|
+
* ## `status()` and `exec()`
|
|
36
|
+
*
|
|
37
|
+
* `status()` runs the R44-SBX.4 self-test once and memoises the *promise*, so
|
|
38
|
+
* concurrent callers share one probe. `exec()` awaits that same status first and
|
|
39
|
+
* throws `SandboxUnavailableError` when it is not `available` -- **before**
|
|
40
|
+
* spawning anything. That ordering is the whole failure posture: a backend that
|
|
41
|
+
* cannot prove confinement does not run the command in a weaker sandbox and does
|
|
42
|
+
* not run it bare, it does not run it.
|
|
43
|
+
*
|
|
44
|
+
* ## `sandbox-exec` is deprecated
|
|
45
|
+
*
|
|
46
|
+
* It has carried a deprecation warning for years and still ships on every macOS;
|
|
47
|
+
* Chrome, Claude Code and Codex all depend on it. The risk is handled by
|
|
48
|
+
* structure rather than by hope: if Apple removes it, `existsSync` fails or the
|
|
49
|
+
* self-test fails, and this backend reports `unavailable`. Deprecation therefore
|
|
50
|
+
* degrades us to today's permission-gate behaviour (Phase 45), never to silently
|
|
51
|
+
* unconfined execution.
|
|
52
|
+
*/
|
|
53
|
+
import { type SandboxExecutor } from "./executor.ts";
|
|
54
|
+
import type { SandboxPolicy } from "./policy.ts";
|
|
55
|
+
export declare const DEFAULT_SANDBOX_EXEC_BIN = "/usr/bin/sandbox-exec";
|
|
56
|
+
/**
|
|
57
|
+
* Ceiling on the inline profile, well under the 1 MiB `ARG_MAX` this machine
|
|
58
|
+
* reports. A policy that renders larger than this is not one we hand to `execve`
|
|
59
|
+
* and hope: an `E2BIG` from the wrapper would surface as an opaque spawn failure,
|
|
60
|
+
* whereas refusing here surfaces as `unavailable`, which is the outcome every
|
|
61
|
+
* other "cannot confine" case in this module already produces.
|
|
62
|
+
*/
|
|
63
|
+
export declare const MAX_INLINE_PROFILE_BYTES: number;
|
|
64
|
+
/**
|
|
65
|
+
* Builds the wrapper argv.
|
|
66
|
+
*
|
|
67
|
+
* Exported so a test can assert the shape directly: the profile travels as the
|
|
68
|
+
* `-p` operand and **no element is a path to a profile file**, which is the
|
|
69
|
+
* invariant that keeps a sandboxed command from tampering with the profile of a
|
|
70
|
+
* later one.
|
|
71
|
+
*/
|
|
72
|
+
export declare function buildSandboxExecArgs(profile: string, shell: string, shellArgs: readonly string[], command: string): string[];
|
|
73
|
+
export interface SeatbeltSandboxOptions {
|
|
74
|
+
/**
|
|
75
|
+
* Path to `sandbox-exec`. Overridable chiefly as a test injection point for
|
|
76
|
+
* proving fail-closed behaviour -- point it at a nonexistent path and the
|
|
77
|
+
* backend must report `unavailable`, not fall back to a bare spawn. Same role
|
|
78
|
+
* the equivalent option plays in `packages/rlm/src/sandbox.ts`.
|
|
79
|
+
*/
|
|
80
|
+
sandboxExecBin?: string;
|
|
81
|
+
/** Explicit shell path from settings; defaults to `getShellConfig()`'s resolution. */
|
|
82
|
+
shellPath?: string;
|
|
83
|
+
/**
|
|
84
|
+
* Profile generator override. Exists so tests can hand the backend a
|
|
85
|
+
* deliberately broken or deliberately permissive profile and assert the
|
|
86
|
+
* self-test catches both. Production never sets it.
|
|
87
|
+
*/
|
|
88
|
+
buildProfile?: (policy: SandboxPolicy) => string;
|
|
89
|
+
/** Extra environment variable names to admit (Phase 45 wires this to settings). */
|
|
90
|
+
extraAllowedEnvVars?: readonly string[];
|
|
91
|
+
/** Seconds allowed for the self-test probe. Defaults to the self-test's own default. */
|
|
92
|
+
selfTestTimeoutSeconds?: number;
|
|
93
|
+
}
|
|
94
|
+
export declare function createSeatbeltSandboxExecutor(options?: SeatbeltSandboxOptions): SandboxExecutor;
|
|
95
|
+
//# sourceMappingURL=seatbelt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"seatbelt.d.ts","sourceRoot":"","sources":["../../../src/core/sandbox/seatbelt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AAKH,OAAO,EAGN,KAAK,eAAe,EAGpB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAKjD,eAAO,MAAM,wBAAwB,0BAA0B,CAAC;AAEhE;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,QAAa,CAAC;AAEnD;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CACnC,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,SAAS,MAAM,EAAE,EAC5B,OAAO,EAAE,MAAM,GACb,MAAM,EAAE,CAEV;AAED,MAAM,WAAW,sBAAsB;IACtC;;;;;OAKG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,sFAAsF;IACtF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,MAAM,CAAC;IACjD,mFAAmF;IACnF,mBAAmB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACxC,wFAAwF;IACxF,sBAAsB,CAAC,EAAE,MAAM,CAAC;CAChC;AAED,wBAAgB,6BAA6B,CAAC,OAAO,GAAE,sBAA2B,GAAG,eAAe,CAyFnG"}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* macOS Seatbelt backend (R44-SBX.1) -- `sandbox-exec -p <generated profile>`.
|
|
3
|
+
*
|
|
4
|
+
* This is the platform this machine can and does exercise for real: every claim
|
|
5
|
+
* in `seatbelt-profile.ts`'s doc comment was measured here, and the tests in
|
|
6
|
+
* `test/sandbox-backend.test.ts` run against the actual `/usr/bin/sandbox-exec`,
|
|
7
|
+
* not a stub.
|
|
8
|
+
*
|
|
9
|
+
* ## Flow
|
|
10
|
+
*
|
|
11
|
+
* 1. Render the policy to SBPL (`buildSeatbeltProfile`).
|
|
12
|
+
* 2. `sandbox-exec -p <profile> <shell> -c <command>` with a constructed env.
|
|
13
|
+
*
|
|
14
|
+
* There is no step where the profile touches the filesystem, and that is the
|
|
15
|
+
* point. This backend used to stage the SBPL at
|
|
16
|
+
* `mkdtemp(os.tmpdir())/policy.sb` and pass `-f <path>` -- but `os.tmpdir()` is
|
|
17
|
+
* in the write allowlist of *every* production policy (R44-SBX.2), so the file
|
|
18
|
+
* describing the sandbox sat inside the sandbox's own writable area. A confined
|
|
19
|
+
* command could therefore watch that directory and overwrite the profile of a
|
|
20
|
+
* later command with `(allow default)`; a reviewer demonstrated the write
|
|
21
|
+
* succeeding. Passing the profile inline through `-p` removes the artifact
|
|
22
|
+
* rather than trying to protect it: there is no path to race, no directory to
|
|
23
|
+
* watch, and no window between write and read.
|
|
24
|
+
*
|
|
25
|
+
* The profile is visible in the wrapper's argv, which is a disclosure of the
|
|
26
|
+
* policy (which directories are writable), never of a secret -- and a sandboxed
|
|
27
|
+
* process cannot read another process's argv anyway, since the profile denies
|
|
28
|
+
* `process-info*` against other processes.
|
|
29
|
+
*
|
|
30
|
+
* Regenerating per invocation rather than caching by policy hash is deliberate
|
|
31
|
+
* for v1: the policy is resolved per invocation anyway (R44-SBX.2). Profile
|
|
32
|
+
* generation is string building; Phase 46 owns the spawn-overhead budget and can
|
|
33
|
+
* revisit with numbers.
|
|
34
|
+
*
|
|
35
|
+
* ## `status()` and `exec()`
|
|
36
|
+
*
|
|
37
|
+
* `status()` runs the R44-SBX.4 self-test once and memoises the *promise*, so
|
|
38
|
+
* concurrent callers share one probe. `exec()` awaits that same status first and
|
|
39
|
+
* throws `SandboxUnavailableError` when it is not `available` -- **before**
|
|
40
|
+
* spawning anything. That ordering is the whole failure posture: a backend that
|
|
41
|
+
* cannot prove confinement does not run the command in a weaker sandbox and does
|
|
42
|
+
* not run it bare, it does not run it.
|
|
43
|
+
*
|
|
44
|
+
* ## `sandbox-exec` is deprecated
|
|
45
|
+
*
|
|
46
|
+
* It has carried a deprecation warning for years and still ships on every macOS;
|
|
47
|
+
* Chrome, Claude Code and Codex all depend on it. The risk is handled by
|
|
48
|
+
* structure rather than by hope: if Apple removes it, `existsSync` fails or the
|
|
49
|
+
* self-test fails, and this backend reports `unavailable`. Deprecation therefore
|
|
50
|
+
* degrades us to today's permission-gate behaviour (Phase 45), never to silently
|
|
51
|
+
* unconfined execution.
|
|
52
|
+
*/
|
|
53
|
+
import { existsSync } from "node:fs";
|
|
54
|
+
import { getShellConfig } from "../../utils/shell.js";
|
|
55
|
+
import { buildSandboxEnv } from "./env.js";
|
|
56
|
+
import { SandboxUnavailableError, } from "./executor.js";
|
|
57
|
+
import { buildSeatbeltProfile } from "./seatbelt-profile.js";
|
|
58
|
+
import { runSandboxSelfTest } from "./self-test.js";
|
|
59
|
+
import { spawnSandboxedProcess } from "./spawn.js";
|
|
60
|
+
export const DEFAULT_SANDBOX_EXEC_BIN = "/usr/bin/sandbox-exec";
|
|
61
|
+
/**
|
|
62
|
+
* Ceiling on the inline profile, well under the 1 MiB `ARG_MAX` this machine
|
|
63
|
+
* reports. A policy that renders larger than this is not one we hand to `execve`
|
|
64
|
+
* and hope: an `E2BIG` from the wrapper would surface as an opaque spawn failure,
|
|
65
|
+
* whereas refusing here surfaces as `unavailable`, which is the outcome every
|
|
66
|
+
* other "cannot confine" case in this module already produces.
|
|
67
|
+
*/
|
|
68
|
+
export const MAX_INLINE_PROFILE_BYTES = 256 * 1024;
|
|
69
|
+
/**
|
|
70
|
+
* Builds the wrapper argv.
|
|
71
|
+
*
|
|
72
|
+
* Exported so a test can assert the shape directly: the profile travels as the
|
|
73
|
+
* `-p` operand and **no element is a path to a profile file**, which is the
|
|
74
|
+
* invariant that keeps a sandboxed command from tampering with the profile of a
|
|
75
|
+
* later one.
|
|
76
|
+
*/
|
|
77
|
+
export function buildSandboxExecArgs(profile, shell, shellArgs, command) {
|
|
78
|
+
return ["-p", profile, shell, ...shellArgs, command];
|
|
79
|
+
}
|
|
80
|
+
export function createSeatbeltSandboxExecutor(options = {}) {
|
|
81
|
+
const sandboxExecBin = options.sandboxExecBin ?? DEFAULT_SANDBOX_EXEC_BIN;
|
|
82
|
+
const buildProfile = options.buildProfile ?? buildSeatbeltProfile;
|
|
83
|
+
/**
|
|
84
|
+
* Runs one command confined by `policy`. Used by both `exec` and the
|
|
85
|
+
* self-test, so the probe cannot pass through a path production does not use.
|
|
86
|
+
*/
|
|
87
|
+
const runConfined = async (command, cwd, policy, execOptions) => {
|
|
88
|
+
if (!existsSync(sandboxExecBin)) {
|
|
89
|
+
throw new SandboxUnavailableError(`macOS sandbox-exec not found at ${JSON.stringify(sandboxExecBin)} -- refusing to run the command unconfined`);
|
|
90
|
+
}
|
|
91
|
+
let profile;
|
|
92
|
+
try {
|
|
93
|
+
profile = buildProfile(policy);
|
|
94
|
+
}
|
|
95
|
+
catch (err) {
|
|
96
|
+
// A policy this backend cannot render exactly is a policy it cannot
|
|
97
|
+
// enforce. Surfacing it as `SandboxUnavailableError` (rather than letting
|
|
98
|
+
// a `SandboxProfileError` escape) keeps every "could not confine" outcome
|
|
99
|
+
// one type at the call site -- and, as everywhere else here, the command
|
|
100
|
+
// has not been spawned at this point and will not be.
|
|
101
|
+
throw new SandboxUnavailableError(`cannot generate a sandbox profile for this policy: ${err instanceof Error ? err.message : String(err)}`);
|
|
102
|
+
}
|
|
103
|
+
const profileBytes = Buffer.byteLength(profile, "utf8");
|
|
104
|
+
if (profileBytes > MAX_INLINE_PROFILE_BYTES) {
|
|
105
|
+
throw new SandboxUnavailableError(`the sandbox profile for this policy is ${profileBytes} bytes, over the ${MAX_INLINE_PROFILE_BYTES}-byte limit for passing it inline -- refusing to run the command unconfined`);
|
|
106
|
+
}
|
|
107
|
+
const shell = getShellConfig(options.shellPath);
|
|
108
|
+
return await spawnSandboxedProcess(sandboxExecBin, buildSandboxExecArgs(profile, shell.shell, shell.args, command), {
|
|
109
|
+
cwd,
|
|
110
|
+
env: buildSandboxEnv({
|
|
111
|
+
source: execOptions.env,
|
|
112
|
+
extraAllowedNames: options.extraAllowedEnvVars,
|
|
113
|
+
}),
|
|
114
|
+
onData: execOptions.onData,
|
|
115
|
+
signal: execOptions.signal,
|
|
116
|
+
timeout: execOptions.timeout,
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
let statusPromise;
|
|
120
|
+
const status = () => {
|
|
121
|
+
statusPromise ??= runSandboxSelfTest({
|
|
122
|
+
backendName: "seatbelt",
|
|
123
|
+
timeoutSeconds: options.selfTestTimeoutSeconds,
|
|
124
|
+
run: async (command, cwd, policy, timeoutSeconds) => {
|
|
125
|
+
let output = "";
|
|
126
|
+
const result = await runConfined(command, cwd, policy, {
|
|
127
|
+
onData: (data) => {
|
|
128
|
+
output += data.toString();
|
|
129
|
+
},
|
|
130
|
+
timeout: timeoutSeconds,
|
|
131
|
+
});
|
|
132
|
+
return { exitCode: result.exitCode, output };
|
|
133
|
+
},
|
|
134
|
+
// A throwing `runConfined` (missing binary, unrenderable policy) is a
|
|
135
|
+
// failed self-test like any other; `runSandboxSelfTest` catches it and
|
|
136
|
+
// turns it into a reason.
|
|
137
|
+
}).catch((err) => ({
|
|
138
|
+
available: false,
|
|
139
|
+
reason: `seatbelt sandbox self-test failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
140
|
+
}));
|
|
141
|
+
return statusPromise;
|
|
142
|
+
};
|
|
143
|
+
return {
|
|
144
|
+
name: "seatbelt",
|
|
145
|
+
status,
|
|
146
|
+
exec: async (command, cwd, policy, execOptions) => {
|
|
147
|
+
const current = await status();
|
|
148
|
+
if (!current.available)
|
|
149
|
+
throw new SandboxUnavailableError(current.reason);
|
|
150
|
+
return runConfined(command, cwd, policy, execOptions);
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
//# sourceMappingURL=seatbelt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"seatbelt.js","sourceRoot":"","sources":["../../../src/core/sandbox/seatbelt.ts"],"names":[],"mappings":"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","sourcesContent":["/**\n * macOS Seatbelt backend (R44-SBX.1) -- `sandbox-exec -p <generated profile>`.\n *\n * This is the platform this machine can and does exercise for real: every claim\n * in `seatbelt-profile.ts`'s doc comment was measured here, and the tests in\n * `test/sandbox-backend.test.ts` run against the actual `/usr/bin/sandbox-exec`,\n * not a stub.\n *\n * ## Flow\n *\n * 1. Render the policy to SBPL (`buildSeatbeltProfile`).\n * 2. `sandbox-exec -p <profile> <shell> -c <command>` with a constructed env.\n *\n * There is no step where the profile touches the filesystem, and that is the\n * point. This backend used to stage the SBPL at\n * `mkdtemp(os.tmpdir())/policy.sb` and pass `-f <path>` -- but `os.tmpdir()` is\n * in the write allowlist of *every* production policy (R44-SBX.2), so the file\n * describing the sandbox sat inside the sandbox's own writable area. A confined\n * command could therefore watch that directory and overwrite the profile of a\n * later command with `(allow default)`; a reviewer demonstrated the write\n * succeeding. Passing the profile inline through `-p` removes the artifact\n * rather than trying to protect it: there is no path to race, no directory to\n * watch, and no window between write and read.\n *\n * The profile is visible in the wrapper's argv, which is a disclosure of the\n * policy (which directories are writable), never of a secret -- and a sandboxed\n * process cannot read another process's argv anyway, since the profile denies\n * `process-info*` against other processes.\n *\n * Regenerating per invocation rather than caching by policy hash is deliberate\n * for v1: the policy is resolved per invocation anyway (R44-SBX.2). Profile\n * generation is string building; Phase 46 owns the spawn-overhead budget and can\n * revisit with numbers.\n *\n * ## `status()` and `exec()`\n *\n * `status()` runs the R44-SBX.4 self-test once and memoises the *promise*, so\n * concurrent callers share one probe. `exec()` awaits that same status first and\n * throws `SandboxUnavailableError` when it is not `available` -- **before**\n * spawning anything. That ordering is the whole failure posture: a backend that\n * cannot prove confinement does not run the command in a weaker sandbox and does\n * not run it bare, it does not run it.\n *\n * ## `sandbox-exec` is deprecated\n *\n * It has carried a deprecation warning for years and still ships on every macOS;\n * Chrome, Claude Code and Codex all depend on it. The risk is handled by\n * structure rather than by hope: if Apple removes it, `existsSync` fails or the\n * self-test fails, and this backend reports `unavailable`. Deprecation therefore\n * degrades us to today's permission-gate behaviour (Phase 45), never to silently\n * unconfined execution.\n */\n\nimport { existsSync } from \"node:fs\";\nimport { getShellConfig } from \"../../utils/shell.ts\";\nimport { buildSandboxEnv } from \"./env.ts\";\nimport {\n\ttype SandboxExecOptions,\n\ttype SandboxExecResult,\n\ttype SandboxExecutor,\n\ttype SandboxStatus,\n\tSandboxUnavailableError,\n} from \"./executor.ts\";\nimport type { SandboxPolicy } from \"./policy.ts\";\nimport { buildSeatbeltProfile } from \"./seatbelt-profile.ts\";\nimport { runSandboxSelfTest } from \"./self-test.ts\";\nimport { spawnSandboxedProcess } from \"./spawn.ts\";\n\nexport const DEFAULT_SANDBOX_EXEC_BIN = \"/usr/bin/sandbox-exec\";\n\n/**\n * Ceiling on the inline profile, well under the 1 MiB `ARG_MAX` this machine\n * reports. A policy that renders larger than this is not one we hand to `execve`\n * and hope: an `E2BIG` from the wrapper would surface as an opaque spawn failure,\n * whereas refusing here surfaces as `unavailable`, which is the outcome every\n * other \"cannot confine\" case in this module already produces.\n */\nexport const MAX_INLINE_PROFILE_BYTES = 256 * 1024;\n\n/**\n * Builds the wrapper argv.\n *\n * Exported so a test can assert the shape directly: the profile travels as the\n * `-p` operand and **no element is a path to a profile file**, which is the\n * invariant that keeps a sandboxed command from tampering with the profile of a\n * later one.\n */\nexport function buildSandboxExecArgs(\n\tprofile: string,\n\tshell: string,\n\tshellArgs: readonly string[],\n\tcommand: string,\n): string[] {\n\treturn [\"-p\", profile, shell, ...shellArgs, command];\n}\n\nexport interface SeatbeltSandboxOptions {\n\t/**\n\t * Path to `sandbox-exec`. Overridable chiefly as a test injection point for\n\t * proving fail-closed behaviour -- point it at a nonexistent path and the\n\t * backend must report `unavailable`, not fall back to a bare spawn. Same role\n\t * the equivalent option plays in `packages/rlm/src/sandbox.ts`.\n\t */\n\tsandboxExecBin?: string;\n\t/** Explicit shell path from settings; defaults to `getShellConfig()`'s resolution. */\n\tshellPath?: string;\n\t/**\n\t * Profile generator override. Exists so tests can hand the backend a\n\t * deliberately broken or deliberately permissive profile and assert the\n\t * self-test catches both. Production never sets it.\n\t */\n\tbuildProfile?: (policy: SandboxPolicy) => string;\n\t/** Extra environment variable names to admit (Phase 45 wires this to settings). */\n\textraAllowedEnvVars?: readonly string[];\n\t/** Seconds allowed for the self-test probe. Defaults to the self-test's own default. */\n\tselfTestTimeoutSeconds?: number;\n}\n\nexport function createSeatbeltSandboxExecutor(options: SeatbeltSandboxOptions = {}): SandboxExecutor {\n\tconst sandboxExecBin = options.sandboxExecBin ?? DEFAULT_SANDBOX_EXEC_BIN;\n\tconst buildProfile = options.buildProfile ?? buildSeatbeltProfile;\n\n\t/**\n\t * Runs one command confined by `policy`. Used by both `exec` and the\n\t * self-test, so the probe cannot pass through a path production does not use.\n\t */\n\tconst runConfined = async (\n\t\tcommand: string,\n\t\tcwd: string,\n\t\tpolicy: SandboxPolicy,\n\t\texecOptions: SandboxExecOptions,\n\t): Promise<SandboxExecResult> => {\n\t\tif (!existsSync(sandboxExecBin)) {\n\t\t\tthrow new SandboxUnavailableError(\n\t\t\t\t`macOS sandbox-exec not found at ${JSON.stringify(sandboxExecBin)} -- refusing to run the command unconfined`,\n\t\t\t);\n\t\t}\n\t\tlet profile: string;\n\t\ttry {\n\t\t\tprofile = buildProfile(policy);\n\t\t} catch (err) {\n\t\t\t// A policy this backend cannot render exactly is a policy it cannot\n\t\t\t// enforce. Surfacing it as `SandboxUnavailableError` (rather than letting\n\t\t\t// a `SandboxProfileError` escape) keeps every \"could not confine\" outcome\n\t\t\t// one type at the call site -- and, as everywhere else here, the command\n\t\t\t// has not been spawned at this point and will not be.\n\t\t\tthrow new SandboxUnavailableError(\n\t\t\t\t`cannot generate a sandbox profile for this policy: ${err instanceof Error ? err.message : String(err)}`,\n\t\t\t);\n\t\t}\n\t\tconst profileBytes = Buffer.byteLength(profile, \"utf8\");\n\t\tif (profileBytes > MAX_INLINE_PROFILE_BYTES) {\n\t\t\tthrow new SandboxUnavailableError(\n\t\t\t\t`the sandbox profile for this policy is ${profileBytes} bytes, over the ${MAX_INLINE_PROFILE_BYTES}-byte limit for passing it inline -- refusing to run the command unconfined`,\n\t\t\t);\n\t\t}\n\t\tconst shell = getShellConfig(options.shellPath);\n\t\treturn await spawnSandboxedProcess(\n\t\t\tsandboxExecBin,\n\t\t\tbuildSandboxExecArgs(profile, shell.shell, shell.args, command),\n\t\t\t{\n\t\t\t\tcwd,\n\t\t\t\tenv: buildSandboxEnv({\n\t\t\t\t\tsource: execOptions.env,\n\t\t\t\t\textraAllowedNames: options.extraAllowedEnvVars,\n\t\t\t\t}),\n\t\t\t\tonData: execOptions.onData,\n\t\t\t\tsignal: execOptions.signal,\n\t\t\t\ttimeout: execOptions.timeout,\n\t\t\t},\n\t\t);\n\t};\n\n\tlet statusPromise: Promise<SandboxStatus> | undefined;\n\tconst status = (): Promise<SandboxStatus> => {\n\t\tstatusPromise ??= runSandboxSelfTest({\n\t\t\tbackendName: \"seatbelt\",\n\t\t\ttimeoutSeconds: options.selfTestTimeoutSeconds,\n\t\t\trun: async (command, cwd, policy, timeoutSeconds) => {\n\t\t\t\tlet output = \"\";\n\t\t\t\tconst result = await runConfined(command, cwd, policy, {\n\t\t\t\t\tonData: (data) => {\n\t\t\t\t\t\toutput += data.toString();\n\t\t\t\t\t},\n\t\t\t\t\ttimeout: timeoutSeconds,\n\t\t\t\t});\n\t\t\t\treturn { exitCode: result.exitCode, output };\n\t\t\t},\n\t\t\t// A throwing `runConfined` (missing binary, unrenderable policy) is a\n\t\t\t// failed self-test like any other; `runSandboxSelfTest` catches it and\n\t\t\t// turns it into a reason.\n\t\t}).catch((err) => ({\n\t\t\tavailable: false as const,\n\t\t\treason: `seatbelt sandbox self-test failed: ${err instanceof Error ? err.message : String(err)}`,\n\t\t}));\n\t\treturn statusPromise;\n\t};\n\n\treturn {\n\t\tname: \"seatbelt\",\n\t\tstatus,\n\t\texec: async (command, cwd, policy, execOptions) => {\n\t\t\tconst current = await status();\n\t\t\tif (!current.available) throw new SandboxUnavailableError(current.reason);\n\t\t\treturn runConfined(command, cwd, policy, execOptions);\n\t\t},\n\t};\n}\n"]}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Startup self-test (R44-SBX.4) -- the only thing that may report `available`.
|
|
3
|
+
*
|
|
4
|
+
* Phase 28 established the pattern: prove the sandbox holds before trusting it
|
|
5
|
+
* (`packages/rlm/src/session.ts` sends a `self_test` message and refuses the
|
|
6
|
+
* session unless the driver reports network and file reads actually blocked).
|
|
7
|
+
* This is the same idea applied to a shell backend, with one addition that
|
|
8
|
+
* turned out to matter more than the original probe.
|
|
9
|
+
*
|
|
10
|
+
* ## Why the probe is two-sided
|
|
11
|
+
*
|
|
12
|
+
* The obvious self-test -- "try to write outside the allowlist, expect failure"
|
|
13
|
+
* -- passes for the *worst possible* backend. Measured on macOS: a profile with
|
|
14
|
+
* a syntax error makes `sandbox-exec` exit 65 **without ever running the
|
|
15
|
+
* command**. The write does not happen, no file appears, and a one-sided probe
|
|
16
|
+
* concludes "confined" about a backend that cannot confine anything. It would
|
|
17
|
+
* then report `available`, and every downstream permission decision would
|
|
18
|
+
* inherit that lie -- precisely the failure this requirement exists to prevent.
|
|
19
|
+
*
|
|
20
|
+
* So every probe carries a positive control as well as a negative one:
|
|
21
|
+
*
|
|
22
|
+
* | control | probe | proves |
|
|
23
|
+
* |----------|----------------------------------|---------------------------------|
|
|
24
|
+
* | positive | write *inside* the allowlist | the sandbox ran the command |
|
|
25
|
+
* | negative | write *outside* the allowlist | writes are actually confined |
|
|
26
|
+
* | positive | loopback connect, network **on** | the network probe can connect |
|
|
27
|
+
* | negative | loopback connect, network **off**| the network is actually cut |
|
|
28
|
+
* | negative | exec a setuid-root binary | privileges cannot be acquired |
|
|
29
|
+
*
|
|
30
|
+
* A broken profile fails the positive controls. An over-permissive profile
|
|
31
|
+
* (`(allow default)` and nothing else) fails the negative ones. Both answer
|
|
32
|
+
* `unavailable`. There is no third outcome.
|
|
33
|
+
*
|
|
34
|
+
* ## The privilege-escalation probe, and what it is actually worth
|
|
35
|
+
*
|
|
36
|
+
* `SandboxPolicy.allowPrivilegeEscalation` is typed as the literal `false`
|
|
37
|
+
* precisely because it is an invariant no caller may widen -- yet the self-test
|
|
38
|
+
* used to grant `available` without testing it at all, and `linux.ts` leans on
|
|
39
|
+
* this self-test as its entire safety argument. So the probe now attempts the
|
|
40
|
+
* escalation from inside the throwaway sandbox and reports two facts:
|
|
41
|
+
*
|
|
42
|
+
* - **`privilegeEscalation`** -- it locates a setuid-root binary on the host
|
|
43
|
+
* (`sudo`, then `su`) and executes it. Three outcomes matter:
|
|
44
|
+
* `escalated:*` (it acquired uid 0 -- an outright failure), `exec-refused:*`
|
|
45
|
+
* (the kernel refused to `exec` a setuid binary from inside the sandbox), and
|
|
46
|
+
* `ran:*` (it executed but did not acquire privileges).
|
|
47
|
+
* - **`noNewPrivs`** -- on Linux, `NoNewPrivs` from `/proc/self/status`. `1` is
|
|
48
|
+
* the kernel's own guarantee that no `exec` can gain privileges, which is
|
|
49
|
+
* exactly the mechanism `linux.ts` claims bubblewrap gives it (and that
|
|
50
|
+
* Landlock requires); `not-linux` elsewhere.
|
|
51
|
+
*
|
|
52
|
+
* The verdict is fail-closed and requires *evidence*, not absence of failure:
|
|
53
|
+
* `escalated:*` and `NoNewPrivs: 0` are failures, and a pass needs either
|
|
54
|
+
* `exec-refused:*` or `NoNewPrivs: 1`. A bare `ran:*` is deliberately **not**
|
|
55
|
+
* enough -- on a host where the user simply has no `sudo` rights, an entirely
|
|
56
|
+
* unconfined process produces the same `ran:*`, which is the one-sided-probe
|
|
57
|
+
* mistake this module already refuses to make elsewhere.
|
|
58
|
+
*
|
|
59
|
+
* Measured on macOS 25.5: `exec` of `/usr/bin/sudo` from inside *any* seatbelt
|
|
60
|
+
* sandbox fails `EPERM` (`exec-refused:EPERM`), while the same `exec` outside
|
|
61
|
+
* one succeeds -- so on darwin the negative control has a real positive control
|
|
62
|
+
* behind it. On Linux under bubblewrap the evidence is `NoNewPrivs: 1`; the
|
|
63
|
+
* `unshare` fallback establishes neither and therefore reports `unavailable`,
|
|
64
|
+
* which is the fail-closed reading of an invariant that backend cannot show it
|
|
65
|
+
* holds.
|
|
66
|
+
*
|
|
67
|
+
* ## Evidence comes from outside the sandbox
|
|
68
|
+
*
|
|
69
|
+
* The probe reports what it observed, but the probe runs inside the thing under
|
|
70
|
+
* test, so its word alone is not evidence. Every negative control is confirmed
|
|
71
|
+
* from the parent: the file the probe was told to create must not exist on disk
|
|
72
|
+
* afterwards, and the loopback listener -- a real server in this process -- must
|
|
73
|
+
* not have accepted a connection. A backend that lets a write through but
|
|
74
|
+
* garbles its own stderr still fails.
|
|
75
|
+
*
|
|
76
|
+
* ## Why network is probed even for a network-on session
|
|
77
|
+
*
|
|
78
|
+
* The self-test runs once per backend instance and covers both axes, so the
|
|
79
|
+
* cached answer is valid for any policy the session later uses. If network-off
|
|
80
|
+
* enforcement is broken while write confinement works, the backend reports
|
|
81
|
+
* `unavailable` even for sessions that would have run with network on. That is
|
|
82
|
+
* deliberately conservative: `available` is a claim about the backend, and half
|
|
83
|
+
* a backend is not one.
|
|
84
|
+
*/
|
|
85
|
+
import type { SandboxStatus } from "./executor.ts";
|
|
86
|
+
import { type SandboxPolicy } from "./policy.ts";
|
|
87
|
+
/**
|
|
88
|
+
* Runs one command through the backend under test and returns its exit code and
|
|
89
|
+
* combined output. Backends pass their own `exec` here so the self-test and
|
|
90
|
+
* production execution cannot drift apart.
|
|
91
|
+
*/
|
|
92
|
+
export type SandboxSelfTestRunner = (command: string, cwd: string, policy: SandboxPolicy, timeoutSeconds: number) => Promise<{
|
|
93
|
+
exitCode: number | null;
|
|
94
|
+
output: string;
|
|
95
|
+
}>;
|
|
96
|
+
export interface SandboxSelfTestOptions {
|
|
97
|
+
/** Backend name, used only to make the failure reason say who failed. */
|
|
98
|
+
backendName: string;
|
|
99
|
+
run: SandboxSelfTestRunner;
|
|
100
|
+
/** Seconds. Defaults to 30. */
|
|
101
|
+
timeoutSeconds?: number;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Runs the self-test in a throwaway sandbox and returns the status the backend
|
|
105
|
+
* may report. Never throws: any error is itself a failed self-test, and a
|
|
106
|
+
* self-test that blew up is not one that passed.
|
|
107
|
+
*/
|
|
108
|
+
export declare function runSandboxSelfTest(options: SandboxSelfTestOptions): Promise<SandboxStatus>;
|
|
109
|
+
//# sourceMappingURL=self-test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"self-test.d.ts","sourceRoot":"","sources":["../../../src/core/sandbox/self-test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmFG;AAMH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAA0B,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AA2HzE;;;;GAIG;AACH,MAAM,MAAM,qBAAqB,GAAG,CACnC,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,aAAa,EACrB,cAAc,EAAE,MAAM,KAClB,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAE1D,MAAM,WAAW,sBAAsB;IACtC,yEAAyE;IACzE,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,EAAE,qBAAqB,CAAC;IAC3B,+BAA+B;IAC/B,cAAc,CAAC,EAAE,MAAM,CAAC;CACxB;AA8DD;;;;GAIG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,aAAa,CAAC,CA8IhG"}
|