@boxes-dev/dvb-runtime 1.0.297 → 1.0.299

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 (488) hide show
  1. package/dist/bin/.bundle-state.json +2 -2
  2. package/dist/bin/dvb.cjs +6 -6
  3. package/dist/bin/dvbd.cjs +6 -6
  4. package/package.json +7 -5
  5. package/dist/devbox/auth.d.ts +0 -22
  6. package/dist/devbox/auth.d.ts.map +0 -1
  7. package/dist/devbox/auth.js +0 -233
  8. package/dist/devbox/auth.js.map +0 -1
  9. package/dist/devbox/browser.d.ts +0 -19
  10. package/dist/devbox/browser.d.ts.map +0 -1
  11. package/dist/devbox/browser.js +0 -60
  12. package/dist/devbox/browser.js.map +0 -1
  13. package/dist/devbox/cli.d.ts +0 -7
  14. package/dist/devbox/cli.d.ts.map +0 -1
  15. package/dist/devbox/cli.js +0 -124
  16. package/dist/devbox/cli.js.map +0 -1
  17. package/dist/devbox/commandRegistry/args.d.ts +0 -18
  18. package/dist/devbox/commandRegistry/args.d.ts.map +0 -1
  19. package/dist/devbox/commandRegistry/args.js +0 -107
  20. package/dist/devbox/commandRegistry/args.js.map +0 -1
  21. package/dist/devbox/commandRegistry/catalog.d.ts +0 -4
  22. package/dist/devbox/commandRegistry/catalog.d.ts.map +0 -1
  23. package/dist/devbox/commandRegistry/catalog.js +0 -763
  24. package/dist/devbox/commandRegistry/catalog.js.map +0 -1
  25. package/dist/devbox/commandRegistry/dispatch.d.ts +0 -3
  26. package/dist/devbox/commandRegistry/dispatch.d.ts.map +0 -1
  27. package/dist/devbox/commandRegistry/dispatch.js +0 -61
  28. package/dist/devbox/commandRegistry/dispatch.js.map +0 -1
  29. package/dist/devbox/commandRegistry/errors.d.ts +0 -8
  30. package/dist/devbox/commandRegistry/errors.d.ts.map +0 -1
  31. package/dist/devbox/commandRegistry/errors.js +0 -26
  32. package/dist/devbox/commandRegistry/errors.js.map +0 -1
  33. package/dist/devbox/commandRegistry/help.d.ts +0 -5
  34. package/dist/devbox/commandRegistry/help.d.ts.map +0 -1
  35. package/dist/devbox/commandRegistry/help.js +0 -94
  36. package/dist/devbox/commandRegistry/help.js.map +0 -1
  37. package/dist/devbox/commandRegistry/resolve.d.ts +0 -7
  38. package/dist/devbox/commandRegistry/resolve.d.ts.map +0 -1
  39. package/dist/devbox/commandRegistry/resolve.js +0 -32
  40. package/dist/devbox/commandRegistry/resolve.js.map +0 -1
  41. package/dist/devbox/commandRegistry/tab.d.ts +0 -10
  42. package/dist/devbox/commandRegistry/tab.d.ts.map +0 -1
  43. package/dist/devbox/commandRegistry/tab.js +0 -83
  44. package/dist/devbox/commandRegistry/tab.js.map +0 -1
  45. package/dist/devbox/commandRegistry/types.d.ts +0 -32
  46. package/dist/devbox/commandRegistry/types.d.ts.map +0 -1
  47. package/dist/devbox/commandRegistry/types.js +0 -2
  48. package/dist/devbox/commandRegistry/types.js.map +0 -1
  49. package/dist/devbox/commands/agent.d.ts +0 -52
  50. package/dist/devbox/commands/agent.d.ts.map +0 -1
  51. package/dist/devbox/commands/agent.js +0 -397
  52. package/dist/devbox/commands/agent.js.map +0 -1
  53. package/dist/devbox/commands/boxSelect.d.ts +0 -25
  54. package/dist/devbox/commands/boxSelect.d.ts.map +0 -1
  55. package/dist/devbox/commands/boxSelect.js +0 -94
  56. package/dist/devbox/commands/boxSelect.js.map +0 -1
  57. package/dist/devbox/commands/checkpoint.d.ts +0 -9
  58. package/dist/devbox/commands/checkpoint.d.ts.map +0 -1
  59. package/dist/devbox/commands/checkpoint.js +0 -105
  60. package/dist/devbox/commands/checkpoint.js.map +0 -1
  61. package/dist/devbox/commands/commandProvider.d.ts +0 -33
  62. package/dist/devbox/commands/commandProvider.d.ts.map +0 -1
  63. package/dist/devbox/commands/commandProvider.js +0 -156
  64. package/dist/devbox/commands/commandProvider.js.map +0 -1
  65. package/dist/devbox/commands/connect.d.ts +0 -39
  66. package/dist/devbox/commands/connect.d.ts.map +0 -1
  67. package/dist/devbox/commands/connect.js +0 -1367
  68. package/dist/devbox/commands/connect.js.map +0 -1
  69. package/dist/devbox/commands/connectSessionMapping.d.ts +0 -64
  70. package/dist/devbox/commands/connectSessionMapping.d.ts.map +0 -1
  71. package/dist/devbox/commands/connectSessionMapping.js +0 -153
  72. package/dist/devbox/commands/connectSessionMapping.js.map +0 -1
  73. package/dist/devbox/commands/cp.d.ts +0 -60
  74. package/dist/devbox/commands/cp.d.ts.map +0 -1
  75. package/dist/devbox/commands/cp.js +0 -383
  76. package/dist/devbox/commands/cp.js.map +0 -1
  77. package/dist/devbox/commands/daemon.d.ts +0 -4
  78. package/dist/devbox/commands/daemon.d.ts.map +0 -1
  79. package/dist/devbox/commands/daemon.js +0 -49
  80. package/dist/devbox/commands/daemon.js.map +0 -1
  81. package/dist/devbox/commands/destroy.d.ts +0 -2
  82. package/dist/devbox/commands/destroy.d.ts.map +0 -1
  83. package/dist/devbox/commands/destroy.js +0 -204
  84. package/dist/devbox/commands/destroy.js.map +0 -1
  85. package/dist/devbox/commands/destroyE2b.d.ts +0 -22
  86. package/dist/devbox/commands/destroyE2b.d.ts.map +0 -1
  87. package/dist/devbox/commands/destroyE2b.js +0 -12
  88. package/dist/devbox/commands/destroyE2b.js.map +0 -1
  89. package/dist/devbox/commands/destroyLocalState.d.ts +0 -34
  90. package/dist/devbox/commands/destroyLocalState.d.ts.map +0 -1
  91. package/dist/devbox/commands/destroyLocalState.js +0 -187
  92. package/dist/devbox/commands/destroyLocalState.js.map +0 -1
  93. package/dist/devbox/commands/destroyModal.d.ts +0 -21
  94. package/dist/devbox/commands/destroyModal.d.ts.map +0 -1
  95. package/dist/devbox/commands/destroyModal.js +0 -13
  96. package/dist/devbox/commands/destroyModal.js.map +0 -1
  97. package/dist/devbox/commands/destroyShared.d.ts +0 -14
  98. package/dist/devbox/commands/destroyShared.d.ts.map +0 -1
  99. package/dist/devbox/commands/destroyShared.js +0 -37
  100. package/dist/devbox/commands/destroyShared.js.map +0 -1
  101. package/dist/devbox/commands/fork.d.ts +0 -9
  102. package/dist/devbox/commands/fork.d.ts.map +0 -1
  103. package/dist/devbox/commands/fork.js +0 -94
  104. package/dist/devbox/commands/fork.js.map +0 -1
  105. package/dist/devbox/commands/ide.d.ts +0 -35
  106. package/dist/devbox/commands/ide.d.ts.map +0 -1
  107. package/dist/devbox/commands/ide.js +0 -987
  108. package/dist/devbox/commands/ide.js.map +0 -1
  109. package/dist/devbox/commands/init/args.d.ts +0 -18
  110. package/dist/devbox/commands/init/args.d.ts.map +0 -1
  111. package/dist/devbox/commands/init/args.js +0 -44
  112. package/dist/devbox/commands/init/args.js.map +0 -1
  113. package/dist/devbox/commands/init/clack.d.ts +0 -22
  114. package/dist/devbox/commands/init/clack.d.ts.map +0 -1
  115. package/dist/devbox/commands/init/clack.js +0 -158
  116. package/dist/devbox/commands/init/clack.js.map +0 -1
  117. package/dist/devbox/commands/init/claudeBootstrap.d.ts +0 -49
  118. package/dist/devbox/commands/init/claudeBootstrap.d.ts.map +0 -1
  119. package/dist/devbox/commands/init/claudeBootstrap.js +0 -504
  120. package/dist/devbox/commands/init/claudeBootstrap.js.map +0 -1
  121. package/dist/devbox/commands/init/codex/artifacts.d.ts +0 -49
  122. package/dist/devbox/commands/init/codex/artifacts.d.ts.map +0 -1
  123. package/dist/devbox/commands/init/codex/artifacts.js +0 -278
  124. package/dist/devbox/commands/init/codex/artifacts.js.map +0 -1
  125. package/dist/devbox/commands/init/codex/config.d.ts +0 -6
  126. package/dist/devbox/commands/init/codex/config.d.ts.map +0 -1
  127. package/dist/devbox/commands/init/codex/config.js +0 -43
  128. package/dist/devbox/commands/init/codex/config.js.map +0 -1
  129. package/dist/devbox/commands/init/codex/events.d.ts +0 -14
  130. package/dist/devbox/commands/init/codex/events.d.ts.map +0 -1
  131. package/dist/devbox/commands/init/codex/events.js +0 -435
  132. package/dist/devbox/commands/init/codex/events.js.map +0 -1
  133. package/dist/devbox/commands/init/codex/execConfig.d.ts +0 -5
  134. package/dist/devbox/commands/init/codex/execConfig.d.ts.map +0 -1
  135. package/dist/devbox/commands/init/codex/execConfig.js +0 -10
  136. package/dist/devbox/commands/init/codex/execConfig.js.map +0 -1
  137. package/dist/devbox/commands/init/codex/index.d.ts +0 -136
  138. package/dist/devbox/commands/init/codex/index.d.ts.map +0 -1
  139. package/dist/devbox/commands/init/codex/index.js +0 -1115
  140. package/dist/devbox/commands/init/codex/index.js.map +0 -1
  141. package/dist/devbox/commands/init/codex/local.d.ts +0 -124
  142. package/dist/devbox/commands/init/codex/local.d.ts.map +0 -1
  143. package/dist/devbox/commands/init/codex/local.js +0 -1381
  144. package/dist/devbox/commands/init/codex/local.js.map +0 -1
  145. package/dist/devbox/commands/init/codex/localExecArgs.d.ts +0 -25
  146. package/dist/devbox/commands/init/codex/localExecArgs.d.ts.map +0 -1
  147. package/dist/devbox/commands/init/codex/localExecArgs.js +0 -48
  148. package/dist/devbox/commands/init/codex/localExecArgs.js.map +0 -1
  149. package/dist/devbox/commands/init/codex/plan.d.ts +0 -99
  150. package/dist/devbox/commands/init/codex/plan.d.ts.map +0 -1
  151. package/dist/devbox/commands/init/codex/plan.js +0 -231
  152. package/dist/devbox/commands/init/codex/plan.js.map +0 -1
  153. package/dist/devbox/commands/init/codex/prompts.d.ts +0 -9
  154. package/dist/devbox/commands/init/codex/prompts.d.ts.map +0 -1
  155. package/dist/devbox/commands/init/codex/prompts.js +0 -51
  156. package/dist/devbox/commands/init/codex/prompts.js.map +0 -1
  157. package/dist/devbox/commands/init/codex/proxy.d.ts +0 -10
  158. package/dist/devbox/commands/init/codex/proxy.d.ts.map +0 -1
  159. package/dist/devbox/commands/init/codex/proxy.js +0 -32
  160. package/dist/devbox/commands/init/codex/proxy.js.map +0 -1
  161. package/dist/devbox/commands/init/codex/remote.d.ts +0 -96
  162. package/dist/devbox/commands/init/codex/remote.d.ts.map +0 -1
  163. package/dist/devbox/commands/init/codex/remote.js +0 -927
  164. package/dist/devbox/commands/init/codex/remote.js.map +0 -1
  165. package/dist/devbox/commands/init/codex/retry.d.ts +0 -17
  166. package/dist/devbox/commands/init/codex/retry.d.ts.map +0 -1
  167. package/dist/devbox/commands/init/codex/retry.js +0 -17
  168. package/dist/devbox/commands/init/codex/retry.js.map +0 -1
  169. package/dist/devbox/commands/init/codex/scanStatus.d.ts +0 -5
  170. package/dist/devbox/commands/init/codex/scanStatus.d.ts.map +0 -1
  171. package/dist/devbox/commands/init/codex/scanStatus.js +0 -27
  172. package/dist/devbox/commands/init/codex/scanStatus.js.map +0 -1
  173. package/dist/devbox/commands/init/codex/shellHistory.d.ts +0 -39
  174. package/dist/devbox/commands/init/codex/shellHistory.d.ts.map +0 -1
  175. package/dist/devbox/commands/init/codex/shellHistory.js +0 -258
  176. package/dist/devbox/commands/init/codex/shellHistory.js.map +0 -1
  177. package/dist/devbox/commands/init/codex/template.d.ts +0 -3
  178. package/dist/devbox/commands/init/codex/template.d.ts.map +0 -1
  179. package/dist/devbox/commands/init/codex/template.js +0 -3
  180. package/dist/devbox/commands/init/codex/template.js.map +0 -1
  181. package/dist/devbox/commands/init/finalizeFlow.d.ts +0 -95
  182. package/dist/devbox/commands/init/finalizeFlow.d.ts.map +0 -1
  183. package/dist/devbox/commands/init/finalizeFlow.js +0 -786
  184. package/dist/devbox/commands/init/finalizeFlow.js.map +0 -1
  185. package/dist/devbox/commands/init/index.d.ts +0 -11
  186. package/dist/devbox/commands/init/index.d.ts.map +0 -1
  187. package/dist/devbox/commands/init/index.js +0 -1058
  188. package/dist/devbox/commands/init/index.js.map +0 -1
  189. package/dist/devbox/commands/init/modal.d.ts +0 -5
  190. package/dist/devbox/commands/init/modal.d.ts.map +0 -1
  191. package/dist/devbox/commands/init/modal.js +0 -4
  192. package/dist/devbox/commands/init/modal.js.map +0 -1
  193. package/dist/devbox/commands/init/packaging.d.ts +0 -5
  194. package/dist/devbox/commands/init/packaging.d.ts.map +0 -1
  195. package/dist/devbox/commands/init/packaging.js +0 -81
  196. package/dist/devbox/commands/init/packaging.js.map +0 -1
  197. package/dist/devbox/commands/init/progress.d.ts +0 -31
  198. package/dist/devbox/commands/init/progress.d.ts.map +0 -1
  199. package/dist/devbox/commands/init/progress.js +0 -205
  200. package/dist/devbox/commands/init/progress.js.map +0 -1
  201. package/dist/devbox/commands/init/provider/e2b.d.ts +0 -29
  202. package/dist/devbox/commands/init/provider/e2b.d.ts.map +0 -1
  203. package/dist/devbox/commands/init/provider/e2b.js +0 -130
  204. package/dist/devbox/commands/init/provider/e2b.js.map +0 -1
  205. package/dist/devbox/commands/init/provider/e2bRuntime.d.ts +0 -39
  206. package/dist/devbox/commands/init/provider/e2bRuntime.d.ts.map +0 -1
  207. package/dist/devbox/commands/init/provider/e2bRuntime.js +0 -679
  208. package/dist/devbox/commands/init/provider/e2bRuntime.js.map +0 -1
  209. package/dist/devbox/commands/init/provider/index.d.ts +0 -8
  210. package/dist/devbox/commands/init/provider/index.d.ts.map +0 -1
  211. package/dist/devbox/commands/init/provider/index.js +0 -5
  212. package/dist/devbox/commands/init/provider/index.js.map +0 -1
  213. package/dist/devbox/commands/init/provider/modal.d.ts +0 -34
  214. package/dist/devbox/commands/init/provider/modal.d.ts.map +0 -1
  215. package/dist/devbox/commands/init/provider/modal.js +0 -274
  216. package/dist/devbox/commands/init/provider/modal.js.map +0 -1
  217. package/dist/devbox/commands/init/provider/modalRuntime.d.ts +0 -3
  218. package/dist/devbox/commands/init/provider/modalRuntime.d.ts.map +0 -1
  219. package/dist/devbox/commands/init/provider/modalRuntime.js +0 -2
  220. package/dist/devbox/commands/init/provider/modalRuntime.js.map +0 -1
  221. package/dist/devbox/commands/init/provider/resolve.d.ts +0 -44
  222. package/dist/devbox/commands/init/provider/resolve.d.ts.map +0 -1
  223. package/dist/devbox/commands/init/provider/resolve.js +0 -172
  224. package/dist/devbox/commands/init/provider/resolve.js.map +0 -1
  225. package/dist/devbox/commands/init/provider/shared.d.ts +0 -10
  226. package/dist/devbox/commands/init/provider/shared.d.ts.map +0 -1
  227. package/dist/devbox/commands/init/provider/shared.js +0 -2
  228. package/dist/devbox/commands/init/provider/shared.js.map +0 -1
  229. package/dist/devbox/commands/init/provider/sprites.d.ts +0 -30
  230. package/dist/devbox/commands/init/provider/sprites.d.ts.map +0 -1
  231. package/dist/devbox/commands/init/provider/sprites.js +0 -183
  232. package/dist/devbox/commands/init/provider/sprites.js.map +0 -1
  233. package/dist/devbox/commands/init/provider/types.d.ts +0 -19
  234. package/dist/devbox/commands/init/provider/types.d.ts.map +0 -1
  235. package/dist/devbox/commands/init/provider/types.js +0 -2
  236. package/dist/devbox/commands/init/provider/types.js.map +0 -1
  237. package/dist/devbox/commands/init/provisionFlow.d.ts +0 -53
  238. package/dist/devbox/commands/init/provisionFlow.d.ts.map +0 -1
  239. package/dist/devbox/commands/init/provisionFlow.js +0 -541
  240. package/dist/devbox/commands/init/provisionFlow.js.map +0 -1
  241. package/dist/devbox/commands/init/registry.d.ts +0 -15
  242. package/dist/devbox/commands/init/registry.d.ts.map +0 -1
  243. package/dist/devbox/commands/init/registry.js +0 -38
  244. package/dist/devbox/commands/init/registry.js.map +0 -1
  245. package/dist/devbox/commands/init/remote.d.ts +0 -48
  246. package/dist/devbox/commands/init/remote.d.ts.map +0 -1
  247. package/dist/devbox/commands/init/remote.js +0 -766
  248. package/dist/devbox/commands/init/remote.js.map +0 -1
  249. package/dist/devbox/commands/init/repo.d.ts +0 -45
  250. package/dist/devbox/commands/init/repo.d.ts.map +0 -1
  251. package/dist/devbox/commands/init/repo.js +0 -235
  252. package/dist/devbox/commands/init/repo.js.map +0 -1
  253. package/dist/devbox/commands/init/retryableErrors.d.ts +0 -4
  254. package/dist/devbox/commands/init/retryableErrors.d.ts.map +0 -1
  255. package/dist/devbox/commands/init/retryableErrors.js +0 -42
  256. package/dist/devbox/commands/init/retryableErrors.js.map +0 -1
  257. package/dist/devbox/commands/init/scanProgress.d.ts +0 -18
  258. package/dist/devbox/commands/init/scanProgress.d.ts.map +0 -1
  259. package/dist/devbox/commands/init/scanProgress.js +0 -47
  260. package/dist/devbox/commands/init/scanProgress.js.map +0 -1
  261. package/dist/devbox/commands/init/session.d.ts +0 -72
  262. package/dist/devbox/commands/init/session.d.ts.map +0 -1
  263. package/dist/devbox/commands/init/session.js +0 -348
  264. package/dist/devbox/commands/init/session.js.map +0 -1
  265. package/dist/devbox/commands/init/setupArtifactsValidation.d.ts +0 -28
  266. package/dist/devbox/commands/init/setupArtifactsValidation.d.ts.map +0 -1
  267. package/dist/devbox/commands/init/setupArtifactsValidation.js +0 -113
  268. package/dist/devbox/commands/init/setupArtifactsValidation.js.map +0 -1
  269. package/dist/devbox/commands/init/setupPlanFlow.d.ts +0 -34
  270. package/dist/devbox/commands/init/setupPlanFlow.d.ts.map +0 -1
  271. package/dist/devbox/commands/init/setupPlanFlow.js +0 -967
  272. package/dist/devbox/commands/init/setupPlanFlow.js.map +0 -1
  273. package/dist/devbox/commands/init/ssh.d.ts +0 -19
  274. package/dist/devbox/commands/init/ssh.d.ts.map +0 -1
  275. package/dist/devbox/commands/init/ssh.js +0 -276
  276. package/dist/devbox/commands/init/ssh.js.map +0 -1
  277. package/dist/devbox/commands/init/state.d.ts +0 -73
  278. package/dist/devbox/commands/init/state.d.ts.map +0 -1
  279. package/dist/devbox/commands/init/state.js +0 -118
  280. package/dist/devbox/commands/init/state.js.map +0 -1
  281. package/dist/devbox/commands/init/statusFlow.d.ts +0 -27
  282. package/dist/devbox/commands/init/statusFlow.d.ts.map +0 -1
  283. package/dist/devbox/commands/init/statusFlow.js +0 -160
  284. package/dist/devbox/commands/init/statusFlow.js.map +0 -1
  285. package/dist/devbox/commands/list.d.ts +0 -35
  286. package/dist/devbox/commands/list.d.ts.map +0 -1
  287. package/dist/devbox/commands/list.js +0 -311
  288. package/dist/devbox/commands/list.js.map +0 -1
  289. package/dist/devbox/commands/listFormatting.d.ts +0 -27
  290. package/dist/devbox/commands/listFormatting.d.ts.map +0 -1
  291. package/dist/devbox/commands/listFormatting.js +0 -155
  292. package/dist/devbox/commands/listFormatting.js.map +0 -1
  293. package/dist/devbox/commands/logout.d.ts +0 -2
  294. package/dist/devbox/commands/logout.d.ts.map +0 -1
  295. package/dist/devbox/commands/logout.js +0 -64
  296. package/dist/devbox/commands/logout.js.map +0 -1
  297. package/dist/devbox/commands/managedProviderClient.d.ts +0 -24
  298. package/dist/devbox/commands/managedProviderClient.d.ts.map +0 -1
  299. package/dist/devbox/commands/managedProviderClient.js +0 -42
  300. package/dist/devbox/commands/managedProviderClient.js.map +0 -1
  301. package/dist/devbox/commands/managedProviderContext.d.ts +0 -34
  302. package/dist/devbox/commands/managedProviderContext.d.ts.map +0 -1
  303. package/dist/devbox/commands/managedProviderContext.js +0 -34
  304. package/dist/devbox/commands/managedProviderContext.js.map +0 -1
  305. package/dist/devbox/commands/mount.d.ts +0 -25
  306. package/dist/devbox/commands/mount.d.ts.map +0 -1
  307. package/dist/devbox/commands/mount.js +0 -200
  308. package/dist/devbox/commands/mount.js.map +0 -1
  309. package/dist/devbox/commands/ports.d.ts +0 -11
  310. package/dist/devbox/commands/ports.d.ts.map +0 -1
  311. package/dist/devbox/commands/ports.js +0 -183
  312. package/dist/devbox/commands/ports.js.map +0 -1
  313. package/dist/devbox/commands/power.d.ts +0 -10
  314. package/dist/devbox/commands/power.d.ts.map +0 -1
  315. package/dist/devbox/commands/power.js +0 -139
  316. package/dist/devbox/commands/power.js.map +0 -1
  317. package/dist/devbox/commands/provider/daemonRuntimeShared.d.ts +0 -25
  318. package/dist/devbox/commands/provider/daemonRuntimeShared.d.ts.map +0 -1
  319. package/dist/devbox/commands/provider/daemonRuntimeShared.js +0 -217
  320. package/dist/devbox/commands/provider/daemonRuntimeShared.js.map +0 -1
  321. package/dist/devbox/commands/provider/directDaemonRuntime.d.ts +0 -106
  322. package/dist/devbox/commands/provider/directDaemonRuntime.d.ts.map +0 -1
  323. package/dist/devbox/commands/provider/directDaemonRuntime.js +0 -1442
  324. package/dist/devbox/commands/provider/directDaemonRuntime.js.map +0 -1
  325. package/dist/devbox/commands/provider/e2bCommandContext.d.ts +0 -11
  326. package/dist/devbox/commands/provider/e2bCommandContext.d.ts.map +0 -1
  327. package/dist/devbox/commands/provider/e2bCommandContext.js +0 -16
  328. package/dist/devbox/commands/provider/e2bCommandContext.js.map +0 -1
  329. package/dist/devbox/commands/provider/e2bLifecycleShared.d.ts +0 -20
  330. package/dist/devbox/commands/provider/e2bLifecycleShared.d.ts.map +0 -1
  331. package/dist/devbox/commands/provider/e2bLifecycleShared.js +0 -42
  332. package/dist/devbox/commands/provider/e2bLifecycleShared.js.map +0 -1
  333. package/dist/devbox/commands/provider/modalCommandContext.d.ts +0 -22
  334. package/dist/devbox/commands/provider/modalCommandContext.d.ts.map +0 -1
  335. package/dist/devbox/commands/provider/modalCommandContext.js +0 -47
  336. package/dist/devbox/commands/provider/modalCommandContext.js.map +0 -1
  337. package/dist/devbox/commands/provider/modalLifecycle.d.ts +0 -158
  338. package/dist/devbox/commands/provider/modalLifecycle.d.ts.map +0 -1
  339. package/dist/devbox/commands/provider/modalLifecycle.js +0 -702
  340. package/dist/devbox/commands/provider/modalLifecycle.js.map +0 -1
  341. package/dist/devbox/commands/provider/modalRuntime.d.ts +0 -25
  342. package/dist/devbox/commands/provider/modalRuntime.d.ts.map +0 -1
  343. package/dist/devbox/commands/provider/modalRuntime.js +0 -791
  344. package/dist/devbox/commands/provider/modalRuntime.js.map +0 -1
  345. package/dist/devbox/commands/provider/runtimeTypes.d.ts +0 -8
  346. package/dist/devbox/commands/provider/runtimeTypes.d.ts.map +0 -1
  347. package/dist/devbox/commands/provider/runtimeTypes.js +0 -2
  348. package/dist/devbox/commands/provider/runtimeTypes.js.map +0 -1
  349. package/dist/devbox/commands/providerClient.d.ts +0 -82
  350. package/dist/devbox/commands/providerClient.d.ts.map +0 -1
  351. package/dist/devbox/commands/providerClient.js +0 -719
  352. package/dist/devbox/commands/providerClient.js.map +0 -1
  353. package/dist/devbox/commands/reboot.d.ts +0 -8
  354. package/dist/devbox/commands/reboot.d.ts.map +0 -1
  355. package/dist/devbox/commands/reboot.js +0 -100
  356. package/dist/devbox/commands/reboot.js.map +0 -1
  357. package/dist/devbox/commands/reset.d.ts +0 -30
  358. package/dist/devbox/commands/reset.d.ts.map +0 -1
  359. package/dist/devbox/commands/reset.js +0 -114
  360. package/dist/devbox/commands/reset.js.map +0 -1
  361. package/dist/devbox/commands/runtimeClient.d.ts +0 -65
  362. package/dist/devbox/commands/runtimeClient.d.ts.map +0 -1
  363. package/dist/devbox/commands/runtimeClient.js +0 -127
  364. package/dist/devbox/commands/runtimeClient.js.map +0 -1
  365. package/dist/devbox/commands/sentryTest.d.ts +0 -2
  366. package/dist/devbox/commands/sentryTest.d.ts.map +0 -1
  367. package/dist/devbox/commands/sentryTest.js +0 -117
  368. package/dist/devbox/commands/sentryTest.js.map +0 -1
  369. package/dist/devbox/commands/services.d.ts +0 -2
  370. package/dist/devbox/commands/services.d.ts.map +0 -1
  371. package/dist/devbox/commands/services.js +0 -619
  372. package/dist/devbox/commands/services.js.map +0 -1
  373. package/dist/devbox/commands/servicesConfig.d.ts +0 -19
  374. package/dist/devbox/commands/servicesConfig.d.ts.map +0 -1
  375. package/dist/devbox/commands/servicesConfig.js +0 -61
  376. package/dist/devbox/commands/servicesConfig.js.map +0 -1
  377. package/dist/devbox/commands/servicesToml.d.ts +0 -13
  378. package/dist/devbox/commands/servicesToml.d.ts.map +0 -1
  379. package/dist/devbox/commands/servicesToml.js +0 -201
  380. package/dist/devbox/commands/servicesToml.js.map +0 -1
  381. package/dist/devbox/commands/sessionUtils.d.ts +0 -10
  382. package/dist/devbox/commands/sessionUtils.d.ts.map +0 -1
  383. package/dist/devbox/commands/sessionUtils.js +0 -48
  384. package/dist/devbox/commands/sessionUtils.js.map +0 -1
  385. package/dist/devbox/commands/sessions.d.ts +0 -3
  386. package/dist/devbox/commands/sessions.d.ts.map +0 -1
  387. package/dist/devbox/commands/sessions.js +0 -490
  388. package/dist/devbox/commands/sessions.js.map +0 -1
  389. package/dist/devbox/commands/setup.d.ts +0 -36
  390. package/dist/devbox/commands/setup.d.ts.map +0 -1
  391. package/dist/devbox/commands/setup.js +0 -816
  392. package/dist/devbox/commands/setup.js.map +0 -1
  393. package/dist/devbox/commands/setupClaude.d.ts +0 -51
  394. package/dist/devbox/commands/setupClaude.d.ts.map +0 -1
  395. package/dist/devbox/commands/setupClaude.js +0 -202
  396. package/dist/devbox/commands/setupClaude.js.map +0 -1
  397. package/dist/devbox/commands/setupTooling.d.ts +0 -56
  398. package/dist/devbox/commands/setupTooling.d.ts.map +0 -1
  399. package/dist/devbox/commands/setupTooling.js +0 -187
  400. package/dist/devbox/commands/setupTooling.js.map +0 -1
  401. package/dist/devbox/commands/sshAccess.d.ts +0 -31
  402. package/dist/devbox/commands/sshAccess.d.ts.map +0 -1
  403. package/dist/devbox/commands/sshAccess.js +0 -353
  404. package/dist/devbox/commands/sshAccess.js.map +0 -1
  405. package/dist/devbox/commands/sshConfig.d.ts +0 -23
  406. package/dist/devbox/commands/sshConfig.d.ts.map +0 -1
  407. package/dist/devbox/commands/sshConfig.js +0 -366
  408. package/dist/devbox/commands/sshConfig.js.map +0 -1
  409. package/dist/devbox/commands/sshProxy.d.ts +0 -2
  410. package/dist/devbox/commands/sshProxy.d.ts.map +0 -1
  411. package/dist/devbox/commands/sshProxy.js +0 -215
  412. package/dist/devbox/commands/sshProxy.js.map +0 -1
  413. package/dist/devbox/commands/uninstall.d.ts +0 -2
  414. package/dist/devbox/commands/uninstall.d.ts.map +0 -1
  415. package/dist/devbox/commands/uninstall.js +0 -365
  416. package/dist/devbox/commands/uninstall.js.map +0 -1
  417. package/dist/devbox/commands/upgrade.d.ts +0 -14
  418. package/dist/devbox/commands/upgrade.d.ts.map +0 -1
  419. package/dist/devbox/commands/upgrade.js +0 -60
  420. package/dist/devbox/commands/upgrade.js.map +0 -1
  421. package/dist/devbox/commands/version.d.ts +0 -8
  422. package/dist/devbox/commands/version.d.ts.map +0 -1
  423. package/dist/devbox/commands/version.js +0 -134
  424. package/dist/devbox/commands/version.js.map +0 -1
  425. package/dist/devbox/commands/whoami.d.ts +0 -2
  426. package/dist/devbox/commands/whoami.d.ts.map +0 -1
  427. package/dist/devbox/commands/whoami.js +0 -114
  428. package/dist/devbox/commands/whoami.js.map +0 -1
  429. package/dist/devbox/completions/cache.d.ts +0 -53
  430. package/dist/devbox/completions/cache.d.ts.map +0 -1
  431. package/dist/devbox/completions/cache.js +0 -227
  432. package/dist/devbox/completions/cache.js.map +0 -1
  433. package/dist/devbox/completions/index.d.ts +0 -18
  434. package/dist/devbox/completions/index.d.ts.map +0 -1
  435. package/dist/devbox/completions/index.js +0 -759
  436. package/dist/devbox/completions/index.js.map +0 -1
  437. package/dist/devbox/controlPlane.d.ts +0 -460
  438. package/dist/devbox/controlPlane.d.ts.map +0 -1
  439. package/dist/devbox/controlPlane.js +0 -1910
  440. package/dist/devbox/controlPlane.js.map +0 -1
  441. package/dist/devbox/daemonClient.d.ts +0 -44
  442. package/dist/devbox/daemonClient.d.ts.map +0 -1
  443. package/dist/devbox/daemonClient.js +0 -677
  444. package/dist/devbox/daemonClient.js.map +0 -1
  445. package/dist/devbox/e2bExecErrors.d.ts +0 -11
  446. package/dist/devbox/e2bExecErrors.d.ts.map +0 -1
  447. package/dist/devbox/e2bExecErrors.js +0 -19
  448. package/dist/devbox/e2bExecErrors.js.map +0 -1
  449. package/dist/devbox/latency.d.ts +0 -25
  450. package/dist/devbox/latency.d.ts.map +0 -1
  451. package/dist/devbox/latency.js +0 -186
  452. package/dist/devbox/latency.js.map +0 -1
  453. package/dist/devbox/logger.d.ts +0 -2
  454. package/dist/devbox/logger.d.ts.map +0 -1
  455. package/dist/devbox/logger.js +0 -3
  456. package/dist/devbox/logger.js.map +0 -1
  457. package/dist/devbox/terminal/kittyCtrlCReleaseSuppressor.d.ts +0 -11
  458. package/dist/devbox/terminal/kittyCtrlCReleaseSuppressor.d.ts.map +0 -1
  459. package/dist/devbox/terminal/kittyCtrlCReleaseSuppressor.js +0 -118
  460. package/dist/devbox/terminal/kittyCtrlCReleaseSuppressor.js.map +0 -1
  461. package/dist/devbox/terminal/osc.d.ts +0 -11
  462. package/dist/devbox/terminal/osc.d.ts.map +0 -1
  463. package/dist/devbox/terminal/osc.js +0 -84
  464. package/dist/devbox/terminal/osc.js.map +0 -1
  465. package/dist/devbox/terminal/sessionProtocol.d.ts +0 -46
  466. package/dist/devbox/terminal/sessionProtocol.d.ts.map +0 -1
  467. package/dist/devbox/terminal/sessionProtocol.js +0 -631
  468. package/dist/devbox/terminal/sessionProtocol.js.map +0 -1
  469. package/dist/devbox/ui/colors.d.ts +0 -19
  470. package/dist/devbox/ui/colors.d.ts.map +0 -1
  471. package/dist/devbox/ui/colors.js +0 -22
  472. package/dist/devbox/ui/colors.js.map +0 -1
  473. package/dist/devbox/ui/copyableUrl.d.ts +0 -4
  474. package/dist/devbox/ui/copyableUrl.d.ts.map +0 -1
  475. package/dist/devbox/ui/copyableUrl.js +0 -10
  476. package/dist/devbox/ui/copyableUrl.js.map +0 -1
  477. package/dist/devbox/ui/qr.d.ts +0 -3
  478. package/dist/devbox/ui/qr.d.ts.map +0 -1
  479. package/dist/devbox/ui/qr.js +0 -17
  480. package/dist/devbox/ui/qr.js.map +0 -1
  481. package/dist/devbox/ui/statusLine.d.ts +0 -14
  482. package/dist/devbox/ui/statusLine.d.ts.map +0 -1
  483. package/dist/devbox/ui/statusLine.js +0 -92
  484. package/dist/devbox/ui/statusLine.js.map +0 -1
  485. package/dist/devbox/updateNotice.d.ts +0 -2
  486. package/dist/devbox/updateNotice.d.ts.map +0 -1
  487. package/dist/devbox/updateNotice.js +0 -43
  488. package/dist/devbox/updateNotice.js.map +0 -1
