@agentuity/cli 0.1.8 → 0.1.10

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 (325) hide show
  1. package/README.md +2 -2
  2. package/bin/cli.ts +8 -0
  3. package/dist/cache/index.d.ts +2 -0
  4. package/dist/cache/index.d.ts.map +1 -0
  5. package/dist/cache/index.js +2 -0
  6. package/dist/cache/index.js.map +1 -0
  7. package/dist/cache/resource-region.d.ts +46 -0
  8. package/dist/cache/resource-region.d.ts.map +1 -0
  9. package/dist/cache/resource-region.js +115 -0
  10. package/dist/cache/resource-region.js.map +1 -0
  11. package/dist/cli.d.ts.map +1 -1
  12. package/dist/cli.js +44 -18
  13. package/dist/cli.js.map +1 -1
  14. package/dist/cmd/ai/capabilities/show.d.ts.map +1 -1
  15. package/dist/cmd/ai/capabilities/show.js +12 -15
  16. package/dist/cmd/ai/capabilities/show.js.map +1 -1
  17. package/dist/cmd/ai/prompt/llm.js +5 -5
  18. package/dist/cmd/ai/prompt/llm.js.map +1 -1
  19. package/dist/cmd/ai/skills/generator.d.ts.map +1 -1
  20. package/dist/cmd/ai/skills/generator.js +9 -1
  21. package/dist/cmd/ai/skills/generator.js.map +1 -1
  22. package/dist/cmd/auth/logout.d.ts.map +1 -1
  23. package/dist/cmd/auth/logout.js +5 -2
  24. package/dist/cmd/auth/logout.js.map +1 -1
  25. package/dist/cmd/build/ast.d.ts.map +1 -1
  26. package/dist/cmd/build/ast.js +87 -1
  27. package/dist/cmd/build/ast.js.map +1 -1
  28. package/dist/cmd/build/vite/metadata-generator.js +1 -1
  29. package/dist/cmd/build/vite/metadata-generator.js.map +1 -1
  30. package/dist/cmd/build/vite/vite-asset-server-config.d.ts.map +1 -1
  31. package/dist/cmd/build/vite/vite-asset-server-config.js +8 -3
  32. package/dist/cmd/build/vite/vite-asset-server-config.js.map +1 -1
  33. package/dist/cmd/build/vite/vite-asset-server.d.ts.map +1 -1
  34. package/dist/cmd/build/vite/vite-asset-server.js +5 -3
  35. package/dist/cmd/build/vite/vite-asset-server.js.map +1 -1
  36. package/dist/cmd/cloud/db/delete.d.ts.map +1 -1
  37. package/dist/cmd/cloud/db/delete.js +69 -11
  38. package/dist/cmd/cloud/db/delete.js.map +1 -1
  39. package/dist/cmd/cloud/db/get.d.ts.map +1 -1
  40. package/dist/cmd/cloud/db/get.js +23 -7
  41. package/dist/cmd/cloud/db/get.js.map +1 -1
  42. package/dist/cmd/cloud/db/list.d.ts.map +1 -1
  43. package/dist/cmd/cloud/db/list.js +15 -7
  44. package/dist/cmd/cloud/db/list.js.map +1 -1
  45. package/dist/cmd/cloud/db/logs.d.ts.map +1 -1
  46. package/dist/cmd/cloud/db/logs.js +24 -4
  47. package/dist/cmd/cloud/db/logs.js.map +1 -1
  48. package/dist/cmd/cloud/deploy.d.ts.map +1 -1
  49. package/dist/cmd/cloud/deploy.js +50 -1
  50. package/dist/cmd/cloud/deploy.js.map +1 -1
  51. package/dist/cmd/cloud/env/delete.d.ts.map +1 -1
  52. package/dist/cmd/cloud/env/delete.js +30 -13
  53. package/dist/cmd/cloud/env/delete.js.map +1 -1
  54. package/dist/cmd/cloud/env/get.d.ts.map +1 -1
  55. package/dist/cmd/cloud/env/get.js +27 -30
  56. package/dist/cmd/cloud/env/get.js.map +1 -1
  57. package/dist/cmd/cloud/env/import.d.ts.map +1 -1
  58. package/dist/cmd/cloud/env/import.js +41 -48
  59. package/dist/cmd/cloud/env/import.js.map +1 -1
  60. package/dist/cmd/cloud/env/index.d.ts.map +1 -1
  61. package/dist/cmd/cloud/env/index.js +6 -2
  62. package/dist/cmd/cloud/env/index.js.map +1 -1
  63. package/dist/cmd/cloud/env/list.d.ts.map +1 -1
  64. package/dist/cmd/cloud/env/list.js +51 -28
  65. package/dist/cmd/cloud/env/list.js.map +1 -1
  66. package/dist/cmd/cloud/env/pull.d.ts.map +1 -1
  67. package/dist/cmd/cloud/env/pull.js +3 -3
  68. package/dist/cmd/cloud/env/pull.js.map +1 -1
  69. package/dist/cmd/cloud/env/push.d.ts.map +1 -1
  70. package/dist/cmd/cloud/env/push.js +31 -11
  71. package/dist/cmd/cloud/env/push.js.map +1 -1
  72. package/dist/cmd/cloud/env/set.d.ts.map +1 -1
  73. package/dist/cmd/cloud/env/set.js +41 -26
  74. package/dist/cmd/cloud/env/set.js.map +1 -1
  75. package/dist/cmd/cloud/index.d.ts.map +1 -1
  76. package/dist/cmd/cloud/index.js +0 -2
  77. package/dist/cmd/cloud/index.js.map +1 -1
  78. package/dist/cmd/cloud/region-lookup.d.ts +18 -0
  79. package/dist/cmd/cloud/region-lookup.d.ts.map +1 -0
  80. package/dist/cmd/cloud/region-lookup.js +64 -0
  81. package/dist/cmd/cloud/region-lookup.js.map +1 -0
  82. package/dist/cmd/cloud/sandbox/cp.d.ts.map +1 -1
  83. package/dist/cmd/cloud/sandbox/cp.js +5 -3
  84. package/dist/cmd/cloud/sandbox/cp.js.map +1 -1
  85. package/dist/cmd/cloud/sandbox/create.d.ts.map +1 -1
  86. package/dist/cmd/cloud/sandbox/create.js +54 -2
  87. package/dist/cmd/cloud/sandbox/create.js.map +1 -1
  88. package/dist/cmd/cloud/sandbox/delete.d.ts.map +1 -1
  89. package/dist/cmd/cloud/sandbox/delete.js +5 -3
  90. package/dist/cmd/cloud/sandbox/delete.js.map +1 -1
  91. package/dist/cmd/cloud/sandbox/download.d.ts.map +1 -1
  92. package/dist/cmd/cloud/sandbox/download.js +4 -3
  93. package/dist/cmd/cloud/sandbox/download.js.map +1 -1
  94. package/dist/cmd/cloud/sandbox/env.d.ts.map +1 -1
  95. package/dist/cmd/cloud/sandbox/env.js +4 -3
  96. package/dist/cmd/cloud/sandbox/env.js.map +1 -1
  97. package/dist/cmd/cloud/sandbox/exec.d.ts.map +1 -1
  98. package/dist/cmd/cloud/sandbox/exec.js +4 -3
  99. package/dist/cmd/cloud/sandbox/exec.js.map +1 -1
  100. package/dist/cmd/cloud/sandbox/execution/get.js +4 -4
  101. package/dist/cmd/cloud/sandbox/execution/get.js.map +1 -1
  102. package/dist/cmd/cloud/sandbox/execution/index.js +1 -1
  103. package/dist/cmd/cloud/sandbox/execution/index.js.map +1 -1
  104. package/dist/cmd/cloud/sandbox/execution/list.d.ts.map +1 -1
  105. package/dist/cmd/cloud/sandbox/execution/list.js +4 -3
  106. package/dist/cmd/cloud/sandbox/execution/list.js.map +1 -1
  107. package/dist/cmd/cloud/sandbox/get.d.ts.map +1 -1
  108. package/dist/cmd/cloud/sandbox/get.js +26 -4
  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 +3 -1
  112. package/dist/cmd/cloud/sandbox/index.js.map +1 -1
  113. package/dist/cmd/cloud/sandbox/list.d.ts.map +1 -1
  114. package/dist/cmd/cloud/sandbox/list.js +16 -9
  115. package/dist/cmd/cloud/sandbox/list.js.map +1 -1
  116. package/dist/cmd/cloud/sandbox/ls.d.ts.map +1 -1
  117. package/dist/cmd/cloud/sandbox/ls.js +4 -3
  118. package/dist/cmd/cloud/sandbox/ls.js.map +1 -1
  119. package/dist/cmd/cloud/sandbox/mkdir.d.ts.map +1 -1
  120. package/dist/cmd/cloud/sandbox/mkdir.js +4 -3
  121. package/dist/cmd/cloud/sandbox/mkdir.js.map +1 -1
  122. package/dist/cmd/cloud/sandbox/rm.d.ts.map +1 -1
  123. package/dist/cmd/cloud/sandbox/rm.js +4 -3
  124. package/dist/cmd/cloud/sandbox/rm.js.map +1 -1
  125. package/dist/cmd/cloud/sandbox/rmdir.d.ts.map +1 -1
  126. package/dist/cmd/cloud/sandbox/rmdir.js +4 -3
  127. package/dist/cmd/cloud/sandbox/rmdir.js.map +1 -1
  128. package/dist/cmd/cloud/sandbox/run.d.ts.map +1 -1
  129. package/dist/cmd/cloud/sandbox/run.js +51 -2
  130. package/dist/cmd/cloud/sandbox/run.js.map +1 -1
  131. package/dist/cmd/cloud/sandbox/runtime/index.d.ts +3 -0
  132. package/dist/cmd/cloud/sandbox/runtime/index.d.ts.map +1 -0
  133. package/dist/cmd/cloud/sandbox/runtime/index.js +19 -0
  134. package/dist/cmd/cloud/sandbox/runtime/index.js.map +1 -0
  135. package/dist/cmd/cloud/sandbox/runtime/list.d.ts +3 -0
  136. package/dist/cmd/cloud/sandbox/runtime/list.d.ts.map +1 -0
  137. package/dist/cmd/cloud/sandbox/runtime/list.js +68 -0
  138. package/dist/cmd/cloud/sandbox/runtime/list.js.map +1 -0
  139. package/dist/cmd/cloud/sandbox/snapshot/create.d.ts.map +1 -1
  140. package/dist/cmd/cloud/sandbox/snapshot/create.js +41 -8
  141. package/dist/cmd/cloud/sandbox/snapshot/create.js.map +1 -1
  142. package/dist/cmd/cloud/sandbox/snapshot/delete.js +4 -4
  143. package/dist/cmd/cloud/sandbox/snapshot/delete.js.map +1 -1
  144. package/dist/cmd/cloud/sandbox/snapshot/get.js +5 -5
  145. package/dist/cmd/cloud/sandbox/snapshot/get.js.map +1 -1
  146. package/dist/cmd/cloud/sandbox/snapshot/index.js +1 -1
  147. package/dist/cmd/cloud/sandbox/snapshot/index.js.map +1 -1
  148. package/dist/cmd/cloud/sandbox/snapshot/list.d.ts.map +1 -1
  149. package/dist/cmd/cloud/sandbox/snapshot/list.js +8 -4
  150. package/dist/cmd/cloud/sandbox/snapshot/list.js.map +1 -1
  151. package/dist/cmd/cloud/sandbox/snapshot/tag.d.ts.map +1 -1
  152. package/dist/cmd/cloud/sandbox/snapshot/tag.js +14 -4
  153. package/dist/cmd/cloud/sandbox/snapshot/tag.js.map +1 -1
  154. package/dist/cmd/cloud/sandbox/upload.d.ts.map +1 -1
  155. package/dist/cmd/cloud/sandbox/upload.js +4 -3
  156. package/dist/cmd/cloud/sandbox/upload.js.map +1 -1
  157. package/dist/cmd/cloud/sandbox/util.d.ts +13 -0
  158. package/dist/cmd/cloud/sandbox/util.d.ts.map +1 -1
  159. package/dist/cmd/cloud/sandbox/util.js +40 -1
  160. package/dist/cmd/cloud/sandbox/util.js.map +1 -1
  161. package/dist/cmd/cloud/scp/download.d.ts.map +1 -1
  162. package/dist/cmd/cloud/scp/download.js +6 -2
  163. package/dist/cmd/cloud/scp/download.js.map +1 -1
  164. package/dist/cmd/cloud/scp/upload.d.ts.map +1 -1
  165. package/dist/cmd/cloud/scp/upload.js +6 -2
  166. package/dist/cmd/cloud/scp/upload.js.map +1 -1
  167. package/dist/cmd/cloud/session/get.js +4 -4
  168. package/dist/cmd/cloud/session/get.js.map +1 -1
  169. package/dist/cmd/cloud/session/list.js +4 -4
  170. package/dist/cmd/cloud/session/list.js.map +1 -1
  171. package/dist/cmd/cloud/ssh.d.ts.map +1 -1
  172. package/dist/cmd/cloud/ssh.js +7 -2
  173. package/dist/cmd/cloud/ssh.js.map +1 -1
  174. package/dist/cmd/cloud/storage/delete.d.ts.map +1 -1
  175. package/dist/cmd/cloud/storage/delete.js +46 -10
  176. package/dist/cmd/cloud/storage/delete.js.map +1 -1
  177. package/dist/cmd/cloud/storage/download.d.ts.map +1 -1
  178. package/dist/cmd/cloud/storage/download.js +19 -6
  179. package/dist/cmd/cloud/storage/download.js.map +1 -1
  180. package/dist/cmd/cloud/storage/get.d.ts.map +1 -1
  181. package/dist/cmd/cloud/storage/get.js +19 -6
  182. package/dist/cmd/cloud/storage/get.js.map +1 -1
  183. package/dist/cmd/cloud/storage/list.d.ts.map +1 -1
  184. package/dist/cmd/cloud/storage/list.js +17 -7
  185. package/dist/cmd/cloud/storage/list.js.map +1 -1
  186. package/dist/cmd/cloud/storage/upload.d.ts.map +1 -1
  187. package/dist/cmd/cloud/storage/upload.js +19 -6
  188. package/dist/cmd/cloud/storage/upload.js.map +1 -1
  189. package/dist/cmd/cloud/thread/delete.js +4 -4
  190. package/dist/cmd/cloud/thread/delete.js.map +1 -1
  191. package/dist/cmd/cloud/thread/get.js +4 -4
  192. package/dist/cmd/cloud/thread/get.js.map +1 -1
  193. package/dist/cmd/cloud/thread/list.js +4 -4
  194. package/dist/cmd/cloud/thread/list.js.map +1 -1
  195. package/dist/cmd/project/auth/init.d.ts.map +1 -1
  196. package/dist/cmd/project/auth/init.js +6 -3
  197. package/dist/cmd/project/auth/init.js.map +1 -1
  198. package/dist/cmd/project/auth/shared.d.ts +6 -2
  199. package/dist/cmd/project/auth/shared.d.ts.map +1 -1
  200. package/dist/cmd/project/auth/shared.js +40 -12
  201. package/dist/cmd/project/auth/shared.js.map +1 -1
  202. package/dist/config.d.ts +37 -0
  203. package/dist/config.d.ts.map +1 -1
  204. package/dist/config.js +61 -8
  205. package/dist/config.js.map +1 -1
  206. package/dist/env-util.d.ts +25 -2
  207. package/dist/env-util.d.ts.map +1 -1
  208. package/dist/env-util.js +44 -4
  209. package/dist/env-util.js.map +1 -1
  210. package/dist/utils/apt-validator.d.ts +20 -0
  211. package/dist/utils/apt-validator.d.ts.map +1 -0
  212. package/dist/utils/apt-validator.js +157 -0
  213. package/dist/utils/apt-validator.js.map +1 -0
  214. package/package.json +6 -6
  215. package/src/cache/index.ts +11 -0
  216. package/src/cache/resource-region.ts +183 -0
  217. package/src/cli.ts +51 -17
  218. package/src/cmd/ai/capabilities/show.ts +12 -15
  219. package/src/cmd/ai/prompt/llm.ts +5 -5
  220. package/src/cmd/ai/skills/generator.ts +9 -1
  221. package/src/cmd/auth/logout.ts +5 -2
  222. package/src/cmd/build/ast.ts +160 -1
  223. package/src/cmd/build/vite/metadata-generator.ts +1 -1
  224. package/src/cmd/build/vite/vite-asset-server-config.ts +7 -3
  225. package/src/cmd/build/vite/vite-asset-server.ts +6 -3
  226. package/src/cmd/cloud/db/delete.ts +83 -11
  227. package/src/cmd/cloud/db/get.ts +29 -7
  228. package/src/cmd/cloud/db/list.ts +16 -7
  229. package/src/cmd/cloud/db/logs.ts +33 -4
  230. package/src/cmd/cloud/deploy.ts +63 -0
  231. package/src/cmd/cloud/env/delete.ts +36 -12
  232. package/src/cmd/cloud/env/get.ts +28 -27
  233. package/src/cmd/cloud/env/import.ts +43 -56
  234. package/src/cmd/cloud/env/index.ts +6 -2
  235. package/src/cmd/cloud/env/list.ts +57 -30
  236. package/src/cmd/cloud/env/pull.ts +9 -3
  237. package/src/cmd/cloud/env/push.ts +44 -11
  238. package/src/cmd/cloud/env/set.ts +49 -30
  239. package/src/cmd/cloud/index.ts +0 -2
  240. package/src/cmd/cloud/region-lookup.ts +89 -0
  241. package/src/cmd/cloud/sandbox/cp.ts +5 -3
  242. package/src/cmd/cloud/sandbox/create.ts +61 -2
  243. package/src/cmd/cloud/sandbox/delete.ts +6 -3
  244. package/src/cmd/cloud/sandbox/download.ts +4 -3
  245. package/src/cmd/cloud/sandbox/env.ts +4 -3
  246. package/src/cmd/cloud/sandbox/exec.ts +4 -3
  247. package/src/cmd/cloud/sandbox/execution/get.ts +4 -4
  248. package/src/cmd/cloud/sandbox/execution/index.ts +1 -1
  249. package/src/cmd/cloud/sandbox/execution/list.ts +4 -3
  250. package/src/cmd/cloud/sandbox/get.ts +27 -4
  251. package/src/cmd/cloud/sandbox/index.ts +3 -1
  252. package/src/cmd/cloud/sandbox/list.ts +16 -9
  253. package/src/cmd/cloud/sandbox/ls.ts +4 -3
  254. package/src/cmd/cloud/sandbox/mkdir.ts +4 -3
  255. package/src/cmd/cloud/sandbox/rm.ts +4 -3
  256. package/src/cmd/cloud/sandbox/rmdir.ts +4 -3
  257. package/src/cmd/cloud/sandbox/run.ts +58 -2
  258. package/src/cmd/cloud/sandbox/runtime/index.ts +20 -0
  259. package/src/cmd/cloud/sandbox/runtime/list.ts +75 -0
  260. package/src/cmd/cloud/sandbox/snapshot/create.ts +53 -8
  261. package/src/cmd/cloud/sandbox/snapshot/delete.ts +4 -4
  262. package/src/cmd/cloud/sandbox/snapshot/get.ts +5 -5
  263. package/src/cmd/cloud/sandbox/snapshot/index.ts +1 -1
  264. package/src/cmd/cloud/sandbox/snapshot/list.ts +8 -4
  265. package/src/cmd/cloud/sandbox/snapshot/tag.ts +20 -4
  266. package/src/cmd/cloud/sandbox/upload.ts +4 -3
  267. package/src/cmd/cloud/sandbox/util.ts +60 -1
  268. package/src/cmd/cloud/scp/download.ts +14 -2
  269. package/src/cmd/cloud/scp/upload.ts +14 -2
  270. package/src/cmd/cloud/session/get.ts +4 -4
  271. package/src/cmd/cloud/session/list.ts +4 -4
  272. package/src/cmd/cloud/ssh.ts +15 -2
  273. package/src/cmd/cloud/storage/delete.ts +61 -10
  274. package/src/cmd/cloud/storage/download.ts +31 -6
  275. package/src/cmd/cloud/storage/get.ts +31 -6
  276. package/src/cmd/cloud/storage/list.ts +18 -7
  277. package/src/cmd/cloud/storage/upload.ts +31 -6
  278. package/src/cmd/cloud/thread/delete.ts +4 -4
  279. package/src/cmd/cloud/thread/get.ts +4 -4
  280. package/src/cmd/cloud/thread/list.ts +4 -4
  281. package/src/cmd/project/auth/init.ts +7 -3
  282. package/src/cmd/project/auth/shared.ts +52 -13
  283. package/src/config.ts +74 -8
  284. package/src/env-util.ts +50 -5
  285. package/src/utils/apt-validator.ts +215 -0
  286. package/dist/cmd/cloud/secret/delete.d.ts +0 -2
  287. package/dist/cmd/cloud/secret/delete.d.ts.map +0 -1
  288. package/dist/cmd/cloud/secret/delete.js +0 -53
  289. package/dist/cmd/cloud/secret/delete.js.map +0 -1
  290. package/dist/cmd/cloud/secret/get.d.ts +0 -2
  291. package/dist/cmd/cloud/secret/get.d.ts.map +0 -1
  292. package/dist/cmd/cloud/secret/get.js +0 -73
  293. package/dist/cmd/cloud/secret/get.js.map +0 -1
  294. package/dist/cmd/cloud/secret/import.d.ts +0 -2
  295. package/dist/cmd/cloud/secret/import.d.ts.map +0 -1
  296. package/dist/cmd/cloud/secret/import.js +0 -91
  297. package/dist/cmd/cloud/secret/import.js.map +0 -1
  298. package/dist/cmd/cloud/secret/index.d.ts +0 -3
  299. package/dist/cmd/cloud/secret/index.d.ts.map +0 -1
  300. package/dist/cmd/cloud/secret/index.js +0 -33
  301. package/dist/cmd/cloud/secret/index.js.map +0 -1
  302. package/dist/cmd/cloud/secret/list.d.ts +0 -2
  303. package/dist/cmd/cloud/secret/list.d.ts.map +0 -1
  304. package/dist/cmd/cloud/secret/list.js +0 -65
  305. package/dist/cmd/cloud/secret/list.js.map +0 -1
  306. package/dist/cmd/cloud/secret/pull.d.ts +0 -2
  307. package/dist/cmd/cloud/secret/pull.d.ts.map +0 -1
  308. package/dist/cmd/cloud/secret/pull.js +0 -82
  309. package/dist/cmd/cloud/secret/pull.js.map +0 -1
  310. package/dist/cmd/cloud/secret/push.d.ts +0 -2
  311. package/dist/cmd/cloud/secret/push.d.ts.map +0 -1
  312. package/dist/cmd/cloud/secret/push.js +0 -61
  313. package/dist/cmd/cloud/secret/push.js.map +0 -1
  314. package/dist/cmd/cloud/secret/set.d.ts +0 -2
  315. package/dist/cmd/cloud/secret/set.d.ts.map +0 -1
  316. package/dist/cmd/cloud/secret/set.js +0 -63
  317. package/dist/cmd/cloud/secret/set.js.map +0 -1
  318. package/src/cmd/cloud/secret/delete.ts +0 -65
  319. package/src/cmd/cloud/secret/get.ts +0 -77
  320. package/src/cmd/cloud/secret/import.ts +0 -110
  321. package/src/cmd/cloud/secret/index.ts +0 -33
  322. package/src/cmd/cloud/secret/list.ts +0 -70
  323. package/src/cmd/cloud/secret/pull.ts +0 -92
  324. package/src/cmd/cloud/secret/push.ts +0 -69
  325. package/src/cmd/cloud/secret/set.ts +0 -76
