@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,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 把一次模型调用的用量,按 dsh 的 `llm/stream` 事件发出去。
|
|
3
|
+
*
|
|
4
|
+
* 为什么需要:dsh 的计费类插件(`dsh-cost-meter` 就是)记**实时花费**不听用量日志,而是
|
|
5
|
+
* 在 `llm/stream` 这个 **waterfall 事件**上包一层流:拿到下游流之后自己逐个 chunk 读,
|
|
6
|
+
* 见到 `{ type: 'usage', usage }` 就记账,再把 chunk 原样吐给调用方。只做会话历史读取
|
|
7
|
+
* (core/dsh-compat/session-bridge)不会让它有数——2026-10-26 真包验收时确认过。
|
|
8
|
+
*
|
|
9
|
+
* 我们这边没有 dsh 那种流式 chunk 协议,所以走**最小可信的合成**:把这一次调用的用量
|
|
10
|
+
* 包成**唯一一个 chunk** 交出去,然后把这个(被插件包过的)迭代器消费掉,让插件的
|
|
11
|
+
* `finally` 与记账逻辑跑完。谁也没看见假数据:chunk 里的数字就是本次请求真实的 token 数。
|
|
12
|
+
*
|
|
13
|
+
* 边界:这条事件只影响「听它的插件」,不改变回合本身的流式路径——我们的流仍然是回调式
|
|
14
|
+
* (`LlmService.stream` 的 handlers),这里只是并行发一条旁路读数。插件抛错一律吞掉:
|
|
15
|
+
* 记账失败绝不能把用户的回合带崩。
|
|
16
|
+
*
|
|
17
|
+
* @module dsc/core/dsh-compat/llm-usage-event
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* 把我们的用量换算成 dsh 的分项。
|
|
21
|
+
*
|
|
22
|
+
* 两边的口径不一样,直接抄会**多算钱**:我们的 `inputTokens` 是 prompt_tokens 总量,
|
|
23
|
+
* 缓存命中**包含在内**;dsh 的 `inputTokens` 只算未命中的部分,命中另记
|
|
24
|
+
* `cacheReadTokens`,计费时三项相加。照搬就把命中那部分按未命中价又收了一遍。
|
|
25
|
+
*
|
|
26
|
+
* `cacheWriteTokens` 一律 0:我们这边没有「缓存写入」这个概念(命中的补集是未命中,
|
|
27
|
+
* 不是写入)。dsh 的 `totalTokens` 是四项相加,这里按同一口径给出。
|
|
28
|
+
*
|
|
29
|
+
* @param usage - 内核读数
|
|
30
|
+
* @returns dsh 口径的分项
|
|
31
|
+
*/
|
|
32
|
+
export function toDshUsage(usage) {
|
|
33
|
+
const hit = usage.cacheHitTokens ?? 0;
|
|
34
|
+
const miss = usage.cacheMissTokens ?? Math.max(usage.inputTokens - hit, 0);
|
|
35
|
+
return {
|
|
36
|
+
inputTokens: Math.max(miss, 0),
|
|
37
|
+
outputTokens: usage.outputTokens,
|
|
38
|
+
cacheReadTokens: Math.max(hit, 0),
|
|
39
|
+
cacheWriteTokens: 0,
|
|
40
|
+
reasoningTokens: usage.reasoningTokens ?? 0,
|
|
41
|
+
totalTokens: Math.max(miss, 0) + usage.outputTokens + Math.max(hit, 0),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/** 事件名。抽成常量:发布侧与自检都引它,拼错一个字符就两边同时红。 */
|
|
45
|
+
export const LLM_STREAM_EVENT = 'llm/stream';
|
|
46
|
+
/**
|
|
47
|
+
* 派发一次 `llm/stream`,把用量作为唯一 chunk 交给监听者链。
|
|
48
|
+
*
|
|
49
|
+
* @param ctx - 宿主上下文(waterfall 在它上面派发)
|
|
50
|
+
* @param info - 本次调用的用量与会话归属
|
|
51
|
+
* @returns 派发完成(无论有没有监听者);永不抛错
|
|
52
|
+
*/
|
|
53
|
+
export async function publishDshUsage(ctx, info) {
|
|
54
|
+
const chunk = {
|
|
55
|
+
type: 'usage',
|
|
56
|
+
// 分项换算在一处:两个出口(流旁路与事件旁路)必须同一口径,不然同一个回合
|
|
57
|
+
// 在两处会报出两个不同的数。
|
|
58
|
+
usage: toDshUsage({
|
|
59
|
+
inputTokens: info.inputTokens,
|
|
60
|
+
outputTokens: info.outputTokens,
|
|
61
|
+
...(info.cacheHitTokens === undefined ? {} : { cacheHitTokens: info.cacheHitTokens }),
|
|
62
|
+
...(info.cacheMissTokens === undefined ? {} : { cacheMissTokens: info.cacheMissTokens }),
|
|
63
|
+
...(info.reasoningTokens === undefined ? {} : { reasoningTokens: info.reasoningTokens }),
|
|
64
|
+
}),
|
|
65
|
+
};
|
|
66
|
+
const next = async function* () {
|
|
67
|
+
yield chunk;
|
|
68
|
+
};
|
|
69
|
+
try {
|
|
70
|
+
// 形状按 cordis 的 waterfall 约定:最后一个参数是 next,监听者可以「包住」它。
|
|
71
|
+
const dispatch = ctx.waterfall;
|
|
72
|
+
if (typeof dispatch !== 'function')
|
|
73
|
+
return;
|
|
74
|
+
const stream = dispatch.call(ctx, LLM_STREAM_EVENT, {
|
|
75
|
+
sessionId: info.sessionId,
|
|
76
|
+
provider: info.provider,
|
|
77
|
+
model: info.model,
|
|
78
|
+
}, next);
|
|
79
|
+
const iterator = stream?.[Symbol.asyncIterator];
|
|
80
|
+
if (iterator === undefined)
|
|
81
|
+
return;
|
|
82
|
+
// 必须消费完:插件在 `finally` 里记账与释放,不消费就永远不跑。
|
|
83
|
+
for await (const ignored of stream)
|
|
84
|
+
void ignored;
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
// 记账是旁路:插件抛错不该影响用户的回合。留一行 warn 给排查,不写进对话流。
|
|
88
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
89
|
+
process.stderr.write(`[dsh-compat] llm/stream 旁路派发失败(不影响回合):${reason}\n`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dsh 的两样「呈现」数据:卡片视图(presentCall / presentResult)与规范值校验。
|
|
3
|
+
*
|
|
4
|
+
* 为什么单开一个文件:这两件事都只在兼容层出现——Pneuma 自己的工具直接返回文本或
|
|
5
|
+
* 文本+图像,没有卡片视图概念,也不需要校验返回值(返回值就是给人看的文本)。
|
|
6
|
+
*
|
|
7
|
+
* 卡片词汇照 dsh 的 `packages/core/tools/src/presentation.ts` 抄一份(**不引它的包**:
|
|
8
|
+
* 兼容层与 dsh 源码零耦合,抄的是形状)。它用 `card` 标签区分六种:
|
|
9
|
+
* - `generic`:标题 + 可选内容块 + 可跟随的文件位置(默认卡)
|
|
10
|
+
* - `terminal`:一条命令 + 工作目录 + 输出(终端卡)
|
|
11
|
+
* - `diff`:每个被改文件一条 `{ path, oldText, newText }`(内联 diff 卡)
|
|
12
|
+
* - `search` / `read` / `web`:搜索结果、按行号的文件窗口、网页抓取结果
|
|
13
|
+
*
|
|
14
|
+
* 我们**不重画**六种卡:宿主把卡片 JSON 原样落盘、界面按 `card` 取用(现在只认
|
|
15
|
+
* `diff` 与 `terminal` 两种,其余回落通用工具卡),没认出来的数据也不会丢。
|
|
16
|
+
*
|
|
17
|
+
* @module dsc/core/dsh-compat/presentation
|
|
18
|
+
*/
|
|
19
|
+
import type { ToolPresentation } from '../tools.js';
|
|
20
|
+
export type { ToolPresentation };
|
|
21
|
+
/** dsh 卡片标签(六种结果卡 + 三种调用卡的并集)。 */
|
|
22
|
+
export type DshCardTag = 'generic' | 'terminal' | 'diff' | 'search' | 'read' | 'web';
|
|
23
|
+
/** 一张卡片视图(字段按 dsh 的契约取,未列出的字段原样保留)。 */
|
|
24
|
+
export interface DshCardView {
|
|
25
|
+
card: DshCardTag;
|
|
26
|
+
title?: string;
|
|
27
|
+
/** generic / terminal 的正文内容块(dsh 的 ContentBlock[];这里不解释,原样留给界面)。 */
|
|
28
|
+
content?: unknown;
|
|
29
|
+
/** terminal 卡:命令、说明、工作目录。 */
|
|
30
|
+
command?: string;
|
|
31
|
+
description?: string;
|
|
32
|
+
cwd?: string;
|
|
33
|
+
output?: string;
|
|
34
|
+
exitCode?: number;
|
|
35
|
+
/** diff 卡:每个被改文件一条。 */
|
|
36
|
+
diffs?: readonly {
|
|
37
|
+
path: string;
|
|
38
|
+
oldText: string | null;
|
|
39
|
+
newText: string;
|
|
40
|
+
}[];
|
|
41
|
+
/** read 卡:按行号的文件窗口。 */
|
|
42
|
+
path?: string;
|
|
43
|
+
lines?: readonly {
|
|
44
|
+
number: number;
|
|
45
|
+
text: string;
|
|
46
|
+
}[];
|
|
47
|
+
/** 其余字段原样保留(dsh 加字段时不至于丢数据)。 */
|
|
48
|
+
[key: string]: unknown;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* 把 dsh 的 presentCall / presentResult 返回值收敛成一张卡片视图。
|
|
52
|
+
*
|
|
53
|
+
* 收敛口径:必须是个对象、`card` 是认识的标签,否则返回 undefined(当作没有卡片,
|
|
54
|
+
* 界面回落通用工具卡)。**不做深校验**——卡片是展示用的,展示错了比崩了强。
|
|
55
|
+
* @param raw - presentCall / presentResult 的返回值
|
|
56
|
+
* @returns 卡片视图;认不出就是 undefined
|
|
57
|
+
*/
|
|
58
|
+
export declare function asCardView(raw: unknown): DshCardView | undefined;
|
|
59
|
+
/** JSON Schema 节点(dsh 的 output.schema 是它;这里只认常用的那几个关键字)。 */
|
|
60
|
+
export type JsonSchemaNode = boolean | {
|
|
61
|
+
type?: string | readonly string[];
|
|
62
|
+
properties?: Record<string, JsonSchemaNode>;
|
|
63
|
+
required?: readonly string[];
|
|
64
|
+
items?: JsonSchemaNode;
|
|
65
|
+
enum?: readonly unknown[];
|
|
66
|
+
const?: unknown;
|
|
67
|
+
additionalProperties?: boolean | JsonSchemaNode;
|
|
68
|
+
anyOf?: readonly JsonSchemaNode[];
|
|
69
|
+
oneOf?: readonly JsonSchemaNode[];
|
|
70
|
+
allOf?: readonly JsonSchemaNode[];
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* 按 dsh 的 output.schema 校验一次工具返回值(「规范值」契约)。
|
|
74
|
+
*
|
|
75
|
+
* 只实现 dsh 用到的那一小撮关键字:type / properties / required / items / enum /
|
|
76
|
+
* const / additionalProperties / anyOf / oneOf / allOf。校验失败**返回违规清单**
|
|
77
|
+
* (JSON Pointer 形式,空串表示根),由调用方决定怎么报——dsh 是抛 ToolArgsError,
|
|
78
|
+
* 我们抛一条中文 Error,让模型看到「工具的返回值不合自己声明的 schema」。
|
|
79
|
+
* @param schema - 工具声明的 schema(boolean 形式的 schema 也认:true 放行、false 一律拒)
|
|
80
|
+
* @param value - 工具返回的规范值
|
|
81
|
+
* @param path - 当前 JSON Pointer(递归用)
|
|
82
|
+
* @returns 违规清单(空数组 = 通过)
|
|
83
|
+
*/
|
|
84
|
+
export declare function validateOutput(schema: JsonSchemaNode, value: unknown, path?: string): string[];
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
const CARDS = new Set(['generic', 'terminal', 'diff', 'search', 'read', 'web']);
|
|
2
|
+
/**
|
|
3
|
+
* 把 dsh 的 presentCall / presentResult 返回值收敛成一张卡片视图。
|
|
4
|
+
*
|
|
5
|
+
* 收敛口径:必须是个对象、`card` 是认识的标签,否则返回 undefined(当作没有卡片,
|
|
6
|
+
* 界面回落通用工具卡)。**不做深校验**——卡片是展示用的,展示错了比崩了强。
|
|
7
|
+
* @param raw - presentCall / presentResult 的返回值
|
|
8
|
+
* @returns 卡片视图;认不出就是 undefined
|
|
9
|
+
*/
|
|
10
|
+
export function asCardView(raw) {
|
|
11
|
+
if (raw === null || typeof raw !== 'object')
|
|
12
|
+
return undefined;
|
|
13
|
+
const record = raw;
|
|
14
|
+
const card = record['card'];
|
|
15
|
+
if (typeof card !== 'string' || !CARDS.has(card))
|
|
16
|
+
return undefined;
|
|
17
|
+
return record;
|
|
18
|
+
}
|
|
19
|
+
/** 一个值的 JSON 类型名(与 JSON Schema 的 type 取值对齐)。 */
|
|
20
|
+
function jsonTypeOf(value) {
|
|
21
|
+
if (value === null)
|
|
22
|
+
return 'null';
|
|
23
|
+
if (Array.isArray(value))
|
|
24
|
+
return 'array';
|
|
25
|
+
if (typeof value === 'number')
|
|
26
|
+
return Number.isInteger(value) ? 'integer' : 'number';
|
|
27
|
+
return typeof value;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* 按 dsh 的 output.schema 校验一次工具返回值(「规范值」契约)。
|
|
31
|
+
*
|
|
32
|
+
* 只实现 dsh 用到的那一小撮关键字:type / properties / required / items / enum /
|
|
33
|
+
* const / additionalProperties / anyOf / oneOf / allOf。校验失败**返回违规清单**
|
|
34
|
+
* (JSON Pointer 形式,空串表示根),由调用方决定怎么报——dsh 是抛 ToolArgsError,
|
|
35
|
+
* 我们抛一条中文 Error,让模型看到「工具的返回值不合自己声明的 schema」。
|
|
36
|
+
* @param schema - 工具声明的 schema(boolean 形式的 schema 也认:true 放行、false 一律拒)
|
|
37
|
+
* @param value - 工具返回的规范值
|
|
38
|
+
* @param path - 当前 JSON Pointer(递归用)
|
|
39
|
+
* @returns 违规清单(空数组 = 通过)
|
|
40
|
+
*/
|
|
41
|
+
export function validateOutput(schema, value, path = '') {
|
|
42
|
+
if (schema === true)
|
|
43
|
+
return [];
|
|
44
|
+
if (schema === false)
|
|
45
|
+
return [`${path === '' ? '/' : path}:schema 声明为 false,任何值都不许返回`];
|
|
46
|
+
const where = path === '' ? '/' : path;
|
|
47
|
+
const violations = [];
|
|
48
|
+
if (schema.type !== undefined) {
|
|
49
|
+
const wanted = typeof schema.type === 'string' ? [schema.type] : schema.type;
|
|
50
|
+
const actual = jsonTypeOf(value);
|
|
51
|
+
// JSON Schema 的 number 也接受整数;integer 不接受小数。
|
|
52
|
+
const ok = wanted.includes(actual) ||
|
|
53
|
+
(actual === 'integer' && wanted.includes('number'));
|
|
54
|
+
if (!ok) {
|
|
55
|
+
violations.push(`${where}:期望类型 ${wanted.join('|')},实际是 ${actual}`);
|
|
56
|
+
return violations;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (schema.enum !== undefined && !schema.enum.some((item) => JSON.stringify(item) === JSON.stringify(value))) {
|
|
60
|
+
violations.push(`${where}:取值不在枚举 ${JSON.stringify(schema.enum)} 里`);
|
|
61
|
+
}
|
|
62
|
+
if (schema.const !== undefined && JSON.stringify(schema.const) !== JSON.stringify(value)) {
|
|
63
|
+
violations.push(`${where}:取值应当恒为 ${JSON.stringify(schema.const)}`);
|
|
64
|
+
}
|
|
65
|
+
for (const [index, branch] of (schema.allOf ?? []).entries()) {
|
|
66
|
+
violations.push(...validateOutput(branch, value, path).map((item) => `allOf[${String(index)}] ${item}`));
|
|
67
|
+
}
|
|
68
|
+
if (schema.anyOf !== undefined && !schema.anyOf.some((branch) => validateOutput(branch, value, path).length === 0)) {
|
|
69
|
+
violations.push(`${where}:不满足 anyOf 里的任何一支`);
|
|
70
|
+
}
|
|
71
|
+
if (schema.oneOf !== undefined && schema.oneOf.filter((branch) => validateOutput(branch, value, path).length === 0).length !== 1) {
|
|
72
|
+
violations.push(`${where}:oneOf 要求恰好满足一支`);
|
|
73
|
+
}
|
|
74
|
+
if (Array.isArray(value) && schema.items !== undefined) {
|
|
75
|
+
for (const [index, item] of value.entries()) {
|
|
76
|
+
violations.push(...validateOutput(schema.items, item, `${path}/${String(index)}`));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (value !== null && typeof value === 'object' && !Array.isArray(value)) {
|
|
80
|
+
const record = value;
|
|
81
|
+
for (const name of schema.required ?? []) {
|
|
82
|
+
if (!(name in record))
|
|
83
|
+
violations.push(`${path}/${name}:缺少必填字段`);
|
|
84
|
+
}
|
|
85
|
+
for (const [name, node] of Object.entries(schema.properties ?? {})) {
|
|
86
|
+
if (name in record)
|
|
87
|
+
violations.push(...validateOutput(node, record[name], `${path}/${name}`));
|
|
88
|
+
}
|
|
89
|
+
if (schema.additionalProperties === false) {
|
|
90
|
+
const known = new Set(Object.keys(schema.properties ?? {}));
|
|
91
|
+
for (const name of Object.keys(record)) {
|
|
92
|
+
if (!known.has(name))
|
|
93
|
+
violations.push(`${path}/${name}:schema 没声明的多余字段`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
else if (schema.additionalProperties !== undefined && typeof schema.additionalProperties === 'object') {
|
|
97
|
+
const known = new Set(Object.keys(schema.properties ?? {}));
|
|
98
|
+
for (const name of Object.keys(record)) {
|
|
99
|
+
if (!known.has(name))
|
|
100
|
+
violations.push(...validateOutput(schema.additionalProperties, record[name], `${path}/${name}`));
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return violations;
|
|
105
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* @param
|
|
2
|
+
* 注册解析钩子(幂等;重复调用只追加解析根)。
|
|
3
|
+
* @param pluginRoots - 允许重定向的插件目录(`~/.dsc/plugins/`、profile 的 node_modules)
|
|
4
4
|
*/
|
|
5
|
-
export declare function ensureResolveHook(
|
|
5
|
+
export declare function ensureResolveHook(pluginRoots: readonly string[]): void;
|
|
@@ -3,26 +3,50 @@
|
|
|
3
3
|
*
|
|
4
4
|
* dsh 外部插件以裸说明符 import dsh 生态的库(`@deepseek-ai/dsh-tools` 的
|
|
5
5
|
* defineTool、`@deepseek-ai/schemastery` 的 z……)。这些文件装在 `~/.dsc/plugins/`
|
|
6
|
-
* 下,Node 的解析走不到 dsc 自带的 node_modules
|
|
7
|
-
*
|
|
8
|
-
* node_modules(以及 dsh-tools 自身的真实目录,pnpm 的传递依赖在那里)按 ESM
|
|
9
|
-
* 条件重新解析。双构建包(schemastery 这类)因此会命中与 dsh-tools 内部 import
|
|
10
|
-
* 完全相同的文件,不会出现 CJS/ESM 双实例的 instanceof 分裂。
|
|
6
|
+
* 或 profile 的 `node_modules/` 下,Node 的解析走不到 dsc 自带的 node_modules。
|
|
7
|
+
* 本钩子做两件事:
|
|
11
8
|
*
|
|
12
|
-
*
|
|
9
|
+
* 1. `@deepseek-ai/` 开头的说明符,改从 dsc 运行时的 node_modules 重新解析
|
|
10
|
+
* (双构建包因此命中与 dsh-tools 内部 import 完全相同的文件,不出现 CJS/ESM 双实例)。
|
|
11
|
+
* 2. 两个 **dsh 宿主库**换成我们自己的实现({@link SHIMS}):它们不是随便哪个
|
|
12
|
+
* 第三方包,而是「用户数据目录在哪」「凭据引用怎么建」这两件宿主才知道的事,
|
|
13
|
+
* 照 dsh 的原样返回 `~/.dsh` 会把插件的账本写到别人家里去。
|
|
14
|
+
*
|
|
15
|
+
* 为什么用 `registerHooks`(同步、本线程)而不是 `register`(异步、hooks 线程):
|
|
13
16
|
* 注册完成即可生效,挂载路径不必等钩子线程就绪,也没有跨线程状态要传。
|
|
14
17
|
*
|
|
18
|
+
* 解析根可以**后加**:外部插件目录在启动时就位,profile 的组合包目录要等读到
|
|
19
|
+
* 配置才知道,所以 `ensureResolveHook` 可重复调用,后加的名字追加进同一份闭包。
|
|
20
|
+
*
|
|
15
21
|
* @module dsc/core/dsh-compat/resolve-hook
|
|
16
22
|
*/
|
|
17
23
|
import { registerHooks, createRequire } from 'node:module';
|
|
18
24
|
import { join } from 'node:path';
|
|
19
25
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
20
26
|
let registered = false;
|
|
27
|
+
/** 允许重定向的目录(各以 `/` 结尾的 file: URL);后加的名字追加到这份数组。 */
|
|
28
|
+
const roots = [];
|
|
29
|
+
/**
|
|
30
|
+
* 用 Pneuma 自己的实现顶替的 dsh 宿主库。
|
|
31
|
+
*
|
|
32
|
+
* 只收「语义完全由宿主决定、且 dsh 的默认值在 Pneuma 上是错的」两个:
|
|
33
|
+
* home-paths 的默认根是 `~/.dsh`,不当宿主就会把插件数据写进 dsh 的家目录;
|
|
34
|
+
* credentials 的 credentialRef 只是「校验过的字符串」,不需要 dsh 的凭据库。
|
|
35
|
+
*/
|
|
36
|
+
const SHIMS = {
|
|
37
|
+
'@deepseek-ai/dsh-home-paths': './shims/home-paths.js',
|
|
38
|
+
'@deepseek-ai/dsh-credentials': './shims/credentials.js',
|
|
39
|
+
};
|
|
21
40
|
/**
|
|
22
|
-
*
|
|
23
|
-
* @param
|
|
41
|
+
* 注册解析钩子(幂等;重复调用只追加解析根)。
|
|
42
|
+
* @param pluginRoots - 允许重定向的插件目录(`~/.dsc/plugins/`、profile 的 node_modules)
|
|
24
43
|
*/
|
|
25
|
-
export function ensureResolveHook(
|
|
44
|
+
export function ensureResolveHook(pluginRoots) {
|
|
45
|
+
for (const root of pluginRoots) {
|
|
46
|
+
const url = `${pathToFileURL(root).href.replace(/\/+$/, '')}/`;
|
|
47
|
+
if (!roots.includes(url))
|
|
48
|
+
roots.push(url);
|
|
49
|
+
}
|
|
26
50
|
if (registered)
|
|
27
51
|
return;
|
|
28
52
|
registered = true;
|
|
@@ -36,13 +60,17 @@ export function ensureResolveHook(pluginsRoots) {
|
|
|
36
60
|
catch {
|
|
37
61
|
// 没装 dsh-tools 就只剩 dsc 根目录一个基点:插件 import 时会响亮失败
|
|
38
62
|
}
|
|
39
|
-
const
|
|
63
|
+
const shimUrls = new Map(Object.entries(SHIMS).map(([specifier, file]) => [specifier, new URL(file, import.meta.url).href]));
|
|
40
64
|
registerHooks({
|
|
41
65
|
resolve(specifier, context, nextResolve) {
|
|
42
66
|
const parent = context.parentURL ?? '';
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
67
|
+
const fromPlugin = parent.startsWith('file:') && roots.some((root) => parent.startsWith(root));
|
|
68
|
+
if (!fromPlugin)
|
|
69
|
+
return nextResolve(specifier, context);
|
|
70
|
+
const shim = shimUrls.get(specifier);
|
|
71
|
+
if (shim !== undefined)
|
|
72
|
+
return { url: shim, shortCircuit: true };
|
|
73
|
+
if (specifier.startsWith('@deepseek-ai/')) {
|
|
46
74
|
for (const base of bases) {
|
|
47
75
|
try {
|
|
48
76
|
// 借基点目录当 parent:裸说明符解析只用目录做向上查走,假文件名不要求存在
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dsh 服务名 → Pneuma 的判定表(兼容层拒绝插件时用来说人话)。
|
|
3
|
+
*
|
|
4
|
+
* 为什么要有这张表:插件 `inject` 里出现 Pneuma 不认识的服务名时,一句「超出兼容层范围」
|
|
5
|
+
* 对插件作者没有用——他不知道差在哪、也不知道该换成什么。这张表给每个常见 dsh 服务名
|
|
6
|
+
* 一句判定:**能直传**(同名同义,本来就在 Pneuma 的服务清单里)、**有对应但语义不同**
|
|
7
|
+
* (必须写适配器,直接透传会静默错)、**没有对应**(拒绝并说明)。
|
|
8
|
+
*
|
|
9
|
+
* 口径来自对 dsh 源码的逐条核对(服务定义文件与 Pneuma 的方法签名两侧对照),
|
|
10
|
+
* 判定有分歧时以「照原名直传会不会静默错」为准——宁可拒绝,不要装上一个一调就炸的服务。
|
|
11
|
+
*
|
|
12
|
+
* @module dsc/core/dsh-compat/service-map
|
|
13
|
+
*/
|
|
14
|
+
/** 一个 dsh 服务名在 Pneuma 这边的判定。 */
|
|
15
|
+
export type DshServiceVerdict =
|
|
16
|
+
/** 同名同义:Pneuma 也有这个服务,形状由兼容层/适配器吸收。 */
|
|
17
|
+
{
|
|
18
|
+
tier: 'same';
|
|
19
|
+
}
|
|
20
|
+
/** 有对应物但语义或 API 不同:必须先有适配器,直接透传会静默错。 */
|
|
21
|
+
| {
|
|
22
|
+
tier: 'adapted';
|
|
23
|
+
pneuma: string;
|
|
24
|
+
note: string;
|
|
25
|
+
}
|
|
26
|
+
/** Pneuma 没有对应,或对应物根本不是一回事:拒绝。 */
|
|
27
|
+
| {
|
|
28
|
+
tier: 'missing';
|
|
29
|
+
note: string;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* 判定表。键是 dsh 的服务名。
|
|
33
|
+
*
|
|
34
|
+
* 只收「插件真会 inject 的」那些;dsh 的客户端(界面)服务不在此列——那是阶段 D 的事。
|
|
35
|
+
*
|
|
36
|
+
* `sessionPersistence` 与 `sessions` 走的是「兼容层 `ctx.get` 兜底」:真挂载时它们由
|
|
37
|
+
* core/dsh-compat/session-bridge 现造一个只读桥交出去。写进 `inject` 仍会被拒(cordis
|
|
38
|
+
* 的服务表里没有这两个名字,等不到)——插件改成 `ctx.get` 即可,dsh 自己的 cost-meter
|
|
39
|
+
* 就是这种写法。
|
|
40
|
+
*/
|
|
41
|
+
export declare const DSH_SERVICE_MAP: Readonly<Record<string, DshServiceVerdict>>;
|
|
42
|
+
/** 查一个 dsh 服务名的判定;没收录给 undefined。 */
|
|
43
|
+
export declare function dshServiceVerdict(name: string): DshServiceVerdict | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* 把一批不认识的服务名折成一句人话(插件挂不上时写进诊断)。
|
|
46
|
+
*
|
|
47
|
+
* @param names - 插件 inject 里 Pneuma 不认识的名字
|
|
48
|
+
* @returns 中文说明(一行一条,分号隔开)
|
|
49
|
+
* @example
|
|
50
|
+
* // "sessionProjections(Pneuma 没有事件投影系统);sessions(dsh 是多会话注册表,Pneuma 只有当前会话)"
|
|
51
|
+
*/
|
|
52
|
+
export declare function describeForeignServices(names: readonly string[]): string;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dsh 服务名 → Pneuma 的判定表(兼容层拒绝插件时用来说人话)。
|
|
3
|
+
*
|
|
4
|
+
* 为什么要有这张表:插件 `inject` 里出现 Pneuma 不认识的服务名时,一句「超出兼容层范围」
|
|
5
|
+
* 对插件作者没有用——他不知道差在哪、也不知道该换成什么。这张表给每个常见 dsh 服务名
|
|
6
|
+
* 一句判定:**能直传**(同名同义,本来就在 Pneuma 的服务清单里)、**有对应但语义不同**
|
|
7
|
+
* (必须写适配器,直接透传会静默错)、**没有对应**(拒绝并说明)。
|
|
8
|
+
*
|
|
9
|
+
* 口径来自对 dsh 源码的逐条核对(服务定义文件与 Pneuma 的方法签名两侧对照),
|
|
10
|
+
* 判定有分歧时以「照原名直传会不会静默错」为准——宁可拒绝,不要装上一个一调就炸的服务。
|
|
11
|
+
*
|
|
12
|
+
* @module dsc/core/dsh-compat/service-map
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* 判定表。键是 dsh 的服务名。
|
|
16
|
+
*
|
|
17
|
+
* 只收「插件真会 inject 的」那些;dsh 的客户端(界面)服务不在此列——那是阶段 D 的事。
|
|
18
|
+
*
|
|
19
|
+
* `sessionPersistence` 与 `sessions` 走的是「兼容层 `ctx.get` 兜底」:真挂载时它们由
|
|
20
|
+
* core/dsh-compat/session-bridge 现造一个只读桥交出去。写进 `inject` 仍会被拒(cordis
|
|
21
|
+
* 的服务表里没有这两个名字,等不到)——插件改成 `ctx.get` 即可,dsh 自己的 cost-meter
|
|
22
|
+
* 就是这种写法。
|
|
23
|
+
*/
|
|
24
|
+
export const DSH_SERVICE_MAP = {
|
|
25
|
+
// ── 同名同义(Pneuma 有同名服务,本来就不算 foreign) ──────────────────────
|
|
26
|
+
tools: { tier: 'same' },
|
|
27
|
+
commands: { tier: 'same' },
|
|
28
|
+
approval: { tier: 'same' },
|
|
29
|
+
skills: { tier: 'same' },
|
|
30
|
+
compaction: { tier: 'adapted', pneuma: 'compact', note: 'dsh 的压缩服务带 agent 参数,Pneuma 只压当前会话' },
|
|
31
|
+
permissionPresets: { tier: 'adapted', pneuma: 'permissionPresets', note: 'dsh 按会话写预设,Pneuma 写的是用户偏好' },
|
|
32
|
+
// ── 有对应但语义不同 ──────────────────────────────────────────────────────
|
|
33
|
+
llm: { tier: 'adapted', pneuma: 'llm', note: 'dsh 的 llm 不存当前模型,Pneuma 的 llm 是选路单例;读 provider 会拿到不同东西' },
|
|
34
|
+
sessions: { tier: 'adapted', pneuma: 'sessions(只读桥)', note: 'dsh 是多会话注册表;Pneuma 给一份只读的会话清单(list / get / has),没有 fork、prompt 这些写口' },
|
|
35
|
+
sessionPersistence: { tier: 'adapted', pneuma: 'sessions(只读桥)', note: 'dsh 是事件溯源的持久化(create / open / stat + 读写句柄);Pneuma 只给 list / stat / open(read) / read,写方法响亮拒绝——会话由内核独占写入' },
|
|
36
|
+
agents: { tier: 'adapted', pneuma: 'agent', note: 'dsh 是 agent 注册表,Pneuma 只有当前回合循环;子智能体走 team' },
|
|
37
|
+
settings: { tier: 'adapted', pneuma: 'settings', note: '同名不同物:dsh 是插件 Config 表单,Pneuma 是应用设置' },
|
|
38
|
+
systemPrompt: { tier: 'adapted', pneuma: 'prompt', note: 'dsh 是结构化 section,Pneuma 是 register(id, text, order)' },
|
|
39
|
+
goals: { tier: 'adapted', pneuma: 'goal', note: 'dsh 的调用都带 agent,Pneuma 是单例 store' },
|
|
40
|
+
planMode: { tier: 'adapted', pneuma: 'plan', note: 'dsh 是计划模式开关,Pneuma 是「交计划等批」' },
|
|
41
|
+
sandbox: { tier: 'adapted', pneuma: 'sandbox', note: 'dsh 包进程执行,Pneuma 只判路径能不能写' },
|
|
42
|
+
userQuestions: { tier: 'adapted', pneuma: 'ask', note: '异名近义,按 ask 的接口改写' },
|
|
43
|
+
sessionQuery: { tier: 'adapted', pneuma: 'sessionSearch', note: '异名近义,按全文检索改写' },
|
|
44
|
+
agentPresets: { tier: 'adapted', pneuma: 'presets', note: '异名近义,Pneuma 的模式是 md 文件' },
|
|
45
|
+
subagents: { tier: 'adapted', pneuma: 'team', note: '异名近义,Pneuma 只有队友名册' },
|
|
46
|
+
mcpResources: { tier: 'adapted', pneuma: 'mcp', note: 'dsh 只给资源,Pneuma 有 servers/tools/call' },
|
|
47
|
+
// ── 没有对应 ──────────────────────────────────────────────────────────────
|
|
48
|
+
sessionProjections: { tier: 'missing', note: 'Pneuma 没有事件投影系统' },
|
|
49
|
+
schedule: { tier: 'missing', note: 'Pneuma 的 schedule 只在服务名单里登记过名字,没有实现' },
|
|
50
|
+
jobs: { tier: 'missing', note: 'Pneuma 没有作业服务(后台活只到 backgroundWorks 快照)' },
|
|
51
|
+
storage: { tier: 'missing', note: 'Pneuma 让插件自己落盘' },
|
|
52
|
+
fs: { tier: 'missing', note: '请改用 node:fs' },
|
|
53
|
+
shell: { tier: 'missing', note: 'Pneuma 没有 shell 服务' },
|
|
54
|
+
terminal: { tier: 'missing', note: 'Pneuma 的终端是界面插件,不是宿主服务' },
|
|
55
|
+
workspaces: { tier: 'missing', note: 'Pneuma 没有工作区注册表' },
|
|
56
|
+
web: { tier: 'missing', note: 'Pneuma 没有 web 服务' },
|
|
57
|
+
clientModules: { tier: 'missing', note: 'Pneuma 没有前端模块注册表' },
|
|
58
|
+
agentLoop: { tier: 'missing', note: 'Pneuma 的回合循环是 agent 插件内部实现' },
|
|
59
|
+
tokenMeter: { tier: 'missing', note: 'Pneuma 没有 token 计量服务' },
|
|
60
|
+
spillStore: { tier: 'missing', note: 'Pneuma 的大输出溢出是 DSL 插件自己的事' },
|
|
61
|
+
};
|
|
62
|
+
/** 查一个 dsh 服务名的判定;没收录给 undefined。 */
|
|
63
|
+
export function dshServiceVerdict(name) {
|
|
64
|
+
return DSH_SERVICE_MAP[name];
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* 把一批不认识的服务名折成一句人话(插件挂不上时写进诊断)。
|
|
68
|
+
*
|
|
69
|
+
* @param names - 插件 inject 里 Pneuma 不认识的名字
|
|
70
|
+
* @returns 中文说明(一行一条,分号隔开)
|
|
71
|
+
* @example
|
|
72
|
+
* // "sessionProjections(Pneuma 没有事件投影系统);sessions(dsh 是多会话注册表,Pneuma 只有当前会话)"
|
|
73
|
+
*/
|
|
74
|
+
export function describeForeignServices(names) {
|
|
75
|
+
return names
|
|
76
|
+
.map((name) => {
|
|
77
|
+
const verdict = DSH_SERVICE_MAP[name];
|
|
78
|
+
if (verdict === undefined)
|
|
79
|
+
return `${name}(Pneuma 不认识这个服务名)`;
|
|
80
|
+
if (verdict.tier === 'same')
|
|
81
|
+
return `${name}(同名同义,但这次挂载没走到它,可能是加载顺序问题)`;
|
|
82
|
+
if (verdict.tier === 'adapted')
|
|
83
|
+
return `${name}(dsh 侧有对应:${verdict.pneuma}。${verdict.note})`;
|
|
84
|
+
return `${name}(${verdict.note})`;
|
|
85
|
+
})
|
|
86
|
+
.join(';');
|
|
87
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/** dsh 的事件最简形:类型 + seq + 时间 + 载荷。字段少了有插件读不到,多了我们也猜不准。 */
|
|
2
|
+
export interface BridgeEvent {
|
|
3
|
+
readonly seq: number;
|
|
4
|
+
readonly type: string;
|
|
5
|
+
/** Unix 毫秒。dsh 的每条事件都带,按时间排序/算耗时的插件要用。 */
|
|
6
|
+
readonly time: number;
|
|
7
|
+
/** dsh 形状的载荷(消息类事件包着 `{ id, role, content, source }`)。 */
|
|
8
|
+
readonly data: Record<string, unknown>;
|
|
9
|
+
/**
|
|
10
|
+
* `true` = 不认识的读者可以安全跳过。dsh 用这个标记「纯信息性记录」,
|
|
11
|
+
* 我们只给两种自造事件打:`state`(Pneuma 的会话状态行)与 `llm/usage`(没处挂的用量)。
|
|
12
|
+
*/
|
|
13
|
+
readonly ignorable?: true;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* `stat()` 的返回(照 dsh 的 `SessionPersistenceSnapshot` 取最小集)。
|
|
17
|
+
*
|
|
18
|
+
* `header.id` 这个字段名是**照着真实消费方核过的**:`dsh-cost-meter` 的
|
|
19
|
+
* `sessionRowOf()` 只认 `header.id`,写 `sessionId` 会被当成「没有这个会话」直接跳过。
|
|
20
|
+
*/
|
|
21
|
+
export interface BridgeSnapshot {
|
|
22
|
+
readonly header: {
|
|
23
|
+
readonly id: string;
|
|
24
|
+
readonly cwd?: string;
|
|
25
|
+
readonly createdAt?: number;
|
|
26
|
+
};
|
|
27
|
+
readonly formatStatus: 'current';
|
|
28
|
+
readonly revision: string;
|
|
29
|
+
readonly eventCount: number;
|
|
30
|
+
readonly sizeBytes: number;
|
|
31
|
+
}
|
|
32
|
+
/** 一页事件(照 `SessionPageRequest` 的两个游标取最小集)。 */
|
|
33
|
+
export interface BridgePage {
|
|
34
|
+
readonly events: readonly BridgeEvent[];
|
|
35
|
+
/** 这一页之后还有没有更多事件。 */
|
|
36
|
+
readonly hasMore: boolean;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* 只读句柄:dsh 的 `open(id, 'read')` 拿到的那个东西。
|
|
40
|
+
*
|
|
41
|
+
* 三个成员都是按真实消费方(`dsh-cost-meter` 的 `recordsFromPersistence`)核出来的:
|
|
42
|
+
* 它读 `handle.header` 取会话头、读 `handle.inheritedEventCount` 算继承计数、然后
|
|
43
|
+
* `await handle.read(offset)`——**offset 是一个 seq 数字**,不是我们原先那种对象。
|
|
44
|
+
*/
|
|
45
|
+
export interface BridgeHandle {
|
|
46
|
+
readonly sessionId: string;
|
|
47
|
+
readonly header: {
|
|
48
|
+
readonly id: string;
|
|
49
|
+
readonly cwd?: string;
|
|
50
|
+
readonly createdAt?: number;
|
|
51
|
+
};
|
|
52
|
+
readonly inheritedEventCount: number;
|
|
53
|
+
/**
|
|
54
|
+
* 读一页事件。
|
|
55
|
+
* @param range - 起点:数字 = dsh 的 seq 偏移(从这一号开始取);对象 = 本仓库自用的游标
|
|
56
|
+
*/
|
|
57
|
+
read(range?: number | {
|
|
58
|
+
readonly throughSeq?: number;
|
|
59
|
+
readonly beforeSeq?: number;
|
|
60
|
+
readonly maxMessages?: number;
|
|
61
|
+
}): BridgePage;
|
|
62
|
+
close(): void;
|
|
63
|
+
}
|
|
64
|
+
/** `sessionPersistence` 的只读面。 */
|
|
65
|
+
export interface SessionPersistenceBridge {
|
|
66
|
+
list(options?: {
|
|
67
|
+
readonly signal?: AbortSignal;
|
|
68
|
+
}): readonly BridgeSnapshot[];
|
|
69
|
+
stat(sessionId: string, options?: {
|
|
70
|
+
readonly signal?: AbortSignal;
|
|
71
|
+
}): BridgeSnapshot | undefined;
|
|
72
|
+
open(sessionId: string, mode?: 'read' | 'write', options?: {
|
|
73
|
+
readonly signal?: AbortSignal;
|
|
74
|
+
}): BridgeHandle;
|
|
75
|
+
create(): never;
|
|
76
|
+
append(): never;
|
|
77
|
+
}
|
|
78
|
+
/** `sessions` 的只读面(dsh 的多会话注册表,Pneuma 只有当前工作区这一份)。 */
|
|
79
|
+
export interface SessionsBridge {
|
|
80
|
+
list(): readonly {
|
|
81
|
+
sessionId: string;
|
|
82
|
+
cwd?: string;
|
|
83
|
+
createdAt?: number;
|
|
84
|
+
title?: string;
|
|
85
|
+
live: boolean;
|
|
86
|
+
persisted: boolean;
|
|
87
|
+
}[];
|
|
88
|
+
get(sessionId: string): {
|
|
89
|
+
sessionId: string;
|
|
90
|
+
cwd?: string;
|
|
91
|
+
createdAt?: number;
|
|
92
|
+
title?: string;
|
|
93
|
+
live: boolean;
|
|
94
|
+
persisted: boolean;
|
|
95
|
+
} | undefined;
|
|
96
|
+
has(sessionId: string): boolean;
|
|
97
|
+
}
|
|
98
|
+
/** 造一个只读的 `sessionPersistence`。 */
|
|
99
|
+
export declare function createSessionPersistenceBridge(): SessionPersistenceBridge;
|
|
100
|
+
/** 造一个只读的 `sessions`。 */
|
|
101
|
+
export declare function createSessionsBridge(): SessionsBridge;
|
|
102
|
+
/**
|
|
103
|
+
* 按名字取一个桥(compat 的 `ctx.get` 兜底用)。
|
|
104
|
+
* @param name - 服务名
|
|
105
|
+
* @returns 桥;不归这座桥管的服务给 undefined(交给上层继续判缺)
|
|
106
|
+
*/
|
|
107
|
+
export declare function compatServiceOf(name: string): unknown;
|