@@ -1,1910 +0,0 @@
1
- import http from "node:http";
2
- import { randomUUID } from "node:crypto";
3
- import { cancel as clackCancel, log as clackLog, spinner as clackSpinner, } from "@clack/prompts";
4
- import { addDevboxClientVersionHeader, coerceUpgradeRequiredError, parseUpgradeRequiredResponseBody, } from "@boxes-dev/core";
5
- import { ConvexClient } from "convex/browser";
6
- import { makeFunctionReference } from "convex/server";
7
- import NodeWebSocket from "ws";
8
- import { openBrowser } from "./browser.js";
9
- import { logger } from "./logger.js";
10
- import { showCopyableUrl } from "./ui/copyableUrl.js";
11
- const CURRENT_MODAL_BOOTSTRAP_CONTRACT_VERSION = "2";
12
- const MANAGED_DAEMON_NOT_READY_CODE = "managed_daemon_not_ready";
13
- const CONVEX_INFLIGHT_ACTION_DISCONNECTED_MESSAGE = "Connection lost while action was in flight";
14
- const CONTROL_PLANE_ACTION_RETRY_MAX_ATTEMPTS = 3;
15
- const CONTROL_PLANE_ACTION_RETRY_BASE_DELAY_MS = 250;
16
- export class ManagedDaemonNotReadyError extends Error {
17
- code = MANAGED_DAEMON_NOT_READY_CODE;
18
- provider;
19
- alias;
20
- state;
21
- detail;
22
- constructor(args) {
23
- super(args.message);
24
- this.name = "ManagedDaemonNotReadyError";
25
- this.provider = args.provider;
26
- this.alias = args.alias;
27
- this.state = args.state;
28
- if (args.detail !== undefined) {
29
- this.detail = args.detail;
30
- }
31
- }
32
- }
33
- export const isManagedDaemonNotReadyError = (error) => error instanceof ManagedDaemonNotReadyError ||
34
- (!!error &&
35
- typeof error === "object" &&
36
- error.code === MANAGED_DAEMON_NOT_READY_CODE);
37
- const trim = (value) => value.trim().replace(/\r/g, "");
38
- const normalizeConvexDeployment = (value) => {
39
- const normalized = trim(value);
40
- if (!normalized)
41
- return "";
42
- if (normalized.includes(":")) {
43
- const [prefix, rest] = normalized.split(":", 2);
44
- return `${prefix}:${trim(rest ?? "")}`;
45
- }
46
- return normalized;
47
- };
48
- const stripDevPrefix = (value) => {
49
- if (value.startsWith("dev:")) {
50
- return trim(value.slice(4));
51
- }
52
- return value;
53
- };
54
- const sleep = async (ms) => {
55
- await new Promise((resolve) => {
56
- setTimeout(resolve, ms);
57
- });
58
- };
59
- const isRetryableTransientConvexActionError = (error) => error instanceof Error &&
60
- error.message.includes(CONVEX_INFLIGHT_ACTION_DISCONNECTED_MESSAGE);
61
- const buildTransientConvexActionRetryMessage = (info) => {
62
- const baseReason = "Convex dropped the in-flight response while the backend was still processing the request.";
63
- const actionDetail = info.actionName === "devboxes:issueManagedDaemonConnectInfoForViewer"
64
- ? {
65
- label: "managed daemon connect info",
66
- reason: "Convex dropped the in-flight response while the backend may still be waking the devbox or ensuring the daemon is ready.",
67
- }
68
- : info.actionName === "e2bDevboxes:issueBootstrapConnectInfoForViewer"
69
- ? {
70
- label: "E2B bootstrap connect info",
71
- reason: "Convex dropped the in-flight response while the backend may still be preparing bootstrap access to the devbox.",
72
- }
73
- : {
74
- label: info.actionName,
75
- reason: baseReason,
76
- };
77
- return `Retrying ${actionDetail.label} (attempt ${String(info.nextAttempt)}/${String(info.maxAttempts)}) in ${String(info.delayMs)}ms because ${actionDetail.reason}`;
78
- };
79
- const announceTransientConvexActionRetry = (info) => {
80
- if (!process.stderr.isTTY && !process.stdout.isTTY) {
81
- return;
82
- }
83
- clackLog.warn(buildTransientConvexActionRetryMessage(info));
84
- };
85
- const retryTransientConvexAction = async (options) => {
86
- const maxAttempts = options.maxAttempts ?? CONTROL_PLANE_ACTION_RETRY_MAX_ATTEMPTS;
87
- const baseDelayMs = options.baseDelayMs ?? CONTROL_PLANE_ACTION_RETRY_BASE_DELAY_MS;
88
- const sleepImpl = options.sleep ?? sleep;
89
- let attempt = 1;
90
- while (true) {
91
- try {
92
- return await options.run();
93
- }
94
- catch (error) {
95
- if (!isRetryableTransientConvexActionError(error) ||
96
- attempt >= maxAttempts) {
97
- throw error;
98
- }
99
- const delayMs = baseDelayMs * 2 ** (attempt - 1);
100
- const retryInfo = {
101
- actionName: options.actionName,
102
- attempt,
103
- nextAttempt: attempt + 1,
104
- maxAttempts,
105
- delayMs,
106
- error: error.message,
107
- };
108
- logger.warn("control_plane_action_retry", {
109
- action: options.actionName,
110
- attempt,
111
- maxAttempts,
112
- delayMs,
113
- error: error.message,
114
- });
115
- options.onRetry?.(retryInfo);
116
- await sleepImpl(delayMs);
117
- attempt += 1;
118
- }
119
- }
120
- };
121
- const normalizeStringRecord = (value) => {
122
- if (!value || typeof value !== "object") {
123
- return {};
124
- }
125
- const normalized = {};
126
- for (const [rawKey, rawValue] of Object.entries(value)) {
127
- if (typeof rawValue !== "string") {
128
- continue;
129
- }
130
- const key = rawKey.trim();
131
- if (!key) {
132
- continue;
133
- }
134
- normalized[key] = rawValue.trim();
135
- }
136
- return normalized;
137
- };
138
- const resolveFromDeployment = (deploymentRaw, suffix) => {
139
- const deployment = stripDevPrefix(normalizeConvexDeployment(deploymentRaw));
140
- if (!deployment)
141
- return "";
142
- if (deployment.includes("://")) {
143
- return deployment;
144
- }
145
- if (deployment.includes(".")) {
146
- const host = suffix === "cloud"
147
- ? deployment.replace(".convex.site", ".convex.cloud")
148
- : deployment.replace(".convex.cloud", ".convex.site");
149
- return `https://${host}`;
150
- }
151
- return `https://${deployment}.convex.${suffix}`;
152
- };
153
- const resolveFromUrl = (raw, suffix) => {
154
- const value = trim(raw);
155
- if (!value)
156
- return "";
157
- try {
158
- const url = new URL(value);
159
- const host = suffix === "cloud"
160
- ? url.host.replace(".convex.site", ".convex.cloud")
161
- : url.host.replace(".convex.cloud", ".convex.site");
162
- return `${url.protocol}//${host}`;
163
- }
164
- catch {
165
- return "";
166
- }
167
- };
168
- const resolveControlPlaneUrl = () => {
169
- const envOverride = process.env.DEVBOX_CONTROL_PLANE_URL ?? process.env.CONVEX_SITE_URL;
170
- if (envOverride && envOverride.trim().length > 0) {
171
- return envOverride.trim();
172
- }
173
- if (typeof __DEVBOX_CONTROL_PLANE_URL__ !== "string")
174
- return null;
175
- const trimmed = __DEVBOX_CONTROL_PLANE_URL__.trim();
176
- return trimmed.length > 0 ? trimmed : null;
177
- };
178
- const resolveConvexUrl = () => {
179
- const envOverride = process.env.DEVBOX_CONVEX_URL ?? process.env.CONVEX_CLOUD_URL;
180
- if (envOverride && envOverride.trim().length > 0) {
181
- return envOverride.trim();
182
- }
183
- if (typeof __DEVBOX_CONVEX_URL__ !== "string")
184
- return null;
185
- const trimmed = __DEVBOX_CONVEX_URL__.trim();
186
- return trimmed.length > 0 ? trimmed : null;
187
- };
188
- const waitForAnyKeypress = () => {
189
- const stdin = process.stdin;
190
- const wasPaused = stdin.isPaused();
191
- let stopRawMode = null;
192
- let stopped = false;
193
- let resolvePromise = null;
194
- let rejectPromise = null;
195
- const stop = () => {
196
- if (stopped)
197
- return;
198
- stopped = true;
199
- stdin.off("data", onData);
200
- stdin.off("error", onError);
201
- stopRawMode?.();
202
- if (wasPaused) {
203
- stdin.pause();
204
- }
205
- };
206
- const settle = (value) => {
207
- if (stopped)
208
- return;
209
- const resolve = resolvePromise;
210
- stop();
211
- resolve?.(value);
212
- };
213
- const reject = (error) => {
214
- if (stopped)
215
- return;
216
- const rejectFn = rejectPromise;
217
- stop();
218
- rejectFn?.(error);
219
- };
220
- const onData = (chunk) => {
221
- const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
222
- if (buffer.includes(3)) {
223
- settle("cancel");
224
- return;
225
- }
226
- settle("open_browser");
227
- };
228
- const onError = (error) => {
229
- reject(error);
230
- };
231
- const promise = new Promise((resolve, reject) => {
232
- resolvePromise = resolve;
233
- rejectPromise = reject;
234
- });
235
- if (stdin.isTTY) {
236
- const wasRaw = stdin.isRaw;
237
- if (wasRaw !== true) {
238
- try {
239
- stdin.setRawMode(true);
240
- stopRawMode = () => {
241
- try {
242
- stdin.setRawMode(false);
243
- }
244
- catch {
245
- // Ignore raw mode restore failures.
246
- }
247
- };
248
- }
249
- catch {
250
- // Fallback to cooked mode if raw mode isn't available.
251
- }
252
- }
253
- }
254
- stdin.resume();
255
- stdin.on("data", onData);
256
- stdin.on("error", onError);
257
- return { promise, stop };
258
- };
259
- const escapeHtml = (value) => value
260
- .replaceAll("&", "&")
261
- .replaceAll("<", "&lt;")
262
- .replaceAll(">", "&gt;")
263
- .replaceAll('"', "&quot;")
264
- .replaceAll("'", "&#39;");
265
- const CALLBACK_LOGO_MARK = `<svg viewBox="0 0 48 48" aria-hidden="true" focusable="false">
266
- <rect x="1.5" y="1.5" width="45" height="45" rx="8" fill="#111" />
267
- <rect x="9" y="9" width="30" height="30" fill="none" stroke="#fff" stroke-width="6" />
268
- <rect x="42" y="9" width="3" height="30" fill="#fff" />
269
- <rect x="9" y="42" width="30" height="3" fill="#fff" />
270
- <rect x="3" y="9" width="3" height="30" fill="#fff" />
271
- <rect x="9" y="3" width="30" height="3" fill="#fff" />
272
- </svg>`;
273
- const CALLBACK_FULL_LOGO = typeof __DEVBOX_AUTH_CALLBACK_LOGO_SVG__ === "string" &&
274
- __DEVBOX_AUTH_CALLBACK_LOGO_SVG__.trim().length > 0
275
- ? __DEVBOX_AUTH_CALLBACK_LOGO_SVG__
276
- : CALLBACK_LOGO_MARK;
277
- const renderCallbackPage = (tone, title, message) => {
278
- const isSuccess = tone === "success";
279
- const badgeClass = isSuccess ? "badge success" : "badge error";
280
- const badgeLabel = isSuccess ? "Success" : "Error";
281
- const escapedTitle = escapeHtml(title);
282
- const escapedMessage = escapeHtml(message);
283
- return `<!doctype html>
284
- <html lang="en">
285
- <head>
286
- <meta charset="utf-8" />
287
- <meta name="viewport" content="width=device-width, initial-scale=1" />
288
- <title>${escapedTitle}</title>
289
- <style>
290
- :root {
291
- color-scheme: light dark;
292
- --bg: #f4f6fb;
293
- --card: #ffffff;
294
- --text: #111827;
295
- --muted: #4b5563;
296
- --ring: #d0d5dd;
297
- --success: #047857;
298
- --success-bg: #ecfdf3;
299
- --error: #b42318;
300
- --error-bg: #fef3f2;
301
- }
302
- @media (prefers-color-scheme: dark) {
303
- :root {
304
- --bg: #0b1220;
305
- --card: #121b2f;
306
- --text: #f8fafc;
307
- --muted: #c5ccda;
308
- --ring: #263247;
309
- --success: #34d399;
310
- --success-bg: #06291f;
311
- --error: #fda29b;
312
- --error-bg: #3b1715;
313
- }
314
- }
315
- * {
316
- box-sizing: border-box;
317
- }
318
- body {
319
- margin: 0;
320
- min-height: 100vh;
321
- display: grid;
322
- place-items: center;
323
- padding: 20px;
324
- font-family:
325
- "IBM Plex Sans",
326
- "Segoe UI",
327
- "Helvetica Neue",
328
- Arial,
329
- sans-serif;
330
- background:
331
- radial-gradient(circle at 0% 0%, #dbe7ff 0%, transparent 50%),
332
- radial-gradient(circle at 100% 100%, #d7f2e3 0%, transparent 42%),
333
- var(--bg);
334
- color: var(--text);
335
- }
336
- main {
337
- width: min(100%, 520px);
338
- padding: 28px;
339
- border-radius: 16px;
340
- border: 1px solid var(--ring);
341
- background: var(--card);
342
- box-shadow:
343
- 0 24px 48px rgba(0, 0, 0, 0.1),
344
- 0 4px 14px rgba(0, 0, 0, 0.05);
345
- }
346
- .brand {
347
- display: flex;
348
- align-items: center;
349
- justify-content: center;
350
- width: min(100%, 360px);
351
- border-radius: 12px;
352
- border: 1px solid rgba(255, 255, 255, 0.08);
353
- background: #111827;
354
- padding: 12px 14px;
355
- margin-bottom: 18px;
356
- }
357
- .brand svg {
358
- width: 100%;
359
- height: auto;
360
- display: block;
361
- }
362
- .badge {
363
- display: inline-flex;
364
- align-items: center;
365
- justify-content: center;
366
- border-radius: 999px;
367
- font-size: 12px;
368
- font-weight: 600;
369
- letter-spacing: 0.04em;
370
- text-transform: uppercase;
371
- padding: 6px 10px;
372
- }
373
- .badge.success {
374
- color: var(--success);
375
- background: var(--success-bg);
376
- }
377
- .badge.error {
378
- color: var(--error);
379
- background: var(--error-bg);
380
- }
381
- h1 {
382
- margin: 14px 0 10px;
383
- font-size: clamp(22px, 3vw, 28px);
384
- line-height: 1.2;
385
- }
386
- p {
387
- margin: 0;
388
- font-size: 16px;
389
- line-height: 1.5;
390
- color: var(--muted);
391
- }
392
- </style>
393
- </head>
394
- <body>
395
- <main>
396
- <div class="brand">
397
- ${CALLBACK_FULL_LOGO}
398
- </div>
399
- <span class="${badgeClass}">${badgeLabel}</span>
400
- <h1>${escapedTitle}</h1>
401
- <p>${escapedMessage}</p>
402
- </main>
403
- </body>
404
- </html>`;
405
- };
406
- const requestJson = async (baseUrl, method, path, body, token) => {
407
- const requestId = randomUUID();
408
- const url = new URL(path, baseUrl);
409
- const headers = {
410
- "x-request-id": requestId,
411
- };
412
- addDevboxClientVersionHeader(headers);
413
- if (token) {
414
- headers.authorization = `Bearer ${token}`;
415
- }
416
- if (body) {
417
- headers["content-type"] = "application/json";
418
- }
419
- logger.info("control_plane_request", {
420
- requestId,
421
- method,
422
- path: url.pathname,
423
- });
424
- const init = { method, headers };
425
- if (body) {
426
- init.body = JSON.stringify(body);
427
- }
428
- const response = await fetch(url, init);
429
- logger.info("control_plane_response", {
430
- requestId,
431
- method,
432
- path: url.pathname,
433
- status: response.status,
434
- });
435
- if (!response.ok) {
436
- const message = await response.text();
437
- const upgradeRequired = parseUpgradeRequiredResponseBody(message, {
438
- source: "control_plane",
439
- statusCode: response.status,
440
- });
441
- if (upgradeRequired) {
442
- throw upgradeRequired;
443
- }
444
- throw new Error(`Control plane error ${response.status}: ${message}`);
445
- }
446
- const text = await response.text();
447
- if (!text)
448
- return {};
449
- return JSON.parse(text);
450
- };
451
- const startCallbackServer = async () => new Promise((resolve, reject) => {
452
- const server = http.createServer((req, res) => {
453
- const url = new URL(req.url ?? "", `http://${req.headers.host ?? ""}`);
454
- if (url.pathname !== "/auth/callback") {
455
- res.statusCode = 404;
456
- res.end("Not found.");
457
- return;
458
- }
459
- const code = url.searchParams.get("code");
460
- const error = url.searchParams.get("error");
461
- res.statusCode = code ? 200 : 400;
462
- res.setHeader("content-type", "text/html; charset=utf-8");
463
- if (code) {
464
- res.end(renderCallbackPage("success", "Authentication complete", "You can close this window and return to your terminal."));
465
- }
466
- else {
467
- const errorDetails = error && error.length > 0 ? error : "missing code";
468
- res.end(renderCallbackPage("error", "Authentication failed", `The sign-in flow returned an error (${errorDetails}).`));
469
- }
470
- if (code) {
471
- waiter.resolve(code);
472
- }
473
- else {
474
- waiter.reject(new Error("OAuth failed."));
475
- }
476
- });
477
- const waiter = (() => {
478
- let resolveFn;
479
- let rejectFn;
480
- const promise = new Promise((resolve, reject) => {
481
- resolveFn = resolve;
482
- rejectFn = reject;
483
- });
484
- return {
485
- promise,
486
- resolve: (code) => resolveFn(code),
487
- reject: (error) => rejectFn(error),
488
- };
489
- })();
490
- server.listen(0, "127.0.0.1", () => {
491
- const address = server.address();
492
- if (!address || typeof address === "string") {
493
- server.close();
494
- reject(new Error("Unable to start callback server."));
495
- return;
496
- }
497
- resolve({
498
- redirectTo: `http://127.0.0.1:${address.port}/auth/callback`,
499
- waitForCode: () => waiter.promise,
500
- close: () => new Promise((closeResolve) => {
501
- server.close(() => closeResolve());
502
- }),
503
- });
504
- });
505
- });
506
- export const getControlPlaneUrl = () => resolveControlPlaneUrl();
507
- export const getConvexUrl = () => resolveConvexUrl();
508
- export const signInWithBrowser = async () => {
509
- const baseUrl = resolveControlPlaneUrl();
510
- if (!baseUrl) {
511
- throw new Error("Control plane URL is not embedded. Rebuild with CONVEX_SITE_URL set.");
512
- }
513
- if (!process.stdin.isTTY) {
514
- throw new Error("Control plane sign-in requires a TTY.");
515
- }
516
- const callback = await startCallbackServer();
517
- try {
518
- const start = await requestJson(baseUrl, "POST", "/auth/signin/start", {
519
- provider: "google",
520
- redirect_to: callback.redirectTo,
521
- });
522
- if (!start.redirect || !start.verifier) {
523
- throw new Error("Control plane sign-in failed to start.");
524
- }
525
- const codePromise = callback.waitForCode();
526
- const keypress = waitForAnyKeypress();
527
- const listeningSpinner = clackSpinner();
528
- let code = "";
529
- try {
530
- listeningSpinner.start("Press any key to open the browser for sign-in.");
531
- const firstResult = await Promise.race([
532
- codePromise.then((value) => ({ type: "code", value })),
533
- keypress.promise.then((value) => ({
534
- type: "keypress",
535
- value,
536
- })),
537
- ]);
538
- listeningSpinner.clear();
539
- if (firstResult.type === "code") {
540
- code = firstResult.value;
541
- }
542
- else {
543
- if (firstResult.value === "cancel") {
544
- clackCancel("Sign-in canceled.");
545
- throw new Error("Control plane sign-in cancelled.");
546
- }
547
- const opened = openBrowser(start.redirect);
548
- if (!opened) {
549
- clackLog.warn("Unable to open the browser automatically.");
550
- }
551
- showCopyableUrl(start.redirect, "If the browser did not open, use this URL");
552
- const waitSpinner = clackSpinner();
553
- waitSpinner.start("Listening for login. Complete sign-in in your browser...");
554
- try {
555
- code = await codePromise;
556
- }
557
- finally {
558
- waitSpinner.clear();
559
- }
560
- }
561
- }
562
- finally {
563
- listeningSpinner.clear();
564
- keypress.stop();
565
- }
566
- const finish = await requestJson(baseUrl, "POST", "/auth/signin/finish", {
567
- code,
568
- verifier: start.verifier,
569
- });
570
- if (!finish.token) {
571
- throw new Error("Control plane sign-in failed to complete.");
572
- }
573
- const viewer = await fetchViewerIdentity(finish.token).catch((error) => {
574
- logger.warn("control_plane_viewer_identity_failed", {
575
- error: error instanceof Error ? error.message : String(error),
576
- });
577
- return null;
578
- });
579
- const email = typeof viewer?.email === "string" ? viewer.email.trim() : "";
580
- if (email.length > 0) {
581
- clackLog.success(`Signed in as ${email}.`);
582
- }
583
- else {
584
- clackLog.success("Signed in.");
585
- }
586
- return finish.refresh_token
587
- ? { token: finish.token, refreshToken: finish.refresh_token }
588
- : { token: finish.token };
589
- }
590
- finally {
591
- await callback.close();
592
- }
593
- };
594
- const spriteTokenGet = makeFunctionReference("spriteTokens:getForViewer");
595
- const spriteTokenSet = makeFunctionReference("spriteTokens:setForViewer");
596
- const spriteTokenClear = makeFunctionReference("spriteTokens:clearForViewer");
597
- const claudeTokenGet = makeFunctionReference("claudeTokens:getForViewer");
598
- const claudeTokenSet = makeFunctionReference("claudeTokens:setForViewer");
599
- const claudeTokenClear = makeFunctionReference("claudeTokens:clearForViewer");
600
- const modalTokenSet = makeFunctionReference("modalTokens:setForViewer");
601
- const modalTokenClear = makeFunctionReference("modalTokens:clearForViewer");
602
- const modalTokenResolvedGet = makeFunctionReference("modalTokens:getResolvedForViewer");
603
- const e2bTokenResolvedGet = makeFunctionReference("e2bTokens:getResolvedForViewer");
604
- const e2bDevboxUpsert = makeFunctionReference("e2bDevboxes:upsertForViewer");
605
- const e2bDevboxRemove = makeFunctionReference("e2bDevboxes:removeForViewer");
606
- const e2bDevboxGet = makeFunctionReference("e2bDevboxes:getForViewer");
607
- const e2bDevboxStatusesList = makeFunctionReference("e2bDevboxes:listStatusesForViewer");
608
- const e2bDevboxDestroy = makeFunctionReference("e2bDevboxes:destroyForViewer");
609
- const e2bDevboxProvision = makeFunctionReference("e2bDevboxes:provisionForViewer");
610
- const e2bDevboxRestoreLatestSnapshot = makeFunctionReference("e2bDevboxes:restoreLatestSnapshotForViewer");
611
- const e2bDevboxPause = makeFunctionReference("e2bDevboxes:pauseForViewer");
612
- const e2bDevboxEnsureActive = makeFunctionReference("e2bDevboxes:ensureActiveForViewer");
613
- const e2bDevboxReset = makeFunctionReference("e2bDevboxes:resetForViewer");
614
- const e2bDevboxIssueBootstrapConnectInfo = makeFunctionReference("e2bDevboxes:issueBootstrapConnectInfoForViewer");
615
- const e2bDevboxSetDaemonBootstrapState = makeFunctionReference("e2bDevboxes:setDaemonBootstrapStateForViewer");
616
- const managedDevboxIssueDaemonConnectInfo = makeFunctionReference("devboxes:issueManagedDaemonConnectInfoForViewer");
617
- const managedDevboxCreateCheckpoint = makeFunctionReference("devboxes:createManagedCheckpointForViewer");
618
- const managedDevboxListRemoteStates = makeFunctionReference("devboxes:listManagedRemoteStatesForViewer");
619
- const modalDevboxUpsert = makeFunctionReference("modalDevboxes:upsertForViewer");
620
- const modalDevboxRemove = makeFunctionReference("modalDevboxes:removeForViewer");
621
- const modalDevboxEnsureActive = makeFunctionReference("modalDevboxes:ensureActiveForViewer");
622
- const modalDevboxReboot = makeFunctionReference("modalDevboxes:rebootForViewer");
623
- const modalDevboxEnsureDaemon = makeFunctionReference("modalDevboxes:ensureDaemonForViewer");
624
- const modalDevboxProvision = makeFunctionReference("modalDevboxes:provisionSandboxForViewer");
625
- const modalDevboxFind = makeFunctionReference("modalDevboxes:findSandboxForViewer");
626
- const modalDevboxTerminate = makeFunctionReference("modalDevboxes:terminateSandboxesByAliasForViewer");
627
- const modalDevboxShellConnectionOpened = makeFunctionReference("modalDevboxes:recordShellConnectionOpenedForViewer");
628
- const modalDevboxShellConnectionClosed = makeFunctionReference("modalDevboxes:recordShellConnectionClosedForViewer");
629
- const modalDevboxProxyConnectionOpened = makeFunctionReference("modalDevboxes:recordProxyConnectionOpenedForViewer");
630
- const modalDevboxProxyConnectionClosed = makeFunctionReference("modalDevboxes:recordProxyConnectionClosedForViewer");
631
- const modalDevboxStatusesList = makeFunctionReference("modalDevboxes:listStatusesForViewer");
632
- const spriteDaemonReleaseGet = makeFunctionReference("spriteDaemonReleases:getLatest");
633
- const spriteDaemonTokenIssue = makeFunctionReference("spriteDaemonAuth:issueTokenForViewer");
634
- const spriteDaemonSessionSummariesList = makeFunctionReference("spriteDaemonSessionSummaries:listForInstance");
635
- const spriteDaemonSessionsList = makeFunctionReference("spriteDaemonSessions:listForInstance");
636
- const instancesList = makeFunctionReference("instances:listForViewer");
637
- const helloViewerGet = makeFunctionReference("hello:getViewer");
638
- const buildConvexClientOptions = () => ({
639
- logger: false,
640
- // Force the stable `ws` transport in Node. Letting Convex pick the global
641
- // WebSocket uses Node's experimental Undici implementation on Node 22+,
642
- // which is the path that crashed `dvb setup` in the shipped runtime.
643
- webSocketConstructor: NodeWebSocket,
644
- });
645
- const withConvexClient = async (token, handler) => {
646
- const convexUrl = resolveConvexUrl();
647
- if (!convexUrl) {
648
- throw new Error("Convex URL is not embedded. Rebuild with CONVEX_CLOUD_URL set.");
649
- }
650
- const client = new ConvexClient(convexUrl, buildConvexClientOptions());
651
- client.setAuth(async () => token);
652
- try {
653
- try {
654
- return await handler(client);
655
- }
656
- catch (error) {
657
- const upgradeRequired = coerceUpgradeRequiredError(error, {
658
- source: "control_plane",
659
- });
660
- if (upgradeRequired) {
661
- throw upgradeRequired;
662
- }
663
- throw error;
664
- }
665
- }
666
- finally {
667
- await client.close();
668
- }
669
- };
670
- const resolveInstanceIdForAlias = async (client, aliasRaw) => {
671
- const alias = aliasRaw.trim().toLowerCase();
672
- if (!alias) {
673
- throw new Error("Sprite alias is required.");
674
- }
675
- const entries = await client.query(instancesList, {});
676
- const match = entries.find((entry) => entry.alias.trim() === alias);
677
- const instanceId = match?.instanceId?.trim() ?? "";
678
- if (!instanceId) {
679
- throw new Error(`Unknown sprite alias: ${aliasRaw}`);
680
- }
681
- return instanceId;
682
- };
683
- export const fetchSpriteTokenStatus = async (token) => {
684
- return await withConvexClient(token, async (client) => {
685
- const response = await client.query(spriteTokenGet, {});
686
- return {
687
- hasToken: response?.hasToken === true,
688
- hasOverrideToken: response?.hasOverrideToken === true,
689
- tokenSource: response?.tokenSource === "user" || response?.tokenSource === "shared"
690
- ? response.tokenSource
691
- : null,
692
- updatedAt: typeof response?.updatedAt === "number" ? response.updatedAt : null,
693
- };
694
- });
695
- };
696
- export const fetchClaudeTokenStatus = async (token) => {
697
- return await withConvexClient(token, async (client) => {
698
- const response = await client.query(claudeTokenGet, {});
699
- return {
700
- hasToken: response?.hasToken === true,
701
- expiresAt: typeof response?.expiresAt === "number" ? response.expiresAt : null,
702
- updatedAt: typeof response?.updatedAt === "number" ? response.updatedAt : null,
703
- lastValidatedAt: typeof response?.lastValidatedAt === "number"
704
- ? response.lastValidatedAt
705
- : null,
706
- lastRuntimeAuthFailureAt: typeof response?.lastRuntimeAuthFailureAt === "number"
707
- ? response.lastRuntimeAuthFailureAt
708
- : null,
709
- lastRuntimeAuthFailureReason: typeof response?.lastRuntimeAuthFailureReason === "string"
710
- ? response.lastRuntimeAuthFailureReason
711
- : null,
712
- };
713
- });
714
- };
715
- export const fetchResolvedModalCredentials = async (token) => {
716
- return await withConvexClient(token, async (client) => {
717
- const response = await client.query(modalTokenResolvedGet, {});
718
- const tokenId = typeof response?.tokenId === "string" ? response.tokenId : null;
719
- const tokenSecret = typeof response?.tokenSecret === "string" ? response.tokenSecret : null;
720
- const source = response?.source === "user" ? response.source : null;
721
- return { tokenId, tokenSecret, source };
722
- });
723
- };
724
- export const fetchResolvedE2bCredentials = async (token) => {
725
- return await withConvexClient(token, async (client) => {
726
- const response = await client.query(e2bTokenResolvedGet, {});
727
- const apiKey = typeof response?.apiKey === "string" ? response.apiKey : null;
728
- const source = response?.source === "shared" ? response.source : null;
729
- return { apiKey, source };
730
- });
731
- };
732
- export const fetchViewerIdentity = async (token) => {
733
- return await withConvexClient(token, async (client) => {
734
- return await client.query(helloViewerGet, {});
735
- });
736
- };
737
- export const storeSpriteToken = async (token, spriteToken) => {
738
- await withConvexClient(token, async (client) => {
739
- await client.mutation(spriteTokenSet, { token: spriteToken });
740
- });
741
- };
742
- export const clearSpriteToken = async (token) => {
743
- await withConvexClient(token, async (client) => {
744
- await client.mutation(spriteTokenClear, {});
745
- });
746
- };
747
- export const storeClaudeCodeOauthToken = async (token, claudeCodeOauthToken) => {
748
- return await withConvexClient(token, async (client) => {
749
- const response = await client.mutation(claudeTokenSet, {
750
- token: claudeCodeOauthToken,
751
- });
752
- return {
753
- expiresAt: typeof response?.expiresAt === "number" ? response.expiresAt : 0,
754
- };
755
- });
756
- };
757
- export const clearClaudeCodeOauthToken = async (token) => {
758
- await withConvexClient(token, async (client) => {
759
- await client.mutation(claudeTokenClear, {});
760
- });
761
- };
762
- export const storeModalCredentials = async (token, tokenId, tokenSecret) => {
763
- await withConvexClient(token, async (client) => {
764
- await client.mutation(modalTokenSet, { tokenId, tokenSecret });
765
- });
766
- };
767
- export const clearModalCredentials = async (token) => {
768
- await withConvexClient(token, async (client) => {
769
- await client.mutation(modalTokenClear, {});
770
- });
771
- };
772
- const normalizeE2bDevboxRecord = (row) => {
773
- if (!row) {
774
- return null;
775
- }
776
- const instanceId = typeof row.instanceId === "string" ? row.instanceId.trim() : "";
777
- const alias = typeof row.alias === "string" ? row.alias.trim() : "";
778
- const sandboxId = typeof row.sandboxId === "string" ? row.sandboxId.trim() : "";
779
- const templateRef = typeof row.templateRef === "string" ? row.templateRef.trim() : "";
780
- const currentTemplateRef = typeof row.currentTemplateRef === "string"
781
- ? row.currentTemplateRef.trim() || null
782
- : null;
783
- const status = row.status === "running" || row.status === "paused" ? row.status : null;
784
- const timeoutMs = typeof row.timeoutMs === "number" ? row.timeoutMs : null;
785
- const autoPauseEnabled = typeof row.autoPauseEnabled === "boolean" ? row.autoPauseEnabled : null;
786
- const createdAt = typeof row.createdAt === "number" ? row.createdAt : null;
787
- const updatedAt = typeof row.updatedAt === "number" ? row.updatedAt : null;
788
- if (!instanceId ||
789
- !alias ||
790
- !sandboxId ||
791
- !templateRef ||
792
- !status ||
793
- timeoutMs === null ||
794
- autoPauseEnabled === null ||
795
- createdAt === null ||
796
- updatedAt === null) {
797
- return null;
798
- }
799
- return {
800
- instanceId,
801
- alias,
802
- sandboxId,
803
- templateRef,
804
- currentTemplateRef,
805
- templateCurrent: typeof row.templateCurrent === "boolean" ? row.templateCurrent : null,
806
- status,
807
- timeoutMs,
808
- autoPauseEnabled,
809
- metadata: normalizeStringRecord(row.metadata),
810
- latestSnapshotId: typeof row.latestSnapshotId === "string" &&
811
- row.latestSnapshotId.trim().length > 0
812
- ? row.latestSnapshotId.trim()
813
- : null,
814
- createdAt,
815
- updatedAt,
816
- lastConnectedAt: typeof row.lastConnectedAt === "number" ? row.lastConnectedAt : null,
817
- lastPausedAt: typeof row.lastPausedAt === "number" ? row.lastPausedAt : null,
818
- };
819
- };
820
- export const upsertE2bDevboxLifecycle = async (token, payload) => {
821
- await withConvexClient(token, async (client) => {
822
- await client.mutation(e2bDevboxUpsert, payload);
823
- });
824
- };
825
- export const removeE2bDevboxLifecycle = async (token, alias) => {
826
- return await withConvexClient(token, async (client) => {
827
- const response = await client.mutation(e2bDevboxRemove, { alias });
828
- return response?.removed === true;
829
- });
830
- };
831
- export const fetchE2bDevboxLifecycle = async (token, alias) => {
832
- return await withConvexClient(token, async (client) => {
833
- const response = await client.query(e2bDevboxGet, { alias });
834
- return normalizeE2bDevboxRecord(response);
835
- });
836
- };
837
- export const listE2bDevboxStatuses = async (token) => {
838
- return await withConvexClient(token, async (client) => {
839
- const rows = await client.query(e2bDevboxStatusesList, {});
840
- return rows
841
- .map((row) => normalizeE2bDevboxRecord(row))
842
- .filter((row) => row !== null);
843
- });
844
- };
845
- export const destroyE2bDevbox = async (token, alias) => {
846
- return await withConvexClient(token, async (client) => {
847
- const response = await client.action(e2bDevboxDestroy, { alias });
848
- const resolvedAlias = typeof response?.alias === "string" && response.alias.trim().length > 0
849
- ? response.alias.trim()
850
- : alias.trim();
851
- return {
852
- ok: response?.ok === true,
853
- alias: resolvedAlias,
854
- sandboxId: typeof response?.sandboxId === "string" ? response.sandboxId : null,
855
- providerDestroyed: response?.providerDestroyed === true,
856
- lifecycleRemoved: response?.lifecycleRemoved === true,
857
- instanceRemoved: response?.instanceRemoved === true,
858
- };
859
- });
860
- };
861
- export const provisionE2bDevbox = async (token, alias) => {
862
- return await withConvexClient(token, async (client) => {
863
- const response = await client.action(e2bDevboxProvision, { alias });
864
- const instanceId = typeof response?.instanceId === "string"
865
- ? response.instanceId.trim()
866
- : "";
867
- const resolvedAlias = typeof response?.alias === "string" ? response.alias.trim() : "";
868
- const sandboxId = typeof response?.sandboxId === "string" ? response.sandboxId.trim() : "";
869
- const templateRef = typeof response?.templateRef === "string"
870
- ? response.templateRef.trim()
871
- : "";
872
- const timeoutMs = typeof response?.timeoutMs === "number" ? response.timeoutMs : NaN;
873
- if (response?.ok !== true ||
874
- !instanceId ||
875
- !resolvedAlias ||
876
- !sandboxId ||
877
- !templateRef ||
878
- !Number.isFinite(timeoutMs) ||
879
- timeoutMs <= 0) {
880
- throw new Error("E2B provision response is missing required lifecycle fields.");
881
- }
882
- return {
883
- ok: true,
884
- instanceId,
885
- alias: resolvedAlias,
886
- sandboxId,
887
- templateRef,
888
- status: "running",
889
- timeoutMs,
890
- autoPauseEnabled: response?.autoPauseEnabled === true,
891
- metadata: normalizeStringRecord(response?.metadata),
892
- };
893
- });
894
- };
895
- export const restoreLatestSnapshotForE2bDevbox = async (token, sourceAlias, alias) => {
896
- return await withConvexClient(token, async (client) => {
897
- const response = await client.action(e2bDevboxRestoreLatestSnapshot, {
898
- sourceAlias,
899
- alias,
900
- });
901
- const resolvedSourceAlias = typeof response?.sourceAlias === "string"
902
- ? response.sourceAlias.trim()
903
- : "";
904
- const instanceId = typeof response?.instanceId === "string"
905
- ? response.instanceId.trim()
906
- : "";
907
- const resolvedAlias = typeof response?.alias === "string" ? response.alias.trim() : "";
908
- const sandboxId = typeof response?.sandboxId === "string" ? response.sandboxId.trim() : "";
909
- const snapshotId = typeof response?.snapshotId === "string"
910
- ? response.snapshotId.trim()
911
- : "";
912
- const templateRef = typeof response?.templateRef === "string"
913
- ? response.templateRef.trim()
914
- : "";
915
- const timeoutMs = typeof response?.timeoutMs === "number" ? response.timeoutMs : NaN;
916
- if (response?.ok !== true ||
917
- !resolvedSourceAlias ||
918
- !instanceId ||
919
- !resolvedAlias ||
920
- !sandboxId ||
921
- !snapshotId ||
922
- !templateRef ||
923
- !Number.isFinite(timeoutMs) ||
924
- timeoutMs <= 0) {
925
- throw new Error("E2B restore response is missing required lifecycle fields.");
926
- }
927
- return {
928
- ok: true,
929
- sourceAlias: resolvedSourceAlias,
930
- instanceId,
931
- alias: resolvedAlias,
932
- sandboxId,
933
- snapshotId,
934
- templateRef,
935
- status: "running",
936
- timeoutMs,
937
- autoPauseEnabled: response?.autoPauseEnabled === true,
938
- metadata: normalizeStringRecord(response?.metadata),
939
- };
940
- });
941
- };
942
- export const pauseE2bDevbox = async (token, alias) => {
943
- return await withConvexClient(token, async (client) => {
944
- const response = await client.action(e2bDevboxPause, { alias });
945
- const resolvedAlias = typeof response?.alias === "string" ? response.alias.trim() : "";
946
- const sandboxId = typeof response?.sandboxId === "string" ? response.sandboxId.trim() : "";
947
- const lastPausedAt = typeof response?.lastPausedAt === "number" ? response.lastPausedAt : NaN;
948
- if (response?.ok !== true ||
949
- !resolvedAlias ||
950
- !sandboxId ||
951
- !Number.isFinite(lastPausedAt) ||
952
- lastPausedAt <= 0) {
953
- throw new Error("E2B pause response is missing required fields.");
954
- }
955
- return {
956
- ok: true,
957
- alias: resolvedAlias,
958
- sandboxId,
959
- status: "paused",
960
- providerPaused: response?.providerPaused === true,
961
- lastPausedAt,
962
- };
963
- });
964
- };
965
- export const ensureE2bDevboxActive = async (token, alias) => {
966
- return await withConvexClient(token, async (client) => {
967
- const response = await client.action(e2bDevboxEnsureActive, { alias });
968
- const resolvedAlias = typeof response?.alias === "string" ? response.alias.trim() : "";
969
- const sandboxId = typeof response?.sandboxId === "string" ? response.sandboxId.trim() : "";
970
- const lastConnectedAt = typeof response?.lastConnectedAt === "number"
971
- ? response.lastConnectedAt
972
- : NaN;
973
- if (response?.ok !== true ||
974
- !resolvedAlias ||
975
- !sandboxId ||
976
- !Number.isFinite(lastConnectedAt) ||
977
- lastConnectedAt <= 0) {
978
- throw new Error("E2B ensure-active response is missing required fields.");
979
- }
980
- return {
981
- ok: true,
982
- alias: resolvedAlias,
983
- sandboxId,
984
- status: "running",
985
- woke: response?.woke === true,
986
- lastConnectedAt,
987
- };
988
- });
989
- };
990
- export const resetE2bDevbox = async (token, alias) => {
991
- return await withConvexClient(token, async (client) => {
992
- const response = await client.action(e2bDevboxReset, { alias });
993
- const resolvedAlias = typeof response?.alias === "string" ? response.alias.trim() : "";
994
- const result = response?.result;
995
- if (response?.ok !== true ||
996
- !resolvedAlias ||
997
- result?.computeProvider !== "e2b") {
998
- throw new Error("E2B reset response is missing required fields.");
999
- }
1000
- return {
1001
- ok: true,
1002
- alias: resolvedAlias,
1003
- result: {
1004
- computeProvider: "e2b",
1005
- requestId: normalizeOptionalString(result.requestId),
1006
- sessionsKilled: Array.isArray(result.sessionsKilled)
1007
- ? result.sessionsKilled
1008
- .map((entry) => normalizeOptionalString(entry))
1009
- .filter((entry) => entry !== null)
1010
- : [],
1011
- sessionsAlreadyGone: Array.isArray(result.sessionsAlreadyGone)
1012
- ? result.sessionsAlreadyGone
1013
- .map((entry) => normalizeOptionalString(entry))
1014
- .filter((entry) => entry !== null)
1015
- : [],
1016
- userServicesStopped: Array.isArray(result.userServicesStopped)
1017
- ? result.userServicesStopped
1018
- .map((entry) => normalizeOptionalString(entry))
1019
- .filter((entry) => entry !== null)
1020
- : [],
1021
- userServicesAlreadyStopped: Array.isArray(result.userServicesAlreadyStopped)
1022
- ? result.userServicesAlreadyStopped
1023
- .map((entry) => normalizeOptionalString(entry))
1024
- .filter((entry) => entry !== null)
1025
- : [],
1026
- claudeSessionsDisposed: Array.isArray(result.claudeSessionsDisposed)
1027
- ? result.claudeSessionsDisposed
1028
- .map((entry) => normalizeOptionalString(entry))
1029
- .filter((entry) => entry !== null)
1030
- : [],
1031
- workloadInitialPids: Array.isArray(result.workloadInitialPids)
1032
- ? result.workloadInitialPids.filter((entry) => typeof entry === "number" && Number.isInteger(entry))
1033
- : [],
1034
- workloadTermSignaledPids: Array.isArray(result.workloadTermSignaledPids)
1035
- ? result.workloadTermSignaledPids.filter((entry) => typeof entry === "number" && Number.isInteger(entry))
1036
- : [],
1037
- workloadKillSignaledPids: Array.isArray(result.workloadKillSignaledPids)
1038
- ? result.workloadKillSignaledPids.filter((entry) => typeof entry === "number" && Number.isInteger(entry))
1039
- : [],
1040
- workloadRemainingPids: Array.isArray(result.workloadRemainingPids)
1041
- ? result.workloadRemainingPids.filter((entry) => typeof entry === "number" && Number.isInteger(entry))
1042
- : [],
1043
- sshdStatusBefore: normalizeOptionalString(result.sshdStatusBefore),
1044
- sshdStatusAfter: normalizeOptionalString(result.sshdStatusAfter),
1045
- sshdRestarted: result.sshdRestarted === true,
1046
- cgroupStatusBefore: result.cgroupStatusBefore &&
1047
- typeof result.cgroupStatusBefore === "object" &&
1048
- !Array.isArray(result.cgroupStatusBefore)
1049
- ? result.cgroupStatusBefore
1050
- : {},
1051
- cgroupStatusAfter: result.cgroupStatusAfter &&
1052
- typeof result.cgroupStatusAfter === "object" &&
1053
- !Array.isArray(result.cgroupStatusAfter)
1054
- ? result.cgroupStatusAfter
1055
- : {},
1056
- },
1057
- };
1058
- });
1059
- };
1060
- export const fetchE2bDaemonConnectInfo = async (token, alias, allowWake) => {
1061
- const response = await fetchManagedDaemonConnectInfo(token, alias, "proxy", allowWake);
1062
- if (response.provider !== "e2b") {
1063
- throw new Error(`Managed daemon connect returned provider "${response.provider}" for alias "${alias}".`);
1064
- }
1065
- return {
1066
- ok: true,
1067
- alias: response.alias,
1068
- sandboxId: response.sandboxId,
1069
- status: "running",
1070
- url: response.url,
1071
- token: response.token,
1072
- };
1073
- };
1074
- const setE2bDaemonBootstrapState = async (token, alias, state, error) => {
1075
- await withConvexClient(token, async (client) => {
1076
- const response = await client.action(e2bDevboxSetDaemonBootstrapState, {
1077
- alias,
1078
- state,
1079
- ...(error !== undefined ? { error } : {}),
1080
- });
1081
- if (response?.ok !== true) {
1082
- throw new Error("Managed daemon bootstrap state update did not confirm success.");
1083
- }
1084
- });
1085
- };
1086
- export const markE2bDaemonBootstrapReady = async (token, alias) => {
1087
- await setE2bDaemonBootstrapState(token, alias, "ready", null);
1088
- };
1089
- export const markE2bDaemonBootstrapFailed = async (token, alias, error) => {
1090
- await setE2bDaemonBootstrapState(token, alias, "failed", error);
1091
- };
1092
- const throwManagedDaemonNotReady = (response, requestedAlias) => {
1093
- const provider = response.provider === "e2b" ? "e2b" : "modal";
1094
- const alias = typeof response.alias === "string" && response.alias.trim().length > 0
1095
- ? response.alias.trim()
1096
- : requestedAlias.trim();
1097
- const state = response.state === "failed" ? "failed" : "pending";
1098
- const message = typeof response.message === "string" && response.message.trim().length > 0
1099
- ? response.message.trim()
1100
- : `Managed devbox "${alias}" is not ready. Run \`dvb init --resume\`.`;
1101
- const detail = typeof response.error === "string" && response.error.trim().length > 0
1102
- ? response.error.trim()
1103
- : undefined;
1104
- throw new ManagedDaemonNotReadyError({
1105
- provider,
1106
- alias,
1107
- state,
1108
- message,
1109
- ...(detail ? { detail } : {}),
1110
- });
1111
- };
1112
- const normalizeOptionalString = (value) => {
1113
- if (typeof value !== "string") {
1114
- return null;
1115
- }
1116
- const trimmed = value.trim();
1117
- return trimmed.length > 0 ? trimmed : null;
1118
- };
1119
- const normalizeAliasForLookup = (value) => value.trim().toLowerCase();
1120
- const normalizeManagedCheckpointResponse = (response) => {
1121
- if (!Array.isArray(response)) {
1122
- throw new Error("Managed checkpoint response is invalid.");
1123
- }
1124
- return response
1125
- .filter((entry) => entry && typeof entry === "object")
1126
- .map((entry) => entry);
1127
- };
1128
- const buildRecoveredManagedCheckpointResponse = ({ baseline, current, comment, }) => {
1129
- if (!baseline || !current) {
1130
- return null;
1131
- }
1132
- if (baseline.provider !== current.provider ||
1133
- baseline.alias !== current.alias ||
1134
- !current.latestCheckpointId ||
1135
- current.latestCheckpointId === baseline.latestCheckpointId) {
1136
- return null;
1137
- }
1138
- return [
1139
- {
1140
- id: current.latestCheckpointId,
1141
- checkpoint_id: current.latestCheckpointId,
1142
- provider: current.provider,
1143
- provider_checkpoint_id: current.latestCheckpointId,
1144
- ...(typeof comment === "string" ? { comment } : {}),
1145
- },
1146
- ];
1147
- };
1148
- const readManagedCheckpointRecoveryState = async (token, alias) => {
1149
- return await withConvexClient(token, async (client) => {
1150
- const normalizedAlias = normalizeAliasForLookup(alias);
1151
- if (!normalizedAlias) {
1152
- return null;
1153
- }
1154
- const entries = await client.query(instancesList, {});
1155
- const instance = entries.find((entry) => typeof entry?.alias === "string" &&
1156
- normalizeAliasForLookup(entry.alias) === normalizedAlias);
1157
- if (!instance) {
1158
- return null;
1159
- }
1160
- if (instance.provider === "e2b") {
1161
- const response = await client.query(e2bDevboxGet, {
1162
- alias: normalizedAlias,
1163
- });
1164
- return {
1165
- provider: "e2b",
1166
- alias: normalizedAlias,
1167
- latestCheckpointId: normalizeOptionalString(response?.latestSnapshotId),
1168
- };
1169
- }
1170
- if (instance.provider === "modal") {
1171
- const rows = await client.query(modalDevboxStatusesList, {});
1172
- const row = rows.find((entry) => typeof entry?.alias === "string" &&
1173
- normalizeAliasForLookup(entry.alias) === normalizedAlias);
1174
- return {
1175
- provider: "modal",
1176
- alias: normalizedAlias,
1177
- latestCheckpointId: normalizeOptionalString(row?.latestFilesystemImageId),
1178
- };
1179
- }
1180
- return null;
1181
- });
1182
- };
1183
- const recoverManagedCheckpointAfterDisconnect = async ({ token, alias, comment, baseline, maxAttempts = 12, pollMs = 1_000, sleepImpl = sleep, }) => {
1184
- if (!baseline) {
1185
- return null;
1186
- }
1187
- const attempts = Math.max(1, Math.floor(maxAttempts));
1188
- for (let attempt = 1; attempt <= attempts; attempt += 1) {
1189
- try {
1190
- const current = await readManagedCheckpointRecoveryState(token, alias);
1191
- const recovered = buildRecoveredManagedCheckpointResponse({
1192
- baseline,
1193
- current,
1194
- ...(typeof comment === "string" ? { comment } : {}),
1195
- });
1196
- if (recovered) {
1197
- logger.warn("control_plane_checkpoint_recovered_after_disconnect", {
1198
- alias: baseline.alias,
1199
- provider: baseline.provider,
1200
- attempt,
1201
- checkpointId: recovered[0]?.id ?? null,
1202
- });
1203
- return recovered;
1204
- }
1205
- }
1206
- catch (error) {
1207
- logger.warn("control_plane_checkpoint_recovery_poll_failed", {
1208
- alias: baseline.alias,
1209
- provider: baseline.provider,
1210
- attempt,
1211
- error: error instanceof Error ? error.message : String(error),
1212
- });
1213
- }
1214
- if (attempt < attempts) {
1215
- await sleepImpl(pollMs);
1216
- }
1217
- }
1218
- return null;
1219
- };
1220
- const buildManagedDaemonConnectInfoResponseSummary = (args) => {
1221
- const responseRecord = args.response && typeof args.response === "object"
1222
- ? args.response
1223
- : null;
1224
- return {
1225
- requestedAlias: args.requestedAlias.trim(),
1226
- responseAlias: normalizeOptionalString(args.response?.alias),
1227
- intent: args.intent,
1228
- allowWake: args.allowWake !== false,
1229
- ok: args.response?.ok === true
1230
- ? true
1231
- : args.response?.ok === false
1232
- ? false
1233
- : null,
1234
- provider: args.response?.provider === "modal" || args.response?.provider === "e2b"
1235
- ? args.response.provider
1236
- : null,
1237
- status: normalizeOptionalString(args.response?.status),
1238
- code: normalizeOptionalString(args.response?.code),
1239
- state: normalizeOptionalString(args.response?.state),
1240
- hasSandboxId: normalizeOptionalString(args.response?.sandboxId) !== null,
1241
- hasUrl: normalizeOptionalString(args.response?.url) !== null,
1242
- hasToken: normalizeOptionalString(args.response?.token) !== null,
1243
- hasCanonical: normalizeOptionalString(args.response?.canonical) !== null,
1244
- hasAppName: normalizeOptionalString(args.response?.appName) !== null,
1245
- hasAppId: normalizeOptionalString(args.response?.appId) !== null,
1246
- message: normalizeOptionalString(args.response?.message),
1247
- error: normalizeOptionalString(args.response?.error),
1248
- detail: normalizeOptionalString(args.response?.detail),
1249
- responseKeys: responseRecord ? Object.keys(responseRecord).sort() : [],
1250
- };
1251
- };
1252
- const buildManagedDaemonConnectInfoUnexpectedMessage = (summary) => {
1253
- const parts = [
1254
- `provider=${summary.provider ?? "unknown"}`,
1255
- `ok=${summary.ok === null ? "unknown" : String(summary.ok)}`,
1256
- `intent=${summary.intent}`,
1257
- `allowWake=${String(summary.allowWake)}`,
1258
- `status=${summary.status ?? "unknown"}`,
1259
- `state=${summary.state ?? "unknown"}`,
1260
- `code=${summary.code ?? "unknown"}`,
1261
- `hasSandboxId=${String(summary.hasSandboxId)}`,
1262
- `hasUrl=${String(summary.hasUrl)}`,
1263
- `hasToken=${String(summary.hasToken)}`,
1264
- ];
1265
- if (summary.provider === "modal") {
1266
- parts.push(`hasCanonical=${String(summary.hasCanonical)}`);
1267
- parts.push(`hasAppName=${String(summary.hasAppName)}`);
1268
- parts.push(`hasAppId=${String(summary.hasAppId)}`);
1269
- }
1270
- parts.push(`responseKeys=${summary.responseKeys.length > 0 ? summary.responseKeys.join("|") : "none"}`);
1271
- return `Managed daemon connect-info returned an unexpected response shape for "${summary.requestedAlias}" (${parts.join(", ")}).`;
1272
- };
1273
- const buildManagedDaemonConnectInfoSleepingMessage = (summary) => {
1274
- const alias = summary.responseAlias ?? summary.requestedAlias;
1275
- const wakeClause = summary.allowWake
1276
- ? "after a wake-enabled connect attempt"
1277
- : "while wake was disabled";
1278
- const detail = summary.detail ?? summary.error ?? summary.message;
1279
- return [
1280
- `E2B devbox "${alias}" is sleeping and did not provide daemon connect info ${wakeClause}.`,
1281
- "Wake the devbox and retry.",
1282
- detail ? `Detail: ${detail}` : null,
1283
- ]
1284
- .filter((part) => part !== null)
1285
- .join(" ");
1286
- };
1287
- const logManagedDaemonConnectInfoResponse = (event, summary) => {
1288
- logger.warn(event, {
1289
- requestedAlias: summary.requestedAlias,
1290
- responseAlias: summary.responseAlias,
1291
- intent: summary.intent,
1292
- allowWake: summary.allowWake,
1293
- ok: summary.ok,
1294
- provider: summary.provider,
1295
- status: summary.status,
1296
- code: summary.code,
1297
- state: summary.state,
1298
- hasSandboxId: summary.hasSandboxId,
1299
- hasUrl: summary.hasUrl,
1300
- hasToken: summary.hasToken,
1301
- hasCanonical: summary.hasCanonical,
1302
- hasAppName: summary.hasAppName,
1303
- hasAppId: summary.hasAppId,
1304
- message: summary.message,
1305
- error: summary.error,
1306
- detail: summary.detail,
1307
- responseKeys: summary.responseKeys,
1308
- });
1309
- };
1310
- export const fetchManagedDaemonConnectInfo = async (token, alias, intent, allowWake) => {
1311
- const response = await retryTransientConvexAction({
1312
- actionName: "devboxes:issueManagedDaemonConnectInfoForViewer",
1313
- onRetry: announceTransientConvexActionRetry,
1314
- run: async () => await withConvexClient(token, async (client) => {
1315
- return await client.action(managedDevboxIssueDaemonConnectInfo, {
1316
- alias,
1317
- intent,
1318
- ...(allowWake !== undefined ? { allowWake } : {}),
1319
- });
1320
- }),
1321
- });
1322
- if (response?.ok === false &&
1323
- response.code === MANAGED_DAEMON_NOT_READY_CODE) {
1324
- throwManagedDaemonNotReady(response, alias);
1325
- }
1326
- const summary = buildManagedDaemonConnectInfoResponseSummary({
1327
- response,
1328
- requestedAlias: alias,
1329
- intent,
1330
- allowWake,
1331
- });
1332
- const provider = summary.provider;
1333
- const resolvedAlias = summary.responseAlias ?? "";
1334
- const sandboxId = normalizeOptionalString(response?.sandboxId) ?? "";
1335
- const url = normalizeOptionalString(response?.url) ?? "";
1336
- const connectToken = normalizeOptionalString(response?.token) ?? "";
1337
- if (provider === "e2b" &&
1338
- summary.ok === true &&
1339
- summary.status === "sleeping") {
1340
- logManagedDaemonConnectInfoResponse("managed_daemon_connect_info_sleeping", summary);
1341
- throw new Error(buildManagedDaemonConnectInfoSleepingMessage(summary));
1342
- }
1343
- if (summary.ok !== true ||
1344
- (provider !== "modal" && provider !== "e2b") ||
1345
- !resolvedAlias ||
1346
- !sandboxId ||
1347
- !url ||
1348
- !connectToken) {
1349
- logManagedDaemonConnectInfoResponse("managed_daemon_connect_info_unexpected", summary);
1350
- throw new Error(buildManagedDaemonConnectInfoUnexpectedMessage(summary));
1351
- }
1352
- if (provider === "e2b") {
1353
- return {
1354
- ok: true,
1355
- provider: "e2b",
1356
- alias: resolvedAlias,
1357
- sandboxId,
1358
- status: "running",
1359
- url,
1360
- token: connectToken,
1361
- };
1362
- }
1363
- const canonical = normalizeOptionalString(response?.canonical) ?? "";
1364
- const appName = normalizeOptionalString(response?.appName) ?? "";
1365
- const appId = normalizeOptionalString(response?.appId) ?? "";
1366
- if (!canonical || !appName || !appId) {
1367
- logManagedDaemonConnectInfoResponse("managed_daemon_connect_info_unexpected", summary);
1368
- throw new Error(buildManagedDaemonConnectInfoUnexpectedMessage(summary));
1369
- }
1370
- return {
1371
- ok: true,
1372
- provider: "modal",
1373
- alias: resolvedAlias,
1374
- canonical,
1375
- appName,
1376
- appId,
1377
- sandboxId,
1378
- status: "running",
1379
- url,
1380
- token: connectToken,
1381
- };
1382
- };
1383
- export const fetchE2bBootstrapConnectInfo = async (token, alias) => {
1384
- const response = await retryTransientConvexAction({
1385
- actionName: "e2bDevboxes:issueBootstrapConnectInfoForViewer",
1386
- onRetry: announceTransientConvexActionRetry,
1387
- run: async () => await withConvexClient(token, async (client) => {
1388
- return await client.action(e2bDevboxIssueBootstrapConnectInfo, {
1389
- alias,
1390
- });
1391
- }),
1392
- });
1393
- const resolvedAlias = typeof response?.alias === "string" ? response.alias.trim() : "";
1394
- const sandboxId = typeof response?.sandboxId === "string" ? response.sandboxId.trim() : "";
1395
- const sandboxDomain = typeof response?.sandboxDomain === "string"
1396
- ? response.sandboxDomain.trim()
1397
- : "";
1398
- const envdVersion = typeof response?.envdVersion === "string"
1399
- ? response.envdVersion.trim()
1400
- : "";
1401
- const envdAccessToken = typeof response?.envdAccessToken === "string"
1402
- ? response.envdAccessToken.trim()
1403
- : "";
1404
- const trafficAccessToken = typeof response?.trafficAccessToken === "string"
1405
- ? response.trafficAccessToken.trim() || null
1406
- : null;
1407
- if (response?.ok !== true ||
1408
- !resolvedAlias ||
1409
- !sandboxId ||
1410
- !sandboxDomain ||
1411
- !envdVersion ||
1412
- !envdAccessToken) {
1413
- throw new Error("E2B bootstrap connect-info response is missing required fields.");
1414
- }
1415
- return {
1416
- ok: true,
1417
- alias: resolvedAlias,
1418
- sandboxId,
1419
- status: "running",
1420
- sandboxDomain,
1421
- envdVersion,
1422
- envdAccessToken,
1423
- trafficAccessToken,
1424
- };
1425
- };
1426
- export const createManagedCheckpoint = async (token, alias, comment) => {
1427
- const baseline = await readManagedCheckpointRecoveryState(token, alias).catch((error) => {
1428
- logger.warn("control_plane_checkpoint_recovery_baseline_failed", {
1429
- alias: normalizeAliasForLookup(alias),
1430
- error: error instanceof Error ? error.message : String(error),
1431
- });
1432
- return null;
1433
- });
1434
- try {
1435
- return await withConvexClient(token, async (client) => {
1436
- const response = await client.action(managedDevboxCreateCheckpoint, {
1437
- alias,
1438
- ...(typeof comment === "string" ? { comment } : {}),
1439
- });
1440
- return normalizeManagedCheckpointResponse(response);
1441
- });
1442
- }
1443
- catch (error) {
1444
- if (!isRetryableTransientConvexActionError(error)) {
1445
- throw error;
1446
- }
1447
- const recovered = await recoverManagedCheckpointAfterDisconnect({
1448
- token,
1449
- alias,
1450
- baseline,
1451
- ...(typeof comment === "string" ? { comment } : {}),
1452
- });
1453
- if (recovered) {
1454
- return recovered;
1455
- }
1456
- throw error;
1457
- }
1458
- };
1459
- export const listManagedRemoteStates = async (token, boxes) => {
1460
- return await withConvexClient(token, async (client) => {
1461
- const response = await client.query(managedDevboxListRemoteStates, {
1462
- boxes,
1463
- });
1464
- if (!Array.isArray(response)) {
1465
- throw new Error("Managed remote-state response is invalid.");
1466
- }
1467
- return response
1468
- .filter((entry) => entry && typeof entry === "object")
1469
- .map((entry) => entry);
1470
- });
1471
- };
1472
- export const upsertModalDevboxLifecycle = async (token, payload) => {
1473
- await withConvexClient(token, async (client) => {
1474
- await client.mutation(modalDevboxUpsert, payload);
1475
- });
1476
- };
1477
- export const removeModalDevboxLifecycle = async (token, alias) => {
1478
- await withConvexClient(token, async (client) => {
1479
- await client.mutation(modalDevboxRemove, { alias });
1480
- });
1481
- };
1482
- export const ensureModalDevboxActive = async (token, alias, intent) => {
1483
- return await withConvexClient(token, async (client) => {
1484
- const response = await client.action(modalDevboxEnsureActive, {
1485
- alias,
1486
- intent,
1487
- });
1488
- const resolvedAlias = typeof response?.alias === "string" ? response.alias.trim() : "";
1489
- const canonical = typeof response?.canonical === "string" ? response.canonical.trim() : "";
1490
- const appName = typeof response?.appName === "string" ? response.appName.trim() : "";
1491
- const appId = typeof response?.appId === "string" ? response.appId.trim() : "";
1492
- const sandboxId = typeof response?.sandboxId === "string" ? response.sandboxId.trim() : "";
1493
- const wakeSource = response?.wakeSource === "already_running" ||
1494
- response?.wakeSource === "memory_snapshot" ||
1495
- response?.wakeSource === "filesystem_snapshot"
1496
- ? response.wakeSource
1497
- : null;
1498
- if (!resolvedAlias || !canonical || !appName || !appId || !sandboxId) {
1499
- throw new Error("Modal ensure-active response is missing required fields.");
1500
- }
1501
- if (response?.status !== "running") {
1502
- throw new Error("Modal ensure-active response has invalid status.");
1503
- }
1504
- if (!wakeSource) {
1505
- throw new Error("Modal ensure-active response has invalid wake source.");
1506
- }
1507
- const bootstrapContractVersion = typeof response?.bootstrapContractVersion === "string"
1508
- ? response.bootstrapContractVersion.trim() || null
1509
- : null;
1510
- if (bootstrapContractVersion !== null &&
1511
- bootstrapContractVersion !== CURRENT_MODAL_BOOTSTRAP_CONTRACT_VERSION) {
1512
- throw new Error(`Modal ensure-active returned bootstrap contract ${bootstrapContractVersion}, but CLI hot paths require current contract ${CURRENT_MODAL_BOOTSTRAP_CONTRACT_VERSION}.`);
1513
- }
1514
- return {
1515
- alias: resolvedAlias,
1516
- canonical,
1517
- appName,
1518
- appId,
1519
- sandboxId,
1520
- status: "running",
1521
- woke: response?.woke === true,
1522
- wakeSource,
1523
- platformVersion: typeof response?.platformVersion === "string"
1524
- ? response.platformVersion.trim() || null
1525
- : null,
1526
- bootstrapContractVersion,
1527
- };
1528
- });
1529
- };
1530
- export const rebootModalDevbox = async (token, alias) => {
1531
- return await withConvexClient(token, async (client) => {
1532
- const response = await client.action(modalDevboxReboot, { alias });
1533
- const resolvedAlias = typeof response?.alias === "string" ? response.alias.trim() : "";
1534
- const canonical = typeof response?.canonical === "string" ? response.canonical.trim() : "";
1535
- const appName = typeof response?.appName === "string" ? response.appName.trim() : "";
1536
- const appId = typeof response?.appId === "string" ? response.appId.trim() : "";
1537
- const sandboxId = typeof response?.sandboxId === "string" ? response.sandboxId.trim() : "";
1538
- const wakeSource = response?.wakeSource === "already_running" ||
1539
- response?.wakeSource === "memory_snapshot" ||
1540
- response?.wakeSource === "filesystem_snapshot"
1541
- ? response.wakeSource
1542
- : null;
1543
- if (!resolvedAlias || !canonical || !appName || !appId || !sandboxId) {
1544
- throw new Error("Modal reboot response is missing required fields.");
1545
- }
1546
- if (response?.status !== "running") {
1547
- throw new Error("Modal reboot response has invalid status.");
1548
- }
1549
- if (!wakeSource) {
1550
- throw new Error("Modal reboot response has invalid wake source.");
1551
- }
1552
- if (response?.sleepStatus !== "slept") {
1553
- throw new Error("Modal reboot response did not confirm a fresh snapshot.");
1554
- }
1555
- const bootstrapContractVersion = typeof response?.bootstrapContractVersion === "string"
1556
- ? response.bootstrapContractVersion.trim() || null
1557
- : null;
1558
- if (bootstrapContractVersion !== null &&
1559
- bootstrapContractVersion !== CURRENT_MODAL_BOOTSTRAP_CONTRACT_VERSION) {
1560
- throw new Error(`Modal reboot returned bootstrap contract ${bootstrapContractVersion}, but CLI hot paths require current contract ${CURRENT_MODAL_BOOTSTRAP_CONTRACT_VERSION}.`);
1561
- }
1562
- return {
1563
- alias: resolvedAlias,
1564
- canonical,
1565
- appName,
1566
- appId,
1567
- sandboxId,
1568
- status: "running",
1569
- woke: response?.woke === true,
1570
- wakeSource,
1571
- platformVersion: typeof response?.platformVersion === "string"
1572
- ? response.platformVersion.trim() || null
1573
- : null,
1574
- bootstrapContractVersion,
1575
- sleepStatus: "slept",
1576
- };
1577
- });
1578
- };
1579
- export const ensureModalDaemonInstalled = async (token, alias) => {
1580
- await withConvexClient(token, async (client) => {
1581
- const response = await client.action(modalDevboxEnsureDaemon, {
1582
- alias,
1583
- force: true,
1584
- });
1585
- if (response?.ok !== true) {
1586
- const detail = typeof response?.error === "string" && response.error.trim().length > 0
1587
- ? response.error.trim()
1588
- : "Failed to install the remote daemon in the managed devbox.";
1589
- throw new Error(detail);
1590
- }
1591
- const spriteName = typeof response?.spriteName === "string"
1592
- ? response.spriteName.trim()
1593
- : "";
1594
- const sha256 = typeof response?.sha256 === "string" ? response.sha256 : "";
1595
- if (!spriteName || !sha256) {
1596
- throw new Error("Modal daemon-install response is missing required fields.");
1597
- }
1598
- });
1599
- };
1600
- export const fetchModalDaemonConnectToken = async (token, alias, intent) => {
1601
- const response = await fetchManagedDaemonConnectInfo(token, alias, intent);
1602
- if (response.provider !== "modal") {
1603
- throw new Error(`Managed daemon connect returned provider "${response.provider}" for modal alias "${alias}".`);
1604
- }
1605
- return {
1606
- alias: response.alias,
1607
- canonical: response.canonical,
1608
- appName: response.appName,
1609
- appId: response.appId,
1610
- sandboxId: response.sandboxId,
1611
- url: response.url,
1612
- token: response.token,
1613
- };
1614
- };
1615
- export const findModalSandboxViaControlPlane = async (token, args) => {
1616
- return await withConvexClient(token, async (client) => {
1617
- const response = await client.action(modalDevboxFind, args);
1618
- if (!response) {
1619
- return null;
1620
- }
1621
- const sandboxId = typeof response.sandboxId === "string" ? response.sandboxId.trim() : "";
1622
- const appId = typeof response.appId === "string" ? response.appId.trim() : "";
1623
- const appName = typeof response.appName === "string" ? response.appName.trim() : "";
1624
- const name = typeof response.name === "string" ? response.name.trim() : "";
1625
- const createdAt = typeof response.createdAt === "number" ? response.createdAt : null;
1626
- const status = typeof response.status === "string" ? response.status.trim() : "";
1627
- const regions = Array.isArray(response.regions)
1628
- ? response.regions
1629
- .filter((entry) => typeof entry === "string")
1630
- .map((entry) => entry.trim())
1631
- .filter((entry) => entry.length > 0)
1632
- : [];
1633
- if (!sandboxId || !appId || !appName || !name || createdAt === null) {
1634
- throw new Error("Modal sandbox lookup response is missing required data.");
1635
- }
1636
- return { sandboxId, appId, appName, name, createdAt, status, regions };
1637
- });
1638
- };
1639
- export const provisionModalSandboxViaControlPlane = async (token, alias) => {
1640
- return await withConvexClient(token, async (client) => {
1641
- const response = await client.action(modalDevboxProvision, { alias });
1642
- const sandboxId = typeof response?.sandboxId === "string" ? response.sandboxId.trim() : "";
1643
- const appId = typeof response?.appId === "string" ? response.appId.trim() : "";
1644
- const appName = typeof response?.appName === "string" ? response.appName.trim() : "";
1645
- const imageTag = typeof response?.imageTag === "string" ? response.imageTag.trim() : "";
1646
- const timeoutMs = typeof response?.timeoutMs === "number" ? response.timeoutMs : null;
1647
- const regions = Array.isArray(response?.regions)
1648
- ? response.regions
1649
- .filter((entry) => typeof entry === "string")
1650
- .map((entry) => entry.trim())
1651
- .filter((entry) => entry.length > 0)
1652
- : [];
1653
- if (!sandboxId || !appId || !appName || !imageTag || timeoutMs === null) {
1654
- throw new Error("Modal provision response is missing required fields.");
1655
- }
1656
- return {
1657
- sandboxId,
1658
- appId,
1659
- appName,
1660
- imageTag,
1661
- timeoutMs,
1662
- memorySnapshotEnabled: response?.memorySnapshotEnabled === true,
1663
- regions,
1664
- platformVersion: typeof response?.platformVersion === "string"
1665
- ? response.platformVersion.trim() || null
1666
- : null,
1667
- bootstrapContractVersion: typeof response?.bootstrapContractVersion === "string"
1668
- ? response.bootstrapContractVersion.trim() || null
1669
- : null,
1670
- };
1671
- });
1672
- };
1673
- export const terminateModalSandboxesByAliasViaControlPlane = async (token, args) => {
1674
- return await withConvexClient(token, async (client) => {
1675
- const response = await client.action(modalDevboxTerminate, args);
1676
- const appName = typeof response?.appName === "string" ? response.appName.trim() : "";
1677
- const appId = typeof response?.appId === "string" ? response.appId.trim() : null;
1678
- const matchedSandboxIds = Array.isArray(response?.matchedSandboxIds)
1679
- ? response.matchedSandboxIds
1680
- .filter((entry) => typeof entry === "string")
1681
- .map((entry) => entry.trim())
1682
- .filter((entry) => entry.length > 0)
1683
- : [];
1684
- const terminatedSandboxIds = Array.isArray(response?.terminatedSandboxIds)
1685
- ? response.terminatedSandboxIds
1686
- .filter((entry) => typeof entry === "string")
1687
- .map((entry) => entry.trim())
1688
- .filter((entry) => entry.length > 0)
1689
- : [];
1690
- if (!appName) {
1691
- throw new Error("Modal terminate response is missing appName.");
1692
- }
1693
- return {
1694
- appName,
1695
- appId,
1696
- matchedSandboxIds,
1697
- terminatedSandboxIds,
1698
- };
1699
- });
1700
- };
1701
- export const recordModalShellConnectionOpened = async (token, alias) => {
1702
- await withConvexClient(token, async (client) => {
1703
- await client.mutation(modalDevboxShellConnectionOpened, { alias });
1704
- });
1705
- };
1706
- export const recordModalShellConnectionClosed = async (token, alias) => {
1707
- await withConvexClient(token, async (client) => {
1708
- await client.mutation(modalDevboxShellConnectionClosed, { alias });
1709
- });
1710
- };
1711
- export const recordModalProxyConnectionOpened = async (token, alias) => {
1712
- await withConvexClient(token, async (client) => {
1713
- await client.mutation(modalDevboxProxyConnectionOpened, { alias });
1714
- });
1715
- };
1716
- export const recordModalProxyConnectionClosed = async (token, alias) => {
1717
- await withConvexClient(token, async (client) => {
1718
- await client.mutation(modalDevboxProxyConnectionClosed, { alias });
1719
- });
1720
- };
1721
- export const listModalDevboxStatuses = async (token) => {
1722
- return await withConvexClient(token, async (client) => {
1723
- const rows = await client.query(modalDevboxStatusesList, {});
1724
- const result = [];
1725
- for (const row of rows) {
1726
- const alias = typeof row?.alias === "string" ? row.alias.trim() : "";
1727
- const canonical = typeof row?.canonical === "string" ? row.canonical.trim() : "";
1728
- const status = row?.status === "running" || row?.status === "sleeping"
1729
- ? row.status
1730
- : null;
1731
- const updatedAt = typeof row?.updatedAt === "number" ? row.updatedAt : null;
1732
- if (!alias || !canonical || !status || updatedAt === null) {
1733
- continue;
1734
- }
1735
- const runningSandboxId = typeof row.runningSandboxId === "string"
1736
- ? row.runningSandboxId.trim()
1737
- : null;
1738
- result.push({
1739
- alias,
1740
- canonical,
1741
- status,
1742
- runningSandboxId,
1743
- runningPlatformVersion: typeof row.runningPlatformVersion === "string"
1744
- ? row.runningPlatformVersion.trim() || null
1745
- : null,
1746
- runningBootstrapContractVersion: typeof row.runningBootstrapContractVersion === "string"
1747
- ? row.runningBootstrapContractVersion.trim() || null
1748
- : null,
1749
- latestMemorySnapshotPlatformVersion: typeof row.latestMemorySnapshotPlatformVersion === "string"
1750
- ? row.latestMemorySnapshotPlatformVersion.trim() || null
1751
- : null,
1752
- latestMemorySnapshotBootstrapContractVersion: typeof row.latestMemorySnapshotBootstrapContractVersion === "string"
1753
- ? row.latestMemorySnapshotBootstrapContractVersion.trim() || null
1754
- : null,
1755
- latestFilesystemImageId: typeof row.latestFilesystemImageId === "string"
1756
- ? row.latestFilesystemImageId.trim() || null
1757
- : null,
1758
- latestFilesystemSnapshotPlatformVersion: typeof row.latestFilesystemSnapshotPlatformVersion === "string"
1759
- ? row.latestFilesystemSnapshotPlatformVersion.trim() || null
1760
- : null,
1761
- latestFilesystemSnapshotBootstrapContractVersion: typeof row.latestFilesystemSnapshotBootstrapContractVersion ===
1762
- "string"
1763
- ? row.latestFilesystemSnapshotBootstrapContractVersion.trim() ||
1764
- null
1765
- : null,
1766
- updatedAt,
1767
- });
1768
- }
1769
- return result;
1770
- });
1771
- };
1772
- export const listViewerInstances = async (token) => {
1773
- return await withConvexClient(token, async (client) => {
1774
- const entries = await client.query(instancesList, {});
1775
- const result = [];
1776
- for (const entry of entries) {
1777
- const provider = entry?.provider === "sprites" ||
1778
- entry?.provider === "modal" ||
1779
- entry?.provider === "e2b"
1780
- ? entry.provider
1781
- : null;
1782
- const instanceId = typeof entry?.instanceId === "string" ? entry.instanceId.trim() : "";
1783
- const alias = typeof entry?.alias === "string" ? entry.alias.trim() : "";
1784
- const providerInstanceId = typeof entry?.providerInstanceId === "string"
1785
- ? entry.providerInstanceId.trim()
1786
- : "";
1787
- if (!instanceId || !alias || !provider || !providerInstanceId) {
1788
- continue;
1789
- }
1790
- result.push({
1791
- instanceId,
1792
- alias,
1793
- provider,
1794
- providerInstanceId,
1795
- });
1796
- }
1797
- return result;
1798
- });
1799
- };
1800
- export const fetchSpriteDaemonRelease = async (token, computeProvider) => {
1801
- return await withConvexClient(token, async (client) => {
1802
- return await client.query(spriteDaemonReleaseGet, { computeProvider });
1803
- });
1804
- };
1805
- export const issueSpriteDaemonToken = async (token, spriteAlias) => {
1806
- return await withConvexClient(token, async (client) => {
1807
- const instanceAlias = spriteAlias.trim();
1808
- if (!instanceAlias) {
1809
- throw new Error("Sprite alias is required.");
1810
- }
1811
- await resolveInstanceIdForAlias(client, instanceAlias);
1812
- const response = await client.mutation(spriteDaemonTokenIssue, {
1813
- instanceAlias,
1814
- });
1815
- return typeof response?.token === "string" ? response.token : null;
1816
- });
1817
- };
1818
- export const listSpriteDaemonSessionSummaries = async (token, spriteAlias) => {
1819
- const requestId = randomUUID();
1820
- logger.info("control_plane_query", {
1821
- requestId,
1822
- action: "spriteDaemonSessionSummaries:listForInstance",
1823
- spriteAlias,
1824
- });
1825
- try {
1826
- const result = await withConvexClient(token, async (client) => {
1827
- const instanceId = await resolveInstanceIdForAlias(client, spriteAlias);
1828
- return await client.query(spriteDaemonSessionSummariesList, {
1829
- instanceId,
1830
- });
1831
- });
1832
- logger.info("control_plane_query_result", {
1833
- requestId,
1834
- action: "spriteDaemonSessionSummaries:listForInstance",
1835
- status: "ok",
1836
- count: result.length,
1837
- });
1838
- return result;
1839
- }
1840
- catch (error) {
1841
- logger.info("control_plane_query_result", {
1842
- requestId,
1843
- action: "spriteDaemonSessionSummaries:listForInstance",
1844
- status: "error",
1845
- error: error instanceof Error ? error.message : String(error),
1846
- });
1847
- throw error;
1848
- }
1849
- };
1850
- export const listSpriteDaemonSessions = async (token, spriteAlias) => {
1851
- const requestId = randomUUID();
1852
- logger.info("control_plane_query", {
1853
- requestId,
1854
- action: "spriteDaemonSessions:listForInstance",
1855
- spriteAlias,
1856
- });
1857
- try {
1858
- const result = await withConvexClient(token, async (client) => {
1859
- const instanceId = await resolveInstanceIdForAlias(client, spriteAlias);
1860
- return await client.query(spriteDaemonSessionsList, { instanceId });
1861
- });
1862
- logger.info("control_plane_query_result", {
1863
- requestId,
1864
- action: "spriteDaemonSessions:listForInstance",
1865
- status: "ok",
1866
- count: result.length,
1867
- });
1868
- return result;
1869
- }
1870
- catch (error) {
1871
- logger.info("control_plane_query_result", {
1872
- requestId,
1873
- action: "spriteDaemonSessions:listForInstance",
1874
- status: "error",
1875
- error: error instanceof Error ? error.message : String(error),
1876
- });
1877
- throw error;
1878
- }
1879
- };
1880
- export const signOutControlPlane = async (token) => {
1881
- const baseUrl = resolveControlPlaneUrl();
1882
- if (!baseUrl) {
1883
- throw new Error("Control plane URL is not embedded. Rebuild with CONVEX_SITE_URL set.");
1884
- }
1885
- await requestJson(baseUrl, "POST", "/auth/signout", undefined, token);
1886
- };
1887
- export const refreshControlPlaneSession = async (refreshToken) => {
1888
- const baseUrl = resolveControlPlaneUrl();
1889
- if (!baseUrl) {
1890
- throw new Error("Control plane URL is not embedded. Rebuild with CONVEX_SITE_URL set.");
1891
- }
1892
- const response = await requestJson(baseUrl, "POST", "/auth/refresh", { refresh_token: refreshToken });
1893
- if (!response.token) {
1894
- throw new Error("Control plane refresh failed.");
1895
- }
1896
- return response.refresh_token
1897
- ? { token: response.token, refreshToken: response.refresh_token }
1898
- : { token: response.token };
1899
- };
1900
- export const __testOnly = {
1901
- buildRecoveredManagedCheckpointResponse,
1902
- buildManagedDaemonConnectInfoResponseSummary,
1903
- buildManagedDaemonConnectInfoSleepingMessage,
1904
- buildManagedDaemonConnectInfoUnexpectedMessage,
1905
- buildConvexClientOptions,
1906
- buildTransientConvexActionRetryMessage,
1907
- isRetryableTransientConvexActionError,
1908
- retryTransientConvexAction,
1909
- };
1910
- //# sourceMappingURL=controlPlane.js.map