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,96 @@
|
|
|
1
|
+
"""Reversible SCOPE visibility state; never move/delete native agent history."""
|
|
2
|
+
import base64
|
|
3
|
+
import fcntl
|
|
4
|
+
import json
|
|
5
|
+
import os
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
import re
|
|
8
|
+
import subprocess
|
|
9
|
+
import sys
|
|
10
|
+
import time
|
|
11
|
+
|
|
12
|
+
config = json.loads(base64.urlsafe_b64decode(sys.argv[1] + "==="))
|
|
13
|
+
provider = config.get("provider", "claude")
|
|
14
|
+
if provider not in ("claude", "antigravity"):
|
|
15
|
+
raise ValueError("Unsupported provider")
|
|
16
|
+
label = "Claude" if provider == "claude" else "Antigravity"
|
|
17
|
+
sid = config.get("sessionId", "")
|
|
18
|
+
if not re.fullmatch(r"[a-fA-F0-9-]{36}", sid):
|
|
19
|
+
raise ValueError("Invalid native session ID")
|
|
20
|
+
root = Path.home() / ".local/state/scope" / (provider + "-sessions")
|
|
21
|
+
root.mkdir(parents=True, exist_ok=True, mode=0o700)
|
|
22
|
+
lock = (root / (sid + ".lock")).open("a")
|
|
23
|
+
try:
|
|
24
|
+
fcntl.flock(lock, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
|
25
|
+
except BlockingIOError:
|
|
26
|
+
raise RuntimeError("此 Agent 会话正在被 SCOPE 使用,请等待本轮结束")
|
|
27
|
+
filename = root / (sid + ".json")
|
|
28
|
+
state = json.loads(filename.read_text()) if filename.exists() else {"sessionId": sid, "phase": "active"}
|
|
29
|
+
|
|
30
|
+
def active_writer():
|
|
31
|
+
if provider == "antigravity":
|
|
32
|
+
# Probe native presence locks; stale files alone do not mean active.
|
|
33
|
+
native_lock = Path.home() / ".gemini/antigravity-cli/presence" / (sid + ".lock")
|
|
34
|
+
if native_lock.exists():
|
|
35
|
+
with native_lock.open("r") as presence:
|
|
36
|
+
try:
|
|
37
|
+
fcntl.flock(presence, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
|
38
|
+
except BlockingIOError:
|
|
39
|
+
return "native presence lock"
|
|
40
|
+
finally:
|
|
41
|
+
fcntl.flock(presence, fcntl.LOCK_UN)
|
|
42
|
+
for entry in Path("/proc").glob("[0-9]*/cmdline"):
|
|
43
|
+
try:
|
|
44
|
+
args = entry.read_bytes().decode(errors="replace").split("\0")
|
|
45
|
+
if sid in args and any(Path(a).name == "agy" or "antigravity" in a for a in args[:2]):
|
|
46
|
+
return entry.parent.name
|
|
47
|
+
except (FileNotFoundError, ProcessLookupError):
|
|
48
|
+
continue
|
|
49
|
+
return None
|
|
50
|
+
registry = Path(os.environ.get("CLAUDE_CONFIG_DIR", str(Path.home() / ".claude"))) / "sessions"
|
|
51
|
+
for entry in registry.glob("*.json"):
|
|
52
|
+
try:
|
|
53
|
+
record = json.loads(entry.read_text())
|
|
54
|
+
if record.get("sessionId") != sid:
|
|
55
|
+
continue
|
|
56
|
+
pid = int(record["pid"])
|
|
57
|
+
if pid <= 0:
|
|
58
|
+
continue
|
|
59
|
+
os.kill(pid, 0)
|
|
60
|
+
# Reject conservatively on a live registered PID; never signal it.
|
|
61
|
+
return pid
|
|
62
|
+
except (FileNotFoundError, ProcessLookupError, ValueError, KeyError):
|
|
63
|
+
continue
|
|
64
|
+
# Older CLIs can lack registry files. Check explicit --resume/--session-id arguments.
|
|
65
|
+
for entry in Path("/proc").glob("[0-9]*/cmdline"):
|
|
66
|
+
try:
|
|
67
|
+
args = entry.read_bytes().decode(errors="replace").split("\0")
|
|
68
|
+
if sid in args and any("claude" in a for a in args[:2]):
|
|
69
|
+
return int(entry.parent.name)
|
|
70
|
+
except (FileNotFoundError, ProcessLookupError):
|
|
71
|
+
continue
|
|
72
|
+
return None
|
|
73
|
+
|
|
74
|
+
action = config["action"]
|
|
75
|
+
if action != "status":
|
|
76
|
+
writer = active_writer()
|
|
77
|
+
if writer:
|
|
78
|
+
raise RuntimeError("%s 会话仍被远端终端或其他客户端使用(%s),请先正常退出该会话" % (label, writer))
|
|
79
|
+
if action == "run":
|
|
80
|
+
if state["phase"] != "active":
|
|
81
|
+
raise RuntimeError("会话已归档或在回收站,请先恢复")
|
|
82
|
+
# This lock is held throughout the child turn, serializing SCOPE clients on the same host.
|
|
83
|
+
sys.exit(subprocess.call(["bash", "-ic", config["command"]], stdin=subprocess.DEVNULL))
|
|
84
|
+
elif action in ("archive", "delete", "restore"):
|
|
85
|
+
if action == "delete" and state["phase"] not in ("archived", "deleted"):
|
|
86
|
+
raise RuntimeError("请先归档,再移入回收站")
|
|
87
|
+
state.update(phase={"archive": "archived", "delete": "deleted", "restore": "active"}[action],
|
|
88
|
+
updatedAt=int(time.time() * 1000))
|
|
89
|
+
temporary = filename.with_suffix(".tmp")
|
|
90
|
+
temporary.write_text(json.dumps(state))
|
|
91
|
+
temporary.replace(filename)
|
|
92
|
+
elif action not in ("status", "check"):
|
|
93
|
+
raise ValueError("Unsupported action")
|
|
94
|
+
elif action == "check" and state["phase"] != "active":
|
|
95
|
+
raise RuntimeError("会话已归档或在回收站,请先恢复")
|
|
96
|
+
print(json.dumps(state))
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { renderInstructionWithAttachments } from "../session-attachments.mjs";
|
|
3
|
+
import { cliCommand, parseCliResult } from "./cli-command.mjs";
|
|
4
|
+
import { nativeGuardCommand } from "./native-session-state.mjs";
|
|
5
|
+
import { claudeInteractiveCommand } from "./claude-interactive.mjs";
|
|
6
|
+
import { antigravityInteractiveCommand } from "./antigravity-interactive.mjs";
|
|
7
|
+
|
|
8
|
+
export function remoteCliAdapter(runSsh, { hostPreLaunch } = {}) {
|
|
9
|
+
const script = readFile(new URL("./remote-job.py", import.meta.url), "utf8");
|
|
10
|
+
async function call(host, payload) {
|
|
11
|
+
const encoded = Buffer.from(JSON.stringify(payload)).toString("base64url");
|
|
12
|
+
const result = await runSsh(
|
|
13
|
+
host,
|
|
14
|
+
"python3 -",
|
|
15
|
+
`import sys\nsys.argv.append(${JSON.stringify(encoded)})\n${await script}`,
|
|
16
|
+
20000,
|
|
17
|
+
7_000_000, // JSON escaping may expand the two bounded 512 KB output streams.
|
|
18
|
+
);
|
|
19
|
+
if (result.code !== 0)
|
|
20
|
+
throw new Error(result.stderr || "远端 Agent 连接失败");
|
|
21
|
+
return JSON.parse(result.stdout.trim());
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
async archive(task) {
|
|
25
|
+
return call(task.host, { operation: "archive", id: task.id });
|
|
26
|
+
},
|
|
27
|
+
async restore(task) {
|
|
28
|
+
return call(task.host, { operation: "restore", id: task.id });
|
|
29
|
+
},
|
|
30
|
+
async launch(task, config) {
|
|
31
|
+
const baseProvider = config?.providers?.[task.provider] || {};
|
|
32
|
+
const preLaunchCommand = String(
|
|
33
|
+
baseProvider.preLaunchCommand || hostPreLaunch?.(task.host) || "",
|
|
34
|
+
).trim();
|
|
35
|
+
const effectiveProvider = { ...baseProvider, preLaunchCommand };
|
|
36
|
+
const effectiveTask =
|
|
37
|
+
Array.isArray(task.attachments) && task.attachments.length
|
|
38
|
+
? {
|
|
39
|
+
...task,
|
|
40
|
+
prompt: renderInstructionWithAttachments(task.prompt, task.attachments),
|
|
41
|
+
}
|
|
42
|
+
: task;
|
|
43
|
+
let command = effectiveTask.interactive
|
|
44
|
+
? await (effectiveTask.provider === "antigravity"
|
|
45
|
+
? antigravityInteractiveCommand(effectiveTask, effectiveProvider)
|
|
46
|
+
: claudeInteractiveCommand(effectiveTask, effectiveProvider))
|
|
47
|
+
: cliCommand(effectiveTask, effectiveProvider);
|
|
48
|
+
if (["claude", "antigravity"].includes(effectiveTask.provider) && effectiveTask.resumeSessionId) command = await nativeGuardCommand({ action: "run", provider: effectiveTask.provider, sessionId: effectiveTask.resumeSessionId, command });
|
|
49
|
+
const result = await call(effectiveTask.host, {
|
|
50
|
+
operation: "launch",
|
|
51
|
+
id: effectiveTask.id,
|
|
52
|
+
command,
|
|
53
|
+
...(effectiveTask.interactive ? { interactiveConfig: { ...effectiveTask, executable: effectiveProvider.executable || (effectiveTask.provider === "antigravity" ? "agy" : "claude"), model: effectiveProvider.model } } : {}),
|
|
54
|
+
// Interactive shell startup may spawn zsh and consume stdin before the
|
|
55
|
+
// agent starts. Pass the quoted prompt in the command, never shell stdin.
|
|
56
|
+
input: "",
|
|
57
|
+
});
|
|
58
|
+
return { kind: "remote-cli", id: task.id, remotePath: result.remotePath };
|
|
59
|
+
},
|
|
60
|
+
async poll(task) {
|
|
61
|
+
if (task.interactive) {
|
|
62
|
+
const result = await call(task.host, { operation: "status", id: task.id });
|
|
63
|
+
return result.interactive || { ...result, error: result.stderr || result.error };
|
|
64
|
+
}
|
|
65
|
+
return parseCliResult(
|
|
66
|
+
task.provider,
|
|
67
|
+
await call(task.host, { operation: "status", id: task.id }),
|
|
68
|
+
);
|
|
69
|
+
},
|
|
70
|
+
async control(task, control) {
|
|
71
|
+
if (!task.interactive) throw new Error("此旧任务没有交互通道;请等待结束后开始新一轮");
|
|
72
|
+
return call(task.host, { operation: "control", id: task.id, control });
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"""Small Linux SSH spool. No agent is invoked by status requests.
|
|
2
|
+
|
|
3
|
+
A UUID directory is claimed before launching. Repeating launch returns the same
|
|
4
|
+
receipt; an incomplete claim is unknown and never launches a duplicate process.
|
|
5
|
+
"""
|
|
6
|
+
import base64
|
|
7
|
+
import hashlib
|
|
8
|
+
import json
|
|
9
|
+
import os
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
import re
|
|
12
|
+
import subprocess
|
|
13
|
+
import sys
|
|
14
|
+
|
|
15
|
+
if hasattr(sys.stdout, "reconfigure"):
|
|
16
|
+
sys.stdout.reconfigure(encoding="utf-8")
|
|
17
|
+
|
|
18
|
+
WORKER = r'''
|
|
19
|
+
import json, os, subprocess, sys, time
|
|
20
|
+
from pathlib import Path
|
|
21
|
+
root = Path(sys.argv[1])
|
|
22
|
+
def save(value):
|
|
23
|
+
temporary = root / "status.tmp"
|
|
24
|
+
temporary.write_text(json.dumps(value), encoding="utf-8")
|
|
25
|
+
temporary.replace(root / "status.json")
|
|
26
|
+
try:
|
|
27
|
+
request = json.loads((root / "request.json").read_text(encoding="utf-8"))
|
|
28
|
+
save({"status": "running", "pid": os.getpid(), "startedAt": time.time()})
|
|
29
|
+
with (root / "stdout").open("wb") as out, (root / "stderr").open("wb") as err:
|
|
30
|
+
child = subprocess.Popen(["bash", "-ic", request["command"]], stdin=subprocess.PIPE, stdout=out, stderr=err)
|
|
31
|
+
# No remote timeout kill: a disconnected observer must not terminate work.
|
|
32
|
+
child.communicate(request["input"].encode("utf-8"))
|
|
33
|
+
save({"status": "completed" if child.returncode == 0 else "failed", "code": child.returncode, "endedAt": time.time()})
|
|
34
|
+
except Exception as error:
|
|
35
|
+
save({"status": "unknown", "error": str(error)})
|
|
36
|
+
'''
|
|
37
|
+
|
|
38
|
+
request = json.loads(base64.urlsafe_b64decode(sys.argv[1] + "==="))
|
|
39
|
+
task_id = request.get("id", "")
|
|
40
|
+
if not re.fullmatch(r"[a-f0-9-]{36}", task_id):
|
|
41
|
+
raise ValueError("invalid task id")
|
|
42
|
+
base = Path.home() / ".local" / "state" / "scope"
|
|
43
|
+
active = base / "runs" / task_id
|
|
44
|
+
archived = base / "archives" / task_id
|
|
45
|
+
root = archived if archived.exists() else active
|
|
46
|
+
if active.exists() and archived.exists():
|
|
47
|
+
raise ValueError("conflicting archive receipts; inspect remote state")
|
|
48
|
+
if request["operation"] in ("archive", "restore"):
|
|
49
|
+
status = root / "status.json"
|
|
50
|
+
record = json.loads(status.read_text()) if status.exists() else {}
|
|
51
|
+
if record.get("status") not in ("completed", "failed"):
|
|
52
|
+
raise ValueError("remote task is not confirmed finished; not archived")
|
|
53
|
+
target = archived if request["operation"] == "archive" else active
|
|
54
|
+
if root != target:
|
|
55
|
+
target.parent.mkdir(parents=True, exist_ok=True, mode=0o700)
|
|
56
|
+
root.rename(target)
|
|
57
|
+
root = target
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
if request["operation"] == "launch":
|
|
61
|
+
payload = {"command": request["command"], "input": request["input"]}
|
|
62
|
+
if "interactiveConfig" in request: payload["interactiveConfig"] = request["interactiveConfig"]
|
|
63
|
+
fingerprint = hashlib.sha256(json.dumps(payload, sort_keys=True).encode()).hexdigest()
|
|
64
|
+
root.parent.mkdir(parents=True, exist_ok=True, mode=0o700)
|
|
65
|
+
try:
|
|
66
|
+
root.mkdir(mode=0o700)
|
|
67
|
+
except FileExistsError:
|
|
68
|
+
existing = root / "fingerprint"
|
|
69
|
+
if existing.exists() and existing.read_text() != fingerprint:
|
|
70
|
+
raise ValueError("task id already belongs to a different request")
|
|
71
|
+
else:
|
|
72
|
+
(root / "fingerprint").write_text(fingerprint)
|
|
73
|
+
(root / "request.json").write_text(json.dumps(payload), encoding="utf-8")
|
|
74
|
+
if "interactiveConfig" in request:
|
|
75
|
+
(root / "claude-config.json").write_text(json.dumps(request["interactiveConfig"]), encoding="utf-8")
|
|
76
|
+
subprocess.Popen([sys.executable, "-c", WORKER, str(root)], stdin=subprocess.DEVNULL,
|
|
77
|
+
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, start_new_session=True)
|
|
78
|
+
elif request["operation"] == "control":
|
|
79
|
+
import fcntl
|
|
80
|
+
with (root / "control.lock").open("a") as mutex:
|
|
81
|
+
fcntl.flock(mutex, fcntl.LOCK_EX)
|
|
82
|
+
snapshot = json.loads((root / "interactive.json").read_text())
|
|
83
|
+
if snapshot.get("status") not in ("running", "waiting_permission"):
|
|
84
|
+
raise ValueError("会话已结束或正在停止,请刷新后重试")
|
|
85
|
+
control = request["control"]
|
|
86
|
+
if not re.fullmatch(r"[a-f0-9-]{36}", control["id"]):
|
|
87
|
+
raise ValueError("invalid control id")
|
|
88
|
+
if control["action"] not in ("message", "permission", "stop"):
|
|
89
|
+
raise ValueError("unsupported control")
|
|
90
|
+
if control["action"] == "permission" and not any(p["id"] == control.get("requestId") for p in snapshot.get("permissions", [])):
|
|
91
|
+
raise ValueError("权限请求已失效或已处理")
|
|
92
|
+
target = root / "controls" / (control["id"] + ".json")
|
|
93
|
+
if target.exists():
|
|
94
|
+
prior = json.loads(target.read_text())
|
|
95
|
+
prior.pop("_sequence", None)
|
|
96
|
+
if prior != control: raise ValueError("conflicting control id")
|
|
97
|
+
else:
|
|
98
|
+
# Filesystem timestamp resolution is insufficient for ordered inputs.
|
|
99
|
+
counter = root / "control-sequence"
|
|
100
|
+
sequence = int(counter.read_text()) + 1 if counter.exists() else 1
|
|
101
|
+
counter.write_text(str(sequence))
|
|
102
|
+
target.write_text(json.dumps({**control, "_sequence": sequence}))
|
|
103
|
+
elif request["operation"] not in ("status", "archive", "restore"):
|
|
104
|
+
raise ValueError("unsupported operation")
|
|
105
|
+
|
|
106
|
+
status_file = root / "status.json"
|
|
107
|
+
result = json.loads(status_file.read_text()) if status_file.exists() else {"status": "unknown", "error": "等待启动回执;不会重复启动"}
|
|
108
|
+
if result.get("status") == "running":
|
|
109
|
+
try:
|
|
110
|
+
os.kill(result["pid"], 0)
|
|
111
|
+
except ProcessLookupError:
|
|
112
|
+
result = {"status": "unknown", "error": "远端监督进程已退出,执行结果待核实"}
|
|
113
|
+
|
|
114
|
+
for name in ("stdout", "stderr"):
|
|
115
|
+
filename = root / name
|
|
116
|
+
if filename.exists():
|
|
117
|
+
with filename.open("rb") as handle:
|
|
118
|
+
size = filename.stat().st_size
|
|
119
|
+
if size > 512_000:
|
|
120
|
+
handle.seek(size - 512_000)
|
|
121
|
+
result["truncated"] = True
|
|
122
|
+
result[name] = handle.read(512_000).decode("utf-8", errors="replace")
|
|
123
|
+
result["remotePath"] = str(root)
|
|
124
|
+
snapshot_file = root / "interactive.json"
|
|
125
|
+
if snapshot_file.exists():
|
|
126
|
+
snapshot = json.loads(snapshot_file.read_text(encoding="utf-8"))
|
|
127
|
+
if result.get("status") == "unknown" and snapshot.get("status") in ("running", "waiting_permission", "stopping", "finishing"):
|
|
128
|
+
snapshot.update(status="unknown", error=result.get("error"))
|
|
129
|
+
result["interactive"] = snapshot
|
|
130
|
+
print(json.dumps(result, ensure_ascii=False))
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { prepareProfileHome, profileHomeSelection } from "./remote-profile-home.mjs";
|
|
2
|
+
|
|
3
|
+
function shellQuote(value) {
|
|
4
|
+
return `'${String(value ?? "").replace(/'/g, `'"'"'`)}'`;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function safeKey(value) {
|
|
8
|
+
return String(value || "default")
|
|
9
|
+
.replace(/[^a-zA-Z0-9_.-]/g, "-")
|
|
10
|
+
.slice(0, 80);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function durableRemoteAppServerCommand({
|
|
14
|
+
executable = "codex",
|
|
15
|
+
key = "default",
|
|
16
|
+
codexHome = "",
|
|
17
|
+
useActiveProfile = false,
|
|
18
|
+
isolatedProfile = "",
|
|
19
|
+
} = {}) {
|
|
20
|
+
const id = safeKey(key);
|
|
21
|
+
const setup = [
|
|
22
|
+
"set -eu",
|
|
23
|
+
'test ! -d "$HOME/.scope-codex-migration.lock" || { echo "SCOPE Codex storage migration in progress; retry after completion" >&2; exit 75; }',
|
|
24
|
+
`scope_codex_exe=${shellQuote(executable)}`,
|
|
25
|
+
];
|
|
26
|
+
if (isolatedProfile) {
|
|
27
|
+
if (!/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,47}$/.test(isolatedProfile)) throw new Error("Invalid isolated profile");
|
|
28
|
+
setup.push(
|
|
29
|
+
`app_id=${shellQuote(id)}`,
|
|
30
|
+
...prepareProfileHome(isolatedProfile),
|
|
31
|
+
// A shared rollout requires a shared writer lock across CODEX_HOME values.
|
|
32
|
+
'mkdir -p "$HOME/.codex/thread-writer-locks"',
|
|
33
|
+
'if test -d "$app_codex_home/thread-writer-locks" && test ! -L "$app_codex_home/thread-writer-locks"; then',
|
|
34
|
+
' rmdir "$app_codex_home/thread-writer-locks" 2>/dev/null || { echo "Profile has private writer locks; refusing unsafe history sharing" >&2; exit 77; }',
|
|
35
|
+
'fi',
|
|
36
|
+
'if test ! -L "$app_codex_home/thread-writer-locks"; then ln -s "$HOME/.codex/thread-writer-locks" "$app_codex_home/thread-writer-locks" 2>/dev/null || test -L "$app_codex_home/thread-writer-locks"; fi',
|
|
37
|
+
'test "$(readlink -f "$app_codex_home/thread-writer-locks")" = "$(readlink -f "$HOME/.codex/thread-writer-locks")" || { echo "Profile writer lock directory mismatch" >&2; exit 77; }',
|
|
38
|
+
// Share instructions/history, never credentials or the runtime database.
|
|
39
|
+
'for scope_shared in config.toml AGENTS.md skills memories sessions archived_sessions; do',
|
|
40
|
+
' if test ! -e "$app_codex_home/$scope_shared" && test ! -L "$app_codex_home/$scope_shared" && test -e "$HOME/.codex/$scope_shared"; then',
|
|
41
|
+
' ln -s "$HOME/.codex/$scope_shared" "$app_codex_home/$scope_shared" 2>/dev/null || test -e "$app_codex_home/$scope_shared"',
|
|
42
|
+
' fi',
|
|
43
|
+
'done',
|
|
44
|
+
);
|
|
45
|
+
} else if (codexHome) {
|
|
46
|
+
setup.push(`app_id=${shellQuote(id)}`, `app_codex_home="${codexHome}"`);
|
|
47
|
+
} else if (useActiveProfile) {
|
|
48
|
+
setup.push(
|
|
49
|
+
'root_codex_home="$HOME/.codex"',
|
|
50
|
+
'active_slug="$(cat "$root_codex_home/scope-auth-profiles/active" 2>/dev/null || true)"',
|
|
51
|
+
"case \"$active_slug\" in",
|
|
52
|
+
' ""|*[!a-zA-Z0-9._-]*) app_id=default; app_codex_home="$root_codex_home" ;;',
|
|
53
|
+
' *) candidate_home="$root_codex_home/scope-auth-profiles/$active_slug/home"; if test -f "$candidate_home/auth.json"; then app_id="profile-$active_slug"; app_codex_home="$root_codex_home"; else app_id=default; app_codex_home="$root_codex_home"; fi ;;',
|
|
54
|
+
"esac",
|
|
55
|
+
);
|
|
56
|
+
} else {
|
|
57
|
+
setup.push(
|
|
58
|
+
`app_id=${shellQuote(id)}`,
|
|
59
|
+
'app_codex_home="$HOME/.codex"',
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
return [
|
|
63
|
+
...setup,
|
|
64
|
+
'tmux_name="scope-app-server-$app_id"',
|
|
65
|
+
'state_dir="$app_codex_home/app-server-control"',
|
|
66
|
+
'socket_path="$state_dir/scope-$app_id.sock"',
|
|
67
|
+
'log_path="$state_dir/scope-$app_id.log"',
|
|
68
|
+
'lock_path="$state_dir/app-server-startup.lock"',
|
|
69
|
+
'mkdir -p "$state_dir"',
|
|
70
|
+
'lock_mode=none',
|
|
71
|
+
'if command -v flock >/dev/null 2>&1; then',
|
|
72
|
+
' exec 9>"$lock_path"',
|
|
73
|
+
' if ! flock -w 15 9; then echo "SCOPE app-server startup lock timed out" >&2; exit 73; fi',
|
|
74
|
+
' lock_mode=flock',
|
|
75
|
+
'else',
|
|
76
|
+
' lock_dir="$lock_path.d"',
|
|
77
|
+
' lock_attempt=0',
|
|
78
|
+
' while test "$lock_attempt" -lt 60; do',
|
|
79
|
+
' if mkdir "$lock_dir" 2>/dev/null; then lock_mode=mkdir; break; fi',
|
|
80
|
+
' lock_attempt=$((lock_attempt + 1))',
|
|
81
|
+
' sleep 0.25',
|
|
82
|
+
' done',
|
|
83
|
+
' if test "$lock_mode" != mkdir; then echo "SCOPE app-server startup lock timed out" >&2; exit 73; fi',
|
|
84
|
+
'fi',
|
|
85
|
+
'scope_unlock() {',
|
|
86
|
+
' if test "$lock_mode" = flock; then flock -u 9 || true; exec 9>&-; fi',
|
|
87
|
+
' if test "$lock_mode" = mkdir; then rmdir "$lock_dir" 2>/dev/null || true; fi',
|
|
88
|
+
' lock_mode=none',
|
|
89
|
+
'}',
|
|
90
|
+
'trap scope_unlock EXIT',
|
|
91
|
+
"trap 'scope_unlock; exit 74' HUP INT TERM",
|
|
92
|
+
'socket_is_live() {',
|
|
93
|
+
' test -S "$socket_path" || return 1',
|
|
94
|
+
' if command -v ss >/dev/null 2>&1; then',
|
|
95
|
+
// Newer Codex daemons expose custom socket paths as symlinks into /tmp.
|
|
96
|
+
// ss reports the bound target, not that public alias. Preserve live writers.
|
|
97
|
+
' scope_socket_target="$(readlink -f -- "$socket_path" 2>/dev/null || printf \'%s\' "$socket_path")"',
|
|
98
|
+
' ss -xlH 2>/dev/null | awk -v alias="$socket_path" -v target="$scope_socket_target" \'index($0, " " alias " ") || index($0, " " target " ") { found = 1 } END { exit !found }\'',
|
|
99
|
+
' else',
|
|
100
|
+
' tmux has-session -t "=$tmux_name" 2>/dev/null',
|
|
101
|
+
' fi',
|
|
102
|
+
'}',
|
|
103
|
+
'if test -S "$socket_path" && ! socket_is_live; then',
|
|
104
|
+
' if tmux has-session -t "=$tmux_name" 2>/dev/null; then',
|
|
105
|
+
' echo "SCOPE app-server tmux $tmux_name exists but its socket is not listening; preserving it for inspection" >&2',
|
|
106
|
+
' exit 71',
|
|
107
|
+
' fi',
|
|
108
|
+
' rm -f -- "$socket_path"',
|
|
109
|
+
'fi',
|
|
110
|
+
'if ! socket_is_live; then',
|
|
111
|
+
' if tmux has-session -t "=$tmux_name" 2>/dev/null; then',
|
|
112
|
+
' echo "SCOPE app-server tmux $tmux_name exists without a live socket; refusing to terminate or replace it" >&2',
|
|
113
|
+
' exit 71',
|
|
114
|
+
' fi',
|
|
115
|
+
' tmux new-session -d -s "$tmux_name" "export CODEX_HOME=\"$app_codex_home\"; exec \"$scope_codex_exe\"' + (isolatedProfile ? ' -c cli_auth_credentials_store=file' : '') + ' app-server --listen \"unix://$socket_path\" >>\"$log_path\" 2>&1"',
|
|
116
|
+
' ready=0',
|
|
117
|
+
' ready_attempt=0',
|
|
118
|
+
' while test "$ready_attempt" -lt 60; do',
|
|
119
|
+
' if socket_is_live; then ready=1; break; fi',
|
|
120
|
+
' ready_attempt=$((ready_attempt + 1))',
|
|
121
|
+
' sleep 0.25',
|
|
122
|
+
' done',
|
|
123
|
+
' if test "$ready" != 1; then echo "SCOPE app-server $tmux_name did not create a live socket within 15 seconds; pane preserved for inspection" >&2; tail -n 20 "$log_path" >&2 || true; exit 72; fi',
|
|
124
|
+
"fi",
|
|
125
|
+
'scope_unlock',
|
|
126
|
+
'trap - EXIT HUP INT TERM',
|
|
127
|
+
'export CODEX_HOME="$app_codex_home"',
|
|
128
|
+
'exec "$scope_codex_exe" app-server proxy --sock "$socket_path"',
|
|
129
|
+
].join("\n");
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export function retireProfileAppServerCommand(connectionKey) {
|
|
133
|
+
const id = String(connectionKey || "").trim();
|
|
134
|
+
if (!/^profile-[a-zA-Z0-9_.-]{1,80}$/.test(id)) {
|
|
135
|
+
throw new Error("Refusing to retire a non-profile app-server writer");
|
|
136
|
+
}
|
|
137
|
+
return [
|
|
138
|
+
"set -eu",
|
|
139
|
+
`app_id=${shellQuote(id)}`,
|
|
140
|
+
'tmux_name="scope-app-server-$app_id"',
|
|
141
|
+
'state_dir="$HOME/.codex/app-server-control"',
|
|
142
|
+
'socket_path="$state_dir/scope-$app_id.sock"',
|
|
143
|
+
'if tmux has-session -t "=$tmux_name" 2>/dev/null; then',
|
|
144
|
+
' pane_count="$(tmux list-panes -t "=$tmux_name" -F \'#{pane_pid}\' | wc -l | tr -d \' \')"',
|
|
145
|
+
' test "$pane_count" = 1 || { echo "unexpected pane count: $pane_count" >&2; exit 78; }',
|
|
146
|
+
' pane_pid="$(tmux list-panes -t "=$tmux_name" -F \'#{pane_pid}\')"',
|
|
147
|
+
' pane_args="$(ps -o args= -p "$pane_pid" 2>/dev/null || true)"',
|
|
148
|
+
' case "$pane_args" in',
|
|
149
|
+
' *"codex app-server --listen unix://$socket_path"*) ;;',
|
|
150
|
+
' *) echo "refusing non-SCOPE tmux command: $pane_args" >&2; exit 79 ;;',
|
|
151
|
+
' esac',
|
|
152
|
+
' tmux kill-session -t "=$tmux_name"',
|
|
153
|
+
'fi',
|
|
154
|
+
'attempt=0',
|
|
155
|
+
'while test "$attempt" -lt 40 && test -S "$socket_path"; do',
|
|
156
|
+
' sleep 0.1',
|
|
157
|
+
' attempt=$((attempt + 1))',
|
|
158
|
+
'done',
|
|
159
|
+
'if test -S "$socket_path"; then rm -f -- "$socket_path"; fi',
|
|
160
|
+
'printf \'{"retired":true,"tmux":"%s"}\\n\' "$tmux_name"',
|
|
161
|
+
].join("\n");
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// Explicit config reload only: exact named SCOPE daemon, never a process-tree kill.
|
|
165
|
+
export function retireScopedAppServerCommand(connectionKey) {
|
|
166
|
+
const id = String(connectionKey || "");
|
|
167
|
+
const account = /^account-([a-zA-Z0-9][a-zA-Z0-9._-]{0,47})$/.exec(id);
|
|
168
|
+
if (!account && !/^profile-[a-zA-Z0-9_.-]{1,48}$/.test(id)) {
|
|
169
|
+
throw new Error("无法确认 SCOPE daemon 归属,拒绝重启");
|
|
170
|
+
}
|
|
171
|
+
const base = retireProfileAppServerCommand(account ? `profile-${account[1]}` : id);
|
|
172
|
+
return account ? base
|
|
173
|
+
.replace(`app_id=${shellQuote(`profile-${account[1]}`)}`, `app_id=${shellQuote(id)}`)
|
|
174
|
+
.replace('state_dir="$HOME/.codex/app-server-control"',
|
|
175
|
+
[...profileHomeSelection(account[1]), 'state_dir="$app_codex_home/app-server-control"'].join("\n"))
|
|
176
|
+
.replace('*"codex app-server --listen unix://$socket_path"*', '*"codex -c cli_auth_credentials_store=file app-server --listen unix://$socket_path"*') : base;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/** Run the bootstrap handler in the host's preferred interactive shell.
|
|
180
|
+
*
|
|
181
|
+
* `-c` is important for app-server: it keeps the shell from reading JSONL from
|
|
182
|
+
* stdin as another command. The final exec gives that unchanged stream to
|
|
183
|
+
* Codex. Hosts without zsh retain the established Bash bootstrap path.
|
|
184
|
+
*/
|
|
185
|
+
export function wrapBootstrapAppServer(command, preLaunchCommand = "") {
|
|
186
|
+
const startup = String(preLaunchCommand || "").trim();
|
|
187
|
+
const zshHandler = [startup, command].filter(Boolean).join("; ");
|
|
188
|
+
const bashHandler = [
|
|
189
|
+
"source ~/.bashrc >/dev/null 2>&1 || true",
|
|
190
|
+
startup,
|
|
191
|
+
command,
|
|
192
|
+
].filter(Boolean).join("; ");
|
|
193
|
+
return [
|
|
194
|
+
"if command -v zsh >/dev/null 2>&1",
|
|
195
|
+
`then exec zsh -ic ${shellQuote(zshHandler)}`,
|
|
196
|
+
`else exec bash -ic ${shellQuote(bashHandler)}`,
|
|
197
|
+
"fi",
|
|
198
|
+
].join("; ");
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export function wrapProxyBootstrapAppServer(command, preLaunchCommand = "") {
|
|
202
|
+
return wrapBootstrapAppServer(command, preLaunchCommand);
|
|
203
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export function remoteBootstrapRoutes({ bootstrap, readJsonBody, jsonResponse }) {
|
|
2
|
+
return async (request, response, url) => {
|
|
3
|
+
if (url.pathname !== "/api/remote-bootstrap") return false;
|
|
4
|
+
|
|
5
|
+
if (request.method === "GET") {
|
|
6
|
+
const host = String(url.searchParams.get("host") || "").trim();
|
|
7
|
+
jsonResponse(response, 200, bootstrap.state(host));
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
if (request.method === "POST") {
|
|
12
|
+
try {
|
|
13
|
+
const body = await readJsonBody(request);
|
|
14
|
+
const host = String(body.host || "").trim();
|
|
15
|
+
const action = String(body.action || "inspect").trim();
|
|
16
|
+
if (action === "inspect") {
|
|
17
|
+
jsonResponse(response, 200, await bootstrap.inspect(host));
|
|
18
|
+
} else if (action === "sync-protocol") {
|
|
19
|
+
jsonResponse(
|
|
20
|
+
response,
|
|
21
|
+
200,
|
|
22
|
+
await bootstrap.syncProtocol(host, {
|
|
23
|
+
operatorName: body.operatorName,
|
|
24
|
+
}),
|
|
25
|
+
);
|
|
26
|
+
} else if (action === "deploy") {
|
|
27
|
+
jsonResponse(
|
|
28
|
+
response,
|
|
29
|
+
200,
|
|
30
|
+
await bootstrap.deploy(host, {
|
|
31
|
+
remotePort: body.remotePort,
|
|
32
|
+
registerMcp: body.registerMcp !== false,
|
|
33
|
+
injectProtocol: body.injectProtocol !== false,
|
|
34
|
+
operatorName: body.operatorName,
|
|
35
|
+
}),
|
|
36
|
+
);
|
|
37
|
+
} else if (action === "remove") {
|
|
38
|
+
jsonResponse(response, 200, await bootstrap.remove(host));
|
|
39
|
+
} else {
|
|
40
|
+
jsonResponse(response, 400, { error: "不支持的操作类型" });
|
|
41
|
+
}
|
|
42
|
+
} catch (error) {
|
|
43
|
+
jsonResponse(response, 400, { error: error.message });
|
|
44
|
+
}
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
jsonResponse(response, 405, { error: "不支持的请求方法" });
|
|
49
|
+
return true;
|
|
50
|
+
};
|
|
51
|
+
}
|