@diffra-ai/cli 0.1.1 → 0.1.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 +38 -0
- package/dist/bundle/chunks/{anthropic-messages-M3HXJPTI.js → anthropic-messages-5EMOURYI.js} +1 -1
- package/dist/bundle/chunks/{azure-openai-responses-GIFO2563.js → azure-openai-responses-N67KWG2X.js} +1 -1
- package/dist/bundle/chunks/bedrock-converse-stream.js +1 -1
- package/dist/bundle/chunks/{chunk-CVEPACZO.js → chunk-3UNTEQ65.js} +1 -1
- package/dist/bundle/chunks/{chunk-VJQ6ZYW4.js → chunk-4NMBWIZG.js} +5 -5
- package/dist/bundle/chunks/{chunk-INTHKDF2.js → chunk-65DC2T66.js} +1 -1
- package/dist/bundle/chunks/chunk-6ZD23B2R.js +2 -0
- package/dist/bundle/chunks/{chunk-WEJVQTLI.js → chunk-BF423NQ7.js} +1 -1
- package/dist/bundle/chunks/{chunk-262RLABF.js → chunk-CES65UJH.js} +1 -1
- package/dist/bundle/chunks/{chunk-RJRIMI6M.js → chunk-GRYHVZSI.js} +1 -1
- package/dist/bundle/chunks/{chunk-WAH3PGZX.js → chunk-HFTZ6OJJ.js} +2 -2
- package/dist/bundle/chunks/{chunk-N6Q2WLPG.js → chunk-NEFH2K3C.js} +1 -1
- package/dist/bundle/chunks/{chunk-OQFRYL4U.js → chunk-PISJX26Y.js} +1 -1
- package/dist/bundle/chunks/{chunk-VSFRR6IC.js → chunk-QQ6NVGNW.js} +1 -1
- package/dist/bundle/chunks/{chunk-N6QWAQ6I.js → chunk-QYYUGS66.js} +1 -1
- package/dist/bundle/chunks/{chunk-GT3WTHFU.js → chunk-RLMZZV4Q.js} +1 -1
- package/dist/bundle/chunks/chunk-RTPG7C5I.js +2003 -0
- package/dist/bundle/chunks/{chunk-6S2AQWGR.js → chunk-SI7T4LPD.js} +4 -4
- package/dist/bundle/chunks/{chunk-CCH74R6M.js → chunk-VOKUVFV4.js} +1 -1
- package/dist/bundle/chunks/{chunk-OOE7BGUD.js → chunk-VWWMBH3G.js} +1 -1
- package/dist/bundle/chunks/{chunk-B3FUE2LF.js → chunk-XAA355T2.js} +1 -1
- package/dist/bundle/chunks/{cli-EC3ZETTA.js → cli-55VO5MAJ.js} +1 -1
- package/dist/bundle/chunks/{cloudflare-workers-ai-system-one-YW7YYPAC.js → cloudflare-workers-ai-system-one-HB5U67WC.js} +1 -1
- package/dist/bundle/chunks/{easter-egg-3d-QN5RJMZR.js → easter-egg-3d-VAZ2JWDP.js} +1 -1
- package/dist/bundle/chunks/{execute-3J63CQJG.js → execute-OEFRHFHI.js} +1 -1
- package/dist/bundle/chunks/{google-generative-ai-F6DN2LQU.js → google-generative-ai-XRHE7R52.js} +1 -1
- package/dist/bundle/chunks/{google-vertex-MDWFDVAW.js → google-vertex-75CQOPKC.js} +1 -1
- package/dist/bundle/chunks/{llama-cpp-classify-XO72TVVH.js → llama-cpp-classify-LKIRB7ZR.js} +1 -1
- package/dist/bundle/chunks/{mistral-conversations-KYVGR5VN.js → mistral-conversations-KLGIHK73.js} +1 -1
- package/dist/bundle/chunks/{openai-codex-responses-SIQN5LUE.js → openai-codex-responses-7L5VV67U.js} +1 -1
- package/dist/bundle/chunks/{openai-completions-B22DYT4F.js → openai-completions-RBF6UXDW.js} +1 -1
- package/dist/bundle/chunks/{openai-decisions-4GVNTR54.js → openai-decisions-W3PJQIOF.js} +1 -1
- package/dist/bundle/chunks/{openai-responses-5DVNSQCE.js → openai-responses-W5ZMLOTR.js} +1 -1
- package/dist/bundle/chunks/{openrouter-images-SQMQNKJU.js → openrouter-images-4FW6VFV4.js} +1 -1
- package/dist/bundle/chunks/{pi-messages-GZ4HZRKJ.js → pi-messages-RT7FVQ4G.js} +1 -1
- package/dist/bundle/chunks/{runtime-KEVIZBAR.js → runtime-SI4R3AXJ.js} +1 -1
- package/dist/bundle/chunks/{typesafe-system-one-GMPGMPLA.js → typesafe-system-one-DSJ7OYVL.js} +1 -1
- package/dist/bundle/chunks/virtual-modules-M75O3ECA.js +2 -0
- package/dist/bundle/cli-runtime.js +1 -1
- package/dist/bundle/index.js +1 -1
- package/dist/bundle/rpc-entry.js +1 -1
- package/dist/cli/args.d.ts +2 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +13 -0
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/sandbox-command.d.ts +8 -0
- package/dist/cli/sandbox-command.d.ts.map +1 -0
- package/dist/cli/sandbox-command.js +52 -0
- package/dist/cli/sandbox-command.js.map +1 -0
- package/dist/config.d.ts +7 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +14 -0
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session.d.ts +20 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +72 -2
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/approval-mode.d.ts +28 -0
- package/dist/core/approval-mode.d.ts.map +1 -0
- package/dist/core/approval-mode.js +34 -0
- package/dist/core/approval-mode.js.map +1 -0
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +15 -0
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +3 -0
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +30 -3
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/fast-model.d.ts +10 -0
- package/dist/core/fast-model.d.ts.map +1 -0
- package/dist/core/fast-model.js +13 -0
- package/dist/core/fast-model.js.map +1 -0
- package/dist/core/keybindings.d.ts +8 -0
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +4 -0
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/sandbox/escalation.d.ts +32 -0
- package/dist/core/sandbox/escalation.d.ts.map +1 -0
- package/dist/core/sandbox/escalation.js +70 -0
- package/dist/core/sandbox/escalation.js.map +1 -0
- package/dist/core/sandbox/launch.d.ts +14 -0
- package/dist/core/sandbox/launch.d.ts.map +1 -0
- package/dist/core/sandbox/launch.js +18 -0
- package/dist/core/sandbox/launch.js.map +1 -0
- package/dist/core/sandbox/policy.d.ts +50 -0
- package/dist/core/sandbox/policy.d.ts.map +1 -0
- package/dist/core/sandbox/policy.js +96 -0
- package/dist/core/sandbox/policy.js.map +1 -0
- package/dist/core/sandbox/seatbelt.d.ts +17 -0
- package/dist/core/sandbox/seatbelt.d.ts.map +1 -0
- package/dist/core/sandbox/seatbelt.js +169 -0
- package/dist/core/sandbox/seatbelt.js.map +1 -0
- package/dist/core/sandbox/windows.d.ts +30 -0
- package/dist/core/sandbox/windows.d.ts.map +1 -0
- package/dist/core/sandbox/windows.js +104 -0
- package/dist/core/sandbox/windows.js.map +1 -0
- package/dist/core/settings-defaults.d.ts +28 -0
- package/dist/core/settings-defaults.d.ts.map +1 -1
- package/dist/core/settings-defaults.js +28 -0
- package/dist/core/settings-defaults.js.map +1 -1
- package/dist/core/settings-manager.d.ts +9 -1
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +58 -1
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/settings-schema.d.ts +124 -0
- package/dist/core/settings-schema.d.ts.map +1 -1
- package/dist/core/settings-schema.js +177 -0
- package/dist/core/settings-schema.js.map +1 -1
- package/dist/core/tools/bash.d.ts +12 -2
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +27 -7
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit.d.ts +3 -0
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +2 -0
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/powershell.d.ts +3 -2
- package/dist/core/tools/powershell.d.ts.map +1 -1
- package/dist/core/tools/powershell.js +4 -6
- package/dist/core/tools/powershell.js.map +1 -1
- package/dist/core/tools/render-utils.d.ts +2 -2
- package/dist/core/tools/render-utils.js +5 -5
- package/dist/core/tools/render-utils.js.map +1 -1
- package/dist/core/tools/renderers/edit.d.ts.map +1 -1
- package/dist/core/tools/renderers/edit.js +16 -19
- package/dist/core/tools/renderers/edit.js.map +1 -1
- package/dist/core/tools/write.d.ts +3 -0
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +2 -0
- package/dist/core/tools/write.js.map +1 -1
- package/dist/extensions/agents/agent-tool.d.ts +61 -0
- package/dist/extensions/agents/agent-tool.d.ts.map +1 -0
- package/dist/extensions/agents/agent-tool.js +277 -0
- package/dist/extensions/agents/agent-tool.js.map +1 -0
- package/dist/extensions/agents/background.d.ts +56 -0
- package/dist/extensions/agents/background.d.ts.map +1 -0
- package/dist/extensions/agents/background.js +142 -0
- package/dist/extensions/agents/background.js.map +1 -0
- package/dist/extensions/agents/builtin-agents.d.ts +8 -0
- package/dist/extensions/agents/builtin-agents.d.ts.map +1 -0
- package/dist/extensions/agents/builtin-agents.js +38 -0
- package/dist/extensions/agents/builtin-agents.js.map +1 -0
- package/dist/extensions/agents/call-scopes.d.ts +34 -0
- package/dist/extensions/agents/call-scopes.d.ts.map +1 -0
- package/dist/extensions/agents/call-scopes.js +36 -0
- package/dist/extensions/agents/call-scopes.js.map +1 -0
- package/dist/extensions/agents/definitions.d.ts +64 -0
- package/dist/extensions/agents/definitions.d.ts.map +1 -0
- package/dist/extensions/agents/definitions.js +216 -0
- package/dist/extensions/agents/definitions.js.map +1 -0
- package/dist/extensions/agents/index.d.ts +15 -0
- package/dist/extensions/agents/index.d.ts.map +1 -0
- package/dist/extensions/agents/index.js +327 -0
- package/dist/extensions/agents/index.js.map +1 -0
- package/dist/extensions/agents/runner.d.ts +63 -0
- package/dist/extensions/agents/runner.d.ts.map +1 -0
- package/dist/extensions/agents/runner.js +156 -0
- package/dist/extensions/agents/runner.js.map +1 -0
- package/dist/extensions/approval/auto-classifier.d.ts +32 -0
- package/dist/extensions/approval/auto-classifier.d.ts.map +1 -0
- package/dist/extensions/approval/auto-classifier.js +116 -0
- package/dist/extensions/approval/auto-classifier.js.map +1 -0
- package/dist/extensions/approval/exit-plan-mode.d.ts +24 -0
- package/dist/extensions/approval/exit-plan-mode.d.ts.map +1 -0
- package/dist/extensions/approval/exit-plan-mode.js +99 -0
- package/dist/extensions/approval/exit-plan-mode.js.map +1 -0
- package/dist/extensions/approval/index.d.ts +15 -0
- package/dist/extensions/approval/index.d.ts.map +1 -0
- package/dist/extensions/approval/index.js +329 -0
- package/dist/extensions/approval/index.js.map +1 -0
- package/dist/extensions/approval/plan-reminders.d.ts +9 -0
- package/dist/extensions/approval/plan-reminders.d.ts.map +1 -0
- package/dist/extensions/approval/plan-reminders.js +42 -0
- package/dist/extensions/approval/plan-reminders.js.map +1 -0
- package/dist/extensions/approval/policy.d.ts +52 -0
- package/dist/extensions/approval/policy.d.ts.map +1 -0
- package/dist/extensions/approval/policy.js +124 -0
- package/dist/extensions/approval/policy.js.map +1 -0
- package/dist/extensions/approval/shell-safety.d.ts +11 -0
- package/dist/extensions/approval/shell-safety.d.ts.map +1 -0
- package/dist/extensions/approval/shell-safety.js +264 -0
- package/dist/extensions/approval/shell-safety.js.map +1 -0
- package/dist/extensions/cron/cron-expression.d.ts +30 -0
- package/dist/extensions/cron/cron-expression.d.ts.map +1 -0
- package/dist/extensions/cron/cron-expression.js +119 -0
- package/dist/extensions/cron/cron-expression.js.map +1 -0
- package/dist/extensions/cron/index.d.ts +19 -0
- package/dist/extensions/cron/index.d.ts.map +1 -0
- package/dist/extensions/cron/index.js +215 -0
- package/dist/extensions/cron/index.js.map +1 -0
- package/dist/extensions/cron/loop-args.d.ts +35 -0
- package/dist/extensions/cron/loop-args.d.ts.map +1 -0
- package/dist/extensions/cron/loop-args.js +95 -0
- package/dist/extensions/cron/loop-args.js.map +1 -0
- package/dist/extensions/cron/loop-texts.d.ts +29 -0
- package/dist/extensions/cron/loop-texts.d.ts.map +1 -0
- package/dist/extensions/cron/loop-texts.js +83 -0
- package/dist/extensions/cron/loop-texts.js.map +1 -0
- package/dist/extensions/cron/scheduler.d.ts +79 -0
- package/dist/extensions/cron/scheduler.d.ts.map +1 -0
- package/dist/extensions/cron/scheduler.js +146 -0
- package/dist/extensions/cron/scheduler.js.map +1 -0
- package/dist/extensions/cron/tools.d.ts +47 -0
- package/dist/extensions/cron/tools.d.ts.map +1 -0
- package/dist/extensions/cron/tools.js +141 -0
- package/dist/extensions/cron/tools.js.map +1 -0
- package/dist/extensions/goals/evidence.d.ts +20 -0
- package/dist/extensions/goals/evidence.d.ts.map +1 -0
- package/dist/extensions/goals/evidence.js +77 -0
- package/dist/extensions/goals/evidence.js.map +1 -0
- package/dist/extensions/goals/index.d.ts +45 -0
- package/dist/extensions/goals/index.d.ts.map +1 -0
- package/dist/extensions/goals/index.js +438 -0
- package/dist/extensions/goals/index.js.map +1 -0
- package/dist/extensions/goals/prompts.d.ts +15 -0
- package/dist/extensions/goals/prompts.d.ts.map +1 -0
- package/dist/extensions/goals/prompts.js +51 -0
- package/dist/extensions/goals/prompts.js.map +1 -0
- package/dist/extensions/goals/state.d.ts +88 -0
- package/dist/extensions/goals/state.d.ts.map +1 -0
- package/dist/extensions/goals/state.js +204 -0
- package/dist/extensions/goals/state.js.map +1 -0
- package/dist/extensions/goals/tools.d.ts +40 -0
- package/dist/extensions/goals/tools.d.ts.map +1 -0
- package/dist/extensions/goals/tools.js +118 -0
- package/dist/extensions/goals/tools.js.map +1 -0
- package/dist/extensions/goals/verifier.d.ts +30 -0
- package/dist/extensions/goals/verifier.d.ts.map +1 -0
- package/dist/extensions/goals/verifier.js +89 -0
- package/dist/extensions/goals/verifier.js.map +1 -0
- package/dist/extensions/hooks/aggregate.d.ts +30 -0
- package/dist/extensions/hooks/aggregate.d.ts.map +1 -0
- package/dist/extensions/hooks/aggregate.js +103 -0
- package/dist/extensions/hooks/aggregate.js.map +1 -0
- package/dist/extensions/hooks/config.d.ts +47 -0
- package/dist/extensions/hooks/config.d.ts.map +1 -0
- package/dist/extensions/hooks/config.js +169 -0
- package/dist/extensions/hooks/config.js.map +1 -0
- package/dist/extensions/hooks/file-watcher.d.ts +31 -0
- package/dist/extensions/hooks/file-watcher.d.ts.map +1 -0
- package/dist/extensions/hooks/file-watcher.js +106 -0
- package/dist/extensions/hooks/file-watcher.js.map +1 -0
- package/dist/extensions/hooks/index.d.ts +17 -0
- package/dist/extensions/hooks/index.d.ts.map +1 -0
- package/dist/extensions/hooks/index.js +349 -0
- package/dist/extensions/hooks/index.js.map +1 -0
- package/dist/extensions/hooks/matcher.d.ts +10 -0
- package/dist/extensions/hooks/matcher.d.ts.map +1 -0
- package/dist/extensions/hooks/matcher.js +85 -0
- package/dist/extensions/hooks/matcher.js.map +1 -0
- package/dist/extensions/hooks/runner.d.ts +54 -0
- package/dist/extensions/hooks/runner.d.ts.map +1 -0
- package/dist/extensions/hooks/runner.js +197 -0
- package/dist/extensions/hooks/runner.js.map +1 -0
- package/dist/extensions/index.d.ts.map +1 -1
- package/dist/extensions/index.js +29 -2
- package/dist/extensions/index.js.map +1 -1
- package/dist/extensions/lsp/config.d.ts +40 -0
- package/dist/extensions/lsp/config.d.ts.map +1 -0
- package/dist/extensions/lsp/config.js +92 -0
- package/dist/extensions/lsp/config.js.map +1 -0
- package/dist/extensions/lsp/connection.d.ts +32 -0
- package/dist/extensions/lsp/connection.d.ts.map +1 -0
- package/dist/extensions/lsp/connection.js +124 -0
- package/dist/extensions/lsp/connection.js.map +1 -0
- package/dist/extensions/lsp/index.d.ts +15 -0
- package/dist/extensions/lsp/index.d.ts.map +1 -0
- package/dist/extensions/lsp/index.js +103 -0
- package/dist/extensions/lsp/index.js.map +1 -0
- package/dist/extensions/lsp/server.d.ts +68 -0
- package/dist/extensions/lsp/server.d.ts.map +1 -0
- package/dist/extensions/lsp/server.js +373 -0
- package/dist/extensions/lsp/server.js.map +1 -0
- package/dist/extensions/lsp/tool.d.ts +43 -0
- package/dist/extensions/lsp/tool.d.ts.map +1 -0
- package/dist/extensions/lsp/tool.js +534 -0
- package/dist/extensions/lsp/tool.js.map +1 -0
- package/dist/extensions/memory/index.d.ts +15 -0
- package/dist/extensions/memory/index.d.ts.map +1 -0
- package/dist/extensions/memory/index.js +336 -0
- package/dist/extensions/memory/index.js.map +1 -0
- package/dist/extensions/memory/memory-agent.d.ts +29 -0
- package/dist/extensions/memory/memory-agent.d.ts.map +1 -0
- package/dist/extensions/memory/memory-agent.js +102 -0
- package/dist/extensions/memory/memory-agent.js.map +1 -0
- package/dist/extensions/memory/prompts.d.ts +18 -0
- package/dist/extensions/memory/prompts.d.ts.map +1 -0
- package/dist/extensions/memory/prompts.js +124 -0
- package/dist/extensions/memory/prompts.js.map +1 -0
- package/dist/extensions/memory/recall.d.ts +14 -0
- package/dist/extensions/memory/recall.d.ts.map +1 -0
- package/dist/extensions/memory/recall.js +80 -0
- package/dist/extensions/memory/recall.js.map +1 -0
- package/dist/extensions/memory/store.d.ts +48 -0
- package/dist/extensions/memory/store.d.ts.map +1 -0
- package/dist/extensions/memory/store.js +132 -0
- package/dist/extensions/memory/store.js.map +1 -0
- package/dist/extensions/skills/bundled/batch/SKILL.md +74 -0
- package/dist/extensions/skills/bundled/review/SKILL.md +93 -0
- package/dist/extensions/skills/index.d.ts +15 -0
- package/dist/extensions/skills/index.d.ts.map +1 -0
- package/dist/extensions/skills/index.js +68 -0
- package/dist/extensions/skills/index.js.map +1 -0
- package/dist/extensions/skills/learn.d.ts +9 -0
- package/dist/extensions/skills/learn.d.ts.map +1 -0
- package/dist/extensions/skills/learn.js +46 -0
- package/dist/extensions/skills/learn.js.map +1 -0
- package/dist/extensions/todo/index.d.ts +14 -0
- package/dist/extensions/todo/index.d.ts.map +1 -0
- package/dist/extensions/todo/index.js +55 -0
- package/dist/extensions/todo/index.js.map +1 -0
- package/dist/extensions/todo/todos.d.ts +64 -0
- package/dist/extensions/todo/todos.d.ts.map +1 -0
- package/dist/extensions/todo/todos.js +145 -0
- package/dist/extensions/todo/todos.js.map +1 -0
- package/dist/extensions/todo/tool.d.ts +23 -0
- package/dist/extensions/todo/tool.d.ts.map +1 -0
- package/dist/extensions/todo/tool.js +104 -0
- package/dist/extensions/todo/tool.js.map +1 -0
- package/dist/extensions/web-fetch/fetch-tool.d.ts +27 -0
- package/dist/extensions/web-fetch/fetch-tool.d.ts.map +1 -0
- package/dist/extensions/web-fetch/fetch-tool.js +319 -0
- package/dist/extensions/web-fetch/fetch-tool.js.map +1 -0
- package/dist/extensions/web-fetch/html-to-markdown.d.ts +7 -0
- package/dist/extensions/web-fetch/html-to-markdown.d.ts.map +1 -0
- package/dist/extensions/web-fetch/html-to-markdown.js +21 -0
- package/dist/extensions/web-fetch/html-to-markdown.js.map +1 -0
- package/dist/extensions/web-fetch/index.d.ts +10 -0
- package/dist/extensions/web-fetch/index.d.ts.map +1 -0
- package/dist/extensions/web-fetch/index.js +13 -0
- package/dist/extensions/web-fetch/index.js.map +1 -0
- package/dist/extensions/web-fetch/page-fetch.d.ts +45 -0
- package/dist/extensions/web-fetch/page-fetch.d.ts.map +1 -0
- package/dist/extensions/web-fetch/page-fetch.js +117 -0
- package/dist/extensions/web-fetch/page-fetch.js.map +1 -0
- package/dist/extensions/web-fetch/pdf-text.d.ts +29 -0
- package/dist/extensions/web-fetch/pdf-text.d.ts.map +1 -0
- package/dist/extensions/web-fetch/pdf-text.js +71 -0
- package/dist/extensions/web-fetch/pdf-text.js.map +1 -0
- package/dist/extensions/web-fetch/preapproved-hosts.d.ts +7 -0
- package/dist/extensions/web-fetch/preapproved-hosts.d.ts.map +1 -0
- package/dist/extensions/web-fetch/preapproved-hosts.js +110 -0
- package/dist/extensions/web-fetch/preapproved-hosts.js.map +1 -0
- package/dist/extensions/web-search/dashscope-search.d.ts +29 -0
- package/dist/extensions/web-search/dashscope-search.d.ts.map +1 -0
- package/dist/extensions/web-search/dashscope-search.js +279 -0
- package/dist/extensions/web-search/dashscope-search.js.map +1 -0
- package/dist/extensions/web-search/index.d.ts +15 -0
- package/dist/extensions/web-search/index.d.ts.map +1 -0
- package/dist/extensions/web-search/index.js +51 -0
- package/dist/extensions/web-search/index.js.map +1 -0
- package/dist/extensions/web-search/search-config.d.ts +53 -0
- package/dist/extensions/web-search/search-config.d.ts.map +1 -0
- package/dist/extensions/web-search/search-config.js +174 -0
- package/dist/extensions/web-search/search-config.js.map +1 -0
- package/dist/extensions/web-search/search-tool.d.ts +29 -0
- package/dist/extensions/web-search/search-tool.d.ts.map +1 -0
- package/dist/extensions/web-search/search-tool.js +149 -0
- package/dist/extensions/web-search/search-tool.js.map +1 -0
- package/dist/extensions/worktree/git-worktree.d.ts +69 -0
- package/dist/extensions/worktree/git-worktree.d.ts.map +1 -0
- package/dist/extensions/worktree/git-worktree.js +199 -0
- package/dist/extensions/worktree/git-worktree.js.map +1 -0
- package/dist/extensions/worktree/index.d.ts +27 -0
- package/dist/extensions/worktree/index.d.ts.map +1 -0
- package/dist/extensions/worktree/index.js +188 -0
- package/dist/extensions/worktree/index.js.map +1 -0
- package/dist/extensions/worktree/startup.d.ts +17 -0
- package/dist/extensions/worktree/startup.d.ts.map +1 -0
- package/dist/extensions/worktree/startup.js +56 -0
- package/dist/extensions/worktree/startup.js.map +1 -0
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +28 -4
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts +18 -0
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js +87 -20
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/diffra-logo.d.ts +6 -0
- package/dist/modes/interactive/components/diffra-logo.d.ts.map +1 -1
- package/dist/modes/interactive/components/diffra-logo.js +30 -4
- package/dist/modes/interactive/components/diffra-logo.js.map +1 -1
- package/dist/modes/interactive/components/dynamic-border.d.ts +1 -1
- package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -1
- package/dist/modes/interactive/components/dynamic-border.js +3 -3
- package/dist/modes/interactive/components/dynamic-border.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts +16 -0
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +84 -46
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +5 -2
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +152 -62
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tool-status.d.ts +5 -0
- package/dist/modes/interactive/components/tool-status.d.ts.map +1 -0
- package/dist/modes/interactive/components/tool-status.js +15 -0
- package/dist/modes/interactive/components/tool-status.js.map +1 -0
- package/dist/modes/interactive/components/user-message.d.ts +4 -8
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message.js +38 -36
- package/dist/modes/interactive/components/user-message.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +24 -8
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/theme/dark.json +3 -2
- package/dist/modes/interactive/theme/light.json +3 -2
- package/dist/modes/interactive/theme/system-theme.d.ts +1 -0
- package/dist/modes/interactive/theme/system-theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/system-theme.js +41 -14
- package/dist/modes/interactive/theme/system-theme.js.map +1 -1
- package/dist/utils/shell.d.ts +1 -1
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +12 -2
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/tools-manager.d.ts +5 -0
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +48 -0
- package/dist/utils/tools-manager.js.map +1 -1
- package/docs/approval-modes.md +99 -0
- package/docs/builtin-skills.md +53 -0
- package/docs/cli.md +25 -1
- package/docs/docs.json +44 -0
- package/docs/environment-variables.md +7 -0
- package/docs/extensions.md +27 -2
- package/docs/goals.md +84 -0
- package/docs/hooks.md +112 -0
- package/docs/keybindings.md +1 -0
- package/docs/lsp.md +71 -0
- package/docs/memory.md +71 -0
- package/docs/sandbox.md +108 -0
- package/docs/scheduled-tasks.md +84 -0
- package/docs/security.md +3 -2
- package/docs/settings.md +28 -3
- package/docs/shell-aliases.md +1 -1
- package/docs/skills.md +4 -0
- package/docs/slash-commands.md +15 -0
- package/docs/subagents.md +102 -0
- package/docs/web-tools.md +83 -0
- package/docs/windows.md +2 -1
- package/docs/worktrees.md +52 -0
- package/examples/extensions/README.md +1 -1
- package/examples/extensions/plan-mode/README.md +2 -2
- package/examples/extensions/plan-mode/index.ts +7 -4
- package/examples/extensions/subagent/README.md +2 -0
- package/examples/extensions/subagent/index.ts +3 -0
- package/examples/extensions/todo.ts +4 -0
- package/package.json +9 -8
- package/schemas/keybindings.schema.json +4 -0
- package/schemas/settings.schema.json +421 -0
- package/dist/bundle/chunks/chunk-GCKVPVMH.js +0 -2
- package/dist/bundle/chunks/chunk-UNQMECQ4.js +0 -1240
- package/dist/bundle/chunks/virtual-modules-TRFD5ZOL.js +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keybindings.js","sourceRoot":"","sources":["../../src/core/keybindings.ts"],"names":[],"mappings":"AAAA,OAAO,EAKN,eAAe,EACf,kBAAkB,IAAI,qBAAqB,GAC3C,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,O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AAE,CAAC;QAC1B,OAAO,mBAAmB,CAAC,wBAAwB,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC;IACxE,CAAC;CACD","sourcesContent":["import {\n\ttype Keybinding,\n\ttype KeybindingDefinitions,\n\ttype KeybindingsConfig,\n\ttype KeyId,\n\tTUI_KEYBINDINGS,\n\tKeybindingsManager as TuiKeybindingsManager,\n} from \"@diffra-ai/tui\";\nimport { existsSync, readFileSync } from \"fs\";\nimport { join } from \"path\";\nimport { Compile } from \"typebox/compile\";\nimport { getAgentDir } from \"../config.ts\";\nimport { stripBom } from \"../utils/text.ts\";\nimport { KeybindingValueSchema } from \"./key-id-schema.ts\";\n\nexport function useWindowsKeybindings(\n\tplatform: NodeJS.Platform = process.platform,\n\tenv: NodeJS.ProcessEnv = process.env,\n): boolean {\n\treturn platform === \"win32\" || (platform === \"linux\" && Boolean(env.WSL_DISTRO_NAME || env.WSL_INTEROP));\n}\n\nconst windowsKeybindings = useWindowsKeybindings();\n\nconst APP_KEYBINDINGS = {\n\t\"app.interrupt\": { defaultKeys: \"escape\", description: \"Cancel or abort\" },\n\t\"app.clear\": { defaultKeys: \"ctrl+c\", description: \"Clear editor\" },\n\t\"app.exit\": { defaultKeys: \"ctrl+d\", description: \"Exit when editor is empty\" },\n\t\"app.suspend\": {\n\t\tdefaultKeys: process.platform === \"win32\" ? [] : \"ctrl+z\",\n\t\tdescription: \"Suspend to background\",\n\t},\n\t\"app.thinking.cycle\": {\n\t\tdefaultKeys: \"shift+tab\",\n\t\tdescription: \"Cycle thinking level\",\n\t},\n\t\"app.thinking.save\": {\n\t\tdefaultKeys: \"ctrl+s\",\n\t\tdescription: \"Save thinking level\",\n\t},\n\t\"app.model.cycleForward\": {\n\t\tdefaultKeys: \"ctrl+p\",\n\t\tdescription: \"Cycle to next model\",\n\t},\n\t\"app.model.cycleBackward\": {\n\t\tdefaultKeys: windowsKeybindings ? \"alt+p\" : \"shift+ctrl+p\",\n\t\tdescription: \"Cycle to previous model\",\n\t},\n\t\"app.model.select\": { defaultKeys: \"ctrl+l\", description: \"Open model selector\" },\n\t\"app.tools.expand\": { defaultKeys: \"ctrl+o\", description: \"Toggle tool output\" },\n\t\"app.thinking.toggle\": {\n\t\tdefaultKeys: \"ctrl+t\",\n\t\tdescription: \"Toggle thinking blocks\",\n\t},\n\t\"app.session.toggleNamedFilter\": {\n\t\tdefaultKeys: \"ctrl+n\",\n\t\tdescription: \"Toggle named session filter\",\n\t},\n\t\"app.editor.external\": {\n\t\tdefaultKeys: \"ctrl+g\",\n\t\tdescription: \"Open external editor\",\n\t},\n\t\"app.message.copy\": {\n\t\tdefaultKeys: \"ctrl+x\",\n\t\tdescription: \"Copy selection or last assistant message\",\n\t},\n\t\"app.message.followUp\": {\n\t\tdefaultKeys: windowsKeybindings ? \"ctrl+q\" : \"alt+enter\",\n\t\tdescription: \"Queue follow-up message\",\n\t},\n\t\"app.message.dequeue\": {\n\t\tdefaultKeys: windowsKeybindings ? \"alt+q\" : \"alt+up\",\n\t\tdescription: \"Restore queued messages\",\n\t},\n\t\"app.clipboard.pasteImage\": {\n\t\tdefaultKeys: windowsKeybindings ? [\"alt+v\", \"ctrl+v\"] : \"ctrl+v\",\n\t\tdescription: \"Paste files on macOS, images, or text from clipboard\",\n\t},\n\t\"app.session.new\": { defaultKeys: [], description: \"Start a new session\" },\n\t\"app.session.tree\": { defaultKeys: [], description: \"Open session tree\" },\n\t\"app.session.fork\": { defaultKeys: [], description: \"Fork current session\" },\n\t\"app.session.resume\": { defaultKeys: [], description: \"Resume a session\" },\n\t\"app.tree.foldOrUp\": {\n\t\tdefaultKeys: process.platform === \"darwin\" ? [\"alt+left\", \"ctrl+left\"] : [\"ctrl+left\", \"alt+left\"],\n\t\tdescription: \"Fold tree branch or move up\",\n\t},\n\t\"app.tree.unfoldOrDown\": {\n\t\tdefaultKeys: process.platform === \"darwin\" ? [\"alt+right\", \"ctrl+right\"] : [\"ctrl+right\", \"alt+right\"],\n\t\tdescription: \"Unfold tree branch or move down\",\n\t},\n\t\"app.tree.editLabel\": {\n\t\tdefaultKeys: \"shift+l\",\n\t\tdescription: \"Edit tree label\",\n\t},\n\t\"app.tree.toggleLabelTimestamp\": {\n\t\tdefaultKeys: \"shift+t\",\n\t\tdescription: \"Toggle tree label timestamps\",\n\t},\n\t\"app.session.togglePath\": {\n\t\tdefaultKeys: \"ctrl+p\",\n\t\tdescription: \"Toggle session path display\",\n\t},\n\t\"app.session.toggleSort\": {\n\t\tdefaultKeys: \"ctrl+s\",\n\t\tdescription: \"Toggle session sort mode\",\n\t},\n\t\"app.session.rename\": {\n\t\tdefaultKeys: \"ctrl+r\",\n\t\tdescription: \"Rename session\",\n\t},\n\t\"app.session.delete\": {\n\t\tdefaultKeys: \"ctrl+d\",\n\t\tdescription: \"Delete session\",\n\t},\n\t\"app.session.deleteNoninvasive\": {\n\t\tdefaultKeys: \"ctrl+backspace\",\n\t\tdescription: \"Delete session when query is empty\",\n\t},\n\t\"app.models.save\": {\n\t\tdefaultKeys: \"ctrl+s\",\n\t\tdescription: \"Save model selection\",\n\t},\n\t\"app.models.enableAll\": {\n\t\tdefaultKeys: \"ctrl+a\",\n\t\tdescription: \"Enable all models\",\n\t},\n\t\"app.models.clearAll\": {\n\t\tdefaultKeys: \"ctrl+x\",\n\t\tdescription: \"Clear all models\",\n\t},\n\t\"app.models.toggleProvider\": {\n\t\tdefaultKeys: \"ctrl+p\",\n\t\tdescription: \"Toggle all models for provider\",\n\t},\n\t\"app.models.reorderUp\": {\n\t\tdefaultKeys: \"alt+up\",\n\t\tdescription: \"Move model up in order\",\n\t},\n\t\"app.models.reorderDown\": {\n\t\tdefaultKeys: \"alt+down\",\n\t\tdescription: \"Move model down in order\",\n\t},\n\t\"app.tree.filter.default\": {\n\t\tdefaultKeys: \"ctrl+d\",\n\t\tdescription: \"Tree filter: default view\",\n\t},\n\t\"app.tree.filter.noTools\": {\n\t\tdefaultKeys: \"ctrl+t\",\n\t\tdescription: \"Tree filter: hide tool results\",\n\t},\n\t\"app.tree.filter.userOnly\": {\n\t\tdefaultKeys: \"ctrl+u\",\n\t\tdescription: \"Tree filter: user messages only\",\n\t},\n\t\"app.tree.filter.labeledOnly\": {\n\t\tdefaultKeys: \"ctrl+l\",\n\t\tdescription: \"Tree filter: labeled entries only\",\n\t},\n\t\"app.tree.filter.all\": {\n\t\tdefaultKeys: \"ctrl+a\",\n\t\tdescription: \"Tree filter: show all entries\",\n\t},\n\t\"app.tree.filter.cycleForward\": {\n\t\tdefaultKeys: \"ctrl+o\",\n\t\tdescription: \"Tree filter: cycle forward\",\n\t},\n\t\"app.tree.filter.cycleBackward\": {\n\t\tdefaultKeys: \"shift+ctrl+o\",\n\t\tdescription: \"Tree filter: cycle backward\",\n\t},\n} as const satisfies KeybindingDefinitions;\n\nexport type AppKeybinding = keyof typeof APP_KEYBINDINGS;\nexport type AppKeybindings = { [K in AppKeybinding]: true };\n\ndeclare module \"@diffra-ai/tui\" {\n\tinterface Keybindings extends AppKeybindings {}\n}\n\nexport const KEYBINDINGS = {\n\t...TUI_KEYBINDINGS,\n\t\"tui.editor.undo\": {\n\t\t...TUI_KEYBINDINGS[\"tui.editor.undo\"],\n\t\tdefaultKeys: process.platform === \"win32\" ? \"ctrl+z\" : windowsKeybindings ? \"alt+z\" : \"ctrl+-\",\n\t},\n\t\"tui.altScreen.previousPrompt\": {\n\t\t...TUI_KEYBINDINGS[\"tui.altScreen.previousPrompt\"],\n\t\tdefaultKeys: windowsKeybindings ? \"ctrl+up\" : [\"ctrl+shift+up\", \"ctrl+up\"],\n\t},\n\t\"tui.altScreen.nextPrompt\": {\n\t\t...TUI_KEYBINDINGS[\"tui.altScreen.nextPrompt\"],\n\t\tdefaultKeys: windowsKeybindings ? \"ctrl+down\" : [\"ctrl+shift+down\", \"ctrl+down\"],\n\t},\n\t\"tui.altScreen.search\": {\n\t\t...TUI_KEYBINDINGS[\"tui.altScreen.search\"],\n\t\tdefaultKeys: windowsKeybindings ? \"ctrl+f\" : \"ctrl+shift+f\",\n\t},\n\t...APP_KEYBINDINGS,\n} as const satisfies KeybindingDefinitions;\n\nconst KEYBINDING_NAME_MIGRATIONS = {\n\tcursorUp: \"tui.editor.cursorUp\",\n\tcursorDown: \"tui.editor.cursorDown\",\n\tcursorLeft: \"tui.editor.cursorLeft\",\n\tcursorRight: \"tui.editor.cursorRight\",\n\tcursorWordLeft: \"tui.editor.cursorWordLeft\",\n\tcursorWordRight: \"tui.editor.cursorWordRight\",\n\tcursorLineStart: \"tui.editor.cursorLineStart\",\n\tcursorLineEnd: \"tui.editor.cursorLineEnd\",\n\tjumpForward: \"tui.editor.jumpForward\",\n\tjumpBackward: \"tui.editor.jumpBackward\",\n\tpageUp: \"tui.editor.pageUp\",\n\tpageDown: \"tui.editor.pageDown\",\n\tdeleteCharBackward: \"tui.editor.deleteCharBackward\",\n\tdeleteCharForward: \"tui.editor.deleteCharForward\",\n\tdeleteWordBackward: \"tui.editor.deleteWordBackward\",\n\tdeleteWordForward: \"tui.editor.deleteWordForward\",\n\tdeleteToLineStart: \"tui.editor.deleteToLineStart\",\n\tdeleteToLineEnd: \"tui.editor.deleteToLineEnd\",\n\tyank: \"tui.editor.yank\",\n\tyankPop: \"tui.editor.yankPop\",\n\tundo: \"tui.editor.undo\",\n\tnewLine: \"tui.input.newLine\",\n\tsubmit: \"tui.input.submit\",\n\ttab: \"tui.input.tab\",\n\tcopy: \"tui.input.copy\",\n\tselectUp: \"tui.select.up\",\n\tselectDown: \"tui.select.down\",\n\tselectPageUp: \"tui.select.pageUp\",\n\tselectPageDown: \"tui.select.pageDown\",\n\tselectConfirm: \"tui.select.confirm\",\n\tselectCancel: \"tui.select.cancel\",\n\tinterrupt: \"app.interrupt\",\n\tclear: \"app.clear\",\n\texit: \"app.exit\",\n\tsuspend: \"app.suspend\",\n\tcycleThinkingLevel: \"app.thinking.cycle\",\n\tcycleModelForward: \"app.model.cycleForward\",\n\tcycleModelBackward: \"app.model.cycleBackward\",\n\tselectModel: \"app.model.select\",\n\texpandTools: \"app.tools.expand\",\n\ttoggleThinking: \"app.thinking.toggle\",\n\ttoggleSessionNamedFilter: \"app.session.toggleNamedFilter\",\n\texternalEditor: \"app.editor.external\",\n\tfollowUp: \"app.message.followUp\",\n\tdequeue: \"app.message.dequeue\",\n\tpasteImage: \"app.clipboard.pasteImage\",\n\tnewSession: \"app.session.new\",\n\ttree: \"app.session.tree\",\n\tfork: \"app.session.fork\",\n\tresume: \"app.session.resume\",\n\ttreeFoldOrUp: \"app.tree.foldOrUp\",\n\ttreeUnfoldOrDown: \"app.tree.unfoldOrDown\",\n\ttreeEditLabel: \"app.tree.editLabel\",\n\ttreeToggleLabelTimestamp: \"app.tree.toggleLabelTimestamp\",\n\ttoggleSessionPath: \"app.session.togglePath\",\n\ttoggleSessionSort: \"app.session.toggleSort\",\n\trenameSession: \"app.session.rename\",\n\tdeleteSession: \"app.session.delete\",\n\tdeleteSessionNoninvasive: \"app.session.deleteNoninvasive\",\n} as const satisfies Record<string, Keybinding>;\n\nfunction isLegacyKeybindingName(key: string): key is keyof typeof KEYBINDING_NAME_MIGRATIONS {\n\treturn key in KEYBINDING_NAME_MIGRATIONS;\n}\n\nconst validateKeybindingValue = Compile(KeybindingValueSchema);\n\nfunction toKeybindingsConfig(value: Record<string, unknown>): KeybindingsConfig {\n\tconst config: KeybindingsConfig = {};\n\tfor (const [key, binding] of Object.entries(value)) {\n\t\tif (key === \"$schema\") continue;\n\t\tif (validateKeybindingValue.Check(binding)) config[key] = binding;\n\t}\n\treturn config;\n}\n\nexport function migrateKeybindingsConfig(rawConfig: Record<string, unknown>): {\n\tconfig: Record<string, unknown>;\n\tmigrated: boolean;\n} {\n\tconst config: Record<string, unknown> = {};\n\tlet migrated = false;\n\n\tfor (const [key, value] of Object.entries(rawConfig)) {\n\t\tconst nextKey = isLegacyKeybindingName(key) ? KEYBINDING_NAME_MIGRATIONS[key] : key;\n\t\tif (nextKey !== key) {\n\t\t\tmigrated = true;\n\t\t}\n\t\tif (key !== nextKey && Object.hasOwn(rawConfig, nextKey)) {\n\t\t\tmigrated = true;\n\t\t\tcontinue;\n\t\t}\n\t\tconfig[nextKey] = value;\n\t}\n\n\treturn { config: orderKeybindingsConfig(config), migrated };\n}\n\nfunction orderKeybindingsConfig(config: Record<string, unknown>): Record<string, unknown> {\n\tconst ordered: Record<string, unknown> = {};\n\tfor (const keybinding of Object.keys(KEYBINDINGS)) {\n\t\tif (Object.hasOwn(config, keybinding)) {\n\t\t\tordered[keybinding] = config[keybinding];\n\t\t}\n\t}\n\n\tconst extras = Object.keys(config)\n\t\t.filter((key) => !Object.hasOwn(ordered, key))\n\t\t.sort();\n\tfor (const key of extras) {\n\t\tordered[key] = config[key];\n\t}\n\n\treturn ordered;\n}\n\nfunction loadRawConfig(path: string): Record<string, unknown> | undefined {\n\tif (!existsSync(path)) return undefined;\n\ttry {\n\t\tconst parsed = JSON.parse(stripBom(readFileSync(path, \"utf-8\"))) as unknown;\n\t\tif (typeof parsed !== \"object\" || parsed === null) return undefined;\n\t\treturn parsed as Record<string, unknown>;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nexport class KeybindingsManager extends TuiKeybindingsManager {\n\tprivate configPath: string | undefined;\n\n\tconstructor(userBindings: KeybindingsConfig = {}, configPath?: string) {\n\t\tsuper(KEYBINDINGS, userBindings);\n\t\tthis.configPath = configPath;\n\t}\n\n\tstatic create(agentDir: string = getAgentDir()): KeybindingsManager {\n\t\tconst configPath = join(agentDir, \"keybindings.json\");\n\t\tconst userBindings = KeybindingsManager.loadFromFile(configPath);\n\t\treturn new KeybindingsManager(userBindings, configPath);\n\t}\n\n\treload(): void {\n\t\tif (!this.configPath) return;\n\t\tthis.setUserBindings(KeybindingsManager.loadFromFile(this.configPath));\n\t}\n\n\tgetEffectiveConfig(): KeybindingsConfig {\n\t\treturn this.getResolvedBindings();\n\t}\n\n\tprivate static loadFromFile(path: string): KeybindingsConfig {\n\t\tconst rawConfig = loadRawConfig(path);\n\t\tif (!rawConfig) return {};\n\t\treturn toKeybindingsConfig(migrateKeybindingsConfig(rawConfig).config);\n\t}\n}\n\nexport type { Keybinding, KeyId, KeybindingsConfig };\n"]}
|
|
1
|
+
{"version":3,"file":"keybindings.js","sourceRoot":"","sources":["../../src/core/keybindings.ts"],"names":[],"mappings":"AAAA,OAAO,EAKN,eAAe,EACf,kBAAkB,IAAI,qBAAqB,GAC3C,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,MAAM,UAAU,qBAAqB,CACpC,QAAQ,GAAoB,OAAO,CAAC,QAAQ,EAC5C,GAAG,GAAsB,OAAO,CAAC,GAAG;IAEpC,OAAO,QAAQ,KAAK,OAAO,IAAI,CAAC,QAAQ,KAAK,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC;AAC1G,CAAC;AAED,MAAM,kBAAkB,GAAG,qBAAqB,EAAE,CAAC;AAEnD,MAAM,eAAe,GAAG;IACvB,eAAe,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,iBAAiB,EAAE;IAC1E,WAAW,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,cAAc,EAAE;IACnE,UAAU,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,2BAA2B,EAAE;IAC/E,aAAa,EAAE;QACd,WAAW,EAAE,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,EAAE,CA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AM,CAAC,QAAQ,GAAW,WAAW,EAAE;QAC7C,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,EAAE,kBAAkB,CAAC,CAAC;QACtD,MAAM,YAAY,GAAG,kBAAkB,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;QACjE,OAAO,IAAI,kBAAkB,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;IACzD,CAAC;IAED,MAAM;QACL,IAAI,CAAC,IAAI,CAAC,UAAU;YAAE,OAAO;QAC7B,IAAI,CAAC,eAAe,CAAC,kBAAkB,CAAC,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;IACxE,CAAC;IAED,kBAAkB;QACjB,OAAO,IAAI,CAAC,mBAAmB,EAAE,CAAC;IACnC,CAAC;IAEO,MAAM,CAAC,YAAY,CAAC,IAAY;QACvC,MAAM,SAAS,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;QACtC,IAAI,CAAC,SAAS;YAAE,OAAO,EAAE,CAAC;QAC1B,OAAO,mBAAmB,CAAC,wBAAwB,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC;IACxE,CAAC;CACD","sourcesContent":["import {\n\ttype Keybinding,\n\ttype KeybindingDefinitions,\n\ttype KeybindingsConfig,\n\ttype KeyId,\n\tTUI_KEYBINDINGS,\n\tKeybindingsManager as TuiKeybindingsManager,\n} from \"@diffra-ai/tui\";\nimport { existsSync, readFileSync } from \"fs\";\nimport { join } from \"path\";\nimport { Compile } from \"typebox/compile\";\nimport { getAgentDir } from \"../config.ts\";\nimport { stripBom } from \"../utils/text.ts\";\nimport { KeybindingValueSchema } from \"./key-id-schema.ts\";\n\nexport function useWindowsKeybindings(\n\tplatform: NodeJS.Platform = process.platform,\n\tenv: NodeJS.ProcessEnv = process.env,\n): boolean {\n\treturn platform === \"win32\" || (platform === \"linux\" && Boolean(env.WSL_DISTRO_NAME || env.WSL_INTEROP));\n}\n\nconst windowsKeybindings = useWindowsKeybindings();\n\nconst APP_KEYBINDINGS = {\n\t\"app.interrupt\": { defaultKeys: \"escape\", description: \"Cancel or abort\" },\n\t\"app.clear\": { defaultKeys: \"ctrl+c\", description: \"Clear editor\" },\n\t\"app.exit\": { defaultKeys: \"ctrl+d\", description: \"Exit when editor is empty\" },\n\t\"app.suspend\": {\n\t\tdefaultKeys: process.platform === \"win32\" ? [] : \"ctrl+z\",\n\t\tdescription: \"Suspend to background\",\n\t},\n\t\"app.thinking.cycle\": {\n\t\tdefaultKeys: \"shift+tab\",\n\t\tdescription: \"Cycle thinking level\",\n\t},\n\t\"app.approvalMode.cycle\": {\n\t\tdefaultKeys: \"alt+m\",\n\t\tdescription: \"Cycle approval mode\",\n\t},\n\t\"app.thinking.save\": {\n\t\tdefaultKeys: \"ctrl+s\",\n\t\tdescription: \"Save thinking level\",\n\t},\n\t\"app.model.cycleForward\": {\n\t\tdefaultKeys: \"ctrl+p\",\n\t\tdescription: \"Cycle to next model\",\n\t},\n\t\"app.model.cycleBackward\": {\n\t\tdefaultKeys: windowsKeybindings ? \"alt+p\" : \"shift+ctrl+p\",\n\t\tdescription: \"Cycle to previous model\",\n\t},\n\t\"app.model.select\": { defaultKeys: \"ctrl+l\", description: \"Open model selector\" },\n\t\"app.tools.expand\": { defaultKeys: \"ctrl+o\", description: \"Toggle tool output\" },\n\t\"app.thinking.toggle\": {\n\t\tdefaultKeys: \"ctrl+t\",\n\t\tdescription: \"Toggle thinking blocks\",\n\t},\n\t\"app.session.toggleNamedFilter\": {\n\t\tdefaultKeys: \"ctrl+n\",\n\t\tdescription: \"Toggle named session filter\",\n\t},\n\t\"app.editor.external\": {\n\t\tdefaultKeys: \"ctrl+g\",\n\t\tdescription: \"Open external editor\",\n\t},\n\t\"app.message.copy\": {\n\t\tdefaultKeys: \"ctrl+x\",\n\t\tdescription: \"Copy selection or last assistant message\",\n\t},\n\t\"app.message.followUp\": {\n\t\tdefaultKeys: windowsKeybindings ? \"ctrl+q\" : \"alt+enter\",\n\t\tdescription: \"Queue follow-up message\",\n\t},\n\t\"app.message.dequeue\": {\n\t\tdefaultKeys: windowsKeybindings ? \"alt+q\" : \"alt+up\",\n\t\tdescription: \"Restore queued messages\",\n\t},\n\t\"app.clipboard.pasteImage\": {\n\t\tdefaultKeys: windowsKeybindings ? [\"alt+v\", \"ctrl+v\"] : \"ctrl+v\",\n\t\tdescription: \"Paste files on macOS, images, or text from clipboard\",\n\t},\n\t\"app.session.new\": { defaultKeys: [], description: \"Start a new session\" },\n\t\"app.session.tree\": { defaultKeys: [], description: \"Open session tree\" },\n\t\"app.session.fork\": { defaultKeys: [], description: \"Fork current session\" },\n\t\"app.session.resume\": { defaultKeys: [], description: \"Resume a session\" },\n\t\"app.tree.foldOrUp\": {\n\t\tdefaultKeys: process.platform === \"darwin\" ? [\"alt+left\", \"ctrl+left\"] : [\"ctrl+left\", \"alt+left\"],\n\t\tdescription: \"Fold tree branch or move up\",\n\t},\n\t\"app.tree.unfoldOrDown\": {\n\t\tdefaultKeys: process.platform === \"darwin\" ? [\"alt+right\", \"ctrl+right\"] : [\"ctrl+right\", \"alt+right\"],\n\t\tdescription: \"Unfold tree branch or move down\",\n\t},\n\t\"app.tree.editLabel\": {\n\t\tdefaultKeys: \"shift+l\",\n\t\tdescription: \"Edit tree label\",\n\t},\n\t\"app.tree.toggleLabelTimestamp\": {\n\t\tdefaultKeys: \"shift+t\",\n\t\tdescription: \"Toggle tree label timestamps\",\n\t},\n\t\"app.session.togglePath\": {\n\t\tdefaultKeys: \"ctrl+p\",\n\t\tdescription: \"Toggle session path display\",\n\t},\n\t\"app.session.toggleSort\": {\n\t\tdefaultKeys: \"ctrl+s\",\n\t\tdescription: \"Toggle session sort mode\",\n\t},\n\t\"app.session.rename\": {\n\t\tdefaultKeys: \"ctrl+r\",\n\t\tdescription: \"Rename session\",\n\t},\n\t\"app.session.delete\": {\n\t\tdefaultKeys: \"ctrl+d\",\n\t\tdescription: \"Delete session\",\n\t},\n\t\"app.session.deleteNoninvasive\": {\n\t\tdefaultKeys: \"ctrl+backspace\",\n\t\tdescription: \"Delete session when query is empty\",\n\t},\n\t\"app.models.save\": {\n\t\tdefaultKeys: \"ctrl+s\",\n\t\tdescription: \"Save model selection\",\n\t},\n\t\"app.models.enableAll\": {\n\t\tdefaultKeys: \"ctrl+a\",\n\t\tdescription: \"Enable all models\",\n\t},\n\t\"app.models.clearAll\": {\n\t\tdefaultKeys: \"ctrl+x\",\n\t\tdescription: \"Clear all models\",\n\t},\n\t\"app.models.toggleProvider\": {\n\t\tdefaultKeys: \"ctrl+p\",\n\t\tdescription: \"Toggle all models for provider\",\n\t},\n\t\"app.models.reorderUp\": {\n\t\tdefaultKeys: \"alt+up\",\n\t\tdescription: \"Move model up in order\",\n\t},\n\t\"app.models.reorderDown\": {\n\t\tdefaultKeys: \"alt+down\",\n\t\tdescription: \"Move model down in order\",\n\t},\n\t\"app.tree.filter.default\": {\n\t\tdefaultKeys: \"ctrl+d\",\n\t\tdescription: \"Tree filter: default view\",\n\t},\n\t\"app.tree.filter.noTools\": {\n\t\tdefaultKeys: \"ctrl+t\",\n\t\tdescription: \"Tree filter: hide tool results\",\n\t},\n\t\"app.tree.filter.userOnly\": {\n\t\tdefaultKeys: \"ctrl+u\",\n\t\tdescription: \"Tree filter: user messages only\",\n\t},\n\t\"app.tree.filter.labeledOnly\": {\n\t\tdefaultKeys: \"ctrl+l\",\n\t\tdescription: \"Tree filter: labeled entries only\",\n\t},\n\t\"app.tree.filter.all\": {\n\t\tdefaultKeys: \"ctrl+a\",\n\t\tdescription: \"Tree filter: show all entries\",\n\t},\n\t\"app.tree.filter.cycleForward\": {\n\t\tdefaultKeys: \"ctrl+o\",\n\t\tdescription: \"Tree filter: cycle forward\",\n\t},\n\t\"app.tree.filter.cycleBackward\": {\n\t\tdefaultKeys: \"shift+ctrl+o\",\n\t\tdescription: \"Tree filter: cycle backward\",\n\t},\n} as const satisfies KeybindingDefinitions;\n\nexport type AppKeybinding = keyof typeof APP_KEYBINDINGS;\nexport type AppKeybindings = { [K in AppKeybinding]: true };\n\ndeclare module \"@diffra-ai/tui\" {\n\tinterface Keybindings extends AppKeybindings {}\n}\n\nexport const KEYBINDINGS = {\n\t...TUI_KEYBINDINGS,\n\t\"tui.editor.undo\": {\n\t\t...TUI_KEYBINDINGS[\"tui.editor.undo\"],\n\t\tdefaultKeys: process.platform === \"win32\" ? \"ctrl+z\" : windowsKeybindings ? \"alt+z\" : \"ctrl+-\",\n\t},\n\t\"tui.altScreen.previousPrompt\": {\n\t\t...TUI_KEYBINDINGS[\"tui.altScreen.previousPrompt\"],\n\t\tdefaultKeys: windowsKeybindings ? \"ctrl+up\" : [\"ctrl+shift+up\", \"ctrl+up\"],\n\t},\n\t\"tui.altScreen.nextPrompt\": {\n\t\t...TUI_KEYBINDINGS[\"tui.altScreen.nextPrompt\"],\n\t\tdefaultKeys: windowsKeybindings ? \"ctrl+down\" : [\"ctrl+shift+down\", \"ctrl+down\"],\n\t},\n\t\"tui.altScreen.search\": {\n\t\t...TUI_KEYBINDINGS[\"tui.altScreen.search\"],\n\t\tdefaultKeys: windowsKeybindings ? \"ctrl+f\" : \"ctrl+shift+f\",\n\t},\n\t...APP_KEYBINDINGS,\n} as const satisfies KeybindingDefinitions;\n\nconst KEYBINDING_NAME_MIGRATIONS = {\n\tcursorUp: \"tui.editor.cursorUp\",\n\tcursorDown: \"tui.editor.cursorDown\",\n\tcursorLeft: \"tui.editor.cursorLeft\",\n\tcursorRight: \"tui.editor.cursorRight\",\n\tcursorWordLeft: \"tui.editor.cursorWordLeft\",\n\tcursorWordRight: \"tui.editor.cursorWordRight\",\n\tcursorLineStart: \"tui.editor.cursorLineStart\",\n\tcursorLineEnd: \"tui.editor.cursorLineEnd\",\n\tjumpForward: \"tui.editor.jumpForward\",\n\tjumpBackward: \"tui.editor.jumpBackward\",\n\tpageUp: \"tui.editor.pageUp\",\n\tpageDown: \"tui.editor.pageDown\",\n\tdeleteCharBackward: \"tui.editor.deleteCharBackward\",\n\tdeleteCharForward: \"tui.editor.deleteCharForward\",\n\tdeleteWordBackward: \"tui.editor.deleteWordBackward\",\n\tdeleteWordForward: \"tui.editor.deleteWordForward\",\n\tdeleteToLineStart: \"tui.editor.deleteToLineStart\",\n\tdeleteToLineEnd: \"tui.editor.deleteToLineEnd\",\n\tyank: \"tui.editor.yank\",\n\tyankPop: \"tui.editor.yankPop\",\n\tundo: \"tui.editor.undo\",\n\tnewLine: \"tui.input.newLine\",\n\tsubmit: \"tui.input.submit\",\n\ttab: \"tui.input.tab\",\n\tcopy: \"tui.input.copy\",\n\tselectUp: \"tui.select.up\",\n\tselectDown: \"tui.select.down\",\n\tselectPageUp: \"tui.select.pageUp\",\n\tselectPageDown: \"tui.select.pageDown\",\n\tselectConfirm: \"tui.select.confirm\",\n\tselectCancel: \"tui.select.cancel\",\n\tinterrupt: \"app.interrupt\",\n\tclear: \"app.clear\",\n\texit: \"app.exit\",\n\tsuspend: \"app.suspend\",\n\tcycleThinkingLevel: \"app.thinking.cycle\",\n\tcycleModelForward: \"app.model.cycleForward\",\n\tcycleModelBackward: \"app.model.cycleBackward\",\n\tselectModel: \"app.model.select\",\n\texpandTools: \"app.tools.expand\",\n\ttoggleThinking: \"app.thinking.toggle\",\n\ttoggleSessionNamedFilter: \"app.session.toggleNamedFilter\",\n\texternalEditor: \"app.editor.external\",\n\tfollowUp: \"app.message.followUp\",\n\tdequeue: \"app.message.dequeue\",\n\tpasteImage: \"app.clipboard.pasteImage\",\n\tnewSession: \"app.session.new\",\n\ttree: \"app.session.tree\",\n\tfork: \"app.session.fork\",\n\tresume: \"app.session.resume\",\n\ttreeFoldOrUp: \"app.tree.foldOrUp\",\n\ttreeUnfoldOrDown: \"app.tree.unfoldOrDown\",\n\ttreeEditLabel: \"app.tree.editLabel\",\n\ttreeToggleLabelTimestamp: \"app.tree.toggleLabelTimestamp\",\n\ttoggleSessionPath: \"app.session.togglePath\",\n\ttoggleSessionSort: \"app.session.toggleSort\",\n\trenameSession: \"app.session.rename\",\n\tdeleteSession: \"app.session.delete\",\n\tdeleteSessionNoninvasive: \"app.session.deleteNoninvasive\",\n} as const satisfies Record<string, Keybinding>;\n\nfunction isLegacyKeybindingName(key: string): key is keyof typeof KEYBINDING_NAME_MIGRATIONS {\n\treturn key in KEYBINDING_NAME_MIGRATIONS;\n}\n\nconst validateKeybindingValue = Compile(KeybindingValueSchema);\n\nfunction toKeybindingsConfig(value: Record<string, unknown>): KeybindingsConfig {\n\tconst config: KeybindingsConfig = {};\n\tfor (const [key, binding] of Object.entries(value)) {\n\t\tif (key === \"$schema\") continue;\n\t\tif (validateKeybindingValue.Check(binding)) config[key] = binding;\n\t}\n\treturn config;\n}\n\nexport function migrateKeybindingsConfig(rawConfig: Record<string, unknown>): {\n\tconfig: Record<string, unknown>;\n\tmigrated: boolean;\n} {\n\tconst config: Record<string, unknown> = {};\n\tlet migrated = false;\n\n\tfor (const [key, value] of Object.entries(rawConfig)) {\n\t\tconst nextKey = isLegacyKeybindingName(key) ? KEYBINDING_NAME_MIGRATIONS[key] : key;\n\t\tif (nextKey !== key) {\n\t\t\tmigrated = true;\n\t\t}\n\t\tif (key !== nextKey && Object.hasOwn(rawConfig, nextKey)) {\n\t\t\tmigrated = true;\n\t\t\tcontinue;\n\t\t}\n\t\tconfig[nextKey] = value;\n\t}\n\n\treturn { config: orderKeybindingsConfig(config), migrated };\n}\n\nfunction orderKeybindingsConfig(config: Record<string, unknown>): Record<string, unknown> {\n\tconst ordered: Record<string, unknown> = {};\n\tfor (const keybinding of Object.keys(KEYBINDINGS)) {\n\t\tif (Object.hasOwn(config, keybinding)) {\n\t\t\tordered[keybinding] = config[keybinding];\n\t\t}\n\t}\n\n\tconst extras = Object.keys(config)\n\t\t.filter((key) => !Object.hasOwn(ordered, key))\n\t\t.sort();\n\tfor (const key of extras) {\n\t\tordered[key] = config[key];\n\t}\n\n\treturn ordered;\n}\n\nfunction loadRawConfig(path: string): Record<string, unknown> | undefined {\n\tif (!existsSync(path)) return undefined;\n\ttry {\n\t\tconst parsed = JSON.parse(stripBom(readFileSync(path, \"utf-8\"))) as unknown;\n\t\tif (typeof parsed !== \"object\" || parsed === null) return undefined;\n\t\treturn parsed as Record<string, unknown>;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nexport class KeybindingsManager extends TuiKeybindingsManager {\n\tprivate configPath: string | undefined;\n\n\tconstructor(userBindings: KeybindingsConfig = {}, configPath?: string) {\n\t\tsuper(KEYBINDINGS, userBindings);\n\t\tthis.configPath = configPath;\n\t}\n\n\tstatic create(agentDir: string = getAgentDir()): KeybindingsManager {\n\t\tconst configPath = join(agentDir, \"keybindings.json\");\n\t\tconst userBindings = KeybindingsManager.loadFromFile(configPath);\n\t\treturn new KeybindingsManager(userBindings, configPath);\n\t}\n\n\treload(): void {\n\t\tif (!this.configPath) return;\n\t\tthis.setUserBindings(KeybindingsManager.loadFromFile(this.configPath));\n\t}\n\n\tgetEffectiveConfig(): KeybindingsConfig {\n\t\treturn this.getResolvedBindings();\n\t}\n\n\tprivate static loadFromFile(path: string): KeybindingsConfig {\n\t\tconst rawConfig = loadRawConfig(path);\n\t\tif (!rawConfig) return {};\n\t\treturn toKeybindingsConfig(migrateKeybindingsConfig(rawConfig).config);\n\t}\n}\n\nexport type { Keybinding, KeyId, KeybindingsConfig };\n"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Escalation: when the sandbox denies a write or a command, the session may ask the user to allow that one action
|
|
3
|
+
* without the sandbox. Commands only tell their denial through their output, so a failed sandboxed command whose
|
|
4
|
+
* output reads like a denial counts as one.
|
|
5
|
+
*/
|
|
6
|
+
import type { ExtensionContext } from "../extensions/types.ts";
|
|
7
|
+
import type { BashOperations } from "../tools/bash.ts";
|
|
8
|
+
import { type SandboxPolicyResolver } from "./policy.ts";
|
|
9
|
+
/** An action the sandbox denied. */
|
|
10
|
+
export type SandboxEscalationRequest = {
|
|
11
|
+
kind: "command";
|
|
12
|
+
command: string;
|
|
13
|
+
} | {
|
|
14
|
+
kind: "write";
|
|
15
|
+
path: string;
|
|
16
|
+
reason: string;
|
|
17
|
+
};
|
|
18
|
+
/** Asks whether a denied action may run without the sandbox; true allows it once. */
|
|
19
|
+
export type SandboxEscalation = (request: SandboxEscalationRequest, ctx: ExtensionContext | undefined) => Promise<boolean>;
|
|
20
|
+
/** The sandbox of a tool: its policy, and who may allow a denied action. */
|
|
21
|
+
export interface SandboxOptions {
|
|
22
|
+
policy: SandboxPolicyResolver;
|
|
23
|
+
escalate?: SandboxEscalation;
|
|
24
|
+
}
|
|
25
|
+
/** Throw the denial reason unless the sandbox in `cwd` allows writing `path`, or the escalation allows it once. */
|
|
26
|
+
export declare function enforceSandboxWrite(sandbox: SandboxOptions | undefined, cwd: string, path: string, ctx: ExtensionContext | undefined): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Operations that run commands with `sandboxed` and, when one fails like a sandbox denial and `approve` allows it,
|
|
29
|
+
* run it again with `unsandboxed`. The second run's output follows the first one's.
|
|
30
|
+
*/
|
|
31
|
+
export declare function withUnsandboxedRetry(sandboxed: BashOperations, unsandboxed: BashOperations, approve: (command: string) => Promise<boolean>): BashOperations;
|
|
32
|
+
//# sourceMappingURL=escalation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"escalation.d.ts","sourceRoot":"","sources":["../../../src/core/sandbox/escalation.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAqB,KAAK,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAE5E,oCAAoC;AACpC,MAAM,MAAM,wBAAwB,GACjC;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GACpC;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnD,qFAAqF;AACrF,MAAM,MAAM,iBAAiB,GAAG,CAC/B,OAAO,EAAE,wBAAwB,EACjC,GAAG,EAAE,gBAAgB,GAAG,SAAS,KAC7B,OAAO,CAAC,OAAO,CAAC,CAAC;AAEtB,4EAA4E;AAC5E,MAAM,WAAW,cAAc;IAC9B,MAAM,EAAE,qBAAqB,CAAC;IAC9B,QAAQ,CAAC,EAAE,iBAAiB,CAAC;CAC7B;AAED,mHAAmH;AACnH,wBAAsB,mBAAmB,CACxC,OAAO,EAAE,cAAc,GAAG,SAAS,EACnC,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,gBAAgB,GAAG,SAAS,GAC/B,OAAO,CAAC,IAAI,CAAC,CAOf;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CACnC,SAAS,EAAE,cAAc,EACzB,WAAW,EAAE,cAAc,EAC3B,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,GAC5C,cAAc,CA0BhB"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Escalation: when the sandbox denies a write or a command, the session may ask the user to allow that one action
|
|
3
|
+
* without the sandbox. Commands only tell their denial through their output, so a failed sandboxed command whose
|
|
4
|
+
* output reads like a denial counts as one.
|
|
5
|
+
*/
|
|
6
|
+
import { checkSandboxWrite } from "./policy.js";
|
|
7
|
+
/** Throw the denial reason unless the sandbox in `cwd` allows writing `path`, or the escalation allows it once. */
|
|
8
|
+
export async function enforceSandboxWrite(sandbox, cwd, path, ctx) {
|
|
9
|
+
const policy = sandbox?.policy(cwd);
|
|
10
|
+
if (!policy)
|
|
11
|
+
return;
|
|
12
|
+
const check = checkSandboxWrite(policy, path);
|
|
13
|
+
if (check.kind === "allowed")
|
|
14
|
+
return;
|
|
15
|
+
if (await sandbox?.escalate?.({ kind: "write", path, reason: check.reason }, ctx))
|
|
16
|
+
return;
|
|
17
|
+
throw new Error(check.reason);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Operations that run commands with `sandboxed` and, when one fails like a sandbox denial and `approve` allows it,
|
|
21
|
+
* run it again with `unsandboxed`. The second run's output follows the first one's.
|
|
22
|
+
*/
|
|
23
|
+
export function withUnsandboxedRetry(sandboxed, unsandboxed, approve) {
|
|
24
|
+
return {
|
|
25
|
+
exec: async (command, cwd, options) => {
|
|
26
|
+
let tail = "";
|
|
27
|
+
const first = await sandboxed.exec(command, cwd, {
|
|
28
|
+
...options,
|
|
29
|
+
onData: (data) => {
|
|
30
|
+
tail = (tail + data.toString("utf-8")).slice(-DENIAL_SCAN_CHARS);
|
|
31
|
+
options.onData(data);
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
if (first.exitCode === null ||
|
|
35
|
+
NEVER_DENIAL_EXIT_CODES.includes(first.exitCode) ||
|
|
36
|
+
!looksLikeSandboxDenial(tail)) {
|
|
37
|
+
return first;
|
|
38
|
+
}
|
|
39
|
+
if (!(await approve(command))) {
|
|
40
|
+
options.onData(Buffer.from(`\n${DENIAL_NOTE}\n`));
|
|
41
|
+
return first;
|
|
42
|
+
}
|
|
43
|
+
options.onData(Buffer.from(`\n${RETRY_NOTE}\n`));
|
|
44
|
+
return unsandboxed.exec(command, cwd, options);
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
// Denials show at the end of the output; a bounded tail keeps long outputs from growing this copy.
|
|
49
|
+
const DENIAL_SCAN_CHARS = 64 * 1024;
|
|
50
|
+
const DENIAL_NOTE = "[The sandbox probably blocked this command. Its policy cannot be changed from inside the sandbox.]";
|
|
51
|
+
const RETRY_NOTE = "[The sandbox blocked this command. Running it again without the sandbox, as the user allowed.]";
|
|
52
|
+
// Success, usage errors, and commands that cannot run: never a denial.
|
|
53
|
+
const NEVER_DENIAL_EXIT_CODES = [0, 2, 126, 127];
|
|
54
|
+
// What macOS, Linux, Windows, and PowerShell print when a write or connection is refused. SEC_E_NO_CREDENTIALS is
|
|
55
|
+
// how Windows' own TLS refuses the Windows sandbox's token, as in curl.exe's HTTPS requests.
|
|
56
|
+
const DENIAL_WORDS = [
|
|
57
|
+
"operation not permitted",
|
|
58
|
+
"permission denied",
|
|
59
|
+
"read-only file system",
|
|
60
|
+
"access is denied",
|
|
61
|
+
"access to the path",
|
|
62
|
+
"unauthorizedaccessexception",
|
|
63
|
+
"sec_e_no_credentials",
|
|
64
|
+
"sandbox",
|
|
65
|
+
];
|
|
66
|
+
function looksLikeSandboxDenial(output) {
|
|
67
|
+
const lower = output.toLowerCase();
|
|
68
|
+
return DENIAL_WORDS.some((word) => lower.includes(word));
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=escalation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"escalation.js","sourceRoot":"","sources":["../../../src/core/sandbox/escalation.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,iBAAiB,EAA8B,MAAM,aAAa,CAAC;AAmB5E,mHAAmH;AACnH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACxC,OAAmC,EACnC,GAAW,EACX,IAAY,EACZ,GAAiC;IAEjC,MAAM,MAAM,GAAG,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;IACpC,IAAI,CAAC,MAAM;QAAE,OAAO;IACpB,MAAM,KAAK,GAAG,iBAAiB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC9C,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS;QAAE,OAAO;IACrC,IAAI,MAAM,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,EAAE,GAAG,CAAC;QAAE,OAAO;IAC1F,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC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ChB,oGAAoG,CAAC;AACtG,MAAM,UAAU,GAAG,gGAAgG,CAAC;AAEpH,uEAAuE;AACvE,MAAM,uBAAuB,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AAEjD,kHAAkH;AAClH,6FAA6F;AAC7F,MAAM,YAAY,GAAG;IACpB,yBAAyB;IACzB,mBAAmB;IACnB,uBAAuB;IACvB,kBAAkB;IAClB,oBAAoB;IACpB,6BAA6B;IAC7B,sBAAsB;IACtB,SAAS;CACT,CAAC;AAEF,SAAS,sBAAsB,CAAC,MAAc;IAC7C,MAAM,KAAK,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;IACnC,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;AAC1D,CAAC","sourcesContent":["/**\n * Escalation: when the sandbox denies a write or a command, the session may ask the user to allow that one action\n * without the sandbox. Commands only tell their denial through their output, so a failed sandboxed command whose\n * output reads like a denial counts as one.\n */\n\nimport type { ExtensionContext } from \"../extensions/types.ts\";\nimport type { BashOperations } from \"../tools/bash.ts\";\nimport { checkSandboxWrite, type SandboxPolicyResolver } from \"./policy.ts\";\n\n/** An action the sandbox denied. */\nexport type SandboxEscalationRequest =\n\t| { kind: \"command\"; command: string }\n\t| { kind: \"write\"; path: string; reason: string };\n\n/** Asks whether a denied action may run without the sandbox; true allows it once. */\nexport type SandboxEscalation = (\n\trequest: SandboxEscalationRequest,\n\tctx: ExtensionContext | undefined,\n) => Promise<boolean>;\n\n/** The sandbox of a tool: its policy, and who may allow a denied action. */\nexport interface SandboxOptions {\n\tpolicy: SandboxPolicyResolver;\n\tescalate?: SandboxEscalation;\n}\n\n/** Throw the denial reason unless the sandbox in `cwd` allows writing `path`, or the escalation allows it once. */\nexport async function enforceSandboxWrite(\n\tsandbox: SandboxOptions | undefined,\n\tcwd: string,\n\tpath: string,\n\tctx: ExtensionContext | undefined,\n): Promise<void> {\n\tconst policy = sandbox?.policy(cwd);\n\tif (!policy) return;\n\tconst check = checkSandboxWrite(policy, path);\n\tif (check.kind === \"allowed\") return;\n\tif (await sandbox?.escalate?.({ kind: \"write\", path, reason: check.reason }, ctx)) return;\n\tthrow new Error(check.reason);\n}\n\n/**\n * Operations that run commands with `sandboxed` and, when one fails like a sandbox denial and `approve` allows it,\n * run it again with `unsandboxed`. The second run's output follows the first one's.\n */\nexport function withUnsandboxedRetry(\n\tsandboxed: BashOperations,\n\tunsandboxed: BashOperations,\n\tapprove: (command: string) => Promise<boolean>,\n): BashOperations {\n\treturn {\n\t\texec: async (command, cwd, options) => {\n\t\t\tlet tail = \"\";\n\t\t\tconst first = await sandboxed.exec(command, cwd, {\n\t\t\t\t...options,\n\t\t\t\tonData: (data) => {\n\t\t\t\t\ttail = (tail + data.toString(\"utf-8\")).slice(-DENIAL_SCAN_CHARS);\n\t\t\t\t\toptions.onData(data);\n\t\t\t\t},\n\t\t\t});\n\t\t\tif (\n\t\t\t\tfirst.exitCode === null ||\n\t\t\t\tNEVER_DENIAL_EXIT_CODES.includes(first.exitCode) ||\n\t\t\t\t!looksLikeSandboxDenial(tail)\n\t\t\t) {\n\t\t\t\treturn first;\n\t\t\t}\n\t\t\tif (!(await approve(command))) {\n\t\t\t\toptions.onData(Buffer.from(`\\n${DENIAL_NOTE}\\n`));\n\t\t\t\treturn first;\n\t\t\t}\n\t\t\toptions.onData(Buffer.from(`\\n${RETRY_NOTE}\\n`));\n\t\t\treturn unsandboxed.exec(command, cwd, options);\n\t\t},\n\t};\n}\n\n// Denials show at the end of the output; a bounded tail keeps long outputs from growing this copy.\nconst DENIAL_SCAN_CHARS = 64 * 1024;\n\nconst DENIAL_NOTE =\n\t\"[The sandbox probably blocked this command. Its policy cannot be changed from inside the sandbox.]\";\nconst RETRY_NOTE = \"[The sandbox blocked this command. Running it again without the sandbox, as the user allowed.]\";\n\n// Success, usage errors, and commands that cannot run: never a denial.\nconst NEVER_DENIAL_EXIT_CODES = [0, 2, 126, 127];\n\n// What macOS, Linux, Windows, and PowerShell print when a write or connection is refused. SEC_E_NO_CREDENTIALS is\n// how Windows' own TLS refuses the Windows sandbox's token, as in curl.exe's HTTPS requests.\nconst DENIAL_WORDS = [\n\t\"operation not permitted\",\n\t\"permission denied\",\n\t\"read-only file system\",\n\t\"access is denied\",\n\t\"access to the path\",\n\t\"unauthorizedaccessexception\",\n\t\"sec_e_no_credentials\",\n\t\"sandbox\",\n];\n\nfunction looksLikeSandboxDenial(output: string): boolean {\n\tconst lower = output.toLowerCase();\n\treturn DENIAL_WORDS.some((word) => lower.includes(word));\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** Starts sandboxed commands: wraps a process launch in the sandbox backend of the current platform. */
|
|
2
|
+
import type { SandboxPolicy } from "./policy.ts";
|
|
3
|
+
/** A process to start: the executable, its arguments, and its environment. */
|
|
4
|
+
export interface SandboxLaunch {
|
|
5
|
+
command: string;
|
|
6
|
+
args: string[];
|
|
7
|
+
env: NodeJS.ProcessEnv;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Wrap `launch`, which starts in `cwd`, so the process runs under `policy`. Rejects when this platform has no
|
|
11
|
+
* sandbox backend.
|
|
12
|
+
*/
|
|
13
|
+
export declare function wrapForSandbox(policy: SandboxPolicy, launch: SandboxLaunch, cwd: string): Promise<SandboxLaunch>;
|
|
14
|
+
//# sourceMappingURL=launch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"launch.d.ts","sourceRoot":"","sources":["../../../src/core/sandbox/launch.ts"],"names":[],"mappings":"AAAA,wGAAwG;AAExG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAIjD,8EAA8E;AAC9E,MAAM,WAAW,aAAa;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;CACvB;AAED;;;GAGG;AACH,wBAAsB,cAAc,CACnC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,aAAa,EACrB,GAAG,EAAE,MAAM,GACT,OAAO,CAAC,aAAa,CAAC,CAWxB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** Starts sandboxed commands: wraps a process launch in the sandbox backend of the current platform. */
|
|
2
|
+
import { wrapWithSeatbelt } from "./seatbelt.js";
|
|
3
|
+
import { wrapWithWindowsSandbox } from "./windows.js";
|
|
4
|
+
/**
|
|
5
|
+
* Wrap `launch`, which starts in `cwd`, so the process runs under `policy`. Rejects when this platform has no
|
|
6
|
+
* sandbox backend.
|
|
7
|
+
*/
|
|
8
|
+
export async function wrapForSandbox(policy, launch, cwd) {
|
|
9
|
+
switch (process.platform) {
|
|
10
|
+
case "darwin":
|
|
11
|
+
return wrapWithSeatbelt(policy, launch);
|
|
12
|
+
case "win32":
|
|
13
|
+
return wrapWithWindowsSandbox(policy, launch, cwd);
|
|
14
|
+
default:
|
|
15
|
+
throw new Error(`The sandbox is not available on ${process.platform}. Set sandbox.mode to "off" in your user settings to run commands without it.`);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=launch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"launch.js","sourceRoot":"","sources":["../../../src/core/sandbox/launch.ts"],"names":[],"mappings":"AAAA,wGAAwG;AAGxG,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAStD;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CACnC,MAAqB,EACrB,MAAqB,EACrB,GAAW;IAEX,QAAQ,OAAO,CAAC,QAAQ,EAAE,CAAC;QAC1B,KAAK,QAAQ;YACZ,OAAO,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACzC,KAAK,OAAO;YACX,OAAO,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;QACpD;YACC,MAAM,IAAI,KAAK,CACd,mCAAmC,OAAO,CAAC,QAAQ,+EAA+E,CAClI,CAAC;IACJ,CAAC;AACF,CAAC","sourcesContent":["/** Starts sandboxed commands: wraps a process launch in the sandbox backend of the current platform. */\n\nimport type { SandboxPolicy } from \"./policy.ts\";\nimport { wrapWithSeatbelt } from \"./seatbelt.ts\";\nimport { wrapWithWindowsSandbox } from \"./windows.ts\";\n\n/** A process to start: the executable, its arguments, and its environment. */\nexport interface SandboxLaunch {\n\tcommand: string;\n\targs: string[];\n\tenv: NodeJS.ProcessEnv;\n}\n\n/**\n * Wrap `launch`, which starts in `cwd`, so the process runs under `policy`. Rejects when this platform has no\n * sandbox backend.\n */\nexport async function wrapForSandbox(\n\tpolicy: SandboxPolicy,\n\tlaunch: SandboxLaunch,\n\tcwd: string,\n): Promise<SandboxLaunch> {\n\tswitch (process.platform) {\n\t\tcase \"darwin\":\n\t\t\treturn wrapWithSeatbelt(policy, launch);\n\t\tcase \"win32\":\n\t\t\treturn wrapWithWindowsSandbox(policy, launch, cwd);\n\t\tdefault:\n\t\t\tthrow new Error(\n\t\t\t\t`The sandbox is not available on ${process.platform}. Set sandbox.mode to \"off\" in your user settings to run commands without it.`,\n\t\t\t);\n\t}\n}\n"]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sandbox policy: which folders the sandboxed shell tools and the write and edit tools may change, resolved from
|
|
3
|
+
* the sandbox settings for one working folder. The platform backends enforce it for commands; the write and edit
|
|
4
|
+
* tools check it themselves because they run inside the diffra process.
|
|
5
|
+
*/
|
|
6
|
+
import type { SandboxMode, WindowsSandboxBackend } from "../settings-schema.ts";
|
|
7
|
+
/** Sandbox settings with defaults applied. */
|
|
8
|
+
export interface SandboxConfig {
|
|
9
|
+
mode: SandboxMode;
|
|
10
|
+
network: boolean;
|
|
11
|
+
writableRoots: readonly string[];
|
|
12
|
+
windows: WindowsSandboxBackend;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Folders that stay read-only inside every writable folder, also before they exist: git metadata, whose hooks
|
|
16
|
+
* run unsandboxed on the user's next git command, and the agent's own configuration.
|
|
17
|
+
*/
|
|
18
|
+
export declare const PROTECTED_FOLDER_NAMES: readonly [".git", ".diffra", ".agents"];
|
|
19
|
+
/** A folder sandboxed writes may change, except its protected folders. */
|
|
20
|
+
export interface WritableFolder {
|
|
21
|
+
/** Canonical absolute path. */
|
|
22
|
+
path: string;
|
|
23
|
+
/** Canonical paths of the protected folders directly inside `path`. */
|
|
24
|
+
protectedPaths: string[];
|
|
25
|
+
}
|
|
26
|
+
/** What the sandbox allows, and which Windows backend enforces it there. A sandbox that is off has no policy. */
|
|
27
|
+
export type SandboxPolicy = {
|
|
28
|
+
kind: "read-only";
|
|
29
|
+
network: boolean;
|
|
30
|
+
windowsBackend: WindowsSandboxBackend;
|
|
31
|
+
} | {
|
|
32
|
+
kind: "workspace-write";
|
|
33
|
+
network: boolean;
|
|
34
|
+
writableFolders: WritableFolder[];
|
|
35
|
+
windowsBackend: WindowsSandboxBackend;
|
|
36
|
+
};
|
|
37
|
+
/** Resolves the sandbox policy for a tool call in `cwd`; undefined while the sandbox is off. */
|
|
38
|
+
export type SandboxPolicyResolver = (cwd: string) => SandboxPolicy | undefined;
|
|
39
|
+
/** Result of checking one write against a policy. */
|
|
40
|
+
export type SandboxWriteCheck = {
|
|
41
|
+
kind: "allowed";
|
|
42
|
+
} | {
|
|
43
|
+
kind: "denied";
|
|
44
|
+
reason: string;
|
|
45
|
+
};
|
|
46
|
+
/** Resolve `config` for the working folder `cwd`. */
|
|
47
|
+
export declare function resolveSandboxPolicy(config: SandboxConfig, cwd: string): SandboxPolicy | undefined;
|
|
48
|
+
/** Check whether `policy` allows writing the absolute path `path`, following symlinks of its existing part. */
|
|
49
|
+
export declare function checkSandboxWrite(policy: SandboxPolicy, path: string): SandboxWriteCheck;
|
|
50
|
+
//# sourceMappingURL=policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../../../src/core/sandbox/policy.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,OAAO,KAAK,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAEhF,8CAA8C;AAC9C,MAAM,WAAW,aAAa;IAC7B,IAAI,EAAE,WAAW,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,OAAO,EAAE,qBAAqB,CAAC;CAC/B;AAED;;;GAGG;AACH,eAAO,MAAM,sBAAsB,YAAI,MAAM,EAAE,SAAS,EAAE,SAAS,CAAU,CAAC;AAE9E,0EAA0E;AAC1E,MAAM,WAAW,cAAc;IAC9B,+BAA+B;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,uEAAuE;IACvE,cAAc,EAAE,MAAM,EAAE,CAAC;CACzB;AAED,iHAAiH;AACjH,MAAM,MAAM,aAAa,GACtB;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC;IAAC,cAAc,EAAE,qBAAqB,CAAA;CAAE,GAC9E;IACA,IAAI,EAAE,iBAAiB,CAAC;IACxB,OAAO,EAAE,OAAO,CAAC;IACjB,eAAe,EAAE,cAAc,EAAE,CAAC;IAClC,cAAc,EAAE,qBAAqB,CAAC;CACrC,CAAC;AAEL,gGAAgG;AAChG,MAAM,MAAM,qBAAqB,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,aAAa,GAAG,SAAS,CAAC;AAE/E,qDAAqD;AACrD,MAAM,MAAM,iBAAiB,GAAG;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAEzF,qDAAqD;AACrD,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAclG;AAqBD,+GAA+G;AAC/G,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,GAAG,iBAAiB,CAwBxF"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sandbox policy: which folders the sandboxed shell tools and the write and edit tools may change, resolved from
|
|
3
|
+
* the sandbox settings for one working folder. The platform backends enforce it for commands; the write and edit
|
|
4
|
+
* tools check it themselves because they run inside the diffra process.
|
|
5
|
+
*/
|
|
6
|
+
import { realpathSync } from "node:fs";
|
|
7
|
+
import { tmpdir } from "node:os";
|
|
8
|
+
import { basename, dirname, join } from "node:path";
|
|
9
|
+
import { getPathComparisonKey, isPathWithin, resolvePath } from "../../utils/paths.js";
|
|
10
|
+
/**
|
|
11
|
+
* Folders that stay read-only inside every writable folder, also before they exist: git metadata, whose hooks
|
|
12
|
+
* run unsandboxed on the user's next git command, and the agent's own configuration.
|
|
13
|
+
*/
|
|
14
|
+
export const PROTECTED_FOLDER_NAMES = [".git", ".diffra", ".agents"];
|
|
15
|
+
/** Resolve `config` for the working folder `cwd`. */
|
|
16
|
+
export function resolveSandboxPolicy(config, cwd) {
|
|
17
|
+
switch (config.mode) {
|
|
18
|
+
case "off":
|
|
19
|
+
return undefined;
|
|
20
|
+
case "read-only":
|
|
21
|
+
return { kind: "read-only", network: config.network, windowsBackend: config.windows };
|
|
22
|
+
case "workspace-write":
|
|
23
|
+
return {
|
|
24
|
+
kind: "workspace-write",
|
|
25
|
+
network: config.network,
|
|
26
|
+
writableFolders: getWritableFolders(config, cwd),
|
|
27
|
+
windowsBackend: config.windows,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function getWritableFolders(config, cwd) {
|
|
32
|
+
const folders = [];
|
|
33
|
+
const seen = new Set();
|
|
34
|
+
for (const path of [cwd, ...getTempFolders(), ...config.writableRoots.map((root) => resolvePath(root))]) {
|
|
35
|
+
const canonical = canonicalizeTarget(path);
|
|
36
|
+
const key = getPathComparisonKey(canonical);
|
|
37
|
+
if (seen.has(key))
|
|
38
|
+
continue;
|
|
39
|
+
seen.add(key);
|
|
40
|
+
folders.push({ path: canonical, protectedPaths: PROTECTED_FOLDER_NAMES.map((name) => join(canonical, name)) });
|
|
41
|
+
}
|
|
42
|
+
return folders;
|
|
43
|
+
}
|
|
44
|
+
// Commands keep working when compilers and package managers can write their scratch files. `/tmp` is listed apart
|
|
45
|
+
// from `TMPDIR` because macOS points `TMPDIR` at a per-user folder while many tools write to `/tmp` directly.
|
|
46
|
+
function getTempFolders() {
|
|
47
|
+
return process.platform === "win32" ? [tmpdir()] : [tmpdir(), "/tmp"];
|
|
48
|
+
}
|
|
49
|
+
/** Check whether `policy` allows writing the absolute path `path`, following symlinks of its existing part. */
|
|
50
|
+
export function checkSandboxWrite(policy, path) {
|
|
51
|
+
if (policy.kind === "read-only") {
|
|
52
|
+
return { kind: "denied", reason: `The sandbox is read-only, so ${path} cannot be written.` };
|
|
53
|
+
}
|
|
54
|
+
const target = canonicalizeTarget(path);
|
|
55
|
+
if (!policy.writableFolders.some((folder) => isPathWithin(folder.path, target))) {
|
|
56
|
+
const folders = policy.writableFolders.map((folder) => folder.path).join(", ");
|
|
57
|
+
return {
|
|
58
|
+
kind: "denied",
|
|
59
|
+
reason: `The sandbox only allows writing in ${folders}, so ${path} cannot be written.`,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
// Every protected folder counts, also one inside another writable folder: with `~/work` writable and the
|
|
63
|
+
// working folder `~/work/app`, `~/work/app/.git` stays read-only.
|
|
64
|
+
const protectedPath = policy.writableFolders
|
|
65
|
+
.flatMap((folder) => folder.protectedPaths)
|
|
66
|
+
.find((candidate) => isPathWithin(candidate, target));
|
|
67
|
+
if (protectedPath) {
|
|
68
|
+
return {
|
|
69
|
+
kind: "denied",
|
|
70
|
+
reason: `The sandbox keeps ${protectedPath} read-only, so ${path} cannot be written.`,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
return { kind: "allowed" };
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Canonical form of a path that may not exist yet: the real path of its deepest existing ancestor, followed by
|
|
77
|
+
* the missing names. Resolving only the full path would let a new file under a symlinked folder escape the check.
|
|
78
|
+
*/
|
|
79
|
+
function canonicalizeTarget(path) {
|
|
80
|
+
const missing = [];
|
|
81
|
+
let existing = path;
|
|
82
|
+
for (;;) {
|
|
83
|
+
try {
|
|
84
|
+
const real = realpathSync.native(existing);
|
|
85
|
+
return missing.length === 0 ? real : join(real, ...missing.reverse());
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
const parent = dirname(existing);
|
|
89
|
+
if (parent === existing)
|
|
90
|
+
return path;
|
|
91
|
+
missing.push(basename(existing));
|
|
92
|
+
existing = parent;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=policy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy.js","sourceRoot":"","sources":["../../../src/core/sandbox/policy.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAWvF;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,CAAU,CAAC;AA0B9E,qDAAqD;AACrD,MAAM,UAAU,oBAAoB,CAAC,MAAqB,EAAE,GAA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,aAAa,kBAAkB,IAAI,qBAAqB;SACrF,CAAC;IACH,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;AAC5B,CAAC;AAED;;;GAGG;AACH,SAAS,kBAAkB,CAAC,IAAY;IACvC,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,IAAI,QAAQ,GAAG,IAAI,CAAC;IACpB,SAAS,CAAC;QACT,IAAI,CAAC;YACJ,MAAM,IAAI,GAAG,YAAY,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC3C,OAAO,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;QACvE,CAAC;QAAC,MAAM,CAAC;YACR,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;YACjC,IAAI,MAAM,KAAK,QAAQ;gBAAE,OAAO,IAAI,CAAC;YACrC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;YACjC,QAAQ,GAAG,MAAM,CAAC;QACnB,CAAC;IACF,CAAC;AACF,CAAC","sourcesContent":["/**\n * Sandbox policy: which folders the sandboxed shell tools and the write and edit tools may change, resolved from\n * the sandbox settings for one working folder. The platform backends enforce it for commands; the write and edit\n * tools check it themselves because they run inside the diffra process.\n */\n\nimport { realpathSync } from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport { basename, dirname, join } from \"node:path\";\nimport { getPathComparisonKey, isPathWithin, resolvePath } from \"../../utils/paths.ts\";\nimport type { SandboxMode, WindowsSandboxBackend } from \"../settings-schema.ts\";\n\n/** Sandbox settings with defaults applied. */\nexport interface SandboxConfig {\n\tmode: SandboxMode;\n\tnetwork: boolean;\n\twritableRoots: readonly string[];\n\twindows: WindowsSandboxBackend;\n}\n\n/**\n * Folders that stay read-only inside every writable folder, also before they exist: git metadata, whose hooks\n * run unsandboxed on the user's next git command, and the agent's own configuration.\n */\nexport const PROTECTED_FOLDER_NAMES = [\".git\", \".diffra\", \".agents\"] as const;\n\n/** A folder sandboxed writes may change, except its protected folders. */\nexport interface WritableFolder {\n\t/** Canonical absolute path. */\n\tpath: string;\n\t/** Canonical paths of the protected folders directly inside `path`. */\n\tprotectedPaths: string[];\n}\n\n/** What the sandbox allows, and which Windows backend enforces it there. A sandbox that is off has no policy. */\nexport type SandboxPolicy =\n\t| { kind: \"read-only\"; network: boolean; windowsBackend: WindowsSandboxBackend }\n\t| {\n\t\t\tkind: \"workspace-write\";\n\t\t\tnetwork: boolean;\n\t\t\twritableFolders: WritableFolder[];\n\t\t\twindowsBackend: WindowsSandboxBackend;\n\t };\n\n/** Resolves the sandbox policy for a tool call in `cwd`; undefined while the sandbox is off. */\nexport type SandboxPolicyResolver = (cwd: string) => SandboxPolicy | undefined;\n\n/** Result of checking one write against a policy. */\nexport type SandboxWriteCheck = { kind: \"allowed\" } | { kind: \"denied\"; reason: string };\n\n/** Resolve `config` for the working folder `cwd`. */\nexport function resolveSandboxPolicy(config: SandboxConfig, cwd: string): SandboxPolicy | undefined {\n\tswitch (config.mode) {\n\t\tcase \"off\":\n\t\t\treturn undefined;\n\t\tcase \"read-only\":\n\t\t\treturn { kind: \"read-only\", network: config.network, windowsBackend: config.windows };\n\t\tcase \"workspace-write\":\n\t\t\treturn {\n\t\t\t\tkind: \"workspace-write\",\n\t\t\t\tnetwork: config.network,\n\t\t\t\twritableFolders: getWritableFolders(config, cwd),\n\t\t\t\twindowsBackend: config.windows,\n\t\t\t};\n\t}\n}\n\nfunction getWritableFolders(config: SandboxConfig, cwd: string): WritableFolder[] {\n\tconst folders: WritableFolder[] = [];\n\tconst seen = new Set<string>();\n\tfor (const path of [cwd, ...getTempFolders(), ...config.writableRoots.map((root) => resolvePath(root))]) {\n\t\tconst canonical = canonicalizeTarget(path);\n\t\tconst key = getPathComparisonKey(canonical);\n\t\tif (seen.has(key)) continue;\n\t\tseen.add(key);\n\t\tfolders.push({ path: canonical, protectedPaths: PROTECTED_FOLDER_NAMES.map((name) => join(canonical, name)) });\n\t}\n\treturn folders;\n}\n\n// Commands keep working when compilers and package managers can write their scratch files. `/tmp` is listed apart\n// from `TMPDIR` because macOS points `TMPDIR` at a per-user folder while many tools write to `/tmp` directly.\nfunction getTempFolders(): string[] {\n\treturn process.platform === \"win32\" ? [tmpdir()] : [tmpdir(), \"/tmp\"];\n}\n\n/** Check whether `policy` allows writing the absolute path `path`, following symlinks of its existing part. */\nexport function checkSandboxWrite(policy: SandboxPolicy, path: string): SandboxWriteCheck {\n\tif (policy.kind === \"read-only\") {\n\t\treturn { kind: \"denied\", reason: `The sandbox is read-only, so ${path} cannot be written.` };\n\t}\n\tconst target = canonicalizeTarget(path);\n\tif (!policy.writableFolders.some((folder) => isPathWithin(folder.path, target))) {\n\t\tconst folders = policy.writableFolders.map((folder) => folder.path).join(\", \");\n\t\treturn {\n\t\t\tkind: \"denied\",\n\t\t\treason: `The sandbox only allows writing in ${folders}, so ${path} cannot be written.`,\n\t\t};\n\t}\n\t// Every protected folder counts, also one inside another writable folder: with `~/work` writable and the\n\t// working folder `~/work/app`, `~/work/app/.git` stays read-only.\n\tconst protectedPath = policy.writableFolders\n\t\t.flatMap((folder) => folder.protectedPaths)\n\t\t.find((candidate) => isPathWithin(candidate, target));\n\tif (protectedPath) {\n\t\treturn {\n\t\t\tkind: \"denied\",\n\t\t\treason: `The sandbox keeps ${protectedPath} read-only, so ${path} cannot be written.`,\n\t\t};\n\t}\n\treturn { kind: \"allowed\" };\n}\n\n/**\n * Canonical form of a path that may not exist yet: the real path of its deepest existing ancestor, followed by\n * the missing names. Resolving only the full path would let a new file under a symlinked folder escape the check.\n */\nfunction canonicalizeTarget(path: string): string {\n\tconst missing: string[] = [];\n\tlet existing = path;\n\tfor (;;) {\n\t\ttry {\n\t\t\tconst real = realpathSync.native(existing);\n\t\t\treturn missing.length === 0 ? real : join(real, ...missing.reverse());\n\t\t} catch {\n\t\t\tconst parent = dirname(existing);\n\t\t\tif (parent === existing) return path;\n\t\t\tmissing.push(basename(existing));\n\t\t\texisting = parent;\n\t\t}\n\t}\n}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* macOS sandbox backend: runs a command under Seatbelt through the system's `sandbox-exec`, with a profile that
|
|
3
|
+
* denies everything and then allows what the policy grants. Paths go in as `-D` parameters, so the profile never
|
|
4
|
+
* has to quote them.
|
|
5
|
+
*/
|
|
6
|
+
import type { SandboxLaunch } from "./launch.ts";
|
|
7
|
+
import type { SandboxPolicy } from "./policy.ts";
|
|
8
|
+
/** A Seatbelt profile and the values of the parameters it names. */
|
|
9
|
+
export interface SeatbeltProfile {
|
|
10
|
+
profile: string;
|
|
11
|
+
params: Array<[name: string, value: string]>;
|
|
12
|
+
}
|
|
13
|
+
/** Wrap `launch` in `sandbox-exec` with the profile of `policy`. */
|
|
14
|
+
export declare function wrapWithSeatbelt(policy: SandboxPolicy, launch: SandboxLaunch): SandboxLaunch;
|
|
15
|
+
/** Build the Seatbelt profile that enforces `policy`. Later rules win over earlier ones. */
|
|
16
|
+
export declare function buildSeatbeltProfile(policy: SandboxPolicy): SeatbeltProfile;
|
|
17
|
+
//# sourceMappingURL=seatbelt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"seatbelt.d.ts","sourceRoot":"","sources":["../../../src/core/sandbox/seatbelt.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAkB,MAAM,aAAa,CAAC;AAEjE,oEAAoE;AACpE,MAAM,WAAW,eAAe;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,KAAK,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;CAC7C;AAKD,oEAAoE;AACpE,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,aAAa,GAAG,aAAa,CAc5F;AAED,4FAA4F;AAC5F,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,aAAa,GAAG,eAAe,CAO3E"}
|