scope-agent-workbench 0.0.0-stage → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (358) hide show
  1. package/CHANGELOG.md +59 -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 +36 -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 +432 -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 +637 -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 +463 -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 +177 -0
  95. package/bridge/routes/accounts.mjs +326 -0
  96. package/bridge/routes/dialogue.mjs +165 -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 +3357 -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 +388 -0
  109. package/bridge/session-catalog/catalog.mjs +110 -0
  110. package/bridge/session-catalog/probe.py +1207 -0
  111. package/bridge/session-catalog/routes.mjs +34 -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 +405 -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-BMior55c.js +3 -0
  215. package/dist/client/assets/index-CNnP2Ses.css +2 -0
  216. package/dist/client/assets/layout-segment-context-DjGudgXn.js +1 -0
  217. package/dist/client/assets/page-CJqXlhDs.js +551 -0
  218. package/dist/client/assets/page-LYzRz6_S.css +1 -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-BB9Dri2u.js +104686 -0
  296. package/dist/server/ssr/assets/page-LYzRz6_S.css +1 -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/subagent-display-prefs.ts +130 -0
  339. package/lib/workbench-config.js +172 -0
  340. package/package.json +105 -4
  341. package/scripts/agent-email-relay.mjs +104 -0
  342. package/scripts/benchmark-bridge.mjs +38 -0
  343. package/scripts/cli-integration-smoke.mjs +64 -0
  344. package/scripts/email-notification-cli.mjs +28 -0
  345. package/scripts/enable-private-access.ps1 +109 -0
  346. package/scripts/export-opensource.mjs +112 -0
  347. package/scripts/fixtures/media/convergence.png +0 -0
  348. package/scripts/fixtures/media/rollout_demo.mp4 +0 -0
  349. package/scripts/fixtures/native-conversations.mjs +465 -0
  350. package/scripts/fixtures/workbench-conversations.mjs +475 -0
  351. package/scripts/install-remote-server.sh +67 -0
  352. package/scripts/lib/export-directory.mjs +38 -0
  353. package/scripts/lib/secret-scanner.mjs +139 -0
  354. package/scripts/plugin-cli.mjs +19 -0
  355. package/scripts/preview-workbench.mjs +669 -0
  356. package/scripts/probe-antigravity-acp.mjs +35 -0
  357. package/scripts/remote-bootstrap-cli.mjs +52 -0
  358. package/scripts/remote-email-tool.py +383 -0
