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,18 @@
|
|
|
1
|
+
import { LOCAL_HOST } from "../../lib/execution-host.js";
|
|
2
|
+
import { shellQuote } from "../transport/ssh-command.mjs";
|
|
3
|
+
import { runLocalPython } from "../local/python-probe.mjs";
|
|
4
|
+
|
|
5
|
+
export async function scanResearchHost({ host, encoded, script, timeoutMs, runSsh, runLocal = runLocalPython, cleanError = String }) {
|
|
6
|
+
const failed = (error) => ({ host: host.alias, error: cleanError(error), terms: [], filesScanned: 0, totalFiles: 0, results: [] });
|
|
7
|
+
try {
|
|
8
|
+
const result = host.alias === LOCAL_HOST
|
|
9
|
+
? await runLocal(script, [encoded], timeoutMs, 8_000_000)
|
|
10
|
+
: await runSsh(host.alias, `timeout ${Math.max(15, Math.floor(timeoutMs / 1000) - 3)}s python3 - ${shellQuote(encoded)}`, script, timeoutMs, 8_000_000);
|
|
11
|
+
if (result.code !== 0) return failed(result.stderr || result.stdout || "检索未完成");
|
|
12
|
+
const data = JSON.parse(result.stdout);
|
|
13
|
+
if (!Array.isArray(data.results)) return failed("检索结果无法解析");
|
|
14
|
+
return { ...data, host: host.alias, error: null };
|
|
15
|
+
} catch (error) {
|
|
16
|
+
return failed(error.message);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
|
|
3
|
+
export function stripContext(value) {
|
|
4
|
+
if (typeof value !== "string") return "";
|
|
5
|
+
return value
|
|
6
|
+
.replace(/<[^>]+>[\s\S]*?<\/[^>]+>/g, " ")
|
|
7
|
+
.replace(/\s+/g, " ")
|
|
8
|
+
.trim();
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function inferCategory(text) {
|
|
12
|
+
if (/调研|查阅|检索|文献|论文|survey|research|literature|paper/i.test(text)) {
|
|
13
|
+
return "research";
|
|
14
|
+
}
|
|
15
|
+
if (/评测|评估|eval|evaluation|benchmark|libero|指标|统计/i.test(text)) {
|
|
16
|
+
return "evaluation";
|
|
17
|
+
}
|
|
18
|
+
if (/训练|train|epoch|step|loss|checkpoint|微调|finetun/i.test(text)) {
|
|
19
|
+
return "training";
|
|
20
|
+
}
|
|
21
|
+
if (/实现|修复|代码|重构|bug|debug|build|部署|接口|脚本/i.test(text)) {
|
|
22
|
+
return "engineering";
|
|
23
|
+
}
|
|
24
|
+
return "other";
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function shortenTheme(value, cwd) {
|
|
28
|
+
const cleaned = stripContext(value)
|
|
29
|
+
.replace(
|
|
30
|
+
/^(请|麻烦|现在|接下来|另外|你可以|能不能|帮我|继续|进入下一步)[,,。:\s]*/i,
|
|
31
|
+
"",
|
|
32
|
+
)
|
|
33
|
+
.replace(/[。!?!?;;].*$/, "")
|
|
34
|
+
.trim();
|
|
35
|
+
if (cleaned && !/^(继续|进度呢|现在呢|下一步|?+)$/.test(cleaned)) {
|
|
36
|
+
return cleaned.slice(0, 22);
|
|
37
|
+
}
|
|
38
|
+
return `${path.posix.basename(cwd || "") || "未命名"} 会话`;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function heuristicSummary(rollout, cwd) {
|
|
42
|
+
const userMessages = [
|
|
43
|
+
rollout?.firstUser,
|
|
44
|
+
...(Array.isArray(rollout?.userMessages) ? rollout.userMessages : []),
|
|
45
|
+
rollout?.lastUser,
|
|
46
|
+
]
|
|
47
|
+
.map(stripContext)
|
|
48
|
+
.filter(Boolean);
|
|
49
|
+
const useful =
|
|
50
|
+
userMessages.find(
|
|
51
|
+
(message) =>
|
|
52
|
+
!/^(继续|进入下一步|现在进度呢|进度呢|为什么不报告进度|干嘛呢|?+)[。!?!?]*$/.test(
|
|
53
|
+
message,
|
|
54
|
+
),
|
|
55
|
+
) ||
|
|
56
|
+
userMessages[0] ||
|
|
57
|
+
"";
|
|
58
|
+
const assistantMessages = Array.isArray(rollout?.assistantMessages)
|
|
59
|
+
? rollout.assistantMessages.map(stripContext).filter(Boolean)
|
|
60
|
+
: [];
|
|
61
|
+
const combined = [...userMessages, ...assistantMessages].join(" ");
|
|
62
|
+
const taskCategory = inferCategory(useful);
|
|
63
|
+
const category =
|
|
64
|
+
taskCategory === "other" ? inferCategory(combined) : taskCategory;
|
|
65
|
+
const latestReport = assistantMessages.at(-1) || rollout?.lastAssistant || "";
|
|
66
|
+
|
|
67
|
+
return {
|
|
68
|
+
theme: shortenTheme(useful, cwd),
|
|
69
|
+
category,
|
|
70
|
+
objective: useful.slice(0, 220) || "尚未从 rollout 中提取到明确任务",
|
|
71
|
+
progress:
|
|
72
|
+
(latestReport || rollout?.lastAction || "等待新的会话事件").slice(0, 420),
|
|
73
|
+
result: category === "research" ? latestReport.slice(0, 1200) : "",
|
|
74
|
+
nextStep: "",
|
|
75
|
+
source: "rollout",
|
|
76
|
+
updatedAt: rollout?.lastEventAt || new Date().toISOString(),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function historicalAgent(host, rollout) {
|
|
81
|
+
const cwd = rollout.cwd || "";
|
|
82
|
+
const lastEventAt = Date.parse(rollout.lastEventAt || "");
|
|
83
|
+
const executable =
|
|
84
|
+
host.agents
|
|
85
|
+
?.map((agent) => agent.executable)
|
|
86
|
+
.find(
|
|
87
|
+
(candidate) =>
|
|
88
|
+
typeof candidate === "string" &&
|
|
89
|
+
candidate.startsWith("/") &&
|
|
90
|
+
candidate.endsWith("/codex"),
|
|
91
|
+
) || "codex";
|
|
92
|
+
return {
|
|
93
|
+
id: `history:${host.alias}:${rollout.id}`,
|
|
94
|
+
host: host.alias,
|
|
95
|
+
hostname: host.hostname || host.alias,
|
|
96
|
+
pid: 0,
|
|
97
|
+
tty: "历史记录",
|
|
98
|
+
cwd,
|
|
99
|
+
executable,
|
|
100
|
+
elapsedSeconds: 0,
|
|
101
|
+
status: "idle",
|
|
102
|
+
pane: null,
|
|
103
|
+
rollout,
|
|
104
|
+
subagents: Array.isArray(rollout.subagents) ? rollout.subagents : [],
|
|
105
|
+
historical: true,
|
|
106
|
+
mapping: {
|
|
107
|
+
rollout: "history",
|
|
108
|
+
tmux: "unmatched",
|
|
109
|
+
},
|
|
110
|
+
lastActivityAt: Number.isFinite(lastEventAt)
|
|
111
|
+
? lastEventAt
|
|
112
|
+
: rollout.mtimeMs || null,
|
|
113
|
+
suggestedSummary: heuristicSummary(rollout, cwd),
|
|
114
|
+
title:
|
|
115
|
+
rollout.lastUser ||
|
|
116
|
+
`历史会话 · ${path.posix.basename(cwd) || rollout.id.slice(0, 8)}`,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export function createAgentEnricher({ getSubmissionItems }) {
|
|
121
|
+
return function enrichAgentRelations(host, agent) {
|
|
122
|
+
const sessionId = agent.rollout?.id || "";
|
|
123
|
+
const subagentById = new Map();
|
|
124
|
+
for (const sub of Array.isArray(agent.subagents) ? agent.subagents : []) {
|
|
125
|
+
if (sub?.id) subagentById.set(sub.id, sub);
|
|
126
|
+
}
|
|
127
|
+
if (sessionId) {
|
|
128
|
+
for (const session of Array.isArray(host.sessions) ? host.sessions : []) {
|
|
129
|
+
if (!session?.isSubagent || !session.id) continue;
|
|
130
|
+
if (session.parentThreadId !== sessionId) continue;
|
|
131
|
+
const prev = subagentById.get(session.id);
|
|
132
|
+
if (!prev || (session.mtimeMs || 0) >= (prev.mtimeMs || 0)) {
|
|
133
|
+
subagentById.set(session.id, session);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
const mergedSubagents = Array.from(subagentById.values()).sort(
|
|
138
|
+
(a, b) => (b.mtimeMs || 0) - (a.mtimeMs || 0),
|
|
139
|
+
);
|
|
140
|
+
const relatedSessionIds = new Set([
|
|
141
|
+
sessionId,
|
|
142
|
+
...mergedSubagents.map((subagent) => subagent.id),
|
|
143
|
+
]);
|
|
144
|
+
const localWorkloads = (host.workloads || []).filter(
|
|
145
|
+
(workload) => workload.ownerSessionId === sessionId,
|
|
146
|
+
);
|
|
147
|
+
const remoteJobs = getSubmissionItems().filter(
|
|
148
|
+
(item) =>
|
|
149
|
+
item.host === host.alias &&
|
|
150
|
+
(relatedSessionIds.has(item.sessionId) ||
|
|
151
|
+
(item.parentThreadId && relatedSessionIds.has(item.parentThreadId))),
|
|
152
|
+
);
|
|
153
|
+
const paneKeys = new Set();
|
|
154
|
+
const relatedPanes = [];
|
|
155
|
+
const addPane = (pane) => {
|
|
156
|
+
if (!pane) return;
|
|
157
|
+
const key = `${pane.session}:${pane.pane}`;
|
|
158
|
+
if (paneKeys.has(key)) return;
|
|
159
|
+
paneKeys.add(key);
|
|
160
|
+
const fullPane =
|
|
161
|
+
host.panes.find(
|
|
162
|
+
(candidate) =>
|
|
163
|
+
candidate.session === pane.session && candidate.pane === pane.pane,
|
|
164
|
+
) || pane;
|
|
165
|
+
relatedPanes.push(fullPane);
|
|
166
|
+
};
|
|
167
|
+
addPane(agent.pane);
|
|
168
|
+
for (const workload of localWorkloads) addPane(workload.pane);
|
|
169
|
+
return {
|
|
170
|
+
...agent,
|
|
171
|
+
subagents: mergedSubagents,
|
|
172
|
+
localWorkloads,
|
|
173
|
+
remoteJobs,
|
|
174
|
+
relatedPanes,
|
|
175
|
+
};
|
|
176
|
+
};
|
|
177
|
+
}
|
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
import { LOCAL_HOST } from "../../lib/execution-host.js";
|
|
2
|
+
|
|
3
|
+
/** Domain routes. Context is read per request so replaced snapshot state stays current. */
|
|
4
|
+
export function authRoutes(context) {
|
|
5
|
+
return async (request, response, url) => {
|
|
6
|
+
const {
|
|
7
|
+
accountQuotas,
|
|
8
|
+
appServerActiveAuthFailoverJobs,
|
|
9
|
+
assertProfileNotBound,
|
|
10
|
+
auditLifecycle,
|
|
11
|
+
authProfileManager,
|
|
12
|
+
authRestartJobs,
|
|
13
|
+
checkedProfileSlug,
|
|
14
|
+
deleteAuthProfile,
|
|
15
|
+
hostCodexExecutable,
|
|
16
|
+
jsonResponse,
|
|
17
|
+
latestAuthRestartJob,
|
|
18
|
+
listAuthProfiles,
|
|
19
|
+
normalizeProfileName,
|
|
20
|
+
publicAuthRestartJob,
|
|
21
|
+
publicProfileFailoverJob,
|
|
22
|
+
readJsonBody,
|
|
23
|
+
readLocalAuthProfiles,
|
|
24
|
+
runProfileWrite,
|
|
25
|
+
snapshot,
|
|
26
|
+
startAuthRestart,
|
|
27
|
+
} = context();
|
|
28
|
+
if (url.pathname === "/api/auth/profiles" && request.method === "GET") {
|
|
29
|
+
try {
|
|
30
|
+
const host = snapshot.hosts.find(
|
|
31
|
+
(candidate) => candidate.alias === url.searchParams.get("host"),
|
|
32
|
+
);
|
|
33
|
+
if (!host?.reachable) {
|
|
34
|
+
jsonResponse(response, 404, { error: "所选 SSH 主机当前不可连接" });
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
const runningSessions = host.agents.filter(
|
|
38
|
+
(agent) => agent.rollout?.id && !agent.rollout.isSubagent,
|
|
39
|
+
).length;
|
|
40
|
+
if (host.alias === LOCAL_HOST) {
|
|
41
|
+
const localProfiles = await readLocalAuthProfiles();
|
|
42
|
+
jsonResponse(response, 200, {
|
|
43
|
+
...localProfiles,
|
|
44
|
+
host: host.alias,
|
|
45
|
+
runningSessions,
|
|
46
|
+
});
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
const profiles = await listAuthProfiles(host.alias);
|
|
50
|
+
jsonResponse(response, 200, {
|
|
51
|
+
host: host.alias,
|
|
52
|
+
...profiles,
|
|
53
|
+
runningSessions,
|
|
54
|
+
restartJob: latestAuthRestartJob(host.alias)
|
|
55
|
+
? publicAuthRestartJob(latestAuthRestartJob(host.alias))
|
|
56
|
+
: null,
|
|
57
|
+
automaticFailover: publicProfileFailoverJob(
|
|
58
|
+
appServerActiveAuthFailoverJobs.get(host.alias),
|
|
59
|
+
),
|
|
60
|
+
});
|
|
61
|
+
} catch (error) {
|
|
62
|
+
jsonResponse(response, 502, {
|
|
63
|
+
error: `读取账号 Profiles 失败:${error.message}`,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (url.pathname === "/api/auth/quota" && request.method === "GET") {
|
|
70
|
+
try {
|
|
71
|
+
const host = snapshot.hosts.find(
|
|
72
|
+
(candidate) => candidate.alias === url.searchParams.get("host"),
|
|
73
|
+
);
|
|
74
|
+
if (!host?.reachable) {
|
|
75
|
+
jsonResponse(response, 404, { error: "所选 SSH 主机当前不可连接" });
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
const force = url.searchParams.get("refresh") === "1";
|
|
79
|
+
if (url.searchParams.get("all") === "1") {
|
|
80
|
+
const quotas = await accountQuotas.readHostQuotas(host.alias, { force });
|
|
81
|
+
jsonResponse(response, 200, quotas);
|
|
82
|
+
} else {
|
|
83
|
+
const connectionKey = url.searchParams.get("connectionKey") || "active";
|
|
84
|
+
const single = await accountQuotas.readSingleQuota(host.alias, {
|
|
85
|
+
connectionKey,
|
|
86
|
+
force,
|
|
87
|
+
});
|
|
88
|
+
jsonResponse(response, 200, single);
|
|
89
|
+
}
|
|
90
|
+
} catch (error) {
|
|
91
|
+
jsonResponse(response, 502, {
|
|
92
|
+
error: `读取账号额度失败:${error.message}`,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (url.pathname === "/api/auth/providers" && request.method === "GET") {
|
|
99
|
+
try {
|
|
100
|
+
const host = snapshot.hosts.find(
|
|
101
|
+
(candidate) => candidate.alias === url.searchParams.get("host"),
|
|
102
|
+
);
|
|
103
|
+
if (!host?.reachable) {
|
|
104
|
+
jsonResponse(response, 404, { error: "所选 SSH 主机当前不可连接" });
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
const force = url.searchParams.get("refresh") === "1";
|
|
108
|
+
jsonResponse(
|
|
109
|
+
response,
|
|
110
|
+
200,
|
|
111
|
+
await accountQuotas.readProviderAuthStatuses(host.alias, { force }),
|
|
112
|
+
);
|
|
113
|
+
} catch (error) {
|
|
114
|
+
jsonResponse(response, 502, {
|
|
115
|
+
error: `读取 Agent 登录状态失败:${error.message}`,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (
|
|
122
|
+
url.pathname === "/api/auth/profiles/save" &&
|
|
123
|
+
request.method === "POST"
|
|
124
|
+
) {
|
|
125
|
+
try {
|
|
126
|
+
const body = await readJsonBody(request);
|
|
127
|
+
const host = snapshot.hosts.find(
|
|
128
|
+
(candidate) => candidate.alias === body.host,
|
|
129
|
+
);
|
|
130
|
+
if (!host?.reachable) throw new Error("所选 SSH 主机当前不可连接");
|
|
131
|
+
const profile = normalizeProfileName(body.profileName);
|
|
132
|
+
assertProfileNotBound(host.alias, profile.slug);
|
|
133
|
+
const account =
|
|
134
|
+
(await listAuthProfiles(host.alias)).currentAccount || null;
|
|
135
|
+
await runProfileWrite(host.alias, "save-current", profile, account);
|
|
136
|
+
jsonResponse(response, 201, {
|
|
137
|
+
ok: true,
|
|
138
|
+
host: host.alias,
|
|
139
|
+
profile,
|
|
140
|
+
account,
|
|
141
|
+
});
|
|
142
|
+
} catch (error) {
|
|
143
|
+
jsonResponse(response, 502, {
|
|
144
|
+
error: `保存当前账号失败:${error.message}`,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (url.pathname === "/api/auth/login/start" && request.method === "POST") {
|
|
151
|
+
try {
|
|
152
|
+
const body = await readJsonBody(request);
|
|
153
|
+
const host = snapshot.hosts.find(
|
|
154
|
+
(candidate) => candidate.alias === body.host,
|
|
155
|
+
);
|
|
156
|
+
if (!host?.reachable) throw new Error("所选 SSH 主机当前不可连接");
|
|
157
|
+
assertProfileNotBound(
|
|
158
|
+
host.alias,
|
|
159
|
+
normalizeProfileName(body.profileName).slug,
|
|
160
|
+
);
|
|
161
|
+
const job = await authProfileManager.start({
|
|
162
|
+
host: host.alias,
|
|
163
|
+
executable: hostCodexExecutable(host),
|
|
164
|
+
profileName: body.profileName,
|
|
165
|
+
});
|
|
166
|
+
jsonResponse(response, 201, job);
|
|
167
|
+
} catch (error) {
|
|
168
|
+
jsonResponse(response, 502, {
|
|
169
|
+
error: `启动 device auth 失败:${error.message}`,
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
return true;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (url.pathname === "/api/auth/login/status" && request.method === "GET") {
|
|
176
|
+
const job = authProfileManager.get(url.searchParams.get("jobId"));
|
|
177
|
+
jsonResponse(
|
|
178
|
+
response,
|
|
179
|
+
job ? 200 : 404,
|
|
180
|
+
job || { error: "找不到这条登录任务;Bridge 重启后请重新发起登录" },
|
|
181
|
+
);
|
|
182
|
+
return true;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if (
|
|
186
|
+
url.pathname === "/api/auth/login/cancel" &&
|
|
187
|
+
request.method === "POST"
|
|
188
|
+
) {
|
|
189
|
+
try {
|
|
190
|
+
const body = await readJsonBody(request);
|
|
191
|
+
jsonResponse(
|
|
192
|
+
response,
|
|
193
|
+
200,
|
|
194
|
+
await authProfileManager.cancel(body.jobId),
|
|
195
|
+
);
|
|
196
|
+
} catch (error) {
|
|
197
|
+
jsonResponse(response, 404, { error: error.message });
|
|
198
|
+
}
|
|
199
|
+
return true;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
if (
|
|
203
|
+
url.pathname === "/api/auth/profiles/activate" &&
|
|
204
|
+
request.method === "POST"
|
|
205
|
+
) {
|
|
206
|
+
try {
|
|
207
|
+
const body = await readJsonBody(request);
|
|
208
|
+
const host = snapshot.hosts.find(
|
|
209
|
+
(candidate) => candidate.alias === body.host,
|
|
210
|
+
);
|
|
211
|
+
if (!host?.reachable) throw new Error("所选 SSH 主机当前不可连接");
|
|
212
|
+
const slug = checkedProfileSlug(body.slug);
|
|
213
|
+
const profile = { slug, name: String(body.name || slug).slice(0, 80) };
|
|
214
|
+
// Account metadata already lives beside the remote profile. Never accept
|
|
215
|
+
// credential-shaped data echoed back by the browser.
|
|
216
|
+
await runProfileWrite(host.alias, "select-default", profile, null);
|
|
217
|
+
await auditLifecycle("host-default-profile-selected", {
|
|
218
|
+
host: host.alias,
|
|
219
|
+
profile: slug,
|
|
220
|
+
existingSessionsUnchanged: true,
|
|
221
|
+
remoteSessionSignalSent: false,
|
|
222
|
+
});
|
|
223
|
+
const runningSessions = host.agents.filter(
|
|
224
|
+
(agent) => agent.rollout?.id && !agent.rollout.isSubagent,
|
|
225
|
+
).length;
|
|
226
|
+
jsonResponse(response, 200, {
|
|
227
|
+
ok: true,
|
|
228
|
+
host: host.alias,
|
|
229
|
+
activeProfile: slug,
|
|
230
|
+
runningSessions,
|
|
231
|
+
restartRequired: false,
|
|
232
|
+
});
|
|
233
|
+
} catch (error) {
|
|
234
|
+
jsonResponse(response, 502, {
|
|
235
|
+
error: `切换账号失败:${error.message}`,
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
return true;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
if (
|
|
242
|
+
url.pathname === "/api/auth/profiles/delete" &&
|
|
243
|
+
request.method === "POST"
|
|
244
|
+
) {
|
|
245
|
+
try {
|
|
246
|
+
const body = await readJsonBody(request);
|
|
247
|
+
const host = snapshot.hosts.find(
|
|
248
|
+
(candidate) => candidate.alias === body.host,
|
|
249
|
+
);
|
|
250
|
+
if (!host?.reachable) throw new Error("所选 SSH 主机当前不可连接");
|
|
251
|
+
const slug = checkedProfileSlug(body.slug);
|
|
252
|
+
if (body.confirmation !== `${host.alias}:${slug}`) {
|
|
253
|
+
jsonResponse(response, 400, {
|
|
254
|
+
error: "删除确认与目标主机/Profile 不匹配",
|
|
255
|
+
});
|
|
256
|
+
return true;
|
|
257
|
+
}
|
|
258
|
+
assertProfileNotBound(host.alias, slug);
|
|
259
|
+
const profiles = await listAuthProfiles(host.alias);
|
|
260
|
+
const profile = profiles.profiles.find(
|
|
261
|
+
(candidate) => candidate.slug === slug,
|
|
262
|
+
);
|
|
263
|
+
if (!profile) {
|
|
264
|
+
jsonResponse(response, 404, { error: "Profile 不存在或已经删除" });
|
|
265
|
+
return true;
|
|
266
|
+
}
|
|
267
|
+
if (profile.active || profiles.activeProfile === slug) {
|
|
268
|
+
jsonResponse(response, 409, {
|
|
269
|
+
error: "当前正在使用的 Profile 不能删除;请先切换到另一套账号",
|
|
270
|
+
});
|
|
271
|
+
return true;
|
|
272
|
+
}
|
|
273
|
+
const cancelledLoginJobs = await authProfileManager.cancelForProfile(
|
|
274
|
+
host.alias,
|
|
275
|
+
slug,
|
|
276
|
+
);
|
|
277
|
+
await deleteAuthProfile(host.alias, slug);
|
|
278
|
+
jsonResponse(response, 200, {
|
|
279
|
+
ok: true,
|
|
280
|
+
host: host.alias,
|
|
281
|
+
slug,
|
|
282
|
+
removed: true,
|
|
283
|
+
cancelledLoginJobs,
|
|
284
|
+
});
|
|
285
|
+
} catch (error) {
|
|
286
|
+
jsonResponse(response, 502, {
|
|
287
|
+
error: `删除 Profile 失败:${error.message}`,
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
return true;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
if (url.pathname === "/api/auth/restart" && request.method === "POST") {
|
|
294
|
+
try {
|
|
295
|
+
const body = await readJsonBody(request);
|
|
296
|
+
const host = typeof body.host === "string" ? body.host : "";
|
|
297
|
+
if (!host || body.confirmation !== host) {
|
|
298
|
+
jsonResponse(response, 400, {
|
|
299
|
+
error: "必须明确确认目标主机名后才能重启会话",
|
|
300
|
+
});
|
|
301
|
+
return true;
|
|
302
|
+
}
|
|
303
|
+
jsonResponse(response, 202, startAuthRestart(host));
|
|
304
|
+
} catch (error) {
|
|
305
|
+
jsonResponse(response, 502, {
|
|
306
|
+
error: `启动批量重启失败:${error.message}`,
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
return true;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
if (
|
|
313
|
+
url.pathname === "/api/auth/restart/status" &&
|
|
314
|
+
request.method === "GET"
|
|
315
|
+
) {
|
|
316
|
+
const job = authRestartJobs.get(url.searchParams.get("jobId"));
|
|
317
|
+
jsonResponse(
|
|
318
|
+
response,
|
|
319
|
+
job ? 200 : 404,
|
|
320
|
+
job ? publicAuthRestartJob(job) : { error: "找不到这条重启任务" },
|
|
321
|
+
);
|
|
322
|
+
return true;
|
|
323
|
+
}
|
|
324
|
+
return false;
|
|
325
|
+
};
|
|
326
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { LOCAL_HOST } from "../../lib/execution-host.js";
|
|
2
|
+
/** Domain routes. Context is read per request so replaced snapshot state stays current. */
|
|
3
|
+
export function dialogueRoutes(context) {
|
|
4
|
+
return async (request, response, url) => {
|
|
5
|
+
const {
|
|
6
|
+
DIALOGUE_PROBE,
|
|
7
|
+
localDialogue,
|
|
8
|
+
DIALOGUE_TIMEOUT_MS,
|
|
9
|
+
RAW_CONTEXT_PROBE,
|
|
10
|
+
cleanSshError,
|
|
11
|
+
findAgent,
|
|
12
|
+
getSnapshot,
|
|
13
|
+
historicalSessions,
|
|
14
|
+
jsonResponse,
|
|
15
|
+
readJsonBody,
|
|
16
|
+
runSshCommand,
|
|
17
|
+
sessionKey,
|
|
18
|
+
shellQuote,
|
|
19
|
+
} = context();
|
|
20
|
+
if (url.pathname === "/api/dialogue" && request.method === "POST") {
|
|
21
|
+
try {
|
|
22
|
+
const body = await readJsonBody(request);
|
|
23
|
+
const subagentId =
|
|
24
|
+
typeof body.subagentId === "string" ? body.subagentId.trim() : "";
|
|
25
|
+
if (body.host === LOCAL_HOST && localDialogue) {
|
|
26
|
+
const dialogue = await localDialogue(body);
|
|
27
|
+
jsonResponse(response, 200, {
|
|
28
|
+
ok: true,
|
|
29
|
+
host: body.host,
|
|
30
|
+
sessionId: body.sessionId,
|
|
31
|
+
...(subagentId ? { subagentId } : {}),
|
|
32
|
+
loadedAt: new Date().toISOString(),
|
|
33
|
+
...dialogue,
|
|
34
|
+
});
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
const agent =
|
|
38
|
+
findAgent(body.host, body.sessionId) ||
|
|
39
|
+
historicalSessions.get(sessionKey(body.host, body.sessionId));
|
|
40
|
+
if (!agent?.rollout?.path) {
|
|
41
|
+
jsonResponse(response, 404, { error: "未找到对应的 rollout" });
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
let targetRollout = agent.rollout;
|
|
45
|
+
let subagentMeta = null;
|
|
46
|
+
if (subagentId) {
|
|
47
|
+
const hostEntry = getSnapshot?.()?.hosts?.find(
|
|
48
|
+
(item) => item.alias === agent.host,
|
|
49
|
+
);
|
|
50
|
+
const parentId = agent.rollout.id || body.sessionId;
|
|
51
|
+
const foundSub =
|
|
52
|
+
(agent.subagents || []).find((item) => item.id === subagentId) ||
|
|
53
|
+
(hostEntry?.sessions || []).find(
|
|
54
|
+
(item) =>
|
|
55
|
+
item.isSubagent &&
|
|
56
|
+
item.id === subagentId &&
|
|
57
|
+
item.parentThreadId === parentId,
|
|
58
|
+
);
|
|
59
|
+
if (!foundSub?.path) {
|
|
60
|
+
jsonResponse(response, 404, { error: "未找到对应的子代理 rollout" });
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
targetRollout = foundSub;
|
|
64
|
+
subagentMeta = {
|
|
65
|
+
id: foundSub.id,
|
|
66
|
+
agentNickname: foundSub.agentNickname || "",
|
|
67
|
+
agentPath: foundSub.agentPath || "",
|
|
68
|
+
agentRole: foundSub.agentRole || "",
|
|
69
|
+
model: foundSub.model || "",
|
|
70
|
+
turnState: foundSub.turnState || "idle",
|
|
71
|
+
lastAction: foundSub.lastAction || "",
|
|
72
|
+
lastEventAt: foundSub.lastEventAt || null,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
const limit = Math.max(
|
|
76
|
+
1,
|
|
77
|
+
Math.min(100, Number(body.limit) || (subagentId ? 40 : 10)),
|
|
78
|
+
);
|
|
79
|
+
const before = Number.isFinite(Number(body.before))
|
|
80
|
+
? Math.max(0, Math.floor(Number(body.before)))
|
|
81
|
+
: "";
|
|
82
|
+
const command = [
|
|
83
|
+
"python3 -",
|
|
84
|
+
shellQuote(targetRollout.path),
|
|
85
|
+
shellQuote(String(limit)),
|
|
86
|
+
shellQuote(String(before)),
|
|
87
|
+
shellQuote(body.dialogueOnly ? "dialogue-only" : "full"),
|
|
88
|
+
].join(" ");
|
|
89
|
+
const result = await runSshCommand(
|
|
90
|
+
agent.host,
|
|
91
|
+
command,
|
|
92
|
+
DIALOGUE_PROBE,
|
|
93
|
+
DIALOGUE_TIMEOUT_MS,
|
|
94
|
+
5_000_000,
|
|
95
|
+
);
|
|
96
|
+
if (result.code !== 0) {
|
|
97
|
+
throw new Error(cleanSshError(result.stderr || result.stdout));
|
|
98
|
+
}
|
|
99
|
+
let dialogue;
|
|
100
|
+
try {
|
|
101
|
+
dialogue = JSON.parse(result.stdout.trim());
|
|
102
|
+
} catch {
|
|
103
|
+
throw new Error("远端返回的 dialogue 数据不完整");
|
|
104
|
+
}
|
|
105
|
+
jsonResponse(response, 200, {
|
|
106
|
+
ok: true,
|
|
107
|
+
host: agent.host,
|
|
108
|
+
sessionId: agent.rollout.id,
|
|
109
|
+
...(subagentMeta ? { subagentId: subagentMeta.id, subagent: subagentMeta } : {}),
|
|
110
|
+
loadedAt: new Date().toISOString(),
|
|
111
|
+
...dialogue,
|
|
112
|
+
});
|
|
113
|
+
} catch (error) {
|
|
114
|
+
jsonResponse(response, 502, {
|
|
115
|
+
error: `Dialogue 读取失败:${error.message}`,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (
|
|
122
|
+
url.pathname === "/api/session/raw-context" &&
|
|
123
|
+
request.method === "POST"
|
|
124
|
+
) {
|
|
125
|
+
try {
|
|
126
|
+
const body = await readJsonBody(request);
|
|
127
|
+
const agent =
|
|
128
|
+
findAgent(body.host, body.sessionId) ||
|
|
129
|
+
historicalSessions.get(sessionKey(body.host, body.sessionId));
|
|
130
|
+
if (!agent?.rollout?.path) {
|
|
131
|
+
jsonResponse(response, 404, { error: "未找到对应的 rollout" });
|
|
132
|
+
return true;
|
|
133
|
+
}
|
|
134
|
+
const result = await runSshCommand(
|
|
135
|
+
agent.host,
|
|
136
|
+
`python3 - ${shellQuote(agent.rollout.path)}`,
|
|
137
|
+
RAW_CONTEXT_PROBE,
|
|
138
|
+
DIALOGUE_TIMEOUT_MS,
|
|
139
|
+
10_000_000,
|
|
140
|
+
);
|
|
141
|
+
if (result.code !== 0) {
|
|
142
|
+
throw new Error(cleanSshError(result.stderr || result.stdout));
|
|
143
|
+
}
|
|
144
|
+
let context;
|
|
145
|
+
try {
|
|
146
|
+
context = JSON.parse(result.stdout.trim());
|
|
147
|
+
} catch {
|
|
148
|
+
throw new Error("远端返回的 raw context 数据不完整");
|
|
149
|
+
}
|
|
150
|
+
jsonResponse(response, 200, {
|
|
151
|
+
ok: true,
|
|
152
|
+
host: agent.host,
|
|
153
|
+
sessionId: agent.rollout.id,
|
|
154
|
+
context,
|
|
155
|
+
});
|
|
156
|
+
} catch (error) {
|
|
157
|
+
jsonResponse(response, 502, {
|
|
158
|
+
error: `Raw context 读取失败:${error.message}`,
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
return true;
|
|
162
|
+
}
|
|
163
|
+
return false;
|
|
164
|
+
};
|
|
165
|
+
}
|