@draht/coding-agent 2026.9.5-1 → 2026.10.4-3
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 +458 -0
- 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-E2P6C3P7.js +6 -0
- package/dist/bundle/chunks/anthropic.js +75 -0
- package/dist/bundle/chunks/azure-openai-responses-JZMSTDIM.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-2JZLKNZ4.js +3 -0
- package/dist/bundle/chunks/chunk-2N4I6WXC.js +2 -0
- package/dist/bundle/chunks/chunk-3HF756LN.js +1472 -0
- package/dist/bundle/chunks/chunk-5QJFWTKA.js +4 -0
- package/dist/bundle/chunks/chunk-63BK6WK2.js +2 -0
- package/dist/bundle/chunks/chunk-A4OX5CPR.js +146 -0
- package/dist/bundle/chunks/chunk-AFL4IDSI.js +82 -0
- package/dist/bundle/chunks/chunk-D3HO453P.js +42 -0
- package/dist/bundle/chunks/chunk-EBVYI75P.js +2 -0
- package/dist/bundle/chunks/chunk-FBU742QF.js +2 -0
- package/dist/bundle/chunks/chunk-FHX2S5IG.js +31 -0
- package/dist/bundle/chunks/chunk-GBFVS2SF.js +12 -0
- package/dist/bundle/chunks/chunk-GVXA72ZA.js +2 -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-JTLUBTZT.js +2 -0
- package/dist/bundle/chunks/chunk-KPO5375S.js +2 -0
- package/dist/bundle/chunks/chunk-KY2BG6BC.js +11 -0
- package/dist/bundle/chunks/chunk-LO6CVU2L.js +6 -0
- package/dist/bundle/chunks/chunk-QMN7OD6G.js +2 -0
- package/dist/bundle/chunks/chunk-SDRCE6OP.js +2 -0
- package/dist/bundle/chunks/chunk-SPZUYYP5.js +170 -0
- package/dist/bundle/chunks/chunk-UTRX2VHB.js +44 -0
- package/dist/bundle/chunks/chunk-V5HG6S2T.js +4 -0
- package/dist/bundle/chunks/chunk-VPYAVQLP.js +137 -0
- package/dist/bundle/chunks/chunk-VXUJMEMO.js +2 -0
- package/dist/bundle/chunks/chunk-XBUEMKIY.js +2 -0
- package/dist/bundle/chunks/chunk-XHCO4PPH.js +8 -0
- package/dist/bundle/chunks/chunk-XO3IECI5.js +18 -0
- package/dist/bundle/chunks/chunk-XOGEYN4Q.js +2 -0
- package/dist/bundle/chunks/cli-L74YA5GF.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-EMOVNTD6.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-HPNDIAZD.js +2 -0
- package/dist/bundle/chunks/google-vertex-KPAWJ4SP.js +2 -0
- package/dist/bundle/chunks/https-proxy-agent-WQIRL24U.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-ULKZYRGD.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-FMSPWQ7A.js +5 -0
- package/dist/bundle/chunks/multipart-parser-HMCXZ4BD.js +3 -0
- package/dist/bundle/chunks/node-4JNG6XQO.js +16 -0
- package/dist/bundle/chunks/node-6IIDYB3K.js +2 -0
- package/dist/bundle/chunks/openai-chatgpt.js +75 -0
- package/dist/bundle/chunks/openai-codex-responses-TU7NGPXE.js +10 -0
- package/dist/bundle/chunks/openai-codex.js +75 -0
- package/dist/bundle/chunks/openai-completions-GANCQQO5.js +7 -0
- package/dist/bundle/chunks/openai-responses-ASDPAX3E.js +3 -0
- package/dist/bundle/chunks/opencode-go.js +2 -0
- package/dist/bundle/chunks/openrouter-images-NROSQXMZ.js +2 -0
- package/dist/bundle/chunks/openrouter.js +75 -0
- package/dist/bundle/chunks/pi-messages-2QEJYOAO.js +8 -0
- package/dist/bundle/chunks/radius.js +75 -0
- package/dist/bundle/chunks/runtime-RYUR6LRB.js +2 -0
- package/dist/bundle/chunks/settings-manager-CHEMMAGQ.js +2 -0
- package/dist/bundle/chunks/src-KDGO7EGF.js +4 -0
- package/dist/bundle/chunks/typesafe-system-one-YBEEY5XU.js +2 -0
- package/dist/bundle/chunks/virtual-modules-OC56AAJ7.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 +4 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +72 -21
- package/dist/cli/args.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 +5 -3
- package/dist/cli/credential-print.d.ts.map +1 -1
- package/dist/cli/credential-print.js +42 -30
- 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 +20 -4
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +42 -6
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +12 -3
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +1 -0
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +14 -0
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +237 -39
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +1386 -565
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts +20 -8
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +199 -56
- 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/duet.js +2 -2
- package/dist/core/builtins/duet.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-manager.d.ts +8 -4
- package/dist/core/checkpoints/checkpoint-manager.d.ts.map +1 -1
- package/dist/core/checkpoints/checkpoint-manager.js +46 -10
- package/dist/core/checkpoints/checkpoint-manager.js.map +1 -1
- package/dist/core/checkpoints/rewind.d.ts +4 -2
- package/dist/core/checkpoints/rewind.d.ts.map +1 -1
- package/dist/core/checkpoints/rewind.js +4 -3
- package/dist/core/checkpoints/rewind.js.map +1 -1
- package/dist/core/compaction/branch-summarization.js +2 -2
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +9 -6
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +196 -118
- 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/context-windows.d.ts.map +1 -1
- package/dist/core/context-windows.js +13 -3
- package/dist/core/context-windows.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 +228 -89
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +47 -8
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +376 -104
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +521 -88
- 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/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 +83 -13
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +33 -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 +19 -2
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +39 -2
- 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 +29 -17
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-runtime.d.ts +79 -20
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +460 -134
- 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 +597 -34
- 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.js +1 -3
- 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 +10 -0
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +149 -33
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/pi-manifest.d.ts.map +1 -1
- package/dist/core/pi-manifest.js +13 -12
- package/dist/core/pi-manifest.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 +7 -1
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +219 -42
- 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/executor.js +1 -0
- package/dist/core/sandbox/executor.js.map +1 -1
- package/dist/core/sdk.d.ts +7 -5
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +100 -52
- 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 +75 -15
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +314 -144
- 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 +84 -4
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +239 -25
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +51 -33
- package/dist/core/skills.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +3 -1
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/soak/soak-log.js +6 -0
- package/dist/core/soak/soak-log.js.map +1 -1
- package/dist/core/socket-server/socket-server.js +11 -0
- package/dist/core/socket-server/socket-server.js.map +1 -1
- package/dist/core/socket-server/types.d.ts +2 -1
- package/dist/core/socket-server/types.d.ts.map +1 -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 -89
- 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 +82 -143
- 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 +19 -171
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/find.d.ts +4 -0
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js +11 -58
- 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.map +1 -1
- package/dist/core/trust-manager.js +4 -1
- 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 +9 -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 +119 -17
- 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/provider.d.ts +2 -2
- package/dist/extensions/stub-provider/provider.d.ts.map +1 -1
- package/dist/extensions/stub-provider/provider.js +2 -1
- package/dist/extensions/stub-provider/provider.js.map +1 -1
- 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/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 +123 -51
- 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 +35 -8
- 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 +1 -0
- package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-selector.js +16 -1
- 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 +128 -78
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +23 -4
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +230 -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 +78 -52
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector.js +44 -18
- 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 +69 -5
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +1314 -593
- 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 +14 -12
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +22 -1
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/package-manager-cli.d.ts +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/plan-phase.md +1 -0
- package/dist/prompts/commands/review.md +2 -0
- package/dist/prompts/commands/verify-work.md +1 -0
- package/dist/prompts/commands/why.md +4 -0
- package/dist/rpc-entry.js +1 -0
- package/dist/rpc-entry.js.map +1 -1
- package/dist/skills/blast-radius/SKILL.md +1 -0
- package/dist/skills/explainers/SKILL.md +65 -0
- package/dist/skills/unslop/SKILL.md +19 -1
- 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/changelog.js +1 -1
- package/dist/utils/changelog.js.map +1 -1
- package/dist/utils/child-process.d.ts +1 -1
- package/dist/utils/child-process.js +1 -1
- 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 +2 -0
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js +116 -121
- 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.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 +4 -3
- package/dist/utils/paths.d.ts.map +1 -1
- package/dist/utils/paths.js +15 -4
- 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 +20 -35
- 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 +53 -36
- 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/cli-integration.md +106 -0
- package/docs/cli.md +374 -0
- package/docs/compaction.md +91 -29
- package/docs/configuration.md +47 -0
- package/docs/containerization.md +100 -66
- package/docs/custom-provider.md +109 -707
- package/docs/docs.json +155 -99
- 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 +197 -56
- package/docs/keybindings.md +89 -93
- package/docs/llama-cpp.md +18 -3
- package/docs/mcp.md +231 -0
- package/docs/message-types.md +261 -0
- package/docs/models.md +94 -478
- package/docs/packages.md +67 -163
- package/docs/prompt-templates.md +31 -68
- package/docs/providers.md +118 -215
- package/docs/quickstart.md +55 -108
- package/docs/rpc-commands.md +860 -0
- package/docs/rpc-extension-ui.md +200 -0
- package/docs/rpc.md +139 -1518
- package/docs/sdk.md +79 -1127
- package/docs/security.md +76 -32
- package/docs/session-format.md +73 -219
- package/docs/sessions.md +36 -116
- package/docs/settings.md +124 -257
- package/docs/shell-aliases.md +85 -5
- package/docs/skills.md +52 -189
- 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/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/package.json +25 -30
- package/prompts/commands/plan-phase.md +1 -0
- package/prompts/commands/review.md +2 -0
- package/prompts/commands/verify-work.md +1 -0
- package/prompts/commands/why.md +4 -0
- package/skills/blast-radius/SKILL.md +1 -0
- package/skills/explainers/SKILL.md +65 -0
- package/skills/unslop/SKILL.md +19 -1
- 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
|
@@ -212,9 +212,28 @@ const PASSTHROUGH_PREFIXES = new Set([
|
|
|
212
212
|
"chrt",
|
|
213
213
|
"setsid",
|
|
214
214
|
"xargs",
|
|
215
|
+
"timeout",
|
|
216
|
+
// busybox dispatches to its builtin applet by the same name and arguments
|
|
217
|
+
// it was given (`busybox rm -rf /` behaves exactly like `rm -rf /`), so it
|
|
218
|
+
// is a pure passthrough for deny-scan purposes.
|
|
219
|
+
"busybox",
|
|
220
|
+
// wsl/wsl.exe runs its arguments as a command inside the Linux subsystem,
|
|
221
|
+
// same shape as sudo/env.
|
|
222
|
+
"wsl",
|
|
215
223
|
]);
|
|
216
224
|
/** Shells whose `-c <command>` argument is itself a full command line to unwrap and re-check. */
|
|
217
|
-
const SHELL_C_WRAPPERS = new Set(["bash", "sh", "zsh", "ksh", "dash"]);
|
|
225
|
+
const SHELL_C_WRAPPERS = new Set(["bash", "sh", "zsh", "ksh", "dash", "fish"]);
|
|
226
|
+
/**
|
|
227
|
+
* Non-POSIX shells whose command-line argument is itself a full command line
|
|
228
|
+
* to unwrap and re-check. Catches bash wrapping another shell, e.g.
|
|
229
|
+
* `bash -c "pwsh -c 'rm -rf ~'"`. Matched by regex rather than a fixed Set so
|
|
230
|
+
* variants like `pwsh-preview`, `powershell_ise`, and `.exe`/path-prefixed
|
|
231
|
+
* spellings (normalized by `basenameOfHeadToken`) are all covered.
|
|
232
|
+
*/
|
|
233
|
+
const OTHER_SHELL_WRAPPER_RE = /^(pwsh|powershell|powershell_ise|cmd)([-_].*)?$/;
|
|
234
|
+
function isOtherShellWrapperName(basename) {
|
|
235
|
+
return OTHER_SHELL_WRAPPER_RE.test(basename);
|
|
236
|
+
}
|
|
218
237
|
/** Constructs that make a command dynamic/opaque enough that allow/approve patterns must never match it. */
|
|
219
238
|
const DANGEROUS_CONSTRUCT_RE = /\$\(|`|<|>/;
|
|
220
239
|
/** Quote-aware split of a command string on top-level chain operators (`;`, `&&`, `||`, `|`, `&`, newlines). */
|
|
@@ -268,15 +287,123 @@ function splitChain(command) {
|
|
|
268
287
|
function collapseWhitespace(text) {
|
|
269
288
|
return text.trim().replace(/\s+/g, " ");
|
|
270
289
|
}
|
|
271
|
-
/**
|
|
290
|
+
/**
|
|
291
|
+
* Canonicalizes combined single-dash short-flag clusters (`-rf` / `-fr`) by
|
|
292
|
+
* sorting their letters. The sort is case-insensitive: matching elsewhere is
|
|
293
|
+
* already case-insensitive (`globToRegExp`'s `i` flag), but a case-sensitive
|
|
294
|
+
* sort would put uppercase letters before lowercase ones (ASCII order), so a
|
|
295
|
+
* mixed-case cluster like `-Rf` would canonicalize to `-Rf` while `-rf`
|
|
296
|
+
* canonicalizes to `-fr` — different letter *order*, which the `i` flag
|
|
297
|
+
* can't paper over. Sorting case-insensitively (while keeping each letter's
|
|
298
|
+
* original case) gives `-Rf` and `-rf` the same order (`-fR` / `-fr`), so
|
|
299
|
+
* `-Rf`/`-fR`/`-RF`/... all canonicalize to match a plain `-rf` pattern.
|
|
300
|
+
*/
|
|
272
301
|
function normalizeFlagClusters(text) {
|
|
273
302
|
return text.replace(/(^|\s)-([A-Za-z]{2,})(?=\s|$)/g, (_match, pre, letters) => {
|
|
274
|
-
|
|
303
|
+
const sorted = [...letters].sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()));
|
|
304
|
+
return `${pre}-${sorted.join("")}`;
|
|
275
305
|
});
|
|
276
306
|
}
|
|
277
307
|
function normalizeForMatch(text) {
|
|
278
308
|
return normalizeFlagClusters(collapseWhitespace(text));
|
|
279
309
|
}
|
|
310
|
+
function tokenize(text) {
|
|
311
|
+
const trimmed = text.trim();
|
|
312
|
+
return trimmed.length === 0 ? [] : trimmed.split(/\s+/);
|
|
313
|
+
}
|
|
314
|
+
/** A combined short-flag cluster token (`-rf`, `-R`), optionally glob-suffixed (`-r*`) by a danger-pattern author. */
|
|
315
|
+
function parseShortFlagClusterToken(token) {
|
|
316
|
+
return token.match(/^-([A-Za-z]+)\*?$/)?.[1];
|
|
317
|
+
}
|
|
318
|
+
function parseLongFlagToken(token) {
|
|
319
|
+
return token.match(/^--([A-Za-z][A-Za-z-]*)$/)?.[1]?.toLowerCase();
|
|
320
|
+
}
|
|
321
|
+
/** Collects every short/long flag found anywhere in `tokens`, regardless of order, clustering, or position. */
|
|
322
|
+
function extractFlagSet(tokens) {
|
|
323
|
+
const shortFlags = new Set();
|
|
324
|
+
const longFlags = new Set();
|
|
325
|
+
for (const token of tokens) {
|
|
326
|
+
const letters = parseShortFlagClusterToken(token);
|
|
327
|
+
if (letters !== undefined) {
|
|
328
|
+
for (const ch of letters)
|
|
329
|
+
shortFlags.add(ch.toLowerCase());
|
|
330
|
+
continue;
|
|
331
|
+
}
|
|
332
|
+
const long = parseLongFlagToken(token);
|
|
333
|
+
if (long !== undefined)
|
|
334
|
+
longFlags.add(long);
|
|
335
|
+
}
|
|
336
|
+
return { shortFlags, longFlags };
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Parses a deny `pattern` of the shape `<command> <flags...> [*]` (e.g.
|
|
340
|
+
* `rm -rf *`, `rm -r*`, `chmod -R *`) into a required flag set, for matching
|
|
341
|
+
* by `flagClusterPatternMatchesCandidate` below. Returns `undefined` for any
|
|
342
|
+
* pattern that doesn't have this exact "bare command name plus only
|
|
343
|
+
* flags/wildcard" shape, so those patterns keep using the generic glob
|
|
344
|
+
* matcher unchanged.
|
|
345
|
+
*/
|
|
346
|
+
function parseFlagClusterPattern(pattern) {
|
|
347
|
+
const [command, ...rest] = tokenize(pattern);
|
|
348
|
+
if (command === undefined || /[*?]/.test(command))
|
|
349
|
+
return undefined;
|
|
350
|
+
const requiredShortFlags = new Set();
|
|
351
|
+
const requiredLongFlags = new Set();
|
|
352
|
+
let sawFlag = false;
|
|
353
|
+
for (const token of rest) {
|
|
354
|
+
if (token === "*")
|
|
355
|
+
continue;
|
|
356
|
+
const letters = parseShortFlagClusterToken(token);
|
|
357
|
+
if (letters !== undefined) {
|
|
358
|
+
sawFlag = true;
|
|
359
|
+
for (const ch of letters)
|
|
360
|
+
requiredShortFlags.add(ch.toLowerCase());
|
|
361
|
+
continue;
|
|
362
|
+
}
|
|
363
|
+
const long = parseLongFlagToken(token);
|
|
364
|
+
if (long !== undefined) {
|
|
365
|
+
sawFlag = true;
|
|
366
|
+
requiredLongFlags.add(long);
|
|
367
|
+
continue;
|
|
368
|
+
}
|
|
369
|
+
return undefined;
|
|
370
|
+
}
|
|
371
|
+
if (!sawFlag)
|
|
372
|
+
return undefined;
|
|
373
|
+
return { command: command.toLowerCase(), requiredShortFlags, requiredLongFlags };
|
|
374
|
+
}
|
|
375
|
+
/** `rm`'s two spellings of "recursive"/"force" that are interchangeable for flag-set matching purposes. */
|
|
376
|
+
const SHORT_LONG_FLAG_EQUIVALENTS = new Map([
|
|
377
|
+
["r", "recursive"],
|
|
378
|
+
["f", "force"],
|
|
379
|
+
]);
|
|
380
|
+
function flagClusterPatternMatchesCandidate(flagPattern, candidateText) {
|
|
381
|
+
const tokens = tokenize(candidateText);
|
|
382
|
+
const commandToken = tokens[0];
|
|
383
|
+
if (commandToken === undefined)
|
|
384
|
+
return false;
|
|
385
|
+
const commandName = (commandToken.includes("/") ? commandToken.slice(commandToken.lastIndexOf("/") + 1) : commandToken).toLowerCase();
|
|
386
|
+
if (commandName !== flagPattern.command)
|
|
387
|
+
return false;
|
|
388
|
+
const { shortFlags, longFlags } = extractFlagSet(tokens.slice(1));
|
|
389
|
+
const hasShort = (flag) => shortFlags.has(flag) || longFlags.has(SHORT_LONG_FLAG_EQUIVALENTS.get(flag) ?? "");
|
|
390
|
+
const hasLong = (flag) => {
|
|
391
|
+
if (longFlags.has(flag))
|
|
392
|
+
return true;
|
|
393
|
+
for (const [short, long] of SHORT_LONG_FLAG_EQUIVALENTS) {
|
|
394
|
+
if (long === flag && shortFlags.has(short))
|
|
395
|
+
return true;
|
|
396
|
+
}
|
|
397
|
+
return false;
|
|
398
|
+
};
|
|
399
|
+
for (const flag of flagPattern.requiredShortFlags)
|
|
400
|
+
if (!hasShort(flag))
|
|
401
|
+
return false;
|
|
402
|
+
for (const flag of flagPattern.requiredLongFlags)
|
|
403
|
+
if (!hasLong(flag))
|
|
404
|
+
return false;
|
|
405
|
+
return true;
|
|
406
|
+
}
|
|
280
407
|
/** Resolves a leading `/some/path/cmd` (or `./cmd`, `../cmd`) first token down to its bare basename. */
|
|
281
408
|
function resolveBasenameOfFirstToken(text) {
|
|
282
409
|
const leadingWs = text.slice(0, text.length - text.trimStart().length);
|
|
@@ -296,34 +423,251 @@ function stripLeadingBackslashEscape(text) {
|
|
|
296
423
|
function stripEnvAssignments(text) {
|
|
297
424
|
return text.replace(/^\s*(?:[A-Za-z_][A-Za-z0-9_]*=\S*\s+)+/, "");
|
|
298
425
|
}
|
|
299
|
-
/**
|
|
426
|
+
/**
|
|
427
|
+
* Flags that consume a separate following argument (rather than being a
|
|
428
|
+
* standalone `-flag` token) for each passthrough wrapper, so
|
|
429
|
+
* `stripPassthroughPrefix` doesn't mistake that argument for the start of
|
|
430
|
+
* the wrapped command.
|
|
431
|
+
*/
|
|
432
|
+
const WRAPPER_FLAGS_WITH_ARG = new Map([
|
|
433
|
+
["timeout", new Set(["-s", "-k", "--signal", "--kill-after"])],
|
|
434
|
+
["nice", new Set(["-n"])],
|
|
435
|
+
["ionice", new Set(["-c", "-n", "-p"])],
|
|
436
|
+
// policy flags (-b/-f/-i/-o/-r) take a priority; -p takes a target pid.
|
|
437
|
+
["chrt", new Set(["-b", "-f", "-i", "-o", "-r", "-p"])],
|
|
438
|
+
["stdbuf", new Set(["-i", "-o", "-e"])],
|
|
439
|
+
["env", new Set(["-u", "-C", "-S", "--split-string"])],
|
|
440
|
+
["sudo", new Set(["-u", "-g", "-h", "-p", "-C", "-D", "-r", "-t", "-U"])],
|
|
441
|
+
]);
|
|
442
|
+
/**
|
|
443
|
+
* Strips one leading passthrough-wrapper command (e.g. `sudo`, `env FOO=1`)
|
|
444
|
+
* and its own flags, if present, consuming each flag's own separate argument
|
|
445
|
+
* (`WRAPPER_FLAGS_WITH_ARG`) rather than mistaking it for the wrapped
|
|
446
|
+
* command. `timeout DURATION cmd...` additionally skips the required
|
|
447
|
+
* duration positional, which isn't a `-flag` token, so `timeout 5 rm -rf /`
|
|
448
|
+
* unwraps down to `rm -rf /` instead of leaving the bogus `5 rm -rf /`
|
|
449
|
+
* behind.
|
|
450
|
+
*/
|
|
300
451
|
function stripPassthroughPrefix(text) {
|
|
301
452
|
const trimmed = text.replace(/^\s+/, "");
|
|
302
|
-
const
|
|
303
|
-
|
|
453
|
+
const tokens = tokenizeShellWords(trimmed);
|
|
454
|
+
const head = tokens[0];
|
|
455
|
+
if (head === undefined)
|
|
304
456
|
return { stripped: text, changed: false };
|
|
305
|
-
const
|
|
306
|
-
|
|
307
|
-
if (!PASSTHROUGH_PREFIXES.has(basename.toLowerCase()))
|
|
457
|
+
const basename = basenameOfHeadToken(head);
|
|
458
|
+
if (!PASSTHROUGH_PREFIXES.has(basename))
|
|
308
459
|
return { stripped: text, changed: false };
|
|
309
|
-
|
|
460
|
+
const argFlags = WRAPPER_FLAGS_WITH_ARG.get(basename);
|
|
461
|
+
let i = 1;
|
|
462
|
+
while (i < tokens.length) {
|
|
463
|
+
const token = tokens[i];
|
|
464
|
+
if (argFlags?.has(token)) {
|
|
465
|
+
i += 2;
|
|
466
|
+
continue;
|
|
467
|
+
}
|
|
468
|
+
if (/^-/.test(token)) {
|
|
469
|
+
i++;
|
|
470
|
+
continue;
|
|
471
|
+
}
|
|
472
|
+
break;
|
|
473
|
+
}
|
|
474
|
+
if (basename === "timeout" && i < tokens.length)
|
|
475
|
+
i++;
|
|
476
|
+
return { stripped: tokens.slice(i).map(requoteTokenIfNeeded).join(" "), changed: true };
|
|
310
477
|
}
|
|
311
|
-
/**
|
|
312
|
-
function
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
478
|
+
/** Re-wraps a dequoted token in single quotes if it contains whitespace, so rejoining tokens with `" "` doesn't silently merge what was one quoted argument into several unquoted words. */
|
|
479
|
+
function requoteTokenIfNeeded(token) {
|
|
480
|
+
return /\s/.test(token) ? `'${token.replace(/'/g, `'\\''`)}'` : token;
|
|
481
|
+
}
|
|
482
|
+
/**
|
|
483
|
+
* Minimal POSIX-ish shell word tokenizer: splits `text` on unquoted
|
|
484
|
+
* whitespace, honoring single quotes (fully literal, no escapes), double
|
|
485
|
+
* quotes (backslash escapes the next character), and a bare backslash
|
|
486
|
+
* outside quotes (escapes the next character). This is only used to locate
|
|
487
|
+
* wrapper flags and the command-body token that follows them, not to
|
|
488
|
+
* implement real shell grammar (no variable expansion, globbing, etc.).
|
|
489
|
+
*/
|
|
490
|
+
function tokenizeShellWords(text) {
|
|
491
|
+
const tokens = [];
|
|
492
|
+
let current = "";
|
|
493
|
+
let hasCurrent = false;
|
|
494
|
+
let i = 0;
|
|
495
|
+
while (i < text.length) {
|
|
496
|
+
const ch = text[i];
|
|
497
|
+
if (/\s/.test(ch)) {
|
|
498
|
+
if (hasCurrent) {
|
|
499
|
+
tokens.push(current);
|
|
500
|
+
current = "";
|
|
501
|
+
hasCurrent = false;
|
|
502
|
+
}
|
|
503
|
+
i++;
|
|
504
|
+
continue;
|
|
505
|
+
}
|
|
506
|
+
if (ch === "'") {
|
|
507
|
+
hasCurrent = true;
|
|
508
|
+
i++;
|
|
509
|
+
while (i < text.length && text[i] !== "'") {
|
|
510
|
+
current += text[i];
|
|
511
|
+
i++;
|
|
512
|
+
}
|
|
513
|
+
i++;
|
|
514
|
+
continue;
|
|
515
|
+
}
|
|
516
|
+
if (ch === '"') {
|
|
517
|
+
hasCurrent = true;
|
|
518
|
+
i++;
|
|
519
|
+
while (i < text.length && text[i] !== '"') {
|
|
520
|
+
if (text[i] === "\\" && i + 1 < text.length) {
|
|
521
|
+
current += text[i + 1];
|
|
522
|
+
i += 2;
|
|
523
|
+
}
|
|
524
|
+
else {
|
|
525
|
+
current += text[i];
|
|
526
|
+
i++;
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
i++;
|
|
530
|
+
continue;
|
|
531
|
+
}
|
|
532
|
+
if (ch === "\\" && i + 1 < text.length) {
|
|
533
|
+
hasCurrent = true;
|
|
534
|
+
current += text[i + 1];
|
|
535
|
+
i += 2;
|
|
536
|
+
continue;
|
|
537
|
+
}
|
|
538
|
+
hasCurrent = true;
|
|
539
|
+
current += ch;
|
|
540
|
+
i++;
|
|
541
|
+
}
|
|
542
|
+
if (hasCurrent)
|
|
543
|
+
tokens.push(current);
|
|
544
|
+
return tokens;
|
|
545
|
+
}
|
|
546
|
+
/**
|
|
547
|
+
* Lowercased basename of a (possibly quoted/escaped, already-tokenized)
|
|
548
|
+
* command-head token: split on both `/` and `\` (Windows paths), lowercased,
|
|
549
|
+
* with a trailing `.exe` stripped — so `C:\Windows\System32\cmd.EXE`,
|
|
550
|
+
* `./cmd`, and `cmd` all normalize to `cmd` for wrapper/interpreter lookup.
|
|
551
|
+
*/
|
|
552
|
+
function basenameOfHeadToken(token) {
|
|
553
|
+
const parts = token.split(/[/\\]/);
|
|
554
|
+
const base = (parts[parts.length - 1] ?? token).toLowerCase();
|
|
555
|
+
return base.endsWith(".exe") ? base.slice(0, -4) : base;
|
|
556
|
+
}
|
|
557
|
+
/** Shell options that consume the following token as their own argument, not as part of the command. */
|
|
558
|
+
const SHELL_DASH_O_FLAGS = new Set(["-o", "-O", "+o", "+O", "--rcfile", "--init-file"]);
|
|
559
|
+
/**
|
|
560
|
+
* Extracts the command-body token following a `-c` flag from an
|
|
561
|
+
* already-tokenized shell invocation, if `text`'s head is in `wrapperSet` and
|
|
562
|
+
* a `-c` flag (bare or clustered with other short flags, e.g. `-lc`, `-cx`,
|
|
563
|
+
* `-ce`) appears anywhere before the first non-flag token — including after
|
|
564
|
+
* `-o pipefail`, `-O extglob`, `--`, or `-l`. Trailing positional arguments
|
|
565
|
+
* after the body (e.g. `$0` in `bash -c '...' x`) are ignored.
|
|
566
|
+
*/
|
|
567
|
+
function extractShellBodyAfterDashC(text, wrapperSet) {
|
|
568
|
+
const tokens = tokenizeShellWords(text.trim());
|
|
569
|
+
const head = tokens[0];
|
|
570
|
+
if (head === undefined || !wrapperSet.has(basenameOfHeadToken(head)))
|
|
316
571
|
return undefined;
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
572
|
+
let sawDashC = false;
|
|
573
|
+
for (let i = 1; i < tokens.length; i++) {
|
|
574
|
+
const token = tokens[i];
|
|
575
|
+
if (token === "--")
|
|
576
|
+
continue;
|
|
577
|
+
if (SHELL_DASH_O_FLAGS.has(token)) {
|
|
578
|
+
i++;
|
|
579
|
+
continue;
|
|
580
|
+
}
|
|
581
|
+
if (/^-[A-Za-z]+$/.test(token)) {
|
|
582
|
+
if (token.includes("c"))
|
|
583
|
+
sawDashC = true;
|
|
584
|
+
continue;
|
|
585
|
+
}
|
|
586
|
+
// Long (`--norc`, `--login`) and `+` options (`+x`) are flags too; skip them
|
|
587
|
+
// so a later `-c` is still found.
|
|
588
|
+
if (/^(?:--|\+)[A-Za-z][\w-]*$/.test(token))
|
|
589
|
+
continue;
|
|
590
|
+
return sawDashC ? token : undefined;
|
|
591
|
+
}
|
|
592
|
+
return undefined;
|
|
593
|
+
}
|
|
594
|
+
/** Extracts the payload of a `<<< '...'` here-string or a `<<DELIM ... DELIM` heredoc, if present anywhere in `text`. */
|
|
595
|
+
function extractHereStringOrHeredocPayload(text) {
|
|
596
|
+
const hereString = text.match(/<<<\s*(['"]?)([\s\S]*?)\1\s*$/);
|
|
597
|
+
if (hereString)
|
|
598
|
+
return hereString[2];
|
|
599
|
+
const heredoc = text.match(/<<-?\s*(['"]?)([A-Za-z_][A-Za-z0-9_]*)\1[^\n]*\n([\s\S]*?)\n[ \t]*\2\s*$/);
|
|
600
|
+
return heredoc ? heredoc[3] : undefined;
|
|
601
|
+
}
|
|
602
|
+
/** `true` when `text` invokes a known shell with no `-c`, but feeds it a here-string or heredoc body. */
|
|
603
|
+
function feedsBareShellViaHereDocOrString(text) {
|
|
604
|
+
const trimmed = text.trim();
|
|
605
|
+
const tokens = tokenizeShellWords(trimmed);
|
|
606
|
+
const head = tokens[0];
|
|
607
|
+
if (head === undefined || !SHELL_C_WRAPPERS.has(basenameOfHeadToken(head)))
|
|
608
|
+
return false;
|
|
609
|
+
if (extractShellBodyAfterDashC(trimmed, SHELL_C_WRAPPERS) !== undefined)
|
|
610
|
+
return false;
|
|
611
|
+
return /<<<|<</.test(trimmed);
|
|
612
|
+
}
|
|
613
|
+
/** `true` when any `|`-joined segment pipes into a known shell with no `-c` (`echo ... | bash`). */
|
|
614
|
+
function pipedIntoBareShell(segments) {
|
|
615
|
+
return segments.some((seg) => {
|
|
616
|
+
if (seg.operator !== "|")
|
|
617
|
+
return false;
|
|
618
|
+
const trimmed = seg.text.trim();
|
|
619
|
+
const tokens = tokenizeShellWords(trimmed);
|
|
620
|
+
const head = tokens[0];
|
|
621
|
+
if (head === undefined || !SHELL_C_WRAPPERS.has(basenameOfHeadToken(head)))
|
|
622
|
+
return false;
|
|
623
|
+
return extractShellBodyAfterDashC(trimmed, SHELL_C_WRAPPERS) === undefined;
|
|
624
|
+
});
|
|
625
|
+
}
|
|
626
|
+
/**
|
|
627
|
+
* `true` when `command` feeds a bare shell interpreter (`bash`, `sh`, `zsh`,
|
|
628
|
+
* `dash`, `ksh`, `fish`) via a pipe, here-string, or heredoc, with no `-c`
|
|
629
|
+
* flag. The deny scan can extract and check the piped/here-doc text (see
|
|
630
|
+
* `scanDenyCandidates`), but can't prove the absence of danger the way a
|
|
631
|
+
* plain unwrapped command can — so auto mode must never silently allow it.
|
|
632
|
+
*/
|
|
633
|
+
function commandFeedsBareShellWithoutDashC(command) {
|
|
634
|
+
const segments = splitChain(command);
|
|
635
|
+
if (pipedIntoBareShell(segments))
|
|
636
|
+
return true;
|
|
637
|
+
return segments.some((seg) => feedsBareShellViaHereDocOrString(seg.text));
|
|
638
|
+
}
|
|
639
|
+
/**
|
|
640
|
+
* Extracts the inner command line from a `pwsh -c "..."` / `powershell
|
|
641
|
+
* -Command "..."` / `cmd /c "..."` style wrapper, if present. Accepts `-c`,
|
|
642
|
+
* `-Command`, and `/c` case-insensitively, anywhere among the wrapper's
|
|
643
|
+
* tokens, rather than the exact flag each shell prefers — for danger
|
|
644
|
+
* detection, over-matching is the safe direction.
|
|
645
|
+
*/
|
|
646
|
+
function extractOtherShellWrapperArg(text) {
|
|
647
|
+
const trimmed = text.trim();
|
|
648
|
+
if (!headIsOtherShellWrapper(trimmed))
|
|
320
649
|
return undefined;
|
|
321
|
-
|
|
650
|
+
const tokens = tokenizeShellWords(trimmed);
|
|
651
|
+
for (let i = 1; i < tokens.length - 1; i++) {
|
|
652
|
+
const token = tokens[i].toLowerCase();
|
|
653
|
+
if (token === "-c" || token === "-command" || token === "/c")
|
|
654
|
+
return tokens[i + 1];
|
|
655
|
+
}
|
|
656
|
+
return undefined;
|
|
322
657
|
}
|
|
323
|
-
/**
|
|
658
|
+
/**
|
|
659
|
+
* Extracts the inner command line from an `eval "..."` / `eval '...'` /
|
|
660
|
+
* `eval <unquoted words...>` wrapper, if present — bash's `eval` joins all of
|
|
661
|
+
* its arguments with spaces and evaluates the result as a command, whether or
|
|
662
|
+
* not they were quoted.
|
|
663
|
+
*/
|
|
324
664
|
function extractEvalArg(text) {
|
|
325
|
-
const
|
|
326
|
-
|
|
665
|
+
const trimmed = text.trim();
|
|
666
|
+
const quoted = trimmed.match(/^eval\s+(['"])([\s\S]*)\1\s*$/i);
|
|
667
|
+
if (quoted)
|
|
668
|
+
return quoted[2];
|
|
669
|
+
const unquoted = trimmed.match(/^eval\s+(\S[\s\S]*)$/i);
|
|
670
|
+
return unquoted ? unquoted[1] : undefined;
|
|
327
671
|
}
|
|
328
672
|
/** Extracts the contents of every `$(...)` and `` `...` `` command substitution found anywhere in `text`. */
|
|
329
673
|
function extractSubstitutions(text) {
|
|
@@ -360,7 +704,11 @@ function extractSubstitutions(text) {
|
|
|
360
704
|
*/
|
|
361
705
|
function extractSimpleEchoOutput(text) {
|
|
362
706
|
const match = text.match(/^\s*echo\s+([^$`]+?)\s*$/i);
|
|
363
|
-
|
|
707
|
+
if (!match)
|
|
708
|
+
return undefined;
|
|
709
|
+
const captured = match[1];
|
|
710
|
+
const quoted = captured.match(/^(['"])([\s\S]*)\1$/);
|
|
711
|
+
return quoted ? quoted[2] : captured;
|
|
364
712
|
}
|
|
365
713
|
const MAX_DENY_CANDIDATES = 50;
|
|
366
714
|
const MAX_DENY_DEPTH = 4;
|
|
@@ -370,11 +718,20 @@ const MAX_DENY_DEPTH = 4;
|
|
|
370
718
|
* segment, prefix/wrapper-stripped variants of each segment, and the bodies
|
|
371
719
|
* of any `bash -c` / `eval` / `$(...)` / backtick constructs — recursively,
|
|
372
720
|
* bounded so adversarial input can't cause unbounded work.
|
|
721
|
+
*
|
|
722
|
+
* The bound is itself a fail-safe surface: a command with more pieces or
|
|
723
|
+
* wrapper layers than the cap allows must not be treated as "scanned clean".
|
|
724
|
+
* `truncated` on the result flags exactly that case.
|
|
373
725
|
*/
|
|
374
|
-
function
|
|
726
|
+
function scanDenyCandidates(command) {
|
|
375
727
|
const seen = new Set();
|
|
376
728
|
const queue = [{ text: command, depth: 0 }];
|
|
377
|
-
|
|
729
|
+
let truncated = false;
|
|
730
|
+
while (queue.length > 0) {
|
|
731
|
+
if (seen.size >= MAX_DENY_CANDIDATES) {
|
|
732
|
+
truncated = true;
|
|
733
|
+
break;
|
|
734
|
+
}
|
|
378
735
|
const next = queue.shift();
|
|
379
736
|
if (!next)
|
|
380
737
|
break;
|
|
@@ -382,20 +739,38 @@ function collectDenyCandidates(command) {
|
|
|
382
739
|
if (seen.has(text))
|
|
383
740
|
continue;
|
|
384
741
|
seen.add(text);
|
|
385
|
-
if (depth >= MAX_DENY_DEPTH)
|
|
742
|
+
if (depth >= MAX_DENY_DEPTH) {
|
|
743
|
+
truncated = true;
|
|
386
744
|
continue;
|
|
745
|
+
}
|
|
387
746
|
const enqueue = (candidate) => {
|
|
388
|
-
if (
|
|
389
|
-
|
|
747
|
+
if (seen.has(candidate))
|
|
748
|
+
return;
|
|
749
|
+
if (seen.size + queue.length >= MAX_DENY_CANDIDATES) {
|
|
750
|
+
truncated = true;
|
|
751
|
+
return;
|
|
390
752
|
}
|
|
753
|
+
queue.push({ text: candidate, depth: depth + 1 });
|
|
391
754
|
};
|
|
392
|
-
const
|
|
755
|
+
const segmentObjs = splitChain(text);
|
|
756
|
+
const segments = segmentObjs.map((s) => s.text);
|
|
393
757
|
const pieces = segments.length > 1 ? segments : [text];
|
|
394
758
|
for (const seg of segments)
|
|
395
759
|
enqueue(seg);
|
|
760
|
+
for (let i = 0; i < segmentObjs.length; i++) {
|
|
761
|
+
if (segmentObjs[i].operator !== "|")
|
|
762
|
+
continue;
|
|
763
|
+
const prevText = segmentObjs[i - 1]?.text;
|
|
764
|
+
if (prevText === undefined)
|
|
765
|
+
continue;
|
|
766
|
+
const echoOutput = extractSimpleEchoOutput(prevText);
|
|
767
|
+
if (echoOutput !== undefined)
|
|
768
|
+
enqueue(echoOutput);
|
|
769
|
+
}
|
|
396
770
|
for (const piece of pieces) {
|
|
397
771
|
let working = stripLeadingBackslashEscape(piece);
|
|
398
772
|
working = stripEnvAssignments(working);
|
|
773
|
+
const beforeWrapperStrip = working;
|
|
399
774
|
for (let guard = 0; guard < 5; guard++) {
|
|
400
775
|
const { stripped, changed } = stripPassthroughPrefix(working);
|
|
401
776
|
if (!changed)
|
|
@@ -405,12 +780,25 @@ function collectDenyCandidates(command) {
|
|
|
405
780
|
enqueue(working);
|
|
406
781
|
const basenameResolved = resolveBasenameOfFirstToken(working);
|
|
407
782
|
enqueue(basenameResolved);
|
|
408
|
-
const shellC =
|
|
783
|
+
const shellC = extractShellBodyAfterDashC(working, SHELL_C_WRAPPERS) ??
|
|
784
|
+
extractShellBodyAfterDashC(basenameResolved, SHELL_C_WRAPPERS);
|
|
409
785
|
if (shellC !== undefined)
|
|
410
786
|
enqueue(shellC);
|
|
787
|
+
const hereRedirect = extractHereStringOrHeredocPayload(piece);
|
|
788
|
+
if (hereRedirect !== undefined)
|
|
789
|
+
enqueue(hereRedirect);
|
|
790
|
+
const otherShellArg = extractOtherShellWrapperArg(working) ?? extractOtherShellWrapperArg(basenameResolved);
|
|
791
|
+
if (otherShellArg !== undefined)
|
|
792
|
+
enqueue(otherShellArg);
|
|
411
793
|
const evalArg = extractEvalArg(working) ?? extractEvalArg(basenameResolved);
|
|
412
794
|
if (evalArg !== undefined)
|
|
413
795
|
enqueue(evalArg);
|
|
796
|
+
const findExecArg = extractFindExecArg(working) ?? extractFindExecArg(basenameResolved);
|
|
797
|
+
if (findExecArg !== undefined)
|
|
798
|
+
enqueue(findExecArg);
|
|
799
|
+
const envSplitStringArg = extractEnvSplitStringArg(beforeWrapperStrip);
|
|
800
|
+
if (envSplitStringArg !== undefined)
|
|
801
|
+
enqueue(envSplitStringArg);
|
|
414
802
|
for (const sub of extractSubstitutions(piece)) {
|
|
415
803
|
enqueue(sub);
|
|
416
804
|
const echoOutput = extractSimpleEchoOutput(sub);
|
|
@@ -419,7 +807,111 @@ function collectDenyCandidates(command) {
|
|
|
419
807
|
}
|
|
420
808
|
}
|
|
421
809
|
}
|
|
422
|
-
return [...seen];
|
|
810
|
+
return { candidates: [...seen], truncated };
|
|
811
|
+
}
|
|
812
|
+
/** Candidate list only, for callers that don't need the truncation flag. */
|
|
813
|
+
function collectDenyCandidates(command) {
|
|
814
|
+
return scanDenyCandidates(command).candidates;
|
|
815
|
+
}
|
|
816
|
+
/**
|
|
817
|
+
* `true` when `command` has more chained pieces or wrapper layers than
|
|
818
|
+
* `scanDenyCandidates` could fully enumerate. A truncated scan can never be
|
|
819
|
+
* trusted to say "no deny/danger match" — the unscanned remainder might hide
|
|
820
|
+
* one — so callers must fail closed (deny or require approval) rather than
|
|
821
|
+
* fall through to an auto-allow default.
|
|
822
|
+
*/
|
|
823
|
+
function commandDenyScanTruncated(command) {
|
|
824
|
+
return scanDenyCandidates(command).truncated;
|
|
825
|
+
}
|
|
826
|
+
/**
|
|
827
|
+
* Raw first whitespace-delimited token of `text`, with at most one matching
|
|
828
|
+
* pair of surrounding quotes stripped — deliberately *not* run through
|
|
829
|
+
* `tokenizeShellWords`'s backslash-escape collapsing, so a literal Windows
|
|
830
|
+
* path separator (`C:\Windows\System32\cmd.exe`) survives for
|
|
831
|
+
* `basenameOfHeadToken` to split on, instead of being eaten as a POSIX
|
|
832
|
+
* shell escape character.
|
|
833
|
+
*/
|
|
834
|
+
function rawFirstToken(text) {
|
|
835
|
+
const token = text.trimStart().match(/^\S+/)?.[0];
|
|
836
|
+
if (token === undefined)
|
|
837
|
+
return undefined;
|
|
838
|
+
const quoted = token.match(/^(['"])([\s\S]*)\1$/);
|
|
839
|
+
return quoted ? quoted[2] : token;
|
|
840
|
+
}
|
|
841
|
+
/**
|
|
842
|
+
* `true` when `basename(head(text))` is a recognized `pwsh`/`powershell`/
|
|
843
|
+
* `cmd` spelling, checking both the POSIX-escape-aware token (`p\wsh` ->
|
|
844
|
+
* `pwsh`) and the raw token (`C:\Windows\...\cmd.exe` -> `cmd`), since the
|
|
845
|
+
* two normalizations disagree on what a bare `\` means.
|
|
846
|
+
*/
|
|
847
|
+
function headIsOtherShellWrapper(text) {
|
|
848
|
+
const dequotedHead = tokenizeShellWords(text.trimStart())[0];
|
|
849
|
+
if (dequotedHead !== undefined && isOtherShellWrapperName(basenameOfHeadToken(dequotedHead)))
|
|
850
|
+
return true;
|
|
851
|
+
const raw = rawFirstToken(text);
|
|
852
|
+
return raw !== undefined && isOtherShellWrapperName(basenameOfHeadToken(raw));
|
|
853
|
+
}
|
|
854
|
+
/**
|
|
855
|
+
* `true` when `command` (bash tool) invokes `pwsh`/`powershell`/`cmd` at any
|
|
856
|
+
* unwrapped layer, e.g. `pwsh -c "Remove-Item -Recurse ~"` or
|
|
857
|
+
* `bash -c "cmd /c del ..."`. Auto mode's danger filter
|
|
858
|
+
* (`DANGEROUS_COMMAND_PATTERNS`) is bash-shaped and has no coverage for these
|
|
859
|
+
* interpreters' own syntax, the same reason unmatched `powershell` tool calls
|
|
860
|
+
* always require approval — so a bash-tool call that merely shells out to one
|
|
861
|
+
* of them must not get a free pass auto mode never meant to give it.
|
|
862
|
+
*/
|
|
863
|
+
function commandInvokesOtherShell(command) {
|
|
864
|
+
return collectDenyCandidates(command).some((candidate) => headIsOtherShellWrapper(candidate));
|
|
865
|
+
}
|
|
866
|
+
/** A shell variable/parameter expansion, command substitution, or backtick substitution in command position. */
|
|
867
|
+
function isDynamicCommandHead(token) {
|
|
868
|
+
return /^(\$\(|\$\{|\$[A-Za-z_]|`)/.test(token);
|
|
869
|
+
}
|
|
870
|
+
/**
|
|
871
|
+
* `true` when any chain segment's command position (after stripping leading
|
|
872
|
+
* `VAR=val` assignments) is a variable/expansion rather than a literal
|
|
873
|
+
* command name (`$p`, `${HOME:+pwsh}`, `$(...)`, a backtick substitution).
|
|
874
|
+
* What actually runs then depends on the environment, so no pattern — deny,
|
|
875
|
+
* danger filter, or interpreter check — can reason about it; auto mode must
|
|
876
|
+
* require approval instead of silently resolving to whatever the variable
|
|
877
|
+
* happens to hold.
|
|
878
|
+
*/
|
|
879
|
+
function commandHeadIsDynamic(command) {
|
|
880
|
+
return splitChain(command).some((seg) => {
|
|
881
|
+
const working = stripEnvAssignments(stripLeadingBackslashEscape(seg.text));
|
|
882
|
+
const head = tokenizeShellWords(working.trim())[0];
|
|
883
|
+
return head !== undefined && isDynamicCommandHead(head);
|
|
884
|
+
});
|
|
885
|
+
}
|
|
886
|
+
/** Extracts the `<cmd>` from `find ... -exec <cmd> ... ;`/`+`/`-execdir <cmd> ... ;`, if present. */
|
|
887
|
+
function extractFindExecArg(text) {
|
|
888
|
+
const tokens = tokenizeShellWords(text.trim());
|
|
889
|
+
const head = tokens[0];
|
|
890
|
+
if (head === undefined || basenameOfHeadToken(head) !== "find")
|
|
891
|
+
return undefined;
|
|
892
|
+
const execIndex = tokens.findIndex((token) => token === "-exec" || token === "-execdir");
|
|
893
|
+
if (execIndex === -1)
|
|
894
|
+
return undefined;
|
|
895
|
+
const cmdTokens = [];
|
|
896
|
+
for (let i = execIndex + 1; i < tokens.length; i++) {
|
|
897
|
+
const token = tokens[i];
|
|
898
|
+
if (token === ";" || token === "+")
|
|
899
|
+
break;
|
|
900
|
+
cmdTokens.push(token);
|
|
901
|
+
}
|
|
902
|
+
return cmdTokens.length > 0 ? cmdTokens.join(" ") : undefined;
|
|
903
|
+
}
|
|
904
|
+
/** Extracts `env -S '<cmd>'` / `env --split-string '<cmd>'`'s argument, which `env` itself parses as a command line. */
|
|
905
|
+
function extractEnvSplitStringArg(text) {
|
|
906
|
+
const tokens = tokenizeShellWords(text.trim());
|
|
907
|
+
const head = tokens[0];
|
|
908
|
+
if (head === undefined || basenameOfHeadToken(head) !== "env")
|
|
909
|
+
return undefined;
|
|
910
|
+
for (let i = 1; i < tokens.length; i++) {
|
|
911
|
+
if (tokens[i] === "-S" || tokens[i] === "--split-string")
|
|
912
|
+
return tokens[i + 1];
|
|
913
|
+
}
|
|
914
|
+
return undefined;
|
|
423
915
|
}
|
|
424
916
|
function globToRegExp(pattern) {
|
|
425
917
|
let source = "";
|
|
@@ -434,8 +926,14 @@ function globToRegExp(pattern) {
|
|
|
434
926
|
return new RegExp(`^${source}$`, "is");
|
|
435
927
|
}
|
|
436
928
|
function matchDenyPattern(command, pattern) {
|
|
929
|
+
const candidates = collectDenyCandidates(command);
|
|
930
|
+
const flagPattern = parseFlagClusterPattern(pattern);
|
|
931
|
+
if (flagPattern !== undefined &&
|
|
932
|
+
candidates.some((candidate) => flagClusterPatternMatchesCandidate(flagPattern, candidate))) {
|
|
933
|
+
return true;
|
|
934
|
+
}
|
|
437
935
|
const regex = globToRegExp(normalizeForMatch(pattern));
|
|
438
|
-
return
|
|
936
|
+
return candidates.some((candidate) => regex.test(normalizeForMatch(candidate)));
|
|
439
937
|
}
|
|
440
938
|
/**
|
|
441
939
|
* Strictly matches `command` against an `allow`/`approve` `pattern`: any
|
|
@@ -573,8 +1071,23 @@ function describeMatch(rule) {
|
|
|
573
1071
|
parts.push(`paths=${JSON.stringify(rule.paths)}`);
|
|
574
1072
|
return `matched rule (${parts.join(", ")}) -> ${rule.action}`;
|
|
575
1073
|
}
|
|
1074
|
+
/**
|
|
1075
|
+
* A `tool: bash` rule's `pattern` is authored against bash command shapes, so
|
|
1076
|
+
* only its `deny` half is safe to reuse for `powershell` calls: a bash `deny`
|
|
1077
|
+
* over-matching onto a powershell command is the fail-safe direction, while a
|
|
1078
|
+
* bash `allow`/`approve` pattern (e.g. `ls *`) under-matching real
|
|
1079
|
+
* powershell syntax would otherwise create the illusion of coverage without
|
|
1080
|
+
* actually vetting powershell-specific danger. `tool: powershell` rules
|
|
1081
|
+
* (and `tool: "*"`) are unaffected and keep matching normally.
|
|
1082
|
+
*/
|
|
1083
|
+
function bashDenyRuleAppliesToPowershell(rule, toolName) {
|
|
1084
|
+
return toolName === "powershell" && rule.tool.toLowerCase() === "bash" && rule.action === "deny";
|
|
1085
|
+
}
|
|
1086
|
+
function toolMatchesRule(rule, toolName) {
|
|
1087
|
+
return rule.tool === "*" || rule.tool.toLowerCase() === toolName || bashDenyRuleAppliesToPowershell(rule, toolName);
|
|
1088
|
+
}
|
|
576
1089
|
function ruleMatches(rule, toolName, args, cwd) {
|
|
577
|
-
if (rule
|
|
1090
|
+
if (!toolMatchesRule(rule, toolName))
|
|
578
1091
|
return false;
|
|
579
1092
|
if (rule.pattern !== undefined) {
|
|
580
1093
|
const command = getCommandArg(args);
|
|
@@ -596,6 +1109,9 @@ function ruleMatches(rule, toolName, args, cwd) {
|
|
|
596
1109
|
* returning a `deny` / `allow` / `approve` decision.
|
|
597
1110
|
*/
|
|
598
1111
|
export class PermissionGate {
|
|
1112
|
+
rules;
|
|
1113
|
+
cwd;
|
|
1114
|
+
mode;
|
|
599
1115
|
constructor(rules = [], options = {}) {
|
|
600
1116
|
this.rules = rules;
|
|
601
1117
|
this.cwd = options.cwd ?? process.cwd();
|
|
@@ -604,6 +1120,18 @@ export class PermissionGate {
|
|
|
604
1120
|
/** Evaluate a tool call. `args` should carry `command` for bash, or `path`/`file_path` for read/write/edit. */
|
|
605
1121
|
evaluate(toolName, args = {}) {
|
|
606
1122
|
const normalizedTool = toolName.toLowerCase();
|
|
1123
|
+
if (normalizedTool === "bash" || normalizedTool === "powershell") {
|
|
1124
|
+
const command = getCommandArg(args);
|
|
1125
|
+
if (command !== undefined && commandDenyScanTruncated(command)) {
|
|
1126
|
+
const denyRuleApplies = this.rules.some((rule) => rule.action === "deny" && toolMatchesRule(rule, normalizedTool));
|
|
1127
|
+
if (denyRuleApplies) {
|
|
1128
|
+
return {
|
|
1129
|
+
action: "deny",
|
|
1130
|
+
reason: "command has more chained/wrapped pieces than the deny scan can fully cover, and a deny rule applies to this tool; failing closed rather than risk missing a match",
|
|
1131
|
+
};
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
607
1135
|
for (const rule of this.rules) {
|
|
608
1136
|
if (ruleMatches(rule, normalizedTool, args, this.cwd)) {
|
|
609
1137
|
return this.applyMode({ action: rule.action, reason: describeMatch(rule) });
|
|
@@ -629,7 +1157,10 @@ export class PermissionGate {
|
|
|
629
1157
|
if (this.mode === "auto") {
|
|
630
1158
|
const command = getCommandArg(args);
|
|
631
1159
|
if (command === undefined) {
|
|
632
|
-
return {
|
|
1160
|
+
return {
|
|
1161
|
+
action: "approve",
|
|
1162
|
+
reason: "auto mode: bash call without a command string requires approval",
|
|
1163
|
+
};
|
|
633
1164
|
}
|
|
634
1165
|
const dangerous = findDangerousPattern(command);
|
|
635
1166
|
if (dangerous !== undefined) {
|
|
@@ -638,10 +1169,42 @@ export class PermissionGate {
|
|
|
638
1169
|
reason: `auto mode: command matched dangerous pattern ${JSON.stringify(dangerous)}, requires approval`,
|
|
639
1170
|
};
|
|
640
1171
|
}
|
|
1172
|
+
if (commandHeadIsDynamic(command)) {
|
|
1173
|
+
return {
|
|
1174
|
+
action: "approve",
|
|
1175
|
+
reason: "auto mode: command position is a variable/parameter expansion, command substitution, or backtick substitution, which can resolve to anything; requires approval",
|
|
1176
|
+
};
|
|
1177
|
+
}
|
|
1178
|
+
if (commandInvokesOtherShell(command)) {
|
|
1179
|
+
return {
|
|
1180
|
+
action: "approve",
|
|
1181
|
+
reason: "auto mode: command invokes a pwsh/powershell/cmd interpreter, which the bash-shaped danger filter has no coverage for; requires approval, same as the powershell tool",
|
|
1182
|
+
};
|
|
1183
|
+
}
|
|
1184
|
+
if (commandDenyScanTruncated(command)) {
|
|
1185
|
+
return {
|
|
1186
|
+
action: "approve",
|
|
1187
|
+
reason: "auto mode: command has more chained/wrapped pieces than the deny scan can fully cover, requires approval",
|
|
1188
|
+
};
|
|
1189
|
+
}
|
|
1190
|
+
if (commandFeedsBareShellWithoutDashC(command)) {
|
|
1191
|
+
return {
|
|
1192
|
+
action: "approve",
|
|
1193
|
+
reason: "auto mode: command feeds a bare shell interpreter via pipe/here-string/heredoc with no -c, which the deny scan can't fully vet; requires approval",
|
|
1194
|
+
};
|
|
1195
|
+
}
|
|
641
1196
|
return { action: "allow", reason: "auto mode: no rule matched and command passed the danger filter" };
|
|
642
1197
|
}
|
|
643
1198
|
return { action: "approve", reason: "no rule matched; bash commands require approval by default" };
|
|
644
1199
|
}
|
|
1200
|
+
if (toolName === "powershell") {
|
|
1201
|
+
// Unlike bash, powershell has no danger filter tuned for its own
|
|
1202
|
+
// syntax (DANGEROUS_COMMAND_PATTERNS is bash-shaped), so auto mode
|
|
1203
|
+
// cannot safely auto-allow it — every unmatched powershell call
|
|
1204
|
+
// requires approval in default and auto mode (yolo's applyMode still
|
|
1205
|
+
// turns this approve into allow, as for every tool).
|
|
1206
|
+
return { action: "approve", reason: "no rule matched; powershell commands always require approval" };
|
|
1207
|
+
}
|
|
645
1208
|
if (PATH_SCOPED_TOOLS.has(toolName)) {
|
|
646
1209
|
const filePath = getPathArg(args);
|
|
647
1210
|
if (filePath !== undefined && isWithinProject(filePath, this.cwd)) {
|