@@ -0,0 +1,29 @@
1
+ import { existsSync, statSync } from "node:fs";
2
+ import path from "node:path";
3
+
4
+ function npmBinaries(directory, arch) {
5
+ const target = { x64: "x86_64", arm64: "aarch64" }[arch];
6
+ if (!target) return [];
7
+ const triple = `${target}-pc-windows-msvc`;
8
+ const packageRoot = path.join(directory, "node_modules", "@openai");
9
+ return [
10
+ path.join(packageRoot, "codex", "node_modules", "@openai", `codex-win32-${arch}`, "vendor", triple, "bin", "codex.exe"),
11
+ path.join(packageRoot, `codex-win32-${arch}`, "vendor", triple, "bin", "codex.exe"),
12
+ path.join(packageRoot, "codex", "vendor", triple, "bin", "codex.exe"),
13
+ ];
14
+ }
15
+
16
+ // Resolve the native binary, never execute a .cmd/.ps1 shim through a shell.
17
+ export function resolveCodexExecutable(env = process.env, platform = process.platform, arch = process.arch) {
18
+ const explicit = env.SCOPE_LOCAL_CODEX;
19
+ const directories = (env.PATH || env.Path || "").split(platform === "win32" ? ";" : ":")
20
+ .map(dir => dir.replace(/^"|"$/g, "")).filter(dir => path.isAbsolute(dir));
21
+ if (platform === "win32" && env.APPDATA) directories.push(path.join(env.APPDATA, "npm"));
22
+ const candidates = explicit
23
+ ? [explicit, ...(platform === "win32" && /[\\/]codex\.(cmd|ps1|bat)$/i.test(explicit) ? npmBinaries(path.dirname(explicit), arch) : [])]
24
+ : directories.flatMap(dir => [path.join(dir, platform === "win32" ? "codex.exe" : "codex"), ...(platform === "win32" ? npmBinaries(dir, arch) : [])]);
25
+ return candidates.find(file => {
26
+ try { return path.isAbsolute(file) && !/\.(cmd|bat|ps1)$/i.test(file) && existsSync(file) && statSync(file).isFile(); }
27
+ catch { return false; }
28
+ }) || null;
29
+ }
@@ -0,0 +1,36 @@
1
+ import { DIALOGUE_PROBE } from "../probes/dialogue-probe.mjs";
2
+ import { runLocalPython } from "./python-probe.mjs";
3
+ import { readLocalDialogue } from "./dialogue.mjs";
4
+
5
+ export function localHistoryReader({ manager, findRollout, run = runLocalPython }) {
6
+ return async (body) => {
7
+ const subagentId = typeof body.subagentId === "string" ? body.subagentId.trim() : "";
8
+ if (!subagentId && manager.sessionRecords().some(record => record.host === body.host && record.sessionId === body.sessionId)) {
9
+ return readLocalDialogue(manager, body.host, body.sessionId, body);
10
+ }
11
+ // Only use a server-discovered path, never a path supplied in the request.
12
+ const rollout = findRollout(body.host, body.sessionId, subagentId);
13
+ if (!rollout?.path) throw new Error(subagentId ? "未找到对应的子代理 rollout" : "未找到本机会话历史,请刷新会话扫描");
14
+ const limit = Math.max(1, Math.min(100, Number(body.limit) || (subagentId ? 40 : 10)));
15
+ const before = body.before != null && body.before !== "" && Number.isFinite(Number(body.before))
16
+ ? String(Math.max(0, Math.floor(Number(body.before)))) : "";
17
+ const result = await run(DIALOGUE_PROBE,
18
+ [rollout.path, String(limit), before, body.dialogueOnly ? "dialogue-only" : "full"], 30_000, 5_000_000);
19
+ if (result.code !== 0) throw new Error(result.stderr || "本机会话历史读取失败");
20
+ const parsed = JSON.parse(result.stdout);
21
+ if (!subagentId) return parsed;
22
+ return {
23
+ ...parsed,
24
+ subagent: {
25
+ id: rollout.id,
26
+ agentNickname: rollout.agentNickname || "",
27
+ agentPath: rollout.agentPath || "",
28
+ agentRole: rollout.agentRole || "",
29
+ model: rollout.model || "",
30
+ turnState: rollout.turnState || "idle",
31
+ lastAction: rollout.lastAction || "",
32
+ lastEventAt: rollout.lastEventAt || null,
33
+ },
34
+ };
35
+ };
36
+ }
@@ -0,0 +1,35 @@
1
+ import { spawn } from "node:child_process";
2
+ import { existsSync } from "node:fs";
3
+ import os from "node:os";
4
+ import path from "node:path";
5
+
6
+ export function pythonExecutable() {
7
+ const bundled = path.join(os.homedir(), ".cache", "codex-runtimes", "codex-primary-runtime", "dependencies", "python", "python.exe");
8
+ return process.env.SCOPE_PYTHON || (process.platform === "win32" && existsSync(bundled) ? bundled : process.platform === "win32" ? "python" : "python3");
9
+ }
10
+
11
+ /** Execute a read-only probe locally, without a shell or a remote transport. */
12
+ export function runLocalPython(script, args = [], timeoutMs = 30_000, maxBytes = 8_000_000) {
13
+ return new Promise((resolve) => {
14
+ const child = spawn(pythonExecutable(), ["-", ...args], { windowsHide: true, env: { ...process.env, PYTHONIOENCODING: "utf-8" } });
15
+ let stdout = "", stderr = "", bytes = 0, settled = false;
16
+ const finish = (code, error = "") => {
17
+ if (settled) return;
18
+ settled = true;
19
+ clearTimeout(timer);
20
+ resolve({ code, stdout, stderr: stderr + error });
21
+ };
22
+ const timer = setTimeout(() => { finish(124, "本机检索超时"); child.kill(); }, timeoutMs);
23
+ child.stdout.setEncoding("utf8").on("data", (chunk) => {
24
+ if (settled) return;
25
+ bytes += Buffer.byteLength(chunk);
26
+ if (bytes > maxBytes) { finish(125, "本机检索输出超过限制"); child.kill(); }
27
+ else stdout += chunk;
28
+ });
29
+ child.stderr.setEncoding("utf8").on("data", (chunk) => { stderr = (stderr + chunk).slice(-20_000); });
30
+ child.on("error", (error) => finish(127, error.message));
31
+ child.on("close", (code) => finish(code ?? 1));
32
+ child.stdin.on("error", () => {});
33
+ child.stdin.end(script);
34
+ });
35
+ }
@@ -0,0 +1,188 @@
1
+ import { spawn } from "node:child_process";
2
+ import { openSync, closeSync } from "node:fs";
3
+ import { mkdir, readFile, writeFile, open, unlink } from "node:fs/promises";
4
+ import { randomBytes, createHash } from "node:crypto";
5
+ import { createServer } from "node:net";
6
+ import os from "node:os";
7
+ import path from "node:path";
8
+ import { setTimeout as delay } from "node:timers/promises";
9
+ import { LOCAL_HOST } from "../../lib/execution-host.js";
10
+ import { LocalJsonlChild } from "./transport.mjs";
11
+ import { resolveCodexExecutable } from "./executable.mjs";
12
+ export { resolveCodexExecutable } from "./executable.mjs";
13
+
14
+ function alive(pid) {
15
+ try {
16
+ process.kill(pid, 0);
17
+ return true;
18
+ } catch {
19
+ return false;
20
+ }
21
+ }
22
+ async function freePort() {
23
+ const server = createServer();
24
+ await new Promise((resolve, reject) => {
25
+ server.once("error", reject);
26
+ server.listen(0, "127.0.0.1", resolve);
27
+ });
28
+ const port = server.address().port;
29
+ await new Promise((resolve) => server.close(resolve));
30
+ return port;
31
+ }
32
+ async function ready(url) {
33
+ try {
34
+ return (
35
+ await fetch(url.replace("ws:", "http:") + "/readyz", {
36
+ signal: AbortSignal.timeout(700),
37
+ })
38
+ ).ok;
39
+ } catch {
40
+ return false;
41
+ }
42
+ }
43
+
44
+ export class LocalCodexRuntime {
45
+ constructor(
46
+ stateDir,
47
+ { defaultCwd = process.cwd(), executable = resolveCodexExecutable() } = {},
48
+ ) {
49
+ this.directory = path.join(stateDir, "local-codex");
50
+ this.executable = executable;
51
+ this.defaultCwd = defaultCwd;
52
+ }
53
+ host() {
54
+ return {
55
+ alias: LOCAL_HOST,
56
+ label: "本机",
57
+ kind: "local",
58
+ defaultCwd: this.defaultCwd,
59
+ reachable: !!this.executable,
60
+ hostname: os.hostname(),
61
+ latencyMs: 0,
62
+ error: this.executable
63
+ ? null
64
+ : "未找到本机 Codex,请安装 CLI 或设置 SCOPE_LOCAL_CODEX 为可执行文件路径",
65
+ processes: [],
66
+ panes: [],
67
+ sessions: [],
68
+ agents: [],
69
+ gpus: [],
70
+ stale: false,
71
+ inventoryUpdatedAt: new Date().toISOString(),
72
+ };
73
+ }
74
+ probe() {
75
+ if (!this.executable) throw new Error(this.host().error);
76
+ return spawn(this.executable, ["app-server", "--listen", "stdio://"], {
77
+ cwd: this.defaultCwd,
78
+ windowsHide: true,
79
+ stdio: ["pipe", "pipe", "pipe"],
80
+ });
81
+ }
82
+ connect() {
83
+ return new LocalJsonlChild(() => this.endpoint());
84
+ }
85
+ async endpoint() {
86
+ if (!this.executable) throw new Error(this.host().error);
87
+ if (this.starting) return this.starting;
88
+ this.starting = this.ensureEndpoint().finally(() => {
89
+ this.starting = null;
90
+ });
91
+ return this.starting;
92
+ }
93
+ async ensureEndpoint() {
94
+ await mkdir(this.directory, { recursive: true });
95
+ const lock = path.join(this.directory, "startup.lock");
96
+ let handle;
97
+ for (let i = 0; i < 100; i++) {
98
+ try {
99
+ handle = await open(lock, "wx", 0o600);
100
+ await handle.writeFile(String(process.pid));
101
+ break;
102
+ } catch (error) {
103
+ if (error.code !== "EEXIST") throw error;
104
+ const owner = Number(await readFile(lock, "utf8").catch(() => ""));
105
+ if (owner && !alive(owner)) await unlink(lock).catch(() => {});
106
+ else await delay(200);
107
+ }
108
+ }
109
+ if (!handle) throw new Error("本机 Codex 正在启动,请稍后重试");
110
+ try {
111
+ const metadataFile = path.join(this.directory, "runtime.json");
112
+ const saved = JSON.parse(
113
+ await readFile(metadataFile, "utf8").catch((e) => {
114
+ if (e.code === "ENOENT") return "null";
115
+ throw e;
116
+ }),
117
+ );
118
+ if (saved && alive(saved.pid)) {
119
+ if (!/^ws:\/\/127\.0\.0\.1:\d+$/.test(saved.url) || !saved.token)
120
+ throw new Error("本机 Codex 运行记录无效");
121
+ if (!(await ready(saved.url)))
122
+ throw new Error(
123
+ "已有本机 Codex 进程尚未就绪;保留运行中的会话,请稍后重试",
124
+ );
125
+ return saved;
126
+ }
127
+ const token = randomBytes(32).toString("hex");
128
+ const url = `ws://127.0.0.1:${await freePort()}`;
129
+ const log = openSync(
130
+ path.join(this.directory, "app-server.log"),
131
+ "a",
132
+ 0o600,
133
+ );
134
+ let child;
135
+ try {
136
+ child = spawn(
137
+ this.executable,
138
+ [
139
+ "app-server",
140
+ "--listen",
141
+ url,
142
+ "--ws-auth",
143
+ "capability-token",
144
+ "--ws-token-sha256",
145
+ createHash("sha256").update(token).digest("hex"),
146
+ ],
147
+ {
148
+ cwd: this.defaultCwd,
149
+ windowsHide: true,
150
+ detached: true,
151
+ stdio: ["ignore", log, log],
152
+ },
153
+ );
154
+ } finally {
155
+ closeSync(log);
156
+ }
157
+ let startupError;
158
+ child.once("error", (error) => {
159
+ startupError = error;
160
+ });
161
+ child.unref();
162
+ if (!child.pid) {
163
+ await delay(10);
164
+ throw startupError || new Error("本机 Codex 启动失败");
165
+ }
166
+ const record = {
167
+ pid: child.pid,
168
+ url,
169
+ token,
170
+ executable: this.executable,
171
+ };
172
+ await writeFile(metadataFile, JSON.stringify(record), { mode: 0o600 });
173
+ for (let i = 0; i < 60; i++) {
174
+ if (startupError || !alive(child.pid))
175
+ throw (
176
+ startupError ||
177
+ new Error("本机 Codex 启动失败,请查看 local-codex/app-server.log")
178
+ );
179
+ if (await ready(url)) return record;
180
+ await delay(200);
181
+ }
182
+ throw new Error("本机 Codex 启动超时;进程已保留,请稍后重试");
183
+ } finally {
184
+ await handle.close();
185
+ await unlink(lock);
186
+ }
187
+ }
188
+ }
@@ -0,0 +1,70 @@
1
+ import { EventEmitter } from "node:events";
2
+ import { PassThrough, Writable } from "node:stream";
3
+ import WebSocket from "ws";
4
+
5
+ /** Disposable connection to a durable local writer; closing never kills Codex. */
6
+ export class LocalJsonlChild extends EventEmitter {
7
+ constructor(endpoint) {
8
+ super();
9
+ this.scopeTransport = "local-websocket";
10
+ this.stdout = new PassThrough();
11
+ this.stderr = new PassThrough();
12
+ this.closed = false;
13
+ this.ready = Promise.resolve()
14
+ .then(endpoint)
15
+ .then(
16
+ ({ url, token }) =>
17
+ new Promise((resolve, reject) => {
18
+ if (this.closed) return reject(new Error("本机连接已关闭"));
19
+ const socket = (this.socket = new WebSocket(url, {
20
+ headers: { Authorization: `Bearer ${token}` },
21
+ handshakeTimeout: 10_000,
22
+ }));
23
+ socket.once("open", () => {
24
+ if (this.closed) {
25
+ socket.close();
26
+ reject(new Error("本机连接已关闭"));
27
+ return;
28
+ }
29
+ this.heartbeat = setInterval(() => socket.ping(), 25_000);
30
+ this.heartbeat.unref();
31
+ resolve(socket);
32
+ });
33
+ socket.on("message", (data) =>
34
+ this.stdout.write(`${data.toString().trimEnd()}\n`),
35
+ );
36
+ socket.on("error", reject);
37
+ socket.once("close", () => {
38
+ clearInterval(this.heartbeat);
39
+ reject(new Error("本机连接已断开"));
40
+ this.stdout.end();
41
+ this.stderr.end();
42
+ this.emit("exit", 0, null);
43
+ });
44
+ }),
45
+ );
46
+ this.ready.catch((error) => this.emit("error", error));
47
+ let buffer = "";
48
+ this.stdin = new Writable({
49
+ write: (chunk, _encoding, callback) => {
50
+ buffer += chunk.toString();
51
+ const messages = buffer.split("\n");
52
+ buffer = messages.pop();
53
+ this.ready.then((socket) => {
54
+ for (const message of messages)
55
+ if (message.trim()) socket.send(message);
56
+ callback();
57
+ }, callback);
58
+ },
59
+ final: (callback) => {
60
+ this.kill();
61
+ callback();
62
+ },
63
+ });
64
+ }
65
+ kill() {
66
+ this.closed = true;
67
+ clearInterval(this.heartbeat);
68
+ this.socket?.close();
69
+ }
70
+ }
@@ -0,0 +1,141 @@
1
+ import { shellQuote } from "../transport/ssh-command.mjs";
2
+
3
+ export const AGENT_PACKAGES = {
4
+ codex: "@openai/codex",
5
+ claude: "@anthropic-ai/claude-code",
6
+ dsh: "@deepseek-ai/dsh",
7
+ };
8
+
9
+ export const MAINTAINED_PROVIDERS = ["codex", "claude", "antigravity", "dsh"];
10
+
11
+ /** Fixed vendor channels; user input only selects an agent and optional pre-launch command. */
12
+ export function installCommand(provider, action, settings = {}) {
13
+ if (
14
+ !MAINTAINED_PROVIDERS.includes(provider) ||
15
+ !["check", "install", "update"].includes(action)
16
+ )
17
+ throw new Error("未知安装操作");
18
+ if (provider === "antigravity" && action !== "check") {
19
+ throw new Error("Antigravity CLI 请使用官方安装包或本地渠道安装与更新");
20
+ }
21
+ const config = JSON.stringify({
22
+ provider,
23
+ action,
24
+ package: AGENT_PACKAGES[provider] || null,
25
+ executable: settings.executable || (provider === "antigravity" ? "agy" : provider),
26
+ });
27
+ const script = String.raw`
28
+ import json, os, re, shutil, subprocess, tempfile, fcntl
29
+ from pathlib import Path
30
+ config = json.loads(${JSON.stringify(config)})
31
+ provider, action, package = config['provider'], config['action'], config['package']
32
+ def extend_path():
33
+ extra = [Path.home() / '.local/bin', Path.home() / '.cargo/bin']
34
+ nvm_root = Path.home() / '.nvm/versions/node'
35
+ if nvm_root.is_dir():
36
+ extra.extend(sorted(nvm_root.glob('*/bin'), reverse=True))
37
+ extra.append(Path('/usr/local/bin'))
38
+ current = [p for p in os.environ.get('PATH', '').split(os.pathsep) if p]
39
+ for candidate in reversed(extra):
40
+ text = str(candidate)
41
+ if candidate.is_dir() and text not in current:
42
+ current.insert(0, text)
43
+ os.environ['PATH'] = os.pathsep.join(current)
44
+ extend_path()
45
+ def run(args, timeout=60):
46
+ result = subprocess.run(args, capture_output=True, text=True, timeout=timeout)
47
+ if result.returncode: raise RuntimeError((result.stderr or result.stdout)[-3000:])
48
+ return result.stdout.strip()
49
+ def emit(info):
50
+ print('SCOPE_INSTALL_RESULT=' + json.dumps(info), flush=True)
51
+ state = Path.home() / '.local/state/scope/install-locks'
52
+ state.mkdir(parents=True, exist_ok=True)
53
+ with open(state / (provider + '.lock'), 'a') as lock:
54
+ try: fcntl.flock(lock, fcntl.LOCK_EX | fcntl.LOCK_NB)
55
+ except BlockingIOError: raise RuntimeError('此 Agent 已有安装任务,请等待完成')
56
+ executable = shutil.which(config['executable'])
57
+ raw_exe = Path(executable) if executable else None
58
+ resolved = raw_exe.resolve() if raw_exe else None
59
+ installed = None
60
+ if executable:
61
+ try:
62
+ ver_out = run([executable, '--version'], 20)
63
+ installed = (ver_out.splitlines()[0] if ver_out else '').strip()[:120] or None
64
+ except Exception:
65
+ if action != 'check':
66
+ raise
67
+ installed = 'installed'
68
+ if provider == 'antigravity':
69
+ emit(dict(installed=installed, latest=None, executable=executable, supported=False, channel='native' if executable else 'not-installed'))
70
+ raise SystemExit(0)
71
+ npm = shutil.which('npm')
72
+ root = None
73
+ if npm:
74
+ try: root = Path(run([npm, 'root', '-g'], 20)).resolve()
75
+ except Exception: root = None
76
+ package_root = root / package if (root and package) else None
77
+ npm_owned = bool(resolved and package_root and package_root in resolved.parents)
78
+ native_claude = bool(provider == 'claude' and executable and (
79
+ raw_exe == Path.home() / '.local/bin/claude'
80
+ or '.claude' in str(resolved or '')
81
+ or (resolved and (Path.home() / '.local/share/claude') in resolved.parents)
82
+ ))
83
+ supported = (not executable and (provider == 'claude' or bool(npm))) or npm_owned or native_claude
84
+ latest = None
85
+ latest_error = None
86
+ if package:
87
+ if npm:
88
+ try:
89
+ raw_latest = run([npm, 'view', package, 'version', '--json', '--fetch-timeout=15000', '--fetch-retries=1'], 25)
90
+ candidate_latest = json.loads(raw_latest)
91
+ if isinstance(candidate_latest, str) and re.fullmatch(r'\d+\.\d+\.\d+(?:-[a-zA-Z0-9.-]+)?', candidate_latest):
92
+ latest = candidate_latest
93
+ except Exception as exc:
94
+ latest = None
95
+ latest_error = str(exc).splitlines()[-1][:200] if str(exc).strip() else 'npm view failed'
96
+ if not latest:
97
+ try:
98
+ import urllib.request
99
+ req = urllib.request.Request(f'https://registry.npmjs.org/{package.replace("/", "%2F")}/latest', headers={'Accept': 'application/json'})
100
+ with urllib.request.urlopen(req, timeout=15) as resp:
101
+ payload = json.loads(resp.read().decode('utf-8', 'replace'))
102
+ candidate_latest = payload.get('version') if isinstance(payload, dict) else None
103
+ if isinstance(candidate_latest, str) and re.fullmatch(r'\d+\.\d+\.\d+(?:-[a-zA-Z0-9.-]+)?', candidate_latest):
104
+ latest = candidate_latest
105
+ latest_error = None
106
+ except Exception as exc:
107
+ if not latest_error:
108
+ latest_error = str(exc).splitlines()[-1][:200] if str(exc).strip() else 'registry check failed'
109
+ info = dict(installed=installed, latest=latest, latestError=latest_error, executable=executable, supported=supported, channel='npm' if npm_owned else 'native' if native_claude else 'not-installed' if not executable else 'external')
110
+ if action != 'check':
111
+ if not supported: raise RuntimeError('现有安装由其他渠道管理,或缺少 npm;请按原渠道配置,未覆盖安装')
112
+ if action == 'install' and executable: raise RuntimeError('已经安装,请使用更新')
113
+ if action == 'update' and not executable: raise RuntimeError('尚未安装,请先安装')
114
+ current_version = re.search(r'(\d+)\.(\d+)\.(\d+)', installed or '')
115
+ if latest and current_version and tuple(map(int, current_version.groups())) > tuple(map(int, latest.split('-')[0].split('.'))): raise RuntimeError('已安装版本高于当前发布版本,拒绝降级;请检查安装渠道')
116
+ print('正在安装' if action == 'install' else '正在更新', provider, f'({package}@{latest or "latest"})' if package else '', '— 下载安装包可能需要 30–120 秒,请稍候…', flush=True)
117
+ if provider == 'claude' and not executable:
118
+ with tempfile.TemporaryDirectory(prefix='scope-claude-install-') as temporary:
119
+ installer = str(Path(temporary) / 'install.sh')
120
+ run(['curl', '-fsSL', '--connect-timeout', '15', '--max-time', '120', 'https://claude.ai/install.sh', '-o', installer], 130)
121
+ run(['bash', installer], 600)
122
+ executable = str(Path.home() / '.local/bin/claude')
123
+ elif native_claude:
124
+ out = run([executable, 'update'], 600)
125
+ if out:
126
+ print(out[-1000:], flush=True)
127
+ else:
128
+ target = latest or 'latest'
129
+ out = run([npm, 'install', '-g', package + '@' + target, '--fetch-timeout=60000', '--fetch-retries=1', '--no-audit', '--no-fund'], 600)
130
+ if out:
131
+ print(out[-1000:], flush=True)
132
+ executable = shutil.which(config['executable'])
133
+ if not executable: raise RuntimeError('安装完成但 PATH 中找不到命令,请检查 npm prefix 和 PATH')
134
+ new_ver_out = run([executable, '--version'], 30)
135
+ info.update(installed=(new_ver_out.splitlines()[0] if new_ver_out else '').strip()[:120] or new_ver_out, executable=executable, latestError=None)
136
+ if latest and provider != 'claude' and not re.search(r'(?<![\d.])' + re.escape(latest) + r'(?![\d.])', info['installed']): raise RuntimeError('PATH 中的版本与安装目标不一致,请检查路径优先级')
137
+ emit(info)
138
+ `;
139
+ const bootstrap = (settings.updatePreCommand || settings.preLaunchCommand || "").trim();
140
+ return `${bootstrap ? `${bootstrap}\nscope_setup_status=$?\nif [ "$scope_setup_status" -ne 0 ]; then exit "$scope_setup_status"; fi\n` : ""}exec python3 -c ${shellQuote(script)}`;
141
+ }
@@ -0,0 +1,21 @@
1
+ import { readJsonBody, jsonResponse } from "../http.mjs";
2
+ export function maintenanceRoutes(service) {
3
+ return async (request, response, url) => {
4
+ if (url.pathname !== "/api/agents/maintenance") return false;
5
+ try {
6
+ if (request.method === "GET")
7
+ jsonResponse(response, 200, {
8
+ agents: await service.view(url.searchParams.get("host") || ""),
9
+ });
10
+ else if (request.method === "POST") {
11
+ const { host, provider, action } = await readJsonBody(request);
12
+ jsonResponse(response, 202, {
13
+ job: await service.start(host, provider, action),
14
+ });
15
+ } else jsonResponse(response, 405, { error: "不支持的请求方法" });
16
+ } catch (error) {
17
+ jsonResponse(response, 409, { error: error.message });
18
+ }
19
+ return true;
20
+ };
21
+ }