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,34 @@
|
|
|
1
|
+
export function catalogRoutes(catalog, { jsonResponse, readJsonBody, resolveCodex }) {
|
|
2
|
+
return async (request, response, url) => {
|
|
3
|
+
if (!url.pathname.startsWith("/api/session-catalog")) return false;
|
|
4
|
+
try {
|
|
5
|
+
if (url.pathname === "/api/session-catalog" && request.method === "GET") {
|
|
6
|
+
void catalog.refresh();
|
|
7
|
+
const { state, etag } = catalog.state();
|
|
8
|
+
response.setHeader("Cache-Control", "no-cache");
|
|
9
|
+
response.setHeader("ETag", etag);
|
|
10
|
+
if (request.headers["if-none-match"] === etag) { response.writeHead(304); response.end(); }
|
|
11
|
+
else jsonResponse(response, 200, state);
|
|
12
|
+
} else if (url.pathname === "/api/session-catalog/scan" && request.method === "POST") {
|
|
13
|
+
void catalog.refresh(true);
|
|
14
|
+
jsonResponse(response, 202, { scanning: true });
|
|
15
|
+
} else if (url.pathname === "/api/session-catalog/dialogue" && request.method === "GET") {
|
|
16
|
+
response.setHeader("Cache-Control", "no-store");
|
|
17
|
+
jsonResponse(response, 200, await catalog.dialogue(url.searchParams.get("key"), {
|
|
18
|
+
before: url.searchParams.get("before"), version: url.searchParams.get("version"),
|
|
19
|
+
}));
|
|
20
|
+
} else if (url.pathname === "/api/session-catalog/subagent-workflow" && request.method === "GET") {
|
|
21
|
+
response.setHeader("Cache-Control", "no-store");
|
|
22
|
+
jsonResponse(response, 200, await catalog.subagentWorkflow(url.searchParams.get("key"), {
|
|
23
|
+
subagentId: url.searchParams.get("subagentId"),
|
|
24
|
+
version: url.searchParams.get("version"),
|
|
25
|
+
}));
|
|
26
|
+
} else if (url.pathname === "/api/session-catalog/select" && request.method === "POST") {
|
|
27
|
+
const entry = catalog.get((await readJsonBody(request)).key);
|
|
28
|
+
if (!entry || entry.provider !== "codex") throw new Error("不是 Codex 会话");
|
|
29
|
+
jsonResponse(response, 200, { agent: resolveCodex(entry) });
|
|
30
|
+
} else jsonResponse(response, 404, { error: "接口不存在" });
|
|
31
|
+
} catch (error) { jsonResponse(response, 400, { error: error.message }); }
|
|
32
|
+
return true;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
export function sessionProfileKey(slug) {
|
|
2
|
+
if (!/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,47}$/.test(slug || "")) {
|
|
3
|
+
throw new Error("Profile 标识无效");
|
|
4
|
+
}
|
|
5
|
+
return `account-${slug}`;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function profileFromConnection(key) {
|
|
9
|
+
if (!String(key || "").startsWith("account-")) return null;
|
|
10
|
+
const slug = key.slice(8);
|
|
11
|
+
sessionProfileKey(slug);
|
|
12
|
+
return slug;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function boundConnectionKey(binding, persistedKey = "active") {
|
|
16
|
+
// A restart between writer transfer and committing the assignment must keep
|
|
17
|
+
// the already-persisted target, not revive the previous account.
|
|
18
|
+
if (binding?.status === "switching" && binding.desiredProfile &&
|
|
19
|
+
persistedKey === sessionProfileKey(binding.desiredProfile)) return persistedKey;
|
|
20
|
+
return binding?.profile ? sessionProfileKey(binding.profile) : persistedKey;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function profileHandoffPending(binding) {
|
|
24
|
+
return Boolean(binding?.handoff && binding.status !== "applied");
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Persist intent separately from the current writer. Never claim a queued or
|
|
28
|
+
// failed migration changed the account, and never fall back to another account.
|
|
29
|
+
export class SessionProfileAssignments {
|
|
30
|
+
constructor({ read, write, session, blocked, verify, migrate,
|
|
31
|
+
hold = () => {}, release = async () => {}, restore = async () => {}, now = () => Date.now() }) {
|
|
32
|
+
Object.assign(this, { read, write, session, blocked, verify, migrate, hold, release, restore, now });
|
|
33
|
+
this.running = new Set();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async assign(host, sessionId, slug) {
|
|
37
|
+
sessionProfileKey(slug);
|
|
38
|
+
const key = `${host}:${sessionId}`;
|
|
39
|
+
if (this.running.has(key)) throw new Error("该 Session 正在切换账号,请稍后再试");
|
|
40
|
+
const current = this.session(host, sessionId);
|
|
41
|
+
if (!current) throw new Error("请先将这个 Session 恢复到 App Server");
|
|
42
|
+
if (profileHandoffPending(this.read(host, sessionId))) throw new Error("旧账号正在释放 writer;请等待或先取消交接,再选择其他账号");
|
|
43
|
+
this.running.add(key);
|
|
44
|
+
try {
|
|
45
|
+
await this.write(host, sessionId, {
|
|
46
|
+
...this.read(host, sessionId), desiredProfile: slug,
|
|
47
|
+
status: "queued", error: null,
|
|
48
|
+
});
|
|
49
|
+
} finally { this.running.delete(key); }
|
|
50
|
+
return this.apply(host, sessionId);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async cancel(host, sessionId) {
|
|
54
|
+
const key = `${host}:${sessionId}`;
|
|
55
|
+
if (this.running.has(key)) throw new Error("正在交接 writer,请等待本次检查完成后取消");
|
|
56
|
+
const current = this.read(host, sessionId);
|
|
57
|
+
if (!current || current.status === "applied") return current;
|
|
58
|
+
this.running.add(key);
|
|
59
|
+
try {
|
|
60
|
+
if (profileHandoffPending(current)) await this.restore(host, sessionId, current.handoff.source);
|
|
61
|
+
const restored = current.profile ? { profile: current.profile, desiredProfile: current.profile,
|
|
62
|
+
status: "applied", error: null } : null;
|
|
63
|
+
await this.write(host, sessionId, restored);
|
|
64
|
+
return restored;
|
|
65
|
+
} finally { this.running.delete(key); }
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
async apply(host, sessionId) {
|
|
69
|
+
const key = `${host}:${sessionId}`;
|
|
70
|
+
let intent = this.read(host, sessionId);
|
|
71
|
+
if (!intent || !["queued", "switching", "waiting-writer"].includes(intent.status) || this.running.has(key)) return intent;
|
|
72
|
+
if ((intent.nextAttemptAt || 0) > this.now()) return intent;
|
|
73
|
+
const current = this.session(host, sessionId);
|
|
74
|
+
if (!current || (!profileHandoffPending(intent) && (current.status === "offline" || this.blocked(host, sessionId)))) return intent;
|
|
75
|
+
this.running.add(key);
|
|
76
|
+
try {
|
|
77
|
+
if (!profileHandoffPending(intent)) {
|
|
78
|
+
await this.write(host, sessionId, { ...intent, status: "switching", error: null });
|
|
79
|
+
const account = await this.verify(host, intent.desiredProfile, current.executable);
|
|
80
|
+
if (this.blocked(host, sessionId)) {
|
|
81
|
+
await this.write(host, sessionId, { ...intent, status: "queued", error: null });
|
|
82
|
+
return this.read(host, sessionId);
|
|
83
|
+
}
|
|
84
|
+
const latest = this.session(host, sessionId);
|
|
85
|
+
this.hold(host, sessionId);
|
|
86
|
+
const source = Object.fromEntries(["host", "sessionId", "path", "cwd", "model", "effort", "yolo", "executable", "connectionKey", "resumeOnRecovery"]
|
|
87
|
+
.map((field) => [field, latest[field]]));
|
|
88
|
+
intent = { ...intent, status: "waiting-writer", error: null, targetAccount: account,
|
|
89
|
+
handoff: { source, released: false, startedAt: this.now() } };
|
|
90
|
+
await this.write(host, sessionId, intent);
|
|
91
|
+
}
|
|
92
|
+
if (!intent.handoff.released) {
|
|
93
|
+
await this.release(host, sessionId, intent.handoff.source);
|
|
94
|
+
intent = { ...intent, handoff: { ...intent.handoff, released: true, releasedAt: this.now() } };
|
|
95
|
+
await this.write(host, sessionId, intent);
|
|
96
|
+
}
|
|
97
|
+
await this.migrate(host, sessionId, sessionProfileKey(intent.desiredProfile), current.executable, intent.handoff.source);
|
|
98
|
+
await this.write(host, sessionId, {
|
|
99
|
+
profile: intent.desiredProfile, desiredProfile: intent.desiredProfile,
|
|
100
|
+
status: "applied", account: intent.targetAccount, verifiedAt: new Date(this.now()).toISOString(), error: null,
|
|
101
|
+
});
|
|
102
|
+
} catch (error) {
|
|
103
|
+
if (profileHandoffPending(intent) && /already has an active writer|connection reset|disconnected|连接|超时|timeout|ECONN|远端 app-server 已退出/i.test(error.message)) {
|
|
104
|
+
// Crucially, do not resume the source: doing so restarts its 30 minute
|
|
105
|
+
// inactivity grace period. The timer retries only the target writer.
|
|
106
|
+
await this.write(host, sessionId, { ...intent, status: "waiting-writer",
|
|
107
|
+
error: /already has an active writer/i.test(error.message) ? null : `连接暂时不可用,后台将重试:${error.message}`,
|
|
108
|
+
nextAttemptAt: this.now() + 30_000 });
|
|
109
|
+
} else {
|
|
110
|
+
await this.write(host, sessionId, { ...intent, status: "failed", error: error.message, nextAttemptAt: null });
|
|
111
|
+
}
|
|
112
|
+
} finally { this.running.delete(key); }
|
|
113
|
+
return this.read(host, sessionId);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { isIP } from "node:net";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { createPrivateGateway, loadOrCreatePrivateAccessToken } from "./private-gateway.mjs";
|
|
6
|
+
|
|
7
|
+
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
8
|
+
const directory = path.join(root, ".scope", "shared-access");
|
|
9
|
+
const config = JSON.parse(await readFile(path.join(directory, "config.json"), "utf8"));
|
|
10
|
+
if (!isIP(config.host) || ["0.0.0.0", "::"].includes(config.host) ||
|
|
11
|
+
!Array.isArray(config.allowedClients) || !config.allowedClients.length ||
|
|
12
|
+
config.allowedClients.some(address => !isIP(address)) ||
|
|
13
|
+
!Number.isInteger(config.port) || config.port < 1024 || config.port > 65535) {
|
|
14
|
+
throw new Error("Shared access requires a specific local IP, port and explicit client IP allowlist");
|
|
15
|
+
}
|
|
16
|
+
const token = await loadOrCreatePrivateAccessToken(path.join(directory, "access.json"));
|
|
17
|
+
const server = createPrivateGateway({ token, allowedClients: config.allowedClients, tls: {
|
|
18
|
+
key: await readFile(path.join(directory, "server.key")),
|
|
19
|
+
cert: await readFile(path.join(directory, "server.crt")),
|
|
20
|
+
} });
|
|
21
|
+
server.listen(config.port, config.host, () => console.log(`SCOPE shared access: https://${config.host}:${config.port}`));
|
|
22
|
+
for (const signal of ["SIGINT", "SIGTERM"]) process.on(signal, () => server.close(() => process.exit(0)));
|
package/bridge/start.mjs
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { connect } from "node:net";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
|
|
6
|
+
const UI_PORT = Number(process.env.SCOPE_UI_PORT || 3000);
|
|
7
|
+
const BRIDGE_PORT = Number(process.env.SCOPE_BRIDGE_PORT || 4815);
|
|
8
|
+
const developmentMode = process.argv.includes("--dev");
|
|
9
|
+
const forceBuild = process.argv.includes("--build");
|
|
10
|
+
const skipBuild = process.argv.includes("--skip-build");
|
|
11
|
+
|
|
12
|
+
function portIsOpen(port) {
|
|
13
|
+
return new Promise((resolve) => {
|
|
14
|
+
const socket = connect({ host: "127.0.0.1", port });
|
|
15
|
+
const finish = (open) => {
|
|
16
|
+
socket.removeAllListeners();
|
|
17
|
+
socket.destroy();
|
|
18
|
+
resolve(open);
|
|
19
|
+
};
|
|
20
|
+
socket.setTimeout(800);
|
|
21
|
+
socket.once("connect", () => finish(true));
|
|
22
|
+
socket.once("error", () => finish(false));
|
|
23
|
+
socket.once("timeout", () => finish(false));
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async function isScopeBridge() {
|
|
28
|
+
try {
|
|
29
|
+
const healthResponse = await fetch(
|
|
30
|
+
`http://127.0.0.1:${BRIDGE_PORT}/api/health`,
|
|
31
|
+
{
|
|
32
|
+
signal: AbortSignal.timeout(5_000),
|
|
33
|
+
},
|
|
34
|
+
);
|
|
35
|
+
if (healthResponse.ok) {
|
|
36
|
+
const health = await healthResponse.json();
|
|
37
|
+
if (health?.service === "scope-bridge") return true;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const response = await fetch(`http://127.0.0.1:${BRIDGE_PORT}/api/snapshot`, {
|
|
41
|
+
signal: AbortSignal.timeout(5_000),
|
|
42
|
+
});
|
|
43
|
+
if (!response.ok) return false;
|
|
44
|
+
const snapshot = await response.json();
|
|
45
|
+
return (
|
|
46
|
+
typeof snapshot?.sshConfig === "string" && Array.isArray(snapshot?.hosts)
|
|
47
|
+
);
|
|
48
|
+
} catch {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async function isScopeUi() {
|
|
54
|
+
try {
|
|
55
|
+
const response = await fetch(`http://127.0.0.1:${UI_PORT}/`, {
|
|
56
|
+
signal: AbortSignal.timeout(5_000),
|
|
57
|
+
});
|
|
58
|
+
if (!response.ok) return false;
|
|
59
|
+
const html = await response.text();
|
|
60
|
+
return html.includes("SCOPE") && (html.includes("跨项目 Agent 工作台") || html.includes("SSH Codex Monitor"));
|
|
61
|
+
} catch {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const [uiPortOpen, bridgePortOpen] = await Promise.all([
|
|
67
|
+
portIsOpen(UI_PORT),
|
|
68
|
+
portIsOpen(BRIDGE_PORT),
|
|
69
|
+
]);
|
|
70
|
+
|
|
71
|
+
if (uiPortOpen || bridgePortOpen) {
|
|
72
|
+
const [scopeUi, scopeBridge] = await Promise.all([
|
|
73
|
+
uiPortOpen ? isScopeUi() : false,
|
|
74
|
+
bridgePortOpen ? isScopeBridge() : false,
|
|
75
|
+
]);
|
|
76
|
+
if (scopeUi && scopeBridge) {
|
|
77
|
+
console.log(
|
|
78
|
+
`SCOPE 已在运行:http://localhost:${UI_PORT}(Bridge ${BRIDGE_PORT})`,
|
|
79
|
+
);
|
|
80
|
+
process.exit(0);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const occupied = [
|
|
84
|
+
uiPortOpen ? UI_PORT : null,
|
|
85
|
+
bridgePortOpen ? BRIDGE_PORT : null,
|
|
86
|
+
].filter(Boolean);
|
|
87
|
+
console.error(
|
|
88
|
+
`[scope] 无法启动:本机端口 ${occupied.join(", ")} 已被其他或不完整的服务占用。`,
|
|
89
|
+
);
|
|
90
|
+
process.exit(1);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const bridgeEntry = fileURLToPath(new URL("./server.mjs", import.meta.url));
|
|
94
|
+
const vinextEntry = fileURLToPath(
|
|
95
|
+
new URL("../node_modules/vinext/dist/cli.js", import.meta.url),
|
|
96
|
+
);
|
|
97
|
+
const uiEntry = fileURLToPath(new URL("./ui-server.mjs", import.meta.url));
|
|
98
|
+
const prebuiltServerEntry = fileURLToPath(
|
|
99
|
+
new URL("../dist/server/index.js", import.meta.url),
|
|
100
|
+
);
|
|
101
|
+
const shouldBuild =
|
|
102
|
+
!developmentMode &&
|
|
103
|
+
!skipBuild &&
|
|
104
|
+
(forceBuild || !existsSync(prebuiltServerEntry) || existsSync(vinextEntry));
|
|
105
|
+
|
|
106
|
+
if (shouldBuild && !existsSync(vinextEntry)) {
|
|
107
|
+
if (existsSync(prebuiltServerEntry)) {
|
|
108
|
+
console.log("[scope] Using prebuilt UI bundle.");
|
|
109
|
+
} else {
|
|
110
|
+
console.error("[scope] Missing prebuilt dist/ bundle and vinext build tool.");
|
|
111
|
+
process.exit(1);
|
|
112
|
+
}
|
|
113
|
+
} else if (shouldBuild) {
|
|
114
|
+
console.log("[scope] Building the stable local UI...");
|
|
115
|
+
const buildCode = await new Promise((resolve, reject) => {
|
|
116
|
+
const build = spawn(process.execPath, [vinextEntry, "build"], {
|
|
117
|
+
stdio: "inherit",
|
|
118
|
+
});
|
|
119
|
+
build.once("error", reject);
|
|
120
|
+
build.once("exit", (code) => resolve(code ?? 1));
|
|
121
|
+
});
|
|
122
|
+
if (buildCode !== 0) {
|
|
123
|
+
console.error(`[scope] UI build failed with exit code ${buildCode}`);
|
|
124
|
+
process.exit(buildCode);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const childSpecs = [
|
|
129
|
+
{ name: "Bridge", args: [bridgeEntry] },
|
|
130
|
+
{
|
|
131
|
+
name: "UI",
|
|
132
|
+
args: developmentMode
|
|
133
|
+
? [
|
|
134
|
+
vinextEntry,
|
|
135
|
+
"dev",
|
|
136
|
+
"--hostname",
|
|
137
|
+
"127.0.0.1",
|
|
138
|
+
"--port",
|
|
139
|
+
String(UI_PORT),
|
|
140
|
+
]
|
|
141
|
+
: [
|
|
142
|
+
uiEntry,
|
|
143
|
+
"--hostname",
|
|
144
|
+
"127.0.0.1",
|
|
145
|
+
"--port",
|
|
146
|
+
String(UI_PORT),
|
|
147
|
+
],
|
|
148
|
+
},
|
|
149
|
+
];
|
|
150
|
+
let stopping = false;
|
|
151
|
+
const children = new Set();
|
|
152
|
+
const restartAttempts = new Map();
|
|
153
|
+
const restartTimers = new Set();
|
|
154
|
+
|
|
155
|
+
function launchChild(spec) {
|
|
156
|
+
if (stopping) return;
|
|
157
|
+
const startedAt = Date.now();
|
|
158
|
+
const child = spawn(process.execPath, spec.args, { stdio: "inherit" });
|
|
159
|
+
children.add(child);
|
|
160
|
+
child.on("exit", (code, signal) => {
|
|
161
|
+
children.delete(child);
|
|
162
|
+
if (stopping) return;
|
|
163
|
+
const previousAttempts =
|
|
164
|
+
Date.now() - startedAt >= 60_000
|
|
165
|
+
? 0
|
|
166
|
+
: restartAttempts.get(spec.name) || 0;
|
|
167
|
+
const attempts = previousAttempts + 1;
|
|
168
|
+
restartAttempts.set(spec.name, attempts);
|
|
169
|
+
if (attempts > 5) {
|
|
170
|
+
console.error(
|
|
171
|
+
`[scope] ${spec.name} 连续退出 ${attempts} 次;停止 SCOPE 以避免重启循环`,
|
|
172
|
+
);
|
|
173
|
+
stop(code ?? 1);
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
const delay = Math.min(10_000, 1_000 * 2 ** (attempts - 1));
|
|
177
|
+
console.error(
|
|
178
|
+
`[scope] ${spec.name} exited (${signal || `code ${code ?? 1}`}); ` +
|
|
179
|
+
`${Math.round(delay / 1_000)} 秒后自动重启`,
|
|
180
|
+
);
|
|
181
|
+
const timer = setTimeout(() => {
|
|
182
|
+
restartTimers.delete(timer);
|
|
183
|
+
launchChild(spec);
|
|
184
|
+
}, delay);
|
|
185
|
+
restartTimers.add(timer);
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function stop(exitCode = 0) {
|
|
190
|
+
if (stopping) return;
|
|
191
|
+
stopping = true;
|
|
192
|
+
|
|
193
|
+
for (const timer of restartTimers) clearTimeout(timer);
|
|
194
|
+
restartTimers.clear();
|
|
195
|
+
for (const child of children) {
|
|
196
|
+
if (!child.killed) child.kill("SIGTERM");
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
setTimeout(() => process.exit(exitCode), 1_000);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
for (const spec of childSpecs) launchChild(spec);
|
|
203
|
+
|
|
204
|
+
process.on("SIGINT", () => stop(0));
|
|
205
|
+
process.on("SIGTERM", () => stop(0));
|