@agentuity/cli 0.0.100 → 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.
- package/AGENTS.md +1 -1
- package/dist/api.d.ts +1 -0
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +1 -1
- package/dist/api.js.map +1 -1
- package/dist/cmd/build/ast.d.ts +2 -1
- package/dist/cmd/build/ast.d.ts.map +1 -1
- package/dist/cmd/build/ast.js +135 -47
- package/dist/cmd/build/ast.js.map +1 -1
- package/dist/cmd/build/entry-generator.d.ts.map +1 -1
- package/dist/cmd/build/entry-generator.js +220 -188
- package/dist/cmd/build/entry-generator.js.map +1 -1
- package/dist/cmd/build/vite/agent-discovery.d.ts.map +1 -1
- package/dist/cmd/build/vite/agent-discovery.js +103 -45
- package/dist/cmd/build/vite/agent-discovery.js.map +1 -1
- package/dist/cmd/build/vite/bun-dev-server.js +1 -1
- package/dist/cmd/build/vite/bun-dev-server.js.map +1 -1
- package/dist/cmd/build/vite/docs-generator.d.ts +13 -0
- package/dist/cmd/build/vite/docs-generator.d.ts.map +1 -0
- package/dist/cmd/build/vite/docs-generator.js +81 -0
- package/dist/cmd/build/vite/docs-generator.js.map +1 -0
- package/dist/cmd/build/vite/index.d.ts +3 -3
- package/dist/cmd/build/vite/index.d.ts.map +1 -1
- package/dist/cmd/build/vite/index.js +9 -7
- package/dist/cmd/build/vite/index.js.map +1 -1
- package/dist/cmd/build/vite/lifecycle-generator.d.ts +1 -1
- package/dist/cmd/build/vite/lifecycle-generator.d.ts.map +1 -1
- package/dist/cmd/build/vite/lifecycle-generator.js +19 -5
- package/dist/cmd/build/vite/lifecycle-generator.js.map +1 -1
- package/dist/cmd/build/vite/metadata-generator.d.ts.map +1 -1
- package/dist/cmd/build/vite/metadata-generator.js +145 -0
- package/dist/cmd/build/vite/metadata-generator.js.map +1 -1
- package/dist/cmd/build/vite/registry-generator.d.ts +3 -3
- package/dist/cmd/build/vite/registry-generator.d.ts.map +1 -1
- package/dist/cmd/build/vite/registry-generator.js +627 -103
- package/dist/cmd/build/vite/registry-generator.js.map +1 -1
- package/dist/cmd/build/vite/route-discovery.d.ts +4 -0
- package/dist/cmd/build/vite/route-discovery.d.ts.map +1 -1
- package/dist/cmd/build/vite/route-discovery.js.map +1 -1
- package/dist/cmd/build/vite/server-bundler.d.ts.map +1 -1
- package/dist/cmd/build/vite/server-bundler.js +18 -1
- package/dist/cmd/build/vite/server-bundler.js.map +1 -1
- package/dist/cmd/build/vite/vite-builder.d.ts +1 -1
- package/dist/cmd/build/vite/vite-builder.d.ts.map +1 -1
- package/dist/cmd/build/vite/vite-builder.js +28 -18
- package/dist/cmd/build/vite/vite-builder.js.map +1 -1
- package/dist/cmd/build/vite-bundler.js +6 -6
- package/dist/cmd/build/vite-bundler.js.map +1 -1
- package/dist/cmd/cloud/deploy.d.ts.map +1 -1
- package/dist/cmd/cloud/deploy.js +11 -5
- package/dist/cmd/cloud/deploy.js.map +1 -1
- package/dist/cmd/dev/file-watcher.d.ts.map +1 -1
- package/dist/cmd/dev/file-watcher.js +4 -2
- package/dist/cmd/dev/file-watcher.js.map +1 -1
- package/dist/cmd/dev/index.d.ts.map +1 -1
- package/dist/cmd/dev/index.js +102 -21
- package/dist/cmd/dev/index.js.map +1 -1
- package/dist/cmd/dev/sync.d.ts.map +1 -1
- package/dist/cmd/dev/sync.js +19 -3
- package/dist/cmd/dev/sync.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +8 -0
- package/dist/config.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/package.json +5 -8
- package/src/api.ts +1 -1
- package/src/cmd/build/ast.ts +161 -48
- package/src/cmd/build/entry-generator.ts +225 -190
- package/src/cmd/build/vite/agent-discovery.ts +151 -58
- package/src/cmd/build/vite/bun-dev-server.ts +1 -1
- package/src/cmd/build/vite/docs-generator.ts +87 -0
- package/src/cmd/build/vite/index.ts +9 -7
- package/src/cmd/build/vite/lifecycle-generator.ts +19 -5
- package/src/cmd/build/vite/metadata-generator.ts +178 -0
- package/src/cmd/build/vite/registry-generator.ts +727 -108
- package/src/cmd/build/vite/route-discovery.ts +4 -0
- package/src/cmd/build/vite/server-bundler.ts +20 -1
- package/src/cmd/build/vite/vite-builder.ts +44 -30
- package/src/cmd/build/vite-bundler.ts +6 -6
- package/src/cmd/cloud/deploy.ts +15 -5
- package/src/cmd/dev/file-watcher.ts +8 -2
- package/src/cmd/dev/index.ts +141 -30
- package/src/cmd/dev/sync.ts +41 -6
- package/src/config.ts +9 -0
- package/src/index.ts +0 -5
- package/src/runtime-bootstrap.md +1 -1
- package/dist/runtime-bootstrap.d.ts +0 -56
- package/dist/runtime-bootstrap.d.ts.map +0 -1
- package/dist/runtime-bootstrap.js +0 -95
- package/dist/runtime-bootstrap.js.map +0 -1
- package/src/runtime-bootstrap.ts +0 -131
|
@@ -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"}
|
package/src/runtime-bootstrap.ts
DELETED
|
@@ -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
|
-
}
|