@agentuity/cli 1.0.23 → 1.0.25

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 (309) hide show
  1. package/dist/cache/index.d.ts +1 -0
  2. package/dist/cache/index.d.ts.map +1 -1
  3. package/dist/cache/index.js +1 -0
  4. package/dist/cache/index.js.map +1 -1
  5. package/dist/cache/user-cache.d.ts +20 -0
  6. package/dist/cache/user-cache.d.ts.map +1 -0
  7. package/dist/cache/user-cache.js +79 -0
  8. package/dist/cache/user-cache.js.map +1 -0
  9. package/dist/cmd/auth/logout.d.ts.map +1 -1
  10. package/dist/cmd/auth/logout.js +3 -1
  11. package/dist/cmd/auth/logout.js.map +1 -1
  12. package/dist/cmd/build/entry-generator.d.ts +4 -0
  13. package/dist/cmd/build/entry-generator.d.ts.map +1 -1
  14. package/dist/cmd/build/entry-generator.js +18 -3
  15. package/dist/cmd/build/entry-generator.js.map +1 -1
  16. package/dist/cmd/build/vite/bun-dev-server.d.ts +1 -0
  17. package/dist/cmd/build/vite/bun-dev-server.d.ts.map +1 -1
  18. package/dist/cmd/build/vite/bun-dev-server.js +11 -9
  19. package/dist/cmd/build/vite/bun-dev-server.js.map +1 -1
  20. package/dist/cmd/cloud/db/index.d.ts.map +1 -1
  21. package/dist/cmd/cloud/db/index.js +2 -0
  22. package/dist/cmd/cloud/db/index.js.map +1 -1
  23. package/dist/cmd/cloud/db/stats.d.ts +3 -0
  24. package/dist/cmd/cloud/db/stats.d.ts.map +1 -0
  25. package/dist/cmd/cloud/db/stats.js +66 -0
  26. package/dist/cmd/cloud/db/stats.js.map +1 -0
  27. package/dist/cmd/cloud/email/create.d.ts.map +1 -1
  28. package/dist/cmd/cloud/email/create.js +15 -10
  29. package/dist/cmd/cloud/email/create.js.map +1 -1
  30. package/dist/cmd/cloud/email/delete.js +1 -1
  31. package/dist/cmd/cloud/email/delete.js.map +1 -1
  32. package/dist/cmd/cloud/email/destination/delete.d.ts.map +1 -1
  33. package/dist/cmd/cloud/email/destination/delete.js +6 -2
  34. package/dist/cmd/cloud/email/destination/delete.js.map +1 -1
  35. package/dist/cmd/cloud/email/destination/list.js +1 -1
  36. package/dist/cmd/cloud/email/destination/list.js.map +1 -1
  37. package/dist/cmd/cloud/email/destination/url.d.ts.map +1 -1
  38. package/dist/cmd/cloud/email/destination/url.js +5 -4
  39. package/dist/cmd/cloud/email/destination/url.js.map +1 -1
  40. package/dist/cmd/cloud/email/get.d.ts.map +1 -1
  41. package/dist/cmd/cloud/email/get.js +2 -4
  42. package/dist/cmd/cloud/email/get.js.map +1 -1
  43. package/dist/cmd/cloud/email/inbound/get.d.ts.map +1 -1
  44. package/dist/cmd/cloud/email/inbound/get.js +2 -3
  45. package/dist/cmd/cloud/email/inbound/get.js.map +1 -1
  46. package/dist/cmd/cloud/email/inbound/list.d.ts.map +1 -1
  47. package/dist/cmd/cloud/email/inbound/list.js +1 -3
  48. package/dist/cmd/cloud/email/inbound/list.js.map +1 -1
  49. package/dist/cmd/cloud/email/inbound/schemas.d.ts +3 -1
  50. package/dist/cmd/cloud/email/inbound/schemas.d.ts.map +1 -1
  51. package/dist/cmd/cloud/email/inbound/schemas.js +3 -1
  52. package/dist/cmd/cloud/email/inbound/schemas.js.map +1 -1
  53. package/dist/cmd/cloud/email/index.d.ts.map +1 -1
  54. package/dist/cmd/cloud/email/index.js +2 -0
  55. package/dist/cmd/cloud/email/index.js.map +1 -1
  56. package/dist/cmd/cloud/email/list.d.ts.map +1 -1
  57. package/dist/cmd/cloud/email/list.js +9 -2
  58. package/dist/cmd/cloud/email/list.js.map +1 -1
  59. package/dist/cmd/cloud/email/outbound/get.js +4 -4
  60. package/dist/cmd/cloud/email/outbound/get.js.map +1 -1
  61. package/dist/cmd/cloud/email/outbound/list.js +3 -3
  62. package/dist/cmd/cloud/email/outbound/list.js.map +1 -1
  63. package/dist/cmd/cloud/email/outbound/schemas.d.ts +2 -2
  64. package/dist/cmd/cloud/email/outbound/schemas.js +2 -2
  65. package/dist/cmd/cloud/email/outbound/schemas.js.map +1 -1
  66. package/dist/cmd/cloud/email/send.d.ts.map +1 -1
  67. package/dist/cmd/cloud/email/send.js +9 -15
  68. package/dist/cmd/cloud/email/send.js.map +1 -1
  69. package/dist/cmd/cloud/email/stats.d.ts +3 -0
  70. package/dist/cmd/cloud/email/stats.d.ts.map +1 -0
  71. package/dist/cmd/cloud/email/stats.js +65 -0
  72. package/dist/cmd/cloud/email/stats.js.map +1 -0
  73. package/dist/cmd/cloud/email/util.d.ts +4 -7
  74. package/dist/cmd/cloud/email/util.d.ts.map +1 -1
  75. package/dist/cmd/cloud/email/util.js +8 -24
  76. package/dist/cmd/cloud/email/util.js.map +1 -1
  77. package/dist/cmd/cloud/index.d.ts.map +1 -1
  78. package/dist/cmd/cloud/index.js +2 -0
  79. package/dist/cmd/cloud/index.js.map +1 -1
  80. package/dist/cmd/cloud/queue/get.js +4 -4
  81. package/dist/cmd/cloud/queue/get.js.map +1 -1
  82. package/dist/cmd/cloud/queue/receive.d.ts.map +1 -1
  83. package/dist/cmd/cloud/queue/receive.js +11 -7
  84. package/dist/cmd/cloud/queue/receive.js.map +1 -1
  85. package/dist/cmd/cloud/queue/stats.js +3 -3
  86. package/dist/cmd/cloud/queue/stats.js.map +1 -1
  87. package/dist/cmd/cloud/sandbox/checkpoint/create.d.ts +3 -0
  88. package/dist/cmd/cloud/sandbox/checkpoint/create.d.ts.map +1 -0
  89. package/dist/cmd/cloud/sandbox/checkpoint/create.js +71 -0
  90. package/dist/cmd/cloud/sandbox/checkpoint/create.js.map +1 -0
  91. package/dist/cmd/cloud/sandbox/checkpoint/delete.d.ts +3 -0
  92. package/dist/cmd/cloud/sandbox/checkpoint/delete.d.ts.map +1 -0
  93. package/dist/cmd/cloud/sandbox/checkpoint/delete.js +78 -0
  94. package/dist/cmd/cloud/sandbox/checkpoint/delete.js.map +1 -0
  95. package/dist/cmd/cloud/sandbox/checkpoint/index.d.ts +2 -0
  96. package/dist/cmd/cloud/sandbox/checkpoint/index.d.ts.map +1 -0
  97. package/dist/cmd/cloud/sandbox/checkpoint/index.js +33 -0
  98. package/dist/cmd/cloud/sandbox/checkpoint/index.js.map +1 -0
  99. package/dist/cmd/cloud/sandbox/checkpoint/list.d.ts +3 -0
  100. package/dist/cmd/cloud/sandbox/checkpoint/list.d.ts.map +1 -0
  101. package/dist/cmd/cloud/sandbox/checkpoint/list.js +72 -0
  102. package/dist/cmd/cloud/sandbox/checkpoint/list.js.map +1 -0
  103. package/dist/cmd/cloud/sandbox/checkpoint/restore.d.ts +3 -0
  104. package/dist/cmd/cloud/sandbox/checkpoint/restore.d.ts.map +1 -0
  105. package/dist/cmd/cloud/sandbox/checkpoint/restore.js +61 -0
  106. package/dist/cmd/cloud/sandbox/checkpoint/restore.js.map +1 -0
  107. package/dist/cmd/cloud/sandbox/get.d.ts.map +1 -1
  108. package/dist/cmd/cloud/sandbox/get.js +5 -3
  109. package/dist/cmd/cloud/sandbox/get.js.map +1 -1
  110. package/dist/cmd/cloud/sandbox/index.d.ts.map +1 -1
  111. package/dist/cmd/cloud/sandbox/index.js +4 -0
  112. package/dist/cmd/cloud/sandbox/index.js.map +1 -1
  113. package/dist/cmd/cloud/sandbox/snapshot/build.d.ts.map +1 -1
  114. package/dist/cmd/cloud/sandbox/snapshot/build.js +13 -10
  115. package/dist/cmd/cloud/sandbox/snapshot/build.js.map +1 -1
  116. package/dist/cmd/cloud/sandbox/snapshot/get.js +3 -3
  117. package/dist/cmd/cloud/sandbox/snapshot/get.js.map +1 -1
  118. package/dist/cmd/cloud/sandbox/stats.d.ts +3 -0
  119. package/dist/cmd/cloud/sandbox/stats.d.ts.map +1 -0
  120. package/dist/cmd/cloud/sandbox/stats.js +72 -0
  121. package/dist/cmd/cloud/sandbox/stats.js.map +1 -0
  122. package/dist/cmd/cloud/schedule/create.d.ts.map +1 -1
  123. package/dist/cmd/cloud/schedule/create.js +3 -4
  124. package/dist/cmd/cloud/schedule/create.js.map +1 -1
  125. package/dist/cmd/cloud/schedule/delete.d.ts.map +1 -1
  126. package/dist/cmd/cloud/schedule/delete.js +6 -4
  127. package/dist/cmd/cloud/schedule/delete.js.map +1 -1
  128. package/dist/cmd/cloud/schedule/delivery/get.d.ts.map +1 -1
  129. package/dist/cmd/cloud/schedule/delivery/get.js +3 -4
  130. package/dist/cmd/cloud/schedule/delivery/get.js.map +1 -1
  131. package/dist/cmd/cloud/schedule/delivery/list.d.ts.map +1 -1
  132. package/dist/cmd/cloud/schedule/delivery/list.js +2 -3
  133. package/dist/cmd/cloud/schedule/delivery/list.js.map +1 -1
  134. package/dist/cmd/cloud/schedule/destination/create.d.ts.map +1 -1
  135. package/dist/cmd/cloud/schedule/destination/create.js +10 -5
  136. package/dist/cmd/cloud/schedule/destination/create.js.map +1 -1
  137. package/dist/cmd/cloud/schedule/destination/delete.d.ts.map +1 -1
  138. package/dist/cmd/cloud/schedule/destination/delete.js +2 -3
  139. package/dist/cmd/cloud/schedule/destination/delete.js.map +1 -1
  140. package/dist/cmd/cloud/schedule/destination/get.js +15 -13
  141. package/dist/cmd/cloud/schedule/destination/get.js.map +1 -1
  142. package/dist/cmd/cloud/schedule/destination/index.d.ts.map +1 -1
  143. package/dist/cmd/cloud/schedule/destination/index.js.map +1 -1
  144. package/dist/cmd/cloud/schedule/destination/list.d.ts.map +1 -1
  145. package/dist/cmd/cloud/schedule/destination/list.js +13 -9
  146. package/dist/cmd/cloud/schedule/destination/list.js.map +1 -1
  147. package/dist/cmd/cloud/schedule/get.d.ts.map +1 -1
  148. package/dist/cmd/cloud/schedule/get.js +19 -12
  149. package/dist/cmd/cloud/schedule/get.js.map +1 -1
  150. package/dist/cmd/cloud/schedule/index.d.ts.map +1 -1
  151. package/dist/cmd/cloud/schedule/index.js +6 -1
  152. package/dist/cmd/cloud/schedule/index.js.map +1 -1
  153. package/dist/cmd/cloud/schedule/list.d.ts.map +1 -1
  154. package/dist/cmd/cloud/schedule/list.js +2 -3
  155. package/dist/cmd/cloud/schedule/list.js.map +1 -1
  156. package/dist/cmd/cloud/schedule/stats.d.ts +3 -0
  157. package/dist/cmd/cloud/schedule/stats.d.ts.map +1 -0
  158. package/dist/cmd/cloud/schedule/stats.js +64 -0
  159. package/dist/cmd/cloud/schedule/stats.js.map +1 -0
  160. package/dist/cmd/cloud/schedule/update.js +5 -5
  161. package/dist/cmd/cloud/schedule/update.js.map +1 -1
  162. package/dist/cmd/cloud/schedule/util.d.ts +4 -5
  163. package/dist/cmd/cloud/schedule/util.d.ts.map +1 -1
  164. package/dist/cmd/cloud/schedule/util.js +6 -7
  165. package/dist/cmd/cloud/schedule/util.js.map +1 -1
  166. package/dist/cmd/cloud/services/index.d.ts +3 -0
  167. package/dist/cmd/cloud/services/index.d.ts.map +1 -0
  168. package/dist/cmd/cloud/services/index.js +10 -0
  169. package/dist/cmd/cloud/services/index.js.map +1 -0
  170. package/dist/cmd/cloud/services/stats.d.ts +3 -0
  171. package/dist/cmd/cloud/services/stats.d.ts.map +1 -0
  172. package/dist/cmd/cloud/services/stats.js +153 -0
  173. package/dist/cmd/cloud/services/stats.js.map +1 -0
  174. package/dist/cmd/cloud/stream/index.d.ts.map +1 -1
  175. package/dist/cmd/cloud/stream/index.js +8 -1
  176. package/dist/cmd/cloud/stream/index.js.map +1 -1
  177. package/dist/cmd/cloud/stream/stats.d.ts +3 -0
  178. package/dist/cmd/cloud/stream/stats.d.ts.map +1 -0
  179. package/dist/cmd/cloud/stream/stats.js +64 -0
  180. package/dist/cmd/cloud/stream/stats.js.map +1 -0
  181. package/dist/cmd/cloud/task/attachment.d.ts +2 -0
  182. package/dist/cmd/cloud/task/attachment.d.ts.map +1 -0
  183. package/dist/cmd/cloud/task/attachment.js +393 -0
  184. package/dist/cmd/cloud/task/attachment.js.map +1 -0
  185. package/dist/cmd/cloud/task/create.d.ts.map +1 -1
  186. package/dist/cmd/cloud/task/create.js +125 -5
  187. package/dist/cmd/cloud/task/create.js.map +1 -1
  188. package/dist/cmd/cloud/task/get.d.ts.map +1 -1
  189. package/dist/cmd/cloud/task/get.js +33 -14
  190. package/dist/cmd/cloud/task/get.js.map +1 -1
  191. package/dist/cmd/cloud/task/index.d.ts.map +1 -1
  192. package/dist/cmd/cloud/task/index.js +14 -1
  193. package/dist/cmd/cloud/task/index.js.map +1 -1
  194. package/dist/cmd/cloud/task/list.d.ts.map +1 -1
  195. package/dist/cmd/cloud/task/list.js +32 -17
  196. package/dist/cmd/cloud/task/list.js.map +1 -1
  197. package/dist/cmd/cloud/task/stats.d.ts +3 -0
  198. package/dist/cmd/cloud/task/stats.d.ts.map +1 -0
  199. package/dist/cmd/cloud/task/stats.js +68 -0
  200. package/dist/cmd/cloud/task/stats.js.map +1 -0
  201. package/dist/cmd/cloud/task/update.d.ts.map +1 -1
  202. package/dist/cmd/cloud/task/update.js +0 -1
  203. package/dist/cmd/cloud/task/update.js.map +1 -1
  204. package/dist/cmd/cloud/task/util.d.ts +4 -7
  205. package/dist/cmd/cloud/task/util.d.ts.map +1 -1
  206. package/dist/cmd/cloud/task/util.js +6 -12
  207. package/dist/cmd/cloud/task/util.js.map +1 -1
  208. package/dist/cmd/cloud/vector/get.d.ts.map +1 -1
  209. package/dist/cmd/cloud/vector/get.js +17 -12
  210. package/dist/cmd/cloud/vector/get.js.map +1 -1
  211. package/dist/cmd/cloud/vector/stats.d.ts.map +1 -1
  212. package/dist/cmd/cloud/vector/stats.js +10 -7
  213. package/dist/cmd/cloud/vector/stats.js.map +1 -1
  214. package/dist/cmd/cloud/webhook/create.d.ts.map +1 -1
  215. package/dist/cmd/cloud/webhook/create.js +6 -1
  216. package/dist/cmd/cloud/webhook/create.js.map +1 -1
  217. package/dist/cmd/cloud/webhook/deliveries.d.ts.map +1 -1
  218. package/dist/cmd/cloud/webhook/deliveries.js +12 -3
  219. package/dist/cmd/cloud/webhook/deliveries.js.map +1 -1
  220. package/dist/cmd/cloud/webhook/destinations.d.ts.map +1 -1
  221. package/dist/cmd/cloud/webhook/destinations.js +19 -9
  222. package/dist/cmd/cloud/webhook/destinations.js.map +1 -1
  223. package/dist/cmd/cloud/webhook/get.js +2 -2
  224. package/dist/cmd/cloud/webhook/get.js.map +1 -1
  225. package/dist/cmd/cloud/webhook/receipts.d.ts.map +1 -1
  226. package/dist/cmd/cloud/webhook/receipts.js +19 -3
  227. package/dist/cmd/cloud/webhook/receipts.js.map +1 -1
  228. package/dist/cmd/dev/index.d.ts.map +1 -1
  229. package/dist/cmd/dev/index.js +80 -34
  230. package/dist/cmd/dev/index.js.map +1 -1
  231. package/dist/tui.d.ts +4 -0
  232. package/dist/tui.d.ts.map +1 -1
  233. package/dist/tui.js +8 -0
  234. package/dist/tui.js.map +1 -1
  235. package/package.json +6 -6
  236. package/src/cache/index.ts +2 -0
  237. package/src/cache/user-cache.ts +93 -0
  238. package/src/cmd/auth/logout.ts +3 -1
  239. package/src/cmd/build/entry-generator.ts +34 -4
  240. package/src/cmd/build/vite/bun-dev-server.ts +21 -9
  241. package/src/cmd/cloud/db/index.ts +2 -0
  242. package/src/cmd/cloud/db/stats.ts +72 -0
  243. package/src/cmd/cloud/email/create.ts +17 -10
  244. package/src/cmd/cloud/email/delete.ts +1 -1
  245. package/src/cmd/cloud/email/destination/delete.ts +6 -2
  246. package/src/cmd/cloud/email/destination/list.ts +1 -1
  247. package/src/cmd/cloud/email/destination/url.ts +5 -4
  248. package/src/cmd/cloud/email/get.ts +2 -4
  249. package/src/cmd/cloud/email/inbound/get.ts +2 -3
  250. package/src/cmd/cloud/email/inbound/list.ts +1 -3
  251. package/src/cmd/cloud/email/inbound/schemas.ts +3 -1
  252. package/src/cmd/cloud/email/index.ts +2 -0
  253. package/src/cmd/cloud/email/list.ts +9 -2
  254. package/src/cmd/cloud/email/outbound/get.ts +4 -4
  255. package/src/cmd/cloud/email/outbound/list.ts +3 -3
  256. package/src/cmd/cloud/email/outbound/schemas.ts +2 -2
  257. package/src/cmd/cloud/email/send.ts +9 -15
  258. package/src/cmd/cloud/email/stats.ts +73 -0
  259. package/src/cmd/cloud/email/util.ts +11 -31
  260. package/src/cmd/cloud/index.ts +2 -0
  261. package/src/cmd/cloud/queue/get.ts +4 -4
  262. package/src/cmd/cloud/queue/receive.ts +15 -7
  263. package/src/cmd/cloud/queue/stats.ts +3 -3
  264. package/src/cmd/cloud/sandbox/checkpoint/create.ts +85 -0
  265. package/src/cmd/cloud/sandbox/checkpoint/delete.ts +93 -0
  266. package/src/cmd/cloud/sandbox/checkpoint/index.ts +33 -0
  267. package/src/cmd/cloud/sandbox/checkpoint/list.ts +83 -0
  268. package/src/cmd/cloud/sandbox/checkpoint/restore.ts +72 -0
  269. package/src/cmd/cloud/sandbox/get.ts +6 -3
  270. package/src/cmd/cloud/sandbox/index.ts +4 -0
  271. package/src/cmd/cloud/sandbox/snapshot/build.ts +34 -15
  272. package/src/cmd/cloud/sandbox/snapshot/get.ts +3 -3
  273. package/src/cmd/cloud/sandbox/stats.ts +82 -0
  274. package/src/cmd/cloud/schedule/create.ts +3 -4
  275. package/src/cmd/cloud/schedule/delete.ts +6 -4
  276. package/src/cmd/cloud/schedule/delivery/get.ts +3 -4
  277. package/src/cmd/cloud/schedule/delivery/list.ts +17 -16
  278. package/src/cmd/cloud/schedule/destination/create.ts +19 -7
  279. package/src/cmd/cloud/schedule/destination/delete.ts +2 -3
  280. package/src/cmd/cloud/schedule/destination/get.ts +17 -17
  281. package/src/cmd/cloud/schedule/destination/index.ts +3 -1
  282. package/src/cmd/cloud/schedule/destination/list.ts +22 -15
  283. package/src/cmd/cloud/schedule/get.ts +30 -20
  284. package/src/cmd/cloud/schedule/index.ts +6 -1
  285. package/src/cmd/cloud/schedule/list.ts +20 -19
  286. package/src/cmd/cloud/schedule/stats.ts +72 -0
  287. package/src/cmd/cloud/schedule/update.ts +5 -5
  288. package/src/cmd/cloud/schedule/util.ts +14 -20
  289. package/src/cmd/cloud/services/index.ts +11 -0
  290. package/src/cmd/cloud/services/stats.ts +199 -0
  291. package/src/cmd/cloud/stream/index.ts +8 -1
  292. package/src/cmd/cloud/stream/stats.ts +70 -0
  293. package/src/cmd/cloud/task/attachment.ts +432 -0
  294. package/src/cmd/cloud/task/create.ts +130 -5
  295. package/src/cmd/cloud/task/get.ts +35 -16
  296. package/src/cmd/cloud/task/index.ts +14 -1
  297. package/src/cmd/cloud/task/list.ts +32 -17
  298. package/src/cmd/cloud/task/stats.ts +74 -0
  299. package/src/cmd/cloud/task/update.ts +0 -1
  300. package/src/cmd/cloud/task/util.ts +14 -28
  301. package/src/cmd/cloud/vector/get.ts +16 -11
  302. package/src/cmd/cloud/vector/stats.ts +10 -8
  303. package/src/cmd/cloud/webhook/create.ts +6 -1
  304. package/src/cmd/cloud/webhook/deliveries.ts +15 -3
  305. package/src/cmd/cloud/webhook/destinations.ts +21 -9
  306. package/src/cmd/cloud/webhook/get.ts +2 -2
  307. package/src/cmd/cloud/webhook/receipts.ts +16 -3
  308. package/src/cmd/dev/index.ts +91 -48
  309. package/src/tui.ts +9 -0
