@agentuity/cli 0.0.64 → 0.0.66

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 (216) hide show
  1. package/dist/api.d.ts +1 -0
  2. package/dist/api.d.ts.map +1 -1
  3. package/dist/api.js +12 -2
  4. package/dist/api.js.map +1 -1
  5. package/dist/cli.d.ts.map +1 -1
  6. package/dist/cli.js +5 -1
  7. package/dist/cli.js.map +1 -1
  8. package/dist/cmd/auth/signup.js +1 -1
  9. package/dist/cmd/auth/signup.js.map +1 -1
  10. package/dist/cmd/build/ast.d.ts.map +1 -1
  11. package/dist/cmd/build/ast.js +70 -4
  12. package/dist/cmd/build/ast.js.map +1 -1
  13. package/dist/cmd/build/ast.test.js +186 -1
  14. package/dist/cmd/build/ast.test.js.map +1 -1
  15. package/dist/cmd/build/bundler.d.ts +2 -24
  16. package/dist/cmd/build/bundler.d.ts.map +1 -1
  17. package/dist/cmd/build/bundler.js +24 -41
  18. package/dist/cmd/build/bundler.js.map +1 -1
  19. package/dist/cmd/build/index.d.ts.map +1 -1
  20. package/dist/cmd/build/index.js +14 -24
  21. package/dist/cmd/build/index.js.map +1 -1
  22. package/dist/cmd/build/plugin.d.ts.map +1 -1
  23. package/dist/cmd/build/plugin.js +13 -10
  24. package/dist/cmd/build/plugin.js.map +1 -1
  25. package/dist/cmd/build/workbench-templates.d.ts +1 -1
  26. package/dist/cmd/build/workbench-templates.d.ts.map +1 -1
  27. package/dist/cmd/build/workbench-templates.js +6 -19
  28. package/dist/cmd/build/workbench-templates.js.map +1 -1
  29. package/dist/cmd/cloud/apikey/create.d.ts.map +1 -1
  30. package/dist/cmd/cloud/apikey/create.js +7 -16
  31. package/dist/cmd/cloud/apikey/create.js.map +1 -1
  32. package/dist/cmd/cloud/db/create.d.ts.map +1 -1
  33. package/dist/cmd/cloud/db/create.js +4 -3
  34. package/dist/cmd/cloud/db/create.js.map +1 -1
  35. package/dist/cmd/cloud/db/delete.js +1 -1
  36. package/dist/cmd/cloud/db/delete.js.map +1 -1
  37. package/dist/cmd/cloud/db/get.d.ts.map +1 -1
  38. package/dist/cmd/cloud/db/get.js +73 -4
  39. package/dist/cmd/cloud/db/get.js.map +1 -1
  40. package/dist/cmd/cloud/db/index.d.ts.map +1 -1
  41. package/dist/cmd/cloud/db/index.js +9 -1
  42. package/dist/cmd/cloud/db/index.js.map +1 -1
  43. package/dist/cmd/cloud/db/list.js +1 -1
  44. package/dist/cmd/cloud/db/list.js.map +1 -1
  45. package/dist/cmd/cloud/db/logs.d.ts +2 -0
  46. package/dist/cmd/cloud/db/logs.d.ts.map +1 -0
  47. package/dist/cmd/cloud/db/logs.js +150 -0
  48. package/dist/cmd/cloud/db/logs.js.map +1 -0
  49. package/dist/cmd/cloud/db/sql.d.ts.map +1 -1
  50. package/dist/cmd/cloud/db/sql.js +17 -52
  51. package/dist/cmd/cloud/db/sql.js.map +1 -1
  52. package/dist/cmd/cloud/deploy.d.ts.map +1 -1
  53. package/dist/cmd/cloud/deploy.js +3 -2
  54. package/dist/cmd/cloud/deploy.js.map +1 -1
  55. package/dist/cmd/cloud/deployment/list.d.ts.map +1 -1
  56. package/dist/cmd/cloud/deployment/list.js +1 -1
  57. package/dist/cmd/cloud/deployment/list.js.map +1 -1
  58. package/dist/cmd/cloud/deployment/logs.d.ts.map +1 -1
  59. package/dist/cmd/cloud/deployment/logs.js +1 -1
  60. package/dist/cmd/cloud/deployment/logs.js.map +1 -1
  61. package/dist/cmd/cloud/deployment/remove.js +1 -1
  62. package/dist/cmd/cloud/deployment/remove.js.map +1 -1
  63. package/dist/cmd/cloud/deployment/rollback.js +1 -1
  64. package/dist/cmd/cloud/deployment/rollback.js.map +1 -1
  65. package/dist/cmd/cloud/deployment/show.js +1 -1
  66. package/dist/cmd/cloud/deployment/show.js.map +1 -1
  67. package/dist/cmd/cloud/deployment/undeploy.js +1 -1
  68. package/dist/cmd/cloud/deployment/undeploy.js.map +1 -1
  69. package/dist/cmd/cloud/keyvalue/util.d.ts +3 -0
  70. package/dist/cmd/cloud/keyvalue/util.d.ts.map +1 -1
  71. package/dist/cmd/cloud/keyvalue/util.js +4 -3
  72. package/dist/cmd/cloud/keyvalue/util.js.map +1 -1
  73. package/dist/cmd/cloud/objectstore/util.d.ts +3 -0
  74. package/dist/cmd/cloud/objectstore/util.d.ts.map +1 -1
  75. package/dist/cmd/cloud/objectstore/util.js +3 -3
  76. package/dist/cmd/cloud/objectstore/util.js.map +1 -1
  77. package/dist/cmd/cloud/session/get.d.ts.map +1 -1
  78. package/dist/cmd/cloud/session/get.js +4 -4
  79. package/dist/cmd/cloud/session/get.js.map +1 -1
  80. package/dist/cmd/cloud/session/list.d.ts.map +1 -1
  81. package/dist/cmd/cloud/session/list.js +4 -4
  82. package/dist/cmd/cloud/session/list.js.map +1 -1
  83. package/dist/cmd/cloud/session/logs.d.ts.map +1 -1
  84. package/dist/cmd/cloud/session/logs.js +1 -1
  85. package/dist/cmd/cloud/session/logs.js.map +1 -1
  86. package/dist/cmd/cloud/storage/create.js +1 -1
  87. package/dist/cmd/cloud/storage/create.js.map +1 -1
  88. package/dist/cmd/cloud/storage/delete.js +1 -1
  89. package/dist/cmd/cloud/storage/delete.js.map +1 -1
  90. package/dist/cmd/cloud/storage/download.js +1 -1
  91. package/dist/cmd/cloud/storage/download.js.map +1 -1
  92. package/dist/cmd/cloud/storage/get.js +1 -1
  93. package/dist/cmd/cloud/storage/get.js.map +1 -1
  94. package/dist/cmd/cloud/storage/list.js +1 -1
  95. package/dist/cmd/cloud/storage/list.js.map +1 -1
  96. package/dist/cmd/cloud/storage/upload.js +1 -1
  97. package/dist/cmd/cloud/storage/upload.js.map +1 -1
  98. package/dist/cmd/cloud/stream/util.d.ts +3 -0
  99. package/dist/cmd/cloud/stream/util.d.ts.map +1 -1
  100. package/dist/cmd/cloud/stream/util.js +4 -3
  101. package/dist/cmd/cloud/stream/util.js.map +1 -1
  102. package/dist/cmd/cloud/thread/delete.d.ts.map +1 -1
  103. package/dist/cmd/cloud/thread/delete.js +4 -4
  104. package/dist/cmd/cloud/thread/delete.js.map +1 -1
  105. package/dist/cmd/cloud/thread/get.d.ts.map +1 -1
  106. package/dist/cmd/cloud/thread/get.js +4 -4
  107. package/dist/cmd/cloud/thread/get.js.map +1 -1
  108. package/dist/cmd/cloud/thread/list.d.ts.map +1 -1
  109. package/dist/cmd/cloud/thread/list.js +4 -4
  110. package/dist/cmd/cloud/thread/list.js.map +1 -1
  111. package/dist/cmd/cloud/vector/util.d.ts +3 -0
  112. package/dist/cmd/cloud/vector/util.d.ts.map +1 -1
  113. package/dist/cmd/cloud/vector/util.js +4 -3
  114. package/dist/cmd/cloud/vector/util.js.map +1 -1
  115. package/dist/cmd/dev/index.d.ts.map +1 -1
  116. package/dist/cmd/dev/index.js +48 -21
  117. package/dist/cmd/dev/index.js.map +1 -1
  118. package/dist/cmd/profile/current.d.ts +3 -0
  119. package/dist/cmd/profile/current.d.ts.map +1 -0
  120. package/dist/cmd/profile/current.js +27 -0
  121. package/dist/cmd/profile/current.js.map +1 -0
  122. package/dist/cmd/profile/index.d.ts.map +1 -1
  123. package/dist/cmd/profile/index.js +9 -1
  124. package/dist/cmd/profile/index.js.map +1 -1
  125. package/dist/cmd/profile/show.d.ts.map +1 -1
  126. package/dist/cmd/profile/show.js +0 -1
  127. package/dist/cmd/profile/show.js.map +1 -1
  128. package/dist/cmd/project/download.d.ts.map +1 -1
  129. package/dist/cmd/project/download.js +15 -16
  130. package/dist/cmd/project/download.js.map +1 -1
  131. package/dist/cmd/project/template-flow.d.ts.map +1 -1
  132. package/dist/cmd/project/template-flow.js +5 -4
  133. package/dist/cmd/project/template-flow.js.map +1 -1
  134. package/dist/cmd/project/templates.d.ts +2 -1
  135. package/dist/cmd/project/templates.d.ts.map +1 -1
  136. package/dist/cmd/project/templates.js +4 -9
  137. package/dist/cmd/project/templates.js.map +1 -1
  138. package/dist/command-prefix.d.ts.map +1 -1
  139. package/dist/command-prefix.js +2 -1
  140. package/dist/command-prefix.js.map +1 -1
  141. package/dist/config.d.ts +2 -2
  142. package/dist/config.d.ts.map +1 -1
  143. package/dist/config.js +127 -24
  144. package/dist/config.js.map +1 -1
  145. package/dist/download.js +1 -1
  146. package/dist/download.js.map +1 -1
  147. package/dist/env-util.d.ts.map +1 -1
  148. package/dist/env-util.js +3 -0
  149. package/dist/env-util.js.map +1 -1
  150. package/dist/schemas/deploy.d.ts +24 -0
  151. package/dist/schemas/deploy.d.ts.map +1 -0
  152. package/dist/schemas/deploy.js +26 -0
  153. package/dist/schemas/deploy.js.map +1 -0
  154. package/dist/types.d.ts +12 -12
  155. package/dist/types.d.ts.map +1 -1
  156. package/dist/types.js +11 -35
  157. package/dist/types.js.map +1 -1
  158. package/dist/utils/workbench-notify.d.ts +29 -0
  159. package/dist/utils/workbench-notify.d.ts.map +1 -0
  160. package/dist/utils/workbench-notify.js +56 -0
  161. package/dist/utils/workbench-notify.js.map +1 -0
  162. package/package.json +3 -3
  163. package/src/api.ts +13 -2
  164. package/src/cli.ts +6 -1
  165. package/src/cmd/auth/signup.ts +1 -1
  166. package/src/cmd/build/ast.test.ts +246 -1
  167. package/src/cmd/build/ast.ts +88 -4
  168. package/src/cmd/build/bundler.ts +27 -44
  169. package/src/cmd/build/index.ts +15 -24
  170. package/src/cmd/build/plugin.ts +13 -10
  171. package/src/cmd/build/workbench-templates.ts +6 -21
  172. package/src/cmd/cloud/apikey/create.ts +7 -15
  173. package/src/cmd/cloud/db/create.ts +4 -3
  174. package/src/cmd/cloud/db/delete.ts +1 -1
  175. package/src/cmd/cloud/db/get.ts +86 -6
  176. package/src/cmd/cloud/db/index.ts +9 -1
  177. package/src/cmd/cloud/db/list.ts +1 -1
  178. package/src/cmd/cloud/db/logs.ts +163 -0
  179. package/src/cmd/cloud/db/sql.ts +17 -67
  180. package/src/cmd/cloud/deploy.ts +3 -2
  181. package/src/cmd/cloud/deployment/list.ts +1 -4
  182. package/src/cmd/cloud/deployment/logs.ts +1 -4
  183. package/src/cmd/cloud/deployment/remove.ts +1 -1
  184. package/src/cmd/cloud/deployment/rollback.ts +1 -1
  185. package/src/cmd/cloud/deployment/show.ts +1 -1
  186. package/src/cmd/cloud/deployment/undeploy.ts +1 -1
  187. package/src/cmd/cloud/keyvalue/util.ts +5 -3
  188. package/src/cmd/cloud/objectstore/util.ts +4 -3
  189. package/src/cmd/cloud/session/get.ts +4 -7
  190. package/src/cmd/cloud/session/list.ts +4 -7
  191. package/src/cmd/cloud/session/logs.ts +1 -4
  192. package/src/cmd/cloud/storage/create.ts +1 -1
  193. package/src/cmd/cloud/storage/delete.ts +1 -1
  194. package/src/cmd/cloud/storage/download.ts +1 -1
  195. package/src/cmd/cloud/storage/get.ts +1 -1
  196. package/src/cmd/cloud/storage/list.ts +1 -1
  197. package/src/cmd/cloud/storage/upload.ts +1 -1
  198. package/src/cmd/cloud/stream/util.ts +7 -3
  199. package/src/cmd/cloud/thread/delete.ts +4 -7
  200. package/src/cmd/cloud/thread/get.ts +4 -7
  201. package/src/cmd/cloud/thread/list.ts +4 -7
  202. package/src/cmd/cloud/vector/util.ts +5 -3
  203. package/src/cmd/dev/index.ts +54 -21
  204. package/src/cmd/profile/current.ts +31 -0
  205. package/src/cmd/profile/index.ts +9 -1
  206. package/src/cmd/profile/show.ts +0 -1
  207. package/src/cmd/project/download.ts +15 -16
  208. package/src/cmd/project/template-flow.ts +6 -4
  209. package/src/cmd/project/templates.ts +9 -11
  210. package/src/command-prefix.ts +4 -1
  211. package/src/config.ts +150 -24
  212. package/src/download.ts +1 -1
  213. package/src/env-util.ts +3 -0
  214. package/src/schemas/deploy.ts +28 -0
  215. package/src/types.ts +11 -35
  216. package/src/utils/workbench-notify.ts +67 -0
