scope-agent-workbench 0.0.0-stage → 0.2.3
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/CHANGELOG.md +59 -0
- package/LICENSE +21 -0
- package/README.md +174 -2
- package/README.zh-CN.md +175 -0
- package/bin/scope.mjs +111 -0
- package/bridge/account-quotas.mjs +881 -0
- package/bridge/agent-email-relay.mjs +160 -0
- package/bridge/app-server-client.mjs +2522 -0
- package/bridge/app-server-websocket-transport.mjs +219 -0
- package/bridge/archive/routes.mjs +19 -0
- package/bridge/archive/service.mjs +130 -0
- package/bridge/archive/thread-lifecycle.mjs +52 -0
- package/bridge/attachment-store.mjs +184 -0
- package/bridge/auth-profile-failover.mjs +58 -0
- package/bridge/auth-profile-manager.mjs +215 -0
- package/bridge/capacity-recovery.mjs +90 -0
- package/bridge/codex-upgrade.mjs +150 -0
- package/bridge/deployment-profile.mjs +64 -0
- package/bridge/email-notifier.mjs +616 -0
- package/bridge/gpu-usage-history.mjs +322 -0
- package/bridge/host-session-restart.mjs +35 -0
- package/bridge/http.mjs +69 -0
- package/bridge/idle-sessions.mjs +185 -0
- package/bridge/inventory-scanner.mjs +517 -0
- package/bridge/local/dialogue.mjs +150 -0
- package/bridge/local/directories.mjs +40 -0
- package/bridge/local/executable.mjs +29 -0
- package/bridge/local/history.mjs +36 -0
- package/bridge/local/python-probe.mjs +35 -0
- package/bridge/local/runtime.mjs +188 -0
- package/bridge/local/transport.mjs +70 -0
- package/bridge/maintenance/install-command.mjs +141 -0
- package/bridge/maintenance/routes.mjs +21 -0
- package/bridge/maintenance/service.mjs +175 -0
- package/bridge/model-catalog.mjs +21 -0
- package/bridge/persistent-home-guard.mjs +6 -0
- package/bridge/plugins/aliyun-dlc/index.mjs +47 -0
- package/bridge/plugins/aliyun-dlc/manifest.mjs +12 -0
- package/bridge/plugins/aliyun-dlc/monitor.mjs +236 -0
- package/bridge/plugins/aliyun-dlc/probe.mjs +701 -0
- package/bridge/plugins/config-store.mjs +35 -0
- package/bridge/plugins/external.mjs +87 -0
- package/bridge/plugins/package.mjs +96 -0
- package/bridge/plugins/registry.mjs +37 -0
- package/bridge/plugins/routes.mjs +27 -0
- package/bridge/private-gateway.mjs +371 -0
- package/bridge/private-start.mjs +22 -0
- package/bridge/probes/app-server-handoff-probe.mjs +89 -0
- package/bridge/probes/app-server-writer-probe.mjs +72 -0
- package/bridge/probes/assistant-search-probe.mjs +323 -0
- package/bridge/probes/dialogue-probe.mjs +464 -0
- package/bridge/probes/history-probe.mjs +432 -0
- package/bridge/probes/index.mjs +15 -0
- package/bridge/probes/new-session-preflight.mjs +16 -0
- package/bridge/probes/profile-cancel-probe.mjs +19 -0
- package/bridge/probes/profile-delete-probe.mjs +28 -0
- package/bridge/probes/profile-list-probe.mjs +117 -0
- package/bridge/probes/profile-write-probe.mjs +111 -0
- package/bridge/probes/raw-context-probe.mjs +53 -0
- package/bridge/probes/remote-probe.mjs +637 -0
- package/bridge/probes/submission-probe.mjs +2 -0
- package/bridge/probes/takeover-probe.mjs +328 -0
- package/bridge/probes/vscode-open-preflight.mjs +23 -0
- package/bridge/profile-capacity-policy.mjs +14 -0
- package/bridge/providers/acp-forms.py +49 -0
- package/bridge/providers/antigravity-interactive.mjs +14 -0
- package/bridge/providers/antigravity-interactive.py +349 -0
- package/bridge/providers/claude-capabilities.py +52 -0
- package/bridge/providers/claude-interactive.mjs +14 -0
- package/bridge/providers/claude-interactive.py +463 -0
- package/bridge/providers/cli-command.mjs +103 -0
- package/bridge/providers/codex-workbench.mjs +164 -0
- package/bridge/providers/conversation-routes.mjs +28 -0
- package/bridge/providers/conversations.mjs +231 -0
- package/bridge/providers/native-commands.mjs +48 -0
- package/bridge/providers/native-commands.py +38 -0
- package/bridge/providers/native-models.mjs +129 -0
- package/bridge/providers/native-session-state.mjs +14 -0
- package/bridge/providers/native-session-state.py +96 -0
- package/bridge/providers/remote-cli.mjs +75 -0
- package/bridge/providers/remote-job.py +130 -0
- package/bridge/remote-app-server-command.mjs +203 -0
- package/bridge/remote-bootstrap/routes.mjs +51 -0
- package/bridge/remote-bootstrap/scope-protocol.mjs +125 -0
- package/bridge/remote-bootstrap/service.mjs +597 -0
- package/bridge/remote-bootstrap/tunnels.mjs +347 -0
- package/bridge/remote-directory-listing.mjs +148 -0
- package/bridge/remote-images.mjs +140 -0
- package/bridge/remote-profile-home.mjs +39 -0
- package/bridge/remote-rollout-locks.mjs +31 -0
- package/bridge/remote-videos.mjs +129 -0
- package/bridge/research/insights.mjs +522 -0
- package/bridge/research/scan-host.mjs +18 -0
- package/bridge/rollout-summary.mjs +177 -0
- package/bridge/routes/accounts.mjs +326 -0
- package/bridge/routes/dialogue.mjs +165 -0
- package/bridge/routes/email.mjs +50 -0
- package/bridge/routes/management.mjs +291 -0
- package/bridge/routes/models.mjs +312 -0
- package/bridge/routes/runtime.mjs +82 -0
- package/bridge/routes/session-commands.mjs +12 -0
- package/bridge/routes/session-delivery.mjs +328 -0
- package/bridge/routes/session-lifecycle.mjs +839 -0
- package/bridge/routes/system.mjs +289 -0
- package/bridge/server.mjs +3357 -0
- package/bridge/session-attachments.mjs +150 -0
- package/bridge/session-cache-archive.mjs +22 -0
- package/bridge/session-catalog/agy-history.py +388 -0
- package/bridge/session-catalog/catalog.mjs +110 -0
- package/bridge/session-catalog/probe.py +1207 -0
- package/bridge/session-catalog/routes.mjs +34 -0
- package/bridge/session-profiles.mjs +115 -0
- package/bridge/shared-start.mjs +22 -0
- package/bridge/start.mjs +205 -0
- package/bridge/state-persistence.mjs +405 -0
- package/bridge/submissions/settings.mjs +50 -0
- package/bridge/terminal-gateway.mjs +171 -0
- package/bridge/tmux-delivery.mjs +390 -0
- package/bridge/tmux-session-control.mjs +29 -0
- package/bridge/transport/ssh-command.mjs +119 -0
- package/bridge/ui-server.mjs +257 -0
- package/bridge/vscode-opener.mjs +157 -0
- package/bridge/web-terminal.mjs +52 -0
- package/bridge/workbench/conversation-routes.mjs +31 -0
- package/bridge/workbench/directory-probe.mjs +41 -0
- package/bridge/workbench/directory-routes.mjs +112 -0
- package/bridge/workbench/manager-context.mjs +51 -0
- package/bridge/workbench/routes.mjs +40 -0
- package/bridge/workbench/scheduler.mjs +131 -0
- package/bridge/workbench/service.mjs +301 -0
- package/bridge/workbench/store.mjs +64 -0
- package/bridge/workbench/task-archive.mjs +46 -0
- package/dist/client/.assetsignore +2 -0
- package/dist/client/.vite/manifest.json +366 -0
- package/dist/client/_headers +3 -0
- package/dist/client/agents/LICENSE.lobe-icons +21 -0
- package/dist/client/agents/README.md +14 -0
- package/dist/client/agents/antigravity.svg +39 -0
- package/dist/client/agents/claude.svg +1 -0
- package/dist/client/agents/codex.svg +1 -0
- package/dist/client/agents/dsh.svg +4 -0
- package/dist/client/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- package/dist/client/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
- package/dist/client/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
- package/dist/client/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
- package/dist/client/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
- package/dist/client/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- package/dist/client/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
- package/dist/client/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- package/dist/client/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
- package/dist/client/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
- package/dist/client/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
- package/dist/client/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- package/dist/client/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
- package/dist/client/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- package/dist/client/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
- package/dist/client/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- package/dist/client/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
- package/dist/client/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
- package/dist/client/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- package/dist/client/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
- package/dist/client/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
- package/dist/client/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
- package/dist/client/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
- package/dist/client/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- package/dist/client/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- package/dist/client/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
- package/dist/client/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
- package/dist/client/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
- package/dist/client/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- package/dist/client/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
- package/dist/client/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
- package/dist/client/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
- package/dist/client/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- package/dist/client/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
- package/dist/client/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- package/dist/client/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
- package/dist/client/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- package/dist/client/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
- package/dist/client/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
- package/dist/client/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
- package/dist/client/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
- package/dist/client/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- package/dist/client/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
- package/dist/client/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- package/dist/client/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
- package/dist/client/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
- package/dist/client/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
- package/dist/client/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- package/dist/client/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
- package/dist/client/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- package/dist/client/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
- package/dist/client/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
- package/dist/client/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
- package/dist/client/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
- package/dist/client/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
- package/dist/client/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- package/dist/client/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
- package/dist/client/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- package/dist/client/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
- package/dist/client/assets/_vinext_fonts/geist-8ac0455e797f/geist-001175b1.woff2 +0 -0
- package/dist/client/assets/_vinext_fonts/geist-8ac0455e797f/geist-52306abf.woff2 +0 -0
- package/dist/client/assets/_vinext_fonts/geist-8ac0455e797f/geist-875ccdd4.woff2 +0 -0
- package/dist/client/assets/_vinext_fonts/geist-8ac0455e797f/geist-98bbbccb.woff2 +0 -0
- package/dist/client/assets/_vinext_fonts/geist-8ac0455e797f/geist-ff2310f5.woff2 +0 -0
- package/dist/client/assets/_vinext_fonts/geist-mono-00e989178794/geist-mono-013b2f2f.woff2 +0 -0
- package/dist/client/assets/_vinext_fonts/geist-mono-00e989178794/geist-mono-0638449e.woff2 +0 -0
- package/dist/client/assets/_vinext_fonts/geist-mono-00e989178794/geist-mono-44745446.woff2 +0 -0
- package/dist/client/assets/_vinext_fonts/geist-mono-00e989178794/geist-mono-44e03052.woff2 +0 -0
- package/dist/client/assets/_vinext_fonts/geist-mono-00e989178794/geist-mono-971fb274.woff2 +0 -0
- package/dist/client/assets/_vinext_fonts/geist-mono-00e989178794/geist-mono-f6b33328.woff2 +0 -0
- package/dist/client/assets/addon-fit-BZbxZs2G.js +1 -0
- package/dist/client/assets/framework-CXnKph_e.js +9 -0
- package/dist/client/assets/index-BMior55c.js +3 -0
- package/dist/client/assets/index-CNnP2Ses.css +2 -0
- package/dist/client/assets/layout-segment-context-DjGudgXn.js +1 -0
- package/dist/client/assets/page-CJqXlhDs.js +551 -0
- package/dist/client/assets/page-LYzRz6_S.css +1 -0
- package/dist/client/assets/rolldown-runtime-S-ySWqyJ.js +1 -0
- package/dist/client/assets/xterm-BBgU7shl.js +36 -0
- package/dist/client/favicon.svg +6 -0
- package/dist/client/file.svg +1 -0
- package/dist/client/globe.svg +1 -0
- package/dist/client/og.png +0 -0
- package/dist/client/scope-logo.svg +11 -0
- package/dist/client/window.svg +1 -0
- package/dist/server/.vite/manifest.json +14 -0
- package/dist/server/__vite_rsc_assets_manifest.js +49 -0
- package/dist/server/assets/index-CNnP2Ses.css +2 -0
- package/dist/server/image-config.json +1 -0
- package/dist/server/index.js +15201 -0
- package/dist/server/ssr/__vite_rsc_assets_manifest.js +49 -0
- package/dist/server/ssr/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- package/dist/server/ssr/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
- package/dist/server/ssr/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
- package/dist/server/ssr/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
- package/dist/server/ssr/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
- package/dist/server/ssr/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- package/dist/server/ssr/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
- package/dist/server/ssr/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- package/dist/server/ssr/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
- package/dist/server/ssr/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
- package/dist/server/ssr/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
- package/dist/server/ssr/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- package/dist/server/ssr/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
- package/dist/server/ssr/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- package/dist/server/ssr/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
- package/dist/server/ssr/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- package/dist/server/ssr/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
- package/dist/server/ssr/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
- package/dist/server/ssr/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- package/dist/server/ssr/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
- package/dist/server/ssr/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
- package/dist/server/ssr/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
- package/dist/server/ssr/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
- package/dist/server/ssr/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- package/dist/server/ssr/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- package/dist/server/ssr/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
- package/dist/server/ssr/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
- package/dist/server/ssr/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
- package/dist/server/ssr/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- package/dist/server/ssr/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
- package/dist/server/ssr/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
- package/dist/server/ssr/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
- package/dist/server/ssr/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- package/dist/server/ssr/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
- package/dist/server/ssr/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- package/dist/server/ssr/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
- package/dist/server/ssr/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- package/dist/server/ssr/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
- package/dist/server/ssr/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
- package/dist/server/ssr/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
- package/dist/server/ssr/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
- package/dist/server/ssr/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- package/dist/server/ssr/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
- package/dist/server/ssr/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- package/dist/server/ssr/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
- package/dist/server/ssr/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
- package/dist/server/ssr/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
- package/dist/server/ssr/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- package/dist/server/ssr/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
- package/dist/server/ssr/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- package/dist/server/ssr/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
- package/dist/server/ssr/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
- package/dist/server/ssr/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
- package/dist/server/ssr/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
- package/dist/server/ssr/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
- package/dist/server/ssr/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- package/dist/server/ssr/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
- package/dist/server/ssr/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- package/dist/server/ssr/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
- package/dist/server/ssr/assets/addon-fit-C09Jj0_f.js +42 -0
- package/dist/server/ssr/assets/error-boundary-Dd2ZYXA8.js +277 -0
- package/dist/server/ssr/assets/layout-segment-context-HV_Mvyzf.js +37 -0
- package/dist/server/ssr/assets/page-BB9Dri2u.js +104686 -0
- package/dist/server/ssr/assets/page-LYzRz6_S.css +1 -0
- package/dist/server/ssr/assets/xterm-DgzE4ZZ1.js +10232 -0
- package/dist/server/ssr/index.js +11840 -0
- package/dist/server/ssr/vinext-server.json +1 -0
- package/dist/server/vinext-externals.json +1 -0
- package/dist/server/vinext-server.json +1 -0
- package/dist/server/wrangler.json +1 -0
- package/examples/agents/global-agreements.example.md +10 -0
- package/examples/agents/research-project.example.md +10 -0
- package/examples/agents-media-previews.md +22 -0
- package/examples/deployment.example.json +6 -0
- package/examples/leak-denylist.example.json +10 -0
- package/examples/plugins/hello/index.mjs +4 -0
- package/examples/plugins/hello/scope-plugin.json +13 -0
- package/examples/workbench.config.json +44 -0
- package/lib/account-quota.d.ts +42 -0
- package/lib/account-quota.js +121 -0
- package/lib/browser-snapshot-cache.js +61 -0
- package/lib/conversation-location.js +26 -0
- package/lib/conversation.js +62 -0
- package/lib/dialogue-refresh.js +14 -0
- package/lib/execution-host.js +22 -0
- package/lib/formula-preview.js +48 -0
- package/lib/i18n.tsx +81 -0
- package/lib/incremental-snapshot.js +324 -0
- package/lib/manager-plan.js +37 -0
- package/lib/markdown-images.js +22 -0
- package/lib/markdown-math.js +151 -0
- package/lib/markdown-url.js +13 -0
- package/lib/model-effort.js +13 -0
- package/lib/native-history.d.ts +32 -0
- package/lib/native-history.js +94 -0
- package/lib/overview-delta.js +41 -0
- package/lib/project-view.js +86 -0
- package/lib/projects.js +74 -0
- package/lib/remote-links.js +95 -0
- package/lib/runtime-config.js +70 -0
- package/lib/session-activity.js +34 -0
- package/lib/session-cache-guard.js +52 -0
- package/lib/session-filters.js +38 -0
- package/lib/ssh-config.js +26 -0
- package/lib/stable-order.js +39 -0
- package/lib/subagent-display-prefs.ts +130 -0
- package/lib/workbench-config.js +172 -0
- package/package.json +105 -4
- package/scripts/agent-email-relay.mjs +104 -0
- package/scripts/benchmark-bridge.mjs +38 -0
- package/scripts/cli-integration-smoke.mjs +64 -0
- package/scripts/email-notification-cli.mjs +28 -0
- package/scripts/enable-private-access.ps1 +109 -0
- package/scripts/export-opensource.mjs +112 -0
- package/scripts/fixtures/media/convergence.png +0 -0
- package/scripts/fixtures/media/rollout_demo.mp4 +0 -0
- package/scripts/fixtures/native-conversations.mjs +465 -0
- package/scripts/fixtures/workbench-conversations.mjs +475 -0
- package/scripts/install-remote-server.sh +67 -0
- package/scripts/lib/export-directory.mjs +38 -0
- package/scripts/lib/secret-scanner.mjs +139 -0
- package/scripts/plugin-cli.mjs +19 -0
- package/scripts/preview-workbench.mjs +669 -0
- package/scripts/probe-antigravity-acp.mjs +35 -0
- package/scripts/remote-bootstrap-cli.mjs +52 -0
- package/scripts/remote-email-tool.py +383 -0
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import { createReadStream } from "node:fs";
|
|
2
|
+
import { cp, mkdtemp, rm, stat } from "node:fs/promises";
|
|
3
|
+
import { createServer } from "node:http";
|
|
4
|
+
import os from "node:os";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { Readable } from "node:stream";
|
|
7
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
8
|
+
import { listRemoteDirectories } from "./remote-directory-listing.mjs";
|
|
9
|
+
import { remoteImageResponse } from "./remote-images.mjs";
|
|
10
|
+
import { remoteVideoResponse } from "./remote-videos.mjs";
|
|
11
|
+
|
|
12
|
+
const DEFAULT_HOST = "127.0.0.1";
|
|
13
|
+
const DEFAULT_PORT = 3000;
|
|
14
|
+
const DEFAULT_CLIENT_DIR = fileURLToPath(new URL("../dist/client/", import.meta.url));
|
|
15
|
+
const DEFAULT_WORKER_ENTRY = fileURLToPath(
|
|
16
|
+
new URL("../dist/server/index.js", import.meta.url),
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
const CONTENT_TYPES = new Map([
|
|
20
|
+
[".css", "text/css; charset=utf-8"],
|
|
21
|
+
[".js", "text/javascript; charset=utf-8"],
|
|
22
|
+
[".json", "application/json; charset=utf-8"],
|
|
23
|
+
[".svg", "image/svg+xml; charset=utf-8"],
|
|
24
|
+
[".png", "image/png"],
|
|
25
|
+
[".jpg", "image/jpeg"],
|
|
26
|
+
[".jpeg", "image/jpeg"],
|
|
27
|
+
[".webp", "image/webp"],
|
|
28
|
+
[".ico", "image/x-icon"],
|
|
29
|
+
[".woff", "font/woff"],
|
|
30
|
+
[".woff2", "font/woff2"],
|
|
31
|
+
[".ttf", "font/ttf"],
|
|
32
|
+
]);
|
|
33
|
+
|
|
34
|
+
function argumentValue(name, fallback) {
|
|
35
|
+
const index = process.argv.indexOf(name);
|
|
36
|
+
return index >= 0 && process.argv[index + 1] ? process.argv[index + 1] : fallback;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function safeAssetPath(clientDir, pathname) {
|
|
40
|
+
let decoded;
|
|
41
|
+
try {
|
|
42
|
+
decoded = decodeURIComponent(pathname);
|
|
43
|
+
} catch {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
const relative = decoded.replace(/^\/+/, "");
|
|
47
|
+
if (!relative || relative.split("/").some((segment) => segment.startsWith("."))) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
const root = path.resolve(clientDir);
|
|
51
|
+
const candidate = path.resolve(root, relative);
|
|
52
|
+
return candidate.startsWith(`${root}${path.sep}`) ? candidate : null;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async function assetResponse(clientDir, request) {
|
|
56
|
+
const url = new URL(request.url);
|
|
57
|
+
const filename = safeAssetPath(clientDir, url.pathname);
|
|
58
|
+
if (!filename) return new Response("Not found", { status: 404 });
|
|
59
|
+
let details;
|
|
60
|
+
try {
|
|
61
|
+
details = await stat(filename);
|
|
62
|
+
} catch {
|
|
63
|
+
return new Response("Not found", { status: 404 });
|
|
64
|
+
}
|
|
65
|
+
if (!details.isFile()) return new Response("Not found", { status: 404 });
|
|
66
|
+
const headers = new Headers({
|
|
67
|
+
"Content-Type":
|
|
68
|
+
CONTENT_TYPES.get(path.extname(filename).toLowerCase()) ||
|
|
69
|
+
"application/octet-stream",
|
|
70
|
+
"Content-Length": String(details.size),
|
|
71
|
+
"X-Content-Type-Options": "nosniff",
|
|
72
|
+
"Cache-Control": url.pathname.startsWith("/assets/")
|
|
73
|
+
? "public, max-age=31536000, immutable"
|
|
74
|
+
: "no-cache",
|
|
75
|
+
});
|
|
76
|
+
const body =
|
|
77
|
+
request.method === "HEAD"
|
|
78
|
+
? null
|
|
79
|
+
: Readable.toWeb(createReadStream(filename));
|
|
80
|
+
return new Response(body, { status: 200, headers });
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function webRequest(request, host) {
|
|
84
|
+
const init = {
|
|
85
|
+
method: request.method,
|
|
86
|
+
headers: request.headers,
|
|
87
|
+
};
|
|
88
|
+
if (!["GET", "HEAD"].includes(request.method || "GET")) {
|
|
89
|
+
init.body = Readable.toWeb(request);
|
|
90
|
+
init.duplex = "half";
|
|
91
|
+
}
|
|
92
|
+
return new Request(new URL(request.url || "/", `http://${host}`), init);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
async function sendWebResponse(response, target) {
|
|
96
|
+
const headers = {};
|
|
97
|
+
response.headers.forEach((value, key) => {
|
|
98
|
+
headers[key] = value;
|
|
99
|
+
});
|
|
100
|
+
target.writeHead(response.status, headers);
|
|
101
|
+
if (!response.body) {
|
|
102
|
+
target.end();
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const stream = Readable.fromWeb(response.body);
|
|
106
|
+
target.once("close", () => stream.destroy());
|
|
107
|
+
stream.once("error", () => target.destroy());
|
|
108
|
+
stream.pipe(target);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
async function snapshotProductionBuild(clientDir, workerEntry) {
|
|
112
|
+
const runtimeRoot = await mkdtemp(
|
|
113
|
+
path.join(os.tmpdir(), "scope-ui-runtime-"),
|
|
114
|
+
);
|
|
115
|
+
const runtimeClientDir = path.join(runtimeRoot, "client");
|
|
116
|
+
const runtimeServerDir = path.join(runtimeRoot, "server");
|
|
117
|
+
try {
|
|
118
|
+
await Promise.all([
|
|
119
|
+
cp(clientDir, runtimeClientDir, { recursive: true }),
|
|
120
|
+
cp(path.dirname(workerEntry), runtimeServerDir, { recursive: true }),
|
|
121
|
+
]);
|
|
122
|
+
return {
|
|
123
|
+
root: runtimeRoot,
|
|
124
|
+
clientDir: runtimeClientDir,
|
|
125
|
+
workerEntry: path.join(runtimeServerDir, path.basename(workerEntry)),
|
|
126
|
+
};
|
|
127
|
+
} catch (error) {
|
|
128
|
+
await rm(runtimeRoot, { recursive: true, force: true }).catch(() => {});
|
|
129
|
+
throw error;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export async function startProductionUiServer({
|
|
134
|
+
host = DEFAULT_HOST,
|
|
135
|
+
port = DEFAULT_PORT,
|
|
136
|
+
clientDir = DEFAULT_CLIENT_DIR,
|
|
137
|
+
workerEntry = DEFAULT_WORKER_ENTRY,
|
|
138
|
+
directoryLister = listRemoteDirectories,
|
|
139
|
+
} = {}) {
|
|
140
|
+
// A vinext build replaces hashed assets in dist in place. Keep the worker and
|
|
141
|
+
// client assets from one build in a private runtime snapshot so a background
|
|
142
|
+
// build cannot leave the running server's HTML pointing at deleted files.
|
|
143
|
+
const runtime = await snapshotProductionBuild(clientDir, workerEntry);
|
|
144
|
+
const workerUrl = pathToFileURL(runtime.workerEntry);
|
|
145
|
+
workerUrl.searchParams.set("scope-ui", `${process.pid}-${Date.now()}`);
|
|
146
|
+
let worker;
|
|
147
|
+
try {
|
|
148
|
+
({ default: worker } = await import(workerUrl.href));
|
|
149
|
+
} catch (error) {
|
|
150
|
+
await rm(runtime.root, { recursive: true, force: true }).catch(() => {});
|
|
151
|
+
throw error;
|
|
152
|
+
}
|
|
153
|
+
const server = createServer(async (request, response) => {
|
|
154
|
+
try {
|
|
155
|
+
const incoming = webRequest(request, request.headers.host || `${host}:${port}`);
|
|
156
|
+
const incomingUrl = new URL(incoming.url);
|
|
157
|
+
if (incomingUrl.pathname === "/scope-video-api") {
|
|
158
|
+
await sendWebResponse(await remoteVideoResponse(incoming), response);
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
if (incomingUrl.pathname === "/scope-image-api") {
|
|
162
|
+
await sendWebResponse(await remoteImageResponse(incoming), response);
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
if (incomingUrl.pathname === "/scope-directory-api") {
|
|
166
|
+
if (incoming.method !== "GET") {
|
|
167
|
+
await sendWebResponse(
|
|
168
|
+
Response.json({ error: "只允许读取远端目录" }, { status: 405 }),
|
|
169
|
+
response,
|
|
170
|
+
);
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
try {
|
|
174
|
+
const listing = await directoryLister({
|
|
175
|
+
host: incomingUrl.searchParams.get("host") || "",
|
|
176
|
+
requestedPath: incomingUrl.searchParams.get("path") || "/",
|
|
177
|
+
});
|
|
178
|
+
await sendWebResponse(Response.json(listing), response);
|
|
179
|
+
} catch (error) {
|
|
180
|
+
await sendWebResponse(
|
|
181
|
+
Response.json(
|
|
182
|
+
{ error: error instanceof Error ? error.message : String(error) },
|
|
183
|
+
{ status: 400 },
|
|
184
|
+
),
|
|
185
|
+
response,
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
const directAsset = await assetResponse(runtime.clientDir, incoming);
|
|
191
|
+
if (directAsset.status !== 404) {
|
|
192
|
+
await sendWebResponse(directAsset, response);
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
const rendered = await worker.fetch(
|
|
196
|
+
incoming,
|
|
197
|
+
{
|
|
198
|
+
ASSETS: {
|
|
199
|
+
fetch: (assetRequest) =>
|
|
200
|
+
assetResponse(runtime.clientDir, assetRequest),
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
waitUntil() {},
|
|
205
|
+
passThroughOnException() {},
|
|
206
|
+
},
|
|
207
|
+
);
|
|
208
|
+
const customBridgePort = Number(process.env.SCOPE_BRIDGE_PORT || 4815);
|
|
209
|
+
const contentType = rendered.headers.get("content-type") || "";
|
|
210
|
+
if (
|
|
211
|
+
Number.isInteger(customBridgePort) &&
|
|
212
|
+
customBridgePort !== 4815 &&
|
|
213
|
+
contentType.includes("text/html")
|
|
214
|
+
) {
|
|
215
|
+
const html = await rendered.text();
|
|
216
|
+
const injected = html.replace(
|
|
217
|
+
/<head(\b[^>]*)>/i,
|
|
218
|
+
`<head$1><meta name="scope-bridge-url" content="http://127.0.0.1:${customBridgePort}">`,
|
|
219
|
+
);
|
|
220
|
+
const headers = new Headers(rendered.headers);
|
|
221
|
+
headers.delete("content-length");
|
|
222
|
+
await sendWebResponse(new Response(injected, { status: rendered.status, headers }), response);
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
await sendWebResponse(rendered, response);
|
|
226
|
+
} catch (error) {
|
|
227
|
+
console.error(`[scope-ui] ${error instanceof Error ? error.stack : error}`);
|
|
228
|
+
if (!response.headersSent) {
|
|
229
|
+
response.writeHead(500, { "Content-Type": "text/plain; charset=utf-8" });
|
|
230
|
+
}
|
|
231
|
+
response.end("SCOPE UI failed to render");
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
server.once("close", () => {
|
|
235
|
+
rm(runtime.root, { recursive: true, force: true }).catch(() => {});
|
|
236
|
+
});
|
|
237
|
+
try {
|
|
238
|
+
await new Promise((resolve, reject) => {
|
|
239
|
+
server.once("error", reject);
|
|
240
|
+
server.listen(port, host, resolve);
|
|
241
|
+
});
|
|
242
|
+
} catch (error) {
|
|
243
|
+
await rm(runtime.root, { recursive: true, force: true }).catch(() => {});
|
|
244
|
+
throw error;
|
|
245
|
+
}
|
|
246
|
+
return server;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
if (pathToFileURL(process.argv[1] || "").href === import.meta.url) {
|
|
250
|
+
const host = argumentValue("--hostname", DEFAULT_HOST);
|
|
251
|
+
const port = Number(argumentValue("--port", String(DEFAULT_PORT)));
|
|
252
|
+
const server = await startProductionUiServer({ host, port });
|
|
253
|
+
console.log(`[scope-ui] Production server running at http://${host}:${port}`);
|
|
254
|
+
const stop = () => server.close(() => process.exit(0));
|
|
255
|
+
process.once("SIGINT", stop);
|
|
256
|
+
process.once("SIGTERM", stop);
|
|
257
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
|
|
4
|
+
function requireText(value, label) {
|
|
5
|
+
if (typeof value !== "string" || !value.trim()) {
|
|
6
|
+
throw new Error(`${label}不能为空`);
|
|
7
|
+
}
|
|
8
|
+
if (value.includes("\0")) throw new Error(`${label}包含非法字符`);
|
|
9
|
+
return value.trim();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function normalizeRemoteAbsolutePath(value, label = "远端路径") {
|
|
13
|
+
const candidate = requireText(value, label).replaceAll("\\", "/");
|
|
14
|
+
if (!candidate.startsWith("/")) throw new Error(`${label}必须是绝对路径`);
|
|
15
|
+
return path.posix.normalize(candidate);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function optionalPositiveInteger(value, label) {
|
|
19
|
+
if (value === undefined || value === null || value === "") return null;
|
|
20
|
+
const parsed = Number(value);
|
|
21
|
+
if (!Number.isSafeInteger(parsed) || parsed < 1) {
|
|
22
|
+
throw new Error(`${label}必须是正整数`);
|
|
23
|
+
}
|
|
24
|
+
return parsed;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function normalizeRemoteFileTarget({ file, line, column }) {
|
|
28
|
+
if (file === undefined || file === null || file === "") return null;
|
|
29
|
+
let candidate = requireText(file, "远端文件").replaceAll("\\", "/");
|
|
30
|
+
let normalizedLine = optionalPositiveInteger(line, "行号");
|
|
31
|
+
let normalizedColumn = optionalPositiveInteger(column, "列号");
|
|
32
|
+
const legacyWithColumn = candidate.match(/^(.*):(\d+):(\d+)$/);
|
|
33
|
+
const legacyWithLine = candidate.match(/^(.*):(\d+)$/);
|
|
34
|
+
const legacyPosition = legacyWithColumn || legacyWithLine;
|
|
35
|
+
if (legacyPosition?.[1] && normalizedLine === null) {
|
|
36
|
+
candidate = legacyPosition[1];
|
|
37
|
+
normalizedLine = Number(legacyPosition[2]);
|
|
38
|
+
normalizedColumn = legacyWithColumn
|
|
39
|
+
? Number(legacyWithColumn[3])
|
|
40
|
+
: normalizedColumn;
|
|
41
|
+
}
|
|
42
|
+
if (normalizedColumn !== null && normalizedLine === null) {
|
|
43
|
+
throw new Error("指定列号时必须同时指定行号");
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
path: normalizeRemoteAbsolutePath(candidate, "远端文件"),
|
|
47
|
+
line: normalizedLine,
|
|
48
|
+
column: normalizedColumn,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function vscodeRemoteOpenArgs(request) {
|
|
53
|
+
const { host, cwd } = request;
|
|
54
|
+
const normalizedHost = requireText(host, "SSH 主机");
|
|
55
|
+
const normalizedCwd = normalizeRemoteAbsolutePath(cwd, "远端工作目录");
|
|
56
|
+
const target = normalizeRemoteFileTarget(request);
|
|
57
|
+
const args = [
|
|
58
|
+
"--remote",
|
|
59
|
+
`ssh-remote+${normalizedHost}`,
|
|
60
|
+
"--new-window",
|
|
61
|
+
normalizedCwd,
|
|
62
|
+
];
|
|
63
|
+
if (target) {
|
|
64
|
+
const positionedPath = [target.path, target.line, target.column]
|
|
65
|
+
.filter((value) => value !== null)
|
|
66
|
+
.join(":");
|
|
67
|
+
args.push("--goto", positionedPath);
|
|
68
|
+
}
|
|
69
|
+
return args;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function resolveVscodeExecutable({
|
|
73
|
+
env = process.env,
|
|
74
|
+
platform = process.platform,
|
|
75
|
+
fileExists = existsSync,
|
|
76
|
+
} = {}) {
|
|
77
|
+
const override = env.SCOPE_VSCODE_EXECUTABLE?.trim();
|
|
78
|
+
if (override) return override;
|
|
79
|
+
|
|
80
|
+
const candidates = [];
|
|
81
|
+
if (platform === "win32") {
|
|
82
|
+
if (env.LOCALAPPDATA) {
|
|
83
|
+
candidates.push(
|
|
84
|
+
path.win32.join(
|
|
85
|
+
env.LOCALAPPDATA,
|
|
86
|
+
"Programs",
|
|
87
|
+
"Microsoft VS Code",
|
|
88
|
+
"Code.exe",
|
|
89
|
+
),
|
|
90
|
+
path.win32.join(
|
|
91
|
+
env.LOCALAPPDATA,
|
|
92
|
+
"Programs",
|
|
93
|
+
"Microsoft VS Code Insiders",
|
|
94
|
+
"Code - Insiders.exe",
|
|
95
|
+
),
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
if (env.ProgramFiles) {
|
|
99
|
+
candidates.push(
|
|
100
|
+
path.win32.join(env.ProgramFiles, "Microsoft VS Code", "Code.exe"),
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
if (env["ProgramFiles(x86)"]) {
|
|
104
|
+
candidates.push(
|
|
105
|
+
path.win32.join(
|
|
106
|
+
env["ProgramFiles(x86)"],
|
|
107
|
+
"Microsoft VS Code",
|
|
108
|
+
"Code.exe",
|
|
109
|
+
),
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
} else if (platform === "darwin") {
|
|
113
|
+
candidates.push(
|
|
114
|
+
"/Applications/Visual Studio Code.app/Contents/MacOS/Electron",
|
|
115
|
+
"/Applications/Visual Studio Code - Insiders.app/Contents/MacOS/Electron",
|
|
116
|
+
);
|
|
117
|
+
} else {
|
|
118
|
+
return "code";
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const executable = candidates.find((candidate) => fileExists(candidate));
|
|
122
|
+
if (executable) return executable;
|
|
123
|
+
throw new Error(
|
|
124
|
+
"未找到本机 VS Code;可通过 SCOPE_VSCODE_EXECUTABLE 指定可执行文件",
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export function launchVscodeRemoteFile(
|
|
129
|
+
request,
|
|
130
|
+
{
|
|
131
|
+
spawnProcess,
|
|
132
|
+
resolveExecutable = resolveVscodeExecutable,
|
|
133
|
+
env = process.env,
|
|
134
|
+
platform = process.platform,
|
|
135
|
+
} = {},
|
|
136
|
+
) {
|
|
137
|
+
if (typeof spawnProcess !== "function") {
|
|
138
|
+
throw new Error("缺少 VS Code 启动器");
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const executable = resolveExecutable({ env, platform });
|
|
142
|
+
const args = vscodeRemoteOpenArgs(request);
|
|
143
|
+
|
|
144
|
+
return new Promise((resolve, reject) => {
|
|
145
|
+
const child = spawnProcess(executable, args, {
|
|
146
|
+
detached: true,
|
|
147
|
+
env,
|
|
148
|
+
stdio: "ignore",
|
|
149
|
+
windowsHide: true,
|
|
150
|
+
});
|
|
151
|
+
child.once("error", reject);
|
|
152
|
+
child.once("spawn", () => {
|
|
153
|
+
child.unref();
|
|
154
|
+
resolve({ executable, args });
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
function shellQuote(value) {
|
|
2
|
+
return `'${String(value).replaceAll("'", `'\"'\"'`)}'`;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export function terminalDimension(value, fallback, maximum) {
|
|
6
|
+
const numeric = Math.floor(Number(value));
|
|
7
|
+
return Number.isFinite(numeric)
|
|
8
|
+
? Math.max(2, Math.min(maximum, numeric))
|
|
9
|
+
: fallback;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function buildRemoteTerminalCommand({
|
|
13
|
+
cwd,
|
|
14
|
+
tmuxSession = "",
|
|
15
|
+
cols = 100,
|
|
16
|
+
rows = 28,
|
|
17
|
+
}) {
|
|
18
|
+
const size = `stty rows ${terminalDimension(rows, 28, 200)} cols ${terminalDimension(cols, 100, 400)} 2>/dev/null || true;`;
|
|
19
|
+
if (tmuxSession) {
|
|
20
|
+
return `${size} exec tmux attach-session -t ${shellQuote(tmuxSession)}`;
|
|
21
|
+
}
|
|
22
|
+
const changeDirectory = cwd ? `cd -- ${shellQuote(cwd)} || exit $?;` : "";
|
|
23
|
+
return [
|
|
24
|
+
size,
|
|
25
|
+
changeDirectory,
|
|
26
|
+
'if [ -n "$SHELL" ] && [ -x "$SHELL" ]; then exec "$SHELL" -l; fi;',
|
|
27
|
+
"exec /bin/sh -l",
|
|
28
|
+
]
|
|
29
|
+
.filter(Boolean)
|
|
30
|
+
.join(" ");
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function sshTerminalArguments({ host, command, timeoutSeconds = 7 }) {
|
|
34
|
+
return [
|
|
35
|
+
"-tt",
|
|
36
|
+
"-o",
|
|
37
|
+
"BatchMode=yes",
|
|
38
|
+
"-o",
|
|
39
|
+
"StrictHostKeyChecking=yes",
|
|
40
|
+
"-o",
|
|
41
|
+
"ConnectionAttempts=1",
|
|
42
|
+
"-o",
|
|
43
|
+
`ConnectTimeout=${Math.max(2, Math.ceil(Number(timeoutSeconds) || 7))}`,
|
|
44
|
+
"-o",
|
|
45
|
+
"ServerAliveInterval=15",
|
|
46
|
+
"-o",
|
|
47
|
+
"ServerAliveCountMax=3",
|
|
48
|
+
"--",
|
|
49
|
+
host,
|
|
50
|
+
command,
|
|
51
|
+
];
|
|
52
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export function conversationRoutes(
|
|
2
|
+
manager,
|
|
3
|
+
{ readJsonBody, jsonResponse, persist },
|
|
4
|
+
) {
|
|
5
|
+
return async (request, response, url) => {
|
|
6
|
+
if (url.pathname !== "/api/session/interrupt") return false;
|
|
7
|
+
if (request.method !== "POST") {
|
|
8
|
+
jsonResponse(response, 405, { error: "不支持的请求方法" });
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
try {
|
|
12
|
+
const body = await readJsonBody(request);
|
|
13
|
+
if (
|
|
14
|
+
typeof body.host !== "string" ||
|
|
15
|
+
typeof body.sessionId !== "string" ||
|
|
16
|
+
!body.host.trim() ||
|
|
17
|
+
!body.sessionId.trim()
|
|
18
|
+
)
|
|
19
|
+
throw new Error("缺少主机或会话 ID");
|
|
20
|
+
const result = await manager.interruptTurn(
|
|
21
|
+
body.host.trim(),
|
|
22
|
+
body.sessionId.trim(),
|
|
23
|
+
);
|
|
24
|
+
await persist();
|
|
25
|
+
jsonResponse(response, 200, result);
|
|
26
|
+
} catch (error) {
|
|
27
|
+
jsonResponse(response, 409, { error: error.message });
|
|
28
|
+
}
|
|
29
|
+
return true;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export const REMOTE_DIRECTORY_PROBE = String.raw`
|
|
2
|
+
import json
|
|
3
|
+
import os
|
|
4
|
+
import sys
|
|
5
|
+
|
|
6
|
+
requested = sys.argv[1]
|
|
7
|
+
if not requested.startswith("/") or "\n" in requested or "\r" in requested:
|
|
8
|
+
print("工作目录必须是远端绝对路径", file=sys.stderr)
|
|
9
|
+
raise SystemExit(2)
|
|
10
|
+
resolved = os.path.realpath(requested)
|
|
11
|
+
if not os.path.isdir(resolved):
|
|
12
|
+
print("工作目录不存在:" + resolved, file=sys.stderr)
|
|
13
|
+
raise SystemExit(3)
|
|
14
|
+
|
|
15
|
+
directories = []
|
|
16
|
+
truncated = False
|
|
17
|
+
try:
|
|
18
|
+
names = sorted(os.listdir(resolved), key=lambda value: value.lower())
|
|
19
|
+
for name in names:
|
|
20
|
+
candidate = os.path.join(resolved, name)
|
|
21
|
+
try:
|
|
22
|
+
if os.path.isdir(candidate):
|
|
23
|
+
directories.append({"name": name, "path": candidate})
|
|
24
|
+
except OSError:
|
|
25
|
+
continue
|
|
26
|
+
if len(directories) >= 300:
|
|
27
|
+
truncated = True
|
|
28
|
+
break
|
|
29
|
+
except OSError as error:
|
|
30
|
+
print("无法读取工作目录:" + str(error), file=sys.stderr)
|
|
31
|
+
raise SystemExit(4)
|
|
32
|
+
|
|
33
|
+
parent = os.path.dirname(resolved)
|
|
34
|
+
print(json.dumps({
|
|
35
|
+
"ok": True,
|
|
36
|
+
"cwd": resolved,
|
|
37
|
+
"parent": parent if parent != resolved else None,
|
|
38
|
+
"directories": directories,
|
|
39
|
+
"truncated": truncated,
|
|
40
|
+
}, ensure_ascii=False, separators=(",", ":")))
|
|
41
|
+
`;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { LOCAL_HOST } from "../../lib/execution-host.js";
|
|
2
|
+
export function validateDirectoryTarget({ parent, name }) {
|
|
3
|
+
if (
|
|
4
|
+
typeof parent !== "string" ||
|
|
5
|
+
!parent.startsWith("/") ||
|
|
6
|
+
parent.length > 4000 ||
|
|
7
|
+
/[\x00-\x1f\x7f]/.test(parent)
|
|
8
|
+
)
|
|
9
|
+
throw new Error("工作目录必须是远端绝对路径");
|
|
10
|
+
if (
|
|
11
|
+
typeof name !== "string" ||
|
|
12
|
+
!name.trim() ||
|
|
13
|
+
name !== name.trim() ||
|
|
14
|
+
name.length > 255 ||
|
|
15
|
+
name === "." ||
|
|
16
|
+
name === ".." ||
|
|
17
|
+
/[/\\\x00-\x1f\x7f]/.test(name)
|
|
18
|
+
)
|
|
19
|
+
throw new Error("请输入单个文件夹名称,不包含路径或控制字符");
|
|
20
|
+
return { parent, name };
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const CREATE_DIRECTORY = String.raw`
|
|
24
|
+
import base64, json, os, sys
|
|
25
|
+
target = json.loads(base64.b64decode(sys.argv[1]))
|
|
26
|
+
parent = os.path.realpath(target["parent"])
|
|
27
|
+
name = target["name"]
|
|
28
|
+
if not name or name in (".", "..") or any(c in name for c in ("/", "\\", "\x00")):
|
|
29
|
+
raise SystemExit("文件夹名称无效")
|
|
30
|
+
if not os.path.isdir(parent):
|
|
31
|
+
raise SystemExit("上级目录不存在")
|
|
32
|
+
cwd = os.path.join(parent, name)
|
|
33
|
+
try:
|
|
34
|
+
os.mkdir(cwd)
|
|
35
|
+
except FileExistsError:
|
|
36
|
+
raise SystemExit("同名文件或目录已存在,请选择已有目录或更换名称")
|
|
37
|
+
except OSError as error:
|
|
38
|
+
raise SystemExit("创建目录失败:" + str(error))
|
|
39
|
+
print(json.dumps({"cwd": cwd}, ensure_ascii=False))
|
|
40
|
+
`;
|
|
41
|
+
|
|
42
|
+
export function directoryRoutes({
|
|
43
|
+
local,
|
|
44
|
+
getHost,
|
|
45
|
+
run,
|
|
46
|
+
readJsonBody,
|
|
47
|
+
jsonResponse,
|
|
48
|
+
listScript,
|
|
49
|
+
shellQuote,
|
|
50
|
+
cleanError,
|
|
51
|
+
}) {
|
|
52
|
+
return async (request, response, url) => {
|
|
53
|
+
if (url.pathname !== "/api/remote/directories") return false;
|
|
54
|
+
if (!["GET", "POST"].includes(request.method)) {
|
|
55
|
+
jsonResponse(response, 405, { error: "不支持的请求方法" });
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
try {
|
|
59
|
+
const input =
|
|
60
|
+
request.method === "POST"
|
|
61
|
+
? await readJsonBody(request)
|
|
62
|
+
: Object.fromEntries(url.searchParams);
|
|
63
|
+
const host = getHost(input.host);
|
|
64
|
+
if (!host?.reachable) {
|
|
65
|
+
jsonResponse(response, 404, { error: "所选 SSH 主机当前不可连接" });
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
const creating = request.method === "POST";
|
|
69
|
+
if (host.alias === LOCAL_HOST && local) {
|
|
70
|
+
jsonResponse(response, 200, { host: host.alias, ...await local(input, creating) });
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
const argument = creating
|
|
74
|
+
? Buffer.from(JSON.stringify(validateDirectoryTarget(input))).toString(
|
|
75
|
+
"base64",
|
|
76
|
+
)
|
|
77
|
+
: (input.path || "/").trim().slice(0, 4000);
|
|
78
|
+
const result = await run(
|
|
79
|
+
host.alias,
|
|
80
|
+
`python3 - ${shellQuote(argument)}`,
|
|
81
|
+
creating ? CREATE_DIRECTORY : listScript,
|
|
82
|
+
20000,
|
|
83
|
+
2000000,
|
|
84
|
+
);
|
|
85
|
+
if (result.code !== 0) {
|
|
86
|
+
jsonResponse(response, 400, {
|
|
87
|
+
error: cleanError(result.stderr || result.stdout),
|
|
88
|
+
});
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
const listing = JSON.parse(result.stdout.trim());
|
|
92
|
+
jsonResponse(
|
|
93
|
+
response,
|
|
94
|
+
200,
|
|
95
|
+
creating
|
|
96
|
+
? { host: host.alias, cwd: listing.cwd }
|
|
97
|
+
: {
|
|
98
|
+
host: host.alias,
|
|
99
|
+
cwd: listing.cwd,
|
|
100
|
+
parent: listing.parent || null,
|
|
101
|
+
directories: Array.isArray(listing.directories)
|
|
102
|
+
? listing.directories
|
|
103
|
+
: [],
|
|
104
|
+
truncated: Boolean(listing.truncated),
|
|
105
|
+
},
|
|
106
|
+
);
|
|
107
|
+
} catch (error) {
|
|
108
|
+
jsonResponse(response, 400, { error: error.message });
|
|
109
|
+
}
|
|
110
|
+
return true;
|
|
111
|
+
};
|
|
112
|
+
}
|