@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
|
@@ -11,14 +11,19 @@
|
|
|
11
11
|
*
|
|
12
12
|
* @module dsc/core/plugin-loader
|
|
13
13
|
*/
|
|
14
|
-
import { readdirSync, statSync } from 'node:fs';
|
|
15
|
-
import { basename, join } from 'node:path';
|
|
14
|
+
import { existsSync, readFileSync, readdirSync, statSync } from 'node:fs';
|
|
15
|
+
import { basename, isAbsolute, join } from 'node:path';
|
|
16
16
|
import { pathToFileURL } from 'node:url';
|
|
17
17
|
import { ensureResolveHook } from './dsh-compat/resolve-hook.js';
|
|
18
18
|
import { dshToolsFacade } from './dsh-compat/tools-facade.js';
|
|
19
19
|
import { checkApiVersion, getPluginConfig, getPluginMeta, isPluginEnabled, readPluginEntries, registerPluginMeta, writePluginEnabled, KERNEL_API_VERSION, } from './plugin-registry.js';
|
|
20
20
|
import { errText as err } from './err-text.js';
|
|
21
|
+
import { describeForeignServices } from './dsh-compat/service-map.js';
|
|
22
|
+
import { compatServiceOf } from './dsh-compat/session-bridge.js';
|
|
23
|
+
import { applyPatchLayers } from './plugin-patch.js';
|
|
24
|
+
import { bundleDirOf, enginesProblem, readBundle, readProfile } from './plugin-bundle.js';
|
|
21
25
|
import { dscPath } from './path-policy.js';
|
|
26
|
+
import { activeProfileDir } from './profile-dir.js';
|
|
22
27
|
/** 内核插件 API 版本(重导出,供宿主/文档引用)。 */
|
|
23
28
|
export { KERNEL_API_VERSION };
|
|
24
29
|
/**
|
|
@@ -31,6 +36,39 @@ const DSC_SERVICE_NAMES = new Set([
|
|
|
31
36
|
'hooks', 'memory', 'dock', 'ui', 'team', 'mcp', 'sessionSearch', 'approvalFloor', 'interactive',
|
|
32
37
|
'sandbox', 'logger',
|
|
33
38
|
]);
|
|
39
|
+
/**
|
|
40
|
+
* 读插件声明的 dsh 客户端能力名(只读,不加载)。
|
|
41
|
+
*
|
|
42
|
+
* dsh 的 `dsh.client` 是个对象(platform / inject / modules…),我们把**键名**当能力列出来;
|
|
43
|
+
* 数组就给里面的字符串;字符串原样。认不出给空数组(不猜)。
|
|
44
|
+
* @param raw - 插件模块上的 client / dshClient 导出
|
|
45
|
+
* @returns 能力名清单(去重、按出现顺序)
|
|
46
|
+
*/
|
|
47
|
+
function clientCapabilitiesOf(raw) {
|
|
48
|
+
const names = [];
|
|
49
|
+
const push = (value) => {
|
|
50
|
+
if (typeof value === 'string' && value !== '' && !names.includes(value))
|
|
51
|
+
names.push(value);
|
|
52
|
+
};
|
|
53
|
+
if (typeof raw === 'string')
|
|
54
|
+
push(raw);
|
|
55
|
+
else if (Array.isArray(raw))
|
|
56
|
+
for (const item of raw)
|
|
57
|
+
push(item);
|
|
58
|
+
else if (raw !== null && typeof raw === 'object') {
|
|
59
|
+
for (const [key, value] of Object.entries(raw)) {
|
|
60
|
+
// platform / inject 这类字段的值本身就是能力线索,也一并列出(去重靠 push)。
|
|
61
|
+
if (key === 'platform')
|
|
62
|
+
push(`platform:${String(value)}`);
|
|
63
|
+
else if (key === 'inject' && Array.isArray(value))
|
|
64
|
+
for (const item of value)
|
|
65
|
+
push(`服务:${String(item)}`);
|
|
66
|
+
else
|
|
67
|
+
push(key);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return names;
|
|
71
|
+
}
|
|
34
72
|
/** 兼容层开着的判定与说明文案在挂载路径里;这里只留服务名清单。 */
|
|
35
73
|
/** 已挂载的外部插件:文件名 → cordis Fiber(dispose 即卸载)。 */
|
|
36
74
|
const mounted = new Map();
|
|
@@ -46,6 +84,18 @@ const builtinMounts = new Map();
|
|
|
46
84
|
export function registerBuiltinMount(file, plugin) {
|
|
47
85
|
builtinMounts.set(basename(file), plugin);
|
|
48
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* 登记一个“启动时就挂上”的官方插件 fiber(宿主装配时调用一次)。
|
|
89
|
+
*
|
|
90
|
+
* 为什么需要:createKernel 不走 mountExternalPlugin(启动失败应该响亮,不能静默停用),
|
|
91
|
+
* 但热停用只认 {@link mounted} 这张表。不登记的话,停用只写盘、fiber 照跑;
|
|
92
|
+
* 再启用又会挂第二份,带 provide 的插件还会因服务重名直接失败。
|
|
93
|
+
* @param file - 开关键,与 registerBuiltinMount 用的名字一致。
|
|
94
|
+
* @param fiber - root.plugin() 返回的 fiber;卸载时由 unmountExternalPlugin 统一 dispose。
|
|
95
|
+
*/
|
|
96
|
+
export function trackBuiltinMount(file, fiber) {
|
|
97
|
+
mounted.set(basename(file), fiber);
|
|
98
|
+
}
|
|
49
99
|
/** 初始化(宿主启动时调用一次,传入内核 root)。 */
|
|
50
100
|
let rootRef = null;
|
|
51
101
|
export function initPluginRuntime(root) {
|
|
@@ -69,7 +119,13 @@ async function importPluginModule(file, meta) {
|
|
|
69
119
|
return (await import(url));
|
|
70
120
|
}
|
|
71
121
|
catch (error) {
|
|
72
|
-
|
|
122
|
+
const message = err(error);
|
|
123
|
+
// dsh 插件在模块顶层就 import @deepseek-ai/*,兼容层没开时导入钩子不在,
|
|
124
|
+
// 于是第一句报错是「找不到包」——不说清楚用户只会以为包坏了。
|
|
125
|
+
const hint = message.includes('@deepseek-ai/') && !isPluginEnabled('dsh-compat')
|
|
126
|
+
? '(这像是 dsh 插件:它 import 的 @deepseek-ai/* 由「dsh 兼容层」提供,请先在插件中心启用 dsh-compat 再试)'
|
|
127
|
+
: '';
|
|
128
|
+
meta.problem = `模块导入失败:${message}${hint}`;
|
|
73
129
|
return null;
|
|
74
130
|
}
|
|
75
131
|
}
|
|
@@ -106,6 +162,13 @@ export async function mountExternalPlugin(file) {
|
|
|
106
162
|
}
|
|
107
163
|
const meta = { file: base, name: base.replace(/\.js$/, ''), description: '', source: 'external' };
|
|
108
164
|
registerPluginMeta(meta);
|
|
165
|
+
// 解析钩子必须在**导入之前**就位:dsh 插件在模块顶层就 import @deepseek-ai/* 的东西,
|
|
166
|
+
// 等 apply 时再注册已经太晚(import 早就抛 ERR_MODULE_NOT_FOUND 了)。
|
|
167
|
+
const needsCompat = isPluginEnabled('dsh-compat');
|
|
168
|
+
if (needsCompat) {
|
|
169
|
+
ensureResolveHook([DSC_PLUGINS_DIR]);
|
|
170
|
+
normalizeDshHome();
|
|
171
|
+
}
|
|
109
172
|
const mod = await importPluginModule(file, meta);
|
|
110
173
|
if (mod === null) {
|
|
111
174
|
await disableSilently(base);
|
|
@@ -117,6 +180,9 @@ export async function mountExternalPlugin(file) {
|
|
|
117
180
|
meta.description = mod.description;
|
|
118
181
|
if (typeof mod.apiVersion === 'number')
|
|
119
182
|
meta.apiVersion = mod.apiVersion;
|
|
183
|
+
const capabilities = clientCapabilitiesOf(mod.client ?? mod.dshClient);
|
|
184
|
+
if (capabilities.length > 0)
|
|
185
|
+
meta.clientCapabilities = capabilities;
|
|
120
186
|
// ---- 版本管理:不兼容自动回滚(停用并写盘) ----
|
|
121
187
|
const problem = checkApiVersion(meta.apiVersion);
|
|
122
188
|
if (problem !== null) {
|
|
@@ -135,15 +201,18 @@ export async function mountExternalPlugin(file) {
|
|
|
135
201
|
const injectNames = Array.isArray(mod.inject) ? mod.inject.filter((n) => typeof n === 'string') : [];
|
|
136
202
|
const foreign = injectNames.filter((n) => !DSC_SERVICE_NAMES.has(n));
|
|
137
203
|
if (foreign.length > 0) {
|
|
204
|
+
// 一句「超出范围」帮不到插件作者:这张表给每个常见 dsh 服务名一句判定
|
|
205
|
+
// (有对应但语义不同 / 根本没有),见 core/dsh-compat/service-map.ts。
|
|
206
|
+
const detail = describeForeignServices(foreign);
|
|
138
207
|
if (!isPluginEnabled('dsh-compat')) {
|
|
139
208
|
meta.problem =
|
|
140
|
-
`插件需要 dsc 不认识的服务:${
|
|
209
|
+
`插件需要 dsc 不认识的服务:${detail}。若这是 dsh(DeepSeek Harness)风格的插件,` +
|
|
141
210
|
'请先在插件中心启用「dsh 兼容层」(dsh-compat)再打开本插件';
|
|
142
211
|
}
|
|
143
212
|
else {
|
|
144
213
|
meta.problem =
|
|
145
|
-
`这个 dsh
|
|
146
|
-
'
|
|
214
|
+
`这个 dsh 插件要的服务 Pneuma 没有或对不上:${detail}。` +
|
|
215
|
+
'依赖这些语义的插件在 Pneuma 上跑不起来,需要改写(或等对应服务做出来)';
|
|
147
216
|
}
|
|
148
217
|
await disableSilently(base);
|
|
149
218
|
return false;
|
|
@@ -167,14 +236,13 @@ export async function mountExternalPlugin(file) {
|
|
|
167
236
|
// 兼容层开着:外部插件的 ctx.tools 换成双形状兼容面(dsc ToolEntry 与 dsh
|
|
168
237
|
// ToolDefinition 都收),dsh 插件 inject ['tools'] 时不再需要任何特判。
|
|
169
238
|
// 解析钩子同步注册(registerHooks),这里先确保它在,插件导入 @deepseek-ai/* 才走得通。
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
ensureResolveHook([DSC_PLUGINS_DIR]);
|
|
239
|
+
/** 插件运行时直接 `ctx.get` 过的服务名(诊断用:它可能不声明 inject)。 */
|
|
240
|
+
const asked = [];
|
|
173
241
|
try {
|
|
174
242
|
const pluginObject = {
|
|
175
243
|
name: meta.name,
|
|
176
244
|
inject: mod.inject,
|
|
177
|
-
apply: (innerCtx, config) => mod.apply(needsCompat ? compatCtx(innerCtx, base) : innerCtx, config),
|
|
245
|
+
apply: (innerCtx, config) => mod.apply(needsCompat ? compatCtx(innerCtx, base, asked) : innerCtx, config),
|
|
178
246
|
};
|
|
179
247
|
const fiber = root.plugin(pluginObject, configForApply);
|
|
180
248
|
await fiber;
|
|
@@ -183,7 +251,14 @@ export async function mountExternalPlugin(file) {
|
|
|
183
251
|
return true;
|
|
184
252
|
}
|
|
185
253
|
catch (error) {
|
|
186
|
-
|
|
254
|
+
// 很多 dsh 插件不声明 inject,而是在 apply 里 ctx.get('sessions') 现取。取到
|
|
255
|
+
// undefined 再调方法就只剩一句 "Cannot read properties of undefined",等于没说话。
|
|
256
|
+
// 这里把「它取过、但我们没有或对不上」的服务名一并写进诊断。
|
|
257
|
+
const missing = missingServicesOf(asked);
|
|
258
|
+
meta.problem =
|
|
259
|
+
missing === null
|
|
260
|
+
? `挂载失败:${err(error)}`
|
|
261
|
+
: `挂载失败:${err(error)}。它在运行时直接取这些服务,Pneuma 没有或对不上:${missing}`;
|
|
187
262
|
await disableSilently(base);
|
|
188
263
|
return false;
|
|
189
264
|
}
|
|
@@ -192,16 +267,53 @@ export async function mountExternalPlugin(file) {
|
|
|
192
267
|
* dsh 兼容的 ctx 视图:`ctx.tools` 换成双形状的兼容面(risk 的映射每次 register
|
|
193
268
|
* 时现读插件条目配置),其余服务原样透传。logger 是 cordis 内置服务,不用垫。
|
|
194
269
|
*/
|
|
195
|
-
function compatCtx(innerCtx, file) {
|
|
270
|
+
function compatCtx(innerCtx, file, asked) {
|
|
196
271
|
return new Proxy(innerCtx, {
|
|
197
272
|
get(target, prop, receiver) {
|
|
198
273
|
if (prop === 'tools') {
|
|
199
274
|
return dshToolsFacade((entry) => target.tools.register(entry), () => resolveRiskConfig(file));
|
|
200
275
|
}
|
|
276
|
+
if (prop === 'get') {
|
|
277
|
+
// 先问 cordis(原样转发);真没有就看服务桥有没有**只读**的对应物。
|
|
278
|
+
// 为什么在这里兜底而不是 ctx.provide:桥是按插件现造的视图(每次 get 拿到的是
|
|
279
|
+
// 同一份磁盘状态的读口,不是全局单例),provide 出去会变成所有插件共享一个可变对象。
|
|
280
|
+
return (name) => {
|
|
281
|
+
if (typeof name === 'string')
|
|
282
|
+
asked.push(name);
|
|
283
|
+
const direct = target.get(String(name));
|
|
284
|
+
if (direct !== undefined)
|
|
285
|
+
return direct;
|
|
286
|
+
return compatServiceOf(String(name));
|
|
287
|
+
};
|
|
288
|
+
}
|
|
201
289
|
return Reflect.get(target, prop, receiver);
|
|
202
290
|
},
|
|
203
291
|
});
|
|
204
292
|
}
|
|
293
|
+
/**
|
|
294
|
+
* 把 `$DSH_HOME` 定到 Pneuma 的家(用户设过就不动)。
|
|
295
|
+
*
|
|
296
|
+
* 为什么要在**导入之前**做:dsh 插件里有一半的路径不走 home-paths 包,而是在模块
|
|
297
|
+
* 顶层直接算 `process.env.DSH_HOME || join(homedir(), '.dsh')`(cost-meter 的
|
|
298
|
+
* store.js 就是),算完存成常量。等 apply 时再设已经晚了,账本照样写进 dsh 的家目录。
|
|
299
|
+
*/
|
|
300
|
+
function normalizeDshHome() {
|
|
301
|
+
// 一律覆盖,包括继承来的值:`DSH_HOME` 是 dsh 的内部开关,不是 Pneuma 用户的设置项。
|
|
302
|
+
// 从 dsh 终端里启动 Pneuma 时会继承到 `~/.dsh`,照抄就等于让插件写进 dsh 的家目录;
|
|
303
|
+
// 想换 Pneuma 的家请设 `DSC_HOME`,那条路我们本来就认。
|
|
304
|
+
process.env['DSH_HOME'] = dscPath();
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* 把「插件取过、Pneuma 没有或对不上」的服务名折成一句人话。
|
|
308
|
+
* @param asked - 插件运行时 `ctx.get` 过的名字(按调用顺序,可能重复)
|
|
309
|
+
* @returns 说明;没有缺失给 null
|
|
310
|
+
*/
|
|
311
|
+
function missingServicesOf(asked) {
|
|
312
|
+
const foreign = [...new Set(asked)].filter((name) => !DSC_SERVICE_NAMES.has(name));
|
|
313
|
+
if (foreign.length === 0)
|
|
314
|
+
return null;
|
|
315
|
+
return describeForeignServices(foreign);
|
|
316
|
+
}
|
|
205
317
|
/** 从条目树现读 risk 映射:`risk` 是这份插件全部工具的缺省,`risks` 按工具名覆盖。 */
|
|
206
318
|
function resolveRiskConfig(file) {
|
|
207
319
|
const raw = getPluginConfig(file);
|
|
@@ -275,8 +387,220 @@ export async function mountAllExternalPlugins(root, extraPaths) {
|
|
|
275
387
|
failures.push({ file: base, name: meta.name, problem: meta.problem });
|
|
276
388
|
}
|
|
277
389
|
}
|
|
390
|
+
// 组合包(dsh 的安装形态):只在这一份配置指定了 profile 时才走。
|
|
391
|
+
// 没配 profile 的用户启动路径与以前一个字节都不差。
|
|
392
|
+
const profileDir = activeProfileDir();
|
|
393
|
+
if (profileDir !== null && existsSync(profileDir)) {
|
|
394
|
+
const bundles = await mountBundlePlugins(root, profileDir);
|
|
395
|
+
failures.push(...bundles.failures);
|
|
396
|
+
for (const warning of bundles.warnings) {
|
|
397
|
+
root.transcript.system(`组合包:${warning}`, 'error');
|
|
398
|
+
}
|
|
399
|
+
}
|
|
278
400
|
return failures;
|
|
279
401
|
}
|
|
402
|
+
/**
|
|
403
|
+
* 当前生效的 profile 目录(没配就是 null = 不加载组合包)。
|
|
404
|
+
*
|
|
405
|
+
* 实现在 `core/profile-dir`:界面产物表也要用它,放这里会把整个宿主装载器拖进界面壳的
|
|
406
|
+
* 编译单元。这里转出保持既有 import 不变。
|
|
407
|
+
*/
|
|
408
|
+
export { activeProfileDir };
|
|
409
|
+
/**
|
|
410
|
+
* 装一个 profile 里的组合包插件(dsh 的安装形态)。
|
|
411
|
+
*
|
|
412
|
+
* 流程与 dsh 同形:profile 的 `dsh.profile.bundles` 给出层序 → 每个包读自己的
|
|
413
|
+
* `dsh.bundle.patch` 成一层 → 所有层按顺序套到「行」上(patch 里 insert 的行就是
|
|
414
|
+
* 要加载的插件)→ 每一行解析成文件路径后走与外置插件同一条挂载路径。
|
|
415
|
+
*
|
|
416
|
+
* 版本闸:包的 `engines.dsh` 不满足就先跳过并记一条告警(除非 profile 的
|
|
417
|
+
* compatibility.json 里登记了豁免)。
|
|
418
|
+
* @param root - 内核 root(组合包也走同一条热挂载路径)
|
|
419
|
+
* @param profileDir - profile 目录
|
|
420
|
+
* @returns 挂载失败清单(与 mountAllExternalPlugins 同形)+ 告警
|
|
421
|
+
*/
|
|
422
|
+
export async function mountBundlePlugins(root, profileDir) {
|
|
423
|
+
initPluginRuntime(root);
|
|
424
|
+
// 组合包的插件代码在 profile 自己的 node_modules 里,它们 import @deepseek-ai/* 时
|
|
425
|
+
// 要把这个目录也当成「允许重定向的插件根」——只认 ~/.dsc/plugins/ 的话,真装一个
|
|
426
|
+
// dsh 组合包会在 import 阶段就 ERR_MODULE_NOT_FOUND。
|
|
427
|
+
if (isPluginEnabled('dsh-compat'))
|
|
428
|
+
ensureResolveHook([join(profileDir, 'node_modules')]);
|
|
429
|
+
const profile = readProfile(profileDir);
|
|
430
|
+
const layers = [];
|
|
431
|
+
const warnings = [];
|
|
432
|
+
/** 每一层是哪个包的(解析相对路径时按它来)。 */
|
|
433
|
+
const layerOwner = new Map();
|
|
434
|
+
/** 包名 → 读盘结果(挂上之后要拿它的 `dsh.client` 给插件中心看)。 */
|
|
435
|
+
const bundleInfoOf = new Map();
|
|
436
|
+
for (const name of profile.bundles) {
|
|
437
|
+
const dir = bundleDirOf(profileDir, name);
|
|
438
|
+
if (!existsSync(dir)) {
|
|
439
|
+
warnings.push(`profile 里列了包「${name}」,但 ${dir} 不存在(先 pnpm install?),已跳过`);
|
|
440
|
+
continue;
|
|
441
|
+
}
|
|
442
|
+
let info;
|
|
443
|
+
try {
|
|
444
|
+
info = readBundle(dir);
|
|
445
|
+
}
|
|
446
|
+
catch (error) {
|
|
447
|
+
warnings.push(err(error));
|
|
448
|
+
continue;
|
|
449
|
+
}
|
|
450
|
+
if (info === null) {
|
|
451
|
+
warnings.push(`${dir} 里没有 package.json,不是插件包,已跳过`);
|
|
452
|
+
continue;
|
|
453
|
+
}
|
|
454
|
+
bundleInfoOf.set(info.name, info);
|
|
455
|
+
const manifest = JSON.parse(readFileSync(join(dir, 'package.json'), 'utf8'));
|
|
456
|
+
const engineProblem = enginesProblem(manifest);
|
|
457
|
+
if (engineProblem !== null && !profile.exemptions.includes(info.name)) {
|
|
458
|
+
warnings.push(`${info.name}:${engineProblem}`);
|
|
459
|
+
continue;
|
|
460
|
+
}
|
|
461
|
+
if (info.patch !== null) {
|
|
462
|
+
layers.push(info.patch);
|
|
463
|
+
layerOwner.set(info.patch.label, dir);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
if (profile.patch !== null)
|
|
467
|
+
layers.push(profile.patch);
|
|
468
|
+
// 行 id → 是哪个包的行(插件中心显示「来自组合包 X」用)
|
|
469
|
+
const ownerOf = new Map();
|
|
470
|
+
for (let index = 0; index < layers.length; index += 1) {
|
|
471
|
+
const layer = layers[index];
|
|
472
|
+
const owner = layerOwner.get(layer.label);
|
|
473
|
+
if (owner === undefined)
|
|
474
|
+
continue;
|
|
475
|
+
const name = basename(owner);
|
|
476
|
+
for (const patch of layer.patches) {
|
|
477
|
+
for (const row of patch.insert ?? []) {
|
|
478
|
+
if (typeof row.id === 'string' && row.id !== '')
|
|
479
|
+
ownerOf.set(row.id, name);
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
const base = [];
|
|
484
|
+
const applied = applyPatchLayers(base, layers);
|
|
485
|
+
warnings.push(...applied.warnings);
|
|
486
|
+
const failures = [];
|
|
487
|
+
for (const row of applied.rows) {
|
|
488
|
+
const target = typeof row.name === 'string' ? row.name : undefined;
|
|
489
|
+
if (target === undefined) {
|
|
490
|
+
warnings.push(`组合包里有一行没有 name(不知道加载什么),已跳过`);
|
|
491
|
+
continue;
|
|
492
|
+
}
|
|
493
|
+
const file = resolveBundleTarget(profileDir, target, layerOwner);
|
|
494
|
+
if (file === null) {
|
|
495
|
+
warnings.push(`组合包里的「${target}」找不到对应文件,已跳过`);
|
|
496
|
+
continue;
|
|
497
|
+
}
|
|
498
|
+
if (row.disabled === true)
|
|
499
|
+
continue;
|
|
500
|
+
const ok = await mountExternalPlugin(file);
|
|
501
|
+
const meta = getPluginMeta(basename(file));
|
|
502
|
+
const owner = typeof row.id === 'string' ? ownerOf.get(row.id) : undefined;
|
|
503
|
+
if (ok && meta !== undefined) {
|
|
504
|
+
if (owner !== undefined)
|
|
505
|
+
meta.bundle = owner;
|
|
506
|
+
// 有的包把界面能力写在 package.json 的 dsh.client(不在模块导出里)。
|
|
507
|
+
// 只列不加载,但要列得出来,否则用户在插件中心看不到「它还想改界面」。
|
|
508
|
+
//
|
|
509
|
+
// 例外:platform = 'pneuma' 的是**我们自己会加载**的界面半(见 core/ui-bundles 的
|
|
510
|
+
// discoverPackageUiArtifacts)。把它列成「dsh 客户端插件 · 只列不加载」是假话。
|
|
511
|
+
const declared = owner === undefined ? undefined : bundleInfoOf.get(owner)?.client;
|
|
512
|
+
const platform = declared?.platform;
|
|
513
|
+
if (meta.clientCapabilities === undefined && declared !== undefined && platform !== 'pneuma') {
|
|
514
|
+
meta.clientCapabilities = clientCapabilitiesOf(declared);
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
if (!ok && meta?.problem !== undefined) {
|
|
518
|
+
failures.push({ file: basename(file), name: meta.name, problem: meta.problem });
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
return { failures, warnings };
|
|
522
|
+
}
|
|
523
|
+
/**
|
|
524
|
+
* 把行里的 `name` 解析成文件路径。
|
|
525
|
+
*
|
|
526
|
+
* 三种写法:绝对路径、以 `./` `../` 开头(相对 profile 目录)、或包名(从 profile 的
|
|
527
|
+
* node_modules 解析)。解析不出来给 null(调用方记告警)。
|
|
528
|
+
*/
|
|
529
|
+
function resolveBundleTarget(profileDir, target, layerOwner) {
|
|
530
|
+
if (isAbsolute(target))
|
|
531
|
+
return entryFileOf(target);
|
|
532
|
+
if (target.startsWith('./') || target.startsWith('../')) {
|
|
533
|
+
// 相对路径按「哪一层的 patch 写的」算:bundle 的 patch 相对它自己的包目录。
|
|
534
|
+
const owner = [...layerOwner.values()].find((dir) => existsSync(join(dir, target)));
|
|
535
|
+
const candidate = owner === undefined ? join(profileDir, target) : join(owner, target);
|
|
536
|
+
return entryFileOf(candidate);
|
|
537
|
+
}
|
|
538
|
+
return entryFileOf(join(profileDir, 'node_modules', ...target.split('/')));
|
|
539
|
+
}
|
|
540
|
+
/**
|
|
541
|
+
* 把一个「可能是包目录」的路径落成真正的入口文件。
|
|
542
|
+
*
|
|
543
|
+
* dsh 的 patch 行写的是**包名**,pnpm 装上来的 `node_modules/<包名>` 是目录,
|
|
544
|
+
* 而 ESM 的 `import()` 不吃目录(`ERR_UNSUPPORTED_DIR_IMPORT`)。dsh 那边由 Node
|
|
545
|
+
* 的包解析负责找入口,我们这一层自己补:先看 `exports["."]`,再看 `main`,
|
|
546
|
+
* 最后退回 `index.js`。
|
|
547
|
+
* @param candidate - 绝对路径(文件或包目录)
|
|
548
|
+
* @returns 入口文件的绝对路径;路径不存在或目录里找不到入口给 null
|
|
549
|
+
*/
|
|
550
|
+
function entryFileOf(candidate) {
|
|
551
|
+
if (!existsSync(candidate))
|
|
552
|
+
return null;
|
|
553
|
+
let stats;
|
|
554
|
+
try {
|
|
555
|
+
stats = statSync(candidate);
|
|
556
|
+
}
|
|
557
|
+
catch {
|
|
558
|
+
return null;
|
|
559
|
+
}
|
|
560
|
+
if (!stats.isDirectory())
|
|
561
|
+
return candidate;
|
|
562
|
+
const manifest = readJsonObject(join(candidate, 'package.json'));
|
|
563
|
+
const fromExports = exportsEntry(manifest?.exports);
|
|
564
|
+
for (const relative of [fromExports, typeof manifest?.main === 'string' ? manifest.main : null, 'index.js']) {
|
|
565
|
+
if (relative === null || relative === '')
|
|
566
|
+
continue;
|
|
567
|
+
const file = join(candidate, relative);
|
|
568
|
+
if (existsSync(file))
|
|
569
|
+
return file;
|
|
570
|
+
}
|
|
571
|
+
return null;
|
|
572
|
+
}
|
|
573
|
+
/** `exports` 字段里 `"."` 那一路的入口(字符串或条件对象)。 */
|
|
574
|
+
function exportsEntry(exports) {
|
|
575
|
+
const root = typeof exports === 'string'
|
|
576
|
+
? exports
|
|
577
|
+
: exports !== null && typeof exports === 'object' && '.' in exports
|
|
578
|
+
? exports['.']
|
|
579
|
+
: exports;
|
|
580
|
+
if (typeof root === 'string')
|
|
581
|
+
return root;
|
|
582
|
+
if (root === null || typeof root !== 'object')
|
|
583
|
+
return null;
|
|
584
|
+
const conditions = root;
|
|
585
|
+
for (const key of ['default', 'import', 'node', 'require']) {
|
|
586
|
+
const value = conditions[key];
|
|
587
|
+
if (typeof value === 'string')
|
|
588
|
+
return value;
|
|
589
|
+
}
|
|
590
|
+
return null;
|
|
591
|
+
}
|
|
592
|
+
/** 松读一个 JSON 文件:不存在/坏掉给 null(入口解析按「没有」处理)。 */
|
|
593
|
+
function readJsonObject(file) {
|
|
594
|
+
if (!existsSync(file))
|
|
595
|
+
return null;
|
|
596
|
+
try {
|
|
597
|
+
const parsed = JSON.parse(readFileSync(file, 'utf8'));
|
|
598
|
+
return parsed !== null && typeof parsed === 'object' ? parsed : null;
|
|
599
|
+
}
|
|
600
|
+
catch {
|
|
601
|
+
return null;
|
|
602
|
+
}
|
|
603
|
+
}
|
|
280
604
|
function isDisabledByEntry(file) {
|
|
281
605
|
return readPluginEntries().find((entry) => entry.file === file)?.disabled ?? false;
|
|
282
606
|
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/** 一行插件(Pneuma 侧的最小形状:id 是稳定键,name 是加载目标)。 */
|
|
2
|
+
export interface PluginRow {
|
|
3
|
+
/** 行的稳定 id(patch 按它定位;Pneuma 里就是插件文件名或包名)。 */
|
|
4
|
+
id?: string;
|
|
5
|
+
/** 加载目标(文件路径或包名)。 */
|
|
6
|
+
name?: string;
|
|
7
|
+
/** 这一行的配置(patch 替换的是整块)。 */
|
|
8
|
+
config?: unknown;
|
|
9
|
+
/** 停用这一行。 */
|
|
10
|
+
disabled?: boolean | null;
|
|
11
|
+
/** group 行:`config` 是子行数组。 */
|
|
12
|
+
group?: boolean | null;
|
|
13
|
+
/** 其余字段原样保留(dsh 的 inject / intercept / isolate 之类)。 */
|
|
14
|
+
[key: string]: unknown;
|
|
15
|
+
}
|
|
16
|
+
/** 一条 patch(dsh 的 `PatchOptions`)。 */
|
|
17
|
+
export interface PatchEntry {
|
|
18
|
+
id?: string;
|
|
19
|
+
insert?: PluginRow[];
|
|
20
|
+
name?: string;
|
|
21
|
+
[key: string]: unknown;
|
|
22
|
+
}
|
|
23
|
+
/** 一层 patch:一个来源(某个 bundle 的 cordis.patch.yml、profile 自己的、或 `--patch` 覆盖层)。 */
|
|
24
|
+
export interface PatchLayer {
|
|
25
|
+
/** 诊断里显示的来源(文件路径或 `包名 v1.2.3`)。 */
|
|
26
|
+
label: string;
|
|
27
|
+
patches: readonly PatchEntry[];
|
|
28
|
+
}
|
|
29
|
+
/** 一层 patch 的结果。 */
|
|
30
|
+
export interface PatchResult {
|
|
31
|
+
rows: PluginRow[];
|
|
32
|
+
/** 人话告警(找不到目标行、目标不是 group、名字不符、含 `!!js` 被拒)。 */
|
|
33
|
+
warnings: string[];
|
|
34
|
+
}
|
|
35
|
+
/** patch 文件里出现了 `!!js`(求值等于任意代码执行)时的错误。 */
|
|
36
|
+
export declare class PatchUnsafeError extends Error {
|
|
37
|
+
constructor(file: string);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* 解析一份 patch 列表(YAML 文本)。
|
|
41
|
+
* @param text - 文件内容
|
|
42
|
+
* @param label - 诊断里怎么称呼这一层(通常是文件路径)
|
|
43
|
+
* @returns 这一层的 patch 条目
|
|
44
|
+
* @throws {PatchUnsafeError} 文本里出现 `!!js`
|
|
45
|
+
* @throws {Error} 不是 YAML、顶层不是数组、数组元素不是 mapping
|
|
46
|
+
*/
|
|
47
|
+
export declare function parsePatchList(text: string, label: string): PatchEntry[];
|
|
48
|
+
/**
|
|
49
|
+
* 读一层 patch 文件;文件不存在返回 null(= 这一层没有)。
|
|
50
|
+
* @param file - 绝对路径
|
|
51
|
+
* @param label - 诊断名(缺省用路径)
|
|
52
|
+
* @returns 这一层;文件不存在给 null
|
|
53
|
+
* @throws {PatchUnsafeError} 含 `!!js`
|
|
54
|
+
*/
|
|
55
|
+
export declare function readPatchFile(file: string, label?: string): PatchLayer | null;
|
|
56
|
+
/**
|
|
57
|
+
* 按 dsh 的 `applyEntryPatches` 逐层套用 patch。
|
|
58
|
+
*
|
|
59
|
+
* 层序即调用顺序:后面的层看得见前面层 insert 进来的行(同一条 patch 列表内部也是这样)。
|
|
60
|
+
* @param rows - 初始行(内置行 + 用户清单)
|
|
61
|
+
* @param layers - 按顺序的 patch 层
|
|
62
|
+
* @returns 套用后的行 + 告警
|
|
63
|
+
*/
|
|
64
|
+
export declare function applyPatchLayers(rows: readonly PluginRow[], layers: readonly PatchLayer[]): PatchResult;
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 插件「行」的 patch 层:把 dsh 的 `cordis.patch.yml` 语义搬过来。
|
|
3
|
+
*
|
|
4
|
+
* 为什么需要它:dsh 的插件包(bundle)自带一份 patch 列表,用 **id 指向某一行** 改配置、
|
|
5
|
+
* 或 `insert` 往某个 group 里插几行。没有这层语义,组合包「插几行插件」的意图就丢了——
|
|
6
|
+
* 装进去只剩一个空壳。
|
|
7
|
+
*
|
|
8
|
+
* 算法照 dsh 的 `vendor/include/src/index.ts` 的 `applyEntryPatches`(逐条对齐,别自创):
|
|
9
|
+
* 1. 先按 id 建索引,**递归进 group 的子行**(`group === true` 且 `config` 是数组);
|
|
10
|
+
* 2. 有 `insert` 的条目:带 id 就插到那个 group 的子行末尾(目标不是 group 就告警跳过),
|
|
11
|
+
* 不带 id 就追加到顶层;插完把新行**也建进索引**(同一层后面的 patch 要能改它们);
|
|
12
|
+
* 3. 没有 `insert` 的条目必须有 id,找不到目标就告警跳过;
|
|
13
|
+
* 4. 带 `name` 的条目先核对名字,不符就跳过(防「改错行」);
|
|
14
|
+
* 5. 其余键**逐个覆盖**到目标行上——注意 `config` 是整块替换,不是深合并
|
|
15
|
+
* (dsh 就是这个口径,深合并会让「删掉一个字段」表达不出来)。
|
|
16
|
+
*
|
|
17
|
+
* 与 dsh 唯一的有意差别:**`!!js` 一律拒绝**。dsh 允许 patch 里写 `!!js` 表达式并在加载时
|
|
18
|
+
* 求值——那等于让一个插件包在宿主进程里执行任意表达式。我们读到就抛错并说清原因,
|
|
19
|
+
* 不静默跳过(跳过会让「配置没生效」变成一个查不出来的谜)。
|
|
20
|
+
*
|
|
21
|
+
* @module dsc/core/plugin-patch
|
|
22
|
+
*/
|
|
23
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
24
|
+
import YAML from 'yaml';
|
|
25
|
+
/** patch 文件里出现了 `!!js`(求值等于任意代码执行)时的错误。 */
|
|
26
|
+
export class PatchUnsafeError extends Error {
|
|
27
|
+
constructor(file) {
|
|
28
|
+
super(`${file} 里用了 !!js 表达式。dsh 会在加载时求值,那等于让插件包在 Pneuma 进程里执行任意表达式,` +
|
|
29
|
+
'所以这里一律拒绝。请让插件作者改成字面量配置,或者用 Pneuma 自己的设置项。');
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const isRow = (value) => value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
33
|
+
/**
|
|
34
|
+
* 解析一份 patch 列表(YAML 文本)。
|
|
35
|
+
* @param text - 文件内容
|
|
36
|
+
* @param label - 诊断里怎么称呼这一层(通常是文件路径)
|
|
37
|
+
* @returns 这一层的 patch 条目
|
|
38
|
+
* @throws {PatchUnsafeError} 文本里出现 `!!js`
|
|
39
|
+
* @throws {Error} 不是 YAML、顶层不是数组、数组元素不是 mapping
|
|
40
|
+
*/
|
|
41
|
+
export function parsePatchList(text, label) {
|
|
42
|
+
// 先查 !!js:解析器遇到它要么求值要么报错,两种都不该发生,所以按文本先拦住。
|
|
43
|
+
if (/!!js\b/.test(text))
|
|
44
|
+
throw new PatchUnsafeError(label);
|
|
45
|
+
let parsed;
|
|
46
|
+
try {
|
|
47
|
+
parsed = YAML.parse(text);
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
throw new Error(`${label} 不是合法的 YAML:${error instanceof Error ? error.message : String(error)}`);
|
|
51
|
+
}
|
|
52
|
+
if (parsed === null || parsed === undefined)
|
|
53
|
+
return [];
|
|
54
|
+
if (!Array.isArray(parsed)) {
|
|
55
|
+
throw new Error(`${label} 的顶层必须是 YAML 数组(一行一条 patch),实际是 ${typeof parsed}`);
|
|
56
|
+
}
|
|
57
|
+
return parsed.map((entry, index) => {
|
|
58
|
+
if (!isRow(entry))
|
|
59
|
+
throw new Error(`${label} 第 ${String(index + 1)} 条不是 mapping(一行一条 patch)`);
|
|
60
|
+
return entry;
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* 读一层 patch 文件;文件不存在返回 null(= 这一层没有)。
|
|
65
|
+
* @param file - 绝对路径
|
|
66
|
+
* @param label - 诊断名(缺省用路径)
|
|
67
|
+
* @returns 这一层;文件不存在给 null
|
|
68
|
+
* @throws {PatchUnsafeError} 含 `!!js`
|
|
69
|
+
*/
|
|
70
|
+
export function readPatchFile(file, label = file) {
|
|
71
|
+
if (!existsSync(file))
|
|
72
|
+
return null;
|
|
73
|
+
const text = readFileSync(file, 'utf8');
|
|
74
|
+
return { label, patches: parsePatchList(text, label) };
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* 按 dsh 的 `applyEntryPatches` 逐层套用 patch。
|
|
78
|
+
*
|
|
79
|
+
* 层序即调用顺序:后面的层看得见前面层 insert 进来的行(同一条 patch 列表内部也是这样)。
|
|
80
|
+
* @param rows - 初始行(内置行 + 用户清单)
|
|
81
|
+
* @param layers - 按顺序的 patch 层
|
|
82
|
+
* @returns 套用后的行 + 告警
|
|
83
|
+
*/
|
|
84
|
+
export function applyPatchLayers(rows, layers) {
|
|
85
|
+
const data = structuredClone(rows);
|
|
86
|
+
const warnings = [];
|
|
87
|
+
/** id → 行(group 的子行也进来)。 */
|
|
88
|
+
const index = new Map();
|
|
89
|
+
const buildIndex = (entries) => {
|
|
90
|
+
for (const entry of entries) {
|
|
91
|
+
if (typeof entry.id === 'string' && entry.id !== '')
|
|
92
|
+
index.set(entry.id, entry);
|
|
93
|
+
if (entry.group === true && Array.isArray(entry.config))
|
|
94
|
+
buildIndex(entry.config);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
buildIndex(data);
|
|
98
|
+
for (const layer of layers) {
|
|
99
|
+
for (const [position, patch] of layer.patches.entries()) {
|
|
100
|
+
const where = `${layer.label} 第 ${String(position + 1)} 条`;
|
|
101
|
+
const insert = patch.insert;
|
|
102
|
+
if (insert !== undefined) {
|
|
103
|
+
const added = structuredClone(insert);
|
|
104
|
+
if (patch.id === undefined) {
|
|
105
|
+
data.push(...added);
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
const target = index.get(patch.id);
|
|
109
|
+
if (target === undefined) {
|
|
110
|
+
warnings.push(`${where}:要插入的 group「${patch.id}」不存在,已跳过`);
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
if (target.group !== true) {
|
|
114
|
+
warnings.push(`${where}:目标「${patch.id}」不是 group,插不进子行,已跳过`);
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
if (!Array.isArray(target.config))
|
|
118
|
+
target.config = [];
|
|
119
|
+
target.config.push(...added);
|
|
120
|
+
}
|
|
121
|
+
buildIndex(added);
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
if (patch.id === undefined) {
|
|
125
|
+
warnings.push(`${where}:不是 insert 就必须写 id(要改哪一行),已跳过`);
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
const target = index.get(patch.id);
|
|
129
|
+
if (target === undefined) {
|
|
130
|
+
// dsh 对「目标行不在」只告警不抛:一个覆盖层可能给多个界面共用,不该要求处处都有。
|
|
131
|
+
warnings.push(`${where}:找不到 id 为「${patch.id}」的行,已跳过`);
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
if (typeof patch.name === 'string' && patch.name !== target.name) {
|
|
135
|
+
warnings.push(`${where}:名字对不上(这行是「${String(target.name)}」,patch 写的是「${patch.name}」),已跳过`);
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
for (const [key, value] of Object.entries(patch)) {
|
|
139
|
+
if (key === 'id' || key === 'name' || key === 'insert')
|
|
140
|
+
continue;
|
|
141
|
+
target[key] = value;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return { rows: data, warnings };
|
|
146
|
+
}
|
|
@@ -25,6 +25,20 @@ export interface PluginMeta {
|
|
|
25
25
|
* 危险一点的官方插件(电脑操作)用它,装完不主动拿到桌面控制权。
|
|
26
26
|
*/
|
|
27
27
|
defaultDisabled?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* 这个插件来自哪个组合包(bundle)。单文件插件没有这一项。
|
|
30
|
+
* 插件中心据此显示「来自组合包 X」,方便用户知道该去哪卸载。
|
|
31
|
+
*/
|
|
32
|
+
bundle?: string;
|
|
33
|
+
/**
|
|
34
|
+
* 这个插件声明的 **dsh 客户端(界面)能力**,只列不加载。
|
|
35
|
+
*
|
|
36
|
+
* 为什么只列:dsh 的 `dsh.client` 插件要一份 dsh 自己的客户端运行时(cordis 客户端
|
|
37
|
+
* 服务 + 平台模块表),Pneuma 的界面壳是另一套契约。真加载等于在页面里跑第二个框架,
|
|
38
|
+
* 与更严的信任模型冲突。所以这里如实告诉用户「这个插件想让界面做什么」,
|
|
39
|
+
* 但不执行它的界面代码。
|
|
40
|
+
*/
|
|
41
|
+
clientCapabilities?: string[];
|
|
28
42
|
}
|
|
29
43
|
/** 注册(或覆盖)一条插件元数据。 */
|
|
30
44
|
export declare function registerPluginMeta(meta: PluginMeta): void;
|