@@ -1,23 +1,14 @@
1
1
  import { z } from 'zod';
2
- import { SQL } from 'bun';
3
- import { listResources, type ResourceList } from '@agentuity/server';
2
+ import { dbQuery } from '@agentuity/server';
4
3
  import { createSubcommand } from '../../../types';
5
4
  import * as tui from '../../../tui';
6
5
  import { getCatalystAPIClient } from '../../../config';
7
6
  import { getCommand } from '../../../command-prefix';
8
- import { ErrorCode } from '../../../errors';
9
-
10
- interface DatabaseResource {
11
- name: string;
12
- username?: string | null;
13
- password?: string | null;
14
- url?: string | null;
15
- }
16
7
 
17
8
  const DBSQLResponseSchema = z.object({
18
9
  rows: z.array(z.record(z.string(), z.unknown())).describe('Query results'),
19
10
  rowCount: z.number().describe('Number of rows returned'),
20
- executionTime: z.number().optional().describe('Query execution time in ms'),
11
+ truncated: z.boolean().describe('Whether results were truncated'),
21
12
  });
22
13
 
23
14
  export const sqlSubcommand = createSubcommand({
@@ -53,82 +44,41 @@ export const sqlSubcommand = createSubcommand({
53
44
  async handler(ctx) {
54
45
  const { logger, args, options, orgId, region, config, auth } = ctx;
55
46
 
56
- const catalystClient = getCatalystAPIClient(config, logger, auth);
47
+ const catalystClient = getCatalystAPIClient(config, logger, auth, region);
57
48
 
58
- const resources: ResourceList = await tui.spinner({
59
- message: `Fetching database ${args.name}`,
49
+ const result = await tui.spinner({
50
+ message: `Executing query on ${args.name}`,
60
51
  clearOnSuccess: true,
61
52
  callback: async () => {
62
- return listResources(catalystClient, orgId, region);
53
+ return dbQuery(catalystClient, {
54
+ database: args.name,
55
+ query: args.query,
56
+ orgId,
57
+ region,
58
+ });
63
59
  },
64
60
  });
65
61
 
66
- const db: DatabaseResource | undefined = resources.db.find(
67
- (d: DatabaseResource) => d.name === args.name
68
- );
69
-
70
- if (!db) {
71
- tui.fatal(`Database '${args.name}' not found`, ErrorCode.RESOURCE_NOT_FOUND);
72
- }
73
-
74
- if (!db.url) {
75
- tui.fatal(`Database '${args.name}' has no connection URL`, ErrorCode.RUNTIME_ERROR);
76
- }
77
-
78
- let database: SQL | undefined;
79
- let rows: Record<string, unknown>[];
80
- let executionTime: number | undefined;
81
-
82
- try {
83
- // Add sslmode=require if not already present in URL
84
- let connectionUrl = db.url;
85
- if (!connectionUrl.includes('sslmode=') && !connectionUrl.includes('ssl=')) {
86
- const separator = connectionUrl.includes('?') ? '&' : '?';
87
- connectionUrl = `${connectionUrl}${separator}sslmode=require`;
88
- }
89
-
90
- database = new SQL(connectionUrl);
91
-
92
- const startTime = performance.now();
93
- const result = await tui.spinner({
94
- message: `Executing query on ${args.name}`,
95
- clearOnSuccess: true,
96
- callback: async () => {
97
- return database!.unsafe(args.query);
98
- },
99
- });
100
- executionTime = performance.now() - startTime;
101
-
102
- rows = result;
103
- } catch (error) {
104
- const message = error instanceof Error ? error.message : String(error);
105
- tui.fatal(`Query execution failed: ${message}`, ErrorCode.RUNTIME_ERROR);
106
- } finally {
107
- if (database) {
108
- await database.close();
109
- }
110
- }
111
-
112
62
  if (!options.json) {
113
- if (rows.length === 0) {
63
+ if (result.rowCount === 0) {
114
64
  tui.info('No rows returned');
115
65
  } else {
116
66
  if (process.stdout.isTTY) {
117
67
  tui.newline();
118
68
  tui.success(
119
- `Query returned ${rows.length} row${rows.length !== 1 ? 's' : ''} (${executionTime?.toFixed(2)}ms):`
69
+ `Query returned ${result.rowCount} row${result.rowCount !== 1 ? 's' : ''}${result.truncated ? ' (truncated to 1000 rows)' : ''}:`
120
70
  );
121
71
  tui.newline();
122
72
  }
123
73
 
124
- tui.table(rows);
74
+ tui.table(result.rows);
125
75
  }
126
76
  }
127
77
 
128
78
  return {
129
- rows,
130
- rowCount: rows.length,
131
- executionTime,
79
+ rows: result.rows,
80
+ rowCount: result.rowCount,
81
+ truncated: result.truncated,
132
82
  };
133
83
  },
134
84
  });
@@ -27,9 +27,9 @@ import {
27
27
  } from '../../env-util';
28
28
  import { zipDir } from '../../utils/zip';
29
29
  import { encryptFIPSKEMDEMStream } from '../../crypto/box';
30
- import { DeployOptionsSchema } from '../build/bundler';
31
30
  import { getCommand } from '../../command-prefix';
32
31
  import { checkCustomDomainForDNS } from './domain';
32
+ import { DeployOptionsSchema } from '../../schemas/deploy';
33
33
 
34
34
  const DeployResponseSchema = z.object({
35
35
  success: z.boolean().describe('Whether deployment succeeded'),
@@ -162,7 +162,8 @@ export const deploySubcommand = createSubcommand({
162
162
  );
163
163
  return stepSuccess();
164
164
  } catch (ex) {
165
- return stepError(ex instanceof Error ? ex.message : String(ex));
165
+ const _ex = ex as { message?: string };
166
+ return stepError(_ex.message ?? String(_ex), ex as Error);
166
167
  }
167
168
  },
168
169
  },
@@ -103,10 +103,7 @@ export const listSubcommand = createSubcommand({
103
103
 
104
104
  return result;
105
105
  } catch (ex) {
106
- tui.fatal(
107
- `Failed to list deployments: ${ex instanceof Error ? ex.message : String(ex)}`,
108
- ErrorCode.API_ERROR
109
- );
106
+ tui.fatal(`Failed to list deployments: ${ex}`, ErrorCode.API_ERROR);
110
107
  }
111
108
  },
112
109
  });
@@ -78,10 +78,7 @@ export const logsSubcommand = createSubcommand({
78
78
 
79
79
  return logs;
80
80
  } catch (ex) {
81
- tui.fatal(
82
- `Failed to fetch deployment logs: ${ex instanceof Error ? ex.message : String(ex)}`,
83
- ErrorCode.API_ERROR
84
- );
81
+ tui.fatal(`Failed to fetch deployment logs: ${ex}`, ErrorCode.API_ERROR);
85
82
  }
86
83
  },
87
84
  });
@@ -69,7 +69,7 @@ export const removeSubcommand = createSubcommand({
69
69
  deploymentId: args.deployment_id,
70
70
  };
71
71
  } catch (ex) {
72
- tui.fatal(`Failed to remove deployment: ${ex instanceof Error ? ex.message : String(ex)}`);
72
+ tui.fatal(`Failed to remove deployment: ${ex}`);
73
73
  }
74
74
  },
