@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,10 +1,11 @@
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
+ import { getResourceInfo, setResourceInfo } from '../../../cache';
8
9
 
9
10
  const StorageGetResponseSchema = z.object({
10
11
  bucket_name: z.string().describe('Storage bucket name'),
@@ -19,7 +20,8 @@ export const getSubcommand = createSubcommand({
19
20
  aliases: ['show'],
20
21
  description: 'Show details about a specific storage bucket',
21
22
  tags: ['read-only', 'fast', 'requires-auth'],
22
- requires: { auth: true, org: true, region: true },
23
+ requires: { auth: true },
24
+ optional: { org: true },
23
25
  idempotent: true,
24
26
  examples: [
25
27
  {
@@ -52,20 +54,43 @@ export const getSubcommand = createSubcommand({
52
54
  webUrl: (ctx) => `/services/storage/${encodeURIComponent(ctx.args.name)}`,
53
55
 
54
56
  async handler(ctx) {
55
- const { logger, args, opts, options, orgId, region, auth } = ctx;
57
+ const { logger, args, opts, options, auth, config } = ctx;
56
58
 
57
- const catalystClient = getCatalystAPIClient(logger, auth, region);
59
+ const profileName = config?.name ?? 'production';
60
+ const catalystClient = await getGlobalCatalystAPIClient(logger, auth, profileName);
61
+
62
+ // Check cache first for orgId
63
+ const cachedInfo = await getResourceInfo('bucket', profileName, args.name);
64
+ const orgId = ctx.orgId ?? cachedInfo?.orgId;
65
+
66
+ if (!orgId) {
67
+ tui.fatal(
68
+ `Organization not found for bucket '${args.name}'. Run 'agentuity cloud storage list' first or specify --org-id.`,
69
+ ErrorCode.INVALID_ARGUMENT
70
+ );
71
+ }
58
72
 
59
73
  const resources = await tui.spinner({
60
74
  message: `Fetching storage bucket ${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
  }
@@ -1,11 +1,12 @@
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 { setResourceInfo } from '../../../cache';
9
10
 
10
11
  const StorageListResponseSchema = z.object({
11
12
  buckets: z
@@ -16,6 +17,7 @@ const StorageListResponseSchema = z.object({
16
17
  secret_key: z.string().optional().describe('S3 secret key'),
17
18
  region: z.string().optional().describe('S3 region'),
18
19
  endpoint: z.string().optional().describe('S3 endpoint URL'),
20
+ cloud_region: z.string().optional().describe('Cloud region where bucket is hosted'),
19
21
  })
20
22
  )
21
23
  .optional()
@@ -37,7 +39,7 @@ export const listSubcommand = createSubcommand({
37
39
  aliases: ['ls'],
38
40
  description: 'List storage resources or files in a bucket',
39
41
  tags: ['read-only', 'fast', 'requires-auth'],
40
- requires: { auth: true, org: true, region: true },
42
+ requires: { auth: true, org: true },
41
43
  idempotent: true,
42
44
  examples: [
43
45
  { command: getCommand('cloud storage list'), description: 'List items' },
@@ -78,18 +80,26 @@ export const listSubcommand = createSubcommand({
78
80
  : '/services/storage',
79
81
 
80
82
  async handler(ctx) {
81
- const { logger, args, opts, options, orgId, region, auth } = ctx;
83
+ const { logger, args, opts, options, orgId, auth, config } = ctx;
82
84
 
83
- const catalystClient = getCatalystAPIClient(logger, auth, region);
85
+ const catalystClient = await getGlobalCatalystAPIClient(logger, auth, config?.name);
84
86
 
87
+ const profileName = config?.name ?? 'production';
85
88
  const resources = await tui.spinner({
86
- message: `Fetching storage for ${orgId} in ${region}`,
89
+ message: `Fetching storage for ${orgId}`,
87
90
  clearOnSuccess: true,
88
91
  callback: async () => {
89
- return listResources(catalystClient, orgId, region);
92
+ return listOrgResources(catalystClient, { type: 's3', orgId });
90
93
  },
91
94
  });
92
95
 
96
+ // Cache each bucket with its region and orgId for future lookups
97
+ for (const s3 of resources.s3) {
98
+ if (s3.cloud_region) {
99
+ await setResourceInfo('bucket', profileName, s3.bucket_name, s3.cloud_region, orgId);
100
+ }
101
+ }
102
+
93
103
  // If bucket name is provided, list files in the bucket
94
104
  if (args.name) {
95
105
  const bucket = resources.s3.find((s3) => s3.bucket_name === args.name);
@@ -219,6 +229,7 @@ export const listSubcommand = createSubcommand({
219
229
  secret_key: s3.secret_key ?? undefined,
220
230
  region: s3.region ?? undefined,
221
231
  endpoint: s3.endpoint ?? undefined,
232
+ cloud_region: s3.cloud_region,
222
233
  })),
223
234
  };
224
235
  },
@@ -1,19 +1,21 @@
1
1
  import { z } from 'zod';
2
2
  import { basename } from 'path';
3
- import { listResources } from '@agentuity/server';
3
+ import { listOrgResources } from '@agentuity/server';
4
4
  import { createSubcommand } from '../../../types';
5
5
  import * as tui from '../../../tui';
6
- import { getCatalystAPIClient } from '../../../config';
6
+ import { getGlobalCatalystAPIClient } from '../../../config';
7
7
  import { getCommand } from '../../../command-prefix';
8
8
  import { ErrorCode } from '../../../errors';
9
9
  import { createS3Client } from './utils';
10
+ import { getResourceInfo, setResourceInfo } from '../../../cache';
10
11
 
11
12
  export const uploadSubcommand = createSubcommand({
12
13
  name: 'upload',
13
14
  aliases: ['put'],
14
15
  description: 'Upload a file to storage bucket',
15
16
  tags: ['write', 'requires-auth'],
16
- requires: { auth: true, org: true, region: true },
17
+ requires: { auth: true },
18
+ optional: { org: true },
17
19
  idempotent: false,
18
20
  examples: [
19
21
  {
@@ -61,21 +63,44 @@ export const uploadSubcommand = createSubcommand({
61
63
  },
62
64
 
63
65
  async handler(ctx) {
64
- const { logger, args, opts, options, orgId, region, auth } = ctx;
66
+ const { logger, args, opts, options, auth, config } = ctx;
65
67
 
66
- const catalystClient = getCatalystAPIClient(logger, auth, region);
68
+ const profileName = config?.name ?? 'production';
69
+ const catalystClient = await getGlobalCatalystAPIClient(logger, auth, profileName);
70
+
71
+ // Check cache first for orgId
72
+ const cachedInfo = await getResourceInfo('bucket', profileName, args.name);
73
+ const orgId = ctx.orgId ?? cachedInfo?.orgId;
74
+
75
+ if (!orgId) {
76
+ tui.fatal(
77
+ `Organization not found for bucket '${args.name}'. Run 'agentuity cloud storage list' first or specify --org-id.`,
78
+ ErrorCode.INVALID_ARGUMENT
79
+ );
80
+ }
67
81
 
68
82
  // Fetch bucket credentials
69
83
  const resources = await tui.spinner({
70
84
  message: `Fetching credentials for ${args.name}`,
71
85
  clearOnSuccess: true,
72
86
  callback: async () => {
73
- return listResources(catalystClient, orgId, region);
87
+ return listOrgResources(catalystClient, { type: 's3', orgId });
74
88
  },
75
89
  });
76
90
 
77
91
  const bucket = resources.s3.find((s3) => s3.bucket_name === args.name);
78
92
 
93
+ // Cache the bucket info for future lookups
94
+ if (bucket?.cloud_region) {
95
+ await setResourceInfo(
96
+ 'bucket',
97
+ profileName,
98
+ bucket.bucket_name,
99
+ bucket.cloud_region,
100
+ orgId
101
+ );
102
+ }
103
+
79
104
  if (!bucket) {
80
105
  tui.fatal(`Storage bucket '${args.name}' not found`, ErrorCode.RESOURCE_NOT_FOUND);
81
106
  }
@@ -4,7 +4,7 @@ import * as tui from '../../../tui';
4
4
  import { threadDelete, APIError } 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
  export const deleteSubcommand = createSubcommand({
10
10
  name: 'delete',
@@ -17,15 +17,15 @@ export const deleteSubcommand = createSubcommand({
17
17
  },
18
18
  ],
19
19
  aliases: ['rm'],
20
- requires: { auth: true, region: true },
20
+ requires: { auth: true },
21
21
  schema: {
22
22
  args: z.object({
23
23
  thread_id: z.string().describe('Thread ID'),
24
24
  }),
25
25
  },
26
26
  async handler(ctx) {
27
- const { logger, auth, args, region } = ctx;
28
- const catalystClient = getCatalystAPIClient(logger, auth, region);
27
+ const { logger, auth, args, config } = ctx;
28
+ const catalystClient = await getGlobalCatalystAPIClient(logger, auth, config?.name);
29
29
 
30
30
  try {
31
31
  await threadDelete(catalystClient, { id: args.thread_id });
@@ -4,7 +4,7 @@ import * as tui from '../../../tui';
4
4
  import { threadGet, APIError } 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 ThreadGetResponseSchema = z.object({
10
10
  id: z.string().describe('Thread ID'),
@@ -28,7 +28,7 @@ export const getSubcommand = createSubcommand({
28
28
  description: 'Get a thread by ID',
29
29
  },
30
30
  ],
31
- requires: { auth: true, region: true },
31
+ requires: { auth: true },
32
32
  idempotent: true,
33
33
  schema: {
34
34
  args: z.object({
@@ -37,8 +37,8 @@ export const getSubcommand = createSubcommand({
37
37
  response: ThreadGetResponseSchema,
38
38
  },
39
39
  async handler(ctx) {
40
- const { logger, auth, args, options, region } = ctx;
41
- const catalystClient = getCatalystAPIClient(logger, auth, region);
40
+ const { logger, auth, args, options, config } = ctx;
41
+ const catalystClient = await getGlobalCatalystAPIClient(logger, auth, config?.name);
42
42
 
43
43
  try {
44
44
  const thread = await threadGet(catalystClient, { id: args.thread_id });
@@ -4,7 +4,7 @@ import * as tui from '../../../tui';
4
4
  import { threadList, type Thread } 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 ThreadListResponseSchema = z.array(
10
10
  z.object({
@@ -36,7 +36,7 @@ export const listSubcommand = createSubcommand({
36
36
  },
37
37
  ],
38
38
  aliases: ['ls'],
39
- requires: { auth: true, region: true },
39
+ requires: { auth: true },
40
40
  optional: { project: true },
41
41
  idempotent: true,
42
42
  pagination: {
@@ -62,8 +62,8 @@ export const listSubcommand = createSubcommand({
62
62
  response: ThreadListResponseSchema,
63
63
  },
64
64
  async handler(ctx) {
65
- const { logger, auth, project, opts, options, region } = ctx;
66
- const catalystClient = getCatalystAPIClient(logger, auth, region);
65
+ const { logger, auth, project, opts, options, config } = ctx;
66
+ const catalystClient = await getGlobalCatalystAPIClient(logger, auth, config?.name);
67
67
 
68
68
  const projectId = opts.projectId || project?.projectId;
69
69
  const orgId = opts.orgId;
@@ -20,7 +20,7 @@ export const initSubcommand = createSubcommand({
20
20
  name: 'init',
21
21
  description: 'Set up Agentuity Auth for your project',
22
22
  tags: ['mutating', 'slow', 'requires-auth'],
23
- requires: { auth: true, org: true, region: true },
23
+ requires: { auth: true, org: true },
24
24
  idempotent: false,
25
25
  examples: [
26
26
  {
@@ -46,7 +46,7 @@ export const initSubcommand = createSubcommand({
46
46
  },
47
47
 
48
48
  async handler(ctx) {
49
- const { logger, opts, auth, orgId, region } = ctx;
49
+ const { logger, opts, auth, orgId, config } = ctx;
50
50
 
51
51
  tui.newline();
52
52
  tui.info(tui.bold('Agentuity Auth Setup'));
@@ -86,10 +86,14 @@ export const initSubcommand = createSubcommand({
86
86
  logger,
87
87
  auth,
88
88
  orgId,
89
- region,
89
+ config,
90
90
  existingUrl: databaseUrl,
91
+ projectDir,
91
92
  });
92
93
 
94
+ // Get the region from the selected database
95
+ const region = dbInfo.region;
96
+
93
97
  const databaseName = dbInfo.name;
94
98
 
95
99
  // Update .env with database URL
@@ -3,11 +3,17 @@
3
3
  */
4
4
 
5
5
  import * as path from 'node:path';
6
- import { listResources, createResources, dbQuery } from '@agentuity/server';
6
+ import { listOrgResources, createResources, dbQuery } from '@agentuity/server';
7
7
  import * as tui from '../../../tui';
8
- import { getCatalystAPIClient } from '../../../config';
8
+ import {
9
+ getCatalystAPIClient,
10
+ getGlobalCatalystAPIClient,
11
+ loadProjectConfig,
12
+ ProjectConfigNotFoundException,
13
+ } from '../../../config';
9
14
  import type { Logger } from '../../../types';
10
15
  import type { AuthData } from '../../../types';
16
+ import type { Config } from '../../../types';
11
17
  import enquirer from 'enquirer';
12
18
 
13
19
  /**
@@ -16,25 +22,29 @@ import enquirer from 'enquirer';
16
22
  export interface DatabaseInfo {
17
23
  name: string;
18
24
  url: string;
25
+ region: string;
19
26
  }
20
27
 
21
28
  /**
22
- * Select an existing database or create a new one
29
+ * Select an existing database or create a new one.
30
+ * When creating a new database, uses the project's region from agentuity.json if available.
23
31
  */
24
32
  export async function selectOrCreateDatabase(options: {
25
33
  logger: Logger;
26
34
  auth: AuthData;
27
35
  orgId: string;
28
- region: string;
36
+ config: Config | null;
29
37
  existingUrl?: string;
38
+ projectDir?: string;
30
39
  }): Promise<DatabaseInfo> {
31
- const { logger, auth, orgId, region, existingUrl } = options;
32
- const catalystClient = getCatalystAPIClient(logger, auth, region);
40
+ const { logger, auth, orgId, config, existingUrl, projectDir } = options;
41
+ const profileName = config?.name;
42
+ const globalClient = await getGlobalCatalystAPIClient(logger, auth, profileName);
33
43
 
34
44
  const resources = await tui.spinner({
35
- message: `Fetching databases for ${orgId} in ${region}`,
45
+ message: `Fetching databases for ${orgId}`,
36
46
  clearOnSuccess: true,
37
- callback: async () => listResources(catalystClient, orgId, region),
47
+ callback: async () => listOrgResources(globalClient, { type: 'db', orgId }),
38
48
  });
39
49
 
40
50
  const databases = resources.db;
@@ -81,14 +91,42 @@ export async function selectOrCreateDatabase(options: {
81
91
 
82
92
  // Handle "use existing" selection
83
93
  if (response.database === '__existing__' && existingUrl && existingDbName) {
84
- return { name: existingDbName, url: existingUrl };
94
+ // Find the database to get its region
95
+ const existingDb = databases.find((d) => d.name === existingDbName);
96
+ const region = existingDb?.cloud_region ?? 'usc';
97
+ return { name: existingDbName, url: existingUrl, region };
85
98
  }
86
99
 
87
100
  if (response.database === '__create__') {
101
+ // For creating a new database, determine the region:
102
+ // 1. Try to get from project's agentuity.json
103
+ // 2. Fall back to first existing database's region
104
+ // 3. Fall back to 'usc' as default
105
+ let region: string | undefined;
106
+
107
+ if (projectDir) {
108
+ try {
109
+ const projectConfig = await loadProjectConfig(projectDir, config);
110
+ region = projectConfig.region;
111
+ logger.trace(`[auth init] Using region from project config: ${region}`);
112
+ } catch (err) {
113
+ if (!(err instanceof ProjectConfigNotFoundException)) {
114
+ logger.trace(`[auth init] Error loading project config: ${err}`);
115
+ }
116
+ }
117
+ }
118
+
119
+ if (!region) {
120
+ region = databases.length > 0 ? databases[0].cloud_region : 'usc';
121
+ logger.trace(`[auth init] Using fallback region: ${region}`);
122
+ }
123
+
124
+ const regionalClient = getCatalystAPIClient(logger, auth, region);
125
+
88
126
  const created = await tui.spinner({
89
127
  message: `Creating database in ${region}`,
90
128
  clearOnSuccess: true,
91
- callback: async () => createResources(catalystClient, orgId, region, [{ type: 'db' }]),
129
+ callback: async () => createResources(regionalClient, orgId, region, [{ type: 'db' }]),
92
130
  });
93
131
 
94
132
  if (created.length === 0) {
@@ -98,14 +136,15 @@ export async function selectOrCreateDatabase(options: {
98
136
  const newDb = created[0];
99
137
  tui.success(`Created database: ${tui.bold(newDb.name)}`);
100
138
 
101
- const updatedResources = await listResources(catalystClient, orgId, region);
139
+ // Fetch updated list to get the URL
140
+ const updatedResources = await listOrgResources(globalClient, { type: 'db', orgId });
102
141
  const dbInfo = updatedResources.db.find((d) => d.name === newDb.name);
103
142
 
104
143
  if (!dbInfo?.url) {
105
144
  tui.fatal('Failed to retrieve database connection URL');
106
145
  }
107
146
 
108
- return { name: newDb.name, url: dbInfo.url };
147
+ return { name: newDb.name, url: dbInfo.url, region };
109
148
  }
110
149
 
111
150
  const selectedDb = databases.find((d) => d.name === response.database);
@@ -113,7 +152,7 @@ export async function selectOrCreateDatabase(options: {
113
152
  tui.fatal('Failed to retrieve database connection URL');
114
153
  }
115
154
 
116
- return { name: selectedDb.name, url: selectedDb.url };
155
+ return { name: selectedDb.name, url: selectedDb.url, region: selectedDb.cloud_region };
117
156
  }
118
157
 
119
158
  /**
package/src/config.ts CHANGED
@@ -21,6 +21,7 @@ import {
21
21
  getAuthFromKeychain,
22
22
  deleteAuthFromKeychain,
23
23
  } from './keychain';
24
+ import { clearProfileCache } from './cache';
24
25
 
25
26
  export const defaultProfileName = 'production';
26
27
 
@@ -330,6 +331,9 @@ export async function clearAuth(): Promise<void> {
330
331
  }
331
332
  }
332
333
 
334
+ // Clear resource cache for this profile
335
+ await clearProfileCache(profileName);
336
+
333
337
  // Also clear from config file (for backwards compatibility)
334
338
  if (config.auth) {
335
339
  delete config.auth;
@@ -381,6 +385,13 @@ export async function getAuth(): Promise<AuthData | null> {
381
385
  try {
382
386
  const keychainAuth = await getAuthFromKeychain(profileName);
383
387
  if (keychainAuth) {
388
+ // If there's auth api_key in the config file, remove it since we have it in keychain
389
+ if (config?.auth?.api_key) {
390
+ const { api_key: _, ...authWithoutApiKey } = config.auth;
391
+ const configCopy = { ...config, auth: authWithoutApiKey };
392
+ cachedConfig = null; // Force cache refresh
393
+ await saveConfig(configCopy);
394
+ }
384
395
  return {
385
396
  apiKey: keychainAuth.api_key,
386
397
  userId: keychainAuth.user_id,
@@ -499,13 +510,7 @@ export function generateYAMLTemplate(name: string): string {
499
510
  return lines.join('\n');
500
511
  }
501
512
 
502
- class ProjectConfigNotFoundExpection extends Error {
503
- public name: string;
504
- constructor() {
505
- super('project not found');
506
- this.name = 'ProjectConfigNotFoundExpection';
507
- }
508
- }
513
+ export const ProjectConfigNotFoundException = StructuredError('ProjectConfigNotFoundException');
509
514
 
510
515
  type ProjectConfig = z.infer<typeof ProjectSchema>;
511
516
 
@@ -529,7 +534,7 @@ export async function loadProjectConfig(
529
534
  // and then if so:
530
535
  // 1. if authentication, offer to import the project
531
536
  // 2. tell them that they need to login to use the command and import the project
532
- throw new ProjectConfigNotFoundExpection();
537
+ throw new ProjectConfigNotFoundException({ message: 'project config not found' });
533
538
  }
534
539
  const text = await file.text();
535
540
  const parsedConfig = JSON5.parse(text);
@@ -563,6 +568,16 @@ export async function createProjectConfig(dir: string, config: InitialProjectCon
563
568
  const configData = {
564
569
  $schema: 'https://agentuity.dev/schema/cli/v1/agentuity.json',
565
570
  ...sanitizedConfig,
571
+ deployment: {
572
+ ...sanitizedConfig.deployment,
573
+ resources: {
574
+ memory: '500Mi',
575
+ cpu: '500m',
576
+ disk: '500Mi',
577
+ ...sanitizedConfig.deployment?.resources,
578
+ },
579
+ domains: sanitizedConfig.deployment?.domains ?? [],
580
+ },
566
581
  };
567
582
  await Bun.write(configPath, JSON.stringify(configData, null, 2) + '\n');
568
583
 
@@ -697,6 +712,57 @@ export function getCatalystAPIClient(logger: Logger, auth: AuthData, region: str
697
712
  return new ServerAPIClient(catalystUrl, logger, auth.apiKey);
698
713
  }
699
714
 
715
+ interface RegionsCacheData {
716
+ timestamp: number;
717
+ regions: Array<{ region: string; description: string }>;
718
+ }
719
+
720
+ /**
721
+ * Get the default region using priority ordering:
722
+ * 1. AGENTUITY_REGION environment variable
723
+ * 2. First entry in region-{profile}.json (nearest region, sorted by distance)
724
+ * 3. 'local' for local profile, 'usc' otherwise
725
+ *
726
+ * Used for API calls that can hit any Catalyst instance (global database operations).
727
+ * Note: This is NOT called when --region flag is provided (handled at command level).
728
+ */
729
+ export async function getDefaultRegion(profileName = 'production'): Promise<string> {
730
+ // 1. Check environment variable first
731
+ if (process.env.AGENTUITY_REGION) {
732
+ return process.env.AGENTUITY_REGION;
733
+ }
734
+
735
+ // 2. Check cached regions file (sorted by distance)
736
+ try {
737
+ const cachePath = join(getDefaultConfigDir(), `regions-${profileName}.json`);
738
+ const file = Bun.file(cachePath);
739
+ if (await file.exists()) {
740
+ const data: RegionsCacheData = await file.json();
741
+ if (data.regions && data.regions.length > 0) {
742
+ return data.regions[0].region;
743
+ }
744
+ }
745
+ } catch {
746
+ // Fall through to default
747
+ }
748
+
749
+ // 3. Final fallback - 'local' for local profile, 'usc' otherwise
750
+ return profileName === 'local' ? 'local' : 'usc';
751
+ }
752
+
753
+ /**
754
+ * Get a Catalyst API client for global database operations.
755
+ * Uses the default region since the admin DB is global.
756
+ */
757
+ export async function getGlobalCatalystAPIClient(
758
+ logger: Logger,
759
+ auth: AuthData,
760
+ profileName = 'production'
761
+ ) {
762
+ const region = await getDefaultRegion(profileName);
763
+ return getCatalystAPIClient(logger, auth, region);
764
+ }
765
+
700
766
  export function getIONHost(config: Config | null, region: string) {
701
767
  if (config?.overrides?.ion_url) {
702
768
  const url = new URL(config.overrides.ion_url);
package/src/env-util.ts CHANGED
@@ -8,6 +8,42 @@ export interface EnvVars {
8
8
  [key: string]: string;
9
9
  }
10
10
 
11
+ /**
12
+ * Prefixes for public/frontend-exposed environment variables
13
+ */
14
+ export const PUBLIC_VAR_PREFIXES = ['VITE_', 'AGENTUITY_PUBLIC_', 'PUBLIC_'] as const;
15
+
16
+ /**
17
+ * Check if a key is a public variable (exposed to frontend)
18
+ */
19
+ export function isPublicVarKey(key: string): boolean {
20
+ const upperKey = key.toUpperCase();
21
+ return PUBLIC_VAR_PREFIXES.some((prefix) => upperKey.startsWith(prefix));
22
+ }
23
+
24
+ /**
25
+ * Check if a key is a reserved AGENTUITY key (except AGENTUITY_PUBLIC_)
26
+ */
27
+ export function isReservedAgentuityKey(key: string): boolean {
28
+ const upperKey = key.toUpperCase();
29
+ return upperKey.startsWith('AGENTUITY_') && !upperKey.startsWith('AGENTUITY_PUBLIC_');
30
+ }
31
+
32
+ /**
33
+ * Get public variable keys from secrets that should not be secrets
34
+ */
35
+ export function getPublicSecretKeys(secrets: EnvVars): string[] {
36
+ return Object.keys(secrets).filter(isPublicVarKey);
37
+ }
38
+
39
+ /**
40
+ * Validate that no public variables are being added as secrets
41
+ * Returns the list of invalid keys, or empty array if valid
42
+ */
43
+ export function validateNoPublicSecrets(secrets: EnvVars): string[] {
44
+ return getPublicSecretKeys(secrets);
45
+ }
46
+
11
47
  /**
12
48
  * Find an existing .env file for reading.
13
49
  */
@@ -162,14 +198,16 @@ export function mergeEnvVars(
162
198
  }
163
199
 
164
200
  /**
165
- * Filter out AGENTUITY_ prefixed keys from env vars
201
+ * Filter out reserved AGENTUITY_ prefixed keys from env vars
166
202
  * This is used when pushing to the cloud to avoid sending SDK keys
203
+ * Note: AGENTUITY_PUBLIC_* keys are allowed (they are public env vars)
167
204
  */
168
- export function filterAgentuitySdkKeys(vars: EnvVars): EnvVars {
205
+ export function filterAgentuitySdkKeys(vars?: EnvVars): EnvVars {
206
+ if (!vars) return {};
169
207
  const filtered: EnvVars = {};
170
208
 
171
209
  for (const [key, value] of Object.entries(vars)) {
172
- if (!key.startsWith('AGENTUITY_')) {
210
+ if (!isReservedAgentuityKey(key)) {
173
211
  filtered[key] = value;
174
212
  }
175
213
  }
@@ -186,6 +224,7 @@ const secretExactKeys = ['DATABASE_URL'];
186
224
  * Split env vars into env and secrets based on key names
187
225
  * Convention: Keys ending with _SECRET, _KEY, _TOKEN, _PASSWORD are secrets
188
226
  * Also treats DATABASE_URL as a secret since it contains credentials
227
+ * Note: Public vars (VITE_, AGENTUITY_PUBLIC_, PUBLIC_) always go to env, never secrets
189
228
  */
190
229
  export function splitEnvAndSecrets(vars: EnvVars): {
191
230
  env: EnvVars;
@@ -197,8 +236,14 @@ export function splitEnvAndSecrets(vars: EnvVars): {
197
236
  const secretSuffixes = ['_SECRET', '_KEY', '_TOKEN', '_PASSWORD', '_PRIVATE'];
198
237
 
199
238
  for (const [key, value] of Object.entries(vars)) {
200
- // Skip AGENTUITY_ prefixed keys
201
- if (key.startsWith('AGENTUITY_')) {
239
+ // Skip reserved AGENTUITY_ prefixed keys (except AGENTUITY_PUBLIC_)
240
+ if (isReservedAgentuityKey(key)) {
241
+ continue;
242
+ }
243
+
244
+ // Public vars always go to env, never secrets
245
+ if (isPublicVarKey(key)) {
246
+ env[key] = value;
202
247
  continue;
203
248
  }
204
249