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,517 @@
1
+ import path from "node:path";
2
+
3
+ export function parseSshAliases(source) {
4
+ const aliases = new Set();
5
+ for (const line of source.split(/\r?\n/)) {
6
+ const match = line.match(/^\s*Host\s+(.+?)\s*$/i);
7
+ if (!match) continue;
8
+ for (const value of match[1].split(/\s+/)) {
9
+ if (value && !/[*?!]/.test(value)) aliases.add(value);
10
+ }
11
+ }
12
+ return [...aliases].sort((a, b) => a.localeCompare(b));
13
+ }
14
+
15
+ export function decodeBase64Url(value) {
16
+ try {
17
+ return Buffer.from(value, "base64url").toString("utf8");
18
+ } catch {
19
+ return "";
20
+ }
21
+ }
22
+
23
+ export function cleanSshError(stderr) {
24
+ const line = stderr
25
+ .split(/\r?\n/)
26
+ .map((item) => item.trim())
27
+ .find((item) => item && !item.startsWith("META\t"));
28
+ if (!line) return "SSH 连接失败";
29
+ if (/timed out/i.test(line)) return "连接超时";
30
+ if (/permission denied/i.test(line)) return "认证失败";
31
+ if (/could not resolve/i.test(line)) return "无法解析主机";
32
+ if (/host key verification failed/i.test(line)) return "主机密钥未确认";
33
+ return line.replace(/^ssh:\s*/i, "").slice(0, 160);
34
+ }
35
+
36
+ export async function mapLimit(items, limit, worker) {
37
+ const results = new Array(items.length);
38
+ let cursor = 0;
39
+ async function run() {
40
+ while (cursor < items.length) {
41
+ const index = cursor++;
42
+ results[index] = await worker(items[index], index);
43
+ }
44
+ }
45
+ await Promise.all(
46
+ Array.from({ length: Math.min(limit, items.length) }, () => run()),
47
+ );
48
+ return results;
49
+ }
50
+
51
+ export function createInventoryScanner({
52
+ REMOTE_PROBE,
53
+ shellQuote,
54
+ guardPersistentCodexHome,
55
+ persistentCodexHomes,
56
+ SSH_TIMEOUT_MS,
57
+ INVENTORY_TIMEOUT_MS,
58
+ inventoryOperations,
59
+ spawn,
60
+ heuristicSummary,
61
+ preserveHostSessions,
62
+ }) {
63
+ // Keep plain function declarations in order: inventory-transport tests extract this slice for vm execution.
64
+ function sessionFingerprintPayload(previous) {
65
+ const fingerprints = {};
66
+ for (const session of previous?.sessions || []) {
67
+ if (
68
+ typeof session?.path !== "string" ||
69
+ !Number.isFinite(session?.mtimeMs) ||
70
+ !Number.isFinite(session?.sizeBytes)
71
+ ) {
72
+ continue;
73
+ }
74
+ fingerprints[session.path] = [session.mtimeMs, session.sizeBytes];
75
+ }
76
+ return Buffer.from(JSON.stringify(fingerprints), "utf8").toString("base64url");
77
+ }
78
+
79
+ function inventoryProbe(previous) {
80
+ const fingerprints = sessionFingerprintPayload(previous);
81
+ if (!fingerprints) return REMOTE_PROBE;
82
+ return `export SCOPE_SESSION_FINGERPRINTS_B64=${shellQuote(fingerprints)}\n${REMOTE_PROBE}`;
83
+ }
84
+
85
+ function runSsh(alias, previous) {
86
+ const operation = new Promise((resolve) => {
87
+ const startedAt = Date.now();
88
+ const child = spawn(
89
+ (typeof process !== "undefined" && process.platform === "win32" ? "ssh.exe" : "ssh"),
90
+ [
91
+ "-T",
92
+ "-o",
93
+ "BatchMode=yes",
94
+ "-o",
95
+ "StrictHostKeyChecking=yes",
96
+ "-o",
97
+ "ConnectionAttempts=1",
98
+ "-o",
99
+ `ConnectTimeout=${Math.ceil(SSH_TIMEOUT_MS / 1000)}`,
100
+ "-o",
101
+ "ServerAliveInterval=10",
102
+ "-o",
103
+ "ServerAliveCountMax=2",
104
+ "--",
105
+ alias,
106
+ // Keep Windows argv bounded. The growing probe/cache travels on stdin.
107
+ guardPersistentCodexHome("sh -s", persistentCodexHomes[alias]),
108
+ ],
109
+ { windowsHide: true },
110
+ );
111
+
112
+ let stdout = "";
113
+ let stderr = "";
114
+ let settled = false;
115
+ let timedOut = false;
116
+
117
+ const timer = setTimeout(() => {
118
+ if (settled) return;
119
+ timedOut = true;
120
+ child.kill();
121
+ }, INVENTORY_TIMEOUT_MS);
122
+
123
+ child.stdout.on("data", (chunk) => {
124
+ if (stdout.length < 4_000_000) stdout += chunk.toString("utf8");
125
+ });
126
+ child.stderr.on("data", (chunk) => {
127
+ if (stderr.length < 20_000) stderr += chunk.toString("utf8");
128
+ });
129
+ child.on("error", (error) => {
130
+ stderr += `\n${error.message}`;
131
+ });
132
+ child.stdin.on("error", (error) => {
133
+ // SSH may exit before the whole probe has been written (EPIPE).
134
+ stderr += `\n${error.message}`;
135
+ });
136
+ child.on("close", (code) => {
137
+ if (settled) return;
138
+ settled = true;
139
+ clearTimeout(timer);
140
+ resolve({
141
+ code: code ?? 1,
142
+ stdout,
143
+ stderr,
144
+ timedOut,
145
+ latencyMs: Date.now() - startedAt,
146
+ });
147
+ });
148
+ child.stdin.end(inventoryProbe(previous));
149
+ }).catch((error) => ({
150
+ code: 1,
151
+ stdout: "",
152
+ stderr: `SSH inventory launch failed: ${error.message}`,
153
+ timedOut: false,
154
+ latencyMs: 0,
155
+ }));
156
+ inventoryOperations.set(alias, operation);
157
+ const cleanup = () => {
158
+ if (inventoryOperations.get(alias) === operation) {
159
+ inventoryOperations.delete(alias);
160
+ }
161
+ };
162
+ // Do not create an unobserved rejected promise with .finally().
163
+ operation.then(cleanup, cleanup);
164
+ return operation;
165
+ }
166
+
167
+ function commandSignatures(value) {
168
+ const text = String(value || "");
169
+ const signatures = new Set();
170
+ for (const match of text.matchAll(
171
+ /(?:^|[\s"'=])((?:[A-Za-z0-9_.-]+\/)*[A-Za-z0-9_.-]+\.(?:py|sh|ya?ml|json))(?:\s|$|["'])/gi,
172
+ )) {
173
+ signatures.add(path.posix.basename(match[1]).toLowerCase());
174
+ }
175
+ for (const match of text.matchAll(
176
+ /(?:^|\s)-m\s+([A-Za-z_][A-Za-z0-9_.-]+)/g,
177
+ )) {
178
+ signatures.add(match[1].toLowerCase());
179
+ }
180
+ return signatures;
181
+ }
182
+
183
+ function intersectSignatures(left, right) {
184
+ return [...left].filter((value) => right.has(value));
185
+ }
186
+
187
+ function assignWorkloadOwners(host) {
188
+ const rootSessions = host.sessions.filter((session) => !session.isSubagent);
189
+ const sessionsById = new Map(rootSessions.map((session) => [session.id, session]));
190
+ for (const subagent of host.sessions.filter((session) => session.isSubagent)) {
191
+ const parent = sessionsById.get(subagent.parentThreadId);
192
+ if (!parent || !subagent.launches?.length) continue;
193
+ parent.launches = [...(parent.launches || []), ...subagent.launches].slice(-120);
194
+ }
195
+ const activeBySession = new Map(
196
+ host.agents
197
+ .filter((agent) => agent.rollout?.id)
198
+ .map((agent) => [agent.rollout.id, agent]),
199
+ );
200
+ const cwdCounts = new Map();
201
+ for (const session of rootSessions) {
202
+ if (!session.cwd) continue;
203
+ cwdCounts.set(session.cwd, (cwdCounts.get(session.cwd) || 0) + 1);
204
+ }
205
+ const now = Date.now();
206
+
207
+ for (const workload of host.workloads) {
208
+ const pane =
209
+ host.panes.find((candidate) => candidate.tty === workload.tty) || null;
210
+ workload.pane = pane
211
+ ? {
212
+ session: pane.session,
213
+ pane: pane.pane,
214
+ tty: pane.tty,
215
+ cwd: pane.cwd,
216
+ command: pane.command,
217
+ }
218
+ : null;
219
+ const workloadSignatures = commandSignatures(workload.cmdline);
220
+ const startedAt = now - Math.max(0, workload.elapsedSeconds || 0) * 1_000;
221
+ const candidates = rootSessions.map((session) => {
222
+ const agent = activeBySession.get(session.id);
223
+ let score = 0;
224
+ const evidence = [];
225
+ if (agent && workload.ancestorPids.includes(agent.pid)) {
226
+ score = 100;
227
+ evidence.push(`进程树包含 Codex PID ${agent.pid}`);
228
+ }
229
+ if (
230
+ agent &&
231
+ workload.tty &&
232
+ workload.tty !== "?" &&
233
+ workload.tty === agent.tty
234
+ ) {
235
+ score = Math.max(score, 96);
236
+ evidence.push(`与 Codex 共用 TTY ${agent.tty}`);
237
+ }
238
+
239
+ for (const launch of session.launches || []) {
240
+ const launchTime = Date.parse(launch.timestamp || "");
241
+ const launchSignatures = commandSignatures(launch.command);
242
+ const shared = intersectSignatures(
243
+ workloadSignatures,
244
+ launchSignatures,
245
+ );
246
+ const paneNamed =
247
+ pane?.session &&
248
+ new RegExp(
249
+ `(?:^|\\s)(?:-s|-t)\\s+${pane.session.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}(?:\\s|$)`,
250
+ ).test(launch.command);
251
+ if (paneNamed) {
252
+ score = Math.max(score, 94);
253
+ evidence.push(`rollout 启动了 tmux ${pane.session}`);
254
+ }
255
+ if (
256
+ shared.length &&
257
+ Number.isFinite(launchTime) &&
258
+ launchTime <= startedAt + 5 * 60_000 &&
259
+ startedAt - launchTime <= 48 * 60 * 60_000
260
+ ) {
261
+ const sameCwd =
262
+ workload.cwd &&
263
+ session.cwd &&
264
+ (workload.cwd === session.cwd ||
265
+ workload.cwd.startsWith(`${session.cwd}/`));
266
+ score = Math.max(score, sameCwd ? 92 : 86);
267
+ evidence.push(`启动命令匹配 ${shared.slice(0, 3).join(", ")}`);
268
+ if (sameCwd) evidence.push("启动目录一致");
269
+ }
270
+ }
271
+
272
+ if (
273
+ workload.cwd &&
274
+ session.cwd &&
275
+ workload.cwd === session.cwd &&
276
+ cwdCounts.get(session.cwd) === 1
277
+ ) {
278
+ score = Math.max(score, 68);
279
+ evidence.push("唯一活跃 Session 的工作目录一致");
280
+ }
281
+ return { session, score, evidence };
282
+ });
283
+ candidates.sort((left, right) => right.score - left.score);
284
+ const best = candidates[0];
285
+ const runnerUp = candidates[1];
286
+ const unambiguous =
287
+ best &&
288
+ (best.score >= 85 ||
289
+ (best.score >= 65 && best.score - (runnerUp?.score || 0) >= 15));
290
+ workload.ownerSessionId = unambiguous ? best.session.id : null;
291
+ workload.ownerConfidence = !unambiguous
292
+ ? "unmatched"
293
+ : best.score >= 95
294
+ ? "exact"
295
+ : best.score >= 85
296
+ ? "strong"
297
+ : "inferred";
298
+ workload.ownerScore = unambiguous ? best.score : best?.score || 0;
299
+ workload.ownerEvidence = unambiguous
300
+ ? [...new Set(best.evidence)].slice(0, 6)
301
+ : best?.score
302
+ ? ["存在候选 Session,但证据不足或归属冲突"]
303
+ : ["没有找到对应的 rollout 启动证据"];
304
+ }
305
+ }
306
+
307
+ function parseHost(alias, result, previous) {
308
+ if (result.code !== 0) {
309
+ return {
310
+ alias,
311
+ reachable: false,
312
+ latencyMs: result.latencyMs,
313
+ error: result.timedOut
314
+ ? "资源扫描超时"
315
+ : cleanSshError(result.stderr || result.stdout),
316
+ hostname: null,
317
+ processes: [],
318
+ workloads: [],
319
+ panes: [],
320
+ sessions: [],
321
+ agents: [],
322
+ gpus: [],
323
+ };
324
+ }
325
+
326
+ const host = {
327
+ alias,
328
+ reachable: true,
329
+ latencyMs: result.latencyMs,
330
+ error: null,
331
+ inventoryError: null,
332
+ inventoryUpdatedAt: new Date().toISOString(),
333
+ hostname: alias,
334
+ processes: [],
335
+ workloads: [],
336
+ panes: [],
337
+ sessions: [],
338
+ agents: [],
339
+ gpus: [],
340
+ };
341
+ const previousSessions = new Map(
342
+ (previous?.sessions || []).map((session) => [session.path, session]),
343
+ );
344
+
345
+ for (const rawLine of result.stdout.split(/\r?\n/)) {
346
+ const line = rawLine.trimEnd();
347
+ if (!line) continue;
348
+ const fields = line.split("\t");
349
+
350
+ if (fields[0] === "META") {
351
+ host.hostname = fields.slice(1).join("\t") || alias;
352
+ } else if (fields[0] === "PROC" && fields.length >= 7) {
353
+ host.processes.push({
354
+ pid: Number(fields[1]),
355
+ elapsedSeconds: Number(fields[2]),
356
+ stat: fields[3],
357
+ tty: fields[4],
358
+ command: fields[5],
359
+ cwd: fields.slice(6).join("\t"),
360
+ cmdline: "",
361
+ sessionPaths: [],
362
+ });
363
+ } else if (fields[0] === "PROCESS_META" && fields[1]) {
364
+ try {
365
+ const metadata = JSON.parse(decodeBase64Url(fields[1]));
366
+ const process = host.processes.find(
367
+ (candidate) => candidate.pid === metadata.pid,
368
+ );
369
+ if (process) {
370
+ process.cmdline = metadata.cmdline || "";
371
+ process.sessionPaths = Array.isArray(metadata.sessionPaths)
372
+ ? metadata.sessionPaths
373
+ : [];
374
+ }
375
+ } catch {
376
+ // Keep this process explicitly unmatched when metadata cannot be decoded.
377
+ }
378
+ } else if (fields[0] === "WORKLOAD" && fields[1]) {
379
+ try {
380
+ host.workloads.push(JSON.parse(decodeBase64Url(fields[1])));
381
+ } catch {
382
+ // Keep scanning when one process record races with process exit.
383
+ }
384
+ } else if (fields[0] === "PANE" && fields.length >= 11) {
385
+ if (fields[1].startsWith("scope-app-server-")) continue;
386
+ host.panes.push({
387
+ session: fields[1],
388
+ pane: fields[2],
389
+ command: fields[3],
390
+ cwd: fields[4],
391
+ tty: fields[5].replace(/^\/dev\//, ""),
392
+ pid: Number(fields[6]),
393
+ activityAt: Number(fields[7]) * 1000 || null,
394
+ dead: fields[8] === "1",
395
+ exitStatus: fields[9] === "" ? null : Number(fields[9]),
396
+ preview: Buffer.from(fields[10] || "", "base64").toString("utf8").trimEnd(),
397
+ });
398
+ } else if (fields[0] === "GPU") {
399
+ const gpuFields = fields.slice(1).join("\t").split(",").map((item) => item.trim());
400
+ const hasUuid = gpuFields.length >= 6;
401
+ host.gpus.push({
402
+ index: Number(gpuFields[0]),
403
+ uuid: hasUuid ? gpuFields[1] || "" : "",
404
+ name: gpuFields[hasUuid ? 2 : 1] || "GPU",
405
+ utilization: Number(gpuFields[hasUuid ? 3 : 2]) || 0,
406
+ memoryUsed: Number(gpuFields[hasUuid ? 4 : 3]) || 0,
407
+ memoryTotal: Number(gpuFields[hasUuid ? 5 : 4]) || 0,
408
+ });
409
+ } else if (fields[0] === "SESSION" && fields[1]) {
410
+ try {
411
+ host.sessions.push(JSON.parse(decodeBase64Url(fields[1])));
412
+ } catch {
413
+ // Ignore a single malformed rollout record.
414
+ }
415
+ } else if (fields[0] === "SESSION_REF" && fields[1]) {
416
+ const cached = previousSessions.get(decodeBase64Url(fields[1]));
417
+ if (cached) host.sessions.push(cached);
418
+ }
419
+ }
420
+
421
+ host.sessions = preserveHostSessions(previous, host).sessions;
422
+ host.sessions.sort((a, b) => b.mtimeMs - a.mtimeMs);
423
+ const rootProcessCandidates = host.processes.filter(
424
+ (proc) =>
425
+ (proc.command === "codex" ||
426
+ (proc.command === "node" &&
427
+ /(?:^|\s)(?:\S*\/)?codex(?:\s|$)/.test(proc.cmdline || ""))) &&
428
+ !/(^|\s)app-server(?:\s|$)/.test(proc.cmdline || ""),
429
+ );
430
+ const rootProcesses = rootProcessCandidates.filter((process) => {
431
+ if (process.sessionPaths?.length) return true;
432
+ return !rootProcessCandidates.some(
433
+ (candidate) =>
434
+ candidate.pid !== process.pid &&
435
+ candidate.tty === process.tty &&
436
+ candidate.cwd === process.cwd &&
437
+ candidate.sessionPaths?.length,
438
+ );
439
+ });
440
+ const now = Date.now();
441
+
442
+ host.agents = rootProcesses.map((process) => {
443
+ const openPaths = new Set(process.sessionPaths || []);
444
+ const activeSessions = host.sessions.filter((session) =>
445
+ openPaths.has(session.path),
446
+ );
447
+ const rootSessions = activeSessions.filter((session) => !session.isSubagent);
448
+ const matched =
449
+ rootSessions.sort((a, b) => b.mtimeMs - a.mtimeMs)[0] ||
450
+ activeSessions.sort((a, b) => b.mtimeMs - a.mtimeMs)[0] ||
451
+ null;
452
+ const subagents = activeSessions
453
+ .filter((session) => session.isSubagent)
454
+ .sort((a, b) => b.mtimeMs - a.mtimeMs);
455
+ const pane = host.panes.find((item) => item.tty === process.tty) || null;
456
+ const lastActivityAt = activeSessions.reduce(
457
+ (latest, session) => Math.max(latest, session.mtimeMs || 0),
458
+ matched?.mtimeMs || 0,
459
+ );
460
+ const activityAgeMs = lastActivityAt ? now - lastActivityAt : Infinity;
461
+ let status = "idle";
462
+ if (activityAgeMs < 30_000) status = "working";
463
+ else if (
464
+ activeSessions.some((session) => session.turnState === "working") &&
465
+ activityAgeMs < 180_000
466
+ )
467
+ status = "working";
468
+ else if (
469
+ activeSessions.some((session) => session.lastError) &&
470
+ activityAgeMs < 300_000
471
+ )
472
+ status = "attention";
473
+
474
+ return {
475
+ id: `${alias}:${process.pid}`,
476
+ host: alias,
477
+ hostname: host.hostname,
478
+ pid: process.pid,
479
+ tty: process.tty,
480
+ cwd: process.cwd,
481
+ executable: (process.cmdline || "").split(/\s+/)[0] || "codex",
482
+ elapsedSeconds: process.elapsedSeconds,
483
+ status,
484
+ pane,
485
+ rollout: matched,
486
+ subagents,
487
+ mapping: {
488
+ rollout: matched ? "open-fd" : "unmatched",
489
+ tmux: pane ? "tty" : "unmatched",
490
+ },
491
+ lastActivityAt: lastActivityAt || null,
492
+ suggestedSummary: matched
493
+ ? heuristicSummary(matched, process.cwd)
494
+ : {
495
+ theme: `${path.posix.basename(process.cwd || "") || process.pid} 会话`,
496
+ category: "other",
497
+ objective: "尚未关联 rollout",
498
+ progress: "只能观察进程与 TTY",
499
+ result: "",
500
+ nextStep: "",
501
+ source: "rollout",
502
+ updatedAt: null,
503
+ },
504
+ title:
505
+ matched?.lastUser ||
506
+ (matched
507
+ ? `未命名会话 · ${path.posix.basename(process.cwd || "") || process.pid}`
508
+ : `未关联 rollout · ${path.posix.basename(process.cwd || "") || process.pid}`),
509
+ };
510
+ });
511
+ assignWorkloadOwners(host);
512
+
513
+ return host;
514
+ }
515
+
516
+ return { runSsh, parseHost };
517
+ }
@@ -0,0 +1,150 @@
1
+ /** Normalize protocol items for the same conversation renderer used by SSH sessions. */
2
+ function contentText(content) {
3
+ if (typeof content === "string") return content;
4
+ if (!Array.isArray(content)) return "";
5
+ return content
6
+ .map((part) =>
7
+ typeof part === "string"
8
+ ? part
9
+ : part.text || (part.type === "image" ? "[图片]" : ""),
10
+ )
11
+ .join("\n");
12
+ }
13
+ export function localThreadDialogue(
14
+ thread,
15
+ { limit = 10, before, dialogueOnly = false } = {},
16
+ ) {
17
+ const all = [];
18
+ for (const turn of thread.turns || []) {
19
+ for (const item of turn.items || []) {
20
+ let kind,
21
+ text = "",
22
+ title,
23
+ extra = {};
24
+ switch (item.type) {
25
+ case "userMessage":
26
+ kind = "user";
27
+ title = "User";
28
+ text = contentText(item.content);
29
+ break;
30
+ case "agentMessage":
31
+ kind = "assistant";
32
+ title = "Codex";
33
+ text = item.text || "";
34
+ extra.phase = item.phase;
35
+ break;
36
+ case "reasoning":
37
+ kind = "reasoning";
38
+ title = "思考摘要";
39
+ text = contentText(item.summary);
40
+ break;
41
+ case "commandExecution":
42
+ kind = "command";
43
+ title = "命令";
44
+ text = item.command || "";
45
+ extra = {
46
+ command: item.command,
47
+ output: (item.aggregatedOutput || "").slice(-20_000),
48
+ status: item.status,
49
+ };
50
+ break;
51
+ case "fileChange":
52
+ kind = "tool";
53
+ title = "文件修改";
54
+ text = (item.changes || [])
55
+ .map((c) => `${c.path}\n${c.diff || ""}`)
56
+ .join("\n");
57
+ break;
58
+ case "plan":
59
+ kind = "intermediate";
60
+ title = "计划";
61
+ text = item.text || "";
62
+ break;
63
+ default:
64
+ kind = "tool";
65
+ title = item.tool || item.type;
66
+ text = item.text || contentText(item.result?.content);
67
+ extra.status = item.status;
68
+ }
69
+ const category =
70
+ kind === "user" || (kind === "assistant" && item.phase !== "commentary")
71
+ ? "dialogue"
72
+ : ["assistant", "reasoning", "intermediate"].includes(kind)
73
+ ? "reasoning"
74
+ : "operations";
75
+ all.push({
76
+ id: `${turn.id}:${item.id}`,
77
+ kind,
78
+ category,
79
+ title,
80
+ text: text.slice(0, 200_000),
81
+ timestamp: turn.startedAt
82
+ ? new Date(turn.startedAt * 1000).toISOString()
83
+ : null,
84
+ turnId: turn.id,
85
+ ...extra,
86
+ });
87
+ }
88
+ if (turn.error?.message)
89
+ all.push({
90
+ id: `${turn.id}:error`,
91
+ kind: "error",
92
+ category: "operations",
93
+ title: "会话错误",
94
+ text: turn.error.message,
95
+ timestamp: null,
96
+ });
97
+ }
98
+ const end =
99
+ before === undefined || before === null || before === ""
100
+ ? all.length
101
+ : Math.min(all.length, Math.max(0, Math.floor(Number(before)) || 0));
102
+ const pageSize = Math.max(1, Math.min(100, Number(limit) || 10));
103
+ const candidates = all
104
+ .slice(0, end)
105
+ .map((event, index) => ({ event, index }))
106
+ .filter(({ event }) => event.category === "dialogue");
107
+ const start = candidates.length
108
+ ? candidates.slice(-pageSize)[0].index
109
+ : Math.max(0, end - pageSize);
110
+ const events = all
111
+ .slice(start, end)
112
+ .filter((e) => !dialogueOnly || e.category === "dialogue");
113
+ const counts = {};
114
+ for (const event of events)
115
+ counts[event.kind] = (counts[event.kind] || 0) + 1;
116
+ return {
117
+ path: thread.path || "",
118
+ totalLines: all.length,
119
+ totalBytes: 0,
120
+ scannedBytes: 0,
121
+ events,
122
+ counts,
123
+ toolEventCount: (counts.tool || 0) + (counts.command || 0),
124
+ omittedToolEvents: 0,
125
+ hiddenReasoningCount: 0,
126
+ pageSize,
127
+ hasMore: start > 0,
128
+ nextBefore: start > 0 ? start : null,
129
+ };
130
+ }
131
+ export async function readLocalDialogue(manager, host, sessionId, options) {
132
+ const record = manager
133
+ .sessionRecords()
134
+ .find((s) => s.host === host && s.sessionId === sessionId);
135
+ if (!record) throw new Error("本机会话尚未恢复,请稍后重试");
136
+ const connection = await manager.prepareHost(
137
+ host,
138
+ record.executable,
139
+ record.connectionKey,
140
+ );
141
+ try {
142
+ const { thread } = await connection.request("thread/read", { threadId: sessionId, includeTurns: true });
143
+ return localThreadDialogue(thread, options);
144
+ } catch (error) {
145
+ // The first turn can arrive before Codex flushes its new rollout metadata.
146
+ if (/rollout .* is empty/.test(error.message) && Date.now() - Date.parse(record.connectedAt || "") < 10_000)
147
+ return localThreadDialogue({ path: record.path, turns: [] }, options);
148
+ throw error;
149
+ }
150
+ }
@@ -0,0 +1,40 @@
1
+ import { mkdir, readdir, realpath, stat } from "node:fs/promises";
2
+ import path from "node:path";
3
+ import { LOCAL_HOST, workingDirectory } from "../../lib/execution-host.js";
4
+ import { validateDirectoryTarget } from "../workbench/directory-routes.mjs";
5
+
6
+ export async function localDirectory(value) {
7
+ workingDirectory(LOCAL_HOST, value);
8
+ const cwd = await realpath(value);
9
+ if (!(await stat(cwd)).isDirectory()) throw new Error("工作目录不是文件夹");
10
+ return cwd;
11
+ }
12
+ export async function localDirectories(input, creating, defaultCwd) {
13
+ if (creating) {
14
+ const parent = await localDirectory(input.parent);
15
+ validateDirectoryTarget({ parent: "/", name: input.name });
16
+ if (
17
+ process.platform === "win32" &&
18
+ /[<>:"|?*]|[. ]$|^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])(?:\.|$)/i.test(
19
+ input.name,
20
+ )
21
+ )
22
+ throw new Error("文件夹名称包含 Windows 不支持的字符或保留名称");
23
+ const cwd = path.join(parent, input.name);
24
+ await mkdir(cwd); // Never overwrite or recursively create an unreviewed parent.
25
+ return { cwd };
26
+ }
27
+ const cwd = await localDirectory(input.path || defaultCwd);
28
+ const entries = (await readdir(cwd, { withFileTypes: true }))
29
+ .filter((e) => e.isDirectory())
30
+ .sort((a, b) => a.name.localeCompare(b.name));
31
+ const parent = path.dirname(cwd);
32
+ return {
33
+ cwd,
34
+ parent: parent === cwd ? null : parent,
35
+ directories: entries
36
+ .slice(0, 500)
37
+ .map((e) => ({ name: e.name, path: path.join(cwd, e.name) })),
38
+ truncated: entries.length > 500,
39
+ };
40
+ }