@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
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dsh 服务桥(第一版,**只读**):把 Pneuma 的会话历史与用量日志,按 dsh 的
|
|
3
|
+
* `sessions` / `sessionPersistence` 的形状露给外部插件。
|
|
4
|
+
*
|
|
5
|
+
* 为什么要有它:`dsh-cost-meter` 这类插件在运行时 `ctx.get('sessionPersistence')` 现取,
|
|
6
|
+
* 取到 `undefined` 就静默少一段功能——「装得上」与「用得了」是两件事。判定表
|
|
7
|
+
* (`service-map.ts`)早就把这两个名字标成 `adapted`:有对应物、形状不同、必须写适配器。
|
|
8
|
+
*
|
|
9
|
+
* ## 边界(重要)
|
|
10
|
+
*
|
|
11
|
+
* 只实现**读**。dsh 的 `create` / `append` 要求「写所有权」与 seq 单调,而 Pneuma 的会话
|
|
12
|
+
* 由内核的回合循环独占写入;给插件开写口等于两套写者改同一份会话记录,坏的是用户的历史。
|
|
13
|
+
* 所以写方法一律抛一条中文错误,**不做静默 no-op**——静默会让插件以为写成功了。
|
|
14
|
+
*
|
|
15
|
+
* ## 字段口径
|
|
16
|
+
*
|
|
17
|
+
* 形状照 dsh 的声明抄(`SessionPersistenceSnapshot` / `SessionPersistenceListOptions` /
|
|
18
|
+
* `SessionPageRequest`,以及内部调用点上出现的 `create` / `open` / `stat` / `list`)。
|
|
19
|
+
* **没有逐字段核对过 dsh 的运行时**,所以刻意只给最小面:多给一个字段就多一个猜错的机会。
|
|
20
|
+
* 真包验收(见 docs/dsh-service-bridge-plan.md 第三步)之后再来收紧。
|
|
21
|
+
*
|
|
22
|
+
* 事件流怎么来:
|
|
23
|
+
* - 会话 jsonl 的一行 = 一个事件,**翻译成 dsh 的事件类型**(`user/message` /
|
|
24
|
+
* `assistant/message` / `tool/result`),并把正文包成 dsh 的消息形状
|
|
25
|
+
* (`{ id, role, content: 内容块[], source }`)。为什么不原样丢行:插件是按
|
|
26
|
+
* dsh 的类型认的——`dsh-cost-meter` 的 backfill / context-costs / trajectory
|
|
27
|
+
* 只认 `assistant/message`,拿 `assistant` 行去喂它等于没喂。
|
|
28
|
+
* - 每次模型调用的 token 用量在 `~/.dsc/usage/usage.jsonl`(不在会话日志里),
|
|
29
|
+
* 按 `sid` 归到会话上:**并进它前面最近的那条 assistant/message**(dsh 的用量就
|
|
30
|
+
* 挂在助手消息上,不单独成事件)。前面没有助手消息可挂时,才落一条
|
|
31
|
+
* `llm/usage` 扩展事件(带 `ignorable`,不认识的插件可以跳过)。
|
|
32
|
+
* - `seq` 是事件在这个视图里的位置(1 起);`time` 是行上的 `ts`(毫秒)。
|
|
33
|
+
*
|
|
34
|
+
* @module dsc/core/dsh-compat/session-bridge
|
|
35
|
+
*/
|
|
36
|
+
import { existsSync, readFileSync, statSync } from 'node:fs';
|
|
37
|
+
import { listSessions } from '../session.js';
|
|
38
|
+
import { usageLogFile } from '../usage-log.js';
|
|
39
|
+
import { toDshUsage } from './llm-usage-event.js';
|
|
40
|
+
/** 写侧的唯一一句话:为什么不行、怎么办。 */
|
|
41
|
+
const WRITE_REFUSAL = 'dsh 的会话写句柄在 Pneuma 里不可用:会话由内核的回合循环独占写入,第二套写者会改坏用户的会话记录。' +
|
|
42
|
+
'只读接口(list / stat / open(…, "read"))可以照常用。';
|
|
43
|
+
/** 读一份文件的全部行;坏行跳过(与宿主读会话的口径一致)。 */
|
|
44
|
+
function linesOf(path) {
|
|
45
|
+
try {
|
|
46
|
+
return readFileSync(path, 'utf8').split(/\r?\n/);
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return [];
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* 用量日志按会话归档(只读请求行;工具行没有 token,算账用不上)。
|
|
54
|
+
*
|
|
55
|
+
* 结果按文件的 mtime+size 缓存:一份用了几周的 usage.jsonl 能有几万行,而插件会按秒
|
|
56
|
+
* 轮询 `stat()`——每次都整文件重解析是白烧 CPU。追加一行就会改 mtime,所以缓存不会旧。
|
|
57
|
+
*/
|
|
58
|
+
let usageCache = null;
|
|
59
|
+
function usageBySession() {
|
|
60
|
+
const file = usageLogFile();
|
|
61
|
+
const stamp = (() => {
|
|
62
|
+
try {
|
|
63
|
+
const info = statSync(file);
|
|
64
|
+
return `${String(info.mtimeMs)}:${String(info.size)}`;
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
return '';
|
|
68
|
+
}
|
|
69
|
+
})();
|
|
70
|
+
if (stamp !== '' && usageCache !== null && usageCache.stamp === stamp)
|
|
71
|
+
return usageCache.rows;
|
|
72
|
+
const out = new Map();
|
|
73
|
+
if (!existsSync(file)) {
|
|
74
|
+
usageCache = { stamp: '', rows: out };
|
|
75
|
+
return out;
|
|
76
|
+
}
|
|
77
|
+
for (const line of linesOf(file)) {
|
|
78
|
+
if (line.trim() === '')
|
|
79
|
+
continue;
|
|
80
|
+
let row;
|
|
81
|
+
try {
|
|
82
|
+
row = JSON.parse(line);
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
if (row === null || typeof row !== 'object')
|
|
88
|
+
continue;
|
|
89
|
+
const record = row;
|
|
90
|
+
if (record.k !== undefined)
|
|
91
|
+
continue; // 工具行
|
|
92
|
+
if (typeof record.sid !== 'string' || typeof record.i !== 'number' || typeof record.o !== 'number')
|
|
93
|
+
continue;
|
|
94
|
+
if (typeof record.t !== 'number')
|
|
95
|
+
continue;
|
|
96
|
+
const list = out.get(record.sid) ?? [];
|
|
97
|
+
list.push(record);
|
|
98
|
+
out.set(record.sid, list);
|
|
99
|
+
}
|
|
100
|
+
usageCache = { stamp, rows: out };
|
|
101
|
+
return out;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* 一个会话的全部事件:先 jsonl 的逐行事件,再按时间把用量事件并进去。
|
|
105
|
+
*
|
|
106
|
+
* 合并方式:两边都按时间戳排序后归并(会话行用 `ts`,缺 `ts` 的老行排在最前)。
|
|
107
|
+
* seq 是事件在**这个视图里**的位置(1 起),不是文件行号——因为并进来之后行号会错位,
|
|
108
|
+
* 而 dsh 的游标语义是「事件序号」,不是「文件行」。
|
|
109
|
+
*/
|
|
110
|
+
/** 一条消息的身份:稳定、可复现(同一份日志读两次给同一个 id)。 */
|
|
111
|
+
function messageIdOf(sessionId, index) {
|
|
112
|
+
return `pneuma-${sessionId}-${String(index)}`;
|
|
113
|
+
}
|
|
114
|
+
/** 把一行会话记录翻成 dsh 的事件(认不出的行按 `ignorable` 原样透传)。 */
|
|
115
|
+
function eventOfRow(row, sessionId, index) {
|
|
116
|
+
const type = typeof row['type'] === 'string' ? row['type'] : 'unknown';
|
|
117
|
+
const id = messageIdOf(sessionId, index);
|
|
118
|
+
if (type === 'meta')
|
|
119
|
+
return undefined;
|
|
120
|
+
if (type === 'user') {
|
|
121
|
+
return {
|
|
122
|
+
type: 'user/message',
|
|
123
|
+
data: {
|
|
124
|
+
id,
|
|
125
|
+
role: 'user',
|
|
126
|
+
content: typeof row['text'] === 'string' ? [{ type: 'text', text: row['text'] }] : [],
|
|
127
|
+
source: { kind: 'user' },
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
if (type === 'assistant') {
|
|
132
|
+
const content = [];
|
|
133
|
+
if (typeof row['text'] === 'string' && row['text'] !== '')
|
|
134
|
+
content.push({ type: 'text', text: row['text'] });
|
|
135
|
+
if (typeof row['reasoning'] === 'string' && row['reasoning'] !== '')
|
|
136
|
+
content.push({ type: 'reasoning', text: row['reasoning'] });
|
|
137
|
+
const calls = Array.isArray(row['toolCalls']) ? row['toolCalls'] : [];
|
|
138
|
+
for (const call of calls) {
|
|
139
|
+
content.push({
|
|
140
|
+
type: 'tool-call',
|
|
141
|
+
id: typeof call['id'] === 'string' ? call['id'] : '',
|
|
142
|
+
name: typeof call['name'] === 'string' ? call['name'] : '',
|
|
143
|
+
arguments: typeof call['arguments'] === 'string' ? call['arguments'] : JSON.stringify(call['arguments'] ?? {}),
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
return {
|
|
147
|
+
type: 'assistant/message',
|
|
148
|
+
data: {
|
|
149
|
+
// 历史里没有 dsh 的步骤编号(我们的日志不记),给 0:插件拿它对齐时间线时
|
|
150
|
+
// 得到的是「同一步」而不是一个大得离谱的数。
|
|
151
|
+
turn: 0,
|
|
152
|
+
step: 0,
|
|
153
|
+
message: { id, role: 'assistant', content, source: { kind: 'model', provider: '', model: '' } },
|
|
154
|
+
stream: [],
|
|
155
|
+
},
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
if (type === 'tool') {
|
|
159
|
+
const callId = typeof row['callId'] === 'string' ? row['callId'] : '';
|
|
160
|
+
return {
|
|
161
|
+
type: 'tool/result',
|
|
162
|
+
data: {
|
|
163
|
+
turn: 0,
|
|
164
|
+
step: 0,
|
|
165
|
+
message: {
|
|
166
|
+
id,
|
|
167
|
+
role: 'tool',
|
|
168
|
+
content: typeof row['text'] === 'string' ? [{ type: 'text', text: row['text'] }] : [],
|
|
169
|
+
source: { kind: 'tool', callId },
|
|
170
|
+
toolCallId: callId,
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
// 剩下的都是 Pneuma 自己的记录(state 之类):原样给,标 ignorable 让插件放手跳过。
|
|
176
|
+
return { type, data: row, ignorable: true };
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* 一个会话的全部事件:jsonl 逐行翻译,再把用量并进助手消息。
|
|
180
|
+
*
|
|
181
|
+
* 合并方式:先按时间戳排序(会话行用 `ts`,缺 `ts` 的老行排在最前),再顺序扫一遍;
|
|
182
|
+
* 每条用量挂到**它前面最近的那条、还没挂过用量的** `assistant/message` 上。
|
|
183
|
+
* 挂不上(前面没有助手消息)才落一条 `llm/usage` 扩展事件,不丢数。
|
|
184
|
+
*/
|
|
185
|
+
function eventsOf(path, usage, sessionId) {
|
|
186
|
+
const rows = [];
|
|
187
|
+
let fallbackAt = 0;
|
|
188
|
+
let index = 0;
|
|
189
|
+
for (const line of linesOf(path)) {
|
|
190
|
+
if (line.trim() === '')
|
|
191
|
+
continue;
|
|
192
|
+
let row;
|
|
193
|
+
try {
|
|
194
|
+
row = JSON.parse(line);
|
|
195
|
+
}
|
|
196
|
+
catch {
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
199
|
+
const at = typeof row['ts'] === 'number' ? row['ts'] : fallbackAt;
|
|
200
|
+
fallbackAt += 1;
|
|
201
|
+
index += 1;
|
|
202
|
+
const event = eventOfRow(row, sessionId, index);
|
|
203
|
+
if (event !== undefined)
|
|
204
|
+
rows.push({ at, event });
|
|
205
|
+
}
|
|
206
|
+
for (const record of usage) {
|
|
207
|
+
rows.push({
|
|
208
|
+
at: record.t,
|
|
209
|
+
event: {
|
|
210
|
+
type: 'llm/usage',
|
|
211
|
+
ignorable: true,
|
|
212
|
+
data: {
|
|
213
|
+
provider: record.provider,
|
|
214
|
+
model: record.model,
|
|
215
|
+
...toDshUsage({
|
|
216
|
+
inputTokens: record.i,
|
|
217
|
+
outputTokens: record.o,
|
|
218
|
+
...(record.ch === undefined ? {} : { cacheHitTokens: record.ch }),
|
|
219
|
+
...(record.cm === undefined ? {} : { cacheMissTokens: record.cm }),
|
|
220
|
+
}),
|
|
221
|
+
at: record.t,
|
|
222
|
+
},
|
|
223
|
+
},
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
const ordered = rows.sort((a, b) => a.at - b.at);
|
|
227
|
+
/** 已经挂进助手消息的那些用量事件(后面从时间线里剔掉,别重复计数)。 */
|
|
228
|
+
const attached = new Set();
|
|
229
|
+
/** 最近一条还没挂用量的助手消息(按时间往前找,找到就挂)。 */
|
|
230
|
+
let lastAssistant = null;
|
|
231
|
+
for (const row of ordered) {
|
|
232
|
+
const { event } = row;
|
|
233
|
+
if (event.type === 'assistant/message') {
|
|
234
|
+
lastAssistant = { data: event.data, hasUsage: false };
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
237
|
+
if (event.type !== 'llm/usage' || lastAssistant === null || lastAssistant.hasUsage)
|
|
238
|
+
continue;
|
|
239
|
+
// 用量并进助手消息:这就是 dsh 的读法(用量不长在单独的事件上)。
|
|
240
|
+
// 整份搬过去、不再换算一次——那两个数字已经是 dsh 口径,换算两遍会把输入算成 0。
|
|
241
|
+
const { provider, model, at: _at, ...usageOnly } = event.data;
|
|
242
|
+
lastAssistant.data['usage'] = usageOnly;
|
|
243
|
+
const message = lastAssistant.data['message'];
|
|
244
|
+
if (message?.source !== undefined) {
|
|
245
|
+
message.source['provider'] = provider;
|
|
246
|
+
message.source['model'] = model;
|
|
247
|
+
}
|
|
248
|
+
lastAssistant.hasUsage = true;
|
|
249
|
+
// 挂上了就把这条独立的用量事件从时间线里拿掉(它已经以 usage 的形式活在消息里)。
|
|
250
|
+
attached.add(event);
|
|
251
|
+
}
|
|
252
|
+
return ordered
|
|
253
|
+
.filter((row) => !attached.has(row.event))
|
|
254
|
+
.map((row, position) => ({ ...row.event, seq: position + 1, time: row.at }));
|
|
255
|
+
}
|
|
256
|
+
/** 一个会话文件的快照(stat 与句柄共用,免得两处口径不一)。 */
|
|
257
|
+
function snapshotOf(item, eventCount, sizeBytes) {
|
|
258
|
+
return {
|
|
259
|
+
header: { id: item.id, cwd: item.cwd, createdAt: item.createdAt },
|
|
260
|
+
formatStatus: 'current',
|
|
261
|
+
// revision 用「事件数 + 字节数」:够插件判断「读到的这一份有没有变」,不假装是内容哈希。
|
|
262
|
+
revision: `${String(eventCount)}:${String(sizeBytes)}`,
|
|
263
|
+
eventCount,
|
|
264
|
+
sizeBytes,
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* 会话清单的短时缓存:
|
|
269
|
+
*
|
|
270
|
+
* 为什么要有:`list()` 要给每个会话读一遍 jsonl 才能数事件,几十个会话就是几十次读盘;
|
|
271
|
+
* 而插件(费用条这类)会按秒轮询。2 秒的窗口够挡住「同一帧里问三遍」,又不会让新会话
|
|
272
|
+
* 看不见。缓存里存的是**读盘结果**,不是授权——过期就重读。
|
|
273
|
+
*/
|
|
274
|
+
const LIST_TTL_MS = 2_000;
|
|
275
|
+
let listCache = null;
|
|
276
|
+
/** 造一个只读的 `sessionPersistence`。 */
|
|
277
|
+
export function createSessionPersistenceBridge() {
|
|
278
|
+
const handleOf = (sessionId) => {
|
|
279
|
+
const item = listSessions().find((candidate) => candidate.id === sessionId);
|
|
280
|
+
if (item === undefined)
|
|
281
|
+
throw new Error(`没有这个会话:${sessionId}`);
|
|
282
|
+
const events = eventsOf(item.path, usageBySession().get(sessionId) ?? [], sessionId);
|
|
283
|
+
return {
|
|
284
|
+
sessionId,
|
|
285
|
+
header: { id: item.id, cwd: item.cwd, createdAt: item.createdAt },
|
|
286
|
+
// dsh 的「继承事件数」是 fork 时带过来的前缀条数;Pneuma 没有 fork 概念,恒 0。
|
|
287
|
+
inheritedEventCount: 0,
|
|
288
|
+
read(range) {
|
|
289
|
+
// 两种调用形态都要吃:dsh 那条传的是**数字偏移**(从这一号 seq 开始取),
|
|
290
|
+
// 本仓库的探针传对象(three cursors)。分成两条路各自都好读,不合并成一个万能参数。
|
|
291
|
+
if (typeof range === 'number') {
|
|
292
|
+
const start = Math.max(0, range);
|
|
293
|
+
const slice = events.filter((event) => event.seq >= start);
|
|
294
|
+
return { events: slice, hasMore: false };
|
|
295
|
+
}
|
|
296
|
+
const through = range?.throughSeq;
|
|
297
|
+
const before = range?.beforeSeq;
|
|
298
|
+
const max = range?.maxMessages;
|
|
299
|
+
let slice = events;
|
|
300
|
+
if (through !== undefined)
|
|
301
|
+
slice = slice.filter((event) => event.seq <= through);
|
|
302
|
+
if (before !== undefined)
|
|
303
|
+
slice = slice.filter((event) => event.seq < before);
|
|
304
|
+
const limited = max === undefined ? slice : slice.slice(0, Math.max(0, max));
|
|
305
|
+
return { events: limited, hasMore: limited.length < slice.length };
|
|
306
|
+
},
|
|
307
|
+
close() {
|
|
308
|
+
/* 只读句柄没有要释放的东西;留着只为对上 dsh 的接口形状。 */
|
|
309
|
+
},
|
|
310
|
+
};
|
|
311
|
+
};
|
|
312
|
+
return {
|
|
313
|
+
list() {
|
|
314
|
+
if (listCache !== null && Date.now() - listCache.at < LIST_TTL_MS)
|
|
315
|
+
return listCache.rows;
|
|
316
|
+
const usage = usageBySession();
|
|
317
|
+
const rows = listSessions().map((item) => {
|
|
318
|
+
const events = eventsOf(item.path, usage.get(item.id) ?? [], item.id);
|
|
319
|
+
return snapshotOf(item, events.length, existsSync(item.path) ? statSync(item.path).size : 0);
|
|
320
|
+
});
|
|
321
|
+
listCache = { at: Date.now(), rows };
|
|
322
|
+
return rows;
|
|
323
|
+
},
|
|
324
|
+
stat(sessionId) {
|
|
325
|
+
const item = listSessions().find((candidate) => candidate.id === sessionId);
|
|
326
|
+
if (item === undefined)
|
|
327
|
+
return undefined;
|
|
328
|
+
const events = eventsOf(item.path, usageBySession().get(sessionId) ?? [], sessionId);
|
|
329
|
+
return snapshotOf(item, events.length, existsSync(item.path) ? statSync(item.path).size : 0);
|
|
330
|
+
},
|
|
331
|
+
open(sessionId, mode = 'read') {
|
|
332
|
+
if (mode !== 'read')
|
|
333
|
+
throw new Error(WRITE_REFUSAL);
|
|
334
|
+
return handleOf(sessionId);
|
|
335
|
+
},
|
|
336
|
+
create() {
|
|
337
|
+
throw new Error(WRITE_REFUSAL);
|
|
338
|
+
},
|
|
339
|
+
append() {
|
|
340
|
+
throw new Error(WRITE_REFUSAL);
|
|
341
|
+
},
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
/** 造一个只读的 `sessions`。 */
|
|
345
|
+
export function createSessionsBridge() {
|
|
346
|
+
const rows = () => listSessions().map((item) => ({
|
|
347
|
+
sessionId: item.id,
|
|
348
|
+
cwd: item.cwd,
|
|
349
|
+
createdAt: item.createdAt,
|
|
350
|
+
...(item.title === undefined ? {} : { title: item.title }),
|
|
351
|
+
// live:pinned 不表示活着;这里没有「正在跑」的判据,一律 false,别假装知道。
|
|
352
|
+
live: false,
|
|
353
|
+
persisted: true,
|
|
354
|
+
}));
|
|
355
|
+
return {
|
|
356
|
+
list: rows,
|
|
357
|
+
get(sessionId) {
|
|
358
|
+
return rows().find((row) => row.sessionId === sessionId);
|
|
359
|
+
},
|
|
360
|
+
has(sessionId) {
|
|
361
|
+
return rows().some((row) => row.sessionId === sessionId);
|
|
362
|
+
},
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* 按名字取一个桥(compat 的 `ctx.get` 兜底用)。
|
|
367
|
+
* @param name - 服务名
|
|
368
|
+
* @returns 桥;不归这座桥管的服务给 undefined(交给上层继续判缺)
|
|
369
|
+
*/
|
|
370
|
+
export function compatServiceOf(name) {
|
|
371
|
+
if (name === 'sessionPersistence')
|
|
372
|
+
return createSessionPersistenceBridge();
|
|
373
|
+
if (name === 'sessions')
|
|
374
|
+
return createSessionsBridge();
|
|
375
|
+
return undefined;
|
|
376
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { CoreEvent } from '../events.js';
|
|
2
|
+
/** 事件名。抽成常量:发布侧与自检都引它,拼错一个字符就两边同时红。 */
|
|
3
|
+
export declare const DSH_SESSION_EVENT = "session/event";
|
|
4
|
+
/** 发出去的一条事件。 */
|
|
5
|
+
export interface DshSessionEvent {
|
|
6
|
+
type: string;
|
|
7
|
+
seq: number;
|
|
8
|
+
time: number;
|
|
9
|
+
data: Record<string, unknown>;
|
|
10
|
+
/** 会改动模型可见面的那几类事件带这个;生命周期事件不许有。 */
|
|
11
|
+
surfaceOp?: 'append';
|
|
12
|
+
}
|
|
13
|
+
/** 交给监听者的只读会话视图。字段名对着 dsh 的 Session,只留读得到的。 */
|
|
14
|
+
export interface DshSessionCarrierView {
|
|
15
|
+
readonly id: string;
|
|
16
|
+
readonly header: {
|
|
17
|
+
readonly id: string;
|
|
18
|
+
readonly cwd?: string;
|
|
19
|
+
readonly createdAt?: number;
|
|
20
|
+
};
|
|
21
|
+
readonly cwd?: string;
|
|
22
|
+
/** 最近发出去的事件(最多 256 条)。 */
|
|
23
|
+
readonly events: readonly DshSessionEvent[];
|
|
24
|
+
}
|
|
25
|
+
/** 桥的构造参数。 */
|
|
26
|
+
export interface DshSessionEventBridgeOptions {
|
|
27
|
+
/** 宿主上下文:事件在它上面派发(兼容层插件的监听器也在同一棵树上)。 */
|
|
28
|
+
readonly ctx: unknown;
|
|
29
|
+
readonly sessionId: string;
|
|
30
|
+
readonly cwd?: string;
|
|
31
|
+
readonly createdAt?: number;
|
|
32
|
+
/**
|
|
33
|
+
* 当前路由。每条助手消息都要带 provider / model(dsh 的 MessageSource 要求),
|
|
34
|
+
* 而我们的用量事件只带 model——所以问一次宿主要答案。
|
|
35
|
+
*/
|
|
36
|
+
readonly route?: () => {
|
|
37
|
+
provider: string;
|
|
38
|
+
model: string;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/** 桥的对外面。 */
|
|
42
|
+
export interface DshSessionEventBridge {
|
|
43
|
+
/** 投喂一条内核事件。非回合事件自动忽略,永不抛错。 */
|
|
44
|
+
publish(event: CoreEvent): void;
|
|
45
|
+
/** 交给监听者的那个只读视图。 */
|
|
46
|
+
readonly carrier: DshSessionCarrierView;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* 造一座桥。**一个会话一座**:`seq` / `turn` / `step` 都是它的内部状态。
|
|
50
|
+
*
|
|
51
|
+
* @param options - 会话身份、宿主上下文与路由读取方式
|
|
52
|
+
* @returns 可以投喂内核事件的桥
|
|
53
|
+
*/
|
|
54
|
+
export declare function createDshSessionEventBridge(options: DshSessionEventBridgeOptions): DshSessionEventBridge;
|