75
75
  });
@@ -86,7 +86,7 @@ export const rollbackSubcommand = createSubcommand({
86
86
  targetDeploymentId,
87
87
  };
88
88
  } catch (ex) {
89
- tui.fatal(`Failed to rollback: ${ex instanceof Error ? ex.message : String(ex)}`);
89
+ tui.fatal(`Failed to rollback: ${ex}`);
90
90
  }
91
91
  },
92
92
  });
@@ -155,7 +155,7 @@ export const showSubcommand = createSubcommand({
155
155
  metadata: deployment.metadata ?? undefined,
156
156
  };
157
157
  } catch (ex) {
158
- tui.fatal(`Failed to show deployment: ${ex instanceof Error ? ex.message : String(ex)}`);
158
+ tui.fatal(`Failed to show deployment: ${ex}`);
159
159
  }
160
160
  },
161
161
  });
@@ -50,7 +50,7 @@ export const undeploySubcommand = createSubcommand({
50
50
  await projectDeploymentUndeploy(apiClient, projectId);
51
51
  tui.success('Undeployed successfully.');
52
52
  } catch (ex) {
53
- tui.fatal(`Failed to undeploy: ${ex instanceof Error ? ex.message : String(ex)}`);
53
+ tui.fatal(`Failed to undeploy: ${ex}`);
54
54
  }
55
55
  },
