@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,1367 +0,0 @@
1
- import { spawn } from "node:child_process";
2
- import { randomUUID } from "node:crypto";
3
- import os from "node:os";
4
- import { createInterface as createLineReader } from "node:readline";
5
- import readline from "node:readline/promises";
6
- import { resolveSocketInfo } from "@boxes-dev/core";
7
- import { CONTROL_TTY_REPLACED_CLOSE_CODE, createSecretStore, createSpritesClient, loadConfig, readSpriteSessions, resolveProjectWorkdir, resolveRelayBaseUrl, writeSpriteSessions, } from "@boxes-dev/core";
8
- import { DAEMON_TIMEOUT_MS, ensureDaemonRunning, requestJson, requireDaemonFeatures, throwDaemonResponseError, } from "../daemonClient.js";
9
- import { ensureSpritesToken } from "../auth.js";
10
- import { openBrowser } from "../browser.js";
11
- import { logger } from "../logger.js";
12
- import { createLatencyTracker } from "../latency.js";
13
- import { streamExecSession, } from "../terminal/sessionProtocol.js";
14
- import { createStatusLine } from "../ui/statusLine.js";
15
- import { recordCompletionSessionsFromMap } from "../completions/index.js";
16
- import { listDevboxes, selectDevbox } from "./boxSelect.js";
17
- import { assertCommandProviderCapability, hasCommandProviderCapability, resolveCommandComputeProvider, } from "./commandProvider.js";
18
- import { finalizeAutoNamedSession, initializeSessionMapState, refreshSessionMapState, renameMappedSession, } from "./connectSessionMapping.js";
19
- import { resolveRuntimeClient } from "./runtimeClient.js";
20
- import { resolveRemoteHome } from "./sshAccess.js";
21
- import { buildSessionLogPath, shellQuote } from "./sessionUtils.js";
22
- import { parseCommandArgs, readBooleanFlag, readStringFlag, } from "../commandRegistry/args.js";
23
- import { usageError } from "../commandRegistry/errors.js";
24
- export const resolveInitialSessionId = ({ supportsAttachExecSession, sessionIdOverride, sessionName, sessions, requireFreshSessionOpen, }) => {
25
- if (!supportsAttachExecSession)
26
- return undefined;
27
- if (sessionIdOverride)
28
- return sessionIdOverride;
29
- if (requireFreshSessionOpen)
30
- return undefined;
31
- return sessionName ? sessions[sessionName] : undefined;
32
- };
33
- export const shouldAttachToExistingSession = ({ supportsAttachExecSession, sessionId, requireFreshSessionOpen, }) => supportsAttachExecSession && Boolean(sessionId) && !requireFreshSessionOpen;
34
- export const resolveSessionSpecifierFromExplicitTarget = ({ sessionName, availableSessions, }) => {
35
- const requested = sessionName?.trim();
36
- if (!requested) {
37
- return { sessionName, sessionIdOverride: undefined };
38
- }
39
- const match = availableSessions.find((session) => session.id === requested && session.tty !== false);
40
- if (!match) {
41
- return { sessionName, sessionIdOverride: undefined };
42
- }
43
- return { sessionName: undefined, sessionIdOverride: match.id };
44
- };
45
- export const isAttachReplacedCloseCode = (closeCode) => closeCode === CONTROL_TTY_REPLACED_CLOSE_CODE;
46
- export const shouldCancelConnectOnSigint = (phase) => phase !== "attached";
47
- export const isRawCtrlCChunk = (chunk) => chunk.length === 1 && chunk[0] === 0x03;
48
- export const normalizeTtyTerm = (term) => {
49
- const trimmed = term?.trim() ?? "";
50
- const normalized = trimmed.toLowerCase();
51
- if (!trimmed || normalized === "dumb" || normalized === "unknown") {
52
- return "xterm-256color";
53
- }
54
- return trimmed;
55
- };
56
- const DEFAULT_TTY_COLS = 80;
57
- const DEFAULT_TTY_ROWS = 24;
58
- const TERMINAL_INPUT_MODE_RESET = [
59
- "\u001b[?1004l", // disable focus in/out reporting
60
- "\u001b[?2004l", // disable bracketed paste
61
- "\u001b[>4;0m", // disable xterm modifyOtherKeys (CSI-u style ctrl keys)
62
- "\u001b[<u", // disable kitty keyboard protocol
63
- ].join("");
64
- const resetTerminalInputModes = () => {
65
- const stream = process.stderr.isTTY
66
- ? process.stderr
67
- : process.stdout.isTTY
68
- ? process.stdout
69
- : null;
70
- if (!stream)
71
- return;
72
- try {
73
- stream.write(TERMINAL_INPUT_MODE_RESET);
74
- }
75
- catch {
76
- // ignore terminal reset failures
77
- }
78
- };
79
- const warnSetupStatus = (status, spriteAlias) => {
80
- if (status === "complete")
81
- return;
82
- if (status === "local_required") {
83
- console.warn(`Warning: devbox setup incomplete for ${spriteAlias}. Resume from the repo with \`dvb init --resume\`.`);
84
- return;
85
- }
86
- if (status === "remote_ready") {
87
- console.warn(`Warning: devbox setup incomplete for ${spriteAlias}. Finish setup with \`dvb init --resume\`.`);
88
- }
89
- };
90
- const resolveTtyEnv = (terminalSessionId) => {
91
- const env = {};
92
- env.TERM = normalizeTtyTerm(process.env.TERM);
93
- const colorterm = process.env.COLORTERM?.trim();
94
- if (colorterm)
95
- env.COLORTERM = colorterm;
96
- if (terminalSessionId)
97
- env.DEVBOX_TERM_SESSION_ID = terminalSessionId;
98
- return env;
99
- };
100
- const formatEnvExports = (env) => Object.entries(env)
101
- .map(([key, value]) => `export ${key}=${shellQuote(value)}`)
102
- .join("; ");
103
- const parseEnvSize = (value) => {
104
- if (!value)
105
- return undefined;
106
- const parsed = Number(value);
107
- if (!Number.isFinite(parsed) || parsed <= 0)
108
- return undefined;
109
- return Math.floor(parsed);
110
- };
111
- const readStreamSize = (stream) => {
112
- const cols = stream.columns;
113
- const rows = stream.rows;
114
- if (typeof cols !== "number" || cols <= 0)
115
- return null;
116
- if (typeof rows !== "number" || rows <= 0)
117
- return null;
118
- return { cols, rows };
119
- };
120
- const resolveTtySize = () => {
121
- const stdoutSize = readStreamSize(process.stdout);
122
- if (stdoutSize)
123
- return stdoutSize;
124
- const stderrSize = readStreamSize(process.stderr);
125
- if (stderrSize)
126
- return stderrSize;
127
- const envCols = parseEnvSize(process.env.COLUMNS);
128
- const envRows = parseEnvSize(process.env.LINES);
129
- return {
130
- cols: envCols ?? DEFAULT_TTY_COLS,
131
- rows: envRows ?? DEFAULT_TTY_ROWS,
132
- };
133
- };
134
- const resolveSessionEnv = (terminalSessionId, sessionName) => {
135
- const env = {};
136
- if (terminalSessionId)
137
- env.DEVBOX_TERM_SESSION_ID = terminalSessionId;
138
- if (sessionName) {
139
- env[SESSION_NAME_TOKEN_KEY] = encodeSessionNameToken(sessionName);
140
- }
141
- return env;
142
- };
143
- const parseReachabilityState = (output) => {
144
- const lines = output
145
- .split(/\r?\n/)
146
- .map((line) => line.trim())
147
- .filter(Boolean);
148
- for (const line of lines) {
149
- if (line.startsWith("Not Reachable"))
150
- return "not_reachable";
151
- }
152
- for (const line of lines) {
153
- if (line.startsWith("Reachable"))
154
- return "reachable";
155
- }
156
- return "unknown";
157
- };
158
- const runCommand = async (command, args) => new Promise((resolve) => {
159
- const child = spawn(command, args, {
160
- stdio: ["ignore", "pipe", "pipe"],
161
- });
162
- let stdout = "";
163
- let stderr = "";
164
- if (child.stdout) {
165
- child.stdout.setEncoding("utf8");
166
- child.stdout.on("data", (chunk) => {
167
- stdout += String(chunk);
168
- });
169
- }
170
- if (child.stderr) {
171
- child.stderr.setEncoding("utf8");
172
- child.stderr.on("data", (chunk) => {
173
- stderr += String(chunk);
174
- });
175
- }
176
- child.on("error", () => resolve({ ok: false, stdout, stderr }));
177
- child.on("close", (code) => resolve({ ok: code === 0, stdout, stderr }));
178
- });
179
- const checkReachability = async (targetHost) => {
180
- const result = await runCommand("scutil", ["-r", targetHost]);
181
- if (!result.ok)
182
- return "unknown";
183
- return parseReachabilityState(result.stdout);
184
- };
185
- const watchReachabilityWithScutil = (targetHost, signal) => new Promise((resolve) => {
186
- let settled = false;
187
- let rl = null;
188
- const child = spawn("scutil", ["-r", "-W", targetHost], {
189
- stdio: ["ignore", "pipe", "pipe"],
190
- });
191
- const finish = (result) => {
192
- if (settled)
193
- return;
194
- settled = true;
195
- cleanup();
196
- resolve(result);
197
- };
198
- const onAbort = () => finish("aborted");
199
- const onError = () => finish("error");
200
- const onClose = () => finish("error");
201
- const cleanup = () => {
202
- signal.removeEventListener("abort", onAbort);
203
- rl?.removeAllListeners();
204
- rl?.close();
205
- if (child.stdout)
206
- child.stdout.removeAllListeners();
207
- if (child.stderr)
208
- child.stderr.removeAllListeners();
209
- child.removeListener("error", onError);
210
- child.removeListener("close", onClose);
211
- if (child.exitCode === null && !child.killed) {
212
- try {
213
- child.kill();
214
- }
215
- catch {
216
- // ignore kill failure
217
- }
218
- }
219
- };
220
- if (signal.aborted) {
221
- finish("aborted");
222
- return;
223
- }
224
- signal.addEventListener("abort", onAbort);
225
- child.on("error", onError);
226
- child.on("close", onClose);
227
- if (!child.stdout) {
228
- finish("error");
229
- return;
230
- }
231
- child.stdout.setEncoding("utf8");
232
- rl = createLineReader({ input: child.stdout });
233
- rl.on("line", (line) => {
234
- const trimmed = line.trim();
235
- if (trimmed.startsWith("Reachable")) {
236
- finish("online");
237
- }
238
- });
239
- });
240
- const watchReachabilityWithNotifyutil = (targetHost, signal) => new Promise((resolve) => {
241
- let settled = false;
242
- let checking = false;
243
- let pending = false;
244
- let rl = null;
245
- const child = spawn("notifyutil", ["-w", "com.apple.system.config.network_change"], { stdio: ["ignore", "pipe", "pipe"] });
246
- const finish = (result) => {
247
- if (settled)
248
- return;
249
- settled = true;
250
- cleanup();
251
- resolve(result);
252
- };
253
- const onAbort = () => finish("aborted");
254
- const onError = () => finish("error");
255
- const onClose = () => finish("error");
256
- const cleanup = () => {
257
- signal.removeEventListener("abort", onAbort);
258
- rl?.removeAllListeners();
259
- rl?.close();
260
- if (child.stdout)
261
- child.stdout.removeAllListeners();
262
- if (child.stderr)
263
- child.stderr.removeAllListeners();
264
- child.removeListener("error", onError);
265
- child.removeListener("close", onClose);
266
- if (child.exitCode === null && !child.killed) {
267
- try {
268
- child.kill();
269
- }
270
- catch {
271
- // ignore kill failure
272
- }
273
- }
274
- };
275
- if (signal.aborted) {
276
- finish("aborted");
277
- return;
278
- }
279
- signal.addEventListener("abort", onAbort);
280
- child.on("error", onError);
281
- child.on("close", onClose);
282
- if (!child.stdout) {
283
- finish("error");
284
- return;
285
- }
286
- const triggerCheck = () => {
287
- if (settled)
288
- return;
289
- if (checking) {
290
- pending = true;
291
- return;
292
- }
293
- checking = true;
294
- void (async () => {
295
- const state = await checkReachability(targetHost);
296
- if (state === "reachable") {
297
- finish("online");
298
- return;
299
- }
300
- checking = false;
301
- if (pending) {
302
- pending = false;
303
- triggerCheck();
304
- }
305
- })();
306
- };
307
- child.stdout.setEncoding("utf8");
308
- rl = createLineReader({ input: child.stdout });
309
- rl.on("line", () => {
310
- triggerCheck();
311
- });
312
- triggerCheck();
313
- });
314
- const waitForNetworkOnline = async (options) => {
315
- if (process.platform !== "darwin")
316
- return "skipped";
317
- if (!options.targetHost)
318
- return "skipped";
319
- const initial = await checkReachability(options.targetHost);
320
- if (initial !== "not_reachable")
321
- return "skipped";
322
- resetTerminalInputModes();
323
- options.onStatus?.("Waiting for network");
324
- options.onNotice?.("Network offline. Waiting for connectivity... (Ctrl+C to cancel)");
325
- const controller = new AbortController();
326
- const onSigint = () => controller.abort();
327
- process.once("SIGINT", onSigint);
328
- try {
329
- const watchResult = await watchReachabilityWithScutil(options.targetHost, controller.signal);
330
- if (watchResult === "online")
331
- return "waited";
332
- if (watchResult === "aborted")
333
- return "aborted";
334
- const fallback = await watchReachabilityWithNotifyutil(options.targetHost, controller.signal);
335
- if (fallback === "online")
336
- return "waited";
337
- if (fallback === "aborted")
338
- return "aborted";
339
- }
340
- finally {
341
- process.removeListener("SIGINT", onSigint);
342
- }
343
- return "skipped";
344
- };
345
- const parseConnectArgs = (args) => {
346
- const { flags, positionals } = parseCommandArgs({
347
- args,
348
- commandPath: ["connect"],
349
- flagLabel: "connect",
350
- boolean: ["detach", "no-log"],
351
- string: ["name", "command"],
352
- aliases: { n: "name" },
353
- });
354
- if (positionals.length > 1) {
355
- throw usageError(["connect"], `Unexpected argument: ${positionals[1]}`);
356
- }
357
- const target = positionals[0];
358
- const name = readStringFlag(flags, "name");
359
- const command = readStringFlag(flags, "command");
360
- return {
361
- ...(target ? { target } : {}),
362
- ...(name ? { name } : {}),
363
- ...(command ? { command } : {}),
364
- ...(readBooleanFlag(flags, "detach") ? { detach: true } : {}),
365
- ...(readBooleanFlag(flags, "no-log") ? { noLog: true } : {}),
366
- };
367
- };
368
- const parseConnectTarget = (value) => {
369
- const slashIndex = value.indexOf("/");
370
- if (slashIndex === -1) {
371
- return { box: value, session: undefined };
372
- }
373
- const box = value.slice(0, slashIndex);
374
- const session = value.slice(slashIndex + 1);
375
- if (!box || !session) {
376
- throw new Error("Invalid connect target. Use <box> or <box>/<session>.");
377
- }
378
- return { box, session };
379
- };
380
- const SESSION_NAME_TOKEN_KEY = "DEVBOX_SESSION_NAME_B64";
381
- const encodeSessionNameToken = (sessionName) => Buffer.from(sessionName, "utf8").toString("base64url");
382
- const SESSION_LOG_FLUSH_BYTES = 24 * 1024;
383
- const SESSION_LOG_EOF_MARKER = "__DVB_LOG_EOF__";
384
- const createRemoteSessionLogSink = (client, spriteAlias, logPath) => {
385
- let bufferedBytes = 0;
386
- let chunks = [];
387
- let closed = false;
388
- let appendQueue = Promise.resolve();
389
- const appendRemote = (payload) => {
390
- const encoded = payload.toString("base64");
391
- const command = [
392
- `log_dir=$(dirname ${shellQuote(logPath)})`,
393
- 'mkdir -p "$log_dir"',
394
- `base64 -d >> ${shellQuote(logPath)} <<'${SESSION_LOG_EOF_MARKER}'`,
395
- encoded,
396
- SESSION_LOG_EOF_MARKER,
397
- ].join("\n");
398
- appendQueue = appendQueue
399
- .then(async () => {
400
- const result = await client.exec(spriteAlias, [
401
- "/bin/bash",
402
- "-lc",
403
- command,
404
- ]);
405
- if (result.exitCode !== 0) {
406
- logger.warn("session_log_append_failed", {
407
- box: spriteAlias,
408
- logPath,
409
- exitCode: result.exitCode,
410
- });
411
- }
412
- })
413
- .catch((error) => {
414
- logger.warn("session_log_append_failed", {
415
- box: spriteAlias,
416
- logPath,
417
- error: String(error),
418
- });
419
- });
420
- };
421
- const flush = (force) => {
422
- if (bufferedBytes === 0)
423
- return;
424
- if (!force && bufferedBytes < SESSION_LOG_FLUSH_BYTES)
425
- return;
426
- const payload = Buffer.concat(chunks, bufferedBytes);
427
- chunks = [];
428
- bufferedBytes = 0;
429
- appendRemote(payload);
430
- };
431
- return {
432
- write: (chunk) => {
433
- if (closed || chunk.length === 0)
434
- return;
435
- chunks.push(Buffer.from(chunk));
436
- bufferedBytes += chunk.length;
437
- flush(false);
438
- },
439
- close: async () => {
440
- if (closed) {
441
- await appendQueue;
442
- return;
443
- }
444
- closed = true;
445
- flush(true);
446
- await appendQueue;
447
- },
448
- };
449
- };
450
- const CONNECT_SHELL_CANDIDATES = ["/bin/zsh", "/bin/bash", "/bin/sh"];
451
- const buildConnectShellProbeCommand = (shellPath) => [
452
- "/bin/bash",
453
- "--noprofile",
454
- "--norc",
455
- "-lc",
456
- `[ -x ${shellQuote(shellPath)} ] && printf '%s\\n' ${shellQuote(shellPath)}`,
457
- ];
458
- export const resolveConnectShell = async (client, spriteAlias) => {
459
- for (const shellPath of CONNECT_SHELL_CANDIDATES) {
460
- const result = await client.exec(spriteAlias, buildConnectShellProbeCommand(shellPath));
461
- if (result.exitCode !== 0)
462
- continue;
463
- const resolved = result.stdout.trim();
464
- if (resolved === shellPath) {
465
- return shellPath;
466
- }
467
- }
468
- throw new Error("No interactive shell found on devbox. Expected one of /bin/zsh, /bin/bash, or /bin/sh.");
469
- };
470
- const confirmNewSession = async (name) => {
471
- if (!process.stdin.isTTY) {
472
- throw new Error(`Session "${name}" not found. Run in a TTY to confirm creation.`);
473
- }
474
- const rl = readline.createInterface({
475
- input: process.stdin,
476
- output: process.stdout,
477
- });
478
- const answer = await rl.question(`Session "${name}" does not exist. Create it? (y/N) `);
479
- rl.close();
480
- return answer.trim().toLowerCase() === "y";
481
- };
482
- const promptRenameSession = async (current) => {
483
- if (!process.stdin.isTTY)
484
- return null;
485
- const rl = readline.createInterface({
486
- input: process.stdin,
487
- output: process.stdout,
488
- });
489
- const answer = await rl.question(`Name this session? (enter to keep "${current}") `);
490
- rl.close();
491
- const trimmed = answer.trim();
492
- return trimmed.length ? trimmed : null;
493
- };
494
- const CONNECT_OPEN_TIMEOUT_MS = 20_000;
495
- export const runConnect = async (args, overrides) => {
496
- const parsed = parseConnectArgs(args);
497
- const latency = createLatencyTracker();
498
- const initialInput = overrides?.initialInput;
499
- let sessionIdOverride = overrides?.sessionIdOverride;
500
- const disableAutoName = overrides?.disableAutoName ?? Boolean(sessionIdOverride);
501
- let targetArg = parsed.target;
502
- if (!targetArg) {
503
- const selected = await selectDevbox("Use `dvb connect <box>` to connect to a specific box.");
504
- if (!selected)
505
- return;
506
- targetArg = selected.box;
507
- }
508
- if (parsed.command && parsed.detach) {
509
- throw new Error("Cannot combine --command and --detach.");
510
- }
511
- if (!process.stdin.isTTY && !parsed.command && !parsed.detach) {
512
- throw new Error("dvb connect requires a TTY (or use --command/--detach).");
513
- }
514
- const parsedTarget = parseConnectTarget(targetArg);
515
- let target = parsedTarget;
516
- if (target.session && parsed.name) {
517
- throw new Error("Provide session name via -n or <box>/<session>, not both.");
518
- }
519
- let sessionName = parsed.name ?? target.session;
520
- if (sessionIdOverride) {
521
- sessionName = undefined;
522
- }
523
- let explicitName = Boolean(sessionName);
524
- let autoNameRequested = !explicitName && !parsed.command && !disableAutoName;
525
- let autoNamed = false;
526
- if (sessionName && parsed.command) {
527
- throw new Error("Cannot use --command with a named session.");
528
- }
529
- const isDetached = Boolean(parsed.detach);
530
- const isTty = !parsed.command;
531
- let shouldLog = isTty && !parsed.noLog;
532
- const statusEnabled = isTty && !parsed.command && !isDetached && process.stderr.isTTY;
533
- let allowStatus = statusEnabled;
534
- const status = createStatusLine({ enabled: statusEnabled });
535
- const stage = (text) => {
536
- if (!allowStatus)
537
- return;
538
- status.stage(text);
539
- };
540
- const shouldReportSession = isTty && !parsed.command && !isDetached;
541
- const pauseStatus = () => {
542
- if (statusEnabled)
543
- status.stop();
544
- };
545
- const pendingPortLogs = new Map();
546
- let nextPortLogToken = 1;
547
- try {
548
- stage("Starting dvbd");
549
- const socketInfo = resolveSocketInfo();
550
- await ensureDaemonRunning(socketInfo.socketPath);
551
- await requireDaemonFeatures(socketInfo.socketPath, ["registry", "ports"]);
552
- let boxes = null;
553
- if (parsed.target) {
554
- try {
555
- boxes = await listDevboxes();
556
- }
557
- catch (error) {
558
- logger.warn("registry_boxes_lookup_failed", { error: String(error) });
559
- }
560
- }
561
- if (parsed.target && !parsedTarget.session) {
562
- if (boxes && boxes.length === 1) {
563
- const onlyBox = boxes[0];
564
- const alias = onlyBox?.alias?.trim() ?? "";
565
- const canonical = onlyBox?.canonical?.trim() ?? "";
566
- const matchesBoxName = (alias.length > 0 && targetArg === alias) ||
567
- (canonical.length > 0 && targetArg === canonical);
568
- if (!matchesBoxName) {
569
- const handle = alias;
570
- if (handle) {
571
- target = { box: handle, session: targetArg };
572
- if (!sessionName) {
573
- sessionName = targetArg;
574
- }
575
- }
576
- }
577
- }
578
- }
579
- stage("Resolving devbox target");
580
- let spriteAlias = target.box;
581
- if (!boxes) {
582
- const response = await requestJson(socketInfo.socketPath, "GET", "/boxes", DAEMON_TIMEOUT_MS.registry);
583
- if (response.status !== 200) {
584
- throwDaemonResponseError(response);
585
- }
586
- boxes = response.body.boxes;
587
- }
588
- const matchedEntry = boxes.find((entry) => entry.alias === spriteAlias) ??
589
- boxes.find((entry) => entry.canonical === spriteAlias) ??
590
- null;
591
- if (matchedEntry?.alias && matchedEntry.alias !== spriteAlias) {
592
- spriteAlias = matchedEntry.alias;
593
- target = { ...target, box: spriteAlias };
594
- }
595
- const providerTarget = await resolveCommandComputeProvider({
596
- box: spriteAlias,
597
- boxes,
598
- homeDir: process.env.HOME ?? os.homedir(),
599
- });
600
- spriteAlias = providerTarget.alias;
601
- target = { ...target, box: spriteAlias };
602
- const computeProvider = providerTarget.computeProvider;
603
- assertCommandProviderCapability({
604
- provider: computeProvider,
605
- command: "connect",
606
- capability: "exec.sessions.open",
607
- });
608
- const supportsAttachExecSession = hasCommandProviderCapability({
609
- provider: computeProvider,
610
- command: "connect",
611
- capability: "exec.sessions.attach",
612
- });
613
- const supportsListExecSessions = hasCommandProviderCapability({
614
- provider: computeProvider,
615
- command: "connect",
616
- capability: "exec.sessions.list",
617
- });
618
- const supportsResizeControlMessages = computeProvider === "sprites" ||
619
- computeProvider === "modal" ||
620
- computeProvider === "e2b";
621
- let client;
622
- let networkTargetHost = null;
623
- if (computeProvider === "modal" || computeProvider === "e2b") {
624
- stage("Loading managed devbox access");
625
- client = await resolveRuntimeClient({
626
- provider: computeProvider,
627
- alias: spriteAlias,
628
- targetBox: target.box ?? spriteAlias,
629
- cwd: process.cwd(),
630
- failureContext: "connect",
631
- stage,
632
- });
633
- }
634
- else {
635
- stage("Loading devbox config");
636
- const config = await loadConfig(process.env.HOME ? { homeDir: process.env.HOME } : undefined);
637
- const store = await createSecretStore(config?.tokenStore, process.env.HOME ? { homeDir: process.env.HOME } : undefined);
638
- const relayBaseUrl = resolveRelayBaseUrl(config);
639
- const { token } = await ensureSpritesToken(store, stage);
640
- networkTargetHost = (() => {
641
- try {
642
- return new URL(relayBaseUrl).hostname || null;
643
- }
644
- catch {
645
- return null;
646
- }
647
- })();
648
- const spritesClient = createSpritesClient({
649
- apiBaseUrl: relayBaseUrl,
650
- token,
651
- });
652
- client = spritesClient;
653
- stage("Checking devbox exists");
654
- const sprite = await spritesClient.getSprite(spriteAlias);
655
- if (!sprite) {
656
- throw new Error(`No devbox found named "${target.box}". Run "dvb init" in a repo to create one, or "dvb list" to see existing devboxes.`);
657
- }
658
- }
659
- if (!sessionIdOverride &&
660
- sessionName &&
661
- supportsAttachExecSession &&
662
- supportsListExecSessions) {
663
- try {
664
- const available = await client.listExecSessions(spriteAlias);
665
- const resolved = resolveSessionSpecifierFromExplicitTarget({
666
- sessionName,
667
- availableSessions: available,
668
- });
669
- if (resolved.sessionIdOverride) {
670
- sessionIdOverride = resolved.sessionIdOverride;
671
- sessionName = undefined;
672
- explicitName = false;
673
- autoNameRequested = false;
674
- latency?.setContext({ box: spriteAlias });
675
- }
676
- }
677
- catch (error) {
678
- logger.warn("session_id_resolution_failed", { error: String(error) });
679
- }
680
- }
681
- stage("Syncing devbox");
682
- const notifyPortEvent = (event) => {
683
- if (event.type !== "port_opened") {
684
- pendingPortLogs.delete(event.port);
685
- return;
686
- }
687
- const token = nextPortLogToken;
688
- nextPortLogToken += 1;
689
- pendingPortLogs.set(event.port, token);
690
- const delays = [30, 60, 120, 200];
691
- void (async () => {
692
- for (const delay of delays) {
693
- await new Promise((resolve) => setTimeout(resolve, delay));
694
- if (pendingPortLogs.get(event.port) !== token) {
695
- return;
696
- }
697
- try {
698
- const response = await requestJson(socketInfo.socketPath, "GET", "/ports", DAEMON_TIMEOUT_MS.quick);
699
- if (response.status < 200 || response.status >= 300) {
700
- continue;
701
- }
702
- const forward = response.body.forwards.find((entry) => entry.box === spriteAlias && entry.remotePort === event.port);
703
- if (forward) {
704
- console.error(`Forwarded ${spriteAlias}:${event.port} -> 127.0.0.1:${forward.localPort}`);
705
- pendingPortLogs.delete(event.port);
706
- return;
707
- }
708
- }
709
- catch (error) {
710
- logger.warn("ports_snapshot_failed", { error: String(error) });
711
- }
712
- }
713
- if (pendingPortLogs.get(event.port) === token) {
714
- pendingPortLogs.delete(event.port);
715
- }
716
- })();
717
- };
718
- try {
719
- const response = await requestJson(socketInfo.socketPath, "POST", "/registry/usage", DAEMON_TIMEOUT_MS.registry, { alias: spriteAlias });
720
- if (response.status !== 200) {
721
- logger.warn("registry_usage_failed", {
722
- status: response.status,
723
- error: response.body?.error,
724
- });
725
- }
726
- }
727
- catch (error) {
728
- logger.warn("registry_usage_failed", { error: String(error) });
729
- }
730
- let setupStatus = null;
731
- try {
732
- const resolvedBoxes = boxes
733
- ? { status: 200, body: { boxes } }
734
- : await requestJson(socketInfo.socketPath, "GET", "/boxes", DAEMON_TIMEOUT_MS.registry);
735
- if (resolvedBoxes.status === 200) {
736
- const summary = resolvedBoxes.body.boxes.find((box) => box.alias === spriteAlias);
737
- setupStatus = summary?.setupStatus ?? null;
738
- }
739
- }
740
- catch (error) {
741
- logger.warn("registry_setup_status_failed", { error: String(error) });
742
- }
743
- if (setupStatus && setupStatus !== "complete") {
744
- pauseStatus();
745
- warnSetupStatus(setupStatus, spriteAlias);
746
- }
747
- stage("Preparing devbox");
748
- if (computeProvider !== "modal") {
749
- await client.exec(spriteAlias, [
750
- "/bin/bash",
751
- "-lc",
752
- "mkdir -p ~/.devbox",
753
- ]);
754
- }
755
- let projectWorkdir = null;
756
- try {
757
- projectWorkdir = await resolveProjectWorkdir(client, spriteAlias);
758
- }
759
- catch (error) {
760
- logger.warn("workdir_lookup_failed", {
761
- box: spriteAlias,
762
- error: String(error),
763
- });
764
- }
765
- const connectShell = computeProvider === "modal"
766
- ? "/bin/bash"
767
- : await resolveConnectShell(client, spriteAlias);
768
- const warnSessionMap = (event, fields) => logger.warn(event, fields);
769
- const initialSessionState = await initializeSessionMapState({
770
- client,
771
- alias: spriteAlias,
772
- sessionName,
773
- autoNameRequested,
774
- onWarn: warnSessionMap,
775
- });
776
- let sessions = initialSessionState.sessions;
777
- sessionName = initialSessionState.sessionName;
778
- autoNamed = initialSessionState.autoNamed;
779
- let requireFreshSessionOpen = initialSessionState.requireFreshSessionOpen;
780
- let sessionId = resolveInitialSessionId({
781
- supportsAttachExecSession,
782
- sessionIdOverride,
783
- sessionName,
784
- sessions,
785
- requireFreshSessionOpen,
786
- });
787
- let confirmedCreateExplicit = Boolean(sessionId && explicitName);
788
- if (latency) {
789
- if (sessionName) {
790
- latency.setContext({ box: spriteAlias, session: sessionName });
791
- }
792
- else {
793
- latency.setContext({ box: spriteAlias });
794
- }
795
- }
796
- const refreshSessionMapping = async () => {
797
- const refreshed = await refreshSessionMapState({
798
- client,
799
- alias: spriteAlias,
800
- computeProvider,
801
- supportsAttachExecSession,
802
- supportsListExecSessions,
803
- sessionName,
804
- sessionId,
805
- sessions,
806
- requireFreshSessionOpen,
807
- explicitName,
808
- onWarn: warnSessionMap,
809
- });
810
- sessions = refreshed.sessions;
811
- sessionId = refreshed.sessionId;
812
- if (refreshed.confirmedCreateExplicit) {
813
- confirmedCreateExplicit = true;
814
- }
815
- };
816
- const remoteHome = await resolveRemoteHome(client, spriteAlias);
817
- const finalizeAutoSession = async (id) => {
818
- const finalized = await finalizeAutoNamedSession({
819
- client,
820
- alias: spriteAlias,
821
- autoNamed,
822
- sessionName,
823
- sessionId: id,
824
- sessions,
825
- remoteHome,
826
- onWarn: warnSessionMap,
827
- });
828
- sessions = finalized.sessions;
829
- sessionName = finalized.sessionName;
830
- if (finalized.renamed && latency && sessionName) {
831
- latency.setContext({ box: spriteAlias, session: sessionName });
832
- }
833
- };
834
- const renameSessionMapping = async (fromName, toName, expectedId) => {
835
- const latest = await renameMappedSession({
836
- client,
837
- alias: spriteAlias,
838
- fromName,
839
- toName,
840
- expectedId,
841
- remoteHome,
842
- sessions,
843
- });
844
- sessions = latest;
845
- sessionName = toName;
846
- autoNamed = false;
847
- if (latency) {
848
- latency.setContext({ box: spriteAlias, session: sessionName });
849
- }
850
- };
851
- await refreshSessionMapping();
852
- if (explicitName && sessionName && !sessionId) {
853
- pauseStatus();
854
- const confirmed = await confirmNewSession(sessionName);
855
- if (!confirmed) {
856
- throw new Error(`Session "${sessionName}" not created.`);
857
- }
858
- confirmedCreateExplicit = true;
859
- }
860
- latency?.setContext({ tty: isTty });
861
- const openStdin = !parsed.command;
862
- const localStdin = !parsed.command && !isDetached;
863
- const terminalSessionId = process.env.DEVBOX_TERM_SESSION_ID?.trim() ||
864
- process.env.TERM_SESSION_ID?.trim() ||
865
- process.env.ITERM_SESSION_ID?.trim() ||
866
- `dvb-${randomUUID()}`;
867
- const logPath = shouldLog && sessionName
868
- ? buildSessionLogPath(sessionName, remoteHome)
869
- : null;
870
- const modalSessionLogPath = computeProvider === "modal" ? logPath : null;
871
- const sessionLogSink = logPath && computeProvider !== "modal"
872
- ? createRemoteSessionLogSink(client, spriteAlias, logPath)
873
- : null;
874
- const sessionEnv = resolveSessionEnv(terminalSessionId, sessionName);
875
- const ttyEnv = isTty ? resolveTtyEnv(terminalSessionId) : null;
876
- const shellEnv = ttyEnv ? { ...sessionEnv, ...ttyEnv } : sessionEnv;
877
- const envExports = Object.keys(shellEnv).length > 0 ? formatEnvExports(shellEnv) : "";
878
- const tracePathExport = 'export PATH="$HOME/.devbox/bin:$PATH"';
879
- const envPrefix = [tracePathExport, envExports].filter(Boolean).join("; ");
880
- const envCommandPrefix = envPrefix ? `${envPrefix}; ` : "";
881
- const modalTtyOpenOptions = computeProvider === "modal" && isTty
882
- ? {
883
- env: shellEnv,
884
- ...(projectWorkdir ? { cwd: projectWorkdir } : {}),
885
- }
886
- : null;
887
- const execCommand = (() => {
888
- if (parsed.command) {
889
- if (projectWorkdir) {
890
- return [
891
- connectShell,
892
- "-lc",
893
- `${envCommandPrefix}cd ${shellQuote(projectWorkdir)} && ${parsed.command}`,
894
- ];
895
- }
896
- return [connectShell, "-lc", `${envCommandPrefix}${parsed.command}`];
897
- }
898
- if (computeProvider === "modal") {
899
- return [];
900
- }
901
- if (projectWorkdir) {
902
- return [
903
- connectShell,
904
- "-c",
905
- `${envCommandPrefix}cd ${shellQuote(projectWorkdir)} && ${`exec ${shellQuote(connectShell)}`}`,
906
- ];
907
- }
908
- return [
909
- connectShell,
910
- "-c",
911
- `${envCommandPrefix}exec ${shellQuote(connectShell)}`,
912
- ];
913
- })();
914
- if (parsed.command) {
915
- stage("Running command");
916
- const result = await client.exec(spriteAlias, execCommand);
917
- if (result.stdout.length > 0) {
918
- process.stdout.write(result.stdout);
919
- }
920
- if (result.stderr.length > 0) {
921
- process.stderr.write(result.stderr);
922
- }
923
- process.exitCode = result.exitCode;
924
- return;
925
- }
926
- const resolveCurrentTtySize = () => (isTty ? resolveTtySize() : null);
927
- try {
928
- if (isDetached) {
929
- if (!sessionId) {
930
- latency?.noteConnectStart();
931
- const ws = client.openExecSession(spriteAlias, {
932
- cmd: execCommand,
933
- tty: isTty,
934
- stdin: openStdin,
935
- ...(() => {
936
- const ttySize = resolveCurrentTtySize();
937
- return ttySize ? { cols: ttySize.cols, rows: ttySize.rows } : {};
938
- })(),
939
- ...(modalSessionLogPath ? { logPath: modalSessionLogPath } : {}),
940
- ...(modalTtyOpenOptions ?? {}),
941
- });
942
- let mappingWrite = null;
943
- const streamResult = await streamExecSession(ws, {
944
- tty: isTty,
945
- stdin: false,
946
- supportsResizeControlMessages,
947
- resolveTtySize,
948
- openBrowser,
949
- isRawCtrlCChunk,
950
- ...(latency ? { latency } : {}),
951
- onSessionInfo: (id) => {
952
- if (supportsAttachExecSession) {
953
- requireFreshSessionOpen = false;
954
- sessionId = sessionId ?? id;
955
- }
956
- if (sessionName) {
957
- if (autoNamed) {
958
- mappingWrite = finalizeAutoSession(id);
959
- }
960
- else {
961
- sessions[sessionName] = id;
962
- mappingWrite = writeSpriteSessions(client, spriteAlias, sessions);
963
- }
964
- }
965
- ws.close();
966
- },
967
- });
968
- if (streamResult.kind === "disconnect" && !sessionId) {
969
- const detail = streamResult.errorMessage?.trim();
970
- throw new Error(detail
971
- ? `Failed to open exec session: ${detail}`
972
- : "Failed to open exec session.");
973
- }
974
- if (mappingWrite) {
975
- await mappingWrite;
976
- }
977
- if (!sessionId) {
978
- throw new Error("Failed to create detached session.");
979
- }
980
- }
981
- process.exitCode = 0;
982
- return;
983
- }
984
- const shouldReconnect = isTty && !parsed.command && !isDetached;
985
- let reconnectNoticeShown = false;
986
- let pendingInitialInput = initialInput;
987
- let retryDelayMs = 250;
988
- let printedSessionInfo = false;
989
- let sawOutput = false;
990
- let connectPhase = "connecting";
991
- let activeSocket = null;
992
- let localCancelRequested = false;
993
- let attemptedAttach = false;
994
- let sigintListenerInstalled = false;
995
- const printSessionInfo = (message) => {
996
- if (process.stderr.isTTY && process.stdout.isTTY) {
997
- process.stderr.write(`\u001b7\r\n${message}\r\n\u001b8`);
998
- return;
999
- }
1000
- console.error(message);
1001
- };
1002
- const reportSessionInfo = (id) => {
1003
- if (printedSessionInfo || !shouldReportSession || sawOutput)
1004
- return;
1005
- printedSessionInfo = true;
1006
- const label = sessionName ? `${target.box}/${sessionName}` : target.box;
1007
- const message = `Session connected: ${label} (${id})`;
1008
- if (statusEnabled) {
1009
- status.stop();
1010
- }
1011
- printSessionInfo(message);
1012
- };
1013
- const noteOutput = () => {
1014
- if (sawOutput)
1015
- return;
1016
- sawOutput = true;
1017
- if (statusEnabled) {
1018
- allowStatus = false;
1019
- status.stop();
1020
- }
1021
- };
1022
- const onSigint = () => {
1023
- logger.info("connect_sigint", {
1024
- connectPhase,
1025
- hasActiveSocket: Boolean(activeSocket),
1026
- localCancelRequested,
1027
- });
1028
- localCancelRequested = true;
1029
- if (!activeSocket)
1030
- return;
1031
- try {
1032
- activeSocket.terminate?.();
1033
- }
1034
- catch {
1035
- logger.warn("connect_sigint_terminate_failed", {
1036
- connectPhase,
1037
- });
1038
- // ignore terminate failures
1039
- }
1040
- try {
1041
- activeSocket.close();
1042
- }
1043
- catch {
1044
- logger.warn("connect_sigint_close_failed", {
1045
- connectPhase,
1046
- });
1047
- // ignore close failures
1048
- }
1049
- };
1050
- const setConnectPhase = (phase) => {
1051
- if (connectPhase !== phase) {
1052
- logger.debug("connect_phase_change", {
1053
- from: connectPhase,
1054
- to: phase,
1055
- });
1056
- }
1057
- connectPhase = phase;
1058
- const shouldInstallListener = shouldReconnect && shouldCancelConnectOnSigint(connectPhase);
1059
- if (shouldInstallListener && !sigintListenerInstalled) {
1060
- process.on("SIGINT", onSigint);
1061
- sigintListenerInstalled = true;
1062
- return;
1063
- }
1064
- if (!shouldInstallListener && sigintListenerInstalled) {
1065
- process.removeListener("SIGINT", onSigint);
1066
- sigintListenerInstalled = false;
1067
- }
1068
- };
1069
- setConnectPhase("connecting");
1070
- try {
1071
- while (true) {
1072
- if (localCancelRequested) {
1073
- process.exitCode = 130;
1074
- break;
1075
- }
1076
- setConnectPhase(attemptedAttach ? "reconnecting" : "connecting");
1077
- attemptedAttach = true;
1078
- try {
1079
- await refreshSessionMapping();
1080
- }
1081
- catch (error) {
1082
- logger.warn("session_refresh_failed", { error: String(error) });
1083
- }
1084
- if (explicitName &&
1085
- sessionName &&
1086
- !sessionId &&
1087
- !confirmedCreateExplicit) {
1088
- pauseStatus();
1089
- const confirmed = await confirmNewSession(sessionName);
1090
- if (!confirmed) {
1091
- throw new Error(`Session "${sessionName}" not created.`);
1092
- }
1093
- confirmedCreateExplicit = true;
1094
- }
1095
- let createdNew = false;
1096
- let mappingWrite = null;
1097
- latency?.noteConnectStart();
1098
- const canAttach = shouldAttachToExistingSession({
1099
- supportsAttachExecSession,
1100
- sessionId,
1101
- requireFreshSessionOpen,
1102
- });
1103
- const attachSessionId = canAttach ? sessionId : undefined;
1104
- const modalAttachViaOpen = canAttach &&
1105
- computeProvider === "modal" &&
1106
- typeof attachSessionId === "string" &&
1107
- attachSessionId.length > 0;
1108
- stage(canAttach ? "Attaching to session" : "Opening session");
1109
- let ws;
1110
- if (modalAttachViaOpen) {
1111
- const ttySize = resolveCurrentTtySize();
1112
- ws = client.openExecSession(spriteAlias, {
1113
- cmd: execCommand,
1114
- tty: isTty,
1115
- stdin: openStdin,
1116
- sessionId: attachSessionId,
1117
- ...(ttySize ? { cols: ttySize.cols, rows: ttySize.rows } : {}),
1118
- ...(modalSessionLogPath ? { logPath: modalSessionLogPath } : {}),
1119
- ...(modalTtyOpenOptions ?? {}),
1120
- });
1121
- }
1122
- else if (canAttach) {
1123
- if (!attachSessionId) {
1124
- throw new Error("Missing session id for attach.");
1125
- }
1126
- ws = client.attachExecSession(spriteAlias, attachSessionId);
1127
- }
1128
- else {
1129
- createdNew = true;
1130
- const ttySize = resolveCurrentTtySize();
1131
- ws = client.openExecSession(spriteAlias, {
1132
- cmd: execCommand,
1133
- tty: isTty,
1134
- stdin: openStdin,
1135
- ...(ttySize ? { cols: ttySize.cols, rows: ttySize.rows } : {}),
1136
- ...(modalSessionLogPath ? { logPath: modalSessionLogPath } : {}),
1137
- ...(modalTtyOpenOptions ?? {}),
1138
- });
1139
- }
1140
- activeSocket = ws;
1141
- const shouldSendInitialInput = createdNew && Boolean(pendingInitialInput);
1142
- const initialInputToSend = shouldSendInitialInput
1143
- ? pendingInitialInput
1144
- : undefined;
1145
- let result;
1146
- try {
1147
- result = await streamExecSession(ws, {
1148
- tty: isTty,
1149
- stdin: localStdin,
1150
- supportsResizeControlMessages,
1151
- resolveTtySize,
1152
- openBrowser,
1153
- isRawCtrlCChunk,
1154
- ...(latency ? { latency } : {}),
1155
- openTimeoutMs: CONNECT_OPEN_TIMEOUT_MS,
1156
- onOutput: noteOutput,
1157
- onOutputChunk: (chunk) => {
1158
- sessionLogSink?.write(chunk);
1159
- },
1160
- onInputChunk: (chunk) => {
1161
- sessionLogSink?.write(chunk);
1162
- },
1163
- onOpen: () => {
1164
- setConnectPhase("attached");
1165
- if (shouldSendInitialInput) {
1166
- pendingInitialInput = undefined;
1167
- }
1168
- if (sessionId) {
1169
- reportSessionInfo(sessionId);
1170
- }
1171
- },
1172
- ...(initialInputToSend
1173
- ? { initialInput: initialInputToSend }
1174
- : {}),
1175
- onSessionInfo: (id) => {
1176
- const replacedSessionViaModalFallback = modalAttachViaOpen && attachSessionId !== id;
1177
- if (supportsAttachExecSession) {
1178
- if (createdNew || replacedSessionViaModalFallback) {
1179
- requireFreshSessionOpen = false;
1180
- }
1181
- sessionId = id;
1182
- }
1183
- if (sessionName &&
1184
- (createdNew || replacedSessionViaModalFallback)) {
1185
- if (autoNamed) {
1186
- mappingWrite = finalizeAutoSession(id);
1187
- if (mappingWrite) {
1188
- mappingWrite
1189
- .then(() => {
1190
- reportSessionInfo(id);
1191
- })
1192
- .catch((error) => {
1193
- logger.warn("session_auto_rename_failed", {
1194
- error: String(error),
1195
- });
1196
- reportSessionInfo(id);
1197
- });
1198
- }
1199
- else {
1200
- reportSessionInfo(id);
1201
- }
1202
- }
1203
- else {
1204
- sessions[sessionName] = id;
1205
- mappingWrite = writeSpriteSessions(client, spriteAlias, sessions);
1206
- reportSessionInfo(id);
1207
- }
1208
- }
1209
- else {
1210
- reportSessionInfo(id);
1211
- }
1212
- if (isDetached) {
1213
- ws.close();
1214
- }
1215
- },
1216
- onPortEvent: notifyPortEvent,
1217
- ...(shouldReconnect
1218
- ? {
1219
- onRawCtrlC: () => {
1220
- if (!shouldCancelConnectOnSigint(connectPhase)) {
1221
- return false;
1222
- }
1223
- onSigint();
1224
- return true;
1225
- },
1226
- onDisconnectNotice: () => {
1227
- setConnectPhase("reconnecting");
1228
- resetTerminalInputModes();
1229
- if (!reconnectNoticeShown) {
1230
- console.error("Connection lost. Reconnecting... (Ctrl+C to cancel)");
1231
- reconnectNoticeShown = true;
1232
- }
1233
- },
1234
- }
1235
- : {}),
1236
- });
1237
- }
1238
- finally {
1239
- activeSocket = null;
1240
- }
1241
- if (mappingWrite) {
1242
- try {
1243
- await mappingWrite;
1244
- }
1245
- catch (error) {
1246
- logger.warn("session_write_failed", { error: String(error) });
1247
- }
1248
- }
1249
- if (localCancelRequested) {
1250
- process.exitCode = 130;
1251
- break;
1252
- }
1253
- if (result.kind === "exit") {
1254
- process.exitCode = result.code;
1255
- break;
1256
- }
1257
- if (result.kind === "detach") {
1258
- if (autoNamed && sessionName && sessionId) {
1259
- const nextName = await promptRenameSession(sessionName);
1260
- if (nextName && nextName !== sessionName) {
1261
- try {
1262
- await renameSessionMapping(sessionName, nextName, sessionId);
1263
- }
1264
- catch (error) {
1265
- console.error(`Failed to rename session: ${error instanceof Error ? error.message : String(error)}`);
1266
- }
1267
- }
1268
- }
1269
- process.exitCode = 0;
1270
- break;
1271
- }
1272
- if (isDetached) {
1273
- process.exitCode = 0;
1274
- break;
1275
- }
1276
- if (isAttachReplacedCloseCode(result.closeCode)) {
1277
- resetTerminalInputModes();
1278
- console.error("Session attached from another client. Closing this window.");
1279
- process.exitCode = 0;
1280
- break;
1281
- }
1282
- if (!shouldReconnect) {
1283
- if (result.errorMessage) {
1284
- throw new Error(`Connection lost: ${result.errorMessage}`);
1285
- }
1286
- throw new Error("Connection lost.");
1287
- }
1288
- setConnectPhase("reconnecting");
1289
- resetTerminalInputModes();
1290
- if (!reconnectNoticeShown) {
1291
- console.error("Connection lost. Reconnecting... (Ctrl+C to cancel)");
1292
- reconnectNoticeShown = true;
1293
- }
1294
- if (sessionId && supportsAttachExecSession) {
1295
- if (computeProvider !== "modal" &&
1296
- result.opened === false &&
1297
- supportsListExecSessions) {
1298
- try {
1299
- const available = await client.listExecSessions(spriteAlias);
1300
- const match = available.find((session) => session.id === sessionId);
1301
- if (!match || match.tty === false) {
1302
- if (sessionName) {
1303
- delete sessions[sessionName];
1304
- await writeSpriteSessions(client, spriteAlias, sessions);
1305
- }
1306
- sessionId = undefined;
1307
- }
1308
- }
1309
- catch (error) {
1310
- logger.warn("session_lookup_failed", { error: String(error) });
1311
- }
1312
- }
1313
- }
1314
- const networkWait = await waitForNetworkOnline({
1315
- targetHost: networkTargetHost,
1316
- onStatus: stage,
1317
- onNotice: (message) => console.error(message),
1318
- });
1319
- if (networkWait === "aborted" || localCancelRequested) {
1320
- process.exitCode = 130;
1321
- break;
1322
- }
1323
- if (networkWait === "waited") {
1324
- retryDelayMs = 250;
1325
- }
1326
- await new Promise((resolve) => setTimeout(resolve, retryDelayMs));
1327
- retryDelayMs = Math.min(5000, Math.round(retryDelayMs * 1.6));
1328
- }
1329
- }
1330
- finally {
1331
- if (sigintListenerInstalled) {
1332
- process.removeListener("SIGINT", onSigint);
1333
- }
1334
- }
1335
- }
1336
- finally {
1337
- const exitCode = typeof process.exitCode === "number" ? process.exitCode : undefined;
1338
- latency?.flush(exitCode);
1339
- if (sessionLogSink) {
1340
- await sessionLogSink.close().catch((error) => {
1341
- logger.warn("session_log_close_failed", {
1342
- box: spriteAlias,
1343
- logPath,
1344
- error: String(error),
1345
- });
1346
- });
1347
- }
1348
- }
1349
- try {
1350
- await recordCompletionSessionsFromMap(spriteAlias, sessions);
1351
- }
1352
- catch (error) {
1353
- logger.warn("completion_cache_update_failed", { error: String(error) });
1354
- }
1355
- }
1356
- catch (error) {
1357
- status.fail("Connect failed");
1358
- throw error;
1359
- }
1360
- finally {
1361
- if (isTty) {
1362
- resetTerminalInputModes();
1363
- }
1364
- status.stop();
1365
- }
1366
- };
1367
- //# sourceMappingURL=connect.js.map