@@ -32,11 +32,7 @@ export const sendSubcommand = createCommand({
32
32
  tui.fatal('At least one of --text or --html is required');
33
33
  }
34
34
 
35
- const fileValues = Array.isArray(opts.file)
36
- ? opts.file
37
- : opts.file
38
- ? [opts.file]
39
- : [];
35
+ const fileValues = Array.isArray(opts.file) ? opts.file : opts.file ? [opts.file] : [];
40
36
 
41
37
  const attachments: EmailAttachment[] = [];
42
38
  for (const filePath of fileValues) {
@@ -53,7 +49,7 @@ export const sendSubcommand = createCommand({
53
49
  });
54
50
  }
55
51
 
56
- const email = createEmailAdapter(ctx);
52
+ const email = await createEmailAdapter(ctx);
57
53
  const outbound = await email.send({
58
54
  to: [args.to],
59
55
  from: opts.from,
@@ -69,17 +65,15 @@ export const sendSubcommand = createCommand({
69
65
  [
70
66
  {
71
67
  ID: outbound.id,
72
- From: outbound.from,
73
- To: outbound.to,
74
- Subject: outbound.subject ?? '-',
75
- Text: truncate(outbound.text),
76
- Status: outbound.status ?? '-',
77
- Sent: outbound.sent_at
78
- ? new Date(outbound.sent_at).toLocaleString()
79
- : '-',
68
+ From: outbound.from || opts.from,
69
+ To: outbound.to || args.to,
70
+ Subject: outbound.subject ?? opts.subject,
71
+ Text: truncate(outbound.text ?? opts.text),
72
+ Status: outbound.status ?? 'pending',
73
+ Attachments: attachments.length > 0 ? attachments.length.toString() : '-',
80
74
  },
81
75
  ],
82
- ['ID', 'From', 'To', 'Subject', 'Text', 'Status', 'Sent'],
76
+ ['ID', 'From', 'To', 'Subject', 'Text', 'Status', 'Attachments'],
83
77
  { layout: 'vertical', padStart: ' ' }
84
78
  );
85
79
  }
@@ -0,0 +1,73 @@
1
+ import { z } from 'zod';
2
+ import { createCommand } from '../../../types';
3
+ import * as tui from '../../../tui';
4
+ import { getGlobalCatalystAPIClient } from '../../../config';
5
+ import { getCommand } from '../../../command-prefix';
6
+ import { getServiceStats, type ServiceStatsData } from '@agentuity/server';
7
+
8
+ function formatNumber(n: number): string {
9
+ if (n >= 1_000_000) return `${(n / 1_000_000).toFixed(1)}M`;
10
+ if (n >= 1_000) return `${(n / 1_000).toFixed(1)}K`;
11
+ return String(n);
12
+ }
13
+
14
+ function displayStats(data: ServiceStatsData): void {
15
+ const svc = data.services.email;
16
+ if (!svc) {
17
+ tui.info('No email data found.');
18
+ return;
19
+ }
20
+ tui.header('Email Statistics');
21
+ tui.newline();
22
+ console.log(` ${tui.muted('Addresses:')} ${formatNumber(svc.addressCount)}`);
23
+ console.log(` ${tui.muted('Inbound:')} ${formatNumber(svc.inboundCount)}`);
24
+ console.log(
25
+ ` ${tui.muted('Outbound:')} ${formatNumber(svc.outboundCount)} (${svc.outboundSuccess} ok, ${svc.outboundFailed} failed)`
26
+ );
27
+ }
28
+
29
+ export const statsSubcommand = createCommand({
30
+ name: 'stats',
31
+ description: 'View email statistics',
32
+ tags: ['read-only', 'requires-auth'],
33
+ requires: { auth: true, org: true },
34
+ examples: [
35
+ {
36
+ command: getCommand('cloud email stats'),
37
+ description: 'View email statistics',
38
+ },
39
+ ],
40
+ schema: {
41
+ options: z.object({
42
+ start: z.string().optional().describe('Start time (ISO 8601)'),
43
+ end: z.string().optional().describe('End time (ISO 8601)'),
44
+ }),
45
+ },
46
+ idempotent: true,
47
+
48
+ async handler(ctx) {
49
+ const { opts, options } = ctx;
50
+ const client = await getGlobalCatalystAPIClient(ctx.logger, ctx.auth, ctx.config?.name);
51
+ const orgId = ctx.orgId ?? ctx.options.orgId ?? ctx.config?.preferences?.orgId;
52
+
53
+ if (!orgId) {
54
+ ctx.logger.fatal('Organization ID is required. Use --org-id or set a preferred org.');
55
+ return;
56
+ }
57
+
58
+ const data = await getServiceStats(client, orgId, {
59
+ service: 'email',
60
+ start: opts.start,
61
+ end: opts.end,
62
+ orgIdHeader: orgId,
63
+ });
64
+
65
+ if (!options.json) {
66
+ displayStats(data);
67
+ }
68
+
69
+ return data;
70
+ },
71
+ });
72
+
73
+ export default statsSubcommand;
@@ -1,8 +1,9 @@
1
1
  import { z } from 'zod';
2
2
  import { EmailStorageService, type Logger } from '@agentuity/core';
3
3
  import { createServerFetchAdapter } from '@agentuity/server';
4
- import type { AuthData, Config, GlobalOptions, ProjectConfig } from '../../../types';
4
+ import type { AuthData, Config, GlobalOptions } from '../../../types';
5
5
  import { getCatalystUrl } from '../../../catalyst';
6
+ import { defaultProfileName, getDefaultRegion } from '../../../config';
6
7
  import * as tui from '../../../tui';
7
8
 
8
9
  export type {
@@ -14,47 +15,24 @@ export type {
14
15
  EmailSendParams,
15
16
  } from '@agentuity/core';
16
17
 
17
- interface EmailContext {
18
+ export interface EmailContext {
18
19
  logger: Logger;
19
20
  auth: AuthData;
20
- region?: string;
21
- project?: ProjectConfig;
22
21
  config: Config | null;
23
22
  options: GlobalOptions;
24
23
  }
25
24
 
26
- export function resolveEmailOrgId(ctx: EmailContext, explicitOrgId?: string): string {
25
+ export function resolveEmailOrgId(ctx: EmailContext): string {
27
26
  const orgId =
28
- explicitOrgId ??
29
- ctx.project?.orgId ??
30
- ctx.options.orgId ??
31
- (process.env.AGENTUITY_CLOUD_ORG_ID || ctx.config?.preferences?.orgId);
27
+ ctx.options.orgId ?? (process.env.AGENTUITY_CLOUD_ORG_ID || ctx.config?.preferences?.orgId);
32
28
 
33
29
  if (!orgId) {
34
- tui.fatal(
35
- 'Organization ID is required. Either run from a project directory or use --org-id flag.'
36
- );
30
+ tui.fatal('Organization ID is required. Use --org-id flag or set AGENTUITY_CLOUD_ORG_ID.');
37
31
  }
38
32
 
39
33
  return orgId;
40
34
  }
41
35
 
42
- export function resolveEmailRegion(ctx: EmailContext): string {
43
- if (ctx.region) {
44
- return ctx.region;
45
- }
46
- if (process.env.AGENTUITY_REGION) {
47
- return process.env.AGENTUITY_REGION;
48
- }
49
- if (ctx.config?.name === 'local') {
50
- return 'local';
51
- }
52
- if (ctx.config?.preferences?.region) {
53
- return ctx.config.preferences.region;
54
- }
55
- return 'usc';
56
- }
57
-
58
36
  export const EmailAddressSchema = z.object({
59
37
  id: z.string(),
60
38
  email: z.string(),
@@ -72,8 +50,8 @@ export function truncate(value: string | undefined, length = 200): string {
72
50
  return value.length > length ? `${value.slice(0, length - 3)}...` : value;
73
51
  }
74
52
 
75
- export function createEmailAdapter(ctx: EmailContext, explicitOrgId?: string) {
76
- const orgId = resolveEmailOrgId(ctx, explicitOrgId);
53
+ export async function createEmailAdapter(ctx: EmailContext, region?: string) {
54
+ const orgId = resolveEmailOrgId(ctx);
77
55
  const adapter = createServerFetchAdapter(
78
56
  {
79
57
  headers: {
@@ -84,6 +62,8 @@ export function createEmailAdapter(ctx: EmailContext, explicitOrgId?: string) {
84
62
  ctx.logger
85
63
  );
86
64
 
87
- const baseUrl = getCatalystUrl(resolveEmailRegion(ctx));
65
+ const resolvedRegion =
66
+ region ?? (await getDefaultRegion(ctx.config?.name ?? defaultProfileName, ctx.config));
67
+ const baseUrl = getCatalystUrl(resolvedRegion);
88
68
  return new EmailStorageService(baseUrl, adapter);
89
69
  }
@@ -20,6 +20,7 @@ import { emailCommand } from './email';
20
20
  import taskCommand from './task';
21
21
  import sandboxCommand from './sandbox';
22
22
  import scheduleCommand from './schedule';
23
+ import servicesCommand from './services';
23
24
  import { regionSubcommand } from './region';
24
25
  import { machineCommand } from './machine';
25
26
  import { evalCommand } from './eval';
@@ -54,6 +55,7 @@ export const command = createCommand({
54
55
  dbCommand,
55
56
  redisCommand,
56
57
  storageCommand,
58
+ servicesCommand,
57
59
  sessionCommand,
58
60
  threadCommand,
59
61
  sshSubcommand,
@@ -42,12 +42,12 @@ function displayMessage(message: Message): void {
42
42
  tui.table([details], undefined, { layout: 'vertical' });
43
43
 
44
44
  tui.newline();
45
- tui.info('Payload');
45
+ tui.header('Payload');
46
46
  tui.json(message.payload);
47
47
 
48
48
  if (message.metadata && Object.keys(message.metadata).length > 0) {
49
49
  tui.newline();
50
- tui.info('Metadata');
50
+ tui.header('Metadata');
51
51
  tui.json(message.metadata);
52
52
  }
53
53
  }
@@ -119,7 +119,7 @@ export const getSubcommand = createCommand({
119
119
  queue.next_offset !== undefined
120
120
  ) {
121
121
  tui.newline();
122
- tui.info('Stats');
122
+ tui.header('Stats');
123
123
  tui.table(
124
124
  [
125
125
  {
@@ -135,7 +135,7 @@ export const getSubcommand = createCommand({
135
135
 
136
136
  if (queue.default_visibility_timeout_seconds !== undefined) {
137
137
  tui.newline();
138
- tui.info('Settings');
138
+ tui.header('Settings');
139
139
  const settings: Record<string, unknown> = {};
140
140
  if (queue.default_ttl_seconds != null) {
141
141
  settings['Default TTL'] = `${queue.default_ttl_seconds}s`;
@@ -55,15 +55,23 @@ export const receiveSubcommand = createCommand({
55
55
  tui.info('No messages available');
56
56
  } else {
57
57
  tui.success(`Received message: ${message.id}`);
58
- tui.info(` Offset: ${message.offset}`);
59
- tui.info(` State: ${message.state}`);
60
- tui.info(` Delivery Attempts: ${message.delivery_attempts}`);
61
- tui.info('');
62
- tui.info('Payload:');
58
+ tui.table(
59
+ [
60
+ {
61
+ Offset: message.offset,
62
+ State: message.state,
63
+ 'Delivery Attempts': message.delivery_attempts,
64
+ },
65
+ ],
66
+ undefined,
67
+ { layout: 'vertical' }
68
+ );
69
+ tui.newline();
70
+ tui.header('Payload');
63
71
  tui.json(message.payload);
64
72
  if (message.metadata) {
65
- tui.info('');
66
- tui.info('Metadata:');
73
+ tui.newline();
74
+ tui.header('Metadata');
67
75
  tui.json(message.metadata);
68
76
  }
69
77
  }
@@ -45,7 +45,7 @@ function formatDuration(start: string, end: string): string {
45
45
  function displayOrgAnalytics(analytics: OrgAnalytics): void {
46
46
  const { summary, queues, period } = analytics;
47
47
 
48
- tui.info(`Organization Analytics (${formatDuration(period.start, period.end)})`);
48
+ tui.header(`Organization Analytics (${formatDuration(period.start, period.end)})`);
49
49
  tui.newline();
50
50
  console.log(tui.colorPrimary('Summary:'));
51
51
  console.log(` ${tui.muted('Total Queues:')} ${summary.total_queues}`);
@@ -84,7 +84,7 @@ function displayQueueAnalytics(analytics: QueueAnalytics): void {
84
84
  const { queue_name, queue_type, period, current, period_stats, latency, consumer_latency } =
85
85
  analytics;
86
86
 
87
- tui.info(`Queue: ${queue_name} (${queue_type})`);
87
+ tui.header(`Queue: ${queue_name} (${queue_type})`);
88
88
  console.log(tui.colorWarning(`Period: ${formatDuration(period.start, period.end)}`));
89
89
  tui.newline();
90
90
 
@@ -146,7 +146,7 @@ function displayQueueAnalytics(analytics: QueueAnalytics): void {
146
146
 
147
147
  if (analytics.destinations && analytics.destinations.length > 0) {
148
148
  tui.newline();
149
- tui.info('Destinations:');
149
+ tui.header('Destinations');
150
150
  const destData = analytics.destinations.map((d) => {
151
151
  const total = d.success_count + d.failure_count;
152
152
  const errorRate = total > 0 ? (d.failure_count / total) * 100 : 0;
@@ -0,0 +1,85 @@
1
+ import { z } from 'zod';
2
+ import { createCommand } from '../../../../types';
3
+ import * as tui from '../../../../tui';
4
+ import { createSandboxClient } from '../util';
5
+ import { getCommand } from '../../../../command-prefix';
6
+ import { sandboxResolve, diskCheckpointCreate } from '@agentuity/server';
7
+
8
+ const CheckpointCreateResponseSchema = z.object({
9
+ success: z.boolean().describe('Whether the operation succeeded'),
10
+ sandboxId: z.string().describe('Sandbox ID'),
11
+ checkpointId: z.string().describe('Created checkpoint ID'),
12
+ name: z.string().describe('Checkpoint name'),
13
+ createdAt: z.string().describe('Checkpoint creation timestamp'),
14
+ parent: z.string().describe('Parent checkpoint name'),
15
+ durationMs: z.number().describe('Operation duration in milliseconds'),
16
+ });
17
+
18
+ export const createSubcommand = createCommand({
19
+ name: 'create',
20
+ description: 'Create a disk checkpoint of the sandbox filesystem',
21
+ tags: ['slow', 'requires-auth'],
22
+ requires: { auth: true, apiClient: true },
23
+ idempotent: false,
24
+ examples: [
25
+ {
26
+ command: getCommand('cloud sandbox checkpoint create sbx_abc123 my-checkpoint'),
27
+ description: 'Create a disk checkpoint',
28
+ },
29
+ ],
30
+ schema: {
31
+ args: z.object({
32
+ sandboxId: z.string().describe('Sandbox ID'),
33
+ name: z.string().describe('Checkpoint name'),
34
+ }),
35
+ options: z.object({}),
36
+ response: CheckpointCreateResponseSchema,
37
+ },
38
+
39
+ async handler(ctx) {
40
+ const { args, options, auth, logger, apiClient } = ctx;
41
+
42
+ const started = Date.now();
43
+
44
+ // Resolve sandbox to get region and orgId using CLI API
45
+ const sandboxInfo = await sandboxResolve(apiClient, args.sandboxId);
46
+
47
+ const client = createSandboxClient(logger, auth, sandboxInfo.region);
48
+
49
+ const checkpoint = await diskCheckpointCreate(client, {
50
+ sandboxId: args.sandboxId,
51
+ name: args.name,
52
+ orgId: sandboxInfo.orgId,
53
+ });
54
+ const durationMs = Date.now() - started;
55
+
56
+ if (!options.json) {
57
+ tui.success(`created disk checkpoint ${tui.bold(checkpoint.id)} in ${durationMs}ms`);
58
+
59
+ tui.table(
60
+ [
61
+ {
62
+ ID: checkpoint.id,
63
+ Name: checkpoint.name,
64
+ 'Created At': checkpoint.createdAt,
65
+ Parent: checkpoint.parent || '-',
66
+ },
67
+ ],
68
+ ['ID', 'Name', 'Created At', 'Parent'],
69
+ { layout: 'vertical', padStart: ' ' }
70
+ );
71
+ }
72
+
73
+ return {
74
+ success: true,
75
+ sandboxId: args.sandboxId,
76
+ checkpointId: checkpoint.id,
77
+ name: checkpoint.name,
78
+ createdAt: checkpoint.createdAt,
79
+ parent: checkpoint.parent,
80
+ durationMs,
81
+ };
82
+ },
83
+ });
84
+
85
+ export default createSubcommand;
@@ -0,0 +1,93 @@
1
+ import { z } from 'zod';
2
+ import { createCommand } from '../../../../types';
3
+ import * as tui from '../../../../tui';
4
+ import { createSandboxClient } from '../util';
5
+ import { getCommand } from '../../../../command-prefix';
6
+ import { sandboxResolve, diskCheckpointDelete } from '@agentuity/server';
7
+
8
+ const CheckpointDeleteResponseSchema = z.object({
9
+ success: z.boolean().describe('Whether the operation succeeded'),
10
+ sandboxId: z.string().describe('Sandbox ID'),
11
+ checkpointId: z.string().describe('Deleted checkpoint ID'),
12
+ durationMs: z.number().describe('Operation duration in milliseconds'),
13
+ message: z.string().optional().describe('Status message'),
14
+ });
15
+
16
+ export const deleteSubcommand = createCommand({
17
+ name: 'delete',
18
+ aliases: ['del', 'rm', 'remove'],
19
+ description: 'Delete a disk checkpoint',
20
+ tags: ['destructive', 'deletes-resource', 'slow', 'requires-auth'],
21
+ requires: { auth: true, apiClient: true },
22
+ idempotent: true,
23
+ examples: [
24
+ {
25
+ command: getCommand('cloud sandbox checkpoint delete sbx_abc123 ckpt_def456'),
26
+ description: 'Delete a disk checkpoint',
27
+ },
28
+ {
29
+ command: getCommand('cloud sandbox checkpoint delete sbx_abc123 ckpt_def456 --confirm'),
30
+ description: 'Delete without confirmation prompt',
31
+ },
32
+ ],
33
+ schema: {
34
+ args: z.object({
35
+ sandboxId: z.string().describe('Sandbox ID'),
36
+ checkpointId: z.string().describe('Checkpoint ID or name'),
37
+ }),
38
+ options: z.object({
39
+ confirm: z.boolean().optional().default(false).describe('Skip confirmation prompt'),
40
+ }),
41
+ response: CheckpointDeleteResponseSchema,
42
+ },
43
+
44
+ async handler(ctx) {
45
+ const { args, options, opts, auth, logger, apiClient } = ctx;
46
+
47
+ if (!opts.confirm) {
48
+ const confirmed = await tui.confirm(
49
+ `Delete disk checkpoint "${args.checkpointId}" from sandbox "${args.sandboxId}"?`,
50
+ false
51
+ );
52
+ if (!confirmed) {
53
+ logger.info('Cancelled');
54
+ return {
55
+ success: false,
56
+ sandboxId: args.sandboxId,
57
+ checkpointId: args.checkpointId,
58
+ durationMs: 0,
59
+ message: 'Cancelled',
60
+ };
61
+ }
62
+ }
63
+
64
+ const started = Date.now();
65
+
66
+ // Resolve sandbox to get region and orgId using CLI API
67
+ const sandboxInfo = await sandboxResolve(apiClient, args.sandboxId);
68
+
69
+ const client = createSandboxClient(logger, auth, sandboxInfo.region);
70
+
71
+ await diskCheckpointDelete(client, {
72
+ sandboxId: args.sandboxId,
73
+ checkpointId: args.checkpointId,
74
+ orgId: sandboxInfo.orgId,
75
+ });
76
+ const durationMs = Date.now() - started;
77
+
78
+ if (!options.json) {
79
+ tui.success(
80
+ `deleted disk checkpoint ${tui.bold(args.checkpointId)} from sandbox ${tui.bold(args.sandboxId)} in ${durationMs}ms`
81
+ );
82
+ }
83
+
84
+ return {
85
+ success: true,
86
+ sandboxId: args.sandboxId,
87
+ checkpointId: args.checkpointId,
88
+ durationMs,
89
+ };
90
+ },
91
+ });
92
+
93
+ export default deleteSubcommand;
@@ -0,0 +1,33 @@
1
+ import { createCommand } from '../../../../types';
2
+ import { createSubcommand } from './create';
3
+ import { listSubcommand } from './list';
4
+ import { restoreSubcommand } from './restore';
5
+ import { deleteSubcommand } from './delete';
6
+ import { getCommand } from '../../../../command-prefix';
7
+
8
+ export const checkpointCommand = createCommand({
9
+ name: 'checkpoint',
10
+ aliases: ['ckpt'],
11
+ description: 'Manage disk checkpoints for sandbox filesystem',
12
+ tags: ['slow', 'requires-auth'],
13
+ requires: { auth: true, apiClient: true },
14
+ examples: [
15
+ {
16
+ command: getCommand('cloud sandbox checkpoint create sbx_abc123 my-checkpoint'),
17
+ description: 'Create a disk checkpoint',
18
+ },
19
+ {
20
+ command: getCommand('cloud sandbox checkpoint list sbx_abc123'),
21
+ description: 'List disk checkpoints',
22
+ },
23
+ {
24
+ command: getCommand('cloud sandbox checkpoint restore sbx_abc123 ckpt_def456'),
25
+ description: 'Restore a disk checkpoint',
26
+ },
27
+ {
28
+ command: getCommand('cloud sandbox checkpoint delete sbx_abc123 ckpt_def456'),
29
+ description: 'Delete a disk checkpoint',
30
+ },
31
+ ],
32
+ subcommands: [createSubcommand, listSubcommand, restoreSubcommand, deleteSubcommand],
33
+ });
@@ -0,0 +1,83 @@
1
+ import { z } from 'zod';
2
+ import { createCommand } from '../../../../types';
3
+ import * as tui from '../../../../tui';
4
+ import { createSandboxClient } from '../util';
5
+ import { getCommand } from '../../../../command-prefix';
6
+ import { sandboxResolve, diskCheckpointList } from '@agentuity/server';
7
+
8
+ const CheckpointInfoSchema = z.object({
9
+ id: z.string(),
10
+ name: z.string(),
11
+ createdAt: z.string(),
12
+ parent: z.string(),
13
+ });
14
+
15
+ const CheckpointListResponseSchema = z.object({
16
+ checkpoints: z.array(CheckpointInfoSchema).describe('List of disk checkpoints'),
17
+ total: z.number().describe('Total number of checkpoints'),
18
+ });
19
+
20
+ export const listSubcommand = createCommand({
21
+ name: 'list',
22
+ aliases: ['ls'],
23
+ description: 'List disk checkpoints for a sandbox',
24
+ tags: ['slow', 'requires-auth'],
25
+ requires: { auth: true, apiClient: true },
26
+ examples: [
27
+ {
28
+ command: getCommand('cloud sandbox checkpoint list sbx_abc123'),
29
+ description: 'List disk checkpoints for a sandbox',
30
+ },
31
+ ],
32
+ schema: {
33
+ args: z.object({
34
+ sandboxId: z.string().describe('Sandbox ID'),
35
+ }),
36
+ options: z.object({}),
37
+ response: CheckpointListResponseSchema,
38
+ },
39
+
40
+ async handler(ctx) {
41
+ const { args, options, auth, logger, apiClient } = ctx;
42
+
43
+ // Resolve sandbox to get region and orgId using CLI API
44
+ const sandboxInfo = await sandboxResolve(apiClient, args.sandboxId);
45
+
46
+ const client = createSandboxClient(logger, auth, sandboxInfo.region);
47
+
48
+ const checkpoints = await diskCheckpointList(client, {
49
+ sandboxId: args.sandboxId,
50
+ orgId: sandboxInfo.orgId,
51
+ });
52
+
53
+ if (!options.json) {
54
+ if (checkpoints.length === 0) {
55
+ tui.info('No disk checkpoints found');
56
+ } else {
57
+ const tableData = checkpoints.map((ckpt) => ({
58
+ ID: ckpt.id,
59
+ Name: ckpt.name,
60
+ 'Created At': ckpt.createdAt,
61
+ Parent: ckpt.parent || '-',
62
+ }));
63
+ tui.table(tableData, [
64
+ { name: 'ID', alignment: 'left' },
65
+ { name: 'Name', alignment: 'left' },
66
+ { name: 'Created At', alignment: 'left' },
67
+ { name: 'Parent', alignment: 'left' },
68
+ ]);
69
+
70
+ tui.info(
71
+ `Total: ${checkpoints.length} ${tui.plural(checkpoints.length, 'checkpoint', 'checkpoints')}`
72
+ );
73
+ }
74
+ }
75
+
76
+ return {
77
+ checkpoints,
78
+ total: checkpoints.length,
79
+ };
80
+ },
81
+ });
82
+
83
+ export default listSubcommand;
@@ -0,0 +1,72 @@
1
+ import { z } from 'zod';
2
+ import { createCommand } from '../../../../types';
3
+ import * as tui from '../../../../tui';
4
+ import { createSandboxClient } from '../util';
5
+ import { getCommand } from '../../../../command-prefix';
6
+ import { sandboxResolve, diskCheckpointRestore } from '@agentuity/server';
7
+
8
+ const CheckpointRestoreResponseSchema = z.object({
9
+ success: z.boolean().describe('Whether the operation succeeded'),
10
+ sandboxId: z.string().describe('Sandbox ID'),
11
+ checkpointId: z.string().describe('Restored checkpoint ID'),
12
+ durationMs: z.number().describe('Operation duration in milliseconds'),
13
+ });
14
+
15
+ export const restoreSubcommand = createCommand({
16
+ name: 'restore',
17
+ description: 'Restore a sandbox to a disk checkpoint',
18
+ tags: ['slow', 'requires-auth'],
19
+ requires: { auth: true, apiClient: true },
20
+ idempotent: false,
21
+ examples: [
22
+ {
23
+ command: getCommand('cloud sandbox checkpoint restore sbx_abc123 ckpt_def456'),
24
+ description: 'Restore a sandbox to a checkpoint by ID',
25
+ },
26
+ {
27
+ command: getCommand('cloud sandbox checkpoint restore sbx_abc123 my-checkpoint'),
28
+ description: 'Restore a sandbox to a checkpoint by name',
29
+ },
30
+ ],
31
+ schema: {
32
+ args: z.object({
33
+ sandboxId: z.string().describe('Sandbox ID'),
34
+ checkpointId: z.string().describe('Checkpoint ID or name'),
35
+ }),
36
+ options: z.object({}),
37
+ response: CheckpointRestoreResponseSchema,
38
+ },
39
+
40
+ async handler(ctx) {
41
+ const { args, options, auth, logger, apiClient } = ctx;
42
+
43
+ const started = Date.now();
44
+
45
+ // Resolve sandbox to get region and orgId using CLI API
46
+ const sandboxInfo = await sandboxResolve(apiClient, args.sandboxId);
47
+
48
+ const client = createSandboxClient(logger, auth, sandboxInfo.region);
49
+
50
+ await diskCheckpointRestore(client, {
51
+ sandboxId: args.sandboxId,
52
+ checkpointId: args.checkpointId,
53
+ orgId: sandboxInfo.orgId,
54
+ });
55
+ const durationMs = Date.now() - started;
56
+
57
+ if (!options.json) {
58
+ tui.success(
59
+ `restored sandbox ${tui.bold(args.sandboxId)} to checkpoint ${tui.bold(args.checkpointId)} in ${durationMs}ms`
60
+ );
61
+ }
62
+
63
+ return {
64
+ success: true,
65
+ sandboxId: args.sandboxId,
66
+ checkpointId: args.checkpointId,
67
+ durationMs,
68
+ };
69
+ },
70
+ });
71
+
72
+ export default restoreSubcommand;