@@ -1,11 +1,11 @@
1
1
  import { z } from 'zod';
2
2
  import { createCommand } from '../../../../types';
3
3
  import * as tui from '../../../../tui';
4
- import { createSandboxClient } from '../util';
5
4
  import { getCommand } from '../../../../command-prefix';
6
5
  import { snapshotGet, sandboxList } from '@agentuity/server';
7
6
  import type { SnapshotFileInfo } from '@agentuity/server';
8
7
  import type { SandboxInfo } from '@agentuity/core';
8
+ import { getGlobalCatalystAPIClient } from '../../../../config';
9
9
 
10
10
  const SnapshotFileSchema = z.object({
11
11
  path: z.string(),
@@ -27,7 +27,7 @@ const SnapshotGetResponseSchema = z.object({
27
27
  parentSnapshotId: z.string().nullable().optional().describe('Parent snapshot ID'),
28
28
  createdAt: z.string().describe('Creation timestamp'),
29
29
  downloadUrl: z.string().optional().describe('Presigned download URL'),
30
- files: z.array(SnapshotFileSchema).optional().describe('Files in snapshot'),
30
+ files: z.array(SnapshotFileSchema).nullable().optional().describe('Files in snapshot'),
31
31
  sandboxes: z
32
32
  .array(SandboxInfoSchema)
33
33
  .optional()
@@ -39,7 +39,7 @@ export const getSubcommand = createCommand({
39
39
  aliases: ['info', 'show'],
40
40
  description: 'Get snapshot details',
41
41
  tags: ['slow', 'requires-auth'],
42
- requires: { auth: true, region: true, org: true },
42
+ requires: { auth: true, org: true },
43
43
  examples: [
44
44
  {
45
45
  command: getCommand('cloud sandbox snapshot get snp_abc123'),
@@ -54,8 +54,8 @@ export const getSubcommand = createCommand({
54
54
  },
55
55
 
56
56
  async handler(ctx) {
57
- const { args, options, auth, region, logger, orgId } = ctx;
58
- const client = createSandboxClient(logger, auth, region);
57
+ const { args, options, auth, logger, orgId, config } = ctx;
58
+ const client = await getGlobalCatalystAPIClient(logger, auth, config?.name);
59
59
 
60
60
  const snapshot = await snapshotGet(client, {
61
61
  snapshotId: args.snapshotId,
@@ -22,7 +22,7 @@ export const snapshotCommand = createCommand({
22
22
  },
23
23
  ],
24
24
  subcommands: [createSubcommand, listSubcommand, getSubcommand, deleteSubcommand, tagSubcommand],
25
- requires: { auth: true, region: true, org: true },
25
+ requires: { auth: true, org: true },
26
26
  });
27
27
 
28
28
  export default snapshotCommand;
@@ -1,12 +1,14 @@
1
1
  import { z } from 'zod';
2
2
  import { createCommand } from '../../../../types';
3
3
  import * as tui from '../../../../tui';
4
- import { createSandboxClient } from '../util';
5
4
  import { getCommand } from '../../../../command-prefix';
6
5
  import { snapshotList } from '@agentuity/server';
6
+ import { getGlobalCatalystAPIClient } from '../../../../config';
7
7
 
8
8
  const SnapshotInfoSchema = z.object({
9
9
  snapshotId: z.string(),
10
+ name: z.string().nullable().optional(),
11
+ description: z.string().nullable().optional(),
10
12
  tag: z.string().nullable().optional(),
11
13
  sizeBytes: z.number(),
12
14
  fileCount: z.number(),
@@ -24,7 +26,7 @@ export const listSubcommand = createCommand({
24
26
  aliases: ['ls'],
25
27
  description: 'List snapshots',
26
28
  tags: ['slow', 'requires-auth'],
27
- requires: { auth: true, region: true, org: true },
29
+ requires: { auth: true, org: true },
28
30
  examples: [
29
31
  {
30
32
  command: getCommand('cloud sandbox snapshot list'),
@@ -45,8 +47,8 @@ export const listSubcommand = createCommand({
45
47
  },
46
48
 
47
49
  async handler(ctx) {
48
- const { opts, options, auth, region, logger, orgId } = ctx;
49
- const client = createSandboxClient(logger, auth, region);
50
+ const { opts, options, auth, logger, orgId, config } = ctx;
51
+ const client = await getGlobalCatalystAPIClient(logger, auth, config?.name);
50
52
 
51
53
  const result = await snapshotList(client, {
52
54
  sandboxId: opts.sandbox,
@@ -62,6 +64,7 @@ export const listSubcommand = createCommand({
62
64
  const tableData = result.snapshots.map((snap) => {
63
65
  return {
64
66
  ID: snap.snapshotId,
67
+ Name: snap.name ?? '-',
65
68
  Tag: snap.tag ?? '-',
66
69
  Size: tui.formatBytes(snap.sizeBytes),
67
70
  Files: snap.fileCount,
@@ -70,6 +73,7 @@ export const listSubcommand = createCommand({
70
73
  });
71
74
  tui.table(tableData, [
72
75
  { name: 'ID', alignment: 'left' },
76
+ { name: 'Name', alignment: 'left' },
73
77
  { name: 'Tag', alignment: 'left' },
74
78
  { name: 'Size', alignment: 'right' },
75
79
  { name: 'Files', alignment: 'right' },
@@ -1,9 +1,12 @@
1
1
  import { z } from 'zod';
2
2
  import { createCommand } from '../../../../types';
3
3
  import * as tui from '../../../../tui';
4
- import { createSandboxClient } from '../util';
5
4
  import { getCommand } from '../../../../command-prefix';
6
5
  import { snapshotTag } from '@agentuity/server';
6
+ import { getGlobalCatalystAPIClient } from '../../../../config';
7
+
8
+ const SNAPSHOT_TAG_REGEX = /^[a-zA-Z0-9_][a-zA-Z0-9._-]*$/;
9
+ const MAX_SNAPSHOT_TAG_LENGTH = 128;
7
10
 
8
11
  const SnapshotTagResponseSchema = z.object({
9
12
  snapshotId: z.string().describe('Snapshot ID'),
@@ -14,7 +17,7 @@ export const tagSubcommand = createCommand({
14
17
  name: 'tag',
15
18
  description: 'Add or update a tag on a snapshot',
16
19
  tags: ['slow', 'requires-auth'],
17
- requires: { auth: true, region: true, org: true },
20
+ requires: { auth: true, org: true },
18
21
  examples: [
19
22
  {
20
23
  command: getCommand('cloud sandbox snapshot tag snp_abc123 latest'),
@@ -37,13 +40,26 @@ export const tagSubcommand = createCommand({
37
40
  },
38
41
 
39
42
  async handler(ctx) {
40
- const { args, opts, options, auth, region, logger, orgId } = ctx;
41
- const client = createSandboxClient(logger, auth, region);
43
+ const { args, opts, options, auth, logger, orgId, config } = ctx;
44
+ const client = await getGlobalCatalystAPIClient(logger, auth, config?.name);
42
45
 
43
46
  if (!args.tag && !opts.clear) {
44
47
  throw new Error('Either provide a tag name or use --clear to remove the tag');
45
48
  }
46
49
 
50
+ if (args.tag) {
51
+ if (args.tag.length > MAX_SNAPSHOT_TAG_LENGTH) {
52
+ logger.fatal(
53
+ `Invalid snapshot tag: must be at most ${MAX_SNAPSHOT_TAG_LENGTH} characters`
54
+ );
55
+ }
56
+ if (!SNAPSHOT_TAG_REGEX.test(args.tag)) {
57
+ logger.fatal(
58
+ 'Invalid snapshot tag: must only contain letters, numbers, dashes, underscores, and dots, and cannot start with a period or dash'
59
+ );
60
+ }
61
+ }
62
+
47
63
  const tag = opts.clear ? null : (args.tag ?? null);
48
64
 
49
65
  const snapshot = await snapshotTag(client, {
@@ -2,7 +2,7 @@ import { z } from 'zod';
2
2
  import { readFileSync, statSync } from 'node:fs';
3
3
  import { createCommand } from '../../../types';
4
4
  import * as tui from '../../../tui';
5
- import { createSandboxClient } from './util';
5
+ import { createSandboxClient, getSandboxRegion } from './util';
6
6
  import { getCommand } from '../../../command-prefix';
7
7
  import { sandboxUploadArchive } from '@agentuity/server';
8
8
 
@@ -11,7 +11,7 @@ export const uploadSubcommand = createCommand({
11
11
  aliases: ['ul'],
12
12
  description: 'Upload a compressed archive to a sandbox and extract it',
13
13
  tags: ['slow', 'requires-auth'],
14
- requires: { auth: true, region: true, org: true },
14
+ requires: { auth: true, org: true },
15
15
  examples: [
16
16
  {
17
17
  command: getCommand('cloud sandbox upload sbx_abc123 ./archive.tar.gz'),
@@ -45,8 +45,9 @@ export const uploadSubcommand = createCommand({
45
45
  },
46
46
 
47
47
  async handler(ctx) {
48
- const { args, opts, options, auth, region, logger, orgId } = ctx;
48
+ const { args, opts, options, auth, logger, orgId, config } = ctx;
49
49
 
50
+ const region = await getSandboxRegion(logger, auth, config?.name, args.sandboxId, orgId);
50
51
  const client = createSandboxClient(logger, auth, region);
51
52
 
52
53
  const stat = statSync(args.archive);
@@ -1,14 +1,73 @@
1
1
  import { existsSync, readFileSync } from 'node:fs';
2
2
  import { resolve } from 'node:path';
3
3
  import type { Logger, FileToWrite } from '@agentuity/core';
4
- import { APIClient, getServiceUrls } from '@agentuity/server';
4
+ import { APIClient, getServiceUrls, sandboxGet } from '@agentuity/server';
5
5
  import type { AuthData } from '../../../types';
6
+ import { getGlobalCatalystAPIClient } from '../../../config';
7
+ import { getResourceRegion, setResourceRegion, deleteResourceRegion } from '../../../cache';
8
+ import * as tui from '../../../tui';
9
+ import { ErrorCode } from '../../../errors';
6
10
 
7
11
  export function createSandboxClient(logger: Logger, auth: AuthData, region: string): APIClient {
8
12
  const urls = getServiceUrls(region);
9
13
  return new APIClient(urls.catalyst, logger, auth.apiKey);
10
14
  }
11
15
 
16
+ /**
17
+ * Look up the region for a sandbox, using cache-first strategy.
18
+ * Falls back to API lookup if not in cache.
19
+ */
20
+ export async function getSandboxRegion(
21
+ logger: Logger,
22
+ auth: AuthData,
23
+ profileName = 'production',
24
+ sandboxId: string,
25
+ orgId: string
26
+ ): Promise<string> {
27
+ // Check cache first
28
+ const cachedRegion = await getResourceRegion('sandbox', profileName, sandboxId);
29
+ if (cachedRegion) {
30
+ logger.trace(`[sandbox] Found cached region for ${sandboxId}: ${cachedRegion}`);
31
+ return cachedRegion;
32
+ }
33
+
34
+ // Fallback to API lookup using global client
35
+ logger.trace(`[sandbox] Cache miss for ${sandboxId}, fetching from API`);
36
+ const globalClient = await getGlobalCatalystAPIClient(logger, auth, profileName);
37
+
38
+ const sandbox = await sandboxGet(globalClient, { sandboxId, orgId });
39
+ if (!sandbox.region) {
40
+ tui.fatal(`Sandbox '${sandboxId}' has no region information`, ErrorCode.RESOURCE_NOT_FOUND);
41
+ }
42
+
43
+ // Cache the result
44
+ await setResourceRegion('sandbox', profileName, sandboxId, sandbox.region);
45
+ logger.trace(`[sandbox] Cached region for ${sandboxId}: ${sandbox.region}`);
46
+
47
+ return sandbox.region;
48
+ }
49
+
50
+ /**
51
+ * Cache the region for a sandbox after create/run operations
52
+ */
53
+ export async function cacheSandboxRegion(
54
+ profileName = 'production',
55
+ sandboxId: string,
56
+ region: string
57
+ ): Promise<void> {
58
+ await setResourceRegion('sandbox', profileName, sandboxId, region);
59
+ }
60
+
61
+ /**
62
+ * Clear cached region for a sandbox after delete
63
+ */
64
+ export async function clearSandboxRegionCache(
65
+ profileName = 'production',
66
+ sandboxId: string
67
+ ): Promise<void> {
68
+ await deleteResourceRegion('sandbox', profileName, sandboxId);
69
+ }
70
+
12
71
  /**
13
72
  * Parse --file arguments and read file contents.
14
73
  *
@@ -3,6 +3,7 @@ import { createSubcommand } from '../../../types';
3
3
  import * as tui from '../../../tui';
4
4
  import { getIONHost } from '../../../config';
5
5
  import { getCommand } from '../../../command-prefix';
6
+ import { getIdentifierRegion } from '../region-lookup';
6
7
  const args = z.object({
7
8
  source: z.string().describe('the source file'),
8
9
  destination: z.string().optional().describe('the destination file'),
@@ -36,7 +37,7 @@ export const downloadCommand = createSubcommand({
36
37
  description: 'Download multiple files',
37
38
  },
38
39
  ],
39
- requires: { apiClient: true, auth: true, region: true },
40
+ requires: { apiClient: true, auth: true },
40
41
  optional: { project: true },
41
42
  prerequisites: ['cloud deploy'],
42
43
  schema: {
@@ -51,7 +52,7 @@ export const downloadCommand = createSubcommand({
51
52
  },
52
53
 
53
54
  async handler(ctx) {
54
- const { apiClient, args, opts, project, projectDir, config, region } = ctx;
55
+ const { apiClient, args, opts, project, projectDir, config, logger, auth, orgId } = ctx;
55
56
 
56
57
  let identifier = opts?.identifier ?? project?.projectId;
57
58
 
@@ -59,6 +60,17 @@ export const downloadCommand = createSubcommand({
59
60
  identifier = await tui.showProjectList(apiClient, true);
60
61
  }
61
62
 
63
+ // Look up region from identifier (project/deployment)
64
+ const profileName = config?.name;
65
+ const region = await getIdentifierRegion(
66
+ logger,
67
+ auth,
68
+ apiClient,
69
+ profileName,
70
+ identifier,
71
+ orgId
72
+ );
73
+
62
74
  const hostname = getIONHost(config, region);
63
75
  const destination = args.destination ?? projectDir;
64
76
 
@@ -3,6 +3,7 @@ import { createSubcommand } from '../../../types';
3
3
  import * as tui from '../../../tui';
4
4
  import { getIONHost } from '../../../config';
5
5
  import { getCommand } from '../../../command-prefix';
6
+ import { getIdentifierRegion } from '../region-lookup';
6
7
  const args = z.object({
7
8
  source: z.string().describe('the source file'),
8
9
  destination: z
@@ -39,7 +40,7 @@ export const uploadCommand = createSubcommand({
39
40
  description: 'Upload multiple files',
40
41
  },
41
42
  ],
42
- requires: { apiClient: true, auth: true, region: true },
43
+ requires: { apiClient: true, auth: true },
43
44
  schema: {
44
45
  args,
45
46
  options,
@@ -54,7 +55,7 @@ export const uploadCommand = createSubcommand({
54
55
  prerequisites: ['cloud deploy'],
55
56
 
56
57
  async handler(ctx) {
57
- const { apiClient, args, opts, project, projectDir, config, region } = ctx;
58
+ const { apiClient, args, opts, project, projectDir, config, logger, auth, orgId } = ctx;
58
59
 
59
60
  let identifier = opts?.identifier ?? project?.projectId;
60
61
 
@@ -62,6 +63,17 @@ export const uploadCommand = createSubcommand({
62
63
  identifier = await tui.showProjectList(apiClient, true);
63
64
  }
64
65
 
66
+ // Look up region from identifier (project/deployment)
67
+ const profileName = config?.name;
68
+ const region = await getIdentifierRegion(
69
+ logger,
70
+ auth,
71
+ apiClient,
72
+ profileName,
73
+ identifier,
74
+ orgId
75
+ );
76
+
65
77
  const hostname = getIONHost(config, region);
66
78
  const destination = args.destination ?? '.';
67
79
 
@@ -10,7 +10,7 @@ import {
10
10
  } from '@agentuity/server';
11
11
  import { getCommand } from '../../../command-prefix';
12
12
  import { ErrorCode } from '../../../errors';
13
- import { getCatalystAPIClient } from '../../../config';
13
+ import { getGlobalCatalystAPIClient } from '../../../config';
14
14
 
15
15
  const SpanNodeSchema: z.ZodType<SpanNode> = z.lazy(() =>
16
16
  z.object({
@@ -116,7 +116,7 @@ export const getSubcommand = createSubcommand({
116
116
  description: 'Get a session by ID',
117
117
  },
118
118
  ],
119
- requires: { auth: true, region: true },
119
+ requires: { auth: true },
120
120
  idempotent: true,
121
121
  schema: {
122
122
  args: z.object({
@@ -125,8 +125,8 @@ export const getSubcommand = createSubcommand({
125
125
  response: SessionGetResponseSchema,
126
126
  },
127
127
  async handler(ctx) {
128
- const { logger, auth, args, options, region } = ctx;
129
- const catalystClient = getCatalystAPIClient(logger, auth, region);
128
+ const { logger, auth, args, options, config } = ctx;
129
+ const catalystClient = await getGlobalCatalystAPIClient(logger, auth, config?.name);
130
130
 
131
131
  try {
132
132
  const enriched = await sessionGet(catalystClient, { id: args.session_id });
@@ -4,7 +4,7 @@ import * as tui from '../../../tui';
4
4
  import { sessionList } from '@agentuity/server';
5
5
  import { getCommand } from '../../../command-prefix';
6
6
  import { ErrorCode } from '../../../errors';
7
- import { getCatalystAPIClient } from '../../../config';
7
+ import { getGlobalCatalystAPIClient } from '../../../config';
8
8
 
9
9
  const SessionListResponseSchema = z.array(
10
10
  z.object({
@@ -55,7 +55,7 @@ export const listSubcommand = createSubcommand({
55
55
  },
56
56
  ],
57
57
  aliases: ['ls'],
58
- requires: { auth: true, region: true },
58
+ requires: { auth: true },
59
59
  optional: { project: true },
60
60
  idempotent: true,
61
61
  pagination: {
@@ -93,8 +93,8 @@ export const listSubcommand = createSubcommand({
93
93
  return projectId ? `/projects/${encodeURIComponent(projectId)}/sessions` : undefined;
94
94
  },
95
95
  async handler(ctx) {
96
- const { logger, auth, project, opts, options, region } = ctx;
97
- const catalystClient = getCatalystAPIClient(logger, auth, region);
96
+ const { logger, auth, project, opts, options, config } = ctx;
97
+ const catalystClient = await getGlobalCatalystAPIClient(logger, auth, config?.name);
98
98
 
99
99
  const projectId = opts.projectId || project?.projectId;
100
100
 
@@ -3,6 +3,7 @@ import { createSubcommand } from '../../types';
3
3
  import * as tui from '../../tui';
4
4
  import { getIONHost } from '../../config';
5
5
  import { getCommand } from '../../command-prefix';
6
+ import { getIdentifierRegion } from './region-lookup';
6
7
  const args = z.object({
7
8
  identifier: z.string().optional().describe('The project, deployment, or sandbox id to use'),
8
9
  command: z.string().optional().describe('The command to run'),
@@ -39,13 +40,13 @@ export const sshSubcommand = createSubcommand({
39
40
  },
40
41
  ],
41
42
  toplevel: true,
42
- requires: { auth: true, apiClient: true, region: true },
43
+ requires: { auth: true, apiClient: true },
43
44
  optional: { project: true },
44
45
  prerequisites: ['cloud deploy'],
45
46
  schema: { args, options },
46
47
 
47
48
  async handler(ctx) {
48
- const { apiClient, project, projectDir, args, config, opts, region } = ctx;
49
+ const { apiClient, project, projectDir, args, config, opts, logger, auth, orgId } = ctx;
49
50
 
50
51
  let projectId = project?.projectId;
51
52
  let identifier = args?.identifier;
@@ -66,6 +67,18 @@ export const sshSubcommand = createSubcommand({
66
67
  projectId = await tui.showProjectList(apiClient, true);
67
68
  }
68
69
 
70
+ // Look up region from identifier (project/deployment/sandbox)
71
+ const profileName = config?.name;
72
+ const targetIdentifier = identifier ?? projectId!;
73
+ const region = await getIdentifierRegion(
74
+ logger,
75
+ auth,
76
+ apiClient,
77
+ profileName,
78
+ targetIdentifier,
79
+ orgId
80
+ );
81
+
69
82
  const hostname = getIONHost(config, region);
70
83
 
71
84
  const cmd = ['ssh', `${identifier ?? projectId}@${hostname}`, command].filter(
@@ -1,14 +1,15 @@
1
1
  import { z } from 'zod';
2
- import { listResources, deleteResources } from '@agentuity/server';
2
+ import { listOrgResources, deleteResources } from '@agentuity/server';
3
3
  import enquirer from 'enquirer';
4
4
  import { createSubcommand } from '../../../types';
5
5
  import * as tui from '../../../tui';
6
- import { getCatalystAPIClient } from '../../../config';
6
+ import { getGlobalCatalystAPIClient, getCatalystAPIClient } from '../../../config';
7
7
  import { getCommand } from '../../../command-prefix';
8
8
  import { isDryRunMode, outputDryRun } from '../../../explain';
9
9
  import { ErrorCode } from '../../../errors';
10
10
  import { createS3Client } from './utils';
11
11
  import { removeResourceEnvVars } from '../../../env-util';
12
+ import { getResourceInfo, setResourceInfo, deleteResourceRegion } from '../../../cache';
12
13
 
13
14
  export const deleteSubcommand = createSubcommand({
14
15
  name: 'delete',
@@ -16,7 +17,8 @@ export const deleteSubcommand = createSubcommand({
16
17
  description: 'Delete a storage resource or file',
17
18
  tags: ['destructive', 'deletes-resource', 'slow', 'requires-auth', 'requires-deployment'],
18
19
  idempotent: false,
19
- requires: { auth: true, org: true, region: true },
20
+ requires: { auth: true },
21
+ optional: { org: true },
20
22
  examples: [
21
23
  {
22
24
  command: getCommand('cloud storage delete my-bucket'),
@@ -50,19 +52,50 @@ export const deleteSubcommand = createSubcommand({
50
52
  },
51
53
 
52
54
  async handler(ctx) {
53
- const { logger, args, opts, orgId, region, auth, options } = ctx;
55
+ const { logger, args, opts, auth, options, config } = ctx;
54
56
 
55
- const catalystClient = getCatalystAPIClient(logger, auth, region);
57
+ const profileName = config?.name ?? 'production';
58
+ const catalystClient = await getGlobalCatalystAPIClient(logger, auth, profileName);
59
+
60
+ let bucketName = args.name;
61
+
62
+ // If bucket name provided, try cache first for orgId
63
+ let orgId = ctx.orgId;
64
+ if (bucketName && !orgId) {
65
+ const cachedInfo = await getResourceInfo('bucket', profileName, bucketName);
66
+ orgId = cachedInfo?.orgId;
67
+ }
68
+
69
+ // For interactive selection (no bucket name), we need orgId
70
+ if (!bucketName && !orgId) {
71
+ tui.fatal(
72
+ 'Organization required for interactive bucket selection. Specify --org-id or provide bucket name.',
73
+ ErrorCode.INVALID_ARGUMENT
74
+ );
75
+ }
76
+
77
+ // If we still don't have orgId and have a bucket name, error out
78
+ if (!orgId) {
79
+ tui.fatal(
80
+ `Organization not found for bucket '${bucketName}'. Run 'agentuity cloud storage list' first or specify --org-id.`,
81
+ ErrorCode.INVALID_ARGUMENT
82
+ );
83
+ }
56
84
 
57
85
  const resources = await tui.spinner({
58
- message: `Fetching storage for ${orgId} in ${region}`,
86
+ message: `Fetching storage for ${orgId}`,
59
87
  clearOnSuccess: true,
60
88
  callback: async () => {
61
- return listResources(catalystClient, orgId, region!);
89
+ return listOrgResources(catalystClient, { type: 's3', orgId });
62
90
  },
63
91
  });
64
92
 
65
- let bucketName = args.name;
93
+ // Cache all fetched buckets
94
+ for (const s3 of resources.s3) {
95
+ if (s3.cloud_region) {
96
+ await setResourceInfo('bucket', profileName, s3.bucket_name, s3.cloud_region, orgId);
97
+ }
98
+ }
66
99
 
67
100
  if (!bucketName) {
68
101
  if (resources.s3.length === 0) {
@@ -155,9 +188,22 @@ export const deleteSubcommand = createSubcommand({
155
188
  }
156
189
 
157
190
  // Otherwise, delete the bucket
191
+ // Find the bucket to get its region
192
+ const bucketToDelete = resources.s3.find((s3) => s3.bucket_name === bucketName);
193
+ if (!bucketToDelete) {
194
+ tui.fatal(`Storage bucket '${bucketName}' not found`, ErrorCode.RESOURCE_NOT_FOUND);
195
+ }
196
+ if (!bucketToDelete.cloud_region) {
197
+ tui.fatal(
198
+ `Storage bucket '${bucketName}' is missing region information`,
199
+ ErrorCode.RESOURCE_NOT_FOUND
200
+ );
201
+ }
202
+ const region = bucketToDelete.cloud_region;
203
+
158
204
  // Handle dry-run mode
159
205
  if (isDryRunMode(options)) {
160
- outputDryRun(`Would delete storage bucket: ${bucketName}`, options);
206
+ outputDryRun(`Would delete storage bucket: ${bucketName} (region: ${region})`, options);
161
207
  if (!options.json) {
162
208
  tui.newline();
163
209
  tui.info('[DRY RUN] Storage bucket deletion skipped');
@@ -184,11 +230,13 @@ export const deleteSubcommand = createSubcommand({
184
230
  }
185
231
  }
186
232
 
233
+ // Use regional client for the delete operation
234
+ const regionalClient = getCatalystAPIClient(logger, auth, region);
187
235
  const deleted = await tui.spinner({
188
236
  message: `Deleting storage bucket ${bucketName}`,
189
237
  clearOnSuccess: true,
190
238
  callback: async () => {
191
- return deleteResources(catalystClient, orgId, region!, [
239
+ return deleteResources(regionalClient, orgId, region, [
192
240
  { type: 's3', name: bucketName },
193
241
  ]);
194
242
  },
@@ -197,6 +245,9 @@ export const deleteSubcommand = createSubcommand({
197
245
  if (deleted.length > 0) {
198
246
  const resource = deleted[0];
199
247
 
248
+ // Clear cache entry for deleted bucket
249
+ await deleteResourceRegion('bucket', profileName, resource.name);
250
+
200
251
  // Remove env vars from .env if running inside a project
201
252
  if (ctx.projectDir && resource.env_keys.length > 0) {
202
253
  await removeResourceEnvVars(ctx.projectDir, resource.env_keys);
@@ -1,17 +1,19 @@
1
1
  import { z } from 'zod';
2
- import { listResources } from '@agentuity/server';
2
+ import { listOrgResources } from '@agentuity/server';
3
3
  import { createSubcommand } from '../../../types';
4
4
  import * as tui from '../../../tui';
5
- import { getCatalystAPIClient } from '../../../config';
5
+ import { getGlobalCatalystAPIClient } from '../../../config';
6
6
  import { getCommand } from '../../../command-prefix';
7
7
  import { ErrorCode } from '../../../errors';
8
8
  import { createS3Client } from './utils';
9
+ import { getResourceInfo, setResourceInfo } from '../../../cache';
9
10
 
10
11
  export const downloadSubcommand = createSubcommand({
11
12
  name: 'download',
12
13
  description: 'Download a file from storage bucket',
13
14
  tags: ['read-only', 'requires-auth'],
14
- requires: { auth: true, org: true, region: true },
15
+ requires: { auth: true },
16
+ optional: { org: true },
15
17
  idempotent: true,
16
18
  examples: [
17
19
  {
@@ -51,21 +53,44 @@ export const downloadSubcommand = createSubcommand({
51
53
  },
52
54
 
53
55
  async handler(ctx) {
54
- const { logger, args, opts, options, orgId, region, auth } = ctx;
56
+ const { logger, args, opts, options, auth, config } = ctx;
55
57
 
56
- const catalystClient = getCatalystAPIClient(logger, auth, region);
58
+ const profileName = config?.name ?? 'production';
59
+ const catalystClient = await getGlobalCatalystAPIClient(logger, auth, profileName);
60
+
61
+ // Check cache first for orgId
62
+ const cachedInfo = await getResourceInfo('bucket', profileName, args.name);
63
+ const orgId = ctx.orgId ?? cachedInfo?.orgId;
64
+
65
+ if (!orgId) {
66
+ tui.fatal(
67
+ `Organization not found for bucket '${args.name}'. Run 'agentuity cloud storage list' first or specify --org-id.`,
68
+ ErrorCode.INVALID_ARGUMENT
69
+ );
70
+ }
57
71
 
58
72
  // Fetch bucket credentials
59
73
  const resources = await tui.spinner({
60
74
  message: `Fetching credentials for ${args.name}`,
61
75
  clearOnSuccess: true,
62
76
  callback: async () => {
63
- return listResources(catalystClient, orgId, region);
77
+ return listOrgResources(catalystClient, { type: 's3', orgId });
64
78
  },
65
79
  });
66
80
 
67
81
  const bucket = resources.s3.find((s3) => s3.bucket_name === args.name);
68
82
 
83
+ // Cache the bucket info for future lookups
84
+ if (bucket?.cloud_region) {
85
+ await setResourceInfo(
86
+ 'bucket',
87
+ profileName,
88
+ bucket.bucket_name,
89
+ bucket.cloud_region,
90
+ orgId
91
+ );
92
+ }
93
+
69
94
  if (!bucket) {
70
95
  tui.fatal(`Storage bucket '${args.name}' not found`, ErrorCode.RESOURCE_NOT_FOUND);
71
96
  }