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,637 @@
|
|
|
1
|
+
/** Remote probe, kept independent of HTTP and local mutable state. */
|
|
2
|
+
export const REMOTE_PROBE = String.raw`
|
|
3
|
+
set +e
|
|
4
|
+
printf 'META\t'
|
|
5
|
+
hostname
|
|
6
|
+
|
|
7
|
+
ps -eo pid=,etimes=,stat=,tty=,comm= 2>/dev/null | awk '$5 ~ /^(codex|node)$/ {print}' | while read pid etimes stat tty comm; do
|
|
8
|
+
if [ "$comm" = "node" ]; then
|
|
9
|
+
cmdline=$(tr '\0' ' ' < "/proc/$pid/cmdline" 2>/dev/null)
|
|
10
|
+
case "$cmdline" in
|
|
11
|
+
*"/codex "*|*"/codex --"*) ;;
|
|
12
|
+
*) continue ;;
|
|
13
|
+
esac
|
|
14
|
+
fi
|
|
15
|
+
cwd=$(readlink "/proc/$pid/cwd" 2>/dev/null)
|
|
16
|
+
printf 'PROC\t%s\t%s\t%s\t%s\t%s\t%s\n' "$pid" "$etimes" "$stat" "$tty" "$comm" "$cwd"
|
|
17
|
+
done
|
|
18
|
+
|
|
19
|
+
nvidia-smi --query-gpu=index,uuid,name,utilization.gpu,memory.used,memory.total --format=csv,noheader,nounits 2>/dev/null | while IFS= read -r gpu; do
|
|
20
|
+
printf 'GPU\t%s\n' "$gpu"
|
|
21
|
+
done
|
|
22
|
+
|
|
23
|
+
python3 - <<'PY' 2>/dev/null
|
|
24
|
+
import ast
|
|
25
|
+
import base64
|
|
26
|
+
import glob
|
|
27
|
+
import json
|
|
28
|
+
import os
|
|
29
|
+
import re
|
|
30
|
+
import subprocess
|
|
31
|
+
import time
|
|
32
|
+
|
|
33
|
+
try:
|
|
34
|
+
encoded_fingerprints = os.environ.get("SCOPE_SESSION_FINGERPRINTS_B64", "")
|
|
35
|
+
encoded_fingerprints += "=" * (-len(encoded_fingerprints) % 4)
|
|
36
|
+
cached_fingerprints = json.loads(
|
|
37
|
+
base64.urlsafe_b64decode(encoded_fingerprints).decode("utf-8")
|
|
38
|
+
) if encoded_fingerprints else {}
|
|
39
|
+
if not isinstance(cached_fingerprints, dict):
|
|
40
|
+
cached_fingerprints = {}
|
|
41
|
+
except Exception:
|
|
42
|
+
cached_fingerprints = {}
|
|
43
|
+
|
|
44
|
+
def text_from_content(content):
|
|
45
|
+
if isinstance(content, str):
|
|
46
|
+
return content
|
|
47
|
+
if not isinstance(content, list):
|
|
48
|
+
return ""
|
|
49
|
+
parts = []
|
|
50
|
+
for item in content:
|
|
51
|
+
if not isinstance(item, dict):
|
|
52
|
+
continue
|
|
53
|
+
text = item.get("text")
|
|
54
|
+
if isinstance(text, str):
|
|
55
|
+
parts.append(text)
|
|
56
|
+
return "\n".join(parts)
|
|
57
|
+
|
|
58
|
+
def tool_output_text(value):
|
|
59
|
+
parsed = value
|
|
60
|
+
if isinstance(value, str):
|
|
61
|
+
stripped = value.strip()
|
|
62
|
+
for parser in (json.loads, ast.literal_eval):
|
|
63
|
+
try:
|
|
64
|
+
parsed = parser(stripped)
|
|
65
|
+
break
|
|
66
|
+
except Exception:
|
|
67
|
+
parsed = value
|
|
68
|
+
if isinstance(parsed, dict):
|
|
69
|
+
parsed = parsed.get("content") or parsed.get("output") or parsed
|
|
70
|
+
if isinstance(parsed, list):
|
|
71
|
+
extracted = text_from_content(parsed)
|
|
72
|
+
if extracted:
|
|
73
|
+
return extracted
|
|
74
|
+
return value if isinstance(value, str) else str(value or "")
|
|
75
|
+
|
|
76
|
+
def clean(value, limit=260):
|
|
77
|
+
if not isinstance(value, str):
|
|
78
|
+
return ""
|
|
79
|
+
value = " ".join(value.replace("\x00", "").split())
|
|
80
|
+
return value[:limit]
|
|
81
|
+
|
|
82
|
+
def parse_subagent_notification(value):
|
|
83
|
+
text = text_from_content(value) if not isinstance(value, str) else value
|
|
84
|
+
if not isinstance(text, str):
|
|
85
|
+
return None
|
|
86
|
+
stripped = text.strip()
|
|
87
|
+
markers = ("<subagent_notification>", "{subagent_notification}")
|
|
88
|
+
marker = next((item for item in markers if stripped.startswith(item)), None)
|
|
89
|
+
if not marker:
|
|
90
|
+
return None
|
|
91
|
+
encoded = stripped[len(marker):].strip()
|
|
92
|
+
try:
|
|
93
|
+
notification, _ = json.JSONDecoder().raw_decode(encoded)
|
|
94
|
+
except Exception:
|
|
95
|
+
return None
|
|
96
|
+
if not isinstance(notification, dict):
|
|
97
|
+
return None
|
|
98
|
+
status = notification.get("status")
|
|
99
|
+
if not isinstance(status, dict):
|
|
100
|
+
return None
|
|
101
|
+
state = next(
|
|
102
|
+
(key for key in ("completed", "failed", "errored", "cancelled") if key in status),
|
|
103
|
+
"updated",
|
|
104
|
+
)
|
|
105
|
+
content = status.get(state)
|
|
106
|
+
if not isinstance(content, str):
|
|
107
|
+
content = json.dumps(content, ensure_ascii=False) if content is not None else ""
|
|
108
|
+
return {
|
|
109
|
+
"agentPath": str(notification.get("agent_path") or ""),
|
|
110
|
+
"state": state,
|
|
111
|
+
"text": content,
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
def is_context_message(value):
|
|
115
|
+
if not isinstance(value, str):
|
|
116
|
+
return True
|
|
117
|
+
return value.startswith(
|
|
118
|
+
(
|
|
119
|
+
"<environment_context>",
|
|
120
|
+
"<permissions",
|
|
121
|
+
"<INSTRUCTIONS>",
|
|
122
|
+
"<collaboration_mode>",
|
|
123
|
+
"<apps_instructions>",
|
|
124
|
+
"<plugins_instructions>",
|
|
125
|
+
"<skills_instructions>",
|
|
126
|
+
"<recommended_plugins>",
|
|
127
|
+
"<in-app-browser-context",
|
|
128
|
+
"# AGENTS.md instructions",
|
|
129
|
+
"A previous agent produced",
|
|
130
|
+
"You are Codex",
|
|
131
|
+
)
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
training_command_pattern = re.compile(
|
|
135
|
+
r"(?i)(?:\btorchrun\b|\bdeepspeed\b|\baccelerate\s+launch\b|"
|
|
136
|
+
r"(?:^|[\s/_.-])(?:train|eval|evaluate|rollout|benchmark|inference)"
|
|
137
|
+
r"(?:[\s/_.-]|$)|\blibero\b|\beval_suite\b)"
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
def command_values(value):
|
|
141
|
+
if isinstance(value, str):
|
|
142
|
+
try:
|
|
143
|
+
parsed = json.loads(value)
|
|
144
|
+
except Exception:
|
|
145
|
+
parsed = None
|
|
146
|
+
if parsed is not None and parsed != value:
|
|
147
|
+
return command_values(parsed)
|
|
148
|
+
commands = []
|
|
149
|
+
for match in re.finditer(
|
|
150
|
+
r'(?:"(?:cmd|command)"|(?<![\w])(?:cmd|command))\s*:\s*'
|
|
151
|
+
r'("(?:\\.|[^"\\])*")',
|
|
152
|
+
value,
|
|
153
|
+
):
|
|
154
|
+
try:
|
|
155
|
+
commands.append(json.loads(match.group(1)))
|
|
156
|
+
except Exception:
|
|
157
|
+
pass
|
|
158
|
+
return commands or [value]
|
|
159
|
+
if isinstance(value, dict):
|
|
160
|
+
commands = []
|
|
161
|
+
for key in ("cmd", "command"):
|
|
162
|
+
candidate = value.get(key)
|
|
163
|
+
if isinstance(candidate, str):
|
|
164
|
+
commands.append(candidate)
|
|
165
|
+
for key, nested in value.items():
|
|
166
|
+
if key not in ("cmd", "command"):
|
|
167
|
+
commands.extend(command_values(nested))
|
|
168
|
+
return commands
|
|
169
|
+
if isinstance(value, list):
|
|
170
|
+
commands = []
|
|
171
|
+
for nested in value:
|
|
172
|
+
commands.extend(command_values(nested))
|
|
173
|
+
return commands
|
|
174
|
+
return []
|
|
175
|
+
|
|
176
|
+
all_paths = glob.glob(
|
|
177
|
+
os.path.join(os.environ.get("CODEX_HOME", os.path.expanduser("~/.codex")), "sessions", "**", "*.jsonl"), recursive=True
|
|
178
|
+
)
|
|
179
|
+
all_paths = list(dict.fromkeys(os.path.realpath(filename) for filename in all_paths))
|
|
180
|
+
all_paths.sort(key=lambda item: os.path.getmtime(item), reverse=True)
|
|
181
|
+
|
|
182
|
+
active_paths = set()
|
|
183
|
+
for proc_name in os.listdir("/proc"):
|
|
184
|
+
if not proc_name.isdigit():
|
|
185
|
+
continue
|
|
186
|
+
proc_root = os.path.join("/proc", proc_name)
|
|
187
|
+
try:
|
|
188
|
+
with open(os.path.join(proc_root, "comm"), "r") as handle:
|
|
189
|
+
command = handle.read().strip()
|
|
190
|
+
with open(os.path.join(proc_root, "cmdline"), "rb") as handle:
|
|
191
|
+
cmdline = handle.read().replace(b"\x00", b" ").decode(
|
|
192
|
+
"utf-8", errors="replace"
|
|
193
|
+
).strip()
|
|
194
|
+
except Exception:
|
|
195
|
+
continue
|
|
196
|
+
if command != "codex" and not (
|
|
197
|
+
command == "node" and re.search(r"(?:^|\s)(?:\S*/)?codex(?:\s|$)", cmdline)
|
|
198
|
+
):
|
|
199
|
+
continue
|
|
200
|
+
|
|
201
|
+
session_paths = []
|
|
202
|
+
try:
|
|
203
|
+
for fd in os.listdir(os.path.join(proc_root, "fd")):
|
|
204
|
+
try:
|
|
205
|
+
target = os.readlink(os.path.join(proc_root, "fd", fd))
|
|
206
|
+
except Exception:
|
|
207
|
+
continue
|
|
208
|
+
# /proc exposes the real path, which need not contain '.codex':
|
|
209
|
+
# CODEX_HOME, symlinked homes and account profiles all relocate it.
|
|
210
|
+
target = os.path.realpath(target)
|
|
211
|
+
if "/sessions/" in target and os.path.basename(target).startswith("rollout-") and target.endswith(".jsonl"):
|
|
212
|
+
session_paths.append(target)
|
|
213
|
+
active_paths.add(target)
|
|
214
|
+
except Exception:
|
|
215
|
+
pass
|
|
216
|
+
|
|
217
|
+
process_record = {
|
|
218
|
+
"pid": int(proc_name),
|
|
219
|
+
"cmdline": cmdline,
|
|
220
|
+
"sessionPaths": sorted(set(session_paths)),
|
|
221
|
+
}
|
|
222
|
+
encoded_process = base64.urlsafe_b64encode(
|
|
223
|
+
json.dumps(process_record, ensure_ascii=False).encode("utf-8")
|
|
224
|
+
).decode("ascii")
|
|
225
|
+
print("PROCESS_META\t" + encoded_process)
|
|
226
|
+
|
|
227
|
+
gpu_processes = {}
|
|
228
|
+
try:
|
|
229
|
+
uuid_rows = subprocess.check_output(
|
|
230
|
+
[
|
|
231
|
+
"nvidia-smi",
|
|
232
|
+
"--query-gpu=index,uuid",
|
|
233
|
+
"--format=csv,noheader,nounits",
|
|
234
|
+
],
|
|
235
|
+
stderr=subprocess.DEVNULL,
|
|
236
|
+
text=True,
|
|
237
|
+
).splitlines()
|
|
238
|
+
gpu_indices = {}
|
|
239
|
+
for row in uuid_rows:
|
|
240
|
+
fields = [field.strip() for field in row.split(",", 1)]
|
|
241
|
+
if len(fields) == 2:
|
|
242
|
+
gpu_indices[fields[1]] = int(fields[0])
|
|
243
|
+
process_rows = subprocess.check_output(
|
|
244
|
+
[
|
|
245
|
+
"nvidia-smi",
|
|
246
|
+
"--query-compute-apps=pid,gpu_uuid,used_gpu_memory",
|
|
247
|
+
"--format=csv,noheader,nounits",
|
|
248
|
+
],
|
|
249
|
+
stderr=subprocess.DEVNULL,
|
|
250
|
+
text=True,
|
|
251
|
+
).splitlines()
|
|
252
|
+
for row in process_rows:
|
|
253
|
+
fields = [field.strip() for field in row.split(",", 2)]
|
|
254
|
+
if len(fields) != 3 or not fields[0].isdigit():
|
|
255
|
+
continue
|
|
256
|
+
gpu_processes.setdefault(int(fields[0]), []).append({
|
|
257
|
+
"index": gpu_indices.get(fields[1]),
|
|
258
|
+
"memoryMiB": int(fields[2]) if fields[2].isdigit() else 0,
|
|
259
|
+
})
|
|
260
|
+
except Exception:
|
|
261
|
+
pass
|
|
262
|
+
|
|
263
|
+
process_table = {}
|
|
264
|
+
try:
|
|
265
|
+
rows = subprocess.check_output(
|
|
266
|
+
[
|
|
267
|
+
"ps",
|
|
268
|
+
"-eo",
|
|
269
|
+
"pid=,ppid=,pgid=,sid=,etimes=,tty=,stat=,args=",
|
|
270
|
+
],
|
|
271
|
+
stderr=subprocess.DEVNULL,
|
|
272
|
+
text=True,
|
|
273
|
+
).splitlines()
|
|
274
|
+
except Exception:
|
|
275
|
+
rows = []
|
|
276
|
+
|
|
277
|
+
for row in rows:
|
|
278
|
+
fields = row.strip().split(None, 7)
|
|
279
|
+
if len(fields) < 8:
|
|
280
|
+
continue
|
|
281
|
+
try:
|
|
282
|
+
pid, ppid, pgid, sid, elapsed = map(int, fields[:5])
|
|
283
|
+
except Exception:
|
|
284
|
+
continue
|
|
285
|
+
try:
|
|
286
|
+
cwd = os.readlink(f"/proc/{pid}/cwd")
|
|
287
|
+
except Exception:
|
|
288
|
+
cwd = ""
|
|
289
|
+
try:
|
|
290
|
+
with open(f"/proc/{pid}/comm", "r") as handle:
|
|
291
|
+
command = handle.read().strip()
|
|
292
|
+
except Exception:
|
|
293
|
+
command = os.path.basename(fields[7].split(None, 1)[0])
|
|
294
|
+
process_table[pid] = {
|
|
295
|
+
"pid": pid,
|
|
296
|
+
"ppid": ppid,
|
|
297
|
+
"pgid": pgid,
|
|
298
|
+
"sid": sid,
|
|
299
|
+
"elapsedSeconds": elapsed,
|
|
300
|
+
"tty": fields[5].replace("/dev/", ""),
|
|
301
|
+
"stat": fields[6],
|
|
302
|
+
"command": command,
|
|
303
|
+
"cmdline": fields[7],
|
|
304
|
+
"cwd": cwd,
|
|
305
|
+
"gpus": gpu_processes.get(pid, []),
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
workload_candidates = {}
|
|
309
|
+
for pid, process in process_table.items():
|
|
310
|
+
command = process["command"].lower()
|
|
311
|
+
cmdline = process["cmdline"]
|
|
312
|
+
if command in ("codex", "ssh", "sshd", "tmux: server", "tmux"):
|
|
313
|
+
continue
|
|
314
|
+
if "monitor_" in cmdline and not process["gpus"]:
|
|
315
|
+
continue
|
|
316
|
+
if process["gpus"] or training_command_pattern.search(cmdline):
|
|
317
|
+
workload_candidates[pid] = process
|
|
318
|
+
|
|
319
|
+
workload_groups = {}
|
|
320
|
+
for process in workload_candidates.values():
|
|
321
|
+
group_id = process["sid"] if process["sid"] > 1 else process["pgid"]
|
|
322
|
+
if group_id <= 1:
|
|
323
|
+
group_id = process["pid"]
|
|
324
|
+
workload_groups.setdefault(group_id, []).append(process)
|
|
325
|
+
|
|
326
|
+
for group_id, members in workload_groups.items():
|
|
327
|
+
member_ids = {member["pid"] for member in members}
|
|
328
|
+
roots = [member for member in members if member["ppid"] not in member_ids]
|
|
329
|
+
root = sorted(
|
|
330
|
+
roots or members,
|
|
331
|
+
key=lambda item: (-item["elapsedSeconds"], item["pid"]),
|
|
332
|
+
)[0]
|
|
333
|
+
ancestor_pids = []
|
|
334
|
+
cursor = root["ppid"]
|
|
335
|
+
seen = set()
|
|
336
|
+
while cursor > 1 and cursor not in seen and len(ancestor_pids) < 40:
|
|
337
|
+
seen.add(cursor)
|
|
338
|
+
ancestor_pids.append(cursor)
|
|
339
|
+
parent = process_table.get(cursor)
|
|
340
|
+
if not parent:
|
|
341
|
+
break
|
|
342
|
+
cursor = parent["ppid"]
|
|
343
|
+
gpu_entries = []
|
|
344
|
+
for member in members:
|
|
345
|
+
for gpu in member["gpus"]:
|
|
346
|
+
gpu_entries.append({
|
|
347
|
+
**gpu,
|
|
348
|
+
"pid": member["pid"],
|
|
349
|
+
})
|
|
350
|
+
record = {
|
|
351
|
+
**root,
|
|
352
|
+
"groupId": group_id,
|
|
353
|
+
"workerPids": sorted(member_ids),
|
|
354
|
+
"ancestorPids": ancestor_pids,
|
|
355
|
+
"gpus": gpu_entries,
|
|
356
|
+
"gpuMemoryMiB": sum(gpu["memoryMiB"] for gpu in gpu_entries),
|
|
357
|
+
"kind": (
|
|
358
|
+
"evaluation"
|
|
359
|
+
if re.search(r"(?i)(?:eval|evaluate|benchmark|rollout|libero|eval_suite)", root["cmdline"])
|
|
360
|
+
else "training"
|
|
361
|
+
),
|
|
362
|
+
}
|
|
363
|
+
encoded_workload = base64.urlsafe_b64encode(
|
|
364
|
+
json.dumps(record, ensure_ascii=False).encode("utf-8")
|
|
365
|
+
).decode("ascii")
|
|
366
|
+
print("WORKLOAD\t" + encoded_workload)
|
|
367
|
+
|
|
368
|
+
paths = list(dict.fromkeys(all_paths[:10] + list(active_paths)))
|
|
369
|
+
paths.sort(key=lambda item: os.path.getmtime(item), reverse=True)
|
|
370
|
+
|
|
371
|
+
try:
|
|
372
|
+
panes = subprocess.check_output(
|
|
373
|
+
[
|
|
374
|
+
"tmux",
|
|
375
|
+
"list-panes",
|
|
376
|
+
"-a",
|
|
377
|
+
"-F",
|
|
378
|
+
"#{session_name}\t#{window_index}.#{pane_index}\t#{pane_current_command}\t#{pane_current_path}\t#{pane_tty}\t#{pane_pid}\t#{session_activity}\t#{pane_dead}\t#{pane_dead_status}",
|
|
379
|
+
],
|
|
380
|
+
stderr=subprocess.DEVNULL,
|
|
381
|
+
text=True,
|
|
382
|
+
).splitlines()
|
|
383
|
+
for line in panes:
|
|
384
|
+
fields = line.split("\t")
|
|
385
|
+
if len(fields) != 9:
|
|
386
|
+
continue
|
|
387
|
+
target = f"{fields[0]}:{fields[1]}"
|
|
388
|
+
try:
|
|
389
|
+
preview = subprocess.check_output(
|
|
390
|
+
["tmux", "capture-pane", "-p", "-S", "-24", "-t", target],
|
|
391
|
+
stderr=subprocess.DEVNULL,
|
|
392
|
+
)
|
|
393
|
+
except Exception:
|
|
394
|
+
preview = b""
|
|
395
|
+
encoded_preview = base64.b64encode(preview).decode("ascii")
|
|
396
|
+
print("PANE\t" + "\t".join(fields) + "\t" + encoded_preview)
|
|
397
|
+
except Exception:
|
|
398
|
+
pass
|
|
399
|
+
|
|
400
|
+
def bounded_session_lines(filename, active):
|
|
401
|
+
head_bytes = 2 * 1024 * 1024
|
|
402
|
+
tail_bytes = (8 if active else 2) * 1024 * 1024
|
|
403
|
+
tail_lines = 5000 if active else 500
|
|
404
|
+
with open(filename, "rb") as handle:
|
|
405
|
+
first = handle.readline(1024 * 1024).decode("utf-8", errors="replace")
|
|
406
|
+
head_blob = handle.read(head_bytes)
|
|
407
|
+
size = os.fstat(handle.fileno()).st_size
|
|
408
|
+
handle.seek(max(0, size - tail_bytes))
|
|
409
|
+
tail_blob = handle.read(tail_bytes)
|
|
410
|
+
head = head_blob.decode("utf-8", errors="replace").splitlines(keepends=True)[:400]
|
|
411
|
+
tail = tail_blob.decode("utf-8", errors="replace").splitlines(keepends=True)
|
|
412
|
+
if size > tail_bytes and tail:
|
|
413
|
+
# The first entry begins in the middle of a JSONL record.
|
|
414
|
+
tail = tail[1:]
|
|
415
|
+
return first, head, tail[-tail_lines:]
|
|
416
|
+
|
|
417
|
+
for filename in paths:
|
|
418
|
+
try:
|
|
419
|
+
stat = os.stat(filename)
|
|
420
|
+
mtime_ms = int(stat.st_mtime * 1000)
|
|
421
|
+
size_bytes = int(stat.st_size)
|
|
422
|
+
cached = cached_fingerprints.get(filename)
|
|
423
|
+
if (
|
|
424
|
+
isinstance(cached, list)
|
|
425
|
+
and len(cached) == 2
|
|
426
|
+
and cached[0] == mtime_ms
|
|
427
|
+
and cached[1] == size_bytes
|
|
428
|
+
):
|
|
429
|
+
encoded_path = base64.urlsafe_b64encode(
|
|
430
|
+
filename.encode("utf-8")
|
|
431
|
+
).decode("ascii")
|
|
432
|
+
print("SESSION_REF\t" + encoded_path)
|
|
433
|
+
continue
|
|
434
|
+
first, head, tail = bounded_session_lines(
|
|
435
|
+
filename, filename in active_paths
|
|
436
|
+
)
|
|
437
|
+
first_obj = json.loads(first)
|
|
438
|
+
meta = first_obj.get("payload", {}) if first_obj.get("type") == "session_meta" else {}
|
|
439
|
+
except Exception:
|
|
440
|
+
continue
|
|
441
|
+
|
|
442
|
+
source = meta.get("source")
|
|
443
|
+
subagent = source.get("subagent", {}) if isinstance(source, dict) else {}
|
|
444
|
+
spawn = subagent.get("thread_spawn", {}) if isinstance(subagent, dict) else {}
|
|
445
|
+
record = {
|
|
446
|
+
"id": meta.get("id") or meta.get("session_id") or os.path.basename(filename),
|
|
447
|
+
"rootSessionId": meta.get("session_id") or meta.get("id") or "",
|
|
448
|
+
"parentThreadId": meta.get("parent_thread_id")
|
|
449
|
+
or spawn.get("parent_thread_id")
|
|
450
|
+
or "",
|
|
451
|
+
"agentPath": spawn.get("agent_path") or "",
|
|
452
|
+
"agentNickname": spawn.get("agent_nickname") or meta.get("agent_nickname") or "",
|
|
453
|
+
"agentRole": spawn.get("agent_role") or meta.get("agent_role") or "",
|
|
454
|
+
"isSubagent": bool(spawn or meta.get("parent_thread_id")),
|
|
455
|
+
"cwd": meta.get("cwd") or "",
|
|
456
|
+
"startedAt": meta.get("timestamp") or first_obj.get("timestamp"),
|
|
457
|
+
"cliVersion": meta.get("cli_version") or "",
|
|
458
|
+
"path": filename,
|
|
459
|
+
"mtimeMs": mtime_ms,
|
|
460
|
+
"sizeBytes": size_bytes,
|
|
461
|
+
"firstUser": "",
|
|
462
|
+
"lastUser": "",
|
|
463
|
+
"lastAssistant": "",
|
|
464
|
+
"lastAction": "",
|
|
465
|
+
"lastError": "",
|
|
466
|
+
"launches": [],
|
|
467
|
+
"userMessages": [],
|
|
468
|
+
"assistantMessages": [],
|
|
469
|
+
"model": "",
|
|
470
|
+
"reasoningEffort": "",
|
|
471
|
+
"approvalPolicy": "",
|
|
472
|
+
"sandboxPolicy": "",
|
|
473
|
+
"collaborationMode": "",
|
|
474
|
+
"account": None,
|
|
475
|
+
"tokenUsage": None,
|
|
476
|
+
"turnState": "idle",
|
|
477
|
+
"lastEventAt": first_obj.get("timestamp"),
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
seen_lines = set()
|
|
481
|
+
for raw in head + tail:
|
|
482
|
+
if raw in seen_lines:
|
|
483
|
+
continue
|
|
484
|
+
seen_lines.add(raw)
|
|
485
|
+
try:
|
|
486
|
+
event = json.loads(raw)
|
|
487
|
+
except Exception:
|
|
488
|
+
continue
|
|
489
|
+
payload = event.get("payload", {})
|
|
490
|
+
event_type = event.get("type")
|
|
491
|
+
record["lastEventAt"] = event.get("timestamp") or record["lastEventAt"]
|
|
492
|
+
|
|
493
|
+
if event_type == "turn_context":
|
|
494
|
+
record["model"] = payload.get("model") or record["model"]
|
|
495
|
+
record["reasoningEffort"] = (
|
|
496
|
+
payload.get("effort")
|
|
497
|
+
or payload.get("reasoning_effort")
|
|
498
|
+
or record["reasoningEffort"]
|
|
499
|
+
)
|
|
500
|
+
record["approvalPolicy"] = (
|
|
501
|
+
payload.get("approval_policy") or record["approvalPolicy"]
|
|
502
|
+
)
|
|
503
|
+
sandbox = payload.get("sandbox_policy")
|
|
504
|
+
if isinstance(sandbox, dict):
|
|
505
|
+
record["sandboxPolicy"] = (
|
|
506
|
+
sandbox.get("type")
|
|
507
|
+
or sandbox.get("mode")
|
|
508
|
+
or record["sandboxPolicy"]
|
|
509
|
+
)
|
|
510
|
+
elif isinstance(sandbox, str):
|
|
511
|
+
record["sandboxPolicy"] = sandbox
|
|
512
|
+
collaboration = payload.get("collaboration_mode")
|
|
513
|
+
if isinstance(collaboration, dict):
|
|
514
|
+
record["collaborationMode"] = (
|
|
515
|
+
collaboration.get("mode")
|
|
516
|
+
or collaboration.get("name")
|
|
517
|
+
or record["collaborationMode"]
|
|
518
|
+
)
|
|
519
|
+
elif isinstance(collaboration, str):
|
|
520
|
+
record["collaborationMode"] = collaboration
|
|
521
|
+
|
|
522
|
+
if event_type == "event_msg":
|
|
523
|
+
kind = payload.get("type")
|
|
524
|
+
if kind == "task_started":
|
|
525
|
+
record["turnState"] = "working"
|
|
526
|
+
elif kind in ("task_complete", "turn_complete", "task_completed"):
|
|
527
|
+
record["turnState"] = "idle"
|
|
528
|
+
candidate = clean(payload.get("last_agent_message"), 1600)
|
|
529
|
+
if candidate:
|
|
530
|
+
record["lastAssistant"] = candidate
|
|
531
|
+
record["assistantMessages"].append(candidate)
|
|
532
|
+
record["assistantMessages"] = record["assistantMessages"][-6:]
|
|
533
|
+
elif kind == "agent_message":
|
|
534
|
+
candidate = clean(
|
|
535
|
+
payload.get("message") or payload.get("text"),
|
|
536
|
+
1600,
|
|
537
|
+
)
|
|
538
|
+
if candidate:
|
|
539
|
+
record["lastAssistant"] = candidate
|
|
540
|
+
record["assistantMessages"].append(candidate)
|
|
541
|
+
record["assistantMessages"] = record["assistantMessages"][-6:]
|
|
542
|
+
elif kind in ("user_message", "user_input"):
|
|
543
|
+
raw_candidate = (
|
|
544
|
+
payload.get("message") or payload.get("text") or payload.get("content")
|
|
545
|
+
)
|
|
546
|
+
notification = parse_subagent_notification(raw_candidate)
|
|
547
|
+
if notification:
|
|
548
|
+
candidate = clean(notification["text"], 1600)
|
|
549
|
+
if candidate:
|
|
550
|
+
record["lastAssistant"] = candidate
|
|
551
|
+
record["assistantMessages"].append(candidate)
|
|
552
|
+
record["assistantMessages"] = record["assistantMessages"][-6:]
|
|
553
|
+
else:
|
|
554
|
+
candidate = clean(raw_candidate, 1200)
|
|
555
|
+
if candidate and not is_context_message(candidate):
|
|
556
|
+
record["firstUser"] = record["firstUser"] or candidate
|
|
557
|
+
record["lastUser"] = clean(candidate)
|
|
558
|
+
record["userMessages"].append(candidate)
|
|
559
|
+
record["userMessages"] = record["userMessages"][-8:]
|
|
560
|
+
elif kind == "token_count":
|
|
561
|
+
info = payload.get("info")
|
|
562
|
+
if isinstance(info, dict):
|
|
563
|
+
record["tokenUsage"] = {
|
|
564
|
+
"modelContextWindow": info.get("model_context_window"),
|
|
565
|
+
"total": info.get("total_token_usage"),
|
|
566
|
+
"last": info.get("last_token_usage"),
|
|
567
|
+
}
|
|
568
|
+
rate_limits = payload.get("rate_limits")
|
|
569
|
+
if isinstance(rate_limits, dict):
|
|
570
|
+
primary = rate_limits.get("primary")
|
|
571
|
+
secondary = rate_limits.get("secondary")
|
|
572
|
+
credits = rate_limits.get("credits")
|
|
573
|
+
record["account"] = {
|
|
574
|
+
"planType": rate_limits.get("plan_type") or "",
|
|
575
|
+
"primary": primary if isinstance(primary, dict) else None,
|
|
576
|
+
"secondary": secondary if isinstance(secondary, dict) else None,
|
|
577
|
+
"credits": credits if isinstance(credits, dict) else None,
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
if event_type != "response_item":
|
|
581
|
+
continue
|
|
582
|
+
|
|
583
|
+
kind = payload.get("type")
|
|
584
|
+
role = payload.get("role")
|
|
585
|
+
if kind == "message" and role == "user":
|
|
586
|
+
raw_candidate = text_from_content(payload.get("content"))
|
|
587
|
+
notification = parse_subagent_notification(raw_candidate)
|
|
588
|
+
if notification:
|
|
589
|
+
candidate = clean(notification["text"], 1600)
|
|
590
|
+
if candidate:
|
|
591
|
+
record["lastAssistant"] = candidate
|
|
592
|
+
record["assistantMessages"].append(candidate)
|
|
593
|
+
record["assistantMessages"] = record["assistantMessages"][-6:]
|
|
594
|
+
else:
|
|
595
|
+
candidate = clean(raw_candidate)
|
|
596
|
+
is_context = is_context_message(candidate)
|
|
597
|
+
if candidate and not is_context:
|
|
598
|
+
record["firstUser"] = record["firstUser"] or candidate
|
|
599
|
+
record["lastUser"] = candidate
|
|
600
|
+
record["userMessages"].append(clean(candidate, 1200))
|
|
601
|
+
record["userMessages"] = record["userMessages"][-8:]
|
|
602
|
+
elif kind == "message" and role == "assistant":
|
|
603
|
+
candidate = clean(text_from_content(payload.get("content")), 1600)
|
|
604
|
+
if candidate:
|
|
605
|
+
record["lastAssistant"] = candidate
|
|
606
|
+
record["assistantMessages"].append(candidate)
|
|
607
|
+
record["assistantMessages"] = record["assistantMessages"][-6:]
|
|
608
|
+
elif kind in ("function_call", "custom_tool_call"):
|
|
609
|
+
name = payload.get("name") or "tool"
|
|
610
|
+
arguments = payload.get("arguments") or payload.get("input") or ""
|
|
611
|
+
record["lastAction"] = clean(f"{name}: {arguments}", 300)
|
|
612
|
+
record["turnState"] = "working"
|
|
613
|
+
for command in command_values(arguments):
|
|
614
|
+
if (
|
|
615
|
+
training_command_pattern.search(command)
|
|
616
|
+
or re.search(r"(?i)\btmux\s+(?:new-session|new)\b", command)
|
|
617
|
+
):
|
|
618
|
+
record["launches"].append({
|
|
619
|
+
"timestamp": event.get("timestamp"),
|
|
620
|
+
"command": clean(command, 2400),
|
|
621
|
+
})
|
|
622
|
+
record["launches"] = record["launches"][-80:]
|
|
623
|
+
elif kind in ("function_call_output", "custom_tool_call_output"):
|
|
624
|
+
output = clean(tool_output_text(payload.get("output")), 300)
|
|
625
|
+
if (
|
|
626
|
+
"exit code 1" in output.lower()
|
|
627
|
+
or "process exited with code 1" in output.lower()
|
|
628
|
+
or "traceback" in output.lower()
|
|
629
|
+
):
|
|
630
|
+
record["lastError"] = output
|
|
631
|
+
|
|
632
|
+
encoded = base64.urlsafe_b64encode(
|
|
633
|
+
json.dumps(record, ensure_ascii=False).encode("utf-8")
|
|
634
|
+
).decode("ascii")
|
|
635
|
+
print("SESSION\t" + encoded)
|
|
636
|
+
PY
|
|
637
|
+
`;
|