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,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
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { mkdir, readFile, realpath, writeFile } from "node:fs/promises";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
|
|
5
|
+
export const SCOPE_PROTOCOL_BEGIN = "<!-- SCOPE_PROTOCOL_BEGIN -->";
|
|
6
|
+
export const SCOPE_PROTOCOL_END = "<!-- SCOPE_PROTOCOL_END -->";
|
|
7
|
+
|
|
8
|
+
const GENERIC_OPERATOR_NAMES = new Set(["", "operator", "preview", "预览", "user"]);
|
|
9
|
+
|
|
10
|
+
export function sanitizeOperatorName(value) {
|
|
11
|
+
const cleaned = String(value || "")
|
|
12
|
+
.replace(/[\u0000-\u001f\u007f\r\n`*_<>[\]]/g, "")
|
|
13
|
+
.trim()
|
|
14
|
+
.slice(0, 40);
|
|
15
|
+
return GENERIC_OPERATOR_NAMES.has(cleaned.toLowerCase()) ? "" : cleaned;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function buildScopeProtocolBlock({ operatorName = "" } = {}) {
|
|
19
|
+
const operator = sanitizeOperatorName(operatorName);
|
|
20
|
+
const lines = [
|
|
21
|
+
SCOPE_PROTOCOL_BEGIN,
|
|
22
|
+
"## SCOPE Output & Rich-Media Display Protocol",
|
|
23
|
+
"",
|
|
24
|
+
"When responding inside SCOPE (or generating reports meant to be read in SCOPE Web UI), follow these formatting rules so formulas, tables, media, and file links render natively:",
|
|
25
|
+
"",
|
|
26
|
+
];
|
|
27
|
+
if (operator) {
|
|
28
|
+
lines.push(
|
|
29
|
+
`0. **Operator / User Name**: Address the user as **${operator}** in direct replies and completion summaries.`,
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
lines.push(
|
|
33
|
+
"1. **LaTeX Math**: Use `$...$` for inline math and `$$...$$` (or fenced ```` ```latex ```` blocks) for display equations. Never spell out multi-term equations in plain ASCII text.",
|
|
34
|
+
"2. **Markdown Tables (GFM)**: Present structured comparisons, metrics, and schedules using standard GitHub Flavored Markdown pipe tables (`| Column A | Column B |` followed by `| --- | --- |`). Do not use raw tab-separated text or space-padded ASCII tables.",
|
|
35
|
+
"3. **Inline Images & Videos**: Embed generated charts, screenshots, and video rollouts using Markdown image syntax with absolute paths or `file://` URIs so SCOPE displays them inline:",
|
|
36
|
+
" - Images (`.png`, `.jpg`, `.jpeg`, `.webp`, `.gif`, `.svg`): `` or ``",
|
|
37
|
+
" - Videos (`.mp4`, `.webm`, `.m4v`, `.ogv`, `.mov`): `` or `[Caption](file:///abs/path/to/video.mp4)`",
|
|
38
|
+
" - Do not wrap visual asset paths solely in backticks when the user should inspect the rendered image or video.",
|
|
39
|
+
"4. **Clickable File & Line Links**: Reference source files, configs, and logs as clickable Markdown links using `file://` or absolute paths with optional line anchors, e.g. `[train.py](file:///abs/path/to/train.py#L42-L68)` or `[train.py](/abs/path/to/train.py:42)`.",
|
|
40
|
+
SCOPE_PROTOCOL_END,
|
|
41
|
+
);
|
|
42
|
+
return lines.join("\n");
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export const SCOPE_PROTOCOL_BLOCK = buildScopeProtocolBlock();
|
|
46
|
+
|
|
47
|
+
export function upsertMarkedBlock(current, begin, end, block) {
|
|
48
|
+
const source = String(current || "");
|
|
49
|
+
if (source.includes(begin) && source.includes(end)) {
|
|
50
|
+
const startIdx = source.indexOf(begin);
|
|
51
|
+
const endIdx = source.indexOf(end, startIdx + begin.length);
|
|
52
|
+
if (endIdx >= 0) {
|
|
53
|
+
const prefix = source.slice(0, startIdx).trimEnd();
|
|
54
|
+
const suffix = source.slice(endIdx + end.length);
|
|
55
|
+
const joinedPrefix = prefix ? `${prefix}\n\n` : "";
|
|
56
|
+
const joinedSuffix = suffix.startsWith("\n") ? suffix : suffix ? `\n${suffix}` : "\n";
|
|
57
|
+
return `${joinedPrefix}${block}${joinedSuffix}`;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return source.trim() ? `${source.trimEnd()}\n\n${block}\n` : `${block}\n`;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function removeMarkedBlock(current, begin, end) {
|
|
64
|
+
const source = String(current || "");
|
|
65
|
+
if (!source.includes(begin) || !source.includes(end)) return source;
|
|
66
|
+
const startIdx = source.indexOf(begin);
|
|
67
|
+
const endIdx = source.indexOf(end, startIdx + begin.length);
|
|
68
|
+
if (endIdx < 0) return source;
|
|
69
|
+
const prefix = source.slice(0, startIdx).trimEnd();
|
|
70
|
+
const suffix = source.slice(endIdx + end.length).trimStart();
|
|
71
|
+
const cleaned = [prefix, suffix].filter(Boolean).join("\n\n").trim();
|
|
72
|
+
return cleaned ? `${cleaned}\n` : "";
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Sync SCOPE_PROTOCOL_BLOCK into local Codex, Claude Code, and Antigravity
|
|
77
|
+
* instruction files without overwriting any existing user instructions.
|
|
78
|
+
*/
|
|
79
|
+
export async function syncLocalScopeProtocol(homeDir = os.homedir(), { operatorName = "" } = {}) {
|
|
80
|
+
const block = buildScopeProtocolBlock({ operatorName });
|
|
81
|
+
const candidates = [
|
|
82
|
+
{ client: "codex", file: path.join(homeDir, ".codex", "AGENTS.md") },
|
|
83
|
+
{ client: "claude", file: path.join(homeDir, ".claude", "CLAUDE.md") },
|
|
84
|
+
{ client: "antigravity", file: path.join(homeDir, ".gemini", "config", "GEMINI.md") },
|
|
85
|
+
];
|
|
86
|
+
const seen = new Set();
|
|
87
|
+
const updated = [];
|
|
88
|
+
for (const item of candidates) {
|
|
89
|
+
await mkdir(path.dirname(item.file), { recursive: true });
|
|
90
|
+
let canonical = item.file;
|
|
91
|
+
try {
|
|
92
|
+
canonical = await realpath(item.file);
|
|
93
|
+
} catch {
|
|
94
|
+
/* File does not exist yet; canonicalize parent instead. */
|
|
95
|
+
try {
|
|
96
|
+
canonical = path.join(await realpath(path.dirname(item.file)), path.basename(item.file));
|
|
97
|
+
} catch {
|
|
98
|
+
canonical = path.resolve(item.file);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
if (seen.has(canonical)) continue;
|
|
102
|
+
seen.add(canonical);
|
|
103
|
+
let current = "";
|
|
104
|
+
try {
|
|
105
|
+
current = await readFile(item.file, "utf8");
|
|
106
|
+
} catch (error) {
|
|
107
|
+
if (error.code !== "ENOENT") throw error;
|
|
108
|
+
}
|
|
109
|
+
const next = upsertMarkedBlock(
|
|
110
|
+
current,
|
|
111
|
+
SCOPE_PROTOCOL_BEGIN,
|
|
112
|
+
SCOPE_PROTOCOL_END,
|
|
113
|
+
block,
|
|
114
|
+
);
|
|
115
|
+
await writeFile(item.file, next, "utf8");
|
|
116
|
+
updated.push({ client: item.client, path: item.file });
|
|
117
|
+
}
|
|
118
|
+
return {
|
|
119
|
+
codex: true,
|
|
120
|
+
claude: true,
|
|
121
|
+
antigravity: true,
|
|
122
|
+
operatorName: sanitizeOperatorName(operatorName) || null,
|
|
123
|
+
files: updated,
|
|
124
|
+
};
|
|
125
|
+
}
|