@waq666/pneuma 0.0.0-stage → 0.7.0
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 +144 -2
- 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 +13 -0
- package/lib/app/App.js +1498 -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 +32 -0
- package/lib/app/ChatView.js +198 -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 +272 -0
- package/lib/app/TaskStrips.d.ts +13 -0
- package/lib/app/TaskStrips.js +40 -0
- package/lib/app/ToolCard.d.ts +5 -0
- package/lib/app/ToolCard.js +40 -0
- package/lib/app/TranscriptOverlay.d.ts +12 -0
- package/lib/app/TranscriptOverlay.js +17 -0
- package/lib/app/Welcome.d.ts +6 -0
- package/lib/app/Welcome.js +66 -0
- package/lib/app/attach.d.ts +16 -0
- package/lib/app/attach.js +58 -0
- package/lib/app/click.d.ts +27 -0
- package/lib/app/click.js +89 -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/markdown.d.ts +54 -0
- package/lib/app/markdown.js +189 -0
- package/lib/app/settings-model.d.ts +69 -0
- package/lib/app/settings-model.js +114 -0
- package/lib/app/theme.d.ts +166 -0
- package/lib/app/theme.js +141 -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 +272 -0
- package/lib/core/llm.js +548 -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 +862 -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 +425 -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,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* plugin-manager 插件:AI 参与插件管理(对应 dsh 的 plugin_manager 工具)。
|
|
3
|
+
* 注册 `plugin_manager` 工具(list/enable/disable/install/browse_remote/install_remote)
|
|
4
|
+
* 与 `/plugins` 命令。
|
|
5
|
+
*
|
|
6
|
+
* 全部写操作走 core/plugin-loader 的热挂载(即时生效,写盘持久化);工具
|
|
7
|
+
* risk='write',执行前经权限模式/审批卡把关。install 仅支持本地 .js 路径
|
|
8
|
+
* (复制到 ~/.dsc/plugins/ 并热挂载)。T28:browse_remote / install_remote
|
|
9
|
+
* 照技能市场的两类源(GitHub 目录 / 索引 JSON)远程安装——拉取走
|
|
10
|
+
* core/market 的插件市场函数,源 URL 必须是 https;远程插件是任意代码,
|
|
11
|
+
* 审批卡上写明来源,装不装由用户点头。
|
|
12
|
+
*
|
|
13
|
+
* @module dsc/plugins/plugin-manager
|
|
14
|
+
*/
|
|
15
|
+
import { copyFileSync, mkdirSync } from 'node:fs';
|
|
16
|
+
import { basename, isAbsolute, join, resolve } from 'node:path';
|
|
17
|
+
import { browsePluginMarketSource, installPluginMarketEntry } from '../core/market.js';
|
|
18
|
+
import { listPluginInfos } from '../core/plugin-registry.js';
|
|
19
|
+
import { mountExternalPlugin, setPluginEnabledHot } from '../core/plugin-loader.js';
|
|
20
|
+
import { dscPath } from '../core/path-policy.js';
|
|
21
|
+
function pluginsDir() {
|
|
22
|
+
return dscPath('plugins');
|
|
23
|
+
}
|
|
24
|
+
function renderList() {
|
|
25
|
+
const infos = listPluginInfos();
|
|
26
|
+
if (infos.length === 0)
|
|
27
|
+
return '(无插件)';
|
|
28
|
+
return infos
|
|
29
|
+
.map((info) => {
|
|
30
|
+
const state = info.enabled ? '启用' : '停用';
|
|
31
|
+
const problem = info.problem !== undefined ? ` ⚠ ${info.problem}` : '';
|
|
32
|
+
const desc = info.description !== '' ? ` ${info.description}` : '';
|
|
33
|
+
return `[${state}] ${info.name} (${info.file})${desc}${problem}`;
|
|
34
|
+
})
|
|
35
|
+
.join('\n');
|
|
36
|
+
}
|
|
37
|
+
export const pluginManagerPlugin = {
|
|
38
|
+
name: 'plugin-manager',
|
|
39
|
+
inject: ['tools', 'commands'],
|
|
40
|
+
apply(ctx) {
|
|
41
|
+
const tool = {
|
|
42
|
+
name: 'plugin_manager',
|
|
43
|
+
description: '管理 dsc 插件:列出清单(list)、启用/停用(enable/disable,热生效)、' +
|
|
44
|
+
'安装本地插件文件(install,.js 绝对路径)、浏览远程插件源(browse_remote)、' +
|
|
45
|
+
'从远程安装插件(install_remote,https 的 .js 直链)。写操作会请求用户批准。',
|
|
46
|
+
parameters: {
|
|
47
|
+
type: 'object',
|
|
48
|
+
properties: {
|
|
49
|
+
action: {
|
|
50
|
+
type: 'string',
|
|
51
|
+
enum: ['list', 'enable', 'disable', 'install', 'browse_remote', 'install_remote'],
|
|
52
|
+
description: '操作',
|
|
53
|
+
},
|
|
54
|
+
file: {
|
|
55
|
+
type: 'string',
|
|
56
|
+
description: 'enable/disable:插件文件名;install:待安装的 .js 绝对路径;' +
|
|
57
|
+
'browse_remote:市场源地址(GitHub 目录链接或 .json 索引);install_remote:插件 .js 的 https 直链',
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
required: ['action'],
|
|
61
|
+
},
|
|
62
|
+
risk: 'write',
|
|
63
|
+
async run(args) {
|
|
64
|
+
const action = String(args.action ?? '');
|
|
65
|
+
switch (action) {
|
|
66
|
+
case 'list':
|
|
67
|
+
return renderList();
|
|
68
|
+
case 'enable':
|
|
69
|
+
case 'disable': {
|
|
70
|
+
const file = String(args.file ?? '');
|
|
71
|
+
if (file === '')
|
|
72
|
+
return '错误:缺少 file 参数(插件文件名)';
|
|
73
|
+
const outcome = await setPluginEnabledHot(file, action === 'enable');
|
|
74
|
+
if (!outcome.ok)
|
|
75
|
+
return `错误:${outcome.problem ?? '操作失败'}`;
|
|
76
|
+
return `已${action === 'enable' ? '启用' : '停用'}插件 ${file}(热生效,已写盘持久化)`;
|
|
77
|
+
}
|
|
78
|
+
case 'install': {
|
|
79
|
+
const source = String(args.file ?? '');
|
|
80
|
+
if (source === '')
|
|
81
|
+
return '错误:缺少 file 参数(.js 文件绝对路径)';
|
|
82
|
+
// 相对路径基于 DSC_HOME(插件目录的根,也是 config.yaml 所在处):早先按
|
|
83
|
+
// 进程 cwd 解析,多工作区并用之后那只是「上一次切过的工作区」,等于随机。
|
|
84
|
+
const src = isAbsolute(source) ? source : resolve(dscPath(), source);
|
|
85
|
+
if (!src.endsWith('.js'))
|
|
86
|
+
return '错误:仅支持 .js 插件文件';
|
|
87
|
+
try {
|
|
88
|
+
const dest = join(pluginsDir(), basename(src));
|
|
89
|
+
mkdirSync(pluginsDir(), { recursive: true });
|
|
90
|
+
copyFileSync(src, dest);
|
|
91
|
+
const ok = await mountExternalPlugin(dest);
|
|
92
|
+
if (!ok) {
|
|
93
|
+
const meta = listPluginInfos().find((info) => info.file === basename(src));
|
|
94
|
+
return `错误:${meta?.problem ?? '挂载失败'}(文件已复制,可修复后重新启用)`;
|
|
95
|
+
}
|
|
96
|
+
return `已安装并热挂载 ${basename(src)}`;
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
return `错误:${error instanceof Error ? error.message : String(error)}`;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
case 'browse_remote': {
|
|
103
|
+
const url = String(args.file ?? '');
|
|
104
|
+
if (url === '')
|
|
105
|
+
return '错误:缺少 file 参数(市场源地址:GitHub 目录链接或 .json 索引)';
|
|
106
|
+
if (!url.startsWith('https://'))
|
|
107
|
+
return '错误:远程源必须是 https 地址';
|
|
108
|
+
try {
|
|
109
|
+
const entries = await browsePluginMarketSource({ name: 'remote', url });
|
|
110
|
+
if (entries.length === 0)
|
|
111
|
+
return '这个源里没有可安装的 .js 插件';
|
|
112
|
+
return entries
|
|
113
|
+
.map((entry) => `- ${entry.name}${entry.version === undefined ? '' : `(${entry.version})`}:${entry.description}`)
|
|
114
|
+
.join('\n');
|
|
115
|
+
}
|
|
116
|
+
catch (error) {
|
|
117
|
+
return `错误:${error instanceof Error ? error.message : String(error)}`;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
case 'install_remote': {
|
|
121
|
+
const url = String(args.file ?? '');
|
|
122
|
+
if (url === '')
|
|
123
|
+
return '错误:缺少 file 参数(插件 .js 的 https 直链)';
|
|
124
|
+
if (!url.startsWith('https://'))
|
|
125
|
+
return '错误:远程安装必须走 https 直链';
|
|
126
|
+
const name = basename(new URL(url).pathname);
|
|
127
|
+
if (!name.endsWith('.js'))
|
|
128
|
+
return '错误:远程插件必须是 .js 文件(直链)';
|
|
129
|
+
// 远程插件 = 任意代码:装前把来源完整摆进审批卡(risk=write 本来就会弹卡),
|
|
130
|
+
// 用户点头才落盘、才挂载。
|
|
131
|
+
try {
|
|
132
|
+
const entry = {
|
|
133
|
+
name,
|
|
134
|
+
description: `远程插件(来源:${url})`,
|
|
135
|
+
source: url,
|
|
136
|
+
kind: 'flat',
|
|
137
|
+
root: url.replace(/\/[^/]*$/, ''),
|
|
138
|
+
mainFile: name,
|
|
139
|
+
files: [],
|
|
140
|
+
};
|
|
141
|
+
const target = await installPluginMarketEntry(entry, pluginsDir());
|
|
142
|
+
const ok = await mountExternalPlugin(target);
|
|
143
|
+
if (!ok) {
|
|
144
|
+
const meta = listPluginInfos().find((info) => info.file === name);
|
|
145
|
+
return `错误:${meta?.problem ?? '挂载失败'}(文件已下载到 ${target},可修复后重新启用)`;
|
|
146
|
+
}
|
|
147
|
+
return `已从 ${url} 安装并热挂载 ${name}`;
|
|
148
|
+
}
|
|
149
|
+
catch (error) {
|
|
150
|
+
return `错误:${error instanceof Error ? error.message : String(error)}`;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
default:
|
|
154
|
+
return `错误:未知 action ${action}(可用:list / enable / disable / install / browse_remote / install_remote)`;
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
const offTool = ctx.tools.register(tool);
|
|
159
|
+
// /plugins 命令已收敛到 commands 插件(0.6.63:清单带 source/problem 与桌面端
|
|
160
|
+
// 指引),这里只保留插件管理工具,避免同名注册把新 handler 顶掉。
|
|
161
|
+
return () => {
|
|
162
|
+
offTool();
|
|
163
|
+
};
|
|
164
|
+
},
|
|
165
|
+
};
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* presets 插件:provide `presets` 服务(模式状态 + 三个登记点 + 切换命令)。
|
|
3
|
+
*
|
|
4
|
+
* 模式(模式文件见 `core/presets.ts`)只干三件事,都在自己文件里:
|
|
5
|
+
* 1. 往系统提示里加一段这个模式的话(提示词层,order 15,排在「做事方式」之后、
|
|
6
|
+
* 「工具规范」之前),并登记一个骨架取舍把该摘的叮嘱段摘掉;
|
|
7
|
+
* 2. 给主会话的工具目录过一层投影(`ctx.tools.project`)——极简档因此只把 bash
|
|
8
|
+
* 递给模型,而队友、界面、工具检索看到的仍是完整注册表;
|
|
9
|
+
* 3. 换模式时广播 `dsc/preset-changed`,并把档位写进会话状态(恢复会话时跟着回来)。
|
|
10
|
+
*
|
|
11
|
+
* 三件事都只做减法:工具白名单只能从全量里取子集、drop 只能在名单里去掉提示段。
|
|
12
|
+
* 权限模式(approval 插件)与协作模式(mode 插件)各自是另外两根旋钮,这里一个都不碰——
|
|
13
|
+
* 审批灾难地板与守卫链不看模式,所以再野的模式也放宽不了安全。
|
|
14
|
+
*
|
|
15
|
+
* @module dsc/plugins/presets
|
|
16
|
+
*/
|
|
17
|
+
import { readFileSync } from 'node:fs';
|
|
18
|
+
import { DROPPABLE_LABELS, DROPPABLE_SECTIONS, STANDARD_PRESET, ensureBuiltinPresets, findPreset, listPresets, parsePresetToken, removePreset, standardPreset, writePreset, } from '../core/presets.js';
|
|
19
|
+
import { audit } from '../core/audit.js';
|
|
20
|
+
/** 模式 → 界面投影(IPC 只带这些字段)。 */
|
|
21
|
+
function toView(preset) {
|
|
22
|
+
return {
|
|
23
|
+
name: preset.name,
|
|
24
|
+
label: preset.label,
|
|
25
|
+
description: preset.description,
|
|
26
|
+
tools: preset.tools,
|
|
27
|
+
drop: preset.drop,
|
|
28
|
+
prompt: preset.prompt,
|
|
29
|
+
builtin: preset.builtin,
|
|
30
|
+
...(preset.problem !== undefined ? { problem: preset.problem } : {}),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export const presetsPlugin = {
|
|
34
|
+
name: 'presets',
|
|
35
|
+
inject: ['session', 'commands', 'prompt', 'tools', 'settings', 'surfaces', 'approval', 'mode'],
|
|
36
|
+
provide: 'presets',
|
|
37
|
+
apply(ctx) {
|
|
38
|
+
// 出厂四个模式:第一次用到时写出去;已存在的一律不覆盖(用户改过的永远留着)
|
|
39
|
+
ensureBuiltinPresets();
|
|
40
|
+
/** 名字解析:文件不在了就回落标准档(模式文件可能刚被删,偏好里还留着旧名字)。 */
|
|
41
|
+
const resolve = (candidate) => (findPreset(candidate) === null ? STANDARD_PRESET : candidate);
|
|
42
|
+
/** 当前模式的规格;任何异常路径最后都落到 standardPreset()(它绝不返回 null)。 */
|
|
43
|
+
const spec = () => findPreset(name) ?? standardPreset();
|
|
44
|
+
/** 新会话默认模式(读偏好,认不出回落标准档)。 */
|
|
45
|
+
const savedDefault = () => resolve(ctx.settings.prefs().defaultPreset);
|
|
46
|
+
/** 打开会话时该用哪个模式:会话记过就跟着会话,没记过就用默认。 */
|
|
47
|
+
const openName = () => {
|
|
48
|
+
const stored = ctx.session.current().state('preset');
|
|
49
|
+
return typeof stored === 'string' && stored !== '' ? resolve(stored) : savedDefault();
|
|
50
|
+
};
|
|
51
|
+
let name = openName();
|
|
52
|
+
/**
|
|
53
|
+
* 换档:写会话记录 + 审计 + 广播。
|
|
54
|
+
* @returns 给用户看的一句话(调用方拿去当返回文案;这里同时发一条 dsc/notice,
|
|
55
|
+
* 所以 `/preset` 这类不消费返回值的入口也能在会话流里看到它)。
|
|
56
|
+
*/
|
|
57
|
+
const apply = (next, opts = {}) => {
|
|
58
|
+
const changed = name !== next;
|
|
59
|
+
name = next;
|
|
60
|
+
ctx.session.current().appendState('preset', next);
|
|
61
|
+
if (changed) {
|
|
62
|
+
audit({
|
|
63
|
+
ts: Date.now(),
|
|
64
|
+
kind: 'mode-change',
|
|
65
|
+
reason: `模式(预设)→ ${spec().label}`,
|
|
66
|
+
mode: ctx.mode.mode,
|
|
67
|
+
policy: ctx.approval.policy,
|
|
68
|
+
sessionId: ctx.session.current().meta.id,
|
|
69
|
+
cwd: ctx.session.current().meta.cwd,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
const notice = opts.notice ?? `模式切换为「${spec().label}」:${spec().description || '见设置 → 模式'}`;
|
|
73
|
+
ctx.emit('dsc/preset-changed', next);
|
|
74
|
+
ctx.emit('dsc/notice', notice);
|
|
75
|
+
ctx.emit('dsc/changed');
|
|
76
|
+
return notice;
|
|
77
|
+
};
|
|
78
|
+
const service = {
|
|
79
|
+
get name() {
|
|
80
|
+
return name;
|
|
81
|
+
},
|
|
82
|
+
get defaultName() {
|
|
83
|
+
return savedDefault();
|
|
84
|
+
},
|
|
85
|
+
surface() {
|
|
86
|
+
return {
|
|
87
|
+
current: name,
|
|
88
|
+
defaultName: savedDefault(),
|
|
89
|
+
options: listPresets().map(toView),
|
|
90
|
+
droppable: DROPPABLE_SECTIONS.map((id) => ({ id, label: DROPPABLE_LABELS[id] ?? id })),
|
|
91
|
+
};
|
|
92
|
+
},
|
|
93
|
+
use(next) {
|
|
94
|
+
if (findPreset(next) === null)
|
|
95
|
+
throw new Error(`没有名为「${next}」的模式`);
|
|
96
|
+
return apply(next);
|
|
97
|
+
},
|
|
98
|
+
read(target) {
|
|
99
|
+
const preset = findPreset(target);
|
|
100
|
+
if (preset === null)
|
|
101
|
+
throw new Error(`没有名为「${target}」的模式`);
|
|
102
|
+
return readFileSync(preset.file, 'utf8');
|
|
103
|
+
},
|
|
104
|
+
save(draft) {
|
|
105
|
+
const written = writePreset(draft);
|
|
106
|
+
if (written.problem !== undefined)
|
|
107
|
+
throw new Error(written.problem);
|
|
108
|
+
return draft.oldName === null ? `已创建模式「${written.label}」` : `已保存模式「${written.label}」`;
|
|
109
|
+
},
|
|
110
|
+
remove(target) {
|
|
111
|
+
const label = findPreset(target)?.label ?? target;
|
|
112
|
+
removePreset(target);
|
|
113
|
+
// 删掉的正是当前这一档时当场回落标准档,别让会话停在一个不存在的模式上
|
|
114
|
+
if (name === target)
|
|
115
|
+
apply(STANDARD_PRESET, { notice: `模式「${label}」已删除,当前回落到「${spec().label}」` });
|
|
116
|
+
else
|
|
117
|
+
ctx.emit('dsc/notice', `已删除模式「${label}」`);
|
|
118
|
+
return `已删除模式「${label}」`;
|
|
119
|
+
},
|
|
120
|
+
setDefault(target) {
|
|
121
|
+
if (findPreset(target) === null)
|
|
122
|
+
throw new Error(`没有名为「${target}」的模式`);
|
|
123
|
+
ctx.settings.setPrefs({ defaultPreset: target });
|
|
124
|
+
return `新会话默认模式已设为「${findPreset(target)?.label ?? target}」(当前会话不受影响)`;
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
ctx.provide('presets', service);
|
|
128
|
+
// 1. 模式自己那段话:排在做事方式(10)之后、工具规范(20)之前。
|
|
129
|
+
// 空正文(标准档)会被 composePrompt 滤掉,所以默认档的系统提示逐字节不变。
|
|
130
|
+
ctx.prompt.register('preset:persona', () => spec().prompt, { order: 15 });
|
|
131
|
+
// 2. 骨架取舍:drop 里那几段整段不进提示词。
|
|
132
|
+
// 只碰提示词文本——审批硬地板、命令策略、路径策略都在代码里,少几段叮嘱不等于放宽安全。
|
|
133
|
+
ctx.prompt.registerSkeletonFilter('preset', (ids) => {
|
|
134
|
+
const drop = spec().drop;
|
|
135
|
+
return drop.length === 0 ? ids : ids.filter((id) => !drop.includes(id));
|
|
136
|
+
});
|
|
137
|
+
// 3. 工具目录投影:白名单取交集;带 presets 标签的工具只在它列出的模式里露面。
|
|
138
|
+
// 直接写进白名单的工具名也算「露面」(用户的显式意图优先于标签)。
|
|
139
|
+
ctx.tools.project('preset', (tools) => {
|
|
140
|
+
const allowed = spec().tools;
|
|
141
|
+
return tools.filter((entry) => {
|
|
142
|
+
const explicit = allowed !== null && allowed.includes(entry.name);
|
|
143
|
+
if (entry.presets !== undefined && !entry.presets.includes(name) && !explicit)
|
|
144
|
+
return false;
|
|
145
|
+
return allowed === null || explicit;
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
ctx.surfaces.register('preset', () => service.surface());
|
|
149
|
+
// 恢复历史会话:模式跟着回来(不重复写记录,也不重复播报切换)。
|
|
150
|
+
ctx.on('dsc/session-open', ({ session }) => {
|
|
151
|
+
const stored = session.state('preset');
|
|
152
|
+
name = typeof stored === 'string' && stored !== '' ? resolve(stored) : savedDefault();
|
|
153
|
+
ctx.emit('dsc/preset-changed', name);
|
|
154
|
+
ctx.emit('dsc/changed');
|
|
155
|
+
});
|
|
156
|
+
// 挂载完就播一次:比本插件先挂载的监听者因此不会停在「没听过模式」的状态上。
|
|
157
|
+
ctx.emit('dsc/preset-changed', name);
|
|
158
|
+
/** `/preset <名字>`:支持中文别名(标准 / 极简 / 创造 / 代码)。 */
|
|
159
|
+
ctx.commands.register({
|
|
160
|
+
name: 'preset',
|
|
161
|
+
args: '<名字>',
|
|
162
|
+
description: '切换模式(模式 = 人格 + 工具集 + 提示词;写进会话记录,恢复会话时一起恢复)',
|
|
163
|
+
}, ({ args, ui }) => {
|
|
164
|
+
const token = args.join(' ').trim();
|
|
165
|
+
if (token === '') {
|
|
166
|
+
// 有选择器的端(TUI)开浮层;没接的端保持 notice 清单(桌面有自己的模式页)。
|
|
167
|
+
if (ui.openPresets !== undefined) {
|
|
168
|
+
ui.openPresets();
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
ui.notice(`当前模式:${spec().label}。可选:${listPresets().map((item) => `${item.label}(/preset ${item.name})`).join('、')}`);
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
const target = parsePresetToken(token);
|
|
175
|
+
if (target === null) {
|
|
176
|
+
ui.notice(`认不出模式「${token}」。可选:${listPresets().map((item) => `${item.label}(${item.name})`).join('、')}`);
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
service.use(target);
|
|
180
|
+
});
|
|
181
|
+
},
|
|
182
|
+
};
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* prompt 插件:provide `prompt` 服务——系统提示词的段落注册表与「模型可见投影」链。
|
|
3
|
+
*
|
|
4
|
+
* 这个插件是内核扩展点,也是「这一轮到底发什么提示词」这件事的唯一归属:
|
|
5
|
+
* - 各功能点往这里登记自己那一段话(模式条款、外部插件的附加说明……),
|
|
6
|
+
* 段落顺序由各段自己声明,稳定内容往前放、易变内容往后放(服务端提示缓存只认前缀);
|
|
7
|
+
* - 要改写发给模型那份消息的功能点登记**命名纯投影**(registerProjection),
|
|
8
|
+
* 内核的 fold-system / env-facts / image-diet / drop-images 四条护栏与插件投影走同一条按次序的管道;
|
|
9
|
+
* - 环境事实(env-facts 投影,order 600):日期/分支/脏标不再进系统提示词,作为
|
|
10
|
+
* 请求末尾的 user 快照附上。平台(Windows→PowerShell)只有这一个载体,所以缺省
|
|
11
|
+
* 每轮都发;想要「同一份环境不重复烧 token」的人把 `envRefreshMs` 设成非 0 即可
|
|
12
|
+
* ——缓存只认字节前缀,易变内容不能放头部(2026-10-03 / 2026-10-15);
|
|
13
|
+
* - 本插件自己兜底一件事:指令文件的字符预算(`prompt.instructionBudget`)。
|
|
14
|
+
*
|
|
15
|
+
* 「模型看见什么」可以从会话日志完整重建:日志存原文,投影链是命名且可复算的
|
|
16
|
+
* (dsh 的 Model-visible ⟺ logged,个人版达成方式见 registerProjection 的注释)。
|
|
17
|
+
*
|
|
18
|
+
* 注册都返回退订函数,插件卸载后系统提示里不会留下半句话。
|
|
19
|
+
*
|
|
20
|
+
* @module dsc/plugins/prompt
|
|
21
|
+
*/
|
|
22
|
+
import { createHash } from 'node:crypto';
|
|
23
|
+
import { errText } from '../adapter/transcript.js';
|
|
24
|
+
import { dropImageParts, foldSystemMessages } from '../core/llm.js';
|
|
25
|
+
import { pruneImages, readImageDietConfig } from '../core/image-diet.js';
|
|
26
|
+
import { buildSystemPrompt, DEFAULT_INSTRUCTION_BUDGET, environmentText } from '../core/prompt.js';
|
|
27
|
+
import { resolvePluginConfig } from '../core/plugin-registry.js';
|
|
28
|
+
/** 配置键(`~/.dsc/plugins.json` 条目树里 `file` 等于这个名字那一项的 `config`)。 */
|
|
29
|
+
const CONFIG_KEY = 'prompt';
|
|
30
|
+
/** 图片卸载投影的配置键:投影登记在本文件,配置界面在 plugins/image-diet(同一个键)。 */
|
|
31
|
+
const IMAGE_DIET_CONFIG_KEY = 'image-diet';
|
|
32
|
+
/** 图像没能随请求发送时留在正文里的那句话:模型看得见它,才知道自己手上没图。 */
|
|
33
|
+
const NO_IMAGE_NOTE = '(当前模型没有声明照片输入能力,图像没有随请求发送)';
|
|
34
|
+
/** 内置投影占用的名字:协议护栏不许被外部插件顶掉,同名注册直接报错。 */
|
|
35
|
+
const RESERVED_PROJECTIONS = new Set(['fold-system', 'drop-images']);
|
|
36
|
+
/**
|
|
37
|
+
* 取指令文件的预算:夹在 4k 到 200k 之间。单位是**字符**(不是字节;与 codex/dsh/ZCode
|
|
38
|
+
* 的字节口径怎么换算,见 core/prompt.ts 的 DEFAULT_INSTRUCTION_BUDGET 注释)。
|
|
39
|
+
* @param passed - 装配时直接传进来的配置(内核挂载时的第二参数)。
|
|
40
|
+
*/
|
|
41
|
+
function readBudget(passed) {
|
|
42
|
+
const raw = resolvePluginConfig(CONFIG_KEY, passed);
|
|
43
|
+
const num = Number(raw.instructionBudget);
|
|
44
|
+
if (!Number.isFinite(num))
|
|
45
|
+
return DEFAULT_INSTRUCTION_BUDGET;
|
|
46
|
+
return Math.min(Math.max(Math.round(num), 4_000), 200_000);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* 环境快照刷新下限的缺省值(毫秒):**0 = 每轮都发**(缺省)。见 {@link readEnvRefreshMs}。
|
|
50
|
+
*/
|
|
51
|
+
const DEFAULT_ENV_FACTS_REFRESH_MS = 0;
|
|
52
|
+
/**
|
|
53
|
+
* 取环境快照的刷新下限(毫秒,可配 `prompt.envRefreshMs`,0 = 每轮都发)。
|
|
54
|
+
*
|
|
55
|
+
* **缺省是 0(每轮都发)**,不是 dsh 那个 10 分钟——理由比「省几十个 token」硬:
|
|
56
|
+
* 「平台:Windows(bash 工具跑的是 PowerShell)」这条事实**只有 env 快照一个载体**
|
|
57
|
+
* (core/prompt.ts 的 IDENTITY/BEHAVIOR/TOOL_RULES 里没有它,dsh 那边也没有平台注入)。
|
|
58
|
+
* 一旦按「没变就不发」跳过,被跳过的那几轮请求里模型既没有环境、又很可能写出 bash-ism
|
|
59
|
+
* (dsc 主力平台就是 Windows)。省下的那点 token 明显不划算,所以缺省保持每轮都发;
|
|
60
|
+
* 这条闸门留给想要「同一份环境不重复烧 token」的人自己打开(设一个非 0 的毫秒数)。
|
|
61
|
+
* 语义:`now - last.at < refreshMs` 为真才跳过;refreshMs=0 时右边是 0,而 `now - last.at`
|
|
62
|
+
* 单调不小于 0,所以恒不跳过 = 每轮都发。
|
|
63
|
+
* @param passed - 装配时直接传进来的配置(内核挂载时的第二参数)。
|
|
64
|
+
*/
|
|
65
|
+
function readEnvRefreshMs(passed) {
|
|
66
|
+
const raw = resolvePluginConfig(CONFIG_KEY, passed);
|
|
67
|
+
const num = Number(raw.envRefreshMs);
|
|
68
|
+
if (!Number.isFinite(num) || num < 0)
|
|
69
|
+
return DEFAULT_ENV_FACTS_REFRESH_MS;
|
|
70
|
+
return Math.round(num);
|
|
71
|
+
}
|
|
72
|
+
export const promptPlugin = {
|
|
73
|
+
name: 'prompt',
|
|
74
|
+
inject: ['llm', 'skills', 'session'],
|
|
75
|
+
provide: 'prompt',
|
|
76
|
+
apply(ctx, passed) {
|
|
77
|
+
let budget = readBudget(passed);
|
|
78
|
+
/** 附加提示段:id → {顺序, 取文本, 归并目标}。同名后注册者顶掉先注册的,退订只撤自己那一份。 */
|
|
79
|
+
const sections = new Map();
|
|
80
|
+
/**
|
|
81
|
+
* 骨架过滤器表:id → 取舍函数。按登记顺序串起来应用(前一个的输出是后一个的输入)。
|
|
82
|
+
* 模式(presets 插件)登记的那一位把「做事方式」「工具规范」这类段摘掉,
|
|
83
|
+
* 极简档因此只剩一段固定提示词;一个都不登记时提示词逐字节不变。
|
|
84
|
+
*/
|
|
85
|
+
const skeletonFilters = new Map();
|
|
86
|
+
/**
|
|
87
|
+
* 命名投影表:id → {次序, 改写函数}。内核两条内置投影也在表里,与插件投影
|
|
88
|
+
* 走同一条按次序应用的管道——「日志原文 + 这条链」就是模型看见的内容
|
|
89
|
+
* (dsh Model-visible ⟺ logged 的个人版)。
|
|
90
|
+
*/
|
|
91
|
+
const projections = new Map();
|
|
92
|
+
/**
|
|
93
|
+
* 本次改写所属的会话(0.6.48 常驻多 agent):env-facts 这类按会话取 cwd/落
|
|
94
|
+
* 状态条目的投影靠它取对归属。rewrite 是纯同步的,调用前后换值即可,
|
|
95
|
+
* 不会串到别的请求;没带(老调用方)就回落当前查看的会话。
|
|
96
|
+
*/
|
|
97
|
+
let requestSession;
|
|
98
|
+
/** 按次序排好(同次序按 id,稳定),返回投影链。 */
|
|
99
|
+
const projectionChain = () => [...projections.entries()].sort(([aId, a], [bId, b]) => a.order === b.order ? aId.localeCompare(bId) : a.order - b.order);
|
|
100
|
+
// 内置投影一:多条 system 并进头部一条。不少 OpenAI 兼容网关只认「第一条可以是
|
|
101
|
+
// system」,历史中间再冒一条就 400。放在插件投影之后(500):插件往末尾补的
|
|
102
|
+
// system 话术在这里被并进头部。
|
|
103
|
+
projections.set('fold-system', { order: 500, fn: foldSystemMessages });
|
|
104
|
+
// 内置投影二:环境事实快照(2026-10-03)。日期/分支/脏标这类东西每天都变,
|
|
105
|
+
// 放进系统提示词等于每次变化都重写前缀——服务端前缀缓存从改写点之后整段失效
|
|
106
|
+
// (dsh 的 agent-loop README 把这条规律写得很直白)。改成追加在请求末尾的 user
|
|
107
|
+
// 快照:前缀原样命中,变化只落在尾巴这一点;每次请求都带当前值,模型手里
|
|
108
|
+
// 不会有过期环境。它补的是 user 消息,与 fold-system(只动 system)互不干扰。
|
|
109
|
+
//
|
|
110
|
+
// 「变了才发」的闸门默认是**关**的(`envRefreshMs` 缺省 0 = 每轮都发),原因是
|
|
111
|
+
// 「平台:Windows(bash 工具跑的是 PowerShell)」只有 env 快照这一个载体——跳过一轮
|
|
112
|
+
// 就等于那一轮模型没有平台事实,容易写出 bash-ism。开关留给愿意拿这点风险换 token 的人。
|
|
113
|
+
// 打开后(设一个非 0 毫秒数)的语义(照 dsh time-context 的刷新下限):
|
|
114
|
+
// 上一次发过的快照文本与这次相同、又没到下限,就整条不发——它落在缓存前缀之外,
|
|
115
|
+
// 但每轮重发就是每轮白烧几十个 token(长会话里是稳定开销);**首次(含会话刚恢复)
|
|
116
|
+
// 必发、文本变了必发**,到点也重注一次。
|
|
117
|
+
//
|
|
118
|
+
// 打开后的取舍写明(别被 dsh 的字面骗了):dsh 的快照是 durable 的 user 消息,跳过的
|
|
119
|
+
// 那些轮请求里仍带着上一条;dsc 的快照是**投影注入、不落会话历史**(落盘的只有 hash
|
|
120
|
+
// 去重的 `env-facts` 状态条目),所以「不发」的那一轮请求里确实没有环境快照。要 dsh
|
|
121
|
+
// 那种「模型一直持有最近一次快照」,得把快照落成 durable 消息(改会话日志形状,不在本线)。
|
|
122
|
+
// 上次发过什么按会话记(常驻多 agent 各看各的 cwd),只留内存:进程重启后
|
|
123
|
+
// 一律当「首次」,宁可多发一条,不可让模型拿着过期环境而不自知。
|
|
124
|
+
const envSent = new Map();
|
|
125
|
+
projections.set('env-facts', {
|
|
126
|
+
order: 600,
|
|
127
|
+
fn: (messages) => {
|
|
128
|
+
const session = requestSession;
|
|
129
|
+
const snapshot = environmentSnapshot(session.meta.cwd);
|
|
130
|
+
const now = Date.now();
|
|
131
|
+
const last = envSent.get(session.meta.id);
|
|
132
|
+
if (last !== undefined && last.text === snapshot && now - last.at < readEnvRefreshMs(passed)) {
|
|
133
|
+
return messages;
|
|
134
|
+
}
|
|
135
|
+
if (envSent.size > 64)
|
|
136
|
+
envSent.clear(); // 会话多了别让这张表无界长
|
|
137
|
+
envSent.set(session.meta.id, { text: snapshot, at: now });
|
|
138
|
+
// 落一条状态(hash 去重,变了才写):重放会话时最后一条就是模型当时看到的环境
|
|
139
|
+
//(Model-visible ⟺ logged 的环境半边,与 agent 插件的 system-prompt 条目同套做法)。
|
|
140
|
+
noteEnvFacts(session, snapshot);
|
|
141
|
+
return [...messages, { role: 'user', content: snapshot }];
|
|
142
|
+
},
|
|
143
|
+
});
|
|
144
|
+
// 内置投影三:每轮按龄/按预算卸载图片(0.6.68 WS2,口径见 core/image-diet)。
|
|
145
|
+
// 用户贴的图、工具结果里的图、电脑控制的历史截图在长会话里每轮重发,一张 JPEG 截图
|
|
146
|
+
// 100~300KB——旧图既烧 token 又早已过期(界面被后面的操作改掉了)。这一层只留「最近的」:
|
|
147
|
+
// 用户图与工具图各按预算保留,更早回合的图全卸载;卸载只把 image_url 部件换成一句占位,
|
|
148
|
+
// **不删消息、不改 role 序列**(删一条工具结果就会留下孤儿调用,端点直接 400)。
|
|
149
|
+
// 与 drop-images(900,能力门:模型根本不收图时全剥)职责分开,所以排在它前面。
|
|
150
|
+
//
|
|
151
|
+
// 排在 env-facts(600)**之前**:env-facts 会往末尾追加一条 user 环境快照,而本投影
|
|
152
|
+
// 按「最近几个用户回合」决定哪些图还留着——若落在它之后,那条合成快照会白占一格,
|
|
153
|
+
// keepRounds 的口径就比字面保守一格(更早的图被多卸一轮)。先卸图、再补快照,口径才对得上。
|
|
154
|
+
projections.set('image-diet', {
|
|
155
|
+
order: 550,
|
|
156
|
+
fn: (messages) => {
|
|
157
|
+
// 现读配置:设置分区保存后下一轮就生效,不必重启宿主(照 readBudget 的做法)。
|
|
158
|
+
const config = readImageDietConfig(resolvePluginConfig(IMAGE_DIET_CONFIG_KEY));
|
|
159
|
+
return config.enabled ? pruneImages(messages, config) : messages;
|
|
160
|
+
},
|
|
161
|
+
});
|
|
162
|
+
// 内置投影四(永远最后):模型没勾照片输入时把图像换成一句说明。留着图像会让
|
|
163
|
+
// 端点整条请求报错,而电脑操作插件的截图、用户贴进来的图都可能落在这里。
|
|
164
|
+
projections.set('drop-images', {
|
|
165
|
+
order: 900,
|
|
166
|
+
fn: (messages) => (ctx.llm.inputModalities.includes('image') ? messages : dropImageParts(messages, NO_IMAGE_NOTE)),
|
|
167
|
+
});
|
|
168
|
+
const service = {
|
|
169
|
+
register(id, text, options) {
|
|
170
|
+
sections.set(id, { order: options?.order ?? 60, text, block: options?.block });
|
|
171
|
+
return () => {
|
|
172
|
+
if (sections.get(id)?.text === text)
|
|
173
|
+
sections.delete(id);
|
|
174
|
+
};
|
|
175
|
+
},
|
|
176
|
+
registerProjection(id, fn, options) {
|
|
177
|
+
if (RESERVED_PROJECTIONS.has(id)) {
|
|
178
|
+
throw new Error(`投影名 ${id} 是内核保留的(协议护栏),换个名字`);
|
|
179
|
+
}
|
|
180
|
+
projections.set(id, { order: options?.order ?? 60, fn });
|
|
181
|
+
return () => {
|
|
182
|
+
if (projections.get(id)?.fn === fn)
|
|
183
|
+
projections.delete(id);
|
|
184
|
+
};
|
|
185
|
+
},
|
|
186
|
+
sections() {
|
|
187
|
+
const out = [];
|
|
188
|
+
for (const [id, entry] of sections) {
|
|
189
|
+
try {
|
|
190
|
+
out.push({ id, order: entry.order, text: entry.text(), ...(entry.block === undefined ? {} : { block: entry.block }) });
|
|
191
|
+
}
|
|
192
|
+
catch {
|
|
193
|
+
// 一个插件把提示词生成崩了,不该让这一轮请求整个失败:这段本轮跳过。
|
|
194
|
+
void id;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
return out;
|
|
198
|
+
},
|
|
199
|
+
registerSkeletonFilter(id, fn) {
|
|
200
|
+
skeletonFilters.set(id, fn);
|
|
201
|
+
return () => {
|
|
202
|
+
if (skeletonFilters.get(id) === fn)
|
|
203
|
+
skeletonFilters.delete(id);
|
|
204
|
+
};
|
|
205
|
+
},
|
|
206
|
+
systemPrompt(cwd) {
|
|
207
|
+
budget = readBudget(passed);
|
|
208
|
+
// 没有过滤器时走 keep=undefined 的那条路:段的清单与顺序与以前完全一样
|
|
209
|
+
const filters = [...skeletonFilters.entries()];
|
|
210
|
+
const keep = filters.length === 0
|
|
211
|
+
? undefined
|
|
212
|
+
: (ids) => {
|
|
213
|
+
let out = ids;
|
|
214
|
+
for (const [id, fn] of filters) {
|
|
215
|
+
try {
|
|
216
|
+
out = fn(out);
|
|
217
|
+
}
|
|
218
|
+
catch (error) {
|
|
219
|
+
// 取舍崩了就当这一位不存在(提示词多一段总比整轮请求失败强)
|
|
220
|
+
ctx.emit('dsc/notice', `提示词段取舍 ${id} 这轮没跑成,已跳过:${errText(error)}`);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
return out;
|
|
224
|
+
};
|
|
225
|
+
return buildSystemPrompt(cwd, {
|
|
226
|
+
skills: ctx.skills.catalogText(),
|
|
227
|
+
instructionBudget: budget,
|
|
228
|
+
contributions: [
|
|
229
|
+
...service.sections(),
|
|
230
|
+
{ id: 'model', order: 890, text: `当前模型:${ctx.llm.model}(provider ${ctx.llm.provider})` },
|
|
231
|
+
],
|
|
232
|
+
...(keep === undefined ? {} : { keep }),
|
|
233
|
+
});
|
|
234
|
+
},
|
|
235
|
+
rewrite(messages, session) {
|
|
236
|
+
requestSession = session ?? ctx.session.current();
|
|
237
|
+
let out = messages;
|
|
238
|
+
for (const [id, projection] of projectionChain()) {
|
|
239
|
+
try {
|
|
240
|
+
out = projection.fn(out);
|
|
241
|
+
}
|
|
242
|
+
catch (error) {
|
|
243
|
+
// 一个投影崩了不该让这一轮请求整个失败:跳过它(模型本轮看到未投影的
|
|
244
|
+
// 原文),但要把话说出来,别让用户对着莫名其妙的端点报错猜。
|
|
245
|
+
ctx.emit('dsc/notice', `投影 ${id} 这轮没跑成,已跳过:${errText(error)}`);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
return out;
|
|
249
|
+
},
|
|
250
|
+
};
|
|
251
|
+
ctx.provide('prompt', service);
|
|
252
|
+
},
|
|
253
|
+
};
|
|
254
|
+
/** 环境快照消息的全文(发给模型与写进日志状态条目是同一份文本)。 */
|
|
255
|
+
function environmentSnapshot(cwd) {
|
|
256
|
+
return `${environmentText(cwd)}\n(本条是程序在每次请求时自动附上的当前环境快照,不是用户发言)`;
|
|
257
|
+
}
|
|
258
|
+
/** 环境快照落盘(hash 去重):变了才写一条状态,恢复会话时最后一条就是当前环境。 */
|
|
259
|
+
function noteEnvFacts(session, text) {
|
|
260
|
+
const hash = createHash('sha256').update(text).digest('hex').slice(0, 16);
|
|
261
|
+
if (session.state('env-facts')?.hash === hash)
|
|
262
|
+
return;
|
|
263
|
+
session.appendState('env-facts', { hash, text });
|
|
264
|
+
}
|