@waq666/pneuma 0.0.0-stage → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +206 -3
- package/bin/dsc.js +91 -0
- package/bin/headless.cjs +40 -0
- package/lib/adapter/core-runtime.d.ts +11 -0
- package/lib/adapter/core-runtime.js +259 -0
- package/lib/adapter/host.d.ts +18 -0
- package/lib/adapter/host.js +14 -0
- package/lib/adapter/runtime.d.ts +15 -0
- package/lib/adapter/runtime.js +290 -0
- package/lib/adapter/transcript.d.ts +184 -0
- package/lib/adapter/transcript.js +605 -0
- package/lib/app/AgentsOverlay.d.ts +18 -0
- package/lib/app/AgentsOverlay.js +63 -0
- package/lib/app/App.d.ts +15 -0
- package/lib/app/App.js +1650 -0
- package/lib/app/App.js.nv-backup +1650 -0
- package/lib/app/ApprovalCard.d.ts +12 -0
- package/lib/app/ApprovalCard.js +76 -0
- package/lib/app/AskCard.d.ts +20 -0
- package/lib/app/AskCard.js +45 -0
- package/lib/app/ChatView.d.ts +63 -0
- package/lib/app/ChatView.js +310 -0
- package/lib/app/Composer.d.ts +50 -0
- package/lib/app/Composer.js +282 -0
- package/lib/app/DiffBlock.d.ts +6 -0
- package/lib/app/DiffBlock.js +37 -0
- package/lib/app/MarkdownView.d.ts +6 -0
- package/lib/app/MarkdownView.js +99 -0
- package/lib/app/ModelPicker.d.ts +7 -0
- package/lib/app/ModelPicker.js +18 -0
- package/lib/app/PlanReviewCard.d.ts +13 -0
- package/lib/app/PlanReviewCard.js +54 -0
- package/lib/app/PresetPicker.d.ts +11 -0
- package/lib/app/PresetPicker.js +19 -0
- package/lib/app/PreviewOverlay.d.ts +14 -0
- package/lib/app/PreviewOverlay.js +22 -0
- package/lib/app/SessionPicker.d.ts +43 -0
- package/lib/app/SessionPicker.js +56 -0
- package/lib/app/SettingsOverlay.d.ts +32 -0
- package/lib/app/SettingsOverlay.js +157 -0
- package/lib/app/SkillsPicker.d.ts +7 -0
- package/lib/app/SkillsPicker.js +19 -0
- package/lib/app/StatusBar.d.ts +22 -0
- package/lib/app/StatusBar.js +201 -0
- package/lib/app/TaskStrips.d.ts +13 -0
- package/lib/app/TaskStrips.js +40 -0
- package/lib/app/TimelineRail.d.ts +22 -0
- package/lib/app/TimelineRail.js +160 -0
- package/lib/app/TimelineRail.js.negbak +98 -0
- package/lib/app/TimelineRail.js.nv-backup +160 -0
- package/lib/app/ToolCard.d.ts +11 -0
- package/lib/app/ToolCard.js +64 -0
- package/lib/app/ToolCard.js.nv-backup +64 -0
- package/lib/app/TranscriptOverlay.d.ts +27 -0
- package/lib/app/TranscriptOverlay.js +36 -0
- package/lib/app/TranscriptViewport.d.ts +78 -0
- package/lib/app/TranscriptViewport.js +218 -0
- package/lib/app/Welcome.d.ts +6 -0
- package/lib/app/Welcome.js +71 -0
- package/lib/app/attach.d.ts +16 -0
- package/lib/app/attach.js +58 -0
- package/lib/app/click.d.ts +40 -0
- package/lib/app/click.js +103 -0
- package/lib/app/clipboard-image.d.ts +11 -0
- package/lib/app/clipboard-image.js +66 -0
- package/lib/app/cursor.d.ts +4 -0
- package/lib/app/cursor.js +24 -0
- package/lib/app/hello.d.ts +11 -0
- package/lib/app/hello.js +8 -0
- package/lib/app/history-store.d.ts +4 -0
- package/lib/app/history-store.js +41 -0
- package/lib/app/image-blocks.d.ts +12 -0
- package/lib/app/image-blocks.js +125 -0
- package/lib/app/keymap.d.ts +56 -0
- package/lib/app/keymap.js +56 -0
- package/lib/app/markdown.d.ts +54 -0
- package/lib/app/markdown.js +189 -0
- package/lib/app/mouse.d.ts +33 -0
- package/lib/app/mouse.js +35 -0
- package/lib/app/pointer.d.ts +16 -0
- package/lib/app/pointer.js +60 -0
- package/lib/app/scroll-model.d.ts +240 -0
- package/lib/app/scroll-model.js +347 -0
- package/lib/app/settings-model.d.ts +69 -0
- package/lib/app/settings-model.js +114 -0
- package/lib/app/snapshot-subscribe.d.ts +34 -0
- package/lib/app/snapshot-subscribe.js +110 -0
- package/lib/app/theme.d.ts +194 -0
- package/lib/app/theme.js +186 -0
- package/lib/app/ticker.d.ts +7 -0
- package/lib/app/ticker.js +53 -0
- package/lib/boot.d.ts +1 -0
- package/lib/boot.js +34 -0
- package/lib/commands.d.ts +49 -0
- package/lib/commands.js +115 -0
- package/lib/contract.d.ts +1973 -0
- package/lib/contract.js +36 -0
- package/lib/core/agent-roles.d.ts +52 -0
- package/lib/core/agent-roles.js +274 -0
- package/lib/core/approval-floor.d.ts +183 -0
- package/lib/core/approval-floor.js +679 -0
- package/lib/core/approval.d.ts +42 -0
- package/lib/core/approval.js +8 -0
- package/lib/core/audit.d.ts +61 -0
- package/lib/core/audit.js +59 -0
- package/lib/core/boot-notices.d.ts +6 -0
- package/lib/core/boot-notices.js +61 -0
- package/lib/core/cdp/actions.d.ts +182 -0
- package/lib/core/cdp/actions.js +649 -0
- package/lib/core/cdp/launch.d.ts +192 -0
- package/lib/core/cdp/launch.js +491 -0
- package/lib/core/cdp/snapshot.d.ts +139 -0
- package/lib/core/cdp/snapshot.js +316 -0
- package/lib/core/cdp/transport.d.ts +160 -0
- package/lib/core/cdp/transport.js +359 -0
- package/lib/core/command-policy.d.ts +108 -0
- package/lib/core/command-policy.js +580 -0
- package/lib/core/commands-completion.d.ts +78 -0
- package/lib/core/commands-completion.js +167 -0
- package/lib/core/compact-anchors.d.ts +76 -0
- package/lib/core/compact-anchors.js +284 -0
- package/lib/core/compact.d.ts +110 -0
- package/lib/core/compact.js +210 -0
- package/lib/core/config-store.d.ts +38 -0
- package/lib/core/config-store.js +307 -0
- package/lib/core/config.d.ts +36 -0
- package/lib/core/config.js +124 -0
- package/lib/core/connection-test.d.ts +60 -0
- package/lib/core/connection-test.js +84 -0
- package/lib/core/desktop-control.d.ts +298 -0
- package/lib/core/desktop-control.js +1311 -0
- package/lib/core/diff-text.d.ts +74 -0
- package/lib/core/diff-text.js +257 -0
- package/lib/core/dock-browser.d.ts +137 -0
- package/lib/core/dock-browser.js +146 -0
- package/lib/core/dock-ops.d.ts +59 -0
- package/lib/core/dock-ops.js +104 -0
- package/lib/core/dock-session.d.ts +39 -0
- package/lib/core/dock-session.js +28 -0
- package/lib/core/dsh-compat/hook.d.ts +18 -0
- package/lib/core/dsh-compat/hook.js +52 -0
- package/lib/core/dsh-compat/resolve-hook.d.ts +5 -0
- package/lib/core/dsh-compat/resolve-hook.js +59 -0
- package/lib/core/dsh-compat/tools-facade.d.ts +47 -0
- package/lib/core/dsh-compat/tools-facade.js +108 -0
- package/lib/core/err-text.d.ts +13 -0
- package/lib/core/err-text.js +15 -0
- package/lib/core/events.d.ts +149 -0
- package/lib/core/events.js +1 -0
- package/lib/core/git-exec.d.ts +23 -0
- package/lib/core/git-exec.js +72 -0
- package/lib/core/git-info.d.ts +47 -0
- package/lib/core/git-info.js +157 -0
- package/lib/core/goal.d.ts +89 -0
- package/lib/core/goal.js +189 -0
- package/lib/core/hooks.d.ts +272 -0
- package/lib/core/hooks.js +818 -0
- package/lib/core/host-browser-link.d.ts +59 -0
- package/lib/core/host-browser-link.js +9 -0
- package/lib/core/host-methods.d.ts +25 -0
- package/lib/core/host-methods.js +103 -0
- package/lib/core/image-diet.d.ts +77 -0
- package/lib/core/image-diet.js +127 -0
- package/lib/core/learnings/ledger.d.ts +73 -0
- package/lib/core/learnings/ledger.js +273 -0
- package/lib/core/learnings/skill-write.d.ts +250 -0
- package/lib/core/learnings/skill-write.js +854 -0
- package/lib/core/learnings/store.d.ts +102 -0
- package/lib/core/learnings/store.js +266 -0
- package/lib/core/lifecycle-hooks.d.ts +189 -0
- package/lib/core/lifecycle-hooks.js +576 -0
- package/lib/core/llm.d.ts +283 -0
- package/lib/core/llm.js +565 -0
- package/lib/core/lockfile.d.ts +17 -0
- package/lib/core/lockfile.js +110 -0
- package/lib/core/loop.d.ts +185 -0
- package/lib/core/loop.js +587 -0
- package/lib/core/lsp/client.d.ts +189 -0
- package/lib/core/lsp/client.js +690 -0
- package/lib/core/lsp/framing.d.ts +84 -0
- package/lib/core/lsp/framing.js +181 -0
- package/lib/core/lsp/line-shift.d.ts +28 -0
- package/lib/core/lsp/line-shift.js +127 -0
- package/lib/core/lsp/manager.d.ts +93 -0
- package/lib/core/lsp/manager.js +418 -0
- package/lib/core/lsp/normalize.d.ts +32 -0
- package/lib/core/lsp/normalize.js +139 -0
- package/lib/core/lsp/servers.d.ts +106 -0
- package/lib/core/lsp/servers.js +352 -0
- package/lib/core/lsp/uri.d.ts +76 -0
- package/lib/core/lsp/uri.js +179 -0
- package/lib/core/market.d.ts +51 -0
- package/lib/core/market.js +358 -0
- package/lib/core/mcp.d.ts +201 -0
- package/lib/core/mcp.js +836 -0
- package/lib/core/memory-eval.d.ts +158 -0
- package/lib/core/memory-eval.js +215 -0
- package/lib/core/memory.d.ts +266 -0
- package/lib/core/memory.js +703 -0
- package/lib/core/mention.d.ts +57 -0
- package/lib/core/mention.js +129 -0
- package/lib/core/microcompact.d.ts +48 -0
- package/lib/core/microcompact.js +79 -0
- package/lib/core/migrate.d.ts +56 -0
- package/lib/core/migrate.js +134 -0
- package/lib/core/model-caps.d.ts +83 -0
- package/lib/core/model-caps.js +150 -0
- package/lib/core/model-discovery.d.ts +19 -0
- package/lib/core/model-discovery.js +69 -0
- package/lib/core/modes.d.ts +72 -0
- package/lib/core/modes.js +152 -0
- package/lib/core/native-bridge.d.ts +135 -0
- package/lib/core/native-bridge.js +563 -0
- package/lib/core/path-policy.d.ts +32 -0
- package/lib/core/path-policy.js +248 -0
- package/lib/core/permission-presets.d.ts +67 -0
- package/lib/core/permission-presets.js +75 -0
- package/lib/core/plugin-loader.d.ts +36 -0
- package/lib/core/plugin-loader.js +294 -0
- package/lib/core/plugin-registry.d.ts +113 -0
- package/lib/core/plugin-registry.js +256 -0
- package/lib/core/prefs.d.ts +82 -0
- package/lib/core/prefs.js +372 -0
- package/lib/core/presets.d.ts +80 -0
- package/lib/core/presets.js +373 -0
- package/lib/core/pricing.d.ts +90 -0
- package/lib/core/pricing.js +126 -0
- package/lib/core/prompt.d.ts +92 -0
- package/lib/core/prompt.js +339 -0
- package/lib/core/ptc.d.ts +66 -0
- package/lib/core/ptc.js +70 -0
- package/lib/core/remote/frames.d.ts +91 -0
- package/lib/core/remote/frames.js +174 -0
- package/lib/core/remote/notify.d.ts +54 -0
- package/lib/core/remote/notify.js +77 -0
- package/lib/core/remote/owner.d.ts +32 -0
- package/lib/core/remote/owner.js +75 -0
- package/lib/core/remote/pairing.d.ts +104 -0
- package/lib/core/remote/pairing.js +261 -0
- package/lib/core/remote/push.d.ts +80 -0
- package/lib/core/remote/push.js +222 -0
- package/lib/core/remote/store.d.ts +18 -0
- package/lib/core/remote/store.js +59 -0
- package/lib/core/remote/tickets.d.ts +20 -0
- package/lib/core/remote/tickets.js +49 -0
- package/lib/core/remote/uploads.d.ts +63 -0
- package/lib/core/remote/uploads.js +161 -0
- package/lib/core/request-attribution.d.ts +26 -0
- package/lib/core/request-attribution.js +86 -0
- package/lib/core/request-invariant.d.ts +61 -0
- package/lib/core/request-invariant.js +199 -0
- package/lib/core/sandbox/backends.d.ts +64 -0
- package/lib/core/sandbox/backends.js +194 -0
- package/lib/core/sandbox/execpolicy.d.ts +93 -0
- package/lib/core/sandbox/execpolicy.js +452 -0
- package/lib/core/sandbox/net-proxy.d.ts +31 -0
- package/lib/core/sandbox/net-proxy.js +162 -0
- package/lib/core/sandbox/policy.d.ts +211 -0
- package/lib/core/sandbox/policy.js +559 -0
- package/lib/core/sandbox/win/abi.d.ts +161 -0
- package/lib/core/sandbox/win/abi.js +169 -0
- package/lib/core/sandbox/win/account.d.ts +71 -0
- package/lib/core/sandbox/win/account.js +206 -0
- package/lib/core/sandbox/win/acl.d.ts +54 -0
- package/lib/core/sandbox/win/acl.js +339 -0
- package/lib/core/sandbox/win/backend.d.ts +61 -0
- package/lib/core/sandbox/win/backend.js +249 -0
- package/lib/core/sandbox/win/doctor.d.ts +24 -0
- package/lib/core/sandbox/win/doctor.js +272 -0
- package/lib/core/sandbox/win/ffi.d.ts +107 -0
- package/lib/core/sandbox/win/ffi.js +166 -0
- package/lib/core/sandbox/win/net-abi.d.ts +154 -0
- package/lib/core/sandbox/win/net-abi.js +316 -0
- package/lib/core/sandbox/win/runner-entry.d.ts +35 -0
- package/lib/core/sandbox/win/runner-entry.js +391 -0
- package/lib/core/sandbox/win/setup.d.ts +60 -0
- package/lib/core/sandbox/win/setup.js +986 -0
- package/lib/core/sandbox/win/token.d.ts +35 -0
- package/lib/core/sandbox/win/token.js +238 -0
- package/lib/core/sandbox/win/wfp.d.ts +41 -0
- package/lib/core/sandbox/win/wfp.js +200 -0
- package/lib/core/sandbox/win/workspace-sid.d.ts +9 -0
- package/lib/core/sandbox/win/workspace-sid.js +45 -0
- package/lib/core/schedule/rule.d.ts +184 -0
- package/lib/core/schedule/rule.js +745 -0
- package/lib/core/schedule/runner.d.ts +185 -0
- package/lib/core/schedule/runner.js +678 -0
- package/lib/core/schedule/store.d.ts +182 -0
- package/lib/core/schedule/store.js +455 -0
- package/lib/core/secrets.d.ts +41 -0
- package/lib/core/secrets.js +150 -0
- package/lib/core/session-export.d.ts +18 -0
- package/lib/core/session-export.js +73 -0
- package/lib/core/session-index.d.ts +159 -0
- package/lib/core/session-index.js +683 -0
- package/lib/core/session-meta.d.ts +41 -0
- package/lib/core/session-meta.js +97 -0
- package/lib/core/session.d.ts +356 -0
- package/lib/core/session.js +998 -0
- package/lib/core/skills.d.ts +60 -0
- package/lib/core/skills.js +171 -0
- package/lib/core/spill.d.ts +159 -0
- package/lib/core/spill.js +329 -0
- package/lib/core/surface-registry.d.ts +45 -0
- package/lib/core/surface-registry.js +67 -0
- package/lib/core/team-board.d.ts +95 -0
- package/lib/core/team-board.js +316 -0
- package/lib/core/throughput.d.ts +46 -0
- package/lib/core/throughput.js +40 -0
- package/lib/core/todo-reminder.d.ts +44 -0
- package/lib/core/todo-reminder.js +55 -0
- package/lib/core/todo.d.ts +81 -0
- package/lib/core/todo.js +222 -0
- package/lib/core/token-estimate.d.ts +55 -0
- package/lib/core/token-estimate.js +82 -0
- package/lib/core/tool-guards.d.ts +103 -0
- package/lib/core/tool-guards.js +77 -0
- package/lib/core/tool-search.d.ts +152 -0
- package/lib/core/tool-search.js +311 -0
- package/lib/core/tools/bash.d.ts +281 -0
- package/lib/core/tools/bash.js +871 -0
- package/lib/core/tools/command-runner.d.ts +84 -0
- package/lib/core/tools/command-runner.js +68 -0
- package/lib/core/tools/fs-tools.d.ts +23 -0
- package/lib/core/tools/fs-tools.js +247 -0
- package/lib/core/tools/index.d.ts +8 -0
- package/lib/core/tools/index.js +4 -0
- package/lib/core/tools/sandbox-args.d.ts +51 -0
- package/lib/core/tools/sandbox-args.js +90 -0
- package/lib/core/tools/search-tools.d.ts +3 -0
- package/lib/core/tools/search-tools.js +153 -0
- package/lib/core/tools.d.ts +96 -0
- package/lib/core/tools.js +53 -0
- package/lib/core/ui-boot-source.d.ts +71 -0
- package/lib/core/ui-boot-source.js +121 -0
- package/lib/core/ui-bundles.d.ts +249 -0
- package/lib/core/ui-bundles.js +830 -0
- package/lib/core/ui-combo.d.ts +49 -0
- package/lib/core/ui-combo.js +55 -0
- package/lib/core/ui-events.d.ts +81 -0
- package/lib/core/ui-events.js +364 -0
- package/lib/core/ui-hmr.d.ts +36 -0
- package/lib/core/ui-hmr.js +128 -0
- package/lib/core/ui-methods.d.ts +69 -0
- package/lib/core/ui-methods.js +341 -0
- package/lib/core/ui-route.d.ts +69 -0
- package/lib/core/ui-route.js +122 -0
- package/lib/core/ui-server.d.ts +75 -0
- package/lib/core/ui-server.js +369 -0
- package/lib/core/ui-trust.d.ts +47 -0
- package/lib/core/ui-trust.js +164 -0
- package/lib/core/untrusted.d.ts +30 -0
- package/lib/core/untrusted.js +48 -0
- package/lib/core/update-check.d.ts +81 -0
- package/lib/core/update-check.js +177 -0
- package/lib/core/usage-log.d.ts +82 -0
- package/lib/core/usage-log.js +306 -0
- package/lib/core/version.d.ts +1 -0
- package/lib/core/version.js +37 -0
- package/lib/core/web-http.d.ts +57 -0
- package/lib/core/web-http.js +137 -0
- package/lib/core/web-static.d.ts +31 -0
- package/lib/core/web-static.js +75 -0
- package/lib/headless.d.ts +1 -0
- package/lib/headless.js +31 -0
- package/lib/host/kernel.d.ts +33 -0
- package/lib/host/kernel.js +451 -0
- package/lib/index.d.ts +41 -0
- package/lib/index.js +35 -0
- package/lib/plugins/agent.d.ts +2 -0
- package/lib/plugins/agent.js +274 -0
- package/lib/plugins/approval-floor.d.ts +2 -0
- package/lib/plugins/approval-floor.js +223 -0
- package/lib/plugins/approval.d.ts +16 -0
- package/lib/plugins/approval.js +674 -0
- package/lib/plugins/ask.d.ts +2 -0
- package/lib/plugins/ask.js +245 -0
- package/lib/plugins/browser.d.ts +68 -0
- package/lib/plugins/browser.js +1341 -0
- package/lib/plugins/commands.d.ts +23 -0
- package/lib/plugins/commands.js +498 -0
- package/lib/plugins/compact.d.ts +21 -0
- package/lib/plugins/compact.js +274 -0
- package/lib/plugins/computer-use.d.ts +47 -0
- package/lib/plugins/computer-use.js +539 -0
- package/lib/plugins/desktop-dock.d.ts +2 -0
- package/lib/plugins/desktop-dock.js +626 -0
- package/lib/plugins/dock-browser.d.ts +34 -0
- package/lib/plugins/dock-browser.js +765 -0
- package/lib/plugins/dsh-compat.d.ts +25 -0
- package/lib/plugins/dsh-compat.js +37 -0
- package/lib/plugins/file-review.d.ts +108 -0
- package/lib/plugins/file-review.js +393 -0
- package/lib/plugins/git.d.ts +26 -0
- package/lib/plugins/git.js +132 -0
- package/lib/plugins/goal.d.ts +20 -0
- package/lib/plugins/goal.js +245 -0
- package/lib/plugins/guards.d.ts +14 -0
- package/lib/plugins/guards.js +18 -0
- package/lib/plugins/hooks.d.ts +19 -0
- package/lib/plugins/hooks.js +583 -0
- package/lib/plugins/host-stdio.d.ts +88 -0
- package/lib/plugins/host-stdio.js +317 -0
- package/lib/plugins/image-diet.d.ts +17 -0
- package/lib/plugins/image-diet.js +85 -0
- package/lib/plugins/lifecycle-hooks.d.ts +26 -0
- package/lib/plugins/lifecycle-hooks.js +338 -0
- package/lib/plugins/llm.d.ts +13 -0
- package/lib/plugins/llm.js +215 -0
- package/lib/plugins/lsp.d.ts +54 -0
- package/lib/plugins/lsp.js +608 -0
- package/lib/plugins/mcp.d.ts +16 -0
- package/lib/plugins/mcp.js +673 -0
- package/lib/plugins/memory.d.ts +17 -0
- package/lib/plugins/memory.js +858 -0
- package/lib/plugins/microcompact.d.ts +18 -0
- package/lib/plugins/microcompact.js +119 -0
- package/lib/plugins/mode.d.ts +18 -0
- package/lib/plugins/mode.js +115 -0
- package/lib/plugins/permission-presets.d.ts +18 -0
- package/lib/plugins/permission-presets.js +135 -0
- package/lib/plugins/plan.d.ts +2 -0
- package/lib/plugins/plan.js +192 -0
- package/lib/plugins/plugin-manager.d.ts +2 -0
- package/lib/plugins/plugin-manager.js +165 -0
- package/lib/plugins/presets.d.ts +2 -0
- package/lib/plugins/presets.js +182 -0
- package/lib/plugins/prompt.d.ts +2 -0
- package/lib/plugins/prompt.js +264 -0
- package/lib/plugins/ptc.d.ts +2 -0
- package/lib/plugins/ptc.js +272 -0
- package/lib/plugins/remote/http.d.ts +11 -0
- package/lib/plugins/remote/http.js +11 -0
- package/lib/plugins/remote/routes.d.ts +24 -0
- package/lib/plugins/remote/routes.js +384 -0
- package/lib/plugins/remote/types.d.ts +135 -0
- package/lib/plugins/remote/types.js +87 -0
- package/lib/plugins/remote.d.ts +17 -0
- package/lib/plugins/remote.js +1028 -0
- package/lib/plugins/runtime-api.d.ts +16 -0
- package/lib/plugins/runtime-api.js +99 -0
- package/lib/plugins/runtime.d.ts +10 -0
- package/lib/plugins/runtime.js +451 -0
- package/lib/plugins/sandbox.d.ts +2 -0
- package/lib/plugins/sandbox.js +761 -0
- package/lib/plugins/schedule.d.ts +26 -0
- package/lib/plugins/schedule.js +538 -0
- package/lib/plugins/self-improve.d.ts +61 -0
- package/lib/plugins/self-improve.js +953 -0
- package/lib/plugins/session-search.d.ts +16 -0
- package/lib/plugins/session-search.js +308 -0
- package/lib/plugins/session-title.d.ts +19 -0
- package/lib/plugins/session-title.js +109 -0
- package/lib/plugins/session.d.ts +7 -0
- package/lib/plugins/session.js +296 -0
- package/lib/plugins/settings.d.ts +3 -0
- package/lib/plugins/settings.js +705 -0
- package/lib/plugins/skills.d.ts +2 -0
- package/lib/plugins/skills.js +360 -0
- package/lib/plugins/spill.d.ts +16 -0
- package/lib/plugins/spill.js +200 -0
- package/lib/plugins/subagent.d.ts +2 -0
- package/lib/plugins/subagent.js +896 -0
- package/lib/plugins/surfaces.d.ts +11 -0
- package/lib/plugins/surfaces.js +20 -0
- package/lib/plugins/team.d.ts +16 -0
- package/lib/plugins/team.js +149 -0
- package/lib/plugins/todo.d.ts +19 -0
- package/lib/plugins/todo.js +188 -0
- package/lib/plugins/tool-search.d.ts +2 -0
- package/lib/plugins/tool-search.js +434 -0
- package/lib/plugins/tool-search.js.nv-backup +434 -0
- package/lib/plugins/tools-default.d.ts +12 -0
- package/lib/plugins/tools-default.js +275 -0
- package/lib/plugins/tools.d.ts +16 -0
- package/lib/plugins/tools.js +62 -0
- package/lib/plugins/transcript.d.ts +15 -0
- package/lib/plugins/transcript.js +311 -0
- package/lib/plugins/tui.d.ts +2 -0
- package/lib/plugins/tui.js +98 -0
- package/lib/plugins/waiting.d.ts +12 -0
- package/lib/plugins/waiting.js +34 -0
- package/lib/plugins/web-search.d.ts +14 -0
- package/lib/plugins/web-search.js +263 -0
- package/lib/plugins/webserver.d.ts +48 -0
- package/lib/plugins/webserver.js +228 -0
- package/lib/remote/assets/app-DAcUCOEn.js +14 -0
- package/lib/remote/assets/icon-192.png +0 -0
- package/lib/remote/assets/icon-512.png +0 -0
- package/lib/remote/assets/index.html +34 -0
- package/lib/remote/assets/manifest.json +27 -0
- package/lib/remote/assets/style-DIB6729x.css +1 -0
- package/lib/remote/assets/sw.js +66 -0
- package/lib/services/types.d.ts +1228 -0
- package/lib/services/types.js +1 -0
- package/lib/tools/config-cli.d.ts +1 -0
- package/lib/tools/config-cli.js +89 -0
- package/lib/ui/arrival.d.ts +72 -0
- package/lib/ui/arrival.js +105 -0
- package/lib/ui/assets/app-B70nVIKd.js +69 -0
- package/lib/ui/assets/chunk-2UxHyX5q.js +1 -0
- package/lib/ui/assets/chunk-B1dDrJ26.js +1 -0
- package/lib/ui/assets/chunk-B6aJPvgy.js +1 -0
- package/lib/ui/assets/chunk-BEwlwnbL.js +1 -0
- package/lib/ui/assets/chunk-BGcgwlCI.js +12 -0
- package/lib/ui/assets/chunk-BIGW1oBm.js +1 -0
- package/lib/ui/assets/chunk-BPQ3VLAy.js +1 -0
- package/lib/ui/assets/chunk-BRH0KZbk.js +141 -0
- package/lib/ui/assets/chunk-BX6H_ySx.js +1 -0
- package/lib/ui/assets/chunk-B_P3UbPa.js +1 -0
- package/lib/ui/assets/chunk-B_TYUkTI.js +1 -0
- package/lib/ui/assets/chunk-B_vNuMnf.js +1 -0
- package/lib/ui/assets/chunk-BajyYBss.js +10 -0
- package/lib/ui/assets/chunk-BdnUsdx6.js +1 -0
- package/lib/ui/assets/chunk-Buea-lGh.js +1 -0
- package/lib/ui/assets/chunk-C0PvZCCE.js +1 -0
- package/lib/ui/assets/chunk-C0m74zRD.js +1 -0
- package/lib/ui/assets/chunk-C27-OAKa.js +1 -0
- package/lib/ui/assets/chunk-C2oV4EkX.js +1 -0
- package/lib/ui/assets/chunk-C7zT0LnQ.js +1 -0
- package/lib/ui/assets/chunk-C9GSunVT.js +1 -0
- package/lib/ui/assets/chunk-C9tS-k6U.js +1 -0
- package/lib/ui/assets/chunk-CHLpvVh8.js +1 -0
- package/lib/ui/assets/chunk-CLxacb5B.js +1 -0
- package/lib/ui/assets/chunk-COt5Ahok.js +1 -0
- package/lib/ui/assets/chunk-CPTIWCL2.js +1 -0
- package/lib/ui/assets/chunk-CQLl-L-p.js +1 -0
- package/lib/ui/assets/chunk-CUWRgxuq.js +55 -0
- package/lib/ui/assets/chunk-CWanVSXC.js +1 -0
- package/lib/ui/assets/chunk-Cf5RLm7j.js +1 -0
- package/lib/ui/assets/chunk-CickPsom.js +1 -0
- package/lib/ui/assets/chunk-Cj5Yp3dK.js +1 -0
- package/lib/ui/assets/chunk-Cmh6b_Ma.js +1 -0
- package/lib/ui/assets/chunk-Cp-IABpG.js +1 -0
- package/lib/ui/assets/chunk-CqE71os6.js +1 -0
- package/lib/ui/assets/chunk-CtKP3W-j.js +1 -0
- package/lib/ui/assets/chunk-Cvjx9yec.js +1 -0
- package/lib/ui/assets/chunk-CxGP3dtY.js +1 -0
- package/lib/ui/assets/chunk-CylS5w8V.js +1 -0
- package/lib/ui/assets/chunk-D38fbIBN.js +1 -0
- package/lib/ui/assets/chunk-D97Zzqfu.js +1 -0
- package/lib/ui/assets/chunk-DAi9KRSo.js +1 -0
- package/lib/ui/assets/chunk-DHK4yRfg.js +1 -0
- package/lib/ui/assets/chunk-DJeabLx-.js +1 -0
- package/lib/ui/assets/chunk-DNRxmY5a.js +1 -0
- package/lib/ui/assets/chunk-DNSN1z5r.js +1 -0
- package/lib/ui/assets/chunk-DNasK_ZG.js +1 -0
- package/lib/ui/assets/chunk-DPvrY3IQ.js +1 -0
- package/lib/ui/assets/chunk-DXmwc3jG.js +1 -0
- package/lib/ui/assets/chunk-Dd0kTxKP.js +1 -0
- package/lib/ui/assets/chunk-De0Btta0.js +1 -0
- package/lib/ui/assets/chunk-Des-eS-w.js +1 -0
- package/lib/ui/assets/chunk-Df6bDoY_.js +1 -0
- package/lib/ui/assets/chunk-DijEV5ha.js +1 -0
- package/lib/ui/assets/chunk-DkvoVjww.js +1 -0
- package/lib/ui/assets/chunk-DlC-OlHO.js +1 -0
- package/lib/ui/assets/chunk-DnzrXTVv.js +1 -0
- package/lib/ui/assets/chunk-Dualf0xi.js +1 -0
- package/lib/ui/assets/chunk-EXT84bkm.js +1 -0
- package/lib/ui/assets/chunk-GwR3hkPK.js +1 -0
- package/lib/ui/assets/chunk-P80f7IUj.js +1 -0
- package/lib/ui/assets/chunk-VOosw3JB.js +1 -0
- package/lib/ui/assets/chunk-YQ4lDkt_.js +140 -0
- package/lib/ui/assets/chunk-Yzrsuije.js +1 -0
- package/lib/ui/assets/chunk-Z72CF80r.js +1 -0
- package/lib/ui/assets/chunk-g9-lgVsj.js +1 -0
- package/lib/ui/assets/chunk-vGWfd6FD.js +1 -0
- package/lib/ui/assets/chunk-wDzz0qaB.js +1 -0
- package/lib/ui/assets/chunk-ySF7HWmS.js +1 -0
- package/lib/ui/assets/icon.png +0 -0
- package/lib/ui/assets/index.html +14 -0
- package/lib/ui/assets/pdf.worker.min-CjEcRF4W.mjs +28 -0
- package/lib/ui/assets/style-Bq01xH_b.css +1 -0
- package/lib/ui/frames.d.ts +67 -0
- package/lib/ui/frames.js +146 -0
- package/lib/ui/index.d.ts +59 -0
- package/lib/ui/index.js +50 -0
- package/lib/ui/manifest.d.ts +172 -0
- package/lib/ui/manifest.js +158 -0
- package/lib/ui/plugin.d.ts +161 -0
- package/lib/ui/plugin.js +7 -0
- package/lib/ui/plugins/browser/client.js +290 -0
- package/lib/ui/plugins/browser/icon.png +0 -0
- package/lib/ui/plugins/composer/client.js +1843 -0
- package/lib/ui/plugins/composer/icon.png +0 -0
- package/lib/ui/plugins/files/client.js +646 -0
- package/lib/ui/plugins/files/icon.png +0 -0
- package/lib/ui/plugins/manifest.json +107 -0
- package/lib/ui/plugins/plugins/client.js +682 -0
- package/lib/ui/plugins/plugins/icon.png +0 -0
- package/lib/ui/plugins/preview/client.js +197 -0
- package/lib/ui/plugins/preview/icon.png +0 -0
- package/lib/ui/plugins/prompt/client.js +653 -0
- package/lib/ui/plugins/prompt/icon.png +0 -0
- package/lib/ui/plugins/sessions/client.js +1577 -0
- package/lib/ui/plugins/sessions/icon.png +0 -0
- package/lib/ui/plugins/settings/client.js +5470 -0
- package/lib/ui/plugins/settings/icon.png +0 -0
- package/lib/ui/plugins/skills/client.js +485 -0
- package/lib/ui/plugins/skills/icon.png +0 -0
- package/lib/ui/plugins/status/client.js +1420 -0
- package/lib/ui/plugins/status/icon.png +0 -0
- package/lib/ui/plugins/statusbar/client.js +504 -0
- package/lib/ui/plugins/statusbar/icon.png +0 -0
- package/lib/ui/plugins/tasks/client.js +52 -0
- package/lib/ui/plugins/tasks/icon.png +0 -0
- package/lib/ui/plugins/team/client.js +527 -0
- package/lib/ui/plugins/team/icon.png +0 -0
- package/lib/ui/plugins/terminal/client.js +232 -0
- package/lib/ui/plugins/terminal/icon.png +0 -0
- package/lib/ui/plugins/trace/client.js +1376 -0
- package/lib/ui/plugins/trace/icon.png +0 -0
- package/lib/ui/plugins/transcript/client.js +2661 -0
- package/lib/ui/plugins/transcript/icon.png +0 -0
- package/lib/ui/scoped-slots.d.ts +20 -0
- package/lib/ui/scoped-slots.js +21 -0
- package/lib/ui/sdk/@dsc/ui/index.d.ts +242 -0
- package/lib/ui/sdk/@dsc/ui/package.json +16 -0
- package/lib/ui/sdk/@dsc/ui-core/contract.d.ts +1973 -0
- package/lib/ui/sdk/@dsc/ui-core/core/diff-text.d.ts +74 -0
- package/lib/ui/sdk/@dsc/ui-core/core/dock-browser.d.ts +137 -0
- package/lib/ui/sdk/@dsc/ui-core/core/dock-ops.d.ts +59 -0
- package/lib/ui/sdk/@dsc/ui-core/core/model-caps.d.ts +83 -0
- package/lib/ui/sdk/@dsc/ui-core/core/native-bridge.d.ts +135 -0
- package/lib/ui/sdk/@dsc/ui-core/core/token-estimate.d.ts +55 -0
- package/lib/ui/sdk/@dsc/ui-core/package.json +16 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/arrival.d.ts +72 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/frames.d.ts +67 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/index.d.ts +59 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/manifest.d.ts +172 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/plugin.d.ts +161 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/scoped-slots.d.ts +20 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/services-react.d.ts +27 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/services.d.ts +63 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/slots-react.d.ts +28 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/slots.d.ts +481 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/store.d.ts +89 -0
- package/lib/ui/sdk/@dsc/ui-dockkit/dock-model.d.ts +238 -0
- package/lib/ui/sdk/@dsc/ui-dockkit/dock-state.d.ts +163 -0
- package/lib/ui/sdk/@dsc/ui-dockkit/dock.d.ts +24 -0
- package/lib/ui/sdk/@dsc/ui-dockkit/index.d.ts +15 -0
- package/lib/ui/sdk/@dsc/ui-dockkit/package.json +16 -0
- package/lib/ui/sdk/@dsc/ui-layout/app.d.ts +74 -0
- package/lib/ui/sdk/@dsc/ui-layout/appearance.d.ts +70 -0
- package/lib/ui/sdk/@dsc/ui-layout/host-channel.d.ts +112 -0
- package/lib/ui/sdk/@dsc/ui-layout/index.d.ts +34 -0
- package/lib/ui/sdk/@dsc/ui-layout/package.json +16 -0
- package/lib/ui/sdk/@dsc/ui-layout/page-state.d.ts +14 -0
- package/lib/ui/sdk/@dsc/ui-layout/review-pane.d.ts +21 -0
- package/lib/ui/sdk/@dsc/ui-layout/runtime-context.d.ts +44 -0
- package/lib/ui/sdk/@dsc/ui-layout/thread-view.d.ts +28 -0
- package/lib/ui/sdk/@dsc/ui-layout/update-button.d.ts +21 -0
- package/lib/ui/sdk/@dsc/ui-primitives/code-file-icon-artwork.d.ts +53 -0
- package/lib/ui/sdk/@dsc/ui-primitives/code-view.d.ts +15 -0
- package/lib/ui/sdk/@dsc/ui-primitives/compat.d.ts +27 -0
- package/lib/ui/sdk/@dsc/ui-primitives/completion-sound.d.ts +24 -0
- package/lib/ui/sdk/@dsc/ui-primitives/confirm.d.ts +33 -0
- package/lib/ui/sdk/@dsc/ui-primitives/css.d.ts +47 -0
- package/lib/ui/sdk/@dsc/ui-primitives/diff-rows.d.ts +20 -0
- package/lib/ui/sdk/@dsc/ui-primitives/file-icons.d.ts +38 -0
- package/lib/ui/sdk/@dsc/ui-primitives/file-type-classify.d.ts +66 -0
- package/lib/ui/sdk/@dsc/ui-primitives/file-type-icon.d.ts +57 -0
- package/lib/ui/sdk/@dsc/ui-primitives/highlight.d.ts +24 -0
- package/lib/ui/sdk/@dsc/ui-primitives/hover-delay.d.ts +17 -0
- package/lib/ui/sdk/@dsc/ui-primitives/icons.d.ts +109 -0
- package/lib/ui/sdk/@dsc/ui-primitives/index.d.ts +55 -0
- package/lib/ui/sdk/@dsc/ui-primitives/lang-table.d.ts +10 -0
- package/lib/ui/sdk/@dsc/ui-primitives/markdown.d.ts +20 -0
- package/lib/ui/sdk/@dsc/ui-primitives/native.d.ts +41 -0
- package/lib/ui/sdk/@dsc/ui-primitives/package.json +16 -0
- package/lib/ui/sdk/@dsc/ui-primitives/panels.d.ts +86 -0
- package/lib/ui/sdk/@dsc/ui-primitives/paths.d.ts +11 -0
- package/lib/ui/sdk/@dsc/ui-primitives/pdf-view.d.ts +13 -0
- package/lib/ui/sdk/@dsc/ui-primitives/plugin-text.d.ts +15 -0
- package/lib/ui/sdk/@dsc/ui-primitives/select.d.ts +35 -0
- package/lib/ui/sdk/@dsc/ui-primitives/table-view.d.ts +23 -0
- package/lib/ui/sdk/@dsc/ui-primitives/thread-resizer.d.ts +22 -0
- package/lib/ui/sdk/@dsc/ui-primitives/time.d.ts +33 -0
- package/lib/ui/sdk/@dsc/ui-primitives/toast.d.ts +16 -0
- package/lib/ui/sdk/@dsc/ui-primitives/tokens.d.ts +14 -0
- package/lib/ui/sdk/@dsc/ui-primitives/tool-args.d.ts +49 -0
- package/lib/ui/sdk/@dsc/ui-primitives/tool-summary.d.ts +64 -0
- package/lib/ui/sdk/@dsc/ui-renderer/boot.d.ts +121 -0
- package/lib/ui/sdk/@dsc/ui-renderer/hmr.d.ts +43 -0
- package/lib/ui/sdk/@dsc/ui-renderer/index.d.ts +20 -0
- package/lib/ui/sdk/@dsc/ui-renderer/package.json +16 -0
- package/lib/ui/sdk/@dsc/ui-slots/index.d.ts +19 -0
- package/lib/ui/sdk/@dsc/ui-slots/package.json +16 -0
- package/lib/ui/sdk/@dsc/ui-slots/slots-react.d.ts +48 -0
- package/lib/ui/sdk/@dsc/ui-slots/slots.d.ts +102 -0
- package/lib/ui/services-react.d.ts +27 -0
- package/lib/ui/services-react.js +32 -0
- package/lib/ui/services.d.ts +63 -0
- package/lib/ui/services.js +121 -0
- package/lib/ui/slots-ink.d.ts +26 -0
- package/lib/ui/slots-ink.js +78 -0
- package/lib/ui/slots-react.d.ts +28 -0
- package/lib/ui/slots-react.js +88 -0
- package/lib/ui/slots.d.ts +481 -0
- package/lib/ui/slots.js +550 -0
- package/lib/ui/store.d.ts +89 -0
- package/lib/ui/store.js +62 -0
- package/lib/ui/tui-plugin-api.d.ts +23 -0
- package/lib/ui/tui-plugin-api.js +23 -0
- package/lib/ui/tui-plugins.d.ts +47 -0
- package/lib/ui/tui-plugins.js +220 -0
- package/package.json +58 -6
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 沙箱 runner 子进程入口:dsc 宿主 spawn 这个脚本(普通权限),由它在**本进程内**
|
|
3
|
+
* 构造受限令牌并 `CreateProcessAsUserW` 真正的命令。
|
|
4
|
+
*
|
|
5
|
+
* 为什么隔一层 runner(三个理由都有实测依据):
|
|
6
|
+
* 1. `lpEnvironment` 经 koffi 传显式环境块必报 ERROR_INVALID_PARAMETER——子进程环境
|
|
7
|
+
* 只能靠继承;TMP/TEMP 重定向要在「不污染宿主环境」的前提下生效,只能由一个
|
|
8
|
+
* 短命进程改自己再 spawn(runner 干的就是这个);
|
|
9
|
+
* 2. runner 忽略 CTRL+C(SetConsoleCtrlHandler),保证被中断时能把子进程的收尾做完、
|
|
10
|
+
* 把退出码原样镜像回去;
|
|
11
|
+
* 3. 作业对象句柄随 runner 死亡而关闭(KILL_ON_JOB_CLOSE):宿主 taskkill 杀 runner
|
|
12
|
+
* 就等于整棵受限子树被内核收掉,不留孤儿。
|
|
13
|
+
*
|
|
14
|
+
* argv 契约(宿主负责拼,runner 负责逐项验):
|
|
15
|
+
* node runner-entry.js --mode <read-only|workspace-write> --temp <dir>
|
|
16
|
+
* [--root <sid>=<dir> …] -- <argv…>
|
|
17
|
+
*
|
|
18
|
+
* 失败语义:runner 自身的问题打一行 `dsc-sandbox-run: …` 到 stderr 并退出 127;
|
|
19
|
+
* 受限命令的退出码按**全宽 uint32** 原样镜像(NTSTATUS 不做有符号重映射)。
|
|
20
|
+
*
|
|
21
|
+
* 几处踩过坑的硬约束(都别改):
|
|
22
|
+
* - 绝不用 CREATE_NO_WINDOW / CREATE_NEW_CONSOLE:受限令牌下 DLL 初始化会死
|
|
23
|
+
* 0xC0000142,只能 STARTF_USESHOWWINDOW + SW_HIDE;
|
|
24
|
+
* - 先排水后 WaitForSingleObject:管道缓冲填满时先 wait 会双方死锁;
|
|
25
|
+
* - AssignProcessToJobObject 必须在 ResumeThread **之前**:不受作业保护的受限进程
|
|
26
|
+
* 一秒都不许跑。
|
|
27
|
+
*
|
|
28
|
+
* @module dsc/core/sandbox/win/runner-entry
|
|
29
|
+
*/
|
|
30
|
+
import { CREATE_SUSPENDED, INFINITE, JOBOBJ_LIMIT_FLAGS_OFFSET, JOBOBJECT_EXTENDED_LIMIT_SIZE, JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE, JobObjectExtendedLimitInformation, LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, PI_OFFSETS, PROCESS_INFORMATION_SIZE, SI_OFFSETS, STARTF_USESHOWWINDOW, STARTF_USESTDHANDLES, STARTUPINFOW_SIZE, SW_HIDE, WAIT_OBJECT_0, } from './abi.js';
|
|
31
|
+
import { bindAll, byteArea, isBrokenPipe, loadFfi, slotUint32, slotUintPtr, throwLastError, throwWin32, } from './ffi.js';
|
|
32
|
+
import { buildRestrictedToken } from './token.js';
|
|
33
|
+
import { verifySidForPath } from './workspace-sid.js';
|
|
34
|
+
import { accountBlobPath, unprotectSecret } from './account.js';
|
|
35
|
+
import { readFileSync } from 'node:fs';
|
|
36
|
+
/** runner 自身失败签名(宿主诊断认这一行)。 */
|
|
37
|
+
export const RUNNER_SIGNATURE = 'dsc-sandbox-run: ';
|
|
38
|
+
/** runner 自身失败的退出码。 */
|
|
39
|
+
export const RUNNER_EXIT_CODE = 127;
|
|
40
|
+
/** 管道排水每次最多读的字节数(64KB,够填一页还不够撑爆内存)。 */
|
|
41
|
+
const DRAIN_CHUNK = 65536;
|
|
42
|
+
/** SetHandleInformation 的「可继承」标志位。 */
|
|
43
|
+
const HANDLE_FLAG_INHERIT = 1;
|
|
44
|
+
/** 严格解析并校验 argv:任何不认识、缺项、对不上号的输入都算 runner 失败,绝不猜。 */
|
|
45
|
+
export function parseRunnerArgs(argv) {
|
|
46
|
+
let mode;
|
|
47
|
+
let tempDir;
|
|
48
|
+
let account;
|
|
49
|
+
let dscHome;
|
|
50
|
+
const roots = [];
|
|
51
|
+
const separator = argv.indexOf('--');
|
|
52
|
+
if (separator < 0)
|
|
53
|
+
throw new Error('argv 缺少 `--` 分隔符(后面必须跟受限命令)');
|
|
54
|
+
const flags = argv.slice(0, separator);
|
|
55
|
+
const childArgv = argv.slice(separator + 1);
|
|
56
|
+
if (childArgv.length === 0)
|
|
57
|
+
throw new Error('`--` 之后没有受限命令');
|
|
58
|
+
if (childArgv[0] === undefined || childArgv[0] === '')
|
|
59
|
+
throw new Error('`--` 之后的第一个参数必须是非空可执行文件名');
|
|
60
|
+
for (let index = 0; index < flags.length; index += 1) {
|
|
61
|
+
const flag = flags[index];
|
|
62
|
+
if (flag === '--mode') {
|
|
63
|
+
const value = flags[++index];
|
|
64
|
+
if (value !== 'read-only' && value !== 'workspace-write') {
|
|
65
|
+
throw new Error(`--mode 只认 read-only / workspace-write,收到「${String(value)}」`);
|
|
66
|
+
}
|
|
67
|
+
mode = value;
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
if (flag === '--temp') {
|
|
71
|
+
const value = flags[++index];
|
|
72
|
+
if (value === undefined || value === '')
|
|
73
|
+
throw new Error('--temp 需要一个非空目录');
|
|
74
|
+
// 同一个 flag 给两次是调用方 bug:静默取后者等于悄悄换了 TMP/TEMP 落点
|
|
75
|
+
if (tempDir !== undefined)
|
|
76
|
+
throw new Error('--temp 给重复了');
|
|
77
|
+
tempDir = value;
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
if (flag === '--root') {
|
|
81
|
+
const pair = flags[++index];
|
|
82
|
+
if (pair === undefined)
|
|
83
|
+
throw new Error('--root 需要 <sid>=<dir>');
|
|
84
|
+
const eq = pair.indexOf('=');
|
|
85
|
+
if (eq <= 0)
|
|
86
|
+
throw new Error(`--root 的值要写成 <sid>=<dir>,收到「${pair}」`);
|
|
87
|
+
const sid = pair.slice(0, eq);
|
|
88
|
+
const path = pair.slice(eq + 1);
|
|
89
|
+
if (path === '')
|
|
90
|
+
throw new Error(`--root 的目录是空的:「${pair}」`);
|
|
91
|
+
roots.push({ sid, path });
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
if (flag === '--account') {
|
|
95
|
+
const value = flags[++index];
|
|
96
|
+
if (value === undefined || value === '')
|
|
97
|
+
throw new Error('--account 需要一个账号名');
|
|
98
|
+
if (account !== undefined)
|
|
99
|
+
throw new Error('--account 给重复了');
|
|
100
|
+
account = { name: value, dscHome: '' };
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
if (flag === '--dsc-home') {
|
|
104
|
+
const value = flags[++index];
|
|
105
|
+
if (value === undefined || value === '')
|
|
106
|
+
throw new Error('--dsc-home 需要一个目录');
|
|
107
|
+
if (dscHome !== undefined)
|
|
108
|
+
throw new Error('--dsc-home 给重复了');
|
|
109
|
+
dscHome = value;
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
throw new Error(`不认识的 runner 参数:「${flag}」`);
|
|
113
|
+
}
|
|
114
|
+
if (mode === undefined)
|
|
115
|
+
throw new Error('缺少 --mode');
|
|
116
|
+
if (tempDir === undefined)
|
|
117
|
+
throw new Error('缺少 --temp');
|
|
118
|
+
if (mode === 'workspace-write' && roots.length === 0) {
|
|
119
|
+
throw new Error('workspace-write 模式至少要有一个 --root(可写根)');
|
|
120
|
+
}
|
|
121
|
+
// 账号分支成对校验:只给 --account 不给 --dsc-home(或反过来)都找不到密码文件,必拦
|
|
122
|
+
if (account !== undefined || dscHome !== undefined) {
|
|
123
|
+
if (account === undefined || dscHome === undefined) {
|
|
124
|
+
throw new Error('--account 与 --dsc-home 必须成对给(密码文件按 <dsc-home>/sandbox/account.bin 定位)');
|
|
125
|
+
}
|
|
126
|
+
account = { name: account.name, dscHome };
|
|
127
|
+
}
|
|
128
|
+
// SID ↔ 路径逐对复算:调用方把 SID 拼错就等于凭空多一个可写根(受限令牌的
|
|
129
|
+
// restricting 列表按 SID 写死),必须在这里拦死
|
|
130
|
+
for (const root of roots) {
|
|
131
|
+
const kind = samePath(root.path, tempDir) ? 'temp' : 'root';
|
|
132
|
+
if (!verifySidForPath(root.sid, root.path, kind)) {
|
|
133
|
+
throw new Error(`--root 的 SID 与路径对不上(${root.path} 该派生 ${kind} 形状的 SID,实际收到 ${root.sid})`);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
// temp 与每条可写根的双向不相交:可继承 ACE 会把能力串出去,这是真实的逃逸面
|
|
137
|
+
for (const root of roots) {
|
|
138
|
+
if (samePath(root.path, tempDir))
|
|
139
|
+
continue;
|
|
140
|
+
if (strictlyInside(tempDir, root.path) || strictlyInside(root.path, tempDir)) {
|
|
141
|
+
throw new Error(`临时目录与可写根相交(${tempDir} ⊂⊃ ${root.path}):可继承授权会串能力,拒绝这组参数`);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
// 重复的可写根:同一目录授权两次无害,但说明调用方拼重了,直接报出来
|
|
145
|
+
const seen = new Set();
|
|
146
|
+
for (const root of roots) {
|
|
147
|
+
const key = root.path.replace(/[\\/]+$/, '').toLowerCase();
|
|
148
|
+
if (seen.has(key))
|
|
149
|
+
throw new Error(`--root 给重复了:「${root.path}」`);
|
|
150
|
+
seen.add(key);
|
|
151
|
+
}
|
|
152
|
+
// ⚠ account 必须出现在返回值里:漏了它的话账号分支会被「静默跳过」——
|
|
153
|
+
// 命令照常以当前用户受限令牌跑、退出码一切正常,网络第二级等于悄悄失效
|
|
154
|
+
return { mode, tempDir, roots, ...(account === undefined ? {} : { account }), childArgv };
|
|
155
|
+
}
|
|
156
|
+
/** 路径等价判定:大小写不敏感、末尾分隔符不算数(Windows 口径)。 */
|
|
157
|
+
function samePath(a, b) {
|
|
158
|
+
return a.replace(/[\\/]+$/, '').toLowerCase() === b.replace(/[\\/]+$/, '').toLowerCase();
|
|
159
|
+
}
|
|
160
|
+
/** 大小写不敏感的「真包含」:child 在 parent 里且不是 parent 本身(按分隔符边界判)。 */
|
|
161
|
+
export function strictlyInside(child, parent) {
|
|
162
|
+
const outer = parent.replace(/[\\/]+$/, '').toLowerCase();
|
|
163
|
+
const inner = child.replace(/[\\/]+$/, '').toLowerCase();
|
|
164
|
+
if (outer === inner)
|
|
165
|
+
return false;
|
|
166
|
+
return inner.startsWith(`${outer}\\`) || inner.startsWith(`${outer}/`);
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Windows argv 引号化(CommandLineToArgvW 规则):
|
|
170
|
+
* 空串或含空白/引号才加引号;引号前的反斜杠翻倍再加一个转义反斜杠;
|
|
171
|
+
* 结尾的连续反斜杠翻倍(它们在收尾引号前面)。
|
|
172
|
+
*/
|
|
173
|
+
export function quoteArgv(arg) {
|
|
174
|
+
if (arg !== '' && !/[\s"]/.test(arg))
|
|
175
|
+
return arg;
|
|
176
|
+
let out = '"';
|
|
177
|
+
let backslashes = 0;
|
|
178
|
+
for (const character of arg) {
|
|
179
|
+
if (character === '\\') {
|
|
180
|
+
backslashes += 1;
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
if (character === '"') {
|
|
184
|
+
out += '\\'.repeat(backslashes * 2 + 1) + '"';
|
|
185
|
+
backslashes = 0;
|
|
186
|
+
continue;
|
|
187
|
+
}
|
|
188
|
+
out += '\\'.repeat(backslashes) + character;
|
|
189
|
+
backslashes = 0;
|
|
190
|
+
}
|
|
191
|
+
out += '\\'.repeat(backslashes * 2) + '"';
|
|
192
|
+
return out;
|
|
193
|
+
}
|
|
194
|
+
/** 任意字符串 → NUL 结尾的 UTF-16 缓冲(Win32 的 str16 入参口径)。 */
|
|
195
|
+
function utf16Buffer(text) {
|
|
196
|
+
const buffer = Buffer.alloc(text.length * 2 + 2);
|
|
197
|
+
buffer.write(text, 0, 'utf16le');
|
|
198
|
+
return buffer;
|
|
199
|
+
}
|
|
200
|
+
/** 手工打包 STARTUPINFOW(104 字节,偏移见 abi.SI_OFFSETS)。 */
|
|
201
|
+
function packStartupInfo(stdinRead, stdoutWrite, stderrWrite) {
|
|
202
|
+
const info = Buffer.alloc(STARTUPINFOW_SIZE);
|
|
203
|
+
info.writeUInt32LE(STARTUPINFOW_SIZE, SI_OFFSETS.cb);
|
|
204
|
+
info.writeUInt32LE(STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW, SI_OFFSETS.dwFlags);
|
|
205
|
+
info.writeUInt16LE(SW_HIDE, SI_OFFSETS.wShowWindow);
|
|
206
|
+
info.writeBigUInt64LE(BigInt(stdinRead), SI_OFFSETS.hStdInput);
|
|
207
|
+
info.writeBigUInt64LE(BigInt(stdoutWrite), SI_OFFSETS.hStdOutput);
|
|
208
|
+
info.writeBigUInt64LE(BigInt(stderrWrite), SI_OFFSETS.hStdError);
|
|
209
|
+
return info;
|
|
210
|
+
}
|
|
211
|
+
/** 手工打包 JOBOBJECT_EXTENDED_LIMIT_INFORMATION(144 字节,只设 KILL_ON_JOB_CLOSE)。 */
|
|
212
|
+
function packJobLimits() {
|
|
213
|
+
const limits = Buffer.alloc(JOBOBJECT_EXTENDED_LIMIT_SIZE);
|
|
214
|
+
limits.writeUInt32LE(JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE, JOBOBJ_LIMIT_FLAGS_OFFSET);
|
|
215
|
+
return limits;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* 读管道直到对端关闭(PeekNamedPipe 非阻塞探测 + 有数据才 ReadFile)。
|
|
219
|
+
*
|
|
220
|
+
* 为什么不用阻塞 ReadFile:stdout 与 stderr 要同时排,先排 A 会等 B 写满缓冲;
|
|
221
|
+
* PeekNamedPipe 轮询 + 2ms 让步的写法在 dsh 上实证过,不烧 CPU 也不丢数据。
|
|
222
|
+
*/
|
|
223
|
+
async function drainPipe(bound, handle, sink) {
|
|
224
|
+
const available = slotUint32(bound);
|
|
225
|
+
const area = byteArea(bound, DRAIN_CHUNK);
|
|
226
|
+
for (;;) {
|
|
227
|
+
if (Number(bound.peekNamedPipe(handle, null, 0, null, available.slot, null)) === 0) {
|
|
228
|
+
const code = Number(bound.getLastLastError()) >>> 0;
|
|
229
|
+
if (isBrokenPipe(code))
|
|
230
|
+
return;
|
|
231
|
+
throwWin32(bound, 'PeekNamedPipe', code);
|
|
232
|
+
}
|
|
233
|
+
const count = available.get();
|
|
234
|
+
if (count === 0) {
|
|
235
|
+
await new Promise((resolve) => setTimeout(resolve, 2));
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
238
|
+
const read = slotUint32(bound);
|
|
239
|
+
if (Number(bound.readFile(handle, area.ptr, Math.min(count, DRAIN_CHUNK), read.slot, null)) === 0) {
|
|
240
|
+
const code = Number(bound.getLastLastError()) >>> 0;
|
|
241
|
+
if (isBrokenPipe(code))
|
|
242
|
+
return;
|
|
243
|
+
throwWin32(bound, 'ReadFile', code);
|
|
244
|
+
}
|
|
245
|
+
const got = read.get();
|
|
246
|
+
if (got === 0)
|
|
247
|
+
return;
|
|
248
|
+
sink.write(Buffer.from(area.bytes().subarray(0, got)));
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
/** 入口:参数 → 环境 → 令牌 → 管道 → 挂起 spawn → 作业 → 放行 → 排水 → 等待 → 镜像退出码。 */
|
|
252
|
+
/**
|
|
253
|
+
* 账号分支:解密 DPAPI 密码 → LogonUserW 拿专用离线账号的主令牌。
|
|
254
|
+
*
|
|
255
|
+
* 密码文件在 `<dsc-home>/sandbox/account.bin`(提权 setup 落盘的 DPAPI CurrentUser blob,
|
|
256
|
+
* 同用户可解)。失败照 runner 语义抛(`dsc-sandbox-run: …` + 127)——绝不回落成当前用户。
|
|
257
|
+
*/
|
|
258
|
+
function logonAccount(bound, account) {
|
|
259
|
+
const blob = readFileSync(accountBlobPath(account.dscHome));
|
|
260
|
+
const password = unprotectSecret(bound, blob);
|
|
261
|
+
const slot = slotUintPtr(bound);
|
|
262
|
+
if (Number(bound.logonUserW(utf16Buffer(account.name), utf16Buffer('.'), utf16Buffer(password), LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, slot.slot)) === 0) {
|
|
263
|
+
throwLastError(bound, 'LogonUserW');
|
|
264
|
+
}
|
|
265
|
+
return slot.get();
|
|
266
|
+
}
|
|
267
|
+
async function main() {
|
|
268
|
+
const args = parseRunnerArgs(process.argv.slice(2));
|
|
269
|
+
const ffi = loadFfi();
|
|
270
|
+
const bound = bindAll(ffi);
|
|
271
|
+
// runner 忽略 CTRL+C:收尾(镜像退出码、让作业句柄自然关闭)必须做完
|
|
272
|
+
if (Number(bound.setConsoleCtrlHandler(null, 1)) === 0)
|
|
273
|
+
throwLastError(bound, 'SetConsoleCtrlHandler');
|
|
274
|
+
// TMP/TEMP 重定向到自己进程环境。lpEnvironment 必须传 NULL(koffi 传显式环境块
|
|
275
|
+
// 必报 ERROR_INVALID_PARAMETER),子进程继承的就是改过的这一份
|
|
276
|
+
if (Number(bound.setEnvironmentVariableW(utf16Buffer('TMP'), utf16Buffer(args.tempDir))) === 0) {
|
|
277
|
+
throwLastError(bound, 'SetEnvironmentVariableW(TMP)');
|
|
278
|
+
}
|
|
279
|
+
if (Number(bound.setEnvironmentVariableW(utf16Buffer('TEMP'), utf16Buffer(args.tempDir))) === 0) {
|
|
280
|
+
throwLastError(bound, 'SetEnvironmentVariableW(TEMP)');
|
|
281
|
+
}
|
|
282
|
+
// 令牌:restricting 列表 = [logon, Everyone, …可写根 SID](temp 的 SID 也在 roots 里)。
|
|
283
|
+
// 账号分支(--account):解密 account.bin → LogonUserW → 在账号令牌上受限化——
|
|
284
|
+
// pass-1 用账号的普通权限(可写根靠账号 ACE),pass-2 照旧走能力 SID 交集
|
|
285
|
+
const accountToken = args.account === undefined ? undefined : logonAccount(bound, args.account);
|
|
286
|
+
const token = buildRestrictedToken(bound, {
|
|
287
|
+
mode: args.mode,
|
|
288
|
+
rootSids: args.roots.map((root) => root.sid),
|
|
289
|
+
...(accountToken === undefined ? {} : { accountToken }),
|
|
290
|
+
});
|
|
291
|
+
// 三对匿名管道;只给子进程端打继承位(父端要立刻关掉,否则排水永远等不到 EOF)
|
|
292
|
+
const stdinRead = slotUintPtr(bound);
|
|
293
|
+
const stdinWrite = slotUintPtr(bound);
|
|
294
|
+
const stdoutRead = slotUintPtr(bound);
|
|
295
|
+
const stdoutWrite = slotUintPtr(bound);
|
|
296
|
+
const stderrRead = slotUintPtr(bound);
|
|
297
|
+
const stderrWrite = slotUintPtr(bound);
|
|
298
|
+
for (const pair of [[stdinRead, stdinWrite], [stdoutRead, stdoutWrite], [stderrRead, stderrWrite]]) {
|
|
299
|
+
if (Number(bound.createPipe(pair[0].slot, pair[1].slot, null, 0)) === 0)
|
|
300
|
+
throwLastError(bound, 'CreatePipe');
|
|
301
|
+
}
|
|
302
|
+
for (const childEnd of [stdinRead.get(), stdoutWrite.get(), stderrWrite.get()]) {
|
|
303
|
+
if (Number(bound.setHandleInformation(childEnd, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT)) === 0) {
|
|
304
|
+
throwLastError(bound, 'SetHandleInformation');
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
// 命令行按 CommandLineToArgvW 规则引号化:lpApplicationName 传 NULL,第一个 token 就是程序名
|
|
308
|
+
const commandLine = Buffer.from(`${args.childArgv.map((arg) => quoteArgv(arg)).join(' ')}\0`, 'utf16le');
|
|
309
|
+
const startup = packStartupInfo(stdinRead.get(), stdoutWrite.get(), stderrWrite.get());
|
|
310
|
+
// Buffer 出参直接给 koffi 取地址;它必须活到调用返回(这里是局部变量,满足)
|
|
311
|
+
const processInfo = Buffer.alloc(PROCESS_INFORMATION_SIZE);
|
|
312
|
+
const created = Number(bound.createProcessAsUserW(token.handle, null, // lpApplicationName:NULL → 从命令行第一个 token 解析
|
|
313
|
+
commandLine, null, // lpProcessAttributes
|
|
314
|
+
null, // lpThreadAttributes
|
|
315
|
+
1, // bInheritHandles:三个子进程端要传下去
|
|
316
|
+
CREATE_SUSPENDED, // 先挂起:塞进作业前不许跑
|
|
317
|
+
null, // lpEnvironment:NULL(koffi 传显式块必失败),靠继承 runner 的环境
|
|
318
|
+
null, // lpCurrentDirectory:NULL = 用 runner 的 cwd(宿主设成的会话目录)
|
|
319
|
+
startup, processInfo));
|
|
320
|
+
if (created === 0)
|
|
321
|
+
throwLastError(bound, 'CreateProcessAsUserW');
|
|
322
|
+
const hProcess = Number(processInfo.readBigUInt64LE(PI_OFFSETS.hProcess));
|
|
323
|
+
const hThread = Number(processInfo.readBigUInt64LE(PI_OFFSETS.hThread));
|
|
324
|
+
// 作业:KILL_ON_JOB_CLOSE —— runner 死(含被 taskkill)= 整棵子树被内核收掉
|
|
325
|
+
//
|
|
326
|
+
// 从 CreateProcessAsUserW 成功到子进程真正入作业之间,它一直处于**挂起**态;
|
|
327
|
+
// 这段窗口里任何一步失败,都必须当场把它杀掉:一个不受作业保护的受限进程
|
|
328
|
+
// 一秒都不许活着(否则 runner 退出后会留下一个永远挂起的孤儿)。
|
|
329
|
+
let job = 0;
|
|
330
|
+
try {
|
|
331
|
+
job = Number(bound.createJobObjectW(null, null));
|
|
332
|
+
if (job === 0)
|
|
333
|
+
throwLastError(bound, 'CreateJobObjectW');
|
|
334
|
+
if (Number(bound.setInformationJobObject(job, JobObjectExtendedLimitInformation, packJobLimits(), JOBOBJECT_EXTENDED_LIMIT_SIZE)) === 0) {
|
|
335
|
+
throwLastError(bound, 'SetInformationJobObject');
|
|
336
|
+
}
|
|
337
|
+
if (Number(bound.assignProcessToJobObject(job, hProcess)) === 0) {
|
|
338
|
+
const code = Number(bound.getLastLastError()) >>> 0;
|
|
339
|
+
throwWin32(bound, 'AssignProcessToJobObject', code);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
catch (error) {
|
|
343
|
+
bound.terminateProcess(hProcess, 1);
|
|
344
|
+
if (job !== 0) {
|
|
345
|
+
try {
|
|
346
|
+
bound.closeHandle(job);
|
|
347
|
+
}
|
|
348
|
+
catch {
|
|
349
|
+
/* 收尾失败不遮真实错误 */
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
throw error;
|
|
353
|
+
}
|
|
354
|
+
const resumed = Number(bound.resumeThread(hThread)) >>> 0;
|
|
355
|
+
if (resumed === 0xffffffff) {
|
|
356
|
+
const code = Number(bound.getLastLastError()) >>> 0;
|
|
357
|
+
bound.terminateProcess(hProcess, 1);
|
|
358
|
+
throwWin32(bound, 'ResumeThread', code);
|
|
359
|
+
}
|
|
360
|
+
// 父端立刻关掉三个写端/读端(继承副本已在子进程手里)
|
|
361
|
+
for (const parentEnd of [stdinWrite.get(), stdoutWrite.get(), stderrWrite.get()]) {
|
|
362
|
+
if (Number(bound.closeHandle(parentEnd)) === 0)
|
|
363
|
+
throwLastError(bound, 'CloseHandle(父端管道)');
|
|
364
|
+
}
|
|
365
|
+
// 先排水后等待:不排的话管道缓冲满会双方死锁
|
|
366
|
+
await Promise.all([
|
|
367
|
+
drainPipe(bound, stdoutRead.get(), process.stdout),
|
|
368
|
+
drainPipe(bound, stderrRead.get(), process.stderr),
|
|
369
|
+
]);
|
|
370
|
+
if (Number(bound.waitForSingleObject(hProcess, INFINITE)) !== WAIT_OBJECT_0) {
|
|
371
|
+
throwLastError(bound, 'WaitForSingleObject');
|
|
372
|
+
}
|
|
373
|
+
const exitCode = slotUint32(bound);
|
|
374
|
+
if (Number(bound.getExitCodeProcess(hProcess, exitCode.slot)) === 0)
|
|
375
|
+
throwLastError(bound, 'GetExitCodeProcess');
|
|
376
|
+
// 收尾顺序:先线程/进程/令牌,**作业最后关**。子进程已退出,关作业不会再杀人;
|
|
377
|
+
// 而 runner 被外部 taskkill 时作业句柄随进程关闭 → 内核按 KILL_ON_JOB_CLOSE
|
|
378
|
+
// 收掉整棵子树,这就是杀树语义
|
|
379
|
+
bound.closeHandle(hThread);
|
|
380
|
+
bound.closeHandle(hProcess);
|
|
381
|
+
token.dispose();
|
|
382
|
+
bound.closeHandle(job);
|
|
383
|
+
return exitCode.get() >>> 0;
|
|
384
|
+
}
|
|
385
|
+
main().then((code) => {
|
|
386
|
+
process.exitCode = code;
|
|
387
|
+
}).catch((error) => {
|
|
388
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
389
|
+
process.stderr.write(`${RUNNER_SIGNATURE}${message}\n`);
|
|
390
|
+
process.exitCode = RUNNER_EXIT_CODE;
|
|
391
|
+
});
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 二级网络管控的**一次性提权 setup**:生成 PowerShell 5.1 脚本(内嵌 C# 做 WFP 安装)+ 提权执行。
|
|
3
|
+
*
|
|
4
|
+
* 分工:TS 这边只负责「把要做的事写成一个可审计的 .ps1」(`buildSetupScript` 是纯函数,不碰盘),
|
|
5
|
+
* 真正的提权动作全在那个脚本里(建账号、布防火墙、装 WFP filter)。`runSetupElevated` 负责落盘 + 拉起 UAC。
|
|
6
|
+
*
|
|
7
|
+
* 顺序即安全纪律(中断也不留「有账号没布防」的窗口):
|
|
8
|
+
* 建组 → 生成密码 → **-Disabled 建账号** → 进组 → 隐藏账号 → DPAPI 存密码 →
|
|
9
|
+
* 5 条防火墙规则 → 12 条 WFP filter(单事务持久)→ 写 setup-state.json → **最后才 Enable-LocalUser**。
|
|
10
|
+
* 任何一步抛错都 exit 1、账号停在禁用态;重跑脚本幂等。
|
|
11
|
+
*
|
|
12
|
+
* 与 codex 的两处刻意不同:
|
|
13
|
+
* 1. 环回 TCP 的端口补集一步到位(不做「先全堵再收窄」两段式)——因为本脚本全程把账号钉在禁用态,
|
|
14
|
+
* 不存在 codex 那种「账号已启用、规则还在装」的敞口;
|
|
15
|
+
* 2. 账本(setup-state.json)写在 Enable-LocalUser **之前**:这份账本也是「布防」的一部分,
|
|
16
|
+
* 这样「账号已启用」就一定意味着「账本已在」,doctor 不会读到半截状态。
|
|
17
|
+
*
|
|
18
|
+
* @module dsc/core/sandbox/win/setup
|
|
19
|
+
*/
|
|
20
|
+
/** 固定的离线沙箱账号名(普通本地账号,不是服务账号)。 */
|
|
21
|
+
export declare const DSC_SANDBOX_ACCOUNT = "dsc-sandbox-offline";
|
|
22
|
+
/** 沙箱账号组的名字(便于以后整体清理/识别)。 */
|
|
23
|
+
export declare const DSC_SANDBOX_GROUP = "DscSandboxUsers";
|
|
24
|
+
/** 默认代理端口:沙箱里唯一被放行的环回 TCP 出口。 */
|
|
25
|
+
export declare const DSC_SANDBOX_DEFAULT_PROXY_PORT = 3128;
|
|
26
|
+
/** 账本版本号(改了脚本语义就加一,doctor 可以据此判新旧)。 */
|
|
27
|
+
export declare const DSC_SETUP_STATE_VERSION = 1;
|
|
28
|
+
/** `buildSetupScript` 的入参。 */
|
|
29
|
+
export interface SetupScriptOptions {
|
|
30
|
+
/** dsc 家目录(脚本里 `~/.dsc`,状态文件与 account.bin 都落在它下面的 sandbox/)。 */
|
|
31
|
+
readonly dscHome: string;
|
|
32
|
+
/** WFP provider 的 GUID(由调用方给,默认用 net-abi 里那一个)。 */
|
|
33
|
+
readonly guidProvider?: string;
|
|
34
|
+
/** WFP sublayer 的 GUID(同上)。 */
|
|
35
|
+
readonly guidSublayer?: string;
|
|
36
|
+
/** 代理端口,默认 3128。 */
|
|
37
|
+
readonly proxyPort?: number;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* 生成完整的提权脚本(纯函数:同样的入参给同样的文本)。
|
|
41
|
+
*
|
|
42
|
+
* 输入有一处会被写进 PowerShell 单引号字符串(dscHome 与几个名字),所以这里先校一遍形状,
|
|
43
|
+
* 不合法就直接抛——把「路径里带单引号导致脚本被改写」这种事挡在生成阶段。
|
|
44
|
+
*/
|
|
45
|
+
export declare function buildSetupScript(options: SetupScriptOptions): string;
|
|
46
|
+
/**
|
|
47
|
+
* 落盘脚本并提权执行(会弹一次 UAC:`Start-Process -Verb RunAs`)。
|
|
48
|
+
*
|
|
49
|
+
* 结论取自三处:拉起进程的 exit code、`setup-state.json`(成功账本)、`setup-error.txt`(失败原因)。
|
|
50
|
+
* 三处对不上时按「失败」报,并把能看到的信息都写进 detail —— 提权子进程崩了也不能只回一句「失败」。
|
|
51
|
+
*
|
|
52
|
+
* 注意:本任务里**不调用**它(会弹 UAC,且当前 shell 非管理员);这里保证的是代码正确。
|
|
53
|
+
*/
|
|
54
|
+
export declare function runSetupElevated(dscHome: string, options?: {
|
|
55
|
+
readonly proxyPort?: number;
|
|
56
|
+
readonly timeoutMs?: number;
|
|
57
|
+
}): Promise<{
|
|
58
|
+
ok: boolean;
|
|
59
|
+
detail: string;
|
|
60
|
+
}>;
|