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.
Files changed (357) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/LICENSE +21 -0
  3. package/README.md +174 -2
  4. package/README.zh-CN.md +175 -0
  5. package/bin/scope.mjs +111 -0
  6. package/bridge/account-quotas.mjs +881 -0
  7. package/bridge/agent-email-relay.mjs +160 -0
  8. package/bridge/app-server-client.mjs +2522 -0
  9. package/bridge/app-server-websocket-transport.mjs +219 -0
  10. package/bridge/archive/routes.mjs +19 -0
  11. package/bridge/archive/service.mjs +130 -0
  12. package/bridge/archive/thread-lifecycle.mjs +52 -0
  13. package/bridge/attachment-store.mjs +184 -0
  14. package/bridge/auth-profile-failover.mjs +58 -0
  15. package/bridge/auth-profile-manager.mjs +215 -0
  16. package/bridge/capacity-recovery.mjs +90 -0
  17. package/bridge/codex-upgrade.mjs +150 -0
  18. package/bridge/deployment-profile.mjs +64 -0
  19. package/bridge/email-notifier.mjs +616 -0
  20. package/bridge/gpu-usage-history.mjs +322 -0
  21. package/bridge/host-session-restart.mjs +35 -0
  22. package/bridge/http.mjs +69 -0
  23. package/bridge/idle-sessions.mjs +185 -0
  24. package/bridge/inventory-scanner.mjs +517 -0
  25. package/bridge/local/dialogue.mjs +150 -0
  26. package/bridge/local/directories.mjs +40 -0
  27. package/bridge/local/executable.mjs +29 -0
  28. package/bridge/local/history.mjs +21 -0
  29. package/bridge/local/python-probe.mjs +35 -0
  30. package/bridge/local/runtime.mjs +188 -0
  31. package/bridge/local/transport.mjs +70 -0
  32. package/bridge/maintenance/install-command.mjs +141 -0
  33. package/bridge/maintenance/routes.mjs +21 -0
  34. package/bridge/maintenance/service.mjs +175 -0
  35. package/bridge/model-catalog.mjs +21 -0
  36. package/bridge/persistent-home-guard.mjs +6 -0
  37. package/bridge/plugins/aliyun-dlc/index.mjs +47 -0
  38. package/bridge/plugins/aliyun-dlc/manifest.mjs +12 -0
  39. package/bridge/plugins/aliyun-dlc/monitor.mjs +236 -0
  40. package/bridge/plugins/aliyun-dlc/probe.mjs +701 -0
  41. package/bridge/plugins/config-store.mjs +35 -0
  42. package/bridge/plugins/external.mjs +87 -0
  43. package/bridge/plugins/package.mjs +96 -0
  44. package/bridge/plugins/registry.mjs +37 -0
  45. package/bridge/plugins/routes.mjs +27 -0
  46. package/bridge/private-gateway.mjs +371 -0
  47. package/bridge/private-start.mjs +22 -0
  48. package/bridge/probes/app-server-handoff-probe.mjs +89 -0
  49. package/bridge/probes/app-server-writer-probe.mjs +72 -0
  50. package/bridge/probes/assistant-search-probe.mjs +323 -0
  51. package/bridge/probes/dialogue-probe.mjs +464 -0
  52. package/bridge/probes/history-probe.mjs +347 -0
  53. package/bridge/probes/index.mjs +15 -0
  54. package/bridge/probes/new-session-preflight.mjs +16 -0
  55. package/bridge/probes/profile-cancel-probe.mjs +19 -0
  56. package/bridge/probes/profile-delete-probe.mjs +28 -0
  57. package/bridge/probes/profile-list-probe.mjs +117 -0
  58. package/bridge/probes/profile-write-probe.mjs +111 -0
  59. package/bridge/probes/raw-context-probe.mjs +53 -0
  60. package/bridge/probes/remote-probe.mjs +636 -0
  61. package/bridge/probes/submission-probe.mjs +2 -0
  62. package/bridge/probes/takeover-probe.mjs +328 -0
  63. package/bridge/probes/vscode-open-preflight.mjs +23 -0
  64. package/bridge/profile-capacity-policy.mjs +14 -0
  65. package/bridge/providers/acp-forms.py +49 -0
  66. package/bridge/providers/antigravity-interactive.mjs +14 -0
  67. package/bridge/providers/antigravity-interactive.py +349 -0
  68. package/bridge/providers/claude-capabilities.py +52 -0
  69. package/bridge/providers/claude-interactive.mjs +14 -0
  70. package/bridge/providers/claude-interactive.py +341 -0
  71. package/bridge/providers/cli-command.mjs +103 -0
  72. package/bridge/providers/codex-workbench.mjs +164 -0
  73. package/bridge/providers/conversation-routes.mjs +28 -0
  74. package/bridge/providers/conversations.mjs +231 -0
  75. package/bridge/providers/native-commands.mjs +48 -0
  76. package/bridge/providers/native-commands.py +38 -0
  77. package/bridge/providers/native-models.mjs +129 -0
  78. package/bridge/providers/native-session-state.mjs +14 -0
  79. package/bridge/providers/native-session-state.py +96 -0
  80. package/bridge/providers/remote-cli.mjs +75 -0
  81. package/bridge/providers/remote-job.py +130 -0
  82. package/bridge/remote-app-server-command.mjs +203 -0
  83. package/bridge/remote-bootstrap/routes.mjs +51 -0
  84. package/bridge/remote-bootstrap/scope-protocol.mjs +125 -0
  85. package/bridge/remote-bootstrap/service.mjs +597 -0
  86. package/bridge/remote-bootstrap/tunnels.mjs +347 -0
  87. package/bridge/remote-directory-listing.mjs +148 -0
  88. package/bridge/remote-images.mjs +140 -0
  89. package/bridge/remote-profile-home.mjs +39 -0
  90. package/bridge/remote-rollout-locks.mjs +31 -0
  91. package/bridge/remote-videos.mjs +129 -0
  92. package/bridge/research/insights.mjs +522 -0
  93. package/bridge/research/scan-host.mjs +18 -0
  94. package/bridge/rollout-summary.mjs +159 -0
  95. package/bridge/routes/accounts.mjs +326 -0
  96. package/bridge/routes/dialogue.mjs +120 -0
  97. package/bridge/routes/email.mjs +50 -0
  98. package/bridge/routes/management.mjs +291 -0
  99. package/bridge/routes/models.mjs +312 -0
  100. package/bridge/routes/runtime.mjs +82 -0
  101. package/bridge/routes/session-commands.mjs +12 -0
  102. package/bridge/routes/session-delivery.mjs +328 -0
  103. package/bridge/routes/session-lifecycle.mjs +839 -0
  104. package/bridge/routes/system.mjs +289 -0
  105. package/bridge/server.mjs +3332 -0
  106. package/bridge/session-attachments.mjs +150 -0
  107. package/bridge/session-cache-archive.mjs +22 -0
  108. package/bridge/session-catalog/agy-history.py +249 -0
  109. package/bridge/session-catalog/catalog.mjs +93 -0
  110. package/bridge/session-catalog/probe.py +331 -0
  111. package/bridge/session-catalog/routes.mjs +28 -0
  112. package/bridge/session-profiles.mjs +115 -0
  113. package/bridge/shared-start.mjs +22 -0
  114. package/bridge/start.mjs +205 -0
  115. package/bridge/state-persistence.mjs +397 -0
  116. package/bridge/submissions/settings.mjs +50 -0
  117. package/bridge/terminal-gateway.mjs +171 -0
  118. package/bridge/tmux-delivery.mjs +390 -0
  119. package/bridge/tmux-session-control.mjs +29 -0
  120. package/bridge/transport/ssh-command.mjs +119 -0
  121. package/bridge/ui-server.mjs +257 -0
  122. package/bridge/vscode-opener.mjs +157 -0
  123. package/bridge/web-terminal.mjs +52 -0
  124. package/bridge/workbench/conversation-routes.mjs +31 -0
  125. package/bridge/workbench/directory-probe.mjs +41 -0
  126. package/bridge/workbench/directory-routes.mjs +112 -0
  127. package/bridge/workbench/manager-context.mjs +51 -0
  128. package/bridge/workbench/routes.mjs +40 -0
  129. package/bridge/workbench/scheduler.mjs +131 -0
  130. package/bridge/workbench/service.mjs +301 -0
  131. package/bridge/workbench/store.mjs +64 -0
  132. package/bridge/workbench/task-archive.mjs +46 -0
  133. package/dist/client/.assetsignore +2 -0
  134. package/dist/client/.vite/manifest.json +366 -0
  135. package/dist/client/_headers +3 -0
  136. package/dist/client/agents/LICENSE.lobe-icons +21 -0
  137. package/dist/client/agents/README.md +14 -0
  138. package/dist/client/agents/antigravity.svg +39 -0
  139. package/dist/client/agents/claude.svg +1 -0
  140. package/dist/client/agents/codex.svg +1 -0
  141. package/dist/client/agents/dsh.svg +4 -0
  142. package/dist/client/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
  143. package/dist/client/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
  144. package/dist/client/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
  145. package/dist/client/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
  146. package/dist/client/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
  147. package/dist/client/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
  148. package/dist/client/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
  149. package/dist/client/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
  150. package/dist/client/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
  151. package/dist/client/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
  152. package/dist/client/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
  153. package/dist/client/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
  154. package/dist/client/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
  155. package/dist/client/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
  156. package/dist/client/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
  157. package/dist/client/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
  158. package/dist/client/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
  159. package/dist/client/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
  160. package/dist/client/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
  161. package/dist/client/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
  162. package/dist/client/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
  163. package/dist/client/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
  164. package/dist/client/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
  165. package/dist/client/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
  166. package/dist/client/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
  167. package/dist/client/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
  168. package/dist/client/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
  169. package/dist/client/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
  170. package/dist/client/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
  171. package/dist/client/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
  172. package/dist/client/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
  173. package/dist/client/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
  174. package/dist/client/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
  175. package/dist/client/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
  176. package/dist/client/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
  177. package/dist/client/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
  178. package/dist/client/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
  179. package/dist/client/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
  180. package/dist/client/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
  181. package/dist/client/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
  182. package/dist/client/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
  183. package/dist/client/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
  184. package/dist/client/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
  185. package/dist/client/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
  186. package/dist/client/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
  187. package/dist/client/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
  188. package/dist/client/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
  189. package/dist/client/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
  190. package/dist/client/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
  191. package/dist/client/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
  192. package/dist/client/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
  193. package/dist/client/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
  194. package/dist/client/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
  195. package/dist/client/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
  196. package/dist/client/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
  197. package/dist/client/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
  198. package/dist/client/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
  199. package/dist/client/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
  200. package/dist/client/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
  201. package/dist/client/assets/_vinext_fonts/geist-8ac0455e797f/geist-001175b1.woff2 +0 -0
  202. package/dist/client/assets/_vinext_fonts/geist-8ac0455e797f/geist-52306abf.woff2 +0 -0
  203. package/dist/client/assets/_vinext_fonts/geist-8ac0455e797f/geist-875ccdd4.woff2 +0 -0
  204. package/dist/client/assets/_vinext_fonts/geist-8ac0455e797f/geist-98bbbccb.woff2 +0 -0
  205. package/dist/client/assets/_vinext_fonts/geist-8ac0455e797f/geist-ff2310f5.woff2 +0 -0
  206. package/dist/client/assets/_vinext_fonts/geist-mono-00e989178794/geist-mono-013b2f2f.woff2 +0 -0
  207. package/dist/client/assets/_vinext_fonts/geist-mono-00e989178794/geist-mono-0638449e.woff2 +0 -0
  208. package/dist/client/assets/_vinext_fonts/geist-mono-00e989178794/geist-mono-44745446.woff2 +0 -0
  209. package/dist/client/assets/_vinext_fonts/geist-mono-00e989178794/geist-mono-44e03052.woff2 +0 -0
  210. package/dist/client/assets/_vinext_fonts/geist-mono-00e989178794/geist-mono-971fb274.woff2 +0 -0
  211. package/dist/client/assets/_vinext_fonts/geist-mono-00e989178794/geist-mono-f6b33328.woff2 +0 -0
  212. package/dist/client/assets/addon-fit-BZbxZs2G.js +1 -0
  213. package/dist/client/assets/framework-CXnKph_e.js +9 -0
  214. package/dist/client/assets/index-CNnP2Ses.css +2 -0
  215. package/dist/client/assets/index-Enu1x0PS.js +3 -0
  216. package/dist/client/assets/layout-segment-context-CmJzExWq.js +1 -0
  217. package/dist/client/assets/page-COBv6VWj.css +1 -0
  218. package/dist/client/assets/page-DVjU6VG_.js +550 -0
  219. package/dist/client/assets/rolldown-runtime-S-ySWqyJ.js +1 -0
  220. package/dist/client/assets/xterm-BBgU7shl.js +36 -0
  221. package/dist/client/favicon.svg +6 -0
  222. package/dist/client/file.svg +1 -0
  223. package/dist/client/globe.svg +1 -0
  224. package/dist/client/og.png +0 -0
  225. package/dist/client/scope-logo.svg +11 -0
  226. package/dist/client/window.svg +1 -0
  227. package/dist/server/.vite/manifest.json +14 -0
  228. package/dist/server/__vite_rsc_assets_manifest.js +49 -0
  229. package/dist/server/assets/index-CNnP2Ses.css +2 -0
  230. package/dist/server/image-config.json +1 -0
  231. package/dist/server/index.js +15201 -0
  232. package/dist/server/ssr/__vite_rsc_assets_manifest.js +49 -0
  233. package/dist/server/ssr/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
  234. package/dist/server/ssr/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
  235. package/dist/server/ssr/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
  236. package/dist/server/ssr/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
  237. package/dist/server/ssr/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
  238. package/dist/server/ssr/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
  239. package/dist/server/ssr/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
  240. package/dist/server/ssr/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
  241. package/dist/server/ssr/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
  242. package/dist/server/ssr/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
  243. package/dist/server/ssr/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
  244. package/dist/server/ssr/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
  245. package/dist/server/ssr/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
  246. package/dist/server/ssr/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
  247. package/dist/server/ssr/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
  248. package/dist/server/ssr/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
  249. package/dist/server/ssr/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
  250. package/dist/server/ssr/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
  251. package/dist/server/ssr/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
  252. package/dist/server/ssr/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
  253. package/dist/server/ssr/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
  254. package/dist/server/ssr/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
  255. package/dist/server/ssr/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
  256. package/dist/server/ssr/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
  257. package/dist/server/ssr/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
  258. package/dist/server/ssr/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
  259. package/dist/server/ssr/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
  260. package/dist/server/ssr/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
  261. package/dist/server/ssr/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
  262. package/dist/server/ssr/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
  263. package/dist/server/ssr/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
  264. package/dist/server/ssr/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
  265. package/dist/server/ssr/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
  266. package/dist/server/ssr/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
  267. package/dist/server/ssr/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
  268. package/dist/server/ssr/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
  269. package/dist/server/ssr/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
  270. package/dist/server/ssr/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
  271. package/dist/server/ssr/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
  272. package/dist/server/ssr/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
  273. package/dist/server/ssr/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
  274. package/dist/server/ssr/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
  275. package/dist/server/ssr/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
  276. package/dist/server/ssr/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
  277. package/dist/server/ssr/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
  278. package/dist/server/ssr/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
  279. package/dist/server/ssr/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
  280. package/dist/server/ssr/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
  281. package/dist/server/ssr/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
  282. package/dist/server/ssr/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
  283. package/dist/server/ssr/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
  284. package/dist/server/ssr/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
  285. package/dist/server/ssr/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
  286. package/dist/server/ssr/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
  287. package/dist/server/ssr/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
  288. package/dist/server/ssr/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
  289. package/dist/server/ssr/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
  290. package/dist/server/ssr/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
  291. package/dist/server/ssr/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
  292. package/dist/server/ssr/assets/addon-fit-C09Jj0_f.js +42 -0
  293. package/dist/server/ssr/assets/error-boundary-Dd2ZYXA8.js +277 -0
  294. package/dist/server/ssr/assets/layout-segment-context-HV_Mvyzf.js +37 -0
  295. package/dist/server/ssr/assets/page-COBv6VWj.css +1 -0
  296. package/dist/server/ssr/assets/page-CYYyCnKD.js +102541 -0
  297. package/dist/server/ssr/assets/xterm-DgzE4ZZ1.js +10232 -0
  298. package/dist/server/ssr/index.js +11840 -0
  299. package/dist/server/ssr/vinext-server.json +1 -0
  300. package/dist/server/vinext-externals.json +1 -0
  301. package/dist/server/vinext-server.json +1 -0
  302. package/dist/server/wrangler.json +1 -0
  303. package/examples/agents/global-agreements.example.md +10 -0
  304. package/examples/agents/research-project.example.md +10 -0
  305. package/examples/agents-media-previews.md +22 -0
  306. package/examples/deployment.example.json +6 -0
  307. package/examples/leak-denylist.example.json +10 -0
  308. package/examples/plugins/hello/index.mjs +4 -0
  309. package/examples/plugins/hello/scope-plugin.json +13 -0
  310. package/examples/workbench.config.json +44 -0
  311. package/lib/account-quota.d.ts +42 -0
  312. package/lib/account-quota.js +121 -0
  313. package/lib/browser-snapshot-cache.js +61 -0
  314. package/lib/conversation-location.js +26 -0
  315. package/lib/conversation.js +62 -0
  316. package/lib/dialogue-refresh.js +14 -0
  317. package/lib/execution-host.js +22 -0
  318. package/lib/formula-preview.js +48 -0
  319. package/lib/i18n.tsx +81 -0
  320. package/lib/incremental-snapshot.js +324 -0
  321. package/lib/manager-plan.js +37 -0
  322. package/lib/markdown-images.js +22 -0
  323. package/lib/markdown-math.js +151 -0
  324. package/lib/markdown-url.js +13 -0
  325. package/lib/model-effort.js +13 -0
  326. package/lib/native-history.d.ts +32 -0
  327. package/lib/native-history.js +94 -0
  328. package/lib/overview-delta.js +41 -0
  329. package/lib/project-view.js +86 -0
  330. package/lib/projects.js +74 -0
  331. package/lib/remote-links.js +95 -0
  332. package/lib/runtime-config.js +70 -0
  333. package/lib/session-activity.js +34 -0
  334. package/lib/session-cache-guard.js +52 -0
  335. package/lib/session-filters.js +38 -0
  336. package/lib/ssh-config.js +26 -0
  337. package/lib/stable-order.js +39 -0
  338. package/lib/workbench-config.js +172 -0
  339. package/package.json +105 -4
  340. package/scripts/agent-email-relay.mjs +104 -0
  341. package/scripts/benchmark-bridge.mjs +38 -0
  342. package/scripts/cli-integration-smoke.mjs +64 -0
  343. package/scripts/email-notification-cli.mjs +28 -0
  344. package/scripts/enable-private-access.ps1 +109 -0
  345. package/scripts/export-opensource.mjs +112 -0
  346. package/scripts/fixtures/media/convergence.png +0 -0
  347. package/scripts/fixtures/media/rollout_demo.mp4 +0 -0
  348. package/scripts/fixtures/native-conversations.mjs +307 -0
  349. package/scripts/fixtures/workbench-conversations.mjs +352 -0
  350. package/scripts/install-remote-server.sh +67 -0
  351. package/scripts/lib/export-directory.mjs +38 -0
  352. package/scripts/lib/secret-scanner.mjs +139 -0
  353. package/scripts/plugin-cli.mjs +19 -0
  354. package/scripts/preview-workbench.mjs +669 -0
  355. package/scripts/probe-antigravity-acp.mjs +35 -0
  356. package/scripts/remote-bootstrap-cli.mjs +52 -0
  357. package/scripts/remote-email-tool.py +383 -0
