@draht/coding-agent 2026.7.30 → 2026.10.4-2
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 +606 -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/bun/cli.d.ts +1 -1
- package/dist/bun/cli.d.ts.map +1 -1
- package/dist/bun/cli.js +6 -3
- package/dist/bun/cli.js.map +1 -1
- package/dist/bun/sandbox-env-setup.d.ts +2 -0
- package/dist/bun/sandbox-env-setup.d.ts.map +1 -0
- package/dist/bun/sandbox-env-setup.js +4 -0
- package/dist/bun/sandbox-env-setup.js.map +1 -0
- package/dist/bundle/chunks/anthropic-messages-GAKYXF65.js +6 -0
- package/dist/bundle/chunks/anthropic.js +75 -0
- package/dist/bundle/chunks/azure-openai-responses-ZIXMK6JO.js +2 -0
- package/dist/bundle/chunks/bedrock-converse-stream.js +79 -0
- package/dist/bundle/chunks/chunk-2E5VODES.js +2 -0
- package/dist/bundle/chunks/chunk-2FBJKY7F.js +2 -0
- package/dist/bundle/chunks/chunk-2N4I6WXC.js +2 -0
- package/dist/bundle/chunks/chunk-5VZWYVZB.js +82 -0
- package/dist/bundle/chunks/chunk-63BK6WK2.js +2 -0
- package/dist/bundle/chunks/chunk-6MSE6LZ3.js +6 -0
- package/dist/bundle/chunks/chunk-6ZJKIMU7.js +2 -0
- package/dist/bundle/chunks/chunk-736QBNUZ.js +12 -0
- package/dist/bundle/chunks/chunk-BXSHCX3G.js +11 -0
- package/dist/bundle/chunks/chunk-CEJJ5XF2.js +170 -0
- package/dist/bundle/chunks/chunk-COF5JT7R.js +4 -0
- package/dist/bundle/chunks/chunk-D6TMD5Q2.js +44 -0
- package/dist/bundle/chunks/chunk-DPE4ALPU.js +146 -0
- package/dist/bundle/chunks/chunk-EBVYI75P.js +2 -0
- package/dist/bundle/chunks/chunk-GVXA72ZA.js +2 -0
- package/dist/bundle/chunks/chunk-H6FT43VC.js +137 -0
- package/dist/bundle/chunks/chunk-HJ72RANT.js +2 -0
- package/dist/bundle/chunks/chunk-HTJ3L72O.js +2 -0
- package/dist/bundle/chunks/chunk-HZ2UHMBT.js +2 -0
- package/dist/bundle/chunks/chunk-I5OKY6RH.js +11 -0
- package/dist/bundle/chunks/chunk-IWTUBX6V.js +4 -0
- package/dist/bundle/chunks/chunk-KPO5375S.js +2 -0
- package/dist/bundle/chunks/chunk-KVH4HR57.js +31 -0
- package/dist/bundle/chunks/chunk-LDAOC5RB.js +18 -0
- package/dist/bundle/chunks/chunk-ON6XU6AG.js +2 -0
- package/dist/bundle/chunks/chunk-QMN7OD6G.js +2 -0
- package/dist/bundle/chunks/chunk-RZKPFWMH.js +42 -0
- package/dist/bundle/chunks/chunk-SDRCE6OP.js +2 -0
- package/dist/bundle/chunks/chunk-SVNWI7EV.js +8 -0
- package/dist/bundle/chunks/chunk-TIA2T6EO.js +3 -0
- package/dist/bundle/chunks/chunk-VOFPZOUQ.js +1472 -0
- package/dist/bundle/chunks/chunk-XBUEMKIY.js +2 -0
- package/dist/bundle/chunks/chunk-XOGEYN4Q.js +2 -0
- package/dist/bundle/chunks/chunk-ZZD35WKM.js +2 -0
- package/dist/bundle/chunks/cli-SR5QBZH4.js +51 -0
- package/dist/bundle/chunks/cloudflare-workers-ai-system-one-MJKOAE5S.js +2 -0
- package/dist/bundle/chunks/codemode-worker.js +315 -0
- package/dist/bundle/chunks/execute-VCYDHEYA.js +328 -0
- package/dist/bundle/chunks/github-copilot.js +2 -0
- package/dist/bundle/chunks/google-antigravity.js +75 -0
- package/dist/bundle/chunks/google-gemini-cli.js +75 -0
- package/dist/bundle/chunks/google-generative-ai-RPUPQ6PM.js +2 -0
- package/dist/bundle/chunks/google-vertex-EZES5QVQ.js +2 -0
- package/dist/bundle/chunks/https-proxy-agent-O2PVUIOI.js +13 -0
- package/dist/bundle/chunks/image-resize-worker.js +2 -0
- package/dist/bundle/chunks/jiti-loader-RKXLMQV2.js +2 -0
- package/dist/bundle/chunks/kimi-coding.js +2 -0
- package/dist/bundle/chunks/lib-XOG5PI3Y.js +9 -0
- package/dist/bundle/chunks/llama-cpp-classify-EJ5XMSQL.js +22 -0
- package/dist/bundle/chunks/meta.js +2 -0
- package/dist/bundle/chunks/mistral-conversations-AOYGU43Y.js +5 -0
- package/dist/bundle/chunks/multipart-parser-AZP5BX2W.js +3 -0
- package/dist/bundle/chunks/node-C2JGH2OB.js +2 -0
- package/dist/bundle/chunks/node-LQ52KV6B.js +16 -0
- package/dist/bundle/chunks/openai-chatgpt.js +75 -0
- package/dist/bundle/chunks/openai-codex-responses-M2Y77JEQ.js +10 -0
- package/dist/bundle/chunks/openai-codex.js +75 -0
- package/dist/bundle/chunks/openai-completions-A4OKYOYV.js +7 -0
- package/dist/bundle/chunks/openai-responses-6IXV53T3.js +3 -0
- package/dist/bundle/chunks/opencode-go.js +2 -0
- package/dist/bundle/chunks/openrouter-images-LYV4NKFM.js +2 -0
- package/dist/bundle/chunks/openrouter.js +75 -0
- package/dist/bundle/chunks/pi-messages-KKMEUT3Z.js +8 -0
- package/dist/bundle/chunks/radius.js +75 -0
- package/dist/bundle/chunks/runtime-6YJPGSP7.js +2 -0
- package/dist/bundle/chunks/settings-manager-D2EG7WDO.js +2 -0
- package/dist/bundle/chunks/src-TIBHS42X.js +4 -0
- package/dist/bundle/chunks/typesafe-system-one-YBEEY5XU.js +2 -0
- package/dist/bundle/chunks/virtual-modules-CBOAFAFT.js +2 -0
- package/dist/bundle/chunks/xai.js +75 -0
- package/dist/bundle/cli-runtime.js +3 -0
- package/dist/bundle/cli.js +5 -0
- package/dist/bundle/index.js +2 -0
- package/dist/bundle/rpc-entry.js +3 -0
- package/dist/cli/args.d.ts +14 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +140 -22
- 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/auth-check.d.ts +19 -0
- package/dist/cli/auth-check.d.ts.map +1 -0
- package/dist/cli/auth-check.js +50 -0
- package/dist/cli/auth-check.js.map +1 -0
- package/dist/cli/auth-command.d.ts +24 -0
- package/dist/cli/auth-command.d.ts.map +1 -0
- package/dist/cli/auth-command.js +103 -0
- package/dist/cli/auth-command.js.map +1 -0
- package/dist/cli/config-selector.d.ts.map +1 -1
- package/dist/cli/config-selector.js +3 -2
- package/dist/cli/config-selector.js.map +1 -1
- package/dist/cli/credential-print.d.ts +6 -4
- package/dist/cli/credential-print.d.ts.map +1 -1
- package/dist/cli/credential-print.js +47 -34
- package/dist/cli/credential-print.js.map +1 -1
- package/dist/cli/file-processor.d.ts +1 -1
- package/dist/cli/file-processor.d.ts.map +1 -1
- package/dist/cli/file-processor.js +2 -1
- package/dist/cli/file-processor.js.map +1 -1
- package/dist/cli/list-models.d.ts +1 -1
- package/dist/cli/list-models.d.ts.map +1 -1
- package/dist/cli/list-models.js +2 -2
- package/dist/cli/list-models.js.map +1 -1
- package/dist/cli/session-picker.d.ts +1 -1
- package/dist/cli/session-picker.d.ts.map +1 -1
- package/dist/cli/session-picker.js.map +1 -1
- package/dist/cli/setup.d.ts +2 -0
- package/dist/cli/setup.d.ts.map +1 -0
- package/dist/cli/setup.js +12 -0
- package/dist/cli/setup.js.map +1 -0
- package/dist/cli/startup-ui.d.ts +2 -2
- package/dist/cli/startup-ui.d.ts.map +1 -1
- package/dist/cli/startup-ui.js +42 -33
- package/dist/cli/startup-ui.js.map +1 -1
- package/dist/cli.js +3 -12
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +29 -4
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +73 -10
- 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 +98 -32
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +2 -1
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +15 -0
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +266 -49
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +1503 -597
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts +25 -9
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +245 -45
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/bug-report-upload.d.ts +11 -0
- package/dist/core/bug-report-upload.d.ts.map +1 -0
- package/dist/core/bug-report-upload.js +20 -0
- package/dist/core/bug-report-upload.js.map +1 -0
- package/dist/core/bug-report.d.ts +176 -0
- package/dist/core/bug-report.d.ts.map +1 -0
- package/dist/core/bug-report.js +292 -0
- package/dist/core/bug-report.js.map +1 -0
- package/dist/core/builtins/checkpoints.d.ts +20 -0
- package/dist/core/builtins/checkpoints.d.ts.map +1 -0
- package/dist/core/builtins/checkpoints.js +161 -0
- package/dist/core/builtins/checkpoints.js.map +1 -0
- package/dist/core/builtins/duet.d.ts +26 -0
- package/dist/core/builtins/duet.d.ts.map +1 -0
- package/dist/core/builtins/duet.js +660 -0
- package/dist/core/builtins/duet.js.map +1 -0
- package/dist/core/builtins/index.d.ts.map +1 -1
- package/dist/core/builtins/index.js +7 -1
- package/dist/core/builtins/index.js.map +1 -1
- package/dist/core/builtins/subagent.d.ts +24 -4
- package/dist/core/builtins/subagent.d.ts.map +1 -1
- package/dist/core/builtins/subagent.js +278 -35
- package/dist/core/builtins/subagent.js.map +1 -1
- package/dist/core/cache-stats.d.ts.map +1 -1
- package/dist/core/cache-stats.js +12 -1
- package/dist/core/cache-stats.js.map +1 -1
- package/dist/core/cache-warmer.d.ts +103 -0
- package/dist/core/cache-warmer.d.ts.map +1 -0
- package/dist/core/cache-warmer.js +356 -0
- package/dist/core/cache-warmer.js.map +1 -0
- 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 +298 -0
- package/dist/core/checkpoints/checkpoint-manager.d.ts.map +1 -0
- package/dist/core/checkpoints/checkpoint-manager.js +901 -0
- package/dist/core/checkpoints/checkpoint-manager.js.map +1 -0
- package/dist/core/checkpoints/rewind.d.ts +143 -0
- package/dist/core/checkpoints/rewind.d.ts.map +1 -0
- package/dist/core/checkpoints/rewind.js +247 -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 +11 -6
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +14 -6
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +221 -122
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/compaction/utils.d.ts +2 -1
- package/dist/core/compaction/utils.d.ts.map +1 -1
- package/dist/core/compaction/utils.js +25 -18
- package/dist/core/compaction/utils.js.map +1 -1
- package/dist/core/crash-log.d.ts +27 -0
- package/dist/core/crash-log.d.ts.map +1 -0
- package/dist/core/crash-log.js +140 -0
- package/dist/core/crash-log.js.map +1 -0
- package/dist/core/defaults.d.ts +1 -0
- package/dist/core/defaults.d.ts.map +1 -1
- package/dist/core/defaults.js +9 -0
- package/dist/core/defaults.js.map +1 -1
- package/dist/core/experimental.js +1 -1
- package/dist/core/experimental.js.map +1 -1
- package/dist/core/export-html/template.css +10 -0
- package/dist/core/export-html/template.js +72 -18
- package/dist/core/extensions/index.d.ts +2 -2
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/jiti-loader.d.ts +2 -0
- package/dist/core/extensions/jiti-loader.d.ts.map +1 -0
- package/dist/core/extensions/jiti-loader.js +5 -0
- package/dist/core/extensions/jiti-loader.js.map +1 -0
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +298 -96
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +59 -9
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +410 -103
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +701 -85
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js +3 -0
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/extensions/virtual-modules.d.ts +3 -0
- package/dist/core/extensions/virtual-modules.d.ts.map +1 -0
- package/dist/core/extensions/virtual-modules.js +37 -0
- package/dist/core/extensions/virtual-modules.js.map +1 -0
- package/dist/core/extensions/wrapper.d.ts +2 -2
- package/dist/core/extensions/wrapper.d.ts.map +1 -1
- package/dist/core/extensions/wrapper.js +3 -22
- package/dist/core/extensions/wrapper.js.map +1 -1
- package/dist/core/footer-data-provider.d.ts +1 -1
- package/dist/core/footer-data-provider.js +19 -18
- package/dist/core/footer-data-provider.js.map +1 -1
- package/dist/core/http-dispatcher.d.ts.map +1 -1
- package/dist/core/http-dispatcher.js +7 -0
- package/dist/core/http-dispatcher.js.map +1 -1
- package/dist/core/index.d.ts +2 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/keybindings.d.ts +88 -13
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +34 -7
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/mcp-servers.d.ts +119 -0
- package/dist/core/mcp-servers.d.ts.map +1 -0
- package/dist/core/mcp-servers.js +191 -0
- package/dist/core/mcp-servers.js.map +1 -0
- package/dist/core/messages.d.ts +1 -1
- package/dist/core/messages.d.ts.map +1 -1
- package/dist/core/messages.js +1 -0
- package/dist/core/messages.js.map +1 -1
- package/dist/core/model-config.d.ts +202 -20
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +53 -18
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-registry.d.ts +21 -3
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +47 -10
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts +7 -5
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +62 -23
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-runtime.d.ts +80 -15
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +466 -120
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/models-store.d.ts +12 -7
- package/dist/core/models-store.d.ts.map +1 -1
- package/dist/core/models-store.js +87 -18
- package/dist/core/models-store.js.map +1 -1
- package/dist/core/multi-agent/fsm.js +8 -3
- package/dist/core/multi-agent/fsm.js.map +1 -1
- package/dist/core/multi-agent/mailbox.js +1 -3
- package/dist/core/multi-agent/mailbox.js.map +1 -1
- package/dist/core/multi-agent/permission-gate.d.ts +5 -2
- package/dist/core/multi-agent/permission-gate.d.ts.map +1 -1
- package/dist/core/multi-agent/permission-gate.js +601 -37
- package/dist/core/multi-agent/permission-gate.js.map +1 -1
- package/dist/core/multi-agent/task-board.js +2 -4
- package/dist/core/multi-agent/task-board.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 +3 -5
- package/dist/core/multi-agent/worktree.js.map +1 -1
- package/dist/core/nested-tool-calls.d.ts +102 -0
- package/dist/core/nested-tool-calls.d.ts.map +1 -0
- package/dist/core/nested-tool-calls.js +178 -0
- package/dist/core/nested-tool-calls.js.map +1 -0
- package/dist/core/package-manager.d.ts +16 -0
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +162 -69
- 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 +36 -0
- package/dist/core/pi-manifest.js.map +1 -0
- package/dist/core/project-trust.js +2 -2
- package/dist/core/project-trust.js.map +1 -1
- package/dist/core/prompt-templates.d.ts +6 -1
- package/dist/core/prompt-templates.d.ts.map +1 -1
- package/dist/core/prompt-templates.js +63 -37
- package/dist/core/prompt-templates.js.map +1 -1
- package/dist/core/provider-attribution.js +5 -5
- package/dist/core/provider-attribution.js.map +1 -1
- package/dist/core/provider-composer.d.ts +44 -20
- package/dist/core/provider-composer.d.ts.map +1 -1
- package/dist/core/provider-composer.js +151 -51
- package/dist/core/provider-composer.js.map +1 -1
- package/dist/core/radius.d.ts +13 -0
- package/dist/core/radius.d.ts.map +1 -1
- package/dist/core/radius.js +19 -0
- package/dist/core/radius.js.map +1 -1
- package/dist/core/remote-catalog-provider.d.ts +10 -3
- package/dist/core/remote-catalog-provider.d.ts.map +1 -1
- package/dist/core/remote-catalog-provider.js +105 -81
- package/dist/core/remote-catalog-provider.js.map +1 -1
- package/dist/core/resource-loader.d.ts +28 -1
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +319 -65
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/runtime-credentials.d.ts +5 -5
- package/dist/core/runtime-credentials.d.ts.map +1 -1
- package/dist/core/runtime-credentials.js +13 -9
- package/dist/core/runtime-credentials.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 +93 -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 +7 -5
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +103 -53
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-cwd.js +1 -0
- package/dist/core/session-cwd.js.map +1 -1
- package/dist/core/session-export.d.ts +8 -0
- package/dist/core/session-export.d.ts.map +1 -0
- package/dist/core/session-export.js +33 -0
- package/dist/core/session-export.js.map +1 -0
- package/dist/core/session-manager.d.ts +134 -15
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +366 -149
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-diagnostics.d.ts +9 -0
- package/dist/core/settings-diagnostics.d.ts.map +1 -0
- package/dist/core/settings-diagnostics.js +21 -0
- package/dist/core/settings-diagnostics.js.map +1 -0
- package/dist/core/settings-manager.d.ts +105 -4
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +274 -40
- 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 +70 -39
- package/dist/core/skills.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +4 -1
- 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 +666 -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 +786 -26
- package/dist/core/socket-server/socket-server.js.map +1 -1
- package/dist/core/socket-server/types.d.ts +108 -3
- 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/source-info.d.ts +8 -0
- package/dist/core/source-info.d.ts.map +1 -1
- package/dist/core/source-info.js +16 -0
- package/dist/core/source-info.js.map +1 -1
- package/dist/core/system-prompt.d.ts +49 -6
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +126 -90
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/bash.d.ts +32 -2
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +83 -141
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit-diff.d.ts +0 -5
- package/dist/core/tools/edit-diff.d.ts.map +1 -1
- package/dist/core/tools/edit-diff.js +2 -5
- package/dist/core/tools/edit-diff.js.map +1 -1
- package/dist/core/tools/edit.d.ts +5 -12
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +36 -173
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/find.d.ts +7 -0
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js +22 -76
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/grep.d.ts +4 -0
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js +10 -62
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/index.d.ts +4 -1
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +18 -1
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/ls.d.ts +4 -0
- package/dist/core/tools/ls.d.ts.map +1 -1
- package/dist/core/tools/ls.js +9 -50
- package/dist/core/tools/ls.js.map +1 -1
- package/dist/core/tools/output-accumulator.d.ts +11 -0
- package/dist/core/tools/output-accumulator.d.ts.map +1 -1
- package/dist/core/tools/output-accumulator.js +54 -12
- package/dist/core/tools/output-accumulator.js.map +1 -1
- package/dist/core/tools/powershell.d.ts +16 -0
- package/dist/core/tools/powershell.d.ts.map +1 -0
- package/dist/core/tools/powershell.js +39 -0
- package/dist/core/tools/powershell.js.map +1 -0
- package/dist/core/tools/read.d.ts +8 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +16 -123
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/render-utils.d.ts +6 -0
- package/dist/core/tools/render-utils.d.ts.map +1 -1
- package/dist/core/tools/render-utils.js +26 -0
- package/dist/core/tools/render-utils.js.map +1 -1
- package/dist/core/tools/renderers/bash.d.ts +12 -0
- package/dist/core/tools/renderers/bash.d.ts.map +1 -0
- package/dist/core/tools/renderers/bash.js +117 -0
- package/dist/core/tools/renderers/bash.js.map +1 -0
- package/dist/core/tools/renderers/edit.d.ts +23 -0
- package/dist/core/tools/renderers/edit.d.ts.map +1 -0
- package/dist/core/tools/renderers/edit.js +167 -0
- package/dist/core/tools/renderers/edit.js.map +1 -0
- package/dist/core/tools/renderers/find.d.ts +10 -0
- package/dist/core/tools/renderers/find.d.ts.map +1 -0
- package/dist/core/tools/renderers/find.js +64 -0
- package/dist/core/tools/renderers/find.js.map +1 -0
- package/dist/core/tools/renderers/grep.d.ts +10 -0
- package/dist/core/tools/renderers/grep.d.ts.map +1 -0
- package/dist/core/tools/renderers/grep.js +69 -0
- package/dist/core/tools/renderers/grep.js.map +1 -0
- package/dist/core/tools/renderers/index.d.ts +28 -0
- package/dist/core/tools/renderers/index.d.ts.map +1 -0
- package/dist/core/tools/renderers/index.js +47 -0
- package/dist/core/tools/renderers/index.js.map +1 -0
- package/dist/core/tools/renderers/ls.d.ts +10 -0
- package/dist/core/tools/renderers/ls.d.ts.map +1 -0
- package/dist/core/tools/renderers/ls.js +58 -0
- package/dist/core/tools/renderers/ls.js.map +1 -0
- package/dist/core/tools/renderers/read.d.ts +11 -0
- package/dist/core/tools/renderers/read.d.ts.map +1 -0
- package/dist/core/tools/renderers/read.js +130 -0
- package/dist/core/tools/renderers/read.js.map +1 -0
- package/dist/core/tools/renderers/write.d.ts +10 -0
- package/dist/core/tools/renderers/write.d.ts.map +1 -0
- package/dist/core/tools/renderers/write.js +153 -0
- package/dist/core/tools/renderers/write.js.map +1 -0
- package/dist/core/tools/tool-definition-wrapper.d.ts +5 -3
- package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.js +3 -1
- package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
- package/dist/core/tools/truncate.d.ts +14 -0
- package/dist/core/tools/truncate.d.ts.map +1 -1
- package/dist/core/tools/truncate.js +29 -0
- package/dist/core/tools/truncate.js.map +1 -1
- package/dist/core/tools/write.d.ts +4 -0
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +12 -147
- package/dist/core/tools/write.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 +59 -22
- package/dist/core/trust-manager.js.map +1 -1
- package/dist/core/usage-totals.d.ts +3 -1
- package/dist/core/usage-totals.d.ts.map +1 -1
- package/dist/core/usage-totals.js +28 -1
- package/dist/core/usage-totals.js.map +1 -1
- package/dist/core/virtual-models.d.ts +117 -0
- package/dist/core/virtual-models.d.ts.map +1 -0
- package/dist/core/virtual-models.js +124 -0
- package/dist/core/virtual-models.js.map +1 -0
- package/dist/experimental/micro/api.d.ts +81 -0
- package/dist/experimental/micro/api.d.ts.map +1 -0
- package/dist/experimental/micro/api.js +2 -0
- package/dist/experimental/micro/api.js.map +1 -0
- package/dist/experimental/micro/main.d.ts +3 -0
- package/dist/experimental/micro/main.d.ts.map +1 -0
- package/dist/experimental/micro/main.js +21 -0
- package/dist/experimental/micro/main.js.map +1 -0
- package/dist/experimental/micro/models.d.ts +11 -0
- package/dist/experimental/micro/models.d.ts.map +1 -0
- package/dist/experimental/micro/models.js +95 -0
- package/dist/experimental/micro/models.js.map +1 -0
- package/dist/experimental/micro/runtime.d.ts +12 -0
- package/dist/experimental/micro/runtime.d.ts.map +1 -0
- package/dist/experimental/micro/runtime.js +465 -0
- package/dist/experimental/micro/runtime.js.map +1 -0
- package/dist/experimental/micro/sessions.d.ts +10 -0
- package/dist/experimental/micro/sessions.d.ts.map +1 -0
- package/dist/experimental/micro/sessions.js +41 -0
- package/dist/experimental/micro/sessions.js.map +1 -0
- package/dist/experimental/micro/tools.d.ts +10 -0
- package/dist/experimental/micro/tools.d.ts.map +1 -0
- package/dist/experimental/micro/tools.js +96 -0
- package/dist/experimental/micro/tools.js.map +1 -0
- package/dist/experimental/micro/tui.d.ts +3 -0
- package/dist/experimental/micro/tui.d.ts.map +1 -0
- package/dist/experimental/micro/tui.js +510 -0
- package/dist/experimental/micro/tui.js.map +1 -0
- package/dist/experimental/mini/main.d.ts +7 -0
- package/dist/experimental/mini/main.d.ts.map +1 -0
- package/dist/experimental/mini/main.js +21 -0
- package/dist/experimental/mini/main.js.map +1 -0
- package/dist/experimental/mini/server/entry.d.ts +3 -0
- package/dist/experimental/mini/server/entry.d.ts.map +1 -0
- package/dist/experimental/mini/server/entry.js +11 -0
- package/dist/experimental/mini/server/entry.js.map +1 -0
- package/dist/experimental/mini/server/run.d.ts +13 -0
- package/dist/experimental/mini/server/run.d.ts.map +1 -0
- package/dist/experimental/mini/server/run.js +150 -0
- package/dist/experimental/mini/server/run.js.map +1 -0
- package/dist/experimental/mini/shared/protocol.d.ts +127 -0
- package/dist/experimental/mini/shared/protocol.d.ts.map +1 -0
- package/dist/experimental/mini/shared/protocol.js +13 -0
- package/dist/experimental/mini/shared/protocol.js.map +1 -0
- package/dist/experimental/mini/shared/rpc.d.ts +49 -0
- package/dist/experimental/mini/shared/rpc.d.ts.map +1 -0
- package/dist/experimental/mini/shared/rpc.js +171 -0
- package/dist/experimental/mini/shared/rpc.js.map +1 -0
- package/dist/experimental/mini/shared/transport.d.ts +35 -0
- package/dist/experimental/mini/shared/transport.d.ts.map +1 -0
- package/dist/experimental/mini/shared/transport.js +94 -0
- package/dist/experimental/mini/shared/transport.js.map +1 -0
- package/dist/experimental/mini/tui/run.d.ts +9 -0
- package/dist/experimental/mini/tui/run.d.ts.map +1 -0
- package/dist/experimental/mini/tui/run.js +62 -0
- package/dist/experimental/mini/tui/run.js.map +1 -0
- package/dist/experimental/mini/tui/session.d.ts +26 -0
- package/dist/experimental/mini/tui/session.d.ts.map +1 -0
- package/dist/experimental/mini/tui/session.js +94 -0
- package/dist/experimental/mini/tui/session.js.map +1 -0
- package/dist/experimental/mini/tui/view.d.ts +10 -0
- package/dist/experimental/mini/tui/view.d.ts.map +1 -0
- package/dist/experimental/mini/tui/view.js +461 -0
- package/dist/experimental/mini/tui/view.js.map +1 -0
- package/dist/experimental/mini/worker/entry.d.ts +3 -0
- package/dist/experimental/mini/worker/entry.d.ts.map +1 -0
- package/dist/experimental/mini/worker/entry.js +10 -0
- package/dist/experimental/mini/worker/entry.js.map +1 -0
- package/dist/experimental/mini/worker/lane-service.d.ts +44 -0
- package/dist/experimental/mini/worker/lane-service.d.ts.map +1 -0
- package/dist/experimental/mini/worker/lane-service.js +97 -0
- package/dist/experimental/mini/worker/lane-service.js.map +1 -0
- package/dist/experimental/mini/worker/models-service.d.ts +19 -0
- package/dist/experimental/mini/worker/models-service.d.ts.map +1 -0
- package/dist/experimental/mini/worker/models-service.js +136 -0
- package/dist/experimental/mini/worker/models-service.js.map +1 -0
- package/dist/experimental/mini/worker/run.d.ts +14 -0
- package/dist/experimental/mini/worker/run.d.ts.map +1 -0
- package/dist/experimental/mini/worker/run.js +88 -0
- package/dist/experimental/mini/worker/run.js.map +1 -0
- package/dist/extensions/codemode/execute.d.ts +16 -0
- package/dist/extensions/codemode/execute.d.ts.map +1 -0
- package/dist/extensions/codemode/execute.js +429 -0
- package/dist/extensions/codemode/execute.js.map +1 -0
- package/dist/extensions/codemode/execute.lazy.d.ts +3 -0
- package/dist/extensions/codemode/execute.lazy.d.ts.map +1 -0
- package/dist/extensions/codemode/execute.lazy.js +3 -0
- package/dist/extensions/codemode/execute.lazy.js.map +1 -0
- package/dist/extensions/codemode/index.d.ts +21 -0
- package/dist/extensions/codemode/index.d.ts.map +1 -0
- package/dist/extensions/codemode/index.js +31 -0
- package/dist/extensions/codemode/index.js.map +1 -0
- package/dist/extensions/codemode/renderer.d.ts +12 -0
- package/dist/extensions/codemode/renderer.d.ts.map +1 -0
- package/dist/extensions/codemode/renderer.js +137 -0
- package/dist/extensions/codemode/renderer.js.map +1 -0
- package/dist/extensions/codemode/tool.d.ts +123 -0
- package/dist/extensions/codemode/tool.d.ts.map +1 -0
- package/dist/extensions/codemode/tool.js +315 -0
- package/dist/extensions/codemode/tool.js.map +1 -0
- package/dist/extensions/codemode/worker.d.ts +7 -0
- package/dist/extensions/codemode/worker.d.ts.map +1 -0
- package/dist/extensions/codemode/worker.js +7 -0
- package/dist/extensions/codemode/worker.js.map +1 -0
- package/dist/extensions/index.d.ts.map +1 -1
- package/dist/extensions/index.js +13 -1
- package/dist/extensions/index.js.map +1 -1
- package/dist/extensions/llama/client.d.ts +8 -0
- package/dist/extensions/llama/client.d.ts.map +1 -1
- package/dist/extensions/llama/client.js +13 -0
- package/dist/extensions/llama/client.js.map +1 -1
- package/dist/extensions/llama/huggingface.js +2 -0
- package/dist/extensions/llama/huggingface.js.map +1 -1
- package/dist/extensions/llama/index.d.ts.map +1 -1
- package/dist/extensions/llama/index.js +13 -2
- package/dist/extensions/llama/index.js.map +1 -1
- package/dist/extensions/llama/provider.d.ts +4 -2
- package/dist/extensions/llama/provider.d.ts.map +1 -1
- package/dist/extensions/llama/provider.js +121 -15
- package/dist/extensions/llama/provider.js.map +1 -1
- package/dist/extensions/llama/ui.js +28 -12
- package/dist/extensions/llama/ui.js.map +1 -1
- package/dist/extensions/mcp/cli.d.ts +21 -0
- package/dist/extensions/mcp/cli.d.ts.map +1 -0
- package/dist/extensions/mcp/cli.js +500 -0
- package/dist/extensions/mcp/cli.js.map +1 -0
- package/dist/extensions/mcp/cli.lazy.d.ts +3 -0
- package/dist/extensions/mcp/cli.lazy.d.ts.map +1 -0
- package/dist/extensions/mcp/cli.lazy.js +3 -0
- package/dist/extensions/mcp/cli.lazy.js.map +1 -0
- package/dist/extensions/mcp/config.d.ts +72 -0
- package/dist/extensions/mcp/config.d.ts.map +1 -0
- package/dist/extensions/mcp/config.js +158 -0
- package/dist/extensions/mcp/config.js.map +1 -0
- package/dist/extensions/mcp/index.d.ts +76 -0
- package/dist/extensions/mcp/index.d.ts.map +1 -0
- package/dist/extensions/mcp/index.js +1055 -0
- package/dist/extensions/mcp/index.js.map +1 -0
- package/dist/extensions/mcp/log.d.ts +16 -0
- package/dist/extensions/mcp/log.d.ts.map +1 -0
- package/dist/extensions/mcp/log.js +66 -0
- package/dist/extensions/mcp/log.js.map +1 -0
- package/dist/extensions/mcp/oauth.d.ts +96 -0
- package/dist/extensions/mcp/oauth.d.ts.map +1 -0
- package/dist/extensions/mcp/oauth.js +333 -0
- package/dist/extensions/mcp/oauth.js.map +1 -0
- package/dist/extensions/mcp/resources.d.ts +43 -0
- package/dist/extensions/mcp/resources.d.ts.map +1 -0
- package/dist/extensions/mcp/resources.js +262 -0
- package/dist/extensions/mcp/resources.js.map +1 -0
- package/dist/extensions/mcp/runtime.d.ts +98 -0
- package/dist/extensions/mcp/runtime.d.ts.map +1 -0
- package/dist/extensions/mcp/runtime.js +394 -0
- package/dist/extensions/mcp/runtime.js.map +1 -0
- package/dist/extensions/mcp/runtime.lazy.d.ts +3 -0
- package/dist/extensions/mcp/runtime.lazy.d.ts.map +1 -0
- package/dist/extensions/mcp/runtime.lazy.js +3 -0
- package/dist/extensions/mcp/runtime.lazy.js.map +1 -0
- package/dist/extensions/mcp/tools.d.ts +84 -0
- package/dist/extensions/mcp/tools.d.ts.map +1 -0
- package/dist/extensions/mcp/tools.js +251 -0
- package/dist/extensions/mcp/tools.js.map +1 -0
- package/dist/extensions/mcp/ui.d.ts +60 -0
- package/dist/extensions/mcp/ui.d.ts.map +1 -0
- package/dist/extensions/mcp/ui.js +174 -0
- package/dist/extensions/mcp/ui.js.map +1 -0
- package/dist/extensions/stub-provider/index.d.ts +9 -0
- package/dist/extensions/stub-provider/index.d.ts.map +1 -0
- package/dist/extensions/stub-provider/index.js +13 -0
- package/dist/extensions/stub-provider/index.js.map +1 -0
- package/dist/extensions/stub-provider/provider.d.ts +77 -0
- package/dist/extensions/stub-provider/provider.d.ts.map +1 -0
- package/dist/extensions/stub-provider/provider.js +194 -0
- package/dist/extensions/stub-provider/provider.js.map +1 -0
- package/dist/extensions/tool-search/index.d.ts +12 -0
- package/dist/extensions/tool-search/index.d.ts.map +1 -0
- package/dist/extensions/tool-search/index.js +15 -0
- package/dist/extensions/tool-search/index.js.map +1 -0
- package/dist/extensions/tool-search/tool.d.ts +73 -0
- package/dist/extensions/tool-search/tool.d.ts.map +1 -0
- package/dist/extensions/tool-search/tool.js +189 -0
- package/dist/extensions/tool-search/tool.js.map +1 -0
- package/dist/hooks/gsd/draht-quality-gate.js +3 -3
- package/dist/index.d.ts +20 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -6
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts +4 -0
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +365 -96
- package/dist/main.js.map +1 -1
- package/dist/migrations.d.ts +1 -1
- package/dist/migrations.js +7 -6
- package/dist/migrations.js.map +1 -1
- package/dist/modes/index.d.ts +1 -0
- package/dist/modes/index.d.ts.map +1 -1
- package/dist/modes/index.js.map +1 -1
- package/dist/modes/interactive/bug-report.d.ts +19 -0
- package/dist/modes/interactive/bug-report.d.ts.map +1 -0
- package/dist/modes/interactive/bug-report.js +211 -0
- package/dist/modes/interactive/bug-report.js.map +1 -0
- package/dist/modes/interactive/chat-viewport.d.ts +20 -0
- package/dist/modes/interactive/chat-viewport.d.ts.map +1 -0
- package/dist/modes/interactive/chat-viewport.js +28 -0
- package/dist/modes/interactive/chat-viewport.js.map +1 -0
- package/dist/modes/interactive/components/armin.js +10 -6
- package/dist/modes/interactive/components/armin.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts +6 -2
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +38 -15
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/bash-execution.js +9 -4
- package/dist/modes/interactive/components/bash-execution.js.map +1 -1
- package/dist/modes/interactive/components/bordered-loader.js +3 -0
- package/dist/modes/interactive/components/bordered-loader.js.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts +1 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.js +15 -6
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.d.ts +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.js +15 -6
- package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/config-selector.js +38 -10
- package/dist/modes/interactive/components/config-selector.js.map +1 -1
- package/dist/modes/interactive/components/countdown-timer.js +5 -0
- package/dist/modes/interactive/components/countdown-timer.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts +10 -1
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js +54 -2
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/custom-entry.js +4 -1
- package/dist/modes/interactive/components/custom-entry.js.map +1 -1
- package/dist/modes/interactive/components/custom-message.js +7 -1
- package/dist/modes/interactive/components/custom-message.js.map +1 -1
- package/dist/modes/interactive/components/daxnuts.js +8 -6
- package/dist/modes/interactive/components/daxnuts.js.map +1 -1
- package/dist/modes/interactive/components/dynamic-border.js +1 -0
- package/dist/modes/interactive/components/dynamic-border.js.map +1 -1
- package/dist/modes/interactive/components/extension-editor.d.ts +4 -1
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-editor.js +14 -3
- package/dist/modes/interactive/components/extension-editor.js.map +1 -1
- package/dist/modes/interactive/components/extension-input.d.ts +2 -0
- package/dist/modes/interactive/components/extension-input.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-input.js +14 -2
- package/dist/modes/interactive/components/extension-input.js.map +1 -1
- package/dist/modes/interactive/components/extension-selector.d.ts +50 -0
- package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-selector.js +218 -6
- package/dist/modes/interactive/components/extension-selector.js.map +1 -1
- package/dist/modes/interactive/components/first-time-setup.d.ts +4 -4
- package/dist/modes/interactive/components/first-time-setup.d.ts.map +1 -1
- package/dist/modes/interactive/components/first-time-setup.js +12 -4
- package/dist/modes/interactive/components/first-time-setup.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts +7 -0
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +51 -6
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/index.d.ts +1 -1
- package/dist/modes/interactive/components/index.d.ts.map +1 -1
- package/dist/modes/interactive/components/index.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +9 -3
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/markdown-transform.d.ts +3 -0
- package/dist/modes/interactive/components/markdown-transform.d.ts.map +1 -0
- package/dist/modes/interactive/components/markdown-transform.js +19 -0
- package/dist/modes/interactive/components/markdown-transform.js.map +1 -0
- package/dist/modes/interactive/components/mermaid.d.ts +11 -0
- package/dist/modes/interactive/components/mermaid.d.ts.map +1 -0
- package/dist/modes/interactive/components/mermaid.js +75 -0
- package/dist/modes/interactive/components/mermaid.js.map +1 -0
- package/dist/modes/interactive/components/model-selector.d.ts +10 -4
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +101 -40
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.js +11 -3
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +4 -0
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js +60 -32
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts +5 -5
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +138 -80
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +25 -4
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +240 -67
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-submenu.d.ts +72 -0
- package/dist/modes/interactive/components/settings-submenu.d.ts.map +1 -0
- package/dist/modes/interactive/components/settings-submenu.js +165 -0
- package/dist/modes/interactive/components/settings-submenu.js.map +1 -0
- package/dist/modes/interactive/components/show-images-selector.js +1 -0
- package/dist/modes/interactive/components/show-images-selector.js.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.js +14 -5
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
- package/dist/modes/interactive/components/status-indicator.d.ts +3 -1
- package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -1
- package/dist/modes/interactive/components/status-indicator.js +12 -3
- package/dist/modes/interactive/components/status-indicator.js.map +1 -1
- package/dist/modes/interactive/components/theme-selector.js +2 -0
- package/dist/modes/interactive/components/theme-selector.js.map +1 -1
- package/dist/modes/interactive/components/themed-text.d.ts +17 -0
- package/dist/modes/interactive/components/themed-text.d.ts.map +1 -0
- package/dist/modes/interactive/components/themed-text.js +29 -0
- package/dist/modes/interactive/components/themed-text.js.map +1 -0
- package/dist/modes/interactive/components/thinking-selector.d.ts +15 -3
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.js +76 -18
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +21 -4
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +88 -53
- 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 +65 -23
- package/dist/modes/interactive/components/tree-selector.js.map +1 -1
- package/dist/modes/interactive/components/trust-selector.js +8 -2
- package/dist/modes/interactive/components/trust-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message-selector.js +6 -3
- package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message.d.ts +3 -1
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message.js +12 -2
- package/dist/modes/interactive/components/user-message.js.map +1 -1
- package/dist/modes/interactive/components/visual-truncate.d.ts +27 -3
- package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -1
- package/dist/modes/interactive/components/visual-truncate.js +39 -6
- package/dist/modes/interactive/components/visual-truncate.js.map +1 -1
- package/dist/modes/interactive/external-editor.d.ts.map +1 -1
- package/dist/modes/interactive/external-editor.js +2 -1
- package/dist/modes/interactive/external-editor.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +166 -8
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +1690 -599
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/model-catalog-refresh.d.ts +7 -0
- package/dist/modes/interactive/model-catalog-refresh.d.ts.map +1 -0
- package/dist/modes/interactive/model-catalog-refresh.js +34 -0
- package/dist/modes/interactive/model-catalog-refresh.js.map +1 -0
- package/dist/modes/interactive/session-share.d.ts +23 -0
- package/dist/modes/interactive/session-share.d.ts.map +1 -0
- package/dist/modes/interactive/session-share.js +130 -0
- package/dist/modes/interactive/session-share.js.map +1 -0
- package/dist/modes/interactive/theme/dark.json +54 -63
- package/dist/modes/interactive/theme/light.json +52 -60
- package/dist/modes/interactive/theme/system-theme.d.ts +54 -0
- package/dist/modes/interactive/theme/system-theme.d.ts.map +1 -0
- package/dist/modes/interactive/theme/system-theme.js +535 -0
- package/dist/modes/interactive/theme/system-theme.js.map +1 -0
- package/dist/modes/interactive/theme/theme-controller.d.ts +59 -7
- package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme-controller.js +164 -51
- package/dist/modes/interactive/theme/theme-controller.js.map +1 -1
- package/dist/modes/interactive/theme/theme-json.d.ts +85 -0
- package/dist/modes/interactive/theme/theme-json.d.ts.map +1 -0
- package/dist/modes/interactive/theme/theme-json.js +132 -0
- package/dist/modes/interactive/theme/theme-json.js.map +1 -0
- package/dist/modes/interactive/theme/theme-schema.json +24 -3
- package/dist/modes/interactive/theme/theme.d.ts +80 -42
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +274 -417
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/interactive/tui-renderer.d.ts +22 -0
- package/dist/modes/interactive/tui-renderer.d.ts.map +1 -0
- package/dist/modes/interactive/tui-renderer.js +67 -0
- package/dist/modes/interactive/tui-renderer.js.map +1 -0
- package/dist/modes/json-event.d.ts +34 -0
- package/dist/modes/json-event.d.ts.map +1 -0
- package/dist/modes/json-event.js +29 -0
- package/dist/modes/json-event.js.map +1 -0
- package/dist/modes/print-mode.d.ts +1 -1
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js +12 -2
- package/dist/modes/print-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +17 -9
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +27 -15
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +179 -19
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +90 -2
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/package-manager-cli.d.ts +1 -0
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +217 -63
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/prompts/commands/atomic-commit.md +1 -12
- package/dist/prompts/commands/brainstorm.md +12 -15
- package/dist/prompts/commands/create-verification-skill.md +108 -0
- package/dist/prompts/commands/discuss-phase.md +3 -14
- package/dist/prompts/commands/execute-phase.md +3 -11
- package/dist/prompts/commands/fix.md +41 -18
- package/dist/prompts/commands/grill.md +66 -0
- package/dist/prompts/commands/init-project.md +5 -15
- package/dist/prompts/commands/map-codebase.md +1 -13
- package/dist/prompts/commands/new-project.md +5 -15
- package/dist/prompts/commands/next-milestone.md +1 -13
- package/dist/prompts/commands/orchestrate.md +1 -1
- package/dist/prompts/commands/pause-work.md +1 -13
- package/dist/prompts/commands/plan-phase.md +3 -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 +6 -13
- package/dist/prompts/commands/triage.md +159 -0
- package/dist/prompts/commands/verify-work.md +5 -14
- package/dist/prompts/commands/why.md +139 -0
- package/dist/rpc-entry.js +1 -0
- package/dist/rpc-entry.js.map +1 -1
- package/dist/skills/atomic-reasoning/SKILL.md +115 -0
- package/dist/skills/blast-radius/SKILL.md +56 -0
- package/dist/skills/epistemics/SKILL.md +99 -0
- package/dist/skills/explainers/SKILL.md +65 -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 +119 -0
- package/dist/utils/abort.d.ts +5 -0
- package/dist/utils/abort.d.ts.map +1 -0
- package/dist/utils/abort.js +48 -0
- package/dist/utils/abort.js.map +1 -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/changelog.js +1 -1
- package/dist/utils/changelog.js.map +1 -1
- package/dist/utils/child-process.d.ts +13 -2
- package/dist/utils/child-process.d.ts.map +1 -1
- package/dist/utils/child-process.js +26 -9
- package/dist/utils/child-process.js.map +1 -1
- package/dist/utils/clipboard-command.d.ts +7 -0
- package/dist/utils/clipboard-command.d.ts.map +1 -0
- package/dist/utils/clipboard-command.js +45 -0
- package/dist/utils/clipboard-command.js.map +1 -0
- package/dist/utils/clipboard-image.d.ts.map +1 -1
- package/dist/utils/clipboard-image.js +60 -91
- package/dist/utils/clipboard-image.js.map +1 -1
- package/dist/utils/clipboard.d.ts +3 -1
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js +123 -108
- package/dist/utils/clipboard.js.map +1 -1
- package/dist/utils/draht-user-agent.d.ts +2 -0
- package/dist/utils/draht-user-agent.d.ts.map +1 -0
- package/dist/utils/draht-user-agent.js +5 -0
- package/dist/utils/draht-user-agent.js.map +1 -0
- package/dist/utils/exif-orientation.d.ts +2 -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/frontmatter.d.ts.map +1 -1
- package/dist/utils/frontmatter.js +2 -1
- package/dist/utils/frontmatter.js.map +1 -1
- package/dist/utils/management-http.d.ts +25 -0
- package/dist/utils/management-http.d.ts.map +1 -0
- package/dist/utils/management-http.js +54 -0
- package/dist/utils/management-http.js.map +1 -0
- package/dist/utils/mime.js +1 -1
- package/dist/utils/mime.js.map +1 -1
- package/dist/utils/paths.d.ts +6 -10
- package/dist/utils/paths.d.ts.map +1 -1
- package/dist/utils/paths.js +23 -14
- package/dist/utils/paths.js.map +1 -1
- package/dist/utils/photon.d.ts +2 -1
- package/dist/utils/photon.d.ts.map +1 -1
- package/dist/utils/photon.js.map +1 -1
- package/dist/utils/shell.d.ts +4 -3
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +26 -39
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/syntax-highlight.d.ts +1 -0
- package/dist/utils/syntax-highlight.d.ts.map +1 -1
- package/dist/utils/syntax-highlight.js +62 -1
- package/dist/utils/syntax-highlight.js.map +1 -1
- package/dist/utils/text.d.ts +8 -0
- package/dist/utils/text.d.ts.map +1 -0
- package/dist/utils/text.js +9 -0
- package/dist/utils/text.js.map +1 -0
- package/dist/utils/tool-result-images.d.ts +21 -0
- package/dist/utils/tool-result-images.d.ts.map +1 -0
- package/dist/utils/tool-result-images.js +48 -0
- package/dist/utils/tool-result-images.js.map +1 -0
- package/dist/utils/tools-manager.d.ts +11 -1
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +56 -41
- package/dist/utils/tools-manager.js.map +1 -1
- package/dist/utils/version-check.d.ts +4 -1
- package/dist/utils/version-check.d.ts.map +1 -1
- package/dist/utils/version-check.js +30 -9
- package/dist/utils/version-check.js.map +1 -1
- package/dist/utils/wsl.d.ts +3 -0
- package/dist/utils/wsl.d.ts.map +1 -0
- package/dist/utils/wsl.js +15 -0
- package/dist/utils/wsl.js.map +1 -0
- package/dist/utils/zip.d.ts +7 -0
- package/dist/utils/zip.d.ts.map +1 -0
- package/dist/utils/zip.js +60 -0
- package/dist/utils/zip.js.map +1 -0
- package/docs/attachable-sessions.md +79 -0
- package/docs/cli-integration.md +106 -0
- package/docs/cli.md +374 -0
- package/docs/compaction.md +107 -45
- package/docs/configuration.md +47 -0
- package/docs/containerization.md +100 -66
- package/docs/custom-provider.md +109 -707
- package/docs/docs.json +155 -95
- package/docs/duet.md +42 -0
- package/docs/environment-variables.md +30 -17
- package/docs/extensions.md +169 -2811
- package/docs/how-pi-works.md +53 -0
- package/docs/images/interactive-mode.png +0 -0
- package/docs/index.md +25 -69
- package/docs/json.md +198 -57
- package/docs/keybindings.md +89 -92
- package/docs/llama-cpp.md +23 -8
- package/docs/mcp.md +231 -0
- package/docs/message-types.md +261 -0
- package/docs/models.md +94 -478
- package/docs/packages.md +68 -164
- package/docs/prompt-templates.md +31 -68
- package/docs/providers.md +118 -215
- package/docs/quickstart.md +56 -109
- package/docs/rpc-commands.md +860 -0
- package/docs/rpc-extension-ui.md +200 -0
- package/docs/rpc.md +186 -1494
- package/docs/sdk.md +79 -1127
- package/docs/security.md +77 -33
- package/docs/session-format.md +98 -222
- package/docs/sessions.md +36 -113
- package/docs/settings.md +125 -251
- package/docs/shell-aliases.md +85 -5
- package/docs/skills.md +52 -188
- package/docs/slash-commands.md +61 -0
- package/docs/terminal-setup.md +132 -61
- package/docs/termux.md +74 -84
- package/docs/themes.md +91 -252
- package/docs/tmux.md +31 -39
- package/docs/tui.md +74 -891
- package/docs/usage.md +54 -255
- package/docs/virtual-models.md +114 -0
- package/docs/windows.md +57 -7
- package/examples/extensions/antigravity-image-gen.ts +9 -9
- package/examples/extensions/bash-spawn-hook.ts +1 -1
- package/examples/extensions/border-status-editor.ts +1 -1
- package/examples/extensions/built-in-tool-renderer.ts +16 -40
- package/examples/extensions/custom-compaction.ts +1 -16
- package/examples/extensions/custom-provider-anthropic/index.ts +20 -13
- package/examples/extensions/custom-provider-gitlab-duo/index.ts +4 -3
- package/examples/extensions/custom-provider-gitlab-duo/test.ts +5 -5
- package/examples/extensions/debug-provider.ts +90 -0
- package/examples/extensions/doom-overlay/wad-finder.ts +7 -3
- package/examples/extensions/dynamic-resources/dynamic.json +3 -1
- package/examples/extensions/git-checkpoint.ts +2 -2
- package/examples/extensions/handoff.ts +2 -11
- package/examples/extensions/jev-router.ts +113 -0
- package/examples/extensions/minimal-mode.ts +24 -96
- package/examples/extensions/notify.ts +3 -1
- package/examples/extensions/overlay-qa-tests.ts +3 -3
- package/examples/extensions/prompt-customizer.ts +19 -67
- package/examples/extensions/qna.ts +3 -7
- package/examples/extensions/subagent/agents.ts +40 -9
- package/examples/extensions/subagent/index.ts +27 -4
- package/examples/extensions/summarize.ts +7 -18
- package/examples/extensions/titlebar-spinner.ts +1 -1
- package/examples/rpc-client.ts +35 -0
- package/examples/rpc-extension-ui.ts +38 -9
- package/examples/sdk/02-custom-model.ts +1 -2
- package/examples/sdk/06-extensions.ts +1 -1
- package/examples/sdk/09-api-keys-and-oauth.ts +1 -1
- package/examples/sdk/12-full-control.ts +1 -1
- package/examples/sdk/14-codemode-mcp.ts +61 -0
- package/hooks/gsd/draht-quality-gate.js +3 -3
- package/package.json +28 -32
- 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 +3 -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 +6 -13
- package/prompts/commands/triage.md +159 -0
- package/prompts/commands/verify-work.md +5 -14
- package/prompts/commands/why.md +139 -0
- package/skills/atomic-reasoning/SKILL.md +115 -0
- package/skills/blast-radius/SKILL.md +56 -0
- package/skills/epistemics/SKILL.md +99 -0
- package/skills/explainers/SKILL.md +65 -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 +119 -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/dist/utils/clipboard-native.d.ts +0 -11
- package/dist/utils/clipboard-native.d.ts.map +0 -1
- package/dist/utils/clipboard-native.js +0 -20
- package/dist/utils/clipboard-native.js.map +0 -1
- package/dist/utils/pi-user-agent.d.ts +0 -2
- package/dist/utils/pi-user-agent.d.ts.map +0 -1
- package/dist/utils/pi-user-agent.js +0 -5
- package/dist/utils/pi-user-agent.js.map +0 -1
- package/docs/development.md +0 -71
- package/docs/tree.md +0 -231
- package/examples/extensions/kimi-deferred-tools.ts +0 -61
- package/prompts/agents/build.md +0 -86
- package/prompts/agents/plan.md +0 -79
- package/prompts/agents/verify.md +0 -69
|
@@ -0,0 +1,528 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* permission-relay — the session's implementation of the {@link PermissionRelay} port.
|
|
3
|
+
*
|
|
4
|
+
* This is the piece that makes an ask raised by the agent reach a phone, and an answer from that
|
|
5
|
+
* phone reach the agent. Everything it does is one of five things:
|
|
6
|
+
*
|
|
7
|
+
* raise build the frame, register it, fan it out, hand back a promise
|
|
8
|
+
* answer first VALID answer wins, exactly once, and everybody is told
|
|
9
|
+
* withdraw some other surface decided; the remote copies come down, saying WHAT it decided
|
|
10
|
+
* replay a client that arrived late is shown what is still unanswered
|
|
11
|
+
* expire nobody answered in time; fail closed, attributed to the system
|
|
12
|
+
*
|
|
13
|
+
* THE ORDER AFTER A WINNING ANSWER IS LOAD-BEARING, and it cost four adversarial rounds:
|
|
14
|
+
*
|
|
15
|
+
* settle → resolve the raise() promise → broadcast `permission_resolved` → append the JSONL record
|
|
16
|
+
*
|
|
17
|
+
* The decorator that owns the caller's promise aborts the LOSING surfaces as part of resolving, and
|
|
18
|
+
* it does so only after it has marked itself settled. Aborting before resolving is a real defect
|
|
19
|
+
* with a real transcript consequence: interactive mode honours an abort by resolving its selector
|
|
20
|
+
* to `undefined`, which its confirm wrapper maps to `false` — a FABRICATED local denial that would
|
|
21
|
+
* overwrite the remote approval that just won, and be recorded as a human's refusal.
|
|
22
|
+
*
|
|
23
|
+
* NOTHING HERE FABRICATES A DECISION. An answer's meaning is read off the offered option's own
|
|
24
|
+
* `decision`; an option nobody offered is silence and consumes nothing; an ask that expires or is
|
|
25
|
+
* cancelled is attributed to `system`, never to a surface that did not act. AND NOTHING HERE
|
|
26
|
+
* GUESSES ONE EITHER: `withdraw` is told what happened by the surface that settled the ask, because
|
|
27
|
+
* when it guessed `cancelled` it wrote that word over an approval whose command had already run.
|
|
28
|
+
*/
|
|
29
|
+
import { CANCELLED_BY_SYSTEM, } from "./permission-registry.js";
|
|
30
|
+
import { boundedSafeText } from "./safe-text.js";
|
|
31
|
+
/**
|
|
32
|
+
* How many refused-at-raise asks are remembered so their ending can still be recorded truthfully.
|
|
33
|
+
*
|
|
34
|
+
* An entry lives only until the decorator settles that ask and withdraws it, which it does for
|
|
35
|
+
* every ask it settles — so in practice the map holds the handful currently in flight. The cap is
|
|
36
|
+
* the backstop for the one path that settles WITHOUT withdrawing: a local surface whose promise
|
|
37
|
+
* REJECTS, which resolves the caller by rejection and never reaches `settle`.
|
|
38
|
+
*/
|
|
39
|
+
const MAX_UNRAISED = 64;
|
|
40
|
+
/**
|
|
41
|
+
* Grapheme budgets, one per wire field.
|
|
42
|
+
*
|
|
43
|
+
* Each is EXACTLY the bound `packages/geist-protocol/src/wire.ts` re-asserts for that field. They
|
|
44
|
+
* are not a second policy: the mirrored schema counts grapheme clusters, `boundedSafeText` bounds
|
|
45
|
+
* grapheme clusters AND UTF-8 bytes, and a frame constructed here therefore cannot be refused by
|
|
46
|
+
* the bridge for its length — a refusal there drops the renderer's connection with close 1008,
|
|
47
|
+
* which is the phone-killing failure the whole capability gate exists to prevent.
|
|
48
|
+
*/
|
|
49
|
+
const FIELD_BUDGET = {
|
|
50
|
+
toolName: 128,
|
|
51
|
+
cwd: 1024,
|
|
52
|
+
title: 200,
|
|
53
|
+
message: 4000,
|
|
54
|
+
command: 4000,
|
|
55
|
+
path: 1024,
|
|
56
|
+
operation: 128,
|
|
57
|
+
label: 200,
|
|
58
|
+
};
|
|
59
|
+
/** Hard cap on every plain-string id on the wire, in UTF-16 code units. */
|
|
60
|
+
const MAX_ID_LENGTH = 128;
|
|
61
|
+
/** Most options a `permission_request` may carry. */
|
|
62
|
+
const MAX_OPTIONS = 16;
|
|
63
|
+
/** Errors a client gets back when its answer is refused. Codes, so a renderer can switch on them. */
|
|
64
|
+
const ERROR_UNKNOWN_REQUEST = "PERMISSION_UNKNOWN_REQUEST";
|
|
65
|
+
const ERROR_INVALID_OPTION = "PERMISSION_INVALID_OPTION";
|
|
66
|
+
const ERROR_ALREADY_RESOLVED = "PERMISSION_ALREADY_RESOLVED";
|
|
67
|
+
export function createSocketPermissionRelay(options) {
|
|
68
|
+
const { registry, delivery, sessionId } = options;
|
|
69
|
+
const warn = options.onWarning ?? ((message) => console.error(message));
|
|
70
|
+
/**
|
|
71
|
+
* Asks this relay REFUSED to raise, kept until their real ending is known.
|
|
72
|
+
*
|
|
73
|
+
* A refusal is not a decision. `raise` hands back `undefined` for a bound it could not honour —
|
|
74
|
+
* `too_many_pending` at 33 concurrent asks, a frame too large, a socket already gone — and in a
|
|
75
|
+
* headless session with a phone attached that `undefined` became the decorator's fail-closed
|
|
76
|
+
* `false`, which the permission gate reports to the model as "User denied approval": a resource
|
|
77
|
+
* failure wearing a human's refusal. Nothing was written down, so the record could not
|
|
78
|
+
* contradict it either.
|
|
79
|
+
*
|
|
80
|
+
* Remembering the ask is what makes the two distinguishable AFTERWARDS, where it matters. The
|
|
81
|
+
* decorator withdraws every ask it settles, refused ones included, and it states what actually
|
|
82
|
+
* happened — so a bound that nobody could answer is recorded as `cancelled` by `system`, and a
|
|
83
|
+
* local human who answered the same ask anyway is recorded as having done exactly that.
|
|
84
|
+
*/
|
|
85
|
+
const unraised = new Map();
|
|
86
|
+
/**
|
|
87
|
+
* Remember a refused ask and tell the caller the relay is spent.
|
|
88
|
+
*
|
|
89
|
+
* `reason` is warned about when it is given, and withheld for the ROUTINE refusal — a socket
|
|
90
|
+
* that is already gone, which happens on every session replacement and stop. This module's
|
|
91
|
+
* warnings default to `console.error`, and a session running under a TUI that owns the terminal
|
|
92
|
+
* gets its screen corrupted by an expected teardown message.
|
|
93
|
+
*/
|
|
94
|
+
const refuse = (ask, reason) => {
|
|
95
|
+
if (reason !== undefined)
|
|
96
|
+
warn(`Permission ask not relayed: ${reason}`);
|
|
97
|
+
unraised.set(ask.requestId, ask);
|
|
98
|
+
while (unraised.size > MAX_UNRAISED) {
|
|
99
|
+
const oldest = unraised.keys().next();
|
|
100
|
+
if (oldest.done === true)
|
|
101
|
+
break;
|
|
102
|
+
unraised.delete(oldest.value);
|
|
103
|
+
}
|
|
104
|
+
return Promise.resolve(undefined);
|
|
105
|
+
};
|
|
106
|
+
const subjectOf = (entry) => ({
|
|
107
|
+
requestId: entry.requestId,
|
|
108
|
+
detail: entry.detail,
|
|
109
|
+
offeredOptionIds: entry.options.map((option) => option.id),
|
|
110
|
+
requestedAt: entry.requestedAt,
|
|
111
|
+
deadline: entry.frame.deadline,
|
|
112
|
+
});
|
|
113
|
+
const subjectOfAsk = (ask) => ({
|
|
114
|
+
requestId: ask.requestId,
|
|
115
|
+
detail: ask.detail,
|
|
116
|
+
offeredOptionIds: ask.options.map((option) => option.id),
|
|
117
|
+
requestedAt: ask.requestedAt,
|
|
118
|
+
deadline: ask.deadline,
|
|
119
|
+
});
|
|
120
|
+
/**
|
|
121
|
+
* Announce and record one terminal state.
|
|
122
|
+
*
|
|
123
|
+
* Called for every ending there is — approved, denied, cancelled, expired — because a record
|
|
124
|
+
* that only covers approvals is not an audit trail, it is a highlight reel.
|
|
125
|
+
*/
|
|
126
|
+
const finish = (entry, decision, chosenOptionId, decidedBy) => {
|
|
127
|
+
delivery.forgetRequest(entry.requestId);
|
|
128
|
+
const resolved = {
|
|
129
|
+
type: "permission_resolved",
|
|
130
|
+
requestId: entry.requestId,
|
|
131
|
+
decision,
|
|
132
|
+
chosenOptionId,
|
|
133
|
+
surface: decidedBy.surface,
|
|
134
|
+
clientId: decidedBy.clientId,
|
|
135
|
+
};
|
|
136
|
+
try {
|
|
137
|
+
options.server()?.broadcastPermissionResolved(resolved);
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
warn(`Permission relay could not announce a resolution: ${describe(error)}`);
|
|
141
|
+
}
|
|
142
|
+
appendResolution(subjectOf(entry), decision, chosenOptionId, decidedBy);
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* Record the ending of an ask that was never raised. NOTHING is announced.
|
|
146
|
+
*
|
|
147
|
+
* No surface was ever shown this ask, so there is no remote copy to take down and a
|
|
148
|
+
* `permission_resolved` naming it would be a resolution to a request no client has seen.
|
|
149
|
+
* Returns silently for any id that was not refused, which is the ordinary case — the decorator
|
|
150
|
+
* withdraws every ask it settles and almost all of them were raised normally.
|
|
151
|
+
*/
|
|
152
|
+
const finishUnraised = (requestId, decision, chosenOptionId, decidedBy) => {
|
|
153
|
+
const ask = unraised.get(requestId);
|
|
154
|
+
if (ask === undefined)
|
|
155
|
+
return;
|
|
156
|
+
unraised.delete(requestId);
|
|
157
|
+
appendResolution(subjectOfAsk(ask), decision, chosenOptionId, decidedBy);
|
|
158
|
+
};
|
|
159
|
+
/**
|
|
160
|
+
* Write the session's own record of how a TOOL permission ended.
|
|
161
|
+
*
|
|
162
|
+
* Scoped to tool permissions deliberately. `PermissionResolutionEntry` is a record ABOUT A TOOL
|
|
163
|
+
* CALL — it requires a `toolCallId`, a `toolName` and a cwd — and an extension's plain
|
|
164
|
+
* `confirm`/`select`/`input` has none of those. Synthesizing them so that every relayed dialog
|
|
165
|
+
* produced a row would put invented tool facts into the one artifact that is supposed to be
|
|
166
|
+
* evidence. The dialog is still relayed, still answerable and still echoed to every surface;
|
|
167
|
+
* it simply is not written down as a tool permission, because it is not one.
|
|
168
|
+
*/
|
|
169
|
+
const appendResolution = (subject, decision, chosenOptionId, decidedBy) => {
|
|
170
|
+
const detail = subject.detail;
|
|
171
|
+
if (detail === undefined || detail.kind !== "tool_permission")
|
|
172
|
+
return;
|
|
173
|
+
const recorder = options.recorder();
|
|
174
|
+
if (recorder === null)
|
|
175
|
+
return;
|
|
176
|
+
try {
|
|
177
|
+
recorder.appendPermissionResolution({
|
|
178
|
+
requestId: subject.requestId,
|
|
179
|
+
// The FULL id, not the wire's copy: the wire caps ids at 128 code units because a
|
|
180
|
+
// renderer's schema does, and this record's job is to name the tool call the
|
|
181
|
+
// transcript reports, which nothing here may abbreviate.
|
|
182
|
+
toolCallId: detail.toolCallId,
|
|
183
|
+
toolName: detail.toolName,
|
|
184
|
+
cwd: detail.cwd,
|
|
185
|
+
detail: { command: detail.command, path: detail.path, operation: detail.operation },
|
|
186
|
+
offeredOptionIds: [...subject.offeredOptionIds],
|
|
187
|
+
decision,
|
|
188
|
+
chosenOptionId,
|
|
189
|
+
decidedBy,
|
|
190
|
+
requestedAt: subject.requestedAt,
|
|
191
|
+
deadline: subject.deadline,
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
catch (error) {
|
|
195
|
+
// A session that cannot be written to must not take the answer down with it: the human
|
|
196
|
+
// decided, the agent has its answer, and losing the audit row is the lesser failure.
|
|
197
|
+
warn(`Permission relay could not record a resolution: ${describe(error)}`);
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
/**
|
|
201
|
+
* Tell the raiser its ask is OVER — not merely that this relay is spent.
|
|
202
|
+
*
|
|
203
|
+
* The difference is a fail-OPEN defect. `resolve(undefined)` means "the relay gave up", and a
|
|
204
|
+
* decorator with a live local surface correctly keeps waiting on it. For an EXPIRY that reading
|
|
205
|
+
* is catastrophic: the relay has already broadcast `expired` and appended the audit row, and the
|
|
206
|
+
* local dialog was still on screen — a human tapping Approve after that ran the command the
|
|
207
|
+
* durable record says was refused. {@link RelayEnded} is the value that takes the ask down
|
|
208
|
+
* everywhere, and the ending it carries is the one the registry already tombstoned.
|
|
209
|
+
*/
|
|
210
|
+
const endAsk = (entry, ending) => {
|
|
211
|
+
const ended = {
|
|
212
|
+
requestId: entry.requestId,
|
|
213
|
+
// The two words the wire can carry for an ask nobody answered. `approved`/`denied`
|
|
214
|
+
// cannot reach here: this path exists precisely because nobody decided.
|
|
215
|
+
ended: ending.decision === "expired" ? "expired" : "cancelled",
|
|
216
|
+
decidedBy: ending.decidedBy,
|
|
217
|
+
};
|
|
218
|
+
entry.resolve(ended);
|
|
219
|
+
};
|
|
220
|
+
registry.onExpired((entry, ending) => {
|
|
221
|
+
// Fail closed, attributed to nobody — and the ask comes down on EVERY surface, including
|
|
222
|
+
// the local one this relay cannot see. `ending` is the registry's own value, not a second
|
|
223
|
+
// literal saying the same thing; see PermissionEnding.
|
|
224
|
+
endAsk(entry, ending);
|
|
225
|
+
finish(entry, ending.decision, null, ending.decidedBy);
|
|
226
|
+
});
|
|
227
|
+
const relay = {
|
|
228
|
+
readWriteClientCount() {
|
|
229
|
+
// Live, never cached: clients attach and detach while a session is running, and this
|
|
230
|
+
// number is what `hasUI()` becomes for a headless session. Reporting a stale 1 here is
|
|
231
|
+
// how "no UI available to request approval" turns into a fabricated "User denied
|
|
232
|
+
// approval" in the transcript.
|
|
233
|
+
return options.server()?.permissionCapableClientCount ?? 0;
|
|
234
|
+
},
|
|
235
|
+
raise(ask) {
|
|
236
|
+
if (options.server() === null) {
|
|
237
|
+
// The socket this relay belonged to is gone — the session was replaced or stopped.
|
|
238
|
+
// Registering an ask nobody can be sent and nobody can answer would park the caller
|
|
239
|
+
// on it until the clock ran out; saying "spent" immediately lets the local surface,
|
|
240
|
+
// or the raising method's own fail-closed default, end it now.
|
|
241
|
+
return refuse(ask);
|
|
242
|
+
}
|
|
243
|
+
const built = buildRequestFrame(ask, options.cwd, registry.expiryMs);
|
|
244
|
+
if (built === undefined) {
|
|
245
|
+
// The ask cannot be represented on the wire without changing what is being offered.
|
|
246
|
+
// Offering a REPAIRED vocabulary would be worse than offering none: a surface
|
|
247
|
+
// showing only the options that happened to fit — an "Approve" with its "Deny"
|
|
248
|
+
// silently dropped — is a trap. Nothing is sent, so the local surface decides, or
|
|
249
|
+
// the raising method's own fail-closed default does.
|
|
250
|
+
return refuse(ask, "the ask cannot be represented on the wire without changing what is offered");
|
|
251
|
+
}
|
|
252
|
+
let resolveAsk;
|
|
253
|
+
const answered = new Promise((resolve) => {
|
|
254
|
+
resolveAsk = resolve;
|
|
255
|
+
});
|
|
256
|
+
// REGISTERED BEFORE THE FIRST WRITE. A client can answer before the fan-out loop has
|
|
257
|
+
// finished, and an answer naming an id the registry has never seen is refused as
|
|
258
|
+
// unknown — which would refuse the first correct answer to a real ask.
|
|
259
|
+
const inserted = registry.insert({
|
|
260
|
+
requestId: ask.requestId,
|
|
261
|
+
method: ask.method,
|
|
262
|
+
options: built.options,
|
|
263
|
+
detail: ask.detail,
|
|
264
|
+
frame: built.frame,
|
|
265
|
+
requestedAt: built.frame.requestedAt,
|
|
266
|
+
resolve: resolveAsk,
|
|
267
|
+
});
|
|
268
|
+
if (!inserted.ok) {
|
|
269
|
+
// A BOUND, not a decision. Remembered so the ending the decorator settles on is
|
|
270
|
+
// still written down and can be told apart from a human's refusal.
|
|
271
|
+
return refuse(ask, inserted.message);
|
|
272
|
+
}
|
|
273
|
+
try {
|
|
274
|
+
const reached = options.server()?.broadcastPermissionRequest(built.frame) ?? [];
|
|
275
|
+
for (const clientId of reached)
|
|
276
|
+
delivery.markDelivered(clientId, ask.requestId);
|
|
277
|
+
}
|
|
278
|
+
catch (error) {
|
|
279
|
+
// A write failure is not an answer. The ask stays pending: a client that reconnects
|
|
280
|
+
// is replayed it, and the registry's clock still ends it if nobody ever does.
|
|
281
|
+
warn(`Permission ask could not be broadcast: ${describe(error)}`);
|
|
282
|
+
}
|
|
283
|
+
return answered;
|
|
284
|
+
},
|
|
285
|
+
withdraw(requestId, decidedBy, outcome) {
|
|
286
|
+
// WHAT HAPPENED comes from the caller, which has just settled the ask and holds the
|
|
287
|
+
// value. This used to hardcode `cancelled`, and an approved bash call whose command had
|
|
288
|
+
// already run was written into the JSONL — and broadcast to the attached phone — as
|
|
289
|
+
// `{decision: "cancelled", chosenOptionId: null}`. Nothing here reconstructs an outcome.
|
|
290
|
+
const decision = terminalDecisionFor(outcome);
|
|
291
|
+
const chosenOptionId = outcome.kind === "approved" || outcome.kind === "denied" ? outcome.chosenOptionId : null;
|
|
292
|
+
// The decorator withdraws EVERY ask it settles, including the ones a remote answer just
|
|
293
|
+
// settled here. `withdraw` returns undefined for an ask that is already over, and that
|
|
294
|
+
// silence is what stops a second broadcast and a second audit row.
|
|
295
|
+
const entry = registry.withdraw(requestId, decidedBy, decision);
|
|
296
|
+
if (entry === undefined) {
|
|
297
|
+
// Either the ask is already over — the ordinary, silent case — or it was never
|
|
298
|
+
// raised because a bound refused it. Only the second writes anything.
|
|
299
|
+
finishUnraised(requestId, decision, chosenOptionId, decidedBy);
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
// The caller already has its answer from the surface that won; this only releases the
|
|
303
|
+
// arm this relay was holding.
|
|
304
|
+
entry.resolve(undefined);
|
|
305
|
+
finish(entry, decision, chosenOptionId, decidedBy);
|
|
306
|
+
},
|
|
307
|
+
handleResponse(message, clientId) {
|
|
308
|
+
const decidedBy = { surface: "attach", clientId };
|
|
309
|
+
const result = registry.settle(sessionId, message.requestId, message.optionId, decidedBy);
|
|
310
|
+
if (result.status === "refused") {
|
|
311
|
+
// The entry is untouched and still answerable — by this client, by another surface,
|
|
312
|
+
// or by nobody at all. Saying so beats silence: a phone must be able to tell
|
|
313
|
+
// "answered" from "this draht never asked".
|
|
314
|
+
options
|
|
315
|
+
.server()
|
|
316
|
+
?.sendErrorToClient(clientId, result.message, result.reason === "invalid_option" ? ERROR_INVALID_OPTION : ERROR_UNKNOWN_REQUEST);
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
if (result.status === "already_resolved") {
|
|
320
|
+
// A client that answered and then dropped its connection comes back to a definite
|
|
321
|
+
// account of what happened, rather than to a bare unknown-id refusal that reads
|
|
322
|
+
// exactly like a lost answer.
|
|
323
|
+
options.server()?.sendErrorToClient(clientId, result.message, ERROR_ALREADY_RESOLVED);
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
// settle → resolve → (the decorator aborts the losing surfaces) → broadcast → record.
|
|
327
|
+
result.entry.resolve(result.answer);
|
|
328
|
+
finish(result.entry, result.decision, result.chosenOptionId, decidedBy);
|
|
329
|
+
},
|
|
330
|
+
replayTo(clientId) {
|
|
331
|
+
const server = options.server();
|
|
332
|
+
if (server === null)
|
|
333
|
+
return;
|
|
334
|
+
for (const entry of delivery.pendingFor(clientId)) {
|
|
335
|
+
try {
|
|
336
|
+
// Targeted, not broadcast: every other client has already been shown this one.
|
|
337
|
+
// The server drops it silently if this client is read-only or never declared
|
|
338
|
+
// the capability, which is the correct outcome for both.
|
|
339
|
+
server.sendPermissionRequest(clientId, entry.frame);
|
|
340
|
+
delivery.markDelivered(clientId, entry.requestId);
|
|
341
|
+
}
|
|
342
|
+
catch (error) {
|
|
343
|
+
warn(`Permission ask could not be replayed to ${clientId}: ${describe(error)}`);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
},
|
|
347
|
+
forgetClient(clientId) {
|
|
348
|
+
delivery.forgetClient(clientId);
|
|
349
|
+
},
|
|
350
|
+
cancelAll() {
|
|
351
|
+
const ending = CANCELLED_BY_SYSTEM;
|
|
352
|
+
for (const entry of registry.cancelAll(ending.decidedBy)) {
|
|
353
|
+
// Same reasoning as expiry: the session is going away, so the ask is OVER and the
|
|
354
|
+
// local dialog must come down with it. A `undefined` here leaves a live Approve
|
|
355
|
+
// button on an ask this very loop has already recorded as cancelled.
|
|
356
|
+
endAsk(entry, ending);
|
|
357
|
+
finish(entry, ending.decision, null, ending.decidedBy);
|
|
358
|
+
}
|
|
359
|
+
delivery.clear();
|
|
360
|
+
// `unraised` is deliberately NOT cleared. Those asks were never broadcast, so there is
|
|
361
|
+
// nothing of theirs on any client to sweep — and they may still be parked on a LIVE
|
|
362
|
+
// local surface. The session's own recorder outlives this teardown (the bind hands over
|
|
363
|
+
// `session.sessionManager`, which does not go null), so a human who answers one of them
|
|
364
|
+
// a moment later still gets that answer written into the session it belongs to. The map
|
|
365
|
+
// is bounded and dies with this relay object.
|
|
366
|
+
},
|
|
367
|
+
};
|
|
368
|
+
return relay;
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* The wire's word for an outcome. All four map exactly — the gap is closed.
|
|
372
|
+
*
|
|
373
|
+
* GAP CLOSED (geist/0.4). `RelayOutcome` has always carried an honest `answered` kind; what was
|
|
374
|
+
* missing was a neutral member on the wire, so this function flattened `answered` onto `cancelled`.
|
|
375
|
+
* That understated: it said an ask came down UNANSWERED about an ask a human had answered and whose
|
|
376
|
+
* tool call had already RUN. The mirror-image falsehood lived in the registry's `decisionFor`,
|
|
377
|
+
* which said `approved` — a grant nobody made — for the remote half of the very same case.
|
|
378
|
+
*
|
|
379
|
+
* The containment argument that let both survive Phase 34 — "no audit row is written for a `select`
|
|
380
|
+
* or `input`, because `appendResolution` gates on a `tool_permission` detail and those never carry
|
|
381
|
+
* one" — IS FALSE. Nothing stops an extension attaching such a detail to a `select`, and a probe
|
|
382
|
+
* did; at that point the false word was written into the durable session JSONL, not merely
|
|
383
|
+
* broadcast. See ROADMAP.md, "Owner: whoever next opens the wire".
|
|
384
|
+
*
|
|
385
|
+
* `answered` now exists on `TerminalDecision` (`permission-registry.ts`), on
|
|
386
|
+
* `PermissionResolvedMessage.decision` (`socket-server/types.ts`), on
|
|
387
|
+
* `PermissionResolutionEntry.decision` (`core/session-manager.ts`) and on
|
|
388
|
+
* `PermissionResolvedFrameSchema.decision` (`packages/geist-protocol/src/wire.ts`, mirrored through
|
|
389
|
+
* `MIRRORED_FRAMES` and frozen in the `geist-0.4` conformance corpus).
|
|
390
|
+
*
|
|
391
|
+
* IT GRANTS NOTHING. It is neutral, not permissive: any consumer branching on this value must treat
|
|
392
|
+
* `answered` the way it treats `denied`, and only `approved` as permission. What was chosen travels
|
|
393
|
+
* as `chosenOptionId`.
|
|
394
|
+
*/
|
|
395
|
+
function terminalDecisionFor(outcome) {
|
|
396
|
+
switch (outcome.kind) {
|
|
397
|
+
case "approved":
|
|
398
|
+
return "approved";
|
|
399
|
+
case "denied":
|
|
400
|
+
return "denied";
|
|
401
|
+
case "answered":
|
|
402
|
+
return "answered";
|
|
403
|
+
case "cancelled":
|
|
404
|
+
return "cancelled";
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* Build the `permission_request` frame — the ONE place the wire text is constructed.
|
|
409
|
+
*
|
|
410
|
+
* Every free-text field goes through `boundedSafeText`, which neutralizes control, bidi and
|
|
411
|
+
* invisible code points ONE FOR ONE (never deleting: dropping a control character welds `rm -r` +
|
|
412
|
+
* `f /` into `rm -rf /`) and bounds the result in grapheme clusters AND UTF-8 bytes, preserving the
|
|
413
|
+
* decisive TAIL. `truncated` is the OR of every field's own verdict, so a surface can say that a
|
|
414
|
+
* decision is being made on an abbreviated string.
|
|
415
|
+
*
|
|
416
|
+
* THAT OR STARTS FROM THE PRODUCER'S VERDICT, NOT FROM `false`. The text arriving in `detail` was
|
|
417
|
+
* already neutralized-and-bounded at construction, at a budget EIGHT TIMES TIGHTER than the wire's
|
|
418
|
+
* (512 graphemes against `command`'s 4000) — so a 5000-character command reaches this function
|
|
419
|
+
* already ~530 characters long, every `bound` call below leaves it untouched, and an OR that began
|
|
420
|
+
* at `false` reported `truncated: false` about a string the human was shown 4,572 characters short
|
|
421
|
+
* of. Re-bounding here can only ever discover elisions THIS function performs; the producer's is
|
|
422
|
+
* unrecoverable from the value, so it is carried on the detail and read back below.
|
|
423
|
+
*
|
|
424
|
+
* Returns `undefined` when the ask cannot be carried WITHOUT CHANGING WHAT IS OFFERED — an option
|
|
425
|
+
* id the wire cannot hold, or more options than it can carry. Repairing that would mean offering a
|
|
426
|
+
* different vocabulary than the caller authorised.
|
|
427
|
+
*/
|
|
428
|
+
function buildRequestFrame(ask, sessionCwd, registryExpiryMs) {
|
|
429
|
+
if (!isWireId(ask.requestId))
|
|
430
|
+
return undefined;
|
|
431
|
+
if (ask.options.length > MAX_OPTIONS)
|
|
432
|
+
return undefined;
|
|
433
|
+
const detail = ask.detail !== undefined && ask.detail.kind === "tool_permission" ? ask.detail : undefined;
|
|
434
|
+
// Seeded, not initialised to `false`: see the note above. A detail that never elided says
|
|
435
|
+
// nothing, and a detail from a producer that does not carry the flag at all leaves this `false`
|
|
436
|
+
// exactly as before — so this is additive, never a source of a fabricated `true`.
|
|
437
|
+
let truncated = detail?.truncated === true;
|
|
438
|
+
const bound = (raw, budget) => {
|
|
439
|
+
const result = boundedSafeText(raw, budget);
|
|
440
|
+
truncated = truncated || result.truncated;
|
|
441
|
+
return result.value;
|
|
442
|
+
};
|
|
443
|
+
const options = [];
|
|
444
|
+
const wireOptions = [];
|
|
445
|
+
for (const option of ask.options) {
|
|
446
|
+
if (!isWireId(option.id))
|
|
447
|
+
return undefined;
|
|
448
|
+
options.push({ id: option.id, label: option.label, decision: option.decision });
|
|
449
|
+
// `decision` rides in `detail.options` and in the registry, not here: the socket wire's
|
|
450
|
+
// `PermissionOption` is `{id, label}` and the mirrored schema would strip anything else,
|
|
451
|
+
// so adding it would produce a field a renderer can never rely on.
|
|
452
|
+
wireOptions.push({ id: option.id, label: bound(option.label, FIELD_BUDGET.label) });
|
|
453
|
+
}
|
|
454
|
+
// An ask that gates no tool call still has to fill the frame's required identity fields. It is
|
|
455
|
+
// labelled for what it IS — a UI dialog raised by the session — rather than dressed up as a
|
|
456
|
+
// tool call that does not exist, and its id is its own request id so nothing joins it to a
|
|
457
|
+
// tool call in the transcript.
|
|
458
|
+
const toolCallId = clampId(detail?.toolCallId ?? ask.requestId);
|
|
459
|
+
if (toolCallId.clamped)
|
|
460
|
+
truncated = true;
|
|
461
|
+
const toolName = bound(detail?.toolName ?? `ui:${ask.method}`, FIELD_BUDGET.toolName);
|
|
462
|
+
const cwd = bound(detail?.cwd ?? sessionCwd, FIELD_BUDGET.cwd);
|
|
463
|
+
const frame = {
|
|
464
|
+
type: "permission_request",
|
|
465
|
+
requestId: ask.requestId,
|
|
466
|
+
method: ask.method,
|
|
467
|
+
toolCallId: toolCallId.value,
|
|
468
|
+
toolName,
|
|
469
|
+
cwd,
|
|
470
|
+
title: bound(ask.title, FIELD_BUDGET.title),
|
|
471
|
+
message: bound(ask.message ?? "", FIELD_BUDGET.message),
|
|
472
|
+
truncated: false,
|
|
473
|
+
options: wireOptions,
|
|
474
|
+
requestedAt: ask.requestedAt,
|
|
475
|
+
deadline: advisoryDeadline(ask.deadline, registryExpiryMs),
|
|
476
|
+
};
|
|
477
|
+
if (detail?.command !== undefined)
|
|
478
|
+
frame.command = bound(detail.command, FIELD_BUDGET.command);
|
|
479
|
+
if (detail?.path !== undefined)
|
|
480
|
+
frame.path = bound(detail.path, FIELD_BUDGET.path);
|
|
481
|
+
if (detail?.operation !== undefined)
|
|
482
|
+
frame.operation = bound(detail.operation, FIELD_BUDGET.operation);
|
|
483
|
+
// Set last: every `bound` call above contributes to it, on top of the producer's own verdict.
|
|
484
|
+
frame.truncated = truncated;
|
|
485
|
+
return { frame, options };
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* The instant a surface may draw a countdown to — ADVISORY, and enforced by nobody remote.
|
|
489
|
+
*
|
|
490
|
+
* The earlier of the two clocks that really exist: the registry's own fail-closed timer, which is
|
|
491
|
+
* armed for every ask, and the caller's declared timeout, which the decorator arms when it holds
|
|
492
|
+
* the only arm and which interactive mode counts down itself. Showing the earlier of them is the
|
|
493
|
+
* only honest countdown — showing the later one would tick past the moment the ask actually stopped
|
|
494
|
+
* being answerable.
|
|
495
|
+
*
|
|
496
|
+
* NOTHING MAY DENY AN ASK BECAUSE THIS INSTANT PASSED. A client-side auto-deny would be a second
|
|
497
|
+
* clock and a new denial path, and it would deny in the name of a human who simply had not looked
|
|
498
|
+
* at their phone yet. Real expiry binds solely to the registry.
|
|
499
|
+
*/
|
|
500
|
+
function advisoryDeadline(declared, registryExpiryMs) {
|
|
501
|
+
const registryDeadline = new Date(Date.now() + registryExpiryMs).toISOString();
|
|
502
|
+
if (declared === null)
|
|
503
|
+
return registryDeadline;
|
|
504
|
+
const declaredAt = Date.parse(declared);
|
|
505
|
+
if (!Number.isFinite(declaredAt))
|
|
506
|
+
return registryDeadline;
|
|
507
|
+
return declaredAt < Date.parse(registryDeadline) ? declared : registryDeadline;
|
|
508
|
+
}
|
|
509
|
+
/** Whether a plain (non-`safeText`) wire id fits its schema: non-empty, at most 128 code units. */
|
|
510
|
+
function isWireId(value) {
|
|
511
|
+
return value.length > 0 && value.length <= MAX_ID_LENGTH;
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* Fit an id the wire caps at 128 code units.
|
|
515
|
+
*
|
|
516
|
+
* Only ever applied to `toolCallId`, which is a JOIN KEY for rendering and not something a client
|
|
517
|
+
* echoes back; the audit record keeps the full value. An option id is never clamped — a clamped id
|
|
518
|
+
* would come back not matching the set it was offered from.
|
|
519
|
+
*/
|
|
520
|
+
function clampId(value) {
|
|
521
|
+
if (value.length <= MAX_ID_LENGTH)
|
|
522
|
+
return { value, clamped: false };
|
|
523
|
+
return { value: value.slice(0, MAX_ID_LENGTH), clamped: true };
|
|
524
|
+
}
|
|
525
|
+
function describe(error) {
|
|
526
|
+
return error instanceof Error ? error.message : String(error);
|
|
527
|
+
}
|
|
528
|
+
//# sourceMappingURL=permission-relay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permission-relay.js","sourceRoot":"","sources":["../../../src/core/socket-server/permission-relay.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAaH,OAAO,EACN,mBAAmB,GAMnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAuCjD;;;;;;;GAOG;AACH,MAAM,YAAY,GAAG,EAAE,CAAC;AAExB;;;;;;;;GAQG;AACH,MAAM,YAAY,GAAG;IACpB,QAAQ,EAAE,GAAG;IACb,GAAG,EAAE,IAAI;IACT,KAAK,EAAE,GAAG;IACV,OAAO,EAAE,IAAI;IACb,OAAO,EAAE,IAAI;IACb,IAAI,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OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,aAAa,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAChE,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC/B,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC/D,CAAC","sourcesContent":["/**\n * permission-relay — the session's implementation of the {@link PermissionRelay} port.\n *\n * This is the piece that makes an ask raised by the agent reach a phone, and an answer from that\n * phone reach the agent. Everything it does is one of five things:\n *\n * raise build the frame, register it, fan it out, hand back a promise\n * answer first VALID answer wins, exactly once, and everybody is told\n * withdraw some other surface decided; the remote copies come down, saying WHAT it decided\n * replay a client that arrived late is shown what is still unanswered\n * expire nobody answered in time; fail closed, attributed to the system\n *\n * THE ORDER AFTER A WINNING ANSWER IS LOAD-BEARING, and it cost four adversarial rounds:\n *\n * settle → resolve the raise() promise → broadcast `permission_resolved` → append the JSONL record\n *\n * The decorator that owns the caller's promise aborts the LOSING surfaces as part of resolving, and\n * it does so only after it has marked itself settled. Aborting before resolving is a real defect\n * with a real transcript consequence: interactive mode honours an abort by resolving its selector\n * to `undefined`, which its confirm wrapper maps to `false` — a FABRICATED local denial that would\n * overwrite the remote approval that just won, and be recorded as a human's refusal.\n *\n * NOTHING HERE FABRICATES A DECISION. An answer's meaning is read off the offered option's own\n * `decision`; an option nobody offered is silence and consumes nothing; an ask that expires or is\n * cancelled is attributed to `system`, never to a surface that did not act. AND NOTHING HERE\n * GUESSES ONE EITHER: `withdraw` is told what happened by the surface that settled the ask, because\n * when it guessed `cancelled` it wrote that word over an approval whose command had already run.\n */\n\nimport type { PermissionAskDetail } from \"../extensions/types.js\";\nimport type {\n\tPermissionRelay,\n\tRelayAnswer,\n\tRelayAsk,\n\tRelayDecider,\n\tRelayEnded,\n\tRelayOutcome,\n} from \"../permission-relay/types.js\";\nimport type { PermissionResolution } from \"../session-manager.js\";\nimport type { PermissionDelivery } from \"./permission-delivery.js\";\nimport {\n\tCANCELLED_BY_SYSTEM,\n\ttype PermissionEnding,\n\ttype PermissionEntry,\n\ttype PermissionRegistry,\n\ttype RegisteredOption,\n\ttype TerminalDecision,\n} from \"./permission-registry.js\";\nimport { boundedSafeText } from \"./safe-text.js\";\nimport type { PermissionOption, PermissionRequestMessage, PermissionResolvedMessage } from \"./types.js\";\n\n/**\n * The socket server, as this module uses it.\n *\n * Structural on purpose: `SocketServer` satisfies it without this module importing the class, so\n * the relay can be driven by a hand-written double in a unit test and there is no import cycle\n * between the server and the thing it hands answers to.\n */\nexport interface PermissionSocketServer {\n\treadonly permissionCapableClientCount: number;\n\tbroadcastPermissionRequest(message: PermissionRequestMessage): string[];\n\tsendPermissionRequest(clientId: string, message: PermissionRequestMessage): void;\n\tbroadcastPermissionResolved(message: PermissionResolvedMessage): void;\n\tsendErrorToClient(clientId: string, message: string, code?: string): void;\n}\n\n/** The session's own JSONL writer, as this module uses it. `SessionManager` satisfies it. */\nexport interface PermissionRecorder {\n\tappendPermissionResolution(resolution: PermissionResolution): string;\n}\n\n/**\n * What was asked, in exactly the terms an audit row needs.\n *\n * Two things can produce one: a still-pending {@link PermissionEntry}, and an ask this relay\n * REFUSED to raise at all (see {@link SocketPermissionRelayOptions} and `unraised` below). Both are\n * real endings of a real ask and both deserve a row, so the writer takes this rather than an entry.\n */\ninterface ResolutionSubject {\n\treadonly requestId: string;\n\treadonly detail: PermissionAskDetail | undefined;\n\t/** The offered set, in the order it was offered. Empty when nothing was ever offered. */\n\treadonly offeredOptionIds: readonly string[];\n\treadonly requestedAt: string;\n\treadonly deadline: string | null;\n}\n\n/**\n * How many refused-at-raise asks are remembered so their ending can still be recorded truthfully.\n *\n * An entry lives only until the decorator settles that ask and withdraws it, which it does for\n * every ask it settles — so in practice the map holds the handful currently in flight. The cap is\n * the backstop for the one path that settles WITHOUT withdrawing: a local surface whose promise\n * REJECTS, which resolves the caller by rejection and never reaches `settle`.\n */\nconst MAX_UNRAISED = 64;\n\n/**\n * Grapheme budgets, one per wire field.\n *\n * Each is EXACTLY the bound `packages/geist-protocol/src/wire.ts` re-asserts for that field. They\n * are not a second policy: the mirrored schema counts grapheme clusters, `boundedSafeText` bounds\n * grapheme clusters AND UTF-8 bytes, and a frame constructed here therefore cannot be refused by\n * the bridge for its length — a refusal there drops the renderer's connection with close 1008,\n * which is the phone-killing failure the whole capability gate exists to prevent.\n */\nconst FIELD_BUDGET = {\n\ttoolName: 128,\n\tcwd: 1024,\n\ttitle: 200,\n\tmessage: 4000,\n\tcommand: 4000,\n\tpath: 1024,\n\toperation: 128,\n\tlabel: 200,\n} as const;\n\n/** Hard cap on every plain-string id on the wire, in UTF-16 code units. */\nconst MAX_ID_LENGTH = 128;\n\n/** Most options a `permission_request` may carry. */\nconst MAX_OPTIONS = 16;\n\n/** Errors a client gets back when its answer is refused. Codes, so a renderer can switch on them. */\nconst ERROR_UNKNOWN_REQUEST = \"PERMISSION_UNKNOWN_REQUEST\";\nconst ERROR_INVALID_OPTION = \"PERMISSION_INVALID_OPTION\";\nconst ERROR_ALREADY_RESOLVED = \"PERMISSION_ALREADY_RESOLVED\";\n\nexport interface SocketPermissionRelayOptions {\n\tregistry: PermissionRegistry;\n\tdelivery: PermissionDelivery<PermissionEntry>;\n\t/** Read live: the server is replaced when the session is, and stopped before it is. */\n\tserver: () => PermissionSocketServer | null;\n\t/** Read live: the session's own JSONL writer, or null once the session is gone. */\n\trecorder: () => PermissionRecorder | null;\n\t/** The session id the registry is scoped to. */\n\tsessionId: string;\n\t/** The session's resolved working directory, for asks that carry no tool detail of their own. */\n\tcwd: string;\n\t/** Reports non-fatal problems. Defaults to stderr. */\n\tonWarning?: (message: string) => void;\n}\n\n/** The port, plus the four hooks the socket server drives it through. */\nexport interface SocketPermissionRelay extends PermissionRelay {\n\t/** A client answered. Validates, settles at most once, echoes, records. */\n\thandleResponse(message: { requestId: string; optionId: string }, clientId: string): void;\n\t/** A client attached: show it everything still unanswered, exactly once. */\n\treplayTo(clientId: string): void;\n\t/** A client's connection ended: drop its delivery record so a reconnect is shown everything. */\n\tforgetClient(clientId: string): void;\n\t/** The session is going away. Every pending ask ends fail-closed and is recorded as cancelled. */\n\tcancelAll(): void;\n}\n\nexport function createSocketPermissionRelay(options: SocketPermissionRelayOptions): SocketPermissionRelay {\n\tconst { registry, delivery, sessionId } = options;\n\tconst warn = options.onWarning ?? ((message: string) => console.error(message));\n\n\t/**\n\t * Asks this relay REFUSED to raise, kept until their real ending is known.\n\t *\n\t * A refusal is not a decision. `raise` hands back `undefined` for a bound it could not honour —\n\t * `too_many_pending` at 33 concurrent asks, a frame too large, a socket already gone — and in a\n\t * headless session with a phone attached that `undefined` became the decorator's fail-closed\n\t * `false`, which the permission gate reports to the model as \"User denied approval\": a resource\n\t * failure wearing a human's refusal. Nothing was written down, so the record could not\n\t * contradict it either.\n\t *\n\t * Remembering the ask is what makes the two distinguishable AFTERWARDS, where it matters. The\n\t * decorator withdraws every ask it settles, refused ones included, and it states what actually\n\t * happened — so a bound that nobody could answer is recorded as `cancelled` by `system`, and a\n\t * local human who answered the same ask anyway is recorded as having done exactly that.\n\t */\n\tconst unraised = new Map<string, RelayAsk>();\n\n\t/**\n\t * Remember a refused ask and tell the caller the relay is spent.\n\t *\n\t * `reason` is warned about when it is given, and withheld for the ROUTINE refusal — a socket\n\t * that is already gone, which happens on every session replacement and stop. This module's\n\t * warnings default to `console.error`, and a session running under a TUI that owns the terminal\n\t * gets its screen corrupted by an expected teardown message.\n\t */\n\tconst refuse = (ask: RelayAsk, reason?: string): Promise<undefined> => {\n\t\tif (reason !== undefined) warn(`Permission ask not relayed: ${reason}`);\n\t\tunraised.set(ask.requestId, ask);\n\t\twhile (unraised.size > MAX_UNRAISED) {\n\t\t\tconst oldest = unraised.keys().next();\n\t\t\tif (oldest.done === true) break;\n\t\t\tunraised.delete(oldest.value);\n\t\t}\n\t\treturn Promise.resolve(undefined);\n\t};\n\n\tconst subjectOf = (entry: PermissionEntry): ResolutionSubject => ({\n\t\trequestId: entry.requestId,\n\t\tdetail: entry.detail,\n\t\tofferedOptionIds: entry.options.map((option) => option.id),\n\t\trequestedAt: entry.requestedAt,\n\t\tdeadline: entry.frame.deadline,\n\t});\n\n\tconst subjectOfAsk = (ask: RelayAsk): ResolutionSubject => ({\n\t\trequestId: ask.requestId,\n\t\tdetail: ask.detail,\n\t\tofferedOptionIds: ask.options.map((option) => option.id),\n\t\trequestedAt: ask.requestedAt,\n\t\tdeadline: ask.deadline,\n\t});\n\n\t/**\n\t * Announce and record one terminal state.\n\t *\n\t * Called for every ending there is — approved, denied, cancelled, expired — because a record\n\t * that only covers approvals is not an audit trail, it is a highlight reel.\n\t */\n\tconst finish = (\n\t\tentry: PermissionEntry,\n\t\tdecision: TerminalDecision,\n\t\tchosenOptionId: string | null,\n\t\tdecidedBy: RelayDecider,\n\t): void => {\n\t\tdelivery.forgetRequest(entry.requestId);\n\t\tconst resolved: PermissionResolvedMessage = {\n\t\t\ttype: \"permission_resolved\",\n\t\t\trequestId: entry.requestId,\n\t\t\tdecision,\n\t\t\tchosenOptionId,\n\t\t\tsurface: decidedBy.surface,\n\t\t\tclientId: decidedBy.clientId,\n\t\t};\n\t\ttry {\n\t\t\toptions.server()?.broadcastPermissionResolved(resolved);\n\t\t} catch (error) {\n\t\t\twarn(`Permission relay could not announce a resolution: ${describe(error)}`);\n\t\t}\n\t\tappendResolution(subjectOf(entry), decision, chosenOptionId, decidedBy);\n\t};\n\n\t/**\n\t * Record the ending of an ask that was never raised. NOTHING is announced.\n\t *\n\t * No surface was ever shown this ask, so there is no remote copy to take down and a\n\t * `permission_resolved` naming it would be a resolution to a request no client has seen.\n\t * Returns silently for any id that was not refused, which is the ordinary case — the decorator\n\t * withdraws every ask it settles and almost all of them were raised normally.\n\t */\n\tconst finishUnraised = (\n\t\trequestId: string,\n\t\tdecision: TerminalDecision,\n\t\tchosenOptionId: string | null,\n\t\tdecidedBy: RelayDecider,\n\t): void => {\n\t\tconst ask = unraised.get(requestId);\n\t\tif (ask === undefined) return;\n\t\tunraised.delete(requestId);\n\t\tappendResolution(subjectOfAsk(ask), decision, chosenOptionId, decidedBy);\n\t};\n\n\t/**\n\t * Write the session's own record of how a TOOL permission ended.\n\t *\n\t * Scoped to tool permissions deliberately. `PermissionResolutionEntry` is a record ABOUT A TOOL\n\t * CALL — it requires a `toolCallId`, a `toolName` and a cwd — and an extension's plain\n\t * `confirm`/`select`/`input` has none of those. Synthesizing them so that every relayed dialog\n\t * produced a row would put invented tool facts into the one artifact that is supposed to be\n\t * evidence. The dialog is still relayed, still answerable and still echoed to every surface;\n\t * it simply is not written down as a tool permission, because it is not one.\n\t */\n\tconst appendResolution = (\n\t\tsubject: ResolutionSubject,\n\t\tdecision: TerminalDecision,\n\t\tchosenOptionId: string | null,\n\t\tdecidedBy: RelayDecider,\n\t): void => {\n\t\tconst detail = subject.detail;\n\t\tif (detail === undefined || detail.kind !== \"tool_permission\") return;\n\t\tconst recorder = options.recorder();\n\t\tif (recorder === null) return;\n\t\ttry {\n\t\t\trecorder.appendPermissionResolution({\n\t\t\t\trequestId: subject.requestId,\n\t\t\t\t// The FULL id, not the wire's copy: the wire caps ids at 128 code units because a\n\t\t\t\t// renderer's schema does, and this record's job is to name the tool call the\n\t\t\t\t// transcript reports, which nothing here may abbreviate.\n\t\t\t\ttoolCallId: detail.toolCallId,\n\t\t\t\ttoolName: detail.toolName,\n\t\t\t\tcwd: detail.cwd,\n\t\t\t\tdetail: { command: detail.command, path: detail.path, operation: detail.operation },\n\t\t\t\tofferedOptionIds: [...subject.offeredOptionIds],\n\t\t\t\tdecision,\n\t\t\t\tchosenOptionId,\n\t\t\t\tdecidedBy,\n\t\t\t\trequestedAt: subject.requestedAt,\n\t\t\t\tdeadline: subject.deadline,\n\t\t\t});\n\t\t} catch (error) {\n\t\t\t// A session that cannot be written to must not take the answer down with it: the human\n\t\t\t// decided, the agent has its answer, and losing the audit row is the lesser failure.\n\t\t\twarn(`Permission relay could not record a resolution: ${describe(error)}`);\n\t\t}\n\t};\n\n\t/**\n\t * Tell the raiser its ask is OVER — not merely that this relay is spent.\n\t *\n\t * The difference is a fail-OPEN defect. `resolve(undefined)` means \"the relay gave up\", and a\n\t * decorator with a live local surface correctly keeps waiting on it. For an EXPIRY that reading\n\t * is catastrophic: the relay has already broadcast `expired` and appended the audit row, and the\n\t * local dialog was still on screen — a human tapping Approve after that ran the command the\n\t * durable record says was refused. {@link RelayEnded} is the value that takes the ask down\n\t * everywhere, and the ending it carries is the one the registry already tombstoned.\n\t */\n\tconst endAsk = (entry: PermissionEntry, ending: PermissionEnding): void => {\n\t\tconst ended: RelayEnded = {\n\t\t\trequestId: entry.requestId,\n\t\t\t// The two words the wire can carry for an ask nobody answered. `approved`/`denied`\n\t\t\t// cannot reach here: this path exists precisely because nobody decided.\n\t\t\tended: ending.decision === \"expired\" ? \"expired\" : \"cancelled\",\n\t\t\tdecidedBy: ending.decidedBy,\n\t\t};\n\t\tentry.resolve(ended);\n\t};\n\n\tregistry.onExpired((entry, ending) => {\n\t\t// Fail closed, attributed to nobody — and the ask comes down on EVERY surface, including\n\t\t// the local one this relay cannot see. `ending` is the registry's own value, not a second\n\t\t// literal saying the same thing; see PermissionEnding.\n\t\tendAsk(entry, ending);\n\t\tfinish(entry, ending.decision, null, ending.decidedBy);\n\t});\n\n\tconst relay: SocketPermissionRelay = {\n\t\treadWriteClientCount(): number {\n\t\t\t// Live, never cached: clients attach and detach while a session is running, and this\n\t\t\t// number is what `hasUI()` becomes for a headless session. Reporting a stale 1 here is\n\t\t\t// how \"no UI available to request approval\" turns into a fabricated \"User denied\n\t\t\t// approval\" in the transcript.\n\t\t\treturn options.server()?.permissionCapableClientCount ?? 0;\n\t\t},\n\n\t\traise(ask: RelayAsk): Promise<RelayAnswer | RelayEnded | undefined> {\n\t\t\tif (options.server() === null) {\n\t\t\t\t// The socket this relay belonged to is gone — the session was replaced or stopped.\n\t\t\t\t// Registering an ask nobody can be sent and nobody can answer would park the caller\n\t\t\t\t// on it until the clock ran out; saying \"spent\" immediately lets the local surface,\n\t\t\t\t// or the raising method's own fail-closed default, end it now.\n\t\t\t\treturn refuse(ask);\n\t\t\t}\n\t\t\tconst built = buildRequestFrame(ask, options.cwd, registry.expiryMs);\n\t\t\tif (built === undefined) {\n\t\t\t\t// The ask cannot be represented on the wire without changing what is being offered.\n\t\t\t\t// Offering a REPAIRED vocabulary would be worse than offering none: a surface\n\t\t\t\t// showing only the options that happened to fit — an \"Approve\" with its \"Deny\"\n\t\t\t\t// silently dropped — is a trap. Nothing is sent, so the local surface decides, or\n\t\t\t\t// the raising method's own fail-closed default does.\n\t\t\t\treturn refuse(ask, \"the ask cannot be represented on the wire without changing what is offered\");\n\t\t\t}\n\n\t\t\tlet resolveAsk!: (answer: RelayAnswer | RelayEnded | undefined) => void;\n\t\t\tconst answered = new Promise<RelayAnswer | RelayEnded | undefined>((resolve) => {\n\t\t\t\tresolveAsk = resolve;\n\t\t\t});\n\n\t\t\t// REGISTERED BEFORE THE FIRST WRITE. A client can answer before the fan-out loop has\n\t\t\t// finished, and an answer naming an id the registry has never seen is refused as\n\t\t\t// unknown — which would refuse the first correct answer to a real ask.\n\t\t\tconst inserted = registry.insert({\n\t\t\t\trequestId: ask.requestId,\n\t\t\t\tmethod: ask.method,\n\t\t\t\toptions: built.options,\n\t\t\t\tdetail: ask.detail,\n\t\t\t\tframe: built.frame,\n\t\t\t\trequestedAt: built.frame.requestedAt,\n\t\t\t\tresolve: resolveAsk,\n\t\t\t});\n\t\t\tif (!inserted.ok) {\n\t\t\t\t// A BOUND, not a decision. Remembered so the ending the decorator settles on is\n\t\t\t\t// still written down and can be told apart from a human's refusal.\n\t\t\t\treturn refuse(ask, inserted.message);\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tconst reached = options.server()?.broadcastPermissionRequest(built.frame) ?? [];\n\t\t\t\tfor (const clientId of reached) delivery.markDelivered(clientId, ask.requestId);\n\t\t\t} catch (error) {\n\t\t\t\t// A write failure is not an answer. The ask stays pending: a client that reconnects\n\t\t\t\t// is replayed it, and the registry's clock still ends it if nobody ever does.\n\t\t\t\twarn(`Permission ask could not be broadcast: ${describe(error)}`);\n\t\t\t}\n\n\t\t\treturn answered;\n\t\t},\n\n\t\twithdraw(requestId: string, decidedBy: RelayDecider, outcome: RelayOutcome): void {\n\t\t\t// WHAT HAPPENED comes from the caller, which has just settled the ask and holds the\n\t\t\t// value. This used to hardcode `cancelled`, and an approved bash call whose command had\n\t\t\t// already run was written into the JSONL — and broadcast to the attached phone — as\n\t\t\t// `{decision: \"cancelled\", chosenOptionId: null}`. Nothing here reconstructs an outcome.\n\t\t\tconst decision = terminalDecisionFor(outcome);\n\t\t\tconst chosenOptionId =\n\t\t\t\toutcome.kind === \"approved\" || outcome.kind === \"denied\" ? outcome.chosenOptionId : null;\n\n\t\t\t// The decorator withdraws EVERY ask it settles, including the ones a remote answer just\n\t\t\t// settled here. `withdraw` returns undefined for an ask that is already over, and that\n\t\t\t// silence is what stops a second broadcast and a second audit row.\n\t\t\tconst entry = registry.withdraw(requestId, decidedBy, decision);\n\t\t\tif (entry === undefined) {\n\t\t\t\t// Either the ask is already over — the ordinary, silent case — or it was never\n\t\t\t\t// raised because a bound refused it. Only the second writes anything.\n\t\t\t\tfinishUnraised(requestId, decision, chosenOptionId, decidedBy);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// The caller already has its answer from the surface that won; this only releases the\n\t\t\t// arm this relay was holding.\n\t\t\tentry.resolve(undefined);\n\t\t\tfinish(entry, decision, chosenOptionId, decidedBy);\n\t\t},\n\n\t\thandleResponse(message: { requestId: string; optionId: string }, clientId: string): void {\n\t\t\tconst decidedBy: RelayDecider = { surface: \"attach\", clientId };\n\t\t\tconst result = registry.settle(sessionId, message.requestId, message.optionId, decidedBy);\n\n\t\t\tif (result.status === \"refused\") {\n\t\t\t\t// The entry is untouched and still answerable — by this client, by another surface,\n\t\t\t\t// or by nobody at all. Saying so beats silence: a phone must be able to tell\n\t\t\t\t// \"answered\" from \"this draht never asked\".\n\t\t\t\toptions\n\t\t\t\t\t.server()\n\t\t\t\t\t?.sendErrorToClient(\n\t\t\t\t\t\tclientId,\n\t\t\t\t\t\tresult.message,\n\t\t\t\t\t\tresult.reason === \"invalid_option\" ? ERROR_INVALID_OPTION : ERROR_UNKNOWN_REQUEST,\n\t\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (result.status === \"already_resolved\") {\n\t\t\t\t// A client that answered and then dropped its connection comes back to a definite\n\t\t\t\t// account of what happened, rather than to a bare unknown-id refusal that reads\n\t\t\t\t// exactly like a lost answer.\n\t\t\t\toptions.server()?.sendErrorToClient(clientId, result.message, ERROR_ALREADY_RESOLVED);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// settle → resolve → (the decorator aborts the losing surfaces) → broadcast → record.\n\t\t\tresult.entry.resolve(result.answer);\n\t\t\tfinish(result.entry, result.decision, result.chosenOptionId, decidedBy);\n\t\t},\n\n\t\treplayTo(clientId: string): void {\n\t\t\tconst server = options.server();\n\t\t\tif (server === null) return;\n\t\t\tfor (const entry of delivery.pendingFor(clientId)) {\n\t\t\t\ttry {\n\t\t\t\t\t// Targeted, not broadcast: every other client has already been shown this one.\n\t\t\t\t\t// The server drops it silently if this client is read-only or never declared\n\t\t\t\t\t// the capability, which is the correct outcome for both.\n\t\t\t\t\tserver.sendPermissionRequest(clientId, entry.frame);\n\t\t\t\t\tdelivery.markDelivered(clientId, entry.requestId);\n\t\t\t\t} catch (error) {\n\t\t\t\t\twarn(`Permission ask could not be replayed to ${clientId}: ${describe(error)}`);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\n\t\tforgetClient(clientId: string): void {\n\t\t\tdelivery.forgetClient(clientId);\n\t\t},\n\n\t\tcancelAll(): void {\n\t\t\tconst ending = CANCELLED_BY_SYSTEM;\n\t\t\tfor (const entry of registry.cancelAll(ending.decidedBy)) {\n\t\t\t\t// Same reasoning as expiry: the session is going away, so the ask is OVER and the\n\t\t\t\t// local dialog must come down with it. A `undefined` here leaves a live Approve\n\t\t\t\t// button on an ask this very loop has already recorded as cancelled.\n\t\t\t\tendAsk(entry, ending);\n\t\t\t\tfinish(entry, ending.decision, null, ending.decidedBy);\n\t\t\t}\n\t\t\tdelivery.clear();\n\t\t\t// `unraised` is deliberately NOT cleared. Those asks were never broadcast, so there is\n\t\t\t// nothing of theirs on any client to sweep — and they may still be parked on a LIVE\n\t\t\t// local surface. The session's own recorder outlives this teardown (the bind hands over\n\t\t\t// `session.sessionManager`, which does not go null), so a human who answers one of them\n\t\t\t// a moment later still gets that answer written into the session it belongs to. The map\n\t\t\t// is bounded and dies with this relay object.\n\t\t},\n\t};\n\n\treturn relay;\n}\n\n/**\n * The wire's word for an outcome. All four map exactly — the gap is closed.\n *\n * GAP CLOSED (geist/0.4). `RelayOutcome` has always carried an honest `answered` kind; what was\n * missing was a neutral member on the wire, so this function flattened `answered` onto `cancelled`.\n * That understated: it said an ask came down UNANSWERED about an ask a human had answered and whose\n * tool call had already RUN. The mirror-image falsehood lived in the registry's `decisionFor`,\n * which said `approved` — a grant nobody made — for the remote half of the very same case.\n *\n * The containment argument that let both survive Phase 34 — \"no audit row is written for a `select`\n * or `input`, because `appendResolution` gates on a `tool_permission` detail and those never carry\n * one\" — IS FALSE. Nothing stops an extension attaching such a detail to a `select`, and a probe\n * did; at that point the false word was written into the durable session JSONL, not merely\n * broadcast. See ROADMAP.md, \"Owner: whoever next opens the wire\".\n *\n * `answered` now exists on `TerminalDecision` (`permission-registry.ts`), on\n * `PermissionResolvedMessage.decision` (`socket-server/types.ts`), on\n * `PermissionResolutionEntry.decision` (`core/session-manager.ts`) and on\n * `PermissionResolvedFrameSchema.decision` (`packages/geist-protocol/src/wire.ts`, mirrored through\n * `MIRRORED_FRAMES` and frozen in the `geist-0.4` conformance corpus).\n *\n * IT GRANTS NOTHING. It is neutral, not permissive: any consumer branching on this value must treat\n * `answered` the way it treats `denied`, and only `approved` as permission. What was chosen travels\n * as `chosenOptionId`.\n */\nfunction terminalDecisionFor(outcome: RelayOutcome): TerminalDecision {\n\tswitch (outcome.kind) {\n\t\tcase \"approved\":\n\t\t\treturn \"approved\";\n\t\tcase \"denied\":\n\t\t\treturn \"denied\";\n\t\tcase \"answered\":\n\t\t\treturn \"answered\";\n\t\tcase \"cancelled\":\n\t\t\treturn \"cancelled\";\n\t}\n}\n\n/** What was put on the wire, and the offered set exactly as it was offered. */\ninterface BuiltRequest {\n\treadonly frame: PermissionRequestMessage;\n\treadonly options: readonly RegisteredOption[];\n}\n\n/**\n * Build the `permission_request` frame — the ONE place the wire text is constructed.\n *\n * Every free-text field goes through `boundedSafeText`, which neutralizes control, bidi and\n * invisible code points ONE FOR ONE (never deleting: dropping a control character welds `rm -r` +\n * `f /` into `rm -rf /`) and bounds the result in grapheme clusters AND UTF-8 bytes, preserving the\n * decisive TAIL. `truncated` is the OR of every field's own verdict, so a surface can say that a\n * decision is being made on an abbreviated string.\n *\n * THAT OR STARTS FROM THE PRODUCER'S VERDICT, NOT FROM `false`. The text arriving in `detail` was\n * already neutralized-and-bounded at construction, at a budget EIGHT TIMES TIGHTER than the wire's\n * (512 graphemes against `command`'s 4000) — so a 5000-character command reaches this function\n * already ~530 characters long, every `bound` call below leaves it untouched, and an OR that began\n * at `false` reported `truncated: false` about a string the human was shown 4,572 characters short\n * of. Re-bounding here can only ever discover elisions THIS function performs; the producer's is\n * unrecoverable from the value, so it is carried on the detail and read back below.\n *\n * Returns `undefined` when the ask cannot be carried WITHOUT CHANGING WHAT IS OFFERED — an option\n * id the wire cannot hold, or more options than it can carry. Repairing that would mean offering a\n * different vocabulary than the caller authorised.\n */\nfunction buildRequestFrame(ask: RelayAsk, sessionCwd: string, registryExpiryMs: number): BuiltRequest | undefined {\n\tif (!isWireId(ask.requestId)) return undefined;\n\tif (ask.options.length > MAX_OPTIONS) return undefined;\n\n\tconst detail: PermissionAskDetail | undefined =\n\t\task.detail !== undefined && ask.detail.kind === \"tool_permission\" ? ask.detail : undefined;\n\n\t// Seeded, not initialised to `false`: see the note above. A detail that never elided says\n\t// nothing, and a detail from a producer that does not carry the flag at all leaves this `false`\n\t// exactly as before — so this is additive, never a source of a fabricated `true`.\n\tlet truncated = detail?.truncated === true;\n\tconst bound = (raw: string, budget: number): string => {\n\t\tconst result = boundedSafeText(raw, budget);\n\t\ttruncated = truncated || result.truncated;\n\t\treturn result.value;\n\t};\n\n\tconst options: RegisteredOption[] = [];\n\tconst wireOptions: PermissionOption[] = [];\n\tfor (const option of ask.options) {\n\t\tif (!isWireId(option.id)) return undefined;\n\t\toptions.push({ id: option.id, label: option.label, decision: option.decision });\n\t\t// `decision` rides in `detail.options` and in the registry, not here: the socket wire's\n\t\t// `PermissionOption` is `{id, label}` and the mirrored schema would strip anything else,\n\t\t// so adding it would produce a field a renderer can never rely on.\n\t\twireOptions.push({ id: option.id, label: bound(option.label, FIELD_BUDGET.label) });\n\t}\n\n\t// An ask that gates no tool call still has to fill the frame's required identity fields. It is\n\t// labelled for what it IS — a UI dialog raised by the session — rather than dressed up as a\n\t// tool call that does not exist, and its id is its own request id so nothing joins it to a\n\t// tool call in the transcript.\n\tconst toolCallId = clampId(detail?.toolCallId ?? ask.requestId);\n\tif (toolCallId.clamped) truncated = true;\n\tconst toolName = bound(detail?.toolName ?? `ui:${ask.method}`, FIELD_BUDGET.toolName);\n\tconst cwd = bound(detail?.cwd ?? sessionCwd, FIELD_BUDGET.cwd);\n\n\tconst frame: PermissionRequestMessage = {\n\t\ttype: \"permission_request\",\n\t\trequestId: ask.requestId,\n\t\tmethod: ask.method,\n\t\ttoolCallId: toolCallId.value,\n\t\ttoolName,\n\t\tcwd,\n\t\ttitle: bound(ask.title, FIELD_BUDGET.title),\n\t\tmessage: bound(ask.message ?? \"\", FIELD_BUDGET.message),\n\t\ttruncated: false,\n\t\toptions: wireOptions,\n\t\trequestedAt: ask.requestedAt,\n\t\tdeadline: advisoryDeadline(ask.deadline, registryExpiryMs),\n\t};\n\tif (detail?.command !== undefined) frame.command = bound(detail.command, FIELD_BUDGET.command);\n\tif (detail?.path !== undefined) frame.path = bound(detail.path, FIELD_BUDGET.path);\n\tif (detail?.operation !== undefined) frame.operation = bound(detail.operation, FIELD_BUDGET.operation);\n\t// Set last: every `bound` call above contributes to it, on top of the producer's own verdict.\n\tframe.truncated = truncated;\n\n\treturn { frame, options };\n}\n\n/**\n * The instant a surface may draw a countdown to — ADVISORY, and enforced by nobody remote.\n *\n * The earlier of the two clocks that really exist: the registry's own fail-closed timer, which is\n * armed for every ask, and the caller's declared timeout, which the decorator arms when it holds\n * the only arm and which interactive mode counts down itself. Showing the earlier of them is the\n * only honest countdown — showing the later one would tick past the moment the ask actually stopped\n * being answerable.\n *\n * NOTHING MAY DENY AN ASK BECAUSE THIS INSTANT PASSED. A client-side auto-deny would be a second\n * clock and a new denial path, and it would deny in the name of a human who simply had not looked\n * at their phone yet. Real expiry binds solely to the registry.\n */\nfunction advisoryDeadline(declared: string | null, registryExpiryMs: number): string | null {\n\tconst registryDeadline = new Date(Date.now() + registryExpiryMs).toISOString();\n\tif (declared === null) return registryDeadline;\n\tconst declaredAt = Date.parse(declared);\n\tif (!Number.isFinite(declaredAt)) return registryDeadline;\n\treturn declaredAt < Date.parse(registryDeadline) ? declared : registryDeadline;\n}\n\n/** Whether a plain (non-`safeText`) wire id fits its schema: non-empty, at most 128 code units. */\nfunction isWireId(value: string): boolean {\n\treturn value.length > 0 && value.length <= MAX_ID_LENGTH;\n}\n\n/**\n * Fit an id the wire caps at 128 code units.\n *\n * Only ever applied to `toolCallId`, which is a JOIN KEY for rendering and not something a client\n * echoes back; the audit record keeps the full value. An option id is never clamped — a clamped id\n * would come back not matching the set it was offered from.\n */\nfunction clampId(value: string): { value: string; clamped: boolean } {\n\tif (value.length <= MAX_ID_LENGTH) return { value, clamped: false };\n\treturn { value: value.slice(0, MAX_ID_LENGTH), clamped: true };\n}\n\nfunction describe(error: unknown): string {\n\treturn error instanceof Error ? error.message : String(error);\n}\n"]}
|