scope-agent-workbench 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -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 +21 -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 +347 -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 +636 -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 +341 -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 +159 -0
- package/bridge/routes/accounts.mjs +326 -0
- package/bridge/routes/dialogue.mjs +120 -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 +3332 -0
- package/bridge/session-attachments.mjs +150 -0
- package/bridge/session-cache-archive.mjs +22 -0
- package/bridge/session-catalog/agy-history.py +249 -0
- package/bridge/session-catalog/catalog.mjs +93 -0
- package/bridge/session-catalog/probe.py +331 -0
- package/bridge/session-catalog/routes.mjs +28 -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 +397 -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-CNnP2Ses.css +2 -0
- package/dist/client/assets/index-Enu1x0PS.js +3 -0
- package/dist/client/assets/layout-segment-context-CmJzExWq.js +1 -0
- package/dist/client/assets/page-COBv6VWj.css +1 -0
- package/dist/client/assets/page-DVjU6VG_.js +550 -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-COBv6VWj.css +1 -0
- package/dist/server/ssr/assets/page-CYYyCnKD.js +102541 -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/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 +307 -0
- package/scripts/fixtures/workbench-conversations.mjs +352 -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,215 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { JsonlAppServerConnection } from "./app-server-client.mjs";
|
|
3
|
+
|
|
4
|
+
const PROFILE_NAME_PATTERN = /^[\p{L}\p{N}][\p{L}\p{N} ._-]{0,47}$/u;
|
|
5
|
+
|
|
6
|
+
export function normalizeProfileName(value) {
|
|
7
|
+
const name = String(value || "").trim().replace(/\s+/g, " ");
|
|
8
|
+
if (!PROFILE_NAME_PATTERN.test(name)) {
|
|
9
|
+
throw new Error("Profile 名称需为 1–48 个字母、数字、空格、点、下划线或短横线");
|
|
10
|
+
}
|
|
11
|
+
const slug = name
|
|
12
|
+
.normalize("NFKD")
|
|
13
|
+
.replace(/[^a-zA-Z0-9._-]+/g, "-")
|
|
14
|
+
.replace(/^-+|-+$/g, "")
|
|
15
|
+
.slice(0, 48);
|
|
16
|
+
return { name, slug: slug || `profile-${randomUUID().slice(0, 8)}` };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function publicAccount(accountResponse) {
|
|
20
|
+
const account = accountResponse?.account;
|
|
21
|
+
if (!account || typeof account !== "object") return null;
|
|
22
|
+
if (account.type === "chatgpt") {
|
|
23
|
+
return {
|
|
24
|
+
type: "chatgpt",
|
|
25
|
+
email: typeof account.email === "string" ? account.email.slice(0, 320) : "",
|
|
26
|
+
planType:
|
|
27
|
+
typeof account.planType === "string" ? account.planType.slice(0, 80) : "unknown",
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
if (["apiKey", "amazonBedrock"].includes(account.type)) {
|
|
31
|
+
return { type: account.type, email: "", planType: "" };
|
|
32
|
+
}
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export class AuthProfileManager {
|
|
37
|
+
constructor({
|
|
38
|
+
spawnConnection,
|
|
39
|
+
prepareProfile,
|
|
40
|
+
finalizeProfile,
|
|
41
|
+
cancelProfile,
|
|
42
|
+
requestTimeoutMs = 45_000,
|
|
43
|
+
now = () => Date.now(),
|
|
44
|
+
}) {
|
|
45
|
+
this.spawnConnection = spawnConnection;
|
|
46
|
+
this.prepareProfile = prepareProfile;
|
|
47
|
+
this.finalizeProfile = finalizeProfile;
|
|
48
|
+
this.cancelProfile = cancelProfile;
|
|
49
|
+
this.requestTimeoutMs = requestTimeoutMs;
|
|
50
|
+
this.now = now;
|
|
51
|
+
this.jobs = new Map();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async start({ host, executable = "codex", profileName }) {
|
|
55
|
+
const profile = normalizeProfileName(profileName);
|
|
56
|
+
const existing = Array.from(this.jobs.values()).find(
|
|
57
|
+
(job) =>
|
|
58
|
+
job.host === host &&
|
|
59
|
+
job.profile.slug === profile.slug &&
|
|
60
|
+
["starting", "waiting"].includes(job.status),
|
|
61
|
+
);
|
|
62
|
+
if (existing) return this.publicJob(existing);
|
|
63
|
+
|
|
64
|
+
await this.prepareProfile(host, profile);
|
|
65
|
+
const job = {
|
|
66
|
+
id: randomUUID(),
|
|
67
|
+
host,
|
|
68
|
+
profile,
|
|
69
|
+
status: "starting",
|
|
70
|
+
verificationUrl: "",
|
|
71
|
+
userCode: "",
|
|
72
|
+
loginId: "",
|
|
73
|
+
error: null,
|
|
74
|
+
account: null,
|
|
75
|
+
startedAt: new Date(this.now()).toISOString(),
|
|
76
|
+
completedAt: null,
|
|
77
|
+
connection: null,
|
|
78
|
+
};
|
|
79
|
+
this.jobs.set(job.id, job);
|
|
80
|
+
|
|
81
|
+
try {
|
|
82
|
+
const child = this.spawnConnection({ host, executable, profile });
|
|
83
|
+
const connection = new JsonlAppServerConnection({
|
|
84
|
+
host: `${host}:${profile.slug}`,
|
|
85
|
+
child,
|
|
86
|
+
requestTimeoutMs: this.requestTimeoutMs,
|
|
87
|
+
now: this.now,
|
|
88
|
+
});
|
|
89
|
+
job.connection = connection;
|
|
90
|
+
connection.on("notification", (message) => {
|
|
91
|
+
if (
|
|
92
|
+
message.method === "account/login/completed" &&
|
|
93
|
+
(!message.params?.loginId || message.params.loginId === job.loginId)
|
|
94
|
+
) {
|
|
95
|
+
this.#complete(job, message.params).catch((error) =>
|
|
96
|
+
this.#fail(job, error),
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
connection.on("close", (error) => {
|
|
101
|
+
if (["starting", "waiting"].includes(job.status)) this.#fail(job, error);
|
|
102
|
+
});
|
|
103
|
+
await connection.start();
|
|
104
|
+
const login = await connection.request("account/login/start", {
|
|
105
|
+
type: "chatgptDeviceCode",
|
|
106
|
+
});
|
|
107
|
+
if (
|
|
108
|
+
login?.type !== "chatgptDeviceCode" ||
|
|
109
|
+
!login.loginId ||
|
|
110
|
+
!login.userCode ||
|
|
111
|
+
!login.verificationUrl
|
|
112
|
+
) {
|
|
113
|
+
throw new Error("远端 Codex 未返回完整的 device auth 信息");
|
|
114
|
+
}
|
|
115
|
+
let verificationUrl;
|
|
116
|
+
try {
|
|
117
|
+
verificationUrl = new URL(String(login.verificationUrl));
|
|
118
|
+
} catch {
|
|
119
|
+
throw new Error("远端 Codex 返回的 device auth URL 无效");
|
|
120
|
+
}
|
|
121
|
+
if (verificationUrl.protocol !== "https:") {
|
|
122
|
+
throw new Error("远端 Codex 返回了非 HTTPS 的 device auth URL");
|
|
123
|
+
}
|
|
124
|
+
job.loginId = String(login.loginId);
|
|
125
|
+
job.userCode = String(login.userCode);
|
|
126
|
+
job.verificationUrl = verificationUrl.toString();
|
|
127
|
+
job.status = "waiting";
|
|
128
|
+
return this.publicJob(job);
|
|
129
|
+
} catch (error) {
|
|
130
|
+
this.#fail(job, error);
|
|
131
|
+
throw error;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
get(id) {
|
|
136
|
+
const job = this.jobs.get(String(id || ""));
|
|
137
|
+
return job ? this.publicJob(job) : null;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
async cancel(id) {
|
|
141
|
+
const job = this.jobs.get(String(id || ""));
|
|
142
|
+
if (!job) throw new Error("找不到这条登录任务");
|
|
143
|
+
if (["completed", "failed", "cancelled"].includes(job.status)) {
|
|
144
|
+
return this.publicJob(job);
|
|
145
|
+
}
|
|
146
|
+
try {
|
|
147
|
+
if (job.loginId && job.connection && !job.connection.closed) {
|
|
148
|
+
await job.connection.request("account/login/cancel", {
|
|
149
|
+
loginId: job.loginId,
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
} finally {
|
|
153
|
+
job.status = "cancelled";
|
|
154
|
+
job.completedAt = new Date(this.now()).toISOString();
|
|
155
|
+
job.connection?.close();
|
|
156
|
+
job.connection = null;
|
|
157
|
+
await this.cancelProfile?.(job.host, job.profile).catch(() => {});
|
|
158
|
+
}
|
|
159
|
+
return this.publicJob(job);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
async cancelForProfile(host, slug) {
|
|
163
|
+
const matches = Array.from(this.jobs.values()).filter(
|
|
164
|
+
(job) =>
|
|
165
|
+
job.host === host &&
|
|
166
|
+
job.profile.slug === slug &&
|
|
167
|
+
["starting", "waiting"].includes(job.status),
|
|
168
|
+
);
|
|
169
|
+
for (const job of matches) await this.cancel(job.id);
|
|
170
|
+
return matches.length;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
publicJob(job) {
|
|
174
|
+
return {
|
|
175
|
+
id: job.id,
|
|
176
|
+
host: job.host,
|
|
177
|
+
profile: { ...job.profile },
|
|
178
|
+
status: job.status,
|
|
179
|
+
verificationUrl: job.verificationUrl,
|
|
180
|
+
userCode: job.userCode,
|
|
181
|
+
error: job.error,
|
|
182
|
+
account: job.account,
|
|
183
|
+
startedAt: job.startedAt,
|
|
184
|
+
completedAt: job.completedAt,
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
close() {
|
|
189
|
+
for (const job of this.jobs.values()) job.connection?.close();
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
async #complete(job, result) {
|
|
193
|
+
if (!result?.success) {
|
|
194
|
+
throw new Error(result?.error || "Device auth 未完成");
|
|
195
|
+
}
|
|
196
|
+
const response = await job.connection.request("account/read", {
|
|
197
|
+
refreshToken: false,
|
|
198
|
+
});
|
|
199
|
+
job.account = publicAccount(response);
|
|
200
|
+
await this.finalizeProfile(job.host, job.profile, job.account);
|
|
201
|
+
job.status = "completed";
|
|
202
|
+
job.completedAt = new Date(this.now()).toISOString();
|
|
203
|
+
job.connection.close();
|
|
204
|
+
job.connection = null;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
#fail(job, error) {
|
|
208
|
+
if (["completed", "cancelled", "failed"].includes(job.status)) return;
|
|
209
|
+
job.status = "failed";
|
|
210
|
+
job.error = error instanceof Error ? error.message : String(error || "登录失败");
|
|
211
|
+
job.completedAt = new Date(this.now()).toISOString();
|
|
212
|
+
job.connection?.close();
|
|
213
|
+
job.connection = null;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
export const CAPACITY_CONTINUE_PROMPT = "继续";
|
|
2
|
+
|
|
3
|
+
export const DEFAULT_CAPACITY_RETRY_DELAYS_MS = Object.freeze([
|
|
4
|
+
3_000,
|
|
5
|
+
10_000,
|
|
6
|
+
30_000,
|
|
7
|
+
60_000,
|
|
8
|
+
120_000,
|
|
9
|
+
]);
|
|
10
|
+
|
|
11
|
+
const MODEL_CAPACITY_PATTERN = /selected model is(?: currently)? at capacity/i;
|
|
12
|
+
// Codex occasionally accepts a turn and then receives an edge/backend error
|
|
13
|
+
// from its own Responses endpoint. Limit retries to this exact endpoint and
|
|
14
|
+
// retryable statuses; ordinary 404s from a user's command are never retried.
|
|
15
|
+
const TRANSIENT_CODEX_BACKEND_PATTERN =
|
|
16
|
+
/unexpected status\s+(?:404|408|429|500|502|503|504)\b[\s\S]{0,1000}chatgpt\.com\/backend-api\/codex\/responses/i;
|
|
17
|
+
|
|
18
|
+
export function errorText(value, limit = 30_000) {
|
|
19
|
+
const parts = [];
|
|
20
|
+
const seen = new Set();
|
|
21
|
+
|
|
22
|
+
function visit(candidate, depth) {
|
|
23
|
+
if (parts.join("\n").length >= limit || depth > 6 || candidate == null) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if (typeof candidate === "string") {
|
|
27
|
+
if (candidate) parts.push(candidate);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (["number", "boolean", "bigint"].includes(typeof candidate)) {
|
|
31
|
+
parts.push(String(candidate));
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (typeof candidate !== "object" || seen.has(candidate)) return;
|
|
35
|
+
seen.add(candidate);
|
|
36
|
+
if (candidate instanceof Error) {
|
|
37
|
+
visit(candidate.message, depth + 1);
|
|
38
|
+
visit(candidate.cause, depth + 1);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (Array.isArray(candidate)) {
|
|
42
|
+
for (const item of candidate) visit(item, depth + 1);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const preferredKeys = [
|
|
46
|
+
"message",
|
|
47
|
+
"error",
|
|
48
|
+
"additionalDetails",
|
|
49
|
+
"codexErrorInfo",
|
|
50
|
+
"details",
|
|
51
|
+
"turn",
|
|
52
|
+
"data",
|
|
53
|
+
];
|
|
54
|
+
const keys = [
|
|
55
|
+
...preferredKeys.filter((key) => key in candidate),
|
|
56
|
+
...Object.keys(candidate).filter((key) => !preferredKeys.includes(key)),
|
|
57
|
+
];
|
|
58
|
+
for (const key of keys) visit(candidate[key], depth + 1);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
visit(value, 0);
|
|
62
|
+
return parts.join("\n").slice(0, limit);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function isModelCapacityError(value) {
|
|
66
|
+
return MODEL_CAPACITY_PATTERN.test(errorText(value));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function isTransientCodexBackendError(value) {
|
|
70
|
+
return TRANSIENT_CODEX_BACKEND_PATTERN.test(errorText(value));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function countModelCapacityWarnings(value) {
|
|
74
|
+
return (String(value || "").match(
|
|
75
|
+
/selected model is(?: currently)? at capacity/gi,
|
|
76
|
+
) || []).length;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function hasUnansweredModelCapacityWarning(value) {
|
|
80
|
+
const text = String(value || "");
|
|
81
|
+
const matches = Array.from(
|
|
82
|
+
text.matchAll(/selected model is(?: currently)? at capacity/gi),
|
|
83
|
+
);
|
|
84
|
+
const latest = matches.at(-1);
|
|
85
|
+
if (!latest) return false;
|
|
86
|
+
const tail = text.slice((latest.index || 0) + latest[0].length);
|
|
87
|
+
// Codex TUI keeps submitted user prompts in scrollback as `› text`. If a
|
|
88
|
+
// non-empty prompt follows the latest warning, that warning was handled.
|
|
89
|
+
return !/(?:^|\n)\s*[›»>]\s+\S/m.test(tail);
|
|
90
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { shellQuote } from "./transport/ssh-command.mjs";
|
|
2
|
+
|
|
3
|
+
// Upgrade installation, then reuse the guarded account-preserving restart.
|
|
4
|
+
export function stableVersion(value) {
|
|
5
|
+
if (typeof value !== "string" || !/^\d+\.\d+\.\d+$/.test(value)) throw new Error("无效的 Codex 稳定版本");
|
|
6
|
+
return value;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function wrapCodexUpgradeCommand(script, preCommand = "") {
|
|
10
|
+
const setup = String(preCommand || "").trim();
|
|
11
|
+
if (!setup) {
|
|
12
|
+
return { command: "python3 -", stdin: script };
|
|
13
|
+
}
|
|
14
|
+
const encoded = Buffer.from(script, "utf8").toString("base64");
|
|
15
|
+
const inner = [
|
|
16
|
+
setup,
|
|
17
|
+
"scope_setup_status=$?",
|
|
18
|
+
'if [ "$scope_setup_status" -ne 0 ]; then exit "$scope_setup_status"; fi',
|
|
19
|
+
`exec python3 -c ${shellQuote(`import base64; exec(compile(base64.b64decode(${JSON.stringify(encoded)}).decode("utf-8"), "<scope-codex-upgrade>", "exec"))`)}`,
|
|
20
|
+
].join("\n");
|
|
21
|
+
// Interactive bash loads ~/.bashrc aliases/functions; stdin is closed so
|
|
22
|
+
// bash -i never blocks waiting for a terminal.
|
|
23
|
+
return { command: `bash -ic ${shellQuote(inner)} </dev/null`, stdin: "" };
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function parseCodexUpgradeOutput(stdout) {
|
|
27
|
+
const lines = String(stdout || "").split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
|
|
28
|
+
const marked = lines.findLast((line) => line.startsWith("SCOPE_CODEX_UPGRADE_RESULT="));
|
|
29
|
+
if (marked) return JSON.parse(marked.slice("SCOPE_CODEX_UPGRADE_RESULT=".length));
|
|
30
|
+
const jsonLine = lines.findLast((line) => line.startsWith("{") && line.endsWith("}"));
|
|
31
|
+
return JSON.parse(jsonLine || String(stdout || "").trim());
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function remoteCodexUpgradeScript(target = null, knownLatest = null) {
|
|
35
|
+
if (target !== null) stableVersion(target);
|
|
36
|
+
if (knownLatest !== null) stableVersion(knownLatest);
|
|
37
|
+
return [
|
|
38
|
+
"import json, os, re, shutil, subprocess, tempfile, fcntl, signal",
|
|
39
|
+
"from pathlib import Path",
|
|
40
|
+
"def _extend_path():",
|
|
41
|
+
" extra = [Path.home() / '.local/bin', Path.home() / '.cargo/bin']",
|
|
42
|
+
" nvm_root = Path.home() / '.nvm/versions/node'",
|
|
43
|
+
" if nvm_root.is_dir():",
|
|
44
|
+
" extra.extend(sorted(nvm_root.glob('*/bin'), reverse=True))",
|
|
45
|
+
" extra.append(Path('/usr/local/bin'))",
|
|
46
|
+
" current = [p for p in os.environ.get('PATH', '').split(os.pathsep) if p]",
|
|
47
|
+
" for candidate in reversed(extra):",
|
|
48
|
+
" text = str(candidate)",
|
|
49
|
+
" if candidate.is_dir() and text not in current:",
|
|
50
|
+
" current.insert(0, text)",
|
|
51
|
+
" os.environ['PATH'] = os.pathsep.join(current)",
|
|
52
|
+
"_extend_path()",
|
|
53
|
+
"target = " + (target === null ? "None" : JSON.stringify(target)),
|
|
54
|
+
"def run(args, timeout=30):",
|
|
55
|
+
" p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, start_new_session=True)",
|
|
56
|
+
" try: out, err = p.communicate(timeout=timeout)",
|
|
57
|
+
" except subprocess.TimeoutExpired:",
|
|
58
|
+
" os.killpg(p.pid, signal.SIGTERM)",
|
|
59
|
+
" try: p.communicate(timeout=5)",
|
|
60
|
+
" except subprocess.TimeoutExpired:",
|
|
61
|
+
" os.killpg(p.pid, signal.SIGKILL)",
|
|
62
|
+
" p.communicate()",
|
|
63
|
+
" raise RuntimeError('Codex 更新命令超时;未重启任何会话,请检查安装状态')",
|
|
64
|
+
" if p.returncode: raise RuntimeError('命令失败: ' + args[0] + ': ' + (err or out)[-2000:])",
|
|
65
|
+
" return out.strip()",
|
|
66
|
+
"def version():",
|
|
67
|
+
" raw = run(['codex', '--version'])",
|
|
68
|
+
" match = re.fullmatch(r'codex-cli (\\d+\\.\\d+\\.\\d+)', raw)",
|
|
69
|
+
" if not match: raise RuntimeError('不是可识别的稳定版 Codex: ' + raw)",
|
|
70
|
+
" return match.group(1)",
|
|
71
|
+
"installed = version()",
|
|
72
|
+
"latest = " + (knownLatest === null
|
|
73
|
+
? "json.loads(run(['npm', 'view', '@openai/codex', 'version', '--json', '--registry=https://registry.npmjs.org', '--fetch-timeout=15000', '--fetch-retries=1'], 45)) if target is None else target"
|
|
74
|
+
: JSON.stringify(knownLatest)),
|
|
75
|
+
"if not re.fullmatch(r'\\d+\\.\\d+\\.\\d+', latest): raise RuntimeError('注册表未返回稳定版本')",
|
|
76
|
+
"root = Path(run(['npm', 'root', '-g'])).resolve()",
|
|
77
|
+
"package = root / '@openai' / 'codex'",
|
|
78
|
+
"codex_bin = shutil.which('codex')",
|
|
79
|
+
"if not codex_bin: raise RuntimeError('PATH 中未找到 codex 可执行文件')",
|
|
80
|
+
"executable = Path(codex_bin).resolve()",
|
|
81
|
+
"supported = package.is_dir() and (executable == package / 'bin' / 'codex.js' or package in executable.parents)",
|
|
82
|
+
"backup = None",
|
|
83
|
+
"if target is not None:",
|
|
84
|
+
" if not supported: raise RuntimeError('当前 Codex 不是 npm 全局安装,拒绝覆盖;请按原安装渠道更新')",
|
|
85
|
+
" with open(root / '.scope-codex-upgrade.lock', 'a') as lock:",
|
|
86
|
+
" try: fcntl.flock(lock, fcntl.LOCK_EX | fcntl.LOCK_NB)",
|
|
87
|
+
" except BlockingIOError: raise RuntimeError('远端已有安装任务,请等待后检查版本')",
|
|
88
|
+
" installed = version()",
|
|
89
|
+
" if tuple(map(int, installed.split('.'))) > tuple(map(int, target.split('.'))): raise RuntimeError('拒绝降级 Codex;请重新检查版本')",
|
|
90
|
+
" if installed != target:",
|
|
91
|
+
" backup = tempfile.mkdtemp(prefix='scope-codex-' + installed + '-', dir=str(root))",
|
|
92
|
+
" shutil.copytree(package, Path(backup) / 'codex', symlinks=True)",
|
|
93
|
+
" run(['npm', 'install', '-g', '@openai/codex@' + target, '--registry=https://registry.npmjs.org', '--fetch-timeout=60000', '--fetch-retries=1', '--no-audit', '--no-fund'], 240)",
|
|
94
|
+
" installed = version()",
|
|
95
|
+
" if installed != target: raise RuntimeError('安装后 PATH 版本不匹配,未切换会话')",
|
|
96
|
+
"print('SCOPE_CODEX_UPGRADE_RESULT=' + json.dumps(dict(installed=installed, latest=latest, executable=str(executable), supported=supported, backup=backup)))",
|
|
97
|
+
].join("\n") + "\n";
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export class CodexUpgrades {
|
|
101
|
+
constructor({ inspect, install, restart, running }) {
|
|
102
|
+
Object.assign(this, { inspect, install, restart, running });
|
|
103
|
+
this.jobs = new Map();
|
|
104
|
+
}
|
|
105
|
+
view(host) {
|
|
106
|
+
const job = this.jobs.get(host);
|
|
107
|
+
if (!job) return null;
|
|
108
|
+
const { done, ...view } = job;
|
|
109
|
+
return { ...view, runningVersions: this.running(host) };
|
|
110
|
+
}
|
|
111
|
+
start(host, action) {
|
|
112
|
+
if (!["check", "upgrade"].includes(action)) throw new Error("未知更新操作");
|
|
113
|
+
const previous = this.jobs.get(host);
|
|
114
|
+
if (previous?.status === "running") return previous;
|
|
115
|
+
const job = { host, action, status: "running", phase: "checking", info: previous?.info || null, error: null, results: [], startedAt: new Date().toISOString() };
|
|
116
|
+
this.jobs.set(host, job);
|
|
117
|
+
job.done = this.run(job);
|
|
118
|
+
return job;
|
|
119
|
+
}
|
|
120
|
+
async run(job) {
|
|
121
|
+
try {
|
|
122
|
+
const checked = await this.inspect(job.host);
|
|
123
|
+
job.info = { ...checked, backup: checked.backup || job.info?.backup };
|
|
124
|
+
const target = stableVersion(job.info.latest);
|
|
125
|
+
if (job.action === "check") { job.status = "completed"; return; }
|
|
126
|
+
if (!job.info.supported) throw new Error("仅支持 npm 全局安装;未修改该主机");
|
|
127
|
+
job.phase = "installing";
|
|
128
|
+
const installed = await this.install(job.host, target);
|
|
129
|
+
job.info = { ...installed, backup: installed.backup || job.info.backup };
|
|
130
|
+
if (installed.installed !== target) throw new Error("安装版本验证失败,未切换会话");
|
|
131
|
+
job.phase = "switching";
|
|
132
|
+
const restart = await this.restart(job.host);
|
|
133
|
+
job.results = restart.results || [];
|
|
134
|
+
if (restart.status !== "completed") {
|
|
135
|
+
job.status = "pending-switch";
|
|
136
|
+
job.error = restart.error || "部分会话未恢复,请查看逐会话结果后重试";
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
if (this.running(job.host).some((r) => r.version !== target || r.status !== "connected")) {
|
|
140
|
+
job.status = "pending-switch";
|
|
141
|
+
job.error = "安装已完成,但部分托管连接尚未验证为目标版本";
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
job.status = "completed";
|
|
145
|
+
} catch (error) {
|
|
146
|
+
job.status = job.phase === "switching" ? "pending-switch" : "failed";
|
|
147
|
+
job.error = error.message;
|
|
148
|
+
} finally { job.finishedAt = new Date().toISOString(); }
|
|
149
|
+
}
|
|
150
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
|
|
4
|
+
/** Machine-specific integrations are opt-in, outside the tracked repository. */
|
|
5
|
+
export function loadDeploymentProfile({
|
|
6
|
+
env = process.env,
|
|
7
|
+
filename = env.SCOPE_STATE_DIR
|
|
8
|
+
? path.resolve(env.SCOPE_STATE_DIR, "deployment.json")
|
|
9
|
+
: path.resolve(".scope/deployment.json"),
|
|
10
|
+
} = {}) {
|
|
11
|
+
let value = {};
|
|
12
|
+
try {
|
|
13
|
+
value = JSON.parse(readFileSync(filename, "utf8"));
|
|
14
|
+
} catch (error) {
|
|
15
|
+
if (error.code !== "ENOENT")
|
|
16
|
+
throw new Error(`Invalid deployment profile: ${error.message}`);
|
|
17
|
+
}
|
|
18
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
19
|
+
throw new Error("Deployment profile must be an object");
|
|
20
|
+
const keys = [
|
|
21
|
+
"taskQueue",
|
|
22
|
+
"dlcHostname",
|
|
23
|
+
"proxyBootstrapHosts",
|
|
24
|
+
"emailTunnelHost",
|
|
25
|
+
];
|
|
26
|
+
if (Object.keys(value).some((key) => !keys.includes(key)))
|
|
27
|
+
throw new Error("Unknown deployment profile field");
|
|
28
|
+
if (value.taskQueue !== undefined && typeof value.taskQueue !== "boolean")
|
|
29
|
+
throw new Error("taskQueue must be boolean");
|
|
30
|
+
if (
|
|
31
|
+
env.SCOPE_ENABLE_TASK_QUEUE !== undefined &&
|
|
32
|
+
!["0", "1"].includes(env.SCOPE_ENABLE_TASK_QUEUE)
|
|
33
|
+
)
|
|
34
|
+
throw new Error("SCOPE_ENABLE_TASK_QUEUE must be 0 or 1");
|
|
35
|
+
const host = (input) => {
|
|
36
|
+
if (
|
|
37
|
+
typeof input !== "string" ||
|
|
38
|
+
(input && !/^[a-zA-Z0-9_][a-zA-Z0-9_.:@-]*$/.test(input))
|
|
39
|
+
)
|
|
40
|
+
throw new Error("Invalid host in deployment profile");
|
|
41
|
+
return input;
|
|
42
|
+
};
|
|
43
|
+
const proxyHosts =
|
|
44
|
+
env.SCOPE_PROXY_BOOTSTRAP_HOSTS !== undefined
|
|
45
|
+
? env.SCOPE_PROXY_BOOTSTRAP_HOSTS.split(",")
|
|
46
|
+
.map((item) => item.trim())
|
|
47
|
+
.filter(Boolean)
|
|
48
|
+
: (value.proxyBootstrapHosts ?? []);
|
|
49
|
+
if (!Array.isArray(proxyHosts))
|
|
50
|
+
throw new Error("proxyBootstrapHosts must be an array");
|
|
51
|
+
return {
|
|
52
|
+
taskQueue:
|
|
53
|
+
env.SCOPE_ENABLE_TASK_QUEUE !== undefined
|
|
54
|
+
? env.SCOPE_ENABLE_TASK_QUEUE === "1"
|
|
55
|
+
: (value.taskQueue ?? false),
|
|
56
|
+
dlcHostname: host(
|
|
57
|
+
env.SCOPE_DLC_SSH_HOSTNAME?.trim() ?? value.dlcHostname ?? "",
|
|
58
|
+
),
|
|
59
|
+
proxyBootstrapHosts: proxyHosts.map(host),
|
|
60
|
+
emailTunnelHost: host(
|
|
61
|
+
env.SCOPE_EMAIL_TUNNEL_HOST?.trim() ?? value.emailTunnelHost ?? "",
|
|
62
|
+
),
|
|
63
|
+
};
|
|
64
|
+
}
|