@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,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 核心配置:读 dsc 自己的 `~/.dsc/config.yaml`(providers + default),
|
|
3
|
+
* 首次运行自动从 dsh 的 settings.yaml 迁移(见 migrate.ts)。
|
|
4
|
+
*
|
|
5
|
+
* key 来源顺序:`apiKeyEnv` 环境变量 → `~/.dsc/credentials.yaml`
|
|
6
|
+
* → `~/.dsh/.credentials.yaml`(兼容回退)。任何情况下不打印 key。
|
|
7
|
+
*
|
|
8
|
+
* 兼容层:`~/.dsc/config.json` 仍可覆盖 default provider/model/temperature。
|
|
9
|
+
*
|
|
10
|
+
* @module dsc/core/config
|
|
11
|
+
*/
|
|
12
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
13
|
+
import { DSC_CONFIG_YAML, DSC_CREDENTIALS, DSH_CREDENTIALS, migrateFromDsh, parseTolerantYaml, } from './migrate.js';
|
|
14
|
+
import { activeConfigFile } from './config-store.js';
|
|
15
|
+
import { readModelCaps } from './model-caps.js';
|
|
16
|
+
import { dscPath } from './path-policy.js';
|
|
17
|
+
const DSC_CONFIG_JSON = dscPath('config.json');
|
|
18
|
+
/**
|
|
19
|
+
* 把凭据库的 refs 段(env 名 → key 值)注入 process.env:dsc 自己的
|
|
20
|
+
* 凭据文件优先,dsh 的作兼容回退。只注入缺失项。
|
|
21
|
+
*/
|
|
22
|
+
function loadCredentials() {
|
|
23
|
+
for (const file of [DSC_CREDENTIALS, DSH_CREDENTIALS]) {
|
|
24
|
+
if (!existsSync(file))
|
|
25
|
+
continue;
|
|
26
|
+
try {
|
|
27
|
+
const doc = parseTolerantYaml(readFileSync(file, 'utf8'));
|
|
28
|
+
for (const [name, value] of Object.entries(doc.refs ?? {})) {
|
|
29
|
+
if (typeof value === 'string' && value !== '' && process.env[name] === undefined) {
|
|
30
|
+
process.env[name] = value;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
// 单个凭据文件坏了不影响另一个
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/** 把文件里的 provider 形状转成运行时形状(key 缺失的端点不注册)。 */
|
|
40
|
+
function toProvider(name, raw) {
|
|
41
|
+
const apiKey = raw.apiKeyEnv !== undefined ? (process.env[raw.apiKeyEnv] ?? '') : '';
|
|
42
|
+
if (apiKey === '')
|
|
43
|
+
return null;
|
|
44
|
+
// api 字段自给自足(不依赖别的能力声明),写错了当场说,不留到发请求才炸
|
|
45
|
+
if (raw.api !== undefined && (typeof raw.api !== 'string' || raw.api.trim() === '')) {
|
|
46
|
+
throw new Error(`config.yaml 端点 ${name} 的 api 字段写法不对:要填协议适配器 id(如 openai-completions)`);
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
name,
|
|
50
|
+
displayName: raw.displayName ?? name,
|
|
51
|
+
baseUrl: raw.baseURL.replace(/\/+$/, ''),
|
|
52
|
+
apiKey,
|
|
53
|
+
...(raw.api !== undefined ? { api: raw.api.trim() } : {}),
|
|
54
|
+
// 只有显式写了 true 才算支持(宽容读:写错的值一律按不支持,绝不误伤默认路由)
|
|
55
|
+
...(raw.cacheControl === true ? { cacheControl: true } : {}),
|
|
56
|
+
models: raw.models.map((model) => ({
|
|
57
|
+
id: model.id,
|
|
58
|
+
name: model.name ?? model.id,
|
|
59
|
+
contextWindow: typeof model.contextWindow === 'number' ? model.contextWindow : 128_000,
|
|
60
|
+
maxTokens: typeof model.maxTokens === 'number' ? model.maxTokens : 8_192,
|
|
61
|
+
// 能力字段缺省时等价于旧行为:thinking 开关 + 四档 + 只吃文本
|
|
62
|
+
...readModelCaps(model),
|
|
63
|
+
})),
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* 读配置。缺配置时先尝试从 dsh 迁移;provider 全空时返回空表
|
|
68
|
+
* (boot 会把"没有可用端点"报给 UI,而不是崩溃)。
|
|
69
|
+
*/
|
|
70
|
+
export function readConfig() {
|
|
71
|
+
const file = activeConfigFile();
|
|
72
|
+
// 从 dsh 迁移只往**出厂那份**里写:换过配置文件的人自己选了一份,不该被迁移结果盖掉。
|
|
73
|
+
if (file === DSC_CONFIG_YAML && !existsSync(DSC_CONFIG_YAML))
|
|
74
|
+
migrateFromDsh();
|
|
75
|
+
loadCredentials();
|
|
76
|
+
const providers = {};
|
|
77
|
+
let defaultProvider = '';
|
|
78
|
+
let defaultModel = '';
|
|
79
|
+
let temperature;
|
|
80
|
+
if (existsSync(file)) {
|
|
81
|
+
const doc = parseTolerantYaml(readFileSync(file, 'utf8'));
|
|
82
|
+
if (typeof doc.default?.provider === 'string')
|
|
83
|
+
defaultProvider = doc.default.provider;
|
|
84
|
+
if (typeof doc.default?.model === 'string')
|
|
85
|
+
defaultModel = doc.default.model;
|
|
86
|
+
if (typeof doc.temperature === 'number')
|
|
87
|
+
temperature = doc.temperature;
|
|
88
|
+
for (const [name, raw] of Object.entries(doc.providers ?? {})) {
|
|
89
|
+
const provider = toProvider(name, raw);
|
|
90
|
+
if (provider !== null)
|
|
91
|
+
providers[name] = provider;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (existsSync(DSC_CONFIG_JSON)) {
|
|
95
|
+
try {
|
|
96
|
+
const overrides = JSON.parse(readFileSync(DSC_CONFIG_JSON, 'utf8'));
|
|
97
|
+
if (typeof overrides.provider === 'string')
|
|
98
|
+
defaultProvider = overrides.provider;
|
|
99
|
+
if (typeof overrides.model === 'string')
|
|
100
|
+
defaultModel = overrides.model;
|
|
101
|
+
if (typeof overrides.temperature === 'number')
|
|
102
|
+
temperature = overrides.temperature;
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
// 覆盖文件坏了就当没有
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
// 默认路由指向不存在的 provider/model 时退回第一个可用组合
|
|
109
|
+
if (providers[defaultProvider] === undefined) {
|
|
110
|
+
const first = Object.keys(providers)[0];
|
|
111
|
+
if (first !== undefined) {
|
|
112
|
+
defaultProvider = first;
|
|
113
|
+
defaultModel = providers[first].models[0]?.id ?? '';
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
defaultProvider = '';
|
|
117
|
+
defaultModel = '';
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
else if (!providers[defaultProvider].models.some((model) => model.id === defaultModel)) {
|
|
121
|
+
defaultModel = providers[defaultProvider].models[0]?.id ?? '';
|
|
122
|
+
}
|
|
123
|
+
return { providers, defaultProvider, defaultModel, temperature };
|
|
124
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 端点连接测试:拿这个端点**真发一次**最小的对话请求,看能不能通。
|
|
3
|
+
*
|
|
4
|
+
* 为什么不是「再查一次 /models」(那是隔壁的「拉取清单」):那一步只证明地址可达,
|
|
5
|
+
* 证不了 key 对不对、模型 id 在不在、协议适配器认不认、端点要的请求头带没带。
|
|
6
|
+
* 这里走的是与正常对话**同一条**链路(同一个协议适配器、同一份归因头),所以它的
|
|
7
|
+
* 结论就是「现在发一条消息会不会失败」的结论。
|
|
8
|
+
*
|
|
9
|
+
* 探针消息固定两条(system + user `hi`),不掺会话历史、不带工具、不带额外说明——
|
|
10
|
+
* 同类客户端的连接测试也把它钉成固定契约:每个调用方各写一套的话,测的东西就不是
|
|
11
|
+
* 用户要用的那条路了,测试本身也容易把会话内容漏出去。
|
|
12
|
+
*
|
|
13
|
+
* 判定口径:**流正常收尾即成功**(输出被 `max_tokens` 截断、正文为空都算通——通的
|
|
14
|
+
* 意思是「这条路能走完」)。失败折成一句可直接展示的说明,**不重试**:测试要的是
|
|
15
|
+
* 当下的真相,不是退避三轮之后的真相。
|
|
16
|
+
*
|
|
17
|
+
* @module dsc/core/connection-test
|
|
18
|
+
*/
|
|
19
|
+
import type { ChatMessage, LlmRoute, LlmStream, StreamRequest } from './llm.js';
|
|
20
|
+
import type { ConnectionTestOutcome } from '../contract.js';
|
|
21
|
+
/** 固定探针消息:两条、system 在最前、无历史无工具。 */
|
|
22
|
+
export declare const CONNECTION_PROBE_MESSAGES: readonly ChatMessage[];
|
|
23
|
+
/**
|
|
24
|
+
* 输出预算。测试只需要「流能收尾」,不需要模型真的写完一句话——给个很小的上限,
|
|
25
|
+
* 免得一次点按烧掉一整天。参考实现的连接测试把这个预算压到 1 token(正文常常是空的,
|
|
26
|
+
* 它们照样算通)。
|
|
27
|
+
*/
|
|
28
|
+
export declare const CONNECTION_PROBE_MAX_TOKENS = 16;
|
|
29
|
+
/**
|
|
30
|
+
* 测试自己的截止时间。正常请求的建连超时是 30 秒、流空闲超时 3 分钟——按钮不能让人
|
|
31
|
+
* 盯着转那么久,所以这里另起一个更短的闸。
|
|
32
|
+
*/
|
|
33
|
+
export declare const CONNECTION_PROBE_TIMEOUT_MS = 20000;
|
|
34
|
+
/**
|
|
35
|
+
* 组一次测试请求:路由里**照原样**带这个模型平时会发的思考字段(测试的必须是与
|
|
36
|
+
* 正常请求同形状的那条路),只把消息换成探针、预算压小。
|
|
37
|
+
*/
|
|
38
|
+
export declare function connectionProbeRequest(route: LlmRoute): StreamRequest;
|
|
39
|
+
/** 模型回话的单行摘要(换行压平、超长截断);没回正文就是空串,不编一句。 */
|
|
40
|
+
export declare function clipReply(text: string): string;
|
|
41
|
+
/**
|
|
42
|
+
* 测哪个模型:显式点名的 > 这个端点**平时真会用到**的那个(它就是默认端点时,取默认
|
|
43
|
+
* 模型——用户点这颗按钮十有八九在问「我现在这条路由能不能通」)> 清单里的第一个。
|
|
44
|
+
* 返回空串 = 这个端点一个模型都没有,没法测。
|
|
45
|
+
*/
|
|
46
|
+
export declare function pickProbeModel(providerName: string, models: readonly {
|
|
47
|
+
id: string;
|
|
48
|
+
}[], wanted: string | undefined, defaults: {
|
|
49
|
+
provider: string;
|
|
50
|
+
model: string;
|
|
51
|
+
}): string;
|
|
52
|
+
/**
|
|
53
|
+
* 发一次测试请求。`stream` 是经 llm 服务派发的流式调用(与回合/压缩共用同一个口子,
|
|
54
|
+
* 所以端点要的归因头、协议适配器都照走)。
|
|
55
|
+
*
|
|
56
|
+
* @param route - 被测端点的路由(由调用方按端点名/模型组好)。
|
|
57
|
+
* @param stream - 派发用的流式调用。
|
|
58
|
+
* @param timeoutMs - 截止时间;超了就不等了(结论按超时报,不按端点报错报)。
|
|
59
|
+
*/
|
|
60
|
+
export declare function testConnection(route: LlmRoute, stream: LlmStream, timeoutMs?: number): Promise<ConnectionTestOutcome>;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { errText } from './err-text.js';
|
|
2
|
+
/** 固定探针消息:两条、system 在最前、无历史无工具。 */
|
|
3
|
+
export const CONNECTION_PROBE_MESSAGES = [
|
|
4
|
+
{ role: 'system', content: '你是连接测试探针。收到消息后回一句简短的话即可。' },
|
|
5
|
+
{ role: 'user', content: 'hi' },
|
|
6
|
+
];
|
|
7
|
+
/**
|
|
8
|
+
* 输出预算。测试只需要「流能收尾」,不需要模型真的写完一句话——给个很小的上限,
|
|
9
|
+
* 免得一次点按烧掉一整天。参考实现的连接测试把这个预算压到 1 token(正文常常是空的,
|
|
10
|
+
* 它们照样算通)。
|
|
11
|
+
*/
|
|
12
|
+
export const CONNECTION_PROBE_MAX_TOKENS = 16;
|
|
13
|
+
/**
|
|
14
|
+
* 测试自己的截止时间。正常请求的建连超时是 30 秒、流空闲超时 3 分钟——按钮不能让人
|
|
15
|
+
* 盯着转那么久,所以这里另起一个更短的闸。
|
|
16
|
+
*/
|
|
17
|
+
export const CONNECTION_PROBE_TIMEOUT_MS = 20_000;
|
|
18
|
+
/** 回话摘要的长度上限(界面上就那么一格,多出来的没处放)。 */
|
|
19
|
+
const REPLY_CLIP = 80;
|
|
20
|
+
/**
|
|
21
|
+
* 组一次测试请求:路由里**照原样**带这个模型平时会发的思考字段(测试的必须是与
|
|
22
|
+
* 正常请求同形状的那条路),只把消息换成探针、预算压小。
|
|
23
|
+
*/
|
|
24
|
+
export function connectionProbeRequest(route) {
|
|
25
|
+
return {
|
|
26
|
+
baseUrl: route.baseUrl,
|
|
27
|
+
apiKey: route.apiKey,
|
|
28
|
+
model: route.model,
|
|
29
|
+
messages: [...CONNECTION_PROBE_MESSAGES],
|
|
30
|
+
maxTokens: CONNECTION_PROBE_MAX_TOKENS,
|
|
31
|
+
...(route.thinking === undefined ? {} : { thinking: route.thinking }),
|
|
32
|
+
...(route.reasoningEffort === undefined ? {} : { reasoningEffort: route.reasoningEffort }),
|
|
33
|
+
// 端点声明了显式缓存就照原样带(测试的必须是与正常请求同形状的那条路)
|
|
34
|
+
...(route.cacheControl === true ? { cacheControl: true } : {}),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/** 模型回话的单行摘要(换行压平、超长截断);没回正文就是空串,不编一句。 */
|
|
38
|
+
export function clipReply(text) {
|
|
39
|
+
const flat = text.replace(/\s+/g, ' ').trim();
|
|
40
|
+
return flat.length > REPLY_CLIP ? `${flat.slice(0, REPLY_CLIP)}…` : flat;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* 测哪个模型:显式点名的 > 这个端点**平时真会用到**的那个(它就是默认端点时,取默认
|
|
44
|
+
* 模型——用户点这颗按钮十有八九在问「我现在这条路由能不能通」)> 清单里的第一个。
|
|
45
|
+
* 返回空串 = 这个端点一个模型都没有,没法测。
|
|
46
|
+
*/
|
|
47
|
+
export function pickProbeModel(providerName, models, wanted, defaults) {
|
|
48
|
+
const named = wanted?.trim() ?? '';
|
|
49
|
+
if (named !== '')
|
|
50
|
+
return named;
|
|
51
|
+
if (defaults.provider === providerName && models.some((model) => model.id === defaults.model)) {
|
|
52
|
+
return defaults.model;
|
|
53
|
+
}
|
|
54
|
+
return models[0]?.id ?? '';
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* 发一次测试请求。`stream` 是经 llm 服务派发的流式调用(与回合/压缩共用同一个口子,
|
|
58
|
+
* 所以端点要的归因头、协议适配器都照走)。
|
|
59
|
+
*
|
|
60
|
+
* @param route - 被测端点的路由(由调用方按端点名/模型组好)。
|
|
61
|
+
* @param stream - 派发用的流式调用。
|
|
62
|
+
* @param timeoutMs - 截止时间;超了就不等了(结论按超时报,不按端点报错报)。
|
|
63
|
+
*/
|
|
64
|
+
export async function testConnection(route, stream, timeoutMs = CONNECTION_PROBE_TIMEOUT_MS) {
|
|
65
|
+
const started = Date.now();
|
|
66
|
+
const controller = new AbortController();
|
|
67
|
+
const timer = setTimeout(() => {
|
|
68
|
+
controller.abort();
|
|
69
|
+
}, timeoutMs);
|
|
70
|
+
try {
|
|
71
|
+
const result = await stream(route.api, { ...connectionProbeRequest(route), signal: controller.signal }, { onDelta() { } });
|
|
72
|
+
return { ok: true, ms: Date.now() - started, reply: clipReply(result.text) };
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
// 超时与「端点回了错」是两种毛病,得分开说:超时是我们自己按停的,不是它拒了谁
|
|
76
|
+
const message = controller.signal.aborted
|
|
77
|
+
? `超时:${String(Math.round(timeoutMs / 1000))} 秒没等到结果`
|
|
78
|
+
: `连接失败:${errText(error)}`;
|
|
79
|
+
return { ok: false, ms: Date.now() - started, reply: '', error: message };
|
|
80
|
+
}
|
|
81
|
+
finally {
|
|
82
|
+
clearTimeout(timer);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
import type { DesktopElement, DesktopFrame, DesktopRiskTier, DesktopTarget } from '../contract.js';
|
|
2
|
+
/** 桌面动作(工具 action 枚举;名字尽量照 ZCode 语义)。 */
|
|
3
|
+
export declare const DESKTOP_ACTIONS: readonly ["screenshot", "click", "type", "key", "scroll", "drag", "paste", "set_value", "select_text", "perform_action", "cursor", "list_windows", "list_apps", "screens", "get_app_state", "stop"];
|
|
4
|
+
export type DesktopAction = (typeof DESKTOP_ACTIONS)[number];
|
|
5
|
+
/** 旧名兼容:`window_list` 是 `list_windows` 的历史叫法(老配置里可能还写着它)。 */
|
|
6
|
+
export declare const ACTION_ALIASES: Readonly<Record<string, DesktopAction>>;
|
|
7
|
+
/** 把(可能是旧名的)动作名归一成规范名;不认识返回 null。 */
|
|
8
|
+
export declare function canonicalAction(name: string): DesktopAction | null;
|
|
9
|
+
/** 只读观察动作(看,不动手):免审批的那一档就是它们。 */
|
|
10
|
+
export declare const READ_ACTIONS: readonly DesktopAction[];
|
|
11
|
+
/** 屏幕矩形(虚拟屏幕物理像素;多显示器时 left/top 可负)。 */
|
|
12
|
+
export interface ScreenBounds {
|
|
13
|
+
left: number;
|
|
14
|
+
top: number;
|
|
15
|
+
width: number;
|
|
16
|
+
height: number;
|
|
17
|
+
}
|
|
18
|
+
/** 显示器描述。 */
|
|
19
|
+
export interface ScreenInfo {
|
|
20
|
+
device: string;
|
|
21
|
+
primary: boolean;
|
|
22
|
+
bounds: {
|
|
23
|
+
x: number;
|
|
24
|
+
y: number;
|
|
25
|
+
width: number;
|
|
26
|
+
height: number;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/** 桌面参数(x/y 为截图像素坐标;缩放由本模块换算)。 */
|
|
30
|
+
export interface DesktopArgs {
|
|
31
|
+
x?: number;
|
|
32
|
+
y?: number;
|
|
33
|
+
/** 动作目标:元素索引或坐标(与旧版扁平 x/y 并列,二者都认)。 */
|
|
34
|
+
target?: DesktopTarget;
|
|
35
|
+
/** 拖拽起点/终点目标。 */
|
|
36
|
+
from?: DesktopTarget;
|
|
37
|
+
to?: DesktopTarget;
|
|
38
|
+
/** 绑定窗口:句柄(数字)或标题/进程序名片段;绑定后坐标按该窗口左上角解析。 */
|
|
39
|
+
window?: number | string;
|
|
40
|
+
button?: string;
|
|
41
|
+
double?: boolean;
|
|
42
|
+
text?: string;
|
|
43
|
+
key?: string;
|
|
44
|
+
repeat?: number;
|
|
45
|
+
holdSeconds?: number;
|
|
46
|
+
amount?: number;
|
|
47
|
+
/** 截图裁切区域(相对虚拟屏左上角的像素)。 */
|
|
48
|
+
clip?: {
|
|
49
|
+
x: number;
|
|
50
|
+
y: number;
|
|
51
|
+
width: number;
|
|
52
|
+
height: number;
|
|
53
|
+
};
|
|
54
|
+
/** set_value 的值。 */
|
|
55
|
+
value?: string;
|
|
56
|
+
/** perform_action 的 UIA 动作名。 */
|
|
57
|
+
pattern?: string;
|
|
58
|
+
/** 元素/窗口动作:关闭增量观察,取全树。 */
|
|
59
|
+
disableDiffing?: boolean;
|
|
60
|
+
}
|
|
61
|
+
/** 一次动作的结果:文本,或文本 + 图像(data URL)。 */
|
|
62
|
+
export interface DesktopResult {
|
|
63
|
+
text: string;
|
|
64
|
+
images?: string[];
|
|
65
|
+
/** 这次截屏相对屏幕的缩放系数(1 = 一比一);点坐标要按它换算。 */
|
|
66
|
+
scale?: number;
|
|
67
|
+
/** get_app_state 顺带带出的结构化观察(内部用)。 */
|
|
68
|
+
frame?: DesktopFrame;
|
|
69
|
+
}
|
|
70
|
+
/** 观察/遍历上限(防止一棵病态树把上下文撑爆;超了在文本里明说被截断)。 */
|
|
71
|
+
export declare const OBSERVE_MAX_ELEMENTS = 400;
|
|
72
|
+
/**
|
|
73
|
+
* 急停:杀掉所有在跑的 PowerShell 子进程。
|
|
74
|
+
* @returns 实际尝试杀掉的进程数(0 = 当时没有在跑的)。
|
|
75
|
+
*/
|
|
76
|
+
export declare function killAllPowerShell(): number;
|
|
77
|
+
/**
|
|
78
|
+
* 跑一段 PowerShell 并取 stdout。
|
|
79
|
+
* @param signal - 外部取消时立刻杀掉子进程(用户中断这一轮,不该留一个正在点鼠标的进程)。
|
|
80
|
+
*/
|
|
81
|
+
export declare function runPowerShell(script: string, timeoutMs?: number, signal?: AbortSignal): Promise<string>;
|
|
82
|
+
/** 把 `ctrl+shift+s` 这类键名翻成 SendKeys 语法。 */
|
|
83
|
+
export declare function toSendKeys(key: string): string;
|
|
84
|
+
/** 截屏脚本:DPI 感知 → 抓虚拟屏(或裁切块)→ 需要时缩放 → 按质量存 JPEG/PNG → base64。 */
|
|
85
|
+
export declare function screenshotScript(maxEdge: number, format: 'jpeg' | 'png', quality: number, clip?: {
|
|
86
|
+
x: number;
|
|
87
|
+
y: number;
|
|
88
|
+
width: number;
|
|
89
|
+
height: number;
|
|
90
|
+
}): string;
|
|
91
|
+
/** 观察脚本参数。 */
|
|
92
|
+
export interface ObserveOptions {
|
|
93
|
+
windowId?: number;
|
|
94
|
+
windowText?: string;
|
|
95
|
+
maxElements?: number;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* 无障碍观察脚本:枚举目标窗口(或前台窗口)的控件树,输出一行 JSON。
|
|
99
|
+
* UIA 不可用时输出 `{ok:false,error:"…"}`(Node 侧抛成明确中文),绝不静默。
|
|
100
|
+
*/
|
|
101
|
+
export declare function observeScript(options?: ObserveOptions): string;
|
|
102
|
+
/**
|
|
103
|
+
* 元素动作脚本:重新遍历到第 index 个控件,按 pattern 派发(set_value / select_text / perform_action)。
|
|
104
|
+
* 输出 JSON `{ok, error, method}`;method='none' 表示该控件没有对应模式(Node 侧据此回退)。
|
|
105
|
+
*/
|
|
106
|
+
export declare function elementActionScript(kind: 'set_value' | 'select_text' | 'perform_action', options: ObserveOptions & {
|
|
107
|
+
index: number;
|
|
108
|
+
value?: string;
|
|
109
|
+
pattern?: string;
|
|
110
|
+
}): string;
|
|
111
|
+
/** 拖拽脚本:起点按下 → 分步插值移动到终点 → **finally 里保证抬起**。 */
|
|
112
|
+
export declare function dragScript(from: {
|
|
113
|
+
x: number;
|
|
114
|
+
y: number;
|
|
115
|
+
}, to: {
|
|
116
|
+
x: number;
|
|
117
|
+
y: number;
|
|
118
|
+
}, steps: number, stepDelayMs: number): string;
|
|
119
|
+
/** 点击脚本:移动到点 → 单击/双击(可选先激活窗口)。 */
|
|
120
|
+
export declare function clickScript(point: {
|
|
121
|
+
x: number;
|
|
122
|
+
y: number;
|
|
123
|
+
}, button: string, double: boolean, activateLine: string, pauseMs: number): string;
|
|
124
|
+
/** 滚轮脚本:可选先把鼠标移到某点,再滚 amount 档。 */
|
|
125
|
+
export declare function scrollScript(amount: number, move: string, pauseMs: number): string;
|
|
126
|
+
/** 按键脚本:按住 hold_seconds(可选)再松开,repeat 次。 */
|
|
127
|
+
export declare function keyScript(keys: string, repeat: number, holdSeconds: number): string;
|
|
128
|
+
/**
|
|
129
|
+
* 粘贴脚本:把 text(可选)写进系统剪贴板,Ctrl+V,然后**还原用户原来的文本剪贴板**。
|
|
130
|
+
* `text` 省略时直接用当前剪贴板(不动它,也不还原)。
|
|
131
|
+
*/
|
|
132
|
+
export declare function pasteScript(text: string | undefined): string;
|
|
133
|
+
/** 文本输入脚本:写剪贴板 → 粘贴 → 还原原剪贴板。 */
|
|
134
|
+
export declare function typeScript(text: string): string;
|
|
135
|
+
/** 列窗口脚本(增强:window_id/title/app/bounds/main/focused/onscreen)。 */
|
|
136
|
+
export declare function listWindowsScript(): string;
|
|
137
|
+
/** 列应用脚本:进程名 + 主窗口 + 是否前台。 */
|
|
138
|
+
export declare function listAppsScript(): string;
|
|
139
|
+
/** 显示器枚举脚本(含负坐标)。 */
|
|
140
|
+
export declare function screensScript(): string;
|
|
141
|
+
/** 窗口探测脚本:解析 window 选择器,返回句柄 + 标题 + 矩形(绑定坐标与激活用)。 */
|
|
142
|
+
export declare function probeWindowScript(selector: number | string): string;
|
|
143
|
+
/**
|
|
144
|
+
* 把截图像素坐标换算成屏幕物理坐标。
|
|
145
|
+
* @throws 小数坐标,或换算后落在屏幕外(这里不靠 SetCursorPos 静默夹紧,越界就是要告诉模型)。
|
|
146
|
+
*/
|
|
147
|
+
export declare function resolveScreenPoint(args: DesktopArgs, bounds: ScreenBounds, scale: number): {
|
|
148
|
+
x: number;
|
|
149
|
+
y: number;
|
|
150
|
+
};
|
|
151
|
+
/** 目标解析结果。 */
|
|
152
|
+
export interface TargetResolution {
|
|
153
|
+
x: number;
|
|
154
|
+
y: number;
|
|
155
|
+
label: string;
|
|
156
|
+
element?: DesktopElement;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* 解析一个动作目标成屏幕物理坐标(纯函数,自检直接调)。
|
|
160
|
+
*
|
|
161
|
+
* - coordinate:图上的整数像素(按 scale 换算);若绑定了窗口,则相对该窗口左上角。
|
|
162
|
+
* - element:走该窗口**最近一次观察**(frame)里的 index;**元素不存在一律 fail-closed**
|
|
163
|
+
* (抛 ELEMENT_UNAVAILABLE,绝不退回坐标);元素在屏外/无矩形同样报错。
|
|
164
|
+
*
|
|
165
|
+
* @param target - 元素或坐标目标。缺省时用 legacy 的扁平 x/y(兼容旧参数形状)。
|
|
166
|
+
* @param frame - 该窗口最近一次观察(element 目标必须有)。
|
|
167
|
+
* @param bounds - 虚拟屏幕矩形。
|
|
168
|
+
* @param scale - 最近一张截图的缩放系数。
|
|
169
|
+
* @param windowBounds - 绑定窗口的矩形(给了则坐标按窗口左上角解析)。
|
|
170
|
+
*/
|
|
171
|
+
export declare function resolveTarget(target: DesktopTarget | undefined, legacy: {
|
|
172
|
+
x?: number;
|
|
173
|
+
y?: number;
|
|
174
|
+
} | undefined, frame: DesktopFrame | undefined, bounds: ScreenBounds, scale: number, windowBounds?: {
|
|
175
|
+
x: number;
|
|
176
|
+
y: number;
|
|
177
|
+
width: number;
|
|
178
|
+
height: number;
|
|
179
|
+
} | null): TargetResolution;
|
|
180
|
+
/** 自检用:清空观察缓存(生产路径不调用)。 */
|
|
181
|
+
export declare function resetFrames(): void;
|
|
182
|
+
/** 该窗口最近一次观察。 */
|
|
183
|
+
export declare function frameForWindow(windowKey?: string | number): DesktopFrame | undefined;
|
|
184
|
+
/** 解析观察脚本的 JSON,产出 DesktopFrame 并写入缓存。 */
|
|
185
|
+
export declare function parseFrame(raw: string): DesktopFrame;
|
|
186
|
+
/** 帧差分:按 index 对齐(未变的索引仍有效),得出 added/removed/changed。 */
|
|
187
|
+
export declare function diffFrames(base: DesktopFrame, next: DesktopFrame): {
|
|
188
|
+
removed: number[];
|
|
189
|
+
added: number[];
|
|
190
|
+
changed: number[];
|
|
191
|
+
};
|
|
192
|
+
/** 把差分结论写成给人/模型看的文本。 */
|
|
193
|
+
export declare function diffText(base: DesktopFrame, next: DesktopFrame, diff: {
|
|
194
|
+
removed: number[];
|
|
195
|
+
added: number[];
|
|
196
|
+
changed: number[];
|
|
197
|
+
}): string;
|
|
198
|
+
/** settle 观察选项(自检可注入 now/sleep)。 */
|
|
199
|
+
export interface SettleOptions {
|
|
200
|
+
intervalMs?: number;
|
|
201
|
+
timeoutMs?: number;
|
|
202
|
+
sleep?: (ms: number) => Promise<void>;
|
|
203
|
+
now?: () => number;
|
|
204
|
+
}
|
|
205
|
+
/** settle 结论。 */
|
|
206
|
+
export interface SettleResult {
|
|
207
|
+
stable: boolean;
|
|
208
|
+
attempts: number;
|
|
209
|
+
waitedMs: number;
|
|
210
|
+
fingerprint: string;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* 观察稳定性判定:连续两次指纹相同即算稳定;超时上限到了就如实返回 stable:false。
|
|
214
|
+
*
|
|
215
|
+
* 为什么要 settle:动作发出去到界面真正变化之间有延迟,直接观察容易拍到中间态。
|
|
216
|
+
* 禁止模型自己轮询/setTimeout,所以等待发生在这里,且必须有上限。
|
|
217
|
+
*/
|
|
218
|
+
export declare function settleObserve<T>(snapshot: () => Promise<T>, fingerprint: (value: T) => string, options?: SettleOptions): Promise<SettleResult>;
|
|
219
|
+
/** 观察目标窗口的无障碍树(新动作 get_app_state 的实现)。 */
|
|
220
|
+
export declare function observeAppState(options?: {
|
|
221
|
+
window?: number | string;
|
|
222
|
+
disableDiffing?: boolean;
|
|
223
|
+
maxElements?: number;
|
|
224
|
+
}, signal?: AbortSignal): Promise<DesktopResult>;
|
|
225
|
+
/**
|
|
226
|
+
* 执行一个桌面动作。
|
|
227
|
+
* @param scale - 上一次截屏的缩放系数(点/滚动的坐标按它换算回物理像素)。
|
|
228
|
+
* @param allowedApps - 应用白名单(进程名或窗口标题的子串);空数组 = 不限。
|
|
229
|
+
*/
|
|
230
|
+
export declare function runDesktopAction(action: DesktopAction, args: DesktopArgs, options: {
|
|
231
|
+
scale: number;
|
|
232
|
+
allowedApps: readonly string[];
|
|
233
|
+
actionDelayMs: number;
|
|
234
|
+
}, signal?: AbortSignal): Promise<DesktopResult>;
|
|
235
|
+
/**
|
|
236
|
+
* 抓一张全屏图(或裁切块)。
|
|
237
|
+
* @returns 图像 data URL + 缩放系数(点坐标要按它换算)。
|
|
238
|
+
*/
|
|
239
|
+
export declare function takeScreenshot(options: {
|
|
240
|
+
maxEdge: number;
|
|
241
|
+
format: 'jpeg' | 'png';
|
|
242
|
+
quality: number;
|
|
243
|
+
clip?: {
|
|
244
|
+
x: number;
|
|
245
|
+
y: number;
|
|
246
|
+
width: number;
|
|
247
|
+
height: number;
|
|
248
|
+
};
|
|
249
|
+
}, signal?: AbortSignal): Promise<DesktopResult>;
|
|
250
|
+
/** 前台窗口是谁(白名单提示与自查用)。 */
|
|
251
|
+
export declare function foregroundWindow(signal?: AbortSignal): Promise<string>;
|
|
252
|
+
/** 枚举显示器(screens 动作的独立入口,自检/诊断用)。 */
|
|
253
|
+
export declare function listScreens(signal?: AbortSignal): Promise<ScreenInfo[]>;
|
|
254
|
+
/**
|
|
255
|
+
* 危险分级:
|
|
256
|
+
* - `read`:只读观察(截图/查鼠标/列窗口/列应用/列显示器/get_app_state),免审批那一档;
|
|
257
|
+
* - `input`:普通输入与点击(要审批);
|
|
258
|
+
* - `system`:系统级(急停 stop,或目标/文本命中系统工具形状),最严。
|
|
259
|
+
*/
|
|
260
|
+
export declare function gradeDesktopAction(action: DesktopAction, args?: Record<string, unknown>): DesktopRiskTier;
|
|
261
|
+
/** 一行电脑操作审计记录。 */
|
|
262
|
+
export interface ComputerAuditRecord {
|
|
263
|
+
/** 毫秒时间戳。 */
|
|
264
|
+
ts: number;
|
|
265
|
+
action: string;
|
|
266
|
+
/** 危险分级(read/input/system)。 */
|
|
267
|
+
risk: DesktopRiskTier;
|
|
268
|
+
/** 目标摘要(坐标/元素/窗口)。 */
|
|
269
|
+
target: string;
|
|
270
|
+
/** 结果。 */
|
|
271
|
+
result: 'ok' | 'error';
|
|
272
|
+
/** 是否过了审批(只读观察 = false)。 */
|
|
273
|
+
approved: boolean;
|
|
274
|
+
/** 失败原因或补充说明。 */
|
|
275
|
+
detail?: string;
|
|
276
|
+
}
|
|
277
|
+
/** 电脑操作审计文件:`<home>/audit/computer-use.jsonl`(home 来自 ctx.settings.about().home,不硬编码)。 */
|
|
278
|
+
export declare function computerAuditPath(home: string): string;
|
|
279
|
+
/** 把一条审计记录压成一行 JSON(含换行;自检直接断言这一行的形状)。 */
|
|
280
|
+
export declare function auditLine(record: ComputerAuditRecord): string;
|
|
281
|
+
/** 追加一行审计(写失败吞掉:审计是辅助面,不该卡住动作)。 */
|
|
282
|
+
export declare function appendComputerAudit(home: string, record: ComputerAuditRecord): void;
|
|
283
|
+
/**
|
|
284
|
+
* 沙箱接入结论(P2-8,如实记录):
|
|
285
|
+
*
|
|
286
|
+
* 现有的沙箱执行缝是 `src/core/tools/command-runner.ts` 的 `planCommand`,
|
|
287
|
+
* 它是为「命令执行工具」换执行体设计的。电脑操作的 PowerShell **不能**走这条缝,原因是
|
|
288
|
+
* 结构性的、不是偷懒:
|
|
289
|
+
* 1. 隔离后端(docker 容器 / Windows 受限令牌)拿不到**交互式用户桌面**——
|
|
290
|
+
* 容器里没有 user32 的桌面对象,受限令牌换了会话也就没有输入注入能力,
|
|
291
|
+
* 真接上去的结果是电脑操作直接不可用;
|
|
292
|
+
* 2. `command-runner` 的 base 计划是「一条 shell 命令」,而电脑操作是一串
|
|
293
|
+
* P/Invoke 脚本,语义对不上(容器后端会把 `powershell -Command <脚本>` 再套一层 shell);
|
|
294
|
+
* 3. 沙箱守卫链按 `input.command` 判 exec 类,`computer` 工具没有 command 参数,
|
|
295
|
+
* 策略层天然看不到它——它不是「漏判」,而是这类动作本就不该由命令沙箱兜。
|
|
296
|
+
* 因此保持现状:电脑操作由审批卡 + 应用白名单 + 危险分级 + 独立审计兜底。
|
|
297
|
+
*/
|
|
298
|
+
export declare const SANDBOX_NOTE = "\u684C\u9762\u63A7\u5236\u7684 PowerShell \u4E0D\u8D70\u547D\u4EE4\u6C99\u7BB1\u6267\u884C\u7F1D\uFF08\u9694\u79BB\u540E\u7AEF\u62FF\u4E0D\u5230\u4EA4\u4E92\u5F0F\u684C\u9762\uFF09\uFF1B\u7531\u5BA1\u6279 + \u767D\u540D\u5355 + \u5371\u9669\u5206\u7EA7 + \u72EC\u7ACB\u5BA1\u8BA1\u515C\u5E95\u3002";
|