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,347 @@
1
+ /** Remote probe, kept independent of HTTP and local mutable state. */
2
+ export const HISTORY_PROBE = String.raw`
3
+ import ast
4
+ import collections
5
+ import datetime
6
+ import glob
7
+ import json
8
+ import os
9
+ import sys
10
+
11
+ limit = max(1, min(300, int(sys.argv[1])))
12
+ order = sys.argv[2] if len(sys.argv) > 2 and sys.argv[2] == "oldest" else "recent"
13
+
14
+ def text_from_content(content):
15
+ if isinstance(content, str):
16
+ return content
17
+ if not isinstance(content, list):
18
+ return ""
19
+ parts = []
20
+ for item in content:
21
+ if not isinstance(item, dict) or item.get("type") == "encrypted_content":
22
+ continue
23
+ text = item.get("text")
24
+ if isinstance(text, str):
25
+ parts.append(text)
26
+ return "\n".join(parts)
27
+
28
+ def tool_output_text(value):
29
+ parsed = value
30
+ if isinstance(value, str):
31
+ stripped = value.strip()
32
+ for parser in (json.loads, ast.literal_eval):
33
+ try:
34
+ parsed = parser(stripped)
35
+ break
36
+ except Exception:
37
+ parsed = value
38
+ if isinstance(parsed, dict):
39
+ parsed = parsed.get("content") or parsed.get("output") or parsed
40
+ if isinstance(parsed, list):
41
+ extracted = text_from_content(parsed)
42
+ if extracted:
43
+ return extracted
44
+ return value if isinstance(value, str) else str(value or "")
45
+
46
+ def clean(value, limit=600):
47
+ if not isinstance(value, str):
48
+ return ""
49
+ value = " ".join(value.replace("\x00", "").split())
50
+ return value[:limit]
51
+
52
+ def parse_subagent_notification(value):
53
+ text = text_from_content(value) if not isinstance(value, str) else value
54
+ if not isinstance(text, str):
55
+ return None
56
+ stripped = text.strip()
57
+ markers = ("<subagent_notification>", "{subagent_notification}")
58
+ marker = next((item for item in markers if stripped.startswith(item)), None)
59
+ if not marker:
60
+ return None
61
+ try:
62
+ notification, _ = json.JSONDecoder().raw_decode(
63
+ stripped[len(marker):].strip()
64
+ )
65
+ except Exception:
66
+ return None
67
+ status = notification.get("status") if isinstance(notification, dict) else None
68
+ if not isinstance(status, dict):
69
+ return None
70
+ state = next(
71
+ (key for key in ("completed", "failed", "errored", "cancelled") if key in status),
72
+ "updated",
73
+ )
74
+ content = status.get(state)
75
+ if not isinstance(content, str):
76
+ content = json.dumps(content, ensure_ascii=False) if content is not None else ""
77
+ return content
78
+
79
+ def is_context_message(value):
80
+ if not isinstance(value, str):
81
+ return True
82
+ return value.lstrip().startswith((
83
+ "<environment_context>",
84
+ "<permissions",
85
+ "<INSTRUCTIONS>",
86
+ "<collaboration_mode>",
87
+ "<apps_instructions>",
88
+ "<plugins_instructions>",
89
+ "<skills_instructions>",
90
+ "<recommended_plugins>",
91
+ "<in-app-browser-context",
92
+ "# AGENTS.md instructions",
93
+ "A previous agent produced",
94
+ "You are Codex",
95
+ ))
96
+
97
+ def sampled_lines(filename):
98
+ size = os.path.getsize(filename)
99
+ with open(filename, "rb") as handle:
100
+ first = handle.readline()
101
+ head = handle.read(64000)
102
+ if size > 256000:
103
+ handle.seek(max(0, size - 192000))
104
+ tail = handle.read()
105
+ chunks = (first + head + b"\n" + tail).decode("utf-8", errors="replace")
106
+ seen = set()
107
+ for line in chunks.splitlines():
108
+ if line in seen:
109
+ continue
110
+ seen.add(line)
111
+ yield line
112
+
113
+ def timestamp_epoch(value):
114
+ if not isinstance(value, str) or not value:
115
+ return 0.0
116
+ try:
117
+ return datetime.datetime.fromisoformat(
118
+ value.replace("Z", "+00:00")
119
+ ).timestamp()
120
+ except Exception:
121
+ return 0.0
122
+
123
+ def latest_event(filename):
124
+ try:
125
+ size = os.path.getsize(filename)
126
+ with open(filename, "rb") as handle:
127
+ # The final event normally fits in a few KiB. This keeps ordering
128
+ # based on the true event timestamp without reading 256 KiB from
129
+ # every rollout as the previous implementation did.
130
+ handle.seek(max(0, size - 16384))
131
+ tail = handle.read().decode("utf-8", errors="replace")
132
+ for raw in reversed(tail.splitlines()):
133
+ try:
134
+ event = json.loads(raw)
135
+ except Exception:
136
+ continue
137
+ value = event.get("timestamp")
138
+ epoch = timestamp_epoch(value)
139
+ if epoch:
140
+ return epoch, value
141
+ except Exception:
142
+ pass
143
+ try:
144
+ return os.path.getmtime(filename), ""
145
+ except Exception:
146
+ return 0.0, ""
147
+
148
+ paths = list(dict.fromkeys(
149
+ glob.glob(os.path.expanduser("~/.codex/sessions/**/*.jsonl"), recursive=True)
150
+ + glob.glob(
151
+ os.path.expanduser("~/.codex/archived_sessions/**/*.jsonl"),
152
+ recursive=True,
153
+ )
154
+ ))
155
+ path_mtimes = {}
156
+ path_activity = {}
157
+ for filename in paths:
158
+ try:
159
+ path_mtimes[filename] = os.path.getmtime(filename)
160
+ except Exception:
161
+ path_mtimes[filename] = 0.0
162
+ path_activity[filename] = latest_event(filename)
163
+ paths.sort(
164
+ key=lambda item: (path_activity[item][0], path_mtimes[item]),
165
+ reverse=order == "recent",
166
+ )
167
+ records = []
168
+
169
+ for filename in paths:
170
+ if len(records) >= limit:
171
+ break
172
+ try:
173
+ with open(filename, "r", encoding="utf-8", errors="replace") as handle:
174
+ first_obj = json.loads(handle.readline())
175
+ meta = (
176
+ first_obj.get("payload", {})
177
+ if first_obj.get("type") == "session_meta"
178
+ else {}
179
+ )
180
+ except Exception:
181
+ continue
182
+
183
+ source = meta.get("source")
184
+ subagent = source.get("subagent", {}) if isinstance(source, dict) else {}
185
+ spawn = subagent.get("thread_spawn", {}) if isinstance(subagent, dict) else {}
186
+ if spawn or meta.get("parent_thread_id"):
187
+ continue
188
+
189
+ record = {
190
+ "id": meta.get("id") or meta.get("session_id") or os.path.basename(filename),
191
+ "rootSessionId": meta.get("session_id") or meta.get("id") or "",
192
+ "parentThreadId": "",
193
+ "agentPath": "",
194
+ "agentNickname": "",
195
+ "isSubagent": False,
196
+ "cwd": meta.get("cwd") or "",
197
+ "startedAt": meta.get("timestamp") or first_obj.get("timestamp"),
198
+ "cliVersion": meta.get("cli_version") or "",
199
+ "path": filename,
200
+ "archived": "/.codex/archived_sessions/" in filename.replace("\\", "/"),
201
+ "mtimeMs": int(path_mtimes.get(filename, 0.0) * 1000),
202
+ "firstUser": "",
203
+ "lastUser": "",
204
+ "lastAssistant": "",
205
+ "lastAction": "",
206
+ "lastError": "",
207
+ "userMessages": [],
208
+ "assistantMessages": [],
209
+ "model": "",
210
+ "reasoningEffort": "",
211
+ "approvalPolicy": "",
212
+ "sandboxPolicy": "",
213
+ "collaborationMode": "",
214
+ "account": None,
215
+ "tokenUsage": None,
216
+ "turnState": "idle",
217
+ "lastEventAt": path_activity.get(filename, (0, ""))[1]
218
+ or first_obj.get("timestamp"),
219
+ }
220
+
221
+ for raw in sampled_lines(filename):
222
+ try:
223
+ event = json.loads(raw)
224
+ except Exception:
225
+ continue
226
+ payload = event.get("payload", {})
227
+ if not isinstance(payload, dict):
228
+ payload = {}
229
+ event_type = event.get("type")
230
+ event_timestamp = event.get("timestamp")
231
+ if timestamp_epoch(event_timestamp) >= timestamp_epoch(record["lastEventAt"]):
232
+ record["lastEventAt"] = event_timestamp or record["lastEventAt"]
233
+
234
+ if event_type == "turn_context":
235
+ record["model"] = payload.get("model") or record["model"]
236
+ record["reasoningEffort"] = (
237
+ payload.get("effort")
238
+ or payload.get("reasoning_effort")
239
+ or record["reasoningEffort"]
240
+ )
241
+ record["approvalPolicy"] = (
242
+ payload.get("approval_policy") or record["approvalPolicy"]
243
+ )
244
+ sandbox = payload.get("sandbox_policy")
245
+ if isinstance(sandbox, dict):
246
+ record["sandboxPolicy"] = (
247
+ sandbox.get("type")
248
+ or sandbox.get("mode")
249
+ or record["sandboxPolicy"]
250
+ )
251
+ elif isinstance(sandbox, str):
252
+ record["sandboxPolicy"] = sandbox
253
+ collaboration = payload.get("collaboration_mode")
254
+ if isinstance(collaboration, dict):
255
+ record["collaborationMode"] = (
256
+ collaboration.get("mode")
257
+ or collaboration.get("name")
258
+ or record["collaborationMode"]
259
+ )
260
+ elif isinstance(collaboration, str):
261
+ record["collaborationMode"] = collaboration
262
+
263
+ if event_type == "event_msg":
264
+ kind = payload.get("type")
265
+ if kind in ("user_message", "user_input"):
266
+ raw_candidate = (
267
+ payload.get("message") or payload.get("text") or payload.get("content")
268
+ )
269
+ notification = parse_subagent_notification(raw_candidate)
270
+ if notification is not None:
271
+ candidate = clean(notification, 1200)
272
+ if candidate:
273
+ record["lastAssistant"] = candidate
274
+ record["assistantMessages"].append(candidate)
275
+ record["assistantMessages"] = record["assistantMessages"][-4:]
276
+ else:
277
+ candidate = clean(raw_candidate)
278
+ if candidate and not is_context_message(candidate):
279
+ record["firstUser"] = record["firstUser"] or candidate
280
+ record["lastUser"] = candidate
281
+ record["userMessages"].append(candidate)
282
+ record["userMessages"] = record["userMessages"][-4:]
283
+ elif kind == "agent_message":
284
+ candidate = clean(
285
+ payload.get("message") or payload.get("text"),
286
+ 1200,
287
+ )
288
+ if candidate:
289
+ record["lastAssistant"] = candidate
290
+ record["assistantMessages"].append(candidate)
291
+ record["assistantMessages"] = record["assistantMessages"][-4:]
292
+ elif kind in ("task_complete", "turn_complete", "task_completed"):
293
+ candidate = clean(payload.get("last_agent_message"), 1200)
294
+ if candidate:
295
+ record["lastAssistant"] = candidate
296
+ record["assistantMessages"].append(candidate)
297
+ record["assistantMessages"] = record["assistantMessages"][-4:]
298
+ continue
299
+
300
+ if event_type != "response_item":
301
+ continue
302
+ kind = payload.get("type")
303
+ role = payload.get("role")
304
+ if kind == "message" and role == "user":
305
+ raw_candidate = text_from_content(payload.get("content"))
306
+ notification = parse_subagent_notification(raw_candidate)
307
+ if notification is not None:
308
+ candidate = clean(notification, 1200)
309
+ if candidate:
310
+ record["lastAssistant"] = candidate
311
+ record["assistantMessages"].append(candidate)
312
+ record["assistantMessages"] = record["assistantMessages"][-4:]
313
+ else:
314
+ candidate = clean(raw_candidate)
315
+ if candidate and not is_context_message(candidate):
316
+ record["firstUser"] = record["firstUser"] or candidate
317
+ record["lastUser"] = candidate
318
+ record["userMessages"].append(candidate)
319
+ record["userMessages"] = record["userMessages"][-4:]
320
+ elif kind == "message" and role == "assistant":
321
+ candidate = clean(text_from_content(payload.get("content")), 1200)
322
+ if candidate:
323
+ record["lastAssistant"] = candidate
324
+ record["assistantMessages"].append(candidate)
325
+ record["assistantMessages"] = record["assistantMessages"][-4:]
326
+ elif kind in ("function_call", "custom_tool_call"):
327
+ name = payload.get("name") or "tool"
328
+ arguments = payload.get("arguments") or payload.get("input") or ""
329
+ record["lastAction"] = clean(f"{name}: {arguments}", 500)
330
+ elif kind in ("function_call_output", "custom_tool_call_output"):
331
+ output = clean(tool_output_text(payload.get("output")), 500)
332
+ if (
333
+ "exit code 1" in output.lower()
334
+ or "process exited with code 1" in output.lower()
335
+ or "traceback" in output.lower()
336
+ ):
337
+ record["lastError"] = output
338
+
339
+ records.append(record)
340
+
341
+ print(json.dumps({
342
+ "totalFiles": len(paths),
343
+ "limit": limit,
344
+ "truncated": len(records) >= limit,
345
+ "sessions": records,
346
+ }, ensure_ascii=False, separators=(",", ":")))
347
+ `;
@@ -0,0 +1,15 @@
1
+ export { PROFILE_LIST_PROBE } from './profile-list-probe.mjs';
2
+ export { PROFILE_WRITE_PROBE } from './profile-write-probe.mjs';
3
+ export { PROFILE_CANCEL_PROBE } from './profile-cancel-probe.mjs';
4
+ export { PROFILE_DELETE_PROBE } from './profile-delete-probe.mjs';
5
+ export { REMOTE_PROBE } from './remote-probe.mjs';
6
+ export { DIALOGUE_PROBE } from './dialogue-probe.mjs';
7
+ export { RAW_CONTEXT_PROBE } from './raw-context-probe.mjs';
8
+ export { HISTORY_PROBE } from './history-probe.mjs';
9
+ export { ASSISTANT_SEARCH_PROBE } from './assistant-search-probe.mjs';
10
+ export { SUBMISSION_PROBE } from './submission-probe.mjs';
11
+ export { TAKEOVER_PROBE } from './takeover-probe.mjs';
12
+ export { NEW_SESSION_PREFLIGHT } from './new-session-preflight.mjs';
13
+ export { VSCODE_OPEN_PREFLIGHT } from './vscode-open-preflight.mjs';
14
+ export { APP_SERVER_HANDOFF_PROBE } from './app-server-handoff-probe.mjs';
15
+ export { APP_SERVER_WRITER_PROBE } from './app-server-writer-probe.mjs';
@@ -0,0 +1,16 @@
1
+ /** Remote probe, kept independent of HTTP and local mutable state. */
2
+ export const NEW_SESSION_PREFLIGHT = String.raw`
3
+ import json
4
+ import os
5
+ import sys
6
+
7
+ requested = sys.argv[1]
8
+ if not requested.startswith("/") or "\n" in requested or "\r" in requested:
9
+ print("工作目录必须是远端绝对路径", file=sys.stderr)
10
+ raise SystemExit(2)
11
+ resolved = os.path.realpath(requested)
12
+ if not os.path.isdir(resolved):
13
+ print("工作目录不存在:" + resolved, file=sys.stderr)
14
+ raise SystemExit(3)
15
+ print(json.dumps({"ok": True, "cwd": resolved}, ensure_ascii=False))
16
+ `;
@@ -0,0 +1,19 @@
1
+ /** Remote probe, kept independent of HTTP and local mutable state. */
2
+ export const PROFILE_CANCEL_PROBE = String.raw`
3
+ import json
4
+ import os
5
+ import shutil
6
+ import sys
7
+
8
+ slug = sys.argv[1]
9
+ root = os.path.realpath(os.path.expanduser("~/.codex/scope-auth-profiles"))
10
+ target = os.path.realpath(os.path.join(root, slug))
11
+ if os.path.commonpath([root, target]) != root or target == root:
12
+ raise RuntimeError("拒绝清理 Profile 根目录之外的路径")
13
+ auth_path = os.path.join(target, "home", "auth.json")
14
+ removed = False
15
+ if os.path.isdir(target) and not os.path.isfile(auth_path):
16
+ shutil.rmtree(target)
17
+ removed = True
18
+ print(json.dumps({"ok": True, "removed": removed}, separators=(",", ":")))
19
+ `;
@@ -0,0 +1,28 @@
1
+ /** Remote probe, kept independent of HTTP and local mutable state. */
2
+ export const PROFILE_DELETE_PROBE = String.raw`
3
+ import json
4
+ import os
5
+ import shutil
6
+ import sys
7
+
8
+ slug, confirmation = sys.argv[1:3]
9
+ if confirmation != slug:
10
+ raise RuntimeError("删除确认与 Profile 不匹配")
11
+ root = os.path.realpath(os.path.expanduser("~/.codex/scope-auth-profiles"))
12
+ target = os.path.realpath(os.path.join(root, slug))
13
+ if os.path.commonpath([root, target]) != root or target == root:
14
+ raise RuntimeError("拒绝删除 Profile 根目录之外的路径")
15
+ marker_path = os.path.join(root, "active")
16
+ try:
17
+ with open(marker_path, "r", encoding="utf-8") as handle:
18
+ active_slug = handle.read().strip()
19
+ except Exception:
20
+ active_slug = ""
21
+ if active_slug == slug:
22
+ raise RuntimeError("当前正在使用的 Profile 不能删除;请先切换账号")
23
+ removed = False
24
+ if os.path.isdir(target):
25
+ shutil.rmtree(target)
26
+ removed = True
27
+ print(json.dumps({"ok": True, "slug": slug, "removed": removed}, separators=(",", ":")))
28
+ `;
@@ -0,0 +1,117 @@
1
+ /** Remote probe, kept independent of HTTP and local mutable state. */
2
+ export const PROFILE_LIST_PROBE = String.raw`
3
+ import hashlib
4
+ import ast
5
+ import base64
6
+ import json
7
+ import os
8
+
9
+ root = os.path.expanduser("~/.codex/scope-auth-profiles")
10
+ default_auth = os.path.expanduser("~/.codex/auth.json")
11
+ marker_slug = ""
12
+ try:
13
+ with open(os.path.join(root, "active"), "r", encoding="utf-8") as handle:
14
+ marker_slug = handle.read().strip()
15
+ except Exception:
16
+ pass
17
+
18
+ def digest(path):
19
+ try:
20
+ with open(path, "rb") as handle:
21
+ return hashlib.sha256(handle.read()).hexdigest()
22
+ except Exception:
23
+ return ""
24
+
25
+ default_digest = digest(default_auth)
26
+
27
+ def current_account(path):
28
+ try:
29
+ with open(path, "r", encoding="utf-8") as handle:
30
+ data = json.load(handle)
31
+ except Exception:
32
+ return None
33
+ tokens = data.get("tokens") if isinstance(data.get("tokens"), dict) else {}
34
+ candidates = [tokens.get("id_token"), data.get("id_token"), tokens.get("access_token")]
35
+ claims = {}
36
+ for token in candidates:
37
+ if not isinstance(token, str) or token.count(".") < 2:
38
+ continue
39
+ try:
40
+ segment = token.split(".")[1]
41
+ segment += "=" * (-len(segment) % 4)
42
+ claims = json.loads(base64.urlsafe_b64decode(segment).decode("utf-8"))
43
+ break
44
+ except Exception:
45
+ continue
46
+ auth_claims = claims.get("https://api.openai.com/auth")
47
+ if not isinstance(auth_claims, dict):
48
+ auth_claims = {}
49
+ email = claims.get("email") or auth_claims.get("email") or ""
50
+ plan = (
51
+ auth_claims.get("chatgpt_plan_type")
52
+ or claims.get("chatgpt_plan_type")
53
+ or claims.get("plan_type")
54
+ or "unknown"
55
+ )
56
+ mode = str(data.get("auth_mode") or "chatgpt").lower()
57
+ account_type = "apiKey" if "api" in mode and "chatgpt" not in mode else "chatgpt"
58
+ return {
59
+ "type": account_type,
60
+ "email": str(email)[:320],
61
+ "planType": str(plan)[:80],
62
+ }
63
+
64
+ def safe_account(value):
65
+ if not isinstance(value, dict):
66
+ return None
67
+ account_type = str(value.get("type") or "")[:40]
68
+ if account_type not in ("chatgpt", "apiKey", "amazonBedrock"):
69
+ return None
70
+ return {
71
+ "type": account_type,
72
+ "email": str(value.get("email") or "")[:320],
73
+ "planType": str(value.get("planType") or "")[:80],
74
+ }
75
+
76
+ profiles = []
77
+ if os.path.isdir(root):
78
+ for slug in sorted(os.listdir(root)):
79
+ directory = os.path.join(root, slug)
80
+ if not os.path.isdir(directory):
81
+ continue
82
+ auth_path = os.path.join(directory, "home", "auth.json")
83
+ metadata_path = os.path.join(directory, "metadata.json")
84
+ metadata = {}
85
+ try:
86
+ with open(metadata_path, "r", encoding="utf-8") as handle:
87
+ metadata = json.load(handle)
88
+ except Exception:
89
+ pass
90
+ profile_digest = digest(auth_path)
91
+ profiles.append({
92
+ "slug": slug,
93
+ "name": str(metadata.get("name") or slug)[:80],
94
+ "createdAt": metadata.get("createdAt"),
95
+ "updatedAt": metadata.get("updatedAt"),
96
+ "account": current_account(auth_path) or safe_account(metadata.get("account")),
97
+ "ready": bool(profile_digest),
98
+ "active": False,
99
+ "matchesDefault": bool(default_digest and profile_digest == default_digest),
100
+ })
101
+
102
+ ready_slugs = {item["slug"] for item in profiles if item["ready"]}
103
+ matching_slugs = [item["slug"] for item in profiles if item["matchesDefault"]]
104
+ active_slug = marker_slug if marker_slug in ready_slugs else ""
105
+ if not active_slug and len(matching_slugs) == 1:
106
+ active_slug = matching_slugs[0]
107
+ for item in profiles:
108
+ item["active"] = item["slug"] == active_slug
109
+ item.pop("matchesDefault", None)
110
+
111
+ print(json.dumps({
112
+ "profiles": profiles,
113
+ "defaultAuthPresent": bool(default_digest),
114
+ "activeProfile": active_slug or None,
115
+ "currentAccount": current_account(default_auth) if default_digest else None,
116
+ }, ensure_ascii=False, separators=(",", ":")))
117
+ `;
@@ -0,0 +1,111 @@
1
+ /** Remote probe, kept independent of HTTP and local mutable state. */
2
+ export const PROFILE_WRITE_PROBE = String.raw`
3
+ import base64
4
+ import json
5
+ import os
6
+ import shutil
7
+ import sys
8
+ import tempfile
9
+ from datetime import datetime, timezone
10
+
11
+ action, slug, encoded = sys.argv[1:4]
12
+ payload = json.loads(base64.b64decode(encoded).decode("utf-8"))
13
+ root = os.path.realpath(os.path.expanduser("~/.codex/scope-auth-profiles"))
14
+ profile_dir = os.path.realpath(os.path.join(root, slug))
15
+ if os.path.commonpath([root, profile_dir]) != root or profile_dir == root:
16
+ raise RuntimeError("拒绝访问 Profile 根目录之外的路径")
17
+ home_dir = os.path.join(profile_dir, "home")
18
+ auth_path = os.path.join(home_dir, "auth.json")
19
+ default_home = os.path.expanduser("~/.codex")
20
+ default_auth = os.path.join(default_home, "auth.json")
21
+ os.makedirs(home_dir, mode=0o700, exist_ok=True)
22
+ os.chmod(profile_dir, 0o700)
23
+ os.chmod(home_dir, 0o700)
24
+
25
+ def atomic_copy(source, target):
26
+ if not os.path.isfile(source):
27
+ raise RuntimeError("找不到远端 auth.json;请先在该主机登录 Codex")
28
+ os.makedirs(os.path.dirname(target), mode=0o700, exist_ok=True)
29
+ fd, temporary = tempfile.mkstemp(prefix=".scope-auth-", dir=os.path.dirname(target))
30
+ os.close(fd)
31
+ try:
32
+ shutil.copyfile(source, temporary)
33
+ os.chmod(temporary, 0o600)
34
+ os.replace(temporary, target)
35
+ finally:
36
+ try:
37
+ os.unlink(temporary)
38
+ except FileNotFoundError:
39
+ pass
40
+
41
+ if action == "save-current":
42
+ atomic_copy(default_auth, auth_path)
43
+ os.makedirs(root, mode=0o700, exist_ok=True)
44
+ fd, marker_tmp = tempfile.mkstemp(prefix=".active-", dir=root)
45
+ with os.fdopen(fd, "w", encoding="utf-8") as handle:
46
+ handle.write(slug + "\n")
47
+ os.replace(marker_tmp, os.path.join(root, "active"))
48
+ elif action == "select-default":
49
+ # Web default selection must not replace credentials used by live writers.
50
+ if not os.path.isfile(auth_path):
51
+ raise RuntimeError("该 Profile 尚未完成登录")
52
+ fd, marker_tmp = tempfile.mkstemp(prefix=".active-", dir=root)
53
+ with os.fdopen(fd, "w", encoding="utf-8") as handle:
54
+ handle.write(slug + "\n")
55
+ os.replace(marker_tmp, os.path.join(root, "active"))
56
+ elif action == "activate":
57
+ if not os.path.isfile(auth_path):
58
+ raise RuntimeError("该 Profile 尚未完成登录")
59
+ marker_path = os.path.join(root, "active")
60
+ try:
61
+ with open(marker_path, "r", encoding="utf-8") as handle:
62
+ previous_slug = handle.read().strip()
63
+ except Exception:
64
+ previous_slug = ""
65
+ if previous_slug and previous_slug != slug and os.path.isfile(default_auth):
66
+ previous_profile = os.path.realpath(os.path.join(root, previous_slug))
67
+ previous_home = os.path.join(previous_profile, "home")
68
+ if (
69
+ os.path.commonpath([root, previous_profile]) == root
70
+ and previous_profile != root
71
+ and os.path.isdir(previous_home)
72
+ # An isolated writer owns its refreshed credentials. Never replace
73
+ # them with a potentially older canonical-home token snapshot.
74
+ and not os.path.exists(os.path.join(previous_home, "app-server-control", "scope-account-" + previous_slug + ".sock"))
75
+ ):
76
+ atomic_copy(default_auth, os.path.join(previous_home, "auth.json"))
77
+ atomic_copy(auth_path, default_auth)
78
+ os.makedirs(root, mode=0o700, exist_ok=True)
79
+ fd, marker_tmp = tempfile.mkstemp(prefix=".active-", dir=root)
80
+ with os.fdopen(fd, "w", encoding="utf-8") as handle:
81
+ handle.write(slug + "\n")
82
+ os.replace(marker_tmp, marker_path)
83
+ elif action == "finalize":
84
+ if not os.path.isfile(auth_path):
85
+ raise RuntimeError("Device auth 已返回成功,但远端未生成 auth.json")
86
+ os.chmod(auth_path, 0o600)
87
+ else:
88
+ raise RuntimeError("未知 Profile 操作")
89
+
90
+ metadata_path = os.path.join(profile_dir, "metadata.json")
91
+ existing = {}
92
+ try:
93
+ with open(metadata_path, "r", encoding="utf-8") as handle:
94
+ existing = json.load(handle)
95
+ except Exception:
96
+ pass
97
+ now = datetime.now(timezone.utc).isoformat().replace("+00:00", "Z")
98
+ metadata = {
99
+ "name": str(payload.get("name") or slug)[:80],
100
+ "createdAt": existing.get("createdAt") or now,
101
+ "updatedAt": now,
102
+ "account": payload.get("account") if isinstance(payload.get("account"), dict) else existing.get("account"),
103
+ }
104
+ fd, metadata_tmp = tempfile.mkstemp(prefix=".metadata-", dir=profile_dir)
105
+ with os.fdopen(fd, "w", encoding="utf-8") as handle:
106
+ json.dump(metadata, handle, ensure_ascii=False, separators=(",", ":"))
107
+ handle.write("\n")
108
+ os.chmod(metadata_tmp, 0o600)
109
+ os.replace(metadata_tmp, metadata_path)
110
+ print(json.dumps({"ok": True, "slug": slug, "action": action}, separators=(",", ":")))
111
+ `;