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,349 @@
|
|
|
1
|
+
"""Owned ACP v1 process. Durable controls; never takes over an external terminal."""
|
|
2
|
+
import fcntl
|
|
3
|
+
import json
|
|
4
|
+
import os
|
|
5
|
+
import re
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
import selectors
|
|
8
|
+
import signal
|
|
9
|
+
import subprocess
|
|
10
|
+
import sys
|
|
11
|
+
import time
|
|
12
|
+
from scope_acp_forms import fields, validate
|
|
13
|
+
|
|
14
|
+
root = Path.home() / ".local/state/scope/runs" / sys.argv[1]
|
|
15
|
+
config = json.loads((root / "claude-config.json").read_text())
|
|
16
|
+
controls = root / "controls"
|
|
17
|
+
controls.mkdir(mode=0o700, exist_ok=True)
|
|
18
|
+
mutex = (root / "control.lock").open("a")
|
|
19
|
+
state = {"status": "running", "sessionId": config.get("resumeSessionId"), "events": [],
|
|
20
|
+
"permissions": [], "controlResults": [], "subagents": [], "text": "", "interactive": True, "commands": []}
|
|
21
|
+
pending, requests, seen, queue, subagents = {}, {}, set(), [], {}
|
|
22
|
+
child, stopping, finished, ready = None, None, False, False
|
|
23
|
+
counter, last_snapshot, active_prompt, last_subagent_scan = 0, None, "", 0.0
|
|
24
|
+
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})"')
|
|
25
|
+
SENDER_RE = re.compile(r'sender=([a-zA-Z0-9][a-zA-Z0-9_-]{0,127})')
|
|
26
|
+
|
|
27
|
+
def _clean_arg(value):
|
|
28
|
+
if not isinstance(value, str):
|
|
29
|
+
return str(value) if value is not None else ""
|
|
30
|
+
text = value.strip()
|
|
31
|
+
if len(text) >= 2 and text.startswith('"') and text.endswith('"'):
|
|
32
|
+
try:
|
|
33
|
+
decoded = json.loads(text)
|
|
34
|
+
if isinstance(decoded, str):
|
|
35
|
+
return decoded.strip()
|
|
36
|
+
except ValueError:
|
|
37
|
+
pass
|
|
38
|
+
return text[1:-1].strip()
|
|
39
|
+
return text
|
|
40
|
+
|
|
41
|
+
def sync_brain_subagents():
|
|
42
|
+
sid = state.get("sessionId")
|
|
43
|
+
if not isinstance(sid, str) or not re.fullmatch(r"[a-zA-Z0-9][a-zA-Z0-9_-]{0,127}", sid):
|
|
44
|
+
return
|
|
45
|
+
brain_root = (Path.home() / ".gemini/antigravity-cli/brain").resolve()
|
|
46
|
+
logs = brain_root / sid / ".system_generated/logs"
|
|
47
|
+
parent_file = next((p for p in (logs / "transcript_full.jsonl", logs / "transcript.jsonl") if p.is_file()), None)
|
|
48
|
+
if parent_file is None or brain_root not in parent_file.resolve().parents:
|
|
49
|
+
return
|
|
50
|
+
try:
|
|
51
|
+
size = parent_file.stat().st_size
|
|
52
|
+
start = max(0, size - 262_144)
|
|
53
|
+
with parent_file.open("rb") as h:
|
|
54
|
+
h.seek(start)
|
|
55
|
+
data = h.read(262_144)
|
|
56
|
+
if start > 0 and b"\n" in data:
|
|
57
|
+
data = data.split(b"\n", 1)[1]
|
|
58
|
+
pending_meta, ordered_cids, completed_cids, killed_cids = [], [], set(), set()
|
|
59
|
+
for line in data.splitlines():
|
|
60
|
+
try: row = json.loads(line)
|
|
61
|
+
except (ValueError, UnicodeError): continue
|
|
62
|
+
if not isinstance(row, dict): continue
|
|
63
|
+
kind = row.get("type")
|
|
64
|
+
if kind == "PLANNER_RESPONSE":
|
|
65
|
+
for call in row.get("tool_calls") or []:
|
|
66
|
+
if not isinstance(call, dict): continue
|
|
67
|
+
cname = call.get("name") or call.get("tool_name")
|
|
68
|
+
args = call.get("args") or call.get("arguments") or {}
|
|
69
|
+
if not isinstance(args, dict): continue
|
|
70
|
+
if cname == "invoke_subagent":
|
|
71
|
+
pending_meta.append({"role": _clean_arg(args.get("Role"))[:120] or "子代理", "typeName": _clean_arg(args.get("TypeName"))[:60] or "subagent"})
|
|
72
|
+
elif cname == "swarm" and _clean_arg(args.get("action")) == "add":
|
|
73
|
+
pending_meta.append({"role": (_clean_arg(args.get("name")) or "worker")[:120], "typeName": "swarm"})
|
|
74
|
+
elif cname == "manage_subagents":
|
|
75
|
+
act = _clean_arg(args.get("Action"))
|
|
76
|
+
if act == "kill_all": killed_cids.update(ordered_cids)
|
|
77
|
+
elif act == "kill":
|
|
78
|
+
ids = args.get("ConversationIds") or []
|
|
79
|
+
if isinstance(ids, str):
|
|
80
|
+
try: ids = json.loads(ids)
|
|
81
|
+
except ValueError: ids = []
|
|
82
|
+
for x in ids if isinstance(ids, list) else []: killed_cids.add(str(x))
|
|
83
|
+
elif kind == "GENERIC" and isinstance(row.get("content"), str):
|
|
84
|
+
for m in CREATED_SUBAGENT_RE.finditer(row["content"]):
|
|
85
|
+
cid = m.group(1)
|
|
86
|
+
meta = pending_meta.pop(0) if pending_meta else {"role": f"子代理 {cid[:8]}", "typeName": "subagent"}
|
|
87
|
+
if cid not in ordered_cids: ordered_cids.append(cid)
|
|
88
|
+
existing = next((e for k, e in subagents.items() if e.get("childId") == cid or k == cid), None)
|
|
89
|
+
if existing is None:
|
|
90
|
+
unbound = next((e for e in subagents.values() if not e.get("childId") and e.get("role") == meta["role"]), None)
|
|
91
|
+
if unbound is not None:
|
|
92
|
+
unbound["childId"] = cid
|
|
93
|
+
existing = unbound
|
|
94
|
+
if existing is None:
|
|
95
|
+
subagents[cid] = {"id": cid, "childId": cid, "role": meta["role"], "typeName": meta["typeName"], "background": True, "status": "working", "lastAction": "运行中", "updatedAt": int(time.time() * 1000)}
|
|
96
|
+
elif kind == "SYSTEM_MESSAGE" and isinstance(row.get("content"), str):
|
|
97
|
+
m = SENDER_RE.search(row["content"])
|
|
98
|
+
if m: completed_cids.add(m.group(1))
|
|
99
|
+
now_ts = time.time()
|
|
100
|
+
for cid in ordered_cids[-24:]:
|
|
101
|
+
entry = next((e for k, e in subagents.items() if e.get("childId") == cid or k == cid), None)
|
|
102
|
+
if not entry: continue
|
|
103
|
+
c_logs = brain_root / cid / ".system_generated/logs"
|
|
104
|
+
c_file = next((p for p in (c_logs / "transcript_full.jsonl", c_logs / "transcript.jsonl") if p.is_file()), None)
|
|
105
|
+
if c_file is not None and brain_root in c_file.resolve().parents:
|
|
106
|
+
st = c_file.stat()
|
|
107
|
+
entry["updatedAt"] = int(st.st_mtime * 1000)
|
|
108
|
+
with c_file.open("rb") as ch:
|
|
109
|
+
ch.seek(max(0, st.st_size - 16_384))
|
|
110
|
+
cdata = ch.read(16_384)
|
|
111
|
+
if st.st_size > 16_384 and b"\n" in cdata:
|
|
112
|
+
cdata = cdata.split(b"\n", 1)[1]
|
|
113
|
+
last_action, last_row = "", {}
|
|
114
|
+
for cline in cdata.splitlines():
|
|
115
|
+
try: crow = json.loads(cline)
|
|
116
|
+
except (ValueError, UnicodeError): continue
|
|
117
|
+
if isinstance(crow, dict):
|
|
118
|
+
last_row = crow
|
|
119
|
+
for ccall in crow.get("tool_calls") or []:
|
|
120
|
+
if isinstance(ccall, dict) and (ccall.get("name") or ccall.get("tool_name")):
|
|
121
|
+
last_action = str(ccall.get("name") or ccall.get("tool_name"))[:80]
|
|
122
|
+
if cid in killed_cids: entry["status"] = "stopped"
|
|
123
|
+
elif last_row.get("type") == "ERROR_MESSAGE" or last_row.get("status") == "ERROR": entry["status"] = "failed"
|
|
124
|
+
elif last_row.get("type") == "PLANNER_RESPONSE" and last_row.get("status") == "DONE" and not (last_row.get("tool_calls") or []): entry["status"] = "completed"
|
|
125
|
+
elif cid in completed_cids: entry["status"] = "completed"
|
|
126
|
+
elif now_ts - st.st_mtime < 600: entry["status"] = "working"
|
|
127
|
+
else: entry["status"] = "completed"
|
|
128
|
+
if last_action: entry["lastAction"] = last_action
|
|
129
|
+
elif entry["status"] == "completed": entry["lastAction"] = "已完成"
|
|
130
|
+
elif cid in killed_cids: entry["status"] = "stopped"
|
|
131
|
+
elif cid in completed_cids:
|
|
132
|
+
entry["status"] = "completed"; entry["lastAction"] = "已完成"
|
|
133
|
+
except Exception:
|
|
134
|
+
pass
|
|
135
|
+
|
|
136
|
+
def save():
|
|
137
|
+
global last_snapshot
|
|
138
|
+
state["permissions"] = [{k: v for k, v in p.items() if k != "rpcId"} for p in pending.values()]
|
|
139
|
+
state["events"] = state["events"][-300:]
|
|
140
|
+
while len(state["events"]) > 1 and len(json.dumps(state["events"])) > 800000:
|
|
141
|
+
state["events"].pop(0); state["truncated"] = True
|
|
142
|
+
state["controlResults"] = state["controlResults"][-30:]
|
|
143
|
+
state["subagents"] = list(subagents.values())[-24:]
|
|
144
|
+
encoded = json.dumps(state)
|
|
145
|
+
if encoded != last_snapshot:
|
|
146
|
+
(root / "interactive.tmp").write_text(encoded)
|
|
147
|
+
(root / "interactive.tmp").replace(root / "interactive.json")
|
|
148
|
+
last_snapshot = encoded
|
|
149
|
+
|
|
150
|
+
def emit(kind, **values):
|
|
151
|
+
state["events"].append({"kind": kind, "at": int(time.time() * 1000), **values})
|
|
152
|
+
|
|
153
|
+
def send(value):
|
|
154
|
+
child.stdin.write((json.dumps({"jsonrpc": "2.0", **value}) + "\n").encode()); child.stdin.flush()
|
|
155
|
+
|
|
156
|
+
def call(method, params, phase):
|
|
157
|
+
global counter
|
|
158
|
+
counter += 1; requests[counter] = phase
|
|
159
|
+
send({"id": counter, "method": method, "params": params})
|
|
160
|
+
|
|
161
|
+
def prompt(text):
|
|
162
|
+
global finished, active_prompt
|
|
163
|
+
finished = False
|
|
164
|
+
name = re.match(r"^/([\w:-]+)(?:\s|$)", text.strip())
|
|
165
|
+
if name and not any(c.get("name") == name[1] for c in state["commands"]):
|
|
166
|
+
raise ValueError("/" + name[1] + " 不在当前 AGY ACP 命令目录中;请在原终端执行")
|
|
167
|
+
active_prompt = text
|
|
168
|
+
call("session/prompt", {"sessionId": state["sessionId"], "prompt": [{"type": "text", "text": text}]}, "prompt")
|
|
169
|
+
|
|
170
|
+
def next_setting():
|
|
171
|
+
global ready
|
|
172
|
+
if settings:
|
|
173
|
+
method, values = settings.pop(0)
|
|
174
|
+
call(method, {"sessionId": state["sessionId"], **values}, "setting")
|
|
175
|
+
else:
|
|
176
|
+
ready = True; prompt(config["prompt"])
|
|
177
|
+
|
|
178
|
+
def frame(value):
|
|
179
|
+
global finished, settings
|
|
180
|
+
if "method" in value:
|
|
181
|
+
method, params = value["method"], value.get("params", {})
|
|
182
|
+
if "id" in value:
|
|
183
|
+
rid = str(value["id"])
|
|
184
|
+
if stopping:
|
|
185
|
+
send({"id": value["id"], "error": {"code": -32603, "message": "Turn cancelled"}}); return
|
|
186
|
+
if params.get("sessionId") != state["sessionId"]:
|
|
187
|
+
send({"id": value["id"], "error": {"code": -32602, "message": "Unknown session"}}); return
|
|
188
|
+
if len(json.dumps(params)) > 500000:
|
|
189
|
+
send({"id": value["id"], "error": {"code": -32602, "message": "Approval exceeds display limit"}}); return
|
|
190
|
+
if method == "session/request_permission":
|
|
191
|
+
tool = params.get("toolCall", {})
|
|
192
|
+
pending[rid] = {"id": rid, "rpcId": value["id"], "kind": "acp-permission", "tool": tool.get("title", "工具"),
|
|
193
|
+
"input": tool, "options": params.get("options", [])}
|
|
194
|
+
elif method == "elicitation/create" and params.get("mode") == "form":
|
|
195
|
+
try: form_fields = fields(params["requestedSchema"])
|
|
196
|
+
except (ValueError, KeyError) as error:
|
|
197
|
+
send({"id": value["id"], "result": {"action": "decline"}})
|
|
198
|
+
emit("permission", text="未支持的提问表单,已退回 Agent: " + str(error)); return
|
|
199
|
+
pending[rid] = {"id": rid, "rpcId": value["id"], "kind": "acp-form", "tool": "提问", "input": params["requestedSchema"],
|
|
200
|
+
"fields": form_fields, "description": params.get("message", "")}
|
|
201
|
+
else:
|
|
202
|
+
send({"id": value["id"], "error": {"code": -32601, "message": "Client method not supported"}}); return
|
|
203
|
+
state["status"] = "waiting_permission"
|
|
204
|
+
elif method == "session/update" and params.get("sessionId") == state["sessionId"]:
|
|
205
|
+
update = params.get("update", {}); kind = update.get("sessionUpdate")
|
|
206
|
+
if kind == "agent_message_chunk" and ready:
|
|
207
|
+
text = update.get("content", {}).get("text", "")
|
|
208
|
+
events = state["events"]
|
|
209
|
+
if events and events[-1]["kind"] == "assistant": events[-1]["text"] = (events[-1]["text"] + text)[-60000:]
|
|
210
|
+
else: emit("assistant", text=text)
|
|
211
|
+
state["text"] = (state["text"] + text)[-120000:]
|
|
212
|
+
elif kind in ("tool_call", "tool_call_update") and ready:
|
|
213
|
+
tid = update.get("toolCallId")
|
|
214
|
+
title = str(update.get("title") or "")
|
|
215
|
+
raw_in = update.get("rawInput") if isinstance(update.get("rawInput"), dict) else {}
|
|
216
|
+
item = next((e for e in reversed(state["events"]) if e.get("id") == tid and e["kind"] == "tool"), None)
|
|
217
|
+
if not item:
|
|
218
|
+
emit("tool", id=tid, name=update.get("title", "工具"), input={}); item = state["events"][-1]
|
|
219
|
+
item["input"].update({k: update[k] for k in ("rawInput", "content", "status", "locations") if k in update})
|
|
220
|
+
if tid and (("Role" in raw_in and "TypeName" in raw_in) or ("subagent" in title.lower() and "manage" not in title.lower()) or (raw_in.get("action") == "add" and ("brief" in raw_in or "tasks" in raw_in))):
|
|
221
|
+
entry = subagents.get(tid) or {
|
|
222
|
+
"id": str(tid),
|
|
223
|
+
"role": str(raw_in.get("Role") or raw_in.get("name") or title or "子代理")[:120],
|
|
224
|
+
"typeName": str(raw_in.get("TypeName") or ("swarm" if "brief" in raw_in else "subagent"))[:60],
|
|
225
|
+
"background": True,
|
|
226
|
+
"status": "working",
|
|
227
|
+
"lastAction": "启动中",
|
|
228
|
+
"updatedAt": int(time.time() * 1000),
|
|
229
|
+
}
|
|
230
|
+
if raw_in.get("Role"): entry["role"] = str(raw_in["Role"])[:120]
|
|
231
|
+
if raw_in.get("TypeName"): entry["typeName"] = str(raw_in["TypeName"])[:60]
|
|
232
|
+
if "content" in update:
|
|
233
|
+
cm = re.search(r'"conversationId"\s*:\s*"([a-zA-Z0-9][a-zA-Z0-9_-]{0,127})"', json.dumps(update["content"]))
|
|
234
|
+
if cm: entry["childId"] = cm.group(1)
|
|
235
|
+
if update.get("status") in ("failed", "error"):
|
|
236
|
+
entry["status"] = "failed"
|
|
237
|
+
entry["lastAction"] = "启动失败"
|
|
238
|
+
else:
|
|
239
|
+
entry["updatedAt"] = int(time.time() * 1000)
|
|
240
|
+
subagents[tid] = entry
|
|
241
|
+
if len(json.dumps(item["input"])) > 60000:
|
|
242
|
+
item["input"] = {"preview": json.dumps(item["input"], ensure_ascii=False)[:60000], "truncated": True}
|
|
243
|
+
elif kind == "available_commands_update": state["commands"] = update.get("availableCommands", [])
|
|
244
|
+
return
|
|
245
|
+
phase = requests.pop(value.get("id"), None)
|
|
246
|
+
if not phase: return
|
|
247
|
+
if "error" in value: raise RuntimeError(value["error"].get("message", "ACP request failed"))
|
|
248
|
+
result = value.get("result", {})
|
|
249
|
+
if phase == "initialize":
|
|
250
|
+
if result.get("protocolVersion") != 1: raise RuntimeError("Unsupported ACP version")
|
|
251
|
+
params = {"cwd": config["cwd"], "mcpServers": []}
|
|
252
|
+
if config.get("resumeSessionId"):
|
|
253
|
+
params["sessionId"] = config["resumeSessionId"]
|
|
254
|
+
call("session/load", params, "session")
|
|
255
|
+
else: call("session/new", params, "session")
|
|
256
|
+
elif phase == "session":
|
|
257
|
+
state["sessionId"] = result.get("sessionId") or config.get("resumeSessionId")
|
|
258
|
+
if not state["sessionId"]: raise RuntimeError("ACP missing session ID")
|
|
259
|
+
settings = []
|
|
260
|
+
if config.get("model"): settings.append(("session/set_model", {"modelId": config["model"]}))
|
|
261
|
+
if config.get("effort"): settings.append(("session/set_config_option", {"configId": "thought_level", "value": config["effort"]}))
|
|
262
|
+
mode = {"workspace": "accept-edits", "full": "default"}.get(config["permissionMode"], config["permissionMode"])
|
|
263
|
+
settings.append(("session/set_mode", {"modeId": mode}))
|
|
264
|
+
next_setting()
|
|
265
|
+
elif phase == "setting": next_setting()
|
|
266
|
+
elif phase == "prompt":
|
|
267
|
+
if result.get("stopReason") in ("refusal", "max_tokens", "max_turn_requests"):
|
|
268
|
+
state["error"] = "AGY 未完成本轮: " + result["stopReason"]
|
|
269
|
+
if active_prompt.startswith("/") and result.get("stopReason") == "end_turn":
|
|
270
|
+
emit("permission", text="原生命令已完成:" + active_prompt.split()[0])
|
|
271
|
+
finished = True
|
|
272
|
+
|
|
273
|
+
args = [config["executable"], "acp"]
|
|
274
|
+
if config["permissionMode"] in ("workspace", "auto"): args.append("--sandbox")
|
|
275
|
+
if config["permissionMode"] == "full": args.append("--dangerously-skip-permissions")
|
|
276
|
+
try:
|
|
277
|
+
with (root / "agy-stderr").open("wb") as errors:
|
|
278
|
+
child = subprocess.Popen(args, cwd=config["cwd"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=errors, start_new_session=True)
|
|
279
|
+
selector = selectors.DefaultSelector(); selector.register(child.stdout, selectors.EVENT_READ)
|
|
280
|
+
call("initialize", {"protocolVersion": 1, "clientInfo": {"name": "scope", "version": "0.2.0"},
|
|
281
|
+
"clientCapabilities": {"elicitation": {"form": {}}}}, "initialize")
|
|
282
|
+
buffer, started = b"", time.monotonic()
|
|
283
|
+
while child.poll() is None:
|
|
284
|
+
for key, _ in selector.select(.15):
|
|
285
|
+
buffer += os.read(key.fd, 65536)
|
|
286
|
+
if len(buffer) > 8000000: raise RuntimeError("ACP event exceeds limit")
|
|
287
|
+
while b"\n" in buffer:
|
|
288
|
+
line, buffer = buffer.split(b"\n", 1)
|
|
289
|
+
try: value = json.loads(line)
|
|
290
|
+
except ValueError: continue
|
|
291
|
+
frame(value)
|
|
292
|
+
fcntl.flock(mutex, fcntl.LOCK_EX)
|
|
293
|
+
try:
|
|
294
|
+
incoming = [(p, json.loads(p.read_text())) for p in controls.glob("*.json") if p.name not in seen]
|
|
295
|
+
for file, control in sorted(incoming, key=lambda item: item[1].get("_sequence", 0)):
|
|
296
|
+
seen.add(file.name)
|
|
297
|
+
try:
|
|
298
|
+
if stopping: raise ValueError("本轮正在停止")
|
|
299
|
+
action = control["action"]
|
|
300
|
+
if action == "message":
|
|
301
|
+
queue.append(control["prompt"]); emit("user", text=control["prompt"], queued=True)
|
|
302
|
+
elif action == "permission":
|
|
303
|
+
request = pending.get(control["requestId"])
|
|
304
|
+
if not request: raise ValueError("请求已失效")
|
|
305
|
+
if request["kind"] == "acp-form":
|
|
306
|
+
decision = control.get("decision")
|
|
307
|
+
result = {"action": "accept" if decision == "allow" else "cancel" if decision == "cancel" else "decline"}
|
|
308
|
+
if decision == "allow": result["content"] = validate(request["input"], control.get("content"))
|
|
309
|
+
else:
|
|
310
|
+
option = next((o for o in request["options"] if o["optionId"] == control.get("optionId")), None)
|
|
311
|
+
if control.get("optionId") and not option: raise ValueError("审批选项已失效")
|
|
312
|
+
if not option and control.get("decision") == "allow": raise ValueError("请选择审批范围")
|
|
313
|
+
result = {"outcome": {"outcome": "selected", "optionId": option["optionId"]} if option else {"outcome": "cancelled"}}
|
|
314
|
+
send({"id": request["rpcId"], "result": result}); del pending[control["requestId"]]
|
|
315
|
+
emit("permission", text="回答已提交" if request["kind"] == "acp-form" else "审批已提交")
|
|
316
|
+
state["status"] = "waiting_permission" if pending else "running"
|
|
317
|
+
elif action == "stop":
|
|
318
|
+
stopping = time.monotonic(); queue.clear()
|
|
319
|
+
for request in pending.values():
|
|
320
|
+
send({"id": request["rpcId"], "result": {"action": "cancel"} if request["kind"] == "acp-form" else {"outcome": {"outcome": "cancelled"}}})
|
|
321
|
+
pending.clear()
|
|
322
|
+
send({"method": "session/cancel", "params": {"sessionId": state["sessionId"]}})
|
|
323
|
+
state["status"] = "stopping"
|
|
324
|
+
else: raise ValueError("未知操作")
|
|
325
|
+
state["controlResults"].append({"id": control["id"], "status": "accepted"})
|
|
326
|
+
except (ValueError, KeyError) as error:
|
|
327
|
+
state["controlResults"].append({"id": control.get("id"), "status": "rejected", "error": str(error)})
|
|
328
|
+
if finished and not pending:
|
|
329
|
+
if queue and not stopping: prompt(queue.pop(0))
|
|
330
|
+
else: break
|
|
331
|
+
if time.monotonic() - last_subagent_scan >= 2.0:
|
|
332
|
+
last_subagent_scan = time.monotonic()
|
|
333
|
+
sync_brain_subagents()
|
|
334
|
+
save()
|
|
335
|
+
finally: fcntl.flock(mutex, fcntl.LOCK_UN)
|
|
336
|
+
if not ready and time.monotonic() - started > 60: raise RuntimeError("AGY ACP 初始化超时")
|
|
337
|
+
if stopping and time.monotonic() - stopping > 3: break
|
|
338
|
+
sync_brain_subagents()
|
|
339
|
+
state["status"] = "stopped" if stopping else "completed" if finished and not state.get("error") else "failed"
|
|
340
|
+
if state["status"] == "failed" and not state.get("error"):
|
|
341
|
+
state["error"] = (root / "agy-stderr").read_text(errors="replace")[-2000:] or "AGY exited without a result"
|
|
342
|
+
except Exception as error:
|
|
343
|
+
state.update(status="failed", error=str(error))
|
|
344
|
+
finally:
|
|
345
|
+
if child and child.poll() is None:
|
|
346
|
+
os.killpg(child.pid, signal.SIGTERM)
|
|
347
|
+
try: child.wait(timeout=3)
|
|
348
|
+
except subprocess.TimeoutExpired: os.killpg(child.pid, signal.SIGKILL); child.wait()
|
|
349
|
+
pending.clear(); save()
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"""Query CLI initialization metadata only; never send a user turn or export account data."""
|
|
2
|
+
import json
|
|
3
|
+
import selectors
|
|
4
|
+
import subprocess
|
|
5
|
+
import sys
|
|
6
|
+
import tempfile
|
|
7
|
+
import time
|
|
8
|
+
|
|
9
|
+
with tempfile.TemporaryDirectory(prefix="scope-claude-probe-") as cwd:
|
|
10
|
+
child = subprocess.Popen([sys.argv[1], "-p", "--input-format", "stream-json", "--output-format",
|
|
11
|
+
"stream-json", "--verbose", "--no-session-persistence"], cwd=cwd,
|
|
12
|
+
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, text=True)
|
|
13
|
+
try:
|
|
14
|
+
child.stdin.write(json.dumps({"type": "control_request", "request_id": "scope-models",
|
|
15
|
+
"request": {"subtype": "initialize", "hooks": {}}}) + "\n")
|
|
16
|
+
child.stdin.flush()
|
|
17
|
+
selector = selectors.DefaultSelector()
|
|
18
|
+
selector.register(child.stdout, selectors.EVENT_READ)
|
|
19
|
+
deadline = time.monotonic() + 20
|
|
20
|
+
found = False
|
|
21
|
+
while time.monotonic() < deadline:
|
|
22
|
+
if not selector.select(1):
|
|
23
|
+
continue
|
|
24
|
+
line = child.stdout.readline()
|
|
25
|
+
if not line:
|
|
26
|
+
break
|
|
27
|
+
try:
|
|
28
|
+
value = json.loads(line)
|
|
29
|
+
except ValueError:
|
|
30
|
+
continue
|
|
31
|
+
if value.get("type") != "control_response":
|
|
32
|
+
continue
|
|
33
|
+
response = value.get("response", {}).get("response", {})
|
|
34
|
+
models = []
|
|
35
|
+
for model in response.get("models", []):
|
|
36
|
+
models.append({"id": model.get("value"), "label": model.get("displayName"),
|
|
37
|
+
"resolvedModel": model.get("resolvedModel"),
|
|
38
|
+
"efforts": model.get("supportedEffortLevels", []) if model.get("supportsEffort") else [],
|
|
39
|
+
"supportsAutoMode": model.get("supportsAutoMode") is True})
|
|
40
|
+
if models:
|
|
41
|
+
print(json.dumps({"models": models, "version": response.get("claude_code_version")}))
|
|
42
|
+
found = True
|
|
43
|
+
break
|
|
44
|
+
if not found:
|
|
45
|
+
raise RuntimeError("Claude CLI did not return model capabilities; check version and login")
|
|
46
|
+
finally:
|
|
47
|
+
child.terminate()
|
|
48
|
+
try:
|
|
49
|
+
child.wait(timeout=3)
|
|
50
|
+
except subprocess.TimeoutExpired:
|
|
51
|
+
child.kill()
|
|
52
|
+
child.wait()
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { deflateSync } from "node:zlib";
|
|
3
|
+
import { shellQuote } from "./cli-command.mjs";
|
|
4
|
+
|
|
5
|
+
const source = readFile(new URL("./claude-interactive.py", import.meta.url));
|
|
6
|
+
|
|
7
|
+
export async function claudeInteractiveCommand(task, providerSettings = {}) {
|
|
8
|
+
const code = deflateSync(await source).toString("base64");
|
|
9
|
+
const setup = String(providerSettings?.preLaunchCommand || "").trim();
|
|
10
|
+
const bootstrap = setup
|
|
11
|
+
? `${setup}\nscope_proxy_status=$?\nif [ "$scope_proxy_status" -ne 0 ]; then exit "$scope_proxy_status"; fi\n`
|
|
12
|
+
: "";
|
|
13
|
+
return `${bootstrap}exec python3 -c ${shellQuote(`import base64,zlib;exec(zlib.decompress(base64.b64decode('${code}')))`)} ${shellQuote(task.id)}`;
|
|
14
|
+
}
|