@waq666/pneuma 0.0.0-stage → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +206 -3
- package/bin/dsc.js +91 -0
- package/bin/headless.cjs +40 -0
- package/lib/adapter/core-runtime.d.ts +11 -0
- package/lib/adapter/core-runtime.js +259 -0
- package/lib/adapter/host.d.ts +18 -0
- package/lib/adapter/host.js +14 -0
- package/lib/adapter/runtime.d.ts +15 -0
- package/lib/adapter/runtime.js +290 -0
- package/lib/adapter/transcript.d.ts +184 -0
- package/lib/adapter/transcript.js +605 -0
- package/lib/app/AgentsOverlay.d.ts +18 -0
- package/lib/app/AgentsOverlay.js +63 -0
- package/lib/app/App.d.ts +15 -0
- package/lib/app/App.js +1650 -0
- package/lib/app/App.js.nv-backup +1650 -0
- package/lib/app/ApprovalCard.d.ts +12 -0
- package/lib/app/ApprovalCard.js +76 -0
- package/lib/app/AskCard.d.ts +20 -0
- package/lib/app/AskCard.js +45 -0
- package/lib/app/ChatView.d.ts +63 -0
- package/lib/app/ChatView.js +310 -0
- package/lib/app/Composer.d.ts +50 -0
- package/lib/app/Composer.js +282 -0
- package/lib/app/DiffBlock.d.ts +6 -0
- package/lib/app/DiffBlock.js +37 -0
- package/lib/app/MarkdownView.d.ts +6 -0
- package/lib/app/MarkdownView.js +99 -0
- package/lib/app/ModelPicker.d.ts +7 -0
- package/lib/app/ModelPicker.js +18 -0
- package/lib/app/PlanReviewCard.d.ts +13 -0
- package/lib/app/PlanReviewCard.js +54 -0
- package/lib/app/PresetPicker.d.ts +11 -0
- package/lib/app/PresetPicker.js +19 -0
- package/lib/app/PreviewOverlay.d.ts +14 -0
- package/lib/app/PreviewOverlay.js +22 -0
- package/lib/app/SessionPicker.d.ts +43 -0
- package/lib/app/SessionPicker.js +56 -0
- package/lib/app/SettingsOverlay.d.ts +32 -0
- package/lib/app/SettingsOverlay.js +157 -0
- package/lib/app/SkillsPicker.d.ts +7 -0
- package/lib/app/SkillsPicker.js +19 -0
- package/lib/app/StatusBar.d.ts +22 -0
- package/lib/app/StatusBar.js +201 -0
- package/lib/app/TaskStrips.d.ts +13 -0
- package/lib/app/TaskStrips.js +40 -0
- package/lib/app/TimelineRail.d.ts +22 -0
- package/lib/app/TimelineRail.js +160 -0
- package/lib/app/TimelineRail.js.negbak +98 -0
- package/lib/app/TimelineRail.js.nv-backup +160 -0
- package/lib/app/ToolCard.d.ts +11 -0
- package/lib/app/ToolCard.js +64 -0
- package/lib/app/ToolCard.js.nv-backup +64 -0
- package/lib/app/TranscriptOverlay.d.ts +27 -0
- package/lib/app/TranscriptOverlay.js +36 -0
- package/lib/app/TranscriptViewport.d.ts +78 -0
- package/lib/app/TranscriptViewport.js +218 -0
- package/lib/app/Welcome.d.ts +6 -0
- package/lib/app/Welcome.js +71 -0
- package/lib/app/attach.d.ts +16 -0
- package/lib/app/attach.js +58 -0
- package/lib/app/click.d.ts +40 -0
- package/lib/app/click.js +103 -0
- package/lib/app/clipboard-image.d.ts +11 -0
- package/lib/app/clipboard-image.js +66 -0
- package/lib/app/cursor.d.ts +4 -0
- package/lib/app/cursor.js +24 -0
- package/lib/app/hello.d.ts +11 -0
- package/lib/app/hello.js +8 -0
- package/lib/app/history-store.d.ts +4 -0
- package/lib/app/history-store.js +41 -0
- package/lib/app/image-blocks.d.ts +12 -0
- package/lib/app/image-blocks.js +125 -0
- package/lib/app/keymap.d.ts +56 -0
- package/lib/app/keymap.js +56 -0
- package/lib/app/markdown.d.ts +54 -0
- package/lib/app/markdown.js +189 -0
- package/lib/app/mouse.d.ts +33 -0
- package/lib/app/mouse.js +35 -0
- package/lib/app/pointer.d.ts +16 -0
- package/lib/app/pointer.js +60 -0
- package/lib/app/scroll-model.d.ts +240 -0
- package/lib/app/scroll-model.js +347 -0
- package/lib/app/settings-model.d.ts +69 -0
- package/lib/app/settings-model.js +114 -0
- package/lib/app/snapshot-subscribe.d.ts +34 -0
- package/lib/app/snapshot-subscribe.js +110 -0
- package/lib/app/theme.d.ts +194 -0
- package/lib/app/theme.js +186 -0
- package/lib/app/ticker.d.ts +7 -0
- package/lib/app/ticker.js +53 -0
- package/lib/boot.d.ts +1 -0
- package/lib/boot.js +34 -0
- package/lib/commands.d.ts +49 -0
- package/lib/commands.js +115 -0
- package/lib/contract.d.ts +1973 -0
- package/lib/contract.js +36 -0
- package/lib/core/agent-roles.d.ts +52 -0
- package/lib/core/agent-roles.js +274 -0
- package/lib/core/approval-floor.d.ts +183 -0
- package/lib/core/approval-floor.js +679 -0
- package/lib/core/approval.d.ts +42 -0
- package/lib/core/approval.js +8 -0
- package/lib/core/audit.d.ts +61 -0
- package/lib/core/audit.js +59 -0
- package/lib/core/boot-notices.d.ts +6 -0
- package/lib/core/boot-notices.js +61 -0
- package/lib/core/cdp/actions.d.ts +182 -0
- package/lib/core/cdp/actions.js +649 -0
- package/lib/core/cdp/launch.d.ts +192 -0
- package/lib/core/cdp/launch.js +491 -0
- package/lib/core/cdp/snapshot.d.ts +139 -0
- package/lib/core/cdp/snapshot.js +316 -0
- package/lib/core/cdp/transport.d.ts +160 -0
- package/lib/core/cdp/transport.js +359 -0
- package/lib/core/command-policy.d.ts +108 -0
- package/lib/core/command-policy.js +580 -0
- package/lib/core/commands-completion.d.ts +78 -0
- package/lib/core/commands-completion.js +167 -0
- package/lib/core/compact-anchors.d.ts +76 -0
- package/lib/core/compact-anchors.js +284 -0
- package/lib/core/compact.d.ts +110 -0
- package/lib/core/compact.js +210 -0
- package/lib/core/config-store.d.ts +38 -0
- package/lib/core/config-store.js +307 -0
- package/lib/core/config.d.ts +36 -0
- package/lib/core/config.js +124 -0
- package/lib/core/connection-test.d.ts +60 -0
- package/lib/core/connection-test.js +84 -0
- package/lib/core/desktop-control.d.ts +298 -0
- package/lib/core/desktop-control.js +1311 -0
- package/lib/core/diff-text.d.ts +74 -0
- package/lib/core/diff-text.js +257 -0
- package/lib/core/dock-browser.d.ts +137 -0
- package/lib/core/dock-browser.js +146 -0
- package/lib/core/dock-ops.d.ts +59 -0
- package/lib/core/dock-ops.js +104 -0
- package/lib/core/dock-session.d.ts +39 -0
- package/lib/core/dock-session.js +28 -0
- package/lib/core/dsh-compat/hook.d.ts +18 -0
- package/lib/core/dsh-compat/hook.js +52 -0
- package/lib/core/dsh-compat/resolve-hook.d.ts +5 -0
- package/lib/core/dsh-compat/resolve-hook.js +59 -0
- package/lib/core/dsh-compat/tools-facade.d.ts +47 -0
- package/lib/core/dsh-compat/tools-facade.js +108 -0
- package/lib/core/err-text.d.ts +13 -0
- package/lib/core/err-text.js +15 -0
- package/lib/core/events.d.ts +149 -0
- package/lib/core/events.js +1 -0
- package/lib/core/git-exec.d.ts +23 -0
- package/lib/core/git-exec.js +72 -0
- package/lib/core/git-info.d.ts +47 -0
- package/lib/core/git-info.js +157 -0
- package/lib/core/goal.d.ts +89 -0
- package/lib/core/goal.js +189 -0
- package/lib/core/hooks.d.ts +272 -0
- package/lib/core/hooks.js +818 -0
- package/lib/core/host-browser-link.d.ts +59 -0
- package/lib/core/host-browser-link.js +9 -0
- package/lib/core/host-methods.d.ts +25 -0
- package/lib/core/host-methods.js +103 -0
- package/lib/core/image-diet.d.ts +77 -0
- package/lib/core/image-diet.js +127 -0
- package/lib/core/learnings/ledger.d.ts +73 -0
- package/lib/core/learnings/ledger.js +273 -0
- package/lib/core/learnings/skill-write.d.ts +250 -0
- package/lib/core/learnings/skill-write.js +854 -0
- package/lib/core/learnings/store.d.ts +102 -0
- package/lib/core/learnings/store.js +266 -0
- package/lib/core/lifecycle-hooks.d.ts +189 -0
- package/lib/core/lifecycle-hooks.js +576 -0
- package/lib/core/llm.d.ts +283 -0
- package/lib/core/llm.js +565 -0
- package/lib/core/lockfile.d.ts +17 -0
- package/lib/core/lockfile.js +110 -0
- package/lib/core/loop.d.ts +185 -0
- package/lib/core/loop.js +587 -0
- package/lib/core/lsp/client.d.ts +189 -0
- package/lib/core/lsp/client.js +690 -0
- package/lib/core/lsp/framing.d.ts +84 -0
- package/lib/core/lsp/framing.js +181 -0
- package/lib/core/lsp/line-shift.d.ts +28 -0
- package/lib/core/lsp/line-shift.js +127 -0
- package/lib/core/lsp/manager.d.ts +93 -0
- package/lib/core/lsp/manager.js +418 -0
- package/lib/core/lsp/normalize.d.ts +32 -0
- package/lib/core/lsp/normalize.js +139 -0
- package/lib/core/lsp/servers.d.ts +106 -0
- package/lib/core/lsp/servers.js +352 -0
- package/lib/core/lsp/uri.d.ts +76 -0
- package/lib/core/lsp/uri.js +179 -0
- package/lib/core/market.d.ts +51 -0
- package/lib/core/market.js +358 -0
- package/lib/core/mcp.d.ts +201 -0
- package/lib/core/mcp.js +836 -0
- package/lib/core/memory-eval.d.ts +158 -0
- package/lib/core/memory-eval.js +215 -0
- package/lib/core/memory.d.ts +266 -0
- package/lib/core/memory.js +703 -0
- package/lib/core/mention.d.ts +57 -0
- package/lib/core/mention.js +129 -0
- package/lib/core/microcompact.d.ts +48 -0
- package/lib/core/microcompact.js +79 -0
- package/lib/core/migrate.d.ts +56 -0
- package/lib/core/migrate.js +134 -0
- package/lib/core/model-caps.d.ts +83 -0
- package/lib/core/model-caps.js +150 -0
- package/lib/core/model-discovery.d.ts +19 -0
- package/lib/core/model-discovery.js +69 -0
- package/lib/core/modes.d.ts +72 -0
- package/lib/core/modes.js +152 -0
- package/lib/core/native-bridge.d.ts +135 -0
- package/lib/core/native-bridge.js +563 -0
- package/lib/core/path-policy.d.ts +32 -0
- package/lib/core/path-policy.js +248 -0
- package/lib/core/permission-presets.d.ts +67 -0
- package/lib/core/permission-presets.js +75 -0
- package/lib/core/plugin-loader.d.ts +36 -0
- package/lib/core/plugin-loader.js +294 -0
- package/lib/core/plugin-registry.d.ts +113 -0
- package/lib/core/plugin-registry.js +256 -0
- package/lib/core/prefs.d.ts +82 -0
- package/lib/core/prefs.js +372 -0
- package/lib/core/presets.d.ts +80 -0
- package/lib/core/presets.js +373 -0
- package/lib/core/pricing.d.ts +90 -0
- package/lib/core/pricing.js +126 -0
- package/lib/core/prompt.d.ts +92 -0
- package/lib/core/prompt.js +339 -0
- package/lib/core/ptc.d.ts +66 -0
- package/lib/core/ptc.js +70 -0
- package/lib/core/remote/frames.d.ts +91 -0
- package/lib/core/remote/frames.js +174 -0
- package/lib/core/remote/notify.d.ts +54 -0
- package/lib/core/remote/notify.js +77 -0
- package/lib/core/remote/owner.d.ts +32 -0
- package/lib/core/remote/owner.js +75 -0
- package/lib/core/remote/pairing.d.ts +104 -0
- package/lib/core/remote/pairing.js +261 -0
- package/lib/core/remote/push.d.ts +80 -0
- package/lib/core/remote/push.js +222 -0
- package/lib/core/remote/store.d.ts +18 -0
- package/lib/core/remote/store.js +59 -0
- package/lib/core/remote/tickets.d.ts +20 -0
- package/lib/core/remote/tickets.js +49 -0
- package/lib/core/remote/uploads.d.ts +63 -0
- package/lib/core/remote/uploads.js +161 -0
- package/lib/core/request-attribution.d.ts +26 -0
- package/lib/core/request-attribution.js +86 -0
- package/lib/core/request-invariant.d.ts +61 -0
- package/lib/core/request-invariant.js +199 -0
- package/lib/core/sandbox/backends.d.ts +64 -0
- package/lib/core/sandbox/backends.js +194 -0
- package/lib/core/sandbox/execpolicy.d.ts +93 -0
- package/lib/core/sandbox/execpolicy.js +452 -0
- package/lib/core/sandbox/net-proxy.d.ts +31 -0
- package/lib/core/sandbox/net-proxy.js +162 -0
- package/lib/core/sandbox/policy.d.ts +211 -0
- package/lib/core/sandbox/policy.js +559 -0
- package/lib/core/sandbox/win/abi.d.ts +161 -0
- package/lib/core/sandbox/win/abi.js +169 -0
- package/lib/core/sandbox/win/account.d.ts +71 -0
- package/lib/core/sandbox/win/account.js +206 -0
- package/lib/core/sandbox/win/acl.d.ts +54 -0
- package/lib/core/sandbox/win/acl.js +339 -0
- package/lib/core/sandbox/win/backend.d.ts +61 -0
- package/lib/core/sandbox/win/backend.js +249 -0
- package/lib/core/sandbox/win/doctor.d.ts +24 -0
- package/lib/core/sandbox/win/doctor.js +272 -0
- package/lib/core/sandbox/win/ffi.d.ts +107 -0
- package/lib/core/sandbox/win/ffi.js +166 -0
- package/lib/core/sandbox/win/net-abi.d.ts +154 -0
- package/lib/core/sandbox/win/net-abi.js +316 -0
- package/lib/core/sandbox/win/runner-entry.d.ts +35 -0
- package/lib/core/sandbox/win/runner-entry.js +391 -0
- package/lib/core/sandbox/win/setup.d.ts +60 -0
- package/lib/core/sandbox/win/setup.js +986 -0
- package/lib/core/sandbox/win/token.d.ts +35 -0
- package/lib/core/sandbox/win/token.js +238 -0
- package/lib/core/sandbox/win/wfp.d.ts +41 -0
- package/lib/core/sandbox/win/wfp.js +200 -0
- package/lib/core/sandbox/win/workspace-sid.d.ts +9 -0
- package/lib/core/sandbox/win/workspace-sid.js +45 -0
- package/lib/core/schedule/rule.d.ts +184 -0
- package/lib/core/schedule/rule.js +745 -0
- package/lib/core/schedule/runner.d.ts +185 -0
- package/lib/core/schedule/runner.js +678 -0
- package/lib/core/schedule/store.d.ts +182 -0
- package/lib/core/schedule/store.js +455 -0
- package/lib/core/secrets.d.ts +41 -0
- package/lib/core/secrets.js +150 -0
- package/lib/core/session-export.d.ts +18 -0
- package/lib/core/session-export.js +73 -0
- package/lib/core/session-index.d.ts +159 -0
- package/lib/core/session-index.js +683 -0
- package/lib/core/session-meta.d.ts +41 -0
- package/lib/core/session-meta.js +97 -0
- package/lib/core/session.d.ts +356 -0
- package/lib/core/session.js +998 -0
- package/lib/core/skills.d.ts +60 -0
- package/lib/core/skills.js +171 -0
- package/lib/core/spill.d.ts +159 -0
- package/lib/core/spill.js +329 -0
- package/lib/core/surface-registry.d.ts +45 -0
- package/lib/core/surface-registry.js +67 -0
- package/lib/core/team-board.d.ts +95 -0
- package/lib/core/team-board.js +316 -0
- package/lib/core/throughput.d.ts +46 -0
- package/lib/core/throughput.js +40 -0
- package/lib/core/todo-reminder.d.ts +44 -0
- package/lib/core/todo-reminder.js +55 -0
- package/lib/core/todo.d.ts +81 -0
- package/lib/core/todo.js +222 -0
- package/lib/core/token-estimate.d.ts +55 -0
- package/lib/core/token-estimate.js +82 -0
- package/lib/core/tool-guards.d.ts +103 -0
- package/lib/core/tool-guards.js +77 -0
- package/lib/core/tool-search.d.ts +152 -0
- package/lib/core/tool-search.js +311 -0
- package/lib/core/tools/bash.d.ts +281 -0
- package/lib/core/tools/bash.js +871 -0
- package/lib/core/tools/command-runner.d.ts +84 -0
- package/lib/core/tools/command-runner.js +68 -0
- package/lib/core/tools/fs-tools.d.ts +23 -0
- package/lib/core/tools/fs-tools.js +247 -0
- package/lib/core/tools/index.d.ts +8 -0
- package/lib/core/tools/index.js +4 -0
- package/lib/core/tools/sandbox-args.d.ts +51 -0
- package/lib/core/tools/sandbox-args.js +90 -0
- package/lib/core/tools/search-tools.d.ts +3 -0
- package/lib/core/tools/search-tools.js +153 -0
- package/lib/core/tools.d.ts +96 -0
- package/lib/core/tools.js +53 -0
- package/lib/core/ui-boot-source.d.ts +71 -0
- package/lib/core/ui-boot-source.js +121 -0
- package/lib/core/ui-bundles.d.ts +249 -0
- package/lib/core/ui-bundles.js +830 -0
- package/lib/core/ui-combo.d.ts +49 -0
- package/lib/core/ui-combo.js +55 -0
- package/lib/core/ui-events.d.ts +81 -0
- package/lib/core/ui-events.js +364 -0
- package/lib/core/ui-hmr.d.ts +36 -0
- package/lib/core/ui-hmr.js +128 -0
- package/lib/core/ui-methods.d.ts +69 -0
- package/lib/core/ui-methods.js +341 -0
- package/lib/core/ui-route.d.ts +69 -0
- package/lib/core/ui-route.js +122 -0
- package/lib/core/ui-server.d.ts +75 -0
- package/lib/core/ui-server.js +369 -0
- package/lib/core/ui-trust.d.ts +47 -0
- package/lib/core/ui-trust.js +164 -0
- package/lib/core/untrusted.d.ts +30 -0
- package/lib/core/untrusted.js +48 -0
- package/lib/core/update-check.d.ts +81 -0
- package/lib/core/update-check.js +177 -0
- package/lib/core/usage-log.d.ts +82 -0
- package/lib/core/usage-log.js +306 -0
- package/lib/core/version.d.ts +1 -0
- package/lib/core/version.js +37 -0
- package/lib/core/web-http.d.ts +57 -0
- package/lib/core/web-http.js +137 -0
- package/lib/core/web-static.d.ts +31 -0
- package/lib/core/web-static.js +75 -0
- package/lib/headless.d.ts +1 -0
- package/lib/headless.js +31 -0
- package/lib/host/kernel.d.ts +33 -0
- package/lib/host/kernel.js +451 -0
- package/lib/index.d.ts +41 -0
- package/lib/index.js +35 -0
- package/lib/plugins/agent.d.ts +2 -0
- package/lib/plugins/agent.js +274 -0
- package/lib/plugins/approval-floor.d.ts +2 -0
- package/lib/plugins/approval-floor.js +223 -0
- package/lib/plugins/approval.d.ts +16 -0
- package/lib/plugins/approval.js +674 -0
- package/lib/plugins/ask.d.ts +2 -0
- package/lib/plugins/ask.js +245 -0
- package/lib/plugins/browser.d.ts +68 -0
- package/lib/plugins/browser.js +1341 -0
- package/lib/plugins/commands.d.ts +23 -0
- package/lib/plugins/commands.js +498 -0
- package/lib/plugins/compact.d.ts +21 -0
- package/lib/plugins/compact.js +274 -0
- package/lib/plugins/computer-use.d.ts +47 -0
- package/lib/plugins/computer-use.js +539 -0
- package/lib/plugins/desktop-dock.d.ts +2 -0
- package/lib/plugins/desktop-dock.js +626 -0
- package/lib/plugins/dock-browser.d.ts +34 -0
- package/lib/plugins/dock-browser.js +765 -0
- package/lib/plugins/dsh-compat.d.ts +25 -0
- package/lib/plugins/dsh-compat.js +37 -0
- package/lib/plugins/file-review.d.ts +108 -0
- package/lib/plugins/file-review.js +393 -0
- package/lib/plugins/git.d.ts +26 -0
- package/lib/plugins/git.js +132 -0
- package/lib/plugins/goal.d.ts +20 -0
- package/lib/plugins/goal.js +245 -0
- package/lib/plugins/guards.d.ts +14 -0
- package/lib/plugins/guards.js +18 -0
- package/lib/plugins/hooks.d.ts +19 -0
- package/lib/plugins/hooks.js +583 -0
- package/lib/plugins/host-stdio.d.ts +88 -0
- package/lib/plugins/host-stdio.js +317 -0
- package/lib/plugins/image-diet.d.ts +17 -0
- package/lib/plugins/image-diet.js +85 -0
- package/lib/plugins/lifecycle-hooks.d.ts +26 -0
- package/lib/plugins/lifecycle-hooks.js +338 -0
- package/lib/plugins/llm.d.ts +13 -0
- package/lib/plugins/llm.js +215 -0
- package/lib/plugins/lsp.d.ts +54 -0
- package/lib/plugins/lsp.js +608 -0
- package/lib/plugins/mcp.d.ts +16 -0
- package/lib/plugins/mcp.js +673 -0
- package/lib/plugins/memory.d.ts +17 -0
- package/lib/plugins/memory.js +858 -0
- package/lib/plugins/microcompact.d.ts +18 -0
- package/lib/plugins/microcompact.js +119 -0
- package/lib/plugins/mode.d.ts +18 -0
- package/lib/plugins/mode.js +115 -0
- package/lib/plugins/permission-presets.d.ts +18 -0
- package/lib/plugins/permission-presets.js +135 -0
- package/lib/plugins/plan.d.ts +2 -0
- package/lib/plugins/plan.js +192 -0
- package/lib/plugins/plugin-manager.d.ts +2 -0
- package/lib/plugins/plugin-manager.js +165 -0
- package/lib/plugins/presets.d.ts +2 -0
- package/lib/plugins/presets.js +182 -0
- package/lib/plugins/prompt.d.ts +2 -0
- package/lib/plugins/prompt.js +264 -0
- package/lib/plugins/ptc.d.ts +2 -0
- package/lib/plugins/ptc.js +272 -0
- package/lib/plugins/remote/http.d.ts +11 -0
- package/lib/plugins/remote/http.js +11 -0
- package/lib/plugins/remote/routes.d.ts +24 -0
- package/lib/plugins/remote/routes.js +384 -0
- package/lib/plugins/remote/types.d.ts +135 -0
- package/lib/plugins/remote/types.js +87 -0
- package/lib/plugins/remote.d.ts +17 -0
- package/lib/plugins/remote.js +1028 -0
- package/lib/plugins/runtime-api.d.ts +16 -0
- package/lib/plugins/runtime-api.js +99 -0
- package/lib/plugins/runtime.d.ts +10 -0
- package/lib/plugins/runtime.js +451 -0
- package/lib/plugins/sandbox.d.ts +2 -0
- package/lib/plugins/sandbox.js +761 -0
- package/lib/plugins/schedule.d.ts +26 -0
- package/lib/plugins/schedule.js +538 -0
- package/lib/plugins/self-improve.d.ts +61 -0
- package/lib/plugins/self-improve.js +953 -0
- package/lib/plugins/session-search.d.ts +16 -0
- package/lib/plugins/session-search.js +308 -0
- package/lib/plugins/session-title.d.ts +19 -0
- package/lib/plugins/session-title.js +109 -0
- package/lib/plugins/session.d.ts +7 -0
- package/lib/plugins/session.js +296 -0
- package/lib/plugins/settings.d.ts +3 -0
- package/lib/plugins/settings.js +705 -0
- package/lib/plugins/skills.d.ts +2 -0
- package/lib/plugins/skills.js +360 -0
- package/lib/plugins/spill.d.ts +16 -0
- package/lib/plugins/spill.js +200 -0
- package/lib/plugins/subagent.d.ts +2 -0
- package/lib/plugins/subagent.js +896 -0
- package/lib/plugins/surfaces.d.ts +11 -0
- package/lib/plugins/surfaces.js +20 -0
- package/lib/plugins/team.d.ts +16 -0
- package/lib/plugins/team.js +149 -0
- package/lib/plugins/todo.d.ts +19 -0
- package/lib/plugins/todo.js +188 -0
- package/lib/plugins/tool-search.d.ts +2 -0
- package/lib/plugins/tool-search.js +434 -0
- package/lib/plugins/tool-search.js.nv-backup +434 -0
- package/lib/plugins/tools-default.d.ts +12 -0
- package/lib/plugins/tools-default.js +275 -0
- package/lib/plugins/tools.d.ts +16 -0
- package/lib/plugins/tools.js +62 -0
- package/lib/plugins/transcript.d.ts +15 -0
- package/lib/plugins/transcript.js +311 -0
- package/lib/plugins/tui.d.ts +2 -0
- package/lib/plugins/tui.js +98 -0
- package/lib/plugins/waiting.d.ts +12 -0
- package/lib/plugins/waiting.js +34 -0
- package/lib/plugins/web-search.d.ts +14 -0
- package/lib/plugins/web-search.js +263 -0
- package/lib/plugins/webserver.d.ts +48 -0
- package/lib/plugins/webserver.js +228 -0
- package/lib/remote/assets/app-DAcUCOEn.js +14 -0
- package/lib/remote/assets/icon-192.png +0 -0
- package/lib/remote/assets/icon-512.png +0 -0
- package/lib/remote/assets/index.html +34 -0
- package/lib/remote/assets/manifest.json +27 -0
- package/lib/remote/assets/style-DIB6729x.css +1 -0
- package/lib/remote/assets/sw.js +66 -0
- package/lib/services/types.d.ts +1228 -0
- package/lib/services/types.js +1 -0
- package/lib/tools/config-cli.d.ts +1 -0
- package/lib/tools/config-cli.js +89 -0
- package/lib/ui/arrival.d.ts +72 -0
- package/lib/ui/arrival.js +105 -0
- package/lib/ui/assets/app-B70nVIKd.js +69 -0
- package/lib/ui/assets/chunk-2UxHyX5q.js +1 -0
- package/lib/ui/assets/chunk-B1dDrJ26.js +1 -0
- package/lib/ui/assets/chunk-B6aJPvgy.js +1 -0
- package/lib/ui/assets/chunk-BEwlwnbL.js +1 -0
- package/lib/ui/assets/chunk-BGcgwlCI.js +12 -0
- package/lib/ui/assets/chunk-BIGW1oBm.js +1 -0
- package/lib/ui/assets/chunk-BPQ3VLAy.js +1 -0
- package/lib/ui/assets/chunk-BRH0KZbk.js +141 -0
- package/lib/ui/assets/chunk-BX6H_ySx.js +1 -0
- package/lib/ui/assets/chunk-B_P3UbPa.js +1 -0
- package/lib/ui/assets/chunk-B_TYUkTI.js +1 -0
- package/lib/ui/assets/chunk-B_vNuMnf.js +1 -0
- package/lib/ui/assets/chunk-BajyYBss.js +10 -0
- package/lib/ui/assets/chunk-BdnUsdx6.js +1 -0
- package/lib/ui/assets/chunk-Buea-lGh.js +1 -0
- package/lib/ui/assets/chunk-C0PvZCCE.js +1 -0
- package/lib/ui/assets/chunk-C0m74zRD.js +1 -0
- package/lib/ui/assets/chunk-C27-OAKa.js +1 -0
- package/lib/ui/assets/chunk-C2oV4EkX.js +1 -0
- package/lib/ui/assets/chunk-C7zT0LnQ.js +1 -0
- package/lib/ui/assets/chunk-C9GSunVT.js +1 -0
- package/lib/ui/assets/chunk-C9tS-k6U.js +1 -0
- package/lib/ui/assets/chunk-CHLpvVh8.js +1 -0
- package/lib/ui/assets/chunk-CLxacb5B.js +1 -0
- package/lib/ui/assets/chunk-COt5Ahok.js +1 -0
- package/lib/ui/assets/chunk-CPTIWCL2.js +1 -0
- package/lib/ui/assets/chunk-CQLl-L-p.js +1 -0
- package/lib/ui/assets/chunk-CUWRgxuq.js +55 -0
- package/lib/ui/assets/chunk-CWanVSXC.js +1 -0
- package/lib/ui/assets/chunk-Cf5RLm7j.js +1 -0
- package/lib/ui/assets/chunk-CickPsom.js +1 -0
- package/lib/ui/assets/chunk-Cj5Yp3dK.js +1 -0
- package/lib/ui/assets/chunk-Cmh6b_Ma.js +1 -0
- package/lib/ui/assets/chunk-Cp-IABpG.js +1 -0
- package/lib/ui/assets/chunk-CqE71os6.js +1 -0
- package/lib/ui/assets/chunk-CtKP3W-j.js +1 -0
- package/lib/ui/assets/chunk-Cvjx9yec.js +1 -0
- package/lib/ui/assets/chunk-CxGP3dtY.js +1 -0
- package/lib/ui/assets/chunk-CylS5w8V.js +1 -0
- package/lib/ui/assets/chunk-D38fbIBN.js +1 -0
- package/lib/ui/assets/chunk-D97Zzqfu.js +1 -0
- package/lib/ui/assets/chunk-DAi9KRSo.js +1 -0
- package/lib/ui/assets/chunk-DHK4yRfg.js +1 -0
- package/lib/ui/assets/chunk-DJeabLx-.js +1 -0
- package/lib/ui/assets/chunk-DNRxmY5a.js +1 -0
- package/lib/ui/assets/chunk-DNSN1z5r.js +1 -0
- package/lib/ui/assets/chunk-DNasK_ZG.js +1 -0
- package/lib/ui/assets/chunk-DPvrY3IQ.js +1 -0
- package/lib/ui/assets/chunk-DXmwc3jG.js +1 -0
- package/lib/ui/assets/chunk-Dd0kTxKP.js +1 -0
- package/lib/ui/assets/chunk-De0Btta0.js +1 -0
- package/lib/ui/assets/chunk-Des-eS-w.js +1 -0
- package/lib/ui/assets/chunk-Df6bDoY_.js +1 -0
- package/lib/ui/assets/chunk-DijEV5ha.js +1 -0
- package/lib/ui/assets/chunk-DkvoVjww.js +1 -0
- package/lib/ui/assets/chunk-DlC-OlHO.js +1 -0
- package/lib/ui/assets/chunk-DnzrXTVv.js +1 -0
- package/lib/ui/assets/chunk-Dualf0xi.js +1 -0
- package/lib/ui/assets/chunk-EXT84bkm.js +1 -0
- package/lib/ui/assets/chunk-GwR3hkPK.js +1 -0
- package/lib/ui/assets/chunk-P80f7IUj.js +1 -0
- package/lib/ui/assets/chunk-VOosw3JB.js +1 -0
- package/lib/ui/assets/chunk-YQ4lDkt_.js +140 -0
- package/lib/ui/assets/chunk-Yzrsuije.js +1 -0
- package/lib/ui/assets/chunk-Z72CF80r.js +1 -0
- package/lib/ui/assets/chunk-g9-lgVsj.js +1 -0
- package/lib/ui/assets/chunk-vGWfd6FD.js +1 -0
- package/lib/ui/assets/chunk-wDzz0qaB.js +1 -0
- package/lib/ui/assets/chunk-ySF7HWmS.js +1 -0
- package/lib/ui/assets/icon.png +0 -0
- package/lib/ui/assets/index.html +14 -0
- package/lib/ui/assets/pdf.worker.min-CjEcRF4W.mjs +28 -0
- package/lib/ui/assets/style-Bq01xH_b.css +1 -0
- package/lib/ui/frames.d.ts +67 -0
- package/lib/ui/frames.js +146 -0
- package/lib/ui/index.d.ts +59 -0
- package/lib/ui/index.js +50 -0
- package/lib/ui/manifest.d.ts +172 -0
- package/lib/ui/manifest.js +158 -0
- package/lib/ui/plugin.d.ts +161 -0
- package/lib/ui/plugin.js +7 -0
- package/lib/ui/plugins/browser/client.js +290 -0
- package/lib/ui/plugins/browser/icon.png +0 -0
- package/lib/ui/plugins/composer/client.js +1843 -0
- package/lib/ui/plugins/composer/icon.png +0 -0
- package/lib/ui/plugins/files/client.js +646 -0
- package/lib/ui/plugins/files/icon.png +0 -0
- package/lib/ui/plugins/manifest.json +107 -0
- package/lib/ui/plugins/plugins/client.js +682 -0
- package/lib/ui/plugins/plugins/icon.png +0 -0
- package/lib/ui/plugins/preview/client.js +197 -0
- package/lib/ui/plugins/preview/icon.png +0 -0
- package/lib/ui/plugins/prompt/client.js +653 -0
- package/lib/ui/plugins/prompt/icon.png +0 -0
- package/lib/ui/plugins/sessions/client.js +1577 -0
- package/lib/ui/plugins/sessions/icon.png +0 -0
- package/lib/ui/plugins/settings/client.js +5470 -0
- package/lib/ui/plugins/settings/icon.png +0 -0
- package/lib/ui/plugins/skills/client.js +485 -0
- package/lib/ui/plugins/skills/icon.png +0 -0
- package/lib/ui/plugins/status/client.js +1420 -0
- package/lib/ui/plugins/status/icon.png +0 -0
- package/lib/ui/plugins/statusbar/client.js +504 -0
- package/lib/ui/plugins/statusbar/icon.png +0 -0
- package/lib/ui/plugins/tasks/client.js +52 -0
- package/lib/ui/plugins/tasks/icon.png +0 -0
- package/lib/ui/plugins/team/client.js +527 -0
- package/lib/ui/plugins/team/icon.png +0 -0
- package/lib/ui/plugins/terminal/client.js +232 -0
- package/lib/ui/plugins/terminal/icon.png +0 -0
- package/lib/ui/plugins/trace/client.js +1376 -0
- package/lib/ui/plugins/trace/icon.png +0 -0
- package/lib/ui/plugins/transcript/client.js +2661 -0
- package/lib/ui/plugins/transcript/icon.png +0 -0
- package/lib/ui/scoped-slots.d.ts +20 -0
- package/lib/ui/scoped-slots.js +21 -0
- package/lib/ui/sdk/@dsc/ui/index.d.ts +242 -0
- package/lib/ui/sdk/@dsc/ui/package.json +16 -0
- package/lib/ui/sdk/@dsc/ui-core/contract.d.ts +1973 -0
- package/lib/ui/sdk/@dsc/ui-core/core/diff-text.d.ts +74 -0
- package/lib/ui/sdk/@dsc/ui-core/core/dock-browser.d.ts +137 -0
- package/lib/ui/sdk/@dsc/ui-core/core/dock-ops.d.ts +59 -0
- package/lib/ui/sdk/@dsc/ui-core/core/model-caps.d.ts +83 -0
- package/lib/ui/sdk/@dsc/ui-core/core/native-bridge.d.ts +135 -0
- package/lib/ui/sdk/@dsc/ui-core/core/token-estimate.d.ts +55 -0
- package/lib/ui/sdk/@dsc/ui-core/package.json +16 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/arrival.d.ts +72 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/frames.d.ts +67 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/index.d.ts +59 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/manifest.d.ts +172 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/plugin.d.ts +161 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/scoped-slots.d.ts +20 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/services-react.d.ts +27 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/services.d.ts +63 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/slots-react.d.ts +28 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/slots.d.ts +481 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/store.d.ts +89 -0
- package/lib/ui/sdk/@dsc/ui-dockkit/dock-model.d.ts +238 -0
- package/lib/ui/sdk/@dsc/ui-dockkit/dock-state.d.ts +163 -0
- package/lib/ui/sdk/@dsc/ui-dockkit/dock.d.ts +24 -0
- package/lib/ui/sdk/@dsc/ui-dockkit/index.d.ts +15 -0
- package/lib/ui/sdk/@dsc/ui-dockkit/package.json +16 -0
- package/lib/ui/sdk/@dsc/ui-layout/app.d.ts +74 -0
- package/lib/ui/sdk/@dsc/ui-layout/appearance.d.ts +70 -0
- package/lib/ui/sdk/@dsc/ui-layout/host-channel.d.ts +112 -0
- package/lib/ui/sdk/@dsc/ui-layout/index.d.ts +34 -0
- package/lib/ui/sdk/@dsc/ui-layout/package.json +16 -0
- package/lib/ui/sdk/@dsc/ui-layout/page-state.d.ts +14 -0
- package/lib/ui/sdk/@dsc/ui-layout/review-pane.d.ts +21 -0
- package/lib/ui/sdk/@dsc/ui-layout/runtime-context.d.ts +44 -0
- package/lib/ui/sdk/@dsc/ui-layout/thread-view.d.ts +28 -0
- package/lib/ui/sdk/@dsc/ui-layout/update-button.d.ts +21 -0
- package/lib/ui/sdk/@dsc/ui-primitives/code-file-icon-artwork.d.ts +53 -0
- package/lib/ui/sdk/@dsc/ui-primitives/code-view.d.ts +15 -0
- package/lib/ui/sdk/@dsc/ui-primitives/compat.d.ts +27 -0
- package/lib/ui/sdk/@dsc/ui-primitives/completion-sound.d.ts +24 -0
- package/lib/ui/sdk/@dsc/ui-primitives/confirm.d.ts +33 -0
- package/lib/ui/sdk/@dsc/ui-primitives/css.d.ts +47 -0
- package/lib/ui/sdk/@dsc/ui-primitives/diff-rows.d.ts +20 -0
- package/lib/ui/sdk/@dsc/ui-primitives/file-icons.d.ts +38 -0
- package/lib/ui/sdk/@dsc/ui-primitives/file-type-classify.d.ts +66 -0
- package/lib/ui/sdk/@dsc/ui-primitives/file-type-icon.d.ts +57 -0
- package/lib/ui/sdk/@dsc/ui-primitives/highlight.d.ts +24 -0
- package/lib/ui/sdk/@dsc/ui-primitives/hover-delay.d.ts +17 -0
- package/lib/ui/sdk/@dsc/ui-primitives/icons.d.ts +109 -0
- package/lib/ui/sdk/@dsc/ui-primitives/index.d.ts +55 -0
- package/lib/ui/sdk/@dsc/ui-primitives/lang-table.d.ts +10 -0
- package/lib/ui/sdk/@dsc/ui-primitives/markdown.d.ts +20 -0
- package/lib/ui/sdk/@dsc/ui-primitives/native.d.ts +41 -0
- package/lib/ui/sdk/@dsc/ui-primitives/package.json +16 -0
- package/lib/ui/sdk/@dsc/ui-primitives/panels.d.ts +86 -0
- package/lib/ui/sdk/@dsc/ui-primitives/paths.d.ts +11 -0
- package/lib/ui/sdk/@dsc/ui-primitives/pdf-view.d.ts +13 -0
- package/lib/ui/sdk/@dsc/ui-primitives/plugin-text.d.ts +15 -0
- package/lib/ui/sdk/@dsc/ui-primitives/select.d.ts +35 -0
- package/lib/ui/sdk/@dsc/ui-primitives/table-view.d.ts +23 -0
- package/lib/ui/sdk/@dsc/ui-primitives/thread-resizer.d.ts +22 -0
- package/lib/ui/sdk/@dsc/ui-primitives/time.d.ts +33 -0
- package/lib/ui/sdk/@dsc/ui-primitives/toast.d.ts +16 -0
- package/lib/ui/sdk/@dsc/ui-primitives/tokens.d.ts +14 -0
- package/lib/ui/sdk/@dsc/ui-primitives/tool-args.d.ts +49 -0
- package/lib/ui/sdk/@dsc/ui-primitives/tool-summary.d.ts +64 -0
- package/lib/ui/sdk/@dsc/ui-renderer/boot.d.ts +121 -0
- package/lib/ui/sdk/@dsc/ui-renderer/hmr.d.ts +43 -0
- package/lib/ui/sdk/@dsc/ui-renderer/index.d.ts +20 -0
- package/lib/ui/sdk/@dsc/ui-renderer/package.json +16 -0
- package/lib/ui/sdk/@dsc/ui-slots/index.d.ts +19 -0
- package/lib/ui/sdk/@dsc/ui-slots/package.json +16 -0
- package/lib/ui/sdk/@dsc/ui-slots/slots-react.d.ts +48 -0
- package/lib/ui/sdk/@dsc/ui-slots/slots.d.ts +102 -0
- package/lib/ui/services-react.d.ts +27 -0
- package/lib/ui/services-react.js +32 -0
- package/lib/ui/services.d.ts +63 -0
- package/lib/ui/services.js +121 -0
- package/lib/ui/slots-ink.d.ts +26 -0
- package/lib/ui/slots-ink.js +78 -0
- package/lib/ui/slots-react.d.ts +28 -0
- package/lib/ui/slots-react.js +88 -0
- package/lib/ui/slots.d.ts +481 -0
- package/lib/ui/slots.js +550 -0
- package/lib/ui/store.d.ts +89 -0
- package/lib/ui/store.js +62 -0
- package/lib/ui/tui-plugin-api.d.ts +23 -0
- package/lib/ui/tui-plugin-api.js +23 -0
- package/lib/ui/tui-plugins.d.ts +47 -0
- package/lib/ui/tui-plugins.js +220 -0
- package/package.json +58 -6
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 命令执行器缝:bash 工具在真正 `spawn` 之前问一次注册表,拿到最终的执行计划。
|
|
3
|
+
*
|
|
4
|
+
* 为什么要有这条缝:策略层的沙箱(路径白名单、受保护路径、命令前缀规则)挂在守卫链上
|
|
5
|
+
* 就够了,它只做「拒 / 放行」;但**真隔离**必须换掉整个执行体——把
|
|
6
|
+
* `powershell -NoProfile -Command <用户命令>` 换成
|
|
7
|
+
* `docker run --network none -v <工作区>:/work …`。守卫链改不了 argv,所以单开这一条缝。
|
|
8
|
+
*
|
|
9
|
+
* 缝是可选注册的:**没有注册者时执行计划就是原来的那一份**,bash 工具行为与加这条缝之前
|
|
10
|
+
* 完全一致(沙箱插件关着、或沙箱选了进程内策略后端时走的都是这条路)。
|
|
11
|
+
*
|
|
12
|
+
* @module dsc/core/tools/command-runner
|
|
13
|
+
*/
|
|
14
|
+
import type { ChildProcess } from 'node:child_process';
|
|
15
|
+
/** 一次待执行命令的事实(注册者据此决定要不要换执行体)。 */
|
|
16
|
+
export interface CommandRun {
|
|
17
|
+
/** 要执行的命令原文(shell 语法,未拆分)。 */
|
|
18
|
+
command: string;
|
|
19
|
+
/** 会话工作目录(绝对路径)。 */
|
|
20
|
+
cwd: string;
|
|
21
|
+
/** 这次调用的超时毫秒数。 */
|
|
22
|
+
timeoutMs: number;
|
|
23
|
+
/** 这一轮的取消信号。 */
|
|
24
|
+
signal: AbortSignal;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* 自定义 spawn:`file/args/env/cwd` 表达不了的执行计划(受限令牌的
|
|
28
|
+
* `CreateProcessAsUserW`、容器运行时 API 这类)从这里走。
|
|
29
|
+
*
|
|
30
|
+
* 返回值按 node:child_process 的 `ChildProcess` 最小形状给:
|
|
31
|
+
* `pid`(taskkill 树杀靠它)、可读的 `stdout`/`stderr`、`error`/`close` 事件。
|
|
32
|
+
* spawn 本身同步返回,失败不抛——照 node 的惯例 emit `error`。
|
|
33
|
+
*/
|
|
34
|
+
export type CustomSpawn = () => ChildProcess;
|
|
35
|
+
/** 最终的进程启动计划(bash 工具照着它 spawn)。 */
|
|
36
|
+
export interface SpawnPlan {
|
|
37
|
+
/** 可执行文件。 */
|
|
38
|
+
file: string;
|
|
39
|
+
/** 参数数组(不经 shell,避免二次解析)。 */
|
|
40
|
+
args: string[];
|
|
41
|
+
/** 子进程环境变量。 */
|
|
42
|
+
env: Record<string, string | undefined>;
|
|
43
|
+
/** 子进程工作目录。 */
|
|
44
|
+
cwd: string;
|
|
45
|
+
/**
|
|
46
|
+
* 自定义 spawn(可选):给了它,bash 工具就不走 `spawn(file, args, …)`,
|
|
47
|
+
* 改调这里。`file/args/env/cwd` 此刻只是给后续执行器与诊断看的「计划描述」。
|
|
48
|
+
*/
|
|
49
|
+
spawn?: CustomSpawn;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* 命令执行器:`plan` 返回改写后的计划,返回 null 表示「我不改,按上一位的结果来」。
|
|
53
|
+
* `plan` 抛错按「拒绝执行」处理(坏掉的围栏不该等于放行)。
|
|
54
|
+
*/
|
|
55
|
+
export interface CommandRunner {
|
|
56
|
+
/** 归属键(一般写插件名),同 id 后注册者顶掉先注册者。 */
|
|
57
|
+
id: string;
|
|
58
|
+
/** 小的先问;后一位看到的是前一位改写后的计划。 */
|
|
59
|
+
order: number;
|
|
60
|
+
plan(run: CommandRun, current: SpawnPlan): SpawnPlan | null | Promise<SpawnPlan | null>;
|
|
61
|
+
/** 进程收尾(容器后端用它删临时容器);失败只记不抛。 */
|
|
62
|
+
done?(run: CommandRun, plan: SpawnPlan): void | Promise<void>;
|
|
63
|
+
}
|
|
64
|
+
/** 注册一位命令执行器;返回退订函数。同 id 后注册者顶掉先注册者。 */
|
|
65
|
+
export declare function registerCommandRunner(runner: CommandRunner): () => void;
|
|
66
|
+
/** 当前链上的执行器(按询问顺序;自检与诊断用)。 */
|
|
67
|
+
export declare function commandRunnerIds(): string[];
|
|
68
|
+
/**
|
|
69
|
+
* 依次问执行器,得到最终执行计划。
|
|
70
|
+
*
|
|
71
|
+
* 第二个返回值是「谁改写过」:有改写说明这次命令不是在宿主上直跑的
|
|
72
|
+
* (容器后端会用到),调用方拿它给结果加一行事实说明。
|
|
73
|
+
*
|
|
74
|
+
* @param run - 待执行命令的事实。
|
|
75
|
+
* @param base - 默认计划(bash 工具自己那份)。
|
|
76
|
+
*/
|
|
77
|
+
export declare function planCommand(run: CommandRun, base: SpawnPlan): Promise<{
|
|
78
|
+
plan: SpawnPlan;
|
|
79
|
+
changed: string[];
|
|
80
|
+
}>;
|
|
81
|
+
/** 通知全部执行器一次命令已收尾(只有改写过的那几位在乎)。 */
|
|
82
|
+
export declare function finishCommand(run: CommandRun, plan: SpawnPlan, changed: readonly string[]): Promise<void>;
|
|
83
|
+
/** 自检用:把注册表清空(生产路径不该调用)。 */
|
|
84
|
+
export declare function resetCommandRunners(): void;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 命令执行器缝:bash 工具在真正 `spawn` 之前问一次注册表,拿到最终的执行计划。
|
|
3
|
+
*
|
|
4
|
+
* 为什么要有这条缝:策略层的沙箱(路径白名单、受保护路径、命令前缀规则)挂在守卫链上
|
|
5
|
+
* 就够了,它只做「拒 / 放行」;但**真隔离**必须换掉整个执行体——把
|
|
6
|
+
* `powershell -NoProfile -Command <用户命令>` 换成
|
|
7
|
+
* `docker run --network none -v <工作区>:/work …`。守卫链改不了 argv,所以单开这一条缝。
|
|
8
|
+
*
|
|
9
|
+
* 缝是可选注册的:**没有注册者时执行计划就是原来的那一份**,bash 工具行为与加这条缝之前
|
|
10
|
+
* 完全一致(沙箱插件关着、或沙箱选了进程内策略后端时走的都是这条路)。
|
|
11
|
+
*
|
|
12
|
+
* @module dsc/core/tools/command-runner
|
|
13
|
+
*/
|
|
14
|
+
const runners = new Map();
|
|
15
|
+
/** 注册一位命令执行器;返回退订函数。同 id 后注册者顶掉先注册者。 */
|
|
16
|
+
export function registerCommandRunner(runner) {
|
|
17
|
+
runners.set(runner.id, runner);
|
|
18
|
+
return () => {
|
|
19
|
+
if (runners.get(runner.id) === runner)
|
|
20
|
+
runners.delete(runner.id);
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/** 当前链上的执行器(按询问顺序;自检与诊断用)。 */
|
|
24
|
+
export function commandRunnerIds() {
|
|
25
|
+
return [...runners.values()].sort(byOrder).map((runner) => runner.id);
|
|
26
|
+
}
|
|
27
|
+
function byOrder(a, b) {
|
|
28
|
+
return a.order === b.order ? a.id.localeCompare(b.id) : a.order - b.order;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* 依次问执行器,得到最终执行计划。
|
|
32
|
+
*
|
|
33
|
+
* 第二个返回值是「谁改写过」:有改写说明这次命令不是在宿主上直跑的
|
|
34
|
+
* (容器后端会用到),调用方拿它给结果加一行事实说明。
|
|
35
|
+
*
|
|
36
|
+
* @param run - 待执行命令的事实。
|
|
37
|
+
* @param base - 默认计划(bash 工具自己那份)。
|
|
38
|
+
*/
|
|
39
|
+
export async function planCommand(run, base) {
|
|
40
|
+
const changed = [];
|
|
41
|
+
let current = base;
|
|
42
|
+
for (const runner of [...runners.values()].sort(byOrder)) {
|
|
43
|
+
const next = await runner.plan(run, current);
|
|
44
|
+
if (next !== null && next !== undefined) {
|
|
45
|
+
current = next;
|
|
46
|
+
changed.push(runner.id);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return { plan: current, changed };
|
|
50
|
+
}
|
|
51
|
+
/** 通知全部执行器一次命令已收尾(只有改写过的那几位在乎)。 */
|
|
52
|
+
export async function finishCommand(run, plan, changed) {
|
|
53
|
+
for (const id of changed) {
|
|
54
|
+
const runner = runners.get(id);
|
|
55
|
+
if (runner?.done === undefined)
|
|
56
|
+
continue;
|
|
57
|
+
try {
|
|
58
|
+
await runner.done(run, plan);
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
// 收尾失败不该影响工具结果:容器/临时资源留一份不致命,报错反而会把正常结果吞掉
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/** 自检用:把注册表清空(生产路径不该调用)。 */
|
|
66
|
+
export function resetCommandRunners() {
|
|
67
|
+
runners.clear();
|
|
68
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ToolEntry, ToolOutput } from '../tools.js';
|
|
2
|
+
/** read 工具缺省一次读多少行(配置没给 readLineLimit 时用它)。 */
|
|
3
|
+
export declare const READ_DEFAULT_LINE_LIMIT = 2000;
|
|
4
|
+
/**
|
|
5
|
+
* 把「改之前 / 改之后」的全文算成一份变更摘要(轮尾「文件已更改」卡的数据)。
|
|
6
|
+
*
|
|
7
|
+
* 什么时候没有摘要:新旧内容完全相同(覆盖写了个寂寞)——界面上没有可展示的改动,
|
|
8
|
+
* 事件与日志都不带。diff 段超过 {@link CHANGE_DIFF_LINE_LIMIT} 行时从前往后保留、
|
|
9
|
+
* 砍掉的部分标 `truncated`(整篇重写大文件的场景,面板会提示只显示了前一部分)。
|
|
10
|
+
*
|
|
11
|
+
* 导出给 Session.takeTurnChanges 复用:回合聚合的 diff 就是「回合基线 vs 盘上现值」
|
|
12
|
+
* 走同一套算法,两处的口径(上下文行数、砍尾阈值、status 判定)天然一致。
|
|
13
|
+
*/
|
|
14
|
+
export declare function summarizeChange(file: string, before: string, after: string): ToolOutput['changes'];
|
|
15
|
+
/**
|
|
16
|
+
* 造一个 read 工具。单次读取行数由 tools-default 插件从配置取值传入
|
|
17
|
+
* (缺省 {@link READ_DEFAULT_LINE_LIMIT});模型传了 limit 就用模型的,这里只是缺省。
|
|
18
|
+
*/
|
|
19
|
+
export declare function createReadTool(lineLimit?: number): ToolEntry;
|
|
20
|
+
/** 缺省预算的 read 工具(自检脚本直接复用;插件里走 {@link createReadTool} 收配置值)。 */
|
|
21
|
+
export declare const readTool: ToolEntry;
|
|
22
|
+
export declare const writeTool: ToolEntry;
|
|
23
|
+
export declare const editTool: ToolEntry;
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 文件工具三件套:read / write / edit。路径相对会话 cwd 解析。
|
|
3
|
+
* 三道护栏长在工具自己肚子里(不靠调用方自觉):凭据文件不许读、
|
|
4
|
+
* 系统关键路径不许写、没读过就不许整写覆盖。写要不要经用户点头由审批层管。
|
|
5
|
+
*
|
|
6
|
+
* @module dsc/core/tools/fs-tools
|
|
7
|
+
*/
|
|
8
|
+
import { promises as fs } from 'node:fs';
|
|
9
|
+
import { isAbsolute, resolve } from 'node:path';
|
|
10
|
+
import { diffLines } from '../diff-text.js';
|
|
11
|
+
import { noteRead, noteWrite, readBlockReason, staleEditReason, staleOverwriteReason, writeHardBlockReason } from '../path-policy.js';
|
|
12
|
+
import { sandboxPermissionProperties } from './sandbox-args.js';
|
|
13
|
+
/** read 工具缺省一次读多少行(配置没给 readLineLimit 时用它)。 */
|
|
14
|
+
export const READ_DEFAULT_LINE_LIMIT = 2000;
|
|
15
|
+
/** T34:read 输出的字符硬顶(dsh 的 maxOutputChars 同款口径;再往上是 spill 的事)。 */
|
|
16
|
+
const READ_MAX_CHARS = 16_000;
|
|
17
|
+
/** T34:单行显示的字符上限(bundle/锁文件那种一行几十万字符的,截断后给个说明)。 */
|
|
18
|
+
const READ_LINE_CHAR_CAP = 2_000;
|
|
19
|
+
/** T34:模型传 limit 时的行数硬顶(字符顶才是真防线,这个只防离谱数值)。 */
|
|
20
|
+
const READ_MAX_LINES = 10_000;
|
|
21
|
+
/** T25:read 认得的图片扩展名 → MIME(data URL 前缀用)。 */
|
|
22
|
+
const IMAGE_MIME = {
|
|
23
|
+
png: 'image/png',
|
|
24
|
+
jpg: 'image/jpeg',
|
|
25
|
+
jpeg: 'image/jpeg',
|
|
26
|
+
gif: 'image/gif',
|
|
27
|
+
webp: 'image/webp',
|
|
28
|
+
bmp: 'image/bmp',
|
|
29
|
+
svg: 'image/svg+xml',
|
|
30
|
+
};
|
|
31
|
+
/** 一张图进上下文的尺寸上限:6MB 原图 base64 后约 8MB,与输入框贴图同一条红线。 */
|
|
32
|
+
const IMAGE_MAX_BYTES = 6 * 1024 * 1024;
|
|
33
|
+
/** 变更摘要里 diff 段最多保留多少行(超出砍尾并标 truncated,防一次整篇重写撑爆条目与日志)。 */
|
|
34
|
+
const CHANGE_DIFF_LINE_LIMIT = 800;
|
|
35
|
+
const abs = (cwd, p) => {
|
|
36
|
+
if (typeof p !== 'string' || p === '')
|
|
37
|
+
throw new Error('path 必须是非空字符串');
|
|
38
|
+
return isAbsolute(p) ? p : resolve(cwd, p);
|
|
39
|
+
};
|
|
40
|
+
const str = (v, name) => {
|
|
41
|
+
if (typeof v !== 'string')
|
|
42
|
+
throw new Error(`${name} 必须是字符串`);
|
|
43
|
+
return v;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* 把「改之前 / 改之后」的全文算成一份变更摘要(轮尾「文件已更改」卡的数据)。
|
|
47
|
+
*
|
|
48
|
+
* 什么时候没有摘要:新旧内容完全相同(覆盖写了个寂寞)——界面上没有可展示的改动,
|
|
49
|
+
* 事件与日志都不带。diff 段超过 {@link CHANGE_DIFF_LINE_LIMIT} 行时从前往后保留、
|
|
50
|
+
* 砍掉的部分标 `truncated`(整篇重写大文件的场景,面板会提示只显示了前一部分)。
|
|
51
|
+
*
|
|
52
|
+
* 导出给 Session.takeTurnChanges 复用:回合聚合的 diff 就是「回合基线 vs 盘上现值」
|
|
53
|
+
* 走同一套算法,两处的口径(上下文行数、砍尾阈值、status 判定)天然一致。
|
|
54
|
+
*/
|
|
55
|
+
export function summarizeChange(file, before, after) {
|
|
56
|
+
const result = diffLines(before, after, 3);
|
|
57
|
+
if (result.identical || !result.ok || result.hunks.length === 0)
|
|
58
|
+
return undefined;
|
|
59
|
+
const kept = [];
|
|
60
|
+
let budget = CHANGE_DIFF_LINE_LIMIT;
|
|
61
|
+
for (const hunk of result.hunks) {
|
|
62
|
+
if (budget <= 0)
|
|
63
|
+
break;
|
|
64
|
+
const lines = hunk.lines.length <= budget ? hunk.lines : hunk.lines.slice(0, budget);
|
|
65
|
+
kept.push(lines.length === hunk.lines.length ? hunk : { ...hunk, lines });
|
|
66
|
+
budget -= lines.length;
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
path: file,
|
|
70
|
+
added: result.added,
|
|
71
|
+
removed: result.removed,
|
|
72
|
+
hunks: kept,
|
|
73
|
+
...(kept.length < result.hunks.length ? { truncated: true } : {}),
|
|
74
|
+
status: before === '' ? 'added' : 'modified',
|
|
75
|
+
baseline: before,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* 造一个 read 工具。单次读取行数由 tools-default 插件从配置取值传入
|
|
80
|
+
* (缺省 {@link READ_DEFAULT_LINE_LIMIT});模型传了 limit 就用模型的,这里只是缺省。
|
|
81
|
+
*/
|
|
82
|
+
export function createReadTool(lineLimit = READ_DEFAULT_LINE_LIMIT) {
|
|
83
|
+
return {
|
|
84
|
+
name: 'read',
|
|
85
|
+
description: '读取文件内容。文本文件输出「行号 + 制表符 + 原文」,可指定起始行与行数;' +
|
|
86
|
+
'图片文件(png/jpg/gif/webp/bmp/svg)直接作为图片附件加载,用视觉看图即可,不用转 base64。' +
|
|
87
|
+
'读代码、配置、日志一律用它,不要用 bash 跑 cat/head/tail——那样拿不到行号,也没法续读。' +
|
|
88
|
+
'要整写覆盖一个已存在的文件之前必须先读过它,本工具会记下你读过哪个版本。',
|
|
89
|
+
parameters: {
|
|
90
|
+
type: 'object',
|
|
91
|
+
properties: {
|
|
92
|
+
path: { type: 'string', description: '文件路径(绝对或相对当前目录)' },
|
|
93
|
+
offset: { type: 'number', description: '起始行(1-based,默认 1)' },
|
|
94
|
+
limit: { type: 'number', description: `读取行数(默认 ${lineLimit})` },
|
|
95
|
+
},
|
|
96
|
+
required: ['path'],
|
|
97
|
+
},
|
|
98
|
+
risk: 'read',
|
|
99
|
+
async run(args, ctx) {
|
|
100
|
+
const file = abs(ctx.cwd, args.path);
|
|
101
|
+
const blocked = readBlockReason(file);
|
|
102
|
+
if (blocked !== null)
|
|
103
|
+
throw new Error(blocked);
|
|
104
|
+
// T25:图片按扩展名分流——整读成 data URL 走图片附件(模型没勾照片输入时
|
|
105
|
+
// 请求组装的 dropImageParts 投影会兜底换成说明,这里不用关心模态)
|
|
106
|
+
const mime = IMAGE_MIME[file.slice(file.lastIndexOf('.') + 1).toLowerCase()];
|
|
107
|
+
if (mime !== undefined) {
|
|
108
|
+
const stat = await fs.stat(file);
|
|
109
|
+
if (stat.size > IMAGE_MAX_BYTES) {
|
|
110
|
+
throw new Error(`这张图有 ${Math.round(stat.size / 1024 / 1024)}MB,超过 6MB 上限;先压缩或缩小再看`);
|
|
111
|
+
}
|
|
112
|
+
const bytes = await fs.readFile(file);
|
|
113
|
+
noteRead(file, ctx.sessionId);
|
|
114
|
+
return {
|
|
115
|
+
text: `已加载图片 ${file}(${mime},${stat.size} 字节),图在附件里。`,
|
|
116
|
+
images: [`data:${mime};base64,${bytes.toString('base64')}`],
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
const raw = await fs.readFile(file, 'utf8');
|
|
120
|
+
noteRead(file, ctx.sessionId);
|
|
121
|
+
// T34:二进制(含 NUL 字节)不硬灌——乱码只会烧上下文,给一句明确指引
|
|
122
|
+
if (raw.slice(0, 8000).includes('\u0000')) {
|
|
123
|
+
throw new Error('这看起来是二进制文件,read 不支持直接读。需要内容时用 bash 配合格式工具取样(如 base64 / certutil -encode / xxd)。');
|
|
124
|
+
}
|
|
125
|
+
const lines = raw.split(/\r?\n/);
|
|
126
|
+
const start = Math.max(1, typeof args.offset === 'number' ? Math.floor(args.offset) : 1);
|
|
127
|
+
// T34:limit 不再是模型要多少给多少——行数与字符量都有硬顶,超长行也截断
|
|
128
|
+
const requested = typeof args.limit === 'number' ? Math.floor(args.limit) : lineLimit;
|
|
129
|
+
const limit = Math.min(Math.max(requested, 1), READ_MAX_LINES);
|
|
130
|
+
const slice = lines.slice(start - 1, start - 1 + limit);
|
|
131
|
+
const body = [];
|
|
132
|
+
let used = 0;
|
|
133
|
+
let withheld = 0;
|
|
134
|
+
for (const [index, line] of slice.entries()) {
|
|
135
|
+
const shown = line.length > READ_LINE_CHAR_CAP ? `${line.slice(0, READ_LINE_CHAR_CAP)}…(本行超长已截断)` : line;
|
|
136
|
+
const cost = shown.length + 1;
|
|
137
|
+
if (body.length > 0 && used + cost > READ_MAX_CHARS) {
|
|
138
|
+
withheld = slice.length - index;
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
body.push(`${start + index}\t${shown}`);
|
|
142
|
+
used += cost;
|
|
143
|
+
}
|
|
144
|
+
const total = lines.length;
|
|
145
|
+
const tail = [];
|
|
146
|
+
if (withheld > 0)
|
|
147
|
+
tail.push(`…(输出达到 ${String(READ_MAX_CHARS)} 字符上限,还有 ${String(withheld)} 行没显示,用 offset 续读)`);
|
|
148
|
+
if (start - 1 + slice.length < total)
|
|
149
|
+
tail.push(`…(共 ${String(total)} 行,可用 offset/limit 续读)`);
|
|
150
|
+
return `${file}\n${body.join('\n')}${tail.length > 0 ? `\n${tail.join('\n')}` : ''}`;
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
/** 缺省预算的 read 工具(自检脚本直接复用;插件里走 {@link createReadTool} 收配置值)。 */
|
|
155
|
+
export const readTool = createReadTool();
|
|
156
|
+
export const writeTool = {
|
|
157
|
+
name: 'write',
|
|
158
|
+
description: '把内容整体写入文件(覆盖原内容),目录不存在会自动创建。' +
|
|
159
|
+
'改已有文件优先用 edit 做定点替换;只有在「新建文件」或「整篇重写」时才用本工具。' +
|
|
160
|
+
'已存在的文件必须先 read 过才允许覆盖,否则本工具会拒绝并让你先去读。',
|
|
161
|
+
parameters: {
|
|
162
|
+
type: 'object',
|
|
163
|
+
properties: {
|
|
164
|
+
path: { type: 'string', description: '目标文件路径' },
|
|
165
|
+
content: { type: 'string', description: '完整文件内容' },
|
|
166
|
+
...sandboxPermissionProperties,
|
|
167
|
+
},
|
|
168
|
+
required: ['path', 'content'],
|
|
169
|
+
},
|
|
170
|
+
risk: 'write',
|
|
171
|
+
async run(args, ctx) {
|
|
172
|
+
const file = abs(ctx.cwd, args.path);
|
|
173
|
+
const hard = writeHardBlockReason(file);
|
|
174
|
+
if (hard !== null)
|
|
175
|
+
throw new Error(hard);
|
|
176
|
+
const stale = staleOverwriteReason(file, ctx.sessionId);
|
|
177
|
+
if (stale !== null)
|
|
178
|
+
throw new Error(stale);
|
|
179
|
+
const content = str(args.content, 'content');
|
|
180
|
+
// T35:CAS 锚——从这一刻到 writeFile 之间文件若被第三方改过,就拒绝整写
|
|
181
|
+
const anchorStat = await fs.stat(file).catch(() => null);
|
|
182
|
+
// 旧内容拿不到(新建)就当空串:diff 呈现为整篇新增
|
|
183
|
+
const before = await fs.readFile(file, 'utf8').catch(() => '');
|
|
184
|
+
await fs.mkdir(resolve(file, '..'), { recursive: true });
|
|
185
|
+
const beforeWrite = anchorStat === null ? null : await fs.stat(file).catch(() => null);
|
|
186
|
+
if (anchorStat !== null && (beforeWrite === null || Math.abs(beforeWrite.mtimeMs - anchorStat.mtimeMs) > 1)) {
|
|
187
|
+
throw new Error('文件在你准备写入时又被其他程序改动,重试一次(先重新读它)。');
|
|
188
|
+
}
|
|
189
|
+
await fs.writeFile(file, content, 'utf8');
|
|
190
|
+
noteWrite(file, ctx.sessionId);
|
|
191
|
+
const changes = summarizeChange(file, before, content);
|
|
192
|
+
return {
|
|
193
|
+
text: `已写入 ${file}(${content.length} 字符)`,
|
|
194
|
+
...(changes === undefined ? {} : { changes }),
|
|
195
|
+
};
|
|
196
|
+
},
|
|
197
|
+
};
|
|
198
|
+
export const editTool = {
|
|
199
|
+
name: 'edit',
|
|
200
|
+
description: '对文件做一次精确字符串替换:old 必须与文件内容逐字唯一匹配,然后原样换成 new。' +
|
|
201
|
+
'改一两处代码就用它,不要把整个文件读出来再 write 回去。' +
|
|
202
|
+
'old 匹配多处会失败,此时加长上下文(多带几行)让它唯一,而不是改用 write 覆盖。',
|
|
203
|
+
parameters: {
|
|
204
|
+
type: 'object',
|
|
205
|
+
properties: {
|
|
206
|
+
path: { type: 'string', description: '目标文件路径' },
|
|
207
|
+
old: { type: 'string', description: '要被替换的原文(必须唯一匹配)' },
|
|
208
|
+
new: { type: 'string', description: '替换后的内容' },
|
|
209
|
+
...sandboxPermissionProperties,
|
|
210
|
+
},
|
|
211
|
+
required: ['path', 'old', 'new'],
|
|
212
|
+
},
|
|
213
|
+
risk: 'write',
|
|
214
|
+
async run(args, ctx) {
|
|
215
|
+
const file = abs(ctx.cwd, args.path);
|
|
216
|
+
const hard = writeHardBlockReason(file);
|
|
217
|
+
if (hard !== null)
|
|
218
|
+
throw new Error(hard);
|
|
219
|
+
// T35:模型读过、之后又被第三方改过的文件不许拿旧印象去改(与 write 同一台账,
|
|
220
|
+
// 但不要求「没读过就拒绝」——edit 是现读现值,这是它与整写覆盖的语义差别)
|
|
221
|
+
const stale = staleEditReason(file, ctx.sessionId);
|
|
222
|
+
if (stale !== null)
|
|
223
|
+
throw new Error(stale);
|
|
224
|
+
const oldText = str(args.old, 'old');
|
|
225
|
+
const newText = str(args.new, 'new');
|
|
226
|
+
const anchorStat = await fs.stat(file).catch(() => null);
|
|
227
|
+
const raw = await fs.readFile(file, 'utf8');
|
|
228
|
+
const first = raw.indexOf(oldText);
|
|
229
|
+
if (first < 0)
|
|
230
|
+
throw new Error('old 内容在文件中不存在');
|
|
231
|
+
if (raw.indexOf(oldText, first + 1) >= 0)
|
|
232
|
+
throw new Error('old 内容在文件中匹配多处,请加长上下文使其唯一');
|
|
233
|
+
const after = raw.slice(0, first) + newText + raw.slice(first + oldText.length);
|
|
234
|
+
// T35:CAS——读文件与写回之间被别的程序改过就拒绝,绝不拿刚算好的旧基线整篇写回
|
|
235
|
+
const beforeWrite = anchorStat === null ? null : await fs.stat(file).catch(() => null);
|
|
236
|
+
if (anchorStat !== null && (beforeWrite === null || Math.abs(beforeWrite.mtimeMs - anchorStat.mtimeMs) > 1)) {
|
|
237
|
+
throw new Error('文件在编辑过程中又被其他程序改动,重试一次(先重新读它)。');
|
|
238
|
+
}
|
|
239
|
+
await fs.writeFile(file, after, 'utf8');
|
|
240
|
+
noteWrite(file, ctx.sessionId);
|
|
241
|
+
const changes = summarizeChange(file, raw, after);
|
|
242
|
+
return {
|
|
243
|
+
text: `已编辑 ${file}`,
|
|
244
|
+
...(changes === undefined ? {} : { changes }),
|
|
245
|
+
};
|
|
246
|
+
},
|
|
247
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createBashTool } from './bash.js';
|
|
2
|
+
import { createReadTool, editTool, writeTool } from './fs-tools.js';
|
|
3
|
+
import { globTool, grepTool } from './search-tools.js';
|
|
4
|
+
export const defaultTools = [createBashTool(), createReadTool(), writeTool, editTool, globTool, grepTool];
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 一次性升权参数:模型在动手类工具里显式请求「这一次放宽沙箱档位」。
|
|
3
|
+
*
|
|
4
|
+
* 形制照 codex 的 `sandbox_permissions` + `justification`:两个字段**必须成对出现**,
|
|
5
|
+
* 且只对这一次调用生效(不留持久授权——dsc 的既定安全选择)。
|
|
6
|
+
* 判定不在工具自己肚子里,而在沙箱插件挂在守卫链 order 8 的那位守卫上:
|
|
7
|
+
* 工具层只负责把这两个参数写进 schema,让模型有地方说清楚「我要写到哪、为什么」。
|
|
8
|
+
*
|
|
9
|
+
* @module dsc/core/tools/sandbox-args
|
|
10
|
+
*/
|
|
11
|
+
/** 一次调用请求放宽到哪一档。 */
|
|
12
|
+
export declare const SANDBOX_PERMISSION_VALUES: readonly ["workspace-write", "danger-full-access"];
|
|
13
|
+
export type SandboxPermission = (typeof SANDBOX_PERMISSION_VALUES)[number];
|
|
14
|
+
/**
|
|
15
|
+
* 放宽**持续多久**(形制照 codex 的 `PermissionGrantScope`;codex 的 `Turn` 在 dsc 里落成 `once`):
|
|
16
|
+
* once 只这一次调用(默认);
|
|
17
|
+
* session 本会话内同类放宽不再问——**仍要在审批卡上点「本会话允许」才生效**,
|
|
18
|
+
* 模型在参数里写 session 只是表达意图,授权动作永远在用户那一侧。
|
|
19
|
+
*/
|
|
20
|
+
export declare const SANDBOX_SCOPE_VALUES: readonly ["once", "session"];
|
|
21
|
+
export type SandboxScope = (typeof SANDBOX_SCOPE_VALUES)[number];
|
|
22
|
+
/**
|
|
23
|
+
* 两个目标档的语义差别(以前这里是**死的**:守卫 defer 之后没人再看这个值,两档行为一样):
|
|
24
|
+
* workspace-write 留在沙箱里,只把这一次的写边界放宽(codex 的 `WithAdditionalPermissions`);
|
|
25
|
+
* danger-full-access 这一次整个出沙箱,执行体不再受围栏(codex 的 `RequireEscalated`)。
|
|
26
|
+
*/
|
|
27
|
+
export declare const SANDBOX_PERMISSION_EFFECT: Readonly<Record<SandboxPermission, string>>;
|
|
28
|
+
/**
|
|
29
|
+
* 展开进工具的 `parameters.properties`。
|
|
30
|
+
*
|
|
31
|
+
* 描述刻意写成「只在被沙箱拒了之后才填」:沙箱插件关着时这三个参数没有任何作用,
|
|
32
|
+
* 但模型不该因为看见它们就主动要求放宽——没有任何档位能越过审批卡。
|
|
33
|
+
*/
|
|
34
|
+
export declare const sandboxPermissionProperties: Record<string, unknown>;
|
|
35
|
+
/**
|
|
36
|
+
* 读一次工具调用里的升权请求。
|
|
37
|
+
*
|
|
38
|
+
* 四种结果:`none` 没请求;`ok` 请求完整;`malformed` 参数不齐(守卫按拒处理——
|
|
39
|
+
* 单独一个 `sandbox_permissions` 是典型的「想偷偷放宽」,不给理由就不该放过去)。
|
|
40
|
+
*/
|
|
41
|
+
export declare function readSandboxRequest(args: Record<string, unknown>): {
|
|
42
|
+
kind: 'none';
|
|
43
|
+
} | {
|
|
44
|
+
kind: 'ok';
|
|
45
|
+
permission: SandboxPermission;
|
|
46
|
+
justification: string;
|
|
47
|
+
scope: SandboxScope;
|
|
48
|
+
} | {
|
|
49
|
+
kind: 'malformed';
|
|
50
|
+
reason: string;
|
|
51
|
+
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 一次性升权参数:模型在动手类工具里显式请求「这一次放宽沙箱档位」。
|
|
3
|
+
*
|
|
4
|
+
* 形制照 codex 的 `sandbox_permissions` + `justification`:两个字段**必须成对出现**,
|
|
5
|
+
* 且只对这一次调用生效(不留持久授权——dsc 的既定安全选择)。
|
|
6
|
+
* 判定不在工具自己肚子里,而在沙箱插件挂在守卫链 order 8 的那位守卫上:
|
|
7
|
+
* 工具层只负责把这两个参数写进 schema,让模型有地方说清楚「我要写到哪、为什么」。
|
|
8
|
+
*
|
|
9
|
+
* @module dsc/core/tools/sandbox-args
|
|
10
|
+
*/
|
|
11
|
+
/** 一次调用请求放宽到哪一档。 */
|
|
12
|
+
export const SANDBOX_PERMISSION_VALUES = ['workspace-write', 'danger-full-access'];
|
|
13
|
+
/**
|
|
14
|
+
* 放宽**持续多久**(形制照 codex 的 `PermissionGrantScope`;codex 的 `Turn` 在 dsc 里落成 `once`):
|
|
15
|
+
* once 只这一次调用(默认);
|
|
16
|
+
* session 本会话内同类放宽不再问——**仍要在审批卡上点「本会话允许」才生效**,
|
|
17
|
+
* 模型在参数里写 session 只是表达意图,授权动作永远在用户那一侧。
|
|
18
|
+
*/
|
|
19
|
+
export const SANDBOX_SCOPE_VALUES = ['once', 'session'];
|
|
20
|
+
/**
|
|
21
|
+
* 两个目标档的语义差别(以前这里是**死的**:守卫 defer 之后没人再看这个值,两档行为一样):
|
|
22
|
+
* workspace-write 留在沙箱里,只把这一次的写边界放宽(codex 的 `WithAdditionalPermissions`);
|
|
23
|
+
* danger-full-access 这一次整个出沙箱,执行体不再受围栏(codex 的 `RequireEscalated`)。
|
|
24
|
+
*/
|
|
25
|
+
export const SANDBOX_PERMISSION_EFFECT = {
|
|
26
|
+
'workspace-write': '留在沙箱内,只放宽这一次的写边界(网络开关与其他受保护路径照旧)',
|
|
27
|
+
'danger-full-access': '这一次跳过沙箱判定(可写根与网络开关都不再看)',
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* 展开进工具的 `parameters.properties`。
|
|
31
|
+
*
|
|
32
|
+
* 描述刻意写成「只在被沙箱拒了之后才填」:沙箱插件关着时这三个参数没有任何作用,
|
|
33
|
+
* 但模型不该因为看见它们就主动要求放宽——没有任何档位能越过审批卡。
|
|
34
|
+
*/
|
|
35
|
+
export const sandboxPermissionProperties = {
|
|
36
|
+
sandbox_permissions: {
|
|
37
|
+
type: 'string',
|
|
38
|
+
enum: [...SANDBOX_PERMISSION_VALUES],
|
|
39
|
+
description: '仅当沙箱(sandbox 插件)以「超出可写范围」为由拒绝过这次操作、且这个操作确实必要时才填:' +
|
|
40
|
+
'请求把这一次调用放宽到该档位(workspace-write = 留在沙箱内只放宽写边界;' +
|
|
41
|
+
'danger-full-access = 这一次整个出沙箱)。必须与 justification 同时给出;' +
|
|
42
|
+
'放宽请求会照常弹审批卡,用户不点同意就不会执行。',
|
|
43
|
+
},
|
|
44
|
+
justification: {
|
|
45
|
+
type: 'string',
|
|
46
|
+
description: '与 sandbox_permissions 成对出现:一句话说明为什么必须写到可写范围之外(用户据此决定批不批)。',
|
|
47
|
+
},
|
|
48
|
+
sandbox_scope: {
|
|
49
|
+
type: 'string',
|
|
50
|
+
enum: [...SANDBOX_SCOPE_VALUES],
|
|
51
|
+
description: '可选,与 sandbox_permissions 一起给:这一档放宽要持续多久。once(默认)= 只这一次;' +
|
|
52
|
+
'session = 本会话内同类放宽不再问(用户仍要在卡上点「本会话允许」才生效)。',
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* 读一次工具调用里的升权请求。
|
|
57
|
+
*
|
|
58
|
+
* 四种结果:`none` 没请求;`ok` 请求完整;`malformed` 参数不齐(守卫按拒处理——
|
|
59
|
+
* 单独一个 `sandbox_permissions` 是典型的「想偷偷放宽」,不给理由就不该放过去)。
|
|
60
|
+
*/
|
|
61
|
+
export function readSandboxRequest(args) {
|
|
62
|
+
const rawPermission = args.sandbox_permissions;
|
|
63
|
+
const rawJustification = args.justification;
|
|
64
|
+
const rawScope = args.sandbox_scope;
|
|
65
|
+
const hasPermission = rawPermission !== undefined && rawPermission !== null && rawPermission !== '';
|
|
66
|
+
const justification = typeof rawJustification === 'string' ? rawJustification.trim() : '';
|
|
67
|
+
const hasScope = rawScope !== undefined && rawScope !== null && rawScope !== '';
|
|
68
|
+
if (!hasPermission && justification === '' && !hasScope)
|
|
69
|
+
return { kind: 'none' };
|
|
70
|
+
if (!hasPermission) {
|
|
71
|
+
return {
|
|
72
|
+
kind: 'malformed',
|
|
73
|
+
reason: hasScope ? '只给了 sandbox_scope 没给 sandbox_permissions' : '只给了 justification 没给 sandbox_permissions',
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
if (!SANDBOX_PERMISSION_VALUES.includes(String(rawPermission))) {
|
|
77
|
+
return { kind: 'malformed', reason: `sandbox_permissions 只能是 ${SANDBOX_PERMISSION_VALUES.join(' / ')}` };
|
|
78
|
+
}
|
|
79
|
+
if (justification === '') {
|
|
80
|
+
return { kind: 'malformed', reason: '请求放宽沙箱必须同时给出 justification(为什么必须写到范围之外)' };
|
|
81
|
+
}
|
|
82
|
+
let scope = 'once';
|
|
83
|
+
if (hasScope) {
|
|
84
|
+
if (!SANDBOX_SCOPE_VALUES.includes(String(rawScope))) {
|
|
85
|
+
return { kind: 'malformed', reason: `sandbox_scope 只能是 ${SANDBOX_SCOPE_VALUES.join(' / ')}` };
|
|
86
|
+
}
|
|
87
|
+
scope = String(rawScope);
|
|
88
|
+
}
|
|
89
|
+
return { kind: 'ok', permission: String(rawPermission), justification, scope };
|
|
90
|
+
}
|