@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,297 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 把 Pneuma 的回合过程,按 dsh 的 `session/event` 形状播出去。
|
|
3
|
+
*
|
|
4
|
+
* 为什么需要:dsh 的插件普遍**不听「日志文件变了」,而是订阅 `session/event`**
|
|
5
|
+
* 这条广播——回合开合、步的开合、助手消息(带用量)、工具调用与结果。只做会话历史
|
|
6
|
+
* 读取(core/dsh-compat/session-bridge)能让插件查到过去,但正在跑的这一轮它一无所知:
|
|
7
|
+
* `dsh-cost-meter` 的统计预热等 `turn/end`,按事件对账的那部分等
|
|
8
|
+
* `assistant/message` 里的 `usage`。2026-10-26 真包验收时确认过:缺了这条,
|
|
9
|
+
* 那些功能安静地什么都不做。
|
|
10
|
+
*
|
|
11
|
+
* 这是**合成**,所以边界写在这里:
|
|
12
|
+
*
|
|
13
|
+
* 1. 只发我们真的知道的东西:`turn/start`、`step/start`、`assistant/message`
|
|
14
|
+
* (正文 + 推理 + 工具调用 + 用量)、`tool/call`、`tool/result`、`step/end`、
|
|
15
|
+
* `turn/end`、`user/message`。不认识的 dsh 事件类型一律不发,不编。
|
|
16
|
+
* 2. `seq` 是我们自己从 0 起的连续计数,不是 dsh 会话日志里的 seq——它是给
|
|
17
|
+
* 「活着的监听者」用的序号,不承诺能从磁盘复现同一串。
|
|
18
|
+
* 3. 传出去的第一个参数是**只读会话视图**(`id` / `header` / `cwd` / 最近事件尾巴),
|
|
19
|
+
* 不是 dsh 的 `Session` 实例:插件只能看,不能 `append`。真有插件去写,
|
|
20
|
+
* 它在自己的代码里就会抛错——比我们假装支持、然后悄悄丢数据好。
|
|
21
|
+
* 4. 用户消息里的图片**不进事件**(dsh 的 ImageBlock 要附件引用,我们给不出真的)。
|
|
22
|
+
* 正文照发;要看图片走会话桥读历史。
|
|
23
|
+
* 5. 助手消息的 `stream` 记录只还原「说了什么」,不还原逐 delta 的节奏——
|
|
24
|
+
* 我们的流式增量走的是回调,没有 dsh 那种带时间戳的记录。
|
|
25
|
+
*
|
|
26
|
+
* 派发失败一律吞掉并留一行 stderr:广播是旁路,插件的记账绝不能把用户的回合带崩。
|
|
27
|
+
*
|
|
28
|
+
* @module dsc/core/dsh-compat/session-events
|
|
29
|
+
*/
|
|
30
|
+
import { randomUUID } from 'node:crypto';
|
|
31
|
+
import { toDshUsage } from './llm-usage-event.js';
|
|
32
|
+
/** 事件名。抽成常量:发布侧与自检都引它,拼错一个字符就两边同时红。 */
|
|
33
|
+
export const DSH_SESSION_EVENT = 'session/event';
|
|
34
|
+
/**
|
|
35
|
+
* 只读会话视图的尾巴留多少条:够监听者回溯最近几步,又不把整段会话(含大段正文)
|
|
36
|
+
* 常驻内存——一个会话一座桥,长会话不留无界状态。
|
|
37
|
+
*/
|
|
38
|
+
const TAIL_LIMIT = 64;
|
|
39
|
+
/**
|
|
40
|
+
* 造一座桥。**一个会话一座**:`seq` / `turn` / `step` 都是它的内部状态。
|
|
41
|
+
*
|
|
42
|
+
* @param options - 会话身份、宿主上下文与路由读取方式
|
|
43
|
+
* @returns 可以投喂内核事件的桥
|
|
44
|
+
*/
|
|
45
|
+
export function createDshSessionEventBridge(options) {
|
|
46
|
+
const { ctx, sessionId, cwd, createdAt, route } = options;
|
|
47
|
+
const header = {
|
|
48
|
+
id: sessionId,
|
|
49
|
+
...(cwd === undefined ? {} : { cwd }),
|
|
50
|
+
...(createdAt === undefined ? {} : { createdAt }),
|
|
51
|
+
};
|
|
52
|
+
const tail = [];
|
|
53
|
+
const carrier = {
|
|
54
|
+
id: sessionId,
|
|
55
|
+
header,
|
|
56
|
+
...(cwd === undefined ? {} : { cwd }),
|
|
57
|
+
get events() {
|
|
58
|
+
return tail;
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
let seq = 0;
|
|
62
|
+
let turn = 0;
|
|
63
|
+
let step = 0;
|
|
64
|
+
let turnOpen = false;
|
|
65
|
+
let stepOpen = false;
|
|
66
|
+
let stepHasMessage = false;
|
|
67
|
+
/** 回合还没开就来了的用户消息:按 dsh 的顺序,它们属于接下来那个回合。 */
|
|
68
|
+
const bufferedUsers = [];
|
|
69
|
+
/** 等用量的助手消息。 */
|
|
70
|
+
let pending = null;
|
|
71
|
+
/** 最近一条错误事件的文案:回合以 error 收尾时它是 reason 里唯一有信息量的东西。 */
|
|
72
|
+
let lastError = '';
|
|
73
|
+
/** 派发一条事件;失败只留一行 stderr(广播是旁路)。 */
|
|
74
|
+
function dispatch(event) {
|
|
75
|
+
tail.push(event);
|
|
76
|
+
if (tail.length > TAIL_LIMIT)
|
|
77
|
+
tail.splice(0, tail.length - TAIL_LIMIT);
|
|
78
|
+
try {
|
|
79
|
+
const emit = ctx?.emit;
|
|
80
|
+
if (typeof emit !== 'function')
|
|
81
|
+
return;
|
|
82
|
+
emit.call(ctx, DSH_SESSION_EVENT, carrier, event);
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
86
|
+
process.stderr.write(`[dsh-compat] session/event 旁路派发失败(不影响回合):${reason}\n`);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/** 组装一条完整事件(seq 自增、时间取当下)。 */
|
|
90
|
+
function make(type, data, surface = false) {
|
|
91
|
+
const event = {
|
|
92
|
+
type,
|
|
93
|
+
seq,
|
|
94
|
+
time: Date.now(),
|
|
95
|
+
data,
|
|
96
|
+
...(surface ? { surfaceOp: 'append' } : {}),
|
|
97
|
+
};
|
|
98
|
+
seq += 1;
|
|
99
|
+
return event;
|
|
100
|
+
}
|
|
101
|
+
/** 开一步(一次模型调用 + 它的工具)。 */
|
|
102
|
+
function openStep() {
|
|
103
|
+
if (turn <= 0)
|
|
104
|
+
return;
|
|
105
|
+
step += 1;
|
|
106
|
+
stepOpen = true;
|
|
107
|
+
stepHasMessage = false;
|
|
108
|
+
dispatch(make('step/start', { turn, step }));
|
|
109
|
+
}
|
|
110
|
+
/** 关掉当前这一步(没开就什么都不做)。 */
|
|
111
|
+
function closeStep() {
|
|
112
|
+
if (!stepOpen)
|
|
113
|
+
return;
|
|
114
|
+
stepOpen = false;
|
|
115
|
+
stepHasMessage = false;
|
|
116
|
+
dispatch(make('step/end', { turn, step }));
|
|
117
|
+
}
|
|
118
|
+
/** 定稿一条助手消息:带不带用量都发出去。 */
|
|
119
|
+
function flushAssistant(usage) {
|
|
120
|
+
if (pending === null)
|
|
121
|
+
return;
|
|
122
|
+
const current = pending;
|
|
123
|
+
pending = null;
|
|
124
|
+
if (!stepOpen)
|
|
125
|
+
openStep();
|
|
126
|
+
if (stepOpen)
|
|
127
|
+
stepHasMessage = true;
|
|
128
|
+
const data = {
|
|
129
|
+
turn,
|
|
130
|
+
step,
|
|
131
|
+
message: current.message,
|
|
132
|
+
stream: current.stream,
|
|
133
|
+
};
|
|
134
|
+
if (usage !== undefined)
|
|
135
|
+
data['usage'] = usage;
|
|
136
|
+
dispatch(make('assistant/message', data, true));
|
|
137
|
+
}
|
|
138
|
+
/** 回合收尾前把手上所有半成品落定。 */
|
|
139
|
+
function flushAll() {
|
|
140
|
+
flushAssistant();
|
|
141
|
+
}
|
|
142
|
+
/** 把一条用户消息发出去。 */
|
|
143
|
+
function emitUser(text) {
|
|
144
|
+
if (!turnOpen) {
|
|
145
|
+
bufferedUsers.push(text);
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
dispatch(make('user/message', {
|
|
149
|
+
id: randomUUID(),
|
|
150
|
+
role: 'user',
|
|
151
|
+
content: [{ type: 'text', text }],
|
|
152
|
+
source: { kind: 'user' },
|
|
153
|
+
}, true));
|
|
154
|
+
}
|
|
155
|
+
return {
|
|
156
|
+
carrier,
|
|
157
|
+
publish(event) {
|
|
158
|
+
try {
|
|
159
|
+
switch (event.type) {
|
|
160
|
+
case 'user': {
|
|
161
|
+
// 回合没开时先收着:dsh 的顺序是 turn/start 在前。
|
|
162
|
+
emitUser(event.text);
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
case 'turn/start': {
|
|
166
|
+
flushAll();
|
|
167
|
+
closeStep();
|
|
168
|
+
turn += 1;
|
|
169
|
+
turnOpen = true;
|
|
170
|
+
dispatch(make('turn/start', { turn }));
|
|
171
|
+
while (bufferedUsers.length > 0) {
|
|
172
|
+
const text = bufferedUsers.shift();
|
|
173
|
+
if (text !== undefined)
|
|
174
|
+
emitUser(text);
|
|
175
|
+
}
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
case 'context': {
|
|
179
|
+
// 请求组装完、流还没开:正好是 dsh 的「一步开始」。重试会让同一轮再来一条
|
|
180
|
+
// context——那还是同一步(这一步的助手消息还没定稿),不另开。
|
|
181
|
+
if (!turnOpen)
|
|
182
|
+
return;
|
|
183
|
+
if (stepOpen && stepHasMessage) {
|
|
184
|
+
flushAssistant();
|
|
185
|
+
closeStep();
|
|
186
|
+
}
|
|
187
|
+
if (!stepOpen)
|
|
188
|
+
openStep();
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
case 'message': {
|
|
192
|
+
flushAll();
|
|
193
|
+
if (!stepOpen)
|
|
194
|
+
openStep();
|
|
195
|
+
const blocks = [];
|
|
196
|
+
if (event.text !== '')
|
|
197
|
+
blocks.push({ type: 'text', text: event.text });
|
|
198
|
+
if (event.reasoning !== '')
|
|
199
|
+
blocks.push({ type: 'reasoning', text: event.reasoning });
|
|
200
|
+
for (const call of event.toolCalls ?? []) {
|
|
201
|
+
blocks.push({ type: 'tool-call', id: call.id, name: call.name, arguments: call.arguments });
|
|
202
|
+
}
|
|
203
|
+
const router = route?.();
|
|
204
|
+
const now = Date.now();
|
|
205
|
+
const stream = [];
|
|
206
|
+
if (event.text !== '') {
|
|
207
|
+
stream.push({ type: 'chunk', time: now, chunk: { type: 'text-delta', index: 0, text: event.text } });
|
|
208
|
+
}
|
|
209
|
+
pending = {
|
|
210
|
+
message: {
|
|
211
|
+
id: randomUUID(),
|
|
212
|
+
role: 'assistant',
|
|
213
|
+
content: blocks,
|
|
214
|
+
source: { kind: 'model', provider: router?.provider ?? '', model: router?.model ?? '' },
|
|
215
|
+
},
|
|
216
|
+
stream,
|
|
217
|
+
text: event.text,
|
|
218
|
+
};
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
case 'usage': {
|
|
222
|
+
// 与 llm/stream 那条旁路同一份换算:分项互斥,别把命中按未命中价再收一次。
|
|
223
|
+
const usage = toDshUsage({
|
|
224
|
+
inputTokens: event.inputTokens,
|
|
225
|
+
outputTokens: event.outputTokens,
|
|
226
|
+
...(event.cacheHitTokens === undefined ? {} : { cacheHitTokens: event.cacheHitTokens }),
|
|
227
|
+
...(event.cacheMissTokens === undefined ? {} : { cacheMissTokens: event.cacheMissTokens }),
|
|
228
|
+
});
|
|
229
|
+
if (pending !== null) {
|
|
230
|
+
pending.stream.push({ type: 'chunk', time: Date.now(), chunk: { type: 'usage', usage } });
|
|
231
|
+
flushAssistant(usage);
|
|
232
|
+
}
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
case 'tool/call': {
|
|
236
|
+
flushAll();
|
|
237
|
+
if (!stepOpen)
|
|
238
|
+
openStep();
|
|
239
|
+
dispatch(make('tool/call', { turn, step, callId: event.callId, name: event.name, arguments: event.args }));
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
case 'tool/result': {
|
|
243
|
+
flushAll();
|
|
244
|
+
if (!stepOpen)
|
|
245
|
+
openStep();
|
|
246
|
+
const failed = event.error !== undefined;
|
|
247
|
+
dispatch(make('tool/result', {
|
|
248
|
+
turn,
|
|
249
|
+
step,
|
|
250
|
+
message: {
|
|
251
|
+
id: randomUUID(),
|
|
252
|
+
role: 'tool',
|
|
253
|
+
content: [{ type: 'text', text: event.text }],
|
|
254
|
+
source: { kind: 'tool', callId: event.callId },
|
|
255
|
+
toolCallId: event.callId,
|
|
256
|
+
...(failed ? { isError: true } : {}),
|
|
257
|
+
},
|
|
258
|
+
...(failed ? { error: { name: 'ToolError', code: event.error, reason: event.text } } : {}),
|
|
259
|
+
}, true));
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
case 'turn/end': {
|
|
263
|
+
flushAll();
|
|
264
|
+
closeStep();
|
|
265
|
+
if (!turnOpen)
|
|
266
|
+
return;
|
|
267
|
+
turnOpen = false;
|
|
268
|
+
const reason = event.reason === 'completed'
|
|
269
|
+
? { kind: 'completed' }
|
|
270
|
+
: event.reason === 'aborted'
|
|
271
|
+
? { kind: 'aborted', reason: { kind: 'user' } }
|
|
272
|
+
: {
|
|
273
|
+
kind: 'error',
|
|
274
|
+
// 内核先发 error 再发 turn/end,把它记住:只写「这一轮失败了」
|
|
275
|
+
// 等于把唯一的诊断信息丢掉。
|
|
276
|
+
error: { message: lastError === '' ? '这一轮失败了(没有更多信息)' : lastError, code: 'UNKNOWN' },
|
|
277
|
+
};
|
|
278
|
+
lastError = '';
|
|
279
|
+
dispatch(make('turn/end', { turn, reason }));
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
case 'error': {
|
|
283
|
+
// dsh 没有通用的「出错了」事件:失败是 turn/end 的 reason。记下来,随它一起发。
|
|
284
|
+
lastError = event.message;
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
default:
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
catch (error) {
|
|
292
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
293
|
+
process.stderr.write(`[dsh-compat] session/event 消息映射失败(不影响回合):${reason}\n`);
|
|
294
|
+
}
|
|
295
|
+
},
|
|
296
|
+
};
|
|
297
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@deepseek-ai/dsh-credentials` 的 Pneuma 实现(解析钩子按需顶替)。
|
|
3
|
+
*
|
|
4
|
+
* 这个包在插件眼里只是**名字的语法**:`credentialRef('DEEPSEEK_API_KEY')` 把
|
|
5
|
+
* 一个环变量名包成带类型的引用,`credentialKey('provider','openai')` 拼出
|
|
6
|
+
* `provider/openai` 这样的地址。真正的值住在宿主的凭据库里,插件拿不到也不需要。
|
|
7
|
+
*
|
|
8
|
+
* 所以这里只复刻语法与校验,不引入 dsh 的凭据服务(那套要 `ctx.credentials`,
|
|
9
|
+
* Pneuma 的 key 走 `~/.dsc/credentials.yaml`,是另一条路)。
|
|
10
|
+
*
|
|
11
|
+
* @module dsc/core/dsh-compat/shims/credentials
|
|
12
|
+
*/
|
|
13
|
+
/** 凭据引用:一个环变量名的类型化写法(运行时就是字符串)。 */
|
|
14
|
+
export type CredentialRef = string;
|
|
15
|
+
/** 凭据地址:`scope/id` 的类型化写法(运行时就是字符串)。 */
|
|
16
|
+
export type CredentialKey = string;
|
|
17
|
+
/**
|
|
18
|
+
* 把一个环变量名包成凭据引用。
|
|
19
|
+
* @param value - 候选引用名
|
|
20
|
+
* @returns 同一个字符串(类型上更窄)
|
|
21
|
+
* @throws 形状不合语法时抛 TypeError
|
|
22
|
+
*/
|
|
23
|
+
export declare function credentialRef(value: string): CredentialRef;
|
|
24
|
+
/**
|
|
25
|
+
* 判断一个字符串能不能当凭据引用。
|
|
26
|
+
* @param value - 候选名
|
|
27
|
+
* @returns 合规给 true
|
|
28
|
+
*/
|
|
29
|
+
export declare function isCredentialRefName(value: string): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* 判断一个字符串能不能当凭据地址的一段。
|
|
32
|
+
* @param value - 候选段
|
|
33
|
+
* @returns 合规给 true
|
|
34
|
+
*/
|
|
35
|
+
export declare function isCredentialKeySegment(value: string): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* 拼一个凭据地址。
|
|
38
|
+
* @param scope - 前半段(提供方)
|
|
39
|
+
* @param id - 后半段(这条凭据的名字)
|
|
40
|
+
* @returns `scope/id`
|
|
41
|
+
* @throws 任一段不合语法时抛 TypeError
|
|
42
|
+
*/
|
|
43
|
+
export declare function credentialKey(scope: string, id: string): CredentialKey;
|
|
44
|
+
/**
|
|
45
|
+
* 拆一个凭据地址。
|
|
46
|
+
* @param value - `scope/id`
|
|
47
|
+
* @returns 拆出来的两段
|
|
48
|
+
* @throws 形状不对时抛 TypeError
|
|
49
|
+
*/
|
|
50
|
+
export declare function parseCredentialKey(value: string): CredentialKey;
|
|
51
|
+
/**
|
|
52
|
+
* 取凭据地址的前半段。
|
|
53
|
+
* @param key - 凭据地址
|
|
54
|
+
* @returns 提供方名
|
|
55
|
+
*/
|
|
56
|
+
export declare function credentialKeyScope(key: CredentialKey): string;
|
|
57
|
+
/**
|
|
58
|
+
* 取凭据地址的后半段。
|
|
59
|
+
* @param key - 凭据地址
|
|
60
|
+
* @returns 凭据名
|
|
61
|
+
*/
|
|
62
|
+
export declare function credentialKeyId(key: CredentialKey): string;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@deepseek-ai/dsh-credentials` 的 Pneuma 实现(解析钩子按需顶替)。
|
|
3
|
+
*
|
|
4
|
+
* 这个包在插件眼里只是**名字的语法**:`credentialRef('DEEPSEEK_API_KEY')` 把
|
|
5
|
+
* 一个环变量名包成带类型的引用,`credentialKey('provider','openai')` 拼出
|
|
6
|
+
* `provider/openai` 这样的地址。真正的值住在宿主的凭据库里,插件拿不到也不需要。
|
|
7
|
+
*
|
|
8
|
+
* 所以这里只复刻语法与校验,不引入 dsh 的凭据服务(那套要 `ctx.credentials`,
|
|
9
|
+
* Pneuma 的 key 走 `~/.dsc/credentials.yaml`,是另一条路)。
|
|
10
|
+
*
|
|
11
|
+
* @module dsc/core/dsh-compat/shims/credentials
|
|
12
|
+
*/
|
|
13
|
+
/** 凭据引用的合法形状:POSIX 环变量名。 */
|
|
14
|
+
const REF_PATTERN = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
15
|
+
/** 凭据地址每一段的合法形状(小写字母开头的短横线名)。 */
|
|
16
|
+
const KEY_SEGMENT_PATTERN = /^[a-z][a-z0-9-]*$/;
|
|
17
|
+
/**
|
|
18
|
+
* 把一个环变量名包成凭据引用。
|
|
19
|
+
* @param value - 候选引用名
|
|
20
|
+
* @returns 同一个字符串(类型上更窄)
|
|
21
|
+
* @throws 形状不合语法时抛 TypeError
|
|
22
|
+
*/
|
|
23
|
+
export function credentialRef(value) {
|
|
24
|
+
if (!isCredentialRefName(value)) {
|
|
25
|
+
throw new TypeError(`credential ref "${value}" must match ${String(REF_PATTERN)}`);
|
|
26
|
+
}
|
|
27
|
+
return value;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* 判断一个字符串能不能当凭据引用。
|
|
31
|
+
* @param value - 候选名
|
|
32
|
+
* @returns 合规给 true
|
|
33
|
+
*/
|
|
34
|
+
export function isCredentialRefName(value) {
|
|
35
|
+
return REF_PATTERN.test(value);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* 判断一个字符串能不能当凭据地址的一段。
|
|
39
|
+
* @param value - 候选段
|
|
40
|
+
* @returns 合规给 true
|
|
41
|
+
*/
|
|
42
|
+
export function isCredentialKeySegment(value) {
|
|
43
|
+
return KEY_SEGMENT_PATTERN.test(value);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* 拼一个凭据地址。
|
|
47
|
+
* @param scope - 前半段(提供方)
|
|
48
|
+
* @param id - 后半段(这条凭据的名字)
|
|
49
|
+
* @returns `scope/id`
|
|
50
|
+
* @throws 任一段不合语法时抛 TypeError
|
|
51
|
+
*/
|
|
52
|
+
export function credentialKey(scope, id) {
|
|
53
|
+
if (!isCredentialKeySegment(scope) || !isCredentialKeySegment(id)) {
|
|
54
|
+
throw new TypeError(`credential key "${scope}/${id}" must match ${String(KEY_SEGMENT_PATTERN)} on both sides`);
|
|
55
|
+
}
|
|
56
|
+
return `${scope}/${id}`;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* 拆一个凭据地址。
|
|
60
|
+
* @param value - `scope/id`
|
|
61
|
+
* @returns 拆出来的两段
|
|
62
|
+
* @throws 形状不对时抛 TypeError
|
|
63
|
+
*/
|
|
64
|
+
export function parseCredentialKey(value) {
|
|
65
|
+
const [scope, id, ...rest] = value.split('/');
|
|
66
|
+
if (scope === undefined || id === undefined || rest.length > 0) {
|
|
67
|
+
throw new TypeError(`credential key "${value}" must be scope/id`);
|
|
68
|
+
}
|
|
69
|
+
return credentialKey(scope, id);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* 取凭据地址的前半段。
|
|
73
|
+
* @param key - 凭据地址
|
|
74
|
+
* @returns 提供方名
|
|
75
|
+
*/
|
|
76
|
+
export function credentialKeyScope(key) {
|
|
77
|
+
return parseCredentialKey(key).split('/')[0] ?? '';
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* 取凭据地址的后半段。
|
|
81
|
+
* @param key - 凭据地址
|
|
82
|
+
* @returns 凭据名
|
|
83
|
+
*/
|
|
84
|
+
export function credentialKeyId(key) {
|
|
85
|
+
return parseCredentialKey(key).split('/')[1] ?? '';
|
|
86
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/** 用户数据根目录名(Pneuma 是 `.dsc`,dsh 是 `.dsh`)。 */
|
|
2
|
+
export declare const DSH_HOME_DIR_NAME = ".dsc";
|
|
3
|
+
/** 默认根的用户可见写法。 */
|
|
4
|
+
export declare const DEFAULT_DSH_HOME_DISPLAY = "~/.dsc";
|
|
5
|
+
/** 覆盖默认根的环变量(沿用 dsh 的名字,插件读的就是它)。 */
|
|
6
|
+
export declare const DSH_HOME_ENV = "DSH_HOME";
|
|
7
|
+
/** 共享 agent 配置根目录名。 */
|
|
8
|
+
export declare const AGENTS_HOME_DIR_NAME = ".agents";
|
|
9
|
+
/** 共享 agent 配置根的用户可见写法。 */
|
|
10
|
+
export declare const DEFAULT_AGENTS_HOME_DISPLAY = "~/.agents";
|
|
11
|
+
/** 覆盖共享根的环变量。 */
|
|
12
|
+
export declare const AGENTS_HOME_ENV = "DSH_AGENTS_HOME";
|
|
13
|
+
/**
|
|
14
|
+
* 默认用户数据根。
|
|
15
|
+
* @returns 绝对路径(`DSC_HOME` 有值时就是它)
|
|
16
|
+
*/
|
|
17
|
+
export declare function defaultDshHome(): string;
|
|
18
|
+
/**
|
|
19
|
+
* 默认共享 agent 配置根。
|
|
20
|
+
* @returns 绝对路径(`~/.agents`)
|
|
21
|
+
*/
|
|
22
|
+
export declare function defaultAgentsHome(): string;
|
|
23
|
+
/**
|
|
24
|
+
* 展开 `~`、`~/`、`~\\` 前缀。
|
|
25
|
+
* @param path - 可能是波浪号开头的配置值
|
|
26
|
+
* @returns 展开后的路径;没有前缀就原样返回
|
|
27
|
+
*/
|
|
28
|
+
export declare function expandHomePath(path: string): string;
|
|
29
|
+
/**
|
|
30
|
+
* 解析用户数据根。优先级:显式路径 → `$DSH_HOME` → `~/.dsc`。
|
|
31
|
+
* @param configured - 显式覆盖(最高优先)
|
|
32
|
+
* @param env - 读环境变量的表
|
|
33
|
+
* @returns 绝对路径
|
|
34
|
+
*/
|
|
35
|
+
export declare function resolveDshHome(configured?: string, env?: Record<string, string | undefined>): string;
|
|
36
|
+
/**
|
|
37
|
+
* 解析共享 agent 配置根。优先级:显式路径 → `$DSH_AGENTS_HOME` → `~/.agents`。
|
|
38
|
+
* @param configured - 显式覆盖(最高优先)
|
|
39
|
+
* @param env - 读环境变量的表
|
|
40
|
+
* @returns 绝对路径
|
|
41
|
+
*/
|
|
42
|
+
export declare function resolveAgentsHome(configured?: string, env?: Record<string, string | undefined>): string;
|
|
43
|
+
/**
|
|
44
|
+
* 在用户数据根下拼路径(不创建目录)。
|
|
45
|
+
* @param segments - 依次拼上的路径段
|
|
46
|
+
* @returns 绝对路径
|
|
47
|
+
*/
|
|
48
|
+
export declare function dshHomePath(...segments: string[]): string;
|
|
49
|
+
/**
|
|
50
|
+
* 在用户数据根的 `cache` 下拼路径(不创建目录)。
|
|
51
|
+
* @param optionsOrSegment - 显式根覆盖,或第一个路径段
|
|
52
|
+
* @param segments - 其后的路径段
|
|
53
|
+
* @returns 绝对路径
|
|
54
|
+
*/
|
|
55
|
+
export declare function dshCachePath(optionsOrSegment?: {
|
|
56
|
+
dshHome?: string;
|
|
57
|
+
} | string, ...segments: string[]): string;
|
|
58
|
+
/**
|
|
59
|
+
* 给用户看的根目录写法(不泄露机器绝对路径)。
|
|
60
|
+
* @param resolvedHome - {@link resolveDshHome} 的返回值
|
|
61
|
+
* @returns 默认根给 `~/.dsc`,否则给 `$DSH_HOME`
|
|
62
|
+
*/
|
|
63
|
+
export declare function dshHomeDisplay(resolvedHome: string): string;
|
|
64
|
+
/**
|
|
65
|
+
* 给用户看的共享根写法。
|
|
66
|
+
* @param resolvedRoot - {@link resolveAgentsHome} 的返回值
|
|
67
|
+
* @returns 默认根给 `~/.agents`,否则给 `$DSH_AGENTS_HOME`
|
|
68
|
+
*/
|
|
69
|
+
export declare function agentsHomeDisplay(resolvedRoot: string): string;
|
|
70
|
+
/**
|
|
71
|
+
* 给文件监视器一个规范化的路径写法(末段不存在也成立)。
|
|
72
|
+
*
|
|
73
|
+
* 与 dsh 同义:把最深的已存在祖先走一遍 `realpath`,其余段按原名拼回去。
|
|
74
|
+
* @param path - 监视目标
|
|
75
|
+
* @returns 祖先已规范化的路径
|
|
76
|
+
*/
|
|
77
|
+
export declare function canonicalizeWatchPath(path: string): Promise<string>;
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@deepseek-ai/dsh-home-paths` 的 Pneuma 实现(解析钩子按需顶替)。
|
|
3
|
+
*
|
|
4
|
+
* 只改一件事:**默认根从 `~/.dsh` 换成 Pneuma 自己的家目录**(`~/.dsc`,受
|
|
5
|
+
* `DSC_HOME` 覆盖)。函数名、参数顺序、优先级(显式配置 → 环境变量 → 默认根)
|
|
6
|
+
* 与 dsh 原包逐条对齐——插件里那 11 处 `resolveDshHome()` 因此不用改一行,
|
|
7
|
+
* 写出来的账本落在 Pneuma 家里,而不是 dsh 家里。
|
|
8
|
+
*
|
|
9
|
+
* 为什么不能直接装 dsh 那个包:它的默认值是 `join(homedir(), '.dsh')`,
|
|
10
|
+
* 装进来后插件会把成本账本写进 dsh 的 home,两个宿主的账本混在一份文件里。
|
|
11
|
+
*
|
|
12
|
+
* @module dsc/core/dsh-compat/shims/home-paths
|
|
13
|
+
*/
|
|
14
|
+
import { opendir, realpath } from 'node:fs/promises';
|
|
15
|
+
import { homedir } from 'node:os';
|
|
16
|
+
import { basename, dirname, join, resolve } from 'node:path';
|
|
17
|
+
import { dscPath } from '../../path-policy.js';
|
|
18
|
+
/** 用户数据根目录名(Pneuma 是 `.dsc`,dsh 是 `.dsh`)。 */
|
|
19
|
+
export const DSH_HOME_DIR_NAME = '.dsc';
|
|
20
|
+
/** 默认根的用户可见写法。 */
|
|
21
|
+
export const DEFAULT_DSH_HOME_DISPLAY = `~/${DSH_HOME_DIR_NAME}`;
|
|
22
|
+
/** 覆盖默认根的环变量(沿用 dsh 的名字,插件读的就是它)。 */
|
|
23
|
+
export const DSH_HOME_ENV = 'DSH_HOME';
|
|
24
|
+
/** 共享 agent 配置根目录名。 */
|
|
25
|
+
export const AGENTS_HOME_DIR_NAME = '.agents';
|
|
26
|
+
/** 共享 agent 配置根的用户可见写法。 */
|
|
27
|
+
export const DEFAULT_AGENTS_HOME_DISPLAY = `~/${AGENTS_HOME_DIR_NAME}`;
|
|
28
|
+
/** 覆盖共享根的环变量。 */
|
|
29
|
+
export const AGENTS_HOME_ENV = 'DSH_AGENTS_HOME';
|
|
30
|
+
/**
|
|
31
|
+
* 默认用户数据根。
|
|
32
|
+
* @returns 绝对路径(`DSC_HOME` 有值时就是它)
|
|
33
|
+
*/
|
|
34
|
+
export function defaultDshHome() {
|
|
35
|
+
return dscPath();
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* 默认共享 agent 配置根。
|
|
39
|
+
* @returns 绝对路径(`~/.agents`)
|
|
40
|
+
*/
|
|
41
|
+
export function defaultAgentsHome() {
|
|
42
|
+
return join(homedir(), AGENTS_HOME_DIR_NAME);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* 展开 `~`、`~/`、`~\\` 前缀。
|
|
46
|
+
* @param path - 可能是波浪号开头的配置值
|
|
47
|
+
* @returns 展开后的路径;没有前缀就原样返回
|
|
48
|
+
*/
|
|
49
|
+
export function expandHomePath(path) {
|
|
50
|
+
if (path === '~')
|
|
51
|
+
return homedir();
|
|
52
|
+
if (path.startsWith('~/') || path.startsWith('~\\'))
|
|
53
|
+
return join(homedir(), path.slice(2));
|
|
54
|
+
return path;
|
|
55
|
+
}
|
|
56
|
+
function resolveRoot(configured, env, envName, fallback) {
|
|
57
|
+
const fromEnv = env[envName];
|
|
58
|
+
const selected = configured ?? (fromEnv !== undefined && fromEnv.trim().length > 0 ? fromEnv : fallback());
|
|
59
|
+
return resolve(expandHomePath(selected));
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* 解析用户数据根。优先级:显式路径 → `$DSH_HOME` → `~/.dsc`。
|
|
63
|
+
* @param configured - 显式覆盖(最高优先)
|
|
64
|
+
* @param env - 读环境变量的表
|
|
65
|
+
* @returns 绝对路径
|
|
66
|
+
*/
|
|
67
|
+
export function resolveDshHome(configured, env = process.env) {
|
|
68
|
+
return resolveRoot(configured, env, DSH_HOME_ENV, defaultDshHome);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* 解析共享 agent 配置根。优先级:显式路径 → `$DSH_AGENTS_HOME` → `~/.agents`。
|
|
72
|
+
* @param configured - 显式覆盖(最高优先)
|
|
73
|
+
* @param env - 读环境变量的表
|
|
74
|
+
* @returns 绝对路径
|
|
75
|
+
*/
|
|
76
|
+
export function resolveAgentsHome(configured, env = process.env) {
|
|
77
|
+
return resolveRoot(configured, env, AGENTS_HOME_ENV, defaultAgentsHome);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* 在用户数据根下拼路径(不创建目录)。
|
|
81
|
+
* @param segments - 依次拼上的路径段
|
|
82
|
+
* @returns 绝对路径
|
|
83
|
+
*/
|
|
84
|
+
export function dshHomePath(...segments) {
|
|
85
|
+
return join(resolveDshHome(), ...segments);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* 在用户数据根的 `cache` 下拼路径(不创建目录)。
|
|
89
|
+
* @param optionsOrSegment - 显式根覆盖,或第一个路径段
|
|
90
|
+
* @param segments - 其后的路径段
|
|
91
|
+
* @returns 绝对路径
|
|
92
|
+
*/
|
|
93
|
+
export function dshCachePath(optionsOrSegment = {}, ...segments) {
|
|
94
|
+
if (typeof optionsOrSegment === 'string')
|
|
95
|
+
return dshHomePath('cache', optionsOrSegment, ...segments);
|
|
96
|
+
return join(resolveDshHome(optionsOrSegment.dshHome), 'cache', ...segments);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* 给用户看的根目录写法(不泄露机器绝对路径)。
|
|
100
|
+
* @param resolvedHome - {@link resolveDshHome} 的返回值
|
|
101
|
+
* @returns 默认根给 `~/.dsc`,否则给 `$DSH_HOME`
|
|
102
|
+
*/
|
|
103
|
+
export function dshHomeDisplay(resolvedHome) {
|
|
104
|
+
return resolvedHome === resolve(defaultDshHome()) ? DEFAULT_DSH_HOME_DISPLAY : `$${DSH_HOME_ENV}`;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* 给用户看的共享根写法。
|
|
108
|
+
* @param resolvedRoot - {@link resolveAgentsHome} 的返回值
|
|
109
|
+
* @returns 默认根给 `~/.agents`,否则给 `$DSH_AGENTS_HOME`
|
|
110
|
+
*/
|
|
111
|
+
export function agentsHomeDisplay(resolvedRoot) {
|
|
112
|
+
return resolvedRoot === resolve(defaultAgentsHome()) ? DEFAULT_AGENTS_HOME_DISPLAY : `$${AGENTS_HOME_ENV}`;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* 给文件监视器一个规范化的路径写法(末段不存在也成立)。
|
|
116
|
+
*
|
|
117
|
+
* 与 dsh 同义:把最深的已存在祖先走一遍 `realpath`,其余段按原名拼回去。
|
|
118
|
+
* @param path - 监视目标
|
|
119
|
+
* @returns 祖先已规范化的路径
|
|
120
|
+
*/
|
|
121
|
+
export async function canonicalizeWatchPath(path) {
|
|
122
|
+
let current = resolve(path);
|
|
123
|
+
const missing = [];
|
|
124
|
+
for (;;) {
|
|
125
|
+
try {
|
|
126
|
+
const canonical = await realpath(current);
|
|
127
|
+
if (missing.length > 0) {
|
|
128
|
+
const directory = await opendir(canonical);
|
|
129
|
+
await directory.close();
|
|
130
|
+
}
|
|
131
|
+
return join(canonical, ...missing.reverse());
|
|
132
|
+
}
|
|
133
|
+
catch (error) {
|
|
134
|
+
if (error.code !== 'ENOENT')
|
|
135
|
+
throw error;
|
|
136
|
+
const parent = dirname(current);
|
|
137
|
+
if (parent === current)
|
|
138
|
+
throw error;
|
|
139
|
+
missing.push(basename(current));
|
|
140
|
+
current = parent;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|