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 @@
1
+ {"prerenderSecret":"443bfa5a16f83a36167a0bf5251f4e336a23885d73e6c9e9ed142e3331864354"}
@@ -0,0 +1 @@
1
+ []
@@ -0,0 +1 @@
1
+ {"prerenderSecret":"443bfa5a16f83a36167a0bf5251f4e336a23885d73e6c9e9ed142e3331864354"}
@@ -0,0 +1 @@
1
+ {"topLevelName":"scope-agent-workbench","dev":{"ip":"127.0.0.1","local_protocol":"http","upstream_protocol":"http","enable_containers":true,"generate_types":false},"name":"scope-agent-workbench","compatibility_date":"2026-05-15","compatibility_flags":["nodejs_compat"],"vars":{},"durable_objects":{"bindings":[]},"kv_namespaces":[],"queues":{"producers":[],"consumers":[]},"r2_buckets":[],"d1_databases":[],"vectorize":[],"ai_search_namespaces":[],"ai_search":[],"hyperdrive":[],"workflows":[],"secrets_store_secrets":[],"artifacts":[],"services":[],"analytics_engine_datasets":[],"unsafe_hello_world":[],"flagship":[],"ratelimits":[],"worker_loaders":[],"legacy_env":true,"main":"index.js","jsx_factory":"React.createElement","jsx_fragment":"React.Fragment","migrations":[],"triggers":{},"rules":[{"type":"ESModule","globs":["**/*.js","**/*.mjs"]}],"build":{"watch_dir":"./src"},"no_bundle":true,"dispatch_namespaces":[],"logfwdr":{"bindings":[]},"assets":{"directory":"../client"},"observability":{"enabled":true},"python_modules":{"exclude":["**/*.pyc"]},"define":{},"cloudchamber":{},"send_email":[],"mtls_certificates":[],"pipelines":[],"vpc_services":[],"vpc_networks":[]}
@@ -0,0 +1,10 @@
1
+ # Global Working Agreements (Example)
2
+
3
+ Use this template in `~/.codex/AGENTS.md` or `~/.claude/CLAUDE.md` on your GPU hosts.
4
+
5
+ ## Safe Execution & Resource Hygiene
6
+
7
+ - Inspect the working directory, git branch, active jobs, and GPU memory (`nvidia-smi`) before launching training or evaluation runs.
8
+ - Run long jobs inside a durable scheduler or named `tmux` session, never in an unmonitored foreground shell.
9
+ - Never kill or restart unrelated processes, VS Code terminals, or shared tmux sessions owned by other users.
10
+ - Keep run-specific parameters, checkpoint paths, and metrics in a dedicated project log rather than bloating global instruction files.
@@ -0,0 +1,10 @@
1
+ # Project Repository Guide (Example)
2
+
3
+ Place a tailored `AGENTS.md` or `CLAUDE.md` in each project repository root.
4
+
5
+ ## Environment & Data Contracts
6
+
7
+ - Confirm the active Python/Conda environment and dataset mount paths before starting runs.
8
+ - Preserve baseline config files; create new config files or explicit overrides for new experiments.
9
+ - Separate completed runs (with final metrics and artifacts) from partial logs or failed starts.
10
+ - Include direct paths or relative links to generated figures, logs, and checkpoints in your final summary.
@@ -0,0 +1,22 @@
1
+ <!-- SCOPE_MEDIA_PREVIEWS_BEGIN -->
2
+ ## Result handoff: image and video previews
3
+
4
+ - When completed image/video artifacts are relevant to the result, include direct
5
+ preview references in the final reply, not just a directory, HTML gallery, or
6
+ a path inside a code block. Do not generate extra media solely to fill a report.
7
+ - Verify each referenced file exists, is non-empty, and is fully written. Use
8
+ the absolute path on the current SSH host; resolve symlinks when practical.
9
+ Keep durable artifacts under the project/output storage, not transient `/tmp`.
10
+ - Images: `![Short description](</absolute/path/figure.png>)`.
11
+ - Videos: `[Short description — video](</absolute/path/clip.mp4>)`.
12
+ SCOPE renders direct MP4/M4V/WebM/OGV links as video players. Prefer an already
13
+ available browser-compatible MP4 (H.264) or WebM; do not start a costly or lossy
14
+ transcode without need. If a codec is unsupported, say so and retain the original.
15
+ - Show a small representative selection (normally 1–3 previews), plus the full
16
+ gallery/output directory when there are more. Identify the host if artifacts
17
+ are on another host; never present another host's path as locally accessible.
18
+ - Distinguish final artifacts from partial renders or running jobs. Do not claim
19
+ to have visually inspected a video/image merely because its file exists.
20
+ - These are output-format rules only: they do not authorize uploads, emails,
21
+ experiment launches, account changes, or interruption of existing processes.
22
+ <!-- SCOPE_MEDIA_PREVIEWS_END -->
@@ -0,0 +1,6 @@
1
+ {
2
+ "taskQueue": false,
3
+ "dlcHostname": "",
4
+ "proxyBootstrapHosts": [],
5
+ "emailTunnelHost": ""
6
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "literals": [
3
+ "10.0.0.10",
4
+ "internal-gpu-host",
5
+ "private-project-codename"
6
+ ],
7
+ "patterns": [
8
+ "\\bmy_internal_proxy\\b"
9
+ ]
10
+ }
@@ -0,0 +1,4 @@
1
+ export function apply(ctx) {
2
+ ctx.action("hello", () => ({ message: ctx.config.greeting }));
3
+ // Use ctx.onDispose(() => clearInterval(timer)) for timers or subscriptions.
4
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "protocolVersion": 1,
3
+ "id": "hello-scope",
4
+ "name": "Hello SCOPE",
5
+ "version": "1.0.0",
6
+ "description": "验证插件导入、配置和操作,不连接任何外部服务。",
7
+ "entry": "index.mjs",
8
+ "files": ["index.mjs"],
9
+ "capabilities": [],
10
+ "permissions": ["在 SCOPE 服务进程内运行"],
11
+ "settings": [{"key":"greeting","type":"text","label":"问候语","default":"Hello SCOPE"}],
12
+ "actions": [{"id":"hello","label":"测试插件","result":"json/v1"}]
13
+ }
@@ -0,0 +1,44 @@
1
+ {
2
+ "version": 1,
3
+ "manager": {
4
+ "host": "",
5
+ "cwd": "",
6
+ "model": "",
7
+ "effort": ""
8
+ },
9
+ "scheduler": {
10
+ "paused": false,
11
+ "maxRunning": 3,
12
+ "maxPerHost": 2,
13
+ "maxPerProject": 1,
14
+ "inventoryMaxAgeSeconds": 60,
15
+ "residentSessionsPerHost": 5,
16
+ "sessionIdleGraceMinutes": 15
17
+ },
18
+ "providers": {
19
+ "codex": {
20
+ "enabled": true,
21
+ "executable": "codex",
22
+ "preLaunchCommand": "",
23
+ "model": ""
24
+ },
25
+ "claude": {
26
+ "enabled": false,
27
+ "executable": "claude",
28
+ "preLaunchCommand": "",
29
+ "model": ""
30
+ },
31
+ "dsh": {
32
+ "enabled": false,
33
+ "executable": "dsh",
34
+ "preLaunchCommand": "",
35
+ "model": ""
36
+ },
37
+ "antigravity": {
38
+ "enabled": false,
39
+ "executable": "agy",
40
+ "preLaunchCommand": "",
41
+ "model": ""
42
+ }
43
+ }
44
+ }
@@ -0,0 +1,42 @@
1
+ export interface AccountQuotaWindow {
2
+ usedPercent: number;
3
+ remainingPercent: number;
4
+ windowMinutes: number | null;
5
+ resetsAt: number | null;
6
+ expired: boolean;
7
+ }
8
+
9
+ export interface AccountCredits {
10
+ hasCredits: boolean;
11
+ unlimited: boolean;
12
+ balance: string | null;
13
+ }
14
+
15
+ export interface AccountQuotaGroup {
16
+ name: string;
17
+ description?: string;
18
+ primary: AccountQuotaWindow | null;
19
+ secondary: AccountQuotaWindow | null;
20
+ }
21
+
22
+ export interface AccountQuota {
23
+ planType: string | null;
24
+ primary: AccountQuotaWindow | null;
25
+ secondary: AccountQuotaWindow | null;
26
+ credits: AccountCredits | null;
27
+ groups?: AccountQuotaGroup[];
28
+ }
29
+
30
+ export function normalizeAccountQuota(
31
+ raw: unknown,
32
+ nowMs?: number,
33
+ ): AccountQuota | null;
34
+
35
+ export function quotaHeadline(
36
+ quota: AccountQuota | null | undefined,
37
+ ): AccountQuotaWindow | null;
38
+
39
+ export function formatQuotaWindowLabel(
40
+ windowMinutes: number | null | undefined,
41
+ locale?: string,
42
+ ): string;
@@ -0,0 +1,121 @@
1
+ function normalizeWindow(raw, nowMs) {
2
+ if (!raw || typeof raw !== "object") return null;
3
+ const usedRaw = raw.usedPercent ?? raw.used_percent;
4
+ const usedNumeric = Number(usedRaw);
5
+ if (usedRaw === null || usedRaw === undefined || !Number.isFinite(usedNumeric)) {
6
+ return null;
7
+ }
8
+ const usedPercent = Math.max(0, Math.min(100, Math.round(usedNumeric)));
9
+ const windowRaw = raw.windowDurationMins ?? raw.window_minutes;
10
+ const windowNumeric = Number(windowRaw);
11
+ const windowMinutes =
12
+ windowRaw !== null && windowRaw !== undefined && Number.isFinite(windowNumeric) && windowNumeric > 0
13
+ ? Math.round(windowNumeric)
14
+ : null;
15
+ const resetsRaw = raw.resetsAt ?? raw.resets_at;
16
+ const resetsNumeric = Number(resetsRaw);
17
+ const resetsAt =
18
+ resetsRaw !== null && resetsRaw !== undefined && Number.isFinite(resetsNumeric) && resetsNumeric > 0
19
+ ? Math.round(resetsNumeric)
20
+ : null;
21
+ const expired = Boolean(resetsAt && resetsAt * 1000 <= nowMs);
22
+ return {
23
+ usedPercent: expired ? 0 : usedPercent,
24
+ remainingPercent: expired ? 100 : Math.max(0, 100 - usedPercent),
25
+ windowMinutes,
26
+ resetsAt,
27
+ expired,
28
+ };
29
+ }
30
+
31
+ function normalizeCredits(raw) {
32
+ if (!raw || typeof raw !== "object") return null;
33
+ const hasCredits = Boolean(raw.hasCredits ?? raw.has_credits);
34
+ const unlimited = Boolean(raw.unlimited);
35
+ const balance =
36
+ raw.balance !== undefined && raw.balance !== null && String(raw.balance).trim() !== ""
37
+ ? String(raw.balance).trim()
38
+ : null;
39
+ if (!hasCredits && !unlimited && (!balance || Number(balance) <= 0)) {
40
+ return null;
41
+ }
42
+ return { hasCredits, unlimited, balance };
43
+ }
44
+
45
+ function normalizeGroup(raw, nowMs) {
46
+ if (!raw || typeof raw !== "object") return null;
47
+ const name = typeof raw.name === "string" ? raw.name.trim() : "";
48
+ if (!name) return null;
49
+ const primary = normalizeWindow(raw.primary, nowMs);
50
+ const secondary = normalizeWindow(raw.secondary, nowMs);
51
+ if (!primary && !secondary) return null;
52
+ const description =
53
+ typeof raw.description === "string" && raw.description.trim()
54
+ ? raw.description.trim().slice(0, 300)
55
+ : undefined;
56
+ return description
57
+ ? { name: name.slice(0, 120), description, primary, secondary }
58
+ : { name: name.slice(0, 120), primary, secondary };
59
+ }
60
+
61
+ export function normalizeAccountQuota(raw, nowMs = Date.now()) {
62
+ if (!raw || typeof raw !== "object") return null;
63
+ const source =
64
+ raw.rateLimits && typeof raw.rateLimits === "object" ? raw.rateLimits : raw;
65
+ const primary = normalizeWindow(source.primary, nowMs);
66
+ const secondary = normalizeWindow(source.secondary, nowMs);
67
+ const credits = normalizeCredits(source.credits);
68
+ const groups = Array.isArray(source.groups)
69
+ ? source.groups.map((item) => normalizeGroup(item, nowMs)).filter(Boolean)
70
+ : [];
71
+ const rawPlan = source.planType ?? source.plan_type;
72
+ const planType = typeof rawPlan === "string" ? rawPlan.trim() || null : null;
73
+ if (!primary && !secondary && !credits && groups.length === 0) return null;
74
+ const result = {
75
+ planType,
76
+ primary,
77
+ secondary,
78
+ credits,
79
+ };
80
+ if (groups.length > 0) {
81
+ result.groups = groups;
82
+ }
83
+ return result;
84
+ }
85
+
86
+ export function quotaHeadline(quota) {
87
+ if (!quota) return null;
88
+ const top = [quota.primary, quota.secondary].filter(Boolean);
89
+ const windows =
90
+ top.length > 0
91
+ ? top
92
+ : Array.isArray(quota.groups)
93
+ ? quota.groups.flatMap((group) =>
94
+ [group?.primary, group?.secondary].filter(Boolean),
95
+ )
96
+ : [];
97
+ if (!windows.length) return null;
98
+ const sorted = [...windows].sort(
99
+ (left, right) =>
100
+ Number(Boolean(left.expired)) - Number(Boolean(right.expired)) ||
101
+ left.remainingPercent - right.remainingPercent,
102
+ );
103
+ return sorted[0] || null;
104
+ }
105
+
106
+ export function formatQuotaWindowLabel(windowMinutes, locale = "zh-CN") {
107
+ const isEn = locale === "en-US" || locale === "en";
108
+ if (!Number.isFinite(windowMinutes) || !windowMinutes) {
109
+ return isEn ? "Limit" : "用量额度";
110
+ }
111
+ if (windowMinutes >= 10_080 && windowMinutes % 1440 === 0) {
112
+ const days = Math.round(windowMinutes / 1440);
113
+ if (days === 7) return isEn ? "7d" : "周额度";
114
+ return isEn ? `${days}d` : `${days}天额度`;
115
+ }
116
+ if (windowMinutes >= 60 && windowMinutes % 60 === 0) {
117
+ const hours = Math.round(windowMinutes / 60);
118
+ return isEn ? `${hours}h` : `${hours}h 额度`;
119
+ }
120
+ return isEn ? `${windowMinutes}m` : `${windowMinutes}m 额度`;
121
+ }
@@ -0,0 +1,61 @@
1
+ import { preserveSnapshotSessions } from "./session-cache-guard.js";
2
+ const DATABASE_NAME = "scope-monitor-cache";
3
+ const DATABASE_VERSION = 1;
4
+ const STORE_NAME = "resources";
5
+ const SNAPSHOT_KEY = "snapshot-sync-v1";
6
+
7
+ function openDatabase() {
8
+ return new Promise((resolve, reject) => {
9
+ if (typeof indexedDB === "undefined") {
10
+ reject(new Error("IndexedDB unavailable"));
11
+ return;
12
+ }
13
+ const request = indexedDB.open(DATABASE_NAME, DATABASE_VERSION);
14
+ request.onupgradeneeded = () => {
15
+ const database = request.result;
16
+ if (!database.objectStoreNames.contains(STORE_NAME)) {
17
+ database.createObjectStore(STORE_NAME);
18
+ }
19
+ };
20
+ request.onsuccess = () => resolve(request.result);
21
+ request.onerror = () => reject(request.error || new Error("cache open failed"));
22
+ });
23
+ }
24
+
25
+ export async function loadBrowserSnapshotCache() {
26
+ const database = await openDatabase();
27
+ try {
28
+ return await new Promise((resolve, reject) => {
29
+ const transaction = database.transaction(STORE_NAME, "readonly");
30
+ const request = transaction.objectStore(STORE_NAME).get(SNAPSHOT_KEY);
31
+ request.onsuccess = () => resolve(request.result || null);
32
+ request.onerror = () =>
33
+ reject(request.error || new Error("cache read failed"));
34
+ });
35
+ } finally {
36
+ database.close();
37
+ }
38
+ }
39
+
40
+ export async function saveBrowserSnapshotCache(value) {
41
+ const database = await openDatabase();
42
+ try {
43
+ await new Promise((resolve, reject) => {
44
+ const transaction = database.transaction(STORE_NAME, "readwrite");
45
+ const store = transaction.objectStore(STORE_NAME);
46
+ const existing = store.get(SNAPSHOT_KEY);
47
+ existing.onsuccess = () => {
48
+ const snapshot = preserveSnapshotSessions(existing.result?.snapshot, value.snapshot);
49
+ store.put({ ...value, snapshot }, SNAPSHOT_KEY);
50
+ };
51
+ transaction.oncomplete = () => resolve();
52
+ transaction.onerror = () =>
53
+ reject(transaction.error || new Error("cache write failed"));
54
+ transaction.onabort = () =>
55
+ reject(transaction.error || new Error("cache write aborted"));
56
+ });
57
+ } finally {
58
+ database.close();
59
+ }
60
+ }
61
+
@@ -0,0 +1,26 @@
1
+ export const CONVERSATION_LOCATION_KEY = "scope.conversation-location.v1";
2
+
3
+ export function readConversationLocation(raw) {
4
+ try {
5
+ const value = JSON.parse(raw);
6
+ if (value?.version !== 1 || !["manager", "projects", "resources", "settings"].includes(value.section)) return null;
7
+ const text = (v) => typeof v === "string" && v.length <= 4096;
8
+ if (!text(value.projectHost) || !text(value.host) || !text(value.cwd)) return null;
9
+ if (value.session && (!text(value.session.id) || !text(value.session.sessionId) || !["codex", "claude", "antigravity"].includes(value.session.provider))) return null;
10
+ return { version: 1, section: value.section, projectHost: value.projectHost, host: value.host, cwd: value.cwd,
11
+ session: value.session ? { id: value.session.id, sessionId: value.session.sessionId, provider: value.session.provider } : null };
12
+ } catch { return null; }
13
+ }
14
+
15
+ // Durable IDs survive a process restart or the transition from a scanned to a managed session.
16
+ export function findConversationLocation(projects, location) {
17
+ for (const project of projects) {
18
+ if (project.host !== location.host) continue;
19
+ if (!location.session) { if (project.cwd === location.cwd) return { project, session: null }; continue; }
20
+ const wanted = location.session;
21
+ const session = project.sessions.find(item => (item.provider || "codex") === wanted.provider &&
22
+ (wanted.sessionId ? item.sessionId === wanted.sessionId : item.id === wanted.id));
23
+ if (session) return { project, session };
24
+ }
25
+ return null;
26
+ }
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Keep progress reports in the timeline; collapse only adjacent internal activity.
3
+ * @param {import('../features/workspace/types').DialogueEvent[]} events
4
+ * @returns {({type: 'message', id: string, event: import('../features/workspace/types').DialogueEvent} | {type: 'activity', id: string, events: import('../features/workspace/types').DialogueEvent[]})[]}
5
+ */
6
+ export function conversationEntries(events) {
7
+ /** @type {ReturnType<typeof conversationEntries>} */
8
+ const entries = [];
9
+ const seen = new Set();
10
+ for (const event of events) {
11
+ if (seen.has(event.id)) continue;
12
+ seen.add(event.id);
13
+ if (
14
+ event.kind === "user" ||
15
+ event.kind === "error" ||
16
+ (event.kind === "assistant" &&
17
+ (event.phase === "commentary" || event.category !== "reasoning"))
18
+ ) {
19
+ entries.push({ type: "message", id: event.id, event });
20
+ } else {
21
+ const previous = entries.at(-1);
22
+ if (previous?.type === "activity") previous.events.push(event);
23
+ else entries.push({ type: "activity", id: event.id, events: [event] });
24
+ }
25
+ }
26
+ return entries;
27
+ }
28
+
29
+ /** A new tail must not discard the older pages the reader explicitly loaded. */
30
+ export function mergeConversationPage(previous, incoming) {
31
+ if (
32
+ !previous ||
33
+ previous.sessionId !== incoming.sessionId ||
34
+ previous.host !== incoming.host
35
+ )
36
+ return incoming;
37
+ const events = new Map(previous.events.map((event) => [event.id, event]));
38
+ incoming.events.forEach((event) => events.set(event.id, event));
39
+ const older =
40
+ previous.nextBefore !== null &&
41
+ incoming.nextBefore !== null &&
42
+ previous.nextBefore < incoming.nextBefore;
43
+ const complete = previous.hasMore === false;
44
+ return {
45
+ ...incoming,
46
+ events: [...events.values()],
47
+ hasMore: complete ? false : older ? previous.hasMore : incoming.hasMore,
48
+ nextBefore: complete
49
+ ? null
50
+ : older
51
+ ? previous.nextBefore
52
+ : incoming.nextBefore,
53
+ };
54
+ }
55
+
56
+ /** Identical text in separate assistant messages is still a new reply. */
57
+ export function hasConversationReply(pending, latest) {
58
+ if (!latest.latestAssistant) return false;
59
+ if (pending.baselineAssistantId !== undefined && latest.latestAssistantId)
60
+ return latest.latestAssistantId !== pending.baselineAssistantId;
61
+ return latest.latestAssistant !== pending.baselineAssistant;
62
+ }
@@ -0,0 +1,14 @@
1
+ // Refresh the same session in place. Clearing data here unmounts media while
2
+ // every SSE update waits for another /api/dialogue response.
3
+ export function beginDialogueRefresh(current, key) {
4
+ return {
5
+ key,
6
+ loading: true,
7
+ data: current.key === key ? current.data : null,
8
+ error: "",
9
+ };
10
+ }
11
+
12
+ export function failDialogueRefresh(current, key, error) {
13
+ return { ...beginDialogueRefresh(current, key), loading: false, error };
14
+ }
@@ -0,0 +1,22 @@
1
+ export const LOCAL_HOST = "@local";
2
+ export const hostLabel = (host, locale = "zh-CN") =>
3
+ host === LOCAL_HOST ? (locale === "en" ? "Local" : "本机") : host;
4
+
5
+ export function workingDirectory(host, value) {
6
+ const cwd = typeof value === "string" ? value.trim() : "";
7
+ if (!cwd || cwd.length > 4000 || /[\x00-\x1f\x7f]/.test(cwd))
8
+ throw new Error("请输入有效的工作目录");
9
+ if (host === LOCAL_HOST) {
10
+ if (!/^(?:[A-Za-z]:[\\/]|[\\/]{2}[^\\/]+[\\/][^\\/]+|\/)/.test(cwd))
11
+ throw new Error("请输入本机绝对目录,例如 C:/projects 或 /workspace");
12
+ const normalized = cwd
13
+ .replaceAll("\\", "/")
14
+ .replace(/^([a-z]):/, (_, drive) => `${drive.toUpperCase()}:`);
15
+ return (
16
+ normalized.replace(/\/+$/, "") +
17
+ (/^[A-Z]:\/$/.test(normalized) ? "/" : "") || "/"
18
+ );
19
+ }
20
+ if (!cwd.startsWith("/")) throw new Error("请输入远端 Linux 绝对目录");
21
+ return cwd.replace(/\/+$/, "") || "/";
22
+ }
@@ -0,0 +1,48 @@
1
+ import katex from "katex";
2
+
3
+ const OPTIONS = { trust: false, strict: "ignore", maxExpand: 300, maxSize: 20, throwOnError: true };
4
+
5
+ /** Only formula-like inline code; paths, programs and ordinary identifiers stay code. */
6
+ export function isInlineFormula(source) {
7
+ if (!source || source.length > 1500 || /[\n;`]|[A-Za-z]:\\|(?:https?|file):/.test(source)) return false;
8
+ // Paper prose often contains macros and braces too. Neither is evidence of math.
9
+ if (/\\(?:cite\w*|[cCvV]?ref|label|section|subsection|caption|paragraph)\b/.test(source)) return false;
10
+ const outsideText = source.replace(/\\(?:text\w*|operatorname|mathrm)\{[^{}]*\}/g, "").replace(/\\[A-Za-z]+/g, "");
11
+ if (/[A-Za-z]{3,}\s+[A-Za-z]{2,}\b|[\u4e00-\u9fff]{2,}/.test(outsideText)) return false;
12
+ if (/^\\[([]/.test(source)) return true;
13
+ if (/\\[A-Za-z]+/.test(source)) {
14
+ if (/[=^_{}]|\\(?:pi|alpha|beta|gamma|delta|epsilon|varepsilon|theta|lambda|mu|sigma|Delta|Omega|infty)\b/.test(source)) return true;
15
+ }
16
+ return /^[A-Za-z]\s*=\s*[-+]?\d+(?:\.\d+)?$/.test(source);
17
+ }
18
+
19
+ export function formulaBody(source) {
20
+ let value = source.trim().replace(/^%[^\n]*(?:\n|$)/gm, "").trim();
21
+ for (const [start, end] of [["$$", "$$"], ["\\[", "\\]"], ["\\(", "\\)"], ["$", "$"]]) {
22
+ if (value.startsWith(start) && value.endsWith(end)) { value = value.slice(start.length, -end.length).trim(); break; }
23
+ }
24
+ value = value.replace(/\\begin\{(equation\*?|displaymath)\}([\s\S]*?)\\end\{\1\}/g, "$2");
25
+ return value.replace(/\\(begin|end)\{(?:align\*?|split)\}/g, "\\$1{aligned}").trim();
26
+ }
27
+
28
+ /** Unknown macros remain visibly spelled out, never guessed or shared across messages. */
29
+ export function renderFormula(source, displayMode = false) {
30
+ if (source.length > 20000) return { html: "", missing: [], error: "公式过长,请查看源码" };
31
+ const body = formulaBody(source);
32
+ if (!body || /\\(?:documentclass|usepackage|input|include|includegraphics|href|url|html\w*)\b/.test(body)) return { html: "", missing: [], error: "此内容包含文档或非公式命令,请查看源码" };
33
+ const macros = {};
34
+ const missing = [];
35
+ for (let attempt = 0; attempt <= 20; attempt++) {
36
+ try {
37
+ const html = katex.renderToString(body, { ...OPTIONS, displayMode, macros: { ...macros } });
38
+ return { html, missing, error: "" };
39
+ } catch (error) {
40
+ const command = /Undefined control sequence:\s*(\\[A-Za-z]+)/.exec(error.message)?.[1];
41
+ if (!command || missing.includes(command) || attempt === 20) return { html: "", missing, error: "公式语法或命令暂不支持,请查看源码" };
42
+ missing.push(command);
43
+ // Preserve the command's literal spelling; do not invent a mathematical meaning.
44
+ macros[command] = `\\text{\\textbackslash ${command.slice(1)}}`;
45
+ }
46
+ }
47
+ return { html: "", missing, error: "公式暂无法预览" };
48
+ }
package/lib/i18n.tsx ADDED
@@ -0,0 +1,81 @@
1
+ "use client";
2
+ import { createContext, useContext, useSyncExternalStore, type ReactNode } from "react";
3
+
4
+ export type Locale = "zh-CN" | "en";
5
+ export type SettingsTab = "general" | "hosts" | "agents" | "email" | "plugins";
6
+
7
+ const STORAGE_KEY = "scope:locale";
8
+ const LOCALE_EVENT = "scope:locale-change";
9
+ let fallbackLocale: Locale = "zh-CN";
10
+
11
+ function readLocale(): Locale {
12
+ try {
13
+ const saved = window.localStorage.getItem(STORAGE_KEY);
14
+ if (saved === "en" || saved === "zh-CN") return saved;
15
+ } catch {
16
+ /* ignore storage errors */
17
+ }
18
+ return fallbackLocale;
19
+ }
20
+
21
+ function subscribeLocale(notify: () => void) {
22
+ window.addEventListener("storage", notify);
23
+ window.addEventListener(LOCALE_EVENT, notify);
24
+ return () => {
25
+ window.removeEventListener("storage", notify);
26
+ window.removeEventListener(LOCALE_EVENT, notify);
27
+ };
28
+ }
29
+
30
+ type LocaleContextValue = {
31
+ locale: Locale;
32
+ setLocale: (next: Locale) => void;
33
+ toggleLocale: () => void;
34
+ tr: (zh: string, en: string) => string;
35
+ };
36
+
37
+ const LocaleContext = createContext<LocaleContextValue>({
38
+ locale: "zh-CN",
39
+ setLocale: () => {},
40
+ toggleLocale: () => {},
41
+ tr: (zh) => zh,
42
+ });
43
+
44
+ export function LocaleProvider({ children }: { children: ReactNode }) {
45
+ const locale = useSyncExternalStore<Locale>(
46
+ subscribeLocale,
47
+ readLocale,
48
+ () => "zh-CN",
49
+ );
50
+
51
+ function setLocale(next: Locale) {
52
+ fallbackLocale = next;
53
+ try {
54
+ window.localStorage.setItem(STORAGE_KEY, next);
55
+ } catch {
56
+ /* ignore storage errors */
57
+ }
58
+ window.dispatchEvent(new Event(LOCALE_EVENT));
59
+ }
60
+
61
+ function toggleLocale() {
62
+ setLocale(locale === "zh-CN" ? "en" : "zh-CN");
63
+ }
64
+
65
+ return (
66
+ <LocaleContext.Provider
67
+ value={{
68
+ locale,
69
+ setLocale,
70
+ toggleLocale,
71
+ tr: (zh, en) => (locale === "en" ? en : zh),
72
+ }}
73
+ >
74
+ {children}
75
+ </LocaleContext.Provider>
76
+ );
77
+ }
78
+
79
+ export function useLocale() {
80
+ return useContext(LocaleContext);
81
+ }