@waq666/pneuma 0.7.1 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +242 -206
- package/bin/dsc.js +9 -3
- package/bin/headless.cjs +1 -1
- package/lib/adapter/transcript.d.ts +19 -2
- package/lib/adapter/transcript.js +71 -14
- package/lib/app/AgentsOverlay.js +7 -6
- package/lib/app/App.js +1 -1
- package/lib/app/ApprovalCard.js +15 -9
- package/lib/app/ChatView.d.ts +3 -1
- package/lib/app/ChatView.js +21 -17
- package/lib/app/Composer.js +22 -4
- package/lib/app/MarkdownView.js +2 -1
- package/lib/app/ModelPicker.js +7 -6
- package/lib/app/PickerFrame.d.ts +4 -0
- package/lib/app/PickerFrame.js +18 -0
- package/lib/app/PlanReviewCard.js +2 -1
- package/lib/app/PresetPicker.js +8 -7
- package/lib/app/SessionPicker.js +21 -20
- package/lib/app/SettingsOverlay.js +1 -1
- package/lib/app/SkillsPicker.js +7 -6
- package/lib/app/StatusBar.js +3 -15
- package/lib/app/TaskStrips.js +1 -4
- package/lib/app/TimelineRail.js +2 -1
- package/lib/app/ToolCard.js +2 -6
- package/lib/app/Welcome.d.ts +1 -0
- package/lib/app/Welcome.js +1 -4
- package/lib/app/click.d.ts +0 -2
- package/lib/app/click.js +2 -21
- package/lib/app/display-width.d.ts +16 -0
- package/lib/app/display-width.js +33 -0
- package/lib/app/markdown.d.ts +1 -3
- package/lib/app/markdown.js +2 -19
- package/lib/app/scroll-model.js +1 -1
- package/lib/contract/approval.d.ts +91 -0
- package/lib/contract/approval.js +1 -0
- package/lib/contract/mode.d.ts +69 -0
- package/lib/contract/mode.js +1 -0
- package/lib/contract/plugin.d.ts +240 -0
- package/lib/contract/plugin.js +1 -0
- package/lib/contract/runtime.d.ts +282 -0
- package/lib/contract/runtime.js +1 -0
- package/lib/contract/session.d.ts +208 -0
- package/lib/contract/session.js +36 -0
- package/lib/contract/settings.d.ts +242 -0
- package/lib/contract/settings.js +1 -0
- package/lib/contract/snapshot.d.ts +453 -0
- package/lib/contract/snapshot.js +1 -0
- package/lib/contract/task.d.ts +189 -0
- package/lib/contract/task.js +10 -0
- package/lib/contract/transcript.d.ts +358 -0
- package/lib/contract/transcript.js +1 -0
- package/lib/contract/usage.d.ts +132 -0
- package/lib/contract/usage.js +10 -0
- package/lib/contract.d.ts +20 -1968
- package/lib/contract.js +19 -30
- package/lib/core/agent-roles.d.ts +1 -1
- package/lib/core/agent-roles.js +6 -5
- package/lib/core/approval-floor.d.ts +9 -0
- package/lib/core/approval-floor.js +152 -25
- package/lib/core/attachments.d.ts +185 -0
- package/lib/core/attachments.js +425 -0
- package/lib/core/bytes.d.ts +14 -0
- package/lib/core/bytes.js +28 -0
- package/lib/core/call-meaning.d.ts +20 -0
- package/lib/core/call-meaning.js +347 -0
- package/lib/core/cdp/actions.js +6 -0
- package/lib/core/cdp/launch.js +2 -2
- package/lib/core/cdp/report.d.ts +27 -0
- package/lib/core/cdp/report.js +50 -0
- package/lib/core/cdp/ring-buffer.d.ts +25 -0
- package/lib/core/cdp/ring-buffer.js +44 -0
- package/lib/core/cdp/snapshot.js +5 -9
- package/lib/core/cdp/transport.js +1 -1
- package/lib/core/clamp.d.ts +20 -0
- package/lib/core/clamp.js +24 -0
- package/lib/core/clock.d.ts +16 -0
- package/lib/core/clock.js +20 -0
- package/lib/core/command-policy.js +33 -1
- package/lib/core/commands-completion.d.ts +28 -0
- package/lib/core/commands-completion.js +108 -30
- package/lib/core/compact.d.ts +36 -6
- package/lib/core/compact.js +89 -17
- package/lib/core/desktop-control.js +1 -3
- package/lib/core/dsh-compat/llm-usage-event.d.ts +78 -0
- package/lib/core/dsh-compat/llm-usage-event.js +91 -0
- package/lib/core/dsh-compat/presentation.d.ts +84 -0
- package/lib/core/dsh-compat/presentation.js +105 -0
- package/lib/core/dsh-compat/resolve-hook.d.ts +3 -3
- package/lib/core/dsh-compat/resolve-hook.js +41 -13
- package/lib/core/dsh-compat/service-map.d.ts +52 -0
- package/lib/core/dsh-compat/service-map.js +87 -0
- package/lib/core/dsh-compat/session-bridge.d.ts +107 -0
- package/lib/core/dsh-compat/session-bridge.js +376 -0
- package/lib/core/dsh-compat/session-events.d.ts +54 -0
- package/lib/core/dsh-compat/session-events.js +297 -0
- package/lib/core/dsh-compat/shims/credentials.d.ts +62 -0
- package/lib/core/dsh-compat/shims/credentials.js +86 -0
- package/lib/core/dsh-compat/shims/home-paths.d.ts +77 -0
- package/lib/core/dsh-compat/shims/home-paths.js +143 -0
- package/lib/core/dsh-compat/tools-facade.d.ts +31 -1
- package/lib/core/dsh-compat/tools-facade.js +207 -3
- package/lib/core/err-text.d.ts +5 -0
- package/lib/core/err-text.js +5 -0
- package/lib/core/events.d.ts +31 -2
- package/lib/core/git-info.d.ts +127 -15
- package/lib/core/git-info.js +315 -34
- package/lib/core/git-surface.d.ts +17 -0
- package/lib/core/git-surface.js +7 -0
- package/lib/core/hooks.d.ts +19 -2
- package/lib/core/hooks.js +57 -13
- package/lib/core/host-methods.d.ts +1 -1
- package/lib/core/host-methods.js +4 -0
- package/lib/core/image-diet.js +1 -4
- package/lib/core/json-text.d.ts +11 -0
- package/lib/core/json-text.js +18 -0
- package/lib/core/learnings/skill-write.d.ts +1 -7
- package/lib/core/learnings/skill-write.js +3 -37
- package/lib/core/lifecycle-hooks.d.ts +11 -3
- package/lib/core/lifecycle-hooks.js +33 -42
- package/lib/core/llm.d.ts +42 -0
- package/lib/core/llm.js +40 -25
- package/lib/core/loop.d.ts +11 -1
- package/lib/core/loop.js +95 -28
- package/lib/core/lsp/client.js +30 -17
- package/lib/core/lsp/normalize.d.ts +0 -2
- package/lib/core/lsp/normalize.js +1 -6
- package/lib/core/lsp/servers.js +1 -4
- package/lib/core/mcp.d.ts +18 -0
- package/lib/core/mcp.js +60 -16
- package/lib/core/microcompact.d.ts +45 -0
- package/lib/core/microcompact.js +128 -0
- package/lib/core/native-bridge.js +2 -10
- package/lib/core/path-policy.d.ts +13 -1
- package/lib/core/path-policy.js +87 -18
- package/lib/core/permission-presets.d.ts +9 -5
- package/lib/core/permission-presets.js +14 -7
- package/lib/core/permission-scope.d.ts +65 -0
- package/lib/core/permission-scope.js +109 -0
- package/lib/core/plugin-bundle.d.ts +95 -0
- package/lib/core/plugin-bundle.js +137 -0
- package/lib/core/plugin-loader.d.ts +36 -1
- package/lib/core/plugin-loader.js +336 -12
- package/lib/core/plugin-patch.d.ts +64 -0
- package/lib/core/plugin-patch.js +146 -0
- package/lib/core/plugin-registry.d.ts +14 -0
- package/lib/core/plugin-registry.js +2 -0
- package/lib/core/prefs.js +40 -2
- package/lib/core/presets.d.ts +11 -0
- package/lib/core/presets.js +61 -22
- package/lib/core/profile-dir.d.ts +5 -0
- package/lib/core/profile-dir.js +40 -0
- package/lib/core/prompt.js +55 -19
- package/lib/core/ptc.d.ts +8 -2
- package/lib/core/ptc.js +18 -4
- package/lib/core/records.d.ts +16 -0
- package/lib/core/records.js +22 -0
- package/lib/core/remote/notify.js +1 -3
- package/lib/core/remote/push.js +2 -6
- package/lib/core/sandbox/execpolicy.js +27 -3
- package/lib/core/sandbox/net-proxy.js +2 -2
- package/lib/core/sandbox/policy.d.ts +1 -1
- package/lib/core/sandbox/policy.js +21 -15
- package/lib/core/sandbox/win/account.js +1 -4
- package/lib/core/sandbox/win/acl.js +1 -6
- package/lib/core/sandbox/win/backend.d.ts +24 -3
- package/lib/core/sandbox/win/backend.js +73 -23
- package/lib/core/sandbox/win/doctor.js +1 -4
- package/lib/core/sandbox/win/runner-entry.js +1 -6
- package/lib/core/sandbox/win/setup.js +1 -4
- package/lib/core/sandbox/win/utf16.d.ts +11 -0
- package/lib/core/sandbox/win/utf16.js +15 -0
- package/lib/core/sandbox/win/wfp.js +1 -4
- package/lib/core/schedule/rule.d.ts +0 -17
- package/lib/core/schedule/rule.js +1 -3
- package/lib/core/schedule/runner.d.ts +5 -2
- package/lib/core/schedule/runner.js +32 -9
- package/lib/core/schedule/store.d.ts +0 -2
- package/lib/core/schedule/store.js +2 -9
- package/lib/core/session-index.d.ts +50 -0
- package/lib/core/session-index.js +169 -3
- package/lib/core/session.d.ts +89 -13
- package/lib/core/session.js +385 -32
- package/lib/core/shell-quote.d.ts +21 -0
- package/lib/core/shell-quote.js +24 -0
- package/lib/core/side-ask.d.ts +52 -0
- package/lib/core/side-ask.js +89 -0
- package/lib/core/skills.d.ts +16 -0
- package/lib/core/skills.js +45 -8
- package/lib/core/snapshot-throttle.d.ts +8 -0
- package/lib/core/snapshot-throttle.js +24 -0
- package/lib/core/spill.d.ts +11 -5
- package/lib/core/spill.js +35 -36
- package/lib/core/strings.d.ts +21 -0
- package/lib/core/strings.js +33 -0
- package/lib/core/terminal-env.d.ts +61 -0
- package/lib/core/terminal-env.js +327 -0
- package/lib/core/text-format.d.ts +17 -0
- package/lib/core/text-format.js +26 -0
- package/lib/core/todo-reminder.d.ts +19 -14
- package/lib/core/todo-reminder.js +14 -23
- package/lib/core/token-estimate.d.ts +18 -2
- package/lib/core/token-estimate.js +10 -2
- package/lib/core/tool-result-prune.d.ts +42 -0
- package/lib/core/tool-result-prune.js +47 -0
- package/lib/core/tool-search.d.ts +3 -2
- package/lib/core/tool-search.js +3 -2
- package/lib/core/tools/bash.d.ts +35 -3
- package/lib/core/tools/bash.js +168 -41
- package/lib/core/tools/fs-tools.js +18 -17
- package/lib/core/tools/image-tool.d.ts +2 -0
- package/lib/core/tools/image-tool.js +59 -0
- package/lib/core/tools/path-args.d.ts +4 -0
- package/lib/core/tools/path-args.js +22 -0
- package/lib/core/tools/search-tools.d.ts +30 -0
- package/lib/core/tools/search-tools.js +321 -34
- package/lib/core/tools.d.ts +82 -0
- package/lib/core/tools.js +21 -0
- package/lib/core/transcript-text.d.ts +19 -0
- package/lib/core/transcript-text.js +44 -0
- package/lib/core/ui-boot-source.d.ts +5 -0
- package/lib/core/ui-boot-source.js +10 -3
- package/lib/core/ui-bundles.d.ts +80 -6
- package/lib/core/ui-bundles.js +700 -76
- package/lib/core/ui-events.d.ts +10 -0
- package/lib/core/ui-events.js +25 -0
- package/lib/core/ui-methods.d.ts +1 -1
- package/lib/core/ui-methods.js +42 -13
- package/lib/core/ui-route.js +11 -7
- package/lib/core/ui-server.d.ts +6 -0
- package/lib/core/ui-server.js +106 -1
- package/lib/core/unified-diff.d.ts +35 -0
- package/lib/core/unified-diff.js +86 -0
- package/lib/core/usage-log.js +39 -0
- package/lib/core/web-http.d.ts +1 -1
- package/lib/core/web-http.js +1 -3
- package/lib/host/kernel.js +57 -41
- package/lib/plugins/agent.js +101 -20
- package/lib/plugins/approval-floor.js +12 -8
- package/lib/plugins/approval.js +252 -80
- package/lib/plugins/ask.js +60 -8
- package/lib/plugins/browser.js +32 -84
- package/lib/plugins/commands.js +167 -57
- package/lib/plugins/compact.d.ts +2 -2
- package/lib/plugins/compact.js +200 -30
- package/lib/plugins/computer-use.js +34 -18
- package/lib/plugins/dock-browser.js +24 -65
- package/lib/plugins/dsh-compat.js +7 -0
- package/lib/plugins/file-review.js +59 -15
- package/lib/plugins/git.js +16 -8
- package/lib/plugins/goal.js +9 -8
- package/lib/plugins/hooks.js +4 -2
- package/lib/plugins/host-stdio.js +14 -16
- package/lib/plugins/lifecycle-hooks.d.ts +5 -4
- package/lib/plugins/lifecycle-hooks.js +12 -10
- package/lib/plugins/llm.js +74 -33
- package/lib/plugins/lsp.js +22 -27
- package/lib/plugins/mcp.js +16 -17
- package/lib/plugins/memory.js +3 -24
- package/lib/plugins/microcompact.d.ts +4 -1
- package/lib/plugins/microcompact.js +117 -19
- package/lib/plugins/mode.js +30 -11
- package/lib/plugins/permission-presets.d.ts +2 -1
- package/lib/plugins/permission-presets.js +55 -35
- package/lib/plugins/plugin-manager.js +4 -6
- package/lib/plugins/presets.js +56 -27
- package/lib/plugins/prompt.js +54 -11
- package/lib/plugins/ptc.d.ts +13 -0
- package/lib/plugins/ptc.js +121 -24
- package/lib/plugins/remote/types.d.ts +1 -1
- package/lib/plugins/remote/types.js +11 -0
- package/lib/plugins/remote.js +14 -15
- package/lib/plugins/runtime.js +91 -14
- package/lib/plugins/sandbox.js +181 -60
- package/lib/plugins/schedule.js +12 -11
- package/lib/plugins/self-improve.js +28 -18
- package/lib/plugins/session-search.js +18 -13
- package/lib/plugins/session-title.js +1 -1
- package/lib/plugins/session.js +103 -25
- package/lib/plugins/settings.js +16 -40
- package/lib/plugins/skills.js +18 -1
- package/lib/plugins/spill.js +18 -11
- package/lib/plugins/subagent.js +208 -42
- package/lib/plugins/team.js +11 -5
- package/lib/plugins/todo.d.ts +1 -1
- package/lib/plugins/todo.js +25 -19
- package/lib/plugins/tool-search.js +47 -28
- package/lib/plugins/tools-default.js +89 -5
- package/lib/plugins/tools.js +3 -3
- package/lib/plugins/transcript.js +116 -9
- package/lib/plugins/web-search.d.ts +1 -1
- package/lib/plugins/web-search.js +25 -16
- package/lib/plugins/webserver.js +40 -7
- package/lib/remote/assets/app-B3Id1EBq.js +14 -0
- package/lib/remote/assets/index.html +2 -2
- package/lib/remote/assets/{style-DIB6729x.css → style-NtlpbKOI.css} +1 -1
- package/lib/services/types.d.ts +247 -29
- package/lib/tools/plugin-cli.d.ts +1 -0
- package/lib/tools/plugin-cli.js +209 -0
- package/lib/ui/assets/app-B-Jx5dnh.js +90 -0
- package/lib/ui/assets/{chunk-BajyYBss.js → chunk-Bfdlo8Me.js} +1 -1
- package/lib/ui/assets/chunk-DGX-i4eb.js +12 -0
- package/lib/ui/assets/index.html +62 -14
- package/lib/ui/assets/style-WzxwEPaE.css +1 -0
- package/lib/ui/frames.js +1 -3
- package/lib/ui/index.d.ts +30 -1
- package/lib/ui/index.js +29 -0
- package/lib/ui/manifest.d.ts +24 -6
- package/lib/ui/manifest.js +3 -2
- package/lib/ui/plugins/actions/bundle.json +8 -0
- package/lib/ui/plugins/actions/client.js +43 -0
- package/lib/ui/plugins/ask/bundle.json +8 -0
- package/lib/ui/plugins/ask/client.js +415 -0
- package/lib/ui/plugins/browser/bundle.json +8 -0
- package/lib/ui/plugins/composer/bundle.json +9 -0
- package/lib/ui/plugins/composer/client.js +1806 -1087
- package/lib/ui/plugins/files/bundle.json +8 -0
- package/lib/ui/plugins/files/client.js +13 -98
- package/lib/ui/plugins/manifest.json +1 -104
- package/lib/ui/plugins/palette/bundle.json +8 -0
- package/lib/ui/plugins/palette/client.js +360 -0
- package/lib/ui/plugins/plugins/bundle.json +8 -0
- package/lib/ui/plugins/plugins/client.js +116 -38
- package/lib/ui/plugins/preview/bundle.json +8 -0
- package/lib/ui/plugins/preview/client.js +6 -16
- package/lib/ui/plugins/prompt/bundle.json +8 -0
- package/lib/ui/plugins/prompt/client.js +81 -47
- package/lib/ui/plugins/sessions/bundle.json +8 -0
- package/lib/ui/plugins/sessions/client.js +157 -111
- package/lib/ui/plugins/settings/bundle.json +8 -0
- package/lib/ui/plugins/settings/client.js +184 -170
- package/lib/ui/plugins/skills/bundle.json +8 -0
- package/lib/ui/plugins/skills/client.js +161 -79
- package/lib/ui/plugins/status/bundle.json +8 -0
- package/lib/ui/plugins/status/client.js +165 -26
- package/lib/ui/plugins/statusbar/bundle.json +9 -0
- package/lib/ui/plugins/statusbar/client.js +100 -144
- package/lib/ui/plugins/tasks/bundle.json +8 -0
- package/lib/ui/plugins/team/bundle.json +8 -0
- package/lib/ui/plugins/team/client.js +60 -58
- package/lib/ui/plugins/terminal/bundle.json +8 -0
- package/lib/ui/plugins/terminal/client.js +1 -7
- package/lib/ui/plugins/trace/bundle.json +11 -0
- package/lib/ui/plugins/trace/client.js +86 -179
- package/lib/ui/plugins/transcript/bundle.json +8 -0
- package/lib/ui/plugins/transcript/client.js +1608 -1243
- package/lib/ui/sdk/@dsc/ui/index.d.ts +54 -16
- package/lib/ui/sdk/@dsc/ui/package.json +1 -1
- package/lib/ui/sdk/@dsc/ui-core/contract.d.ts +20 -1968
- package/lib/ui/sdk/@dsc/ui-core/core/attachments.d.ts +185 -0
- package/lib/ui/sdk/@dsc/ui-core/core/bytes.d.ts +14 -0
- package/lib/ui/sdk/@dsc/ui-core/core/err-text.d.ts +18 -0
- package/lib/ui/sdk/@dsc/ui-core/core/git-surface.d.ts +17 -0
- package/lib/ui/sdk/@dsc/ui-core/core/json-text.d.ts +11 -0
- package/lib/ui/sdk/@dsc/ui-core/core/path-policy.d.ts +44 -0
- package/lib/ui/sdk/@dsc/ui-core/core/records.d.ts +16 -0
- package/lib/ui/sdk/@dsc/ui-core/core/throughput.d.ts +46 -0
- package/lib/ui/sdk/@dsc/ui-core/core/token-estimate.d.ts +18 -2
- package/lib/ui/sdk/@dsc/ui-core/core/unified-diff.d.ts +35 -0
- package/lib/ui/sdk/@dsc/ui-core/package.json +1 -1
- package/lib/ui/sdk/@dsc/ui-core/ui/index.d.ts +30 -1
- package/lib/ui/sdk/@dsc/ui-core/ui/manifest.d.ts +24 -6
- package/lib/ui/sdk/@dsc/ui-core/ui/services.d.ts +19 -8
- package/lib/ui/sdk/@dsc/ui-core/ui/signal.d.ts +49 -0
- package/lib/ui/sdk/@dsc/ui-dockkit/dock-model.d.ts +17 -3
- package/lib/ui/sdk/@dsc/ui-dockkit/dock-state.d.ts +1 -1
- package/lib/ui/sdk/@dsc/ui-dockkit/package.json +1 -1
- package/lib/ui/sdk/@dsc/ui-layout/app.d.ts +4 -0
- package/lib/ui/sdk/@dsc/ui-layout/appearance.d.ts +6 -1
- package/lib/ui/sdk/@dsc/ui-layout/host-channel.d.ts +21 -0
- package/lib/ui/sdk/@dsc/ui-layout/index.d.ts +1 -0
- package/lib/ui/sdk/@dsc/ui-layout/package.json +1 -1
- package/lib/ui/sdk/@dsc/ui-layout/page-state.d.ts +1 -1
- package/lib/ui/sdk/@dsc/ui-layout/runtime-context.d.ts +10 -1
- package/lib/ui/sdk/@dsc/ui-layout/thread-view.d.ts +1 -1
- package/lib/ui/sdk/@dsc/ui-layout/usage-today.d.ts +11 -0
- package/lib/ui/sdk/@dsc/ui-primitives/dialog-focus.d.ts +30 -0
- package/lib/ui/sdk/@dsc/ui-primitives/error-text.d.ts +12 -0
- package/lib/ui/sdk/@dsc/ui-primitives/git-surface.d.ts +9 -0
- package/lib/ui/sdk/@dsc/ui-primitives/highlight.d.ts +23 -0
- package/lib/ui/sdk/@dsc/ui-primitives/humanize-error.d.ts +35 -0
- package/lib/ui/sdk/@dsc/ui-primitives/icons-workspace.d.ts +33 -0
- package/lib/ui/sdk/@dsc/ui-primitives/icons.d.ts +21 -3
- package/lib/ui/sdk/@dsc/ui-primitives/image-lightbox.d.ts +21 -0
- package/lib/ui/sdk/@dsc/ui-primitives/index.d.ts +16 -0
- package/lib/ui/sdk/@dsc/ui-primitives/markdown.d.ts +10 -14
- package/lib/ui/sdk/@dsc/ui-primitives/package.json +1 -1
- package/lib/ui/sdk/@dsc/ui-primitives/panels.d.ts +31 -8
- package/lib/ui/sdk/@dsc/ui-primitives/paths.d.ts +2 -0
- package/lib/ui/sdk/@dsc/ui-primitives/review-findings-card.d.ts +25 -0
- package/lib/ui/sdk/@dsc/ui-primitives/review-findings.d.ts +64 -0
- package/lib/ui/sdk/@dsc/ui-primitives/review-notice-card.d.ts +27 -0
- package/lib/ui/sdk/@dsc/ui-primitives/review-notice.d.ts +80 -0
- package/lib/ui/sdk/@dsc/ui-primitives/signal.d.ts +9 -0
- package/lib/ui/sdk/@dsc/ui-primitives/sizes.d.ts +15 -0
- package/lib/ui/sdk/@dsc/ui-primitives/skeleton.d.ts +39 -0
- package/lib/ui/sdk/@dsc/ui-primitives/snapshot.d.ts +46 -0
- package/lib/ui/sdk/@dsc/ui-primitives/thread-resizer.d.ts +3 -3
- package/lib/ui/sdk/@dsc/ui-primitives/throughput.d.ts +13 -0
- package/lib/ui/sdk/@dsc/ui-primitives/tokens.d.ts +9 -0
- package/lib/ui/sdk/@dsc/ui-primitives/tool-args.d.ts +1 -1
- package/lib/ui/sdk/@dsc/ui-primitives/tool-summary.d.ts +30 -6
- package/lib/ui/sdk/@dsc/ui-primitives/unified-diff.d.ts +10 -0
- package/lib/ui/sdk/@dsc/ui-renderer/boot.d.ts +10 -1
- package/lib/ui/sdk/@dsc/ui-renderer/cordis-host.d.ts +113 -0
- package/lib/ui/sdk/@dsc/ui-renderer/package.json +1 -1
- package/lib/ui/sdk/@dsc/ui-slots/package.json +1 -1
- package/lib/ui/services.d.ts +19 -8
- package/lib/ui/services.js +20 -12
- package/lib/ui/signal.d.ts +49 -0
- package/lib/ui/signal.js +57 -0
- package/lib/ui/tui-plugins.js +36 -16
- package/package.json +71 -58
- package/lib/remote/assets/app-DAcUCOEn.js +0 -14
- package/lib/ui/assets/app-B70nVIKd.js +0 -69
- package/lib/ui/assets/chunk-BGcgwlCI.js +0 -12
- package/lib/ui/assets/style-Bq01xH_b.css +0 -1
package/lib/plugins/lsp.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { clampInt as clamp } from '../core/clamp.js';
|
|
3
|
+
import { errText as errorText } from '../core/err-text.js';
|
|
2
4
|
import { wrapUntrusted } from '../core/untrusted.js';
|
|
3
5
|
import { resolvePluginConfig, writePluginConfig } from '../core/plugin-registry.js';
|
|
4
6
|
import { LSP_OPERATIONS, } from '../core/lsp/client.js';
|
|
@@ -59,10 +61,10 @@ export const lspPlugin = {
|
|
|
59
61
|
// 合法命令解析错,还会报出「PATH 里找不到」这种看着像环境问题的假故障)。
|
|
60
62
|
baseCwd: () => sessionCwd(),
|
|
61
63
|
});
|
|
62
|
-
/**
|
|
64
|
+
/** 最近一次写操作留的底(观察者只能从这里知道写的是哪个文件与会话)。 */
|
|
63
65
|
let lastWrite;
|
|
64
|
-
/**
|
|
65
|
-
|
|
66
|
+
/** 按会话攒着、等该会话下一次请求补进去的诊断块(不能串到别的会话)。 */
|
|
67
|
+
const pendingDiagnostics = new Map();
|
|
66
68
|
// ── 注册与退订 ──────────────────────────────────────────────────────────
|
|
67
69
|
// 宿主退出时只发事件就退进程,不走 cordis 卸载:子进程得在这一步收掉,
|
|
68
70
|
// 否则每退一次 dsc 就留一群语言服务器在后台(照 plugins/mcp.ts:151-155 的理由)。
|
|
@@ -78,18 +80,19 @@ export const lspPlugin = {
|
|
|
78
80
|
});
|
|
79
81
|
const offObserver = ctx.guards.registerObserver(buildObserver());
|
|
80
82
|
// 诊断不在会话日志里,塞进请求的同时必须落一条 note(Model-visible ⟺ logged):
|
|
81
|
-
//
|
|
82
|
-
const offProjection = ctx.prompt.registerProjection('lsp-write-diagnostics', (messages) => {
|
|
83
|
-
|
|
83
|
+
// 按请求所属会话取自己那份——后台会话的写诊断不能补进你正在看的会话。
|
|
84
|
+
const offProjection = ctx.prompt.registerProjection('lsp-write-diagnostics', (messages, session) => {
|
|
85
|
+
const target = session ?? ctx.session.current();
|
|
86
|
+
const blocks = pendingDiagnostics.get(target.meta.id);
|
|
87
|
+
if (blocks === undefined || blocks.length === 0)
|
|
84
88
|
return messages;
|
|
85
|
-
|
|
86
|
-
pendingDiagnostics = [];
|
|
89
|
+
pendingDiagnostics.delete(target.meta.id);
|
|
87
90
|
// 补在末尾、user 角色(2026-10-03):原先补 system 段会被 fold-system 并进头部那一条,
|
|
88
91
|
// 头部字节一变,服务端前缀缓存从变化点之后整段失效(下一次请求诊断消失、头部还原,
|
|
89
92
|
// 再失效一次)。user 角色只往历史尾巴追加,前缀原样命中缓存——codex 的
|
|
90
93
|
// environment_context、dsh 的运行时快照都是这个形状;点明出处防模型误认作用户发言。
|
|
91
94
|
const text = `【LSP 诊断】以下诊断由程序在刚才写入文件后自动附上(不是用户发言):\n\n${blocks.join('\n\n')}`;
|
|
92
|
-
|
|
95
|
+
target.appendNote('lsp-write-diagnostics', text);
|
|
93
96
|
return [...messages, { role: 'user', content: text }];
|
|
94
97
|
});
|
|
95
98
|
const offSection = ctx.settings.registerSection(buildSection());
|
|
@@ -174,7 +177,7 @@ export const lspPlugin = {
|
|
|
174
177
|
try {
|
|
175
178
|
const config = readConfig(passed);
|
|
176
179
|
if (!config.enabled) {
|
|
177
|
-
return degradation('
|
|
180
|
+
return degradation('代码跳转与报错关着(插件中心 → 代码跳转与报错 → 总开关)');
|
|
178
181
|
}
|
|
179
182
|
const operation = args.operation;
|
|
180
183
|
if (typeof operation !== 'string' || !isOperation(operation)) {
|
|
@@ -278,6 +281,7 @@ export const lspPlugin = {
|
|
|
278
281
|
lastWrite = {
|
|
279
282
|
path: target,
|
|
280
283
|
cwd: input.cwd,
|
|
284
|
+
sessionId: input.sessionId,
|
|
281
285
|
preText,
|
|
282
286
|
baseline: baseline.then((outcome) => ({
|
|
283
287
|
ok: outcome.ok,
|
|
@@ -339,9 +343,11 @@ export const lspPlugin = {
|
|
|
339
343
|
if (fresh.length === 0)
|
|
340
344
|
return;
|
|
341
345
|
const block = formatDiagnosticBlock(record.path, fresh, record.cwd);
|
|
342
|
-
pendingDiagnostics.
|
|
346
|
+
const list = pendingDiagnostics.get(record.sessionId) ?? [];
|
|
347
|
+
list.push(block);
|
|
348
|
+
pendingDiagnostics.set(record.sessionId, list);
|
|
343
349
|
ctx.transcript.system(`lsp:${displayPath(record.path, record.cwd)} 这次改动新引入 ${fresh.length} 条 ERROR` +
|
|
344
|
-
'(明细附在下一次请求里)');
|
|
350
|
+
'(明细附在下一次请求里)', undefined, false, record.sessionId);
|
|
345
351
|
}
|
|
346
352
|
/** 一个 `<diagnostics file=…>` 段:每行 `ERROR [行:列] 消息 [code] (source)`,字段全部转义 + 截断。 */
|
|
347
353
|
function formatDiagnosticBlock(filePath, diagnostics, cwd) {
|
|
@@ -383,7 +389,7 @@ export const lspPlugin = {
|
|
|
383
389
|
{
|
|
384
390
|
type: 'switch',
|
|
385
391
|
key: 'enabled',
|
|
386
|
-
label: '
|
|
392
|
+
label: '启用代码跳转与报错',
|
|
387
393
|
help: '关掉之后 lsp 工具只回一句说明,也不做编辑后诊断注入(不必停用整个插件)。',
|
|
388
394
|
},
|
|
389
395
|
{
|
|
@@ -400,7 +406,7 @@ export const lspPlugin = {
|
|
|
400
406
|
{
|
|
401
407
|
type: 'number',
|
|
402
408
|
key: 'idleSeconds',
|
|
403
|
-
label: '
|
|
409
|
+
label: '多久不用就关掉语言服务器(秒)',
|
|
404
410
|
min: IDLE_SECONDS_MIN,
|
|
405
411
|
max: IDLE_SECONDS_MAX,
|
|
406
412
|
step: 30,
|
|
@@ -427,8 +433,8 @@ export const lspPlugin = {
|
|
|
427
433
|
};
|
|
428
434
|
return {
|
|
429
435
|
id: CONFIG_KEY,
|
|
430
|
-
title: '
|
|
431
|
-
subtitle: '
|
|
436
|
+
title: '代码跳转与报错',
|
|
437
|
+
subtitle: '查定义、引用、实现与悬停;编辑后新出现的报错会提醒模型',
|
|
432
438
|
order: 33,
|
|
433
439
|
fields,
|
|
434
440
|
values: () => {
|
|
@@ -560,17 +566,6 @@ const LSP_PROMPT_TEXT = [
|
|
|
560
566
|
function isOperation(value) {
|
|
561
567
|
return LSP_OPERATIONS.includes(value);
|
|
562
568
|
}
|
|
563
|
-
/** 数字类配置的兜底:不是有限数就用缺省,否则夹进范围。 */
|
|
564
|
-
function clamp(value, min, max, fallback) {
|
|
565
|
-
const num = Number(value);
|
|
566
|
-
if (!Number.isFinite(num))
|
|
567
|
-
return fallback;
|
|
568
|
-
return Math.min(Math.max(Math.round(num), min), max);
|
|
569
|
-
}
|
|
570
|
-
/** 错误对象取一句话。 */
|
|
571
|
-
function errorText(error) {
|
|
572
|
-
return error instanceof Error ? error.message : String(error);
|
|
573
|
-
}
|
|
574
569
|
/** 读文件为文本;读不到(不存在 / 权限)给 undefined,由调用方跳过这一步。 */
|
|
575
570
|
function readText(filePath) {
|
|
576
571
|
try {
|
package/lib/plugins/mcp.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { asRisk, mcpToolName, openConnection, parseServerList, riskOf, } from '../core/mcp.js';
|
|
2
|
+
import { clampInt as clamp } from '../core/clamp.js';
|
|
3
|
+
import { errText as errorText } from '../core/err-text.js';
|
|
4
|
+
import { asRecord } from '../core/records.js';
|
|
2
5
|
import { resolvePluginConfig, writePluginConfig } from '../core/plugin-registry.js';
|
|
3
6
|
import { wrapUntrusted } from '../core/untrusted.js';
|
|
4
7
|
/** 插件在 `~/.dsc/plugins.json` 条目树里的键(设置分区 id 也是它)。 */
|
|
@@ -41,13 +44,6 @@ function readConfig(passed) {
|
|
|
41
44
|
reconnectMaxAttempts: clamp(raw.reconnectMaxAttempts, ATTEMPTS_MIN, ATTEMPTS_MAX, DEFAULTS.reconnectMaxAttempts),
|
|
42
45
|
};
|
|
43
46
|
}
|
|
44
|
-
/** 数字类配置的兜底:不是有限数就用缺省,否则夹进范围。 */
|
|
45
|
-
function clamp(value, min, max, fallback) {
|
|
46
|
-
const num = Number(value);
|
|
47
|
-
if (!Number.isFinite(num))
|
|
48
|
-
return fallback;
|
|
49
|
-
return Math.min(Math.max(Math.round(num), min), max);
|
|
50
|
-
}
|
|
51
47
|
/** 把 server 返回的工具定义起成目录项(完整名、风险等级都在这儿定)。 */
|
|
52
48
|
function toToolInfo(server, spec) {
|
|
53
49
|
return {
|
|
@@ -119,6 +115,13 @@ export const mcpPlugin = {
|
|
|
119
115
|
for (const state of states.values())
|
|
120
116
|
applyTools(state);
|
|
121
117
|
},
|
|
118
|
+
restoreSchemas: () => {
|
|
119
|
+
// 成对收口:Tool Search 停用/关开关时把动手类工具挂回台面。
|
|
120
|
+
// 重复调用同样是空操作(applyTools 会先 dropTools 再全量挂)。
|
|
121
|
+
deferred = false;
|
|
122
|
+
for (const state of states.values())
|
|
123
|
+
applyTools(state);
|
|
124
|
+
},
|
|
122
125
|
};
|
|
123
126
|
}
|
|
124
127
|
/**
|
|
@@ -419,7 +422,11 @@ export const mcpPlugin = {
|
|
|
419
422
|
}
|
|
420
423
|
}
|
|
421
424
|
catch (error) {
|
|
425
|
+
// 建连成功但握手后的 listTools 失败时,连接已经在 box 里:不关就是一条
|
|
426
|
+
// 活着的子进程 / HTTP 连接,重连还会再起一条,越积越多。
|
|
427
|
+
const opened = box.value;
|
|
422
428
|
box.value = undefined;
|
|
429
|
+
opened?.close();
|
|
423
430
|
markFailed(state, errorText(error));
|
|
424
431
|
}
|
|
425
432
|
}
|
|
@@ -588,8 +595,8 @@ export const mcpPlugin = {
|
|
|
588
595
|
];
|
|
589
596
|
return {
|
|
590
597
|
id: CONFIG_KEY,
|
|
591
|
-
title: 'MCP
|
|
592
|
-
subtitle: '
|
|
598
|
+
title: 'MCP 外部工具',
|
|
599
|
+
subtitle: '连接 MCP 服务器,把外部工具接进来给模型用',
|
|
593
600
|
order: 47,
|
|
594
601
|
fields,
|
|
595
602
|
values: () => {
|
|
@@ -661,13 +668,5 @@ export const mcpPlugin = {
|
|
|
661
668
|
}
|
|
662
669
|
},
|
|
663
670
|
};
|
|
664
|
-
/** 错误对象取一句话。 */
|
|
665
|
-
function errorText(error) {
|
|
666
|
-
return error instanceof Error ? error.message : String(error);
|
|
667
|
-
}
|
|
668
|
-
/** 认得出是个对象就返回,否则 null(模板参数等宽松入参的兜底)。 */
|
|
669
|
-
function asRecord(value) {
|
|
670
|
-
return value !== null && typeof value === 'object' && !Array.isArray(value) ? value : null;
|
|
671
|
-
}
|
|
672
671
|
/** T24:elicitation 等人点卡的上限(毫秒)——审批卡可以慢慢等,但不能永远挂着。 */
|
|
673
672
|
const ELICITATION_TIMEOUT_MS = 600_000;
|
package/lib/plugins/memory.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { errText } from '../adapter/transcript.js';
|
|
2
|
-
import {
|
|
2
|
+
import { lastAssistantText as lastAssistantMessageText, lastUserText as lastUserMessageText } from '../core/transcript-text.js';
|
|
3
3
|
import { resolvePluginConfig, writePluginConfig } from '../core/plugin-registry.js';
|
|
4
4
|
import { applyMemoryOperations, clearCell, DEFAULT_MEMORY_CONFIG, entryLabel, entryText, entryUsageKey, MEMORY_TARGETS, MEMORY_TYPES, memoryFileOf, pruneCells, readAllCells, bumpInjected, bumpUsage, readEval, readUsage, renderMemoryPrompt, TARGET_LABELS, usedChars, writeEval, } from '../core/memory.js';
|
|
5
5
|
import { evaluateMemory, formatMemoryReport, readingsOf } from '../core/memory-eval.js';
|
|
6
6
|
import { argsSummary } from '../core/tools.js';
|
|
7
|
+
import { clampInt as clamp } from '../core/clamp.js';
|
|
7
8
|
/** 配置键(`~/.dsc/plugins.json` 里 `file` 等于这个名字那一项的 `config`)。 */
|
|
8
9
|
const CONFIG_KEY = 'memory';
|
|
9
10
|
/** 一条记忆里一轮连续失败几次就本轮别再试了(额度满时模型会一条条撞,越撞越烧上下文)。 */
|
|
@@ -23,10 +24,6 @@ const CELL_OPTIONS = MEMORY_TARGETS.map((target) => ({ value: target, label: TAR
|
|
|
23
24
|
function readConfig() {
|
|
24
25
|
const raw = resolvePluginConfig(CONFIG_KEY, undefined);
|
|
25
26
|
const flag = (value, fallback) => (value === undefined ? fallback : value === true || value === 'true');
|
|
26
|
-
const clamp = (value, min, max, fallback) => {
|
|
27
|
-
const num = Number(value);
|
|
28
|
-
return Number.isFinite(num) ? Math.min(Math.max(Math.round(num), min), max) : fallback;
|
|
29
|
-
};
|
|
30
27
|
const limits = DEFAULT_MEMORY_CONFIG.limits;
|
|
31
28
|
return {
|
|
32
29
|
enabled: flag(raw.enabled, DEFAULT_MEMORY_CONFIG.enabled),
|
|
@@ -265,7 +262,7 @@ export const memoryPlugin = {
|
|
|
265
262
|
risk: 'write',
|
|
266
263
|
async run(args, scope) {
|
|
267
264
|
if (!config.enabled)
|
|
268
|
-
return '
|
|
265
|
+
return '长期记忆现在是关着的(插件中心 → 长期记忆 里可以打开)。';
|
|
269
266
|
if (failedWrites >= FAILED_WRITES_PER_TURN) {
|
|
270
267
|
return '这一轮已经连着几次写不进记忆了,先别再试:把你想记的东西直接写在回话里告诉用户,让他决定要不要腾额度。';
|
|
271
268
|
}
|
|
@@ -682,24 +679,6 @@ export const memoryPlugin = {
|
|
|
682
679
|
};
|
|
683
680
|
const offSection = ctx.settings.registerSection(section);
|
|
684
681
|
// ── 生命周期 ─────────────────────────────────────────────────────────────
|
|
685
|
-
/** 会话消息里最后一条用户消息的纯文本。 */
|
|
686
|
-
function lastUserMessageText(messages) {
|
|
687
|
-
for (let index = messages.length - 1; index >= 0; index -= 1) {
|
|
688
|
-
const message = messages[index];
|
|
689
|
-
if (message !== undefined && message.role === 'user')
|
|
690
|
-
return contentText(message.content).trim();
|
|
691
|
-
}
|
|
692
|
-
return '';
|
|
693
|
-
}
|
|
694
|
-
/** 会话消息里最后一条 assistant 消息的纯文本(隐式反馈的引用面)。 */
|
|
695
|
-
function lastAssistantMessageText(messages) {
|
|
696
|
-
for (let index = messages.length - 1; index >= 0; index -= 1) {
|
|
697
|
-
const message = messages[index];
|
|
698
|
-
if (message !== undefined && message.role === 'assistant')
|
|
699
|
-
return contentText(message.content).trim();
|
|
700
|
-
}
|
|
701
|
-
return '';
|
|
702
|
-
}
|
|
703
682
|
/**
|
|
704
683
|
* 本段有没有「≥3 词的独立用户文本块」(ZCode 的抽取跳过规则之一):
|
|
705
684
|
* 空白分词 ≥3,或中文字符 ≥3 都算;插件自己投递的复盘话术(`【…】` 开头)不算。
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* (算法与跳过规则见 core/microcompact.ts 的模块注释)。
|
|
4
4
|
*
|
|
5
5
|
* 为什么单列一条内置插件、而不塞进 prompt 插件:它是可配、可关的一层**策略**
|
|
6
|
-
* (keepRecent / minSaveTokens / enabled),跟内核那三条协议护栏(fold-system /
|
|
6
|
+
* (keepRecent / minSaveTokens / minFreePercent / enabled),跟内核那三条协议护栏(fold-system /
|
|
7
7
|
* env-facts / drop-images)不是一回事——护栏不许外部顶掉、也不可关。
|
|
8
8
|
*
|
|
9
9
|
* 注册进投影链时 order 取 650:在 env-facts(600)之后、drop-images(900)之前。
|
|
@@ -12,6 +12,9 @@
|
|
|
12
12
|
*
|
|
13
13
|
* 不改会话日志:日志原文不动,模型看见的是「原文 + 投影链」的结果,可复算。
|
|
14
14
|
*
|
|
15
|
+
* 另外对外提供 `microcompact` 服务(2026-11-02):压缩插件在爆窗重试前先用它算一眼
|
|
16
|
+
* 「清理之后还装不装得下」,装得下就不必牺牲历史去压摘要。
|
|
17
|
+
*
|
|
15
18
|
* @module dsc/plugins/microcompact
|
|
16
19
|
*/
|
|
17
20
|
import type { Plugin } from '@deepseek-ai/cordis';
|
|
@@ -1,32 +1,38 @@
|
|
|
1
|
-
import { DEFAULT_KEEP_RECENT_TOOL_RESULTS, DEFAULT_MIN_SAVE_TOKENS,
|
|
1
|
+
import { applyMicrocompactPlan, DEFAULT_KEEP_RECENT_TOOL_RESULTS, DEFAULT_MIN_SAVE_TOKENS, planMicrocompact, planWorthApplying, roundKeyOf, } from '../core/microcompact.js';
|
|
2
|
+
import { estimateTokens } from '../core/compact.js';
|
|
2
3
|
import { resolvePluginConfig, writePluginConfig } from '../core/plugin-registry.js';
|
|
4
|
+
import { clampInt as clamp } from '../core/clamp.js';
|
|
3
5
|
/** 配置键(`~/.dsc/plugins.json` 条目树里 `file` 等于这个名字那一项的 `config`)。 */
|
|
4
6
|
const CONFIG_KEY = 'microcompact';
|
|
5
7
|
/** 投影在链上的位置:env-facts(600) 之后、drop-images(900) 之前。 */
|
|
6
8
|
const PROJECTION_ORDER = 650;
|
|
9
|
+
/** 空计划:门槛没达到时用它占住 frozen,同一轮的后续请求就不再重算。 */
|
|
10
|
+
const EMPTY_PLAN = new Map();
|
|
7
11
|
const DEFAULTS = {
|
|
8
12
|
keepRecent: DEFAULT_KEEP_RECENT_TOOL_RESULTS,
|
|
9
13
|
minSaveTokens: DEFAULT_MIN_SAVE_TOKENS,
|
|
14
|
+
minFreePercent: 25,
|
|
10
15
|
enabled: true,
|
|
16
|
+
refresh: 'round',
|
|
11
17
|
};
|
|
12
|
-
/**
|
|
18
|
+
/** 三个可调值的区间:低于下限把最近的证据也清掉,高于上限基本清不出空间。 */
|
|
13
19
|
const KEEP_RECENT_RANGE = { min: 1, max: 50 };
|
|
14
20
|
const MIN_SAVE_RANGE = { min: 0, max: 4000 };
|
|
21
|
+
/** 上限 80:再高就等于要求几乎把整段提示词清空,正常会话不可能达到,等于关掉清理。 */
|
|
22
|
+
const MIN_FREE_RANGE = { min: 0, max: 80 };
|
|
15
23
|
/**
|
|
16
24
|
* 从插件配置取这些可调值,并把区间外的值夹回来。
|
|
17
25
|
* @param passed - 装配时传进来的配置(内核挂载时的第二参数);没给就读磁盘。
|
|
18
26
|
*/
|
|
19
27
|
function readConfig(passed) {
|
|
20
28
|
const raw = resolvePluginConfig(CONFIG_KEY, passed);
|
|
21
|
-
const clamp = (value, min, max, fallback) => {
|
|
22
|
-
const num = Number(value);
|
|
23
|
-
return Number.isFinite(num) ? Math.min(Math.max(Math.round(num), min), max) : fallback;
|
|
24
|
-
};
|
|
25
29
|
return {
|
|
26
30
|
// 少于 1 条等于把最近那一轮的现场证据也清掉(模型刚要接着用就没了)。
|
|
27
31
|
keepRecent: clamp(raw.keepRecent, KEEP_RECENT_RANGE.min, KEEP_RECENT_RANGE.max, DEFAULTS.keepRecent),
|
|
28
32
|
minSaveTokens: clamp(raw.minSaveTokens, MIN_SAVE_RANGE.min, MIN_SAVE_RANGE.max, DEFAULTS.minSaveTokens),
|
|
33
|
+
minFreePercent: clamp(raw.minFreePercent, MIN_FREE_RANGE.min, MIN_FREE_RANGE.max, DEFAULTS.minFreePercent),
|
|
29
34
|
enabled: raw.enabled === undefined ? DEFAULTS.enabled : raw.enabled === true || raw.enabled === 'true',
|
|
35
|
+
refresh: raw.refresh === 'request' ? 'request' : DEFAULTS.refresh,
|
|
30
36
|
};
|
|
31
37
|
}
|
|
32
38
|
export const microcompactPlugin = {
|
|
@@ -39,28 +45,94 @@ export const microcompactPlugin = {
|
|
|
39
45
|
writePluginConfig(CONFIG_KEY, patch);
|
|
40
46
|
config = readConfig(passed);
|
|
41
47
|
};
|
|
42
|
-
|
|
48
|
+
/**
|
|
49
|
+
* 每个会话冻结的那份清理计划(2026-10-28):一轮之内复用它,只有新一轮
|
|
50
|
+
* 或消息列表被压缩变短时才重算。投影签名现在带会话(内核 API 加了第二参),
|
|
51
|
+
* 后台会话因此拿自己的计划与自己的失败结果集合。
|
|
52
|
+
*/
|
|
53
|
+
const frozen = new Map();
|
|
54
|
+
const offProjection = ctx.prompt.registerProjection('microcompact', (messages, session) => {
|
|
43
55
|
if (!config.enabled)
|
|
44
56
|
return messages;
|
|
57
|
+
const owner = session ?? ctx.session.current();
|
|
45
58
|
// 失败/被拒的 tool_call_id 记在会话旁路(Session.toolErrors)、不在协议消息里。
|
|
46
|
-
|
|
47
|
-
// agent 下后台会话在跑、用户正看着另一个会话时会取错,那条失败结果就拿不到保护、
|
|
48
|
-
// 可能被当普通旧结果清掉(是「会误清」,只是限于失败结果这一条证据)。同一模式在
|
|
49
|
-
// hooks / lsp 的投影里也有。根治要把会话线程进投影签名 `fn(messages, session)`,
|
|
50
|
-
// 属内核 API 变更,留给后续单独做,本批不动。
|
|
51
|
-
return microcompact(messages, {
|
|
59
|
+
const options = {
|
|
52
60
|
keepRecent: config.keepRecent,
|
|
53
61
|
minSaveTokens: config.minSaveTokens,
|
|
54
|
-
errorCallIds: new Set(
|
|
55
|
-
}
|
|
62
|
+
errorCallIds: new Set(owner.toolErrors.keys()),
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* 门槛:清 1 token 只按 1/10 价省,断一次前缀要按全价重读整段。
|
|
66
|
+
* 所以先算出计划能清多少字符,占整段提示词不够 minFreePercent 就换空计划——
|
|
67
|
+
* 这一轮一条都不清,等下一轮攒多了再动。
|
|
68
|
+
*/
|
|
69
|
+
const worthApplying = (plan) => planWorthApplying(messages, plan, config.minFreePercent);
|
|
70
|
+
if (config.refresh === 'request') {
|
|
71
|
+
const planned = planMicrocompact(messages, options);
|
|
72
|
+
return applyMicrocompactPlan(messages, worthApplying(planned) ? planned : EMPTY_PLAN);
|
|
73
|
+
}
|
|
74
|
+
const round = roundKeyOf(messages);
|
|
75
|
+
const sid = owner.meta.id;
|
|
76
|
+
const held = frozen.get(sid);
|
|
77
|
+
// 同一轮、消息没变短:复用上一次的计划(前缀因此逐步稳定,缓存能一直命中)。
|
|
78
|
+
if (held !== undefined && held.round === round && messages.length >= held.length) {
|
|
79
|
+
return applyMicrocompactPlan(messages, held.plan);
|
|
80
|
+
}
|
|
81
|
+
const planned = planMicrocompact(messages, options);
|
|
82
|
+
// 判定放在「算出计划之后、写进 frozen 之前」:跳过时也冻结空计划与本轮条数,
|
|
83
|
+
// 同一轮内不再反复算(否则每一步都要重扫一遍消息,还显得计划一直在变)。
|
|
84
|
+
const plan = worthApplying(planned) ? planned : EMPTY_PLAN;
|
|
85
|
+
frozen.set(sid, { round, plan, length: messages.length });
|
|
86
|
+
if (frozen.size > 64) {
|
|
87
|
+
// 会话多了别让这张表无界长;删最早登记的那一条(Map 插入序)。
|
|
88
|
+
const first = frozen.keys().next().value;
|
|
89
|
+
if (first !== undefined && first !== sid)
|
|
90
|
+
frozen.delete(first);
|
|
91
|
+
}
|
|
92
|
+
return applyMicrocompactPlan(messages, plan);
|
|
56
93
|
}, { order: PROJECTION_ORDER });
|
|
94
|
+
/**
|
|
95
|
+
* 投影估算服务(2026-11-02):把旧工具结果换成占位符之后,整段消息的估算 token 数。
|
|
96
|
+
* 只算不落盘,用的是本插件现读的 config 与同一套 plan / apply,跟真正发请求时一致。
|
|
97
|
+
*
|
|
98
|
+
* 失败/被拒的 tool_call_id 记在会话旁路(`Session.toolErrors`),这个接口只收消息、
|
|
99
|
+
* 拿不到会话,所以按空集算:那类结果本来就该保留,少清几条只会让估算偏保守
|
|
100
|
+
* (偏保守 = 更容易判定「装不下」= 老老实实去压摘要,不会误判成熟)。
|
|
101
|
+
*/
|
|
102
|
+
const service = {
|
|
103
|
+
projectedTokens(messages) {
|
|
104
|
+
// 关掉时没有投影,发出去的就是原文
|
|
105
|
+
if (!config.enabled)
|
|
106
|
+
return estimateTokens(messages);
|
|
107
|
+
const plan = planMicrocompact(messages, {
|
|
108
|
+
keepRecent: config.keepRecent,
|
|
109
|
+
minSaveTokens: config.minSaveTokens,
|
|
110
|
+
});
|
|
111
|
+
// 门槛没达到时投影也不生效(见 planWorthApplying 的注释),估算按原文算
|
|
112
|
+
if (!planWorthApplying(messages, plan, config.minFreePercent))
|
|
113
|
+
return estimateTokens(messages);
|
|
114
|
+
return estimateTokens(applyMicrocompactPlan(messages, plan));
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
const offService = ctx.provide('microcompact', service);
|
|
57
118
|
// ── 设置分区 ─────────────────────────────────────────────────────────────
|
|
58
119
|
const fields = [
|
|
59
120
|
{
|
|
60
121
|
type: 'switch',
|
|
61
122
|
key: 'enabled',
|
|
62
|
-
label: '
|
|
63
|
-
help: '
|
|
123
|
+
label: '清理旧工具结果',
|
|
124
|
+
help: '开着时把较旧的工具结果正文换成一句占位符(会话日志里的原文不动)。关掉则原样发送。',
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
type: 'select',
|
|
128
|
+
key: 'refresh',
|
|
129
|
+
label: '清理时机',
|
|
130
|
+
options: [
|
|
131
|
+
{ value: 'round', label: '每轮开始清一次(默认,缓存命中高)' },
|
|
132
|
+
{ value: 'request', label: '每次请求都清(省上下文,前缀常失效)' },
|
|
133
|
+
],
|
|
134
|
+
help: '一轮 = 你发一句话之后模型连着跑的那几十步。每轮只清一次时,同一轮内的请求前缀不变,' +
|
|
135
|
+
'服务端前缀缓存能一直命中;每次请求都清会让刚滑出窗口的那条被改写,从那里往后整段不命中。',
|
|
64
136
|
},
|
|
65
137
|
{
|
|
66
138
|
type: 'number',
|
|
@@ -80,18 +152,34 @@ export const microcompactPlugin = {
|
|
|
80
152
|
step: 64,
|
|
81
153
|
help: '清一条短的省不出多少,还白丢证据,所以不到这个门槛就不清。填 0 表示只要能省就清。',
|
|
82
154
|
},
|
|
155
|
+
{
|
|
156
|
+
type: 'number',
|
|
157
|
+
key: 'minFreePercent',
|
|
158
|
+
label: '总共至少省下几成才清(%)',
|
|
159
|
+
min: MIN_FREE_RANGE.min,
|
|
160
|
+
max: MIN_FREE_RANGE.max,
|
|
161
|
+
step: 5,
|
|
162
|
+
help: '一轮里能清掉的字符占整段提示词的百分比,达不到就一条都不清。命中的 token 只按约 1/10 价收,' +
|
|
163
|
+
'没命中的整段按全价重读,清得太少反而亏。默认 25,填 0 表示只要能省就清。',
|
|
164
|
+
},
|
|
83
165
|
];
|
|
84
166
|
const section = {
|
|
85
167
|
id: CONFIG_KEY,
|
|
86
168
|
title: '旧工具结果清理',
|
|
87
|
-
subtitle: '
|
|
169
|
+
subtitle: '把较旧的工具结果换成占位符:只动请求体、不改会话日志,默认每轮只清一次',
|
|
88
170
|
// 紧挨压缩(35)之后:两者都是省上下文的手段,用户找起来是同一类东西。
|
|
89
171
|
order: 36,
|
|
90
172
|
fields: () => fields,
|
|
91
173
|
// 每次打开分区都现读磁盘:手改 plugins.json 也能看到真值。
|
|
92
174
|
values: () => {
|
|
93
175
|
config = readConfig(passed);
|
|
94
|
-
return {
|
|
176
|
+
return {
|
|
177
|
+
enabled: config.enabled,
|
|
178
|
+
refresh: config.refresh,
|
|
179
|
+
keepRecent: config.keepRecent,
|
|
180
|
+
minSaveTokens: config.minSaveTokens,
|
|
181
|
+
minFreePercent: config.minFreePercent,
|
|
182
|
+
};
|
|
95
183
|
},
|
|
96
184
|
// 契约:save 返回字符串 = 失败原因。
|
|
97
185
|
save: (key, value) => {
|
|
@@ -99,6 +187,13 @@ export const microcompactPlugin = {
|
|
|
99
187
|
applyConfig({ enabled: value === true || value === 'true' });
|
|
100
188
|
return;
|
|
101
189
|
}
|
|
190
|
+
if (key === 'refresh') {
|
|
191
|
+
const next = String(value);
|
|
192
|
+
if (next !== 'round' && next !== 'request')
|
|
193
|
+
return '清理时机只能是 round(每轮一次)或 request(每次请求)';
|
|
194
|
+
applyConfig({ refresh: next });
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
102
197
|
const num = Number(value);
|
|
103
198
|
if (!Number.isFinite(num))
|
|
104
199
|
return '这里要填一个数字';
|
|
@@ -106,12 +201,15 @@ export const microcompactPlugin = {
|
|
|
106
201
|
applyConfig({ keepRecent: num });
|
|
107
202
|
else if (key === 'minSaveTokens')
|
|
108
203
|
applyConfig({ minSaveTokens: num });
|
|
204
|
+
else if (key === 'minFreePercent')
|
|
205
|
+
applyConfig({ minFreePercent: num });
|
|
109
206
|
else
|
|
110
207
|
return `这个分区没有这项:${key}`;
|
|
111
208
|
},
|
|
112
209
|
};
|
|
113
210
|
const offSection = ctx.settings.registerSection(section);
|
|
114
211
|
return () => {
|
|
212
|
+
offService();
|
|
115
213
|
offProjection();
|
|
116
214
|
offSection();
|
|
117
215
|
};
|
package/lib/plugins/mode.js
CHANGED
|
@@ -13,10 +13,18 @@ export const modePlugin = {
|
|
|
13
13
|
inject: ['session', 'commands', 'approval', 'guards', 'prompt', 'surfaces'],
|
|
14
14
|
provide: 'mode',
|
|
15
15
|
apply(ctx) {
|
|
16
|
-
|
|
16
|
+
/**
|
|
17
|
+
* 协作模式**按会话**读(2026-10-28):值只在会话 `mode` 状态条目里,没有进程级变量。
|
|
18
|
+
* 后台会话的守卫按它自己的记录判,不会因为你切到执行模式就放行。
|
|
19
|
+
*/
|
|
20
|
+
const modeOf = (session) => session.state('mode') ?? 'build';
|
|
21
|
+
/** 按会话 id 找模式(找不通常驻实例就按当前查看的会话)。 */
|
|
22
|
+
const modeFor = (sessionId) => {
|
|
23
|
+
const found = sessionId === undefined || sessionId === '' ? undefined : ctx.get('agent')?.sessionById(sessionId);
|
|
24
|
+
return modeOf(found ?? ctx.session.current());
|
|
25
|
+
};
|
|
17
26
|
const apply = (next, opts = {}) => {
|
|
18
|
-
const changed =
|
|
19
|
-
mode = next;
|
|
27
|
+
const changed = modeFor() !== next;
|
|
20
28
|
if (opts.record !== false)
|
|
21
29
|
ctx.session.current().appendState('mode', next);
|
|
22
30
|
if (changed) {
|
|
@@ -36,24 +44,36 @@ export const modePlugin = {
|
|
|
36
44
|
};
|
|
37
45
|
const service = {
|
|
38
46
|
get mode() {
|
|
39
|
-
return
|
|
47
|
+
return modeOf(ctx.session.current());
|
|
40
48
|
},
|
|
49
|
+
modeFor,
|
|
41
50
|
setMode(next) {
|
|
42
51
|
apply(next);
|
|
43
52
|
},
|
|
44
53
|
surface() {
|
|
45
|
-
return {
|
|
54
|
+
return {
|
|
55
|
+
current: modeOf(ctx.session.current()),
|
|
56
|
+
options: MODE_IDS.map((id) => ({ id, label: MODES[id].label, hint: MODES[id].hint })),
|
|
57
|
+
};
|
|
46
58
|
},
|
|
47
59
|
};
|
|
48
60
|
ctx.provide('mode', service);
|
|
49
|
-
//
|
|
50
|
-
//
|
|
51
|
-
|
|
61
|
+
// 这一档的条款挂在**请求末尾的环境快照**里,不进系统提示词(2026-10-30)。
|
|
62
|
+
// 原来它是一段 order 30 的系统提示段,换一次模式系统提示词就从头不同,服务端前缀
|
|
63
|
+
// 缓存整段失效——一次 /plan 就能把几十 K 的命中打成未命中。挪到快照之后:
|
|
64
|
+
// 前缀原样复用,模型每轮照样读到当前模式的规则(plan 的禁令一个字都不少)。
|
|
65
|
+
ctx.prompt.registerEnvFacts('mode', (session) => modeSpec(modeFor(session?.meta.id)).prompt);
|
|
52
66
|
// 闸门:执行档一律交给后面的权限模式与审批卡;其余三档照 core/modes.ts 的判法说话。
|
|
53
67
|
const modeGuard = {
|
|
54
68
|
id: 'mode',
|
|
55
69
|
order: 10,
|
|
56
70
|
decide(input) {
|
|
71
|
+
// 这次调用属于哪个会话就用那个会话的模式:后台会话在计划模式跑,你切到执行模式看它,
|
|
72
|
+
// 也不该把它的写操作放行。
|
|
73
|
+
const session = input.sessionId === undefined || input.sessionId === ''
|
|
74
|
+
? ctx.get('agent')?.sessionFor(input.sessionPath)
|
|
75
|
+
: ctx.get('agent')?.sessionById(input.sessionId);
|
|
76
|
+
const mode = modeOf(session ?? ctx.session.current());
|
|
57
77
|
const gate = modeSpec(mode).gate({
|
|
58
78
|
toolName: input.toolName,
|
|
59
79
|
risk: input.risk,
|
|
@@ -73,12 +93,11 @@ export const modePlugin = {
|
|
|
73
93
|
ctx.surfaces.register('mode', () => service.surface());
|
|
74
94
|
// 恢复历史会话:模式跟着回来(不重复写记录,也不重复播报切换)。
|
|
75
95
|
ctx.on('dsc/session-open', ({ session }) => {
|
|
76
|
-
|
|
77
|
-
ctx.emit('dsc/mode-changed', mode);
|
|
96
|
+
ctx.emit('dsc/mode-changed', modeOf(session));
|
|
78
97
|
ctx.emit('dsc/changed');
|
|
79
98
|
});
|
|
80
99
|
// 挂载完就播一次当前档位:比本插件先挂载的监听者(审批插件)因此不会停在默认档位上。
|
|
81
|
-
ctx.emit('dsc/mode-changed',
|
|
100
|
+
ctx.emit('dsc/mode-changed', modeOf(ctx.session.current()));
|
|
82
101
|
/** `/mode <档位>`:支持中文别名(计划 / 探索 / 免打扰 / 执行)。 */
|
|
83
102
|
ctx.commands.register({ name: 'mode', args: '<执行|计划|探索|免打扰>', description: '切换协作模式(写进会话记录,恢复会话时一起恢复)' }, ({ args, ui }) => {
|
|
84
103
|
const token = args[0] ?? '';
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
*
|
|
10
10
|
* 三个登记点:
|
|
11
11
|
* 1. `surfaces.permissionPresets`:输入框那颗权限旋钮与设置页读它(含 `custom` 状态);
|
|
12
|
-
* 2.
|
|
12
|
+
* 2. 预设的切换只写**当前会话**(2026-10-28 起按会话隔离,见 core/permission-scope);
|
|
13
|
+
* 新会话的默认值仍由偏好里的 `defaultPermissionPreset` 决定;
|
|
13
14
|
* 3. `dsc/permission-preset-changed` 广播,界面据此重画。
|
|
14
15
|
*
|
|
15
16
|
* @module dsc/plugins/permission-presets
|