@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/host/kernel.js
CHANGED
|
@@ -19,8 +19,9 @@ import { Context } from '@deepseek-ai/cordis';
|
|
|
19
19
|
import { bootNoticeOnce } from '../core/boot-notices.js';
|
|
20
20
|
import { activeConfigFile } from '../core/config-store.js';
|
|
21
21
|
import { parseTolerantYaml } from '../core/migrate.js';
|
|
22
|
+
import { readSessionUsage } from '../core/usage-log.js';
|
|
22
23
|
import { getPluginConfig, isPluginEnabled, migrateTeamSplit, registerPluginMeta } from '../core/plugin-registry.js';
|
|
23
|
-
import { mountAllExternalPlugins, registerBuiltinMount } from '../core/plugin-loader.js';
|
|
24
|
+
import { mountAllExternalPlugins, registerBuiltinMount, trackBuiltinMount } from '../core/plugin-loader.js';
|
|
24
25
|
import { pluginManagerPlugin } from '../plugins/plugin-manager.js';
|
|
25
26
|
import { desktopDockPlugin } from '../plugins/desktop-dock.js';
|
|
26
27
|
import { gitPlugin } from '../plugins/git.js';
|
|
@@ -73,7 +74,6 @@ import { dockBrowserPlugin } from '../plugins/dock-browser.js';
|
|
|
73
74
|
import { selfImprovePlugin } from '../plugins/self-improve.js';
|
|
74
75
|
import { dshCompatPlugin } from '../plugins/dsh-compat.js';
|
|
75
76
|
import { fileReviewPlugin } from '../plugins/file-review.js';
|
|
76
|
-
const err = (error) => (error instanceof Error ? error.message : String(error));
|
|
77
77
|
/**
|
|
78
78
|
* 官方可开关插件(插件中心「官方可开关」那一档):代码随包发布,但有开关,
|
|
79
79
|
* 也能跳到自己的设置分区。`defaultDisabled` 为 true 的那些在用户主动打开前不挂载。
|
|
@@ -82,31 +82,31 @@ export const OFFICIAL_PLUGINS = [
|
|
|
82
82
|
{
|
|
83
83
|
file: 'subagent',
|
|
84
84
|
name: '子智能体',
|
|
85
|
-
description: '
|
|
85
|
+
description: '让模型把能独立完成的活交给队友并行做;队友只看任务说明,可设层级、人数、轮次与模型',
|
|
86
86
|
toggleable: true,
|
|
87
87
|
defaultDisabled: true,
|
|
88
88
|
settingsSection: 'subagent',
|
|
89
89
|
},
|
|
90
90
|
{
|
|
91
91
|
file: 'team',
|
|
92
|
-
name: '
|
|
93
|
-
description: '
|
|
92
|
+
name: '共享任务板',
|
|
93
|
+
description: '一块按会话分开的任务板:登记、认领、结项,队友和你看到同一块;成员名单在「子智能体」里',
|
|
94
94
|
toggleable: true,
|
|
95
95
|
defaultDisabled: true,
|
|
96
96
|
settingsSection: 'team',
|
|
97
97
|
},
|
|
98
98
|
{
|
|
99
99
|
file: 'computer-use',
|
|
100
|
-
name: '
|
|
101
|
-
description: '
|
|
100
|
+
name: '操作电脑桌面',
|
|
101
|
+
description: '看屏幕、点按钮、输入文字来操作 Windows 桌面;看可免审批,动手每次要确认',
|
|
102
102
|
toggleable: true,
|
|
103
103
|
defaultDisabled: true,
|
|
104
104
|
settingsSection: 'computer-use',
|
|
105
105
|
},
|
|
106
106
|
{
|
|
107
107
|
file: 'web-search',
|
|
108
|
-
name: '
|
|
109
|
-
description: '
|
|
108
|
+
name: '联网搜索',
|
|
109
|
+
description: '让模型上网查资料并附来源链接;先选一家搜索服务(Tavily / 博查 / Serper)并填 key',
|
|
110
110
|
toggleable: true,
|
|
111
111
|
settingsSection: 'web-search',
|
|
112
112
|
},
|
|
@@ -115,45 +115,45 @@ export const OFFICIAL_PLUGINS = [
|
|
|
115
115
|
// 提升安全与本地便利、且不配就完全无副作用的那几档默认开。
|
|
116
116
|
{
|
|
117
117
|
file: 'approval-floor',
|
|
118
|
-
name: '
|
|
119
|
-
description: '
|
|
118
|
+
name: '危险命令硬拦截',
|
|
119
|
+
description: '关机、删盘、改注册表、读密钥这类命令一律拒绝,完全访问也救不回来;常用命令可加白名单',
|
|
120
120
|
toggleable: true,
|
|
121
121
|
settingsSection: 'approval-floor',
|
|
122
122
|
},
|
|
123
123
|
{
|
|
124
124
|
file: 'spill',
|
|
125
|
-
name: '
|
|
126
|
-
description: '
|
|
125
|
+
name: '长输出转存',
|
|
126
|
+
description: '工具输出太长就存成文件,模型先看头尾几行;需要细节时按路径续读,上下文不会被日志撑爆',
|
|
127
127
|
toggleable: true,
|
|
128
128
|
settingsSection: 'spill',
|
|
129
129
|
},
|
|
130
130
|
{
|
|
131
131
|
file: 'session-search',
|
|
132
|
-
name: '
|
|
133
|
-
description: '
|
|
132
|
+
name: '历史会话搜索',
|
|
133
|
+
description: '按关键词翻以前聊过的会话,中文一两个字也能搜到;提供 session_search 工具与 /search 命令',
|
|
134
134
|
toggleable: true,
|
|
135
135
|
settingsSection: 'session-search',
|
|
136
136
|
},
|
|
137
137
|
{
|
|
138
138
|
file: 'lifecycle-hooks',
|
|
139
|
-
name: '
|
|
140
|
-
description: '
|
|
139
|
+
name: '外部命令钩子',
|
|
140
|
+
description: '在模型动手前后跑你的脚本,脚本可以拦下这次操作;事件名沿用 codex 的写法',
|
|
141
141
|
toggleable: true,
|
|
142
142
|
defaultDisabled: true,
|
|
143
143
|
settingsSection: 'lifecycle-hooks',
|
|
144
144
|
},
|
|
145
145
|
{
|
|
146
146
|
file: 'mcp',
|
|
147
|
-
name: 'MCP
|
|
148
|
-
description: '
|
|
147
|
+
name: 'MCP 外部工具',
|
|
148
|
+
description: '连上 MCP 服务器,把它们的工具接进来给模型用;支持本机命令(stdio)与 HTTP 两种连法',
|
|
149
149
|
toggleable: true,
|
|
150
150
|
defaultDisabled: true,
|
|
151
151
|
settingsSection: 'mcp',
|
|
152
152
|
},
|
|
153
153
|
{
|
|
154
154
|
file: 'tool-search',
|
|
155
|
-
name: '
|
|
156
|
-
description: '
|
|
155
|
+
name: '工具按需加载',
|
|
156
|
+
description: '只把用得上的工具说明发给模型;撤下的动手类工具与 MCP 工具用 tool_search 查、tool_call 调',
|
|
157
157
|
toggleable: true,
|
|
158
158
|
defaultDisabled: true,
|
|
159
159
|
settingsSection: 'tool-search',
|
|
@@ -163,46 +163,46 @@ export const OFFICIAL_PLUGINS = [
|
|
|
163
163
|
// 且默认档 workspace-write 不挡正常的工作区读写。
|
|
164
164
|
{
|
|
165
165
|
file: 'sandbox',
|
|
166
|
-
name: '
|
|
167
|
-
description: '
|
|
166
|
+
name: '文件与命令围栏',
|
|
167
|
+
description: '限定模型能写哪里:越界写、关网时联网当场拒;要破例得带理由弹审批卡',
|
|
168
168
|
toggleable: true,
|
|
169
169
|
settingsSection: 'sandbox',
|
|
170
170
|
},
|
|
171
171
|
{
|
|
172
172
|
file: 'file-review',
|
|
173
|
-
name: '
|
|
174
|
-
description: '
|
|
173
|
+
name: '改动前预览',
|
|
174
|
+
description: '写文件或改文件之前,先把要改的几行贴进对话;长改动按行截断,看得见改在哪',
|
|
175
175
|
toggleable: true,
|
|
176
176
|
settingsSection: 'file-review',
|
|
177
177
|
},
|
|
178
178
|
{
|
|
179
179
|
file: 'schedule',
|
|
180
180
|
name: '定时任务',
|
|
181
|
-
description: '
|
|
181
|
+
description: '到点把任务描述投回建它的会话并跑一轮;支持六种时间选择器和时区',
|
|
182
182
|
toggleable: true,
|
|
183
183
|
defaultDisabled: true,
|
|
184
184
|
settingsSection: 'schedule',
|
|
185
185
|
},
|
|
186
186
|
{
|
|
187
187
|
file: 'lsp',
|
|
188
|
-
name: '
|
|
189
|
-
description: '
|
|
188
|
+
name: '代码跳转与报错',
|
|
189
|
+
description: '查定义、引用、实现,并把这次编辑新引入的报错提醒给模型',
|
|
190
190
|
toggleable: true,
|
|
191
191
|
defaultDisabled: true,
|
|
192
192
|
settingsSection: 'lsp',
|
|
193
193
|
},
|
|
194
194
|
{
|
|
195
195
|
file: 'browser',
|
|
196
|
-
name: '
|
|
197
|
-
description: '
|
|
196
|
+
name: '受控浏览器',
|
|
197
|
+
description: '模型自己开一台隔离 Chrome,按页面元素点击输入;动作每次审批,可设域名黑白名单',
|
|
198
198
|
toggleable: true,
|
|
199
199
|
defaultDisabled: true,
|
|
200
200
|
settingsSection: 'browser',
|
|
201
201
|
},
|
|
202
202
|
{
|
|
203
203
|
file: 'dock-browser',
|
|
204
|
-
name: '
|
|
205
|
-
description: '
|
|
204
|
+
name: '侧栏浏览器',
|
|
205
|
+
description: '让模型操作桌面端侧栏那台浏览器;看页面可免审批,动手每次要确认',
|
|
206
206
|
toggleable: true,
|
|
207
207
|
defaultDisabled: true,
|
|
208
208
|
// 指向插件自建的分区(`dock-browser` 插件里 ctx.settings.registerSection 注册的那张,
|
|
@@ -211,16 +211,16 @@ export const OFFICIAL_PLUGINS = [
|
|
|
211
211
|
},
|
|
212
212
|
{
|
|
213
213
|
file: 'self-improve',
|
|
214
|
-
name: '
|
|
215
|
-
description: '
|
|
214
|
+
name: '经验沉淀',
|
|
215
|
+
description: '把你纠正过它的地方记成候选;你确认后才写成技能,每次改动留台账可回滚',
|
|
216
216
|
toggleable: true,
|
|
217
217
|
defaultDisabled: true,
|
|
218
218
|
settingsSection: 'self-improve',
|
|
219
219
|
},
|
|
220
220
|
{
|
|
221
221
|
file: 'dsh-compat',
|
|
222
|
-
name: 'dsh
|
|
223
|
-
description: '
|
|
222
|
+
name: 'dsh 插件兼容',
|
|
223
|
+
description: '让按 dsh 写法做的外部插件也能装进来跑;补 logger、模块解析与工具注册的差异',
|
|
224
224
|
toggleable: true,
|
|
225
225
|
defaultDisabled: true,
|
|
226
226
|
},
|
|
@@ -385,8 +385,11 @@ export async function createKernel(options) {
|
|
|
385
385
|
if (plugin === undefined)
|
|
386
386
|
continue;
|
|
387
387
|
registerBuiltinMount(meta.file, plugin);
|
|
388
|
-
if (isPluginEnabled(meta.file))
|
|
389
|
-
await root.plugin(plugin, getPluginConfig(meta.file));
|
|
388
|
+
if (isPluginEnabled(meta.file)) {
|
|
389
|
+
const fiber = await root.plugin(plugin, getPluginConfig(meta.file));
|
|
390
|
+
// 把 fiber 记进热挂载表:插件中心的开关只认这张表,不登记就等于“停用只写盘”。
|
|
391
|
+
trackBuiltinMount(meta.file, fiber);
|
|
392
|
+
}
|
|
390
393
|
}
|
|
391
394
|
return root;
|
|
392
395
|
}
|
|
@@ -405,7 +408,7 @@ export async function loadExternalPlugins(root, configured) {
|
|
|
405
408
|
const extraPaths = configured.map((entry) => (isAbsolute(entry) ? entry : resolve(configDir, entry)));
|
|
406
409
|
const failures = await mountAllExternalPlugins(root, extraPaths);
|
|
407
410
|
for (const failure of failures) {
|
|
408
|
-
root.transcript.system(`外部插件 ${failure.name}(${failure.file})未能加载:${failure.problem}
|
|
411
|
+
root.transcript.system(`外部插件 ${failure.name}(${failure.file})未能加载:${failure.problem},已自动停用`, 'error');
|
|
409
412
|
}
|
|
410
413
|
}
|
|
411
414
|
export function readUiConfig() {
|
|
@@ -430,7 +433,9 @@ export function emitStartupNotes(root, migration, config) {
|
|
|
430
433
|
root.transcript.system('Pneuma:没有可用的模型端点。\n' +
|
|
431
434
|
'请编辑 ~/.dsc/config.yaml 配置 providers(api: openai-completions 风格),\n' +
|
|
432
435
|
'key 放到 apiKeyEnv 指向的环境变量或 ~/.dsc/credentials.yaml。\n' +
|
|
433
|
-
'若本机有 dsh 配置,可运行 `numa config migrate --force` 迁移。'
|
|
436
|
+
'若本机有 dsh 配置,可运行 `numa config migrate --force` 迁移。',
|
|
437
|
+
// 没有端点等于什么都干不了:标成错误,界面弹一次提示,不铺在首屏。
|
|
438
|
+
'error');
|
|
434
439
|
}
|
|
435
440
|
if (migration !== null) {
|
|
436
441
|
root.transcript.system(`已从 dsh 迁移模型配置到 ${migration.configPath}(端点 ${migration.providers.join('、')}` +
|
|
@@ -440,7 +445,18 @@ export function emitStartupNotes(root, migration, config) {
|
|
|
440
445
|
root.transcript.system(root.session.startupNote);
|
|
441
446
|
if (root.session.resumedStartup) {
|
|
442
447
|
// 启动恢复了历史会话:重放历史到条目(与 dsc/session-open 的行为一致)
|
|
443
|
-
root.transcript.replayHistory(root.session.current().messages, root.session.current().toolErrors, root.session.current().fileChanges);
|
|
448
|
+
root.transcript.replayHistory(root.session.current().messages, root.session.current().toolErrors, root.session.current().fileChanges, root.session.current().presentations);
|
|
449
|
+
// 重启后的第一帧状态栏也得有上下文读数:用量日志按会话存着最后一条请求的
|
|
450
|
+
// 输入 token,它与前台切会话共用同一条回填口径。日志里没有这条会话就不填,
|
|
451
|
+
// 免得把「还没数」画成 0%。
|
|
452
|
+
//
|
|
453
|
+
// 这里断言一个契约外的窄方法:回填只在启动恢复这一个入口用到,不必为它
|
|
454
|
+
// 拓宽 TranscriptService(打开会话的路径直接操作 adapter,无需经过服务面)。
|
|
455
|
+
const usage = readSessionUsage(root.session.current().meta.id);
|
|
456
|
+
if (usage !== null) {
|
|
457
|
+
;
|
|
458
|
+
root.transcript.seedContextUsage(usage.lastInputTokens);
|
|
459
|
+
}
|
|
444
460
|
}
|
|
445
461
|
// 启动提示只展示一次(0.6.64):同一会话同一模型的开机横幅只在首次见到时写,
|
|
446
462
|
// 换会话/换模型自然重现。恢复会话时转录里本来就有历史可辨认,状态栏也带短 id。
|
package/lib/plugins/agent.js
CHANGED
|
@@ -21,6 +21,8 @@ import { createHash } from 'node:crypto';
|
|
|
21
21
|
import { Session } from '../core/session.js';
|
|
22
22
|
import { MiniAgent } from '../core/loop.js';
|
|
23
23
|
import { appendToolRecord, appendUsageRecord } from '../core/usage-log.js';
|
|
24
|
+
import { publishDshUsage } from '../core/dsh-compat/llm-usage-event.js';
|
|
25
|
+
import { createDshSessionEventBridge } from '../core/dsh-compat/session-events.js';
|
|
24
26
|
import { clearReadLedger } from '../core/path-policy.js';
|
|
25
27
|
import { errText } from '../adapter/transcript.js';
|
|
26
28
|
/**
|
|
@@ -36,6 +38,11 @@ function noteSystemPrompt(session, text) {
|
|
|
36
38
|
return;
|
|
37
39
|
session.appendState('system-prompt', { hash, text });
|
|
38
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* 切走之后最多留几个空闲会话(见 {@link rememberIdle})。
|
|
43
|
+
* 3 够覆盖「在最近三条之间来回跳」,再多只是白占内存。
|
|
44
|
+
*/
|
|
45
|
+
const IDLE_KEEP = 3;
|
|
39
46
|
export const agentPlugin = {
|
|
40
47
|
name: 'agent',
|
|
41
48
|
inject: ['session', 'transcript', 'tools', 'llm', 'compact', 'prompt', 'guards'],
|
|
@@ -43,6 +50,8 @@ export const agentPlugin = {
|
|
|
43
50
|
apply(ctx) {
|
|
44
51
|
/** 常驻注册表:会话 id(meta.id)→ agent。含当前查看的那个。 */
|
|
45
52
|
const agents = new Map();
|
|
53
|
+
/** 切走但还留着的空闲会话(按「最近切走的」排在后面),上限见 {@link IDLE_KEEP}。 */
|
|
54
|
+
const idleOrder = [];
|
|
46
55
|
/** 收摊 agent 的墓碑:id → jsonl 路径。非常驻投递(followup 带 id)靠它找文件。 */
|
|
47
56
|
const tombstones = new Map();
|
|
48
57
|
/** 当前查看的 agent。不变量:它的会话就是 ctx.session.current() 那个对象。 */
|
|
@@ -54,27 +63,46 @@ export const agentPlugin = {
|
|
|
54
63
|
const makeAgent = (session) => {
|
|
55
64
|
/** 工具名按 callId 记着:`tool/result` 事件只带 callId,工具行要写工具名。 */
|
|
56
65
|
const toolNames = new Map();
|
|
66
|
+
// dsh 插件的广播面:一个会话一座桥,把回合过程按 dsh 的 session/event 形状播出去
|
|
67
|
+
// (为什么要有它、以及哪些不发,见 core/dsh-compat/session-events 的头注释)。
|
|
68
|
+
const dshEvents = createDshSessionEventBridge({
|
|
69
|
+
ctx,
|
|
70
|
+
sessionId: session.meta.id,
|
|
71
|
+
cwd: session.meta.cwd,
|
|
72
|
+
createdAt: session.meta.createdAt,
|
|
73
|
+
route: () => ({ provider: ctx.llm.providerOf(session), model: ctx.llm.modelOf(session) }),
|
|
74
|
+
});
|
|
57
75
|
return new MiniAgent({
|
|
58
|
-
|
|
76
|
+
// 这个 agent 自己的模型/档位(后台会话不拿「用户正在看」的那一份)
|
|
77
|
+
route: () => ctx.llm.routeForSession(session),
|
|
59
78
|
// 系统提示每次请求重拼:切模式、改 AGENTS.md、换模型都不用重启。
|
|
60
79
|
// 拼好的这份同时落进自己会话的 system-prompt 状态条目(hash 去重)。
|
|
61
80
|
systemPrompt: () => {
|
|
62
|
-
|
|
81
|
+
// 带上「这个 agent 的会话」:模式那段话与段的取舍都按它算。不带的话,
|
|
82
|
+
// 后台会话的提示词会跟着「你此刻点开的会话」变(0.6.48 多 agent 的坑)。
|
|
83
|
+
const text = ctx.prompt.systemPrompt(session.meta.cwd, {
|
|
84
|
+
sessionId: session.meta.id,
|
|
85
|
+
cwd: session.meta.cwd,
|
|
86
|
+
});
|
|
63
87
|
noteSystemPrompt(session, text);
|
|
64
88
|
return text;
|
|
65
89
|
},
|
|
66
90
|
// 模型面前那份目录走 visible():模式(预设)在这里做减法,极简档因此只看到 bash。
|
|
67
91
|
// 队友不走这条路——它们按自己的工牌从全量注册表里挑(见 plugins/subagent.ts)。
|
|
68
|
-
|
|
92
|
+
// 同样带会话:模式白名单按**这个 agent 的**档算(见 plugins/presets.ts 的 bySession)
|
|
93
|
+
tools: () => ctx.tools.visible({ sessionId: session.meta.id }),
|
|
69
94
|
guards: ctx.guards,
|
|
70
95
|
emit: (event) => {
|
|
96
|
+
// 先把这条内核事件翻译成 dsh 的 session/event 广播出去(旁路,内部吞错):
|
|
97
|
+
// 订阅它的插件才能看见「正在跑的这一轮」,而不是只有磁盘上的历史。
|
|
98
|
+
dshEvents.publish(event);
|
|
71
99
|
// 用量按发起回合的会话记账落一条到 ~/.dsc/usage/usage.jsonl;落盘失败
|
|
72
100
|
// 已被 appendUsageRecord 自己吞掉,不能影响对话轮次。这一步的墙钟读数
|
|
73
101
|
// (lm/ft/d)同一条出账:界面按整个会话累计算输出速度与首字延迟。
|
|
74
102
|
if (event.type === 'usage') {
|
|
75
103
|
appendUsageRecord({
|
|
76
|
-
provider: ctx.llm.
|
|
77
|
-
model: ctx.llm.
|
|
104
|
+
provider: ctx.llm.providerOf(session),
|
|
105
|
+
model: ctx.llm.modelOf(session),
|
|
78
106
|
i: event.inputTokens,
|
|
79
107
|
o: event.outputTokens,
|
|
80
108
|
...(event.cacheHitTokens === undefined ? {} : { ch: event.cacheHitTokens }),
|
|
@@ -84,6 +112,18 @@ export const agentPlugin = {
|
|
|
84
112
|
...(event.ttftMs === undefined ? {} : { ft: event.ttftMs }),
|
|
85
113
|
...(event.decodeMs === undefined ? {} : { d: event.decodeMs }),
|
|
86
114
|
});
|
|
115
|
+
// dsh 的计费插件(cost-meter 这类)不听用量日志,而是在 `llm/stream`
|
|
116
|
+
// 这个 waterfall 事件上包一层流读 usage chunk。这里把同一次调用的用量
|
|
117
|
+
// 作为旁路事件发出去——发不发得出去都不影响回合(内部吞错)。
|
|
118
|
+
void publishDshUsage(ctx, {
|
|
119
|
+
sessionId: session.meta.id,
|
|
120
|
+
provider: ctx.llm.providerOf(session),
|
|
121
|
+
model: ctx.llm.modelOf(session),
|
|
122
|
+
inputTokens: event.inputTokens,
|
|
123
|
+
outputTokens: event.outputTokens,
|
|
124
|
+
...(event.cacheHitTokens === undefined ? {} : { cacheHitTokens: event.cacheHitTokens }),
|
|
125
|
+
...(event.cacheMissTokens === undefined ? {} : { cacheMissTokens: event.cacheMissTokens }),
|
|
126
|
+
});
|
|
87
127
|
}
|
|
88
128
|
// 工具调用也记一条(第二种行):界面读同一个文件算「工具耗时」。
|
|
89
129
|
// 没带 ms 的(打断时补的合成结果)不记——没有起点就没有耗时。
|
|
@@ -106,12 +146,16 @@ export const agentPlugin = {
|
|
|
106
146
|
// 只有当前查看 agent 的事件进转录:后台 agent 的流式增量与工具卡留在
|
|
107
147
|
// 各自会话的 jsonl 里,切回去时由转录插件按日志重放。这正是「切走不打断」
|
|
108
148
|
// 的显示面——旧模型里中止轮的残留事件污染新会话视图,这里从源头掐掉。
|
|
109
|
-
|
|
110
|
-
|
|
149
|
+
// 归属也交给转录层兜一道(0.6.68):这里判一次「当前是不是我」,转录层再按
|
|
150
|
+
// 会话 id 判一次——两道都过才写,防的是以后有人绕过这道 if 直接写卡片。
|
|
151
|
+
if (active !== null && active.sessionId === session.meta.id) {
|
|
152
|
+
ctx.transcript.emit(event, session.meta.id);
|
|
153
|
+
}
|
|
111
154
|
},
|
|
112
155
|
// 不阻断的运行时提醒(当前:请求 invariant 失配)。接成 dsc/notice,
|
|
113
156
|
// 由 transcript 折成一条 system 条目;不打断请求,只让用户知道有这回事。
|
|
114
|
-
|
|
157
|
+
// 带上会话归属:后台会话的提醒不该写进用户正在看的那个视图(0.6.68)。
|
|
158
|
+
notice: (text) => ctx.emit('dsc/notice', text, undefined, session.filePath),
|
|
115
159
|
// 压缩的取消信号跟着回合走(T41):用户打断时压到一半的模型调用跟着停;
|
|
116
160
|
// 压缩目标永远是这个 agent 自己的会话(0.6.48 起显式传入)。
|
|
117
161
|
beforeRequest: (signal) => ctx.compact.check(signal, session),
|
|
@@ -122,27 +166,55 @@ export const agentPlugin = {
|
|
|
122
166
|
stream: (api, request, handlers) => ctx.llm.stream(api, request, handlers),
|
|
123
167
|
// 完全闲下来又不是当前查看的:就地收摊(释放写租约与内存)。正被查看的
|
|
124
168
|
// 留着——用户下一句话还得靠它。
|
|
169
|
+
//
|
|
170
|
+
// 收摊统一走 disposeAgent(2026-11-03):它同时清「空闲保留」名册(idleOrder),
|
|
171
|
+
// 这里要是自己删一遍,名册里就会留下已经收摊的 id。
|
|
125
172
|
onIdle: () => {
|
|
126
173
|
if (active !== null && active.sessionId === session.meta.id)
|
|
127
174
|
return;
|
|
128
175
|
const agent = agents.get(session.meta.id);
|
|
129
176
|
if (agent === undefined)
|
|
130
177
|
return;
|
|
131
|
-
|
|
132
|
-
tombstones.set(session.meta.id, session.filePath);
|
|
133
|
-
// 「先读过才许改」的台账跟着会话走,收摊时一起清,防长窗口无界增长
|
|
134
|
-
clearReadLedger(session.meta.id);
|
|
135
|
-
agent.dispose();
|
|
178
|
+
disposeAgent(agent);
|
|
136
179
|
},
|
|
137
180
|
}, session);
|
|
138
181
|
};
|
|
139
182
|
const disposeAgent = (agent) => {
|
|
140
183
|
agents.delete(agent.sessionId);
|
|
184
|
+
const idleAt = idleOrder.indexOf(agent.sessionId);
|
|
185
|
+
if (idleAt >= 0)
|
|
186
|
+
idleOrder.splice(idleAt, 1);
|
|
141
187
|
tombstones.set(agent.sessionId, agent.session.filePath);
|
|
142
188
|
// 「先读过才许改」的台账跟着会话走,收摊时一起清,防长窗口无界增长
|
|
143
189
|
clearReadLedger(agent.sessionId);
|
|
144
190
|
agent.dispose();
|
|
145
191
|
};
|
|
192
|
+
/**
|
|
193
|
+
* 切走之后**先不收摊**,把空闲 agent 留下几个(0.6.48 常驻多 agent 的延伸,2026-11-03)。
|
|
194
|
+
*
|
|
195
|
+
* 为什么:切会话的耗时里最大的一块是重新把整份 jsonl 读回来解析(实测 6.8MB 的会话
|
|
196
|
+
* 45–65ms,同步跑在宿主主线程上)。而人在几条会话之间来回跳是常态——刚切走又切回来,
|
|
197
|
+
* 那时磁盘上的文件一个字都没变,重读纯属白烧。留下最近几个,切回去直接命中
|
|
198
|
+
* `sessionFor`(`plugins/session.ts` 的 open 里那条短路),一次读盘都不用。
|
|
199
|
+
*
|
|
200
|
+
* 为什么是 3:配合 `IDLE_KEEP` 的数量,内存里最多三份已解析的历史(每份几 MB),
|
|
201
|
+
* 换来「来回跳」全部零加载;再多就只是白占内存。
|
|
202
|
+
*
|
|
203
|
+
* 与「常驻」不冲突:这里留下的都是**空闲**的(跑着的走上面 busy 那条分支,本来就不收摊),
|
|
204
|
+
* 也就是说不会有一轮在跑、却因为被人切走而被打断或错位。
|
|
205
|
+
*/
|
|
206
|
+
const rememberIdle = (sessionId) => {
|
|
207
|
+
const at = idleOrder.indexOf(sessionId);
|
|
208
|
+
if (at >= 0)
|
|
209
|
+
idleOrder.splice(at, 1);
|
|
210
|
+
idleOrder.push(sessionId);
|
|
211
|
+
while (idleOrder.length > IDLE_KEEP) {
|
|
212
|
+
const oldest = idleOrder.shift();
|
|
213
|
+
const agent = oldest === undefined ? undefined : agents.get(oldest);
|
|
214
|
+
if (agent !== undefined)
|
|
215
|
+
disposeAgent(agent);
|
|
216
|
+
}
|
|
217
|
+
};
|
|
146
218
|
// ---- 初始 agent:内核启动恢复/新建的那个会话 ----
|
|
147
219
|
active = makeAgent(ctx.session.current());
|
|
148
220
|
agents.set(active.sessionId, active);
|
|
@@ -153,6 +225,12 @@ export const agentPlugin = {
|
|
|
153
225
|
next = makeAgent(session);
|
|
154
226
|
agents.set(session.meta.id, next);
|
|
155
227
|
}
|
|
228
|
+
else {
|
|
229
|
+
// 又切回来了一条还留着的会话:把它从「空闲待收摊」里摘出来(它就是现在这条)。
|
|
230
|
+
const idleAt = idleOrder.indexOf(session.meta.id);
|
|
231
|
+
if (idleAt >= 0)
|
|
232
|
+
idleOrder.splice(idleAt, 1);
|
|
233
|
+
}
|
|
156
234
|
active = next;
|
|
157
235
|
if (prev !== null && prev !== next) {
|
|
158
236
|
if (prev.busy) {
|
|
@@ -169,7 +247,7 @@ export const agentPlugin = {
|
|
|
169
247
|
});
|
|
170
248
|
}
|
|
171
249
|
else {
|
|
172
|
-
|
|
250
|
+
rememberIdle(prev.sessionId);
|
|
173
251
|
}
|
|
174
252
|
}
|
|
175
253
|
});
|
|
@@ -179,7 +257,7 @@ export const agentPlugin = {
|
|
|
179
257
|
agents.clear();
|
|
180
258
|
});
|
|
181
259
|
/** 把一条输入写进没有常驻 agent 的休眠会话(等用户回去自己看到,不起回合)。 */
|
|
182
|
-
const deliverToDormant = (sessionId, text, images) => {
|
|
260
|
+
const deliverToDormant = (sessionId, text, images, files) => {
|
|
183
261
|
const path = tombstones.get(sessionId);
|
|
184
262
|
if (path === undefined) {
|
|
185
263
|
ctx.emit('dsc/notice', `一条通知没能投递:会话 ${sessionId.slice(0, 8)} 不在本窗口的名册里`);
|
|
@@ -187,7 +265,7 @@ export const agentPlugin = {
|
|
|
187
265
|
}
|
|
188
266
|
try {
|
|
189
267
|
const dormant = Session.load(path, true);
|
|
190
|
-
dormant.appendUser(text, images);
|
|
268
|
+
dormant.appendUser(text, images, files);
|
|
191
269
|
dormant.close();
|
|
192
270
|
}
|
|
193
271
|
catch (error) {
|
|
@@ -195,18 +273,18 @@ export const agentPlugin = {
|
|
|
195
273
|
}
|
|
196
274
|
};
|
|
197
275
|
const service = {
|
|
198
|
-
followup(text, images, sessionId, origin) {
|
|
276
|
+
followup(text, images, sessionId, origin, files) {
|
|
199
277
|
if (sessionId === undefined) {
|
|
200
278
|
if (active !== null)
|
|
201
|
-
active.followup(text, images, origin);
|
|
279
|
+
active.followup(text, images, origin, files);
|
|
202
280
|
return;
|
|
203
281
|
}
|
|
204
282
|
const agent = agents.get(sessionId);
|
|
205
283
|
if (agent !== undefined) {
|
|
206
|
-
agent.followup(text, images, origin);
|
|
284
|
+
agent.followup(text, images, origin, files);
|
|
207
285
|
return;
|
|
208
286
|
}
|
|
209
|
-
deliverToDormant(sessionId, text, images);
|
|
287
|
+
deliverToDormant(sessionId, text, images, files);
|
|
210
288
|
},
|
|
211
289
|
interrupt(filePath) {
|
|
212
290
|
if (filePath === undefined) {
|
|
@@ -237,6 +315,9 @@ export const agentPlugin = {
|
|
|
237
315
|
steerQueued(index) {
|
|
238
316
|
return active?.steerQueued(index) ?? false;
|
|
239
317
|
},
|
|
318
|
+
sessionById(sessionId) {
|
|
319
|
+
return agents.get(sessionId)?.session;
|
|
320
|
+
},
|
|
240
321
|
sessionFor(filePath) {
|
|
241
322
|
for (const agent of agents.values()) {
|
|
242
323
|
if (agent.session.filePath === filePath)
|
|
@@ -2,6 +2,7 @@ import { createApprovalFloor, FLOOR_CONFIG_KEY, FLOOR_LIMITS, parseGlobListText,
|
|
|
2
2
|
import { activeRules } from '../core/command-policy.js';
|
|
3
3
|
import { resolvePluginConfig, writePluginConfig } from '../core/plugin-registry.js';
|
|
4
4
|
import { dscPath } from '../core/path-policy.js';
|
|
5
|
+
import { readShellChoice, shellFlavor } from '../core/terminal-env.js';
|
|
5
6
|
/** 配置与设置提示里要写清的来源文件(手改它同样生效)。 */
|
|
6
7
|
const PLUGINS_FILE = dscPath('plugins.json');
|
|
7
8
|
/** 前缀清单的多行文本形式(设置页那个框读写的就是它)。 */
|
|
@@ -25,6 +26,9 @@ export const approvalFloorPlugin = {
|
|
|
25
26
|
const floor = createApprovalFloor({
|
|
26
27
|
readConfig,
|
|
27
28
|
rules: () => activeRules(),
|
|
29
|
+
// 结构扫描按**实际执行命令的终端**判(2026-10-30 默认终端可切换):
|
|
30
|
+
// 选了 Git Bash / WSL 就按 POSIX 规则看引号与转义,不能继续套 PowerShell 那套。
|
|
31
|
+
shell: () => shellFlavor(readShellChoice()),
|
|
28
32
|
});
|
|
29
33
|
const offGuard = ctx.guards.register(floor.guard);
|
|
30
34
|
// 白名单的结论交给审批层执行:地板不自己 pass,因此排在中间的钩子照常被问到。
|
|
@@ -39,7 +43,7 @@ export const approvalFloorPlugin = {
|
|
|
39
43
|
const { config, problems } = readConfig();
|
|
40
44
|
const breaker = floor.breaker();
|
|
41
45
|
const lines = [];
|
|
42
|
-
lines.push('
|
|
46
|
+
lines.push('危险命令硬拦截:守卫链 order 5(先于模式 10、安全钩子 20、审批 30)');
|
|
43
47
|
lines.push(`白名单(命中由审批层免卡放行,共 ${config.allowPrefixes.length} 条):`);
|
|
44
48
|
for (const pattern of config.allowPrefixes)
|
|
45
49
|
lines.push(` ${pattern.join(' ')}`);
|
|
@@ -58,14 +62,14 @@ export const approvalFloorPlugin = {
|
|
|
58
62
|
}
|
|
59
63
|
return lines.join('\n');
|
|
60
64
|
};
|
|
61
|
-
const offCommand = ctx.commands.register({ name: 'floor', args: '', description: '
|
|
65
|
+
const offCommand = ctx.commands.register({ name: 'floor', args: '', description: '看危险命令硬拦截的规则、白名单与熔断状态' }, ({ ui }) => {
|
|
62
66
|
ui.notice(describe());
|
|
63
67
|
});
|
|
64
68
|
// ── 设置分区 ──────────────────────────────────────────────────────────────
|
|
65
69
|
const section = {
|
|
66
70
|
id: FLOOR_CONFIG_KEY,
|
|
67
|
-
title: '
|
|
68
|
-
subtitle: '
|
|
71
|
+
title: '危险命令硬拦截',
|
|
72
|
+
subtitle: '比权限模式和审批卡都早一步的硬拦截:危险命令、黑名单、无人值守',
|
|
69
73
|
order: 33,
|
|
70
74
|
fields() {
|
|
71
75
|
const { config, problems } = readConfig();
|
|
@@ -86,15 +90,15 @@ export const approvalFloorPlugin = {
|
|
|
86
90
|
label: '命令白名单(一行一条,逗号也行)',
|
|
87
91
|
placeholder: 'pnpm run build',
|
|
88
92
|
mono: true,
|
|
89
|
-
help: '
|
|
93
|
+
help: '命中就不弹审批卡。按空格切词、从头逐词比,`*` 只能放末尾。命令里有管道、分号、子 shell、变量、重定向、引号时一律不走白名单。',
|
|
90
94
|
},
|
|
91
95
|
{
|
|
92
96
|
type: 'text',
|
|
93
97
|
key: 'denyGlobs',
|
|
94
|
-
label: '
|
|
98
|
+
label: '命令黑名单(一行一条,通配符)',
|
|
95
99
|
placeholder: '*etc/passwd*',
|
|
96
100
|
mono: true,
|
|
97
|
-
help: '
|
|
101
|
+
help: '出现在命令的参数词或写目标路径里就拒,先于「完全访问」生效。`*` 配任意字符,`?` 配一个字符。',
|
|
98
102
|
},
|
|
99
103
|
{
|
|
100
104
|
type: 'number',
|
|
@@ -210,7 +214,7 @@ export const approvalFloorPlugin = {
|
|
|
210
214
|
// 配置坏掉时说一次:地板会一律拒,用户得知道去改哪儿。
|
|
211
215
|
const problems = readConfig().problems;
|
|
212
216
|
if (problems.length > 0) {
|
|
213
|
-
ctx.emit('dsc/notice',
|
|
217
|
+
ctx.emit('dsc/notice', `危险命令硬拦截配置有问题,现在一律拒:${problems.join(';')}(改 ${FLOOR_CONFIG_KEY} 的配置后立刻恢复)`);
|
|
214
218
|
}
|
|
215
219
|
// 注册一律返回清理函数,这里把四份合成一份。
|
|
216
220
|
return () => {
|