@waq666/pneuma 0.7.1 → 0.8.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/README.md +242 -206
- package/bin/dsc.js +9 -3
- package/bin/headless.cjs +1 -1
- package/lib/adapter/transcript.d.ts +19 -2
- package/lib/adapter/transcript.js +71 -14
- package/lib/app/AgentsOverlay.js +7 -6
- package/lib/app/App.js +1 -1
- package/lib/app/ApprovalCard.js +15 -9
- package/lib/app/ChatView.d.ts +3 -1
- package/lib/app/ChatView.js +21 -17
- package/lib/app/Composer.js +22 -4
- package/lib/app/MarkdownView.js +2 -1
- package/lib/app/ModelPicker.js +7 -6
- package/lib/app/PickerFrame.d.ts +4 -0
- package/lib/app/PickerFrame.js +18 -0
- package/lib/app/PlanReviewCard.js +2 -1
- package/lib/app/PresetPicker.js +8 -7
- package/lib/app/SessionPicker.js +21 -20
- package/lib/app/SettingsOverlay.js +1 -1
- package/lib/app/SkillsPicker.js +7 -6
- package/lib/app/StatusBar.js +3 -15
- package/lib/app/TaskStrips.js +1 -4
- package/lib/app/TimelineRail.js +2 -1
- package/lib/app/ToolCard.js +2 -6
- package/lib/app/Welcome.d.ts +1 -0
- package/lib/app/Welcome.js +1 -4
- package/lib/app/click.d.ts +0 -2
- package/lib/app/click.js +2 -21
- package/lib/app/display-width.d.ts +16 -0
- package/lib/app/display-width.js +33 -0
- package/lib/app/markdown.d.ts +1 -3
- package/lib/app/markdown.js +2 -19
- package/lib/app/scroll-model.js +1 -1
- package/lib/contract/approval.d.ts +91 -0
- package/lib/contract/approval.js +1 -0
- package/lib/contract/mode.d.ts +69 -0
- package/lib/contract/mode.js +1 -0
- package/lib/contract/plugin.d.ts +240 -0
- package/lib/contract/plugin.js +1 -0
- package/lib/contract/runtime.d.ts +282 -0
- package/lib/contract/runtime.js +1 -0
- package/lib/contract/session.d.ts +208 -0
- package/lib/contract/session.js +36 -0
- package/lib/contract/settings.d.ts +242 -0
- package/lib/contract/settings.js +1 -0
- package/lib/contract/snapshot.d.ts +453 -0
- package/lib/contract/snapshot.js +1 -0
- package/lib/contract/task.d.ts +189 -0
- package/lib/contract/task.js +10 -0
- package/lib/contract/transcript.d.ts +358 -0
- package/lib/contract/transcript.js +1 -0
- package/lib/contract/usage.d.ts +132 -0
- package/lib/contract/usage.js +10 -0
- package/lib/contract.d.ts +20 -1968
- package/lib/contract.js +19 -30
- package/lib/core/agent-roles.d.ts +1 -1
- package/lib/core/agent-roles.js +6 -5
- package/lib/core/approval-floor.d.ts +9 -0
- package/lib/core/approval-floor.js +152 -25
- package/lib/core/attachments.d.ts +185 -0
- package/lib/core/attachments.js +425 -0
- package/lib/core/bytes.d.ts +14 -0
- package/lib/core/bytes.js +28 -0
- package/lib/core/call-meaning.d.ts +20 -0
- package/lib/core/call-meaning.js +347 -0
- package/lib/core/cdp/actions.js +6 -0
- package/lib/core/cdp/launch.js +2 -2
- package/lib/core/cdp/report.d.ts +27 -0
- package/lib/core/cdp/report.js +50 -0
- package/lib/core/cdp/ring-buffer.d.ts +25 -0
- package/lib/core/cdp/ring-buffer.js +44 -0
- package/lib/core/cdp/snapshot.js +5 -9
- package/lib/core/cdp/transport.js +1 -1
- package/lib/core/clamp.d.ts +20 -0
- package/lib/core/clamp.js +24 -0
- package/lib/core/clock.d.ts +16 -0
- package/lib/core/clock.js +20 -0
- package/lib/core/command-policy.js +33 -1
- package/lib/core/commands-completion.d.ts +28 -0
- package/lib/core/commands-completion.js +108 -30
- package/lib/core/compact.d.ts +36 -6
- package/lib/core/compact.js +89 -17
- package/lib/core/desktop-control.js +1 -3
- package/lib/core/dsh-compat/llm-usage-event.d.ts +78 -0
- package/lib/core/dsh-compat/llm-usage-event.js +91 -0
- package/lib/core/dsh-compat/presentation.d.ts +84 -0
- package/lib/core/dsh-compat/presentation.js +105 -0
- package/lib/core/dsh-compat/resolve-hook.d.ts +3 -3
- package/lib/core/dsh-compat/resolve-hook.js +41 -13
- package/lib/core/dsh-compat/service-map.d.ts +52 -0
- package/lib/core/dsh-compat/service-map.js +87 -0
- package/lib/core/dsh-compat/session-bridge.d.ts +107 -0
- package/lib/core/dsh-compat/session-bridge.js +376 -0
- package/lib/core/dsh-compat/session-events.d.ts +54 -0
- package/lib/core/dsh-compat/session-events.js +297 -0
- package/lib/core/dsh-compat/shims/credentials.d.ts +62 -0
- package/lib/core/dsh-compat/shims/credentials.js +86 -0
- package/lib/core/dsh-compat/shims/home-paths.d.ts +77 -0
- package/lib/core/dsh-compat/shims/home-paths.js +143 -0
- package/lib/core/dsh-compat/tools-facade.d.ts +31 -1
- package/lib/core/dsh-compat/tools-facade.js +207 -3
- package/lib/core/err-text.d.ts +5 -0
- package/lib/core/err-text.js +5 -0
- package/lib/core/events.d.ts +31 -2
- package/lib/core/git-info.d.ts +127 -15
- package/lib/core/git-info.js +315 -34
- package/lib/core/git-surface.d.ts +17 -0
- package/lib/core/git-surface.js +7 -0
- package/lib/core/hooks.d.ts +19 -2
- package/lib/core/hooks.js +57 -13
- package/lib/core/host-methods.d.ts +1 -1
- package/lib/core/host-methods.js +4 -0
- package/lib/core/image-diet.js +1 -4
- package/lib/core/json-text.d.ts +11 -0
- package/lib/core/json-text.js +18 -0
- package/lib/core/learnings/skill-write.d.ts +1 -7
- package/lib/core/learnings/skill-write.js +3 -37
- package/lib/core/lifecycle-hooks.d.ts +11 -3
- package/lib/core/lifecycle-hooks.js +33 -42
- package/lib/core/llm.d.ts +42 -0
- package/lib/core/llm.js +40 -25
- package/lib/core/loop.d.ts +11 -1
- package/lib/core/loop.js +95 -28
- package/lib/core/lsp/client.js +30 -17
- package/lib/core/lsp/normalize.d.ts +0 -2
- package/lib/core/lsp/normalize.js +1 -6
- package/lib/core/lsp/servers.js +1 -4
- package/lib/core/mcp.d.ts +18 -0
- package/lib/core/mcp.js +60 -16
- package/lib/core/microcompact.d.ts +45 -0
- package/lib/core/microcompact.js +128 -0
- package/lib/core/native-bridge.js +2 -10
- package/lib/core/path-policy.d.ts +13 -1
- package/lib/core/path-policy.js +87 -18
- package/lib/core/permission-presets.d.ts +9 -5
- package/lib/core/permission-presets.js +14 -7
- package/lib/core/permission-scope.d.ts +65 -0
- package/lib/core/permission-scope.js +109 -0
- package/lib/core/plugin-bundle.d.ts +95 -0
- package/lib/core/plugin-bundle.js +137 -0
- package/lib/core/plugin-loader.d.ts +36 -1
- package/lib/core/plugin-loader.js +336 -12
- package/lib/core/plugin-patch.d.ts +64 -0
- package/lib/core/plugin-patch.js +146 -0
- package/lib/core/plugin-registry.d.ts +14 -0
- package/lib/core/plugin-registry.js +2 -0
- package/lib/core/prefs.js +40 -2
- package/lib/core/presets.d.ts +11 -0
- package/lib/core/presets.js +61 -22
- package/lib/core/profile-dir.d.ts +5 -0
- package/lib/core/profile-dir.js +40 -0
- package/lib/core/prompt.js +55 -19
- package/lib/core/ptc.d.ts +8 -2
- package/lib/core/ptc.js +18 -4
- package/lib/core/records.d.ts +16 -0
- package/lib/core/records.js +22 -0
- package/lib/core/remote/notify.js +1 -3
- package/lib/core/remote/push.js +2 -6
- package/lib/core/sandbox/execpolicy.js +27 -3
- package/lib/core/sandbox/net-proxy.js +2 -2
- package/lib/core/sandbox/policy.d.ts +1 -1
- package/lib/core/sandbox/policy.js +21 -15
- package/lib/core/sandbox/win/account.js +1 -4
- package/lib/core/sandbox/win/acl.js +1 -6
- package/lib/core/sandbox/win/backend.d.ts +24 -3
- package/lib/core/sandbox/win/backend.js +73 -23
- package/lib/core/sandbox/win/doctor.js +1 -4
- package/lib/core/sandbox/win/runner-entry.js +1 -6
- package/lib/core/sandbox/win/setup.js +1 -4
- package/lib/core/sandbox/win/utf16.d.ts +11 -0
- package/lib/core/sandbox/win/utf16.js +15 -0
- package/lib/core/sandbox/win/wfp.js +1 -4
- package/lib/core/schedule/rule.d.ts +0 -17
- package/lib/core/schedule/rule.js +1 -3
- package/lib/core/schedule/runner.d.ts +5 -2
- package/lib/core/schedule/runner.js +32 -9
- package/lib/core/schedule/store.d.ts +0 -2
- package/lib/core/schedule/store.js +2 -9
- package/lib/core/session-index.d.ts +50 -0
- package/lib/core/session-index.js +169 -3
- package/lib/core/session.d.ts +89 -13
- package/lib/core/session.js +385 -32
- package/lib/core/shell-quote.d.ts +21 -0
- package/lib/core/shell-quote.js +24 -0
- package/lib/core/side-ask.d.ts +52 -0
- package/lib/core/side-ask.js +89 -0
- package/lib/core/skills.d.ts +16 -0
- package/lib/core/skills.js +45 -8
- package/lib/core/snapshot-throttle.d.ts +8 -0
- package/lib/core/snapshot-throttle.js +24 -0
- package/lib/core/spill.d.ts +11 -5
- package/lib/core/spill.js +35 -36
- package/lib/core/strings.d.ts +21 -0
- package/lib/core/strings.js +33 -0
- package/lib/core/terminal-env.d.ts +61 -0
- package/lib/core/terminal-env.js +327 -0
- package/lib/core/text-format.d.ts +17 -0
- package/lib/core/text-format.js +26 -0
- package/lib/core/todo-reminder.d.ts +19 -14
- package/lib/core/todo-reminder.js +14 -23
- package/lib/core/token-estimate.d.ts +18 -2
- package/lib/core/token-estimate.js +10 -2
- package/lib/core/tool-result-prune.d.ts +42 -0
- package/lib/core/tool-result-prune.js +47 -0
- package/lib/core/tool-search.d.ts +3 -2
- package/lib/core/tool-search.js +3 -2
- package/lib/core/tools/bash.d.ts +35 -3
- package/lib/core/tools/bash.js +168 -41
- package/lib/core/tools/fs-tools.js +18 -17
- package/lib/core/tools/image-tool.d.ts +2 -0
- package/lib/core/tools/image-tool.js +59 -0
- package/lib/core/tools/path-args.d.ts +4 -0
- package/lib/core/tools/path-args.js +22 -0
- package/lib/core/tools/search-tools.d.ts +30 -0
- package/lib/core/tools/search-tools.js +321 -34
- package/lib/core/tools.d.ts +82 -0
- package/lib/core/tools.js +21 -0
- package/lib/core/transcript-text.d.ts +19 -0
- package/lib/core/transcript-text.js +44 -0
- package/lib/core/ui-boot-source.d.ts +5 -0
- package/lib/core/ui-boot-source.js +10 -3
- package/lib/core/ui-bundles.d.ts +80 -6
- package/lib/core/ui-bundles.js +700 -76
- package/lib/core/ui-events.d.ts +10 -0
- package/lib/core/ui-events.js +25 -0
- package/lib/core/ui-methods.d.ts +1 -1
- package/lib/core/ui-methods.js +42 -13
- package/lib/core/ui-route.js +11 -7
- package/lib/core/ui-server.d.ts +6 -0
- package/lib/core/ui-server.js +106 -1
- package/lib/core/unified-diff.d.ts +35 -0
- package/lib/core/unified-diff.js +86 -0
- package/lib/core/usage-log.js +39 -0
- package/lib/core/web-http.d.ts +1 -1
- package/lib/core/web-http.js +1 -3
- package/lib/host/kernel.js +57 -41
- package/lib/plugins/agent.js +101 -20
- package/lib/plugins/approval-floor.js +12 -8
- package/lib/plugins/approval.js +252 -80
- package/lib/plugins/ask.js +60 -8
- package/lib/plugins/browser.js +32 -84
- package/lib/plugins/commands.js +167 -57
- package/lib/plugins/compact.d.ts +2 -2
- package/lib/plugins/compact.js +200 -30
- package/lib/plugins/computer-use.js +34 -18
- package/lib/plugins/dock-browser.js +24 -65
- package/lib/plugins/dsh-compat.js +7 -0
- package/lib/plugins/file-review.js +59 -15
- package/lib/plugins/git.js +16 -8
- package/lib/plugins/goal.js +9 -8
- package/lib/plugins/hooks.js +4 -2
- package/lib/plugins/host-stdio.js +14 -16
- package/lib/plugins/lifecycle-hooks.d.ts +5 -4
- package/lib/plugins/lifecycle-hooks.js +12 -10
- package/lib/plugins/llm.js +74 -33
- package/lib/plugins/lsp.js +22 -27
- package/lib/plugins/mcp.js +16 -17
- package/lib/plugins/memory.js +3 -24
- package/lib/plugins/microcompact.d.ts +4 -1
- package/lib/plugins/microcompact.js +117 -19
- package/lib/plugins/mode.js +30 -11
- package/lib/plugins/permission-presets.d.ts +2 -1
- package/lib/plugins/permission-presets.js +55 -35
- package/lib/plugins/plugin-manager.js +4 -6
- package/lib/plugins/presets.js +56 -27
- package/lib/plugins/prompt.js +54 -11
- package/lib/plugins/ptc.d.ts +13 -0
- package/lib/plugins/ptc.js +121 -24
- package/lib/plugins/remote/types.d.ts +1 -1
- package/lib/plugins/remote/types.js +11 -0
- package/lib/plugins/remote.js +14 -15
- package/lib/plugins/runtime.js +91 -14
- package/lib/plugins/sandbox.js +181 -60
- package/lib/plugins/schedule.js +12 -11
- package/lib/plugins/self-improve.js +28 -18
- package/lib/plugins/session-search.js +18 -13
- package/lib/plugins/session-title.js +1 -1
- package/lib/plugins/session.js +103 -25
- package/lib/plugins/settings.js +16 -40
- package/lib/plugins/skills.js +18 -1
- package/lib/plugins/spill.js +18 -11
- package/lib/plugins/subagent.js +208 -42
- package/lib/plugins/team.js +11 -5
- package/lib/plugins/todo.d.ts +1 -1
- package/lib/plugins/todo.js +25 -19
- package/lib/plugins/tool-search.js +47 -28
- package/lib/plugins/tools-default.js +89 -5
- package/lib/plugins/tools.js +3 -3
- package/lib/plugins/transcript.js +116 -9
- package/lib/plugins/web-search.d.ts +1 -1
- package/lib/plugins/web-search.js +25 -16
- package/lib/plugins/webserver.js +40 -7
- package/lib/remote/assets/app-B3Id1EBq.js +14 -0
- package/lib/remote/assets/index.html +2 -2
- package/lib/remote/assets/{style-DIB6729x.css → style-NtlpbKOI.css} +1 -1
- package/lib/services/types.d.ts +247 -29
- package/lib/tools/plugin-cli.d.ts +1 -0
- package/lib/tools/plugin-cli.js +209 -0
- package/lib/ui/assets/app-B-Jx5dnh.js +90 -0
- package/lib/ui/assets/{chunk-BajyYBss.js → chunk-Bfdlo8Me.js} +1 -1
- package/lib/ui/assets/chunk-DGX-i4eb.js +12 -0
- package/lib/ui/assets/index.html +62 -14
- package/lib/ui/assets/style-WzxwEPaE.css +1 -0
- package/lib/ui/frames.js +1 -3
- package/lib/ui/index.d.ts +30 -1
- package/lib/ui/index.js +29 -0
- package/lib/ui/manifest.d.ts +24 -6
- package/lib/ui/manifest.js +3 -2
- package/lib/ui/plugins/actions/bundle.json +8 -0
- package/lib/ui/plugins/actions/client.js +43 -0
- package/lib/ui/plugins/ask/bundle.json +8 -0
- package/lib/ui/plugins/ask/client.js +415 -0
- package/lib/ui/plugins/browser/bundle.json +8 -0
- package/lib/ui/plugins/composer/bundle.json +9 -0
- package/lib/ui/plugins/composer/client.js +1806 -1087
- package/lib/ui/plugins/files/bundle.json +8 -0
- package/lib/ui/plugins/files/client.js +13 -98
- package/lib/ui/plugins/manifest.json +1 -104
- package/lib/ui/plugins/palette/bundle.json +8 -0
- package/lib/ui/plugins/palette/client.js +360 -0
- package/lib/ui/plugins/plugins/bundle.json +8 -0
- package/lib/ui/plugins/plugins/client.js +116 -38
- package/lib/ui/plugins/preview/bundle.json +8 -0
- package/lib/ui/plugins/preview/client.js +6 -16
- package/lib/ui/plugins/prompt/bundle.json +8 -0
- package/lib/ui/plugins/prompt/client.js +81 -47
- package/lib/ui/plugins/sessions/bundle.json +8 -0
- package/lib/ui/plugins/sessions/client.js +157 -111
- package/lib/ui/plugins/settings/bundle.json +8 -0
- package/lib/ui/plugins/settings/client.js +184 -170
- package/lib/ui/plugins/skills/bundle.json +8 -0
- package/lib/ui/plugins/skills/client.js +161 -79
- package/lib/ui/plugins/status/bundle.json +8 -0
- package/lib/ui/plugins/status/client.js +165 -26
- package/lib/ui/plugins/statusbar/bundle.json +9 -0
- package/lib/ui/plugins/statusbar/client.js +100 -144
- package/lib/ui/plugins/tasks/bundle.json +8 -0
- package/lib/ui/plugins/team/bundle.json +8 -0
- package/lib/ui/plugins/team/client.js +60 -58
- package/lib/ui/plugins/terminal/bundle.json +8 -0
- package/lib/ui/plugins/terminal/client.js +1 -7
- package/lib/ui/plugins/trace/bundle.json +11 -0
- package/lib/ui/plugins/trace/client.js +86 -179
- package/lib/ui/plugins/transcript/bundle.json +8 -0
- package/lib/ui/plugins/transcript/client.js +1608 -1243
- package/lib/ui/sdk/@dsc/ui/index.d.ts +54 -16
- package/lib/ui/sdk/@dsc/ui/package.json +1 -1
- package/lib/ui/sdk/@dsc/ui-core/contract.d.ts +20 -1968
- package/lib/ui/sdk/@dsc/ui-core/core/attachments.d.ts +185 -0
- package/lib/ui/sdk/@dsc/ui-core/core/bytes.d.ts +14 -0
- package/lib/ui/sdk/@dsc/ui-core/core/err-text.d.ts +18 -0
- package/lib/ui/sdk/@dsc/ui-core/core/git-surface.d.ts +17 -0
- package/lib/ui/sdk/@dsc/ui-core/core/json-text.d.ts +11 -0
- package/lib/ui/sdk/@dsc/ui-core/core/path-policy.d.ts +44 -0
- package/lib/ui/sdk/@dsc/ui-core/core/records.d.ts +16 -0
- package/lib/ui/sdk/@dsc/ui-core/core/throughput.d.ts +46 -0
- package/lib/ui/sdk/@dsc/ui-core/core/token-estimate.d.ts +18 -2
- package/lib/ui/sdk/@dsc/ui-core/core/unified-diff.d.ts +35 -0
- package/lib/ui/sdk/@dsc/ui-core/package.json +1 -1
- package/lib/ui/sdk/@dsc/ui-core/ui/index.d.ts +30 -1
- package/lib/ui/sdk/@dsc/ui-core/ui/manifest.d.ts +24 -6
- package/lib/ui/sdk/@dsc/ui-core/ui/services.d.ts +19 -8
- package/lib/ui/sdk/@dsc/ui-core/ui/signal.d.ts +49 -0
- package/lib/ui/sdk/@dsc/ui-dockkit/dock-model.d.ts +17 -3
- package/lib/ui/sdk/@dsc/ui-dockkit/dock-state.d.ts +1 -1
- package/lib/ui/sdk/@dsc/ui-dockkit/package.json +1 -1
- package/lib/ui/sdk/@dsc/ui-layout/app.d.ts +4 -0
- package/lib/ui/sdk/@dsc/ui-layout/appearance.d.ts +6 -1
- package/lib/ui/sdk/@dsc/ui-layout/host-channel.d.ts +21 -0
- package/lib/ui/sdk/@dsc/ui-layout/index.d.ts +1 -0
- package/lib/ui/sdk/@dsc/ui-layout/package.json +1 -1
- package/lib/ui/sdk/@dsc/ui-layout/page-state.d.ts +1 -1
- package/lib/ui/sdk/@dsc/ui-layout/runtime-context.d.ts +10 -1
- package/lib/ui/sdk/@dsc/ui-layout/thread-view.d.ts +1 -1
- package/lib/ui/sdk/@dsc/ui-layout/usage-today.d.ts +11 -0
- package/lib/ui/sdk/@dsc/ui-primitives/dialog-focus.d.ts +30 -0
- package/lib/ui/sdk/@dsc/ui-primitives/error-text.d.ts +12 -0
- package/lib/ui/sdk/@dsc/ui-primitives/git-surface.d.ts +9 -0
- package/lib/ui/sdk/@dsc/ui-primitives/highlight.d.ts +23 -0
- package/lib/ui/sdk/@dsc/ui-primitives/humanize-error.d.ts +35 -0
- package/lib/ui/sdk/@dsc/ui-primitives/icons-workspace.d.ts +33 -0
- package/lib/ui/sdk/@dsc/ui-primitives/icons.d.ts +21 -3
- package/lib/ui/sdk/@dsc/ui-primitives/image-lightbox.d.ts +21 -0
- package/lib/ui/sdk/@dsc/ui-primitives/index.d.ts +16 -0
- package/lib/ui/sdk/@dsc/ui-primitives/markdown.d.ts +10 -14
- package/lib/ui/sdk/@dsc/ui-primitives/package.json +1 -1
- package/lib/ui/sdk/@dsc/ui-primitives/panels.d.ts +31 -8
- package/lib/ui/sdk/@dsc/ui-primitives/paths.d.ts +2 -0
- package/lib/ui/sdk/@dsc/ui-primitives/review-findings-card.d.ts +25 -0
- package/lib/ui/sdk/@dsc/ui-primitives/review-findings.d.ts +64 -0
- package/lib/ui/sdk/@dsc/ui-primitives/review-notice-card.d.ts +27 -0
- package/lib/ui/sdk/@dsc/ui-primitives/review-notice.d.ts +80 -0
- package/lib/ui/sdk/@dsc/ui-primitives/signal.d.ts +9 -0
- package/lib/ui/sdk/@dsc/ui-primitives/sizes.d.ts +15 -0
- package/lib/ui/sdk/@dsc/ui-primitives/skeleton.d.ts +39 -0
- package/lib/ui/sdk/@dsc/ui-primitives/snapshot.d.ts +46 -0
- package/lib/ui/sdk/@dsc/ui-primitives/thread-resizer.d.ts +3 -3
- package/lib/ui/sdk/@dsc/ui-primitives/throughput.d.ts +13 -0
- package/lib/ui/sdk/@dsc/ui-primitives/tokens.d.ts +9 -0
- package/lib/ui/sdk/@dsc/ui-primitives/tool-args.d.ts +1 -1
- package/lib/ui/sdk/@dsc/ui-primitives/tool-summary.d.ts +30 -6
- package/lib/ui/sdk/@dsc/ui-primitives/unified-diff.d.ts +10 -0
- package/lib/ui/sdk/@dsc/ui-renderer/boot.d.ts +10 -1
- package/lib/ui/sdk/@dsc/ui-renderer/cordis-host.d.ts +113 -0
- package/lib/ui/sdk/@dsc/ui-renderer/package.json +1 -1
- package/lib/ui/sdk/@dsc/ui-slots/package.json +1 -1
- package/lib/ui/services.d.ts +19 -8
- package/lib/ui/services.js +20 -12
- package/lib/ui/signal.d.ts +49 -0
- package/lib/ui/signal.js +57 -0
- package/lib/ui/tui-plugins.js +36 -16
- package/package.json +71 -58
- package/lib/remote/assets/app-DAcUCOEn.js +0 -14
- package/lib/ui/assets/app-B70nVIKd.js +0 -69
- package/lib/ui/assets/chunk-BGcgwlCI.js +0 -12
- package/lib/ui/assets/style-Bq01xH_b.css +0 -1
package/lib/plugins/sandbox.js
CHANGED
|
@@ -30,11 +30,14 @@
|
|
|
30
30
|
*/
|
|
31
31
|
import { mkdirSync } from 'node:fs';
|
|
32
32
|
import { resolve } from 'node:path';
|
|
33
|
+
import { clockText } from '../core/clock.js';
|
|
34
|
+
import { errText } from '../core/err-text.js';
|
|
33
35
|
import { DSC_HOME } from '../core/path-policy.js';
|
|
34
36
|
import { bootNoticeOnce } from '../core/boot-notices.js';
|
|
35
37
|
import { resolvePluginConfig, writePluginConfig } from '../core/plugin-registry.js';
|
|
36
38
|
import { registerCommandRunner } from '../core/tools/command-runner.js';
|
|
37
39
|
import { readSandboxRequest } from '../core/tools/sandbox-args.js';
|
|
40
|
+
import { permissionOf, writePermissions } from '../core/permission-scope.js';
|
|
38
41
|
import { createDockerRunner, probeDocker } from '../core/sandbox/backends.js';
|
|
39
42
|
import { createWindowsTokenRunner, probeWindowsToken } from '../core/sandbox/win/backend.js';
|
|
40
43
|
import { readSetupState } from '../core/sandbox/win/account.js';
|
|
@@ -51,14 +54,18 @@ const SECTION_ORDER = 31;
|
|
|
51
54
|
/** 内存里留最近几次拒绝给 `/sandbox` 看。 */
|
|
52
55
|
const DENY_BUFFER = 3;
|
|
53
56
|
const PASS = { allowed: true, rule: 'allowed', why: '', how: '' };
|
|
54
|
-
/**
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
57
|
+
/**
|
|
58
|
+
* 越界之后**可以问用户一次**的规则(参考实现只读档的形态:沙箱拦下 → 审批卡问
|
|
59
|
+
* 「这一次要不要破例」)。其余规则保持硬拒:
|
|
60
|
+
* read-only-subpath 用户亲手标的只读子树,点一次允许就等于把那个开关作废;
|
|
61
|
+
* protected-metadata .git/.ssh/.env 与 dsc 自己的配置,改它等于换掉安全边界;
|
|
62
|
+
* network-off 显式关掉的网络开关,不该被一张卡绕过去;
|
|
63
|
+
* nt-namespace / ads-stream / short-name / unresolvable 是形状或解析失败,没有「这一次」可言。
|
|
64
|
+
*/
|
|
65
|
+
const ASKABLE_RULES = new Set(['outside-writable-roots', 'mode-read-only']);
|
|
66
|
+
/** 规则名(可能带 `write-target:` 前缀)能不能交审批卡问一次。 */
|
|
67
|
+
function askableRule(rule) {
|
|
68
|
+
return ASKABLE_RULES.has(rule.replace(/^write-target:/, ''));
|
|
62
69
|
}
|
|
63
70
|
export const sandboxPlugin = {
|
|
64
71
|
name: 'sandbox',
|
|
@@ -89,6 +96,26 @@ export const sandboxPlugin = {
|
|
|
89
96
|
const currentCwd = () => ctx.session.current().meta.cwd;
|
|
90
97
|
const currentSessionId = () => ctx.session.current().meta.id;
|
|
91
98
|
const currentSessionPath = () => ctx.session.current().filePath;
|
|
99
|
+
/**
|
|
100
|
+
* 沙箱档位**按会话**读(2026-10-28):会话里有就用会话的,没有就把默认值钉进去。
|
|
101
|
+
* 默认值来自 plugins.json 的沙箱配置——它只对「还没钉过的会话」与新会话生效。
|
|
102
|
+
*/
|
|
103
|
+
const defaultMode = () => readConfig().config.mode;
|
|
104
|
+
/** 这次判定属于哪个会话:优先按会话 id 找常驻实例,其次按路径,最后看当前查看的。 */
|
|
105
|
+
const sessionOf = (sessionId, sessionPath) => {
|
|
106
|
+
const agent = ctx.get('agent');
|
|
107
|
+
const byId = sessionId !== undefined && sessionId !== '' ? agent?.sessionById(sessionId) : undefined;
|
|
108
|
+
if (byId !== undefined)
|
|
109
|
+
return byId;
|
|
110
|
+
if (sessionPath !== undefined && sessionPath !== '') {
|
|
111
|
+
const byPath = agent?.sessionFor(sessionPath);
|
|
112
|
+
if (byPath !== undefined)
|
|
113
|
+
return byPath;
|
|
114
|
+
}
|
|
115
|
+
return ctx.session.current();
|
|
116
|
+
};
|
|
117
|
+
/** 某个会话现在生效的沙箱档位。 */
|
|
118
|
+
const modeOf = (session) => permissionOf(session, 'sandbox', defaultMode());
|
|
92
119
|
/**
|
|
93
120
|
* 组一份当前策略快照:设置与会话状态都现读,所以设置页改完立刻生效,不用重启宿主。
|
|
94
121
|
* 沙箱私有临时目录顺手建出来(建不出来也不抛:策略会把它当普通路径判)。
|
|
@@ -105,9 +132,10 @@ export const sandboxPlugin = {
|
|
|
105
132
|
* 键是会话路径:一个会话放宽了,别的会话照旧被拦。
|
|
106
133
|
*/
|
|
107
134
|
const sessionRoots = new Map();
|
|
108
|
-
const snapshot = (cwdOverride, sessionPath) => {
|
|
135
|
+
const snapshot = (cwdOverride, sessionPath, modeOverride) => {
|
|
109
136
|
const { config, problems } = readConfig();
|
|
110
137
|
const cwd = cwdOverride ?? currentCwd();
|
|
138
|
+
const mode = modeOverride ?? modeOf(ctx.session.current());
|
|
111
139
|
const granted = sessionPath === undefined ? [] : (sessionRoots.get(sessionPath) ?? []);
|
|
112
140
|
const tmpDir = sandboxTmpDir(DSC_HOME, cwd, currentSessionId());
|
|
113
141
|
try {
|
|
@@ -117,7 +145,7 @@ export const sandboxPlugin = {
|
|
|
117
145
|
// 目录建不出来时写它就是失败的,不必在这里报错(工具自己会拿到真实错误)
|
|
118
146
|
}
|
|
119
147
|
const policy = createPolicy({
|
|
120
|
-
mode
|
|
148
|
+
mode,
|
|
121
149
|
cwd,
|
|
122
150
|
tmpDir,
|
|
123
151
|
extraWritableRoots: [...config.extraWritableRoots, ...granted],
|
|
@@ -132,19 +160,19 @@ export const sandboxPlugin = {
|
|
|
132
160
|
if (rule.startsWith('write-target:'))
|
|
133
161
|
return legalWay(rule.slice('write-target:'.length));
|
|
134
162
|
if (rule === 'network-off')
|
|
135
|
-
return '
|
|
163
|
+
return '在「插件中心 → 文件与命令围栏」打开网络开关,或换成不需要联网的做法';
|
|
136
164
|
if (rule === 'malformed-request')
|
|
137
165
|
return '两个升权参数要么都给(sandbox_permissions + justification),要么都不给';
|
|
138
166
|
return '换一个不需要改机器配置的做法;确需执行这条命令请让用户手工跑';
|
|
139
167
|
};
|
|
140
168
|
/** 记一次拒绝 + 拼给模型看的那句话(带档位、可写根、命中规则、下一步怎么走)。 */
|
|
141
|
-
const refuse = (config, policy, tool, verdict) => {
|
|
169
|
+
const refuse = (config, policy, mode, tool, verdict) => {
|
|
142
170
|
denials.push({ at: Date.now(), tool, rule: verdict.rule, why: verdict.why });
|
|
143
171
|
if (denials.length > DENY_BUFFER)
|
|
144
172
|
denials.shift();
|
|
145
173
|
const roots = policy.roots.length === 0 ? '(无)' : policy.roots.join('、');
|
|
146
174
|
const reason = `沙箱拒绝这次 ${tool}:${verdict.why}。` +
|
|
147
|
-
`当前档位 ${
|
|
175
|
+
`当前档位 ${mode}(可写根:${roots};网络:${config.networkAccess ? '开' : '关'}),` +
|
|
148
176
|
`命中规则「${verdict.rule}」。${verdict.how}`;
|
|
149
177
|
return { action: 'deny', reason };
|
|
150
178
|
};
|
|
@@ -176,9 +204,10 @@ export const sandboxPlugin = {
|
|
|
176
204
|
decide(input) {
|
|
177
205
|
// 按这次调用的工作目录算可写根:input.cwd 就是循环传进来的会话目录,
|
|
178
206
|
// 显式优先于会话状态,同进程多工作目录时才不会拿错根。
|
|
179
|
-
const
|
|
207
|
+
const mode = modeOf(sessionOf(input.sessionId, input.sessionPath));
|
|
208
|
+
const { config, policy } = snapshot(input.cwd, input.sessionPath, mode);
|
|
180
209
|
// 不设围栏的档位:整档交出去(审批与权限模式照常管)
|
|
181
|
-
if (
|
|
210
|
+
if (mode === 'danger-full-access')
|
|
182
211
|
return { action: 'defer' };
|
|
183
212
|
// 读限制不在本插件职责内:内核 path-policy 已经管凭据读取,这里再拒一次只会给两条理由
|
|
184
213
|
if (input.risk === 'read')
|
|
@@ -191,9 +220,9 @@ export const sandboxPlugin = {
|
|
|
191
220
|
allowed: false,
|
|
192
221
|
rule: 'backend-unavailable',
|
|
193
222
|
why: '你要的隔离后端(docker / Windows 受限令牌)没建起来,配置又选了「建不起来就拒」',
|
|
194
|
-
how: '
|
|
223
|
+
how: '两条路:在「插件中心 → 文件与命令围栏」把后端换成策略围栏(进程内那个,接受 partial),或把「后端建不起来时」改回 degrade;也可以先修好后端(docker 起得来 / 提权 setup 成功)',
|
|
195
224
|
};
|
|
196
|
-
return refuse(config, policy, input.toolName, verdict);
|
|
225
|
+
return refuse(config, policy, mode, input.toolName, verdict);
|
|
197
226
|
}
|
|
198
227
|
const request = readSandboxRequest(input.args);
|
|
199
228
|
// 半截的升权请求一律拒:单独一个 sandbox_permissions(想偷偷放宽)
|
|
@@ -205,7 +234,7 @@ export const sandboxPlugin = {
|
|
|
205
234
|
why: `升权参数不完整:${request.reason}`,
|
|
206
235
|
how: howTo('malformed-request'),
|
|
207
236
|
};
|
|
208
|
-
return refuse(config, policy, input.toolName, verdict);
|
|
237
|
+
return refuse(config, policy, mode, input.toolName, verdict);
|
|
209
238
|
}
|
|
210
239
|
const verdict = input.risk === 'write'
|
|
211
240
|
? writeVerdict(policy, input.target)
|
|
@@ -231,36 +260,62 @@ export const sandboxPlugin = {
|
|
|
231
260
|
return { action: 'defer' };
|
|
232
261
|
if (widened.allowed)
|
|
233
262
|
return { action: 'defer' };
|
|
234
|
-
return refuse(config, policy, input.toolName, {
|
|
263
|
+
return refuse(config, policy, mode, input.toolName, {
|
|
235
264
|
allowed: false,
|
|
236
265
|
rule: widened.rule,
|
|
237
266
|
why: `${widened.reason}(模型请求的是「留在沙箱内放宽写边界」,可写根放宽到这一次的目标后**仍然**不合法)`,
|
|
238
267
|
how: legalWay(widened.rule),
|
|
239
268
|
});
|
|
240
269
|
}
|
|
241
|
-
|
|
270
|
+
// 越界但这件事可以问用户一次(参考实现只读档的语义):沙箱只 defer,
|
|
271
|
+
// 审批卡是最后一道。审批插件不在场时不能 defer——那等于无人把关地放行。
|
|
272
|
+
if (askableRule(verdict.rule) && ctx.get('approval') !== undefined)
|
|
273
|
+
return { action: 'defer' };
|
|
274
|
+
return refuse(config, policy, mode, input.toolName, verdict);
|
|
242
275
|
},
|
|
243
276
|
};
|
|
244
277
|
const offGuard = ctx.guards.register(guard);
|
|
245
278
|
// ── 系统提示段(降级必须可见)─────────────────────────────────────────────
|
|
246
|
-
/**
|
|
247
|
-
|
|
248
|
-
|
|
279
|
+
/**
|
|
280
|
+
* 强制等级 → 一句人话。
|
|
281
|
+
*
|
|
282
|
+
* 等级从参数进来,不读全局 `enforcement`:全局值记的是「进程级后端建到哪一步」,
|
|
283
|
+
* 与会话实际生效的等级可能不是一回事(见 {@link effectiveEnforcement})。
|
|
284
|
+
* 读全局会让提示词出现「partial(none:当前档位不设围栏)」这种自相矛盾的话。
|
|
285
|
+
*/
|
|
286
|
+
const enforcementText = (level) => {
|
|
287
|
+
switch (level) {
|
|
249
288
|
case 'full':
|
|
250
|
-
return '
|
|
289
|
+
return '命令的执行体被换成了容器(网络与文件系统由容器隔离)';
|
|
251
290
|
case 'partial':
|
|
252
|
-
return '
|
|
291
|
+
return '进程内策略围栏(拦得住自己发起的工具调用,拦不住命令内部的任意写)';
|
|
253
292
|
default:
|
|
254
|
-
return '
|
|
293
|
+
return '当前档位不设围栏';
|
|
255
294
|
}
|
|
256
295
|
};
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
296
|
+
/**
|
|
297
|
+
* 某个会话实际生效的强制等级。
|
|
298
|
+
*
|
|
299
|
+
* 全局 `enforcement` 记的是「进程级后端建到哪一步」:默认档是 danger-full-access 时
|
|
300
|
+
* refreshBackend 会提前返回,全局值停在 none;但另一个会话切到 workspace-write 时,
|
|
301
|
+
* 守卫仍按进程内策略围栏拦越界写——所以对非 danger 会话,实际等级至少是 partial。
|
|
302
|
+
* 直接把全局值写进设置页/系统提示就会谎报「none:不设围栏」。
|
|
303
|
+
*/
|
|
304
|
+
const effectiveEnforcement = (mode) => mode === 'danger-full-access' ? 'none' : enforcement === 'none' ? 'partial' : enforcement;
|
|
305
|
+
/** 「等级 + 一句解释」连在一起写,两半永远取同一档。 */
|
|
306
|
+
const enforcementNote = (mode) => {
|
|
307
|
+
const level = effectiveEnforcement(mode);
|
|
308
|
+
return `${level} —— ${enforcementText(level)}`;
|
|
309
|
+
};
|
|
310
|
+
const promptText = (scope) => {
|
|
311
|
+
// 这个 agent 自己的档位(后台会话不该拿「你此刻点开的会话」的沙箱说明)。
|
|
312
|
+
const mode = modeOf(sessionOf(scope?.sessionId));
|
|
313
|
+
const { config, policy, problems } = snapshot(scope?.cwd, undefined, mode);
|
|
314
|
+
if (mode === 'danger-full-access') {
|
|
260
315
|
return '【沙箱】档位 danger-full-access:沙箱不设围栏,写盘与命令只受权限模式与审批卡约束。';
|
|
261
316
|
}
|
|
262
317
|
const lines = [];
|
|
263
|
-
lines.push(`【沙箱】档位 ${
|
|
318
|
+
lines.push(`【沙箱】档位 ${mode}|强制执行 ${enforcementNote(mode)}`);
|
|
264
319
|
lines.push(`可写根:${policy.roots.length === 0 ? '(无,只读档不许写盘)' : policy.roots.join('、')};` +
|
|
265
320
|
`只读子路径:${policy.readOnlySubpaths.length === 0 ? '(无)' : policy.readOnlySubpaths.join('、')};` +
|
|
266
321
|
`网络:${config.networkAccess ? '开' : '关(要联网的命令会被直接拒)'}`);
|
|
@@ -268,17 +323,21 @@ export const sandboxPlugin = {
|
|
|
268
323
|
lines.push(`当前后端是 Windows 受限令牌:命令内部的越界写(脚本里的 fs.writeFile 这类)会被系统层直接拒绝;读不受限;网络第二级体检 ${networkTier}(明细见 /sandbox)。`);
|
|
269
324
|
}
|
|
270
325
|
else {
|
|
271
|
-
lines.push('策略围栏拦得住 dsc 自己发起的工具调用,拦不住命令内部的任意写(脚本里的 fs.writeFile
|
|
326
|
+
lines.push('策略围栏拦得住 dsc 自己发起的工具调用,拦不住命令内部的任意写(脚本里的 fs.writeFile 这类);要真隔离,请在「插件中心 → 文件与命令围栏」把后端换成 Windows 受限令牌(本机即可,无需 docker)或容器。');
|
|
272
327
|
}
|
|
273
328
|
lines.push('要写到可写根之外(例如另一个盘的项目目录),只能在这一次调用里同时给 sandbox_permissions 与 justification,且照常会弹审批卡让用户点。');
|
|
274
329
|
if (degradedFailClosed) {
|
|
275
|
-
lines.push('⚠
|
|
330
|
+
lines.push('⚠ 你要的隔离后端没建起来,且配置选了「后端建不起来就拒」:写与执行类工具现在会被沙箱直接拒(读照常)。修法见「插件中心 → 文件与命令围栏」。');
|
|
276
331
|
}
|
|
277
332
|
if (problems.length > 0)
|
|
278
333
|
lines.push(`⚠ 沙箱配置有问题(已按默认值兜底):${problems.join(';')}`);
|
|
279
334
|
return lines.join('\n');
|
|
280
335
|
};
|
|
281
|
-
|
|
336
|
+
// 沙箱说明挂在**请求末尾的环境快照**里,不进系统提示词(2026-10-30 报障):
|
|
337
|
+
// 档位一改系统提示词就变,服务端前缀缓存从那一行起全失效(实测切一次权限,
|
|
338
|
+
// 下一次请求 59K 未命中、只命中 4K)。挪到快照之后前缀稳定,模型每轮照样看到最新档位。
|
|
339
|
+
// 子代理不受影响:它本来就不拿系统提示词里的这段(见 subagent 插件自己的提示词)。
|
|
340
|
+
const offPrompt = ctx.prompt.registerEnvFacts('sandbox', (session) => promptText({ sessionId: session?.meta.id, cwd: session?.meta.cwd }));
|
|
282
341
|
// ── 后端探测与降级 ────────────────────────────────────────────────────────
|
|
283
342
|
/**
|
|
284
343
|
* 按当前设置重新决定后端与强制执行等级。
|
|
@@ -298,7 +357,12 @@ export const sandboxPlugin = {
|
|
|
298
357
|
const { config } = readConfig();
|
|
299
358
|
if (config.mode === 'danger-full-access') {
|
|
300
359
|
enforcement = 'none';
|
|
301
|
-
|
|
360
|
+
// 这一档不设围栏,后端与「建不起来就拒」都不参与判定。说清楚,
|
|
361
|
+
// 免得用户以为选了 fail-closed 就一定拒——那和「完全访问」的语义相抵。
|
|
362
|
+
backendDetail =
|
|
363
|
+
config.backend !== 'policy' && config.onUnavailable === 'fail-closed'
|
|
364
|
+
? '档位 danger-full-access:不设围栏;后端与「建不起来就拒」在这一档不生效'
|
|
365
|
+
: '档位 danger-full-access:不设围栏';
|
|
302
366
|
ctx.emit('dsc/changed');
|
|
303
367
|
return backendDetail;
|
|
304
368
|
}
|
|
@@ -327,8 +391,8 @@ export const sandboxPlugin = {
|
|
|
327
391
|
: undefined;
|
|
328
392
|
const handle = createWindowsTokenRunner({
|
|
329
393
|
mode: config.mode === 'read-only' ? 'read-only' : 'workspace-write',
|
|
394
|
+
// 这里只是「挂载时所在会话」的起点;之后每次调用按 run.cwd 现算可写根(常驻多会话)
|
|
330
395
|
cwd: currentCwd(),
|
|
331
|
-
tmpDir: sandboxTmpDir(DSC_HOME, currentCwd(), currentSessionId()),
|
|
332
396
|
extraRoots: config.extraWritableRoots,
|
|
333
397
|
networkAccess: () => readConfig().config.networkAccess,
|
|
334
398
|
networkAllowlist: () => readConfig().config.networkAllowlist,
|
|
@@ -378,11 +442,12 @@ export const sandboxPlugin = {
|
|
|
378
442
|
/** 挂载时那条可见说明:只讲档位、强制等级与网络,明细(后端、可写根)在 /sandbox 与设置里。 */
|
|
379
443
|
const mountLine = () => {
|
|
380
444
|
const { config, problems } = snapshot();
|
|
381
|
-
const
|
|
382
|
-
const
|
|
445
|
+
const effective = effectiveEnforcement(modeOf(ctx.session.current()));
|
|
446
|
+
const head = `沙箱已就绪:档位 ${modeOf(ctx.session.current())}|强制执行 ${effective}|网络 ${config.networkAccess ? '开' : '关'}`;
|
|
447
|
+
const tail = effective === 'partial'
|
|
383
448
|
? (config.backend === 'windows-token'
|
|
384
449
|
? '。越界写已被系统层拦截;明细见 /sandbox。'
|
|
385
|
-
: '
|
|
450
|
+
: '。策略围栏拦得住工具调用,拦不住命令内部的任意写,要真隔离请在「插件中心 → 文件与命令围栏」换后端。')
|
|
386
451
|
: '。';
|
|
387
452
|
const warn = problems.length === 0 ? '' : ` ⚠ 配置有问题(已按默认值兜底):${problems.join(';')}`;
|
|
388
453
|
return `${head}${tail}${warn}`;
|
|
@@ -410,7 +475,7 @@ export const sandboxPlugin = {
|
|
|
410
475
|
const report = () => {
|
|
411
476
|
const { config, policy, problems } = snapshot();
|
|
412
477
|
const lines = [];
|
|
413
|
-
lines.push(
|
|
478
|
+
lines.push(`沙箱现状:当前会话档位 ${modeOf(ctx.session.current())}|新会话默认 ${config.mode}|强制执行 ${effectiveEnforcement(modeOf(ctx.session.current()))}`);
|
|
414
479
|
lines.push(`后端:${config.backend} —— ${backendDetail}`);
|
|
415
480
|
lines.push(`可写根(${String(policy.roots.length)}):`);
|
|
416
481
|
if (policy.roots.length === 0)
|
|
@@ -435,15 +500,15 @@ export const sandboxPlugin = {
|
|
|
435
500
|
if (denials.length === 0)
|
|
436
501
|
lines.push(' (还没有)');
|
|
437
502
|
for (const one of denials)
|
|
438
|
-
lines.push(` [${
|
|
503
|
+
lines.push(` [${clockText(one.at)}] ${one.tool} · ${one.rule} —— ${one.why}`);
|
|
439
504
|
if (problems.length > 0)
|
|
440
505
|
lines.push(`⚠ 配置有问题(已按默认值兜底):${problems.join(';')}`);
|
|
441
506
|
return lines.join('\n');
|
|
442
507
|
};
|
|
443
508
|
const section = {
|
|
444
509
|
id: SANDBOX_CONFIG_KEY,
|
|
445
|
-
title: '
|
|
446
|
-
subtitle: '
|
|
510
|
+
title: '文件与命令围栏',
|
|
511
|
+
subtitle: '限定能写哪里:可写目录、受保护路径、联网开关与强制执行后端',
|
|
447
512
|
order: SECTION_ORDER,
|
|
448
513
|
fields() {
|
|
449
514
|
const { config, policy, problems } = snapshot();
|
|
@@ -451,13 +516,24 @@ export const sandboxPlugin = {
|
|
|
451
516
|
{
|
|
452
517
|
type: 'select',
|
|
453
518
|
key: 'mode',
|
|
454
|
-
label: '
|
|
519
|
+
label: '这个会话允许写哪里',
|
|
520
|
+
options: [
|
|
521
|
+
{ value: 'read-only', label: '只读(任何写盘都拒)' },
|
|
522
|
+
{ value: 'workspace-write', label: '工作区可写(默认)' },
|
|
523
|
+
{ value: 'danger-full-access', label: '不设围栏(等同关掉这层保护)' },
|
|
524
|
+
],
|
|
525
|
+
help: '只改当前打开的会话,换会话各用各的档位。平时保持这一档就行:正常的工作区读写与命令不会被拦,只有越界写、改受保护文件、关网时联网会被拒。',
|
|
526
|
+
},
|
|
527
|
+
{
|
|
528
|
+
type: 'select',
|
|
529
|
+
key: 'defaultMode',
|
|
530
|
+
label: '以后新开的会话默认写哪里',
|
|
455
531
|
options: [
|
|
456
532
|
{ value: 'read-only', label: '只读(任何写盘都拒)' },
|
|
457
533
|
{ value: 'workspace-write', label: '工作区可写(默认)' },
|
|
458
|
-
{ value: 'danger-full-access', label: '
|
|
534
|
+
{ value: 'danger-full-access', label: '不设围栏(等同关掉这层保护)' },
|
|
459
535
|
],
|
|
460
|
-
help: '
|
|
536
|
+
help: '只影响之后新建的会话;已经打开的会话保留自己的档位。',
|
|
461
537
|
},
|
|
462
538
|
{
|
|
463
539
|
type: 'select',
|
|
@@ -467,7 +543,7 @@ export const sandboxPlugin = {
|
|
|
467
543
|
{ value: 'degrade', label: '降级为策略围栏(照常干,审批卡兜底)' },
|
|
468
544
|
{ value: 'fail-closed', label: '拒绝:写与执行类一律拒(读照常)' },
|
|
469
545
|
],
|
|
470
|
-
help: '只对 docker
|
|
546
|
+
help: '只对 docker 与 Windows 受限令牌这两个真隔离后端生效:它们建不起来时,是降级为进程内策略围栏照常干,还是拒绝写与执行。进程内策略围栏的 partial 是预期状态,不受这一项影响。',
|
|
471
547
|
},
|
|
472
548
|
{
|
|
473
549
|
type: 'switch',
|
|
@@ -521,14 +597,14 @@ export const sandboxPlugin = {
|
|
|
521
597
|
placeholder: DEFAULT_SANDBOX_IMAGE,
|
|
522
598
|
help: `容器后端用的镜像,默认 ${DEFAULT_SANDBOX_IMAGE}。镜像里得有你那条命令要用的工具(例如 node:20-alpine)。`,
|
|
523
599
|
},
|
|
524
|
-
{ type: 'info', label: '
|
|
600
|
+
{ type: 'info', label: '当前会话强制执行等级', text: enforcementNote(modeOf(ctx.session.current())) },
|
|
525
601
|
{ type: 'info', label: '后端现状', text: backendDetail },
|
|
526
602
|
{ type: 'info', label: '沙箱私有临时目录', mono: true, copyable: true, text: policy.tmpDir },
|
|
527
603
|
{ type: 'info', label: '当前生效', text: describePolicy(policy) },
|
|
528
604
|
{
|
|
529
605
|
type: 'info',
|
|
530
606
|
label: '最近 3 次拒绝',
|
|
531
|
-
text: denials.length === 0 ? '(还没有)' : denials.map((one) => `[${
|
|
607
|
+
text: denials.length === 0 ? '(还没有)' : denials.map((one) => `[${clockText(one.at)}] ${one.tool} · ${one.rule} —— ${one.why}`).join('\n'),
|
|
532
608
|
},
|
|
533
609
|
{
|
|
534
610
|
type: 'button',
|
|
@@ -566,7 +642,8 @@ export const sandboxPlugin = {
|
|
|
566
642
|
values() {
|
|
567
643
|
const { config } = readConfig();
|
|
568
644
|
return {
|
|
569
|
-
mode:
|
|
645
|
+
mode: modeOf(ctx.session.current()),
|
|
646
|
+
defaultMode: config.mode,
|
|
570
647
|
networkAccess: config.networkAccess,
|
|
571
648
|
networkAllowlist: formatPathList(config.networkAllowlist),
|
|
572
649
|
extraWritableRoots: formatPathList(config.extraWritableRoots),
|
|
@@ -579,6 +656,13 @@ export const sandboxPlugin = {
|
|
|
579
656
|
async save(key, value) {
|
|
580
657
|
switch (key) {
|
|
581
658
|
case 'mode': {
|
|
659
|
+
const mode = String(value);
|
|
660
|
+
if (!SANDBOX_MODES.includes(mode))
|
|
661
|
+
return `档位只能是 ${SANDBOX_MODES.join(' / ')}`;
|
|
662
|
+
writePermissions(ctx.session.current(), { sandbox: mode });
|
|
663
|
+
break;
|
|
664
|
+
}
|
|
665
|
+
case 'defaultMode': {
|
|
582
666
|
const mode = String(value);
|
|
583
667
|
if (!SANDBOX_MODES.includes(mode))
|
|
584
668
|
return `档位只能是 ${SANDBOX_MODES.join(' / ')}`;
|
|
@@ -658,10 +742,10 @@ export const sandboxPlugin = {
|
|
|
658
742
|
// ── 对外服务 ─────────────────────────────────────────────────────────────
|
|
659
743
|
const service = {
|
|
660
744
|
get mode() {
|
|
661
|
-
return
|
|
745
|
+
return modeOf(ctx.session.current());
|
|
662
746
|
},
|
|
663
747
|
get enforcement() {
|
|
664
|
-
return
|
|
748
|
+
return effectiveEnforcement(modeOf(ctx.session.current()));
|
|
665
749
|
},
|
|
666
750
|
get writableRoots() {
|
|
667
751
|
return snapshot().policy.roots;
|
|
@@ -672,24 +756,45 @@ export const sandboxPlugin = {
|
|
|
672
756
|
get tmpDir() {
|
|
673
757
|
return snapshot().policy.tmpDir;
|
|
674
758
|
},
|
|
675
|
-
canWrite(path, cwd) {
|
|
759
|
+
canWrite(path, cwd, sessionPath) {
|
|
676
760
|
// cwd 省略时退回会话工作目录(接口约定见 src/services/types.ts 的 SandboxService)。
|
|
677
|
-
const { policy } = snapshot(cwd);
|
|
761
|
+
const { policy } = snapshot(cwd, sessionPath, modeOf(sessionOf(undefined, sessionPath)));
|
|
678
762
|
const check = checkWrite(policy, path);
|
|
679
763
|
const out = { allowed: check.allowed, reason: check.reason };
|
|
680
764
|
if (check.root !== undefined)
|
|
681
765
|
out.root = check.root;
|
|
682
766
|
return out;
|
|
683
767
|
},
|
|
684
|
-
describe() {
|
|
685
|
-
const { config, policy } = snapshot();
|
|
686
|
-
return `沙箱 ${config.mode}(强制执行 ${enforcement}):${describePolicy(policy)}`;
|
|
687
|
-
},
|
|
688
768
|
/**
|
|
689
|
-
*
|
|
690
|
-
*
|
|
691
|
-
*
|
|
769
|
+
* 审批用:这次调用越界了没有、越界之后能不能问用户。
|
|
770
|
+
* 守卫里同一条判定已经做过一遍(order 8),这里再做一遍是刻意的——审批是
|
|
771
|
+
* 自动放行的最后一道,它不能假设「沙箱一定已经判过」。
|
|
692
772
|
*/
|
|
773
|
+
check(target, command, cwd, sessionPath) {
|
|
774
|
+
const mode = modeOf(sessionOf(undefined, sessionPath));
|
|
775
|
+
const { config, policy } = snapshot(cwd, sessionPath, mode);
|
|
776
|
+
if (mode === 'danger-full-access')
|
|
777
|
+
return { allowed: true, requestable: false };
|
|
778
|
+
const verdict = target !== undefined && target.trim() !== ''
|
|
779
|
+
? writeVerdict(policy, target)
|
|
780
|
+
: command !== undefined && command.trim() !== ''
|
|
781
|
+
? execVerdict(config, policy, command)
|
|
782
|
+
: PASS;
|
|
783
|
+
if (verdict.allowed)
|
|
784
|
+
return { allowed: true, requestable: false };
|
|
785
|
+
const rule = verdict.rule.replace(/^write-target:/, '');
|
|
786
|
+
return {
|
|
787
|
+
allowed: false,
|
|
788
|
+
requestable: askableRule(verdict.rule),
|
|
789
|
+
reason: verdict.why,
|
|
790
|
+
rule,
|
|
791
|
+
};
|
|
792
|
+
},
|
|
793
|
+
describe() {
|
|
794
|
+
const { policy } = snapshot();
|
|
795
|
+
const mode = modeOf(ctx.session.current());
|
|
796
|
+
return `沙箱 ${mode}(强制执行 ${effectiveEnforcement(mode)}):${describePolicy(policy)}`;
|
|
797
|
+
},
|
|
693
798
|
/**
|
|
694
799
|
* 记一条**本会话**的放宽:把几个绝对路径并进这个会话的可写根。
|
|
695
800
|
* 只有审批卡上「本会话允许」那一按会调它(调用方是 approval 插件)。
|
|
@@ -708,7 +813,23 @@ export const sandboxPlugin = {
|
|
|
708
813
|
sessionGrants(sessionPath) {
|
|
709
814
|
return sessionRoots.get(sessionPath) ?? [];
|
|
710
815
|
},
|
|
816
|
+
/**
|
|
817
|
+
* 切**当前会话**的档位(打包权限预设与设置页走同一条写口)。
|
|
818
|
+
* 只写会话状态,不动 plugins.json——那一份是「新会话默认」,换它要走 setDefaultMode。
|
|
819
|
+
* @param next - 三档之一;写错当场抛错(预设表是常量,正常到不了这里)。
|
|
820
|
+
*/
|
|
711
821
|
setMode(next) {
|
|
822
|
+
if (!SANDBOX_MODES.includes(next)) {
|
|
823
|
+
throw new Error(`沙箱档位只能是 ${SANDBOX_MODES.join(' / ')},收到「${next}」`);
|
|
824
|
+
}
|
|
825
|
+
writePermissions(ctx.session.current(), { sandbox: next });
|
|
826
|
+
ctx.emit('dsc/changed');
|
|
827
|
+
},
|
|
828
|
+
/**
|
|
829
|
+
* 设「新会话默认档位」:写 plugins.json 并重算进程级后端。
|
|
830
|
+
* 只影响之后新建的会话;已有会话的档位不受影响。
|
|
831
|
+
*/
|
|
832
|
+
setDefaultMode(next) {
|
|
712
833
|
if (!SANDBOX_MODES.includes(next)) {
|
|
713
834
|
throw new Error(`沙箱档位只能是 ${SANDBOX_MODES.join(' / ')},收到「${next}」`);
|
|
714
835
|
}
|
package/lib/plugins/schedule.js
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import { resolvePluginConfig, writePluginConfig } from '../core/plugin-registry.js';
|
|
2
2
|
import { describeNext, describeRule, isValidTimeZone, isOneShot, nextRunAt, parseRule, systemTimeZone, SCHEDULE_RULE_KINDS, } from '../core/schedule/rule.js';
|
|
3
3
|
import { ScheduleRunner, scheduleLimitsNote } from '../core/schedule/runner.js';
|
|
4
|
-
import {
|
|
4
|
+
import { ScheduleStore } from '../core/schedule/store.js';
|
|
5
|
+
import { errText as errorText } from '../core/err-text.js';
|
|
6
|
+
import { clampInt as clampNumber } from '../core/clamp.js';
|
|
5
7
|
/** 配置键(`~/.dsc/plugins.json` 条目树里 `file` 等于这个名字那一项的 `config`)。 */
|
|
6
8
|
const CONFIG_KEY = 'schedule';
|
|
7
9
|
/** 缺省值:时区取系统时区,单次最长 10 分钟,历史 200 条。 */
|
|
8
10
|
const DEFAULTS = { enabled: true, maxRunSeconds: 600, historyLimit: 200 };
|
|
9
|
-
/** 数值夹取:不是数字就回落,越界就夹。 */
|
|
10
|
-
function clampNumber(value, min, max, fallback) {
|
|
11
|
-
const num = Number(value);
|
|
12
|
-
return Number.isFinite(num) ? Math.min(Math.max(Math.round(num), min), max) : fallback;
|
|
13
|
-
}
|
|
14
11
|
/**
|
|
15
12
|
* 从插件配置里取可调项并夹到合理区间。
|
|
16
13
|
* @param passed - 装配时直接传进来的配置(内核挂载时的第二参数)
|
|
@@ -145,9 +142,12 @@ export const schedulePlugin = {
|
|
|
145
142
|
const route = ctx.llm.route();
|
|
146
143
|
return { baseUrl: route.baseUrl, apiKey: route.apiKey, model: route.model };
|
|
147
144
|
},
|
|
148
|
-
deliver: (text) => {
|
|
145
|
+
deliver: (text, task) => {
|
|
149
146
|
// 定点任务是机器发起的投递:跑动中入箱时标 notice,画在输入框上方的只读通知条。
|
|
150
|
-
|
|
147
|
+
// 目标会话用**建这条任务的那个会话**(task.sessionId),不是当前正在看的会话:
|
|
148
|
+
// 用户切走之后,提醒仍该回到原来的对话里。老任务没存 sessionId 时才回落当前会话。
|
|
149
|
+
const target = task.sessionId === '' ? undefined : task.sessionId;
|
|
150
|
+
ctx.agent.followup(text, undefined, target, 'notice');
|
|
151
151
|
},
|
|
152
152
|
waiting: () => ctx.waiting.any,
|
|
153
153
|
sessionId: () => ctx.session.current().meta.id,
|
|
@@ -405,14 +405,15 @@ export const schedulePlugin = {
|
|
|
405
405
|
'宿主不常驻(桌面端/终端关着)时不会触发,错过的排期至多补一次、不补积压。');
|
|
406
406
|
}, { order: 41 });
|
|
407
407
|
// ── 会话结束对账:把「投出去了但回合失败」接回到重试策略上 ───────────────────
|
|
408
|
-
const turnEndDisposer = ctx.on('dsc/turn-end', (reason) => {
|
|
409
|
-
|
|
408
|
+
const turnEndDisposer = ctx.on('dsc/turn-end', (reason, signal) => {
|
|
409
|
+
// 带上会话归属:后台会话的回合结束不能把队首那条投递记成「成功了」。
|
|
410
|
+
runner.noteTurnEnd(reason, signal.sessionId);
|
|
410
411
|
});
|
|
411
412
|
// ── 设置分区 ──────────────────────────────────────────────────────────────
|
|
412
413
|
const section = {
|
|
413
414
|
id: 'schedule',
|
|
414
415
|
title: '定时任务',
|
|
415
|
-
subtitle: '
|
|
416
|
+
subtitle: '六种时间选择器 + 时区;到点把任务投回建它的会话',
|
|
416
417
|
order: 32,
|
|
417
418
|
fields() {
|
|
418
419
|
const current = readConfig(passed);
|