@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 @@
|
|
|
1
|
+
{"version":3,"file":"relay-ui-context.js","sourceRoot":"","sources":["../../../src/core/permission-relay/relay-ui-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAezC,OAAO,EACN,YAAY,EAGZ,cAAc,EACd,eAAe,GAMf,MAAM,YAAY,CAAC;AAuBpB;;;;;GAKG;AACH,MAAM,kBAAkB,GAA4D,MAAM,CAAC,MAAM,CAAC;IACjG,OAAO,EAAE,IAAI;IACb,IAAI,EAAE,KAAK;CACX,CAAC,CAAC;AAEH;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,SAAS,CAAC;AAC3C,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC;AACrC,MAAM,uBAAuB,GAA+B,MAAM,CAAC,MAAM,CAAC;IACzE,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,iBAAiB,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAkB,EAAE,CAAC;IACpF,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,cAAc,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAe,EAAE,CAAC;CAC7E,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,cAAc,GAAiB,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AAiC3E;;;;;;;;;;GAUG;AACH,SAAS,KAAK,CAAI,EAAU,EAAE,KAAa,EAAE,KAAQ,EAAE,QAAuC;IAC7F,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,CAAC;AACvD,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,UAAU,CAAI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BAAiB,CAAC,MAAyB;IACnD,8FAA8F;IAC9F,gGAAgG;IAChG,+FAA+F;IAC/F,+FAA+F;IAC/F,4FAA4F;IAC5F,6FAA6F;IAC7F,2FAA2F;IAC3F,MAAM,OAAO,GAAwC,EAAE,CAAC;IACxD,KAAK,IAAI,QAAQ,GAAG,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE,CAAC;QAC7D,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC/B,IAAI,OAAO,KAAK,KAAK,QAAQ;YAAE,SAAS;QACxC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,QAAQ,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;IACzD,CAAC;IACD,OAAO,UAAU,CAAC,OAAO,CAAC,CAAC;AAC5B,CAAC","sourcesContent":["/**\n * RelayUIContext — the decorator that lets a remote surface answer a local dialog.\n *\n * It wraps EXACTLY `confirm`, `select` and `input`. Every other `ExtensionUIContext` member is\n * hand-delegated verbatim. This is deliberately NOT a Proxy: `getEditorText`, `theme`,\n * `getAllThemes`, `getTheme`, `getToolsExpanded` and `getEditorComponent` are synchronous reads of\n * the base's local state, and `setWidget`/`setFooter`/`setHeader`/`custom` take component\n * factories that cannot be serialized. `editor` and `custom` therefore stay purely local by\n * documented exception.\n *\n * THE INVARIANT THIS FILE EXISTS TO HOLD: an offered option CARRIES the value the caller receives\n * when it comes back. Nothing derives that value later — not from the option's index, not from its\n * position relative to its siblings, not by matching labels across two arrays, not from a magic id.\n * Every past defect here (an approval read as a denial, a denial read as an approval, an answered\n * \"Deny\" resolved to the string \"Allow\") was one of those derivations. There is exactly one\n * constructor of an offered option, {@link offer}, and it takes the caller-side value as an\n * argument — so an option with no resolution cannot be built at all.\n *\n * ITS COROLLARY: a caller vocabulary this file cannot honour is REJECTED, never repaired.\n * {@link classifyVocabulary} is the one gate, and it has exactly three outcomes — absent, valid,\n * invalid. Invalid offers nothing remotely at all, so the ask falls to the local surface or to the\n * raising method's own fail-closed default. Quietly substituting our default pair for a caller's\n * rejected one would broadcast an approval that caller never authorised, and a human tapping it\n * would run the gated call.\n */\n\nimport { randomUUID } from \"node:crypto\";\nimport type { Component, OverlayHandle, OverlayOptions, TUI } from \"@draht/tui\";\nimport type { Theme } from \"../../modes/interactive/theme/theme.ts\";\nimport type {\n\tAutocompleteProviderFactory,\n\tEditorFactory,\n\tExtensionUIContext,\n\tExtensionUIDialogOptions,\n\tExtensionWidgetOptions,\n\tPermissionAskDetail,\n\tTerminalInputHandler,\n\tWorkingIndicatorOptions,\n} from \"../extensions/types.ts\";\nimport type { ReadonlyFooterDataProvider } from \"../footer-data-provider.ts\";\nimport type { KeybindingsManager } from \"../keybindings.ts\";\nimport {\n\tisRelayEnded,\n\ttype LocalSurface,\n\ttype PermissionRelay,\n\tRELAY_ANSWERED,\n\tRELAY_CANCELLED,\n\ttype RelayAnswer,\n\ttype RelayAsk,\n\ttype RelayDecider,\n\ttype RelayEnded,\n\ttype RelayOutcome,\n} from \"./types.ts\";\n\n/** One entry of a permission vocabulary: an id, a label, and the decision it DECLARES. */\ntype PermissionOption = PermissionAskDetail[\"options\"][number];\n\n/**\n * One option this file has PROVEN valid: its three primitives, copied out and frozen.\n *\n * This is the gate's OWN data. Every field was read exactly once, during validation, and nothing\n * downstream ever touches the caller's array again — so the option that was validated and the\n * option that is offered are the same read BY CONSTRUCTION, and no getter, Proxy or later mutation\n * can separate them. Handing the caller's own array back as the verdict made proof and use two\n * different reads of memory this file does not own: a `decision` getter answering \"deny\" to the\n * validation read and \"approve\" to the mint produced a wire option labelled \"Deny\" that resolved\n * `true`, and an `id` getter unique during the uniqueness pass and shared at mint collapsed two\n * options into one while `detail.options` still rendered both.\n */\ninterface ValidatedOption {\n\treadonly id: string;\n\treadonly label: string;\n\treadonly decision: PermissionOption[\"decision\"];\n}\n\n/**\n * The caller-side meaning of each declared decision.\n *\n * A total map from the vocabulary's own word to the boolean a `confirm` caller receives. It is not\n * a test of an id and not a position rule: the option says what it means, this only translates.\n */\nconst CONFIRM_RESOLUTION: Readonly<Record<PermissionOption[\"decision\"], boolean>> = Object.freeze({\n\tapprove: true,\n\tdeny: false,\n});\n\n/**\n * The frozen two-way vocabulary a bare `confirm` offers when the caller supplied no\n * `detail.options`.\n *\n * These ids are a DEFAULT, never a test: a caller may offer any vocabulary it likes (T5's tool\n * permission ask does), and every vocabulary states its own semantics through `decision`. Nothing\n * in this file compares an answered id against a literal.\n */\nexport const APPROVE_OPTION_ID = \"approve\";\nexport const DENY_OPTION_ID = \"deny\";\nconst DEFAULT_CONFIRM_OPTIONS: readonly ValidatedOption[] = Object.freeze([\n\tObject.freeze({ id: APPROVE_OPTION_ID, label: \"Yes\", decision: \"approve\" as const }),\n\tObject.freeze({ id: DENY_OPTION_ID, label: \"No\", decision: \"deny\" as const }),\n]);\n\n/**\n * Nobody decided: the ask was dismissed from outside via the caller's own AbortSignal, the relay\n * gave up while no local surface existed to fall back to, or the caller's own declared timeout\n * expired with the decorator holding the only arm.\n */\nconst SYSTEM_DECIDER: RelayDecider = { surface: \"system\", clientId: null };\n\n/** An option as it travels on the wire. `decision` is rendering data; it interprets nothing. */\ntype WireOption = RelayAsk[\"options\"][number];\n\n/**\n * One offered option, together with the value the CALLER receives when that option comes back.\n *\n * `resolution` is REQUIRED. An offered option with no caller-side value is unrepresentable, which\n * is what makes \"a fully tappable remote dialog whose every answer is discarded as silence\"\n * impossible rather than merely unlikely.\n *\n * `declares` is the option's own `decision` word, carried ALONG so a remote client can render a\n * denial as destructive without joining two arrays by id. It is descriptive only: `resolution` was\n * already bound at construction, and nothing ever reads `declares` back to decide anything.\n */\ninterface OfferedOption<T> {\n\treadonly id: string;\n\treadonly label: string;\n\treadonly resolution: { readonly value: T };\n\treadonly declares?: PermissionOption[\"decision\"];\n}\n\n/**\n * The offered set of one ask, keyed by the id that travels on the wire.\n *\n * Minted ONCE and the single authority for both halves of the round trip: its values are what gets\n * broadcast, and it is the only thing an answer is ever interpreted against. Because the broadcast\n * list is derived from this map, every option a remote surface can see is an option this map can\n * resolve.\n */\ntype OfferedSet<T> = ReadonlyMap<string, OfferedOption<T>>;\n\n/**\n * The ONE place an offered option is constructed.\n *\n * The caller-side value is an argument, supplied at construction from data the caller actually\n * gave us — the option's own declared decision, or the very string the caller listed. No other\n * function in this file builds an `OfferedOption`, so there is no second path where a resolution\n * could be inferred after the fact.\n *\n * `declares` is optional and purely descriptive: `select` and `input` have no permission semantics\n * to state. Passing it never changes `resolution`.\n */\nfunction offer<T>(id: string, label: string, value: T, declares?: PermissionOption[\"decision\"]): OfferedOption<T> {\n\treturn { id, label, resolution: { value }, declares };\n}\n\n/**\n * Index a freshly minted list by id. Ids are wire handles; they are never parsed or ordered.\n *\n * Callers must have proved the ids unique first — `new Map` is last-wins, and letting array\n * position silently pick which of two same-id options survives is precisely the inference this\n * file exists to abolish. {@link classifyVocabulary} is that proof for caller-supplied\n * vocabularies; the other two mints generate their own ids and cannot collide.\n */\nfunction offeredSet<T>(options: readonly OfferedOption<T>[]): OfferedSet<T> {\n\t// Callers must hand this a DENSE array. `new Map` iterates, so a hole reaches it as `undefined`\n\t// and throws. Both mints guarantee density: `classifyVocabulary` builds its own frozen snapshot,\n\t// and `mintSelectOptions` skips holes by index.\n\treturn new Map(options.map((option) => [option.id, option]));\n}\n\n/**\n * The offered set of an ask with NO remote answerable option.\n *\n * Two asks reach it: a free-text `input`, whose answer is the text itself, and a `confirm` whose\n * caller-supplied vocabulary did not survive validation. Both broadcast zero options, so both are\n * decided by the local surface or by the method's own fail-closed default — never by a fabrication.\n */\nconst NO_OFFERED_OPTIONS: OfferedSet<never> = new Map();\n\ninterface RaceSpec<T> {\n\tmethod: RelayAsk[\"method\"];\n\ttitle: string;\n\tmessage?: string;\n\t/** Minted once: broadcast verbatim, and the sole interpreter of the answer. */\n\toffered: OfferedSet<T>;\n\t/**\n\t * Free-text asks only: the answer's optionId IS the text, so an id outside the offered set is\n\t * still a real answer. Absent for every ask with a fixed vocabulary.\n\t */\n\tfromFreeText?: (text: string) => T;\n\topts: ExtensionUIDialogOptions | undefined;\n\t/** Value returned when the ask ends without an answer. Always the fail-closed value. */\n\tfallback: T;\n\t/**\n\t * What a value the LOCAL surface produced means, stated per method — the FALLBACK reading.\n\t *\n\t * Used only when the base did not state its own outcome through\n\t * {@link ExtensionUIDialogOptions.reportOutcome}. A base that did is believed instead: it is\n\t * the only party that knows whether its `false` was a human pressing \"No\" or its own shutdown.\n\t *\n\t * Applied ONLY to a value the base actually handed back — never to {@link RaceSpec.fallback}\n\t * when the ask was aborted, timed out or exhausted, because for `confirm` the two are the same\n\t * `false` and only the call site knows which one it is holding. That distinction is the whole\n\t * reason `settle` takes the outcome as an argument instead of deriving it.\n\t *\n\t * TOTAL and non-throwing: it is evaluated as an argument inside a discarded `.then`, so a throw\n\t * here would escape as an unhandled rejection. Only this file's own three methods set it, and\n\t * both implementations are a single comparison.\n\t */\n\tlocalOutcome: (value: T) => RelayOutcome;\n\trunBase: (opts: ExtensionUIDialogOptions | undefined) => Promise<T>;\n}\n\n/**\n * What a `confirm` answered on the LOCAL surface means, when the surface DID NOT SAY.\n *\n * `true` is unambiguous: no fail-closed path in this file, in the barrel's no-op, in interactive\n * mode or in RPC mode ever produces `true`, so a `true` is always somebody approving.\n *\n * `false` is NOT unambiguous, and no cleverness about the boolean can make it so:\n * `ExtensionUIContext.confirm` returns `Promise<boolean>`, so a human pressing \"No\" and a surface\n * GIVING UP (RPC's `cancelPendingExtensionRequests` on shutdown, on stdin EOF, on abort;\n * interactive's Esc) arrive here as the same value. ANY derivation from that boolean fabricates\n * something, and this one fabricated a human's refusal for asks nobody ever saw.\n *\n * That is why this function is now the FALLBACK and not the rule. A surface states its own outcome\n * through {@link ExtensionUIDialogOptions.reportOutcome} — the honest four-way `RelayOutcome` —\n * and {@link race} prefers what it was told over what can be guessed. This runs only for a base\n * that never called it, where today's behaviour is kept exactly as it was rather than replaced by\n * a different guess. `chosenOptionId` is null because a surface that answered with a bare boolean\n * never named one of the offered ids.\n */\nfunction confirmOutcome(value: boolean): RelayOutcome {\n\treturn value ? { kind: \"approved\", chosenOptionId: null } : { kind: \"denied\", chosenOptionId: null };\n}\n\n/**\n * What a `select` or `input` answered on the LOCAL surface means.\n *\n * These two methods have NO permission semantics, so neither `approved` nor `denied` may be said\n * about them. `undefined` is both surfaces' documented \"dismissed\" value and is also this file's\n * fail-closed fallback, so the two coincide honestly: either way nobody answered.\n */\nfunction choiceOutcome(value: string | undefined): RelayOutcome {\n\treturn value === undefined ? RELAY_CANCELLED : RELAY_ANSWERED;\n}\n\n/**\n * What an ANSWERED offered option means, read off that option and nothing else.\n *\n * `declares` is the option's own `decision` word, copied out when the option was minted and frozen\n * with it — the same word the registry reads on its own side, so the two halves of a round trip\n * cannot disagree. An option that declares nothing is a `select` entry: it ends the ask by being\n * answered, and says nothing about permission.\n */\nfunction answeredOutcome(declares: PermissionOption[\"decision\"] | undefined, chosenOptionId: string): RelayOutcome {\n\tif (declares === \"approve\") return { kind: \"approved\", chosenOptionId };\n\tif (declares === \"deny\") return { kind: \"denied\", chosenOptionId };\n\treturn RELAY_ANSWERED;\n}\n\nexport function createRelayUIContext(\n\tbase: ExtensionUIContext,\n\trelay: PermissionRelay,\n\tbaseIsLive: boolean,\n\tlocalSurface: LocalSurface,\n): ExtensionUIContext {\n\t/**\n\t * The local surface, named for what it ACTUALLY is.\n\t *\n\t * Passed in rather than hardcoded: this decorator wraps whatever context the binding mode\n\t * installed, and a literal `tui` here recorded an answer typed into the RPC surface — a process\n\t * with no terminal UI at all — as a human at a terminal.\n\t */\n\tconst localDecider: RelayDecider = { surface: localSurface, clientId: null };\n\n\t/** Evaluated LIVE on every call: clients attach and detach while a session is running. */\n\tconst hasAnswerSurface = (): boolean => baseIsLive || relay.readWriteClientCount() > 0;\n\n\tfunction race<T>(spec: RaceSpec<T>): Promise<T> {\n\t\t// (f) Nobody can answer. Do not raise anything anywhere — hand back the base's own value so\n\t\t// the caller's fail-closed branch fires exactly as it does with no relay installed.\n\t\tif (!baseIsLive && relay.readWriteClientCount() === 0) {\n\t\t\treturn spec.runBase(spec.opts);\n\t\t}\n\n\t\tconst externalSignal = spec.opts?.signal;\n\t\tif (externalSignal?.aborted === true) {\n\t\t\t// The undecorated surfaces check this upfront too; nothing should be shown at all.\n\t\t\treturn Promise.resolve(spec.fallback);\n\t\t}\n\n\t\t// (a) One id and one AbortController per ask.\n\t\tconst requestId = randomUUID();\n\t\tconst controller = new AbortController();\n\n\t\tlet settled = false;\n\t\tlet resolveOuter!: (value: T) => void;\n\t\tlet rejectOuter!: (reason: unknown) => void;\n\t\tconst outer = new Promise<T>((resolve, reject) => {\n\t\t\tresolveOuter = resolve;\n\t\t\trejectOuter = reject;\n\t\t});\n\n\t\t// The caller's own signal is replaced below by ours, so forward it or an extension's\n\t\t// programmatic dismissal would silently stop working under the decorator. It is removed\n\t\t// again the moment the ask settles: a caller-owned signal outlives the ask and would\n\t\t// otherwise collect one dead listener per dialog.\n\t\tconst onExternalAbort = (): void => {\n\t\t\tsettle(SYSTEM_DECIDER, spec.fallback, RELAY_CANCELLED);\n\t\t};\n\t\tconst releaseExternalSignal = (): void => {\n\t\t\texternalSignal?.removeEventListener(\"abort\", onExternalAbort);\n\t\t};\n\n\t\t/** (g) The caller's declared timeout, armed only when the decorator owns the only arm. */\n\t\tlet expiry: ReturnType<typeof setTimeout> | undefined;\n\t\tconst releaseTimeout = (): void => {\n\t\t\tif (expiry !== undefined) {\n\t\t\t\tclearTimeout(expiry);\n\t\t\t\texpiry = undefined;\n\t\t\t}\n\t\t};\n\n\t\t/**\n\t\t * (c) SYNCHRONOUS from the settled check through resolve(). A single `await` between the\n\t\t * check and the assignment lets both answers through and produces two conflicting\n\t\t * resolutions with no error at all, because the second resolve() is a silent no-op.\n\t\t *\n\t\t * (d) Order after a winner: mark settled -> resolve -> abort the losing surfaces ->\n\t\t * withdraw. Aborting BEFORE resolving is a real defect: interactive mode honours\n\t\t * `opts.signal` by resolving its selector to `undefined`, which its confirm wrapper maps to\n\t\t * `false` — an abort-first implementation would feed a FABRICATED local deny back through\n\t\t * this decorator and overwrite a remote approve.\n\t\t *\n\t\t * (e) Each teardown step is wrapped on its own, and this is what that does and does not buy.\n\t\t *\n\t\t * GUARANTEED: a `withdraw` that throws synchronously, a `withdraw` that returns a rejected\n\t\t * promise (the shape a socket-writing registry naturally has), and a throwing `interpret`\n\t\t * cannot escape this discarded `.then` as an unhandled rejection — fatal under Node's default\n\t\t * --unhandled-rejections=throw — and cannot prevent the teardown steps behind them from\n\t\t * running. The caller already has its answer before any of this executes.\n\t\t *\n\t\t * NOT GUARANTEED: `quietly(() => controller.abort())` does NOT contain a throw from an abort\n\t\t * listener the BASE surface registered. `AbortController.abort()` dispatches synchronously\n\t\t * through EventTarget, which reports a listener exception as an `uncaughtException` — it never\n\t\t * propagates to the `abort()` call site, so neither try/catch nor `.catch()` can see it. That\n\t\t * is inherent to EventTarget dispatch and is not something this decorator can fix.\n\t\t */\n\t\tconst settle = (decidedBy: RelayDecider, value: T, outcome: RelayOutcome): void => {\n\t\t\tif (settled) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsettled = true;\n\t\t\tresolveOuter(value);\n\t\t\tquietly(releaseExternalSignal);\n\t\t\tquietly(releaseTimeout);\n\t\t\tquietly(() => controller.abort());\n\t\t\t// The outcome is an ARGUMENT, never something the relay may reconstruct. THIS call site\n\t\t\t// has just settled the ask and holds the value; the relay holds neither, and when it\n\t\t\t// guessed it wrote `cancelled` over an approval whose command had already run.\n\t\t\tquietly(() => relay.withdraw(requestId, decidedBy, outcome));\n\t\t};\n\n\t\tlet relayDone = false;\n\t\tlet baseFailure: { error: unknown } | undefined;\n\t\t/** Both sides are spent and the only outcome was an error from the local surface. */\n\t\tconst rejectIfExhausted = (): void => {\n\t\t\tif (settled || !relayDone || baseFailure === undefined) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsettled = true;\n\t\t\trejectOuter(baseFailure.error);\n\t\t\tquietly(releaseExternalSignal);\n\t\t\tquietly(releaseTimeout);\n\t\t};\n\n\t\t/**\n\t\t * The relay is spent without a usable answer: nobody answered, it was withdrawn, it\n\t\t * expired, it failed, or the answer named an option that was never offered.\n\t\t *\n\t\t * With a live local surface we simply keep waiting on it. With NO local surface there is\n\t\t * nothing left to wait for, so the ask ends on its own fail-closed default — the wrapped\n\t\t * no-op's `false` must never stand in as a decision, because a caller reports that as a\n\t\t * user action in the transcript.\n\t\t */\n\t\tconst relayExhausted = (): void => {\n\t\t\tif (!baseIsLive) {\n\t\t\t\tsettle(SYSTEM_DECIDER, spec.fallback, RELAY_CANCELLED);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\trejectIfExhausted();\n\t\t};\n\n\t\t/**\n\t\t * The offered set is the ONLY interpreter, and it is a plain lookup by the id that was\n\t\t * broadcast: the answered option already carries its caller-side value. A free-text ask\n\t\t * carries its answer verbatim instead.\n\t\t *\n\t\t * The OUTCOME comes back with the value, read off the very option that was answered — its own\n\t\t * `declares` word and its own id. It is not derived from the value: two options of one\n\t\t * vocabulary can share a caller-side value (`[allow, deny-once, deny-always]` has two `false`\n\t\t * denials), so a value can never name the option that produced it. An option that declares\n\t\t * nothing is a plain `select` entry and a free-text answer is an `input`: neither approves nor\n\t\t * denies anything, and both report `answered`.\n\t\t */\n\t\tconst interpret = (optionId: string): { value: T; outcome: RelayOutcome } | undefined => {\n\t\t\tconst chosen = spec.offered.get(optionId);\n\t\t\tif (chosen !== undefined) {\n\t\t\t\treturn { value: chosen.resolution.value, outcome: answeredOutcome(chosen.declares, chosen.id) };\n\t\t\t}\n\t\t\ttry {\n\t\t\t\treturn spec.fromFreeText === undefined\n\t\t\t\t\t? undefined\n\t\t\t\t\t: { value: spec.fromFreeText(optionId), outcome: RELAY_ANSWERED };\n\t\t\t} catch {\n\t\t\t\t// An interpreter that blows up produced no answer. It must not settle the ask, and\n\t\t\t\t// it must not escape this discarded `.then` as an unhandled rejection.\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t};\n\n\t\t/**\n\t\t * WHAT THE LOCAL SURFACE SAYS IT DID, when it is willing to say.\n\t\t *\n\t\t * `ExtensionUIContext.confirm` returns a bare `Promise<boolean>`: a human's \"no\" and a\n\t\t * surface giving up are the same value, so anything derived from it fabricates something.\n\t\t * The fix is not a cleverer derivation, it is asking. A surface calls `reportOutcome` with\n\t\t * its own honest {@link RelayOutcome} just before it resolves, and that is what gets\n\t\t * recorded — an rpc-mode shutdown becomes `cancelled` by the system instead of a human's\n\t\t * refusal, and an operator who tapped `deny-once` gets that very id into the audit row\n\t\t * instead of a `null` the boolean could never have carried.\n\t\t *\n\t\t * FIRST STATEMENT WINS, and a late one is ignored: this decorator aborts the losing surface\n\t\t * as part of settling, and a surface that reports `cancelled` from its own abort listener\n\t\t * must not overwrite the answer that just won. Totally non-throwing, because the base calls\n\t\t * it synchronously from inside its own code.\n\t\t */\n\t\tlet reported: RelayOutcome | undefined;\n\t\tconst callerReport = spec.opts?.reportOutcome;\n\t\tconst reportOutcome = (outcome: RelayOutcome): void => {\n\t\t\tif (reported === undefined && isRelayOutcome(outcome)) {\n\t\t\t\treported = outcome;\n\t\t\t}\n\t\t\t// A caller that supplied its own callback still hears from its surface: this decorator\n\t\t\t// replaces the field on the way down and would otherwise silently swallow it.\n\t\t\tif (callerReport !== undefined) {\n\t\t\t\ttry {\n\t\t\t\t\tcallerReport(outcome);\n\t\t\t\t} catch {\n\t\t\t\t\t// A caller's own callback must not break the surface that called it.\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\t/**\n\t\t * WHO to name for an ask the local side settled. ONE rule, and it is total.\n\t\t *\n\t\t * `cancelled` means NOBODY ANSWERED — a shutdown, a stdin EOF, an abort, a surface's own\n\t\t * timeout, a dismissal. Naming the surface for one of those puts a decision in the audit\n\t\t * trail against a person who never made it, which is the same falsehood as calling it a\n\t\t * denial, merely moved into a different field. It is the rule this module already applies\n\t\t * to every OTHER cancellation — the caller's own abort, the declared timeout, an exhausted\n\t\t * relay all settle with {@link SYSTEM_DECIDER} — so applying it here too is what makes\n\t\t * \"cancelled is attributed to the system, never to a surface that did not act\" a property\n\t\t * of this file rather than a habit of four call sites.\n\t\t *\n\t\t * Every other outcome names the surface that produced it: `approved`, `denied` and\n\t\t * `answered` all report that somebody DID act, on this surface.\n\t\t */\n\t\tconst deciderFor = (outcome: RelayOutcome): RelayDecider =>\n\t\t\toutcome.kind === \"cancelled\" ? SYSTEM_DECIDER : localDecider;\n\n\t\texternalSignal?.addEventListener(\"abort\", onExternalAbort, { once: true });\n\n\t\t// ONE usability verdict, read by the advisory `deadline` just below AND by the real clock at\n\t\t// the bottom of this function. Guarding the two expressions separately is how a `NaN` timeout\n\t\t// (an unset `Number(process.env.DRAHT_PERMISSION_TIMEOUT_MS)`) and an `Infinity` timeout (the\n\t\t// idiomatic \"never expire\") reached `new Date(...).toISOString()` and threw a RangeError\n\t\t// SYNCHRONOUSLY out of `confirm()`. Such an ask never reaches the relay and never fails\n\t\t// closed: it propagates as an exception the permission gate reports as a TOOL ERROR rather\n\t\t// than as a denial. A permission ask must fail closed; it must never throw. The verdict also\n\t\t// bounds the MAGNITUDE, for the same reason and in the same one place — see\n\t\t// {@link MAX_USABLE_TIMEOUT_MS}.\n\t\tconst declaredTimeout = usableTimeout(spec.opts?.timeout);\n\n\t\tconst ask: RelayAsk = {\n\t\t\trequestId,\n\t\t\tmethod: spec.method,\n\t\t\ttitle: spec.title,\n\t\t\tmessage: spec.message,\n\t\t\tdetail: spec.opts?.detail,\n\t\t\t// Derived from the offered set itself: nothing can be shown that cannot be answered.\n\t\t\t// `decision` rides along for rendering — see OfferedOption.declares.\n\t\t\toptions: [...spec.offered.values()].map(\n\t\t\t\t({ id, label, declares }): WireOption =>\n\t\t\t\t\tdeclares === undefined ? { id, label } : { id, label, decision: declares },\n\t\t\t),\n\t\t\trequestedAt: new Date().toISOString(),\n\t\t\t// Advisory rendering data only. Real expiry binds to the clock below, never to this.\n\t\t\tdeadline: declaredTimeout === undefined ? null : new Date(Date.now() + declaredTimeout).toISOString(),\n\t\t};\n\n\t\t// (b) Start BOTH surfaces — but ONLY when the mode actually bound one. A base that is not\n\t\t// live is the barrel's no-op, whose `confirm` resolves `false` on the very next microtask:\n\t\t// started, it wins every race outright and fabricates a user denial before the phone can\n\t\t// even render the ask. (e) Both handlers swallow late results and late REJECTIONS against a\n\t\t// settled ask — an unswallowed rejection is fatal under --unhandled-rejections=throw.\n\t\tif (baseIsLive) {\n\t\t\tcallSafely(() => spec.runBase({ ...spec.opts, signal: controller.signal, reportOutcome })).then(\n\t\t\t\t(value) => {\n\t\t\t\t\t// TOLD beats DERIVED. `spec.localOutcome` is a reading of an ambiguous value and\n\t\t\t\t\t// runs only for a base that stated nothing, which is what keeps every existing\n\t\t\t\t\t// `ExtensionUIContext` implementer behaving exactly as it does today.\n\t\t\t\t\tconst outcome = reported ?? spec.localOutcome(value);\n\t\t\t\t\tsettle(deciderFor(outcome), value, outcome);\n\t\t\t\t},\n\t\t\t\t(error: unknown) => {\n\t\t\t\t\tbaseFailure = { error };\n\t\t\t\t\trejectIfExhausted();\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\n\t\tcallSafely<RelayAnswer | RelayEnded | undefined>(() => relay.raise(ask)).then(\n\t\t\t(answer) => {\n\t\t\t\trelayDone = true;\n\t\t\t\tif (isRelayEnded(answer) && answer.requestId === requestId) {\n\t\t\t\t\t// THE ASK IS OVER, not merely unanswerable HERE. The relay's clock ran out, or\n\t\t\t\t\t// the session was stopped: it has already broadcast the ending and written the\n\t\t\t\t\t// audit row. Waiting on the local surface now is the fail-OPEN defect — the\n\t\t\t\t\t// dialog stayed on screen, a human tapped Approve, and the command ran against\n\t\t\t\t\t// a durable record that says `expired`. `settle` aborts the local surface.\n\t\t\t\t\tsettle(answer.decidedBy, spec.fallback, RELAY_CANCELLED);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (answer === undefined || isRelayEnded(answer) || answer.requestId !== requestId) {\n\t\t\t\t\trelayExhausted();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst decided = interpret(answer.optionId);\n\t\t\t\tif (decided === undefined) {\n\t\t\t\t\t// An id nobody offered is not a choice anybody made: it is silence, not a dismissal.\n\t\t\t\t\trelayExhausted();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tsettle(answer.decidedBy, decided.value, decided.outcome);\n\t\t\t},\n\t\t\t() => {\n\t\t\t\trelayDone = true;\n\t\t\t\trelayExhausted();\n\t\t\t},\n\t\t);\n\n\t\t// (g) With a live base, the local surface runs the caller's timeout itself (interactive mode\n\t\t// shows the countdown) and this decorator must not add a second clock. With NO live base the\n\t\t// decorator holds the only arm, so an unhonoured `opts.timeout` means the caller waits\n\t\t// forever whenever the relay never resolves — where without a relay it would have failed\n\t\t// closed instantly. On expiry the ask ends on the method's own fail-closed default,\n\t\t// attributed to the system: nobody decided.\n\t\t//\n\t\t// This is deliberately NOT a default clock. When the caller declares no timeout — or declares\n\t\t// one too large to arm honestly, see usableTimeout — the bound is the pending registry's own\n\t\t// fail-closed timer (R34-PERM.6, a later task): one clock, owned there. All that happens here\n\t\t// is that the caller's OWN declared timeout is respected, when it is a duration we can keep.\n\t\tif (!baseIsLive && declaredTimeout !== undefined) {\n\t\t\texpiry = setTimeout(() => {\n\t\t\t\tsettle(SYSTEM_DECIDER, spec.fallback, RELAY_CANCELLED);\n\t\t\t}, declaredTimeout);\n\t\t}\n\n\t\treturn outer;\n\t}\n\n\treturn {\n\t\tselect(title: string, options: string[], opts?: ExtensionUIDialogOptions): Promise<string | undefined> {\n\t\t\treturn race<string | undefined>({\n\t\t\t\tmethod: \"select\",\n\t\t\t\ttitle,\n\t\t\t\toffered: mintSelectOptions(options),\n\t\t\t\topts,\n\t\t\t\tfallback: undefined,\n\t\t\t\tlocalOutcome: choiceOutcome,\n\t\t\t\trunBase: (baseOpts) => base.select(title, options, baseOpts),\n\t\t\t});\n\t\t},\n\n\t\tconfirm(title: string, message: string, opts?: ExtensionUIDialogOptions): Promise<boolean> {\n\t\t\treturn race<boolean>({\n\t\t\t\tmethod: \"confirm\",\n\t\t\t\ttitle,\n\t\t\t\tmessage,\n\t\t\t\toffered: mintConfirmOptions(opts?.detail?.options),\n\t\t\t\topts,\n\t\t\t\tfallback: false,\n\t\t\t\tlocalOutcome: confirmOutcome,\n\t\t\t\trunBase: (baseOpts) => base.confirm(title, message, baseOpts),\n\t\t\t});\n\t\t},\n\n\t\tinput(title: string, placeholder?: string, opts?: ExtensionUIDialogOptions): Promise<string | undefined> {\n\t\t\treturn race<string | undefined>({\n\t\t\t\tmethod: \"input\",\n\t\t\t\ttitle,\n\t\t\t\tmessage: placeholder,\n\t\t\t\t// A free-text ask offers NOTHING answerable, exactly as `select` takes nothing from\n\t\t\t\t// `detail.options`. Minting suggestions by id put the id namespace and the free-text\n\t\t\t\t// namespace in one map, and the map was consulted first: a human who TYPED the literal\n\t\t\t\t// text \"allow-once\" into an ask carrying a suggestion with that id got the suggestion's\n\t\t\t\t// LABEL back instead of what they typed. `detail` still travels, for rendering only.\n\t\t\t\toffered: NO_OFFERED_OPTIONS,\n\t\t\t\t// The answer IS the text, verbatim.\n\t\t\t\tfromFreeText: (text) => text,\n\t\t\t\topts,\n\t\t\t\tfallback: undefined,\n\t\t\t\tlocalOutcome: choiceOutcome,\n\t\t\t\trunBase: (baseOpts) => base.input(title, placeholder, baseOpts),\n\t\t\t});\n\t\t},\n\n\t\t// ---------------------------------------------------------------------------------------\n\t\t// Hand-delegated, verbatim. Not a Proxy — see the file header.\n\t\t// ---------------------------------------------------------------------------------------\n\n\t\tnotify(message: string, type?: \"info\" | \"warning\" | \"error\"): void {\n\t\t\tbase.notify(message, type);\n\t\t},\n\t\tonTerminalInput(handler: TerminalInputHandler): () => void {\n\t\t\treturn base.onTerminalInput(handler);\n\t\t},\n\t\tsetStatus(key: string, text: string | undefined): void {\n\t\t\tbase.setStatus(key, text);\n\t\t},\n\t\tsetWorkingMessage(message?: string): void {\n\t\t\tbase.setWorkingMessage(message);\n\t\t},\n\t\tsetWorkingVisible(visible: boolean): void {\n\t\t\tbase.setWorkingVisible(visible);\n\t\t},\n\t\tsetWorkingIndicator(options?: WorkingIndicatorOptions): void {\n\t\t\tbase.setWorkingIndicator(options);\n\t\t},\n\t\tsetHiddenThinkingLabel(label?: string): void {\n\t\t\tbase.setHiddenThinkingLabel(label);\n\t\t},\n\t\t// `content` is `never` so this single implementation satisfies both declared overloads.\n\t\tsetWidget(key: string, content: never, options?: ExtensionWidgetOptions): void {\n\t\t\tbase.setWidget(key, content, options);\n\t\t},\n\t\tsetFooter(\n\t\t\tfactory:\n\t\t\t\t| ((tui: TUI, theme: Theme, footerData: ReadonlyFooterDataProvider) => Component & { dispose?(): void })\n\t\t\t\t| undefined,\n\t\t): void {\n\t\t\tbase.setFooter(factory);\n\t\t},\n\t\tsetHeader(factory: ((tui: TUI, theme: Theme) => Component & { dispose?(): void }) | undefined): void {\n\t\t\tbase.setHeader(factory);\n\t\t},\n\t\tsetTitle(title: string): void {\n\t\t\tbase.setTitle(title);\n\t\t},\n\t\t/** Local by documented exception: the factory produces a live component. */\n\t\tcustom<T>(\n\t\t\tfactory: (\n\t\t\t\ttui: TUI,\n\t\t\t\tcomponentTheme: Theme,\n\t\t\t\tkeybindings: KeybindingsManager,\n\t\t\t\tdone: (result: T) => void,\n\t\t\t) => (Component & { dispose?(): void }) | Promise<Component & { dispose?(): void }>,\n\t\t\toptions?: {\n\t\t\t\toverlay?: boolean;\n\t\t\t\toverlayOptions?: OverlayOptions | (() => OverlayOptions);\n\t\t\t\tonHandle?: (handle: OverlayHandle) => void;\n\t\t\t},\n\t\t): Promise<T> {\n\t\t\treturn base.custom<T>(factory, options);\n\t\t},\n\t\tpasteToEditor(text: string): void {\n\t\t\tbase.pasteToEditor(text);\n\t\t},\n\t\tsetEditorText(text: string): void {\n\t\t\tbase.setEditorText(text);\n\t\t},\n\t\tgetEditorText(): string {\n\t\t\treturn base.getEditorText();\n\t\t},\n\t\t/** Local by documented exception: a multi-line editor is not a one-shot answerable ask. */\n\t\teditor(title: string, prefill?: string): Promise<string | undefined> {\n\t\t\treturn base.editor(title, prefill);\n\t\t},\n\t\taddAutocompleteProvider(factory: AutocompleteProviderFactory): void {\n\t\t\tbase.addAutocompleteProvider(factory);\n\t\t},\n\t\tsetEditorComponent(factory: EditorFactory | undefined): void {\n\t\t\tbase.setEditorComponent(factory);\n\t\t},\n\t\tgetEditorComponent(): EditorFactory | undefined {\n\t\t\treturn base.getEditorComponent();\n\t\t},\n\t\tget theme(): Theme {\n\t\t\treturn base.theme;\n\t\t},\n\t\tgetAllThemes(): { name: string; path: string | undefined }[] {\n\t\t\treturn base.getAllThemes();\n\t\t},\n\t\tgetTheme(name: string): Theme | undefined {\n\t\t\treturn base.getTheme(name);\n\t\t},\n\t\tsetTheme(newTheme: string | Theme): { success: boolean; error?: string } {\n\t\t\treturn base.setTheme(newTheme);\n\t\t},\n\t\tgetToolsExpanded(): boolean {\n\t\t\treturn base.getToolsExpanded();\n\t\t},\n\t\tsetToolsExpanded(expanded: boolean): void {\n\t\t\tbase.setToolsExpanded(expanded);\n\t\t},\n\n\t\thasAnswerSurface,\n\t};\n}\n\n/**\n * Whether a surface's self-reported outcome is a {@link RelayOutcome} AT ALL.\n *\n * A VALIDITY test, not a meaning rule — the same discipline {@link classifyVocabulary} applies to a\n * caller's vocabulary. `ExtensionUIContext` is implemented by third parties and by untyped JS\n * extensions, so `reportOutcome(\"approved\")` or `reportOutcome({kind: \"maybe\"})` is reachable, and\n * a malformed report must fall back to today's derivation rather than become a decision word\n * nothing downstream can read.\n *\n * What it deliberately does NOT do is cross-check the report against the value the surface\n * resolved with. They are two different facts about the same act, the surface owns both, and\n * inventing a tie-breaker between them would be exactly the derivation this file exists to\n * abolish. A surface that lies about itself is a bug in that surface, not something a decorator\n * can adjudicate.\n */\nfunction isRelayOutcome(value: unknown): value is RelayOutcome {\n\tif (typeof value !== \"object\" || value === null) return false;\n\tconst { kind, chosenOptionId } = value as { kind?: unknown; chosenOptionId?: unknown };\n\tif (kind === \"answered\" || kind === \"cancelled\") return true;\n\tif (kind !== \"approved\" && kind !== \"denied\") return false;\n\t// `chosenOptionId` is REQUIRED on these two — `null` is the honest report of a surface that\n\t// answered without naming an offered id, and `undefined` is a field somebody forgot.\n\treturn chosenOptionId === null || typeof chosenOptionId === \"string\";\n}\n\n/** Turn a synchronous throw into a rejected promise so both race arms behave identically. */\nfunction callSafely<T>(fn: () => Promise<T>): Promise<T> {\n\ttry {\n\t\treturn fn();\n\t} catch (error) {\n\t\treturn Promise.reject(error);\n\t}\n}\n\n/**\n * Run one teardown step and swallow whatever it fails with — synchronously OR asynchronously.\n *\n * Teardown happens after the caller already has its answer, from inside a discarded `.then`: a\n * surface that blows up while being torn down cannot un-answer a settled ask, and must not become\n * an unhandled rejection. `relay.withdraw` is declared `void` but the real registry writes to a\n * socket, so the natural implementation is `async` — catching only synchronous throws would leave\n * exactly that shape fatal. Each step is wrapped on its own so a failure in one does not skip the\n * rest.\n */\nfunction quietly(step: () => unknown): void {\n\ttry {\n\t\tvoid Promise.resolve(step()).catch(() => {\n\t\t\t// Deliberately ignored — see above.\n\t\t});\n\t} catch {\n\t\t// Deliberately ignored — see above.\n\t}\n}\n\n/**\n * The verdict on a caller-supplied vocabulary. Exactly three outcomes, and no fourth.\n *\n * \"Invalid\" is deliberately NOT \"fall back to the default\": substituting our own words for a\n * caller's rejected ones is how an unauthorised approval gets broadcast.\n */\ntype VocabularyVerdict =\n\t| { readonly kind: \"absent\" }\n\t| { readonly kind: \"valid\"; readonly options: readonly ValidatedOption[] }\n\t| { readonly kind: \"invalid\" };\n\n/**\n * The only words a permission vocabulary may use, as RUNTIME values rather than as a type.\n *\n * Derived from {@link CONFIRM_RESOLUTION}'s own keys so the two cannot drift: a word passes this\n * gate if and only if there is a caller-side value to translate it into.\n */\nconst DECISION_WORDS: ReadonlySet<string> = new Set<string>(Object.keys(CONFIRM_RESOLUTION));\n\n/** Narrow a value read out of untyped data to a decision word. */\nfunction isDecisionWord(value: unknown): value is PermissionOption[\"decision\"] {\n\treturn typeof value === \"string\" && DECISION_WORDS.has(value);\n}\n\n/**\n * THE ONE PLACE a caller's vocabulary is validated.\n *\n * `CONFIRM_RESOLUTION` is total over the declared TYPE but not over runtime values: a detail that\n * crossed a wire or came from an untyped JS extension can carry `decision: \"maybe\"`, and without\n * this gate that option was offered, broadcast, answerable, and resolved a `Promise<boolean>` with\n * `undefined`. Ids likewise must be unique before {@link offeredSet}'s last-wins `new Map` sees\n * them, or ARRAY POSITION decides which of two same-id options survives while `detail.options` —\n * the documented rendering carrier — still shows both, letting a tapped \"Deny\" resolve `true`.\n *\n * This is a validity test, not a meaning rule: no branch here reads an option's COUNT, POSITION or\n * ID to decide what that option means. The emptiness check asks \"is this a vocabulary at all\", and\n * a vocabulary of zero words is not one.\n *\n * It is TOTAL over runtime values, and its parameter is `unknown` to say so. The declared type is\n * exactly what a detail crossing a wire or coming from an untyped JS extension need not honour, and\n * every expression this gate writes must survive being handed the data it exists to police:\n * `vocabulary.length` threw a TypeError on `null`, `for...of` threw \"is not iterable\" on an\n * array-like `{0: {…}, length: 1}`, and a non-object entry threw on the first property read. A\n * malformed container is INVALID — an outcome this file already knows how to fail closed on — and\n * never an exception out of `confirm()`.\n *\n * Every field is read EXACTLY ONCE, here, and the verdict carries {@link ValidatedOption} copies\n * rather than the caller's array. See {@link ValidatedOption} for what that buys.\n */\nfunction classifyVocabulary(vocabulary: unknown): VocabularyVerdict {\n\tif (vocabulary === undefined) {\n\t\treturn { kind: \"absent\" };\n\t}\n\tif (!Array.isArray(vocabulary)) {\n\t\treturn { kind: \"invalid\" };\n\t}\n\tconst entries: readonly unknown[] = vocabulary;\n\t// A caller whose policy layer filtered its vocabulary down to nothing offered nothing. It did\n\t// not ask for OUR yes/no pair, and must never have a \"Yes\" broadcast in its name.\n\tif (entries.length === 0) {\n\t\treturn { kind: \"invalid\" };\n\t}\n\tconst ids = new Set<string>();\n\tconst snapshot: ValidatedOption[] = [];\n\tfor (const entry of entries) {\n\t\tif (typeof entry !== \"object\" || entry === null) {\n\t\t\treturn { kind: \"invalid\" };\n\t\t}\n\t\t// The decision must be the option's OWN word. A bare `DECISION_WORDS.has(option.decision)`\n\t\t// walks the prototype chain: with `Object.prototype.decision = \"approve\"` set anywhere in the\n\t\t// process, an option that declared NOTHING was broadcast as an approval, and tapping its\n\t\t// \"Deny\" label resolved `true`.\n\t\tif (!Object.hasOwn(entry, \"decision\")) {\n\t\t\treturn { kind: \"invalid\" };\n\t\t}\n\t\t// One read per field, into locals. Everything below inspects these locals, never `entry`.\n\t\tconst { id, label, decision } = entry as { id?: unknown; label?: unknown; decision?: unknown };\n\t\t// `RelayAnswer.optionId` is typed `string`, so a non-string id is a promise the wire cannot\n\t\t// keep: `[{id: 1, …deny}, {id: \"1\", …approve}]` passed the SameValueZero uniqueness proof\n\t\t// (1 !== \"1\"), broadcast both, and a client honouring its own wire type by sending\n\t\t// `String(1)` named the APPROVAL while the human had tapped \"Deny\". The type-conforming\n\t\t// client was the one that got it wrong. An empty id is no handle at all.\n\t\tif (typeof id !== \"string\" || id.length === 0) {\n\t\t\treturn { kind: \"invalid\" };\n\t\t}\n\t\tif (typeof label !== \"string\") {\n\t\t\treturn { kind: \"invalid\" };\n\t\t}\n\t\tif (!isDecisionWord(decision)) {\n\t\t\treturn { kind: \"invalid\" };\n\t\t}\n\t\t// KNOWN LATENT (accepted, not fixed): this proof is exact-string, so two ids differing only\n\t\t// by Unicode normalisation form (\"café\" NFC vs NFD) are two distinct options here and one\n\t\t// option in any client that normalises. Harmless for a hand-written vocabulary; a real risk\n\t\t// the moment option ids are DERIVED from tool, path or command data — normalise here then.\n\t\tif (ids.has(id)) {\n\t\t\treturn { kind: \"invalid\" };\n\t\t}\n\t\tids.add(id);\n\t\tsnapshot.push(Object.freeze({ id, label, decision }));\n\t}\n\treturn { kind: \"valid\", options: Object.freeze(snapshot) };\n}\n\n/**\n * Mint the vocabulary of a `confirm`, ONCE, behind the one validation gate.\n *\n * Each offered option's caller-side value is read off the option ITSELF, from the `decision` its\n * vocabulary declares. There is no position rule, so a denial in the middle of the list, a\n * vocabulary with several denials, and a single-option vocabulary are all simply what they say they\n * are. With NO caller vocabulary, the default yes/no pair is minted through the same one path.\n *\n * With an INVALID caller vocabulary, nothing is offered at all: the ask broadcasts an empty option\n * list, so it is decided by the local surface if one is live and otherwise by `confirm`'s own\n * fail-closed `false`. An invalid vocabulary is never silently replaced by a fabricated one, and it\n * can never approve anything.\n *\n * Nothing is logged here on purpose. This decorator runs under a TUI that owns the terminal, and a\n * stray `console.warn` mid-render corrupts the screen; the rejection is visible instead as an ask\n * that carries the caller's `detail` but offers no remote option.\n *\n * An id that is not in the set at all is not an answer, which is where fail-closed lives: it can\n * never become a decision attributed to a human who never touched it.\n */\nfunction mintConfirmOptions(vocabulary: readonly PermissionOption[] | undefined): OfferedSet<boolean> {\n\tconst verdict = classifyVocabulary(vocabulary);\n\tif (verdict.kind === \"invalid\") {\n\t\treturn NO_OFFERED_OPTIONS;\n\t}\n\t// BOTH arms are frozen data this file owns — the gate's snapshot, or our own default pair. The\n\t// caller's array is never read again past validation, so what is minted here is exactly what was\n\t// proved valid there.\n\tconst options = verdict.kind === \"absent\" ? DEFAULT_CONFIRM_OPTIONS : verdict.options;\n\treturn offeredSet(\n\t\toptions.map((option) => offer(option.id, option.label, CONFIRM_RESOLUTION[option.decision], option.decision)),\n\t);\n}\n\n/**\n * The largest timeout this decorator will arm: `2^31-1` ms, about 24.85 days.\n *\n * ONE bound, because it is the smaller of the two real ceilings and therefore covers both.\n *\n * `setTimeout` stores its delay in a signed 32-bit int: anything larger is CLAMPED to 1ms with a\n * `TimeoutOverflowWarning`. A 30-day timeout therefore advertised a deadline a month out and then\n * settled `false` two milliseconds later, attributed to nobody — with no live base, every such ask\n * fabricated a system denial before the phone could render it. Fail-closed, so it could not\n * approve, but it contradicted this file's own promise that real expiry binds to the clock, and it\n * broke the walk-away premise the relay exists for.\n *\n * Far above that, `new Date(Date.now() + t)` leaves the representable range (~8.64e15 ms from the\n * epoch) and `.toISOString()` throws `RangeError: Invalid time value` SYNCHRONOUSLY, so\n * `{ timeout: Number.MAX_SAFE_INTEGER }` — the idiomatic \"never expire\", which compiles cleanly —\n * never reached either surface and arrived at the permission gate as a tool error, not a decision.\n */\nconst MAX_USABLE_TIMEOUT_MS = 2_147_483_647;\n\n/**\n * ONE verdict for a caller's declared timeout: a real, ARMABLE duration, or nothing at all.\n *\n * A DELIBERATE choice, stated because both readings are defensible: a declared timeout above\n * {@link MAX_USABLE_TIMEOUT_MS} is treated as NO timeout at all, not as one capped to the maximum.\n * Capping invents a bound the caller never asked for and then acts on it — \"never expire\" would\n * become a fabricated system denial 24 days in, which is the very defect above, merely postponed.\n * And `Number.MAX_SAFE_INTEGER` and `Infinity` are two spellings of one intent, so they must not\n * behave differently. \"No usable timeout\" already has a documented meaning here: the ask carries\n * `deadline: null`, this decorator arms no clock of its own, and the bound falls to the pending\n * registry's own fail-closed timer (R34-PERM.6) — one clock, owned there.\n */\nfunction usableTimeout(timeout: number | undefined): number | undefined {\n\treturn typeof timeout === \"number\" && Number.isFinite(timeout) && timeout > 0 && timeout <= MAX_USABLE_TIMEOUT_MS\n\t\t? timeout\n\t\t: undefined;\n}\n\n/**\n * Mint the vocabulary of a `select`, ONCE, from the caller's OWN option list and nothing else.\n *\n * Every offered option resolves to the very string it was minted from, bound at construction. The\n * id is a wire handle and nothing more: it is never parsed back into a position, and two identical\n * labels stay two distinct answers.\n *\n * `detail.options` is a permission-DETAIL carrier and deliberately contributes nothing here. Laying\n * a permission vocabulary over a label list — by position, or by label match — is exactly the\n * inference that once resolved an answered \"Deny\" to the caller-side string \"Allow\". The detail\n * still travels on the ask for rendering; it just never decides anything.\n */\nfunction mintSelectOptions(labels: readonly string[]): OfferedSet<string | undefined> {\n\t// Iterate by index rather than with `labels.map`, which PRESERVES array holes: `new Map` then\n\t// iterates the array iterator, hits the hole's `undefined` and throws \"Iterator value undefined\n\t// is not an entry object\" synchronously out of the caller's `ui.select`. A caller reaches that\n\t// with ordinary TypeScript — `for (…) if (keep) labels[i] = name` builds a sparse `string[]` —\n\t// and the undecorated base does not throw, so the decorator would be introducing the crash.\n\t// A hole has no label to render and no value to resolve to, so it is not offered at all; the\n\t// surviving positions keep their own index in the id, so what IS offered stays answerable.\n\tconst options: OfferedOption<string | undefined>[] = [];\n\tfor (let position = 0; position < labels.length; position++) {\n\t\tconst label = labels[position];\n\t\tif (typeof label !== \"string\") continue;\n\t\toptions.push(offer(`option-${position}`, label, label));\n\t}\n\treturn offeredSet(options);\n}\n"]}
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The port the relay UI decorator talks to.
|
|
3
|
+
*
|
|
4
|
+
* This file deliberately imports NOTHING from the socket server. The decorator must be usable
|
|
5
|
+
* with a hand-written fake in tests and must not drag the attach wire into the agent core.
|
|
6
|
+
*/
|
|
7
|
+
import type { PermissionAskDetail } from "../extensions/types.ts";
|
|
8
|
+
/** Which surface produced an answer, and which client on that surface (when it has clients). */
|
|
9
|
+
export interface RelayDecider {
|
|
10
|
+
surface: "tui" | "attach" | "rpc" | "acp" | "system";
|
|
11
|
+
clientId: string | null;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The surface a LOCALLY raised dialog belongs to.
|
|
15
|
+
*
|
|
16
|
+
* `attach` is excluded because it is the REMOTE side by definition — an attached client's answer
|
|
17
|
+
* comes back through {@link RelayAnswer.decidedBy} and is never what the decorator is describing.
|
|
18
|
+
* `system` IS allowed and is the truthful value for a binding mode that shows no dialog to anybody
|
|
19
|
+
* (`print`, `json`): if such a mode ever ends an ask, nobody acted.
|
|
20
|
+
*
|
|
21
|
+
* There is no default. The decorator is built at ONE seam that knows the mode, and a default here
|
|
22
|
+
* would be exactly the hardcoded `tui` this type exists to abolish — an answer typed into the RPC
|
|
23
|
+
* surface, and a process shutdown, both recorded as a human at a terminal that does not exist.
|
|
24
|
+
*/
|
|
25
|
+
export type LocalSurface = Exclude<RelayDecider["surface"], "attach">;
|
|
26
|
+
/**
|
|
27
|
+
* WHAT ACTUALLY HAPPENED to an ask, as the surface that ended it knows it.
|
|
28
|
+
*
|
|
29
|
+
* This exists because a relay cannot GUESS. `withdraw` used to carry only the decider, so the
|
|
30
|
+
* implementation hardcoded `cancelled` — and an approved, EXECUTED command was written into the
|
|
31
|
+
* durable record and put on the wire as `cancelled`, with `chosenOptionId: null`. The decision was
|
|
32
|
+
* known to the caller of `withdraw` all along; it simply had nowhere to put it.
|
|
33
|
+
*
|
|
34
|
+
* - `approved` / `denied` — a surface ANSWERED, and the answer's own vocabulary says what that
|
|
35
|
+
* meant. `chosenOptionId` names the offered option when one was named, and is `null` when the
|
|
36
|
+
* answering surface did not name one (see below).
|
|
37
|
+
* - `answered` — a `select` or `input` was answered. Those methods carry NO permission semantics:
|
|
38
|
+
* nothing was approved and nothing was denied, so neither word may be used for them.
|
|
39
|
+
* - `cancelled` — the ask ended with NO answer at all: an abort, a shutdown, a session
|
|
40
|
+
* replacement, a declared timeout, or a relay that was spent before anybody could act.
|
|
41
|
+
*
|
|
42
|
+
* `chosenOptionId: null` on an `approved`/`denied` outcome is not a hole, it is the honest report
|
|
43
|
+
* of a surface that answered WITHOUT naming an option — the local `ExtensionUIContext.confirm`
|
|
44
|
+
* returns a bare `Promise<boolean>` and draws its own Yes/No, so it never chose one of the offered
|
|
45
|
+
* ids. Reverse-mapping that boolean onto the offered set would be a derivation, and with a
|
|
46
|
+
* vocabulary like `[allow, deny-once, deny-always]` it would name an option nobody touched.
|
|
47
|
+
*/
|
|
48
|
+
export type RelayOutcome = {
|
|
49
|
+
readonly kind: "approved";
|
|
50
|
+
readonly chosenOptionId: string | null;
|
|
51
|
+
} | {
|
|
52
|
+
readonly kind: "denied";
|
|
53
|
+
readonly chosenOptionId: string | null;
|
|
54
|
+
} | {
|
|
55
|
+
readonly kind: "answered";
|
|
56
|
+
} | {
|
|
57
|
+
readonly kind: "cancelled";
|
|
58
|
+
};
|
|
59
|
+
/** The outcome of an ask that ended without anybody answering it. Shared, frozen, allocation-free. */
|
|
60
|
+
export declare const RELAY_CANCELLED: RelayOutcome;
|
|
61
|
+
/** The outcome of a `select` or `input` that WAS answered — no permission was granted or refused. */
|
|
62
|
+
export declare const RELAY_ANSWERED: RelayOutcome;
|
|
63
|
+
/** A single ask broadcast to every attached read-write client. */
|
|
64
|
+
export interface RelayAsk {
|
|
65
|
+
/** Stable id for this ask, minted once per raised dialog. */
|
|
66
|
+
requestId: string;
|
|
67
|
+
/** Which UI primitive raised it. */
|
|
68
|
+
method: "confirm" | "select" | "input";
|
|
69
|
+
/** Headline for the ask. Render it as the dialog's title on every surface. */
|
|
70
|
+
title: string;
|
|
71
|
+
/**
|
|
72
|
+
* Secondary text — but NOT the same thing on every method.
|
|
73
|
+
*
|
|
74
|
+
* For `confirm` and `select` it is body copy. For `input` it is the field's PLACEHOLDER, because
|
|
75
|
+
* that is the only string `ExtensionUIContext.input` carries. A renderer that paints it as body
|
|
76
|
+
* copy leaves the text field with no placeholder and shows a hint where a prompt belongs.
|
|
77
|
+
*/
|
|
78
|
+
message?: string;
|
|
79
|
+
/**
|
|
80
|
+
* Canonical detail for a tool permission ask, when the caller supplied one.
|
|
81
|
+
*
|
|
82
|
+
* `detail.options` is a rendering carrier that states each option's own `decision`. It is NOT a
|
|
83
|
+
* second offered set: what may be answered is {@link RelayAsk.options} below, and only that.
|
|
84
|
+
*/
|
|
85
|
+
detail?: PermissionAskDetail;
|
|
86
|
+
/**
|
|
87
|
+
* The immutable set of options offered for this request — the ONLY answerable set.
|
|
88
|
+
*
|
|
89
|
+
* Ids here are opaque handles minted with the ask. A client echoes one back verbatim; it must
|
|
90
|
+
* never derive an option's meaning from its position in this array or from the shape of its id,
|
|
91
|
+
* and the decorator that minted them never does either: each option's caller-side value was
|
|
92
|
+
* bound when the option was constructed.
|
|
93
|
+
*
|
|
94
|
+
* `decision` states what choosing that option MEANS, so a client can render a denial as
|
|
95
|
+
* destructive without joining this array to `detail.options` by id — a join that is impossible
|
|
96
|
+
* for `select`, whose two arrays share no ids at all. It is present on every option of a
|
|
97
|
+
* `confirm` and absent for `select` and `input`, where the concept does not apply. It is
|
|
98
|
+
* rendering data: what an answer resolves to was fixed when the option was minted, and echoing
|
|
99
|
+
* a different `decision` back changes nothing.
|
|
100
|
+
*
|
|
101
|
+
* An EMPTY array means no option can be named BY ID. It does NOT mean the ask is unanswerable —
|
|
102
|
+
* read {@link RelayAsk.method} for that, because the two empty-array cases behave OPPOSITELY:
|
|
103
|
+
*
|
|
104
|
+
* - `confirm` or `select` with an empty array: nothing is answerable. The ask is shown for
|
|
105
|
+
* context only and is decided by the local surface or by the raising method's own fail-closed
|
|
106
|
+
* default. This is what a `confirm` whose caller-supplied vocabulary failed validation looks
|
|
107
|
+
* like. Echoing any id back is silence, not a dismissal — it decides nothing.
|
|
108
|
+
* - `input`: this array is ALWAYS empty, and the ask is nonetheless fully answerable — with free
|
|
109
|
+
* text, sent verbatim as {@link RelayAnswer.optionId}. EVERY string is a valid answer. A client
|
|
110
|
+
* that renders an input ask as informational-with-no-way-to-answer hangs the agent until the
|
|
111
|
+
* ask expires.
|
|
112
|
+
*
|
|
113
|
+
* No separate "answerable" flag is added: `method` is already on the wire and already carries
|
|
114
|
+
* this distinction, and a second field asserting the same thing is a second thing that can
|
|
115
|
+
* disagree with it.
|
|
116
|
+
*/
|
|
117
|
+
options: readonly {
|
|
118
|
+
id: string;
|
|
119
|
+
label: string;
|
|
120
|
+
decision?: "approve" | "deny";
|
|
121
|
+
}[];
|
|
122
|
+
/** ISO timestamp of when the ask was raised. */
|
|
123
|
+
requestedAt: string;
|
|
124
|
+
/**
|
|
125
|
+
* ISO timestamp for ADVISORY rendering only, or null when there is none.
|
|
126
|
+
*
|
|
127
|
+
* Real expiry binds solely to the pending registry's fail-closed timer — one clock. Nothing
|
|
128
|
+
* may deny an ask because this instant passed.
|
|
129
|
+
*/
|
|
130
|
+
deadline: string | null;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* The relay ITSELF ended the ask. Nobody answered, and nobody still can.
|
|
134
|
+
*
|
|
135
|
+
* THIS IS NOT THE SAME AS `raise()` RESOLVING `undefined`, and conflating the two was a FAIL-OPEN
|
|
136
|
+
* defect. `undefined` means "the relay is spent" — it refused the ask at a bound, its socket was
|
|
137
|
+
* already gone, or an answer named an option nobody offered. In every one of those the ask itself
|
|
138
|
+
* is still live and a human at the LOCAL surface must still get to answer it.
|
|
139
|
+
*
|
|
140
|
+
* This value means the opposite: the ask is OVER. The registry's fail-closed clock ran out, or the
|
|
141
|
+
* session it belonged to was stopped or replaced. The relay has already broadcast the ending and
|
|
142
|
+
* written it down, so a surface that kept its dialog on screen after this would be offering a human
|
|
143
|
+
* a button that can still run the command an audit row already records as expired — which is
|
|
144
|
+
* exactly what happened: the durable record said `expired`, the human tapped Approve on the local
|
|
145
|
+
* dialog nobody had taken down, and the command RAN.
|
|
146
|
+
*
|
|
147
|
+
* A decorator receiving this must settle its ask on the raising method's own fail-closed default,
|
|
148
|
+
* abort the local surface, and attribute the ending to {@link RelayEnded.decidedBy} — which names
|
|
149
|
+
* `system`, because nobody decided anything.
|
|
150
|
+
*/
|
|
151
|
+
export interface RelayEnded {
|
|
152
|
+
/** The ask that ended. An `ended` naming any other ask is ignored, exactly as an answer is. */
|
|
153
|
+
requestId: string;
|
|
154
|
+
/** WHAT ended it. Never `approved`/`denied`: nobody answered, so nothing was granted or refused. */
|
|
155
|
+
ended: "expired" | "cancelled";
|
|
156
|
+
/** Who ended it. Always the system — an ask nobody answered may not be attributed to a person. */
|
|
157
|
+
decidedBy: RelayDecider;
|
|
158
|
+
}
|
|
159
|
+
/** Whether a settled `raise()` is the relay reporting that the ask itself is OVER. */
|
|
160
|
+
export declare function isRelayEnded(value: RelayAnswer | RelayEnded | undefined): value is RelayEnded;
|
|
161
|
+
/** An answer that came back from some surface. */
|
|
162
|
+
export interface RelayAnswer {
|
|
163
|
+
/** The ask being answered. An answer naming any other ask is ignored. */
|
|
164
|
+
requestId: string;
|
|
165
|
+
/**
|
|
166
|
+
* WHAT was answered — and for a free-text ask, the answer ITSELF.
|
|
167
|
+
*
|
|
168
|
+
* For `confirm` and `select`: one {@link RelayAsk.options} id, echoed back verbatim. An id that
|
|
169
|
+
* was never offered is silence — it can never become a decision attributed to a human.
|
|
170
|
+
*
|
|
171
|
+
* For `input`, whose `options` is always empty: the TYPED TEXT, carried in this field and
|
|
172
|
+
* returned to the caller unchanged. The name says `optionId` because one wire shape serves all
|
|
173
|
+
* three methods; for an input ask it is not an id at all, and there is no id namespace for it to
|
|
174
|
+
* collide with — text that happens to equal some other ask's option id is still just text.
|
|
175
|
+
*/
|
|
176
|
+
optionId: string;
|
|
177
|
+
/** Which surface, and which client on it, produced this answer. */
|
|
178
|
+
decidedBy: RelayDecider;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Handle onto the session's pending-ask registry.
|
|
182
|
+
*
|
|
183
|
+
* Implemented outside the agent core (the registry lives in the attach bind closure, because the
|
|
184
|
+
* ExtensionRunner — and therefore the decorator — is rebuilt on every reload).
|
|
185
|
+
*/
|
|
186
|
+
export interface PermissionRelay {
|
|
187
|
+
/** How many attached clients could answer right now. Evaluated live, never cached. */
|
|
188
|
+
readWriteClientCount(): number;
|
|
189
|
+
/**
|
|
190
|
+
* Broadcast an ask and resolve with the first valid answer — or with how the ask ENDED.
|
|
191
|
+
*
|
|
192
|
+
* THREE outcomes, and the last two are not the same thing:
|
|
193
|
+
*
|
|
194
|
+
* - a {@link RelayAnswer}: somebody answered.
|
|
195
|
+
* - a {@link RelayEnded}: the RELAY ended the ask. Its clock ran out, or the session was
|
|
196
|
+
* stopped or replaced. The ask is over on every surface, the ending is already broadcast and
|
|
197
|
+
* recorded, and the decorator must settle on the method's fail-closed default and take the
|
|
198
|
+
* local dialog down. A decorator that kept waiting here leaves a live Approve button on an
|
|
199
|
+
* ask the durable record already says expired — the fail-OPEN defect this member exists to
|
|
200
|
+
* make unrepresentable.
|
|
201
|
+
* - `undefined`: the relay is SPENT, but the ask is not over. It was refused at a bound, its
|
|
202
|
+
* socket was already gone, or the answer named an option nobody offered. With a live local
|
|
203
|
+
* surface the decorator keeps waiting and the human at the terminal still decides; WITHOUT
|
|
204
|
+
* one — the headless case — it settles on the method's own fail-closed default, attributed
|
|
205
|
+
* to the system rather than to any person.
|
|
206
|
+
*/
|
|
207
|
+
raise(ask: RelayAsk): Promise<RelayAnswer | RelayEnded | undefined>;
|
|
208
|
+
/**
|
|
209
|
+
* Tell the relay this ask is over: WHO ended it, and WHAT HAPPENED.
|
|
210
|
+
*
|
|
211
|
+
* Both halves are required and neither may be inferred by the implementation. The caller has
|
|
212
|
+
* just settled the ask and holds the value; an implementation that reconstructs the outcome
|
|
213
|
+
* from anything else is guessing, and a guess written into the session's durable record is a
|
|
214
|
+
* decision that never happened.
|
|
215
|
+
*
|
|
216
|
+
* Withdrawing an ask that is already over MUST be silent — no second broadcast, no second audit
|
|
217
|
+
* row. The decorator withdraws every ask it settles, including the ones a remote answer already
|
|
218
|
+
* settled inside the relay.
|
|
219
|
+
*/
|
|
220
|
+
withdraw(requestId: string, decidedBy: RelayDecider, outcome: RelayOutcome): void;
|
|
221
|
+
}
|
|
222
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/core/permission-relay/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAElE,gGAAgG;AAChG,MAAM,WAAW,YAAY;IAC5B,OAAO,EAAE,KAAK,GAAG,QAAQ,GAAG,KAAK,GAAG,KAAK,GAAG,QAAQ,CAAC;IACrD,QAAQ,EAAE,MAAM,GAA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,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAW,UAAU;IAC1B,+FAA+F;IAC/F,SAAS,EAAE,MAAM,CAAC;IAClB,oGAAoG;IACpG,KAAK,EAAE,SAAS,GAAG,WAAW,CAAC;IAC/B,kGAAkG;IAClG,SAAS,EAAE,YAAY,CAAC;CACxB;AAED,sFAAsF;AACtF,wBAAgB,YAAY,CAAC,KAAK,EAAE,WAAW,GAAG,UAAU,GAAG,SAAS,GAAG,KAAK,IAAI,UAAU,CAE7F;AAED,kDAAkD;AAClD,MAAM,WAAW,WAAW;IAC3B,yEAAyE;IACzE,SAAS,EAAE,MAAM,CAAC;IAClB;;;;;;;;;;OAUG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB,mEAAmE;IACnE,SAAS,EAAE,YAAY,CAAC;CACxB;AAED;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC/B,sFAAsF;IACtF,oBAAoB,IAAI,MAAM,CAAC;IAC/B;;;;;;;;;;;;;;;;;OAiBG;IACH,KAAK,CAAC,GAAG,EAAE,QAAQ,GAAG,OAAO,CAAC,WAAW,GAAG,UAAU,GAAG,SAAS,CAAC,CAAC;IACpE;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,OAAO,EAAE,YAAY,GAAG,IAAI,CAAC;CAClF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The port the relay UI decorator talks to.
|
|
3
|
+
*
|
|
4
|
+
* This file deliberately imports NOTHING from the socket server. The decorator must be usable
|
|
5
|
+
* with a hand-written fake in tests and must not drag the attach wire into the agent core.
|
|
6
|
+
*/
|
|
7
|
+
/** The outcome of an ask that ended without anybody answering it. Shared, frozen, allocation-free. */
|
|
8
|
+
export const RELAY_CANCELLED = Object.freeze({ kind: "cancelled" });
|
|
9
|
+
/** The outcome of a `select` or `input` that WAS answered — no permission was granted or refused. */
|
|
10
|
+
export const RELAY_ANSWERED = Object.freeze({ kind: "answered" });
|
|
11
|
+
/** Whether a settled `raise()` is the relay reporting that the ask itself is OVER. */
|
|
12
|
+
export function isRelayEnded(value) {
|
|
13
|
+
return value !== undefined && "ended" in value;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/core/permission-relay/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAoDH,sGAAsG;AACtG,MAAM,CAAC,MAAM,eAAe,GAAiB,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,WAAoB,EAAE,CAAC,CAAC;AAE3F,qGAAqG;AACrG,MAAM,CAAC,MAAM,cAAc,GAAiB,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,UAAmB,EAAE,CAAC,CAAC;AAgGzF,sFAAsF;AACtF,MAAM,UAAU,YAAY,CAAC,KAA2C;IACvE,OAAO,KAAK,KAAK,SAAS,IAAI,OAAO,IAAI,KAAK,CAAC;AAChD,CAAC","sourcesContent":["/**\n * The port the relay UI decorator talks to.\n *\n * This file deliberately imports NOTHING from the socket server. The decorator must be usable\n * with a hand-written fake in tests and must not drag the attach wire into the agent core.\n */\n\nimport type { PermissionAskDetail } from \"../extensions/types.ts\";\n\n/** Which surface produced an answer, and which client on that surface (when it has clients). */\nexport interface RelayDecider {\n\tsurface: \"tui\" | \"attach\" | \"rpc\" | \"acp\" | \"system\";\n\tclientId: string | null;\n}\n\n/**\n * The surface a LOCALLY raised dialog belongs to.\n *\n * `attach` is excluded because it is the REMOTE side by definition — an attached client's answer\n * comes back through {@link RelayAnswer.decidedBy} and is never what the decorator is describing.\n * `system` IS allowed and is the truthful value for a binding mode that shows no dialog to anybody\n * (`print`, `json`): if such a mode ever ends an ask, nobody acted.\n *\n * There is no default. The decorator is built at ONE seam that knows the mode, and a default here\n * would be exactly the hardcoded `tui` this type exists to abolish — an answer typed into the RPC\n * surface, and a process shutdown, both recorded as a human at a terminal that does not exist.\n */\nexport type LocalSurface = Exclude<RelayDecider[\"surface\"], \"attach\">;\n\n/**\n * WHAT ACTUALLY HAPPENED to an ask, as the surface that ended it knows it.\n *\n * This exists because a relay cannot GUESS. `withdraw` used to carry only the decider, so the\n * implementation hardcoded `cancelled` — and an approved, EXECUTED command was written into the\n * durable record and put on the wire as `cancelled`, with `chosenOptionId: null`. The decision was\n * known to the caller of `withdraw` all along; it simply had nowhere to put it.\n *\n * - `approved` / `denied` — a surface ANSWERED, and the answer's own vocabulary says what that\n * meant. `chosenOptionId` names the offered option when one was named, and is `null` when the\n * answering surface did not name one (see below).\n * - `answered` — a `select` or `input` was answered. Those methods carry NO permission semantics:\n * nothing was approved and nothing was denied, so neither word may be used for them.\n * - `cancelled` — the ask ended with NO answer at all: an abort, a shutdown, a session\n * replacement, a declared timeout, or a relay that was spent before anybody could act.\n *\n * `chosenOptionId: null` on an `approved`/`denied` outcome is not a hole, it is the honest report\n * of a surface that answered WITHOUT naming an option — the local `ExtensionUIContext.confirm`\n * returns a bare `Promise<boolean>` and draws its own Yes/No, so it never chose one of the offered\n * ids. Reverse-mapping that boolean onto the offered set would be a derivation, and with a\n * vocabulary like `[allow, deny-once, deny-always]` it would name an option nobody touched.\n */\nexport type RelayOutcome =\n\t| { readonly kind: \"approved\"; readonly chosenOptionId: string | null }\n\t| { readonly kind: \"denied\"; readonly chosenOptionId: string | null }\n\t| { readonly kind: \"answered\" }\n\t| { readonly kind: \"cancelled\" };\n\n/** The outcome of an ask that ended without anybody answering it. Shared, frozen, allocation-free. */\nexport const RELAY_CANCELLED: RelayOutcome = Object.freeze({ kind: \"cancelled\" as const });\n\n/** The outcome of a `select` or `input` that WAS answered — no permission was granted or refused. */\nexport const RELAY_ANSWERED: RelayOutcome = Object.freeze({ kind: \"answered\" as const });\n\n/** A single ask broadcast to every attached read-write client. */\nexport interface RelayAsk {\n\t/** Stable id for this ask, minted once per raised dialog. */\n\trequestId: string;\n\t/** Which UI primitive raised it. */\n\tmethod: \"confirm\" | \"select\" | \"input\";\n\t/** Headline for the ask. Render it as the dialog's title on every surface. */\n\ttitle: string;\n\t/**\n\t * Secondary text — but NOT the same thing on every method.\n\t *\n\t * For `confirm` and `select` it is body copy. For `input` it is the field's PLACEHOLDER, because\n\t * that is the only string `ExtensionUIContext.input` carries. A renderer that paints it as body\n\t * copy leaves the text field with no placeholder and shows a hint where a prompt belongs.\n\t */\n\tmessage?: string;\n\t/**\n\t * Canonical detail for a tool permission ask, when the caller supplied one.\n\t *\n\t * `detail.options` is a rendering carrier that states each option's own `decision`. It is NOT a\n\t * second offered set: what may be answered is {@link RelayAsk.options} below, and only that.\n\t */\n\tdetail?: PermissionAskDetail;\n\t/**\n\t * The immutable set of options offered for this request — the ONLY answerable set.\n\t *\n\t * Ids here are opaque handles minted with the ask. A client echoes one back verbatim; it must\n\t * never derive an option's meaning from its position in this array or from the shape of its id,\n\t * and the decorator that minted them never does either: each option's caller-side value was\n\t * bound when the option was constructed.\n\t *\n\t * `decision` states what choosing that option MEANS, so a client can render a denial as\n\t * destructive without joining this array to `detail.options` by id — a join that is impossible\n\t * for `select`, whose two arrays share no ids at all. It is present on every option of a\n\t * `confirm` and absent for `select` and `input`, where the concept does not apply. It is\n\t * rendering data: what an answer resolves to was fixed when the option was minted, and echoing\n\t * a different `decision` back changes nothing.\n\t *\n\t * An EMPTY array means no option can be named BY ID. It does NOT mean the ask is unanswerable —\n\t * read {@link RelayAsk.method} for that, because the two empty-array cases behave OPPOSITELY:\n\t *\n\t * - `confirm` or `select` with an empty array: nothing is answerable. The ask is shown for\n\t * context only and is decided by the local surface or by the raising method's own fail-closed\n\t * default. This is what a `confirm` whose caller-supplied vocabulary failed validation looks\n\t * like. Echoing any id back is silence, not a dismissal — it decides nothing.\n\t * - `input`: this array is ALWAYS empty, and the ask is nonetheless fully answerable — with free\n\t * text, sent verbatim as {@link RelayAnswer.optionId}. EVERY string is a valid answer. A client\n\t * that renders an input ask as informational-with-no-way-to-answer hangs the agent until the\n\t * ask expires.\n\t *\n\t * No separate \"answerable\" flag is added: `method` is already on the wire and already carries\n\t * this distinction, and a second field asserting the same thing is a second thing that can\n\t * disagree with it.\n\t */\n\toptions: readonly { id: string; label: string; decision?: \"approve\" | \"deny\" }[];\n\t/** ISO timestamp of when the ask was raised. */\n\trequestedAt: string;\n\t/**\n\t * ISO timestamp for ADVISORY rendering only, or null when there is none.\n\t *\n\t * Real expiry binds solely to the pending registry's fail-closed timer — one clock. Nothing\n\t * may deny an ask because this instant passed.\n\t */\n\tdeadline: string | null;\n}\n\n/**\n * The relay ITSELF ended the ask. Nobody answered, and nobody still can.\n *\n * THIS IS NOT THE SAME AS `raise()` RESOLVING `undefined`, and conflating the two was a FAIL-OPEN\n * defect. `undefined` means \"the relay is spent\" — it refused the ask at a bound, its socket was\n * already gone, or an answer named an option nobody offered. In every one of those the ask itself\n * is still live and a human at the LOCAL surface must still get to answer it.\n *\n * This value means the opposite: the ask is OVER. The registry's fail-closed clock ran out, or the\n * session it belonged to was stopped or replaced. The relay has already broadcast the ending and\n * written it down, so a surface that kept its dialog on screen after this would be offering a human\n * a button that can still run the command an audit row already records as expired — which is\n * exactly what happened: the durable record said `expired`, the human tapped Approve on the local\n * dialog nobody had taken down, and the command RAN.\n *\n * A decorator receiving this must settle its ask on the raising method's own fail-closed default,\n * abort the local surface, and attribute the ending to {@link RelayEnded.decidedBy} — which names\n * `system`, because nobody decided anything.\n */\nexport interface RelayEnded {\n\t/** The ask that ended. An `ended` naming any other ask is ignored, exactly as an answer is. */\n\trequestId: string;\n\t/** WHAT ended it. Never `approved`/`denied`: nobody answered, so nothing was granted or refused. */\n\tended: \"expired\" | \"cancelled\";\n\t/** Who ended it. Always the system — an ask nobody answered may not be attributed to a person. */\n\tdecidedBy: RelayDecider;\n}\n\n/** Whether a settled `raise()` is the relay reporting that the ask itself is OVER. */\nexport function isRelayEnded(value: RelayAnswer | RelayEnded | undefined): value is RelayEnded {\n\treturn value !== undefined && \"ended\" in value;\n}\n\n/** An answer that came back from some surface. */\nexport interface RelayAnswer {\n\t/** The ask being answered. An answer naming any other ask is ignored. */\n\trequestId: string;\n\t/**\n\t * WHAT was answered — and for a free-text ask, the answer ITSELF.\n\t *\n\t * For `confirm` and `select`: one {@link RelayAsk.options} id, echoed back verbatim. An id that\n\t * was never offered is silence — it can never become a decision attributed to a human.\n\t *\n\t * For `input`, whose `options` is always empty: the TYPED TEXT, carried in this field and\n\t * returned to the caller unchanged. The name says `optionId` because one wire shape serves all\n\t * three methods; for an input ask it is not an id at all, and there is no id namespace for it to\n\t * collide with — text that happens to equal some other ask's option id is still just text.\n\t */\n\toptionId: string;\n\t/** Which surface, and which client on it, produced this answer. */\n\tdecidedBy: RelayDecider;\n}\n\n/**\n * Handle onto the session's pending-ask registry.\n *\n * Implemented outside the agent core (the registry lives in the attach bind closure, because the\n * ExtensionRunner — and therefore the decorator — is rebuilt on every reload).\n */\nexport interface PermissionRelay {\n\t/** How many attached clients could answer right now. Evaluated live, never cached. */\n\treadWriteClientCount(): number;\n\t/**\n\t * Broadcast an ask and resolve with the first valid answer — or with how the ask ENDED.\n\t *\n\t * THREE outcomes, and the last two are not the same thing:\n\t *\n\t * - a {@link RelayAnswer}: somebody answered.\n\t * - a {@link RelayEnded}: the RELAY ended the ask. Its clock ran out, or the session was\n\t * stopped or replaced. The ask is over on every surface, the ending is already broadcast and\n\t * recorded, and the decorator must settle on the method's fail-closed default and take the\n\t * local dialog down. A decorator that kept waiting here leaves a live Approve button on an\n\t * ask the durable record already says expired — the fail-OPEN defect this member exists to\n\t * make unrepresentable.\n\t * - `undefined`: the relay is SPENT, but the ask is not over. It was refused at a bound, its\n\t * socket was already gone, or the answer named an option nobody offered. With a live local\n\t * surface the decorator keeps waiting and the human at the terminal still decides; WITHOUT\n\t * one — the headless case — it settles on the method's own fail-closed default, attributed\n\t * to the system rather than to any person.\n\t */\n\traise(ask: RelayAsk): Promise<RelayAnswer | RelayEnded | undefined>;\n\t/**\n\t * Tell the relay this ask is over: WHO ended it, and WHAT HAPPENED.\n\t *\n\t * Both halves are required and neither may be inferred by the implementation. The caller has\n\t * just settled the ask and holds the value; an implementation that reconstructs the outcome\n\t * from anything else is guessing, and a guess written into the session's durable record is a\n\t * decision that never happened.\n\t *\n\t * Withdrawing an ask that is already over MUST be silent — no second broadcast, no second audit\n\t * row. The decorator withdraws every ask it settles, including the ones a remote answer already\n\t * settled inside the relay.\n\t */\n\twithdraw(requestId: string, decidedBy: RelayDecider, outcome: RelayOutcome): void;\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface PiManifest {
|
|
2
|
+
extensions?: string[];
|
|
3
|
+
skills?: string[];
|
|
4
|
+
prompts?: string[];
|
|
5
|
+
themes?: string[];
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* A package declares its extensions/skills/prompts/themes under a top-level
|
|
9
|
+
* manifest key. draht reads `draht` first and falls back to upstream's `pi`,
|
|
10
|
+
* mirroring CONFIG_DIR_NAME / LEGACY_CONFIG_DIR_NAME: packages authored for
|
|
11
|
+
* upstream (or copied from its docs) keep working unchanged.
|
|
12
|
+
*/
|
|
13
|
+
export declare function readPiManifest(packageJsonPath: string): PiManifest | null;
|
|
14
|
+
//# sourceMappingURL=pi-manifest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pi-manifest.d.ts","sourceRoot":"","sources":["../../src/core/pi-manifest.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,UAAU;IAC1B,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CAClB;AAQD;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,eAAe,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAsBzE"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
const RESOURCE_FIELDS = ["extensions", "skills", "prompts", "themes"];
|
|
3
|
+
function isObject(value) {
|
|
4
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* A package declares its extensions/skills/prompts/themes under a top-level
|
|
8
|
+
* manifest key. draht reads `draht` first and falls back to upstream's `pi`,
|
|
9
|
+
* mirroring CONFIG_DIR_NAME / LEGACY_CONFIG_DIR_NAME: packages authored for
|
|
10
|
+
* upstream (or copied from its docs) keep working unchanged.
|
|
11
|
+
*/
|
|
12
|
+
export function readPiManifest(packageJsonPath) {
|
|
13
|
+
try {
|
|
14
|
+
const pkg = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
|
|
15
|
+
if (!isObject(pkg)) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
const raw = isObject(pkg.draht) ? pkg.draht : isObject(pkg.pi) ? pkg.pi : null;
|
|
19
|
+
if (!raw) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
const manifest = {};
|
|
23
|
+
for (const field of RESOURCE_FIELDS) {
|
|
24
|
+
const entries = raw[field];
|
|
25
|
+
if (Array.isArray(entries) && entries.every((entry) => typeof entry === "string")) {
|
|
26
|
+
manifest[field] = entries;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return manifest;
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=pi-manifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pi-manifest.js","sourceRoot":"","sources":["../../src/core/pi-manifest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AASv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;IACb,CAAC;AACF,CAAC","sourcesContent":["import { readFileSync } from \"node:fs\";\n\nexport interface PiManifest {\n\textensions?: string[];\n\tskills?: string[];\n\tprompts?: string[];\n\tthemes?: string[];\n}\n\nconst RESOURCE_FIELDS = [\"extensions\", \"skills\", \"prompts\", \"themes\"] as const;\n\nfunction isObject(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/**\n * A package declares its extensions/skills/prompts/themes under a top-level\n * manifest key. draht reads `draht` first and falls back to upstream's `pi`,\n * mirroring CONFIG_DIR_NAME / LEGACY_CONFIG_DIR_NAME: packages authored for\n * upstream (or copied from its docs) keep working unchanged.\n */\nexport function readPiManifest(packageJsonPath: string): PiManifest | null {\n\ttry {\n\t\tconst pkg: unknown = JSON.parse(readFileSync(packageJsonPath, \"utf-8\"));\n\t\tif (!isObject(pkg)) {\n\t\t\treturn null;\n\t\t}\n\t\tconst raw = isObject(pkg.draht) ? pkg.draht : isObject(pkg.pi) ? pkg.pi : null;\n\t\tif (!raw) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst manifest: PiManifest = {};\n\t\tfor (const field of RESOURCE_FIELDS) {\n\t\t\tconst entries = raw[field];\n\t\t\tif (Array.isArray(entries) && entries.every((entry) => typeof entry === \"string\")) {\n\t\t\t\tmanifest[field] = entries;\n\t\t\t}\n\t\t}\n\t\treturn manifest;\n\t} catch {\n\t\treturn null;\n\t}\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { CONFIG_DIR_NAME } from "../config.js";
|
|
1
|
+
import { APP_NAME, CONFIG_DIR_NAME } from "../config.js";
|
|
2
2
|
import { emitProjectTrustEvent } from "./extensions/runner.js";
|
|
3
3
|
import { getProjectTrustOptions, hasTrustRequiringProjectResources, } from "./trust-manager.js";
|
|
4
4
|
function formatProjectTrustPrompt(cwd) {
|
|
5
|
-
return `Trust project folder?\n${cwd}\n\nThis allows
|
|
5
|
+
return `Trust project folder?\n${cwd}\n\nThis allows ${APP_NAME} to load ${CONFIG_DIR_NAME} settings and resources, install missing project packages, and execute project extensions.`;
|
|
6
6
|
}
|
|
7
7
|
async function selectProjectTrustOption(cwd, ctx) {
|
|
8
8
|
const options = getProjectTrustOptions(cwd, { includeSessionOnly: true });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project-trust.js","sourceRoot":"","sources":["../../src/core/project-trust.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"project-trust.js","sourceRoot":"","sources":["../../src/core/project-trust.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAG/D,OAAO,EACN,sBAAsB,EACtB,iCAAiC,GAGjC,MAAM,oBAAoB,CAAC;AAc5B,SAAS,wBAAwB,CAAC,GAAW;IAC5C,OAAO,0BAA0B,GAAG,mBAAmB,QAAQ,YAAY,eAAe,4FAA4F,CAAC;AACxL,CAAC;AAED,KAAK,UAAU,wBAAwB,CACtC,GAAW,EACX,GAAwB;IAExB,MAAM,OAAO,GAAG,sBAAsB,CAAC,GAAG,EAAE,EAAE,kBAAkB,EAAE,IAAI,EAAE,CAAC,CAAC;IAC1E,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,EAAE,CAAC,MAAM,CACnC,wBAAwB,CAAC,GAAG,CAAC,EAC7B,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CACrC,CAAC;IACF,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC;AAC5D,CAAC;AAED,SAAS,4BAA4B,CAAC,UAA6B,EAAE,MAA0B;IAC9F,IAAI,MAAM,C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AAO,QAAQ,CAAC;IACjB,CAAC;IAED,QAAQ,OAAO,CAAC,mBAAmB,IAAI,KAAK,EAAE,CAAC;QAC9C,KAAK,QAAQ;YACZ,OAAO,IAAI,CAAC;QACb,KAAK,OAAO;YACX,OAAO,KAAK,CAAC;QACd,KAAK,KAAK;YACT,MAAM;IACR,CAAC;IAED,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,KAAK,EAAE,CAAC;QACxC,OAAO,KAAK,CAAC;IACd,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,wBAAwB,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAC1F,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC5B,4BAA4B,CAAC,OAAO,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QAC3D,OAAO,QAAQ,CAAC,OAAO,CAAC;IACzB,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC","sourcesContent":["import { APP_NAME, CONFIG_DIR_NAME } from \"../config.ts\";\nimport { emitProjectTrustEvent } from \"./extensions/runner.ts\";\nimport type { LoadExtensionsResult, ProjectTrustContext } from \"./extensions/types.ts\";\nimport type { DefaultProjectTrust } from \"./settings-manager.ts\";\nimport {\n\tgetProjectTrustOptions,\n\thasTrustRequiringProjectResources,\n\ttype ProjectTrustOption,\n\ttype ProjectTrustStore,\n} from \"./trust-manager.ts\";\n\nexport type AppMode = \"interactive\" | \"print\" | \"json\" | \"rpc\";\n\nexport interface ResolveProjectTrustedOptions {\n\tcwd: string;\n\ttrustStore: ProjectTrustStore;\n\ttrustOverride?: boolean;\n\tdefaultProjectTrust?: DefaultProjectTrust;\n\textensionsResult?: LoadExtensionsResult;\n\tprojectTrustContext: ProjectTrustContext;\n\tonExtensionError?: (message: string) => void;\n}\n\nfunction formatProjectTrustPrompt(cwd: string): string {\n\treturn `Trust project folder?\\n${cwd}\\n\\nThis allows ${APP_NAME} to load ${CONFIG_DIR_NAME} settings and resources, install missing project packages, and execute project extensions.`;\n}\n\nasync function selectProjectTrustOption(\n\tcwd: string,\n\tctx: ProjectTrustContext,\n): Promise<ProjectTrustOption | undefined> {\n\tconst options = getProjectTrustOptions(cwd, { includeSessionOnly: true });\n\tconst selected = await ctx.ui.select(\n\t\tformatProjectTrustPrompt(cwd),\n\t\toptions.map((option) => option.label),\n\t);\n\treturn options.find((option) => option.label === selected);\n}\n\nfunction saveProjectTrustPromptResult(trustStore: ProjectTrustStore, result: ProjectTrustOption): void {\n\tif (result.updates.length > 0) {\n\t\ttrustStore.setMany(result.updates);\n\t}\n}\n\nexport async function resolveProjectTrusted(options: ResolveProjectTrustedOptions): Promise<boolean> {\n\tif (options.trustOverride !== undefined) {\n\t\treturn options.trustOverride;\n\t}\n\tif (!hasTrustRequiringProjectResources(options.cwd)) {\n\t\treturn true;\n\t}\n\n\tif (options.extensionsResult) {\n\t\tconst { result, errors } = await emitProjectTrustEvent(\n\t\t\toptions.extensionsResult,\n\t\t\t{ type: \"project_trust\", cwd: options.cwd },\n\t\t\toptions.projectTrustContext,\n\t\t);\n\t\tfor (const error of errors) {\n\t\t\toptions.onExtensionError?.(`Extension \"${error.extensionPath}\" project_trust error: ${error.error}`);\n\t\t}\n\t\tif (result) {\n\t\t\tconst trusted = result.trusted === \"yes\";\n\t\t\tif (result.remember === true) {\n\t\t\t\toptions.trustStore.set(options.cwd, trusted);\n\t\t\t}\n\t\t\treturn trusted;\n\t\t}\n\t}\n\n\tconst decision = options.trustStore.get(options.cwd);\n\tif (decision !== null) {\n\t\treturn decision;\n\t}\n\n\tswitch (options.defaultProjectTrust ?? \"ask\") {\n\t\tcase \"always\":\n\t\t\treturn true;\n\t\tcase \"never\":\n\t\t\treturn false;\n\t\tcase \"ask\":\n\t\t\tbreak;\n\t}\n\n\tif (!options.projectTrustContext.hasUI) {\n\t\treturn false;\n\t}\n\n\tconst selected = await selectProjectTrustOption(options.cwd, options.projectTrustContext);\n\tif (selected !== undefined) {\n\t\tsaveProjectTrustPromptResult(options.trustStore, selected);\n\t\treturn selected.trusted;\n\t}\n\treturn false;\n}\n"]}
|
|
@@ -60,12 +60,29 @@ export interface ResourceLoader {
|
|
|
60
60
|
export declare function loadProjectContextFiles(options: {
|
|
61
61
|
cwd: string;
|
|
62
62
|
agentDir: string;
|
|
63
|
+
/**
|
|
64
|
+
* Absolute path the ancestor walk stops at, and the root every discovered project
|
|
65
|
+
* context file must be canonically contained under (R36-SPAWN.6).
|
|
66
|
+
*
|
|
67
|
+
* This is the PROJECT ROOT, not the session cwd: draht-mono itself keeps an AGENTS.md
|
|
68
|
+
* at the repo root that subdirectory sessions are meant to inherit, so rooting at cwd
|
|
69
|
+
* would silently drop it.
|
|
70
|
+
*
|
|
71
|
+
* Left unset the walk runs to `/` and nothing is refused on containment grounds, which
|
|
72
|
+
* is byte-identical to the behaviour every discovered session has today.
|
|
73
|
+
*/
|
|
74
|
+
contextRoot?: string;
|
|
63
75
|
}): Array<{
|
|
64
76
|
path: string;
|
|
65
77
|
content: string;
|
|
66
78
|
}>;
|
|
67
79
|
export interface DefaultResourceLoaderOptions {
|
|
68
80
|
cwd: string;
|
|
81
|
+
/**
|
|
82
|
+
* `cwd` before `path.resolve` collapsed any `..`, for callers that resolve first.
|
|
83
|
+
* The ancestor skill walk needs the uncollapsed spelling to resolve it physically.
|
|
84
|
+
*/
|
|
85
|
+
cwdSpelling?: string;
|
|
69
86
|
agentDir: string;
|
|
70
87
|
settingsManager?: SettingsManager;
|
|
71
88
|
eventBus?: EventBus;
|
|
@@ -79,6 +96,8 @@ export interface DefaultResourceLoaderOptions {
|
|
|
79
96
|
noPromptTemplates?: boolean;
|
|
80
97
|
noThemes?: boolean;
|
|
81
98
|
noContextFiles?: boolean;
|
|
99
|
+
/** Absolute project root that automatically-read context files must stay inside (R36-SPAWN.6). */
|
|
100
|
+
contextRoot?: string;
|
|
82
101
|
systemPrompt?: string;
|
|
83
102
|
appendSystemPrompt?: string[];
|
|
84
103
|
extensionsOverride?: (base: LoadExtensionsResult) => LoadExtensionsResult;
|
|
@@ -119,6 +138,7 @@ export interface DefaultResourceLoaderOptions {
|
|
|
119
138
|
}
|
|
120
139
|
export declare class DefaultResourceLoader implements ResourceLoader {
|
|
121
140
|
private cwd;
|
|
141
|
+
private cwdSpelling;
|
|
122
142
|
private agentDir;
|
|
123
143
|
private settingsManager;
|
|
124
144
|
private eventBus;
|
|
@@ -133,6 +153,7 @@ export declare class DefaultResourceLoader implements ResourceLoader {
|
|
|
133
153
|
private noPromptTemplates;
|
|
134
154
|
private noThemes;
|
|
135
155
|
private noContextFiles;
|
|
156
|
+
private contextRoot?;
|
|
136
157
|
private systemPromptSource?;
|
|
137
158
|
private appendSystemPromptSource?;
|
|
138
159
|
private extensionsOverride?;
|