scope-agent-workbench 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/LICENSE +21 -0
- package/README.md +174 -2
- package/README.zh-CN.md +175 -0
- package/bin/scope.mjs +111 -0
- package/bridge/account-quotas.mjs +881 -0
- package/bridge/agent-email-relay.mjs +160 -0
- package/bridge/app-server-client.mjs +2522 -0
- package/bridge/app-server-websocket-transport.mjs +219 -0
- package/bridge/archive/routes.mjs +19 -0
- package/bridge/archive/service.mjs +130 -0
- package/bridge/archive/thread-lifecycle.mjs +52 -0
- package/bridge/attachment-store.mjs +184 -0
- package/bridge/auth-profile-failover.mjs +58 -0
- package/bridge/auth-profile-manager.mjs +215 -0
- package/bridge/capacity-recovery.mjs +90 -0
- package/bridge/codex-upgrade.mjs +150 -0
- package/bridge/deployment-profile.mjs +64 -0
- package/bridge/email-notifier.mjs +616 -0
- package/bridge/gpu-usage-history.mjs +322 -0
- package/bridge/host-session-restart.mjs +35 -0
- package/bridge/http.mjs +69 -0
- package/bridge/idle-sessions.mjs +185 -0
- package/bridge/inventory-scanner.mjs +517 -0
- package/bridge/local/dialogue.mjs +150 -0
- package/bridge/local/directories.mjs +40 -0
- package/bridge/local/executable.mjs +29 -0
- package/bridge/local/history.mjs +21 -0
- package/bridge/local/python-probe.mjs +35 -0
- package/bridge/local/runtime.mjs +188 -0
- package/bridge/local/transport.mjs +70 -0
- package/bridge/maintenance/install-command.mjs +141 -0
- package/bridge/maintenance/routes.mjs +21 -0
- package/bridge/maintenance/service.mjs +175 -0
- package/bridge/model-catalog.mjs +21 -0
- package/bridge/persistent-home-guard.mjs +6 -0
- package/bridge/plugins/aliyun-dlc/index.mjs +47 -0
- package/bridge/plugins/aliyun-dlc/manifest.mjs +12 -0
- package/bridge/plugins/aliyun-dlc/monitor.mjs +236 -0
- package/bridge/plugins/aliyun-dlc/probe.mjs +701 -0
- package/bridge/plugins/config-store.mjs +35 -0
- package/bridge/plugins/external.mjs +87 -0
- package/bridge/plugins/package.mjs +96 -0
- package/bridge/plugins/registry.mjs +37 -0
- package/bridge/plugins/routes.mjs +27 -0
- package/bridge/private-gateway.mjs +371 -0
- package/bridge/private-start.mjs +22 -0
- package/bridge/probes/app-server-handoff-probe.mjs +89 -0
- package/bridge/probes/app-server-writer-probe.mjs +72 -0
- package/bridge/probes/assistant-search-probe.mjs +323 -0
- package/bridge/probes/dialogue-probe.mjs +464 -0
- package/bridge/probes/history-probe.mjs +347 -0
- package/bridge/probes/index.mjs +15 -0
- package/bridge/probes/new-session-preflight.mjs +16 -0
- package/bridge/probes/profile-cancel-probe.mjs +19 -0
- package/bridge/probes/profile-delete-probe.mjs +28 -0
- package/bridge/probes/profile-list-probe.mjs +117 -0
- package/bridge/probes/profile-write-probe.mjs +111 -0
- package/bridge/probes/raw-context-probe.mjs +53 -0
- package/bridge/probes/remote-probe.mjs +636 -0
- package/bridge/probes/submission-probe.mjs +2 -0
- package/bridge/probes/takeover-probe.mjs +328 -0
- package/bridge/probes/vscode-open-preflight.mjs +23 -0
- package/bridge/profile-capacity-policy.mjs +14 -0
- package/bridge/providers/acp-forms.py +49 -0
- package/bridge/providers/antigravity-interactive.mjs +14 -0
- package/bridge/providers/antigravity-interactive.py +349 -0
- package/bridge/providers/claude-capabilities.py +52 -0
- package/bridge/providers/claude-interactive.mjs +14 -0
- package/bridge/providers/claude-interactive.py +341 -0
- package/bridge/providers/cli-command.mjs +103 -0
- package/bridge/providers/codex-workbench.mjs +164 -0
- package/bridge/providers/conversation-routes.mjs +28 -0
- package/bridge/providers/conversations.mjs +231 -0
- package/bridge/providers/native-commands.mjs +48 -0
- package/bridge/providers/native-commands.py +38 -0
- package/bridge/providers/native-models.mjs +129 -0
- package/bridge/providers/native-session-state.mjs +14 -0
- package/bridge/providers/native-session-state.py +96 -0
- package/bridge/providers/remote-cli.mjs +75 -0
- package/bridge/providers/remote-job.py +130 -0
- package/bridge/remote-app-server-command.mjs +203 -0
- package/bridge/remote-bootstrap/routes.mjs +51 -0
- package/bridge/remote-bootstrap/scope-protocol.mjs +125 -0
- package/bridge/remote-bootstrap/service.mjs +597 -0
- package/bridge/remote-bootstrap/tunnels.mjs +347 -0
- package/bridge/remote-directory-listing.mjs +148 -0
- package/bridge/remote-images.mjs +140 -0
- package/bridge/remote-profile-home.mjs +39 -0
- package/bridge/remote-rollout-locks.mjs +31 -0
- package/bridge/remote-videos.mjs +129 -0
- package/bridge/research/insights.mjs +522 -0
- package/bridge/research/scan-host.mjs +18 -0
- package/bridge/rollout-summary.mjs +159 -0
- package/bridge/routes/accounts.mjs +326 -0
- package/bridge/routes/dialogue.mjs +120 -0
- package/bridge/routes/email.mjs +50 -0
- package/bridge/routes/management.mjs +291 -0
- package/bridge/routes/models.mjs +312 -0
- package/bridge/routes/runtime.mjs +82 -0
- package/bridge/routes/session-commands.mjs +12 -0
- package/bridge/routes/session-delivery.mjs +328 -0
- package/bridge/routes/session-lifecycle.mjs +839 -0
- package/bridge/routes/system.mjs +289 -0
- package/bridge/server.mjs +3332 -0
- package/bridge/session-attachments.mjs +150 -0
- package/bridge/session-cache-archive.mjs +22 -0
- package/bridge/session-catalog/agy-history.py +249 -0
- package/bridge/session-catalog/catalog.mjs +93 -0
- package/bridge/session-catalog/probe.py +331 -0
- package/bridge/session-catalog/routes.mjs +28 -0
- package/bridge/session-profiles.mjs +115 -0
- package/bridge/shared-start.mjs +22 -0
- package/bridge/start.mjs +205 -0
- package/bridge/state-persistence.mjs +397 -0
- package/bridge/submissions/settings.mjs +50 -0
- package/bridge/terminal-gateway.mjs +171 -0
- package/bridge/tmux-delivery.mjs +390 -0
- package/bridge/tmux-session-control.mjs +29 -0
- package/bridge/transport/ssh-command.mjs +119 -0
- package/bridge/ui-server.mjs +257 -0
- package/bridge/vscode-opener.mjs +157 -0
- package/bridge/web-terminal.mjs +52 -0
- package/bridge/workbench/conversation-routes.mjs +31 -0
- package/bridge/workbench/directory-probe.mjs +41 -0
- package/bridge/workbench/directory-routes.mjs +112 -0
- package/bridge/workbench/manager-context.mjs +51 -0
- package/bridge/workbench/routes.mjs +40 -0
- package/bridge/workbench/scheduler.mjs +131 -0
- package/bridge/workbench/service.mjs +301 -0
- package/bridge/workbench/store.mjs +64 -0
- package/bridge/workbench/task-archive.mjs +46 -0
- package/dist/client/.assetsignore +2 -0
- package/dist/client/.vite/manifest.json +366 -0
- package/dist/client/_headers +3 -0
- package/dist/client/agents/LICENSE.lobe-icons +21 -0
- package/dist/client/agents/README.md +14 -0
- package/dist/client/agents/antigravity.svg +39 -0
- package/dist/client/agents/claude.svg +1 -0
- package/dist/client/agents/codex.svg +1 -0
- package/dist/client/agents/dsh.svg +4 -0
- package/dist/client/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- package/dist/client/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
- package/dist/client/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
- package/dist/client/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
- package/dist/client/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
- package/dist/client/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- package/dist/client/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
- package/dist/client/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- package/dist/client/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
- package/dist/client/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
- package/dist/client/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
- package/dist/client/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- package/dist/client/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
- package/dist/client/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- package/dist/client/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
- package/dist/client/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- package/dist/client/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
- package/dist/client/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
- package/dist/client/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- package/dist/client/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
- package/dist/client/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
- package/dist/client/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
- package/dist/client/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
- package/dist/client/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- package/dist/client/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- package/dist/client/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
- package/dist/client/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
- package/dist/client/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
- package/dist/client/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- package/dist/client/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
- package/dist/client/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
- package/dist/client/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
- package/dist/client/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- package/dist/client/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
- package/dist/client/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- package/dist/client/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
- package/dist/client/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- package/dist/client/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
- package/dist/client/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
- package/dist/client/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
- package/dist/client/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
- package/dist/client/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- package/dist/client/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
- package/dist/client/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- package/dist/client/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
- package/dist/client/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
- package/dist/client/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
- package/dist/client/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- package/dist/client/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
- package/dist/client/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- package/dist/client/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
- package/dist/client/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
- package/dist/client/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
- package/dist/client/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
- package/dist/client/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
- package/dist/client/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- package/dist/client/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
- package/dist/client/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- package/dist/client/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
- package/dist/client/assets/_vinext_fonts/geist-8ac0455e797f/geist-001175b1.woff2 +0 -0
- package/dist/client/assets/_vinext_fonts/geist-8ac0455e797f/geist-52306abf.woff2 +0 -0
- package/dist/client/assets/_vinext_fonts/geist-8ac0455e797f/geist-875ccdd4.woff2 +0 -0
- package/dist/client/assets/_vinext_fonts/geist-8ac0455e797f/geist-98bbbccb.woff2 +0 -0
- package/dist/client/assets/_vinext_fonts/geist-8ac0455e797f/geist-ff2310f5.woff2 +0 -0
- package/dist/client/assets/_vinext_fonts/geist-mono-00e989178794/geist-mono-013b2f2f.woff2 +0 -0
- package/dist/client/assets/_vinext_fonts/geist-mono-00e989178794/geist-mono-0638449e.woff2 +0 -0
- package/dist/client/assets/_vinext_fonts/geist-mono-00e989178794/geist-mono-44745446.woff2 +0 -0
- package/dist/client/assets/_vinext_fonts/geist-mono-00e989178794/geist-mono-44e03052.woff2 +0 -0
- package/dist/client/assets/_vinext_fonts/geist-mono-00e989178794/geist-mono-971fb274.woff2 +0 -0
- package/dist/client/assets/_vinext_fonts/geist-mono-00e989178794/geist-mono-f6b33328.woff2 +0 -0
- package/dist/client/assets/addon-fit-BZbxZs2G.js +1 -0
- package/dist/client/assets/framework-CXnKph_e.js +9 -0
- package/dist/client/assets/index-CNnP2Ses.css +2 -0
- package/dist/client/assets/index-Enu1x0PS.js +3 -0
- package/dist/client/assets/layout-segment-context-CmJzExWq.js +1 -0
- package/dist/client/assets/page-COBv6VWj.css +1 -0
- package/dist/client/assets/page-DVjU6VG_.js +550 -0
- package/dist/client/assets/rolldown-runtime-S-ySWqyJ.js +1 -0
- package/dist/client/assets/xterm-BBgU7shl.js +36 -0
- package/dist/client/favicon.svg +6 -0
- package/dist/client/file.svg +1 -0
- package/dist/client/globe.svg +1 -0
- package/dist/client/og.png +0 -0
- package/dist/client/scope-logo.svg +11 -0
- package/dist/client/window.svg +1 -0
- package/dist/server/.vite/manifest.json +14 -0
- package/dist/server/__vite_rsc_assets_manifest.js +49 -0
- package/dist/server/assets/index-CNnP2Ses.css +2 -0
- package/dist/server/image-config.json +1 -0
- package/dist/server/index.js +15201 -0
- package/dist/server/ssr/__vite_rsc_assets_manifest.js +49 -0
- package/dist/server/ssr/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- package/dist/server/ssr/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
- package/dist/server/ssr/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
- package/dist/server/ssr/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
- package/dist/server/ssr/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
- package/dist/server/ssr/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- package/dist/server/ssr/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
- package/dist/server/ssr/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- package/dist/server/ssr/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
- package/dist/server/ssr/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
- package/dist/server/ssr/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
- package/dist/server/ssr/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- package/dist/server/ssr/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
- package/dist/server/ssr/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- package/dist/server/ssr/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
- package/dist/server/ssr/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- package/dist/server/ssr/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
- package/dist/server/ssr/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
- package/dist/server/ssr/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- package/dist/server/ssr/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
- package/dist/server/ssr/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
- package/dist/server/ssr/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
- package/dist/server/ssr/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
- package/dist/server/ssr/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- package/dist/server/ssr/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- package/dist/server/ssr/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
- package/dist/server/ssr/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
- package/dist/server/ssr/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
- package/dist/server/ssr/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- package/dist/server/ssr/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
- package/dist/server/ssr/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
- package/dist/server/ssr/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
- package/dist/server/ssr/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- package/dist/server/ssr/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
- package/dist/server/ssr/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- package/dist/server/ssr/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
- package/dist/server/ssr/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- package/dist/server/ssr/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
- package/dist/server/ssr/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
- package/dist/server/ssr/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
- package/dist/server/ssr/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
- package/dist/server/ssr/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- package/dist/server/ssr/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
- package/dist/server/ssr/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- package/dist/server/ssr/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
- package/dist/server/ssr/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
- package/dist/server/ssr/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
- package/dist/server/ssr/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- package/dist/server/ssr/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
- package/dist/server/ssr/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- package/dist/server/ssr/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
- package/dist/server/ssr/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
- package/dist/server/ssr/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
- package/dist/server/ssr/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
- package/dist/server/ssr/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
- package/dist/server/ssr/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- package/dist/server/ssr/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
- package/dist/server/ssr/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- package/dist/server/ssr/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
- package/dist/server/ssr/assets/addon-fit-C09Jj0_f.js +42 -0
- package/dist/server/ssr/assets/error-boundary-Dd2ZYXA8.js +277 -0
- package/dist/server/ssr/assets/layout-segment-context-HV_Mvyzf.js +37 -0
- package/dist/server/ssr/assets/page-COBv6VWj.css +1 -0
- package/dist/server/ssr/assets/page-CYYyCnKD.js +102541 -0
- package/dist/server/ssr/assets/xterm-DgzE4ZZ1.js +10232 -0
- package/dist/server/ssr/index.js +11840 -0
- package/dist/server/ssr/vinext-server.json +1 -0
- package/dist/server/vinext-externals.json +1 -0
- package/dist/server/vinext-server.json +1 -0
- package/dist/server/wrangler.json +1 -0
- package/examples/agents/global-agreements.example.md +10 -0
- package/examples/agents/research-project.example.md +10 -0
- package/examples/agents-media-previews.md +22 -0
- package/examples/deployment.example.json +6 -0
- package/examples/leak-denylist.example.json +10 -0
- package/examples/plugins/hello/index.mjs +4 -0
- package/examples/plugins/hello/scope-plugin.json +13 -0
- package/examples/workbench.config.json +44 -0
- package/lib/account-quota.d.ts +42 -0
- package/lib/account-quota.js +121 -0
- package/lib/browser-snapshot-cache.js +61 -0
- package/lib/conversation-location.js +26 -0
- package/lib/conversation.js +62 -0
- package/lib/dialogue-refresh.js +14 -0
- package/lib/execution-host.js +22 -0
- package/lib/formula-preview.js +48 -0
- package/lib/i18n.tsx +81 -0
- package/lib/incremental-snapshot.js +324 -0
- package/lib/manager-plan.js +37 -0
- package/lib/markdown-images.js +22 -0
- package/lib/markdown-math.js +151 -0
- package/lib/markdown-url.js +13 -0
- package/lib/model-effort.js +13 -0
- package/lib/native-history.d.ts +32 -0
- package/lib/native-history.js +94 -0
- package/lib/overview-delta.js +41 -0
- package/lib/project-view.js +86 -0
- package/lib/projects.js +74 -0
- package/lib/remote-links.js +95 -0
- package/lib/runtime-config.js +70 -0
- package/lib/session-activity.js +34 -0
- package/lib/session-cache-guard.js +52 -0
- package/lib/session-filters.js +38 -0
- package/lib/ssh-config.js +26 -0
- package/lib/stable-order.js +39 -0
- package/lib/workbench-config.js +172 -0
- package/package.json +105 -4
- package/scripts/agent-email-relay.mjs +104 -0
- package/scripts/benchmark-bridge.mjs +38 -0
- package/scripts/cli-integration-smoke.mjs +64 -0
- package/scripts/email-notification-cli.mjs +28 -0
- package/scripts/enable-private-access.ps1 +109 -0
- package/scripts/export-opensource.mjs +112 -0
- package/scripts/fixtures/media/convergence.png +0 -0
- package/scripts/fixtures/media/rollout_demo.mp4 +0 -0
- package/scripts/fixtures/native-conversations.mjs +307 -0
- package/scripts/fixtures/workbench-conversations.mjs +352 -0
- package/scripts/install-remote-server.sh +67 -0
- package/scripts/lib/export-directory.mjs +38 -0
- package/scripts/lib/secret-scanner.mjs +139 -0
- package/scripts/plugin-cli.mjs +19 -0
- package/scripts/preview-workbench.mjs +669 -0
- package/scripts/probe-antigravity-acp.mjs +35 -0
- package/scripts/remote-bootstrap-cli.mjs +52 -0
- package/scripts/remote-email-tool.py +383 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/** Remote probe, kept independent of HTTP and local mutable state. */
|
|
2
|
+
export const APP_SERVER_HANDOFF_PROBE = String.raw`
|
|
3
|
+
import glob
|
|
4
|
+
import json
|
|
5
|
+
import os
|
|
6
|
+
import re
|
|
7
|
+
import sys
|
|
8
|
+
|
|
9
|
+
pid = int(sys.argv[1])
|
|
10
|
+
expected_rollout = os.path.realpath(sys.argv[2])
|
|
11
|
+
expected_cwd = os.path.realpath(sys.argv[3])
|
|
12
|
+
|
|
13
|
+
def fail(message, code=1):
|
|
14
|
+
print(message, file=sys.stderr)
|
|
15
|
+
raise SystemExit(code)
|
|
16
|
+
|
|
17
|
+
def process_alive(target_pid):
|
|
18
|
+
stat_path = f"/proc/{target_pid}/stat"
|
|
19
|
+
try:
|
|
20
|
+
with open(stat_path, "r", encoding="utf-8", errors="replace") as handle:
|
|
21
|
+
fields = handle.read().split()
|
|
22
|
+
return len(fields) > 2 and fields[2] != "Z"
|
|
23
|
+
except Exception:
|
|
24
|
+
return False
|
|
25
|
+
|
|
26
|
+
def rollout_owners():
|
|
27
|
+
owners = []
|
|
28
|
+
for fd_path in glob.glob("/proc/[0-9]*/fd/*"):
|
|
29
|
+
try:
|
|
30
|
+
target = os.path.realpath(os.readlink(fd_path))
|
|
31
|
+
except Exception:
|
|
32
|
+
continue
|
|
33
|
+
if target == expected_rollout:
|
|
34
|
+
try:
|
|
35
|
+
owners.append(int(fd_path.split("/")[2]))
|
|
36
|
+
except Exception:
|
|
37
|
+
pass
|
|
38
|
+
return sorted(set(owners))
|
|
39
|
+
|
|
40
|
+
def process_args(target_pid):
|
|
41
|
+
try:
|
|
42
|
+
with open(f"/proc/{target_pid}/cmdline", "rb") as handle:
|
|
43
|
+
return [
|
|
44
|
+
value.decode("utf-8", errors="replace")
|
|
45
|
+
for value in handle.read().split(b"\x00")
|
|
46
|
+
if value
|
|
47
|
+
]
|
|
48
|
+
except Exception:
|
|
49
|
+
return []
|
|
50
|
+
|
|
51
|
+
def scope_app_server_owner(target_pid):
|
|
52
|
+
args = process_args(target_pid)
|
|
53
|
+
try:
|
|
54
|
+
app_server_index = args.index("app-server")
|
|
55
|
+
listen_index = args.index("--listen", app_server_index + 1)
|
|
56
|
+
endpoint = args[listen_index + 1]
|
|
57
|
+
except (ValueError, IndexError):
|
|
58
|
+
return False
|
|
59
|
+
control_dir = os.path.realpath(
|
|
60
|
+
os.path.expanduser("~/.codex/app-server-control")
|
|
61
|
+
)
|
|
62
|
+
expected_prefix = "unix://" + control_dir + "/scope-"
|
|
63
|
+
isolated_prefix = "unix://" + os.path.realpath(os.path.expanduser("~/.codex/scope-auth-profiles")) + "/"
|
|
64
|
+
isolated_suffix = endpoint[len(isolated_prefix):] if endpoint.startswith(isolated_prefix) else ""
|
|
65
|
+
return (endpoint.startswith(expected_prefix) and endpoint.endswith(".sock")) or bool(
|
|
66
|
+
re.fullmatch(r"([A-Za-z0-9][A-Za-z0-9._-]{0,47})/home/app-server-control/scope-account-\1\.sock", isolated_suffix)
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
if not os.path.isdir(expected_cwd):
|
|
70
|
+
fail(f"工作目录不存在:{expected_cwd}", 18)
|
|
71
|
+
|
|
72
|
+
owners = rollout_owners()
|
|
73
|
+
if pid > 0:
|
|
74
|
+
fail("安全策略禁止终止活动 CLI/VS Code Session", 23)
|
|
75
|
+
foreign_owners = [owner for owner in owners if not scope_app_server_owner(owner)]
|
|
76
|
+
if foreign_owners:
|
|
77
|
+
fail(
|
|
78
|
+
"该 Session 已由 PID " + ",".join(map(str, foreign_owners)) + " 打开;请刷新页面",
|
|
79
|
+
17,
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
print(json.dumps({
|
|
83
|
+
"ok": True,
|
|
84
|
+
"killedPid": None,
|
|
85
|
+
"forced": False,
|
|
86
|
+
"cwd": expected_cwd,
|
|
87
|
+
"reconnectedOwnerPids": owners,
|
|
88
|
+
}, ensure_ascii=False, separators=(",", ":")))
|
|
89
|
+
`;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/** Remote probe, kept independent of HTTP and local mutable state. */
|
|
2
|
+
export const APP_SERVER_WRITER_PROBE = String.raw`
|
|
3
|
+
import glob
|
|
4
|
+
import json
|
|
5
|
+
import os
|
|
6
|
+
import re
|
|
7
|
+
import sys
|
|
8
|
+
|
|
9
|
+
session_id = sys.argv[1]
|
|
10
|
+
if not re.fullmatch(r"[A-Za-z0-9._-]{8,200}", session_id):
|
|
11
|
+
print(json.dumps({"connectionKey": None, "error": "invalid session id"}))
|
|
12
|
+
raise SystemExit(2)
|
|
13
|
+
|
|
14
|
+
expected_lock = os.path.realpath(
|
|
15
|
+
os.path.expanduser(f"~/.codex/thread-writer-locks/{session_id}.lock")
|
|
16
|
+
)
|
|
17
|
+
control_dir = os.path.realpath(os.path.expanduser("~/.codex/app-server-control"))
|
|
18
|
+
|
|
19
|
+
def process_args(pid):
|
|
20
|
+
try:
|
|
21
|
+
with open(f"/proc/{pid}/cmdline", "rb") as handle:
|
|
22
|
+
return [
|
|
23
|
+
value.decode("utf-8", errors="replace")
|
|
24
|
+
for value in handle.read().split(b"\x00")
|
|
25
|
+
if value
|
|
26
|
+
]
|
|
27
|
+
except Exception:
|
|
28
|
+
return []
|
|
29
|
+
|
|
30
|
+
owners = []
|
|
31
|
+
for fd_path in (fd for proc in glob.glob("/proc/[0-9]*")
|
|
32
|
+
if "app-server" in process_args(proc.rsplit("/", 1)[-1])
|
|
33
|
+
for fd in glob.glob(proc + "/fd/*")):
|
|
34
|
+
try:
|
|
35
|
+
target = os.path.realpath(os.readlink(fd_path))
|
|
36
|
+
except Exception:
|
|
37
|
+
continue
|
|
38
|
+
if target != expected_lock:
|
|
39
|
+
continue
|
|
40
|
+
try:
|
|
41
|
+
owners.append(int(fd_path.split("/")[2]))
|
|
42
|
+
except Exception:
|
|
43
|
+
pass
|
|
44
|
+
|
|
45
|
+
for pid in sorted(set(owners)):
|
|
46
|
+
args = process_args(pid)
|
|
47
|
+
try:
|
|
48
|
+
app_server_index = args.index("app-server")
|
|
49
|
+
listen_index = args.index("--listen", app_server_index + 1)
|
|
50
|
+
endpoint = args[listen_index + 1]
|
|
51
|
+
except (ValueError, IndexError):
|
|
52
|
+
continue
|
|
53
|
+
prefix = "unix://" + control_dir + "/scope-"
|
|
54
|
+
if endpoint.startswith(prefix) and endpoint.endswith(".sock"):
|
|
55
|
+
connection_key = endpoint[len(prefix):-len(".sock")]
|
|
56
|
+
else:
|
|
57
|
+
isolated_prefix = "unix://" + os.path.realpath(os.path.expanduser("~/.codex/scope-auth-profiles")) + "/"
|
|
58
|
+
suffix = endpoint[len(isolated_prefix):] if endpoint.startswith(isolated_prefix) else ""
|
|
59
|
+
match = re.fullmatch(r"([A-Za-z0-9][A-Za-z0-9._-]{0,47})/(?:home|scope-home)/app-server-control/scope-account-\1\.sock", suffix)
|
|
60
|
+
if not match:
|
|
61
|
+
continue
|
|
62
|
+
connection_key = "account-" + match.group(1)
|
|
63
|
+
if re.fullmatch(r"[A-Za-z0-9_.-]{1,100}", connection_key):
|
|
64
|
+
print(json.dumps({
|
|
65
|
+
"connectionKey": connection_key,
|
|
66
|
+
"ownerPid": pid,
|
|
67
|
+
"endpoint": endpoint,
|
|
68
|
+
}, ensure_ascii=False, separators=(",", ":")))
|
|
69
|
+
raise SystemExit(0)
|
|
70
|
+
|
|
71
|
+
print(json.dumps({"connectionKey": None, "owners": sorted(set(owners))}))
|
|
72
|
+
`;
|
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
/** Remote probe, kept independent of HTTP and local mutable state. */
|
|
2
|
+
export const ASSISTANT_SEARCH_PROBE = String.raw`
|
|
3
|
+
import base64
|
|
4
|
+
import glob
|
|
5
|
+
import json
|
|
6
|
+
import os
|
|
7
|
+
import re
|
|
8
|
+
import subprocess
|
|
9
|
+
import sys
|
|
10
|
+
|
|
11
|
+
if hasattr(sys.stdout, "reconfigure"):
|
|
12
|
+
try:
|
|
13
|
+
sys.stdout.reconfigure(encoding="utf-8")
|
|
14
|
+
except Exception:
|
|
15
|
+
pass
|
|
16
|
+
|
|
17
|
+
config = json.loads(base64.urlsafe_b64decode(sys.argv[1] + "==").decode("utf-8"))
|
|
18
|
+
question = str(config.get("question") or "").strip()
|
|
19
|
+
result_limit = max(3, min(20, int(config.get("limit") or 10)))
|
|
20
|
+
max_files = max(50, min(1000, int(config.get("maxFiles") or 600)))
|
|
21
|
+
|
|
22
|
+
ascii_stops = {
|
|
23
|
+
"a", "an", "and", "are", "can", "codex", "confirm", "did", "do", "does",
|
|
24
|
+
"find", "for", "from", "i", "in", "is", "it", "me", "my", "now", "of",
|
|
25
|
+
"on", "one", "please", "session", "sessions", "that", "the", "this", "to",
|
|
26
|
+
"use", "using", "want", "which", "with",
|
|
27
|
+
}
|
|
28
|
+
chinese_stops = (
|
|
29
|
+
"我现在想确认", "我想确认", "请帮我", "帮我", "现在", "对应", "使用",
|
|
30
|
+
"哪个", "哪一个", "是什么", "是哪", "这个", "那个", "会话", "任务",
|
|
31
|
+
"去做",
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
lowered_question = question.lower()
|
|
35
|
+
ascii_terms = []
|
|
36
|
+
for term in re.findall(r"[a-z0-9][a-z0-9_.-]*", lowered_question):
|
|
37
|
+
cleaned = term.strip("._-")
|
|
38
|
+
if not cleaned or cleaned in ascii_stops:
|
|
39
|
+
continue
|
|
40
|
+
if len(cleaned) == 1 and cleaned not in {"x", "y", "z"}:
|
|
41
|
+
continue
|
|
42
|
+
if cleaned not in ascii_terms:
|
|
43
|
+
ascii_terms.append(cleaned)
|
|
44
|
+
|
|
45
|
+
chinese_query = lowered_question
|
|
46
|
+
for stop in chinese_stops:
|
|
47
|
+
chinese_query = chinese_query.replace(stop, " ")
|
|
48
|
+
chinese_terms = []
|
|
49
|
+
for run in re.findall(r"[\u3400-\u9fff]{2,}", chinese_query):
|
|
50
|
+
candidates = [run]
|
|
51
|
+
if len(run) > 6:
|
|
52
|
+
candidates.extend(run[index:index + 3] for index in range(len(run) - 2))
|
|
53
|
+
for candidate in candidates:
|
|
54
|
+
if candidate not in chinese_terms:
|
|
55
|
+
chinese_terms.append(candidate)
|
|
56
|
+
|
|
57
|
+
terms = (ascii_terms + chinese_terms)[:24]
|
|
58
|
+
if not terms:
|
|
59
|
+
terms = [question.lower()[:80]]
|
|
60
|
+
|
|
61
|
+
sessions_root = os.path.expanduser("~/.codex/sessions")
|
|
62
|
+
all_paths = glob.glob(os.path.join(sessions_root, "**", "*.jsonl"), recursive=True)
|
|
63
|
+
all_paths.sort(key=lambda item: os.path.getmtime(item), reverse=True)
|
|
64
|
+
|
|
65
|
+
matching_paths = []
|
|
66
|
+
if all_paths:
|
|
67
|
+
if os.name == "nt":
|
|
68
|
+
matching_paths = all_paths[:max_files]
|
|
69
|
+
else:
|
|
70
|
+
pattern = "|".join(re.escape(term) for term in terms if term)
|
|
71
|
+
try:
|
|
72
|
+
grep = subprocess.run(
|
|
73
|
+
["grep", "-RIilE", pattern, sessions_root],
|
|
74
|
+
stdout=subprocess.PIPE,
|
|
75
|
+
stderr=subprocess.DEVNULL,
|
|
76
|
+
text=True,
|
|
77
|
+
timeout=15,
|
|
78
|
+
)
|
|
79
|
+
if grep.returncode in (0, 1):
|
|
80
|
+
matching = {
|
|
81
|
+
os.path.normcase(os.path.normpath(line))
|
|
82
|
+
for line in grep.stdout.splitlines()
|
|
83
|
+
if line.endswith(".jsonl")
|
|
84
|
+
}
|
|
85
|
+
matching_paths = [
|
|
86
|
+
item
|
|
87
|
+
for item in all_paths
|
|
88
|
+
if os.path.normcase(os.path.normpath(item)) in matching
|
|
89
|
+
][:max_files]
|
|
90
|
+
else:
|
|
91
|
+
matching_paths = all_paths[:max_files]
|
|
92
|
+
except Exception:
|
|
93
|
+
matching_paths = all_paths[:max_files]
|
|
94
|
+
|
|
95
|
+
def text_from_content(content):
|
|
96
|
+
if isinstance(content, str):
|
|
97
|
+
return content
|
|
98
|
+
if not isinstance(content, list):
|
|
99
|
+
return ""
|
|
100
|
+
parts = []
|
|
101
|
+
for item in content:
|
|
102
|
+
if not isinstance(item, dict) or item.get("type") == "encrypted_content":
|
|
103
|
+
continue
|
|
104
|
+
text = item.get("text")
|
|
105
|
+
if isinstance(text, str):
|
|
106
|
+
parts.append(text)
|
|
107
|
+
return "\n".join(parts)
|
|
108
|
+
|
|
109
|
+
def is_context_message(value):
|
|
110
|
+
if not isinstance(value, str):
|
|
111
|
+
return True
|
|
112
|
+
return value.lstrip().startswith((
|
|
113
|
+
"<environment_context>",
|
|
114
|
+
"<permissions",
|
|
115
|
+
"<INSTRUCTIONS>",
|
|
116
|
+
"<collaboration_mode>",
|
|
117
|
+
"<apps_instructions>",
|
|
118
|
+
"<plugins_instructions>",
|
|
119
|
+
"<skills_instructions>",
|
|
120
|
+
"<recommended_plugins>",
|
|
121
|
+
"<in-app-browser-context",
|
|
122
|
+
"# AGENTS.md instructions",
|
|
123
|
+
"A previous agent produced",
|
|
124
|
+
"You are Codex",
|
|
125
|
+
))
|
|
126
|
+
|
|
127
|
+
def clean(value, limit=1200):
|
|
128
|
+
if not isinstance(value, str):
|
|
129
|
+
value = json.dumps(value, ensure_ascii=False)
|
|
130
|
+
return " ".join(value.replace("\x00", "").split())[:limit]
|
|
131
|
+
|
|
132
|
+
def snippets_for(value, hits):
|
|
133
|
+
normalized = " ".join(value.replace("\x00", "").split())
|
|
134
|
+
lowered = normalized.lower()
|
|
135
|
+
positions = [lowered.find(term) for term in hits if lowered.find(term) >= 0]
|
|
136
|
+
start = max(0, (min(positions) if positions else 0) - 150)
|
|
137
|
+
return normalized[start:start + 700]
|
|
138
|
+
|
|
139
|
+
def event_texts(event):
|
|
140
|
+
payload = event.get("payload", {})
|
|
141
|
+
if not isinstance(payload, dict):
|
|
142
|
+
return []
|
|
143
|
+
timestamp = event.get("timestamp")
|
|
144
|
+
event_type = event.get("type")
|
|
145
|
+
output = []
|
|
146
|
+
if event_type == "event_msg":
|
|
147
|
+
kind = payload.get("type")
|
|
148
|
+
if kind in ("user_message", "user_input"):
|
|
149
|
+
text = payload.get("message") or payload.get("text") or payload.get("content")
|
|
150
|
+
if isinstance(text, str) and not is_context_message(text):
|
|
151
|
+
output.append(("user", text, timestamp, 8))
|
|
152
|
+
elif kind in ("agent_message", "task_complete", "turn_complete", "task_completed"):
|
|
153
|
+
text = payload.get("message") or payload.get("text") or payload.get("last_agent_message")
|
|
154
|
+
if isinstance(text, str):
|
|
155
|
+
output.append(("assistant", text, timestamp, 6))
|
|
156
|
+
return output
|
|
157
|
+
if event_type != "response_item":
|
|
158
|
+
return output
|
|
159
|
+
kind = payload.get("type")
|
|
160
|
+
role = payload.get("role")
|
|
161
|
+
if kind == "message" and role in ("user", "assistant"):
|
|
162
|
+
text = text_from_content(payload.get("content"))
|
|
163
|
+
if text and (role != "user" or not is_context_message(text)):
|
|
164
|
+
output.append((role, text, timestamp, 8 if role == "user" else 6))
|
|
165
|
+
elif kind in ("function_call", "custom_tool_call"):
|
|
166
|
+
arguments = payload.get("arguments") or payload.get("input") or ""
|
|
167
|
+
output.append(("command", clean(arguments, 20000), timestamp, 7))
|
|
168
|
+
elif kind in ("function_call_output", "custom_tool_call_output"):
|
|
169
|
+
value = payload.get("output") or ""
|
|
170
|
+
output.append(("output", clean(value, 20000), timestamp, 3))
|
|
171
|
+
return output
|
|
172
|
+
|
|
173
|
+
records = []
|
|
174
|
+
for filename in matching_paths:
|
|
175
|
+
try:
|
|
176
|
+
with open(filename, "r", encoding="utf-8", errors="replace") as handle:
|
|
177
|
+
first_raw = handle.readline()
|
|
178
|
+
first_obj = json.loads(first_raw)
|
|
179
|
+
meta = (
|
|
180
|
+
first_obj.get("payload", {})
|
|
181
|
+
if first_obj.get("type") == "session_meta"
|
|
182
|
+
else {}
|
|
183
|
+
)
|
|
184
|
+
if not isinstance(meta, dict):
|
|
185
|
+
meta = {}
|
|
186
|
+
source = meta.get("source")
|
|
187
|
+
subagent = source.get("subagent", {}) if isinstance(source, dict) else {}
|
|
188
|
+
spawn = subagent.get("thread_spawn", {}) if isinstance(subagent, dict) else {}
|
|
189
|
+
record = {
|
|
190
|
+
"id": meta.get("id") or meta.get("session_id") or os.path.basename(filename),
|
|
191
|
+
"rootSessionId": meta.get("session_id") or meta.get("id") or "",
|
|
192
|
+
"parentThreadId": meta.get("parent_thread_id") or spawn.get("parent_thread_id") or "",
|
|
193
|
+
"agentPath": spawn.get("agent_path") or "",
|
|
194
|
+
"agentNickname": spawn.get("agent_nickname") or "",
|
|
195
|
+
"isSubagent": bool(spawn or meta.get("parent_thread_id")),
|
|
196
|
+
"cwd": meta.get("cwd") or "",
|
|
197
|
+
"startedAt": meta.get("timestamp") or first_obj.get("timestamp"),
|
|
198
|
+
"cliVersion": meta.get("cli_version") or "",
|
|
199
|
+
"path": filename,
|
|
200
|
+
"mtimeMs": int(os.path.getmtime(filename) * 1000),
|
|
201
|
+
"firstUser": "",
|
|
202
|
+
"lastUser": "",
|
|
203
|
+
"lastAssistant": "",
|
|
204
|
+
"lastAction": "",
|
|
205
|
+
"lastError": "",
|
|
206
|
+
"userMessages": [],
|
|
207
|
+
"assistantMessages": [],
|
|
208
|
+
"model": "",
|
|
209
|
+
"reasoningEffort": "",
|
|
210
|
+
"approvalPolicy": "",
|
|
211
|
+
"sandboxPolicy": "",
|
|
212
|
+
"collaborationMode": "",
|
|
213
|
+
"launches": [],
|
|
214
|
+
"account": None,
|
|
215
|
+
"tokenUsage": None,
|
|
216
|
+
"turnState": "idle",
|
|
217
|
+
"lastEventAt": first_obj.get("timestamp"),
|
|
218
|
+
}
|
|
219
|
+
matched = set()
|
|
220
|
+
evidence = []
|
|
221
|
+
term_weights = {}
|
|
222
|
+
best_event_hits = 0
|
|
223
|
+
best_event_weight = 0
|
|
224
|
+
proximity_bonus = 0
|
|
225
|
+
for raw in handle:
|
|
226
|
+
try:
|
|
227
|
+
event = json.loads(raw)
|
|
228
|
+
except Exception:
|
|
229
|
+
continue
|
|
230
|
+
for kind, text, timestamp, weight in event_texts(event):
|
|
231
|
+
lowered = text.lower()
|
|
232
|
+
hits = [term for term in terms if term and term in lowered]
|
|
233
|
+
if not hits:
|
|
234
|
+
continue
|
|
235
|
+
unique_hits = list(dict.fromkeys(hits))
|
|
236
|
+
matched.update(unique_hits)
|
|
237
|
+
for term in unique_hits:
|
|
238
|
+
term_weights[term] = max(
|
|
239
|
+
term_weights.get(term, 0),
|
|
240
|
+
weight * (0.6 if len(term) == 1 else 1),
|
|
241
|
+
)
|
|
242
|
+
best_event_hits = max(best_event_hits, len(unique_hits))
|
|
243
|
+
best_event_weight = max(
|
|
244
|
+
best_event_weight,
|
|
245
|
+
weight if len(unique_hits) == best_event_hits else 0,
|
|
246
|
+
)
|
|
247
|
+
positions = [lowered.find(term) for term in unique_hits]
|
|
248
|
+
if len(positions) >= 3:
|
|
249
|
+
span = max(positions) - min(positions)
|
|
250
|
+
proximity_bonus = max(
|
|
251
|
+
proximity_bonus,
|
|
252
|
+
80 if span <= 500 else 45 if span <= 1600 else 20,
|
|
253
|
+
)
|
|
254
|
+
snippet = snippets_for(text, hits)
|
|
255
|
+
if snippet and all(item["text"] != snippet for item in evidence):
|
|
256
|
+
evidence.append({
|
|
257
|
+
"kind": kind,
|
|
258
|
+
"timestamp": timestamp,
|
|
259
|
+
"text": snippet,
|
|
260
|
+
"terms": list(dict.fromkeys(hits)),
|
|
261
|
+
"weight": weight,
|
|
262
|
+
})
|
|
263
|
+
if kind == "user":
|
|
264
|
+
record["firstUser"] = record["firstUser"] or clean(text)
|
|
265
|
+
record["lastUser"] = clean(text)
|
|
266
|
+
record["userMessages"].append(clean(text))
|
|
267
|
+
record["userMessages"] = record["userMessages"][-4:]
|
|
268
|
+
elif kind == "assistant":
|
|
269
|
+
record["lastAssistant"] = clean(text)
|
|
270
|
+
record["assistantMessages"].append(clean(text))
|
|
271
|
+
record["assistantMessages"] = record["assistantMessages"][-4:]
|
|
272
|
+
elif kind == "command":
|
|
273
|
+
record["lastAction"] = clean(text)
|
|
274
|
+
if not matched:
|
|
275
|
+
continue
|
|
276
|
+
coverage = len(matched) / max(1, len(terms))
|
|
277
|
+
phrase_bonus = 0
|
|
278
|
+
ascii_phrase = " ".join(ascii_terms)
|
|
279
|
+
combined_evidence = " ".join(item["text"].lower() for item in evidence)
|
|
280
|
+
if len(ascii_terms) >= 2 and ascii_phrase in combined_evidence:
|
|
281
|
+
phrase_bonus = 18
|
|
282
|
+
score = (
|
|
283
|
+
sum(term_weights.values()) * 4
|
|
284
|
+
+ coverage * coverage * 55
|
|
285
|
+
+ best_event_hits * best_event_hits * 6
|
|
286
|
+
+ best_event_weight
|
|
287
|
+
+ proximity_bonus
|
|
288
|
+
+ phrase_bonus
|
|
289
|
+
)
|
|
290
|
+
evidence.sort(
|
|
291
|
+
key=lambda item: (len(item["terms"]), item["weight"]),
|
|
292
|
+
reverse=True,
|
|
293
|
+
)
|
|
294
|
+
records.append({
|
|
295
|
+
"rollout": record,
|
|
296
|
+
"score": round(score, 2),
|
|
297
|
+
"coverage": round(coverage, 3),
|
|
298
|
+
"bestEventHits": best_event_hits,
|
|
299
|
+
"matchedTerms": sorted(matched),
|
|
300
|
+
"evidence": [
|
|
301
|
+
{key: value for key, value in item.items() if key != "weight"}
|
|
302
|
+
for item in evidence[:6]
|
|
303
|
+
],
|
|
304
|
+
})
|
|
305
|
+
except Exception:
|
|
306
|
+
continue
|
|
307
|
+
|
|
308
|
+
records.sort(
|
|
309
|
+
key=lambda item: (
|
|
310
|
+
item["coverage"],
|
|
311
|
+
item["bestEventHits"],
|
|
312
|
+
item["score"],
|
|
313
|
+
item["rollout"]["mtimeMs"],
|
|
314
|
+
),
|
|
315
|
+
reverse=True,
|
|
316
|
+
)
|
|
317
|
+
print(json.dumps({
|
|
318
|
+
"terms": terms,
|
|
319
|
+
"filesScanned": len(matching_paths),
|
|
320
|
+
"totalFiles": len(all_paths),
|
|
321
|
+
"results": records[:result_limit],
|
|
322
|
+
}, ensure_ascii=False, separators=(",", ":")))
|
|
323
|
+
`;
|