@waq666/pneuma 0.0.0-stage → 0.7.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/LICENSE +21 -0
- package/README.md +206 -3
- package/bin/dsc.js +91 -0
- package/bin/headless.cjs +40 -0
- package/lib/adapter/core-runtime.d.ts +11 -0
- package/lib/adapter/core-runtime.js +259 -0
- package/lib/adapter/host.d.ts +18 -0
- package/lib/adapter/host.js +14 -0
- package/lib/adapter/runtime.d.ts +15 -0
- package/lib/adapter/runtime.js +290 -0
- package/lib/adapter/transcript.d.ts +184 -0
- package/lib/adapter/transcript.js +605 -0
- package/lib/app/AgentsOverlay.d.ts +18 -0
- package/lib/app/AgentsOverlay.js +63 -0
- package/lib/app/App.d.ts +15 -0
- package/lib/app/App.js +1650 -0
- package/lib/app/App.js.nv-backup +1650 -0
- package/lib/app/ApprovalCard.d.ts +12 -0
- package/lib/app/ApprovalCard.js +76 -0
- package/lib/app/AskCard.d.ts +20 -0
- package/lib/app/AskCard.js +45 -0
- package/lib/app/ChatView.d.ts +63 -0
- package/lib/app/ChatView.js +310 -0
- package/lib/app/Composer.d.ts +50 -0
- package/lib/app/Composer.js +282 -0
- package/lib/app/DiffBlock.d.ts +6 -0
- package/lib/app/DiffBlock.js +37 -0
- package/lib/app/MarkdownView.d.ts +6 -0
- package/lib/app/MarkdownView.js +99 -0
- package/lib/app/ModelPicker.d.ts +7 -0
- package/lib/app/ModelPicker.js +18 -0
- package/lib/app/PlanReviewCard.d.ts +13 -0
- package/lib/app/PlanReviewCard.js +54 -0
- package/lib/app/PresetPicker.d.ts +11 -0
- package/lib/app/PresetPicker.js +19 -0
- package/lib/app/PreviewOverlay.d.ts +14 -0
- package/lib/app/PreviewOverlay.js +22 -0
- package/lib/app/SessionPicker.d.ts +43 -0
- package/lib/app/SessionPicker.js +56 -0
- package/lib/app/SettingsOverlay.d.ts +32 -0
- package/lib/app/SettingsOverlay.js +157 -0
- package/lib/app/SkillsPicker.d.ts +7 -0
- package/lib/app/SkillsPicker.js +19 -0
- package/lib/app/StatusBar.d.ts +22 -0
- package/lib/app/StatusBar.js +201 -0
- package/lib/app/TaskStrips.d.ts +13 -0
- package/lib/app/TaskStrips.js +40 -0
- package/lib/app/TimelineRail.d.ts +22 -0
- package/lib/app/TimelineRail.js +160 -0
- package/lib/app/TimelineRail.js.negbak +98 -0
- package/lib/app/TimelineRail.js.nv-backup +160 -0
- package/lib/app/ToolCard.d.ts +11 -0
- package/lib/app/ToolCard.js +64 -0
- package/lib/app/ToolCard.js.nv-backup +64 -0
- package/lib/app/TranscriptOverlay.d.ts +27 -0
- package/lib/app/TranscriptOverlay.js +36 -0
- package/lib/app/TranscriptViewport.d.ts +78 -0
- package/lib/app/TranscriptViewport.js +218 -0
- package/lib/app/Welcome.d.ts +6 -0
- package/lib/app/Welcome.js +71 -0
- package/lib/app/attach.d.ts +16 -0
- package/lib/app/attach.js +58 -0
- package/lib/app/click.d.ts +40 -0
- package/lib/app/click.js +103 -0
- package/lib/app/clipboard-image.d.ts +11 -0
- package/lib/app/clipboard-image.js +66 -0
- package/lib/app/cursor.d.ts +4 -0
- package/lib/app/cursor.js +24 -0
- package/lib/app/hello.d.ts +11 -0
- package/lib/app/hello.js +8 -0
- package/lib/app/history-store.d.ts +4 -0
- package/lib/app/history-store.js +41 -0
- package/lib/app/image-blocks.d.ts +12 -0
- package/lib/app/image-blocks.js +125 -0
- package/lib/app/keymap.d.ts +56 -0
- package/lib/app/keymap.js +56 -0
- package/lib/app/markdown.d.ts +54 -0
- package/lib/app/markdown.js +189 -0
- package/lib/app/mouse.d.ts +33 -0
- package/lib/app/mouse.js +35 -0
- package/lib/app/pointer.d.ts +16 -0
- package/lib/app/pointer.js +60 -0
- package/lib/app/scroll-model.d.ts +240 -0
- package/lib/app/scroll-model.js +347 -0
- package/lib/app/settings-model.d.ts +69 -0
- package/lib/app/settings-model.js +114 -0
- package/lib/app/snapshot-subscribe.d.ts +34 -0
- package/lib/app/snapshot-subscribe.js +110 -0
- package/lib/app/theme.d.ts +194 -0
- package/lib/app/theme.js +186 -0
- package/lib/app/ticker.d.ts +7 -0
- package/lib/app/ticker.js +53 -0
- package/lib/boot.d.ts +1 -0
- package/lib/boot.js +34 -0
- package/lib/commands.d.ts +49 -0
- package/lib/commands.js +115 -0
- package/lib/contract.d.ts +1973 -0
- package/lib/contract.js +36 -0
- package/lib/core/agent-roles.d.ts +52 -0
- package/lib/core/agent-roles.js +274 -0
- package/lib/core/approval-floor.d.ts +183 -0
- package/lib/core/approval-floor.js +679 -0
- package/lib/core/approval.d.ts +42 -0
- package/lib/core/approval.js +8 -0
- package/lib/core/audit.d.ts +61 -0
- package/lib/core/audit.js +59 -0
- package/lib/core/boot-notices.d.ts +6 -0
- package/lib/core/boot-notices.js +61 -0
- package/lib/core/cdp/actions.d.ts +182 -0
- package/lib/core/cdp/actions.js +649 -0
- package/lib/core/cdp/launch.d.ts +192 -0
- package/lib/core/cdp/launch.js +491 -0
- package/lib/core/cdp/snapshot.d.ts +139 -0
- package/lib/core/cdp/snapshot.js +316 -0
- package/lib/core/cdp/transport.d.ts +160 -0
- package/lib/core/cdp/transport.js +359 -0
- package/lib/core/command-policy.d.ts +108 -0
- package/lib/core/command-policy.js +580 -0
- package/lib/core/commands-completion.d.ts +78 -0
- package/lib/core/commands-completion.js +167 -0
- package/lib/core/compact-anchors.d.ts +76 -0
- package/lib/core/compact-anchors.js +284 -0
- package/lib/core/compact.d.ts +110 -0
- package/lib/core/compact.js +210 -0
- package/lib/core/config-store.d.ts +38 -0
- package/lib/core/config-store.js +307 -0
- package/lib/core/config.d.ts +36 -0
- package/lib/core/config.js +124 -0
- package/lib/core/connection-test.d.ts +60 -0
- package/lib/core/connection-test.js +84 -0
- package/lib/core/desktop-control.d.ts +298 -0
- package/lib/core/desktop-control.js +1311 -0
- package/lib/core/diff-text.d.ts +74 -0
- package/lib/core/diff-text.js +257 -0
- package/lib/core/dock-browser.d.ts +137 -0
- package/lib/core/dock-browser.js +146 -0
- package/lib/core/dock-ops.d.ts +59 -0
- package/lib/core/dock-ops.js +104 -0
- package/lib/core/dock-session.d.ts +39 -0
- package/lib/core/dock-session.js +28 -0
- package/lib/core/dsh-compat/hook.d.ts +18 -0
- package/lib/core/dsh-compat/hook.js +52 -0
- package/lib/core/dsh-compat/resolve-hook.d.ts +5 -0
- package/lib/core/dsh-compat/resolve-hook.js +59 -0
- package/lib/core/dsh-compat/tools-facade.d.ts +47 -0
- package/lib/core/dsh-compat/tools-facade.js +108 -0
- package/lib/core/err-text.d.ts +13 -0
- package/lib/core/err-text.js +15 -0
- package/lib/core/events.d.ts +149 -0
- package/lib/core/events.js +1 -0
- package/lib/core/git-exec.d.ts +23 -0
- package/lib/core/git-exec.js +72 -0
- package/lib/core/git-info.d.ts +47 -0
- package/lib/core/git-info.js +157 -0
- package/lib/core/goal.d.ts +89 -0
- package/lib/core/goal.js +189 -0
- package/lib/core/hooks.d.ts +272 -0
- package/lib/core/hooks.js +818 -0
- package/lib/core/host-browser-link.d.ts +59 -0
- package/lib/core/host-browser-link.js +9 -0
- package/lib/core/host-methods.d.ts +25 -0
- package/lib/core/host-methods.js +103 -0
- package/lib/core/image-diet.d.ts +77 -0
- package/lib/core/image-diet.js +127 -0
- package/lib/core/learnings/ledger.d.ts +73 -0
- package/lib/core/learnings/ledger.js +273 -0
- package/lib/core/learnings/skill-write.d.ts +250 -0
- package/lib/core/learnings/skill-write.js +854 -0
- package/lib/core/learnings/store.d.ts +102 -0
- package/lib/core/learnings/store.js +266 -0
- package/lib/core/lifecycle-hooks.d.ts +189 -0
- package/lib/core/lifecycle-hooks.js +576 -0
- package/lib/core/llm.d.ts +283 -0
- package/lib/core/llm.js +565 -0
- package/lib/core/lockfile.d.ts +17 -0
- package/lib/core/lockfile.js +110 -0
- package/lib/core/loop.d.ts +185 -0
- package/lib/core/loop.js +587 -0
- package/lib/core/lsp/client.d.ts +189 -0
- package/lib/core/lsp/client.js +690 -0
- package/lib/core/lsp/framing.d.ts +84 -0
- package/lib/core/lsp/framing.js +181 -0
- package/lib/core/lsp/line-shift.d.ts +28 -0
- package/lib/core/lsp/line-shift.js +127 -0
- package/lib/core/lsp/manager.d.ts +93 -0
- package/lib/core/lsp/manager.js +418 -0
- package/lib/core/lsp/normalize.d.ts +32 -0
- package/lib/core/lsp/normalize.js +139 -0
- package/lib/core/lsp/servers.d.ts +106 -0
- package/lib/core/lsp/servers.js +352 -0
- package/lib/core/lsp/uri.d.ts +76 -0
- package/lib/core/lsp/uri.js +179 -0
- package/lib/core/market.d.ts +51 -0
- package/lib/core/market.js +358 -0
- package/lib/core/mcp.d.ts +201 -0
- package/lib/core/mcp.js +836 -0
- package/lib/core/memory-eval.d.ts +158 -0
- package/lib/core/memory-eval.js +215 -0
- package/lib/core/memory.d.ts +266 -0
- package/lib/core/memory.js +703 -0
- package/lib/core/mention.d.ts +57 -0
- package/lib/core/mention.js +129 -0
- package/lib/core/microcompact.d.ts +48 -0
- package/lib/core/microcompact.js +79 -0
- package/lib/core/migrate.d.ts +56 -0
- package/lib/core/migrate.js +134 -0
- package/lib/core/model-caps.d.ts +83 -0
- package/lib/core/model-caps.js +150 -0
- package/lib/core/model-discovery.d.ts +19 -0
- package/lib/core/model-discovery.js +69 -0
- package/lib/core/modes.d.ts +72 -0
- package/lib/core/modes.js +152 -0
- package/lib/core/native-bridge.d.ts +135 -0
- package/lib/core/native-bridge.js +563 -0
- package/lib/core/path-policy.d.ts +32 -0
- package/lib/core/path-policy.js +248 -0
- package/lib/core/permission-presets.d.ts +67 -0
- package/lib/core/permission-presets.js +75 -0
- package/lib/core/plugin-loader.d.ts +36 -0
- package/lib/core/plugin-loader.js +294 -0
- package/lib/core/plugin-registry.d.ts +113 -0
- package/lib/core/plugin-registry.js +256 -0
- package/lib/core/prefs.d.ts +82 -0
- package/lib/core/prefs.js +372 -0
- package/lib/core/presets.d.ts +80 -0
- package/lib/core/presets.js +373 -0
- package/lib/core/pricing.d.ts +90 -0
- package/lib/core/pricing.js +126 -0
- package/lib/core/prompt.d.ts +92 -0
- package/lib/core/prompt.js +339 -0
- package/lib/core/ptc.d.ts +66 -0
- package/lib/core/ptc.js +70 -0
- package/lib/core/remote/frames.d.ts +91 -0
- package/lib/core/remote/frames.js +174 -0
- package/lib/core/remote/notify.d.ts +54 -0
- package/lib/core/remote/notify.js +77 -0
- package/lib/core/remote/owner.d.ts +32 -0
- package/lib/core/remote/owner.js +75 -0
- package/lib/core/remote/pairing.d.ts +104 -0
- package/lib/core/remote/pairing.js +261 -0
- package/lib/core/remote/push.d.ts +80 -0
- package/lib/core/remote/push.js +222 -0
- package/lib/core/remote/store.d.ts +18 -0
- package/lib/core/remote/store.js +59 -0
- package/lib/core/remote/tickets.d.ts +20 -0
- package/lib/core/remote/tickets.js +49 -0
- package/lib/core/remote/uploads.d.ts +63 -0
- package/lib/core/remote/uploads.js +161 -0
- package/lib/core/request-attribution.d.ts +26 -0
- package/lib/core/request-attribution.js +86 -0
- package/lib/core/request-invariant.d.ts +61 -0
- package/lib/core/request-invariant.js +199 -0
- package/lib/core/sandbox/backends.d.ts +64 -0
- package/lib/core/sandbox/backends.js +194 -0
- package/lib/core/sandbox/execpolicy.d.ts +93 -0
- package/lib/core/sandbox/execpolicy.js +452 -0
- package/lib/core/sandbox/net-proxy.d.ts +31 -0
- package/lib/core/sandbox/net-proxy.js +162 -0
- package/lib/core/sandbox/policy.d.ts +211 -0
- package/lib/core/sandbox/policy.js +559 -0
- package/lib/core/sandbox/win/abi.d.ts +161 -0
- package/lib/core/sandbox/win/abi.js +169 -0
- package/lib/core/sandbox/win/account.d.ts +71 -0
- package/lib/core/sandbox/win/account.js +206 -0
- package/lib/core/sandbox/win/acl.d.ts +54 -0
- package/lib/core/sandbox/win/acl.js +339 -0
- package/lib/core/sandbox/win/backend.d.ts +61 -0
- package/lib/core/sandbox/win/backend.js +249 -0
- package/lib/core/sandbox/win/doctor.d.ts +24 -0
- package/lib/core/sandbox/win/doctor.js +272 -0
- package/lib/core/sandbox/win/ffi.d.ts +107 -0
- package/lib/core/sandbox/win/ffi.js +166 -0
- package/lib/core/sandbox/win/net-abi.d.ts +154 -0
- package/lib/core/sandbox/win/net-abi.js +316 -0
- package/lib/core/sandbox/win/runner-entry.d.ts +35 -0
- package/lib/core/sandbox/win/runner-entry.js +391 -0
- package/lib/core/sandbox/win/setup.d.ts +60 -0
- package/lib/core/sandbox/win/setup.js +986 -0
- package/lib/core/sandbox/win/token.d.ts +35 -0
- package/lib/core/sandbox/win/token.js +238 -0
- package/lib/core/sandbox/win/wfp.d.ts +41 -0
- package/lib/core/sandbox/win/wfp.js +200 -0
- package/lib/core/sandbox/win/workspace-sid.d.ts +9 -0
- package/lib/core/sandbox/win/workspace-sid.js +45 -0
- package/lib/core/schedule/rule.d.ts +184 -0
- package/lib/core/schedule/rule.js +745 -0
- package/lib/core/schedule/runner.d.ts +185 -0
- package/lib/core/schedule/runner.js +678 -0
- package/lib/core/schedule/store.d.ts +182 -0
- package/lib/core/schedule/store.js +455 -0
- package/lib/core/secrets.d.ts +41 -0
- package/lib/core/secrets.js +150 -0
- package/lib/core/session-export.d.ts +18 -0
- package/lib/core/session-export.js +73 -0
- package/lib/core/session-index.d.ts +159 -0
- package/lib/core/session-index.js +683 -0
- package/lib/core/session-meta.d.ts +41 -0
- package/lib/core/session-meta.js +97 -0
- package/lib/core/session.d.ts +356 -0
- package/lib/core/session.js +998 -0
- package/lib/core/skills.d.ts +60 -0
- package/lib/core/skills.js +171 -0
- package/lib/core/spill.d.ts +159 -0
- package/lib/core/spill.js +329 -0
- package/lib/core/surface-registry.d.ts +45 -0
- package/lib/core/surface-registry.js +67 -0
- package/lib/core/team-board.d.ts +95 -0
- package/lib/core/team-board.js +316 -0
- package/lib/core/throughput.d.ts +46 -0
- package/lib/core/throughput.js +40 -0
- package/lib/core/todo-reminder.d.ts +44 -0
- package/lib/core/todo-reminder.js +55 -0
- package/lib/core/todo.d.ts +81 -0
- package/lib/core/todo.js +222 -0
- package/lib/core/token-estimate.d.ts +55 -0
- package/lib/core/token-estimate.js +82 -0
- package/lib/core/tool-guards.d.ts +103 -0
- package/lib/core/tool-guards.js +77 -0
- package/lib/core/tool-search.d.ts +152 -0
- package/lib/core/tool-search.js +311 -0
- package/lib/core/tools/bash.d.ts +281 -0
- package/lib/core/tools/bash.js +871 -0
- package/lib/core/tools/command-runner.d.ts +84 -0
- package/lib/core/tools/command-runner.js +68 -0
- package/lib/core/tools/fs-tools.d.ts +23 -0
- package/lib/core/tools/fs-tools.js +247 -0
- package/lib/core/tools/index.d.ts +8 -0
- package/lib/core/tools/index.js +4 -0
- package/lib/core/tools/sandbox-args.d.ts +51 -0
- package/lib/core/tools/sandbox-args.js +90 -0
- package/lib/core/tools/search-tools.d.ts +3 -0
- package/lib/core/tools/search-tools.js +153 -0
- package/lib/core/tools.d.ts +96 -0
- package/lib/core/tools.js +53 -0
- package/lib/core/ui-boot-source.d.ts +71 -0
- package/lib/core/ui-boot-source.js +121 -0
- package/lib/core/ui-bundles.d.ts +249 -0
- package/lib/core/ui-bundles.js +830 -0
- package/lib/core/ui-combo.d.ts +49 -0
- package/lib/core/ui-combo.js +55 -0
- package/lib/core/ui-events.d.ts +81 -0
- package/lib/core/ui-events.js +364 -0
- package/lib/core/ui-hmr.d.ts +36 -0
- package/lib/core/ui-hmr.js +128 -0
- package/lib/core/ui-methods.d.ts +69 -0
- package/lib/core/ui-methods.js +341 -0
- package/lib/core/ui-route.d.ts +69 -0
- package/lib/core/ui-route.js +122 -0
- package/lib/core/ui-server.d.ts +75 -0
- package/lib/core/ui-server.js +369 -0
- package/lib/core/ui-trust.d.ts +47 -0
- package/lib/core/ui-trust.js +164 -0
- package/lib/core/untrusted.d.ts +30 -0
- package/lib/core/untrusted.js +48 -0
- package/lib/core/update-check.d.ts +81 -0
- package/lib/core/update-check.js +177 -0
- package/lib/core/usage-log.d.ts +82 -0
- package/lib/core/usage-log.js +306 -0
- package/lib/core/version.d.ts +1 -0
- package/lib/core/version.js +37 -0
- package/lib/core/web-http.d.ts +57 -0
- package/lib/core/web-http.js +137 -0
- package/lib/core/web-static.d.ts +31 -0
- package/lib/core/web-static.js +75 -0
- package/lib/headless.d.ts +1 -0
- package/lib/headless.js +31 -0
- package/lib/host/kernel.d.ts +33 -0
- package/lib/host/kernel.js +451 -0
- package/lib/index.d.ts +41 -0
- package/lib/index.js +35 -0
- package/lib/plugins/agent.d.ts +2 -0
- package/lib/plugins/agent.js +274 -0
- package/lib/plugins/approval-floor.d.ts +2 -0
- package/lib/plugins/approval-floor.js +223 -0
- package/lib/plugins/approval.d.ts +16 -0
- package/lib/plugins/approval.js +674 -0
- package/lib/plugins/ask.d.ts +2 -0
- package/lib/plugins/ask.js +245 -0
- package/lib/plugins/browser.d.ts +68 -0
- package/lib/plugins/browser.js +1341 -0
- package/lib/plugins/commands.d.ts +23 -0
- package/lib/plugins/commands.js +498 -0
- package/lib/plugins/compact.d.ts +21 -0
- package/lib/plugins/compact.js +274 -0
- package/lib/plugins/computer-use.d.ts +47 -0
- package/lib/plugins/computer-use.js +539 -0
- package/lib/plugins/desktop-dock.d.ts +2 -0
- package/lib/plugins/desktop-dock.js +626 -0
- package/lib/plugins/dock-browser.d.ts +34 -0
- package/lib/plugins/dock-browser.js +765 -0
- package/lib/plugins/dsh-compat.d.ts +25 -0
- package/lib/plugins/dsh-compat.js +37 -0
- package/lib/plugins/file-review.d.ts +108 -0
- package/lib/plugins/file-review.js +393 -0
- package/lib/plugins/git.d.ts +26 -0
- package/lib/plugins/git.js +132 -0
- package/lib/plugins/goal.d.ts +20 -0
- package/lib/plugins/goal.js +245 -0
- package/lib/plugins/guards.d.ts +14 -0
- package/lib/plugins/guards.js +18 -0
- package/lib/plugins/hooks.d.ts +19 -0
- package/lib/plugins/hooks.js +583 -0
- package/lib/plugins/host-stdio.d.ts +88 -0
- package/lib/plugins/host-stdio.js +317 -0
- package/lib/plugins/image-diet.d.ts +17 -0
- package/lib/plugins/image-diet.js +85 -0
- package/lib/plugins/lifecycle-hooks.d.ts +26 -0
- package/lib/plugins/lifecycle-hooks.js +338 -0
- package/lib/plugins/llm.d.ts +13 -0
- package/lib/plugins/llm.js +215 -0
- package/lib/plugins/lsp.d.ts +54 -0
- package/lib/plugins/lsp.js +608 -0
- package/lib/plugins/mcp.d.ts +16 -0
- package/lib/plugins/mcp.js +673 -0
- package/lib/plugins/memory.d.ts +17 -0
- package/lib/plugins/memory.js +858 -0
- package/lib/plugins/microcompact.d.ts +18 -0
- package/lib/plugins/microcompact.js +119 -0
- package/lib/plugins/mode.d.ts +18 -0
- package/lib/plugins/mode.js +115 -0
- package/lib/plugins/permission-presets.d.ts +18 -0
- package/lib/plugins/permission-presets.js +135 -0
- package/lib/plugins/plan.d.ts +2 -0
- package/lib/plugins/plan.js +192 -0
- package/lib/plugins/plugin-manager.d.ts +2 -0
- package/lib/plugins/plugin-manager.js +165 -0
- package/lib/plugins/presets.d.ts +2 -0
- package/lib/plugins/presets.js +182 -0
- package/lib/plugins/prompt.d.ts +2 -0
- package/lib/plugins/prompt.js +264 -0
- package/lib/plugins/ptc.d.ts +2 -0
- package/lib/plugins/ptc.js +272 -0
- package/lib/plugins/remote/http.d.ts +11 -0
- package/lib/plugins/remote/http.js +11 -0
- package/lib/plugins/remote/routes.d.ts +24 -0
- package/lib/plugins/remote/routes.js +384 -0
- package/lib/plugins/remote/types.d.ts +135 -0
- package/lib/plugins/remote/types.js +87 -0
- package/lib/plugins/remote.d.ts +17 -0
- package/lib/plugins/remote.js +1028 -0
- package/lib/plugins/runtime-api.d.ts +16 -0
- package/lib/plugins/runtime-api.js +99 -0
- package/lib/plugins/runtime.d.ts +10 -0
- package/lib/plugins/runtime.js +451 -0
- package/lib/plugins/sandbox.d.ts +2 -0
- package/lib/plugins/sandbox.js +761 -0
- package/lib/plugins/schedule.d.ts +26 -0
- package/lib/plugins/schedule.js +538 -0
- package/lib/plugins/self-improve.d.ts +61 -0
- package/lib/plugins/self-improve.js +953 -0
- package/lib/plugins/session-search.d.ts +16 -0
- package/lib/plugins/session-search.js +308 -0
- package/lib/plugins/session-title.d.ts +19 -0
- package/lib/plugins/session-title.js +109 -0
- package/lib/plugins/session.d.ts +7 -0
- package/lib/plugins/session.js +296 -0
- package/lib/plugins/settings.d.ts +3 -0
- package/lib/plugins/settings.js +705 -0
- package/lib/plugins/skills.d.ts +2 -0
- package/lib/plugins/skills.js +360 -0
- package/lib/plugins/spill.d.ts +16 -0
- package/lib/plugins/spill.js +200 -0
- package/lib/plugins/subagent.d.ts +2 -0
- package/lib/plugins/subagent.js +896 -0
- package/lib/plugins/surfaces.d.ts +11 -0
- package/lib/plugins/surfaces.js +20 -0
- package/lib/plugins/team.d.ts +16 -0
- package/lib/plugins/team.js +149 -0
- package/lib/plugins/todo.d.ts +19 -0
- package/lib/plugins/todo.js +188 -0
- package/lib/plugins/tool-search.d.ts +2 -0
- package/lib/plugins/tool-search.js +434 -0
- package/lib/plugins/tool-search.js.nv-backup +434 -0
- package/lib/plugins/tools-default.d.ts +12 -0
- package/lib/plugins/tools-default.js +275 -0
- package/lib/plugins/tools.d.ts +16 -0
- package/lib/plugins/tools.js +62 -0
- package/lib/plugins/transcript.d.ts +15 -0
- package/lib/plugins/transcript.js +311 -0
- package/lib/plugins/tui.d.ts +2 -0
- package/lib/plugins/tui.js +98 -0
- package/lib/plugins/waiting.d.ts +12 -0
- package/lib/plugins/waiting.js +34 -0
- package/lib/plugins/web-search.d.ts +14 -0
- package/lib/plugins/web-search.js +263 -0
- package/lib/plugins/webserver.d.ts +48 -0
- package/lib/plugins/webserver.js +228 -0
- package/lib/remote/assets/app-DAcUCOEn.js +14 -0
- package/lib/remote/assets/icon-192.png +0 -0
- package/lib/remote/assets/icon-512.png +0 -0
- package/lib/remote/assets/index.html +34 -0
- package/lib/remote/assets/manifest.json +27 -0
- package/lib/remote/assets/style-DIB6729x.css +1 -0
- package/lib/remote/assets/sw.js +66 -0
- package/lib/services/types.d.ts +1228 -0
- package/lib/services/types.js +1 -0
- package/lib/tools/config-cli.d.ts +1 -0
- package/lib/tools/config-cli.js +89 -0
- package/lib/ui/arrival.d.ts +72 -0
- package/lib/ui/arrival.js +105 -0
- package/lib/ui/assets/app-B70nVIKd.js +69 -0
- package/lib/ui/assets/chunk-2UxHyX5q.js +1 -0
- package/lib/ui/assets/chunk-B1dDrJ26.js +1 -0
- package/lib/ui/assets/chunk-B6aJPvgy.js +1 -0
- package/lib/ui/assets/chunk-BEwlwnbL.js +1 -0
- package/lib/ui/assets/chunk-BGcgwlCI.js +12 -0
- package/lib/ui/assets/chunk-BIGW1oBm.js +1 -0
- package/lib/ui/assets/chunk-BPQ3VLAy.js +1 -0
- package/lib/ui/assets/chunk-BRH0KZbk.js +141 -0
- package/lib/ui/assets/chunk-BX6H_ySx.js +1 -0
- package/lib/ui/assets/chunk-B_P3UbPa.js +1 -0
- package/lib/ui/assets/chunk-B_TYUkTI.js +1 -0
- package/lib/ui/assets/chunk-B_vNuMnf.js +1 -0
- package/lib/ui/assets/chunk-BajyYBss.js +10 -0
- package/lib/ui/assets/chunk-BdnUsdx6.js +1 -0
- package/lib/ui/assets/chunk-Buea-lGh.js +1 -0
- package/lib/ui/assets/chunk-C0PvZCCE.js +1 -0
- package/lib/ui/assets/chunk-C0m74zRD.js +1 -0
- package/lib/ui/assets/chunk-C27-OAKa.js +1 -0
- package/lib/ui/assets/chunk-C2oV4EkX.js +1 -0
- package/lib/ui/assets/chunk-C7zT0LnQ.js +1 -0
- package/lib/ui/assets/chunk-C9GSunVT.js +1 -0
- package/lib/ui/assets/chunk-C9tS-k6U.js +1 -0
- package/lib/ui/assets/chunk-CHLpvVh8.js +1 -0
- package/lib/ui/assets/chunk-CLxacb5B.js +1 -0
- package/lib/ui/assets/chunk-COt5Ahok.js +1 -0
- package/lib/ui/assets/chunk-CPTIWCL2.js +1 -0
- package/lib/ui/assets/chunk-CQLl-L-p.js +1 -0
- package/lib/ui/assets/chunk-CUWRgxuq.js +55 -0
- package/lib/ui/assets/chunk-CWanVSXC.js +1 -0
- package/lib/ui/assets/chunk-Cf5RLm7j.js +1 -0
- package/lib/ui/assets/chunk-CickPsom.js +1 -0
- package/lib/ui/assets/chunk-Cj5Yp3dK.js +1 -0
- package/lib/ui/assets/chunk-Cmh6b_Ma.js +1 -0
- package/lib/ui/assets/chunk-Cp-IABpG.js +1 -0
- package/lib/ui/assets/chunk-CqE71os6.js +1 -0
- package/lib/ui/assets/chunk-CtKP3W-j.js +1 -0
- package/lib/ui/assets/chunk-Cvjx9yec.js +1 -0
- package/lib/ui/assets/chunk-CxGP3dtY.js +1 -0
- package/lib/ui/assets/chunk-CylS5w8V.js +1 -0
- package/lib/ui/assets/chunk-D38fbIBN.js +1 -0
- package/lib/ui/assets/chunk-D97Zzqfu.js +1 -0
- package/lib/ui/assets/chunk-DAi9KRSo.js +1 -0
- package/lib/ui/assets/chunk-DHK4yRfg.js +1 -0
- package/lib/ui/assets/chunk-DJeabLx-.js +1 -0
- package/lib/ui/assets/chunk-DNRxmY5a.js +1 -0
- package/lib/ui/assets/chunk-DNSN1z5r.js +1 -0
- package/lib/ui/assets/chunk-DNasK_ZG.js +1 -0
- package/lib/ui/assets/chunk-DPvrY3IQ.js +1 -0
- package/lib/ui/assets/chunk-DXmwc3jG.js +1 -0
- package/lib/ui/assets/chunk-Dd0kTxKP.js +1 -0
- package/lib/ui/assets/chunk-De0Btta0.js +1 -0
- package/lib/ui/assets/chunk-Des-eS-w.js +1 -0
- package/lib/ui/assets/chunk-Df6bDoY_.js +1 -0
- package/lib/ui/assets/chunk-DijEV5ha.js +1 -0
- package/lib/ui/assets/chunk-DkvoVjww.js +1 -0
- package/lib/ui/assets/chunk-DlC-OlHO.js +1 -0
- package/lib/ui/assets/chunk-DnzrXTVv.js +1 -0
- package/lib/ui/assets/chunk-Dualf0xi.js +1 -0
- package/lib/ui/assets/chunk-EXT84bkm.js +1 -0
- package/lib/ui/assets/chunk-GwR3hkPK.js +1 -0
- package/lib/ui/assets/chunk-P80f7IUj.js +1 -0
- package/lib/ui/assets/chunk-VOosw3JB.js +1 -0
- package/lib/ui/assets/chunk-YQ4lDkt_.js +140 -0
- package/lib/ui/assets/chunk-Yzrsuije.js +1 -0
- package/lib/ui/assets/chunk-Z72CF80r.js +1 -0
- package/lib/ui/assets/chunk-g9-lgVsj.js +1 -0
- package/lib/ui/assets/chunk-vGWfd6FD.js +1 -0
- package/lib/ui/assets/chunk-wDzz0qaB.js +1 -0
- package/lib/ui/assets/chunk-ySF7HWmS.js +1 -0
- package/lib/ui/assets/icon.png +0 -0
- package/lib/ui/assets/index.html +14 -0
- package/lib/ui/assets/pdf.worker.min-CjEcRF4W.mjs +28 -0
- package/lib/ui/assets/style-Bq01xH_b.css +1 -0
- package/lib/ui/frames.d.ts +67 -0
- package/lib/ui/frames.js +146 -0
- package/lib/ui/index.d.ts +59 -0
- package/lib/ui/index.js +50 -0
- package/lib/ui/manifest.d.ts +172 -0
- package/lib/ui/manifest.js +158 -0
- package/lib/ui/plugin.d.ts +161 -0
- package/lib/ui/plugin.js +7 -0
- package/lib/ui/plugins/browser/client.js +290 -0
- package/lib/ui/plugins/browser/icon.png +0 -0
- package/lib/ui/plugins/composer/client.js +1843 -0
- package/lib/ui/plugins/composer/icon.png +0 -0
- package/lib/ui/plugins/files/client.js +646 -0
- package/lib/ui/plugins/files/icon.png +0 -0
- package/lib/ui/plugins/manifest.json +107 -0
- package/lib/ui/plugins/plugins/client.js +682 -0
- package/lib/ui/plugins/plugins/icon.png +0 -0
- package/lib/ui/plugins/preview/client.js +197 -0
- package/lib/ui/plugins/preview/icon.png +0 -0
- package/lib/ui/plugins/prompt/client.js +653 -0
- package/lib/ui/plugins/prompt/icon.png +0 -0
- package/lib/ui/plugins/sessions/client.js +1577 -0
- package/lib/ui/plugins/sessions/icon.png +0 -0
- package/lib/ui/plugins/settings/client.js +5470 -0
- package/lib/ui/plugins/settings/icon.png +0 -0
- package/lib/ui/plugins/skills/client.js +485 -0
- package/lib/ui/plugins/skills/icon.png +0 -0
- package/lib/ui/plugins/status/client.js +1420 -0
- package/lib/ui/plugins/status/icon.png +0 -0
- package/lib/ui/plugins/statusbar/client.js +504 -0
- package/lib/ui/plugins/statusbar/icon.png +0 -0
- package/lib/ui/plugins/tasks/client.js +52 -0
- package/lib/ui/plugins/tasks/icon.png +0 -0
- package/lib/ui/plugins/team/client.js +527 -0
- package/lib/ui/plugins/team/icon.png +0 -0
- package/lib/ui/plugins/terminal/client.js +232 -0
- package/lib/ui/plugins/terminal/icon.png +0 -0
- package/lib/ui/plugins/trace/client.js +1376 -0
- package/lib/ui/plugins/trace/icon.png +0 -0
- package/lib/ui/plugins/transcript/client.js +2661 -0
- package/lib/ui/plugins/transcript/icon.png +0 -0
- package/lib/ui/scoped-slots.d.ts +20 -0
- package/lib/ui/scoped-slots.js +21 -0
- package/lib/ui/sdk/@dsc/ui/index.d.ts +242 -0
- package/lib/ui/sdk/@dsc/ui/package.json +16 -0
- package/lib/ui/sdk/@dsc/ui-core/contract.d.ts +1973 -0
- package/lib/ui/sdk/@dsc/ui-core/core/diff-text.d.ts +74 -0
- package/lib/ui/sdk/@dsc/ui-core/core/dock-browser.d.ts +137 -0
- package/lib/ui/sdk/@dsc/ui-core/core/dock-ops.d.ts +59 -0
- package/lib/ui/sdk/@dsc/ui-core/core/model-caps.d.ts +83 -0
- package/lib/ui/sdk/@dsc/ui-core/core/native-bridge.d.ts +135 -0
- package/lib/ui/sdk/@dsc/ui-core/core/token-estimate.d.ts +55 -0
- package/lib/ui/sdk/@dsc/ui-core/package.json +16 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/arrival.d.ts +72 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/frames.d.ts +67 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/index.d.ts +59 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/manifest.d.ts +172 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/plugin.d.ts +161 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/scoped-slots.d.ts +20 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/services-react.d.ts +27 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/services.d.ts +63 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/slots-react.d.ts +28 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/slots.d.ts +481 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/store.d.ts +89 -0
- package/lib/ui/sdk/@dsc/ui-dockkit/dock-model.d.ts +238 -0
- package/lib/ui/sdk/@dsc/ui-dockkit/dock-state.d.ts +163 -0
- package/lib/ui/sdk/@dsc/ui-dockkit/dock.d.ts +24 -0
- package/lib/ui/sdk/@dsc/ui-dockkit/index.d.ts +15 -0
- package/lib/ui/sdk/@dsc/ui-dockkit/package.json +16 -0
- package/lib/ui/sdk/@dsc/ui-layout/app.d.ts +74 -0
- package/lib/ui/sdk/@dsc/ui-layout/appearance.d.ts +70 -0
- package/lib/ui/sdk/@dsc/ui-layout/host-channel.d.ts +112 -0
- package/lib/ui/sdk/@dsc/ui-layout/index.d.ts +34 -0
- package/lib/ui/sdk/@dsc/ui-layout/package.json +16 -0
- package/lib/ui/sdk/@dsc/ui-layout/page-state.d.ts +14 -0
- package/lib/ui/sdk/@dsc/ui-layout/review-pane.d.ts +21 -0
- package/lib/ui/sdk/@dsc/ui-layout/runtime-context.d.ts +44 -0
- package/lib/ui/sdk/@dsc/ui-layout/thread-view.d.ts +28 -0
- package/lib/ui/sdk/@dsc/ui-layout/update-button.d.ts +21 -0
- package/lib/ui/sdk/@dsc/ui-primitives/code-file-icon-artwork.d.ts +53 -0
- package/lib/ui/sdk/@dsc/ui-primitives/code-view.d.ts +15 -0
- package/lib/ui/sdk/@dsc/ui-primitives/compat.d.ts +27 -0
- package/lib/ui/sdk/@dsc/ui-primitives/completion-sound.d.ts +24 -0
- package/lib/ui/sdk/@dsc/ui-primitives/confirm.d.ts +33 -0
- package/lib/ui/sdk/@dsc/ui-primitives/css.d.ts +47 -0
- package/lib/ui/sdk/@dsc/ui-primitives/diff-rows.d.ts +20 -0
- package/lib/ui/sdk/@dsc/ui-primitives/file-icons.d.ts +38 -0
- package/lib/ui/sdk/@dsc/ui-primitives/file-type-classify.d.ts +66 -0
- package/lib/ui/sdk/@dsc/ui-primitives/file-type-icon.d.ts +57 -0
- package/lib/ui/sdk/@dsc/ui-primitives/highlight.d.ts +24 -0
- package/lib/ui/sdk/@dsc/ui-primitives/hover-delay.d.ts +17 -0
- package/lib/ui/sdk/@dsc/ui-primitives/icons.d.ts +109 -0
- package/lib/ui/sdk/@dsc/ui-primitives/index.d.ts +55 -0
- package/lib/ui/sdk/@dsc/ui-primitives/lang-table.d.ts +10 -0
- package/lib/ui/sdk/@dsc/ui-primitives/markdown.d.ts +20 -0
- package/lib/ui/sdk/@dsc/ui-primitives/native.d.ts +41 -0
- package/lib/ui/sdk/@dsc/ui-primitives/package.json +16 -0
- package/lib/ui/sdk/@dsc/ui-primitives/panels.d.ts +86 -0
- package/lib/ui/sdk/@dsc/ui-primitives/paths.d.ts +11 -0
- package/lib/ui/sdk/@dsc/ui-primitives/pdf-view.d.ts +13 -0
- package/lib/ui/sdk/@dsc/ui-primitives/plugin-text.d.ts +15 -0
- package/lib/ui/sdk/@dsc/ui-primitives/select.d.ts +35 -0
- package/lib/ui/sdk/@dsc/ui-primitives/table-view.d.ts +23 -0
- package/lib/ui/sdk/@dsc/ui-primitives/thread-resizer.d.ts +22 -0
- package/lib/ui/sdk/@dsc/ui-primitives/time.d.ts +33 -0
- package/lib/ui/sdk/@dsc/ui-primitives/toast.d.ts +16 -0
- package/lib/ui/sdk/@dsc/ui-primitives/tokens.d.ts +14 -0
- package/lib/ui/sdk/@dsc/ui-primitives/tool-args.d.ts +49 -0
- package/lib/ui/sdk/@dsc/ui-primitives/tool-summary.d.ts +64 -0
- package/lib/ui/sdk/@dsc/ui-renderer/boot.d.ts +121 -0
- package/lib/ui/sdk/@dsc/ui-renderer/hmr.d.ts +43 -0
- package/lib/ui/sdk/@dsc/ui-renderer/index.d.ts +20 -0
- package/lib/ui/sdk/@dsc/ui-renderer/package.json +16 -0
- package/lib/ui/sdk/@dsc/ui-slots/index.d.ts +19 -0
- package/lib/ui/sdk/@dsc/ui-slots/package.json +16 -0
- package/lib/ui/sdk/@dsc/ui-slots/slots-react.d.ts +48 -0
- package/lib/ui/sdk/@dsc/ui-slots/slots.d.ts +102 -0
- package/lib/ui/services-react.d.ts +27 -0
- package/lib/ui/services-react.js +32 -0
- package/lib/ui/services.d.ts +63 -0
- package/lib/ui/services.js +121 -0
- package/lib/ui/slots-ink.d.ts +26 -0
- package/lib/ui/slots-ink.js +78 -0
- package/lib/ui/slots-react.d.ts +28 -0
- package/lib/ui/slots-react.js +88 -0
- package/lib/ui/slots.d.ts +481 -0
- package/lib/ui/slots.js +550 -0
- package/lib/ui/store.d.ts +89 -0
- package/lib/ui/store.js +62 -0
- package/lib/ui/tui-plugin-api.d.ts +23 -0
- package/lib/ui/tui-plugin-api.js +23 -0
- package/lib/ui/tui-plugins.d.ts +47 -0
- package/lib/ui/tui-plugins.js +220 -0
- package/package.json +58 -6
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 文本差异:把「改之前的行」与「改之后的行」算成标准 unified diff 的几段 hunk。
|
|
3
|
+
*
|
|
4
|
+
* 为什么自己写而不是引第三方包:这个仓库零额外运行时依赖(package.json 的 dependencies
|
|
5
|
+
* 只有 cordis / ink / react / koffi / yaml 五样),为了一个几十行的差异算法再拉一个包,
|
|
6
|
+
* 换来的是供应链上一个新的信任面与一份要跟着升的版本。算法本身是教科书写法。
|
|
7
|
+
*
|
|
8
|
+
* 为什么先削公共前后缀再上 LCS:DP 表的空间是 `(m+1) × (n+1)` 个格子。改一个 3000 行文件
|
|
9
|
+
* 里的一行、或在一个大文件末尾追加一段,公共前后缀一削,真正进表的往往只有几行,
|
|
10
|
+
* 于是「大文件小改动」这个最常见的场景根本不碰内存上限。只有中部就大改时才需要兜底:
|
|
11
|
+
* 超过 {@link MAX_DIFF_CELLS} 就退回「摘要 + 第一处分歧的位置」,宁可少给信息也不把宿主拖死。
|
|
12
|
+
*
|
|
13
|
+
* 为什么超长行要按字符切:minified 的 js、单行几万字的 json 会让一条 diff 就撑爆上下文。
|
|
14
|
+
* 截断处写清「已截断、原本多少字符」,用户和模型都知道那不是完整内容。
|
|
15
|
+
*
|
|
16
|
+
* @module dsc/core/diff-text
|
|
17
|
+
*/
|
|
18
|
+
/** 单行超过这么多字符就切掉(切完在行尾写明原本多少字符)。 */
|
|
19
|
+
export declare const DIFF_LINE_CHAR_LIMIT = 400;
|
|
20
|
+
/**
|
|
21
|
+
* 差异矩阵的格子数上限。超过就走摘要兜底。
|
|
22
|
+
* 取 400 万格 ≈ 一张 2000×2000 的表:这个规模在毫秒级算完,内存也可控;
|
|
23
|
+
* 再往上(整篇重写一万行的文件)摘要其实比逐行 diff 更可读。
|
|
24
|
+
*/
|
|
25
|
+
export declare const MAX_DIFF_CELLS = 4000000;
|
|
26
|
+
/** 一段 diff 行(` ` 上下文 / `-` 删 / `+` 增)及其新旧行号。 */
|
|
27
|
+
export interface DiffLine {
|
|
28
|
+
kind: 'context' | 'remove' | 'add';
|
|
29
|
+
text: string;
|
|
30
|
+
/** 这一行在旧文件里的行号;`add` 行为 null。 */
|
|
31
|
+
oldLine: number | null;
|
|
32
|
+
/** 这一行在新文件里的行号;`remove` 行为 null。 */
|
|
33
|
+
newLine: number | null;
|
|
34
|
+
}
|
|
35
|
+
/** 一段 hunk:`@@ -oldStart,oldCount +newStart,newCount @@` 加上它包含的行。 */
|
|
36
|
+
export interface DiffHunk {
|
|
37
|
+
oldStart: number;
|
|
38
|
+
oldCount: number;
|
|
39
|
+
newStart: number;
|
|
40
|
+
newCount: number;
|
|
41
|
+
lines: DiffLine[];
|
|
42
|
+
}
|
|
43
|
+
/** 一次 diff 的结果。`ok` 为 false 时给的是摘要(算不动或没有变化)。 */
|
|
44
|
+
export interface DiffResult {
|
|
45
|
+
/** true = 逐行 diff 算出来了(哪怕只有一段)。 */
|
|
46
|
+
ok: boolean;
|
|
47
|
+
hunks: DiffHunk[];
|
|
48
|
+
added: number;
|
|
49
|
+
removed: number;
|
|
50
|
+
/** ok=false / 内容相同时的中文说明(一行内说清原因)。 */
|
|
51
|
+
note?: string;
|
|
52
|
+
/** true = 新旧文本完全相同。 */
|
|
53
|
+
identical: boolean;
|
|
54
|
+
/** true = 因为超出 {@link MAX_DIFF_CELLS} 走了摘要兜底。 */
|
|
55
|
+
oversize: boolean;
|
|
56
|
+
}
|
|
57
|
+
/** 按 `\n` 切行;CRLF 的 `\r` 与 BOM 一并抹掉,免得每行都被判成「改过」。 */
|
|
58
|
+
export declare function splitLines(text: string): string[];
|
|
59
|
+
/**
|
|
60
|
+
* 算一次 diff。
|
|
61
|
+
*
|
|
62
|
+
* @param before - 改动前的完整文本。
|
|
63
|
+
* @param after - 改动后的完整文本。
|
|
64
|
+
* @param contextLines - 每个 hunk 前后各留几行上下文(0 = 只给改动的行)。
|
|
65
|
+
* @returns 逐行 diff;算不动或没有变化时给摘要。
|
|
66
|
+
*/
|
|
67
|
+
export declare function diffLines(before: string, after: string, contextLines: number): DiffResult;
|
|
68
|
+
/** 把一段 hunk 铺成文本行(超长行在这里切,见 {@link clipLine})。 */
|
|
69
|
+
export declare function renderHunk(hunk: DiffHunk): string[];
|
|
70
|
+
/**
|
|
71
|
+
* 整份 diff 的文本(把所有 hunk 拼起来)。
|
|
72
|
+
* 只用来落日志或测试;给用户看的那份一律走 `plugins/file-review.ts` 的行数上限渲染。
|
|
73
|
+
*/
|
|
74
|
+
export declare function renderDiff(result: DiffResult): string;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dock 浏览器控制的**契约纯模块**:宿主进程(agent 所在)与桌面壳主进程共用这一份。
|
|
3
|
+
*
|
|
4
|
+
* 为什么单独落一个模块:这两侧在两个进程、两套编译产物里(`src/**` → `lib/`,
|
|
5
|
+
* 桌面端 → `out/`),线上跑的是消息而不是函数调用。方法白名单、动作枚举、消息形状、
|
|
6
|
+
* 超时预算放在一处,两侧 import 同一个常量——加一条命令时不可能只改一边。
|
|
7
|
+
*
|
|
8
|
+
* **这一份不许 import electron,也不许 import 任何有副作用的东西**:宿主侧那个
|
|
9
|
+
* `node lib/headless.js` 的进程也要引用它,探针还要用类型擦除直读它。
|
|
10
|
+
*
|
|
11
|
+
* 信任模型(为什么白名单是硬性的):dock 视图跑在 `persist:dsc-browser` 这个**持久**
|
|
12
|
+
* 分区里,带着用户自己的登录态。裸 CDP 里能读 cookie、能 `Runtime.evaluate`、
|
|
13
|
+
* 能导航到 `file://`——所以桌面侧对每一条命令都做白名单校验,导航参数还要重过一遍
|
|
14
|
+
* 与壳相同的 http/https 闸门(见 {@link dockNavigateTarget})。
|
|
15
|
+
*
|
|
16
|
+
* @module dsc/core/dock-browser
|
|
17
|
+
*/
|
|
18
|
+
/** 宿主协议版本(破坏性变更时递增)。两侧都从这里取,不再各写一份。 */
|
|
19
|
+
export declare const HOST_PROTOCOL_VERSION = 3;
|
|
20
|
+
/**
|
|
21
|
+
* 允许转发到 dock 视图的 CDP 方法。
|
|
22
|
+
*
|
|
23
|
+
* 收口原则:**只放 `src/core/cdp/` 那套动作与快照真正用得到的域**(Page / DOM /
|
|
24
|
+
* Accessibility / Runtime / Network / Input / Emulation)。故意不放的几类:
|
|
25
|
+
* - `Target.*` / `Browser.*`:那是浏览器级命令,会打到别的 target 上(dock 视图的
|
|
26
|
+
* debugger 本来就只作用于这一页,放开它们等于越出这台视图);
|
|
27
|
+
* - `Storage.*` / `Network.getAllCookies` 之类:直接读用户登录态;
|
|
28
|
+
* - `DOM.setFileInputFiles`:ZCode 的内嵌浏览器也明确不支持上传,这里不放。
|
|
29
|
+
*/
|
|
30
|
+
export declare const DOCK_CDP_COMMANDS: readonly string[];
|
|
31
|
+
/** 命令白名单判定(桌面侧每条命令都过它;不在名单里直接拒,不做「尽量执行」)。 */
|
|
32
|
+
export declare function isAllowedDockCommand(method: string): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* 允许推给宿主的 CDP 事件。
|
|
35
|
+
*
|
|
36
|
+
* 与命令白名单同一条收口逻辑:只放那套动作订阅的事件(控制台 / 异常 / 对话框 /
|
|
37
|
+
* 跳转 / 网络),`Target.*` 与渲染相关的高频事件一概不推。
|
|
38
|
+
* 事件是**推**的,跨进程成本按条算——宿主只在真的要看了才 `*.enable`,桌面侧也只
|
|
39
|
+
* 对已经挂上 debugger 的视图转发。
|
|
40
|
+
*/
|
|
41
|
+
export declare const DOCK_CDP_EVENTS: readonly string[];
|
|
42
|
+
/** 事件白名单判定。 */
|
|
43
|
+
export declare function shouldForwardDockEvent(method: string): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* 从一条命令里抽出「这条命令其实在导航到某个地址」那个地址,没有就返回 null。
|
|
46
|
+
*
|
|
47
|
+
* 为什么必须有这一步:壳那条 `browserNav` 走的是 `navigateDockBrowser`,只有 http/https
|
|
48
|
+
* 能进。而 `Page.navigate` 是**绕开那道闸门**的直通车——不在这儿补一刀,agent 就能
|
|
49
|
+
* 把用户那台带登录态的浏览器导到 `file://` 上去。桌面侧收到这两个方法时,
|
|
50
|
+
* 一律用这个函数的返回值再过一次 {@link isHttpUrl} 同款判定。
|
|
51
|
+
*/
|
|
52
|
+
export declare function dockNavigateTarget(method: string, params: Record<string, unknown> | undefined): string | null;
|
|
53
|
+
/** 一台 dock 视图现在的样子(`views` 动作与 `browser-views` 的回执)。 */
|
|
54
|
+
export interface DockViewInfo {
|
|
55
|
+
/** 视图 id(壳那边就是页签 id;agent 自己开的那几张是 `agent-N`)。 */
|
|
56
|
+
id: string;
|
|
57
|
+
url: string;
|
|
58
|
+
title: string;
|
|
59
|
+
loading: boolean;
|
|
60
|
+
/** 现在挂在窗口上(= 侧栏展开且这张页签是激活的那张)。藏起来的视图截不了图。 */
|
|
61
|
+
visible: boolean;
|
|
62
|
+
}
|
|
63
|
+
/** 一条命令的默认超时:跨进程 + 可能等页面,给得比 CDP 那层(20s)宽一点。 */
|
|
64
|
+
export declare const DOCK_CALL_TIMEOUT_MS = 25000;
|
|
65
|
+
/** 开一张页签(要等壳把页签建出来、把原生视图挂上)的超时。 */
|
|
66
|
+
export declare const DOCK_OPEN_TIMEOUT_MS = 8000;
|
|
67
|
+
/** `views`/`snapshot`/`screenshot`/`console`/`network`/`wait_for`:只看不动。 */
|
|
68
|
+
export declare const DOCK_LOOK_ACTIONS: readonly string[];
|
|
69
|
+
/** `open`/`navigate`/`click`/`hover`/`type`/`press`/`scroll`/`evaluate`/`close`:会改页面。 */
|
|
70
|
+
export declare const DOCK_ACTIONS: readonly string[];
|
|
71
|
+
/**
|
|
72
|
+
* agent 自己开的那几张页签的 id 前缀。
|
|
73
|
+
*
|
|
74
|
+
* 为什么要有前缀:`views` 会把用户自己开的页签一起列出来(那些是同一台持久分区,
|
|
75
|
+
* 地址栏里可能是他登录着的后台)。前缀让「这是 agent 开的」这件事在 id 上就看得出,
|
|
76
|
+
* 审批卡与工具输出里都能直接标出来。
|
|
77
|
+
*/
|
|
78
|
+
export declare const DOCK_AGENT_VIEW_PREFIX = "agent-";
|
|
79
|
+
/** 这张视图是不是 agent 自己开的。 */
|
|
80
|
+
export declare function isAgentView(viewId: string): boolean;
|
|
81
|
+
/** runtime → host:宿主请桌面壳办事的四条请求(都带 id,等同一条应答)。 */
|
|
82
|
+
export type DockBrowserRequest =
|
|
83
|
+
/** 在某台视图上执行一条 CDP 命令(method 过 {@link isAllowedDockCommand})。 */
|
|
84
|
+
{
|
|
85
|
+
type: 'browser-call';
|
|
86
|
+
id: number;
|
|
87
|
+
viewId: string;
|
|
88
|
+
method: string;
|
|
89
|
+
params?: Record<string, unknown>;
|
|
90
|
+
}
|
|
91
|
+
/** 开一张浏览器页签(并聚焦它)——`viewId` 不给时由桌面侧发号 `agent-N`。 */
|
|
92
|
+
| {
|
|
93
|
+
type: 'browser-open';
|
|
94
|
+
id: number;
|
|
95
|
+
url: string;
|
|
96
|
+
viewId?: string;
|
|
97
|
+
}
|
|
98
|
+
/** 关掉一台(连带壳里那张页签一起关)。 */
|
|
99
|
+
| {
|
|
100
|
+
type: 'browser-close';
|
|
101
|
+
id: number;
|
|
102
|
+
viewId: string;
|
|
103
|
+
}
|
|
104
|
+
/** 列出现在活着的视图。 */
|
|
105
|
+
| {
|
|
106
|
+
type: 'browser-views';
|
|
107
|
+
id: number;
|
|
108
|
+
};
|
|
109
|
+
/** host → runtime:请求的应答(ok 为假时 error 是一句能给用户看的人话)。 */
|
|
110
|
+
export type DockBrowserReply = {
|
|
111
|
+
type: 'browser-result';
|
|
112
|
+
id: number;
|
|
113
|
+
ok: true;
|
|
114
|
+
value: unknown;
|
|
115
|
+
} | {
|
|
116
|
+
type: 'browser-result';
|
|
117
|
+
id: number;
|
|
118
|
+
ok: false;
|
|
119
|
+
error: string;
|
|
120
|
+
};
|
|
121
|
+
/** host → runtime:CDP 事件推送(只推 {@link DOCK_CDP_EVENTS} 里的)。 */
|
|
122
|
+
export interface DockBrowserEventPush {
|
|
123
|
+
type: 'browser-event';
|
|
124
|
+
viewId: string;
|
|
125
|
+
method: string;
|
|
126
|
+
params: Record<string, unknown>;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* 请壳开一张浏览器页签并聚焦(`id` 由桌面侧指定,壳必须照用,否则宿主对不上号)。
|
|
130
|
+
*
|
|
131
|
+
* 为什么要绕渲染层:原生视图的矩形与页签的激活态都在壳里(`dockBrowser` 的 rect 由
|
|
132
|
+
* 组件量出来),桌面主进程不知道侧栏现在在哪儿。ZCode 同样是「建页签顺手把右侧栏
|
|
133
|
+
* 打开并激活」——我们这条走同一形状。
|
|
134
|
+
*/
|
|
135
|
+
export declare const DOCK_TAB_OPEN_EVENT = "browser-tab-open-request";
|
|
136
|
+
/** 请壳关掉某张浏览器页签(`browser-close` 走它,免得留下一个点不开的空页签)。 */
|
|
137
|
+
export declare const DOCK_TAB_CLOSE_EVENT = "browser-tab-close-request";
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dock 通道的分档规格:读类 / 写类 / 终端。
|
|
3
|
+
*
|
|
4
|
+
* ## 为什么要分档
|
|
5
|
+
*
|
|
6
|
+
* `dock` 原来是**整条**被界面通道排除的,理由是它里面混着 `term-spawn`(起 pwsh/cmd/bash/node)——
|
|
7
|
+
* 那与「在用户机器上执行任意命令」同级,不该交给页面。但这条通道里另外十一个 op 是界面真正要用的:
|
|
8
|
+
* 工作区文件树、文件内容、git 状态与分支清单、差异(读),以及暂存 / 取消暂存 / 提交 /
|
|
9
|
+
* 切分支 / 建分支(写)。
|
|
10
|
+
* 一锅端掉等于「文件面板」永远搬不进壳;整条放行又等于把 spawn 交出去。所以按**动作落在谁手里**拆三档:
|
|
11
|
+
*
|
|
12
|
+
* | 档 | op | 走哪条路 | 为什么 |
|
|
13
|
+
* | --- | --- | --- | --- |
|
|
14
|
+
* | 读 | `fs-list` `fs-read` `git-status` `git-branches` `git-log` `git-diff` | 界面 HTTP 通道**直接放行** | 只读,且宿主侧已经限定在 cwd 内 |
|
|
15
|
+
* | 写 | `git-stage` `git-unstage` `git-commit` `git-checkout` `git-branch-create` | 界面 HTTP 通道,但**过审批** | 会改仓库状态,交给权限模式那套裁决(与工具调用同一口径) |
|
|
16
|
+
* | 终端 | `term-spawn` `term-input` `term-kill` | **只走桌面窗口的原生桥**,不进 HTTP 面 | 起进程 = 任意命令执行;浏览器里拿到 Cookie 的页面不该有这个能力 |
|
|
17
|
+
*
|
|
18
|
+
* 「只走原生桥」是**真的**只走那条路:`DOCK_UI_OPS` 里没有 term op,所以 HTTP 的
|
|
19
|
+
* `/api/invoke { method: 'dock' }` 拿着 `term-spawn` 会被实参校验当场拒(枚举不在表里)。
|
|
20
|
+
* 而原生桥只对主窗口的文档开放(`event.sender === mainWindow.webContents`),
|
|
21
|
+
* 于是"桌面窗口有效"这件事由**传输**保证,而不是靠 payload 里一个可伪造的标记位。
|
|
22
|
+
*
|
|
23
|
+
* 这一份零依赖、浏览器安全,所以三处共用:宿主插件(分档与审批)、界面通道(放行面)、
|
|
24
|
+
* 桌面主进程与壳(终端那条路)。
|
|
25
|
+
*
|
|
26
|
+
* @module dsc/core/dock-ops
|
|
27
|
+
*/
|
|
28
|
+
/** 读类:只读取工作区现状,宿主侧限定在 cwd 内。 */
|
|
29
|
+
export declare const DOCK_READ_OPS: readonly ["fs-list", "fs-read", "git-status", "git-branches", "git-log", "git-diff"];
|
|
30
|
+
/** 写类:会改 git 状态,走审批。 */
|
|
31
|
+
export declare const DOCK_WRITE_OPS: readonly ["git-stage", "git-unstage", "git-commit", "git-checkout", "git-branch-create"];
|
|
32
|
+
/** 终端:起进程,只走桌面窗口的原生桥。 */
|
|
33
|
+
export declare const DOCK_TERM_OPS: readonly ["term-spawn", "term-input", "term-kill"];
|
|
34
|
+
/** 全部 op(宿主插件按它认人)。 */
|
|
35
|
+
export declare const DOCK_OPS: readonly ["fs-list", "fs-read", "git-status", "git-branches", "git-log", "git-diff", "git-stage", "git-unstage", "git-commit", "git-checkout", "git-branch-create", "term-spawn", "term-input", "term-kill"];
|
|
36
|
+
/** 界面 HTTP 通道放行的 op:读 + 写,**没有**终端。 */
|
|
37
|
+
export declare const DOCK_UI_OPS: readonly ["fs-list", "fs-read", "git-status", "git-branches", "git-log", "git-diff", "git-stage", "git-unstage", "git-commit", "git-checkout", "git-branch-create"];
|
|
38
|
+
export type DockReadOp = (typeof DOCK_READ_OPS)[number];
|
|
39
|
+
export type DockWriteOp = (typeof DOCK_WRITE_OPS)[number];
|
|
40
|
+
export type DockTermOp = (typeof DOCK_TERM_OPS)[number];
|
|
41
|
+
export type DockOp = (typeof DOCK_OPS)[number];
|
|
42
|
+
/** 查表用的集合。 */
|
|
43
|
+
export declare const DOCK_TERM_OP_SET: ReadonlySet<string>;
|
|
44
|
+
export declare const DOCK_WRITE_OP_SET: ReadonlySet<string>;
|
|
45
|
+
/** 是不是终端 op(决定它能不能进界面 HTTP 面)。 */
|
|
46
|
+
export declare function isDockTermOp(op: string): op is DockTermOp;
|
|
47
|
+
/** 是不是写类 op(决定要不要过审批)。 */
|
|
48
|
+
export declare function isDockWriteOp(op: string): op is DockWriteOp;
|
|
49
|
+
/**
|
|
50
|
+
* 写类 op 的审批卡文案。
|
|
51
|
+
*
|
|
52
|
+
* `toolName` 用 `git:` 前缀,一眼能跟工具调用区分开(审批卡上会显示这一栏);
|
|
53
|
+
* `summary` 只放**这次要动什么**(文件清单 / 提交信息首行),不放整段 payload——
|
|
54
|
+
* 卡片是单行的,塞不下。
|
|
55
|
+
*/
|
|
56
|
+
export declare const DOCK_WRITE_LABEL: Readonly<Record<DockWriteOp, {
|
|
57
|
+
toolName: string;
|
|
58
|
+
summary: (payload: Record<string, unknown>) => string;
|
|
59
|
+
}>>;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 模型能力(思考档位、档位走哪个请求字段、输入模态)的缺省值、YAML 宽容解析
|
|
3
|
+
* 与线上字段映射。config.yaml 里这些字段全都可以不写:不写就是旧行为——
|
|
4
|
+
* 档位走 DeepSeek 的 `thinking` 开关、四档都在、只吃文本。
|
|
5
|
+
*
|
|
6
|
+
* 读错的东西不抛错,逐项退回缺省值;设置界面回读时用户看得见自己填错了什么。
|
|
7
|
+
*
|
|
8
|
+
* @module dsc/core/model-caps
|
|
9
|
+
*/
|
|
10
|
+
import type { EffortLevel, EffortMap, Modality, ThinkingLevel, ThinkingParam } from '../contract.js';
|
|
11
|
+
/** 全部合法档位(按界面展示顺序,也是写回 YAML 的顺序)。 */
|
|
12
|
+
export declare const THINKING_LEVELS: readonly ThinkingLevel[];
|
|
13
|
+
/** 档位字段的全部合法取值。 */
|
|
14
|
+
export declare const THINKING_PARAMS: readonly ThinkingParam[];
|
|
15
|
+
/** 全部输入模态。 */
|
|
16
|
+
export declare const MODALITIES: readonly Modality[];
|
|
17
|
+
/** 不写 `thinkingParam` 时按 DeepSeek 风格发 `thinking:{type}`。 */
|
|
18
|
+
export declare const DEFAULT_THINKING_PARAM: ThinkingParam;
|
|
19
|
+
/** 不写档位清单时四档都在(与旧版行为一致:界面有四个档位,线上只有开关)。 */
|
|
20
|
+
export declare const DEFAULT_THINKING_LEVELS: readonly ThinkingLevel[];
|
|
21
|
+
/** `reasoning-effort` 各档要发的线上值;端点用的名字不一样时,在 YAML 的 effortMap 里覆盖。 */
|
|
22
|
+
export declare const DEFAULT_EFFORT_MAP: Required<EffortMap>;
|
|
23
|
+
/** 档位中文名(界面与提示共用)。 */
|
|
24
|
+
export declare const THINKING_LEVEL_LABELS: Record<ThinkingLevel, string>;
|
|
25
|
+
/** 档位的英文线上值写法(表单里作为输入框提示)。 */
|
|
26
|
+
export declare const EFFORT_WIRE_HINT: Record<ThinkingLevel, string>;
|
|
27
|
+
/** 模态中文名。 */
|
|
28
|
+
export declare const MODALITY_LABELS: Record<Modality, string>;
|
|
29
|
+
/** 档位字段中文名与一句说明。 */
|
|
30
|
+
export declare const THINKING_PARAM_LABELS: Record<ThinkingParam, {
|
|
31
|
+
label: string;
|
|
32
|
+
help: string;
|
|
33
|
+
}>;
|
|
34
|
+
/** config.yaml 里一个模型条目的能力字段(全部可缺省,值还没校验)。 */
|
|
35
|
+
export interface RawModelCaps {
|
|
36
|
+
/** 档位清单,如 `[off, low, high]`;也认 `thinking:`。 */
|
|
37
|
+
thinkingLevels?: unknown;
|
|
38
|
+
thinking?: unknown;
|
|
39
|
+
/** 档位走哪个字段。 */
|
|
40
|
+
thinkingParam?: unknown;
|
|
41
|
+
/** 各档的线上值;也认 `efforts:`。 */
|
|
42
|
+
effortMap?: unknown;
|
|
43
|
+
efforts?: unknown;
|
|
44
|
+
/** 输入模态,如 `[text, image]`;也认旧字段 `vision: true`。 */
|
|
45
|
+
modalities?: unknown;
|
|
46
|
+
vision?: unknown;
|
|
47
|
+
}
|
|
48
|
+
/** 模型能力的四项声明(写回 YAML 与界面回填都靠它)。 */
|
|
49
|
+
export interface ModelCaps {
|
|
50
|
+
thinkingLevels: ThinkingLevel[];
|
|
51
|
+
thinkingParam: ThinkingParam;
|
|
52
|
+
effortMap: EffortMap;
|
|
53
|
+
modalities: Modality[];
|
|
54
|
+
}
|
|
55
|
+
/** 没有声明时的能力:等价于旧版行为。 */
|
|
56
|
+
export declare const DEFAULT_CAPS: ModelCaps;
|
|
57
|
+
/** 档位字段:认 thinking / reasoning-effort(也认 reasoning_effort、effort 别名)。 */
|
|
58
|
+
export declare function normalizeThinkingParam(raw: unknown): ThinkingParam;
|
|
59
|
+
/** 档位清单:按固定顺序去重;`false` 或空清单 = 这个模型没有思考开关。 */
|
|
60
|
+
export declare function normalizeThinkingLevels(raw: unknown): ThinkingLevel[];
|
|
61
|
+
/** 各档线上值:`null` / 空串 = 这一档不发字段;没出现的档用缺省值。 */
|
|
62
|
+
export declare function normalizeEffortMap(raw: unknown): EffortMap;
|
|
63
|
+
/** 模态:认常见别名(vision/photo/图片…),文本永远保留(协议里没有文本就发不出消息)。 */
|
|
64
|
+
export declare function normalizeModalities(raw: unknown, vision?: unknown): Modality[];
|
|
65
|
+
/** 把 config.yaml 里一个模型条目的能力字段读成结构化能力。 */
|
|
66
|
+
export declare function readModelCaps(raw: RawModelCaps): ModelCaps;
|
|
67
|
+
/** 选中的档位在这个模型上是否存在(默认档永远可选)。 */
|
|
68
|
+
export declare function hasEffortLevel(caps: ModelCaps, effort: EffortLevel): boolean;
|
|
69
|
+
/** 越界的档位退回「默认」(切换模型后原来选的档位可能不存在了)。 */
|
|
70
|
+
export declare function clampEffort(caps: ModelCaps, effort: EffortLevel): EffortLevel;
|
|
71
|
+
/** 一次请求要注入的思考字段(undefined = 不发)。 */
|
|
72
|
+
export interface EffortWire {
|
|
73
|
+
/** DeepSeek / GLM 的 `thinking:{type}`。 */
|
|
74
|
+
thinking?: 'enabled' | 'disabled';
|
|
75
|
+
/** OpenAI 与多数网关的 `reasoning_effort`。 */
|
|
76
|
+
reasoningEffort?: string;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* 档位 → 请求字段。没有思考开关的模型、以及选了「默认」时,都不发字段。
|
|
80
|
+
* @param caps - 这个模型的能力声明。
|
|
81
|
+
* @param effort - 用户选的档位。
|
|
82
|
+
*/
|
|
83
|
+
export declare function effortToWire(caps: ModelCaps, effort: EffortLevel): EffortWire;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 原生桥的规格:桌面外壳能替界面做的事,逐条白名单 + 实参校验。
|
|
3
|
+
*
|
|
4
|
+
* ## 为什么需要这一层
|
|
5
|
+
*
|
|
6
|
+
* 旧渲染层的 26 个 IPC 能力里,有一类**宿主做不了**——它们要 Electron 主进程:
|
|
7
|
+
* 原生窗口控件区的颜色、原生弹层的深浅、系统文件选择框、用系统程序打开路径/链接、
|
|
8
|
+
* 托盘通知、退出与重启宿主。插件壳跑在宿主伺服的 web 文档里,它要摸这些能力,
|
|
9
|
+
* 只能走一条主进程给的窄通道——就是这份规格描述的那条。
|
|
10
|
+
*
|
|
11
|
+
* ## 为什么规格单独放这里(而不再写一份在桌面那侧)
|
|
12
|
+
*
|
|
13
|
+
* 这一份**零依赖**(不 import 任何 node 内置模块、不 import electron),所以两侧共用:
|
|
14
|
+
* 桌面主进程用它校验并分派,界面壳用它拿操作名与实参类型。宿主与壳读同一份源码,
|
|
15
|
+
* 漂移在编译期就暴露——与 `src/ui/index.ts`(`@dsc/ui-core`)和
|
|
16
|
+
* `ui-shell/src/platform-modules.json` 是同一个套路。
|
|
17
|
+
*
|
|
18
|
+
* ## 边界(比"能少给就少给"更具体的三条)
|
|
19
|
+
*
|
|
20
|
+
* 1. **不出现"执行任意命令 / 读写任意文件"的操作**。这里全是"既定动作 + 实参枚举":
|
|
21
|
+
* 打开一个目录、报一次窗口控件色、弹一条通知。没有 op 能把一段字符串变成一次执行。
|
|
22
|
+
* 2. **每条操作的实参都过一遍形状校验**(长度上限、枚举取值、#rrggbb、通知的字段白名单),
|
|
23
|
+
* 规格写成 `Record<NativeOp, …>`,所以**加一个操作就必须写规格**,漏了编不过。
|
|
24
|
+
* 3. **主进程那一侧按 `NativeOp` 建分派表**(`Record<NativeOp, 处理函数>`),
|
|
25
|
+
* 漏实现一个操作同样编不过——"白名单"与"真有实现"被绑在一起。
|
|
26
|
+
*
|
|
27
|
+
* 装东西的四个操作(`installSkill` / `installPlugin` / `installMarketSkill` /
|
|
28
|
+
* `setMarketSources`)**走桥,不在界面通道**:它们是供应链写入口,界面通道
|
|
29
|
+
* (浏览器与远程页都够得着)持续排除;桥只对主窗口那份文档开放,与旧渲染层的
|
|
30
|
+
* 直接 IPC 是同一扇门。前两个弹系统文件选择器(人选了文件才算数),后两个转给
|
|
31
|
+
* 宿主(按市场源下载安装到 `~/.dsc/skills`、把源清单写回 settings.json)。
|
|
32
|
+
* 同一理由的还有 `setUiTrust`(落第三方界面插件的信任记录——放它进启动图这声
|
|
33
|
+
* 「我信任」必须是人在桌面窗口里答的),模型端点三件套
|
|
34
|
+
* (`saveProvider` / `removeProvider` / `setProviderKey`——写 config.yaml 与凭据库,
|
|
35
|
+
* 是设置 → 模型页可编辑形态的写入口;旧渲染层这三件事走的就是直接 IPC),
|
|
36
|
+
* 以及 `setPolicy`(审批策略是安全闸门本身,界面通道同样持续排除;旧渲染层的输入框
|
|
37
|
+
* 里本来就有这根能切的旋钮,桥替它把写口留住)。
|
|
38
|
+
*
|
|
39
|
+
* 内嵌浏览器那一套(`dockBrowser` / `browserNav` / `browserClose` + `browser-state`、
|
|
40
|
+
* `browser-open-requested` 两个事件)2026-10 搬进壳:它们操作的是原生 `WebContentsView`
|
|
41
|
+
* 覆盖层(旧渲染层直连 IPC 的那个),桥只转发「显示/隐藏 + 摆到哪 + 导航到哪 +
|
|
42
|
+
* 关掉哪一台」,页面管不到那个视图的内容。终端(`terminal`)同款——能力留在主进程,
|
|
43
|
+
* 界面只说意图。
|
|
44
|
+
*
|
|
45
|
+
* 2026-10 起浏览器页签可以多开:**一台视图一个 id**(壳拿页签自己的 id 当这个 id),
|
|
46
|
+
* 上面三个操作都带它。id 缺省回落 `'main'`,旧渲染层那条直连 IPC 因此一字不用改。
|
|
47
|
+
* 视图的创建/销毁、会话策略、导航闸门全在主进程(`desktop/electron/main/dock.ts`),
|
|
48
|
+
* 页面报上来的只有「哪一台、摆哪里」。
|
|
49
|
+
*
|
|
50
|
+
* 除了 `call` 之外,桥还有**一个订阅口**:`on(event, listener)`,事件名由 {@link NATIVE_EVENTS}
|
|
51
|
+
* 白名单(现在只有终端输出流)。事件不做实参校验——它是主进程往外推的,不是页面往里送的。
|
|
52
|
+
*
|
|
53
|
+
* @module dsc/core/native-bridge
|
|
54
|
+
*/
|
|
55
|
+
/**
|
|
56
|
+
* 桥的协议版本:**加操作不涨**,改某个操作的实参或语义才涨。
|
|
57
|
+
* 桌面主进程与壳握手时对一下,不一致就在诊断区说明白(不静默降级)。
|
|
58
|
+
*
|
|
59
|
+
* 2 → 3(2026-10):浏览器页签改可多开,`dockBrowser` / `browserNav` 各多一个
|
|
60
|
+
* 视图 id 实参,`browser-state` 的载荷从一个 `url` 扩成带 id / 标题 / 前后退 /
|
|
61
|
+
* 加载中的整份状态。**这一次必须两头同批重建**:旧外壳收到多出来的实参会按
|
|
62
|
+
* 「最多收 N 个实参」拒掉(不会静默忽略),壳与外壳各自出一份产物时对不上,
|
|
63
|
+
* 诊断区那条版本告警就是给这个场景写的。
|
|
64
|
+
*/
|
|
65
|
+
export declare const NATIVE_BRIDGE_VERSION = 3;
|
|
66
|
+
/** 桥放行的操作,一字不差就是分派表的键。 */
|
|
67
|
+
export declare const NATIVE_OPS: readonly ["setWindowChrome", "setThemeSource", "chooseDirectory", "pickDirectory", "rememberCwd", "switchCwd", "recentCwds", "removeRecentCwd", "openPath", "openExternal", "openWorkspace", "installSkill", "installPlugin", "installMarketSkill", "setMarketSources", "setUiTrust", "saveProvider", "removeProvider", "setProviderKey", "setConfigFile", "pickConfigFile", "setPolicy", "setReviewer", "usePermissionPreset", "setDefaultPermissionPreset", "sessionUsage", "notify", "restartHost", "quit", "terminal", "dockBrowser", "browserNav", "browserClose", "checkUpdate", "installUpdate"];
|
|
68
|
+
/** 桥能推给页面的事件(订阅入口按它白名单,别的名字直接拒)。 */
|
|
69
|
+
export declare const NATIVE_EVENTS: readonly ["dock-data", "browser-state", "browser-open-requested", "update-status", "update-progress", "browser-tab-open-request", "browser-tab-close-request"];
|
|
70
|
+
/** 桥认得的一个事件名。 */
|
|
71
|
+
export type NativeEvent = (typeof NATIVE_EVENTS)[number];
|
|
72
|
+
/** 事件名查表。 */
|
|
73
|
+
export declare const NATIVE_EVENT_SET: ReadonlySet<string>;
|
|
74
|
+
/** 桥认得的一个操作名。 */
|
|
75
|
+
export type NativeOp = (typeof NATIVE_OPS)[number];
|
|
76
|
+
/** 查表用的集合。 */
|
|
77
|
+
export declare const NATIVE_OP_SET: ReadonlySet<string>;
|
|
78
|
+
/** 一个实参的形状。取值集合刻意很小:这一层要的正是"最小且能读懂"。 */
|
|
79
|
+
type ArgShape = {
|
|
80
|
+
kind: 'string';
|
|
81
|
+
max: number;
|
|
82
|
+
}
|
|
83
|
+
/** 字符串或 `null`:`null` 是**有意义的取值**(如 setProviderKey 的「清除」,别当省略)。 */
|
|
84
|
+
| {
|
|
85
|
+
kind: 'stringOrNull';
|
|
86
|
+
max: number;
|
|
87
|
+
} | {
|
|
88
|
+
kind: 'bool';
|
|
89
|
+
} | {
|
|
90
|
+
kind: 'hex';
|
|
91
|
+
} | {
|
|
92
|
+
kind: 'enum';
|
|
93
|
+
values: readonly string[];
|
|
94
|
+
} | {
|
|
95
|
+
kind: 'notify';
|
|
96
|
+
} | {
|
|
97
|
+
kind: 'marketSources';
|
|
98
|
+
} | {
|
|
99
|
+
kind: 'rect';
|
|
100
|
+
} | {
|
|
101
|
+
kind: 'json';
|
|
102
|
+
maxBytes: number;
|
|
103
|
+
};
|
|
104
|
+
/** 一个实参的规格。 */
|
|
105
|
+
interface ArgSpec {
|
|
106
|
+
shape: ArgShape;
|
|
107
|
+
/** 可不传:省略表示"没这个实参"(尾部省略规则与界面通道一致)。 */
|
|
108
|
+
optional?: boolean;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* 每个操作的实参规格:数组长度就是参数个数上限,下标就是参数位置。
|
|
112
|
+
*
|
|
113
|
+
* 类型写成 `Readonly<Record<NativeOp, …>>`:少写一个、多写一个不存在的操作都编不过。
|
|
114
|
+
*/
|
|
115
|
+
export declare const NATIVE_ARG_SPECS: Readonly<Record<NativeOp, readonly ArgSpec[]>>;
|
|
116
|
+
/** 一次桥调用的校验结果:过了就带收窄后的操作名与实参,没过给一句能读的错。 */
|
|
117
|
+
export type NativeCall = {
|
|
118
|
+
ok: true;
|
|
119
|
+
op: NativeOp;
|
|
120
|
+
args: unknown[];
|
|
121
|
+
} | {
|
|
122
|
+
ok: false;
|
|
123
|
+
error: string;
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* 校验一次桥调用。
|
|
127
|
+
*
|
|
128
|
+
* 与界面通道的 `validateUiArgs` 同口径:参数个数上限、逐个的 JSON 类型、长度上限、
|
|
129
|
+
* 枚举取值、`#rrggbb`;尾部省略只能从尾部开始,中间空一个会让后面的参数错位(正是要拒的形状)。
|
|
130
|
+
*
|
|
131
|
+
* @param op 调用方给的操作名(来自页面,任何形状都可能)
|
|
132
|
+
* @param args 调用方给的实参(同上)
|
|
133
|
+
*/
|
|
134
|
+
export declare function validateNativeCall(op: unknown, args: unknown): NativeCall;
|
|
135
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 正文 token 粗估(全仓库唯一一份)。
|
|
3
|
+
*
|
|
4
|
+
* 为什么单独一个模块:这段口径此前在宿主 core/compact.ts 和渲染层 token-estimate.ts
|
|
5
|
+
* 各抄了一份——界面上写的「约 N token」必须和宿主自动压缩用的阈值同源,不然会出现
|
|
6
|
+
* 界面说 3 万、宿主按 5 万判断压缩这种对不上的情况。现在宿主与渲染层都从这里取
|
|
7
|
+
* (渲染层经 `@dsc/runtime/core/token-estimate.js`,纯函数、零依赖,进得了渲染层)。
|
|
8
|
+
*
|
|
9
|
+
* 口径(2026-09-29 从 chars/3 改为 CJK 分开算):中文一个字约 0.6~0.7 token,
|
|
10
|
+
* chars/3 会把中文低估约一半——自动压缩要等真实用量冲到窗口 100% 以上才触发,直接爆窗。
|
|
11
|
+
* 这里中文按 0.65、其余按 0.33(≈3 字符/token)估,整体宁可高估(早压一次很便宜)
|
|
12
|
+
* 也不低估(报错结束回合)。
|
|
13
|
+
*
|
|
14
|
+
* 凡是用了这里数字的地方都要带「约」或「~」:它是估算,不是服务端真值。
|
|
15
|
+
*
|
|
16
|
+
* @module dsc/core/token-estimate
|
|
17
|
+
*/
|
|
18
|
+
/** 估一段正文的 token 数(不取整;取整是调用方按展示口径自己的事)。 */
|
|
19
|
+
export declare function estimateTextTokens(text: string): number;
|
|
20
|
+
/** 结构够用的消息形状(与 core/llm 的 ChatMessage 同构;不 import,保住零依赖)。 */
|
|
21
|
+
export interface SegmentMessage {
|
|
22
|
+
role: 'system' | 'user' | 'assistant' | 'tool';
|
|
23
|
+
content: string | null | Array<{
|
|
24
|
+
type: string;
|
|
25
|
+
text?: string;
|
|
26
|
+
}>;
|
|
27
|
+
reasoning_content?: string;
|
|
28
|
+
tool_calls?: {
|
|
29
|
+
function: {
|
|
30
|
+
name: string;
|
|
31
|
+
arguments: string;
|
|
32
|
+
};
|
|
33
|
+
}[];
|
|
34
|
+
}
|
|
35
|
+
/** 请求按内容类型的 token 估算分段(context 进度条占用段的组成,dsh 同款五段)。 */
|
|
36
|
+
export interface RequestSegments {
|
|
37
|
+
system: number;
|
|
38
|
+
prompt: number;
|
|
39
|
+
assistant: number;
|
|
40
|
+
thinking: number;
|
|
41
|
+
tools: number;
|
|
42
|
+
}
|
|
43
|
+
/** 全零分段(新会话 / 尚无请求记录)。 */
|
|
44
|
+
export declare function emptySegments(): RequestSegments;
|
|
45
|
+
/**
|
|
46
|
+
* 对**组装完的整份请求**按内容类型现算分段(每次请求重算,天然带「历史被压缩 /
|
|
47
|
+
* 消息滚出窗口」的重置语义,不用做增量抵账)。口径对齐 dsh projection:system 一段、
|
|
48
|
+
* user 归 prompt、assistant 正文与工具调用参数归 assistant、思考归 thinking、
|
|
49
|
+
* 工具结果归 tools。取整向上(宁可高估)。
|
|
50
|
+
*
|
|
51
|
+
* 为什么是估算不是真值:没有 tokenizer,角色标记与工具 JSON 信封也不在五段里——
|
|
52
|
+
* 这些零头体现在权威读数(真实 prompt_tokens)与分段之和的差上,界面只拿分段画颜色,
|
|
53
|
+
* 读数永远用服务端数字。
|
|
54
|
+
*/
|
|
55
|
+
export declare function estimateRequestSegments(messages: readonly SegmentMessage[]): RequestSegments;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dsc/ui-core",
|
|
3
|
+
"version": "1.2.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"description": "插件版界面的共用核心(槽位 + 清单 + 原生桥规格):宿主与界面壳同一份源码,故意不下发给插件。",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"types": "./ui/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./ui/index.d.ts"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"**/*.d.ts"
|
|
15
|
+
]
|
|
16
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 插件工厂的「到达」协议:一个 id 从「批脚本或单资源 URL」到「工厂已注册」的三态回退。
|
|
3
|
+
*
|
|
4
|
+
* 这份逻辑住在共享层(浏览器安全、零 node 依赖)有三个理由:
|
|
5
|
+
*
|
|
6
|
+
* 1. 它是**取数路径的正确性核心**——批脚本是一段 classic script、一次注册整批工厂,
|
|
7
|
+
* 失败形态与单资源不同:传输失败(`error` 事件,什么都没执行)可以同 URL 重试一次;
|
|
8
|
+
* 加载了却没注册这条 id(解析错、或运行期 throw 停了后面的注册)**绝不能重放**,
|
|
9
|
+
* 否则会停在同一处,还可能把整批旧工厂覆盖回来(dsc 的工厂表是后写覆盖,不会像
|
|
10
|
+
* 参考实现那样「二次注册即抛」,所以这条禁令更要显式写死)。
|
|
11
|
+
* 2. 参考实现的 dump 里最难核对的一段就是「最多三次请求」的算术;放在这里之后,
|
|
12
|
+
* 同一份实现既能被浏览器壳用,也能被 node 探针直接驱动(探针用一个假的 load 计数)。
|
|
13
|
+
* 3. 换装时机与记账(在途共享、已执行集合、已失败集合)是有状态的东西,散在加载器里
|
|
14
|
+
* 容易在两处各写一份而慢慢分叉。
|
|
15
|
+
*
|
|
16
|
+
* @module dsc/ui/arrival
|
|
17
|
+
*/
|
|
18
|
+
/** 一条待到达的图行:首选 URL +(可选)回退的单资源 URL。 */
|
|
19
|
+
export interface UiArrivalRow {
|
|
20
|
+
/** 插件 id(工厂表里的键)。 */
|
|
21
|
+
id: string;
|
|
22
|
+
/** 首选取数地址:批 URL,或 HMR 重取时的单资源 URL。 */
|
|
23
|
+
preferred: string;
|
|
24
|
+
/** 首选不是单资源时给的单资源回退地址。 */
|
|
25
|
+
fallback?: string;
|
|
26
|
+
}
|
|
27
|
+
/** 到达协议依赖的外部面:取数(执行脚本)与「工厂注册了没有」。 */
|
|
28
|
+
export interface UiArrivalHost {
|
|
29
|
+
/** 取一个 URL 并让它执行;拒绝 = 传输失败。同一 URL 的在途共享由账本负责。 */
|
|
30
|
+
load(url: string): Promise<void>;
|
|
31
|
+
/** 工厂表里这个 id 的工厂在不在。 */
|
|
32
|
+
has(id: string): boolean;
|
|
33
|
+
}
|
|
34
|
+
/** 一行到达的结果(探针读数;失败时带完整原因链)。 */
|
|
35
|
+
export interface UiArrivalResult {
|
|
36
|
+
/** 请求过的 URL,按发生顺序(含重试与回退)。 */
|
|
37
|
+
requests: string[];
|
|
38
|
+
/** 失败原因链(成功时为空)。 */
|
|
39
|
+
failures: string[];
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* 到达账本:在途共享 + 「已执行」「已失败」两张 URL 表。
|
|
43
|
+
*
|
|
44
|
+
* 为什么不放在 `boot.ts` 里:HMR 的换装(按新 rev 重取单资源)与首装的批取数走同一条
|
|
45
|
+
* 协议,账本必须跨两次调用活着,也要能被探针单独驱动。
|
|
46
|
+
*/
|
|
47
|
+
export declare class UiArrivalLedger {
|
|
48
|
+
/** 同一 URL 的在途取数(一个批被 N 条 entry 需要时只发一次请求)。 */
|
|
49
|
+
private readonly inFlight;
|
|
50
|
+
/** 已经执行过的 URL:绝不再取(重放会停在同一处/覆盖已注册的工厂)。 */
|
|
51
|
+
private readonly executed;
|
|
52
|
+
/** 已经失败过的 URL:不再尝试(同一 URL 的连续失败只报一次)。 */
|
|
53
|
+
private readonly failed;
|
|
54
|
+
/** 取一个 URL(同 URL 共享在途),成功后记进「已执行」。 */
|
|
55
|
+
private loadShared;
|
|
56
|
+
/**
|
|
57
|
+
* 让一条图行的工厂到达。
|
|
58
|
+
*
|
|
59
|
+
* 三态算术(与参考实现逐分支对齐;`requests` 回填给探针,请求数可逐条数死):
|
|
60
|
+
*
|
|
61
|
+
* | 情形 | 请求序列 | 次数/每条缺行 |
|
|
62
|
+
* | --- | --- | --- |
|
|
63
|
+
* | 批传输失败 | 批 → 批(重试 1 次) → 单资源 | 3 |
|
|
64
|
+
* | 批执行了但没注册这条 id | 批 → 单资源(批进「已失败」,绝不重放) | 2 |
|
|
65
|
+
* | 同批更早的行已让批执行过、这条仍缺 | 0 → 单资源 | 1 |
|
|
66
|
+
* | 批已记失败 | 0 → 单资源 | 1 |
|
|
67
|
+
* | 一切正常 | 批(同批所有行共享在途/已执行) | 整批 1 |
|
|
68
|
+
*
|
|
69
|
+
* @throws 失败时抛出带整条原因链的错误(调用方决定记为报告还是忽略预取失败)
|
|
70
|
+
*/
|
|
71
|
+
arrive(row: UiArrivalRow, host: UiArrivalHost): Promise<UiArrivalResult>;
|
|
72
|
+
}
|