56
56
  });
@@ -1,5 +1,5 @@
1
1
  import { KeyValueStorageService, Logger } from '@agentuity/core';
2
- import { createServerFetchAdapter } from '@agentuity/server';
2
+ import { createServerFetchAdapter, getServiceUrls } from '@agentuity/server';
3
3
  import { loadProjectSDKKey } from '../../../config';
4
4
  import { ErrorCode } from '../../../errors';
5
5
  import type { Config } from '../../../types';
@@ -9,8 +9,9 @@ export async function createStorageAdapter(ctx: {
9
9
  logger: Logger;
10
10
  projectDir: string;
11
11
  config: Config | null;
12
+ project: { region: string };
12
13
  }) {
13
- const sdkKey = await loadProjectSDKKey(ctx.projectDir);
14
+ const sdkKey = await loadProjectSDKKey(ctx.logger, ctx.projectDir);
14
15
  if (!sdkKey) {
15
16
  tui.fatal(
16
17
  `Couldn't find the AGENTUITY_SDK_KEY in ${ctx.projectDir} .env file`,
@@ -27,6 +28,7 @@ export async function createStorageAdapter(ctx: {
27
28
  ctx.logger
28
29
  );
29
30
 
30
- const baseUrl = ctx.config?.overrides?.catalyst_url ?? 'https://catalyst.agentuity.cloud';
31
+ const urls = getServiceUrls(ctx.project.region);
32
+ const baseUrl = urls.catalyst;
31
33
  return new KeyValueStorageService(baseUrl, adapter);
32
34
  }
@@ -1,5 +1,5 @@
1
1
  import { Logger, ObjectStorageService } from '@agentuity/core';
2
- import { createServerFetchAdapter } from '@agentuity/server';
2
+ import { createServerFetchAdapter, getServiceUrls } from '@agentuity/server';
3
3
  import { loadProjectSDKKey } from '../../../config';
4
4
  import type { Config } from '../../../types';
5
5
  import * as tui from '../../../tui';
@@ -8,8 +8,9 @@ export async function createStorageAdapter(ctx: {
8
8
  logger: Logger;
9
9
  projectDir: string;
10
10
  config: Config | null;
11
+ project: { region: string };
11
12
  }) {
12
- const sdkKey = await loadProjectSDKKey(ctx.projectDir);
13
+ const sdkKey = await loadProjectSDKKey(ctx.logger, ctx.projectDir);
13
14
  if (!sdkKey) {
14
15
  tui.fatal(`Couldn't find the AGENTUITY_SDK_KEY in ${ctx.projectDir} .env file`);
15
16
  }
@@ -23,6 +24,6 @@ export async function createStorageAdapter(ctx: {
23
24
  ctx.logger
24
25
  );
25
26
 
26
- const baseUrl = ctx.config?.overrides?.object_url ?? 'https://catalyst.agentuity.cloud';
27
+ const baseUrl = getServiceUrls(ctx.project.region).catalyst;
27
28
  return new ObjectStorageService(baseUrl, adapter);
28
29
  }
@@ -116,7 +116,7 @@ export const getSubcommand = createSubcommand({
116
116
  description: 'Get a session by ID',
117
117
  },
118
118
  ],
119
- requires: { auth: true },
119
+ requires: { auth: true, region: 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 { config, logger, auth, args, options } = ctx;
129
- const catalystClient = getCatalystAPIClient(config, logger, auth);
128
+ const { config, logger, auth, args, options, region } = ctx;
129
+ const catalystClient = getCatalystAPIClient(config, logger, auth, region);
130
130
 
131
131
  try {
132
132
  const enriched = await sessionGet(catalystClient, { id: args.session_id });
@@ -247,10 +247,7 @@ export const getSubcommand = createSubcommand({
247
247
  if (ex instanceof APIError && ex.status === 404) {
248
248
  tui.fatal(`Session ${args.session_id} not found`, ErrorCode.RESOURCE_NOT_FOUND);
249
249
  }
250
- tui.fatal(
251
- `Failed to get session: ${ex instanceof Error ? ex.message : String(ex)}`,
252
- ErrorCode.API_ERROR
253
- );
250
+ tui.fatal(`Failed to get session: ${ex}`, ErrorCode.API_ERROR);
254
251
  }
255
252
  },
256
253
  });
@@ -55,7 +55,7 @@ export const listSubcommand = createSubcommand({
55
55
  },
56
56
  ],
57
57
  aliases: ['ls'],
58
- requires: { auth: true },
58
+ requires: { auth: true, region: true },
59
59
  optional: { project: true },
60
60
  idempotent: true,
61
61
  pagination: {
@@ -89,8 +89,8 @@ export const listSubcommand = createSubcommand({
89
89
  response: SessionListResponseSchema,
90
90
  },
91
91
  async handler(ctx) {
92
- const { config, logger, auth, project, opts, options } = ctx;
93
- const catalystClient = getCatalystAPIClient(config, logger, auth);
92
+ const { config, logger, auth, project, opts, options, region } = ctx;
93
+ const catalystClient = getCatalystAPIClient(config, logger, auth, region);
94
94
 
95
95
  const projectId = opts.projectId || project?.projectId;
96
96
 
@@ -157,10 +157,7 @@ export const listSubcommand = createSubcommand({
157
157
 
158
158
  return result;
159
159
  } catch (ex) {
160
- tui.fatal(
161
- `Failed to list sessions: ${ex instanceof Error ? ex.message : String(ex)}`,
162
- ErrorCode.API_ERROR
163
- );
160
+ tui.fatal(`Failed to list sessions: ${ex}`, ErrorCode.API_ERROR);
164
161
  }
165
162
  },
166
163
  });
@@ -67,10 +67,7 @@ export const logsSubcommand = createSubcommand({
67
67
 
68
68
  return logs;
69
69
  } catch (ex) {
70
- tui.fatal(
71
- `Failed to get session logs: ${ex instanceof Error ? ex.message : String(ex)}`,
72
- ErrorCode.API_ERROR
73
- );
70
+ tui.fatal(`Failed to get session logs: ${ex}`, ErrorCode.API_ERROR);
74
71
  }
75
72
  },
76
73
  });
@@ -51,7 +51,7 @@ export const createSubcommand = defineSubcommand({
51
51
  };
52
52
  }
53
53
 
54
- const catalystClient = getCatalystAPIClient(config, logger, auth);
54
+ const catalystClient = getCatalystAPIClient(config, logger, auth, region);
55
55
 
56
56
  const created = await tui.spinner({
57
57
  message: `Creating storage in ${region}`,
@@ -51,7 +51,7 @@ export const deleteSubcommand = createSubcommand({
51
51
  async handler(ctx) {
52
52
  const { logger, args, opts, config, orgId, region, auth, options } = ctx;
53
53
 
54
- const catalystClient = getCatalystAPIClient(config, logger, auth);
54
+ const catalystClient = getCatalystAPIClient(config, logger, auth, region);
55
55
 
56
56
  const resources = await tui.spinner({
57
57
  message: `Fetching storage for ${orgId} in ${region}`,
@@ -53,7 +53,7 @@ export const downloadSubcommand = createSubcommand({
53
53
  async handler(ctx) {
54
54
  const { logger, args, opts, options, orgId, region, config, auth } = ctx;
55
55
 
56
- const catalystClient = getCatalystAPIClient(config, logger, auth);
56
+ const catalystClient = getCatalystAPIClient(config, logger, auth, region);
57
57
 
58
58
  // Fetch bucket credentials
59
59
  const resources = await tui.spinner({
@@ -53,7 +53,7 @@ export const getSubcommand = createSubcommand({
53
53
  async handler(ctx) {
54
54
  const { logger, args, opts, options, orgId, region, config, auth } = ctx;
55
55
 
56
- const catalystClient = getCatalystAPIClient(config, logger, auth);
56
+ const catalystClient = getCatalystAPIClient(config, logger, auth, region);
57
57
 
58
58
  const resources = await tui.spinner({
59
59
  message: `Fetching storage bucket ${args.name}`,
@@ -76,7 +76,7 @@ export const listSubcommand = createSubcommand({
76
76
  async handler(ctx) {
77
77
  const { logger, args, opts, options, orgId, region, config, auth } = ctx;
78
78
 
79
- const catalystClient = getCatalystAPIClient(config, logger, auth);
79
+ const catalystClient = getCatalystAPIClient(config, logger, auth, region);
80
80
 
81
81
  const resources = await tui.spinner({
82
82
  message: `Fetching storage for ${orgId} in ${region}`,
@@ -51,7 +51,7 @@ export const uploadSubcommand = createSubcommand({
51
51
  async handler(ctx) {
52
52
  const { logger, args, opts, options, orgId, region, config, auth } = ctx;
53
53
 
54
- const catalystClient = getCatalystAPIClient(config, logger, auth);
54
+ const catalystClient = getCatalystAPIClient(config, logger, auth, region);
55
55
 
56
56
  // Fetch bucket credentials
57
57
  const resources = await tui.spinner({
@@ -1,5 +1,5 @@
1
1
  import { StreamStorageService, Logger } from '@agentuity/core';
2
- import { createServerFetchAdapter } from '@agentuity/server';
2
+ import { createServerFetchAdapter, getServiceUrls } from '@agentuity/server';
3
3
  import { loadProjectSDKKey } from '../../../config';
4
4
  import { ErrorCode } from '../../../errors';
5
5
  import type { Config } from '../../../types';
@@ -9,8 +9,9 @@ export async function createStorageAdapter(ctx: {
9
9
  logger: Logger;
10
10
  projectDir: string;
11
11
  config: Config | null;
12
+ project: { region: string };
12
13
  }) {
13
- const sdkKey = await loadProjectSDKKey(ctx.projectDir);
14
+ const sdkKey = await loadProjectSDKKey(ctx.logger, ctx.projectDir);
14
15
  if (!sdkKey) {
15
16
  tui.fatal(
16
17
  `Couldn't find the AGENTUITY_SDK_KEY in ${ctx.projectDir} .env file`,
@@ -27,6 +28,9 @@ export async function createStorageAdapter(ctx: {
27
28
  ctx.logger
28
29
  );
29
30
 
30
- const baseUrl = ctx.config?.overrides?.stream_url ?? 'https://stream.agentuity.cloud';
31
+ const baseUrl = getServiceUrls(ctx.project.region).stream;
32
+
33
+ ctx.logger.trace('using stream url: %s', baseUrl);
34
+
31
35
  return new StreamStorageService(baseUrl, adapter);
32
36
  }
@@ -17,15 +17,15 @@ export const deleteSubcommand = createSubcommand({
17
17
  },
18
18
  ],
19
19
  aliases: ['rm'],
20
- requires: { auth: true },
20
+ requires: { auth: true, region: 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 { config, logger, auth, args } = ctx;
28
- const catalystClient = getCatalystAPIClient(config, logger, auth);
27
+ const { config, logger, auth, args, region } = ctx;
28
+ const catalystClient = getCatalystAPIClient(config, logger, auth, region);
29
29
 
30
30
  try {
31
31
  await threadDelete(catalystClient, { id: args.thread_id });
@@ -35,10 +35,7 @@ export const deleteSubcommand = createSubcommand({
35
35
  tui.fatal(`Thread ${args.thread_id} not found`, ErrorCode.RESOURCE_NOT_FOUND);
36
36
  return;
37
37
  }
38
- tui.fatal(
39
- `Failed to delete thread: ${ex instanceof Error ? ex.message : String(ex)}`,
40
- ErrorCode.API_ERROR
41
- );
38
+ tui.fatal(`Failed to delete thread: ${ex}`, ErrorCode.API_ERROR);
42
39
  }
43
40
  },
44
41
  });
@@ -28,7 +28,7 @@ export const getSubcommand = createSubcommand({
28
28
  description: 'Get a thread by ID',
29
29
  },
30
30
  ],
31
- requires: { auth: true },
31
+ requires: { auth: true, region: 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 { config, logger, auth, args, options } = ctx;
41
- const catalystClient = getCatalystAPIClient(config, logger, auth);
40
+ const { config, logger, auth, args, options, region } = ctx;
41
+ const catalystClient = getCatalystAPIClient(config, logger, auth, region);
42
42
 
43
43
  try {
44
44
  const thread = await threadGet(catalystClient, { id: args.thread_id });
@@ -79,10 +79,7 @@ export const getSubcommand = createSubcommand({
79
79
  if (ex instanceof APIError && ex.status === 404) {
80
80
  tui.fatal(`Thread ${args.thread_id} not found`, ErrorCode.RESOURCE_NOT_FOUND);
81
81
  }
82
- tui.fatal(
83
- `Failed to get thread: ${ex instanceof Error ? ex.message : String(ex)}`,
84
- ErrorCode.API_ERROR
85
- );
82
+ tui.fatal(`Failed to get thread: ${ex}`, ErrorCode.API_ERROR);
86
83
  }
87
84
  },
88
85
  });
@@ -36,7 +36,7 @@ export const listSubcommand = createSubcommand({
36
36
  },
37
37
  ],
38
38
  aliases: ['ls'],
39
- requires: { auth: true },
39
+ requires: { auth: true, region: 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 { config, logger, auth, project, opts, options } = ctx;
66
- const catalystClient = getCatalystAPIClient(config, logger, auth);
65
+ const { config, logger, auth, project, opts, options, region } = ctx;
66
+ const catalystClient = getCatalystAPIClient(config, logger, auth, region);
67
67
 
68
68
  const projectId = opts.projectId || project?.projectId;
69
69
  const orgId = opts.orgId;
@@ -116,10 +116,7 @@ export const listSubcommand = createSubcommand({
116
116
 
117
117
  return result;
118
118
  } catch (ex) {
119
- tui.fatal(
120
- `Failed to list threads: ${ex instanceof Error ? ex.message : String(ex)}`,
121
- ErrorCode.API_ERROR
122
- );
119
+ tui.fatal(`Failed to list threads: ${ex}`, ErrorCode.API_ERROR);
123
120
  }
124
121
  },
125
122
  });
@@ -1,5 +1,5 @@
1
1
  import { Logger, VectorStorageService } from '@agentuity/core';
2
- import { createServerFetchAdapter } from '@agentuity/server';
2
+ import { createServerFetchAdapter, getServiceUrls } from '@agentuity/server';
3
3
  import { loadProjectSDKKey } from '../../../config';
4
4
  import type { Config } from '../../../types';
5
5
  import * as tui from '../../../tui';
@@ -8,8 +8,9 @@ export async function createStorageAdapter(ctx: {
8
8
  logger: Logger;
9
9
  projectDir: string;
10
10
  config: Config | null;
11
+ project: { region: string };
11
12
  }) {
12
- const sdkKey = await loadProjectSDKKey(ctx.projectDir);
13
+ const sdkKey = await loadProjectSDKKey(ctx.logger, ctx.projectDir);
13
14
  if (!sdkKey) {
14
15
  tui.fatal(`Couldn't find the AGENTUITY_SDK_KEY in ${ctx.projectDir} .env file`);
15
16
  }
@@ -23,6 +24,7 @@ export async function createStorageAdapter(ctx: {
23
24
  ctx.logger
24
25
  );
25
26
 
26
- const baseUrl = ctx.config?.overrides?.catalyst_url ?? 'https://catalyst.agentuity.cloud';
27
+ const urls = getServiceUrls(ctx.project.region);
28
+ const baseUrl = urls.catalyst;
27
29
  return new VectorStorageService(baseUrl, adapter);
28
30
  }