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,324 @@
|
|
|
1
|
+
import { preserveSnapshotSessions } from "./session-cache-guard.js";
|
|
2
|
+
import { overviewDelta, applyOverviewDelta } from "./overview-delta.js";
|
|
3
|
+
const SNAPSHOT_SYNC_PROTOCOL = 1;
|
|
4
|
+
|
|
5
|
+
function compactRollout(rollout) {
|
|
6
|
+
if (!rollout) return null;
|
|
7
|
+
return {
|
|
8
|
+
id: rollout.id || "",
|
|
9
|
+
rootSessionId: rollout.rootSessionId || "",
|
|
10
|
+
parentThreadId: rollout.parentThreadId || "",
|
|
11
|
+
agentPath: rollout.agentPath || "",
|
|
12
|
+
agentNickname: rollout.agentNickname || "",
|
|
13
|
+
isSubagent: Boolean(rollout.isSubagent),
|
|
14
|
+
cwd: rollout.cwd || "",
|
|
15
|
+
startedAt: rollout.startedAt || "",
|
|
16
|
+
cliVersion: rollout.cliVersion || "",
|
|
17
|
+
path: rollout.path || "",
|
|
18
|
+
mtimeMs: rollout.mtimeMs || 0,
|
|
19
|
+
lastUser: rollout.lastUser || "",
|
|
20
|
+
lastAssistant: rollout.lastAssistant || "",
|
|
21
|
+
lastAction: rollout.lastAction || "",
|
|
22
|
+
lastError: rollout.lastError || "",
|
|
23
|
+
firstUser: rollout.firstUser || "",
|
|
24
|
+
userMessages: [],
|
|
25
|
+
assistantMessages: [],
|
|
26
|
+
model: rollout.model || "",
|
|
27
|
+
reasoningEffort: rollout.reasoningEffort || "",
|
|
28
|
+
approvalPolicy: rollout.approvalPolicy || "",
|
|
29
|
+
sandboxPolicy: rollout.sandboxPolicy || "",
|
|
30
|
+
collaborationMode: rollout.collaborationMode || "",
|
|
31
|
+
launches: [],
|
|
32
|
+
account: rollout.account || null,
|
|
33
|
+
tokenUsage: rollout.tokenUsage || null,
|
|
34
|
+
turnState: rollout.turnState || "idle",
|
|
35
|
+
lastEventAt: rollout.lastEventAt || "",
|
|
36
|
+
cacheRecovery: rollout.cacheRecovery,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function compactRemoteJob(job) {
|
|
41
|
+
return {
|
|
42
|
+
...job,
|
|
43
|
+
evidence: "",
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function compactHost(host) {
|
|
48
|
+
return {
|
|
49
|
+
...host,
|
|
50
|
+
processes: [],
|
|
51
|
+
sessions: (host.sessions || []).map(compactRollout),
|
|
52
|
+
agents: (host.agents || []).map((agent) => ({
|
|
53
|
+
...agent,
|
|
54
|
+
rollout: compactRollout(agent.rollout),
|
|
55
|
+
subagents: (agent.subagents || []).map(compactRollout),
|
|
56
|
+
remoteJobs: (agent.remoteJobs || []).map(compactRemoteJob),
|
|
57
|
+
})),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Remove resources that are either large, independently versioned, or already
|
|
63
|
+
* available through a dedicated detail endpoint. The overview remains a valid
|
|
64
|
+
* Snapshot once gpuUsage and submissionTracker are merged back in.
|
|
65
|
+
*/
|
|
66
|
+
export function compactSnapshotOverview(snapshot) {
|
|
67
|
+
const rest = { ...snapshot };
|
|
68
|
+
delete rest.gpuUsage;
|
|
69
|
+
delete rest.submissionTracker;
|
|
70
|
+
return {
|
|
71
|
+
...rest,
|
|
72
|
+
hosts: (snapshot.hosts || []).map(compactHost),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function splitSnapshotResources(snapshot) {
|
|
77
|
+
return {
|
|
78
|
+
overview: compactSnapshotOverview(snapshot),
|
|
79
|
+
gpuUsage: snapshot.gpuUsage || {
|
|
80
|
+
updatedAt: null,
|
|
81
|
+
retentionHours: 168,
|
|
82
|
+
episodes: [],
|
|
83
|
+
},
|
|
84
|
+
submissionTracker: snapshot.submissionTracker || {
|
|
85
|
+
scannedAt: null,
|
|
86
|
+
scanning: false,
|
|
87
|
+
items: [],
|
|
88
|
+
calls: [],
|
|
89
|
+
launches: [],
|
|
90
|
+
alerts: [],
|
|
91
|
+
hosts: [],
|
|
92
|
+
error: null,
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function episodeMap(gpuUsage) {
|
|
98
|
+
return new Map(
|
|
99
|
+
(gpuUsage?.episodes || []).map((episode) => [episode.id, episode]),
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function gpuMeta(gpuUsage) {
|
|
104
|
+
return {
|
|
105
|
+
updatedAt: gpuUsage?.updatedAt || null,
|
|
106
|
+
retentionHours: gpuUsage?.retentionHours || 168,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function fullPayload(epoch, revision, resources) {
|
|
111
|
+
return {
|
|
112
|
+
protocol: SNAPSHOT_SYNC_PROTOCOL,
|
|
113
|
+
epoch,
|
|
114
|
+
revision,
|
|
115
|
+
reset: true,
|
|
116
|
+
overview: resources.overview,
|
|
117
|
+
gpuUsage: resources.gpuUsage,
|
|
118
|
+
submissionTracker: resources.submissionTracker,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Keep a bounded, in-memory revision log. Old clients fall back to one reset;
|
|
124
|
+
* active clients receive only the compact overview and changed resource rows.
|
|
125
|
+
*/
|
|
126
|
+
export function createIncrementalSnapshotStore({
|
|
127
|
+
epoch,
|
|
128
|
+
maxHistory = 32,
|
|
129
|
+
maxHistoryBytes = 16 * 1024 * 1024,
|
|
130
|
+
} = {}) {
|
|
131
|
+
const storeEpoch = epoch || `${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
132
|
+
let revision = 0;
|
|
133
|
+
let current = null;
|
|
134
|
+
let submissionJson = "";
|
|
135
|
+
let gpuMetaJson = "";
|
|
136
|
+
let gpuEpisodeJson = new Map();
|
|
137
|
+
let history = [];
|
|
138
|
+
let historyBytes = 0;
|
|
139
|
+
|
|
140
|
+
function publish(snapshot) {
|
|
141
|
+
const next = splitSnapshotResources(snapshot);
|
|
142
|
+
const nextSubmissionJson = JSON.stringify(next.submissionTracker);
|
|
143
|
+
const nextGpuMeta = gpuMeta(next.gpuUsage);
|
|
144
|
+
const nextGpuMetaJson = JSON.stringify(nextGpuMeta);
|
|
145
|
+
const nextGpuEpisodes = episodeMap(next.gpuUsage);
|
|
146
|
+
const nextGpuEpisodeJson = new Map(
|
|
147
|
+
[...nextGpuEpisodes].map(([id, episode]) => [id, JSON.stringify(episode)]),
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
if (!current) {
|
|
151
|
+
revision = 1;
|
|
152
|
+
current = next;
|
|
153
|
+
submissionJson = nextSubmissionJson;
|
|
154
|
+
gpuMetaJson = nextGpuMetaJson;
|
|
155
|
+
gpuEpisodeJson = nextGpuEpisodeJson;
|
|
156
|
+
return revision;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const patch = {};
|
|
160
|
+
const overviewPatch = overviewDelta(current.overview, next.overview);
|
|
161
|
+
if (overviewPatch) patch.overviewDelta = overviewPatch;
|
|
162
|
+
if (nextSubmissionJson !== submissionJson) {
|
|
163
|
+
patch.submissionTracker = next.submissionTracker;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const upserts = [];
|
|
167
|
+
const removes = [];
|
|
168
|
+
for (const [id, episode] of nextGpuEpisodes) {
|
|
169
|
+
if (nextGpuEpisodeJson.get(id) !== gpuEpisodeJson.get(id)) {
|
|
170
|
+
upserts.push(episode);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
for (const id of gpuEpisodeJson.keys()) {
|
|
174
|
+
if (!nextGpuEpisodeJson.has(id)) removes.push(id);
|
|
175
|
+
}
|
|
176
|
+
if (
|
|
177
|
+
nextGpuMetaJson !== gpuMetaJson ||
|
|
178
|
+
upserts.length > 0 ||
|
|
179
|
+
removes.length > 0
|
|
180
|
+
) {
|
|
181
|
+
patch.gpuUsage = {
|
|
182
|
+
meta: nextGpuMeta,
|
|
183
|
+
upserts,
|
|
184
|
+
removes,
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
if (Object.keys(patch).length === 0) return revision;
|
|
189
|
+
|
|
190
|
+
revision += 1;
|
|
191
|
+
const entry = {
|
|
192
|
+
revision,
|
|
193
|
+
patch,
|
|
194
|
+
bytes: new TextEncoder().encode(JSON.stringify(patch)).byteLength,
|
|
195
|
+
};
|
|
196
|
+
history.push(entry);
|
|
197
|
+
historyBytes += entry.bytes;
|
|
198
|
+
while (
|
|
199
|
+
history.length > maxHistory ||
|
|
200
|
+
(historyBytes > maxHistoryBytes && history.length > 1)
|
|
201
|
+
) {
|
|
202
|
+
historyBytes -= history.shift().bytes;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
current = next;
|
|
206
|
+
submissionJson = nextSubmissionJson;
|
|
207
|
+
gpuMetaJson = nextGpuMetaJson;
|
|
208
|
+
gpuEpisodeJson = nextGpuEpisodeJson;
|
|
209
|
+
return revision;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function read({ clientEpoch, since, fieldDeltas = false } = {}) {
|
|
213
|
+
if (!current) return null;
|
|
214
|
+
const requestedRevision = Number(since);
|
|
215
|
+
const minimumBaseRevision = history.length
|
|
216
|
+
? history[0].revision - 1
|
|
217
|
+
: revision;
|
|
218
|
+
if (
|
|
219
|
+
clientEpoch !== storeEpoch ||
|
|
220
|
+
!Number.isInteger(requestedRevision) ||
|
|
221
|
+
requestedRevision < minimumBaseRevision ||
|
|
222
|
+
requestedRevision > revision
|
|
223
|
+
) {
|
|
224
|
+
return fullPayload(storeEpoch, revision, current);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
const patches = history.filter(
|
|
228
|
+
(entry) => entry.revision > requestedRevision,
|
|
229
|
+
);
|
|
230
|
+
const merged = {};
|
|
231
|
+
const gpuUpserts = new Map();
|
|
232
|
+
const gpuRemoves = new Set();
|
|
233
|
+
let gpuMetaPatch = null;
|
|
234
|
+
for (const { patch } of patches) {
|
|
235
|
+
if (patch.overviewDelta) {
|
|
236
|
+
if (fieldDeltas) (merged.overviewPatches ||= []).push(patch.overviewDelta);
|
|
237
|
+
else merged.overview = current.overview; // Existing clients retain the old contract.
|
|
238
|
+
}
|
|
239
|
+
if (patch.submissionTracker) {
|
|
240
|
+
merged.submissionTracker = patch.submissionTracker;
|
|
241
|
+
}
|
|
242
|
+
if (!patch.gpuUsage) continue;
|
|
243
|
+
gpuMetaPatch = patch.gpuUsage.meta;
|
|
244
|
+
for (const id of patch.gpuUsage.removes) {
|
|
245
|
+
gpuUpserts.delete(id);
|
|
246
|
+
gpuRemoves.add(id);
|
|
247
|
+
}
|
|
248
|
+
for (const episode of patch.gpuUsage.upserts) {
|
|
249
|
+
gpuRemoves.delete(episode.id);
|
|
250
|
+
gpuUpserts.set(episode.id, episode);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
if (gpuMetaPatch || gpuUpserts.size || gpuRemoves.size) {
|
|
254
|
+
merged.gpuUsage = {
|
|
255
|
+
meta: gpuMetaPatch || gpuMeta(current.gpuUsage),
|
|
256
|
+
upserts: [...gpuUpserts.values()],
|
|
257
|
+
removes: [...gpuRemoves],
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
return {
|
|
261
|
+
protocol: SNAPSHOT_SYNC_PROTOCOL,
|
|
262
|
+
epoch: storeEpoch,
|
|
263
|
+
fromRevision: requestedRevision,
|
|
264
|
+
revision,
|
|
265
|
+
reset: false,
|
|
266
|
+
...merged,
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
function info() {
|
|
271
|
+
return {
|
|
272
|
+
protocol: SNAPSHOT_SYNC_PROTOCOL,
|
|
273
|
+
epoch: storeEpoch,
|
|
274
|
+
revision,
|
|
275
|
+
retainedRevisions: history.length,
|
|
276
|
+
retainedBytes: historyBytes,
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
return { publish, read, info };
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/** Merge either a reset or a delta response into the browser's local cache. */
|
|
284
|
+
export function applySnapshotSync(previousSnapshot, payload) {
|
|
285
|
+
if (!payload || payload.protocol !== SNAPSHOT_SYNC_PROTOCOL) {
|
|
286
|
+
throw new Error("不支持的 Snapshot 增量协议");
|
|
287
|
+
}
|
|
288
|
+
if (payload.reset) {
|
|
289
|
+
if (!payload.overview || !payload.gpuUsage || !payload.submissionTracker) {
|
|
290
|
+
throw new Error("Snapshot reset 缺少完整资源");
|
|
291
|
+
}
|
|
292
|
+
return preserveSnapshotSessions(previousSnapshot, {
|
|
293
|
+
...payload.overview,
|
|
294
|
+
gpuUsage: payload.gpuUsage,
|
|
295
|
+
submissionTracker: payload.submissionTracker,
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
if (!previousSnapshot) {
|
|
299
|
+
throw new Error("本地 Snapshot 缓存缺失,无法应用增量");
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
let gpuUsage = previousSnapshot.gpuUsage;
|
|
303
|
+
if (payload.gpuUsage) {
|
|
304
|
+
const episodes = episodeMap(gpuUsage);
|
|
305
|
+
for (const id of payload.gpuUsage.removes || []) episodes.delete(id);
|
|
306
|
+
for (const episode of payload.gpuUsage.upserts || []) {
|
|
307
|
+
episodes.set(episode.id, episode);
|
|
308
|
+
}
|
|
309
|
+
gpuUsage = {
|
|
310
|
+
...gpuUsage,
|
|
311
|
+
...(payload.gpuUsage.meta || {}),
|
|
312
|
+
episodes: [...episodes.values()],
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
let overview = { ...previousSnapshot, ...(payload.overview || {}) };
|
|
317
|
+
for (const patch of payload.overviewPatches || []) overview = applyOverviewDelta(overview, patch);
|
|
318
|
+
return preserveSnapshotSessions(previousSnapshot, {
|
|
319
|
+
...overview,
|
|
320
|
+
gpuUsage,
|
|
321
|
+
submissionTracker:
|
|
322
|
+
payload.submissionTracker || previousSnapshot.submissionTracker,
|
|
323
|
+
});
|
|
324
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { projectIdentity } from "./projects.js";
|
|
2
|
+
/** Plans are proposals only. Parsing never dispatches a task. */
|
|
3
|
+
export function managerPlans(text) {
|
|
4
|
+
const blocks = String(text).matchAll(/```scope-plan\s*\n([\s\S]*?)```/g);
|
|
5
|
+
for (const block of blocks) {
|
|
6
|
+
try {
|
|
7
|
+
const value = JSON.parse(block[1]);
|
|
8
|
+
if (!Array.isArray(value)) continue;
|
|
9
|
+
return value
|
|
10
|
+
.slice(0, 8)
|
|
11
|
+
.filter(
|
|
12
|
+
(item) =>
|
|
13
|
+
item &&
|
|
14
|
+
["codex", "claude", "dsh"].includes(item.provider) &&
|
|
15
|
+
typeof item.host === "string" &&
|
|
16
|
+
typeof item.cwd === "string" &&
|
|
17
|
+
projectIdentity(item.host, item.cwd) &&
|
|
18
|
+
typeof item.prompt === "string" &&
|
|
19
|
+
item.prompt.trim() &&
|
|
20
|
+
item.prompt.length <= 16000,
|
|
21
|
+
)
|
|
22
|
+
.map((item) => ({
|
|
23
|
+
provider: item.provider,
|
|
24
|
+
host: item.host,
|
|
25
|
+
cwd: projectIdentity(item.host, item.cwd).cwd,
|
|
26
|
+
prompt: item.prompt,
|
|
27
|
+
gpuCount: Number.isInteger(item.gpuCount) ? item.gpuCount : 0,
|
|
28
|
+
minMemoryMiB: Number.isInteger(item.minMemoryMiB)
|
|
29
|
+
? item.minMemoryMiB
|
|
30
|
+
: 0,
|
|
31
|
+
}));
|
|
32
|
+
} catch {
|
|
33
|
+
/* Invalid model output remains visible as ordinary text. */
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return [];
|
|
37
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { remoteFileTargetFromMarkdownHref } from "./remote-links.js";
|
|
2
|
+
|
|
3
|
+
export function isImageSource(src) {
|
|
4
|
+
return typeof src === "string" && (/\.(png|jpe?g|gif|webp|svg|bmp|ico|avif)(?:[?#]|$)/i.test(src) || src.startsWith("/scope-image-api?"));
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function isVideoSource(src) {
|
|
8
|
+
return typeof src === "string" && (/\.(mp4|m4v|webm|ogv|mov)(?:[?#]|$)/i.test(src) || src.startsWith("/scope-video-api?"));
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function markdownVideoSource(src, host, cwd) {
|
|
12
|
+
if (!isVideoSource(src)) return "";
|
|
13
|
+
return markdownImageSource(src, host, cwd);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function markdownImageSource(src, host, cwd) {
|
|
17
|
+
if (typeof src !== "string" || !src) return "";
|
|
18
|
+
if (/^https?:\/\//i.test(src)) return src;
|
|
19
|
+
const target = remoteFileTargetFromMarkdownHref(src, cwd);
|
|
20
|
+
if (!host || !target) return "";
|
|
21
|
+
return `/${isVideoSource(src) ? "scope-video-api" : "scope-image-api"}?${new URLSearchParams({ host, path: target.path })}`;
|
|
22
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
const CODE_TOKEN_PREFIX = "\uE000SCOPE_CODE_";
|
|
2
|
+
const CODE_TOKEN_SUFFIX = "\uE001";
|
|
3
|
+
|
|
4
|
+
function protectCode(source) {
|
|
5
|
+
const protectedCode = [];
|
|
6
|
+
const protect = (value) => {
|
|
7
|
+
const index = protectedCode.push(value) - 1;
|
|
8
|
+
return `${CODE_TOKEN_PREFIX}${index}${CODE_TOKEN_SUFFIX}`;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
// Shield fenced blocks first, then inline code spans. LaTeX-looking examples in
|
|
12
|
+
// code must stay literal instead of turning into rendered equations.
|
|
13
|
+
const withoutFences = source.replace(
|
|
14
|
+
/(^|\n)[ \t]{0,3}(`{3,}|~{3,})[^\n]*(?:\n[\s\S]*?\n[ \t]{0,3}\2[ \t]*(?=\n|$)|$)/g,
|
|
15
|
+
protect,
|
|
16
|
+
);
|
|
17
|
+
const withoutCode = withoutFences.replace(/(`+)([\s\S]*?)\1/g, protect);
|
|
18
|
+
|
|
19
|
+
return {
|
|
20
|
+
value: withoutCode,
|
|
21
|
+
restore(value) {
|
|
22
|
+
return value.replace(
|
|
23
|
+
new RegExp(`${CODE_TOKEN_PREFIX}(\\d+)${CODE_TOKEN_SUFFIX}`, "g"),
|
|
24
|
+
(_match, index) => protectedCode[Number(index)] ?? "",
|
|
25
|
+
);
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function normalizeMathEnvironments(value) {
|
|
31
|
+
return value.replace(
|
|
32
|
+
/(?<!\\)\\begin\{(equation\*?|displaymath|align\*?|aligned|gather\*?|gathered|multline\*?|split)\}([\s\S]*?)\\end\{\1\}/g,
|
|
33
|
+
(_match, environment, body) => {
|
|
34
|
+
const content = body.trim();
|
|
35
|
+
let displayContent = content;
|
|
36
|
+
|
|
37
|
+
if (/^align\*?$/.test(environment) || environment === "aligned" || environment === "split") {
|
|
38
|
+
displayContent = `\\begin{aligned}\n${content}\n\\end{aligned}`;
|
|
39
|
+
} else if (/^gather\*?$/.test(environment) || environment === "gathered") {
|
|
40
|
+
displayContent = `\\begin{gathered}\n${content}\n\\end{gathered}`;
|
|
41
|
+
} else if (/^multline\*?$/.test(environment)) {
|
|
42
|
+
displayContent = `\\begin{aligned}\n${content}\n\\end{aligned}`;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return `\n\n$$\n${displayContent}\n$$\n\n`;
|
|
46
|
+
},
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Make the LaTeX delimiters commonly emitted by Codex compatible with
|
|
52
|
+
* remark-math, while leaving fenced and inline code untouched.
|
|
53
|
+
*
|
|
54
|
+
* @param {string} source
|
|
55
|
+
* @returns {string}
|
|
56
|
+
*/
|
|
57
|
+
export function normalizeLatexDelimiters(source) {
|
|
58
|
+
if (!source || !source.includes("\\")) {
|
|
59
|
+
return source;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const protectedSource = protectCode(source);
|
|
63
|
+
let normalized = normalizeMathEnvironments(protectedSource.value);
|
|
64
|
+
|
|
65
|
+
normalized = normalized.replace(
|
|
66
|
+
/(?<!\\)\\\[([\s\S]*?)(?<!\\)\\\]/g,
|
|
67
|
+
(_match, body) => `\n\n$$\n${body.trim()}\n$$\n\n`,
|
|
68
|
+
);
|
|
69
|
+
normalized = normalized.replace(
|
|
70
|
+
/(?<!\\)\\\(([\s\S]*?)(?<!\\)\\\)/g,
|
|
71
|
+
(_match, body) => `$${body.trim()}$`,
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
return protectedSource.restore(normalized);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function basenameFromFileUrl(uri) {
|
|
78
|
+
const withoutHash = uri.split("#", 1)[0].split("?", 1)[0];
|
|
79
|
+
const raw = withoutHash.split("/").filter(Boolean).pop() || uri;
|
|
80
|
+
try {
|
|
81
|
+
return decodeURIComponent(raw);
|
|
82
|
+
} catch {
|
|
83
|
+
return raw;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Normalize AGY / HTML-style file:// media and links outside code blocks so
|
|
89
|
+
* react-markdown parses spaces in file:// targets, simple <img>/<video> tags,
|
|
90
|
+
* and bare file:/// links cleanly through SCOPE's sanitized media pipeline.
|
|
91
|
+
*
|
|
92
|
+
* @param {string} source
|
|
93
|
+
* @returns {string}
|
|
94
|
+
*/
|
|
95
|
+
export function normalizeMarkdownMedia(source) {
|
|
96
|
+
if (
|
|
97
|
+
!source ||
|
|
98
|
+
(!source.includes("file:") && !/<(?:img|video)\b/i.test(source))
|
|
99
|
+
) {
|
|
100
|
+
return source;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const protectedSource = protectCode(source);
|
|
104
|
+
let text = protectedSource.value;
|
|
105
|
+
|
|
106
|
+
// Convert simple <img src="..."> and <video src="..."> tags into safe Markdown embeds.
|
|
107
|
+
text = text.replace(
|
|
108
|
+
/<(img|video)\b([^>]*?)\/?>\s*(?:<\/video>)?/gi,
|
|
109
|
+
(match, tag, attrs) => {
|
|
110
|
+
const srcMatch = attrs.match(/\bsrc\s*=\s*(?:"([^"]+)"|'([^']+)')/i);
|
|
111
|
+
const src = (srcMatch?.[1] || srcMatch?.[2] || "").trim();
|
|
112
|
+
if (!src) return match;
|
|
113
|
+
const altMatch = attrs.match(/\balt\s*=\s*(?:"([^"]*)"|'([^']*)')/i);
|
|
114
|
+
const label = (altMatch?.[1] || altMatch?.[2] || basenameFromFileUrl(src) || tag).trim();
|
|
115
|
+
return ``;
|
|
116
|
+
},
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
// Wrap unencoded file:// targets containing spaces inside Markdown links/images
|
|
120
|
+
// as angle-bracketed destinations:  -> 
|
|
121
|
+
text = text.replace(
|
|
122
|
+
/(!?\[[^\]]*\]\()(file:\/\/\/?[^)\r\n<>]*[ \t][^)\r\n<>]*)(\))/gi,
|
|
123
|
+
(_m, open, target, close) => `${open}<${target.trim()}>${close}`,
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
// Protect existing Markdown links/images before autolinking bare file:/// URIs.
|
|
127
|
+
const links = [];
|
|
128
|
+
text = text.replace(
|
|
129
|
+
/!?\[[^\]]*\]\((?:<[^>\r\n]+>|[^)\r\n]+)\)/g,
|
|
130
|
+
(match) => `\uE002SCOPE_LINK_${links.push(match) - 1}\uE003`,
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
// Autolink bare file:///... URLs (common in Antigravity / agent prose).
|
|
134
|
+
text = text.replace(
|
|
135
|
+
/(^|[\s(>\[(【::])(file:\/\/\/[^\s<>)"'\])】]+)/gi,
|
|
136
|
+
(_match, prefix, rawUri) => {
|
|
137
|
+
const trailing = rawUri.match(/[.,;:!?。,;:!?]+$/)?.[0] || "";
|
|
138
|
+
const uri = trailing ? rawUri.slice(0, -trailing.length) : rawUri;
|
|
139
|
+
const label = basenameFromFileUrl(uri);
|
|
140
|
+
const isMedia = /\.(?:png|jpe?g|gif|webp|svg|bmp|ico|avif|mp4|m4v|webm|ogv|mov)(?:[?#]|$)/i.test(uri);
|
|
141
|
+
return `${prefix}${isMedia ? "!" : ""}[${label}](<${uri}>)${trailing}`;
|
|
142
|
+
},
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
text = text.replace(
|
|
146
|
+
/\uE002SCOPE_LINK_(\d+)\uE003/g,
|
|
147
|
+
(_match, idx) => links[Number(idx)] ?? "",
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
return protectedSource.restore(text);
|
|
151
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { defaultUrlTransform } from "react-markdown";
|
|
2
|
+
import { markdownImageSource, markdownVideoSource } from "./markdown-images.js";
|
|
3
|
+
import { remoteFileTargetFromMarkdownHref } from "./remote-links.js";
|
|
4
|
+
|
|
5
|
+
// File hrefs must reach RemoteFileLink before react-markdown strips file: URLs.
|
|
6
|
+
// Without a session host, keep the default sanitizer (never open browser-local files).
|
|
7
|
+
export function markdownUrlTransform(url, key, host, cwd) {
|
|
8
|
+
if (key === "src") return markdownImageSource(url, host, cwd);
|
|
9
|
+
const video = markdownVideoSource(url, host, cwd);
|
|
10
|
+
if (video) return video;
|
|
11
|
+
if (host && remoteFileTargetFromMarkdownHref(url, cwd)) return url;
|
|
12
|
+
return defaultUrlTransform(url);
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const EFFORT_LABELS = {
|
|
2
|
+
none: "无",
|
|
3
|
+
minimal: "最少",
|
|
4
|
+
low: "低",
|
|
5
|
+
medium: "中",
|
|
6
|
+
high: "高",
|
|
7
|
+
xhigh: "极高",
|
|
8
|
+
max: "最大",
|
|
9
|
+
ultra: "超高",
|
|
10
|
+
};
|
|
11
|
+
export function compatibleEffort(model, effort) {
|
|
12
|
+
return model?.supportedReasoningEfforts?.includes(effort) ? effort : "";
|
|
13
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export type NativeHistoryEntry = {
|
|
2
|
+
id?: string;
|
|
3
|
+
role: string;
|
|
4
|
+
text: string;
|
|
5
|
+
activity?: string;
|
|
6
|
+
title?: string;
|
|
7
|
+
createdAt?: string;
|
|
8
|
+
truncated?: boolean;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export type SpoolTurnEntry = {
|
|
12
|
+
id: string;
|
|
13
|
+
prompt: string;
|
|
14
|
+
text?: string;
|
|
15
|
+
status: string;
|
|
16
|
+
createdAt?: number;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export function historyContainsUserTurn(
|
|
20
|
+
messages: NativeHistoryEntry[],
|
|
21
|
+
turn: SpoolTurnEntry,
|
|
22
|
+
): boolean;
|
|
23
|
+
|
|
24
|
+
export function historyContainsTurn(
|
|
25
|
+
messages: NativeHistoryEntry[],
|
|
26
|
+
turn: SpoolTurnEntry,
|
|
27
|
+
): boolean;
|
|
28
|
+
|
|
29
|
+
export function visibleSpoolTurns<T extends SpoolTurnEntry>(
|
|
30
|
+
messages: NativeHistoryEntry[],
|
|
31
|
+
turns: T[],
|
|
32
|
+
): T[];
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
const ATTACHMENT_PREVIEW_RE = /\n*\s*\[附件:\s*[^\]]*\]\s*$/;
|
|
2
|
+
const ATTACHMENT_MANIFEST_RE = /\n*\[SCOPE 网页附件:[\s\S]*$/;
|
|
3
|
+
const EMPTY_ATTACHMENT_PROMPT = "请查看并处理本条消息附带的文件。";
|
|
4
|
+
|
|
5
|
+
function stripAttachmentEnvelope(text, pattern) {
|
|
6
|
+
const source = typeof text === "string" ? text : "";
|
|
7
|
+
const matched = pattern.test(source);
|
|
8
|
+
return {
|
|
9
|
+
text: source.replace(pattern, "").trim(),
|
|
10
|
+
hasAttachment: matched,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function promptsMatch(messageText, turnPrompt) {
|
|
15
|
+
const msg = stripAttachmentEnvelope(messageText, ATTACHMENT_MANIFEST_RE);
|
|
16
|
+
const turn = stripAttachmentEnvelope(turnPrompt, ATTACHMENT_PREVIEW_RE);
|
|
17
|
+
if (msg.text === turn.text) return true;
|
|
18
|
+
if (msg.hasAttachment || turn.hasAttachment) {
|
|
19
|
+
if (
|
|
20
|
+
(turn.text === "" && msg.text === EMPTY_ATTACHMENT_PROMPT) ||
|
|
21
|
+
(msg.text === "" && turn.text === EMPTY_ATTACHMENT_PROMPT)
|
|
22
|
+
) {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Match a spool turn against its corresponding native history user entry. */
|
|
30
|
+
export function historyContainsUserTurn(messages, turn) {
|
|
31
|
+
if (!Array.isArray(messages) || !turn?.prompt) return false;
|
|
32
|
+
for (let index = messages.length - 1; index >= 0; index--) {
|
|
33
|
+
const message = messages[index];
|
|
34
|
+
if (
|
|
35
|
+
message.role !== "user" ||
|
|
36
|
+
!promptsMatch(message.text || "", turn.prompt || "")
|
|
37
|
+
)
|
|
38
|
+
continue;
|
|
39
|
+
const at = Date.parse(message.createdAt || "");
|
|
40
|
+
if (!Number.isFinite(at) || !turn.createdAt || at < turn.createdAt - 2000)
|
|
41
|
+
continue;
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Hide a spool turn only when native history contains that exact user/reply pair. */
|
|
48
|
+
export function historyContainsTurn(messages, turn) {
|
|
49
|
+
if (!Array.isArray(messages) || turn?.status !== "completed" || !turn.text?.trim())
|
|
50
|
+
return false;
|
|
51
|
+
for (let index = messages.length - 1; index >= 0; index--) {
|
|
52
|
+
const message = messages[index];
|
|
53
|
+
if (
|
|
54
|
+
message.role !== "user" ||
|
|
55
|
+
!promptsMatch(message.text || "", turn.prompt || "")
|
|
56
|
+
)
|
|
57
|
+
continue;
|
|
58
|
+
const at = Date.parse(message.createdAt || "");
|
|
59
|
+
if (!Number.isFinite(at) || !turn.createdAt || at < turn.createdAt - 2000)
|
|
60
|
+
continue;
|
|
61
|
+
for (
|
|
62
|
+
let next = index + 1;
|
|
63
|
+
next < messages.length && messages[next].role !== "user";
|
|
64
|
+
next++
|
|
65
|
+
) {
|
|
66
|
+
if (
|
|
67
|
+
messages[next].role === "assistant" &&
|
|
68
|
+
messages[next].text.trim() === turn.text.trim()
|
|
69
|
+
)
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** Keep only unresolved spool turns after the latest native-history-matched turn. */
|
|
77
|
+
export function visibleSpoolTurns(messages, turns) {
|
|
78
|
+
if (!Array.isArray(turns)) return [];
|
|
79
|
+
if (!Array.isArray(messages) || messages.length === 0) return turns;
|
|
80
|
+
const matched = turns.map((turn) => historyContainsTurn(messages, turn));
|
|
81
|
+
const lastMatchedIndex = matched.lastIndexOf(true);
|
|
82
|
+
return turns.filter((turn, index) => {
|
|
83
|
+
if (matched[index]) return false;
|
|
84
|
+
if (index < lastMatchedIndex) return false;
|
|
85
|
+
if (
|
|
86
|
+
turn.status === "stopped" &&
|
|
87
|
+
index < turns.length - 1 &&
|
|
88
|
+
historyContainsUserTurn(messages, turn)
|
|
89
|
+
) {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
return true;
|
|
93
|
+
});
|
|
94
|
+
}
|