@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
|
@@ -96,8 +96,9 @@ export declare function matchesToolGlob(pattern: string, name: string): boolean;
|
|
|
96
96
|
/**
|
|
97
97
|
* 这条工具允许被撤下吗。
|
|
98
98
|
*
|
|
99
|
-
* read
|
|
100
|
-
*
|
|
99
|
+
* read 风险一律不许:撤下之后模型每次读都得先 `tool_search` 再 `tool_call`,多两次往返,
|
|
100
|
+
* 省下的那点 schema 不值这个来回。(2026-10-30 改口径:桥现在按真名过守卫链,撤只读工具
|
|
101
|
+
* 不会再变成「每次只读都弹卡」,但「多两步」这条理由照样成立。)
|
|
101
102
|
*
|
|
102
103
|
* @param tool - 工具的名字与风险等级。
|
|
103
104
|
* @param config - 当前配置。
|
package/lib/core/tool-search.js
CHANGED
|
@@ -119,8 +119,9 @@ export function matchesToolGlob(pattern, name) {
|
|
|
119
119
|
/**
|
|
120
120
|
* 这条工具允许被撤下吗。
|
|
121
121
|
*
|
|
122
|
-
* read
|
|
123
|
-
*
|
|
122
|
+
* read 风险一律不许:撤下之后模型每次读都得先 `tool_search` 再 `tool_call`,多两次往返,
|
|
123
|
+
* 省下的那点 schema 不值这个来回。(2026-10-30 改口径:桥现在按真名过守卫链,撤只读工具
|
|
124
|
+
* 不会再变成「每次只读都弹卡」,但「多两步」这条理由照样成立。)
|
|
124
125
|
*
|
|
125
126
|
* @param tool - 工具的名字与风险等级。
|
|
126
127
|
* @param config - 当前配置。
|
package/lib/core/tools/bash.d.ts
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import { type ChildProcess } from 'node:child_process';
|
|
13
13
|
import type { ToolEntry } from '../tools.js';
|
|
14
|
+
import { type ShellChoice } from '../terminal-env.js';
|
|
14
15
|
import { type SpawnPlan } from './command-runner.js';
|
|
15
16
|
/** bash 工具的可调预算:全都是部署差异的选择,经 tools-default 插件配置下发。 */
|
|
16
17
|
export interface BashBudgets {
|
|
@@ -62,6 +63,37 @@ export interface ShellRunOptions {
|
|
|
62
63
|
* 不接取消信号,靠 onChunk 收增量、onExit 收退出码、trackKey 进登记表。
|
|
63
64
|
*/
|
|
64
65
|
export declare function spawnShell(plan: SpawnPlan, timeoutMs: number, outputLimit: number, signal: AbortSignal, options?: ShellRunOptions): Promise<string>;
|
|
66
|
+
/**
|
|
67
|
+
* 超预算时的截断:留头 60% + 尾 40%,中间写明省了多少字符。
|
|
68
|
+
*
|
|
69
|
+
* 只留头会把「真正的失败原因」丢掉——编译错误、测试断言、退出前的报错几乎都在
|
|
70
|
+
* 输出末尾,前面几千字往往只是进度与告警(0.7.x 实况:一条 30 秒超时的构建,
|
|
71
|
+
* 模型只看到最早那批编译中提示,看不到最后那句 syntax error)。
|
|
72
|
+
*
|
|
73
|
+
* spill 插件在 4000 字符就先接手落盘,走到这里的通常是它没接住的那部分(插件没挂、
|
|
74
|
+
* 阈值被调高、后台作业)。bash 这一层自己不落盘,所以标记里只说清省略了多少字符、
|
|
75
|
+
* 以及怎么看全(缩小命令范围分段重跑),不编一个并不存在的落盘路径。
|
|
76
|
+
*/
|
|
77
|
+
export declare function truncateBashOutput(output: string, outputLimit: number): string;
|
|
78
|
+
/**
|
|
79
|
+
* 把「用户选的终端」折成一次 spawn 的 file + args(2026-10-30 起的默认终端设置)。
|
|
80
|
+
*
|
|
81
|
+
* 四档的差别只在三处:可执行文件、怎么把命令交给它、以及命令里能写什么语法。
|
|
82
|
+
* 其余(环境脱敏、超时、输出封顶、遮红、spill)四条路完全一致。
|
|
83
|
+
*
|
|
84
|
+
* - PowerShell 家族(powershell / pwsh):`-NoProfile -Command`,前面钉 UTF-8 输出编码,
|
|
85
|
+
* 末尾补 exit 把最后一条原生命令的退出码带出来(`-Command` 自己只回 0/1)。
|
|
86
|
+
* - Git Bash:`--noprofile --norc -c`——不读 profile,起得快也不会被用户的 rc 脚本改动行为。
|
|
87
|
+
* - WSL:`--cd <Windows 路径>` 让命令落在对应工作区(WSL 会把盘符翻成 `/mnt/x`),
|
|
88
|
+
* 再交给发行版里的 `bash -lc`;`-l` 是为了让 PATH 带上发行版里配好的工具链。
|
|
89
|
+
* - sh:POSIX 上的出厂值,行为与以前一模一样。
|
|
90
|
+
*
|
|
91
|
+
* @param choice - 设置里的默认终端
|
|
92
|
+
* @param command - 模型给的命令原文
|
|
93
|
+
* @param cwd - 工作目录(WSL 要用它做 `--cd`)
|
|
94
|
+
* @param env - 已脱敏的子进程环境
|
|
95
|
+
*/
|
|
96
|
+
export declare function shellPlan(choice: ShellChoice, command: string, cwd: string, env: NodeJS.ProcessEnv): SpawnPlan;
|
|
65
97
|
/**
|
|
66
98
|
* T15:后台跑一条命令。与 {@link runShell} 同一套执行计划缝、环境脱敏与登记表,
|
|
67
99
|
* 不占回合、不挂有效超时;增量输出与退出码经回调交回作业表,spawn 失败经 onError。
|
|
@@ -70,9 +102,9 @@ export declare function runShellBackground(command: string, cwd: string, outputL
|
|
|
70
102
|
trackKey: string;
|
|
71
103
|
}): void;
|
|
72
104
|
/**
|
|
73
|
-
* T20:起一个长命交互 shell
|
|
74
|
-
*
|
|
75
|
-
*
|
|
105
|
+
* T20:起一个长命交互 shell(终端会话的进程原语)。可执行文件取自设置里的默认终端,
|
|
106
|
+
* 参数都是固定字面量,不拼任何外部输入;环境与前台命令同一份脱敏。
|
|
107
|
+
* 没有 tty(管道模式)——全屏程序跑不了,这是终端降级版的已知边界。进程原语不出本文件。
|
|
76
108
|
*/
|
|
77
109
|
export declare function spawnTerminalShell(cwd: string): ChildProcess;
|
|
78
110
|
/**
|
package/lib/core/tools/bash.js
CHANGED
|
@@ -13,6 +13,7 @@ import { spawn } from 'node:child_process';
|
|
|
13
13
|
import { classifyCommand } from '../command-policy.js';
|
|
14
14
|
import { redact, scrubChildEnv } from '../secrets.js';
|
|
15
15
|
import { wrapUntrusted } from '../untrusted.js';
|
|
16
|
+
import { readShellChoice, resolveShellExecutable, wslDistroName } from '../terminal-env.js';
|
|
16
17
|
import { finishCommand, planCommand } from './command-runner.js';
|
|
17
18
|
import { sandboxPermissionProperties } from './sandbox-args.js';
|
|
18
19
|
const isWin = process.platform === 'win32';
|
|
@@ -131,12 +132,21 @@ export function spawnShell(plan, timeoutMs, outputLimit, signal, options) {
|
|
|
131
132
|
if (options?.trackKey !== undefined)
|
|
132
133
|
backgroundChildren.delete(options.trackKey);
|
|
133
134
|
};
|
|
134
|
-
|
|
135
|
+
// 输出按字节收,退出时再决定用哪种编码解(见 decodeShellOutput):
|
|
136
|
+
// 中文 Windows 上 PowerShell 的默认控制台编码是 GBK,按 UTF-8 硬解就是一屏乱码。
|
|
137
|
+
const chunks = [];
|
|
138
|
+
let bytes = 0;
|
|
139
|
+
/** 后台作业的增量预览:流式解 UTF-8,跨块的多字节字符不会被切成半个。 */
|
|
140
|
+
const chunkDecoder = new TextDecoder('utf-8');
|
|
135
141
|
const append = (chunk) => {
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
142
|
+
const buf = typeof chunk === 'string' ? Buffer.from(chunk, 'utf8') : chunk;
|
|
143
|
+
// 按字节封顶(UTF-8 中文 3 字节/字、GBK 2 字节/字,4 倍字符上限足够留出截断余量)
|
|
144
|
+
if (bytes < outputLimit * 4) {
|
|
145
|
+
chunks.push(buf);
|
|
146
|
+
bytes += buf.length;
|
|
147
|
+
}
|
|
148
|
+
if (options?.onChunk !== undefined)
|
|
149
|
+
options.onChunk(chunkDecoder.decode(buf, { stream: true }));
|
|
140
150
|
};
|
|
141
151
|
child.stdout?.on('data', append);
|
|
142
152
|
child.stderr?.on('data', append);
|
|
@@ -159,7 +169,7 @@ export function spawnShell(plan, timeoutMs, outputLimit, signal, options) {
|
|
|
159
169
|
signal.removeEventListener('abort', onAbort);
|
|
160
170
|
untrack();
|
|
161
171
|
options?.onExit?.(code);
|
|
162
|
-
const truncated =
|
|
172
|
+
const truncated = truncateBashOutput(decodeShellOutput(Buffer.concat(chunks)), outputLimit);
|
|
163
173
|
const body = truncated.trim();
|
|
164
174
|
const lines = [];
|
|
165
175
|
if (reason !== null)
|
|
@@ -181,7 +191,11 @@ export function spawnShell(plan, timeoutMs, outputLimit, signal, options) {
|
|
|
181
191
|
}, KILL_GRACE_MS);
|
|
182
192
|
grace.unref();
|
|
183
193
|
};
|
|
184
|
-
|
|
194
|
+
// 文案改「已请求终止」而不是「已终止进程」(2026-10-30):arm 只是开始收进程树,
|
|
195
|
+
// 真正的退出还要等宽限期;原文案让模型以为活已经死了、于是重复跑一遍。
|
|
196
|
+
// 后半句给它下一步:这类长命令要么显式加大 timeoutMs,要么转后台再去取结果。
|
|
197
|
+
const timer = setTimeout(() => arm(`命令超时(${String(timeoutMs)}ms),已请求终止(还没退干净会强杀)` +
|
|
198
|
+
'。长命令请加 timeoutMs,或传 run_in_background 转后台,之后用 job_output 取结果'), timeoutMs);
|
|
185
199
|
const onAbort = () => {
|
|
186
200
|
clearTimeout(timer);
|
|
187
201
|
arm('命令被用户取消');
|
|
@@ -206,6 +220,103 @@ export function spawnShell(plan, timeoutMs, outputLimit, signal, options) {
|
|
|
206
220
|
child.on('close', finish);
|
|
207
221
|
});
|
|
208
222
|
}
|
|
223
|
+
/**
|
|
224
|
+
* 超预算时的截断:留头 60% + 尾 40%,中间写明省了多少字符。
|
|
225
|
+
*
|
|
226
|
+
* 只留头会把「真正的失败原因」丢掉——编译错误、测试断言、退出前的报错几乎都在
|
|
227
|
+
* 输出末尾,前面几千字往往只是进度与告警(0.7.x 实况:一条 30 秒超时的构建,
|
|
228
|
+
* 模型只看到最早那批编译中提示,看不到最后那句 syntax error)。
|
|
229
|
+
*
|
|
230
|
+
* spill 插件在 4000 字符就先接手落盘,走到这里的通常是它没接住的那部分(插件没挂、
|
|
231
|
+
* 阈值被调高、后台作业)。bash 这一层自己不落盘,所以标记里只说清省略了多少字符、
|
|
232
|
+
* 以及怎么看全(缩小命令范围分段重跑),不编一个并不存在的落盘路径。
|
|
233
|
+
*/
|
|
234
|
+
export function truncateBashOutput(output, outputLimit) {
|
|
235
|
+
if (output.length <= outputLimit)
|
|
236
|
+
return output;
|
|
237
|
+
const head = Math.floor(outputLimit * 0.6);
|
|
238
|
+
const tail = outputLimit - head;
|
|
239
|
+
const omitted = output.length - head - tail;
|
|
240
|
+
const marker = `\n…(中间省略 ${String(omitted)} 字符:这里只保留开头 ${String(head)} 字与结尾 ${String(tail)} 字;` +
|
|
241
|
+
`完整输出不在结果里:要看全就把命令范围缩小分段重跑,或把设置里「命令输出封顶」调大后重跑)\n`;
|
|
242
|
+
return `${output.slice(0, head)}${marker}${output.slice(output.length - tail)}`;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* PowerShell 启动前先把输出编码钉成 UTF-8(2026-10-30)。
|
|
246
|
+
*
|
|
247
|
+
* 为什么必须动手:中文 Windows 上 powershell.exe 默认按控制台代码页(936/GBK)编码
|
|
248
|
+
* 自己写的输出,Node 那边按 UTF-8 解就是一屏乱码——`Get-ChildItem` 的中文文件名、
|
|
249
|
+
* Python 报错里的中文路径都会变成问号或方框,模型据此判断不了路径对不对。
|
|
250
|
+
*
|
|
251
|
+
* 为什么包 try/catch:某些宿主(无控制台的服务里)设置 `[Console]::OutputEncoding`
|
|
252
|
+
* 会抛 IOException,编码没设成不该让整条命令失败。
|
|
253
|
+
*
|
|
254
|
+
* 注意它只管 PowerShell 自己的输出与它转发给原生程序的管道;原生命令(python、git)
|
|
255
|
+
* 仍可能按控制台代码页写字节,那边由 {@link decodeShellOutput} 的 GBK 回落兜住。
|
|
256
|
+
*/
|
|
257
|
+
const PS_UTF8_PROLOGUE = 'try { [Console]::OutputEncoding = [Text.Encoding]::UTF8 } catch { }\n$OutputEncoding = [Text.Encoding]::UTF8';
|
|
258
|
+
/** 一段命令输出该用哪种编码解:先按 UTF-8 严格解,解不开再按 GBK 解。 */
|
|
259
|
+
function decodeShellOutput(buffer) {
|
|
260
|
+
if (buffer.length === 0)
|
|
261
|
+
return '';
|
|
262
|
+
try {
|
|
263
|
+
return new TextDecoder('utf-8', { fatal: true }).decode(buffer);
|
|
264
|
+
}
|
|
265
|
+
catch {
|
|
266
|
+
try {
|
|
267
|
+
return new TextDecoder('gbk').decode(buffer);
|
|
268
|
+
}
|
|
269
|
+
catch {
|
|
270
|
+
return buffer.toString('utf8');
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* 把「用户选的终端」折成一次 spawn 的 file + args(2026-10-30 起的默认终端设置)。
|
|
276
|
+
*
|
|
277
|
+
* 四档的差别只在三处:可执行文件、怎么把命令交给它、以及命令里能写什么语法。
|
|
278
|
+
* 其余(环境脱敏、超时、输出封顶、遮红、spill)四条路完全一致。
|
|
279
|
+
*
|
|
280
|
+
* - PowerShell 家族(powershell / pwsh):`-NoProfile -Command`,前面钉 UTF-8 输出编码,
|
|
281
|
+
* 末尾补 exit 把最后一条原生命令的退出码带出来(`-Command` 自己只回 0/1)。
|
|
282
|
+
* - Git Bash:`--noprofile --norc -c`——不读 profile,起得快也不会被用户的 rc 脚本改动行为。
|
|
283
|
+
* - WSL:`--cd <Windows 路径>` 让命令落在对应工作区(WSL 会把盘符翻成 `/mnt/x`),
|
|
284
|
+
* 再交给发行版里的 `bash -lc`;`-l` 是为了让 PATH 带上发行版里配好的工具链。
|
|
285
|
+
* - sh:POSIX 上的出厂值,行为与以前一模一样。
|
|
286
|
+
*
|
|
287
|
+
* @param choice - 设置里的默认终端
|
|
288
|
+
* @param command - 模型给的命令原文
|
|
289
|
+
* @param cwd - 工作目录(WSL 要用它做 `--cd`)
|
|
290
|
+
* @param env - 已脱敏的子进程环境
|
|
291
|
+
*/
|
|
292
|
+
export function shellPlan(choice, command, cwd, env) {
|
|
293
|
+
const powershellArgs = [
|
|
294
|
+
'-NoProfile',
|
|
295
|
+
'-Command',
|
|
296
|
+
`${PS_UTF8_PROLOGUE}\n${command}\nif ($LASTEXITCODE -ne $null) { exit $LASTEXITCODE }`,
|
|
297
|
+
];
|
|
298
|
+
if (choice === 'gitbash')
|
|
299
|
+
return { file: resolveShellExecutable('gitbash'), args: ['--noprofile', '--norc', '-c', command], env, cwd };
|
|
300
|
+
if (choice === 'wsl') {
|
|
301
|
+
// `-d` 钉住探测时挑的那只发行版:默认发行版在装了 Docker Desktop 的机器上常常是
|
|
302
|
+
// `docker-desktop`(里面没有 bash),不钉就会全挂(2026-10-30 实测)。
|
|
303
|
+
const distro = wslDistroName();
|
|
304
|
+
const target = distro === '' ? [] : ['-d', distro];
|
|
305
|
+
return {
|
|
306
|
+
file: resolveShellExecutable('wsl'),
|
|
307
|
+
args: [...target, '--cd', cwd, '-e', 'bash', '-lc', command],
|
|
308
|
+
env,
|
|
309
|
+
cwd,
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
if (choice === 'sh')
|
|
313
|
+
return { file: 'sh', args: ['-c', command], env, cwd };
|
|
314
|
+
if (choice === 'pwsh')
|
|
315
|
+
return { file: resolveShellExecutable('pwsh'), args: powershellArgs, env, cwd };
|
|
316
|
+
if (isWin)
|
|
317
|
+
return { file: resolveShellExecutable('powershell'), args: powershellArgs, env, cwd };
|
|
318
|
+
return { file: 'sh', args: ['-c', command], env, cwd };
|
|
319
|
+
}
|
|
209
320
|
/**
|
|
210
321
|
* 执行一条命令:先问执行器缝拿最终执行计划,再 spawn,最后让改写过的那几位收尾。
|
|
211
322
|
* 没有沙箱插件注册执行器时,计划就是上面的默认那份,行为与以前完全一致。
|
|
@@ -213,18 +324,7 @@ export function spawnShell(plan, timeoutMs, outputLimit, signal, options) {
|
|
|
213
324
|
*/
|
|
214
325
|
async function runShell(command, cwd, timeoutMs, outputLimit, signal, background) {
|
|
215
326
|
const { env } = scrubChildEnv(process.env);
|
|
216
|
-
const base =
|
|
217
|
-
? {
|
|
218
|
-
file: 'powershell.exe',
|
|
219
|
-
// T15 探针抓出来的老毛病:PowerShell -Command 不透传原生命令的退出码
|
|
220
|
-
//(powershell.exe 自己只回 0/1)。命令末尾补一句显式 exit,把最后一条
|
|
221
|
-
// 原生命令的退出码带出来;纯 cmdlet 命令没有 $LASTEXITCODE,行为不变。
|
|
222
|
-
// 用换行而不是分号追加:command 以注释结尾时语句不会被注释吞掉。
|
|
223
|
-
args: ['-NoProfile', '-Command', `${command}\nif ($LASTEXITCODE -ne $null) { exit $LASTEXITCODE }`],
|
|
224
|
-
env,
|
|
225
|
-
cwd,
|
|
226
|
-
}
|
|
227
|
-
: { file: 'sh', args: ['-c', command], env, cwd };
|
|
327
|
+
const base = shellPlan(readShellChoice(), command, cwd, env);
|
|
228
328
|
const run = { command, cwd, timeoutMs, signal };
|
|
229
329
|
const { plan, changed } = await planCommand(run, base);
|
|
230
330
|
try {
|
|
@@ -244,12 +344,13 @@ export function runShellBackground(command, cwd, outputLimit, background) {
|
|
|
244
344
|
});
|
|
245
345
|
}
|
|
246
346
|
/**
|
|
247
|
-
* T20:起一个长命交互 shell
|
|
248
|
-
*
|
|
249
|
-
*
|
|
347
|
+
* T20:起一个长命交互 shell(终端会话的进程原语)。可执行文件取自设置里的默认终端,
|
|
348
|
+
* 参数都是固定字面量,不拼任何外部输入;环境与前台命令同一份脱敏。
|
|
349
|
+
* 没有 tty(管道模式)——全屏程序跑不了,这是终端降级版的已知边界。进程原语不出本文件。
|
|
250
350
|
*/
|
|
251
351
|
export function spawnTerminalShell(cwd) {
|
|
252
352
|
const { env } = scrubChildEnv(process.env);
|
|
353
|
+
const choice = readShellChoice();
|
|
253
354
|
const options = {
|
|
254
355
|
stdio: ['pipe', 'pipe', 'pipe'],
|
|
255
356
|
windowsHide: true,
|
|
@@ -257,12 +358,40 @@ export function spawnTerminalShell(cwd) {
|
|
|
257
358
|
};
|
|
258
359
|
if (cwd !== '')
|
|
259
360
|
options.cwd = cwd;
|
|
361
|
+
if (choice === 'gitbash') {
|
|
362
|
+
return spawn(resolveShellExecutable('gitbash'), ['--noprofile', '--norc'], options);
|
|
363
|
+
}
|
|
364
|
+
if (choice === 'wsl') {
|
|
365
|
+
// 交互式 WSL:`--cd` 落在会话目录;不传 `-i`,管道模式下 bash 照样从 stdin 读命令,
|
|
366
|
+
// 加了只会多一串提示符噪声。
|
|
367
|
+
return spawn(resolveShellExecutable('wsl'), cwd === '' ? ['--', 'bash', '-l'] : ['--cd', cwd, '--', 'bash', '-l'], options);
|
|
368
|
+
}
|
|
369
|
+
if (choice === 'sh') {
|
|
370
|
+
options.detached = true;
|
|
371
|
+
return spawn('bash', ['--noprofile', '--norc'], options);
|
|
372
|
+
}
|
|
373
|
+
if (choice === 'pwsh') {
|
|
374
|
+
return spawn(resolveShellExecutable('pwsh'), ['-NoProfile', '-Command', '-'], options);
|
|
375
|
+
}
|
|
260
376
|
if (isWin) {
|
|
261
|
-
return spawn('powershell
|
|
377
|
+
return spawn(resolveShellExecutable('powershell'), ['-NoProfile', '-Command', '-'], options);
|
|
262
378
|
}
|
|
263
379
|
options.detached = true;
|
|
264
380
|
return spawn('bash', ['--noprofile', '--norc'], options);
|
|
265
381
|
}
|
|
382
|
+
/**
|
|
383
|
+
* 工具说明里那句「执行什么命令」的宾语:模型看这句话决定怎么写命令,
|
|
384
|
+
* 所以必须与设置里选中的终端一致(选了 Git Bash 还写「执行 PowerShell 命令」= 骗模型)。
|
|
385
|
+
*/
|
|
386
|
+
function shellNoun(choice) {
|
|
387
|
+
if (choice === 'powershell' || choice === 'pwsh' || (choice === 'auto' && isWin))
|
|
388
|
+
return 'PowerShell';
|
|
389
|
+
if (choice === 'gitbash')
|
|
390
|
+
return 'Git Bash';
|
|
391
|
+
if (choice === 'wsl')
|
|
392
|
+
return 'WSL 里的 bash';
|
|
393
|
+
return 'shell';
|
|
394
|
+
}
|
|
266
395
|
/**
|
|
267
396
|
* 造一个 bash 工具。预算由 tools-default 插件从配置取值传入(缺省 {@link BASH_DEFAULT_BUDGETS}),
|
|
268
397
|
* 参数说明里的数值随预算走——模型看到的承诺与实际执行的一致。
|
|
@@ -270,18 +399,19 @@ export function spawnTerminalShell(cwd) {
|
|
|
270
399
|
* 输出与终止走 job_output / job_list / job_kill。
|
|
271
400
|
*/
|
|
272
401
|
export function createBashTool(budgets = BASH_DEFAULT_BUDGETS, background) {
|
|
402
|
+
// 说明里的终端名在**注册时**定(默认终端改了会重注册,见 tools-default 的 syncTools)。
|
|
403
|
+
const choice = readShellChoice();
|
|
404
|
+
const noun = shellNoun(choice);
|
|
405
|
+
const powershell = noun === 'PowerShell';
|
|
273
406
|
return {
|
|
274
407
|
name: 'bash',
|
|
275
|
-
description:
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
'读文件用 read,找代码用 grep/glob,改文件用 edit/write。' +
|
|
283
|
-
'一条命令里有 | ; && 时会被切成几段分别判定,任何一段危险整条就要问用户。耗时命令设 timeoutMs;' +
|
|
284
|
-
'更长的活传 run_in_background 转后台,立即返回 job id。',
|
|
408
|
+
description: `执行 ${noun} 命令(工作目录 = 会话目录)。只留给「非 shell 不可」的事:构建、安装、git、跑测试、查进程。` +
|
|
409
|
+
'不要用 cat/head/tail 读文件(用 read),不要用 grep/rg' +
|
|
410
|
+
(powershell ? '/Get-ChildItem -Recurse' : ' -r') +
|
|
411
|
+
' 找代码(用 grep/glob),' +
|
|
412
|
+
'不要用 echo 重定向或 heredoc 造文件(用 write),不要用 sed/awk 改文件(用 edit)。' +
|
|
413
|
+
'一条命令里有 | ; && 时会被切成几段分别判定,任何一段危险整条就要问用户;带重定向或变量赋值的段不给走已授权规则。' +
|
|
414
|
+
'耗时命令设 timeoutMs;构建/测试/起服务这类更长的活传 run_in_background 转后台,立即返回 job id。',
|
|
285
415
|
parameters: {
|
|
286
416
|
type: 'object',
|
|
287
417
|
properties: {
|
|
@@ -813,16 +943,13 @@ export class TerminalTable {
|
|
|
813
943
|
* 没挂 PTY(降级版):全屏程序跑不了;也没有中途打断——长命令等完或 close 重开。
|
|
814
944
|
*/
|
|
815
945
|
export function createTerminalTool(table) {
|
|
946
|
+
const noun = shellNoun(readShellChoice());
|
|
816
947
|
return {
|
|
817
948
|
name: 'terminal',
|
|
818
|
-
description:
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
'没有中途打断:跑歪了的命令等它结束,或 close 收掉会话重开。'
|
|
823
|
-
: '开一个持久的交互 bash 会话(没有 tty:vim/htop 这类全屏程序跑不了)。' +
|
|
824
|
-
'适合「先激活环境、再连续跑几条命令」的场景。open 开会话,send 写命令(自带换行才执行),' +
|
|
825
|
-
'read 读输出(增量),close 收掉,list 清点。没有中途打断:跑歪了的命令等它结束,或 close 收掉会话重开。',
|
|
949
|
+
description: `开一个持久的交互 ${noun} 会话(没有 tty:vim/htop 这类全屏程序跑不了)。` +
|
|
950
|
+
'适合「先激活环境、再连续跑几条命令」的场景——环境在会话里留着,一次不用重设。' +
|
|
951
|
+
'open 开会话,send 写命令(自带换行才执行),read 读输出(增量),close 收掉,list 清点。' +
|
|
952
|
+
'没有中途打断:跑歪了的命令等它结束,或 close 收掉会话重开。',
|
|
826
953
|
parameters: {
|
|
827
954
|
type: 'object',
|
|
828
955
|
properties: {
|
|
@@ -6,10 +6,11 @@
|
|
|
6
6
|
* @module dsc/core/tools/fs-tools
|
|
7
7
|
*/
|
|
8
8
|
import { promises as fs } from 'node:fs';
|
|
9
|
-
import {
|
|
9
|
+
import { resolve } from 'node:path';
|
|
10
10
|
import { diffLines } from '../diff-text.js';
|
|
11
11
|
import { noteRead, noteWrite, readBlockReason, staleEditReason, staleOverwriteReason, writeHardBlockReason } from '../path-policy.js';
|
|
12
12
|
import { sandboxPermissionProperties } from './sandbox-args.js';
|
|
13
|
+
import { absPath, stringArg } from './path-args.js';
|
|
13
14
|
/** read 工具缺省一次读多少行(配置没给 readLineLimit 时用它)。 */
|
|
14
15
|
export const READ_DEFAULT_LINE_LIMIT = 2000;
|
|
15
16
|
/** T34:read 输出的字符硬顶(dsh 的 maxOutputChars 同款口径;再往上是 spill 的事)。 */
|
|
@@ -32,16 +33,6 @@ const IMAGE_MIME = {
|
|
|
32
33
|
const IMAGE_MAX_BYTES = 6 * 1024 * 1024;
|
|
33
34
|
/** 变更摘要里 diff 段最多保留多少行(超出砍尾并标 truncated,防一次整篇重写撑爆条目与日志)。 */
|
|
34
35
|
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
36
|
/**
|
|
46
37
|
* 把「改之前 / 改之后」的全文算成一份变更摘要(轮尾「文件已更改」卡的数据)。
|
|
47
38
|
*
|
|
@@ -97,7 +88,7 @@ export function createReadTool(lineLimit = READ_DEFAULT_LINE_LIMIT) {
|
|
|
97
88
|
},
|
|
98
89
|
risk: 'read',
|
|
99
90
|
async run(args, ctx) {
|
|
100
|
-
const file =
|
|
91
|
+
const file = absPath(ctx.cwd, args.path);
|
|
101
92
|
const blocked = readBlockReason(file);
|
|
102
93
|
if (blocked !== null)
|
|
103
94
|
throw new Error(blocked);
|
|
@@ -169,14 +160,14 @@ export const writeTool = {
|
|
|
169
160
|
},
|
|
170
161
|
risk: 'write',
|
|
171
162
|
async run(args, ctx) {
|
|
172
|
-
const file =
|
|
163
|
+
const file = absPath(ctx.cwd, args.path);
|
|
173
164
|
const hard = writeHardBlockReason(file);
|
|
174
165
|
if (hard !== null)
|
|
175
166
|
throw new Error(hard);
|
|
176
167
|
const stale = staleOverwriteReason(file, ctx.sessionId);
|
|
177
168
|
if (stale !== null)
|
|
178
169
|
throw new Error(stale);
|
|
179
|
-
const content =
|
|
170
|
+
const content = stringArg(args.content, 'content');
|
|
180
171
|
// T35:CAS 锚——从这一刻到 writeFile 之间文件若被第三方改过,就拒绝整写
|
|
181
172
|
const anchorStat = await fs.stat(file).catch(() => null);
|
|
182
173
|
// 旧内容拿不到(新建)就当空串:diff 呈现为整篇新增
|
|
@@ -212,7 +203,17 @@ export const editTool = {
|
|
|
212
203
|
},
|
|
213
204
|
risk: 'write',
|
|
214
205
|
async run(args, ctx) {
|
|
215
|
-
|
|
206
|
+
// 反馈(2026-10-29):模型按别的工具的习惯传 old_string / new_string / file_path,
|
|
207
|
+
// 只收到一句「old 必须是字符串」,得试一次才知道参数名。认得出来的别名直接说清楚。
|
|
208
|
+
const alias = args.old === undefined && args.new === undefined && (args.old_string !== undefined || args.new_string !== undefined)
|
|
209
|
+
? 'old_string / new_string'
|
|
210
|
+
: args.path === undefined && args.file_path !== undefined
|
|
211
|
+
? 'file_path'
|
|
212
|
+
: null;
|
|
213
|
+
if (alias !== null) {
|
|
214
|
+
throw new Error(`参数名不对:这个工具用 path / old / new(你传的是 ${alias})。把目标路径放 path、要替换的原文放 old、替换后的内容放 new`);
|
|
215
|
+
}
|
|
216
|
+
const file = absPath(ctx.cwd, args.path);
|
|
216
217
|
const hard = writeHardBlockReason(file);
|
|
217
218
|
if (hard !== null)
|
|
218
219
|
throw new Error(hard);
|
|
@@ -221,8 +222,8 @@ export const editTool = {
|
|
|
221
222
|
const stale = staleEditReason(file, ctx.sessionId);
|
|
222
223
|
if (stale !== null)
|
|
223
224
|
throw new Error(stale);
|
|
224
|
-
const oldText =
|
|
225
|
-
const newText =
|
|
225
|
+
const oldText = stringArg(args.old, 'old');
|
|
226
|
+
const newText = stringArg(args.new, 'new');
|
|
226
227
|
const anchorStat = await fs.stat(file).catch(() => null);
|
|
227
228
|
const raw = await fs.readFile(file, 'utf8');
|
|
228
229
|
const first = raw.indexOf(oldText);
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 只读图片的工具(对齐 dsh `tool-fs` 的 `readImage` 能力)。
|
|
3
|
+
*
|
|
4
|
+
* 为什么单独存在而不是复用 read:极简档要测「模型手上只有一条 shell」的基础表现,
|
|
5
|
+
* 参考实现那一档只留 `readImage: true`、把 `read` 关掉;Pneuma 的 read 同时能读文本,
|
|
6
|
+
* 直接给它就等于把「只能靠 shell 看文件」这条前提破了。所以这个工具只认图片,
|
|
7
|
+
* 只挂在极简档(`presets: ['minimal']`),标准档看不见它。
|
|
8
|
+
*
|
|
9
|
+
* 放在独立文件里而不是并进 fs-tools:README 的「工具集 N 件」按
|
|
10
|
+
* `bash / fs-tools / search-tools` 三个文件数工具,极简档专用的这一件不该改变那个口径。
|
|
11
|
+
*
|
|
12
|
+
* @module dsc/core/tools/image-tool
|
|
13
|
+
*/
|
|
14
|
+
import { promises as fs } from 'node:fs';
|
|
15
|
+
import { noteRead, readBlockReason } from '../path-policy.js';
|
|
16
|
+
import { absPath } from './path-args.js';
|
|
17
|
+
/** read 认得的图片扩展名 → MIME(data URL 前缀用;与 fs-tools 的 read 同一条红线)。 */
|
|
18
|
+
const IMAGE_MIME = {
|
|
19
|
+
png: 'image/png',
|
|
20
|
+
jpg: 'image/jpeg',
|
|
21
|
+
jpeg: 'image/jpeg',
|
|
22
|
+
gif: 'image/gif',
|
|
23
|
+
webp: 'image/webp',
|
|
24
|
+
bmp: 'image/bmp',
|
|
25
|
+
svg: 'image/svg+xml',
|
|
26
|
+
};
|
|
27
|
+
/** 一张图进上下文的尺寸上限:6MB 原图 base64 后约 8MB,与输入框贴图同一条红线。 */
|
|
28
|
+
const IMAGE_MAX_BYTES = 6 * 1024 * 1024;
|
|
29
|
+
export const readImageTool = {
|
|
30
|
+
name: 'read_image',
|
|
31
|
+
description: '看一张图片(png/jpg/gif/webp/bmp/svg),直接作为图片附件加载;文本文件请用 shell 读。',
|
|
32
|
+
parameters: {
|
|
33
|
+
type: 'object',
|
|
34
|
+
properties: { path: { type: 'string', description: '图片路径(绝对或相对当前目录)' } },
|
|
35
|
+
required: ['path'],
|
|
36
|
+
},
|
|
37
|
+
risk: 'read',
|
|
38
|
+
presets: ['minimal'],
|
|
39
|
+
async run(args, ctx) {
|
|
40
|
+
const file = absPath(ctx.cwd, args.path);
|
|
41
|
+
const blocked = readBlockReason(file);
|
|
42
|
+
if (blocked !== null)
|
|
43
|
+
throw new Error(blocked);
|
|
44
|
+
const mime = IMAGE_MIME[file.slice(file.lastIndexOf('.') + 1).toLowerCase()];
|
|
45
|
+
if (mime === undefined) {
|
|
46
|
+
throw new Error('read_image 只接受图片(png/jpg/gif/webp/bmp/svg);文本文件请用 shell 命令读');
|
|
47
|
+
}
|
|
48
|
+
const stat = await fs.stat(file);
|
|
49
|
+
if (stat.size > IMAGE_MAX_BYTES) {
|
|
50
|
+
throw new Error(`这张图有 ${Math.round(stat.size / 1024 / 1024)}MB,超过 6MB 上限;先压缩或缩小再看`);
|
|
51
|
+
}
|
|
52
|
+
const bytes = await fs.readFile(file);
|
|
53
|
+
noteRead(file, ctx.sessionId);
|
|
54
|
+
return {
|
|
55
|
+
text: `已加载图片 ${file}(${mime},${stat.size} 字节),图在附件里。`,
|
|
56
|
+
images: [`data:${mime};base64,${bytes.toString('base64')}`],
|
|
57
|
+
};
|
|
58
|
+
},
|
|
59
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 工具入参的两种收口:路径收成绝对路径、必填字符串当场校验。
|
|
3
|
+
*
|
|
4
|
+
* `fs-tools` 与 `image-tool` 各抄过一份,逐字相同。抄两份的代价不是体积,
|
|
5
|
+
* 是报错文案会分叉——模型看到的 `path 必须是非空字符串` 如果在一个工具里变成别的说法,
|
|
6
|
+
* 它下次猜的参数形状就跟着变。
|
|
7
|
+
*
|
|
8
|
+
* @module dsc/core/tools/path-args
|
|
9
|
+
*/
|
|
10
|
+
import { isAbsolute, resolve } from 'node:path';
|
|
11
|
+
/** 把工具收到的 `path` 参数收成绝对路径;空串与非字符串当场报错。 */
|
|
12
|
+
export function absPath(cwd, value) {
|
|
13
|
+
if (typeof value !== 'string' || value === '')
|
|
14
|
+
throw new Error('path 必须是非空字符串');
|
|
15
|
+
return isAbsolute(value) ? value : resolve(cwd, value);
|
|
16
|
+
}
|
|
17
|
+
/** 必填字符串参数;缺了就用调用方给的字段名报错。 */
|
|
18
|
+
export function stringArg(value, name) {
|
|
19
|
+
if (typeof value !== 'string')
|
|
20
|
+
throw new Error(`${name} 必须是字符串`);
|
|
21
|
+
return value;
|
|
22
|
+
}
|
|
@@ -1,3 +1,33 @@
|
|
|
1
1
|
import type { ToolEntry } from '../tools.js';
|
|
2
|
+
/**
|
|
3
|
+
* 把 `{a,b}` 展开成多条模式(花括号展开的最小子集,支持嵌套)。
|
|
4
|
+
*
|
|
5
|
+
* 为什么要有(2026-10-30):反馈里那条 `{vue,ts,js,json}` 多选模式一条都没匹配上,
|
|
6
|
+
* 而且**不报错**,看起来就像「这个目录是空的」——一次误判足以让模型走错方向。
|
|
7
|
+
* 只有真带逗号的 `{a,b}` 才展开:`{single}` 在 shell 里是字面量,这里保持一致。
|
|
8
|
+
* `{` 没有配对的 `}` 直接报错,不静默返回空结果。
|
|
9
|
+
*
|
|
10
|
+
* @param pattern - 原始模式。
|
|
11
|
+
* @param limit - 最多展开出几条;超出后截断(宁少不多,避免一次请求铺开几百个匹配器)。
|
|
12
|
+
* @returns 展开后的模式列表(不需要展开时就是原样一条)。
|
|
13
|
+
*/
|
|
14
|
+
export declare function expandBraces(pattern: string, limit?: number): string[];
|
|
15
|
+
/** 一条忽略规则:`dir` 是它所在的目录,匹配的是相对该目录的路径。 */
|
|
16
|
+
interface IgnoreRule {
|
|
17
|
+
dir: string;
|
|
18
|
+
regex: RegExp;
|
|
19
|
+
negate: boolean;
|
|
20
|
+
/** 只忽略目录(`build/` 这种写法)。 */
|
|
21
|
+
dirOnly: boolean;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* 把 `.gitignore` 的正文解析成规则表。
|
|
25
|
+
*
|
|
26
|
+
* 支持子集:注释、空行、`!` 否定、结尾 `/`(只匹配目录)、开头 `/`(锚定到本目录)、
|
|
27
|
+
* 含 `/` 的模式(相对本目录)、不含 `/` 的模式(匹配任意层级的同名项)、`*` `?` `**`。
|
|
28
|
+
* 不支持 `[a-z]` 字符集与 `\\` 转义——遇到就按字面量处理,宁可少忽略也不错忽略。
|
|
29
|
+
*/
|
|
30
|
+
export declare function parseGitignore(text: string, dir: string): IgnoreRule[];
|
|
2
31
|
export declare const globTool: ToolEntry;
|
|
3
32
|
export declare const grepTool: ToolEntry;
|
|
33
|
+
export {};
|