@agentuity/cli 0.0.63 → 0.0.65

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 (154) hide show
  1. package/dist/cmd/build/ast.d.ts.map +1 -1
  2. package/dist/cmd/build/ast.js +70 -4
  3. package/dist/cmd/build/ast.js.map +1 -1
  4. package/dist/cmd/build/ast.test.js +186 -1
  5. package/dist/cmd/build/ast.test.js.map +1 -1
  6. package/dist/cmd/build/bundler.d.ts +2 -24
  7. package/dist/cmd/build/bundler.d.ts.map +1 -1
  8. package/dist/cmd/build/bundler.js +24 -41
  9. package/dist/cmd/build/bundler.js.map +1 -1
  10. package/dist/cmd/build/index.js +22 -23
  11. package/dist/cmd/build/index.js.map +1 -1
  12. package/dist/cmd/build/plugin.d.ts.map +1 -1
  13. package/dist/cmd/build/plugin.js +5 -4
  14. package/dist/cmd/build/plugin.js.map +1 -1
  15. package/dist/cmd/build/workbench-templates.d.ts +1 -1
  16. package/dist/cmd/build/workbench-templates.d.ts.map +1 -1
  17. package/dist/cmd/build/workbench-templates.js +6 -19
  18. package/dist/cmd/build/workbench-templates.js.map +1 -1
  19. package/dist/cmd/cloud/apikey/create.d.ts.map +1 -1
  20. package/dist/cmd/cloud/apikey/create.js +7 -16
  21. package/dist/cmd/cloud/apikey/create.js.map +1 -1
  22. package/dist/cmd/cloud/db/create.d.ts.map +1 -1
  23. package/dist/cmd/cloud/db/create.js +3 -2
  24. package/dist/cmd/cloud/db/create.js.map +1 -1
  25. package/dist/cmd/cloud/db/get.d.ts.map +1 -1
  26. package/dist/cmd/cloud/db/get.js +72 -3
  27. package/dist/cmd/cloud/db/get.js.map +1 -1
  28. package/dist/cmd/cloud/db/index.d.ts.map +1 -1
  29. package/dist/cmd/cloud/db/index.js +9 -1
  30. package/dist/cmd/cloud/db/index.js.map +1 -1
  31. package/dist/cmd/cloud/db/logs.d.ts +2 -0
  32. package/dist/cmd/cloud/db/logs.d.ts.map +1 -0
  33. package/dist/cmd/cloud/db/logs.js +150 -0
  34. package/dist/cmd/cloud/db/logs.js.map +1 -0
  35. package/dist/cmd/cloud/db/sql.d.ts.map +1 -1
  36. package/dist/cmd/cloud/db/sql.js +16 -51
  37. package/dist/cmd/cloud/db/sql.js.map +1 -1
  38. package/dist/cmd/cloud/deploy.d.ts.map +1 -1
  39. package/dist/cmd/cloud/deploy.js +3 -2
  40. package/dist/cmd/cloud/deploy.js.map +1 -1
  41. package/dist/cmd/cloud/deployment/list.d.ts.map +1 -1
  42. package/dist/cmd/cloud/deployment/list.js +1 -1
  43. package/dist/cmd/cloud/deployment/list.js.map +1 -1
  44. package/dist/cmd/cloud/deployment/logs.d.ts.map +1 -1
  45. package/dist/cmd/cloud/deployment/logs.js +1 -1
  46. package/dist/cmd/cloud/deployment/logs.js.map +1 -1
  47. package/dist/cmd/cloud/deployment/remove.js +1 -1
  48. package/dist/cmd/cloud/deployment/remove.js.map +1 -1
  49. package/dist/cmd/cloud/deployment/rollback.js +1 -1
  50. package/dist/cmd/cloud/deployment/rollback.js.map +1 -1
  51. package/dist/cmd/cloud/deployment/show.js +1 -1
  52. package/dist/cmd/cloud/deployment/show.js.map +1 -1
  53. package/dist/cmd/cloud/deployment/undeploy.js +1 -1
  54. package/dist/cmd/cloud/deployment/undeploy.js.map +1 -1
  55. package/dist/cmd/cloud/keyvalue/util.js +1 -1
  56. package/dist/cmd/cloud/keyvalue/util.js.map +1 -1
  57. package/dist/cmd/cloud/objectstore/util.js +1 -1
  58. package/dist/cmd/cloud/objectstore/util.js.map +1 -1
  59. package/dist/cmd/cloud/session/get.d.ts.map +1 -1
  60. package/dist/cmd/cloud/session/get.js +1 -1
  61. package/dist/cmd/cloud/session/get.js.map +1 -1
  62. package/dist/cmd/cloud/session/list.d.ts.map +1 -1
  63. package/dist/cmd/cloud/session/list.js +1 -1
  64. package/dist/cmd/cloud/session/list.js.map +1 -1
  65. package/dist/cmd/cloud/session/logs.d.ts.map +1 -1
  66. package/dist/cmd/cloud/session/logs.js +1 -1
  67. package/dist/cmd/cloud/session/logs.js.map +1 -1
  68. package/dist/cmd/cloud/stream/util.d.ts.map +1 -1
  69. package/dist/cmd/cloud/stream/util.js +2 -1
  70. package/dist/cmd/cloud/stream/util.js.map +1 -1
  71. package/dist/cmd/cloud/thread/delete.d.ts.map +1 -1
  72. package/dist/cmd/cloud/thread/delete.js +1 -1
  73. package/dist/cmd/cloud/thread/delete.js.map +1 -1
  74. package/dist/cmd/cloud/thread/get.d.ts.map +1 -1
  75. package/dist/cmd/cloud/thread/get.js +1 -1
  76. package/dist/cmd/cloud/thread/get.js.map +1 -1
  77. package/dist/cmd/cloud/thread/list.d.ts.map +1 -1
  78. package/dist/cmd/cloud/thread/list.js +1 -1
  79. package/dist/cmd/cloud/thread/list.js.map +1 -1
  80. package/dist/cmd/cloud/vector/util.js +1 -1
  81. package/dist/cmd/cloud/vector/util.js.map +1 -1
  82. package/dist/cmd/dev/index.d.ts.map +1 -1
  83. package/dist/cmd/dev/index.js +34 -1
  84. package/dist/cmd/dev/index.js.map +1 -1
  85. package/dist/cmd/profile/current.d.ts +3 -0
  86. package/dist/cmd/profile/current.d.ts.map +1 -0
  87. package/dist/cmd/profile/current.js +27 -0
  88. package/dist/cmd/profile/current.js.map +1 -0
  89. package/dist/cmd/profile/index.d.ts.map +1 -1
  90. package/dist/cmd/profile/index.js +9 -1
  91. package/dist/cmd/profile/index.js.map +1 -1
  92. package/dist/cmd/profile/show.d.ts.map +1 -1
  93. package/dist/cmd/profile/show.js +0 -1
  94. package/dist/cmd/profile/show.js.map +1 -1
  95. package/dist/command-prefix.d.ts.map +1 -1
  96. package/dist/command-prefix.js +2 -1
  97. package/dist/command-prefix.js.map +1 -1
  98. package/dist/config.d.ts +1 -1
  99. package/dist/config.d.ts.map +1 -1
  100. package/dist/config.js +18 -5
  101. package/dist/config.js.map +1 -1
  102. package/dist/download.js +1 -1
  103. package/dist/download.js.map +1 -1
  104. package/dist/env-util.d.ts.map +1 -1
  105. package/dist/env-util.js +3 -0
  106. package/dist/env-util.js.map +1 -1
  107. package/dist/schemas/deploy.d.ts +24 -0
  108. package/dist/schemas/deploy.d.ts.map +1 -0
  109. package/dist/schemas/deploy.js +26 -0
  110. package/dist/schemas/deploy.js.map +1 -0
  111. package/dist/utils/workbench-notify.d.ts +29 -0
  112. package/dist/utils/workbench-notify.d.ts.map +1 -0
  113. package/dist/utils/workbench-notify.js +56 -0
  114. package/dist/utils/workbench-notify.js.map +1 -0
  115. package/package.json +3 -3
  116. package/src/cmd/build/ast.test.ts +246 -1
  117. package/src/cmd/build/ast.ts +88 -4
  118. package/src/cmd/build/bundler.ts +27 -44
  119. package/src/cmd/build/index.ts +23 -23
  120. package/src/cmd/build/plugin.ts +5 -4
  121. package/src/cmd/build/workbench-templates.ts +6 -21
  122. package/src/cmd/cloud/apikey/create.ts +7 -15
  123. package/src/cmd/cloud/db/create.ts +3 -2
  124. package/src/cmd/cloud/db/get.ts +85 -5
  125. package/src/cmd/cloud/db/index.ts +9 -1
  126. package/src/cmd/cloud/db/logs.ts +163 -0
  127. package/src/cmd/cloud/db/sql.ts +16 -66
  128. package/src/cmd/cloud/deploy.ts +3 -2
  129. package/src/cmd/cloud/deployment/list.ts +1 -4
  130. package/src/cmd/cloud/deployment/logs.ts +1 -4
  131. package/src/cmd/cloud/deployment/remove.ts +1 -1
  132. package/src/cmd/cloud/deployment/rollback.ts +1 -1
  133. package/src/cmd/cloud/deployment/show.ts +1 -1
  134. package/src/cmd/cloud/deployment/undeploy.ts +1 -1
  135. package/src/cmd/cloud/keyvalue/util.ts +1 -1
  136. package/src/cmd/cloud/objectstore/util.ts +1 -1
  137. package/src/cmd/cloud/session/get.ts +1 -4
  138. package/src/cmd/cloud/session/list.ts +1 -4
  139. package/src/cmd/cloud/session/logs.ts +1 -4
  140. package/src/cmd/cloud/stream/util.ts +4 -1
  141. package/src/cmd/cloud/thread/delete.ts +1 -4
  142. package/src/cmd/cloud/thread/get.ts +1 -4
  143. package/src/cmd/cloud/thread/list.ts +1 -4
  144. package/src/cmd/cloud/vector/util.ts +1 -1
  145. package/src/cmd/dev/index.ts +40 -1
  146. package/src/cmd/profile/current.ts +31 -0
  147. package/src/cmd/profile/index.ts +9 -1
  148. package/src/cmd/profile/show.ts +0 -1
  149. package/src/command-prefix.ts +4 -1
  150. package/src/config.ts +20 -5
  151. package/src/download.ts +1 -1
  152. package/src/env-util.ts +3 -0
  153. package/src/schemas/deploy.ts +28 -0
  154. package/src/utils/workbench-notify.ts +67 -0
