@agentuity/cli 0.0.99 → 0.0.101

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 (107) hide show
  1. package/AGENTS.md +1 -1
  2. package/dist/api.d.ts +1 -0
  3. package/dist/api.d.ts.map +1 -1
  4. package/dist/api.js +1 -1
  5. package/dist/api.js.map +1 -1
  6. package/dist/auth.d.ts.map +1 -1
  7. package/dist/auth.js +5 -0
  8. package/dist/auth.js.map +1 -1
  9. package/dist/cmd/build/ast.d.ts +2 -1
  10. package/dist/cmd/build/ast.d.ts.map +1 -1
  11. package/dist/cmd/build/ast.js +135 -47
  12. package/dist/cmd/build/ast.js.map +1 -1
  13. package/dist/cmd/build/entry-generator.d.ts.map +1 -1
  14. package/dist/cmd/build/entry-generator.js +220 -188
  15. package/dist/cmd/build/entry-generator.js.map +1 -1
  16. package/dist/cmd/build/vite/agent-discovery.d.ts.map +1 -1
  17. package/dist/cmd/build/vite/agent-discovery.js +103 -45
  18. package/dist/cmd/build/vite/agent-discovery.js.map +1 -1
  19. package/dist/cmd/build/vite/bun-dev-server.js +1 -1
  20. package/dist/cmd/build/vite/bun-dev-server.js.map +1 -1
  21. package/dist/cmd/build/vite/docs-generator.d.ts +13 -0
  22. package/dist/cmd/build/vite/docs-generator.d.ts.map +1 -0
  23. package/dist/cmd/build/vite/docs-generator.js +81 -0
  24. package/dist/cmd/build/vite/docs-generator.js.map +1 -0
  25. package/dist/cmd/build/vite/index.d.ts +3 -4
  26. package/dist/cmd/build/vite/index.d.ts.map +1 -1
  27. package/dist/cmd/build/vite/index.js +9 -8
  28. package/dist/cmd/build/vite/index.js.map +1 -1
  29. package/dist/cmd/build/vite/lifecycle-generator.d.ts +1 -1
  30. package/dist/cmd/build/vite/lifecycle-generator.d.ts.map +1 -1
  31. package/dist/cmd/build/vite/lifecycle-generator.js +19 -5
  32. package/dist/cmd/build/vite/lifecycle-generator.js.map +1 -1
  33. package/dist/cmd/build/vite/metadata-generator.d.ts.map +1 -1
  34. package/dist/cmd/build/vite/metadata-generator.js +145 -0
  35. package/dist/cmd/build/vite/metadata-generator.js.map +1 -1
  36. package/dist/cmd/build/vite/registry-generator.d.ts +3 -3
  37. package/dist/cmd/build/vite/registry-generator.d.ts.map +1 -1
  38. package/dist/cmd/build/vite/registry-generator.js +627 -103
  39. package/dist/cmd/build/vite/registry-generator.js.map +1 -1
  40. package/dist/cmd/build/vite/route-discovery.d.ts +4 -0
  41. package/dist/cmd/build/vite/route-discovery.d.ts.map +1 -1
  42. package/dist/cmd/build/vite/route-discovery.js.map +1 -1
  43. package/dist/cmd/build/vite/server-bundler.d.ts.map +1 -1
  44. package/dist/cmd/build/vite/server-bundler.js +48 -1
  45. package/dist/cmd/build/vite/server-bundler.js.map +1 -1
  46. package/dist/cmd/build/vite/vite-builder.d.ts +1 -1
  47. package/dist/cmd/build/vite/vite-builder.d.ts.map +1 -1
  48. package/dist/cmd/build/vite/vite-builder.js +30 -21
  49. package/dist/cmd/build/vite/vite-builder.js.map +1 -1
  50. package/dist/cmd/build/vite-bundler.js +6 -6
  51. package/dist/cmd/build/vite-bundler.js.map +1 -1
  52. package/dist/cmd/cloud/deploy.d.ts.map +1 -1
  53. package/dist/cmd/cloud/deploy.js +11 -5
  54. package/dist/cmd/cloud/deploy.js.map +1 -1
  55. package/dist/cmd/dev/file-watcher.d.ts.map +1 -1
  56. package/dist/cmd/dev/file-watcher.js +33 -1
  57. package/dist/cmd/dev/file-watcher.js.map +1 -1
  58. package/dist/cmd/dev/index.d.ts.map +1 -1
  59. package/dist/cmd/dev/index.js +102 -21
  60. package/dist/cmd/dev/index.js.map +1 -1
  61. package/dist/cmd/dev/sync.d.ts.map +1 -1
  62. package/dist/cmd/dev/sync.js +19 -3
  63. package/dist/cmd/dev/sync.js.map +1 -1
  64. package/dist/cmd/project/create.d.ts.map +1 -1
  65. package/dist/cmd/project/create.js +8 -2
  66. package/dist/cmd/project/create.js.map +1 -1
  67. package/dist/config.d.ts.map +1 -1
  68. package/dist/config.js +8 -0
  69. package/dist/config.js.map +1 -1
  70. package/dist/index.d.ts +0 -1
  71. package/dist/index.d.ts.map +1 -1
  72. package/dist/index.js +0 -1
  73. package/dist/index.js.map +1 -1
  74. package/package.json +5 -8
  75. package/src/api.ts +1 -1
  76. package/src/auth.ts +6 -0
  77. package/src/cmd/build/ast.ts +161 -48
  78. package/src/cmd/build/entry-generator.ts +225 -190
  79. package/src/cmd/build/vite/agent-discovery.ts +151 -58
  80. package/src/cmd/build/vite/bun-dev-server.ts +1 -1
  81. package/src/cmd/build/vite/docs-generator.ts +87 -0
  82. package/src/cmd/build/vite/index.ts +9 -8
  83. package/src/cmd/build/vite/lifecycle-generator.ts +19 -5
  84. package/src/cmd/build/vite/metadata-generator.ts +178 -0
  85. package/src/cmd/build/vite/registry-generator.ts +727 -108
  86. package/src/cmd/build/vite/route-discovery.ts +4 -0
  87. package/src/cmd/build/vite/server-bundler.ts +56 -1
  88. package/src/cmd/build/vite/vite-builder.ts +46 -33
  89. package/src/cmd/build/vite-bundler.ts +6 -6
  90. package/src/cmd/cloud/deploy.ts +15 -5
  91. package/src/cmd/dev/file-watcher.ts +37 -1
  92. package/src/cmd/dev/index.ts +141 -30
  93. package/src/cmd/dev/sync.ts +41 -6
  94. package/src/cmd/project/create.ts +13 -3
  95. package/src/config.ts +9 -0
  96. package/src/index.ts +0 -5
  97. package/src/runtime-bootstrap.md +1 -1
  98. package/dist/cmd/build/vite/patch-plugin.d.ts +0 -21
  99. package/dist/cmd/build/vite/patch-plugin.d.ts.map +0 -1
  100. package/dist/cmd/build/vite/patch-plugin.js +0 -70
  101. package/dist/cmd/build/vite/patch-plugin.js.map +0 -1
  102. package/dist/runtime-bootstrap.d.ts +0 -56
  103. package/dist/runtime-bootstrap.d.ts.map +0 -1
  104. package/dist/runtime-bootstrap.js +0 -95
  105. package/dist/runtime-bootstrap.js.map +0 -1
  106. package/src/cmd/build/vite/patch-plugin.ts +0 -88
  107. package/src/runtime-bootstrap.ts +0 -131
