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,150 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { mkdir, open, readdir, rm, stat } from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
|
|
5
|
+
export const MAX_ATTACHMENT_BYTES = 50 * 1024 * 1024;
|
|
6
|
+
export const MAX_ATTACHMENTS_PER_TURN = 8;
|
|
7
|
+
export const MAX_ATTACHMENTS_TOTAL_BYTES = 100 * 1024 * 1024;
|
|
8
|
+
const LOCAL_RETENTION_MS = 7 * 24 * 60 * 60_000;
|
|
9
|
+
|
|
10
|
+
const STRUCTURED_IMAGE_MIME_TYPES = new Set([
|
|
11
|
+
"image/gif",
|
|
12
|
+
"image/jpeg",
|
|
13
|
+
"image/png",
|
|
14
|
+
"image/webp",
|
|
15
|
+
]);
|
|
16
|
+
|
|
17
|
+
function cleanString(value, limit) {
|
|
18
|
+
return typeof value === "string" ? value.trim().slice(0, limit) : "";
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function safeAttachmentFilename(value, uniqueSuffix = "") {
|
|
22
|
+
const original = path.posix.basename(String(value || "attachment").replaceAll("\\", "/"));
|
|
23
|
+
const extensionMatch = original.match(/(\.[a-zA-Z0-9]{1,12})$/);
|
|
24
|
+
const extension = extensionMatch?.[1]?.toLowerCase() || "";
|
|
25
|
+
const stem = original
|
|
26
|
+
.slice(0, Math.max(0, original.length - extension.length))
|
|
27
|
+
.normalize("NFKD")
|
|
28
|
+
.replace(/[^a-zA-Z0-9._-]+/g, "-")
|
|
29
|
+
.replace(/^[-._]+|[-._]+$/g, "")
|
|
30
|
+
.slice(0, 72) || "attachment";
|
|
31
|
+
const suffix = String(uniqueSuffix || "")
|
|
32
|
+
.replace(/[^a-zA-Z0-9_-]+/g, "")
|
|
33
|
+
.slice(0, 32);
|
|
34
|
+
return `${stem}${suffix ? `-${suffix}` : ""}${extension}`;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function attachmentKind(mimeType) {
|
|
38
|
+
return STRUCTURED_IMAGE_MIME_TYPES.has(cleanString(mimeType, 200).toLowerCase())
|
|
39
|
+
? "image"
|
|
40
|
+
: "file";
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function isValidAttachmentPath(value) {
|
|
44
|
+
return typeof value === "string" && (value.startsWith("/") || /^[A-Za-z]:[\\/]/.test(value));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function normalizeTurnAttachments(value) {
|
|
48
|
+
if (!Array.isArray(value)) return [];
|
|
49
|
+
return value
|
|
50
|
+
.slice(0, MAX_ATTACHMENTS_PER_TURN)
|
|
51
|
+
.map((attachment) => ({
|
|
52
|
+
name: cleanString(attachment?.name, 240) || "attachment",
|
|
53
|
+
mimeType: cleanString(attachment?.mimeType, 200) || "application/octet-stream",
|
|
54
|
+
size: Math.max(0, Math.floor(Number(attachment?.size) || 0)),
|
|
55
|
+
remotePath: cleanString(attachment?.remotePath, 4_000),
|
|
56
|
+
kind: attachment?.kind === "image" ? "image" : "file",
|
|
57
|
+
}))
|
|
58
|
+
.filter((attachment) => isValidAttachmentPath(attachment.remotePath));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function formatUserPromptPreview(prompt, attachments = []) {
|
|
62
|
+
const normalized = normalizeTurnAttachments(attachments);
|
|
63
|
+
const text = typeof prompt === "string" ? prompt.trim() : "";
|
|
64
|
+
if (!normalized.length) return text;
|
|
65
|
+
const names = normalized.map((item) => item.name).join(", ");
|
|
66
|
+
return text ? `${text}\n\n[附件: ${names}]` : `[附件: ${names}]`;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function renderInstructionWithAttachments(prompt, attachments = []) {
|
|
70
|
+
const normalized = normalizeTurnAttachments(attachments);
|
|
71
|
+
// Callers validate their own prompt limits; formatting must not discard instructions.
|
|
72
|
+
const text = typeof prompt === "string" ? prompt.trim() : "";
|
|
73
|
+
if (!normalized.length) return text;
|
|
74
|
+
const manifest = normalized.map(
|
|
75
|
+
(attachment) =>
|
|
76
|
+
`- ${attachment.name} (${attachment.mimeType}, ${attachment.size} bytes): ${attachment.remotePath}`,
|
|
77
|
+
);
|
|
78
|
+
return [
|
|
79
|
+
text || "请查看并处理本条消息附带的文件。",
|
|
80
|
+
"",
|
|
81
|
+
"[SCOPE 网页附件:文件已安全上传到当前目标主机,请按以下绝对路径读取]",
|
|
82
|
+
...manifest,
|
|
83
|
+
].join("\n");
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async function pruneOldLocalAttachments(dir, cutoffMs, depth = 0) {
|
|
87
|
+
const entries = await readdir(dir, { withFileTypes: true }).catch(() => []);
|
|
88
|
+
for (const entry of entries) {
|
|
89
|
+
const entryPath = path.join(dir, entry.name);
|
|
90
|
+
if (entry.isDirectory()) {
|
|
91
|
+
if (depth < 2) {
|
|
92
|
+
await pruneOldLocalAttachments(entryPath, cutoffMs, depth + 1);
|
|
93
|
+
}
|
|
94
|
+
const remaining = await readdir(entryPath).catch(() => ["keep"]);
|
|
95
|
+
if (!remaining.length) await rm(entryPath, { recursive: true, force: true }).catch(() => {});
|
|
96
|
+
} else if (entry.isFile()) {
|
|
97
|
+
const info = await stat(entryPath).catch(() => null);
|
|
98
|
+
if (info && info.mtimeMs < cutoffMs) {
|
|
99
|
+
await rm(entryPath, { force: true }).catch(() => {});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export async function streamAttachmentToLocal(request, { baseDir, scopeSegment, uploadId, filename }) {
|
|
106
|
+
const declaredLength = Number(request.headers?.["content-length"] || 0);
|
|
107
|
+
if (Number.isFinite(declaredLength) && declaredLength > MAX_ATTACHMENT_BYTES) {
|
|
108
|
+
request.resume?.();
|
|
109
|
+
throw Object.assign(new Error("单个附件不能超过 50 MiB"), { statusCode: 413 });
|
|
110
|
+
}
|
|
111
|
+
await pruneOldLocalAttachments(baseDir, Date.now() - LOCAL_RETENTION_MS).catch(() => {});
|
|
112
|
+
const targetDir = path.join(baseDir, scopeSegment, uploadId);
|
|
113
|
+
await mkdir(targetDir, { recursive: true, mode: 0o700 });
|
|
114
|
+
const targetFile = path.join(targetDir, filename);
|
|
115
|
+
// Open exclusively before consuming the request. FileHandle failures are caught
|
|
116
|
+
// promises, rather than an early unhandled WriteStream error event.
|
|
117
|
+
const writer = await open(targetFile, "wx", 0o600);
|
|
118
|
+
let size = 0;
|
|
119
|
+
const hash = createHash("sha256");
|
|
120
|
+
try {
|
|
121
|
+
for await (const rawChunk of request) {
|
|
122
|
+
const chunk = Buffer.isBuffer(rawChunk) ? rawChunk : Buffer.from(rawChunk);
|
|
123
|
+
size += chunk.length;
|
|
124
|
+
if (size > MAX_ATTACHMENT_BYTES) {
|
|
125
|
+
request.resume?.();
|
|
126
|
+
throw Object.assign(new Error("单个附件不能超过 50 MiB"), { statusCode: 413 });
|
|
127
|
+
}
|
|
128
|
+
hash.update(chunk);
|
|
129
|
+
await writer.writeFile(chunk);
|
|
130
|
+
}
|
|
131
|
+
await writer.close();
|
|
132
|
+
} catch (error) {
|
|
133
|
+
await writer.close().catch(() => {});
|
|
134
|
+
await rm(targetFile, { force: true }).catch(() => {});
|
|
135
|
+
throw error;
|
|
136
|
+
}
|
|
137
|
+
return { remotePath: targetFile, size, sha256: hash.digest("hex") };
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export function appServerTurnInput(prompt, attachments = []) {
|
|
141
|
+
const normalized = normalizeTurnAttachments(attachments);
|
|
142
|
+
const text = renderInstructionWithAttachments(prompt, normalized);
|
|
143
|
+
const input = text ? [{ type: "text", text, text_elements: [] }] : [];
|
|
144
|
+
for (const attachment of normalized) {
|
|
145
|
+
if (attachment.kind === "image") {
|
|
146
|
+
input.push({ type: "localImage", path: attachment.remotePath });
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return input;
|
|
150
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { mkdir, writeFile } from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
|
|
5
|
+
// Content-addressed, write-once versions. Never delete on scan/reset/reconnect.
|
|
6
|
+
export async function archiveSessionCache(directory, snapshot) {
|
|
7
|
+
for (const host of snapshot?.hosts || []) {
|
|
8
|
+
for (const s of host.sessions || []) {
|
|
9
|
+
if (!s?.id && !s?.path) continue;
|
|
10
|
+
const identity = createHash("sha256").update(`${host.alias}\0${s.id || s.path}`).digest("hex");
|
|
11
|
+
const content = { host: host.alias, id: s.id, path: s.path, cwd: s.cwd,
|
|
12
|
+
firstUser: s.firstUser, lastUser: s.lastUser, lastAssistant: s.lastAssistant,
|
|
13
|
+
lastEventAt: s.lastEventAt, userMessages: s.userMessages, assistantMessages: s.assistantMessages };
|
|
14
|
+
const data = JSON.stringify(content);
|
|
15
|
+
const version = createHash("sha256").update(data).digest("hex");
|
|
16
|
+
const folder = path.join(directory, identity);
|
|
17
|
+
await mkdir(folder, { recursive: true, mode: 0o700 });
|
|
18
|
+
try { await writeFile(path.join(folder, `${version}.json`), data + "\n", { flag: "wx", mode: 0o600 }); }
|
|
19
|
+
catch (e) { if (e.code !== "EEXIST") throw e; }
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
"""Bounded, read-only AGY transcript reader. Never launches or resumes an agent."""
|
|
2
|
+
import base64
|
|
3
|
+
import json
|
|
4
|
+
import os
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
import re
|
|
7
|
+
import subprocess
|
|
8
|
+
import sys
|
|
9
|
+
import time
|
|
10
|
+
|
|
11
|
+
try:
|
|
12
|
+
import fcntl
|
|
13
|
+
except ImportError:
|
|
14
|
+
fcntl = None
|
|
15
|
+
|
|
16
|
+
if hasattr(sys.stdout, "reconfigure"):
|
|
17
|
+
sys.stdout.reconfigure(encoding="utf-8")
|
|
18
|
+
|
|
19
|
+
MAX_BYTES = 2_000_000
|
|
20
|
+
MAX_ROWS = 100
|
|
21
|
+
MAX_TEXT = 30_000
|
|
22
|
+
CREATED_SUBAGENT_RE = re.compile(r'Created the following subagent:\s*\{\s*"conversationId"\s*:\s*"([a-zA-Z0-9][a-zA-Z0-9_-]{0,127})"')
|
|
23
|
+
SENDER_RE = re.compile(r'sender=([a-zA-Z0-9][a-zA-Z0-9_-]{0,127})')
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def message(row):
|
|
27
|
+
kind = row.get("type")
|
|
28
|
+
content = row.get("content") if isinstance(row.get("content"), str) else ""
|
|
29
|
+
result = {"id": str(row.get("step_index", "")), "createdAt": row.get("created_at"), "status": row.get("status")}
|
|
30
|
+
tool_truncated = False
|
|
31
|
+
if kind == "USER_INPUT" and row.get("source") == "USER_EXPLICIT":
|
|
32
|
+
# Strip only the provider's outer envelope, not arbitrary embedded XML.
|
|
33
|
+
if content.startswith("<USER_REQUEST>\n"):
|
|
34
|
+
end = content.rfind("\n</USER_REQUEST>")
|
|
35
|
+
if end >= 0:
|
|
36
|
+
content = content[len("<USER_REQUEST>\n"):end]
|
|
37
|
+
result.update(role="user", text=content[:MAX_TEXT])
|
|
38
|
+
elif kind == "PLANNER_RESPONSE":
|
|
39
|
+
result.update(role="assistant", text=content[:MAX_TEXT])
|
|
40
|
+
calls = row.get("tool_calls")
|
|
41
|
+
if isinstance(calls, list) and calls:
|
|
42
|
+
# `thinking`, system messages and checkpoint internals are not exported.
|
|
43
|
+
activity = json.dumps(calls, ensure_ascii=False)
|
|
44
|
+
result["activity"] = activity[:MAX_TEXT]
|
|
45
|
+
tool_truncated = len(activity) > MAX_TEXT
|
|
46
|
+
result["title"] = "工具调用"
|
|
47
|
+
elif kind in ("GENERIC", "ERROR_MESSAGE"):
|
|
48
|
+
result.update(role="activity", title="执行错误" if kind == "ERROR_MESSAGE" or row.get("status") == "ERROR" else "工具记录", text=(content or str(row.get("error") or ""))[:MAX_TEXT])
|
|
49
|
+
else:
|
|
50
|
+
return None
|
|
51
|
+
result["truncated"] = tool_truncated or len(content) > MAX_TEXT or bool(row.get("truncated_fields"))
|
|
52
|
+
return result if result.get("text") or result.get("activity") else None
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def _clean_arg(value):
|
|
56
|
+
if not isinstance(value, str):
|
|
57
|
+
return str(value) if value is not None else ""
|
|
58
|
+
text = value.strip()
|
|
59
|
+
if len(text) >= 2 and text.startswith('"') and text.endswith('"'):
|
|
60
|
+
try:
|
|
61
|
+
decoded = json.loads(text)
|
|
62
|
+
if isinstance(decoded, str):
|
|
63
|
+
return decoded.strip()
|
|
64
|
+
except ValueError:
|
|
65
|
+
pass
|
|
66
|
+
return text[1:-1].strip()
|
|
67
|
+
return text
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def _read_tail_rows(filename, max_bytes):
|
|
71
|
+
rows = []
|
|
72
|
+
with filename.open("rb") as handle:
|
|
73
|
+
size = os.fstat(handle.fileno()).st_size
|
|
74
|
+
start = max(0, size - max_bytes)
|
|
75
|
+
handle.seek(start)
|
|
76
|
+
data = handle.read(max_bytes)
|
|
77
|
+
if start > 0:
|
|
78
|
+
nl = data.find(b"\n")
|
|
79
|
+
if nl >= 0:
|
|
80
|
+
data = data[nl + 1:]
|
|
81
|
+
for line in data.splitlines():
|
|
82
|
+
try:
|
|
83
|
+
value = json.loads(line)
|
|
84
|
+
if isinstance(value, dict):
|
|
85
|
+
rows.append(value)
|
|
86
|
+
except (ValueError, UnicodeError):
|
|
87
|
+
continue
|
|
88
|
+
return rows
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def extract_subagents(root, filename):
|
|
92
|
+
pending_meta = []
|
|
93
|
+
ordered_ids = []
|
|
94
|
+
records = {}
|
|
95
|
+
completed_ids = set()
|
|
96
|
+
killed_ids = set()
|
|
97
|
+
for row in _read_tail_rows(filename, 512_000):
|
|
98
|
+
kind = row.get("type")
|
|
99
|
+
if kind == "PLANNER_RESPONSE":
|
|
100
|
+
for call in row.get("tool_calls") or []:
|
|
101
|
+
if not isinstance(call, dict):
|
|
102
|
+
continue
|
|
103
|
+
name = call.get("name") or call.get("tool_name")
|
|
104
|
+
args = call.get("args") or call.get("arguments") or {}
|
|
105
|
+
if not isinstance(args, dict):
|
|
106
|
+
continue
|
|
107
|
+
if name == "invoke_subagent":
|
|
108
|
+
pending_meta.append({
|
|
109
|
+
"role": _clean_arg(args.get("Role"))[:120] or "子代理",
|
|
110
|
+
"typeName": _clean_arg(args.get("TypeName"))[:60] or "subagent",
|
|
111
|
+
})
|
|
112
|
+
elif name == "swarm" and _clean_arg(args.get("action")) == "add":
|
|
113
|
+
base = _clean_arg(args.get("name")) or "worker"
|
|
114
|
+
pending_meta.append({
|
|
115
|
+
"role": base[:120],
|
|
116
|
+
"typeName": "swarm",
|
|
117
|
+
})
|
|
118
|
+
elif name == "manage_subagents":
|
|
119
|
+
action = _clean_arg(args.get("Action"))
|
|
120
|
+
if action == "kill_all":
|
|
121
|
+
killed_ids.update(ordered_ids)
|
|
122
|
+
elif action == "kill":
|
|
123
|
+
ids = args.get("ConversationIds") or []
|
|
124
|
+
if isinstance(ids, str):
|
|
125
|
+
try:
|
|
126
|
+
ids = json.loads(ids)
|
|
127
|
+
except ValueError:
|
|
128
|
+
ids = []
|
|
129
|
+
for cid in ids if isinstance(ids, list) else []:
|
|
130
|
+
killed_ids.add(str(cid))
|
|
131
|
+
elif kind == "GENERIC" and isinstance(row.get("content"), str):
|
|
132
|
+
for match in CREATED_SUBAGENT_RE.finditer(row["content"]):
|
|
133
|
+
cid = match.group(1)
|
|
134
|
+
meta = pending_meta.pop(0) if pending_meta else {"role": f"子代理 {cid[:8]}", "typeName": "subagent"}
|
|
135
|
+
if cid not in records:
|
|
136
|
+
ordered_ids.append(cid)
|
|
137
|
+
records[cid] = {
|
|
138
|
+
"id": cid,
|
|
139
|
+
"role": meta["role"],
|
|
140
|
+
"typeName": meta["typeName"],
|
|
141
|
+
"background": True,
|
|
142
|
+
"status": "working",
|
|
143
|
+
"lastAction": "运行中",
|
|
144
|
+
"updatedAt": None,
|
|
145
|
+
}
|
|
146
|
+
elif kind == "SYSTEM_MESSAGE" and isinstance(row.get("content"), str):
|
|
147
|
+
match = SENDER_RE.search(row["content"])
|
|
148
|
+
if match:
|
|
149
|
+
completed_ids.add(match.group(1))
|
|
150
|
+
|
|
151
|
+
now_ts = time.time()
|
|
152
|
+
result = []
|
|
153
|
+
for cid in ordered_ids[-24:]:
|
|
154
|
+
item = records[cid]
|
|
155
|
+
child_dir = root / cid / ".system_generated/logs"
|
|
156
|
+
child_file = next(
|
|
157
|
+
(p for p in (child_dir / "transcript_full.jsonl", child_dir / "transcript.jsonl") if p.is_file()),
|
|
158
|
+
None,
|
|
159
|
+
)
|
|
160
|
+
if child_file is not None and root in child_file.resolve().parents:
|
|
161
|
+
try:
|
|
162
|
+
st = child_file.stat()
|
|
163
|
+
item["updatedAt"] = int(st.st_mtime * 1000)
|
|
164
|
+
tail = _read_tail_rows(child_file, 16_384)
|
|
165
|
+
last_action = ""
|
|
166
|
+
for crow in tail:
|
|
167
|
+
for call in crow.get("tool_calls") or []:
|
|
168
|
+
if isinstance(call, dict) and (call.get("name") or call.get("tool_name")):
|
|
169
|
+
last_action = str(call.get("name") or call.get("tool_name"))[:80]
|
|
170
|
+
last_row = tail[-1] if tail else {}
|
|
171
|
+
if cid in killed_ids:
|
|
172
|
+
item["status"] = "stopped"
|
|
173
|
+
elif last_row.get("type") == "ERROR_MESSAGE" or last_row.get("status") == "ERROR":
|
|
174
|
+
item["status"] = "failed"
|
|
175
|
+
elif (
|
|
176
|
+
last_row.get("type") == "PLANNER_RESPONSE"
|
|
177
|
+
and last_row.get("status") == "DONE"
|
|
178
|
+
and not (last_row.get("tool_calls") or [])
|
|
179
|
+
):
|
|
180
|
+
item["status"] = "completed"
|
|
181
|
+
elif cid in completed_ids:
|
|
182
|
+
item["status"] = "completed"
|
|
183
|
+
elif now_ts - st.st_mtime < 600:
|
|
184
|
+
item["status"] = "working"
|
|
185
|
+
else:
|
|
186
|
+
item["status"] = "completed"
|
|
187
|
+
if last_action:
|
|
188
|
+
item["lastAction"] = last_action
|
|
189
|
+
elif item["status"] == "completed":
|
|
190
|
+
item["lastAction"] = "已完成"
|
|
191
|
+
except OSError:
|
|
192
|
+
pass
|
|
193
|
+
elif cid in killed_ids:
|
|
194
|
+
item["status"] = "stopped"
|
|
195
|
+
elif cid in completed_ids:
|
|
196
|
+
item["status"] = "completed"
|
|
197
|
+
item["lastAction"] = "已完成"
|
|
198
|
+
result.append(item)
|
|
199
|
+
return result
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
def _scope_agy_lock_active(sid):
|
|
203
|
+
if fcntl is None or not sid:
|
|
204
|
+
return False
|
|
205
|
+
lock_file = Path.home() / ".local/state/scope/antigravity-sessions" / f"{sid}.lock"
|
|
206
|
+
if not lock_file.is_file():
|
|
207
|
+
return False
|
|
208
|
+
try:
|
|
209
|
+
with lock_file.open("r") as handle:
|
|
210
|
+
try:
|
|
211
|
+
fcntl.flock(handle, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
|
212
|
+
except BlockingIOError:
|
|
213
|
+
return True
|
|
214
|
+
else:
|
|
215
|
+
fcntl.flock(handle, fcntl.LOCK_UN)
|
|
216
|
+
return False
|
|
217
|
+
except OSError:
|
|
218
|
+
return False
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
def _read_proc_cmdline(pid):
|
|
222
|
+
try:
|
|
223
|
+
raw = Path(f"/proc/{pid}/cmdline").read_bytes()
|
|
224
|
+
return [part for part in raw.decode("utf-8", errors="replace").split("\0") if part]
|
|
225
|
+
except OSError:
|
|
226
|
+
return []
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
def _read_proc_ppid(pid):
|
|
230
|
+
try:
|
|
231
|
+
txt = Path(f"/proc/{pid}/stat").read_text(encoding="utf-8", errors="replace")
|
|
232
|
+
rparen = txt.rfind(")")
|
|
233
|
+
if rparen < 0:
|
|
234
|
+
return 0
|
|
235
|
+
fields = txt[rparen + 2:].split()
|
|
236
|
+
return int(fields[1]) if len(fields) > 1 else 0
|
|
237
|
+
except (OSError, ValueError):
|
|
238
|
+
return 0
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
def detect_agy_external_lock(sid):
|
|
242
|
+
if os.name == "nt" or not sid or _scope_agy_lock_active(sid):
|
|
243
|
+
return None
|
|
244
|
+
presence_locked = False
|
|
245
|
+
lock_file = Path.home() / ".gemini/antigravity-cli/presence" / f"{sid}.lock"
|
|
246
|
+
if fcntl is not None and lock_file.is_file():
|
|
247
|
+
try:
|
|
248
|
+
with lock_file.open("r") as handle:
|
|
249
|
+
try:
|
|
250
|
+
fcntl.flock(handle, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
|
251
|
+
except BlockingIOError:
|
|
252
|
+
presence_locked = True
|
|
253
|
+
else:
|
|
254
|
+
fcntl.flock(handle, fcntl.LOCK_UN)
|
|
255
|
+
except OSError:
|
|
256
|
+
pass
|
|
257
|
+
holder_pid = 0
|
|
258
|
+
proc_root = Path("/proc")
|
|
259
|
+
if proc_root.is_dir():
|
|
260
|
+
for cmd_file in proc_root.glob("[0-9]*/cmdline"):
|
|
261
|
+
try:
|
|
262
|
+
pid = int(cmd_file.parent.name)
|
|
263
|
+
args = [p for p in cmd_file.read_bytes().decode("utf-8", errors="replace").split("\0") if p]
|
|
264
|
+
except (OSError, ValueError):
|
|
265
|
+
continue
|
|
266
|
+
if not args or not any(Path(a).name == "agy" or "antigravity" in Path(a).name for a in args[:2]):
|
|
267
|
+
continue
|
|
268
|
+
matched = any(args[i] in ("--conversation", "-c") and i + 1 < len(args) and args[i + 1] == sid for i in range(len(args)))
|
|
269
|
+
if not matched:
|
|
270
|
+
try:
|
|
271
|
+
for fd_link in (cmd_file.parent / "fd").iterdir():
|
|
272
|
+
try:
|
|
273
|
+
target = os.readlink(str(fd_link))
|
|
274
|
+
except OSError:
|
|
275
|
+
continue
|
|
276
|
+
if target.endswith(f"/antigravity-cli/presence/{sid}.lock"):
|
|
277
|
+
matched = True
|
|
278
|
+
break
|
|
279
|
+
except OSError:
|
|
280
|
+
pass
|
|
281
|
+
if matched:
|
|
282
|
+
holder_pid = pid
|
|
283
|
+
break
|
|
284
|
+
if not presence_locked and not holder_pid:
|
|
285
|
+
return None
|
|
286
|
+
is_scope = False
|
|
287
|
+
tty = ""
|
|
288
|
+
in_tmux = False
|
|
289
|
+
if holder_pid:
|
|
290
|
+
args = _read_proc_cmdline(holder_pid)
|
|
291
|
+
if len(args) >= 2 and Path(args[0]).name == "agy" and args[1] == "acp":
|
|
292
|
+
is_scope = True
|
|
293
|
+
if not is_scope:
|
|
294
|
+
cur = holder_pid
|
|
295
|
+
for _ in range(5):
|
|
296
|
+
ppid = _read_proc_ppid(cur)
|
|
297
|
+
if ppid <= 1 or ppid == cur:
|
|
298
|
+
break
|
|
299
|
+
pargs = " ".join(_read_proc_cmdline(ppid))
|
|
300
|
+
if ".local/state/scope/runs" in pargs or "antigravity-interactive" in pargs or "native-session-state" in pargs:
|
|
301
|
+
is_scope = True
|
|
302
|
+
break
|
|
303
|
+
cur = ppid
|
|
304
|
+
if is_scope:
|
|
305
|
+
return None
|
|
306
|
+
try:
|
|
307
|
+
link = os.readlink(f"/proc/{holder_pid}/fd/0")
|
|
308
|
+
if link.startswith("/dev/pts/") or link.startswith("/dev/tty"):
|
|
309
|
+
tty = link[len("/dev/"):]
|
|
310
|
+
try:
|
|
311
|
+
proc = subprocess.run(["tmux", "list-panes", "-a", "-F", "#{pane_tty}"], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, text=True, timeout=1.5)
|
|
312
|
+
if proc.returncode == 0 and link in proc.stdout.splitlines():
|
|
313
|
+
in_tmux = True
|
|
314
|
+
except (OSError, subprocess.SubprocessError):
|
|
315
|
+
pass
|
|
316
|
+
except OSError:
|
|
317
|
+
pass
|
|
318
|
+
where = f"tmux ({tty})" if (in_tmux and tty) else (tty or "远端终端")
|
|
319
|
+
reason = f"外部终端占用 ({where} · PID {holder_pid})" if holder_pid else f"外部终端占用 ({where})"
|
|
320
|
+
return {
|
|
321
|
+
"locked": True,
|
|
322
|
+
"pid": holder_pid or None,
|
|
323
|
+
"tty": tty,
|
|
324
|
+
"inTmux": in_tmux,
|
|
325
|
+
"entrypoint": "cli",
|
|
326
|
+
"status": "active",
|
|
327
|
+
"reason": reason,
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
def read_history(config):
|
|
332
|
+
sid = config.get("sessionId", "")
|
|
333
|
+
if not isinstance(sid, str) or not re.fullmatch(r"[a-zA-Z0-9][a-zA-Z0-9_-]{0,127}", sid):
|
|
334
|
+
raise ValueError("Invalid AGY session ID")
|
|
335
|
+
ext_lock = detect_agy_external_lock(sid)
|
|
336
|
+
root = (Path.home() / ".gemini/antigravity-cli/brain").resolve()
|
|
337
|
+
folder = root / sid / ".system_generated/logs"
|
|
338
|
+
candidates = [folder / "transcript_full.jsonl", folder / "transcript.jsonl"]
|
|
339
|
+
filename = next((p for p in candidates if p.is_file()), None)
|
|
340
|
+
if filename is None:
|
|
341
|
+
return {"messages": [], "subagents": [], "externalLock": ext_lock, "summaryOnly": True, "reason": "此会话尚无可读取的文本历史"}
|
|
342
|
+
if root not in filename.resolve().parents:
|
|
343
|
+
raise ValueError("AGY history path escapes its history directory")
|
|
344
|
+
with filename.open("rb") as handle:
|
|
345
|
+
stamp = os.fstat(handle.fileno())
|
|
346
|
+
version = f"{filename.name}:{stamp.st_mtime_ns}:{stamp.st_size}"
|
|
347
|
+
reset = bool(config.get("version") and config["version"] != version)
|
|
348
|
+
before = config.get("before")
|
|
349
|
+
end = stamp.st_size if before is None or reset else int(before)
|
|
350
|
+
if end < 0 or end > stamp.st_size:
|
|
351
|
+
raise ValueError("Invalid AGY history cursor")
|
|
352
|
+
start = max(0, end - MAX_BYTES)
|
|
353
|
+
handle.seek(max(0, start - 1))
|
|
354
|
+
partial = start > 0 and handle.read(1) != b"\n"
|
|
355
|
+
data = handle.read(max(0, end - start))
|
|
356
|
+
rows, skipped, position = [], False, start
|
|
357
|
+
if partial:
|
|
358
|
+
newline = data.find(b"\n")
|
|
359
|
+
if newline < 0:
|
|
360
|
+
data, skipped = b"", True
|
|
361
|
+
else:
|
|
362
|
+
position += newline + 1
|
|
363
|
+
data = data[newline + 1:]
|
|
364
|
+
page_start = position if position < end else start
|
|
365
|
+
for line in data.splitlines(keepends=True):
|
|
366
|
+
try:
|
|
367
|
+
value = json.loads(line)
|
|
368
|
+
item = message(value) if isinstance(value, dict) else None
|
|
369
|
+
if item:
|
|
370
|
+
rows.append((position, item))
|
|
371
|
+
except (ValueError, TypeError, UnicodeError):
|
|
372
|
+
skipped = True
|
|
373
|
+
position += len(line)
|
|
374
|
+
selected = rows[-MAX_ROWS:]
|
|
375
|
+
# Keep the partial line for the previous page; never skip it silently.
|
|
376
|
+
next_before = selected[0][0] if len(rows) > MAX_ROWS else page_start
|
|
377
|
+
current = os.fstat(handle.fileno())
|
|
378
|
+
if (stamp.st_mtime_ns, stamp.st_size) != (current.st_mtime_ns, current.st_size):
|
|
379
|
+
raise ValueError("AGY 历史正在更新,请稍后刷新")
|
|
380
|
+
return {"messages": [item for _, item in selected], "subagents": extract_subagents(root, filename), "externalLock": ext_lock, "summaryOnly": False,
|
|
381
|
+
"source": filename.name, "version": version, "reset": reset,
|
|
382
|
+
"nextBefore": next_before if next_before > 0 else None,
|
|
383
|
+
"limited": skipped or any(item.get("truncated") for _, item in selected) or (not selected and start > 0)}
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
if __name__ == "__main__":
|
|
387
|
+
config = json.loads(base64.urlsafe_b64decode(sys.argv[1] + "==="))
|
|
388
|
+
print(json.dumps(read_history(config), ensure_ascii=False))
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import { LOCAL_HOST } from "../../lib/execution-host.js";
|
|
4
|
+
import { shellQuote } from "../transport/ssh-command.mjs";
|
|
5
|
+
import { runLocalPython } from "../local/python-probe.mjs";
|
|
6
|
+
import { activityTime } from "../../lib/session-activity.js";
|
|
7
|
+
|
|
8
|
+
export const catalogKey = (host, provider, id) => JSON.stringify([host, provider, id]);
|
|
9
|
+
|
|
10
|
+
export class SessionCatalog {
|
|
11
|
+
constructor({ hosts, run, local = runLocalPython }) {
|
|
12
|
+
this.hosts = hosts; this.run = run; this.local = local;
|
|
13
|
+
this.records = new Map(); this.scans = new Map(); this.pending = null; this.lastScan = 0;
|
|
14
|
+
this.script = readFile(new URL("./probe.py", import.meta.url), "utf8");
|
|
15
|
+
this.agyScript = readFile(new URL("./agy-history.py", import.meta.url), "utf8");
|
|
16
|
+
}
|
|
17
|
+
async probe(host, payload, script = this.script) {
|
|
18
|
+
const encoded = Buffer.from(JSON.stringify(payload)).toString("base64url");
|
|
19
|
+
const result = host === LOCAL_HOST
|
|
20
|
+
? await this.local(await script, [encoded], 60_000, 16_000_000)
|
|
21
|
+
: await this.run(host, `python3 - ${shellQuote(encoded)}`, await script, 60_000, 16_000_000);
|
|
22
|
+
if (result.code !== 0) throw new Error(result.stderr || "会话扫描失败");
|
|
23
|
+
return JSON.parse(result.stdout);
|
|
24
|
+
}
|
|
25
|
+
refresh(force = false) {
|
|
26
|
+
if (this.pending) return this.pending;
|
|
27
|
+
if (!force && Date.now() - this.lastScan < 60_000) return Promise.resolve();
|
|
28
|
+
this.lastScan = Date.now();
|
|
29
|
+
const queue = this.hosts().filter((host) => host.reachable || host.alias === LOCAL_HOST);
|
|
30
|
+
const worker = async () => {
|
|
31
|
+
for (let host; (host = queue.shift());) {
|
|
32
|
+
try {
|
|
33
|
+
const result = await this.probe(host.alias, { operation: "scan" });
|
|
34
|
+
if (!Array.isArray(result.entries)) throw new Error("扫描结果格式无效");
|
|
35
|
+
const entries = result.entries.filter((entry) => entry.sessionId && ["codex", "claude", "antigravity"].includes(entry.provider)).map((entry) => ({ ...entry, host: host.alias, key: catalogKey(host.alias, entry.provider, entry.sessionId) }));
|
|
36
|
+
for (const [key, entry] of this.records) if (entry.host === host.alias) this.records.delete(key);
|
|
37
|
+
for (const entry of entries) {
|
|
38
|
+
const previous = this.records.get(entry.key);
|
|
39
|
+
if (!previous || activityTime(entry.updatedAt) >= activityTime(previous.updatedAt)) this.records.set(entry.key, entry);
|
|
40
|
+
}
|
|
41
|
+
this.scans.set(host.alias, { host: host.alias, count: new Set(entries.map((entry) => entry.key)).size, errors: result.errors || [], roots: result.roots, updatedAt: new Date().toISOString() });
|
|
42
|
+
} catch (error) {
|
|
43
|
+
this.scans.set(host.alias, { ...this.scans.get(host.alias), host: host.alias, errors: [error.message], stale: true });
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
this.pending = Promise.all(Array.from({ length: Math.min(3, queue.length) }, worker)).finally(() => { this.pending = null; });
|
|
48
|
+
return this.pending;
|
|
49
|
+
}
|
|
50
|
+
get(key) { return this.records.get(key); }
|
|
51
|
+
state() {
|
|
52
|
+
const entries = [...this.records.values()].map(({ path: _path, ...entry }) => entry);
|
|
53
|
+
const state = { entries, scans: [...this.scans.values()], scanning: Boolean(this.pending) };
|
|
54
|
+
const body = JSON.stringify(state);
|
|
55
|
+
return { state, body, etag: `"${createHash("sha1").update(body).digest("hex")}"` };
|
|
56
|
+
}
|
|
57
|
+
async dialogue(key, paging = {}) {
|
|
58
|
+
const entry = this.get(key);
|
|
59
|
+
if (!entry) {
|
|
60
|
+
let parsed;
|
|
61
|
+
try {
|
|
62
|
+
parsed = JSON.parse(key);
|
|
63
|
+
} catch {
|
|
64
|
+
parsed = null;
|
|
65
|
+
}
|
|
66
|
+
if (
|
|
67
|
+
Array.isArray(parsed) &&
|
|
68
|
+
parsed[1] === "antigravity" &&
|
|
69
|
+
typeof parsed[0] === "string" &&
|
|
70
|
+
typeof parsed[2] === "string" &&
|
|
71
|
+
parsed[2] &&
|
|
72
|
+
this.hosts().some(
|
|
73
|
+
(item) =>
|
|
74
|
+
item.alias === parsed[0] &&
|
|
75
|
+
(item.reachable || item.alias === LOCAL_HOST),
|
|
76
|
+
)
|
|
77
|
+
) {
|
|
78
|
+
const result = await this.probe(
|
|
79
|
+
parsed[0],
|
|
80
|
+
{ sessionId: parsed[2], ...paging },
|
|
81
|
+
this.agyScript,
|
|
82
|
+
);
|
|
83
|
+
return { ...result, summary: "" };
|
|
84
|
+
}
|
|
85
|
+
throw new Error("未找到会话,请刷新扫描");
|
|
86
|
+
}
|
|
87
|
+
if (entry.provider === "antigravity") {
|
|
88
|
+
const result = await this.probe(entry.host, { sessionId: entry.sessionId, ...paging }, this.agyScript);
|
|
89
|
+
return { ...result, summary: entry.preview || entry.title };
|
|
90
|
+
}
|
|
91
|
+
return this.probe(entry.host, { operation: "dialogue", provider: entry.provider, path: entry.path });
|
|
92
|
+
}
|
|
93
|
+
async subagentWorkflow(key, { subagentId, version } = {}) {
|
|
94
|
+
if (!subagentId || typeof subagentId !== "string") {
|
|
95
|
+
throw new Error("缺少子代理标识");
|
|
96
|
+
}
|
|
97
|
+
const entry = this.get(key);
|
|
98
|
+
if (!entry) throw new Error("未找到会话,请刷新扫描");
|
|
99
|
+
if (entry.provider !== "claude" || !entry.path) {
|
|
100
|
+
throw new Error("当前会话不支持 Claude 子代理工作流读取");
|
|
101
|
+
}
|
|
102
|
+
return this.probe(entry.host, {
|
|
103
|
+
operation: "subagent_workflow",
|
|
104
|
+
provider: "claude",
|
|
105
|
+
path: entry.path,
|
|
106
|
+
subagentId: subagentId.trim(),
|
|
107
|
+
...(version ? { version: String(version) } : {}),
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|