@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/spill.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { errText } from '../core/err-text.js';
|
|
2
|
+
import { formatBytes } from '../core/bytes.js';
|
|
3
|
+
import { listSpillFiles, readSpillConfig, SPILL_RANGES, spillText, sweepSpillDir } from '../core/spill.js';
|
|
2
4
|
import { writePluginConfig } from '../core/plugin-registry.js';
|
|
3
5
|
/** 插件在条目树里的键,也是设置分区 id。 */
|
|
4
6
|
const CONFIG_KEY = 'spill';
|
|
@@ -9,9 +11,6 @@ const CONFIG_KEY = 'spill';
|
|
|
9
11
|
const OBSERVER_ORDER = 50;
|
|
10
12
|
/** 不该溢出的工具:read 的结果就是模型点名要的那一段,再落盘只是让它去读另一个文件。 */
|
|
11
13
|
const SKIP_TOOLS = new Set(['read']);
|
|
12
|
-
function errText(error) {
|
|
13
|
-
return error instanceof Error ? error.message : String(error);
|
|
14
|
-
}
|
|
15
14
|
export const spillPlugin = {
|
|
16
15
|
name: 'spill',
|
|
17
16
|
inject: ['guards', 'session', 'settings', 'transcript'],
|
|
@@ -22,6 +21,8 @@ export const spillPlugin = {
|
|
|
22
21
|
let warned = false;
|
|
23
22
|
/** 最近落盘的那份:清理时保住它,模型可能正拿着它的路径在续读。 */
|
|
24
23
|
let lastSpilled;
|
|
24
|
+
/** 上次全盘清理的时刻:目录扫描是同步 IO,不能每条长输出都扫一遍。 */
|
|
25
|
+
let lastSweepAt = 0;
|
|
25
26
|
const usage = (dir) => {
|
|
26
27
|
const files = listSpillFiles(dir);
|
|
27
28
|
return { files: files.length, bytes: files.reduce((sum, file) => sum + file.bytes, 0) };
|
|
@@ -38,14 +39,19 @@ export const spillPlugin = {
|
|
|
38
39
|
try {
|
|
39
40
|
const spilled = spillText(ctx.session.current().meta.id, text, cfg);
|
|
40
41
|
lastSpilled = spilled.written.path;
|
|
41
|
-
//
|
|
42
|
-
|
|
42
|
+
// 顺手清一次,但要节流:长会话里连续几条大输出会把整个目录反复扫一遍,
|
|
43
|
+
// readdir + lstat + unlink 都是同步调用,扫一次就卡一次事件循环。
|
|
44
|
+
// 5 分钟一次足够让总量上限生效;刚落盘的这份始终被 keepPath 保住。
|
|
45
|
+
if (Date.now() - lastSweepAt >= 5 * 60_000) {
|
|
46
|
+
lastSweepAt = Date.now();
|
|
47
|
+
sweepSpillDir(cfg, lastSpilled);
|
|
48
|
+
}
|
|
43
49
|
return spilled.text;
|
|
44
50
|
}
|
|
45
51
|
catch (error) {
|
|
46
52
|
if (!warned) {
|
|
47
53
|
warned = true;
|
|
48
|
-
ctx.transcript.system(
|
|
54
|
+
ctx.transcript.system(`长输出转存没能落盘(${errText(error)}),这次仍按原文回给模型。溢出目录:${cfg.dir}(磁盘满或没有写权限时先看它;这条提醒本次会话只说一次)`);
|
|
49
55
|
}
|
|
50
56
|
return text;
|
|
51
57
|
}
|
|
@@ -73,7 +79,7 @@ export const spillPlugin = {
|
|
|
73
79
|
min: SPILL_RANGES.keepLines.min,
|
|
74
80
|
max: SPILL_RANGES.keepLines.max,
|
|
75
81
|
step: 1,
|
|
76
|
-
help: '
|
|
82
|
+
help: '头尾各留几行:开头能看出这是什么输出,结尾常带错误与汇总;中间省略,模型需要时再按路径续读。',
|
|
77
83
|
},
|
|
78
84
|
{
|
|
79
85
|
type: 'number',
|
|
@@ -116,7 +122,7 @@ export const spillPlugin = {
|
|
|
116
122
|
key: 'dir',
|
|
117
123
|
label: '溢出目录',
|
|
118
124
|
mono: true,
|
|
119
|
-
placeholder: '
|
|
125
|
+
placeholder: '留空 = ~/.dsc/spill(DSC_HOME/spill)',
|
|
120
126
|
help: '目录权限 0700、文件 0600。换成别的盘符也行,目录会在第一次落盘时自动建。',
|
|
121
127
|
},
|
|
122
128
|
{
|
|
@@ -136,8 +142,8 @@ export const spillPlugin = {
|
|
|
136
142
|
};
|
|
137
143
|
const section = {
|
|
138
144
|
id: CONFIG_KEY,
|
|
139
|
-
title: '
|
|
140
|
-
subtitle: '
|
|
145
|
+
title: '长输出转存',
|
|
146
|
+
subtitle: '超过阈值就存文件,模型先看头尾几行,需要时再续读',
|
|
141
147
|
order: 37,
|
|
142
148
|
fields,
|
|
143
149
|
values() {
|
|
@@ -181,6 +187,7 @@ export const spillPlugin = {
|
|
|
181
187
|
action(name) {
|
|
182
188
|
if (name !== 'cleanup')
|
|
183
189
|
return `这个分区没有这个按钮:${name}`;
|
|
190
|
+
lastSweepAt = Date.now();
|
|
184
191
|
const result = sweepSpillDir(config(), lastSpilled);
|
|
185
192
|
const kept = `还剩 ${String(result.keptFiles)} 个(${formatBytes(result.keptBytes)})`;
|
|
186
193
|
if (result.failed.length > 0) {
|
package/lib/plugins/subagent.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* 「另一个 MiniAgent 实例 + 它自己的会话文件 + 一张冻结的工牌」。
|
|
7
7
|
*
|
|
8
8
|
* 队友按会话隔离(对照 dsh 的 parentSession 过滤):每个会话各自一份在队名单与
|
|
9
|
-
* 并发额度,`subagent list`
|
|
9
|
+
* 并发额度,`subagent list` 只报本会话派出的队友;共享任务看板在「共享任务板」
|
|
10
10
|
* 插件里,那是叠在这一层之上的协作层。
|
|
11
11
|
*
|
|
12
12
|
* 工牌(工具白名单 / 审批意愿 / 轮次预算 / 模型)在队友开工那一刻从角色文件复制进
|
|
@@ -25,12 +25,15 @@ import { builtinRoleNames, builtinRole, DSC_AGENTS_DIR, ensureBuiltinRoles, find
|
|
|
25
25
|
import { resolvePluginConfig, writePluginConfig } from '../core/plugin-registry.js';
|
|
26
26
|
import { MiniAgent } from '../core/loop.js';
|
|
27
27
|
import { subagentEnvironmentText } from '../core/prompt.js';
|
|
28
|
+
import { activeRules } from '../core/command-policy.js';
|
|
29
|
+
import { modeSpec } from '../core/modes.js';
|
|
28
30
|
import { REJECTED_TOOL_TEXT, Session, teammateRoot } from '../core/session.js';
|
|
29
31
|
import { redact } from '../core/secrets.js';
|
|
30
32
|
import { argsSummary } from '../core/tools.js';
|
|
31
33
|
import { ToolGuardRegistry, toolApprovalGuard } from '../core/tool-guards.js';
|
|
32
34
|
import { inboxAppend, REVIEW_FINDINGS_OPEN, TEAMMATE_REPORT_OPEN } from '../core/team-board.js';
|
|
33
|
-
import {
|
|
35
|
+
import { reviewTaskText, ReviewJournal, REVIEW_CANCELED_TEXT } from '../core/git-info.js';
|
|
36
|
+
import { clampInt as clamp } from '../core/clamp.js';
|
|
34
37
|
const CONFIG_KEY = 'subagent';
|
|
35
38
|
const DEFAULTS = {
|
|
36
39
|
allowDelegation: true,
|
|
@@ -39,10 +42,22 @@ const DEFAULTS = {
|
|
|
39
42
|
approval: 'forbid',
|
|
40
43
|
notify: 'auto',
|
|
41
44
|
defaultModel: '',
|
|
45
|
+
maxTurns: 0,
|
|
42
46
|
};
|
|
43
47
|
const APPROVAL_RANK = { forbid: 0, foreground: 1, ask: 2 };
|
|
44
48
|
/** 收工的队友最多在名单里留这么多个,超了就挤掉最老的(不占并发额度,只是别把名单撑爆)。 */
|
|
45
49
|
const MAX_LISTED_FINISHED = 12;
|
|
50
|
+
/**
|
|
51
|
+
* 轮次预算取更严的那个:角色与插件都设了上限时取小的;任一方为 0(不限)时看另一方。
|
|
52
|
+
* @returns 0 = 不额外设限。
|
|
53
|
+
*/
|
|
54
|
+
function effectiveMaxTurns(roleTurns, pluginTurns) {
|
|
55
|
+
if (roleTurns <= 0)
|
|
56
|
+
return Math.max(pluginTurns, 0);
|
|
57
|
+
if (pluginTurns <= 0)
|
|
58
|
+
return roleTurns;
|
|
59
|
+
return Math.min(roleTurns, pluginTurns);
|
|
60
|
+
}
|
|
46
61
|
/** 主会话这一方在任务板上的名字。 */
|
|
47
62
|
const LEAD = 'lead';
|
|
48
63
|
/** 名字合法字符,跟角色名同一套。 */
|
|
@@ -93,10 +108,6 @@ export const subagentPlugin = {
|
|
|
93
108
|
// ── 配置 ────────────────────────────────────────────────────────────────
|
|
94
109
|
const readConfig = () => {
|
|
95
110
|
const raw = resolvePluginConfig(CONFIG_KEY, passed);
|
|
96
|
-
const clamp = (value, min, max, fallback) => {
|
|
97
|
-
const num = Number(value);
|
|
98
|
-
return Number.isFinite(num) ? Math.min(Math.max(Math.round(num), min), max) : fallback;
|
|
99
|
-
};
|
|
100
111
|
const approval = APPROVAL_RANK[String(raw.approval)] === undefined
|
|
101
112
|
? DEFAULTS.approval
|
|
102
113
|
: String(raw.approval);
|
|
@@ -107,6 +118,7 @@ export const subagentPlugin = {
|
|
|
107
118
|
approval,
|
|
108
119
|
notify: raw.notify === 'quiet' ? 'quiet' : 'auto',
|
|
109
120
|
defaultModel: typeof raw.defaultModel === 'string' ? raw.defaultModel.trim() : '',
|
|
121
|
+
maxTurns: clamp(raw.maxTurns, 0, 200, DEFAULTS.maxTurns),
|
|
110
122
|
};
|
|
111
123
|
};
|
|
112
124
|
let config = readConfig();
|
|
@@ -195,8 +207,16 @@ export const subagentPlugin = {
|
|
|
195
207
|
? Promise.resolve()
|
|
196
208
|
: new Promise((resolve) => teammate.waiters.push(resolve));
|
|
197
209
|
const settle = (teammate, reason, error) => {
|
|
210
|
+
// 预算最后一轮还欠着(提醒已排队、那一轮还没跑):这一拍是自然收口,不算收工
|
|
211
|
+
if (teammate.finalRoundPending === true && reason === 'completed' && teammate.rounds < teammate.badge.maxTurns)
|
|
212
|
+
return;
|
|
213
|
+
teammate.finalRoundPending = false;
|
|
198
214
|
teammate.finishedAt = Date.now();
|
|
199
|
-
|
|
215
|
+
// 汇报正文取「最后一条非空 assistant 正文」:最后一轮可能是纯工具调用(正文为空),
|
|
216
|
+
// 直接取最后一条就会把它当成「什么也没说」,前面真交过的结论反而丢了。
|
|
217
|
+
const tail = [...teammate.session.messages]
|
|
218
|
+
.reverse()
|
|
219
|
+
.find((message) => message.role === 'assistant' && typeof message.content === 'string' && message.content.trim() !== '');
|
|
200
220
|
teammate.lastText = typeof tail?.content === 'string' ? tail.content : '';
|
|
201
221
|
if (reason === 'completed')
|
|
202
222
|
teammate.state = 'idle';
|
|
@@ -212,6 +232,14 @@ export const subagentPlugin = {
|
|
|
212
232
|
const waiters = teammate.waiters.splice(0);
|
|
213
233
|
for (const resolve of waiters)
|
|
214
234
|
resolve();
|
|
235
|
+
// 传话之后欠的那次汇报:等到模型又说过话(或直接失败)才回,且同一轮不重复回
|
|
236
|
+
const pending = teammate.awaitReport;
|
|
237
|
+
if (pending !== undefined &&
|
|
238
|
+
(teammate.state === 'failed' ||
|
|
239
|
+
(teammate.rounds >= pending.minRound && teammate.rounds > teammate.lastReportedRound))) {
|
|
240
|
+
teammate.awaitReport = undefined;
|
|
241
|
+
reportHome(teammate);
|
|
242
|
+
}
|
|
215
243
|
};
|
|
216
244
|
/** 队友的工具表:按工牌白名单筛。subagent 换成它自己的署名;team_task(智能体团队
|
|
217
245
|
* 插件注册的)保留原实现,只把自己的身份塞进上下文,看板认领人才不会都算成 lead。 */
|
|
@@ -231,10 +259,34 @@ export const subagentPlugin = {
|
|
|
231
259
|
};
|
|
232
260
|
/**
|
|
233
261
|
* 队友自己那条工具守卫链:全局上限与角色意愿取更严的那个,通过的请求在卡上署名。
|
|
234
|
-
*
|
|
262
|
+
* 每条链只有一位审批守卫——队友不共用主会话那条链(模式闸门是另起一条,按父会话判定,
|
|
263
|
+
* 见下面的 `teammate-mode`),所以主会话换档不会连带改这条链上的其它守卫。
|
|
235
264
|
*/
|
|
236
265
|
const guardsFor = (teammate) => {
|
|
237
266
|
const chain = new ToolGuardRegistry();
|
|
267
|
+
// 父会话的协作模式对队友同样有效。队友的工具白名单来自角色文件,不经过主会话
|
|
268
|
+
// order 10 那道模式闸门;少了这一道,计划模式里派一个 writer 就能改工程文件。
|
|
269
|
+
// 每次判定现读父会话的 mode:中途换档也对在跑的队友生效(与主会话同一条口径)。
|
|
270
|
+
chain.register({
|
|
271
|
+
id: `teammate-mode:${teammate.name}`,
|
|
272
|
+
order: 5,
|
|
273
|
+
decide(input) {
|
|
274
|
+
const mode = String(teammate.parentSession.state('mode') ?? 'build');
|
|
275
|
+
const spec = modeSpec(mode);
|
|
276
|
+
const gate = spec.gate({
|
|
277
|
+
toolName: input.toolName,
|
|
278
|
+
risk: input.risk,
|
|
279
|
+
cwd: input.cwd,
|
|
280
|
+
target: input.target,
|
|
281
|
+
command: input.command,
|
|
282
|
+
rules: activeRules(),
|
|
283
|
+
});
|
|
284
|
+
if (gate.action === 'deny') {
|
|
285
|
+
return { action: 'deny', reason: `父会话在「${spec.label}」模式:${gate.reason}` };
|
|
286
|
+
}
|
|
287
|
+
return gate.action === 'pass' ? { action: 'pass' } : { action: 'defer' };
|
|
288
|
+
},
|
|
289
|
+
});
|
|
238
290
|
chain.register(toolApprovalGuard({
|
|
239
291
|
id: `teammate:${teammate.name}`,
|
|
240
292
|
async approve(input) {
|
|
@@ -247,6 +299,10 @@ export const subagentPlugin = {
|
|
|
247
299
|
argsSummary: argsSummary(input.args),
|
|
248
300
|
args: input.args,
|
|
249
301
|
cwd: input.cwd,
|
|
302
|
+
// 队友的审批按**派它的那个会话**归属:不能落到「用户正在看的会话」,
|
|
303
|
+
// 否则权限模式会拿错档(2026-10-28 按会话隔离后这条必须显式给)。
|
|
304
|
+
sessionId: teammate.parentSession.meta.id,
|
|
305
|
+
sessionPath: teammate.parentSession.filePath,
|
|
250
306
|
}, input.signal);
|
|
251
307
|
return decision !== 'reject';
|
|
252
308
|
},
|
|
@@ -278,7 +334,8 @@ export const subagentPlugin = {
|
|
|
278
334
|
// 工牌在此刻冻结:此后改角色文件不影响它
|
|
279
335
|
badge: {
|
|
280
336
|
tools: input.role.tools,
|
|
281
|
-
|
|
337
|
+
// 角色文件与插件设置都设了上限时取更严的;两边都 0 才是真的不设限
|
|
338
|
+
maxTurns: effectiveMaxTurns(input.role.maxTurns, config.maxTurns),
|
|
282
339
|
approval: input.role.approval,
|
|
283
340
|
model,
|
|
284
341
|
effort,
|
|
@@ -288,6 +345,7 @@ export const subagentPlugin = {
|
|
|
288
345
|
state: 'working',
|
|
289
346
|
rounds: 0,
|
|
290
347
|
toolCalls: 0,
|
|
348
|
+
lastReportedRound: 0,
|
|
291
349
|
depth: input.caller.depth + 1,
|
|
292
350
|
parent: input.caller.name,
|
|
293
351
|
background: input.background,
|
|
@@ -303,7 +361,7 @@ export const subagentPlugin = {
|
|
|
303
361
|
teammate.agent = new MiniAgent({
|
|
304
362
|
route: () => {
|
|
305
363
|
if (teammate.badge.model === null)
|
|
306
|
-
return ctx.llm.
|
|
364
|
+
return ctx.llm.routeForSession(teammate.parentSession);
|
|
307
365
|
const at = teammate.badge.model.indexOf('/');
|
|
308
366
|
const provider = at > 0 ? teammate.badge.model.slice(0, at) : teammate.badge.model;
|
|
309
367
|
const modelId = at > 0 ? teammate.badge.model.slice(at + 1) : '';
|
|
@@ -318,19 +376,43 @@ ${subagentEnvironmentText(input.parentSession.meta.cwd, teammate.badge.model ??
|
|
|
318
376
|
|
|
319
377
|
# 你在团队里的位置
|
|
320
378
|
你是队友「${teammate.name}」(角色 ${teammate.role}),派你活的是「${teammate.parent}」。
|
|
321
|
-
|
|
379
|
+
${teammate.badge.maxTurns > 0
|
|
380
|
+
? `你最多能发 ${teammate.badge.maxTurns} 次模型请求,用完会被自动收手,请把力气花在关键处;最后一轮不再给你工具,那轮直接交结论。`
|
|
381
|
+
: '轮次不设上限,但每轮都要往结论推进,别在同一个问题上打转。'}
|
|
322
382
|
${teammate.badge.tools === null ? '' : `你只被授权这些工具:${teammate.badge.tools.join('、')}。用别的办法办不成就在最后一段说清楚,让 ${teammate.parent} 决定。`}
|
|
323
383
|
${teammate.badge.approval === 'forbid' ? '你不能向用户请求授权:需要授权的操作会被直接拒绝,不要反复尝试。' : '需要授权的操作可以向用户请求,审批卡上会写明是你(' + teammate.name + ')在请求。'}
|
|
324
384
|
干完活用一段话交结果:做了什么、看到什么证据(文件名:行号)、还有什么没做。`,
|
|
325
|
-
|
|
385
|
+
// 设限时的最后一轮:工具表收成空,逼它用文本交结论(否则它会一直调工具直到被掐)
|
|
386
|
+
tools: () => teammate.badge.maxTurns > 0 && teammate.rounds >= teammate.badge.maxTurns - 1
|
|
387
|
+
? []
|
|
388
|
+
: toolsFor(teammate),
|
|
326
389
|
guards: guardsFor(teammate),
|
|
327
390
|
stream: (api, request, handlers) => ctx.llm.stream(api, request, handlers),
|
|
328
391
|
emit: (event) => {
|
|
329
|
-
if (event.type === '
|
|
392
|
+
if (event.type === 'turn/start') {
|
|
393
|
+
// 被传话叫醒的队友从「已停止」回到干活中:状态不翻,界面会一直挂着停着的字样
|
|
394
|
+
teammate.state = 'working';
|
|
395
|
+
delete teammate.finishedAt;
|
|
396
|
+
ctx.transcript.touch();
|
|
397
|
+
}
|
|
398
|
+
else if (event.type === 'message') {
|
|
330
399
|
teammate.rounds += 1;
|
|
331
|
-
|
|
332
|
-
if (
|
|
333
|
-
teammate.
|
|
400
|
+
const budget = teammate.badge.maxTurns;
|
|
401
|
+
if (budget > 0) {
|
|
402
|
+
if (teammate.rounds >= budget) {
|
|
403
|
+
// 轮次预算到点就收手:这就是「子智能体不许无限自转」的闸门。
|
|
404
|
+
// 最后一轮的工具表已经收成空,正常应当以正文收束;它偏要再调工具
|
|
405
|
+
// 才真正掐掉(走到 executeToolCalls 之前就会看到 aborted)。
|
|
406
|
+
if ((event.toolCalls?.length ?? 0) > 0)
|
|
407
|
+
teammate.agent.cancel();
|
|
408
|
+
}
|
|
409
|
+
else if (teammate.rounds === budget - 1) {
|
|
410
|
+
// 最后一轮留给汇报:先提醒它交结论,下一轮再把工具收走。
|
|
411
|
+
// 提醒排在收件箱里,模型若就此收口,它会单独起最后一轮(settle 那边等着)。
|
|
412
|
+
teammate.finalRoundPending = true;
|
|
413
|
+
teammate.agent.followup('下一轮是最后一次,直接给结论,不要再调工具', undefined, 'notice');
|
|
414
|
+
}
|
|
415
|
+
}
|
|
334
416
|
}
|
|
335
417
|
else if (event.type === 'tool/call') {
|
|
336
418
|
teammate.toolCalls += 1;
|
|
@@ -425,13 +507,31 @@ ${teammate.badge.approval === 'forbid' ? '你不能向用户请求授权:需
|
|
|
425
507
|
}
|
|
426
508
|
/** 队友报错文本暂存(emit 的 error 事件比 turn/end 早一步)。 */
|
|
427
509
|
const lastError = new Map();
|
|
510
|
+
/**
|
|
511
|
+
* 没留下文字结论时的说明。
|
|
512
|
+
*
|
|
513
|
+
* 为什么单独写:队友被停机、或轮次预算用完时,运行记录里往往只有一串工具调用、
|
|
514
|
+
* 一句正文都没有;原话「(它没留下文字结论)」既不说明原因,也不给证据位置。
|
|
515
|
+
* 这里标出原因并把运行记录路径给用户,让人能自己去看它干到了哪一步。
|
|
516
|
+
* @param withPath - 上文已经给过路径时传 false,免得同一段话里出现两遍。
|
|
517
|
+
*/
|
|
518
|
+
const noTextNote = (teammate, withPath = true) => {
|
|
519
|
+
const budget = teammate.badge.maxTurns;
|
|
520
|
+
const why = budget > 0 && teammate.rounds >= budget
|
|
521
|
+
? `轮次预算用完(${budget} 轮),没交最终结论`
|
|
522
|
+
: teammate.state === 'stopped'
|
|
523
|
+
? `被停机(第 ${teammate.rounds} 轮),没交最终结论`
|
|
524
|
+
: '没交最终结论';
|
|
525
|
+
return withPath ? `${why}。运行记录:${teammate.session.filePath}` : why;
|
|
526
|
+
};
|
|
428
527
|
/** 后台队友干完,把汇报交给派它的那一方。 */
|
|
429
528
|
const reportHome = (teammate) => {
|
|
529
|
+
teammate.lastReportedRound = teammate.rounds;
|
|
430
530
|
const state = teammate.state === 'idle' ? '已完成' : teammate.state === 'stopped' ? '已停止' : '已失败';
|
|
431
531
|
const body = teammate.state === 'failed'
|
|
432
532
|
? `(它失败了:${teammate.error ?? '未知错误'})`
|
|
433
533
|
: teammate.lastText === ''
|
|
434
|
-
?
|
|
534
|
+
? noTextNote(teammate)
|
|
435
535
|
: teammate.lastText;
|
|
436
536
|
const notice = `${TEAMMATE_REPORT_OPEN}from="${teammate.name}" role="${teammate.role}" state="${state}">
|
|
437
537
|
派给它的任务:${teammate.task}
|
|
@@ -457,7 +557,8 @@ ${body}
|
|
|
457
557
|
// 队友汇报是机器发起的唤醒:跑动中入箱时标 notice,界面画在输入框上方的
|
|
458
558
|
// 只读通知条(不是输入框下方的用户队列条),不给人编辑 / 撤掉 / 插话。
|
|
459
559
|
ctx.agent.followup(notice, undefined, teammate.parentSession.meta.id, 'notice');
|
|
460
|
-
|
|
560
|
+
// 带归属:父会话在后台时,这句回执只该进它自己的视图(0.6.68)
|
|
561
|
+
ctx.transcript.system(`${line},汇报已${live ? '并入下一轮' : '投进后台会话'}`, undefined, undefined, teammate.parentSession.meta.id);
|
|
461
562
|
}
|
|
462
563
|
else {
|
|
463
564
|
// 静默,或者父会话的 agent 已收摊:话写进它所属的那个会话文件,
|
|
@@ -465,7 +566,7 @@ ${body}
|
|
|
465
566
|
teammate.parentSession.appendUser(notice);
|
|
466
567
|
ctx.transcript.system(live
|
|
467
568
|
? `${line},汇报已写入会话,下一条消息时模型会看到`
|
|
468
|
-
: `${line}
|
|
569
|
+
: `${line},汇报写入了派出它的会话`, undefined, undefined, teammate.parentSession.meta.id);
|
|
469
570
|
}
|
|
470
571
|
};
|
|
471
572
|
// ── 侧栏要的服务 ────────────────────────────────────────────────────────
|
|
@@ -507,7 +608,7 @@ ${body}
|
|
|
507
608
|
// 只读:载入内存重放,不往那个文件写任何东西(也不拿写租约——队友可能正活着写它)
|
|
508
609
|
const session = Session.load(resolved, true, { lease: false });
|
|
509
610
|
const replay = new Transcript();
|
|
510
|
-
replay.replayHistory(session.messages, session.toolErrors, session.fileChanges);
|
|
611
|
+
replay.replayHistory(session.messages, session.toolErrors, session.fileChanges, session.presentations);
|
|
511
612
|
return [...replay.entries, ...replay.liveEntries()];
|
|
512
613
|
},
|
|
513
614
|
// 用户从界面上管理队友的两条通道:与模型用的 subagent 工具走同一段逻辑,
|
|
@@ -524,6 +625,8 @@ ${body}
|
|
|
524
625
|
const record = readRoster().find((entry) => entry.name === name);
|
|
525
626
|
if (live === undefined && record === undefined)
|
|
526
627
|
return `名册里没有叫「${name}」的队友。`;
|
|
628
|
+
// 真正收掉这一位:会话文件要关(释放写租约),再从名单里摘
|
|
629
|
+
live?.agent.dispose();
|
|
527
630
|
teammates.delete(name);
|
|
528
631
|
writeRoster(readRoster().filter((entry) => entry.name !== name));
|
|
529
632
|
// 运行记录文件一并删:它只在名册里可达,留着就是孤儿。只认 teammateRoot 下的路径,
|
|
@@ -553,11 +656,19 @@ ${body}
|
|
|
553
656
|
},
|
|
554
657
|
};
|
|
555
658
|
ctx.provide('team', teamService);
|
|
556
|
-
// ── 只读代码审查通道(
|
|
659
|
+
// ── 只读代码审查通道(T45)─────────────────────────────────────────────
|
|
557
660
|
// /review 的升级路径:派一个工牌被强制压到只读交集的队友(工具 = read/glob/grep,
|
|
558
661
|
// 审批 = forbid,与角色文件怎么改无关),后台审查,findings 以 <review-findings>
|
|
559
662
|
// 包裹写回发起会话——渲染层解析成卡片,主会话不吃模型轮。
|
|
663
|
+
//
|
|
664
|
+
// 完整 diff 由 core/git-info 的 collectReviewScope 落盘,任务书里只给路径与读法:
|
|
665
|
+
// 审查队友有 read,可以按 offset/limit 分批读完,不需要把 diff 截断塞进描述。
|
|
560
666
|
const READONLY_TOOLS = ['read', 'glob', 'grep'];
|
|
667
|
+
/**
|
|
668
|
+
* 审查记录账本:内存记「本会话有没有在跑的审查」,磁盘留最近一次的状态与结论。
|
|
669
|
+
* 数据目录取 settings.about().home(就是 DSC_HOME),重启后 /review-status 仍读得到。
|
|
670
|
+
*/
|
|
671
|
+
const reviewJournal = new ReviewJournal(ctx.settings.about().home);
|
|
561
672
|
const spawnReviewer = (request) => {
|
|
562
673
|
const parentSession = ctx.session.current();
|
|
563
674
|
const working = busyFor(parentSession.meta.id);
|
|
@@ -576,33 +687,61 @@ ${body}
|
|
|
576
687
|
const teammate = startTeammate({
|
|
577
688
|
name: uniqueName('reviewer'),
|
|
578
689
|
role,
|
|
579
|
-
task:
|
|
690
|
+
task: reviewTaskText(request.scope, request.focus),
|
|
580
691
|
caller: { name: LEAD, depth: 0, background: true },
|
|
581
692
|
background: true,
|
|
582
693
|
seed: null,
|
|
583
694
|
parentSession,
|
|
584
695
|
});
|
|
696
|
+
// 先登记再等收工:这中间用户可能已经 /review-status 或 /review-cancel
|
|
697
|
+
reviewJournal.begin(parentSession.meta.id, {
|
|
698
|
+
target: request.scope.label,
|
|
699
|
+
handle: teammate.name,
|
|
700
|
+
startedAt: teammate.startedAt,
|
|
701
|
+
});
|
|
585
702
|
void waitForIdle(teammate).then(() => deliverReview(teammate));
|
|
586
703
|
return { ok: true, name: teammate.name };
|
|
587
704
|
};
|
|
588
705
|
/** 审查收工:findings(或失败原因)写进发起会话,渲染层认 <review-findings> 标记出卡。 */
|
|
589
706
|
const deliverReview = (teammate) => {
|
|
707
|
+
const sessionId = teammate.parentSession.meta.id;
|
|
708
|
+
// 取消过的那次:记录与上屏都用同一句实话,别让「已停止」把「被取消」盖掉
|
|
709
|
+
const wasCancelled = reviewJournal.wasCancelled(sessionId);
|
|
590
710
|
const state = teammate.state === 'idle' ? '已完成' : teammate.state === 'stopped' ? '已停止' : '已失败';
|
|
591
|
-
const body =
|
|
592
|
-
?
|
|
593
|
-
: teammate.state === '
|
|
594
|
-
? '
|
|
595
|
-
: teammate.
|
|
596
|
-
? '
|
|
597
|
-
: teammate.lastText
|
|
711
|
+
const body = wasCancelled
|
|
712
|
+
? REVIEW_CANCELED_TEXT
|
|
713
|
+
: teammate.state === 'failed'
|
|
714
|
+
? `审查没有完成:${teammate.error ?? '未知错误'}`
|
|
715
|
+
: teammate.state === 'stopped'
|
|
716
|
+
? '审查被停止,没有交回结论。'
|
|
717
|
+
: teammate.lastText === ''
|
|
718
|
+
? '审查没有留下文字结论。'
|
|
719
|
+
: teammate.lastText;
|
|
598
720
|
const notice = `${REVIEW_FINDINGS_OPEN}teammate="${teammate.name}" state="${state}">\n${body}\n</review-findings>`;
|
|
599
721
|
const line = `审查队友 ${teammate.name},${state}`;
|
|
600
722
|
teammate.parentSession.appendUser(notice);
|
|
723
|
+
// 记录跟着收工:/review-status 回看的就是这里写下去的那份
|
|
724
|
+
reviewJournal.finish(sessionId, body, teammate.name);
|
|
601
725
|
const live = ctx.session.current() === teammate.parentSession;
|
|
602
726
|
ctx.transcript.system(live ? `${line},findings 已写进会话` : `${line},findings 写入了派出它的会话`);
|
|
603
727
|
ctx.transcript.touch();
|
|
604
728
|
};
|
|
605
|
-
const reviewService = {
|
|
729
|
+
const reviewService = {
|
|
730
|
+
spawn: spawnReviewer,
|
|
731
|
+
status() {
|
|
732
|
+
return reviewJournal.status(ctx.session.current().meta.id);
|
|
733
|
+
},
|
|
734
|
+
cancel() {
|
|
735
|
+
const sessionId = ctx.session.current().meta.id;
|
|
736
|
+
const run = reviewJournal.running(sessionId);
|
|
737
|
+
if (run === undefined)
|
|
738
|
+
return false;
|
|
739
|
+
// 叫停走队友那条现成的路(agent.cancel + 保留名册),再把记录标成取消
|
|
740
|
+
stopTeammate(run.handle, 'stop');
|
|
741
|
+
reviewJournal.cancel(sessionId);
|
|
742
|
+
return true;
|
|
743
|
+
},
|
|
744
|
+
};
|
|
606
745
|
ctx.provide('review', reviewService);
|
|
607
746
|
// ── 模型侧工具 ──────────────────────────────────────────────────────────
|
|
608
747
|
function uniqueName(role) {
|
|
@@ -624,9 +763,11 @@ ${body}
|
|
|
624
763
|
if (teammate === undefined)
|
|
625
764
|
return `没有叫 ${name} 的队友(subagent list 看现役名单)`;
|
|
626
765
|
teammate.agent.cancel();
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
766
|
+
// 两种叫停都**保留**这个队友:dsh 的 interrupt_agent 就是这个口径——停当前这一轮,
|
|
767
|
+
// 之后还能用 send_message 接着聊。以前 stop 直接把它从名单里删掉,于是「中断之后
|
|
768
|
+
// 还能不能继续」的答案是「不能」,信箱里的话也没人读(2026-10-27 查账)。
|
|
769
|
+
// 真要清掉走名册里的「移除」(TeamService.remove),那里才删文件、释放名字。
|
|
770
|
+
return `${name} ${mode === 'interrupt' ? '这一轮被打断了(信箱里的话还在,传话就能接着用)' : '已叫停(保留在名册里,可以传话接着用;要彻底清掉用名册里的移除)'}`;
|
|
630
771
|
}
|
|
631
772
|
/**
|
|
632
773
|
* `subagent` 的 message 与界面传话通道(TeamService.message)共用的那一条。
|
|
@@ -641,8 +782,10 @@ ${body}
|
|
|
641
782
|
inboxAppend(name === '' ? 'unknown' : name, wrapped);
|
|
642
783
|
if (teammate === undefined)
|
|
643
784
|
return `没有叫 ${name} 的队友,话写进了它的信箱(${join(ctx.settings.about().home, 'team', 'inbox')})但没人会读`;
|
|
785
|
+
// 传话之后欠一次汇报:它这一轮(或下一轮)说完了,主会话要接得到
|
|
786
|
+
teammate.awaitReport = { minRound: teammate.rounds + 1 };
|
|
644
787
|
teammate.agent.followup(wrapped);
|
|
645
|
-
return `话已投给 ${name}${teammate.state === 'working' ? '(它正在干,会在这轮结束后看到)' : '(已把它叫醒)'}
|
|
788
|
+
return `话已投给 ${name}${teammate.state === 'working' ? '(它正在干,会在这轮结束后看到)' : '(已把它叫醒)'},它说完会把结果报回来`;
|
|
646
789
|
}
|
|
647
790
|
async function runSubagent(args, runCtx, caller) {
|
|
648
791
|
const action = String(args.action ?? '');
|
|
@@ -689,6 +832,10 @@ ${body}
|
|
|
689
832
|
for (const entry of finished
|
|
690
833
|
.sort((a, b) => (a.finishedAt ?? a.startedAt) - (b.finishedAt ?? b.startedAt))
|
|
691
834
|
.slice(0, finished.length - MAX_LISTED_FINISHED)) {
|
|
835
|
+
// 挤出名单不能只删 Map 项:队友会话还握着写租约,不 close 会一直占着,
|
|
836
|
+
// 下次同路径会话可能被当成「另一个进程正在写」。取消是幂等的(收工后再调是空操作)。
|
|
837
|
+
entry.agent.cancel();
|
|
838
|
+
entry.session.close();
|
|
692
839
|
teammates.delete(entry.name);
|
|
693
840
|
}
|
|
694
841
|
}
|
|
@@ -728,9 +875,13 @@ ${body}
|
|
|
728
875
|
await waitForIdle(teammate);
|
|
729
876
|
runCtx.signal.removeEventListener('abort', onStop);
|
|
730
877
|
const head = `${teammate.name}(${teammate.role})${teammate.state === 'idle' ? '干完了' : teammate.state === 'stopped' ? '被打断' : '失败'}:第 ${teammate.rounds} 轮、${teammate.toolCalls} 次工具调用。运行记录:${teammate.session.filePath}`;
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
878
|
+
if (teammate.lastText !== '')
|
|
879
|
+
return `${head}\n\n${teammate.lastText}`;
|
|
880
|
+
// 没有正文:失败先报错误,其余按「预算用完 / 被停机」说清原因(路径已在 head 里)
|
|
881
|
+
const reason = teammate.state === 'failed' && teammate.error !== undefined
|
|
882
|
+
? `(它失败了:${teammate.error})`
|
|
883
|
+
: noTextNote(teammate, false);
|
|
884
|
+
return `${head}\n${reason}`;
|
|
734
885
|
}
|
|
735
886
|
void waitForIdle(teammate).then(() => reportHome(teammate));
|
|
736
887
|
return `已派给 ${teammate.name}(角色 ${teammate.role},${teammate.badge.tools === null ? '不限工具' : `工具 ${teammate.badge.tools.join('、')}`})。它在后台干,不用等也不用问:干完我会把汇报接进来。你现在可以继续做别的,或者再派一个。`;
|
|
@@ -738,7 +889,8 @@ ${body}
|
|
|
738
889
|
const subagentTool = () => ({
|
|
739
890
|
name: 'subagent',
|
|
740
891
|
description: '把一件可以独立完成的活派给一个有明确授权的队友(角色见 ~/.dsc/agents),或者给在队队友传话、打断它。' +
|
|
741
|
-
'background=true 时立刻返回,它干完后汇报会自己接进你的下一轮;background=false 时你这一轮会等它的结果。'
|
|
892
|
+
'background=true 时立刻返回,它干完后汇报会自己接进你的下一轮;background=false 时你这一轮会等它的结果。' +
|
|
893
|
+
'interrupt / stop 都只是叫停当前这一轮:队友留在名册里,传话(message)就能接着用,别把它当成已经没了。',
|
|
742
894
|
parameters: {
|
|
743
895
|
type: 'object',
|
|
744
896
|
properties: {
|
|
@@ -768,7 +920,8 @@ ${body}
|
|
|
768
920
|
const roles = listRoles().filter((role) => role.enabled);
|
|
769
921
|
const lines = roles.map((role) => {
|
|
770
922
|
const tools = role.tools === null ? '不限工具' : role.tools.length === 0 ? '不带工具' : role.tools.join('/');
|
|
771
|
-
|
|
923
|
+
const turns = effectiveMaxTurns(role.maxTurns, config.maxTurns);
|
|
924
|
+
return `- ${role.name}:${role.description || '(没写 description)'}(${tools},${turns === 0 ? '轮次不限' : `最多 ${turns} 轮`})`;
|
|
772
925
|
});
|
|
773
926
|
return `# 子智能体
|
|
774
927
|
你可以用 subagent 工具把能独立完成的活派给队友。
|
|
@@ -789,10 +942,19 @@ ${lines.join('\n') || '- (没有启用中的角色,先在设置「子智能
|
|
|
789
942
|
type: 'switch',
|
|
790
943
|
key: 'allowDelegation',
|
|
791
944
|
label: '允许模型自主分派任务给队友',
|
|
792
|
-
help: '关闭后 subagent
|
|
945
|
+
help: '关闭后 subagent 工具连同提示词一并撤下;已经在跑的队友会把当前这轮跑完。',
|
|
793
946
|
},
|
|
794
|
-
{ type: 'number', key: 'maxTeammates', label: '
|
|
947
|
+
{ type: 'number', key: 'maxTeammates', label: '每个会话同时几个队友', min: 1, max: 8, step: 1, help: '每个会话各自的同时干活上限;已完成的队友不占额度,满了再派会被直接拒绝,不排队。' },
|
|
795
948
|
{ type: 'number', key: 'maxDepth', label: '递归层级', min: 0, max: 2, step: 1, help: '0 = 仅主会话可派队友,Lead 不可再下派;1 = Lead 可派队友,队友不可再下派。' },
|
|
949
|
+
{
|
|
950
|
+
type: 'number',
|
|
951
|
+
key: 'maxTurns',
|
|
952
|
+
label: '轮次上限',
|
|
953
|
+
min: 0,
|
|
954
|
+
max: 200,
|
|
955
|
+
step: 1,
|
|
956
|
+
help: '0 = 不限,队友自己决定跑几轮(默认)。填了就与角色文件的 max-turns 取更小的那个,角色写 0 也视为不限。设限后最后一轮不再给工具,只让它直接交结论。',
|
|
957
|
+
},
|
|
796
958
|
{
|
|
797
959
|
type: 'select',
|
|
798
960
|
key: 'approval',
|
|
@@ -820,13 +982,14 @@ ${lines.join('\n') || '- (没有启用中的角色,先在设置「子智能
|
|
|
820
982
|
const section = {
|
|
821
983
|
id: 'subagent',
|
|
822
984
|
title: '子智能体',
|
|
823
|
-
subtitle: '
|
|
985
|
+
subtitle: '队友最多几层、同时几个、各跑几轮、要不要向你申请授权',
|
|
824
986
|
order: 40,
|
|
825
987
|
fields,
|
|
826
988
|
values: () => ({
|
|
827
989
|
allowDelegation: config.allowDelegation,
|
|
828
990
|
maxTeammates: config.maxTeammates,
|
|
829
991
|
maxDepth: config.maxDepth,
|
|
992
|
+
maxTurns: config.maxTurns,
|
|
830
993
|
approval: config.approval,
|
|
831
994
|
notify: config.notify,
|
|
832
995
|
defaultModel: config.defaultModel,
|
|
@@ -843,6 +1006,9 @@ ${lines.join('\n') || '- (没有启用中的角色,先在设置「子智能
|
|
|
843
1006
|
case 'maxDepth':
|
|
844
1007
|
applyConfig({ maxDepth: Number(value) });
|
|
845
1008
|
break;
|
|
1009
|
+
case 'maxTurns':
|
|
1010
|
+
applyConfig({ maxTurns: Number(value) });
|
|
1011
|
+
break;
|
|
846
1012
|
case 'approval': {
|
|
847
1013
|
const next = String(value);
|
|
848
1014
|
if (next !== 'forbid' && next !== 'ask' && next !== 'foreground') {
|
package/lib/plugins/team.js
CHANGED
|
@@ -15,7 +15,13 @@ export const teamPlugin = {
|
|
|
15
15
|
const action = String(args.action ?? '');
|
|
16
16
|
const board = readBoard(sessionId);
|
|
17
17
|
const id = String(args.id ?? '');
|
|
18
|
-
const revision = Number(args.expected_revision
|
|
18
|
+
const revision = Number(args.expected_revision);
|
|
19
|
+
// 改状态必须带版本号:不传就默认「当前版本」等于把并发冲突检测关掉,
|
|
20
|
+
// 两个队友同时认领同一条时后到的会悄悄覆盖先到的。
|
|
21
|
+
const MUTATING_ACTIONS = new Set(['claim', 'release', 'complete', 'reopen', 'delete', 'set_dependencies']);
|
|
22
|
+
if (MUTATING_ACTIONS.has(action) && !Number.isInteger(revision)) {
|
|
23
|
+
return `改任务板状态要带 expected_revision(你上次 list/create 看到的版本号,当前第 ${board.revision} 版)。`;
|
|
24
|
+
}
|
|
19
25
|
const ownerDefault = caller;
|
|
20
26
|
try {
|
|
21
27
|
switch (action) {
|
|
@@ -94,7 +100,7 @@ export const teamPlugin = {
|
|
|
94
100
|
subject: { type: 'string', description: 'create 必填:任务标题' },
|
|
95
101
|
description: { type: 'string', description: 'create:任务的详细说明(背景、验收口径)' },
|
|
96
102
|
id: { type: 'string', description: '除 create/list 外必填:任务 id,例如 t3' },
|
|
97
|
-
expected_revision: { type: 'number', description: '
|
|
103
|
+
expected_revision: { type: 'number', description: '改状态(claim/release/complete/reopen/delete/set_dependencies)必填:你上次 list/create 看到的版本号' },
|
|
98
104
|
owner: { type: 'string', description: 'claim 时的认领人;不填就是你自己' },
|
|
99
105
|
claim_now: { type: 'boolean', description: 'create:true = 建完直接算你认领(状态直接进 in_progress)' },
|
|
100
106
|
write_scopes: { type: 'array', items: { type: 'string' }, description: 'create:这个任务打算改的路径前缀,用于提醒别人别撞车' },
|
|
@@ -112,7 +118,7 @@ export const teamPlugin = {
|
|
|
112
118
|
const ready = isReady(board, task);
|
|
113
119
|
return `- ${task.id} [${task.status}${ready ? ' · 可开工' : ''}] ${task.subject}${task.owner === null ? '' : ` @${task.owner}`}`;
|
|
114
120
|
});
|
|
115
|
-
return `#
|
|
121
|
+
return `# 共享任务板
|
|
116
122
|
本会话有一块共享任务板,你可以用 team_task 工具登记要做的事、认领和结项;队友和你看到的是同一块板。
|
|
117
123
|
${lines.length === 0 ? '板上还没有任务。' : `板上的任务:\n${lines.join('\n')}`}
|
|
118
124
|
|
|
@@ -127,8 +133,8 @@ ${lines.length === 0 ? '板上还没有任务。' : `板上的任务:\n${lines
|
|
|
127
133
|
];
|
|
128
134
|
const section = {
|
|
129
135
|
id: 'team',
|
|
130
|
-
title: '
|
|
131
|
-
subtitle: '
|
|
136
|
+
title: '共享任务板',
|
|
137
|
+
subtitle: '登记、认领、结项都在本会话的任务板上;成员名单由「子智能体」提供',
|
|
132
138
|
fields,
|
|
133
139
|
values: () => ({}),
|
|
134
140
|
action: (name) => {
|