@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,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* safe-text — neutralize-and-bound for attacker-influenced text placed on the attach wire.
|
|
3
|
+
*
|
|
4
|
+
* A permission ask carries strings the model (and therefore an attacker) influenced: a shell
|
|
5
|
+
* command, a file path, a URL. Four properties are load-bearing before such a string may be
|
|
6
|
+
* rendered by a surface we do not control:
|
|
7
|
+
*
|
|
8
|
+
* 1. NEVER DELETE. Dropping a control character silently welds `rm -r` + `f /` into `rm -rf /`,
|
|
9
|
+
* so the displayed string stops matching the executed one with no evidence left behind. Every
|
|
10
|
+
* offending code point is therefore replaced by EXACTLY ONE visible marker code point.
|
|
11
|
+
* 2. KEEP THE TAIL. The decision-relevant part of `curl … | sh # AND THEN rm -rf ~/.ssh` is its
|
|
12
|
+
* end, so bounding elides the MIDDLE and preserves the tail, never the head.
|
|
13
|
+
* 3. PRICE THE SPOOF. Bidi overrides cost zero display width, so a width budget cannot bound them;
|
|
14
|
+
* they are neutralized outright, and the elided grapheme count travels with the text.
|
|
15
|
+
* 4. BOUND BOTH UNITS. A grapheme budget alone bounds nothing on the wire: ONE cluster admits
|
|
16
|
+
* unboundedly many combining marks, so 512 clusters of Zalgo encoded to 383,246 bytes — a frame
|
|
17
|
+
* the schema accepted and the attach bridge then refused, killing the renderer's connection with
|
|
18
|
+
* close 1008. Graphemes AND bytes are therefore bounded here, at CONSTRUCTION, whichever binds
|
|
19
|
+
* first. Downstream byte caps are backstops, not the bound.
|
|
20
|
+
*
|
|
21
|
+
* This module is deliberately pure and dependency-light: no I/O, no imports from socket-server
|
|
22
|
+
* siblings, no @draht/* imports. It is the single place where the wire text is CONSTRUCTED safe;
|
|
23
|
+
* the protocol layer only re-asserts the predicate.
|
|
24
|
+
*/
|
|
25
|
+
/** Neutralized, length-bounded text plus the evidence needed to trust the bound. */
|
|
26
|
+
export interface BoundedText {
|
|
27
|
+
/** The neutralized (and possibly middle-elided) text. Safe to render verbatim. */
|
|
28
|
+
value: string;
|
|
29
|
+
/** True when `value` had to be elided to fit EITHER budget — graphemes or bytes. */
|
|
30
|
+
truncated: boolean;
|
|
31
|
+
/** Grapheme count of the NEUTRALIZED text — never of the raw input. */
|
|
32
|
+
originalLength: number;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Inclusive code point ranges that are replaced one-for-one by a visible marker.
|
|
36
|
+
*
|
|
37
|
+
* C0 (the first range) becomes its Control Pictures glyph, `U+2400 + cp`; every other range becomes
|
|
38
|
+
* U+FFFD. Nothing here is ever deleted, so the neutralized string has the same code point count as
|
|
39
|
+
* its input.
|
|
40
|
+
*
|
|
41
|
+
* A LATER TASK HAND-MIRRORS THIS TABLE inside `packages/geist-protocol` as a zod `.refine()`
|
|
42
|
+
* predicate — that package must keep zero @draht dependencies, so it cannot import this constant.
|
|
43
|
+
* Any edit here has to be repeated there by hand, and the two must stay byte-for-byte equivalent.
|
|
44
|
+
*
|
|
45
|
+
* Sorted ascending by range start; `isForbiddenCodePoint` relies on that for its early exit.
|
|
46
|
+
*/
|
|
47
|
+
export declare const NEUTRALIZED_FORBIDDEN_RANGES: readonly (readonly [number, number])[];
|
|
48
|
+
/**
|
|
49
|
+
* The byte ceiling that applies when a caller names only a grapheme budget — which is every caller
|
|
50
|
+
* that has no reason to think about bytes, and therefore the reason this is a DEFAULT and not an
|
|
51
|
+
* option: a caller who forgets it still gets a bounded string.
|
|
52
|
+
*/
|
|
53
|
+
export declare function defaultMaxBytes(maxGraphemes: number): number;
|
|
54
|
+
/**
|
|
55
|
+
* True when `value` carries no code point from {@link NEUTRALIZED_FORBIDDEN_RANGES} — i.e. when it
|
|
56
|
+
* is safe to hand to a renderer verbatim. Every `BoundedText.value` satisfies this.
|
|
57
|
+
*/
|
|
58
|
+
export declare function isNeutralized(value: string): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Neutralize `raw` one-for-one, then bound it to `maxGraphemes` grapheme clusters AND `maxBytes`
|
|
61
|
+
* UTF-8 bytes — whichever binds first — with a MIDDLE elision that guarantees the decisive tail
|
|
62
|
+
* survives.
|
|
63
|
+
*
|
|
64
|
+
* BOTH UNITS, because either alone is a hole. A byte budget alone would refuse legitimate text a
|
|
65
|
+
* renderer can display in one line (a CJK cluster is three bytes, an astral emoji four); a grapheme
|
|
66
|
+
* budget alone bounds nothing at all, because one cluster may carry unboundedly many combining
|
|
67
|
+
* marks — that is the 383 KB "512-cluster" frame that got a phone disconnected with close 1008.
|
|
68
|
+
* `maxBytes` defaults to {@link defaultMaxBytes}, so a caller that never thought about bytes still
|
|
69
|
+
* gets a string bounded in them.
|
|
70
|
+
*
|
|
71
|
+
* The elision marker is `…[<k> chars elided]…`, where `k` is the number of elided graphemes — a bare
|
|
72
|
+
* `…` cannot distinguish three elided characters from four thousand characters of padding. Of what
|
|
73
|
+
* each budget has left after the marker, two thirds (rounded up) go to the tail and the remainder to
|
|
74
|
+
* the head. When a budget is too small to hold the marker at all, the tail alone is kept.
|
|
75
|
+
*
|
|
76
|
+
* The marker's own width is reserved at the widest it could be — the digit count of the TOTAL, which
|
|
77
|
+
* is an upper bound on the digit count of the elided count. Reserving the worst case rather than
|
|
78
|
+
* solving the marker's self-reference is what keeps the result provably inside both budgets now that
|
|
79
|
+
* `kept` depends on byte widths the marker cannot see; the cost is at most one unused character in
|
|
80
|
+
* the rare case where the elided count has fewer digits than the total.
|
|
81
|
+
*/
|
|
82
|
+
export declare function boundedSafeText(raw: string, maxGraphemes: number, maxBytes?: number): BoundedText;
|
|
83
|
+
//# sourceMappingURL=safe-text.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"safe-text.d.ts","sourceRoot":"","sources":["../../../src/core/socket-server/safe-text.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,oFAAoF;AACpF,MAAM,WAAW,WAAW;IAC3B,kFAAkF;IAClF,KAAK,EAAE,MAAM,CAAC;IACd,oFAAoF;IACpF,SAAS,EAAE,OAAO,CAAC;IACnB,uEAAuE;IACvE,cAAc,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,4BAA4B,EAAE,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAe9E,CAAC;AA6EF;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAE5D;AAwBD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAKpD;AAoED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,eAAe,CAC9B,GAAG,EAAE,MAAM,EACX,YAAY,EAAE,MAAM,EACpB,QAAQ,SAAgC,GACtC,WAAW,CAuCb"}
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* safe-text — neutralize-and-bound for attacker-influenced text placed on the attach wire.
|
|
3
|
+
*
|
|
4
|
+
* A permission ask carries strings the model (and therefore an attacker) influenced: a shell
|
|
5
|
+
* command, a file path, a URL. Four properties are load-bearing before such a string may be
|
|
6
|
+
* rendered by a surface we do not control:
|
|
7
|
+
*
|
|
8
|
+
* 1. NEVER DELETE. Dropping a control character silently welds `rm -r` + `f /` into `rm -rf /`,
|
|
9
|
+
* so the displayed string stops matching the executed one with no evidence left behind. Every
|
|
10
|
+
* offending code point is therefore replaced by EXACTLY ONE visible marker code point.
|
|
11
|
+
* 2. KEEP THE TAIL. The decision-relevant part of `curl … | sh # AND THEN rm -rf ~/.ssh` is its
|
|
12
|
+
* end, so bounding elides the MIDDLE and preserves the tail, never the head.
|
|
13
|
+
* 3. PRICE THE SPOOF. Bidi overrides cost zero display width, so a width budget cannot bound them;
|
|
14
|
+
* they are neutralized outright, and the elided grapheme count travels with the text.
|
|
15
|
+
* 4. BOUND BOTH UNITS. A grapheme budget alone bounds nothing on the wire: ONE cluster admits
|
|
16
|
+
* unboundedly many combining marks, so 512 clusters of Zalgo encoded to 383,246 bytes — a frame
|
|
17
|
+
* the schema accepted and the attach bridge then refused, killing the renderer's connection with
|
|
18
|
+
* close 1008. Graphemes AND bytes are therefore bounded here, at CONSTRUCTION, whichever binds
|
|
19
|
+
* first. Downstream byte caps are backstops, not the bound.
|
|
20
|
+
*
|
|
21
|
+
* This module is deliberately pure and dependency-light: no I/O, no imports from socket-server
|
|
22
|
+
* siblings, no @draht/* imports. It is the single place where the wire text is CONSTRUCTED safe;
|
|
23
|
+
* the protocol layer only re-asserts the predicate.
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* Inclusive code point ranges that are replaced one-for-one by a visible marker.
|
|
27
|
+
*
|
|
28
|
+
* C0 (the first range) becomes its Control Pictures glyph, `U+2400 + cp`; every other range becomes
|
|
29
|
+
* U+FFFD. Nothing here is ever deleted, so the neutralized string has the same code point count as
|
|
30
|
+
* its input.
|
|
31
|
+
*
|
|
32
|
+
* A LATER TASK HAND-MIRRORS THIS TABLE inside `packages/geist-protocol` as a zod `.refine()`
|
|
33
|
+
* predicate — that package must keep zero @draht dependencies, so it cannot import this constant.
|
|
34
|
+
* Any edit here has to be repeated there by hand, and the two must stay byte-for-byte equivalent.
|
|
35
|
+
*
|
|
36
|
+
* Sorted ascending by range start; `isForbiddenCodePoint` relies on that for its early exit.
|
|
37
|
+
*/
|
|
38
|
+
export const NEUTRALIZED_FORBIDDEN_RANGES = [
|
|
39
|
+
[0x0000, 0x001f], // C0 controls, including TAB, LF, CR and ESC
|
|
40
|
+
[0x007f, 0x007f], // DEL
|
|
41
|
+
[0x0080, 0x009f], // C1 controls, including CSI (U+009B)
|
|
42
|
+
[0x00ad, 0x00ad], // SOFT HYPHEN
|
|
43
|
+
[0x061c, 0x061c], // ARABIC LETTER MARK
|
|
44
|
+
[0x200b, 0x200d], // ZWSP, ZWNJ, ZWJ
|
|
45
|
+
[0x200e, 0x200f], // LRM, RLM
|
|
46
|
+
[0x202a, 0x202e], // LRE, RLE, PDF, LRO, RLO
|
|
47
|
+
[0x2060, 0x2060], // WORD JOINER
|
|
48
|
+
[0x2066, 0x2069], // LRI, RLI, FSI, PDI
|
|
49
|
+
[0xfe00, 0xfe0f], // variation selectors VS1..VS16
|
|
50
|
+
[0xfeff, 0xfeff], // ZWNBSP / BOM
|
|
51
|
+
[0xfff9, 0xfffb], // interlinear annotation anchor/separator/terminator
|
|
52
|
+
[0xe0000, 0xe007f], // tag characters
|
|
53
|
+
];
|
|
54
|
+
/** Last C0 code point. C0 is the one range that gets a Control Pictures glyph instead of U+FFFD. */
|
|
55
|
+
const C0_LAST = 0x001f;
|
|
56
|
+
/** Base of the Control Pictures block: `U+2400 + cp` is the visible glyph for C0 code point `cp`. */
|
|
57
|
+
const CONTROL_PICTURES_BASE = 0x2400;
|
|
58
|
+
/** The one-for-one marker for every non-C0 forbidden code point. */
|
|
59
|
+
const REPLACEMENT_CHARACTER = "�";
|
|
60
|
+
const MARKER_PREFIX = "…[";
|
|
61
|
+
const MARKER_SUFFIX = " chars elided]…";
|
|
62
|
+
/** Grapheme length of the elision marker without its digits. */
|
|
63
|
+
const MARKER_FIXED_LENGTH = MARKER_PREFIX.length + MARKER_SUFFIX.length;
|
|
64
|
+
/**
|
|
65
|
+
* UTF-8 bytes `value` occupies. Derived from the code points rather than by encoding, so the wire
|
|
66
|
+
* path never allocates a second copy of a string an attacker chose the length of.
|
|
67
|
+
*/
|
|
68
|
+
function utf8Length(value) {
|
|
69
|
+
let bytes = 0;
|
|
70
|
+
for (const ch of value) {
|
|
71
|
+
const cp = ch.codePointAt(0);
|
|
72
|
+
bytes += cp < 0x80 ? 1 : cp < 0x800 ? 2 : cp < 0x10000 ? 3 : 4;
|
|
73
|
+
}
|
|
74
|
+
return bytes;
|
|
75
|
+
}
|
|
76
|
+
/** UTF-8 bytes of the elision marker without its digits. Derived, so the two markers cannot drift. */
|
|
77
|
+
const MARKER_FIXED_BYTES = utf8Length(MARKER_PREFIX) + utf8Length(MARKER_SUFFIX);
|
|
78
|
+
/**
|
|
79
|
+
* Bytes one cluster may contribute before the byte ceiling binds. Four is the widest a single code
|
|
80
|
+
* point can be in UTF-8, so every ORDINARY cluster — one base code point, its canonical marks
|
|
81
|
+
* already NFC-composed onto it — survives untouched, and what gets cut is a cluster carrying dozens
|
|
82
|
+
* of marks, which is the attack rather than the text.
|
|
83
|
+
*
|
|
84
|
+
* It is an AVERAGE over the field, not a per-cluster refusal: a flag or a skin-tone emoji is eight
|
|
85
|
+
* bytes in one cluster and passes unremarked inside ordinary text. A field that is nothing but such
|
|
86
|
+
* clusters is elided, and the marker says by how much — which is the ordinary bounded outcome, not
|
|
87
|
+
* a refusal.
|
|
88
|
+
*/
|
|
89
|
+
const MAX_BYTES_PER_GRAPHEME = 4;
|
|
90
|
+
/**
|
|
91
|
+
* Absolute per-field byte ceiling, whatever the grapheme budget.
|
|
92
|
+
*
|
|
93
|
+
* 4096 ≥ 4000, the largest free-text grapheme budget on the permission wire, so no all-ASCII field
|
|
94
|
+
* filled to its grapheme maximum is ever cut by bytes — the byte ceiling only ever binds on text
|
|
95
|
+
* that is wide per cluster.
|
|
96
|
+
*
|
|
97
|
+
* THE FRAME ARITHMETIC this number is chosen for. With every field of `permission_request` at its
|
|
98
|
+
* wire maximum and every one of them as wide as this ceiling allows, the worst case a field can
|
|
99
|
+
* contribute to the encoded frame is `max(2 × maxGraphemes, byteCeiling(maxGraphemes))` — the left
|
|
100
|
+
* term because JSON escapes `\` and `"` to two bytes each (an all-backslash ASCII field is bounded
|
|
101
|
+
* by graphemes, not bytes), the right because non-ASCII is never escaped:
|
|
102
|
+
*
|
|
103
|
+
* toolName(128)→512 cwd(1024)→4096 title(200)→800 message(4000)→8000 command(4000)→8000
|
|
104
|
+
* path(1024)→4096 operation(128)→512 16 × label(200)→12800
|
|
105
|
+
* = 38,816 bytes of free text
|
|
106
|
+
* + ids and instants (requestId 128, toolCallId 128, 16 option ids × 128, requestedAt 64,
|
|
107
|
+
* deadline 64 = 2,432 code units). These are plain `z.string().max(n)` on the wire, NOT
|
|
108
|
+
* `safeText`, so they accept control characters, and JSON escapes each of those to `\uXXXX`
|
|
109
|
+
* = 6 bytes. Their worst case is therefore 6 bytes per code unit, not 3: 14,592.
|
|
110
|
+
* + field names, braces, quotes and commas ≈ 700
|
|
111
|
+
* ≈ 54,108 bytes < 65,536 = `DEFAULT_TRANSPORT_LIMITS.maxFrameBytes`, with ~11 KiB of headroom.
|
|
112
|
+
*
|
|
113
|
+
* An earlier version of this comment costed the ids at 3 bytes and claimed ~46,812 with ~18 KiB
|
|
114
|
+
* spare. That was wrong, and it was wrong in the direction that matters — a verifier built the
|
|
115
|
+
* witness and measured 52,752 bytes (80.5% of the cap) using U+0001 in every id. The frame still
|
|
116
|
+
* decodes, so the safety property held; the arithmetic asserting it did not. If those id fields
|
|
117
|
+
* ever gain a `safeText` bound the number drops back to ~46,812.
|
|
118
|
+
*
|
|
119
|
+
* That is the BOUND, not a measurement: the worst witness the tests actually build — Zalgo in the
|
|
120
|
+
* cluster-wide fields, backslashes in the escape-heavy ones — encodes to 35,518 bytes.
|
|
121
|
+
*/
|
|
122
|
+
const MAX_FIELD_BYTES = 4096;
|
|
123
|
+
/**
|
|
124
|
+
* The byte ceiling that applies when a caller names only a grapheme budget — which is every caller
|
|
125
|
+
* that has no reason to think about bytes, and therefore the reason this is a DEFAULT and not an
|
|
126
|
+
* option: a caller who forgets it still gets a bounded string.
|
|
127
|
+
*/
|
|
128
|
+
export function defaultMaxBytes(maxGraphemes) {
|
|
129
|
+
return Math.min(Math.max(maxGraphemes, 0) * MAX_BYTES_PER_GRAPHEME, MAX_FIELD_BYTES);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Same primitive as `getGraphemeSegmenter()` (packages/tui/src/utils.ts:10), deliberately NOT
|
|
133
|
+
* imported from @draht/tui so this module stays dependency-light.
|
|
134
|
+
*/
|
|
135
|
+
const graphemeSegmenter = new Intl.Segmenter("en", { granularity: "grapheme" });
|
|
136
|
+
/**
|
|
137
|
+
* Unpaired surrogates: a high surrogate with no low surrogate after it, or a low surrogate with no
|
|
138
|
+
* high surrogate before it. Replicated from `sanitizeSurrogates` in
|
|
139
|
+
* packages/ai/src/utils/sanitize-unicode.ts:21 — that helper is not re-exported from the @draht/ai
|
|
140
|
+
* entry point, and importing it would pull a heavy package into the wire path.
|
|
141
|
+
*/
|
|
142
|
+
const UNPAIRED_SURROGATE_PATTERN = /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g;
|
|
143
|
+
function isForbiddenCodePoint(cp) {
|
|
144
|
+
for (const [start, end] of NEUTRALIZED_FORBIDDEN_RANGES) {
|
|
145
|
+
if (cp < start)
|
|
146
|
+
return false; // ranges are sorted ascending
|
|
147
|
+
if (cp <= end)
|
|
148
|
+
return true;
|
|
149
|
+
}
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* True when `value` carries no code point from {@link NEUTRALIZED_FORBIDDEN_RANGES} — i.e. when it
|
|
154
|
+
* is safe to hand to a renderer verbatim. Every `BoundedText.value` satisfies this.
|
|
155
|
+
*/
|
|
156
|
+
export function isNeutralized(value) {
|
|
157
|
+
for (const ch of value) {
|
|
158
|
+
if (isForbiddenCodePoint(ch.codePointAt(0)))
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
return true;
|
|
162
|
+
}
|
|
163
|
+
/** Step 1: NFC, then repair unpaired surrogates. */
|
|
164
|
+
function normalizeAndRepair(raw) {
|
|
165
|
+
const composed = raw.normalize("NFC");
|
|
166
|
+
const repaired = composed.replace(UNPAIRED_SURROGATE_PATTERN, "");
|
|
167
|
+
// Re-compose only when the repair actually dropped something: removing a lone surrogate can leave
|
|
168
|
+
// a base character adjacent to a combining mark, and without this second pass a second call to
|
|
169
|
+
// boundedSafeText would compose them and yield a different string, breaking idempotence.
|
|
170
|
+
return repaired === composed ? composed : repaired.normalize("NFC");
|
|
171
|
+
}
|
|
172
|
+
/** Step 2: replace each offending code point with EXACTLY ONE visible marker code point. */
|
|
173
|
+
function neutralize(text) {
|
|
174
|
+
let out = "";
|
|
175
|
+
for (const ch of text) {
|
|
176
|
+
const cp = ch.codePointAt(0);
|
|
177
|
+
if (cp <= C0_LAST) {
|
|
178
|
+
out += String.fromCodePoint(CONTROL_PICTURES_BASE + cp);
|
|
179
|
+
}
|
|
180
|
+
else if (isForbiddenCodePoint(cp)) {
|
|
181
|
+
out += REPLACEMENT_CHARACTER;
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
out += ch;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return out;
|
|
188
|
+
}
|
|
189
|
+
function toGraphemes(text) {
|
|
190
|
+
const out = [];
|
|
191
|
+
for (const { segment } of graphemeSegmenter.segment(text))
|
|
192
|
+
out.push(segment);
|
|
193
|
+
return out;
|
|
194
|
+
}
|
|
195
|
+
function elisionMarker(elided) {
|
|
196
|
+
return `${MARKER_PREFIX}${elided}${MARKER_SUFFIX}`;
|
|
197
|
+
}
|
|
198
|
+
/** The longest suffix of `graphemes` within both budgets. The tail is the decisive part: it goes first. */
|
|
199
|
+
function takeTail(byteLengths, maxGraphemes, maxBytes) {
|
|
200
|
+
let count = 0;
|
|
201
|
+
let bytes = 0;
|
|
202
|
+
for (let i = byteLengths.length - 1; i >= 0 && count < maxGraphemes; i--) {
|
|
203
|
+
if (bytes + byteLengths[i] > maxBytes)
|
|
204
|
+
break;
|
|
205
|
+
bytes += byteLengths[i];
|
|
206
|
+
count++;
|
|
207
|
+
}
|
|
208
|
+
return { count, bytes };
|
|
209
|
+
}
|
|
210
|
+
/** The longest prefix of `graphemes` within both budgets. */
|
|
211
|
+
function takeHead(byteLengths, maxGraphemes, maxBytes) {
|
|
212
|
+
let count = 0;
|
|
213
|
+
let bytes = 0;
|
|
214
|
+
for (let i = 0; i < byteLengths.length && count < maxGraphemes; i++) {
|
|
215
|
+
if (bytes + byteLengths[i] > maxBytes)
|
|
216
|
+
break;
|
|
217
|
+
bytes += byteLengths[i];
|
|
218
|
+
count++;
|
|
219
|
+
}
|
|
220
|
+
return { count, bytes };
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Neutralize `raw` one-for-one, then bound it to `maxGraphemes` grapheme clusters AND `maxBytes`
|
|
224
|
+
* UTF-8 bytes — whichever binds first — with a MIDDLE elision that guarantees the decisive tail
|
|
225
|
+
* survives.
|
|
226
|
+
*
|
|
227
|
+
* BOTH UNITS, because either alone is a hole. A byte budget alone would refuse legitimate text a
|
|
228
|
+
* renderer can display in one line (a CJK cluster is three bytes, an astral emoji four); a grapheme
|
|
229
|
+
* budget alone bounds nothing at all, because one cluster may carry unboundedly many combining
|
|
230
|
+
* marks — that is the 383 KB "512-cluster" frame that got a phone disconnected with close 1008.
|
|
231
|
+
* `maxBytes` defaults to {@link defaultMaxBytes}, so a caller that never thought about bytes still
|
|
232
|
+
* gets a string bounded in them.
|
|
233
|
+
*
|
|
234
|
+
* The elision marker is `…[<k> chars elided]…`, where `k` is the number of elided graphemes — a bare
|
|
235
|
+
* `…` cannot distinguish three elided characters from four thousand characters of padding. Of what
|
|
236
|
+
* each budget has left after the marker, two thirds (rounded up) go to the tail and the remainder to
|
|
237
|
+
* the head. When a budget is too small to hold the marker at all, the tail alone is kept.
|
|
238
|
+
*
|
|
239
|
+
* The marker's own width is reserved at the widest it could be — the digit count of the TOTAL, which
|
|
240
|
+
* is an upper bound on the digit count of the elided count. Reserving the worst case rather than
|
|
241
|
+
* solving the marker's self-reference is what keeps the result provably inside both budgets now that
|
|
242
|
+
* `kept` depends on byte widths the marker cannot see; the cost is at most one unused character in
|
|
243
|
+
* the rare case where the elided count has fewer digits than the total.
|
|
244
|
+
*/
|
|
245
|
+
export function boundedSafeText(raw, maxGraphemes, maxBytes = defaultMaxBytes(maxGraphemes)) {
|
|
246
|
+
const neutralized = neutralize(normalizeAndRepair(raw));
|
|
247
|
+
const graphemes = toGraphemes(neutralized);
|
|
248
|
+
const originalLength = graphemes.length;
|
|
249
|
+
if (maxGraphemes <= 0 || maxBytes <= 0) {
|
|
250
|
+
return { value: "", truncated: originalLength > 0, originalLength };
|
|
251
|
+
}
|
|
252
|
+
if (originalLength <= maxGraphemes && utf8Length(neutralized) <= maxBytes) {
|
|
253
|
+
return { value: neutralized, truncated: false, originalLength };
|
|
254
|
+
}
|
|
255
|
+
const byteLengths = graphemes.map(utf8Length);
|
|
256
|
+
// Marker is ASCII digits plus two U+2026, so its UTF-16 length is also its grapheme length.
|
|
257
|
+
const markerDigits = String(originalLength).length;
|
|
258
|
+
const keepGraphemes = maxGraphemes - (MARKER_FIXED_LENGTH + markerDigits);
|
|
259
|
+
const keepBytes = maxBytes - (MARKER_FIXED_BYTES + markerDigits);
|
|
260
|
+
if (keepGraphemes < 1 || keepBytes < 1) {
|
|
261
|
+
// Not enough budget for the marker: keep the decisive tail alone.
|
|
262
|
+
const tail = takeTail(byteLengths, maxGraphemes, maxBytes);
|
|
263
|
+
return { value: graphemes.slice(originalLength - tail.count).join(""), truncated: true, originalLength };
|
|
264
|
+
}
|
|
265
|
+
const tailGraphemes = Math.ceil((keepGraphemes * 2) / 3);
|
|
266
|
+
const tail = takeTail(byteLengths, tailGraphemes, Math.ceil((keepBytes * 2) / 3));
|
|
267
|
+
// The head gets its share of the clusters and every byte the tail did not spend. It can never
|
|
268
|
+
// reach the tail: the two together are capped at `keepGraphemes`, and `originalLength` is larger.
|
|
269
|
+
const head = takeHead(byteLengths, Math.min(keepGraphemes - tailGraphemes, originalLength - tail.count), keepBytes - tail.bytes);
|
|
270
|
+
const marker = elisionMarker(originalLength - head.count - tail.count);
|
|
271
|
+
return {
|
|
272
|
+
value: `${graphemes.slice(0, head.count).join("")}${marker}${graphemes.slice(originalLength - tail.count).join("")}`,
|
|
273
|
+
truncated: true,
|
|
274
|
+
originalLength,
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
//# sourceMappingURL=safe-text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"safe-text.js","sourceRoot":"","sources":["../../../src/core/socket-server/safe-text.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAYH;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAA2C;IACnF,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,6CAA6C;IAC/D,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;IACxB,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,sCAAsC;IACxD,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,cAAc;IAChC,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,qBAAqB;IACvC,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,kBAAkB;IACpC,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW;IAC7B,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,0BAA0B;IAC5C,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,cAAc;IAChC,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,qBAAqB;IACvC,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,gCAAgC;IAClD,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,eAAe;IACjC,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,qDAAqD;IACvE,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,iBAAiB;CACrC,CAAC;AAEF,oGAAoG;AACpG,MAAM,OAAO,GAAG,MAAM,CAAC;AACvB,qGAAqG;AACrG,MAAM,qBAAqB,GAAG,MAAM,CAAC;AACrC,oEAAoE;AACpE,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAElC,MAAM,aAAa,GAAG,IAAI,CAAC;AAC3B,MAAM,aAAa,GAAG,iBAAiB,CAAC;AACxC,gEAAgE;AAChE,MAAM,mBAAmB,GAAG,aAAa,CAAC,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC;AAExE;;;GAGG;AACH,SAAS,UAAU,CAAC,KAAa;IAChC,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,KAAK,MAAM,EAAE,IAAI,KAAK,EAAE,CAAC;QACxB,MAAM,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,CAAC,CAAW,CAAC;QACvC,KAAK,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAChE,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC;AAED,sGAAsG;AACtG,MAAM,kBAAkB,GAAG,UAAU,CAAC,aAAa,CAAC,GAAG,UAAU,CAAC,aAAa,CAAC,CAAC;AAEjF;;;;;;;;;;GAUG;AACH,MAAM,sBAAsB,GAAG,CAAC,CAAC;AAEjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,eAAe,GAAG,IAAI,CAAC;AAE7B;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,YAAoB;IACnD,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,CAAC,CAAC,GAAG,sBAAsB,EAAE,eAAe,CAAC,CAAC;AACtF,CAAC;AAED;;;GAGG;AACH,MAAM,iBAAiB,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC,CAAC;AAEhF;;;;;GAKG;AACH,MAAM,0BAA0B,GAAG,yEAAyE,CAAC;AAE7G,SAAS,oBAAoB,CAAC,EAAU;IACvC,KAAK,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,IAAI,4BAA4B,EAAE,CAAC;QACzD,IAAI,EAAE,GAAG,KAAK;YAAE,OAAO,KAAK,CAAC,CAAC,8BAA8B;QAC5D,IAAI,EAAE,IAAI,GAAG;YAAE,OAAO,IAAI,CAAC;IAC5B,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,KAAa;IAC1C,KAAK,MAAM,EAAE,IAAI,KAAK,EAAE,CAAC;QACxB,IAAI,oBAAoB,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAW,CAAC;YAAE,OAAO,KAAK,CAAC;IACrE,CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC;AAED,oDAAoD;AACpD,SAAS,kBAAkB,CAAC,GAAW;IACtC,MAAM,QAAQ,GAAG,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACtC,MAAM,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,0BAA0B,EAAE,EAAE,CAAC,CAAC;IAClE,kGAAkG;IAClG,+FAA+F;IAC/F,yFAAyF;IACzF,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AACrE,CAAC;AAED,4FAA4F;AAC5F,SAAS,UAAU,CAAC,IAAY;IAC/B,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,KAAK,MAAM,EAAE,IAAI,IAAI,EAAE,CAAC;QACvB,MAAM,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,CAAC,CAAW,CAAC;QACvC,IAAI,EAAE,IAAI,OAAO,EAAE,CAAC;YACnB,GAAG,IAAI,MAAM,CAAC,aAAa,CAAC,qBAAqB,GAAG,EAAE,CAAC,CAAC;QACzD,CAAC;aAAM,IAAI,oBAAoB,CAAC,EAAE,CAAC,EAAE,CAAC;YACrC,GAAG,IAAI,qBAAqB,CAAC;QAC9B,CAAC;aAAM,CAAC;YACP,GAAG,IAAI,EAAE,CAAC;QACX,CAAC;IACF,CAAC;IACD,OAAO,GAAG,CAAC;AACZ,CAAC;AAED,SAAS,WAAW,CAAC,IAAY;IAChC,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,KAAK,MAAM,EAAE,OAAO,EAAE,IAAI,iBAAiB,CAAC,OAAO,CAAC,IAAI,CAAC;QAAE,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC7E,OAAO,GAAG,CAAC;AACZ,CAAC;AAED,SAAS,aAAa,CAAC,MAAc;IACpC,OAAO,GAAG,aAAa,GAAG,MAAM,GAAG,aAAa,EAAE,CAAC;AACpD,CAAC;AAQD,2GAA2G;AAC3G,SAAS,QAAQ,CAAC,WAA8B,EAAE,YAAoB,EAAE,QAAgB;IACvF,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,KAAK,IAAI,CAAC,GAAG,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,GAAG,YAAY,EAAE,CAAC,EAAE,EAAE,CAAC;QAC1E,IAAI,KAAK,GAAG,WAAW,CAAC,CAAC,CAAC,GAAG,QAAQ;YAAE,MAAM;QAC7C,KAAK,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC;QACxB,KAAK,EAAE,CAAC;IACT,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AACzB,CAAC;AAED,6DAA6D;AAC7D,SAAS,QAAQ,CAAC,WAA8B,EAAE,YAAoB,EAAE,QAAgB;IACvF,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,MAAM,IAAI,KAAK,GAAG,YAAY,EAAE,CAAC,EAAE,EAAE,CAAC;QACrE,IAAI,KAAK,GAAG,WAAW,CAAC,CAAC,CAAC,GAAG,QAAQ;YAAE,MAAM;QAC7C,KAAK,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC;QACxB,KAAK,EAAE,CAAC;IACT,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AACzB,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,eAAe,CAC9B,GAAW,EACX,YAAoB,EACpB,QAAQ,GAAG,eAAe,CAAC,YAAY,CAAC;IAExC,MAAM,WAAW,GAAG,UAAU,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAAC;IACxD,MAAM,SAAS,GAAG,WAAW,CAAC,WAAW,CAAC,CAAC;IAC3C,MAAM,cAAc,GAAG,SAAS,CAAC,MAAM,CAAC;IAExC,IAAI,YAAY,IAAI,CAAC,IAAI,QAAQ,IAAI,CAAC,EAAE,CAAC;QACxC,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,cAAc,GAAG,CAAC,EAAE,cAAc,EAAE,CAAC;IACrE,CAAC;IACD,IAAI,cAAc,IAAI,YAAY,IAAI,UAAU,CAAC,WAAW,CAAC,IAAI,QAAQ,EAAE,CAAC;QAC3E,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,cAAc,EAAE,CAAC;IACjE,CAAC;IAED,MAAM,WAAW,GAAG,SAAS,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAC9C,4FAA4F;IAC5F,MAAM,YAAY,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC,MAAM,CAAC;IACnD,MAAM,aAAa,GAAG,YAAY,GAAG,CAAC,mBAAmB,GAAG,YAAY,CAAC,CAAC;IAC1E,MAAM,SAAS,GAAG,QAAQ,GAAG,CAAC,kBAAkB,GAAG,YAAY,CAAC,CAAC;IAEjE,IAAI,aAAa,GAAG,CAAC,IAAI,SAAS,GAAG,CAAC,EAAE,CAAC;QACxC,kEAAkE;QAClE,MAAM,IAAI,GAAG,QAAQ,CAAC,WAAW,EAAE,YAAY,EAAE,QAAQ,CAAC,CAAC;QAC3D,OAAO,EAAE,KAAK,EAAE,SAAS,CAAC,KAAK,CAAC,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC;IAC1G,CAAC;IAED,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,aAAa,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IACzD,MAAM,IAAI,GAAG,QAAQ,CAAC,WAAW,EAAE,aAAa,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAClF,8FAA8F;IAC9F,kGAAkG;IAClG,MAAM,IAAI,GAAG,QAAQ,CACpB,WAAW,EACX,IAAI,CAAC,GAAG,CAAC,aAAa,GAAG,aAAa,EAAE,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,EACpE,SAAS,GAAG,IAAI,CAAC,KAAK,CACtB,CAAC;IACF,MAAM,MAAM,GAAG,aAAa,CAAC,cAAc,GAAG,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;IACvE,OAAO;QACN,KAAK,EAAE,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE;QACpH,SAAS,EAAE,IAAI;QACf,cAAc;KACd,CAAC;AACH,CAAC","sourcesContent":["/**\n * safe-text — neutralize-and-bound for attacker-influenced text placed on the attach wire.\n *\n * A permission ask carries strings the model (and therefore an attacker) influenced: a shell\n * command, a file path, a URL. Four properties are load-bearing before such a string may be\n * rendered by a surface we do not control:\n *\n * 1. NEVER DELETE. Dropping a control character silently welds `rm -r` + `f /` into `rm -rf /`,\n * so the displayed string stops matching the executed one with no evidence left behind. Every\n * offending code point is therefore replaced by EXACTLY ONE visible marker code point.\n * 2. KEEP THE TAIL. The decision-relevant part of `curl … | sh # AND THEN rm -rf ~/.ssh` is its\n * end, so bounding elides the MIDDLE and preserves the tail, never the head.\n * 3. PRICE THE SPOOF. Bidi overrides cost zero display width, so a width budget cannot bound them;\n * they are neutralized outright, and the elided grapheme count travels with the text.\n * 4. BOUND BOTH UNITS. A grapheme budget alone bounds nothing on the wire: ONE cluster admits\n * unboundedly many combining marks, so 512 clusters of Zalgo encoded to 383,246 bytes — a frame\n * the schema accepted and the attach bridge then refused, killing the renderer's connection with\n * close 1008. Graphemes AND bytes are therefore bounded here, at CONSTRUCTION, whichever binds\n * first. Downstream byte caps are backstops, not the bound.\n *\n * This module is deliberately pure and dependency-light: no I/O, no imports from socket-server\n * siblings, no @draht/* imports. It is the single place where the wire text is CONSTRUCTED safe;\n * the protocol layer only re-asserts the predicate.\n */\n\n/** Neutralized, length-bounded text plus the evidence needed to trust the bound. */\nexport interface BoundedText {\n\t/** The neutralized (and possibly middle-elided) text. Safe to render verbatim. */\n\tvalue: string;\n\t/** True when `value` had to be elided to fit EITHER budget — graphemes or bytes. */\n\ttruncated: boolean;\n\t/** Grapheme count of the NEUTRALIZED text — never of the raw input. */\n\toriginalLength: number;\n}\n\n/**\n * Inclusive code point ranges that are replaced one-for-one by a visible marker.\n *\n * C0 (the first range) becomes its Control Pictures glyph, `U+2400 + cp`; every other range becomes\n * U+FFFD. Nothing here is ever deleted, so the neutralized string has the same code point count as\n * its input.\n *\n * A LATER TASK HAND-MIRRORS THIS TABLE inside `packages/geist-protocol` as a zod `.refine()`\n * predicate — that package must keep zero @draht dependencies, so it cannot import this constant.\n * Any edit here has to be repeated there by hand, and the two must stay byte-for-byte equivalent.\n *\n * Sorted ascending by range start; `isForbiddenCodePoint` relies on that for its early exit.\n */\nexport const NEUTRALIZED_FORBIDDEN_RANGES: readonly (readonly [number, number])[] = [\n\t[0x0000, 0x001f], // C0 controls, including TAB, LF, CR and ESC\n\t[0x007f, 0x007f], // DEL\n\t[0x0080, 0x009f], // C1 controls, including CSI (U+009B)\n\t[0x00ad, 0x00ad], // SOFT HYPHEN\n\t[0x061c, 0x061c], // ARABIC LETTER MARK\n\t[0x200b, 0x200d], // ZWSP, ZWNJ, ZWJ\n\t[0x200e, 0x200f], // LRM, RLM\n\t[0x202a, 0x202e], // LRE, RLE, PDF, LRO, RLO\n\t[0x2060, 0x2060], // WORD JOINER\n\t[0x2066, 0x2069], // LRI, RLI, FSI, PDI\n\t[0xfe00, 0xfe0f], // variation selectors VS1..VS16\n\t[0xfeff, 0xfeff], // ZWNBSP / BOM\n\t[0xfff9, 0xfffb], // interlinear annotation anchor/separator/terminator\n\t[0xe0000, 0xe007f], // tag characters\n];\n\n/** Last C0 code point. C0 is the one range that gets a Control Pictures glyph instead of U+FFFD. */\nconst C0_LAST = 0x001f;\n/** Base of the Control Pictures block: `U+2400 + cp` is the visible glyph for C0 code point `cp`. */\nconst CONTROL_PICTURES_BASE = 0x2400;\n/** The one-for-one marker for every non-C0 forbidden code point. */\nconst REPLACEMENT_CHARACTER = \"�\";\n\nconst MARKER_PREFIX = \"…[\";\nconst MARKER_SUFFIX = \" chars elided]…\";\n/** Grapheme length of the elision marker without its digits. */\nconst MARKER_FIXED_LENGTH = MARKER_PREFIX.length + MARKER_SUFFIX.length;\n\n/**\n * UTF-8 bytes `value` occupies. Derived from the code points rather than by encoding, so the wire\n * path never allocates a second copy of a string an attacker chose the length of.\n */\nfunction utf8Length(value: string): number {\n\tlet bytes = 0;\n\tfor (const ch of value) {\n\t\tconst cp = ch.codePointAt(0) as number;\n\t\tbytes += cp < 0x80 ? 1 : cp < 0x800 ? 2 : cp < 0x10000 ? 3 : 4;\n\t}\n\treturn bytes;\n}\n\n/** UTF-8 bytes of the elision marker without its digits. Derived, so the two markers cannot drift. */\nconst MARKER_FIXED_BYTES = utf8Length(MARKER_PREFIX) + utf8Length(MARKER_SUFFIX);\n\n/**\n * Bytes one cluster may contribute before the byte ceiling binds. Four is the widest a single code\n * point can be in UTF-8, so every ORDINARY cluster — one base code point, its canonical marks\n * already NFC-composed onto it — survives untouched, and what gets cut is a cluster carrying dozens\n * of marks, which is the attack rather than the text.\n *\n * It is an AVERAGE over the field, not a per-cluster refusal: a flag or a skin-tone emoji is eight\n * bytes in one cluster and passes unremarked inside ordinary text. A field that is nothing but such\n * clusters is elided, and the marker says by how much — which is the ordinary bounded outcome, not\n * a refusal.\n */\nconst MAX_BYTES_PER_GRAPHEME = 4;\n\n/**\n * Absolute per-field byte ceiling, whatever the grapheme budget.\n *\n * 4096 ≥ 4000, the largest free-text grapheme budget on the permission wire, so no all-ASCII field\n * filled to its grapheme maximum is ever cut by bytes — the byte ceiling only ever binds on text\n * that is wide per cluster.\n *\n * THE FRAME ARITHMETIC this number is chosen for. With every field of `permission_request` at its\n * wire maximum and every one of them as wide as this ceiling allows, the worst case a field can\n * contribute to the encoded frame is `max(2 × maxGraphemes, byteCeiling(maxGraphemes))` — the left\n * term because JSON escapes `\\` and `\"` to two bytes each (an all-backslash ASCII field is bounded\n * by graphemes, not bytes), the right because non-ASCII is never escaped:\n *\n * toolName(128)→512 cwd(1024)→4096 title(200)→800 message(4000)→8000 command(4000)→8000\n * path(1024)→4096 operation(128)→512 16 × label(200)→12800\n * = 38,816 bytes of free text\n * + ids and instants (requestId 128, toolCallId 128, 16 option ids × 128, requestedAt 64,\n * deadline 64 = 2,432 code units). These are plain `z.string().max(n)` on the wire, NOT\n * `safeText`, so they accept control characters, and JSON escapes each of those to `\\uXXXX`\n * = 6 bytes. Their worst case is therefore 6 bytes per code unit, not 3: 14,592.\n * + field names, braces, quotes and commas ≈ 700\n * ≈ 54,108 bytes < 65,536 = `DEFAULT_TRANSPORT_LIMITS.maxFrameBytes`, with ~11 KiB of headroom.\n *\n * An earlier version of this comment costed the ids at 3 bytes and claimed ~46,812 with ~18 KiB\n * spare. That was wrong, and it was wrong in the direction that matters — a verifier built the\n * witness and measured 52,752 bytes (80.5% of the cap) using U+0001 in every id. The frame still\n * decodes, so the safety property held; the arithmetic asserting it did not. If those id fields\n * ever gain a `safeText` bound the number drops back to ~46,812.\n *\n * That is the BOUND, not a measurement: the worst witness the tests actually build — Zalgo in the\n * cluster-wide fields, backslashes in the escape-heavy ones — encodes to 35,518 bytes.\n */\nconst MAX_FIELD_BYTES = 4096;\n\n/**\n * The byte ceiling that applies when a caller names only a grapheme budget — which is every caller\n * that has no reason to think about bytes, and therefore the reason this is a DEFAULT and not an\n * option: a caller who forgets it still gets a bounded string.\n */\nexport function defaultMaxBytes(maxGraphemes: number): number {\n\treturn Math.min(Math.max(maxGraphemes, 0) * MAX_BYTES_PER_GRAPHEME, MAX_FIELD_BYTES);\n}\n\n/**\n * Same primitive as `getGraphemeSegmenter()` (packages/tui/src/utils.ts:10), deliberately NOT\n * imported from @draht/tui so this module stays dependency-light.\n */\nconst graphemeSegmenter = new Intl.Segmenter(\"en\", { granularity: \"grapheme\" });\n\n/**\n * Unpaired surrogates: a high surrogate with no low surrogate after it, or a low surrogate with no\n * high surrogate before it. Replicated from `sanitizeSurrogates` in\n * packages/ai/src/utils/sanitize-unicode.ts:21 — that helper is not re-exported from the @draht/ai\n * entry point, and importing it would pull a heavy package into the wire path.\n */\nconst UNPAIRED_SURROGATE_PATTERN = /[\\uD800-\\uDBFF](?![\\uDC00-\\uDFFF])|(?<![\\uD800-\\uDBFF])[\\uDC00-\\uDFFF]/g;\n\nfunction isForbiddenCodePoint(cp: number): boolean {\n\tfor (const [start, end] of NEUTRALIZED_FORBIDDEN_RANGES) {\n\t\tif (cp < start) return false; // ranges are sorted ascending\n\t\tif (cp <= end) return true;\n\t}\n\treturn false;\n}\n\n/**\n * True when `value` carries no code point from {@link NEUTRALIZED_FORBIDDEN_RANGES} — i.e. when it\n * is safe to hand to a renderer verbatim. Every `BoundedText.value` satisfies this.\n */\nexport function isNeutralized(value: string): boolean {\n\tfor (const ch of value) {\n\t\tif (isForbiddenCodePoint(ch.codePointAt(0) as number)) return false;\n\t}\n\treturn true;\n}\n\n/** Step 1: NFC, then repair unpaired surrogates. */\nfunction normalizeAndRepair(raw: string): string {\n\tconst composed = raw.normalize(\"NFC\");\n\tconst repaired = composed.replace(UNPAIRED_SURROGATE_PATTERN, \"\");\n\t// Re-compose only when the repair actually dropped something: removing a lone surrogate can leave\n\t// a base character adjacent to a combining mark, and without this second pass a second call to\n\t// boundedSafeText would compose them and yield a different string, breaking idempotence.\n\treturn repaired === composed ? composed : repaired.normalize(\"NFC\");\n}\n\n/** Step 2: replace each offending code point with EXACTLY ONE visible marker code point. */\nfunction neutralize(text: string): string {\n\tlet out = \"\";\n\tfor (const ch of text) {\n\t\tconst cp = ch.codePointAt(0) as number;\n\t\tif (cp <= C0_LAST) {\n\t\t\tout += String.fromCodePoint(CONTROL_PICTURES_BASE + cp);\n\t\t} else if (isForbiddenCodePoint(cp)) {\n\t\t\tout += REPLACEMENT_CHARACTER;\n\t\t} else {\n\t\t\tout += ch;\n\t\t}\n\t}\n\treturn out;\n}\n\nfunction toGraphemes(text: string): string[] {\n\tconst out: string[] = [];\n\tfor (const { segment } of graphemeSegmenter.segment(text)) out.push(segment);\n\treturn out;\n}\n\nfunction elisionMarker(elided: number): string {\n\treturn `${MARKER_PREFIX}${elided}${MARKER_SUFFIX}`;\n}\n\n/** How many clusters fit from one end under BOTH budgets, and what they cost in bytes. */\ninterface Taken {\n\tcount: number;\n\tbytes: number;\n}\n\n/** The longest suffix of `graphemes` within both budgets. The tail is the decisive part: it goes first. */\nfunction takeTail(byteLengths: readonly number[], maxGraphemes: number, maxBytes: number): Taken {\n\tlet count = 0;\n\tlet bytes = 0;\n\tfor (let i = byteLengths.length - 1; i >= 0 && count < maxGraphemes; i--) {\n\t\tif (bytes + byteLengths[i] > maxBytes) break;\n\t\tbytes += byteLengths[i];\n\t\tcount++;\n\t}\n\treturn { count, bytes };\n}\n\n/** The longest prefix of `graphemes` within both budgets. */\nfunction takeHead(byteLengths: readonly number[], maxGraphemes: number, maxBytes: number): Taken {\n\tlet count = 0;\n\tlet bytes = 0;\n\tfor (let i = 0; i < byteLengths.length && count < maxGraphemes; i++) {\n\t\tif (bytes + byteLengths[i] > maxBytes) break;\n\t\tbytes += byteLengths[i];\n\t\tcount++;\n\t}\n\treturn { count, bytes };\n}\n\n/**\n * Neutralize `raw` one-for-one, then bound it to `maxGraphemes` grapheme clusters AND `maxBytes`\n * UTF-8 bytes — whichever binds first — with a MIDDLE elision that guarantees the decisive tail\n * survives.\n *\n * BOTH UNITS, because either alone is a hole. A byte budget alone would refuse legitimate text a\n * renderer can display in one line (a CJK cluster is three bytes, an astral emoji four); a grapheme\n * budget alone bounds nothing at all, because one cluster may carry unboundedly many combining\n * marks — that is the 383 KB \"512-cluster\" frame that got a phone disconnected with close 1008.\n * `maxBytes` defaults to {@link defaultMaxBytes}, so a caller that never thought about bytes still\n * gets a string bounded in them.\n *\n * The elision marker is `…[<k> chars elided]…`, where `k` is the number of elided graphemes — a bare\n * `…` cannot distinguish three elided characters from four thousand characters of padding. Of what\n * each budget has left after the marker, two thirds (rounded up) go to the tail and the remainder to\n * the head. When a budget is too small to hold the marker at all, the tail alone is kept.\n *\n * The marker's own width is reserved at the widest it could be — the digit count of the TOTAL, which\n * is an upper bound on the digit count of the elided count. Reserving the worst case rather than\n * solving the marker's self-reference is what keeps the result provably inside both budgets now that\n * `kept` depends on byte widths the marker cannot see; the cost is at most one unused character in\n * the rare case where the elided count has fewer digits than the total.\n */\nexport function boundedSafeText(\n\traw: string,\n\tmaxGraphemes: number,\n\tmaxBytes = defaultMaxBytes(maxGraphemes),\n): BoundedText {\n\tconst neutralized = neutralize(normalizeAndRepair(raw));\n\tconst graphemes = toGraphemes(neutralized);\n\tconst originalLength = graphemes.length;\n\n\tif (maxGraphemes <= 0 || maxBytes <= 0) {\n\t\treturn { value: \"\", truncated: originalLength > 0, originalLength };\n\t}\n\tif (originalLength <= maxGraphemes && utf8Length(neutralized) <= maxBytes) {\n\t\treturn { value: neutralized, truncated: false, originalLength };\n\t}\n\n\tconst byteLengths = graphemes.map(utf8Length);\n\t// Marker is ASCII digits plus two U+2026, so its UTF-16 length is also its grapheme length.\n\tconst markerDigits = String(originalLength).length;\n\tconst keepGraphemes = maxGraphemes - (MARKER_FIXED_LENGTH + markerDigits);\n\tconst keepBytes = maxBytes - (MARKER_FIXED_BYTES + markerDigits);\n\n\tif (keepGraphemes < 1 || keepBytes < 1) {\n\t\t// Not enough budget for the marker: keep the decisive tail alone.\n\t\tconst tail = takeTail(byteLengths, maxGraphemes, maxBytes);\n\t\treturn { value: graphemes.slice(originalLength - tail.count).join(\"\"), truncated: true, originalLength };\n\t}\n\n\tconst tailGraphemes = Math.ceil((keepGraphemes * 2) / 3);\n\tconst tail = takeTail(byteLengths, tailGraphemes, Math.ceil((keepBytes * 2) / 3));\n\t// The head gets its share of the clusters and every byte the tail did not spend. It can never\n\t// reach the tail: the two together are capped at `keepGraphemes`, and `originalLength` is larger.\n\tconst head = takeHead(\n\t\tbyteLengths,\n\t\tMath.min(keepGraphemes - tailGraphemes, originalLength - tail.count),\n\t\tkeepBytes - tail.bytes,\n\t);\n\tconst marker = elisionMarker(originalLength - head.count - tail.count);\n\treturn {\n\t\tvalue: `${graphemes.slice(0, head.count).join(\"\")}${marker}${graphemes.slice(originalLength - tail.count).join(\"\")}`,\n\t\ttruncated: true,\n\t\toriginalLength,\n\t};\n}\n"]}
|
|
@@ -4,14 +4,77 @@
|
|
|
4
4
|
* Wires up socket server to broadcast agent output and forward client input.
|
|
5
5
|
*/
|
|
6
6
|
import type { AgentSession } from "../agent-session.js";
|
|
7
|
+
import type { PermissionRelay } from "../permission-relay/types.js";
|
|
7
8
|
export interface AttachableSessionOptions {
|
|
8
9
|
session: AgentSession;
|
|
9
10
|
enabled: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Working directory of the session, recorded in the lock file so discovery can
|
|
13
|
+
* report which project a session belongs to. This is the session's resolved cwd,
|
|
14
|
+
* which differs from `process.cwd()` when a session from another project is
|
|
15
|
+
* selected via --session/--resume.
|
|
16
|
+
*/
|
|
17
|
+
cwd: string;
|
|
18
|
+
/** Reports non-fatal problems (default: stderr). */
|
|
19
|
+
onWarning?: (message: string) => void;
|
|
20
|
+
/** Prints the startup banner (default: stdout). */
|
|
21
|
+
log?: (message: string) => void;
|
|
22
|
+
/**
|
|
23
|
+
* Whether to print the three-line "Attachable session started" banner (default: true).
|
|
24
|
+
*
|
|
25
|
+
* Interactive mode does NOT take over stdout (main.ts only calls `takeOverStdout()` for
|
|
26
|
+
* non-interactive modes), so under default-on this banner would print a socket path into
|
|
27
|
+
* every session's scrollback in the instant before the TUI claims the terminal. Measured,
|
|
28
|
+
* it is the ENTIRE stdout delta of default-on. The implicit path passes `announce: false`;
|
|
29
|
+
* an explicit `--attachable` keeps the banner, because someone who typed the flag is
|
|
30
|
+
* entitled to be told the socket exists and where.
|
|
31
|
+
*/
|
|
32
|
+
announce?: boolean;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Handle for a session exposed on a Unix socket.
|
|
36
|
+
*
|
|
37
|
+
* The socket is bound to one session at a time. When the runtime replaces the session
|
|
38
|
+
* (/new, /resume, /fork, /import) the old session object is disposed, so the handle has
|
|
39
|
+
* to follow along via {@link AttachableSession.rebind}.
|
|
40
|
+
*/
|
|
41
|
+
export interface AttachableSession {
|
|
42
|
+
/** Path of the socket currently bound, or null when attachable mode is off or stopped. */
|
|
43
|
+
readonly socketPath: string | null;
|
|
44
|
+
/** Session id the socket currently advertises, or null when nothing is bound. */
|
|
45
|
+
readonly sessionId: string | null;
|
|
46
|
+
/**
|
|
47
|
+
* The pending-ask registry's public face, or null when nothing is bound.
|
|
48
|
+
*
|
|
49
|
+
* Hand this to {@link AgentSession.setPermissionRelay} — and hand the CURRENT one over again
|
|
50
|
+
* after every {@link AttachableSession.rebind}, because a rebind builds a new registry for the
|
|
51
|
+
* new session and the old handle is dead. The relay lives here, in this closure, and NOT in the
|
|
52
|
+
* UI decorator: a new `ExtensionRunner` (and therefore a new decorator) is built on every
|
|
53
|
+
* extension reload, which would orphan every ask raised before it with the agent still parked
|
|
54
|
+
* on the answer.
|
|
55
|
+
*/
|
|
56
|
+
readonly relay: PermissionRelay | null;
|
|
57
|
+
/** Follow a session replacement: close the old socket and bind one for the new session. */
|
|
58
|
+
rebind(session: AgentSession, cwd: string): Promise<void>;
|
|
59
|
+
/** Close the socket and remove the .sock/.lock files. */
|
|
60
|
+
stop(): Promise<void>;
|
|
61
|
+
/** Same as {@link stop}, for synchronous exit paths (`process.on("exit")`, signals). */
|
|
62
|
+
stopSync(): void;
|
|
10
63
|
}
|
|
11
64
|
/**
|
|
12
65
|
* Wrap an agent session with a socket server if attachable mode is enabled.
|
|
13
66
|
*
|
|
14
|
-
* Returns
|
|
67
|
+
* Returns a handle that owns the socket's lifetime.
|
|
68
|
+
*/
|
|
69
|
+
export declare function makeSessionAttachable(options: AttachableSessionOptions): Promise<AttachableSession>;
|
|
70
|
+
/**
|
|
71
|
+
* Remove the socket on process exit and on signals.
|
|
72
|
+
*
|
|
73
|
+
* The mode run loops (interactive, print, rpc) end in `process.exit()` and never return
|
|
74
|
+
* to their caller, so a `finally` around them is not enough: without this the .sock and
|
|
75
|
+
* .lock files outlive the process and keep showing up in `--list-sessions`.
|
|
76
|
+
*
|
|
77
|
+
* @returns unregister function
|
|
15
78
|
*/
|
|
16
|
-
export declare function
|
|
79
|
+
export declare function registerAttachableSessionCleanup(handle: Pick<AttachableSession, "stopSync">): () => void;
|
|
17
80
|
//# sourceMappingURL=session-integration.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-integration.d.ts","sourceRoot":"","sources":["../../../src/core/socket-server/session-integration.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"session-integration.d.ts","sourceRoot":"","sources":["../../../src/core/socket-server/session-integration.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AA8DpE,MAAM,WAAW,wBAAwB;IACxC,OAAO,EAAE,YAAY,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;IACjB;;;;;OAKG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ,oDAAoD;IACpD,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,mDAAmD;IACnD,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC;;;;;;;;;OASG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IACjC,0FAA0F;IAC1F,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,iFAAiF;IACjF,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC;;;;;;;;;OASG;IACH,QAAQ,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI,CAAC;IACvC,2FAA2F;IAC3F,MAAM,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1D,yDAAyD;IACzD,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACtB,wFAAwF;IACxF,QAAQ,IAAI,IAAI,CAAC;CACjB;AAaD;;;;GAIG;AACH,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAsUzG;AAED;;;;;;;;GAQG;AACH,wBAAgB,gCAAgC,CAAC,MAAM,EAAE,IAAI,CAAC,iBAAiB,EAAE,UAAU,CAAC,GAAG,MAAM,IAAI,CA6DxG"}
|