@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
|
@@ -64,6 +64,11 @@ export interface SessionIndexHit {
|
|
|
64
64
|
snippet: string;
|
|
65
65
|
/** 命中所在行号(从 1 数)。 */
|
|
66
66
|
line: number;
|
|
67
|
+
/**
|
|
68
|
+
* true = 这是宽松召回的结果:严格逐字相邻没有命中,按「每组命中多数两字词」找出来的。
|
|
69
|
+
* 调用方要把这层意思说给用户/模型(别让人把模糊命中当原话)。
|
|
70
|
+
*/
|
|
71
|
+
fuzzy?: true;
|
|
67
72
|
}
|
|
68
73
|
/** {@link SessionIndex.search} 的查询条件。 */
|
|
69
74
|
export interface SessionIndexSearchOptions {
|
|
@@ -73,6 +78,11 @@ export interface SessionIndexSearchOptions {
|
|
|
73
78
|
includeArchived?: boolean;
|
|
74
79
|
/** 只搜这个工作目录下的会话。 */
|
|
75
80
|
cwd?: string;
|
|
81
|
+
/**
|
|
82
|
+
* 严格查询一条都没命中时,是否再按「多数两字词」找一次(缺省 true)。
|
|
83
|
+
* 传 false 就只要严格结果(用于那些不能接受近似命中的调用方)。
|
|
84
|
+
*/
|
|
85
|
+
fuzzy?: boolean;
|
|
76
86
|
}
|
|
77
87
|
/** 索引现状。 */
|
|
78
88
|
export interface SessionIndexStats {
|
|
@@ -92,6 +102,30 @@ export declare function documentTerms(text: string): string[];
|
|
|
92
102
|
* 不会因为另一行同时出现「内」和「存」就误命中。
|
|
93
103
|
*/
|
|
94
104
|
export declare function queryTerms(query: string): string[];
|
|
105
|
+
/**
|
|
106
|
+
* 宽松召回用的分组:每组是「一段连续中文的相邻两字」或「一个英文整词」。
|
|
107
|
+
*
|
|
108
|
+
* 为什么要分组(2026-10-30 用户拍板 B 方案):查询「内存占用过高」按相邻两字全 AND,
|
|
109
|
+
* 等于要求原文里逐字出现这六个字,于是「内存占用一直很高」搜不到。分组之后,整段可以
|
|
110
|
+
* 按「这一组命中多数两字词」来判,既能召回换了说法的句子,又不至于把单字命中当结果。
|
|
111
|
+
*/
|
|
112
|
+
export interface QueryGroup {
|
|
113
|
+
/** 这一组的两字词(英文整词只有一项)。 */
|
|
114
|
+
terms: string[];
|
|
115
|
+
/** 这一组至少要命中几个词项才算成立(中文长段取过半,短段要求全中)。 */
|
|
116
|
+
need: number;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* 把查询切成「必须同时成立」的组,供宽松召回用。
|
|
120
|
+
*
|
|
121
|
+
* 与 {@link queryTerms} 的差别:那边把所有两字词平铺成一个 AND 列表(严格逐字相邻),
|
|
122
|
+
* 这边保留「哪几个两字词属于同一段中文」,才能按段算命中比例。
|
|
123
|
+
*
|
|
124
|
+
* @param query - 用户/模型给的查询。
|
|
125
|
+
*/
|
|
126
|
+
export declare function queryGroups(query: string): QueryGroup[];
|
|
127
|
+
/** 宽松召回有没有意义:至少一组中文段长到「全中也不成立严格查询」才有额外结果。 */
|
|
128
|
+
export declare function relaxable(groups: readonly QueryGroup[]): boolean;
|
|
95
129
|
/**
|
|
96
130
|
* 会话倒排索引。生命周期:构造 → {@link SessionIndex.load} 读一次磁盘 →
|
|
97
131
|
* 每次 {@link SessionIndex.search} 前做一次增量对齐({@link SessionIndex.sync})。
|
|
@@ -107,6 +141,8 @@ export declare class SessionIndex {
|
|
|
107
141
|
private updatedAt;
|
|
108
142
|
/** 正在跑的那次对齐;并发的 search 共用它,免得同一时刻重复扫目录。 */
|
|
109
143
|
private inflight;
|
|
144
|
+
/** 旧实例已被换下:正在跑的 sync 在下一批检查处停下,不再写盘覆盖新实例。 */
|
|
145
|
+
private disposed;
|
|
110
146
|
constructor(options: SessionIndexOptions);
|
|
111
147
|
/** 索引文件绝对路径。 */
|
|
112
148
|
indexPath(): string;
|
|
@@ -133,6 +169,20 @@ export declare class SessionIndex {
|
|
|
133
169
|
* @returns 命中列表,时间新的在前。
|
|
134
170
|
*/
|
|
135
171
|
search(query: string, options?: SessionIndexSearchOptions): Promise<SessionIndexHit[]>;
|
|
172
|
+
/** 严格 AND:每个词项都要在同一行出现(原有行为,结果不带 fuzzy 标记)。 */
|
|
173
|
+
private strictHits;
|
|
174
|
+
/**
|
|
175
|
+
* 宽松召回:按 {@link queryGroups} 的分组,每组命中数达到 need 就算这一组成立,
|
|
176
|
+
* 所有组都成立的行入选;组内命中越多排越前。
|
|
177
|
+
*
|
|
178
|
+
* 只在严格查询一条都没有时才调用,所以常规检索的结果与以前完全一致。
|
|
179
|
+
*/
|
|
180
|
+
private relaxedHits;
|
|
181
|
+
/**
|
|
182
|
+
* 这个实例不再用了(换配置重建、插件停用):让在跑的 sync 尽快停手。
|
|
183
|
+
* 不这么做的话,旧实例会在新实例落盘之后又把自己的整张表写回去,两边互相覆盖。
|
|
184
|
+
*/
|
|
185
|
+
dispose(): void;
|
|
136
186
|
/** 索引现状(设置页与自检读它)。 */
|
|
137
187
|
stats(): SessionIndexStats;
|
|
138
188
|
/** 增量对齐的主体。IO 失败一律吞在这一层,绝不让一个坏文件把整张索引带崩。 */
|
|
@@ -114,6 +114,64 @@ export function documentTerms(text) {
|
|
|
114
114
|
export function queryTerms(query) {
|
|
115
115
|
return cut(query, true);
|
|
116
116
|
}
|
|
117
|
+
/**
|
|
118
|
+
* 把查询切成「必须同时成立」的组,供宽松召回用。
|
|
119
|
+
*
|
|
120
|
+
* 与 {@link queryTerms} 的差别:那边把所有两字词平铺成一个 AND 列表(严格逐字相邻),
|
|
121
|
+
* 这边保留「哪几个两字词属于同一段中文」,才能按段算命中比例。
|
|
122
|
+
*
|
|
123
|
+
* @param query - 用户/模型给的查询。
|
|
124
|
+
*/
|
|
125
|
+
export function queryGroups(query) {
|
|
126
|
+
const groups = [];
|
|
127
|
+
let run = [];
|
|
128
|
+
let word = '';
|
|
129
|
+
const flushRun = () => {
|
|
130
|
+
if (run.length === 0)
|
|
131
|
+
return;
|
|
132
|
+
if (run.length === 1) {
|
|
133
|
+
groups.push({ terms: [run[0]], need: 1 });
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
// 词项去重:查询里重复的字符(例如「重复重复重复」)会切出同一个两字词好几次,
|
|
137
|
+
// 不去重的话 relaxedHits 会把同一处命中重复计数,一行就能凑满阈值、凭空召回。
|
|
138
|
+
const bigrams = [];
|
|
139
|
+
for (let at = 0; at + 1 < run.length; at += 1)
|
|
140
|
+
bigrams.push(run[at] + run[at + 1]);
|
|
141
|
+
const terms = [...new Set(bigrams)];
|
|
142
|
+
// 长段要求命中过半;去重后不超过两个两字词的短段要全中,与严格 AND 等价
|
|
143
|
+
const need = terms.length <= 2 ? terms.length : Math.floor(terms.length / 2) + 1;
|
|
144
|
+
groups.push({ terms, need });
|
|
145
|
+
}
|
|
146
|
+
run = [];
|
|
147
|
+
};
|
|
148
|
+
const flushWord = () => {
|
|
149
|
+
if (word !== '')
|
|
150
|
+
groups.push({ terms: [word], need: 1 });
|
|
151
|
+
word = '';
|
|
152
|
+
};
|
|
153
|
+
for (const char of query.toLowerCase()) {
|
|
154
|
+
if (isCjkChar(char)) {
|
|
155
|
+
flushWord();
|
|
156
|
+
run.push(char);
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
if (WORD_CHAR.test(char)) {
|
|
160
|
+
flushRun();
|
|
161
|
+
word += char;
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
flushRun();
|
|
165
|
+
flushWord();
|
|
166
|
+
}
|
|
167
|
+
flushRun();
|
|
168
|
+
flushWord();
|
|
169
|
+
return groups;
|
|
170
|
+
}
|
|
171
|
+
/** 宽松召回有没有意义:至少一组中文段长到「全中也不成立严格查询」才有额外结果。 */
|
|
172
|
+
export function relaxable(groups) {
|
|
173
|
+
return groups.some((group) => group.terms.length > 1 && group.need < group.terms.length);
|
|
174
|
+
}
|
|
117
175
|
/** 两个升序行号数组求交集(倒排表里的行号天然升序)。 */
|
|
118
176
|
function intersectSorted(left, right) {
|
|
119
177
|
const out = [];
|
|
@@ -285,6 +343,8 @@ export class SessionIndex {
|
|
|
285
343
|
updatedAt = 0;
|
|
286
344
|
/** 正在跑的那次对齐;并发的 search 共用它,免得同一时刻重复扫目录。 */
|
|
287
345
|
inflight = null;
|
|
346
|
+
/** 旧实例已被换下:正在跑的 sync 在下一批检查处停下,不再写盘覆盖新实例。 */
|
|
347
|
+
disposed = false;
|
|
288
348
|
constructor(options) {
|
|
289
349
|
this.options = options;
|
|
290
350
|
}
|
|
@@ -357,6 +417,8 @@ export class SessionIndex {
|
|
|
357
417
|
* @returns 这一次真正重新解析了几个文件。
|
|
358
418
|
*/
|
|
359
419
|
sync(onProgress) {
|
|
420
|
+
if (this.disposed)
|
|
421
|
+
return Promise.resolve(0);
|
|
360
422
|
if (this.inflight !== null)
|
|
361
423
|
return this.inflight;
|
|
362
424
|
const run = this.runSync(onProgress);
|
|
@@ -387,6 +449,20 @@ export class SessionIndex {
|
|
|
387
449
|
const terms = queryTerms(query);
|
|
388
450
|
if (terms.length === 0)
|
|
389
451
|
return [];
|
|
452
|
+
const includeArchived = options.includeArchived ?? this.options.includeArchived;
|
|
453
|
+
const limit = Math.max(options.limit ?? this.options.defaultLimit, 0);
|
|
454
|
+
const strict = this.strictHits(terms, includeArchived, options.cwd, limit);
|
|
455
|
+
if (strict.length > 0 || options.fuzzy === false)
|
|
456
|
+
return strict;
|
|
457
|
+
// 严格 AND 一条都没有时,按「每组命中多数两字词」再找一次(2026-10-30 用户拍板 B):
|
|
458
|
+
// 换了说法、换了行、隔了标点的句子因此能被召回,结果带上 fuzzy 标记,调用方要说明是模糊命中。
|
|
459
|
+
const groups = queryGroups(query);
|
|
460
|
+
if (!relaxable(groups))
|
|
461
|
+
return strict;
|
|
462
|
+
return this.relaxedHits(groups, includeArchived, options.cwd, limit);
|
|
463
|
+
}
|
|
464
|
+
/** 严格 AND:每个词项都要在同一行出现(原有行为,结果不带 fuzzy 标记)。 */
|
|
465
|
+
strictHits(terms, includeArchived, cwd, limit) {
|
|
390
466
|
const tables = [];
|
|
391
467
|
for (const term of terms) {
|
|
392
468
|
const table = this.postings.get(term);
|
|
@@ -397,7 +473,6 @@ export class SessionIndex {
|
|
|
397
473
|
}
|
|
398
474
|
// 从最小的倒排表开始走,能少看几个文件
|
|
399
475
|
tables.sort((left, right) => left.size - right.size);
|
|
400
|
-
const includeArchived = options.includeArchived ?? this.options.includeArchived;
|
|
401
476
|
const hits = [];
|
|
402
477
|
for (const [path, lines] of tables[0]) {
|
|
403
478
|
const file = this.files.get(path);
|
|
@@ -405,7 +480,7 @@ export class SessionIndex {
|
|
|
405
480
|
continue;
|
|
406
481
|
if (!zoneVisible(file.zone, includeArchived, this.options.includeHiddenDirs))
|
|
407
482
|
continue;
|
|
408
|
-
if (
|
|
483
|
+
if (cwd !== undefined && file.cwd !== cwd)
|
|
409
484
|
continue;
|
|
410
485
|
let matched = lines;
|
|
411
486
|
for (let at = 1; at < tables.length && matched.length > 0; at += 1) {
|
|
@@ -428,7 +503,92 @@ export class SessionIndex {
|
|
|
428
503
|
}
|
|
429
504
|
}
|
|
430
505
|
hits.sort(compareHits);
|
|
431
|
-
return hits.slice(0,
|
|
506
|
+
return hits.slice(0, limit);
|
|
507
|
+
}
|
|
508
|
+
/**
|
|
509
|
+
* 宽松召回:按 {@link queryGroups} 的分组,每组命中数达到 need 就算这一组成立,
|
|
510
|
+
* 所有组都成立的行入选;组内命中越多排越前。
|
|
511
|
+
*
|
|
512
|
+
* 只在严格查询一条都没有时才调用,所以常规检索的结果与以前完全一致。
|
|
513
|
+
*/
|
|
514
|
+
relaxedHits(groups, includeArchived, cwd, limit) {
|
|
515
|
+
// 每组:path+行号 → 这一组命中了几个词项
|
|
516
|
+
const perGroup = [];
|
|
517
|
+
for (const group of groups) {
|
|
518
|
+
const counts = new Map();
|
|
519
|
+
for (const term of group.terms) {
|
|
520
|
+
const table = this.postings.get(term);
|
|
521
|
+
if (table === undefined)
|
|
522
|
+
continue;
|
|
523
|
+
for (const [path, lines] of table) {
|
|
524
|
+
for (const line of lines) {
|
|
525
|
+
const key = path + '#' + String(line);
|
|
526
|
+
const found = counts.get(key);
|
|
527
|
+
if (found === undefined)
|
|
528
|
+
counts.set(key, { path, line, count: 1 });
|
|
529
|
+
else
|
|
530
|
+
found.count += 1;
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
const met = new Map();
|
|
535
|
+
for (const [key, entry] of counts)
|
|
536
|
+
if (entry.count >= group.need)
|
|
537
|
+
met.set(key, entry);
|
|
538
|
+
if (met.size === 0)
|
|
539
|
+
return [];
|
|
540
|
+
perGroup.push(met);
|
|
541
|
+
}
|
|
542
|
+
perGroup.sort((left, right) => left.size - right.size);
|
|
543
|
+
const terms = groups.flatMap((group) => group.terms);
|
|
544
|
+
const scored = [];
|
|
545
|
+
const [first, ...rest] = perGroup;
|
|
546
|
+
for (const [key, base] of first) {
|
|
547
|
+
let score = base.count;
|
|
548
|
+
let ok = true;
|
|
549
|
+
for (const other of rest) {
|
|
550
|
+
const found = other.get(key);
|
|
551
|
+
if (found === undefined) {
|
|
552
|
+
ok = false;
|
|
553
|
+
break;
|
|
554
|
+
}
|
|
555
|
+
score += found.count;
|
|
556
|
+
}
|
|
557
|
+
if (!ok)
|
|
558
|
+
continue;
|
|
559
|
+
const file = this.files.get(base.path);
|
|
560
|
+
if (file === undefined)
|
|
561
|
+
continue;
|
|
562
|
+
if (!zoneVisible(file.zone, includeArchived, this.options.includeHiddenDirs))
|
|
563
|
+
continue;
|
|
564
|
+
if (cwd !== undefined && file.cwd !== cwd)
|
|
565
|
+
continue;
|
|
566
|
+
const doc = file.byLine.get(base.line);
|
|
567
|
+
if (doc === undefined)
|
|
568
|
+
continue;
|
|
569
|
+
scored.push({
|
|
570
|
+
score,
|
|
571
|
+
hit: {
|
|
572
|
+
sessionId: file.sessionId,
|
|
573
|
+
file: file.path,
|
|
574
|
+
cwd: file.cwd,
|
|
575
|
+
role: doc.role,
|
|
576
|
+
ts: doc.ts,
|
|
577
|
+
snippet: snippetOf(doc.text, terms, this.options.snippetLength),
|
|
578
|
+
line: doc.line,
|
|
579
|
+
fuzzy: true,
|
|
580
|
+
},
|
|
581
|
+
});
|
|
582
|
+
}
|
|
583
|
+
scored.sort((left, right) => (left.score === right.score ? compareHits(left.hit, right.hit) : right.score - left.score));
|
|
584
|
+
return scored.slice(0, limit).map((item) => item.hit);
|
|
585
|
+
}
|
|
586
|
+
/**
|
|
587
|
+
* 这个实例不再用了(换配置重建、插件停用):让在跑的 sync 尽快停手。
|
|
588
|
+
* 不这么做的话,旧实例会在新实例落盘之后又把自己的整张表写回去,两边互相覆盖。
|
|
589
|
+
*/
|
|
590
|
+
dispose() {
|
|
591
|
+
this.disposed = true;
|
|
432
592
|
}
|
|
433
593
|
/** 索引现状(设置页与自检读它)。 */
|
|
434
594
|
stats() {
|
|
@@ -436,6 +596,8 @@ export class SessionIndex {
|
|
|
436
596
|
}
|
|
437
597
|
/** 增量对齐的主体。IO 失败一律吞在这一层,绝不让一个坏文件把整张索引带崩。 */
|
|
438
598
|
async runSync(onProgress) {
|
|
599
|
+
if (this.disposed)
|
|
600
|
+
return 0;
|
|
439
601
|
const targets = this.scanTargets();
|
|
440
602
|
const present = new Set(targets.map((target) => target.path));
|
|
441
603
|
for (const path of [...this.files.keys()]) {
|
|
@@ -453,10 +615,14 @@ export class SessionIndex {
|
|
|
453
615
|
for (const target of slice)
|
|
454
616
|
this.parseFile(target);
|
|
455
617
|
const done = at + slice.length;
|
|
618
|
+
if (this.disposed)
|
|
619
|
+
return done;
|
|
456
620
|
onProgress?.(done, changed.length);
|
|
457
621
|
if (done < changed.length)
|
|
458
622
|
await yieldToHost();
|
|
459
623
|
}
|
|
624
|
+
if (this.disposed)
|
|
625
|
+
return changed.length;
|
|
460
626
|
if (changed.length > 0)
|
|
461
627
|
this.save();
|
|
462
628
|
return changed.length;
|
package/lib/core/session.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { ChatMessage, ToolCall } from './llm.js';
|
|
2
|
-
import type { CollaborationMode, PlanHistoryItem, PlanView, TodoItemView } from '../contract.js';
|
|
2
|
+
import type { ApprovalPolicy, ApprovalReviewer, CollaborationMode, EffortLevel, PlanHistoryItem, PlanView, SandboxMode, TodoItemView, ToolPresentationView } from '../contract.js';
|
|
3
3
|
import type { GoalSnapshot } from './goal.js';
|
|
4
4
|
import { type FileChangeSummary } from './tools.js';
|
|
5
|
+
import { type UserFileAttachment } from './attachments.js';
|
|
5
6
|
/** 会话元数据(jsonl 首行 + 列表投影)。 */
|
|
6
7
|
export interface SessionMeta {
|
|
7
8
|
id: string;
|
|
@@ -24,14 +25,19 @@ export interface SessionNote {
|
|
|
24
25
|
* - `'notice'`:机器发起的唤醒(队友汇报、后台作业完成、目标续跑、定时补投……)——
|
|
25
26
|
* 出账前画输入框上方的只读「待投递通知」条,不给人编辑 / 撤掉 / 插话。
|
|
26
27
|
*
|
|
27
|
-
* 两条路落库后都是同一条 `user`
|
|
28
|
-
*
|
|
28
|
+
* 两条路落库后都是同一条 `user` 消息(模型侧无差别),但来源**要**跟着落库
|
|
29
|
+
* ({@link SessionRecord} 的 `origin` 字段,只有 `'notice'` 才写):出账那一刻界面靠它
|
|
30
|
+
* 把这批消息画成内部触发行,重开历史会话时靠同一个字段还原——不落库的话,机器通知会
|
|
31
|
+
* 长成一个能编辑、能再发一遍的用户气泡(2026-11-02 报障:后台作业完成通知就是这么冒出来的)。
|
|
32
|
+
* 协议侧不受影响:`ChatMessage.origin` 在发请求前被剥掉(见 core/llm 的 serializeMessages)。
|
|
29
33
|
*/
|
|
30
34
|
export type InboxOrigin = 'user' | 'notice';
|
|
31
|
-
/** 收件箱里的一条:正文 + 可选图 + 可选来源(缺省按 `'user'` 算,老状态条目兼容)。 */
|
|
35
|
+
/** 收件箱里的一条:正文 + 可选图 + 可选文件 + 可选来源(缺省按 `'user'` 算,老状态条目兼容)。 */
|
|
32
36
|
export interface AsyncInboxItem {
|
|
33
37
|
text: string;
|
|
34
38
|
images?: string[];
|
|
39
|
+
/** 视频 / 通用文件(图片仍走 `images`)。 */
|
|
40
|
+
files?: UserFileAttachment[];
|
|
35
41
|
/** 来源;老状态条目没有这个字段,读时按 `'user'` 兜底。 */
|
|
36
42
|
origin?: InboxOrigin;
|
|
37
43
|
}
|
|
@@ -43,6 +49,15 @@ export interface AsyncInboxItem {
|
|
|
43
49
|
* `declare module '../core/session.js' { interface SessionStateMap { memory: MyRecord } }`。
|
|
44
50
|
*/
|
|
45
51
|
export interface SessionStateMap {
|
|
52
|
+
/**
|
|
53
|
+
* 权限三项(approval / sandbox / permission-presets 写;按会话隔离,2026-10-28)。
|
|
54
|
+
* 缺项(null)= 还没钉过,读取方补默认值并钉住;钉住后改偏好不影响这个会话。
|
|
55
|
+
*/
|
|
56
|
+
permissions: {
|
|
57
|
+
sandbox: SandboxMode | null;
|
|
58
|
+
policy: ApprovalPolicy | null;
|
|
59
|
+
reviewer: ApprovalReviewer | null;
|
|
60
|
+
};
|
|
46
61
|
/** 协作模式(mode 插件写)。 */
|
|
47
62
|
mode: CollaborationMode;
|
|
48
63
|
/**
|
|
@@ -64,8 +79,14 @@ export interface SessionStateMap {
|
|
|
64
79
|
plans: {
|
|
65
80
|
items: PlanHistoryItem[];
|
|
66
81
|
};
|
|
67
|
-
/**
|
|
68
|
-
|
|
82
|
+
/**
|
|
83
|
+
* 会话目标快照(goal 插件写)。
|
|
84
|
+
*
|
|
85
|
+
* **可以是 null**:用户在目标条上点 ✕ 清空时,插件往日志追加一条 `null`。
|
|
86
|
+
* 日志是 append-only、最后一条生效,于是恢复会话读到 null 就是「这个会话没有目标」。
|
|
87
|
+
* 早期版本清空时不写这一条,导致清掉的目标重启后又冒出来(2026-11-02 报障)。
|
|
88
|
+
*/
|
|
89
|
+
goal: GoalSnapshot | null;
|
|
69
90
|
/**
|
|
70
91
|
* T39:这份会话用的模型(llm 插件在 /model 切换与设默认时写)。恢复会话优先
|
|
71
92
|
* 取它,而不是回落配置默认——会话进行到一半换过的模型不该被「重启」冲掉。
|
|
@@ -73,6 +94,7 @@ export interface SessionStateMap {
|
|
|
73
94
|
model: {
|
|
74
95
|
provider: string;
|
|
75
96
|
model: string;
|
|
97
|
+
effort?: EffortLevel;
|
|
76
98
|
};
|
|
77
99
|
/**
|
|
78
100
|
* 自我改进的记账(self-improve 插件写):本轮复盘到哪个轮次、本会话读过哪些技能。
|
|
@@ -132,6 +154,26 @@ export declare class Session {
|
|
|
132
154
|
private stream;
|
|
133
155
|
/** meta 首行是否已经写进磁盘。 */
|
|
134
156
|
private metaWritten;
|
|
157
|
+
/**
|
|
158
|
+
* 还没落盘时攒下的 state 记账记录。
|
|
159
|
+
*
|
|
160
|
+
* 为什么要有这块缓冲:新会话一建出来,权限与模型插件就立刻补默认值,原先它们
|
|
161
|
+
* 各写一条 state 就把文件建了出来——用户只是点了「新会话」、一个字都没发,磁盘
|
|
162
|
+
* 和列表里却多了一条空会话。记账先攒在内存里,等第一条真正的日志(user /
|
|
163
|
+
* assistant / tool / summary / note)落地时,再按 meta → 攒下的记录 → 这一条
|
|
164
|
+
* 的顺序一次写出;会话 id 与路径仍由 create 当场定下,侧栏、轨迹、用量照旧按
|
|
165
|
+
* sessionId 取值,不依赖文件是否存在。
|
|
166
|
+
*/
|
|
167
|
+
private pendingState;
|
|
168
|
+
/**
|
|
169
|
+
* 只改了内存、还没落盘的状态(id → 负载):读路径补默认值用。
|
|
170
|
+
*
|
|
171
|
+
* 为什么(2026-11-03「点一下老会话时间就变刚刚」):权限三项在**读**的时候补钉
|
|
172
|
+
* (见 core/permission-scope),以前一补就写盘,于是「只是点开看一眼」也会把
|
|
173
|
+
* 会话文件改一遍。改成先记在这里,等下一次真正要写日志(用户说话、切档位)时
|
|
174
|
+
* 跟着那一条一起落盘——同一进程里读到的值立刻生效,不会跟着偏好漂。
|
|
175
|
+
*/
|
|
176
|
+
private readonly deferredState;
|
|
135
177
|
/**
|
|
136
178
|
* T30 写租约:一份会话日志同一时刻只允许一个进程写。桌面端与 TUI 从同一份
|
|
137
179
|
* `.last-session` 取默认会话,没有这层时两边会交错 append、重放串线。
|
|
@@ -145,11 +187,19 @@ export declare class Session {
|
|
|
145
187
|
*/
|
|
146
188
|
readonly toolErrors: Map<string, string>;
|
|
147
189
|
/**
|
|
148
|
-
* 成功的 write / edit 的实际改动(callId →
|
|
190
|
+
* 成功的 write / edit 的实际改动(callId → 变更摘要清单),轮尾「文件已更改」卡的数据源。
|
|
149
191
|
* 与 toolErrors 同一条旁路:不挂 `messages`(协议消息透传给端点),只在 jsonl 的
|
|
150
192
|
* tool 记录里存一份,重放历史时单独交给 transcript 折成 `kind: 'changes'` 条目。
|
|
193
|
+
*
|
|
194
|
+
* 为什么是清单(2026-10-30):PTC 的 `run_code` 一次调用能改好几个文件;以前这里只收
|
|
195
|
+
* 单个 `changes`,多文件场景要么丢、要么只剩最后一个。
|
|
196
|
+
*/
|
|
197
|
+
readonly fileChanges: Map<string, FileChangeSummary[]>;
|
|
198
|
+
/**
|
|
199
|
+
* dsh 插件给的卡片数据(callId → 卡片视图),与 fileChanges 同一条旁路:
|
|
200
|
+
* 只活在日志里,重放历史时交给 transcript 折成 tool/presentation 事件。
|
|
151
201
|
*/
|
|
152
|
-
readonly
|
|
202
|
+
readonly presentations: Map<string, ToolPresentationView>;
|
|
153
203
|
/**
|
|
154
204
|
* 回合内文件基线(codex `TurnDiffTracker` 的同款思路):本回合第一次动某个文件时
|
|
155
205
|
* 记下「动之前的全文」,回合收尾用它和盘上现值重算一份聚合 diff——同一文件改
|
|
@@ -191,8 +241,22 @@ export declare class Session {
|
|
|
191
241
|
*
|
|
192
242
|
* `ts` 只写一份给内存与磁盘共用:界面按它显示「这条消息几点发的」,
|
|
193
243
|
* 也是这一轮「用时」的起点(见 contract.ts 的 TranscriptEntry.ts)。
|
|
244
|
+
*
|
|
245
|
+
* @param origin - 谁发起的这条(缺省 `'user'`)。只有 `'notice'`(机器投递)会写进日志,
|
|
246
|
+
* 界面与重放据此把它画成内部触发行而不是用户气泡(见 {@link InboxOrigin})。
|
|
194
247
|
*/
|
|
195
|
-
appendUser(text: string, images?: string[]): void;
|
|
248
|
+
appendUser(text: string, images?: string[], files?: UserFileAttachment[], origin?: InboxOrigin): void;
|
|
249
|
+
/**
|
|
250
|
+
* 作废第 keep 条用户消息及其之后的一切(「编辑并重发」用,2026-11-03)。
|
|
251
|
+
*
|
|
252
|
+
* 语义:保留前 keep 条人打的用户消息与它们各自的回答,从第 keep 条(0 基)开始整段丢掉,
|
|
253
|
+
* 之后由调用方 appendUser 把改过的文字重新写进去。**日志一个字都不删**——落一条
|
|
254
|
+
* `rewind` 记录声明「从这里往后作废」,重放按同一条规则截断(见 load 的 `case 'rewind'`)。
|
|
255
|
+
*
|
|
256
|
+
* @param keep - 保留几轮(人打的用户消息条数)。
|
|
257
|
+
* @returns false = 这条消息已经不在会话里(序号越界),调用方应当如实回报而不是硬改。
|
|
258
|
+
*/
|
|
259
|
+
rewindToUser(keep: number): boolean;
|
|
196
260
|
appendAssistant(text: string, reasoning: string, toolCalls: ToolCall[]): void;
|
|
197
261
|
/**
|
|
198
262
|
* 追加工具结果。output 为对象时支持附带图像(data URL),消息以多模态
|
|
@@ -203,7 +267,8 @@ export declare class Session {
|
|
|
203
267
|
appendTool(callId: string, name: string, output: string | {
|
|
204
268
|
text: string;
|
|
205
269
|
images?: string[];
|
|
206
|
-
changes?: FileChangeSummary;
|
|
270
|
+
changes?: FileChangeSummary | FileChangeSummary[];
|
|
271
|
+
presentation?: ToolPresentationView;
|
|
207
272
|
}, error?: string): void;
|
|
208
273
|
/**
|
|
209
274
|
* 循环在每次成功的 write / edit 落库时调:本回合首次触碰这个文件就记下「动之前的全文」
|
|
@@ -246,6 +311,14 @@ export declare class Session {
|
|
|
246
311
|
* @param payload - 这个功能点自己的负载。
|
|
247
312
|
*/
|
|
248
313
|
appendState<K extends keyof SessionStateMap>(id: K, payload: SessionStateMap[K]): void;
|
|
314
|
+
/**
|
|
315
|
+
* 只改内存里的状态,等下一次真正写日志时再落盘(读路径补默认值专用)。
|
|
316
|
+
*
|
|
317
|
+
* 与 {@link appendState} 的区别:这里的值由后续写盘顺带带出,所以「只打开一次
|
|
318
|
+
* 会话、什么都没做」不会再改动文件(mtime 不变,侧栏的「最近使用」也就不会跳)。
|
|
319
|
+
* 同一进程里读到的值立刻生效,和落过盘没有区别。
|
|
320
|
+
*/
|
|
321
|
+
setState<K extends keyof SessionStateMap>(id: K, payload: SessionStateMap[K]): void;
|
|
249
322
|
/**
|
|
250
323
|
* 异步输入入箱:回合跑动中到达的输入先在这里排队(state 条目持久化,重启不丢),
|
|
251
324
|
* 等 loop 在步骤边界/回合收尾时出账落库。见 {@link SessionStateMap} 的
|
|
@@ -253,7 +326,7 @@ export declare class Session {
|
|
|
253
326
|
* @param origin - 这条是用户来源还是机器来源(缺省 `'user'`,老调用点行为不变)。
|
|
254
327
|
* 只有 `'notice'` 会被记进条目(`'user'` 保持条目形状与老状态一致,读时兜底)。
|
|
255
328
|
*/
|
|
256
|
-
enqueueAsync(text: string, images?: string[], origin?: InboxOrigin): void;
|
|
329
|
+
enqueueAsync(text: string, images?: string[], origin?: InboxOrigin, files?: UserFileAttachment[]): void;
|
|
257
330
|
/**
|
|
258
331
|
* 收件箱只读快照:界面照它画输入框下方的「排队消息」条(用户来源)与输入框上方的
|
|
259
332
|
* 「待投递通知」条(机器来源)。只偷看,不取货也不动日志——取货是 {@link takeAsyncInbox}。
|
|
@@ -296,7 +369,8 @@ export declare class Session {
|
|
|
296
369
|
}
|
|
297
370
|
/**
|
|
298
371
|
* 列表投影的一行:读一个 jsonl 文件得到的元数据 + sidecar 属性 + 文件路径。
|
|
299
|
-
* `updatedAt`
|
|
372
|
+
* `updatedAt` 是「最后一步」的时刻(最后一条带 `ts` 的对话记录,见
|
|
373
|
+
* {@link lastActivityAt}),是「最近使用」的排序依据;文件 mtime 只用来做读盘缓存的键。
|
|
300
374
|
*/
|
|
301
375
|
export interface SessionListItem {
|
|
302
376
|
/** 会话 uuid。 */
|
|
@@ -304,7 +378,7 @@ export interface SessionListItem {
|
|
|
304
378
|
cwd: string;
|
|
305
379
|
/** 创建时间(meta 首行)。 */
|
|
306
380
|
createdAt: number;
|
|
307
|
-
/**
|
|
381
|
+
/** 最后一步的时刻:最后一条带 `ts` 的对话记录;老日志没有 ts 时回落文件 mtime。 */
|
|
308
382
|
updatedAt: number;
|
|
309
383
|
/** 展示标题:用户改过的标题优先,否则首条用户消息截断。 */
|
|
310
384
|
title?: string;
|
|
@@ -352,5 +426,7 @@ export declare function countTrashFiles(): number;
|
|
|
352
426
|
export declare function forkSession(filePath: string, beforeUserMessage: number): string;
|
|
353
427
|
/** 读一个会话里的用户消息(分叉菜单用它选分叉位置,下标一一对应)。 */
|
|
354
428
|
export declare function readUserMessages(filePath: string): string[];
|
|
429
|
+
/** 文件名就是 `<uuid>.jsonl`,取 uuid 用来写 sidecar。 */
|
|
430
|
+
export declare function uuidOf(filePath: string): string;
|
|
355
431
|
export declare function saveLastSession(session: Session): void;
|
|
356
432
|
export declare function loadLastSessionPath(): string | null;
|