@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/contract.js
CHANGED
|
@@ -1,36 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* UI ⇄ adapter
|
|
2
|
+
* UI ⇄ adapter 的共享契约(单一真源)。**本文件只做转出**,实体按域放在 `src/contract/`。
|
|
3
3
|
*
|
|
4
4
|
* 边界规则(对齐 dsh-TUI 的 adapter 边界实践):
|
|
5
5
|
* - `src/adapter/**` 是唯一允许 import `@deepseek-ai/*` 运行期包的层;
|
|
6
|
-
* - UI
|
|
6
|
+
* - UI 层(`src/app/**`、`src/state/**`、`src/commands.ts`)只依赖这里的
|
|
7
7
|
* 中立类型,通过 DscRuntime 与宿主世界交互;
|
|
8
|
-
* -
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
tokens: false,
|
|
16
|
-
cost: true,
|
|
17
|
-
mode: false,
|
|
18
|
-
policy: true,
|
|
19
|
-
ctx: true,
|
|
20
|
-
cwd: true,
|
|
21
|
-
session: false,
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* 把老存档 / 老宿主 / 手改坏档里的 `ui.statusBar` 归一成全键视图:对象缺失或
|
|
25
|
-
* 单键缺失都回落出厂默认(与 prefs.ts 的读档白名单同一口径,坏档不拦启动)。
|
|
26
|
-
* 桌面渲染层与 TUI 共用这一份——prefs.ts 带着 node 内置模块,渲染层 import 不得。
|
|
8
|
+
* - 本文件与 `src/contract/**` 自身不得 import 任何 `@deepseek-ai/*`。
|
|
9
|
+
*
|
|
10
|
+
* 为什么分家:一份 2,093 行的契约文件里改「设置」的一个字段,要在 2,093 行里找位置;
|
|
11
|
+
* 十来个人同时动的话每次都是冲突。分成十域之后每域一两百行,改设置只看 `settings.ts`。
|
|
12
|
+
* 导出面一个没变——调用方照旧 `import type { … } from '../contract.js'`。
|
|
13
|
+
*
|
|
14
|
+
* @module dsc/contract
|
|
27
15
|
*/
|
|
28
|
-
export
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
16
|
+
export * from './contract/mode.js';
|
|
17
|
+
export * from './contract/task.js';
|
|
18
|
+
export * from './contract/transcript.js';
|
|
19
|
+
export * from './contract/usage.js';
|
|
20
|
+
export * from './contract/runtime.js';
|
|
21
|
+
export * from './contract/approval.js';
|
|
22
|
+
export * from './contract/session.js';
|
|
23
|
+
export * from './contract/plugin.js';
|
|
24
|
+
export * from './contract/settings.js';
|
|
25
|
+
export * from './contract/snapshot.js';
|
|
@@ -15,7 +15,7 @@ export interface AgentRole {
|
|
|
15
15
|
model: string | null;
|
|
16
16
|
/** 思考强度覆盖;null = 跟随当前档位。 */
|
|
17
17
|
effort: EffortLevel | null;
|
|
18
|
-
/**
|
|
18
|
+
/** 内部请求轮次上限(到点自动收手,防止子智能体无限自转);0 = 不限。 */
|
|
19
19
|
maxTurns: number;
|
|
20
20
|
/** 这个角色想不想弹审批卡。 */
|
|
21
21
|
approval: TeammateApproval;
|
package/lib/core/agent-roles.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* tools: read, glob, grep # 工具白名单;写 none 表示一个工具都不给
|
|
13
13
|
* model: # 例 deepseek/deepseek-chat;留空 = 跟随当前模型
|
|
14
14
|
* effort: default # default|off|low|high|max
|
|
15
|
-
* max-turns: 12 #
|
|
15
|
+
* max-turns: 12 # 内部请求轮次上限,到点自动收手;不写或写 0 = 不限
|
|
16
16
|
* approval: forbid # forbid|ask|foreground:这个角色想不想弹审批卡
|
|
17
17
|
* enabled: true
|
|
18
18
|
* ---
|
|
@@ -41,7 +41,6 @@ const BUILTIN_FILES = {
|
|
|
41
41
|
name: explorer
|
|
42
42
|
description: 只读探索:读代码、找定义、把事实汇总回来
|
|
43
43
|
tools: read, glob, grep
|
|
44
|
-
max-turns: 12
|
|
45
44
|
approval: forbid
|
|
46
45
|
---
|
|
47
46
|
|
|
@@ -93,9 +92,9 @@ max-turns: 16
|
|
|
93
92
|
approval: forbid
|
|
94
93
|
---
|
|
95
94
|
|
|
96
|
-
|
|
95
|
+
你是团队里的代码审查员。审查范围(未提交改动 / 对比基准分支 / 某次提交 / 自定义要求)与完整 diff 的**落盘路径**都会写在任务书里;用 read 按 offset/limit 分批把整份 diff 读完,再用 read/glob/grep 打开相关文件核对上下文,然后交审查结论。
|
|
97
96
|
|
|
98
|
-
分级口径:P1 =
|
|
97
|
+
分级口径:P0 = 必须修(必然出错、安全漏洞、数据丢失);P1 = 正确性或安全问题;P2 = 边界、健壮性、性能问题,应该修;P3 = 可读性、风格、更好的写法,可以更好。
|
|
99
98
|
|
|
100
99
|
每条 finding 严格按这个格式交(渲染层按它解析成卡片,一个字段都不能少):
|
|
101
100
|
|
|
@@ -109,6 +108,7 @@ approval: forbid
|
|
|
109
108
|
2. 先说结论——每个问题都要落到改动本身,不评审 diff 之外的历史遗留。
|
|
110
109
|
3. 没有问题就只写一段话:明说没有发现问题,交代你查过的文件与维度。
|
|
111
110
|
4. 你只有读类工具;跑不了构建和测试,判断依据是代码与 diff 本身,不确定的点在说明里如实标注。
|
|
111
|
+
5. 最后单起一段给整体结论:「整体结论:可提交」或「整体结论:需修改后提交」。
|
|
112
112
|
`,
|
|
113
113
|
};
|
|
114
114
|
/** 出厂角色名(UI 上标「内置」,删除时给提示但不阻止)。 */
|
|
@@ -209,8 +209,9 @@ function parseRoleText(file, text) {
|
|
|
209
209
|
else
|
|
210
210
|
problem = problem ?? `effort 只能是 ${EFFORTS.join(' / ')},收到 ${rawEffort},本项退回跟随当前`;
|
|
211
211
|
}
|
|
212
|
+
// 不写或写 0 = 不限;写了就夹进 1..200,0 这个值专门留给「不限」
|
|
212
213
|
const rawTurns = Number.parseInt(String(doc['max-turns'] ?? doc.maxTurns ?? ''), 10);
|
|
213
|
-
const maxTurns = Number.isFinite(rawTurns) ? Math.min(Math.max(rawTurns,
|
|
214
|
+
const maxTurns = Number.isFinite(rawTurns) ? Math.min(Math.max(rawTurns, 0), 200) : 0;
|
|
214
215
|
const rawApproval = typeof doc.approval === 'string' ? doc.approval.trim() : '';
|
|
215
216
|
let approval = 'forbid';
|
|
216
217
|
if (rawApproval !== '') {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type PrefixRule } from './command-policy.js';
|
|
2
|
+
import type { ShellFlavor } from './terminal-env.js';
|
|
2
3
|
import type { ToolGuard } from './tool-guards.js';
|
|
3
4
|
/** 配置键:插件条目树里的 file,同时是设置分区 id。 */
|
|
4
5
|
export declare const FLOOR_CONFIG_KEY = "approval-floor";
|
|
@@ -152,6 +153,14 @@ export interface ApprovalFloorOptions {
|
|
|
152
153
|
rules: () => readonly PrefixRule[];
|
|
153
154
|
/** 当前时间(自检可以把时钟说快一点)。 */
|
|
154
155
|
now?: () => number;
|
|
156
|
+
/**
|
|
157
|
+
* 这台机器上实际执行命令的 shell 家族(2026-10-30 默认终端可切换之后由插件传入)。
|
|
158
|
+
*
|
|
159
|
+
* 为什么必须跟着走:结构扫描按 PowerShell / POSIX 两套引号与转义规则判闭合,
|
|
160
|
+
* 用户把默认终端切成 Git Bash 之后仍按 PowerShell 判,`\"` 这类写法会被误伤或漏判。
|
|
161
|
+
* 不给就按平台默认(Windows 认 PowerShell,其余认 POSIX)。
|
|
162
|
+
*/
|
|
163
|
+
shell?: () => ShellFlavor;
|
|
155
164
|
}
|
|
156
165
|
/** 灾难地板:一位守卫 + 它的熔断状态。 */
|
|
157
166
|
export interface ApprovalFloor {
|
|
@@ -261,22 +261,42 @@ function readBool(value, fallback, name, problems) {
|
|
|
261
261
|
}
|
|
262
262
|
/** 命令替换最多往下看几层;再深就按「看不清」拒。 */
|
|
263
263
|
const MAX_SUBSTITUTION_DEPTH = 6;
|
|
264
|
+
/**
|
|
265
|
+
* 这台机器上 bash 工具默认用的 shell 家族(调用方没传 `options.shell` 时的兜底)。
|
|
266
|
+
*
|
|
267
|
+
* 为什么结构扫描要分 shell(2026-10-30 报障):Windows 上 powershell.exe 是默认执行器,
|
|
268
|
+
* 它的转义符是反引号,不是反斜杠。把 POSIX 的「`\` 转义」套到 PowerShell 上,
|
|
269
|
+
* 一条 `Replace((Get-Location).Path + "\","")` 里的 `\"` 会把右引号当成转义吃掉,
|
|
270
|
+
* 于是整条合法命令被判「引号没闭合」——那次会话里 5 条被误伤的就是它。
|
|
271
|
+
*
|
|
272
|
+
* 2026-10-30 起默认终端可以在设置里改成 Git Bash / WSL:那种情况下实际执行器是 POSIX
|
|
273
|
+
* bash,扫描必须跟着换成 POSIX 规则(由 `plugins/approval-floor.ts` 经 `options.shell`
|
|
274
|
+
* 传入,见 `core/terminal-env.ts` 的 `shellFlavor`)。
|
|
275
|
+
*/
|
|
276
|
+
const DEFAULT_SHELL = process.platform === 'win32' ? 'powershell' : 'posix';
|
|
264
277
|
/**
|
|
265
278
|
* 扫一遍命令的结构:引号与括号闭合没有、命令替换里是什么。
|
|
266
279
|
*
|
|
267
280
|
* 这些构造只做「括号配对 + 摘出内层片段」,不做完整 shell 语法解析:
|
|
268
281
|
* 判不出来的地方一律让调用方按拒处理。
|
|
282
|
+
*
|
|
283
|
+
* 两种 shell 的差别只在两处:双引号里的转义符(POSIX `\` / PowerShell 反引号),
|
|
284
|
+
* 以及引号外的反引号是「命令替换」(POSIX)还是「转义 / 续行」(PowerShell)。
|
|
285
|
+
*
|
|
286
|
+
* @param command - 命令原文。
|
|
287
|
+
* @param shell - 这台机器上实际执行它的 shell;缺省按平台判。
|
|
269
288
|
*/
|
|
270
|
-
function inspectStructure(command) {
|
|
289
|
+
function inspectStructure(command, shell = DEFAULT_SHELL) {
|
|
271
290
|
const substitutions = [];
|
|
272
291
|
const stack = [];
|
|
273
292
|
let quote = null;
|
|
274
293
|
let tickStart = -1;
|
|
294
|
+
const powershell = shell === 'powershell';
|
|
275
295
|
for (let i = 0; i < command.length; i += 1) {
|
|
276
296
|
const ch = command[i];
|
|
277
297
|
if (quote !== null) {
|
|
278
|
-
//
|
|
279
|
-
if (quote !== "'" && ch === '\\' && i + 1 < command.length) {
|
|
298
|
+
// 单引号里的一切都是字面量;双引号里只有本 shell 的转义符能吃掉下一个字符。
|
|
299
|
+
if (quote !== "'" && ch === (powershell ? '`' : '\\') && i + 1 < command.length) {
|
|
280
300
|
i += 1;
|
|
281
301
|
continue;
|
|
282
302
|
}
|
|
@@ -289,6 +309,11 @@ function inspectStructure(command) {
|
|
|
289
309
|
}
|
|
290
310
|
continue;
|
|
291
311
|
}
|
|
312
|
+
// PowerShell 的引号外反引号是转义符(行尾则是续行),不是命令替换;只有 POSIX 才当引号。
|
|
313
|
+
if (ch === '`' && powershell) {
|
|
314
|
+
i += 1;
|
|
315
|
+
continue;
|
|
316
|
+
}
|
|
292
317
|
if (ch === '"' || ch === "'" || ch === '`') {
|
|
293
318
|
quote = ch;
|
|
294
319
|
if (ch === '`')
|
|
@@ -358,13 +383,37 @@ function effectiveHead(tokens) {
|
|
|
358
383
|
return null;
|
|
359
384
|
return { name: baseName(head), args: tokens.slice(index + 1) };
|
|
360
385
|
}
|
|
361
|
-
/**
|
|
362
|
-
|
|
386
|
+
/**
|
|
387
|
+
* 黑名单的候选串:从命令里挑出「可能指向一个文件」的词元,黑名单 glob 只拿它们去比。
|
|
388
|
+
*
|
|
389
|
+
* 为什么要挑:路径常常嵌在长串里(`-Path C:\a\b.key`、`--file=/etc/passwd`、`$f='x.key'`),
|
|
390
|
+
* 拿整条命令原文去比只能命中「整条命令恰好以 .key 结尾」这种极窄的情况;反过来,
|
|
391
|
+
* `$_.Key` 这种变量属性引用又会被 `*.key` 当成凭据文件——实测把一条读会话日志的命令整条拒掉。
|
|
392
|
+
*
|
|
393
|
+
* 两类片段不算路径:纯变量/属性引用(`$f`、`$_.Key`,判据是「含 $ 且没有路径分隔符」),
|
|
394
|
+
* 以及表达式片段(`($_`、`ConvertFrom-Json).Key`,判据是「含括号又不以盘符或斜杠开头」)。
|
|
395
|
+
* 带分隔符的变量引用(`$env:USERPROFILE\.ssh\id_rsa`)算路径,它确实指向文件。
|
|
396
|
+
*/
|
|
397
|
+
function pathCandidates(command) {
|
|
363
398
|
const out = [];
|
|
364
|
-
for (const segment of splitSegments(command))
|
|
365
|
-
|
|
399
|
+
for (const segment of splitSegments(command)) {
|
|
400
|
+
for (const token of segment.tokens) {
|
|
401
|
+
if (isPathCandidate(token))
|
|
402
|
+
out.push(token);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
366
405
|
return out;
|
|
367
406
|
}
|
|
407
|
+
/** 一个词元能不能当路径去比黑名单(判据见 {@link pathCandidates})。 */
|
|
408
|
+
function isPathCandidate(token) {
|
|
409
|
+
if (token === '')
|
|
410
|
+
return false;
|
|
411
|
+
if (token.includes('$') && !/[\\/]/.test(token))
|
|
412
|
+
return false;
|
|
413
|
+
if (/[()]/.test(token) && !/^(?:[A-Za-z]:[\\/]|[\\/]|\\\\)/.test(token))
|
|
414
|
+
return false;
|
|
415
|
+
return true;
|
|
416
|
+
}
|
|
368
417
|
/** 内置危险模式的全部命中(整条命令与每一段都看一遍;管道类模式要整条才认得出)。 */
|
|
369
418
|
function dangerHits(command) {
|
|
370
419
|
const hits = new Map();
|
|
@@ -450,14 +499,83 @@ function compiledGlob(glob) {
|
|
|
450
499
|
GLOB_CACHE.set(glob, re);
|
|
451
500
|
return re;
|
|
452
501
|
}
|
|
453
|
-
/**
|
|
454
|
-
|
|
502
|
+
/** `.env` 模板文件:只含键名与示例值,不是密钥本体(`.env.example` / `.env.sample` 这类)。 */
|
|
503
|
+
const ENV_TEMPLATE_RE = /(?:^|[\\/])\.env\.(?:example|sample|template|dist)(?:\.[^\\/]*)?$/i;
|
|
504
|
+
/**
|
|
505
|
+
* 只做「存在性探测」的命令头:它们回答「这个路径在不在」,不吐出文件内容。
|
|
506
|
+
*
|
|
507
|
+
* 为什么需要这份名单(0.7.2,2026-10-29 报障):deny 黑名单按「命令词元」匹配,
|
|
508
|
+
* `Test-Path .env` 的词元 `.env` 命中 `*.env`,于是连「这个文件存在吗」都答不了。
|
|
509
|
+
* 探测只泄漏一位信息,不泄漏内容,放行;真正读内容的命令(`type`、`Get-Content`)
|
|
510
|
+
* 不在名单里,照旧拒。
|
|
511
|
+
*/
|
|
512
|
+
const EXISTENCE_ONLY_HEADS = new Set([
|
|
513
|
+
'test-path',
|
|
514
|
+
'test',
|
|
515
|
+
'get-item',
|
|
516
|
+
'get-childitem',
|
|
517
|
+
'gci',
|
|
518
|
+
'ls',
|
|
519
|
+
'dir',
|
|
520
|
+
'stat',
|
|
521
|
+
'file',
|
|
522
|
+
'where',
|
|
523
|
+
'which',
|
|
524
|
+
'resolve-path',
|
|
525
|
+
]);
|
|
526
|
+
/** 这个路径是不是 `.env` 家族的模板(不是密钥本体)。 */
|
|
527
|
+
function isEnvTemplate(path) {
|
|
528
|
+
return ENV_TEMPLATE_RE.test(path);
|
|
529
|
+
}
|
|
530
|
+
/** 这个路径是不是 `.env` 家族(含模板)。存在性探测的放行只对这一族生效。 */
|
|
531
|
+
function isEnvPath(path) {
|
|
532
|
+
const base = path.split(/[\\/]/).pop() ?? '';
|
|
533
|
+
return base === '.env' || base.startsWith('.env.');
|
|
534
|
+
}
|
|
535
|
+
/** 整条命令是不是只做存在性探测:单段、无重定向、无命令替换、头在名单里。 */
|
|
536
|
+
function existenceOnlyProbe(command) {
|
|
537
|
+
const segments = splitSegments(command);
|
|
538
|
+
if (segments.length !== 1)
|
|
539
|
+
return false;
|
|
540
|
+
const segment = segments[0];
|
|
541
|
+
if (segment === undefined || segment.redirect || segment.subst)
|
|
542
|
+
return false;
|
|
543
|
+
const head = (segment.tokens[0] ?? '').toLowerCase().replace(/\.exe$/, '');
|
|
544
|
+
return EXISTENCE_ONLY_HEADS.has(head);
|
|
545
|
+
}
|
|
546
|
+
/** 内置那两条 `.env` 规则:模板与存在性探测的例外只对它们生效,用户自加的规则不受影响。 */
|
|
547
|
+
function isEnvGlob(glob) {
|
|
548
|
+
return glob === '*.env' || glob === '*.env.*';
|
|
549
|
+
}
|
|
550
|
+
/**
|
|
551
|
+
* 这些文本里有没有命中黑名单;命中返回那条 glob 与命中的原文(说给模型听)。
|
|
552
|
+
*
|
|
553
|
+
* 两条例外(2026-10-30):
|
|
554
|
+
* - `.env` 模板(`.env.example` 这类)不是密钥,读写都放行——否则项目模板只能改名;
|
|
555
|
+
* - 纯存在性探测(`Test-Path .env`)只泄漏「在不在」一位信息,放行。这条只对 `.env`
|
|
556
|
+
* 一族生效:`Test-Path id_rsa` 这类仍按黑名单拒,不扩大口子。
|
|
557
|
+
*
|
|
558
|
+
* 例外只挂在 `.env` 那两条内置规则上:用户自己在黑名单里加 `.env.example` 是要拦它,
|
|
559
|
+
* 不能被这里顺手放掉。
|
|
560
|
+
*/
|
|
561
|
+
function denyHit(texts, globs, allowEnvProbe) {
|
|
455
562
|
for (const glob of globs) {
|
|
456
563
|
const re = compiledGlob(glob);
|
|
457
564
|
if (re === null)
|
|
458
565
|
continue;
|
|
459
|
-
|
|
460
|
-
|
|
566
|
+
const envGlob = isEnvGlob(glob);
|
|
567
|
+
for (const text of texts) {
|
|
568
|
+
// 分隔符归一:默认规则写成 POSIX 的 *.ssh/*,而 Windows 命令里通常是
|
|
569
|
+
// C:\Users\me\.ssh\config。只按原文比,反斜杠路径永远匹配不到默认黑名单。
|
|
570
|
+
// 两种写法都比一次,用户按反斜杠写的自定义规则也照旧生效。
|
|
571
|
+
if (!re.test(text) && !re.test(text.replace(/\\/g, '/')))
|
|
572
|
+
continue;
|
|
573
|
+
if (envGlob && isEnvTemplate(text))
|
|
574
|
+
continue;
|
|
575
|
+
if (envGlob && allowEnvProbe && isEnvPath(text))
|
|
576
|
+
continue;
|
|
577
|
+
return { glob, text };
|
|
578
|
+
}
|
|
461
579
|
}
|
|
462
580
|
return null;
|
|
463
581
|
}
|
|
@@ -488,7 +606,7 @@ function whitelistHit(command, config) {
|
|
|
488
606
|
return null;
|
|
489
607
|
}
|
|
490
608
|
/** 逐层判定一次调用。每一层的理由写在分支旁边。 */
|
|
491
|
-
function evaluate(input, config, rules) {
|
|
609
|
+
function evaluate(input, config, rules, shell = DEFAULT_SHELL) {
|
|
492
610
|
const command = input.command?.trim() ?? '';
|
|
493
611
|
const target = input.target;
|
|
494
612
|
// 只读工具不归地板管:读文件越界由路径护栏负责,地板只关心「跑什么」与「写哪里」。
|
|
@@ -497,9 +615,9 @@ function evaluate(input, config, rules) {
|
|
|
497
615
|
if (command === '') {
|
|
498
616
|
if (target === undefined)
|
|
499
617
|
return { action: 'defer', layer: 'none', reason: '既没有命令也没有写目标,交给后面的守卫' };
|
|
500
|
-
const hit =
|
|
618
|
+
const hit = denyHit([target], config.denyGlobs, false);
|
|
501
619
|
if (hit !== null)
|
|
502
|
-
return { action: 'deny', layer: 'deny-list', reason: `写目标命中用户 deny 黑名单(${hit})` };
|
|
620
|
+
return { action: 'deny', layer: 'deny-list', reason: `写目标命中用户 deny 黑名单(${hit.glob})` };
|
|
503
621
|
if (config.unattended && !isInsideCwd(input.cwd, target)) {
|
|
504
622
|
return { action: 'deny', layer: 'unattended', reason: `无人值守场景只放行工作区内的写入,这次是 ${target}` };
|
|
505
623
|
}
|
|
@@ -509,7 +627,7 @@ function evaluate(input, config, rules) {
|
|
|
509
627
|
if (command.length > config.maxCommandLength) {
|
|
510
628
|
return { action: 'deny', layer: 'opaque', reason: `命令有 ${command.length} 个字符,超过上限 ${config.maxCommandLength},看不清要跑什么` };
|
|
511
629
|
}
|
|
512
|
-
const structure = inspectStructure(command);
|
|
630
|
+
const structure = inspectStructure(command, shell);
|
|
513
631
|
if (structure.fatal !== null)
|
|
514
632
|
return { action: 'deny', layer: 'opaque', reason: structure.fatal };
|
|
515
633
|
const opaque = opaqueShellReason(command);
|
|
@@ -525,19 +643,28 @@ function evaluate(input, config, rules) {
|
|
|
525
643
|
return { action: 'deny', layer: 'disaster', reason: `${doom}(任何权限模式都不放行)` };
|
|
526
644
|
// 命令替换与反引号里的片段递归再判一次:`echo $(rm -rf /)` 外层看不出灾难,内层看得出。
|
|
527
645
|
for (const fragment of structure.substitutions) {
|
|
528
|
-
const inner = innerDenyReason(fragment, config, rules, 1);
|
|
646
|
+
const inner = innerDenyReason(fragment, config, rules, 1, shell);
|
|
529
647
|
if (inner !== null)
|
|
530
648
|
return { action: 'deny', layer: 'disaster', reason: `命令替换里的片段被判为灾难性动作:${inner}` };
|
|
531
649
|
}
|
|
532
650
|
// 内层干净也不放行:外层的实际效果是两段拼出来的,静态判不出,只能拒(fail-closed)。
|
|
651
|
+
// 为什么不改成「问用户」:`Get-Content $(echo .env)` 这种两半都只读的组合能把路径藏进
|
|
652
|
+
// 替换里,绕过 deny 黑名单;交给审批卡时「完全访问」档会直接放行(plugins/approval.ts:334-337)。
|
|
653
|
+
// 所以这里保持拒绝,但把**怎么改**写进理由,别让人只能自己猜(2026-10-30)。
|
|
533
654
|
if (structure.substitutions.length > 0) {
|
|
534
|
-
return {
|
|
655
|
+
return {
|
|
656
|
+
action: 'deny',
|
|
657
|
+
layer: 'opaque',
|
|
658
|
+
reason: '命令里有 $(...) 或反引号(命令替换),里外两层拼起来的实际效果判不出来。' +
|
|
659
|
+
'改成两步:先把替换的内容赋给变量或单独跑一条命令,再用结果跑第二条。',
|
|
660
|
+
};
|
|
535
661
|
}
|
|
536
662
|
// 第 3 层:用户 deny 黑名单与 deny 前缀规则。排在权限模式与审批之前,
|
|
537
663
|
// 「完全访问」因此在审批层放行不了它(`plugins/approval.ts:334-337` 那条路径直接被抄掉)。
|
|
538
|
-
|
|
664
|
+
// 纯存在性探测(`Test-Path .env`)只回答「在不在」,不放进内容读取那一档(0.7.2)。
|
|
665
|
+
const hit = denyHit(pathCandidates(command), config.denyGlobs, existenceOnlyProbe(command));
|
|
539
666
|
if (hit !== null)
|
|
540
|
-
return { action: 'deny', layer: 'deny-list', reason: `命令命中用户 deny 黑名单(${hit})` };
|
|
667
|
+
return { action: 'deny', layer: 'deny-list', reason: `命令命中用户 deny 黑名单(${hit.glob})` };
|
|
541
668
|
if (verdict.matchedRule !== null && verdict.matchedRule.decision === 'deny') {
|
|
542
669
|
return {
|
|
543
670
|
action: 'deny',
|
|
@@ -566,7 +693,7 @@ function evaluate(input, config, rules) {
|
|
|
566
693
|
return { action: 'defer', layer: 'none', reason: '地板没意见,交给后面的守卫' };
|
|
567
694
|
}
|
|
568
695
|
/** 命令替换片段里的灾难性判定:只看「判不了」与「灾难」两类,理由里不带前缀。 */
|
|
569
|
-
function innerDenyReason(command, config, rules, depth) {
|
|
696
|
+
function innerDenyReason(command, config, rules, depth, shell = DEFAULT_SHELL) {
|
|
570
697
|
const text = command.trim();
|
|
571
698
|
if (text === '')
|
|
572
699
|
return null;
|
|
@@ -574,7 +701,7 @@ function innerDenyReason(command, config, rules, depth) {
|
|
|
574
701
|
return `命令替换嵌套超过 ${MAX_SUBSTITUTION_DEPTH} 层`;
|
|
575
702
|
if (text.length > config.maxCommandLength)
|
|
576
703
|
return `命令替换里的片段太长(${text.length} 个字符)`;
|
|
577
|
-
const structure = inspectStructure(text);
|
|
704
|
+
const structure = inspectStructure(text, shell);
|
|
578
705
|
if (structure.fatal !== null)
|
|
579
706
|
return structure.fatal;
|
|
580
707
|
const opaque = opaqueShellReason(text);
|
|
@@ -587,15 +714,15 @@ function innerDenyReason(command, config, rules, depth) {
|
|
|
587
714
|
if (doom !== null)
|
|
588
715
|
return doom;
|
|
589
716
|
for (const fragment of structure.substitutions) {
|
|
590
|
-
const inner = innerDenyReason(fragment, config, rules, depth + 1);
|
|
717
|
+
const inner = innerDenyReason(fragment, config, rules, depth + 1, shell);
|
|
591
718
|
if (inner !== null)
|
|
592
719
|
return inner;
|
|
593
720
|
}
|
|
594
721
|
if (structure.substitutions.length > 0)
|
|
595
722
|
return '片段里还套着命令替换,拼不出实际效果';
|
|
596
|
-
const hit =
|
|
723
|
+
const hit = denyHit(pathCandidates(text), config.denyGlobs, false);
|
|
597
724
|
if (hit !== null)
|
|
598
|
-
return `命中用户 deny 黑名单(${hit})`;
|
|
725
|
+
return `命中用户 deny 黑名单(${hit.glob})`;
|
|
599
726
|
if (verdict.matchedRule !== null && verdict.matchedRule.decision === 'deny') {
|
|
600
727
|
return `用户规则禁止:${verdict.matchedRule.justification ?? verdict.matchedRule.pattern.join(' ')}`;
|
|
601
728
|
}
|
|
@@ -664,7 +791,7 @@ export function createApprovalFloor(options) {
|
|
|
664
791
|
// 熔断期间的拒不再计数:否则模型每重试一次就续一次冷却,永远恢复不了。
|
|
665
792
|
false);
|
|
666
793
|
}
|
|
667
|
-
return settle(evaluate(input, config, options.rules()), input, config, true);
|
|
794
|
+
return settle(evaluate(input, config, options.rules(), options.shell?.() ?? DEFAULT_SHELL), input, config, true);
|
|
668
795
|
},
|
|
669
796
|
};
|
|
670
797
|
return {
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 附件仓库:把用户贴进来的图片、视频与其它文件存成本机对象,消息里只留引用。
|
|
3
|
+
*
|
|
4
|
+
* ## 为什么不再往消息里塞 base64
|
|
5
|
+
*
|
|
6
|
+
* 原来界面把图片压成 data URL,经 `/api/invoke` 的 64KB 请求体塞进 `submit` 的第二参
|
|
7
|
+
* (`core/web-http.ts` 的 `MAX_BODY_BYTES`),所以单图只能有 32KB——普通截图压到那个
|
|
8
|
+
* 档位已经看不清了(这正是「贴图这一版还不支持」的根因)。会话 jsonl 也把 base64 原样
|
|
9
|
+
* 写进去,一个会话文件会膨胀到几十 MB。
|
|
10
|
+
*
|
|
11
|
+
* 现在照 dsh `dsh-attachment-local` 的做法拆成两步:
|
|
12
|
+
*
|
|
13
|
+
* 1. 字节先经 `POST /api/attachments` 落到这里,内容寻址(sha256),同字节只存一份;
|
|
14
|
+
* 2. 消息里带引用 `/api/attachments/<sha>`,**组装模型请求时**再读成 data URL。
|
|
15
|
+
*
|
|
16
|
+
* 于是请求体只装几个短引用,会话日志也只记引用;界面 `<img>` / `<video>` 直接吃同源
|
|
17
|
+
* 路由,不必再传 base64。
|
|
18
|
+
*
|
|
19
|
+
* ## 与 dsh 的口径对齐与差异
|
|
20
|
+
*
|
|
21
|
+
* 对齐:目录形状 `<DSC_HOME>/attachments/v1/objects/<sha 前 2 位>/<sha>`、内容寻址去重、
|
|
22
|
+
* 只收 PNG / JPEG / WebP / GIF 四类图片、非图片文件按字节原样存、单图 20MiB。
|
|
23
|
+
*
|
|
24
|
+
* 差异:dsh 在服务端用 sharp 做像素级规范化(EXIF、色彩空间、长边、质量阶梯)。本仓库
|
|
25
|
+
* 没有原生图像依赖,**规范化放在界面层**(`ui-shell/src/plugins/composer/attachments.ts`
|
|
26
|
+
* 用 canvas 做同样的事),落到这里的已经是 8-bit sRGB 光栅。所以这里的校验只看字节与
|
|
27
|
+
* 魔数:信不信扩展名/`Content-Type` 一律不信。
|
|
28
|
+
*
|
|
29
|
+
* ## 安全边界
|
|
30
|
+
*
|
|
31
|
+
* - sha 只认 64 位小写十六进制,路径拼接不接用户输入;
|
|
32
|
+
* - 文件名只用于展示,落盘名永远是 sha;
|
|
33
|
+
* - 单文件上限按类别分开(图片 20MiB、视频与其它文件 200MiB),上限在**写入过程中**
|
|
34
|
+
* 就生效,不会先写满盘再判;
|
|
35
|
+
* - 读取前校验对象仍是普通文件,长度与摘要由调用方(会话投影)自行决定要不要复核。
|
|
36
|
+
*
|
|
37
|
+
* @module dsc/core/attachments
|
|
38
|
+
*/
|
|
39
|
+
import type { IncomingMessage } from 'node:http';
|
|
40
|
+
/** 单张图片上限(与 dsh `maxImageBytes` 的默认值一致)。 */
|
|
41
|
+
export declare const MAX_IMAGE_BYTES: number;
|
|
42
|
+
/** 单个视频 / 其它文件上限。比 dsh 的「通用文件不设限」保守,理由是本机磁盘不是仓库。 */
|
|
43
|
+
export declare const MAX_MEDIA_BYTES: number;
|
|
44
|
+
/** 一条消息最多带多少张图片(dsh 默认 20;这里按请求体与上下文成本收到 20)。 */
|
|
45
|
+
export declare const MAX_IMAGES_PER_MESSAGE = 20;
|
|
46
|
+
/** 附件类别:图片进模型请求的 image 块,视频与文件以「路径 + 元数据」交给模型。 */
|
|
47
|
+
export type AttachmentKind = 'image' | 'video' | 'file';
|
|
48
|
+
/** 一次落盘的结果:会话与界面只认这份元数据。 */
|
|
49
|
+
export interface AttachmentMeta {
|
|
50
|
+
/** sha256 十六进制(64 位小写)。 */
|
|
51
|
+
sha: string;
|
|
52
|
+
kind: AttachmentKind;
|
|
53
|
+
/** 用户看到的原始文件名(已安全化,仅用于展示)。 */
|
|
54
|
+
name: string;
|
|
55
|
+
/** 实际类型(按魔数判定,不信扩展名)。 */
|
|
56
|
+
mime: string;
|
|
57
|
+
/** 字节数。 */
|
|
58
|
+
bytes: number;
|
|
59
|
+
/** 同源读取地址(可直接塞进 `<img src>` / `<video src>`)。 */
|
|
60
|
+
url: string;
|
|
61
|
+
/** 本机绝对路径:交给模型用工具读,或给桌面端做原生播放。 */
|
|
62
|
+
path: string;
|
|
63
|
+
}
|
|
64
|
+
/** 会话与界面之间传的文件引用(视频 / 通用文件,图片走 `images` 那一列)。 */
|
|
65
|
+
export interface UserFileAttachment {
|
|
66
|
+
sha: string;
|
|
67
|
+
kind: 'video' | 'file';
|
|
68
|
+
name: string;
|
|
69
|
+
mime: string;
|
|
70
|
+
bytes: number;
|
|
71
|
+
path: string;
|
|
72
|
+
url?: string;
|
|
73
|
+
/**
|
|
74
|
+
* 视频抽出来的关键帧(已上传成图片附件的引用)。
|
|
75
|
+
*
|
|
76
|
+
* 与 `url` 一样只给请求投影用:模型看到这些图,界面只画一张视频卡——帧是「怎么让模型
|
|
77
|
+
* 看见视频」的手段,不是用户要多看六张图。日志里存引用,重放时照样能还原。
|
|
78
|
+
*/
|
|
79
|
+
frames?: string[];
|
|
80
|
+
}
|
|
81
|
+
/** 落盘失败(上限 / 空文件 / 写盘错误)。 */
|
|
82
|
+
export declare class AttachmentError extends Error {
|
|
83
|
+
constructor(message: string);
|
|
84
|
+
}
|
|
85
|
+
/** 文件头魔数 sniff 的结果。 */
|
|
86
|
+
export interface SniffedMedia {
|
|
87
|
+
kind: AttachmentKind;
|
|
88
|
+
mime: string;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* 按文件头认类型。
|
|
92
|
+
*
|
|
93
|
+
* 只认常见、能给模型或播放器直接用的格式;认不出的按 `file` 原样存(模型拿路径自己看)。
|
|
94
|
+
* 图片四类与 dsh 一致:PNG / JPEG / WebP / GIF。
|
|
95
|
+
*/
|
|
96
|
+
export declare function sniffMedia(head: Buffer): SniffedMedia;
|
|
97
|
+
/** 按魔数结果判断一个对象是不是可渲染图片。 */
|
|
98
|
+
export declare function isImageMime(mime: string): boolean;
|
|
99
|
+
/** 类别对应的单文件上限。 */
|
|
100
|
+
export declare function limitFor(kind: AttachmentKind): number;
|
|
101
|
+
/** 把原始文件名洗成可展示的一段(只展示,不参与落盘路径)。 */
|
|
102
|
+
export declare function displayName(raw: string): string;
|
|
103
|
+
/** 附件在界面通道里的读取地址。 */
|
|
104
|
+
export declare function attachmentUrl(sha: string, name?: string): string;
|
|
105
|
+
/** 从任意字符串里认出附件引用;不是引用就回 null。 */
|
|
106
|
+
export declare function parseAttachmentUrl(value: string): string | null;
|
|
107
|
+
/** 造仓库时要给的东西(自检换成临时目录)。 */
|
|
108
|
+
export interface AttachmentStoreOptions {
|
|
109
|
+
/** 根目录,缺省 `<DSC_HOME>/attachments/v1`。 */
|
|
110
|
+
root?: string;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* 内容寻址附件仓库。
|
|
114
|
+
*
|
|
115
|
+
* 目录形状:`<root>/objects/<sha 前两位>/<sha>`,临时文件在 `<root>/tmp/`。
|
|
116
|
+
* 同一个字节序列落两次是同一个对象(第二次直接复用,不重写)。
|
|
117
|
+
*/
|
|
118
|
+
export declare class AttachmentStore {
|
|
119
|
+
private readonly root;
|
|
120
|
+
constructor(options?: AttachmentStoreOptions);
|
|
121
|
+
/** 仓库根目录。 */
|
|
122
|
+
get dir(): string;
|
|
123
|
+
/** 对象的绝对路径(只接受合法 sha,别的一律抛)。 */
|
|
124
|
+
pathOf(sha: string): string;
|
|
125
|
+
/** 对象是否已经在仓库里。 */
|
|
126
|
+
has(sha: string): boolean;
|
|
127
|
+
/** 落盘一段已知字节(浏览器上传的小文件、自检都走这条)。 */
|
|
128
|
+
save(name: string, bytes: Buffer): AttachmentMeta;
|
|
129
|
+
/**
|
|
130
|
+
* 把一条 HTTP 请求体流式落盘。
|
|
131
|
+
*
|
|
132
|
+
* 为什么要流式:视频动辄几十 MB,先 `readBodyBytes` 攒进内存会顶出一整份缓冲。
|
|
133
|
+
* 边写边算 sha,超限时立刻停写并删临时文件,客户端拿到 413。
|
|
134
|
+
*/
|
|
135
|
+
saveStream(req: IncomingMessage, name: string): Promise<AttachmentMeta>;
|
|
136
|
+
/** 读整段字节(组装模型请求时用;只给图片,视频不走这条)。 */
|
|
137
|
+
read(sha: string): Buffer;
|
|
138
|
+
/** 对象的字节数与修改时间;对象不存在时回 null。 */
|
|
139
|
+
stat(sha: string): {
|
|
140
|
+
size: number;
|
|
141
|
+
mtimeMs: number;
|
|
142
|
+
} | null;
|
|
143
|
+
/** 给 HTTP 路由用的类型判定:只读文件头。 */
|
|
144
|
+
mimeOf(sha: string): Promise<{
|
|
145
|
+
mime: string;
|
|
146
|
+
size: number;
|
|
147
|
+
} | null>;
|
|
148
|
+
/** 元数据组装(路径与 url 一处生成,避免两边漂移)。 */
|
|
149
|
+
private meta;
|
|
150
|
+
/** 把临时文件发布成正式对象:临时文件与目标同盘,改名是原子的。 */
|
|
151
|
+
private publish;
|
|
152
|
+
}
|
|
153
|
+
/** 取(首次创建)默认仓库。 */
|
|
154
|
+
export declare function attachmentStore(): AttachmentStore;
|
|
155
|
+
/** 自检替换默认仓库(只给测试脚本用)。 */
|
|
156
|
+
export declare function setAttachmentStoreForTest(store: AttachmentStore | null): void;
|
|
157
|
+
/**
|
|
158
|
+
* 把一条图片引用读成 data URL(组装模型请求时用)。
|
|
159
|
+
*
|
|
160
|
+
* - `data:` 开头的老写法原样返回(老会话兼容);
|
|
161
|
+
* - `/api/attachments/<sha>` 读成 base64;文件不在了就抛错,让这一轮明确失败,
|
|
162
|
+
* 而不是把一条坏链接发给端点;
|
|
163
|
+
* - 其它字符串(远端 http 图)原样返回。
|
|
164
|
+
*/
|
|
165
|
+
export declare function resolveImageForRequest(url: string): string;
|
|
166
|
+
/**
|
|
167
|
+
* 文件类附件给模型看的那一段文字。
|
|
168
|
+
*
|
|
169
|
+
* 形状照 dsh 的文件句柄:一行说清「是什么、多大、摘要前缀、在哪」。模型拿到路径后
|
|
170
|
+
* 用文件工具自己读(视频自己没有解码能力的端点也读不懂,所以这里不承诺「能看画面」)。
|
|
171
|
+
*/
|
|
172
|
+
export declare function fileHandleText(files: readonly UserFileAttachment[]): string;
|
|
173
|
+
/** 按扩展名给一个「像不像图片」的提示(只用于界面提前选路,不参与安全判断)。 */
|
|
174
|
+
export declare function looksLikeImage(name: string): boolean;
|
|
175
|
+
/** 按扩展名给一个「像不像视频」的提示(同上)。 */
|
|
176
|
+
export declare function looksLikeVideo(name: string): boolean;
|
|
177
|
+
/**
|
|
178
|
+
* 校验并洗白「页面传来的文件引用」。
|
|
179
|
+
*
|
|
180
|
+
* 为什么必须在入口洗:界面通道的实参来自网络,页面(含第三方插件)可以编任意
|
|
181
|
+
* `path`——把 `C:\Users\…\credentials.yaml` 塞进来,宿主就会把那条路径写进模型
|
|
182
|
+
* 看得到的句柄里,等于把「模型可读范围」交给页面决定。所以路径一律不信:只认
|
|
183
|
+
* 仓库按 sha 算出来的那一条;其它字段只做类型与长度收口。
|
|
184
|
+
*/
|
|
185
|
+
export declare function sanitizeFileRefs(value: unknown): UserFileAttachment[];
|