@@ -171,9 +171,21 @@ class DevmodeSyncService implements IDevmodeSyncService {
171
171
  for (const agent of currentMetadata.agents || []) {
172
172
  if (agent.evals) {
173
173
  currentEvalCount += agent.evals.length;
174
+ this.logger.info(
175
+ '[CLI EVAL SYNC] Agent "%s" has %d eval(s)',
176
+ agent.name,
177
+ agent.evals.length
178
+ );
179
+ for (const evalItem of agent.evals) {
180
+ this.logger.info(
181
+ '[CLI EVAL SYNC] - %s (evalId: %s)',
182
+ evalItem.name,
183
+ evalItem.evalId
184
+ );
185
+ }
174
186
  }
175
187
  }
176
- this.logger.debug('Processing %d current eval(s)', currentEvalCount);
188
+ this.logger.info('[CLI EVAL SYNC] Total current eval(s): %d', currentEvalCount);
177
189
 
178
190
  // Get agents and evals to sync using shared diff logic
179
191
  const { create: agentsToCreate, delete: agentsToDelete } = getAgentsToSync(
@@ -261,7 +273,14 @@ class DevmodeSyncService implements IDevmodeSyncService {
261
273
  evalsToDelete: string[],
262
274
  deploymentId: string
263
275
  ): Promise<void> {
276
+ this.logger.info(
277
+ '[CLI EVAL SYNC] syncEvals called: %d to create, %d to delete',
278
+ evals.length,
279
+ evalsToDelete.length
280
+ );
281
+
264
282
  if (evals.length === 0 && evalsToDelete.length === 0) {
283
+ this.logger.info('[CLI EVAL SYNC] No evals to sync, skipping');
265
284
  return;
266
285
  }
267
286
 
@@ -270,12 +289,28 @@ class DevmodeSyncService implements IDevmodeSyncService {
270
289
  create: evals,
271
290
  delete: evalsToDelete,
272
291
  };
273
- this.logger.trace(
274
- '[CLI EVAL SYNC] Sending payload to POST /cli/devmode/eval: %s',
275
- JSON.stringify(payload, null, 2)
276
- );
277
292
 
278
- await this.apiClient.post('/cli/devmode/eval', payload, z.object({ success: z.boolean() }));
293
+ this.logger.info('[CLI EVAL SYNC] Sending payload to POST /cli/devmode/eval:');
294
+ for (const evalItem of evals) {
295
+ this.logger.info(
296
+ '[CLI EVAL SYNC] - %s (id: %s, evalId: %s)',
297
+ evalItem.name,
298
+ evalItem.id,
299
+ evalItem.evalId
300
+ );
301
+ }
302
+
303
+ try {
304
+ await this.apiClient.post(
305
+ '/cli/devmode/eval',
306
+ payload,
307
+ z.object({ success: z.boolean() })
308
+ );
309
+ this.logger.info('[CLI EVAL SYNC] Sync successful');
310
+ } catch (error) {
311
+ this.logger.error('[CLI EVAL SYNC] Sync failed: %s', error);
312
+ throw error;
313
+ }
279
314
  }
280
315
  }
281
316
 
@@ -1,7 +1,8 @@
1
- import { createSubcommand } from '../../types';
1
+ import { createSubcommand, type CommandContext, type AuthData } from '../../types';
2
2
  import { z } from 'zod';
3
3
  import { runCreateFlow } from './template-flow';
4
4
  import { getCommand } from '../../command-prefix';
5
+ import type { APIClient as APIClientType } from '../../api';
5
6
 
6
7
  const ProjectCreateResponseSchema = z.object({
7
8
  success: z.boolean().describe('Whether the operation succeeded'),
@@ -21,7 +22,7 @@ export const createProjectSubcommand = createSubcommand({
21
22
  banner: true,
22
23
  toplevel: true,
23
24
  idempotent: false,
24
- optional: { auth: true, org: true, region: true, apiClient: true },
25
+ optional: { auth: true, region: true, apiClient: true },
25
26
  examples: [
26
27
  { command: getCommand('project create'), description: 'Create new item' },
27
28
  { command: getCommand('project create --name my-ai-agent'), description: 'Create new item' },
@@ -69,7 +70,16 @@ export const createProjectSubcommand = createSubcommand({
69
70
  },
70
71
 
71
72
  async handler(ctx) {
72
- const { logger, opts, auth, config, apiClient, orgId, region } = ctx;
73
+ const { logger, opts, auth, config, apiClient, region } = ctx;
74
+
75
+ // Only get org if registering
76
+ let orgId: string | undefined;
77
+ if (opts.register === true && auth && apiClient) {
78
+ const { optionalOrg } = await import('../../auth');
79
+ orgId = await optionalOrg(
80
+ ctx as CommandContext & { apiClient?: APIClientType; auth?: AuthData }
81
+ );
82
+ }
73
83
 
74
84
  await runCreateFlow({
75
85
  projectName: opts.name,
package/src/config.ts CHANGED
@@ -364,6 +364,15 @@ export async function getAuth(): Promise<AuthData | null> {
364
364
  };
365
365
  }
366
366
 
367
+ // Priority 1a: Allow automated login from environment variables (this is set in deployment)
368
+ if (process.env.AGENTUITY_API_KEY) {
369
+ return {
370
+ apiKey: process.env.AGENTUITY_API_KEY,
371
+ userId: '',
372
+ expires: new Date(Date.now() + 30 * 60_000),
373
+ };
374
+ }
375
+
367
376
  // Priority 2: On macOS, try to read from Keychain
368
377
  if (isMacOS()) {
369
378
  try {
package/src/index.ts CHANGED
@@ -75,11 +75,6 @@ export { showBanner } from './banner';
75
75
  export { discoverCommands } from './cmd';
76
76
  export { detectColorScheme } from './terminal';
77
77
  export { getCommandPrefix, getCommand } from './command-prefix';
78
- export {
79
- bootstrapRuntimeEnv,
80
- type RuntimeBootstrapOptions,
81
- type RuntimeBootstrapResult,
82
- } from './runtime-bootstrap';
83
78
  export * as tui from './tui';
84
79
  export {
85
80
  createRepl,
@@ -43,7 +43,7 @@ Call `bootstrapRuntimeEnv()` at the top of your `app.ts` **before** `createApp()
43
43
 
44
44
  ```ts
45
45
  import { createApp } from '@agentuity/runtime';
46
- import { bootstrapRuntimeEnv } from '@agentuity/cli';
46
+ import { bootstrapRuntimeEnv } from '@agentuity/runtime';
47
47
 
48
48
  // Bootstrap runtime environment based on active profile
49
49
  await bootstrapRuntimeEnv();
@@ -1,21 +0,0 @@
1
- /**
2
- * Vite Plugin for Runtime Patching
3
- *
4
- * Applies runtime patches to AI SDK packages to inject:
5
- * - Agentuity AI Gateway routing
6
- * - Telemetry enablement
7
- * - Environment variable guards
8
- *
9
- * This plugin uses Vite's transform hook to modify module code during bundling.
10
- */
11
- import type { Plugin } from 'vite';
12
- import type { Logger } from '../../../types';
13
- export interface PatchPluginOptions {
14
- logger: Logger;
15
- dev?: boolean;
16
- }
17
- /**
18
- * Create Vite plugin that patches AI SDK modules at build time
19
- */
20
- export declare function patchPlugin(options: PatchPluginOptions): Plugin;
21
- //# sourceMappingURL=patch-plugin.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"patch-plugin.d.ts","sourceRoot":"","sources":["../../../../src/cmd/build/vite/patch-plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAG7C,MAAM,WAAW,kBAAkB;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,OAAO,CAAC;CACd;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,MAAM,CAgE/D"}
@@ -1,70 +0,0 @@
1
- /**
2
- * Vite Plugin for Runtime Patching
3
- *
4
- * Applies runtime patches to AI SDK packages to inject:
5
- * - Agentuity AI Gateway routing
6
- * - Telemetry enablement
7
- * - Environment variable guards
8
- *
9
- * This plugin uses Vite's transform hook to modify module code during bundling.
10
- */
11
- import { generatePatches, applyPatch } from '../patch';
12
- /**
13
- * Create Vite plugin that patches AI SDK modules at build time
14
- */
15
- export function patchPlugin(options) {
16
- const { logger } = options;
17
- const patches = generatePatches();
18
- // Log registered patches
19
- logger.trace('Patch plugin initialized with %d patch(es)', patches.size);
20
- for (const [moduleName] of patches) {
21
- logger.trace(' - %s', moduleName);
22
- }
23
- return {
24
- name: 'agentuity:patch',
25
- enforce: 'post', // Run after other transforms
26
- /**
27
- * Transform hook - patches modules during bundling
28
- */
29
- async transform(code, id) {
30
- // Check if this module needs patching
31
- for (const [moduleName, patch] of patches) {
32
- // Match module by package name
33
- const normalizedId = id.replace(/\\/g, '/');
34
- // Check if this file matches the patch module
35
- // Example: node_modules/@ai-sdk/openai/dist/index.js
36
- if (!normalizedId.includes(`node_modules/${moduleName}/`)) {
37
- continue;
38
- }
39
- // If patch specifies a filename, ensure it matches
40
- if (patch.filename) {
41
- const expectedPath = `${moduleName}/${patch.filename}`;
42
- if (!normalizedId.includes(expectedPath) &&
43
- !normalizedId.includes(`${expectedPath}.js`) &&
44
- !normalizedId.includes(`${expectedPath}.mjs`) &&
45
- !normalizedId.includes(`${expectedPath}.ts`)) {
46
- continue;
47
- }
48
- }
49
- // Apply the patch
50
- logger.debug('Applying patch to %s', moduleName);
51
- try {
52
- const [patchedCode] = await applyPatch(id, patch);
53
- // Return transformed code with source map
54
- return {
55
- code: patchedCode,
56
- map: null, // Could add source map generation here
57
- };
58
- }
59
- catch (error) {
60
- logger.warn('Failed to apply patch to %s: %s', moduleName, error);
61
- // Continue without patching on error
62
- return null;
63
- }
64
- }
65
- // No patch needed
66
- return null;
67
- },
68
- };
69
- }
70
- //# sourceMappingURL=patch-plugin.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"patch-plugin.js","sourceRoot":"","sources":["../../../../src/cmd/build/vite/patch-plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAOvD;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,OAA2B;IACtD,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAC3B,MAAM,OAAO,GAAG,eAAe,EAAE,CAAC;IAElC,yBAAyB;IACzB,MAAM,CAAC,KAAK,CAAC,4CAA4C,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACzE,KAAK,MAAM,CAAC,UAAU,CAAC,IAAI,OAAO,EAAE,CAAC;QACpC,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IACpC,CAAC;IAED,OAAO;QACN,IAAI,EAAE,iBAAiB;QACvB,OAAO,EAAE,MAAM,EAAE,6BAA6B;QAE9C;;WAEG;QACH,KAAK,CAAC,SAAS,CAAC,IAAY,EAAE,EAAU;YACvC,sCAAsC;YACtC,KAAK,MAAM,CAAC,UAAU,EAAE,KAAK,CAAC,IAAI,OAAO,EAAE,CAAC;gBAC3C,+BAA+B;gBAC/B,MAAM,YAAY,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;gBAE5C,8CAA8C;gBAC9C,qDAAqD;gBACrD,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,gBAAgB,UAAU,GAAG,CAAC,EAAE,CAAC;oBAC3D,SAAS;gBACV,CAAC;gBAED,mDAAmD;gBACnD,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;oBACpB,MAAM,YAAY,GAAG,GAAG,UAAU,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;oBACvD,IACC,CAAC,YAAY,CAAC,QAAQ,CAAC,YAAY,CAAC;wBACpC,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,YAAY,KAAK,CAAC;wBAC5C,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,YAAY,MAAM,CAAC;wBAC7C,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,YAAY,KAAK,CAAC,EAC3C,CAAC;wBACF,SAAS;oBACV,CAAC;gBACF,CAAC;gBAED,kBAAkB;gBAClB,MAAM,CAAC,KAAK,CAAC,sBAAsB,EAAE,UAAU,CAAC,CAAC;gBAEjD,IAAI,CAAC;oBACJ,MAAM,CAAC,WAAW,CAAC,GAAG,MAAM,UAAU,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;oBAElD,0CAA0C;oBAC1C,OAAO;wBACN,IAAI,EAAE,WAAW;wBACjB,GAAG,EAAE,IAAI,EAAE,uCAAuC;qBAClD,CAAC;gBACH,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBAChB,MAAM,CAAC,IAAI,CAAC,iCAAiC,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;oBAClE,qCAAqC;oBACrC,OAAO,IAAI,CAAC;gBACb,CAAC;YACF,CAAC;YAED,kBAAkB;YAClB,OAAO,IAAI,CAAC;QACb,CAAC;KACD,CAAC;AACH,CAAC"}
@@ -1,56 +0,0 @@
1
- /**
2
- * Runtime environment bootstrapping utility
3
- *
4
- * Loads configuration and environment variables based on the active profile
5
- * before createApp() is called. This ensures .env.{profile} files and
6
- * agentuity.{profile}.json configs are respected.
7
- */
8
- import type { Config, ProjectConfig } from './types';
9
- export interface RuntimeBootstrapOptions {
10
- /**
11
- * Project directory containing agentuity.json and .env files
12
- * @default process.cwd()
13
- */
14
- projectDir?: string;
15
- /**
16
- * Override the active profile (otherwise uses loadConfig())
17
- */
18
- profile?: string;
19
- }
20
- export interface RuntimeBootstrapResult {
21
- /**
22
- * Resolved CLI config (from ~/.config/agentuity/)
23
- */
24
- config: Config | null;
25
- /**
26
- * Resolved project config (agentuity.json or agentuity.{profile}.json)
27
- */
28
- projectConfig: ProjectConfig | null;
29
- }
30
- /**
31
- * Bootstrap runtime environment by loading profile-aware config and env files.
32
- *
33
- * This function:
34
- * 1. Resolves the active profile (from AGENTUITY_PROFILE env or profile config)
35
- * 2. Loads .env.{profile}, .env.development, or .env based on profile
36
- * 3. Sets AGENTUITY_REGION=local for local profile (overrides project config for infrastructure)
37
- * 4. Loads agentuity.{profile}.json if it exists
38
- * 5. Sets AGENTUITY_REGION from project config if not already set (non-local profiles only)
39
- * 6. Does NOT override environment variables already set
40
- *
41
- * Call this BEFORE createApp() in your app.ts:
42
- *
43
- * @example
44
- * ```ts
45
- * import { bootstrapRuntimeEnv } from '@agentuity/cli/runtime-bootstrap';
46
- * import { createApp } from '@agentuity/runtime';
47
- *
48
- * // Load config and env based on active profile
49
- * await bootstrapRuntimeEnv();
50
- *
51
- * // Now createApp() will use the correct env vars
52
- * const app = await createApp();
53
- * ```
54
- */
55
- export declare function bootstrapRuntimeEnv(options?: RuntimeBootstrapOptions): Promise<RuntimeBootstrapResult>;
56
- //# sourceMappingURL=runtime-bootstrap.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"runtime-bootstrap.d.ts","sourceRoot":"","sources":["../src/runtime-bootstrap.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAErD,MAAM,WAAW,uBAAuB;IACvC;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,sBAAsB;IACtC;;OAEG;IACH,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAEtB;;OAEG;IACH,aAAa,EAAE,aAAa,GAAG,IAAI,CAAC;CACpC;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAsB,mBAAmB,CACxC,OAAO,GAAE,uBAA4B,GACnC,OAAO,CAAC,sBAAsB,CAAC,CAkEjC"}
@@ -1,95 +0,0 @@
1
- /**
2
- * Runtime environment bootstrapping utility
3
- *
4
- * Loads configuration and environment variables based on the active profile
5
- * before createApp() is called. This ensures .env.{profile} files and
6
- * agentuity.{profile}.json configs are respected.
7
- */
8
- import { loadConfig, loadProjectConfig } from './config';
9
- import { getEnvFilePaths, readEnvFile } from './env-util';
10
- /**
11
- * Bootstrap runtime environment by loading profile-aware config and env files.
12
- *
13
- * This function:
14
- * 1. Resolves the active profile (from AGENTUITY_PROFILE env or profile config)
15
- * 2. Loads .env.{profile}, .env.development, or .env based on profile
16
- * 3. Sets AGENTUITY_REGION=local for local profile (overrides project config for infrastructure)
17
- * 4. Loads agentuity.{profile}.json if it exists
18
- * 5. Sets AGENTUITY_REGION from project config if not already set (non-local profiles only)
19
- * 6. Does NOT override environment variables already set
20
- *
21
- * Call this BEFORE createApp() in your app.ts:
22
- *
23
- * @example
24
- * ```ts
25
- * import { bootstrapRuntimeEnv } from '@agentuity/cli/runtime-bootstrap';
26
- * import { createApp } from '@agentuity/runtime';
27
- *
28
- * // Load config and env based on active profile
29
- * await bootstrapRuntimeEnv();
30
- *
31
- * // Now createApp() will use the correct env vars
32
- * const app = await createApp();
33
- * ```
34
- */
35
- export async function bootstrapRuntimeEnv(options = {}) {
36
- const projectDir = options.projectDir || process.cwd();
37
- // Load CLI config to determine active profile
38
- let cfg = null;
39
- try {
40
- cfg = await loadConfig();
41
- // Override profile if specified
42
- if (options.profile) {
43
- cfg = { ...cfg, name: options.profile };
44
- }
45
- }
46
- catch {
47
- // No config found - OK for tests without CLI setup
48
- }
49
- // Determine which .env files to load based on profile
50
- const isProduction = process.env.NODE_ENV === 'production';
51
- const envPaths = getEnvFilePaths(projectDir, {
52
- configName: cfg?.name,
53
- isProduction,
54
- });
55
- // Load and merge env files (later files override earlier ones)
56
- let fileEnv = {};
57
- for (const path of envPaths) {
58
- const vars = await readEnvFile(path);
59
- // Later files override earlier ones
60
- fileEnv = { ...fileEnv, ...vars };
61
- }
62
- // Apply to process.env ONLY if not already set
63
- // This ensures existing env vars (from shell/CI) always win
64
- for (const [key, value] of Object.entries(fileEnv)) {
65
- if (process.env[key] === undefined) {
66
- process.env[key] = value;
67
- }
68
- }
69
- // For local profile, default AGENTUITY_REGION to 'local'
70
- // This makes getServiceUrls() use *.agentuity.io instead of *.agentuity.cloud
71
- if (cfg?.name === 'local' && !process.env.AGENTUITY_REGION) {
72
- process.env.AGENTUITY_REGION = 'local';
73
- }
74
- // Propagate profile name into env for consistency
75
- if (cfg?.name && !process.env.AGENTUITY_PROFILE) {
76
- process.env.AGENTUITY_PROFILE = cfg.name;
77
- }
78
- // Load project config (agentuity.json or agentuity.{profile}.json)
79
- let projectConfig = null;
80
- try {
81
- projectConfig = await loadProjectConfig(projectDir, cfg ?? undefined);
82
- // Set AGENTUITY_REGION from project config if not already set
83
- if (projectConfig?.region && !process.env.AGENTUITY_REGION) {
84
- process.env.AGENTUITY_REGION = projectConfig.region;
85
- }
86
- }
87
- catch {
88
- // OK for tests that don't need project config
89
- }
90
- return {
91
- config: cfg,
92
- projectConfig,
93
- };
94
- }
95
- //# sourceMappingURL=runtime-bootstrap.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"runtime-bootstrap.js","sourceRoot":"","sources":["../src/runtime-bootstrap.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,WAAW,EAAgB,MAAM,YAAY,CAAC;AA4BxE;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACxC,UAAmC,EAAE;IAErC,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IAEvD,8CAA8C;IAC9C,IAAI,GAAG,GAAkB,IAAI,CAAC;IAC9B,IAAI,CAAC;QACJ,GAAG,GAAG,MAAM,UAAU,EAAE,CAAC;QACzB,gCAAgC;QAChC,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;YACrB,GAAG,GAAG,EAAE,GAAG,GAAG,EAAE,IAAI,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC;QACzC,CAAC;IACF,CAAC;IAAC,MAAM,CAAC;QACR,mDAAmD;IACpD,CAAC;IAED,sDAAsD;IACtD,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAC;IAC3D,MAAM,QAAQ,GAAG,eAAe,CAAC,UAAU,EAAE;QAC5C,UAAU,EAAE,GAAG,EAAE,IAAI;QACrB,YAAY;KACZ,CAAC,CAAC;IAEH,+DAA+D;IAC/D,IAAI,OAAO,GAAY,EAAE,CAAC;IAC1B,KAAK,MAAM,IAAI,IAAI,QAAQ,EAAE,CAAC;QAC7B,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC,IAAI,CAAC,CAAC;QACrC,oCAAoC;QACpC,OAAO,GAAG,EAAE,GAAG,OAAO,EAAE,GAAG,IAAI,EAAE,CAAC;IACnC,CAAC;IAED,+CAA+C;IAC/C,4DAA4D;IAC5D,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACpD,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,SAAS,EAAE,CAAC;YACpC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QAC1B,CAAC;IACF,CAAC;IAED,yDAAyD;IACzD,8EAA8E;IAC9E,IAAI,GAAG,EAAE,IAAI,KAAK,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;QAC5D,OAAO,CAAC,GAAG,CAAC,gBAAgB,GAAG,OAAO,CAAC;IACxC,CAAC;IAED,kDAAkD;IAClD,IAAI,GAAG,EAAE,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,CAAC;QACjD,OAAO,CAAC,GAAG,CAAC,iBAAiB,GAAG,GAAG,CAAC,IAAI,CAAC;IAC1C,CAAC;IAED,mEAAmE;IACnE,IAAI,aAAa,GAAyB,IAAI,CAAC;IAC/C,IAAI,CAAC;QACJ,aAAa,GAAG,MAAM,iBAAiB,CAAC,UAAU,EAAE,GAAG,IAAI,SAAS,CAAC,CAAC;QAEtE,8DAA8D;QAC9D,IAAI,aAAa,EAAE,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;YAC5D,OAAO,CAAC,GAAG,CAAC,gBAAgB,GAAG,aAAa,CAAC,MAAM,CAAC;QACrD,CAAC;IACF,CAAC;IAAC,MAAM,CAAC;QACR,8CAA8C;IAC/C,CAAC;IAED,OAAO;QACN,MAAM,EAAE,GAAG;QACX,aAAa;KACb,CAAC;AACH,CAAC"}
@@ -1,88 +0,0 @@
1
- /**
2
- * Vite Plugin for Runtime Patching
3
- *
4
- * Applies runtime patches to AI SDK packages to inject:
5
- * - Agentuity AI Gateway routing
6
- * - Telemetry enablement
7
- * - Environment variable guards
8
- *
9
- * This plugin uses Vite's transform hook to modify module code during bundling.
10
- */
11
-
12
- import type { Plugin } from 'vite';
13
- import type { Logger } from '../../../types';
14
- import { generatePatches, applyPatch } from '../patch';
15
-
16
- export interface PatchPluginOptions {
17
- logger: Logger;
18
- dev?: boolean;
19
- }
20
-
21
- /**
22
- * Create Vite plugin that patches AI SDK modules at build time
23
- */
24
- export function patchPlugin(options: PatchPluginOptions): Plugin {
25
- const { logger } = options;
26
- const patches = generatePatches();
27
-
28
- // Log registered patches
29
- logger.trace('Patch plugin initialized with %d patch(es)', patches.size);
30
- for (const [moduleName] of patches) {
31
- logger.trace(' - %s', moduleName);
32
- }
33
-
34
- return {
35
- name: 'agentuity:patch',
36
- enforce: 'post', // Run after other transforms
37
-
38
- /**
39
- * Transform hook - patches modules during bundling
40
- */
41
- async transform(code: string, id: string) {
42
- // Check if this module needs patching
43
- for (const [moduleName, patch] of patches) {
44
- // Match module by package name
45
- const normalizedId = id.replace(/\\/g, '/');
46
-
47
- // Check if this file matches the patch module
48
- // Example: node_modules/@ai-sdk/openai/dist/index.js
49
- if (!normalizedId.includes(`node_modules/${moduleName}/`)) {
50
- continue;
51
- }
52
-
53
- // If patch specifies a filename, ensure it matches
54
- if (patch.filename) {
55
- const expectedPath = `${moduleName}/${patch.filename}`;
56
- if (
57
- !normalizedId.includes(expectedPath) &&
58
- !normalizedId.includes(`${expectedPath}.js`) &&
59
- !normalizedId.includes(`${expectedPath}.mjs`) &&
60
- !normalizedId.includes(`${expectedPath}.ts`)
61
- ) {
62
- continue;
63
- }
64
- }
65
-
66
- // Apply the patch
67
- logger.debug('Applying patch to %s', moduleName);
68
-
69
- try {
70
- const [patchedCode] = await applyPatch(id, patch);
71
-
72
- // Return transformed code with source map
73
- return {
74
- code: patchedCode,
75
- map: null, // Could add source map generation here
76
- };
77
- } catch (error) {
78
- logger.warn('Failed to apply patch to %s: %s', moduleName, error);
79
- // Continue without patching on error
80
- return null;
81
- }
82
- }
83
-
84
- // No patch needed
85
- return null;
86
- },
87
- };
88
- }
@@ -1,131 +0,0 @@
1
- /**
2
- * Runtime environment bootstrapping utility
3
- *
4
- * Loads configuration and environment variables based on the active profile
5
- * before createApp() is called. This ensures .env.{profile} files and
6
- * agentuity.{profile}.json configs are respected.
7
- */
8
-
9
- import { loadConfig, loadProjectConfig } from './config';
10
- import { getEnvFilePaths, readEnvFile, type EnvVars } from './env-util';
11
- import type { Config, ProjectConfig } from './types';
12
-
13
- export interface RuntimeBootstrapOptions {
14
- /**
15
- * Project directory containing agentuity.json and .env files
16
- * @default process.cwd()
17
- */
18
- projectDir?: string;
19
-
20
- /**
21
- * Override the active profile (otherwise uses loadConfig())
22
- */
23
- profile?: string;
24
- }
25
-
26
- export interface RuntimeBootstrapResult {
27
- /**
28
- * Resolved CLI config (from ~/.config/agentuity/)
29
- */
30
- config: Config | null;
31
-
32
- /**
33
- * Resolved project config (agentuity.json or agentuity.{profile}.json)
34
- */
35
- projectConfig: ProjectConfig | null;
36
- }
37
-
38
- /**
39
- * Bootstrap runtime environment by loading profile-aware config and env files.
40
- *
41
- * This function:
42
- * 1. Resolves the active profile (from AGENTUITY_PROFILE env or profile config)
43
- * 2. Loads .env.{profile}, .env.development, or .env based on profile
44
- * 3. Sets AGENTUITY_REGION=local for local profile (overrides project config for infrastructure)
45
- * 4. Loads agentuity.{profile}.json if it exists
46
- * 5. Sets AGENTUITY_REGION from project config if not already set (non-local profiles only)
47
- * 6. Does NOT override environment variables already set
48
- *
49
- * Call this BEFORE createApp() in your app.ts:
50
- *
51
- * @example
52
- * ```ts
53
- * import { bootstrapRuntimeEnv } from '@agentuity/cli/runtime-bootstrap';
54
- * import { createApp } from '@agentuity/runtime';
55
- *
56
- * // Load config and env based on active profile
57
- * await bootstrapRuntimeEnv();
58
- *
59
- * // Now createApp() will use the correct env vars
60
- * const app = await createApp();
61
- * ```
62
- */
63
- export async function bootstrapRuntimeEnv(
64
- options: RuntimeBootstrapOptions = {}
65
- ): Promise<RuntimeBootstrapResult> {
66
- const projectDir = options.projectDir || process.cwd();
67
-
68
- // Load CLI config to determine active profile
69
- let cfg: Config | null = null;
70
- try {
71
- cfg = await loadConfig();
72
- // Override profile if specified
73
- if (options.profile) {
74
- cfg = { ...cfg, name: options.profile };
75
- }
76
- } catch {
77
- // No config found - OK for tests without CLI setup
78
- }
79
-
80
- // Determine which .env files to load based on profile
81
- const isProduction = process.env.NODE_ENV === 'production';
82
- const envPaths = getEnvFilePaths(projectDir, {
83
- configName: cfg?.name,
84
- isProduction,
85
- });
86
-
87
- // Load and merge env files (later files override earlier ones)
88
- let fileEnv: EnvVars = {};
89
- for (const path of envPaths) {
90
- const vars = await readEnvFile(path);
91
- // Later files override earlier ones
92
- fileEnv = { ...fileEnv, ...vars };
93
- }
94
-
95
- // Apply to process.env ONLY if not already set
96
- // This ensures existing env vars (from shell/CI) always win
97
- for (const [key, value] of Object.entries(fileEnv)) {
98
- if (process.env[key] === undefined) {
99
- process.env[key] = value;
100
- }
101
- }
102
-
103
- // For local profile, default AGENTUITY_REGION to 'local'
104
- // This makes getServiceUrls() use *.agentuity.io instead of *.agentuity.cloud
105
- if (cfg?.name === 'local' && !process.env.AGENTUITY_REGION) {
106
- process.env.AGENTUITY_REGION = 'local';
107
- }
108
-
109
- // Propagate profile name into env for consistency
110
- if (cfg?.name && !process.env.AGENTUITY_PROFILE) {
111
- process.env.AGENTUITY_PROFILE = cfg.name;
112
- }
113
-
114
- // Load project config (agentuity.json or agentuity.{profile}.json)
115
- let projectConfig: ProjectConfig | null = null;
116
- try {
117
- projectConfig = await loadProjectConfig(projectDir, cfg ?? undefined);
118
-
119
- // Set AGENTUITY_REGION from project config if not already set
120
- if (projectConfig?.region && !process.env.AGENTUITY_REGION) {
121
- process.env.AGENTUITY_REGION = projectConfig.region;
122
- }
123
- } catch {
124
- // OK for tests that don't need project config
125
- }
126
-
127
- return {
128
- config: cfg,
129
- projectConfig,
130
- };
131
- }