@@ -0,0 +1,669 @@
1
+ /** Isolated UI fixture: synthetic inventory and adapters, no SSH or model calls. */
2
+ import { sessionArchiveService } from "../bridge/archive/service.mjs";
3
+ import { archiveRoutes } from "../bridge/archive/routes.mjs";
4
+ import { createServer } from "node:http";
5
+ import { mkdtemp, readFile } from "node:fs/promises";
6
+ import { tmpdir } from "node:os";
7
+ import path from "node:path";
8
+ import { startProductionUiServer } from "../bridge/ui-server.mjs";
9
+ import { WorkbenchStore } from "../bridge/workbench/store.mjs";
10
+ import { WorkbenchService } from "../bridge/workbench/service.mjs";
11
+ import { workbenchRoutes } from "../bridge/workbench/routes.mjs";
12
+ import { createIncrementalSnapshotStore } from "../lib/incremental-snapshot.js";
13
+ import { createConversationFixture } from "./fixtures/workbench-conversations.mjs";
14
+ import { nativeConversationFixture } from "./fixtures/native-conversations.mjs";
15
+ import { PluginRegistry } from "../bridge/plugins/registry.mjs";
16
+ import { pluginRoutes } from "../bridge/plugins/routes.mjs";
17
+ import { createAliyunDlcPlugin } from "../bridge/plugins/aliyun-dlc/index.mjs";
18
+ import { fileURLToPath } from "node:url";
19
+ import { installPackage } from "../bridge/plugins/package.mjs";
20
+ import { loadExternalPlugins } from "../bridge/plugins/external.mjs";
21
+
22
+ const isEn = process.env.SCOPE_PREVIEW_LOCALE === "en";
23
+ const dir = await mkdtemp(path.join(tmpdir(), "scope-ui-preview-"));
24
+ const store = await new WorkbenchStore(path.join(dir, "workbench.json")).load();
25
+ const projects = [
26
+ { host: "lab-gpu", cwd: "/workspace/vision", name: "Vision Lab" },
27
+ { host: "build-node", cwd: "/workspace/scope", name: "SCOPE" },
28
+ { host: "lab-gpu", cwd: "/workspace/research", name: isEn ? "Research Notes" : "研究笔记" },
29
+ ];
30
+ const snapshot = {
31
+ generatedAt: new Date().toISOString(),
32
+ scanning: false,
33
+ sshConfig: "Preview fixture — no SSH",
34
+ summary: { hosts: 2, online: 2, codex: 0, tmux: 0, attention: 0 },
35
+ management: {
36
+ operatorName: isEn ? "Preview" : "预览",
37
+ sessions: {
38
+ "lab-gpu:vision-plan": {
39
+ reserved: true,
40
+ reservedUpdatedAt: new Date().toISOString(),
41
+ },
42
+ },
43
+ projects,
44
+ hostRuntimeConfigs: {},
45
+ resourcePolicy: { prompt: "", version: 0, updatedAt: null },
46
+ },
47
+ appServer: {
48
+ experimental: true,
49
+ connections: [],
50
+ sessions: [],
51
+ pendingRequests: [],
52
+ pendingInputs: [],
53
+ },
54
+ submissionTracker: {
55
+ scannedAt: null,
56
+ scanning: false,
57
+ windowDays: 1,
58
+ items: [],
59
+ calls: [],
60
+ launches: [],
61
+ alerts: [],
62
+ hosts: [],
63
+ error: null,
64
+ },
65
+ gpuUsage: { updatedAt: null, retentionHours: 168, episodes: [] },
66
+ notifications: { email: { enabled: false, configured: false, to: [] } },
67
+ hosts: [
68
+ ...["lab-gpu", "build-node"].map((alias) => ({
69
+ alias,
70
+ hostname: alias === "lab-gpu" ? "gpu-cluster-a01" : "build-node-02",
71
+ reachable: true,
72
+ latencyMs: alias === "lab-gpu" ? 14 : 9,
73
+ inventoryUpdatedAt: new Date().toISOString(),
74
+ error: null,
75
+ processes: [],
76
+ panes: [],
77
+ sessions: [],
78
+ agents: [],
79
+ workloads: [],
80
+ gpus:
81
+ alias === "lab-gpu"
82
+ ? [
83
+ {
84
+ index: 0,
85
+ name: "NVIDIA A100-SXM4-80GB",
86
+ utilization: 94,
87
+ memoryUsed: 68420,
88
+ memoryTotal: 81920,
89
+ },
90
+ {
91
+ index: 1,
92
+ name: "NVIDIA A100-SXM4-80GB",
93
+ utilization: 88,
94
+ memoryUsed: 64110,
95
+ memoryTotal: 81920,
96
+ },
97
+ {
98
+ index: 2,
99
+ name: "NVIDIA A100-SXM4-80GB",
100
+ utilization: 12,
101
+ memoryUsed: 10240,
102
+ memoryTotal: 81920,
103
+ },
104
+ {
105
+ index: 3,
106
+ name: "NVIDIA A100-SXM4-80GB",
107
+ utilization: 0,
108
+ memoryUsed: 480,
109
+ memoryTotal: 81920,
110
+ },
111
+ ]
112
+ : [
113
+ {
114
+ index: 0,
115
+ name: "NVIDIA GeForce RTX 4090",
116
+ utilization: 36,
117
+ memoryUsed: 9840,
118
+ memoryTotal: 24564,
119
+ },
120
+ ],
121
+ })),
122
+ {
123
+ alias: "archive-node",
124
+ hostname: "archive-node",
125
+ reachable: false,
126
+ latencyMs: null,
127
+ inventoryUpdatedAt: null,
128
+ error: "Connection timed out",
129
+ processes: [],
130
+ panes: [],
131
+ sessions: [],
132
+ agents: [],
133
+ workloads: [],
134
+ gpus: [],
135
+ },
136
+ {
137
+ alias: "eval-rack-2",
138
+ hostname: "eval-rack-2",
139
+ reachable: false,
140
+ latencyMs: null,
141
+ inventoryUpdatedAt: null,
142
+ error: "Host offline (maintenance)",
143
+ processes: [],
144
+ panes: [],
145
+ sessions: [],
146
+ agents: [],
147
+ workloads: [],
148
+ gpus: [],
149
+ },
150
+ ],
151
+ };
152
+ snapshot.hosts.unshift({alias: "@local", hostname: "workstation", reachable: true, defaultCwd: "/workspace", kind: "local", latencyMs: 0, error: null, processes: [], panes: [], sessions: [], agents: [], workloads: [], gpus: []});
153
+ snapshot.summary.hosts = 5; snapshot.summary.online = 3;
154
+ const maintenanceFixture = new Map();
155
+ const emailFixture = {
156
+ enabled: false,
157
+ configured: false,
158
+ to: [],
159
+ from: "",
160
+ monitorUrl: "http://localhost:3000/",
161
+ cooldownMinutes: 15,
162
+ triggers: { humanRequests: true, agentCompletion: true, dlcAlerts: true },
163
+ smtp: { host: "", port: 465, secure: true },
164
+ smtpUser: "",
165
+ hasPassword: false,
166
+ credentialSource: null,
167
+ lastSentAt: null,
168
+ lastError: null,
169
+ };
170
+ const adapter = {
171
+ async archive() {},
172
+ async restore() {},
173
+ async launch(task) {
174
+ return { startedAt: Date.now(), id: task.id };
175
+ },
176
+ async poll(task) {
177
+ return Date.now() - task.remote.startedAt < 3500
178
+ ? { status: "running" }
179
+ : {
180
+ status: "completed",
181
+ text: "这是隔离预览的模拟回复,没有调用任何远端 Agent。\n\n可以从项目进展开始,或者在资源页为新任务选择执行主机。",
182
+ };
183
+ },
184
+ };
185
+ const service = new WorkbenchService({
186
+ store,
187
+ snapshot: () => snapshot,
188
+ adapters: { codex: adapter, claude: adapter, dsh: adapter },
189
+ });
190
+ await store.update((state) => {
191
+ state.tasks.push({
192
+ id: "preview-task",
193
+ requestId: "preview-task",
194
+ kind: "task",
195
+ host: "build-node",
196
+ cwd: "/workspace/scope",
197
+ provider: "codex",
198
+ prompt: isEn ? "Refactor backend modules & API routes" : "整理后端模块与接口",
199
+ status: "completed",
200
+ gpuIndices: [],
201
+ gpuCount: 0,
202
+ minMemoryMiB: 0,
203
+ createdAt: new Date().toISOString(),
204
+ updatedAt: new Date().toISOString(),
205
+ remote: { sessionId: "preview-task-session" },
206
+ });
207
+ });
208
+ service.start();
209
+ const sync = createIncrementalSnapshotStore({
210
+ epoch: `scope-isolated-preview-${crypto.randomUUID()}`,
211
+ });
212
+ sync.publish(snapshot);
213
+ const clients = new Set();
214
+ const conversations = createConversationFixture(snapshot, () => {
215
+ snapshot.generatedAt = new Date().toISOString();
216
+ sync.publish(snapshot);
217
+ for (const response of clients)
218
+ response.write(
219
+ `data: ${JSON.stringify({ type: "snapshot-invalidated", ...sync.info() })}\n\n`,
220
+ );
221
+ });
222
+ sync.publish(snapshot);
223
+ const jsonResponse = (response, status, value) => {
224
+ response.writeHead(status, {
225
+ "content-type": "application/json; charset=utf-8",
226
+ });
227
+ response.end(JSON.stringify(value));
228
+ };
229
+ const readJsonBody = async (request) => {
230
+ let text = "";
231
+ for await (const chunk of request) {
232
+ text += chunk;
233
+ if (text.length > 100000) throw new Error("too large");
234
+ }
235
+ return JSON.parse(text || "{}");
236
+ };
237
+ const routes = workbenchRoutes(service, { jsonResponse, readJsonBody });
238
+ const fixturePlugins = new PluginRegistry();
239
+ installPackage(fileURLToPath(new URL("../examples/plugins/hello", import.meta.url)), dir);
240
+ loadExternalPlugins(fixturePlugins, dir);
241
+ fixturePlugins.register(createAliyunDlcPlugin({ stateDirectory: dir, legacyHost: "",
242
+ context: () => ({ readSshConfig: async () => "", sshAliasesForHostname: () => new Set(), getSnapshot: () => ({ hosts: [] }) }),
243
+ notify() {}, onScanComplete: async () => {} }));
244
+ const fixturePluginRoutes = pluginRoutes(fixturePlugins);
245
+ fixturePlugins.start();
246
+ const archives = sessionArchiveService({
247
+ manager: {
248
+ sessionRecords: () => snapshot.appServer.sessions,
249
+ async archiveSession(host, id) {
250
+ const agent = snapshot.hosts
251
+ .find((h) => h.alias === host)
252
+ ?.agents.find((a) => a.rollout.id === id);
253
+ if (agent?.status === "working") throw new Error("会话仍在执行");
254
+ },
255
+ async unarchiveSession() {
256
+ return {};
257
+ },
258
+ async resumeSession() {},
259
+ },
260
+ getState: () => snapshot.management,
261
+ persist: async () => {},
262
+ findAgent: (host, id) =>
263
+ snapshot.hosts
264
+ .find((h) => h.alias === host)
265
+ ?.agents.find((a) => a.rollout.id === id),
266
+ getHost: (host) => snapshot.hosts.find((h) => h.alias === host),
267
+ executable: () => "codex",
268
+ connectionKey: async () => "active",
269
+ restored() {},
270
+ notify() {
271
+ snapshot.generatedAt = new Date().toISOString();
272
+ sync.publish(snapshot);
273
+ for (const response of clients)
274
+ response.write(
275
+ `data: ${JSON.stringify({ type: "snapshot-invalidated", ...sync.info() })}\n\n`,
276
+ );
277
+ },
278
+ });
279
+ const archiveRoute = archiveRoutes(archives, { jsonResponse, readJsonBody });
280
+ const previewHost = process.env.SCOPE_PREVIEW_HOST || "127.0.0.1";
281
+ const previewPort = Number(process.env.SCOPE_PREVIEW_PORT || 3001);
282
+ const ui = await startProductionUiServer({ host: "127.0.0.1", port: 0 });
283
+ const uiPort = ui.address().port;
284
+ const createdDirectories = new Map();
285
+ const fixtureImageBytes = await readFile(new URL("./fixtures/media/convergence.png", import.meta.url));
286
+ const fixtureVideoBytes = await readFile(new URL("./fixtures/media/rollout_demo.mp4", import.meta.url));
287
+ const preview = createServer(async (request, response) => {
288
+ try {
289
+ const url = new URL(request.url, `http://${previewHost}:${previewPort}`);
290
+ if (url.pathname === "/scope-image-api") {
291
+ response.writeHead(200, {
292
+ "content-type": "image/png",
293
+ "content-length": String(fixtureImageBytes.length),
294
+ "cache-control": "private, max-age=60",
295
+ });
296
+ response.end(fixtureImageBytes);
297
+ return;
298
+ }
299
+ if (url.pathname === "/scope-video-api") {
300
+ const total = fixtureVideoBytes.length;
301
+ const rangeHeader = request.headers.range;
302
+ if (rangeHeader && /^bytes=(\d*)-(\d*)$/.test(rangeHeader)) {
303
+ const [, rawStart, rawEnd] = rangeHeader.match(/^bytes=(\d*)-(\d*)$/);
304
+ const start = rawStart ? Number(rawStart) : 0;
305
+ const end = rawEnd ? Math.min(total - 1, Number(rawEnd)) : total - 1;
306
+ const slice = fixtureVideoBytes.subarray(start, end + 1);
307
+ response.writeHead(206, {
308
+ "content-type": "video/mp4",
309
+ "accept-ranges": "bytes",
310
+ "content-range": `bytes ${start}-${end}/${total}`,
311
+ "content-length": String(slice.length),
312
+ });
313
+ response.end(slice);
314
+ return;
315
+ }
316
+ response.writeHead(200, {
317
+ "content-type": "video/mp4",
318
+ "accept-ranges": "bytes",
319
+ "content-length": String(total),
320
+ });
321
+ response.end(fixtureVideoBytes);
322
+ return;
323
+ }
324
+ if (await fixturePluginRoutes(request, response, new URL(url.pathname.replace(/^\/scope-api/, "") + url.search, url.origin))) return;
325
+ if (url.pathname === "/scope-directory-api") {
326
+ const cwd = url.searchParams.get("path") || "/workspace";
327
+ const host = url.searchParams.get("host");
328
+ const names = createdDirectories.get(`${host}:${cwd}`) || [
329
+ "data",
330
+ "experiments",
331
+ ];
332
+ return jsonResponse(response, 200, {
333
+ host,
334
+ cwd,
335
+ parent:
336
+ cwd === "/" ? null : cwd.split("/").slice(0, -1).join("/") || "/",
337
+ directories: names.map((name) => ({
338
+ name,
339
+ path: `${cwd.replace(/\/$/, "")}/${name}`,
340
+ })),
341
+ truncated: false,
342
+ });
343
+ }
344
+ if (url.pathname.startsWith("/scope-api/")) {
345
+ url.pathname = url.pathname.slice("/scope-api".length);
346
+ if (
347
+ url.pathname === "/api/remote/directories" &&
348
+ request.method === "POST"
349
+ ) {
350
+ const { host, parent, name } = await readJsonBody(request);
351
+ const key = `${host}:${parent}`;
352
+ const names = createdDirectories.get(key) || ["data", "experiments"];
353
+ if (names.includes(name))
354
+ return jsonResponse(response, 400, { error: "同名文件或目录已存在" });
355
+ createdDirectories.set(key, [...names, name]);
356
+ return jsonResponse(response, 200, {
357
+ host,
358
+ cwd: `${parent.replace(/\/$/, "")}/${name}`,
359
+ });
360
+ }
361
+ if (url.pathname === "/api/session/attachment" && request.method === "POST") {
362
+ let size = 0;
363
+ for await (const chunk of request) size += chunk.length;
364
+ const name = (url.searchParams.get("name") || "attachment").trim() || "attachment";
365
+ const mimeType = (url.searchParams.get("mimeType") || "application/octet-stream").trim();
366
+ return jsonResponse(response, 201, {
367
+ ok: true,
368
+ attachment: {
369
+ token: crypto.randomUUID(),
370
+ name,
371
+ mimeType,
372
+ kind: mimeType.startsWith("image/") ? "image" : "file",
373
+ size,
374
+ sha256: "preview",
375
+ remotePath: `/workspace/.codex/scope-attachments/${name}`,
376
+ },
377
+ });
378
+ }
379
+ if (nativeConversationFixture(request, response, url, jsonResponse)) return;
380
+ if (await archiveRoute(request, response, url)) return;
381
+ if (await routes(request, response, url)) return;
382
+ if (
383
+ await conversations(request, response, url, jsonResponse, readJsonBody)
384
+ )
385
+ return;
386
+ if (url.pathname === "/api/events") {
387
+ response.writeHead(200, { "content-type": "text/event-stream" });
388
+ response.write('data: {"type":"ready"}\n\n');
389
+ clients.add(response);
390
+ response.on("close", () => clients.delete(response));
391
+ return;
392
+ }
393
+ if (url.pathname === "/api/sync")
394
+ return jsonResponse(
395
+ response,
396
+ 200,
397
+ sync.read({
398
+ clientEpoch: url.searchParams.get("epoch"),
399
+ since: url.searchParams.get("since"),
400
+ }),
401
+ );
402
+ if (url.pathname === "/api/history/cache")
403
+ return jsonResponse(response, 200, {
404
+ cached: true,
405
+ scope: "preview",
406
+ sessions: [],
407
+ hosts: [],
408
+ scannedAt: new Date().toISOString(),
409
+ });
410
+ if (url.pathname === "/api/agents/maintenance") {
411
+ if (request.method === "POST") {
412
+ const body = await readJsonBody(request);
413
+ const job = {id: crypto.randomUUID(), action: body.action, status: "completed", info: {installed: body.action === "check" ? null : "fixture 1.0.0", latest: "1.0.0", supported: body.provider !== "antigravity"}, log: "Isolated fixture: no installation executed"};
414
+ maintenanceFixture.set(body.host + ":" + body.provider, job);
415
+ return jsonResponse(response, 202, {job});
416
+ }
417
+ return jsonResponse(response, 200, {agents: ["codex", "claude", "antigravity", "dsh"].map(provider => ({provider, job: maintenanceFixture.get(url.searchParams.get("host") + ":" + provider) || null}))});
418
+ }
419
+ if (url.pathname === "/api/email/settings") {
420
+ if (request.method === "POST") {
421
+ const body = await readJsonBody(request);
422
+ Object.assign(emailFixture, {
423
+ enabled: Boolean(body.enabled),
424
+ configured: Boolean(body.enabled && body.smtp?.host && body.to),
425
+ to: Array.isArray(body.to) ? body.to : String(body.to || "").split(/[,;\n]+/).map((s) => s.trim()).filter(Boolean),
426
+ from: body.from || "",
427
+ monitorUrl: body.monitorUrl || "http://localhost:3000/",
428
+ cooldownMinutes: Number(body.cooldownMinutes ?? 15),
429
+ triggers: body.triggers || emailFixture.triggers,
430
+ smtp: body.smtp || emailFixture.smtp,
431
+ smtpUser: body.smtpUser ?? emailFixture.smtpUser,
432
+ hasPassword: body.clearCredentials ? false : Boolean(body.smtpPass || emailFixture.hasPassword),
433
+ });
434
+ return jsonResponse(response, 200, { ok: true, settings: emailFixture });
435
+ }
436
+ return jsonResponse(response, 200, emailFixture);
437
+ }
438
+ if (url.pathname === "/api/email/verify" || url.pathname === "/api/email/test") {
439
+ return jsonResponse(response, 200, { ok: true, messageId: "fixture-mail-1", settings: emailFixture });
440
+ }
441
+ if (url.pathname === "/api/remote-bootstrap") {
442
+ const host = request.method === "POST" ? (await readJsonBody(request)).host : url.searchParams.get("host") || "";
443
+ return jsonResponse(response, 200, {
444
+ host,
445
+ checkedAt: new Date().toISOString(),
446
+ lastAction: "inspect",
447
+ report: {
448
+ user: "researcher",
449
+ isRoot: false,
450
+ home: "/home/researcher",
451
+ python3: "Python 3.11.8",
452
+ node: "v22.14.0",
453
+ npm: true,
454
+ tmux: true,
455
+ gpuCount: host === "lab-gpu" ? 2 : 0,
456
+ localBinInPath: true,
457
+ systemdUserAvailable: true,
458
+ clis: {
459
+ codex: { installed: true, executable: "/home/researcher/.local/bin/codex", version: "0.158.0" },
460
+ claude: { installed: true, executable: "/home/researcher/.local/bin/claude", version: "2.1.325" },
461
+ antigravity: { installed: false, executable: null, version: null },
462
+ dsh: { installed: false, executable: null, version: null },
463
+ },
464
+ scopeProtocol: { codex: true, claude: true, antigravity: true },
465
+ scopeNotify: { installed: false, executable: null, daemonActive: false, systemdServiceActive: false, relayReachable: false, queued: 0, lastDeliveredAt: null, codexMcp: false, claudeMcp: false },
466
+ },
467
+ tunnel: { enabled: false, remotePort: 4922, status: "disabled", connectedAt: null, lastError: null },
468
+ relay: { relayListening: false, relayPort: 4822, relayTokenReady: false },
469
+ });
470
+ }
471
+ if (url.pathname === "/api/auth/profiles") {
472
+ const host = url.searchParams.get("host") || "lab-gpu";
473
+ const isLocal = host === "@local";
474
+ return jsonResponse(response, 200, {
475
+ host,
476
+ local: isLocal,
477
+ defaultAuthPresent: true,
478
+ activeProfile: isLocal ? null : "lab-pro",
479
+ currentAccount: {
480
+ type: "chatgpt",
481
+ email: "researcher@example.com",
482
+ planType: "pro",
483
+ },
484
+ runningSessions: isLocal ? 0 : 3,
485
+ profiles: isLocal
486
+ ? []
487
+ : [
488
+ {
489
+ slug: "lab-pro",
490
+ name: "Lab Pro",
491
+ createdAt: new Date(Date.now() - 86400_000 * 14).toISOString(),
492
+ updatedAt: new Date().toISOString(),
493
+ account: { type: "chatgpt", email: "researcher@example.com", planType: "pro" },
494
+ ready: true,
495
+ active: true,
496
+ },
497
+ {
498
+ slug: "backup-plus",
499
+ name: "Backup Plus",
500
+ createdAt: new Date(Date.now() - 86400_000 * 7).toISOString(),
501
+ updatedAt: new Date().toISOString(),
502
+ account: { type: "chatgpt", email: "backup-team@example.com", planType: "plus" },
503
+ ready: true,
504
+ active: false,
505
+ },
506
+ ],
507
+ restartJob: null,
508
+ automaticFailover: null,
509
+ });
510
+ }
511
+ if (url.pathname === "/api/auth/quota") {
512
+ const host = url.searchParams.get("host") || "lab-gpu";
513
+ const nowSec = Math.floor(Date.now() / 1000);
514
+ const currentQuota = {
515
+ planType: "pro",
516
+ primary: { usedPercent: 9, remainingPercent: 91, windowMinutes: 300, resetsAt: nowSec + 11_400, expired: false },
517
+ secondary: { usedPercent: 26, remainingPercent: 74, windowMinutes: 10080, resetsAt: nowSec + 410_000, expired: false },
518
+ credits: null,
519
+ };
520
+ if (url.searchParams.get("all") === "1") {
521
+ return jsonResponse(response, 200, {
522
+ host,
523
+ local: host === "@local",
524
+ fetchedAt: new Date().toISOString(),
525
+ currentAccount: { type: "chatgpt", email: "researcher@example.com", planType: "pro" },
526
+ currentQuota,
527
+ profileQuotas:
528
+ host === "@local"
529
+ ? {}
530
+ : {
531
+ "lab-pro": { quota: currentQuota, error: null },
532
+ "backup-plus": {
533
+ quota: {
534
+ planType: "plus",
535
+ primary: { usedPercent: 18, remainingPercent: 82, windowMinutes: 300, resetsAt: nowSec + 14_200, expired: false },
536
+ secondary: { usedPercent: 12, remainingPercent: 88, windowMinutes: 10080, resetsAt: nowSec + 500_000, expired: false },
537
+ credits: null,
538
+ },
539
+ error: null,
540
+ },
541
+ },
542
+ error: null,
543
+ });
544
+ }
545
+ return jsonResponse(response, 200, {
546
+ host,
547
+ connectionKey: url.searchParams.get("connectionKey") || "active",
548
+ quota: currentQuota,
549
+ source: "app-server",
550
+ error: null,
551
+ });
552
+ }
553
+ if (url.pathname === "/api/auth/providers") {
554
+ const host = url.searchParams.get("host") || "lab-gpu";
555
+ const nowSec = Math.floor(Date.now() / 1000);
556
+ return jsonResponse(response, 200, {
557
+ host,
558
+ local: host === "@local",
559
+ fetchedAt: new Date().toISOString(),
560
+ claude: {
561
+ installed: true,
562
+ executable: "/usr/local/bin/claude",
563
+ loggedIn: true,
564
+ email: "researcher@example.com",
565
+ authMethod: "claude.ai",
566
+ subscriptionType: "max",
567
+ planTier: "max_20x",
568
+ orgName: "Vision Research Lab",
569
+ loginExpiresAt: new Date(Date.now() + 86400_000 * 30).toISOString(),
570
+ quota: {
571
+ planType: "max_20x",
572
+ primary: { usedPercent: 11, remainingPercent: 89, windowMinutes: 300, resetsAt: nowSec + 9_600, expired: false },
573
+ secondary: { usedPercent: 5, remainingPercent: 95, windowMinutes: 10080, resetsAt: nowSec + 518_400, expired: false },
574
+ credits: null,
575
+ },
576
+ quotaError: null,
577
+ error: null,
578
+ },
579
+ antigravity: {
580
+ installed: true,
581
+ executable: "/usr/local/bin/agy",
582
+ loggedIn: true,
583
+ email: "researcher@example.com",
584
+ authMethod: "consumer",
585
+ defaultModel: "Gemini 2.5 Pro (High)",
586
+ useG1Credits: true,
587
+ quota: {
588
+ planType: null,
589
+ primary: { usedPercent: 4, remainingPercent: 96, windowMinutes: 300, resetsAt: nowSec + 12_600, expired: false },
590
+ secondary: { usedPercent: 16, remainingPercent: 84, windowMinutes: 10080, resetsAt: nowSec + 432_000, expired: false },
591
+ credits: { hasCredits: true, unlimited: false, balance: isEn ? "G1 Credits enabled" : "G1 Credits 已启用" },
592
+ groups: [
593
+ {
594
+ name: "Gemini Models",
595
+ primary: { usedPercent: 4, remainingPercent: 96, windowMinutes: 300, resetsAt: nowSec + 12_600, expired: false },
596
+ secondary: { usedPercent: 16, remainingPercent: 84, windowMinutes: 10080, resetsAt: nowSec + 432_000, expired: false },
597
+ },
598
+ {
599
+ name: "Claude and GPT models",
600
+ primary: { usedPercent: 0, remainingPercent: 100, windowMinutes: 300, resetsAt: nowSec + 16_200, expired: false },
601
+ secondary: { usedPercent: 7, remainingPercent: 93, windowMinutes: 10080, resetsAt: nowSec + 360_000, expired: false },
602
+ },
603
+ ],
604
+ },
605
+ quotaError: null,
606
+ error: null,
607
+ },
608
+ });
609
+ }
610
+ if (url.pathname === "/api/models")
611
+ return jsonResponse(response, 200, {
612
+ models: [
613
+ {
614
+ id: "o3",
615
+ model: "o3",
616
+ displayName: "o3",
617
+ supportedReasoningEfforts: ["medium", "high", "xhigh"],
618
+ defaultReasoningEffort: "high",
619
+ },
620
+ {
621
+ id: "gpt-5-codex",
622
+ model: "gpt-5-codex",
623
+ displayName: "GPT-5 Codex",
624
+ supportedReasoningEfforts: ["medium", "high", "xhigh"],
625
+ defaultReasoningEffort: "high",
626
+ },
627
+ ],
628
+ });
629
+ return jsonResponse(response, 200, {});
630
+ }
631
+ const upstream = await fetch(`http://127.0.0.1:${uiPort}${request.url}`);
632
+ const outHeaders = Object.fromEntries(
633
+ [...upstream.headers].filter(
634
+ ([key]) => !["content-encoding", "content-length"].includes(key),
635
+ ),
636
+ );
637
+ const contentType = upstream.headers.get("content-type") || "";
638
+ if (contentType.includes("text/html")) {
639
+ const html = (await upstream.text()).replace(
640
+ /<head(\b[^>]*)>/i,
641
+ '<head$1><meta name="scope-bridge-url" content="/scope-api">',
642
+ );
643
+ response.writeHead(upstream.status, outHeaders);
644
+ response.end(html);
645
+ return;
646
+ }
647
+ response.writeHead(upstream.status, outHeaders);
648
+ response.end(Buffer.from(await upstream.arrayBuffer()));
649
+ } catch (error) {
650
+ jsonResponse(response, 500, { error: error.message });
651
+ }
652
+ });
653
+ preview.listen(previewPort, previewHost, () =>
654
+ console.log(
655
+ `Isolated preview: http://${previewHost}:${previewPort} (synthetic data, no SSH; temporary state: ` +
656
+ dir +
657
+ ")",
658
+ ),
659
+ );
660
+ function stop() {
661
+ fixturePlugins.stop();
662
+ service.stop();
663
+ preview.closeAllConnections();
664
+ preview.close();
665
+ ui.closeAllConnections();
666
+ ui.close(() => process.exit(0));
667
+ }
668
+ process.once("SIGINT", stop);
669
+ process.once("SIGTERM", stop);