@@ -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
  });
@@ -10,7 +10,7 @@ export async function createStorageAdapter(ctx: {
10
10
  projectDir: string;
11
11
  config: Config | null;
12
12
  }) {
13
- const sdkKey = await loadProjectSDKKey(ctx.projectDir);
13
+ const sdkKey = await loadProjectSDKKey(ctx.logger, ctx.projectDir);
14
14
  if (!sdkKey) {
15
15
  tui.fatal(
16
16
  `Couldn't find the AGENTUITY_SDK_KEY in ${ctx.projectDir} .env file`,
@@ -9,7 +9,7 @@ export async function createStorageAdapter(ctx: {
9
9
  projectDir: string;
10
10
  config: Config | null;
11
11
  }) {
12
- const sdkKey = await loadProjectSDKKey(ctx.projectDir);
12
+ const sdkKey = await loadProjectSDKKey(ctx.logger, ctx.projectDir);
13
13
  if (!sdkKey) {
14
14
  tui.fatal(`Couldn't find the AGENTUITY_SDK_KEY in ${ctx.projectDir} .env file`);
15
15
  }
@@ -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
  });
@@ -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
  });
@@ -10,7 +10,7 @@ export async function createStorageAdapter(ctx: {
10
10
  projectDir: string;
11
11
  config: Config | null;
12
12
  }) {
13
- const sdkKey = await loadProjectSDKKey(ctx.projectDir);
13
+ const sdkKey = await loadProjectSDKKey(ctx.logger, ctx.projectDir);
14
14
  if (!sdkKey) {
15
15
  tui.fatal(
16
16
  `Couldn't find the AGENTUITY_SDK_KEY in ${ctx.projectDir} .env file`,
@@ -28,5 +28,8 @@ export async function createStorageAdapter(ctx: {
28
28
  );
29
29
 
30
30
  const baseUrl = ctx.config?.overrides?.stream_url ?? 'https://stream.agentuity.cloud';
31
+
32
+ ctx.logger.trace('using stream url: %s', baseUrl);
33
+
31
34
  return new StreamStorageService(baseUrl, adapter);
32
35
  }
@@ -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
  });
@@ -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
  });
@@ -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
  });
@@ -9,7 +9,7 @@ export async function createStorageAdapter(ctx: {
9
9
  projectDir: string;
10
10
  config: Config | null;
11
11
  }) {
12
- const sdkKey = await loadProjectSDKKey(ctx.projectDir);
12
+ const sdkKey = await loadProjectSDKKey(ctx.logger, ctx.projectDir);
13
13
  if (!sdkKey) {
14
14
  tui.fatal(`Couldn't find the AGENTUITY_SDK_KEY in ${ctx.projectDir} .env file`);
15
15
  }
@@ -21,6 +21,7 @@ import { createDevmodeSyncService } from './sync';
21
21
  import { getDevmodeDeploymentId } from '../build/ast';
22
22
  import { BuildMetadata } from '@agentuity/server';
23
23
  import { getCommand } from '../../command-prefix';
24
+ import { notifyWorkbenchClients } from '../../utils/workbench-notify';
24
25
 
25
26
  const shouldDisableInteractive = (interactive?: boolean) => {
26
27
  if (!interactive) {
@@ -55,6 +56,12 @@ export const command = createCommand({
55
56
  .max(65535)
56
57
  .default(3500)
57
58
  .describe('The TCP port to start the dev start'),
59
+ watch: z
60
+ .array(z.string())
61
+ .optional()
62
+ .describe(
63
+ 'Additional paths to watch for changes (e.g., --watch ../packages/workbench/dist)'
64
+ ),
58
65
  }),
59
66
  },
60
67
  optional: { auth: 'Continue without an account (local only)', project: true },
@@ -230,6 +237,19 @@ export const command = createCommand({
230
237
 
231
238
  // Watch directories instead of files to survive atomic replacements (sed -i, cp)
232
239
  const watches = [rootDir];
240
+
241
+ // Add additional watch paths from options
242
+ if (opts.watch) {
243
+ for (const watchPath of opts.watch) {
244
+ const resolvedPath = resolve(rootDir, watchPath);
245
+ if (existsSync(resolvedPath)) {
246
+ watches.push(resolvedPath);
247
+ logger.debug('Added additional watch path: %s', resolvedPath);
248
+ } else {
249
+ logger.warn('Watch path does not exist: %s', resolvedPath);
250
+ }
251
+ }
252
+ }
233
253
  const watchers: FSWatcher[] = [];
234
254
  let failures = 0;
235
255
  let running = false;
@@ -249,7 +269,7 @@ export const command = createCommand({
249
269
  let gravityClient: Bun.Subprocess | undefined;
250
270
  let initialStartupComplete = false;
251
271
 
252
- const sdkKey = await loadProjectSDKKey(rootDir);
272
+ const sdkKey = await loadProjectSDKKey(logger, rootDir);
253
273
  if (!sdkKey) {
254
274
  tui.warning(`Couldn't find the AGENTUITY_SDK_KEY in ${rootDir} .env file`);
255
275
  }
@@ -450,6 +470,16 @@ export const command = createCommand({
450
470
  checkRestartThrottle();
451
471
  tui.info('Restarting on file change');
452
472
  showedRestartMessage = true;
473
+
474
+ // Notify workbench clients before killing the server
475
+ await notifyWorkbenchClients({
476
+ port: opts.port,
477
+ message: 'restarting',
478
+ });
479
+
480
+ // Small delay to ensure the restart message is processed before killing server
481
+ await new Promise((resolve) => setTimeout(resolve, 200));
482
+
453
483
  await kill();
454
484
  logger.trace('Server killed, continuing with restart');
455
485
  // Continue with restart after kill completes
@@ -624,6 +654,15 @@ export const command = createCommand({
624
654
  logger.trace('Initial startup complete, file watcher restarts now enabled');
625
655
  }
626
656
 
657
+ // Notify workbench clients that the server is alive and ready
658
+ // Use setTimeout to ensure server is fully ready before notifying
659
+ setTimeout(async () => {
660
+ await notifyWorkbenchClients({
661
+ port: opts.port,
662
+ message: 'alive',
663
+ });
664
+ }, 500);
665
+
627
666
  logger.trace('Attaching exit handler to dev server process...');
628
667
  // Attach non-blocking exit handler
629
668
  exitPromise
@@ -0,0 +1,31 @@
1
+ import { z } from 'zod';
2
+ import { createSubcommand } from '../../types';
3
+ import { getCommand } from '../../command-prefix';
4
+
5
+ export const currentCommand = createSubcommand({
6
+ name: 'current',
7
+ description: 'Show the name of the currently active profile',
8
+ tags: ['read-only', 'fast'],
9
+ idempotent: true,
10
+ aliases: [],
11
+ examples: [
12
+ { command: getCommand('profile current'), description: 'Show current profile' },
13
+ { command: getCommand('profile current --json'), description: 'Show output in JSON format' },
14
+ ],
15
+ schema: {
16
+ response: z.string().describe('The name of the current profile'),
17
+ },
18
+
19
+ async handler(ctx) {
20
+ const { options } = ctx;
21
+ const profileName = ctx.config?.name || 'production';
22
+
23
+ if (!options.json) {
24
+ console.log(profileName);
25
+ }
26
+
27
+ return profileName;
28
+ },
29
+ });
30
+
31
+ export default currentCommand;
@@ -4,6 +4,7 @@ import { useCommand } from './use';
4
4
  import { listCommand } from './list';
5
5
  import { showCommand } from './show';
6
6
  import { deleteCommand } from './delete';
7
+ import { currentCommand } from './current';
7
8
  import { getCommand } from '../../command-prefix';
8
9
 
9
10
  export const command = createCommand({
@@ -18,5 +19,12 @@ export const command = createCommand({
18
19
  description: 'Switch to production profile',
19
20
  },
20
21
  ],
21
- subcommands: [createProfileCmd, useCommand, listCommand, showCommand, deleteCommand],
22
+ subcommands: [
23
+ createProfileCmd,
24
+ useCommand,
25
+ listCommand,
26
+ showCommand,
27
+ deleteCommand,
28
+ currentCommand,
29
+ ],
22
30
  });
@@ -12,7 +12,6 @@ export const showCommand = createSubcommand({
12
12
  name: 'show',
13
13
  description: 'Show the configuration of a profile',
14
14
  tags: ['read-only', 'fast'],
15
- aliases: ['current'],
16
15
  examples: [
17
16
  { command: getCommand('profile show'), description: 'Show details' },
18
17
  { command: getCommand('profile show production'), description: 'Show details' },
@@ -17,10 +17,13 @@ export function getCommandPrefix(): string {
17
17
  const scriptPath = process.argv[1] || '';
18
18
  const normalized = path.normalize(scriptPath);
19
19
 
20
+ const isCompiledBinary =
21
+ process.argv[0] === 'bun' && scriptPath.startsWith('/$bunfs/root/agentuity-');
22
+
20
23
  // If we have AGENTUITY_CLI_VERSION set we are running from compiled binary OR
21
24
  // If the script is in node_modules/.bin or a global bin directory, it's likely global
22
25
  const isGlobal =
23
- process.env.AGENTUITY_CLI_VERSION ||
26
+ isCompiledBinary ||
24
27
  (normalized.includes(`${path.sep}bin${path.sep}`) &&
25
28
  !normalized.includes(`${path.sep}node_modules${path.sep}`) &&
26
29
  !normalized.includes(path.join('packages', 'cli', 'bin')));
package/src/config.ts CHANGED
@@ -631,28 +631,43 @@ export async function loadBuildMetadata(dir: string): Promise<BuildMetadata> {
631
631
  return result.data;
632
632
  }
633
633
 
634
- export async function loadProjectSDKKey(projectDir: string): Promise<string | undefined> {
634
+ export async function loadProjectSDKKey(
635
+ logger: Logger,
636
+ projectDir: string
637
+ ): Promise<string | undefined> {
638
+ const c = await getOrInitConfig();
635
639
  const files: string[] =
636
- process.env.NODE_ENV === 'production'
640
+ process.env.NODE_ENV === 'production' || c?.name !== 'local'
637
641
  ? ['.env', '.env.production']
638
- : ['.env.development', '.env.local', '.env'];
639
- const c = await getOrInitConfig();
642
+ : ['.env.development', '.env'];
640
643
  if (c) {
641
644
  files.unshift(`.env.${c.name}`);
642
645
  }
646
+ logger.trace(`[SDK_KEY] Searching for AGENTUITY_SDK_KEY in files: ${files.join(', ')}`);
647
+ logger.trace(`[SDK_KEY] Project directory: ${projectDir}`);
648
+ logger.trace(`[SDK_KEY] NODE_ENV: ${process.env.NODE_ENV}`);
643
649
  for (const filename of files) {
644
650
  const fn = join(projectDir, filename);
651
+ logger.trace(`[SDK_KEY] Checking file: ${fn}`);
645
652
  if (existsSync(fn)) {
653
+ logger.trace(`[SDK_KEY] File exists: ${fn}`);
646
654
  const buf = await Bun.file(fn).text();
647
655
  const tok = buf.split(/\n/);
648
656
  for (const t of tok) {
649
657
  if (t.charAt(0) !== '#' && t.startsWith('AGENTUITY_SDK_KEY=')) {
650
658
  const i = t.indexOf('=');
651
- return t.substring(i + 1).trim();
659
+ const key = t.substring(i + 1).trim();
660
+ logger.trace(`[SDK_KEY] Found AGENTUITY_SDK_KEY in: ${fn}`);
661
+ logger.trace(`[SDK_KEY] Key value: ${key.substring(0, 10)}...`);
662
+ return key;
652
663
  }
653
664
  }
665
+ logger.trace(`[SDK_KEY] No AGENTUITY_SDK_KEY found in: ${fn}`);
666
+ } else {
667
+ logger.trace(`[SDK_KEY] File does not exist: ${fn}`);
654
668
  }
655
669
  }
670
+ logger.trace(`[SDK_KEY] AGENTUITY_SDK_KEY not found in any file`);
656
671
  }
657
672
 
658
673
  export function getCatalystAPIClient(config: Config | null, logger: Logger, auth: AuthData) {
package/src/download.ts CHANGED
@@ -30,7 +30,7 @@ export async function downloadWithProgress(
30
30
  url,
31
31
  status: response.status,
32
32
  sessionId: response.headers.get('x-session-id'),
33
- error: `Download failed: ${response.statusText}`,
33
+ message: `Download failed: ${response.statusText}`,
34
34
  });
35
35
  }
36
36
 
package/src/env-util.ts CHANGED
@@ -70,6 +70,7 @@ export async function readEnvFile(path: string): Promise<EnvVars> {
70
70
  const file = Bun.file(path);
71
71
 
72
72
  if (!(await file.exists())) {
73
+ console.log(`[ENV] File does not exist: ${path}`);
73
74
  return {};
74
75
  }
75
76
 
@@ -84,6 +85,8 @@ export async function readEnvFile(path: string): Promise<EnvVars> {
84
85
  }
85
86
  }
86
87
 
88
+ console.log(`[ENV] Read ${Object.keys(env).length} variables from: ${path}`);
89
+ console.log(`[ENV] Variables: ${Object.keys(env).join(', ')}`);
87
90
  return env;
88
91
  }
89
92
 
@@ -0,0 +1,28 @@
1
+ import { z } from 'zod';
2
+
3
+ export const DeployOptionsSchema = z.object({
4
+ tag: z
5
+ .array(z.string())
6
+ .default(['latest'])
7
+ .optional()
8
+ .describe('One or more tags to add to the deployment'),
9
+ logsUrl: z.url().optional().describe('The url to the CI build logs'),
10
+ trigger: z
11
+ .enum(['cli', 'workflow', 'webhook'])
12
+ .default('cli')
13
+ .optional()
14
+ .describe('The trigger that caused the build'),
15
+ commitUrl: z.url().optional().describe('The url to the CI commit'),
16
+ message: z.string().optional().describe('The message to associate with this deployment'),
17
+ provider: z.string().optional().describe('The CI provider name (attempts to autodetect)'),
18
+ event: z
19
+ .enum(['pull_request', 'push', 'manual', 'workflow'])
20
+ .default('manual')
21
+ .optional()
22
+ .describe('The event that triggered the deployment'),
23
+ pullRequestNumber: z.number().optional().describe('the pull request number'),
24
+ pullRequestCommentId: z.string().optional().describe('the pull request comment id'),
25
+ pullRequestURL: z.url().optional().describe('the pull request url'),
26
+ });
27
+
28
+ export type DeployOptions = z.infer<typeof DeployOptionsSchema>;
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Utility to send notifications directly to workbench clients via WebSocket
3
+ */
4
+
5
+ export interface WorkbenchNotifyOptions {
6
+ port?: number;
7
+ message: 'restarting' | 'alive';
8
+ }
9
+
10
+ /**
11
+ * Send a notification directly to workbench clients via WebSocket
12
+ *
13
+ * @param options - Configuration for the notification
14
+ * @returns Promise that resolves when notification is sent
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * // Notify clients that server is restarting
19
+ * await notifyWorkbenchClients({
20
+ * baseUrl: 'ws://localhost:3500',
21
+ * message: 'restarting'
22
+ * });
23
+ *
24
+ * // Notify clients that server is alive
25
+ * await notifyWorkbenchClients({
26
+ * message: 'alive'
27
+ * });
28
+ * ```
29
+ */
30
+ export async function notifyWorkbenchClients(options: WorkbenchNotifyOptions): Promise<void> {
31
+ const { port = 3500, message } = options;
32
+
33
+ const wsUrl = new URL(`ws://localhost:${port}`);
34
+
35
+ return new Promise((resolve) => {
36
+ try {
37
+ wsUrl.pathname = '/_agentuity/workbench/ws';
38
+
39
+ const ws = new WebSocket(wsUrl.toString());
40
+
41
+ // Set a timeout to avoid hanging
42
+ const timeout = setTimeout(() => {
43
+ ws.close();
44
+ resolve();
45
+ }, 2000);
46
+
47
+ ws.onopen = () => {
48
+ ws.send(message);
49
+ ws.close();
50
+ };
51
+
52
+ ws.onclose = () => {
53
+ clearTimeout(timeout);
54
+ resolve();
55
+ };
56
+
57
+ ws.onerror = () => {
58
+ clearTimeout(timeout);
59
+ ws.close();
60
+ resolve();
61
+ };
62
+ } catch (_error) {
63
+ // Silently fail - this ensures the CLI doesn't fail if the app server isn't running
64
+ resolve();
65
+ }
66
+ });
67
+ }