@agentuity/cli 0.0.89 → 0.0.91
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-loader.d.ts","sourceRoot":"","sources":["../../../src/cmd/build/config-loader.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config-loader.d.ts","sourceRoot":"","sources":["../../../src/cmd/build/config-loader.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAU9F;;GAEG;AACH,wBAAsB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAwG1F;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CACvC,cAAc,EAAE,mBAAmB,EACnC,KAAK,EAAE,UAAU,EACjB,OAAO,EAAE,YAAY,GACnB,OAAO,CAAC,WAAW,CAAC,CAqGtB;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC/B,UAAU,EAAE,OAAO,KAAK,EAAE,WAAW,EACrC,UAAU,EAAE,WAAW,GACrB,OAAO,KAAK,EAAE,WAAW,CA2B3B"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { join } from 'node:path';
|
|
2
|
+
import { rmSync, writeFileSync } from 'node:fs';
|
|
2
3
|
import { StructuredError } from '@agentuity/core';
|
|
3
4
|
const BuildConfigLoadError = StructuredError('BuildConfigLoadError');
|
|
4
5
|
const BuildConfigValidationError = StructuredError('BuildConfigValidationError');
|
|
@@ -17,18 +18,79 @@ export async function loadBuildConfig(rootDir) {
|
|
|
17
18
|
return null; // No config file is OK - it's optional
|
|
18
19
|
}
|
|
19
20
|
try {
|
|
20
|
-
//
|
|
21
|
-
//
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
// Create wrapper script in project root so imports resolve correctly
|
|
22
|
+
// Using a hidden temp file to avoid conflicts with user files
|
|
23
|
+
const wrapperPath = join(rootDir, `.agentuity-config-loader-${Date.now()}.mts`);
|
|
24
|
+
try {
|
|
25
|
+
// Create a wrapper script that imports the config and outputs it as JSON
|
|
26
|
+
// Using relative import so Bun can resolve dependencies from project's node_modules
|
|
27
|
+
const wrapperCode = `
|
|
28
|
+
import configFunction from './agentuity.config.ts';
|
|
29
|
+
|
|
30
|
+
// Validate it's a function
|
|
31
|
+
if (typeof configFunction !== 'function') {
|
|
32
|
+
console.error(JSON.stringify({
|
|
33
|
+
error: 'BuildConfigValidationError',
|
|
34
|
+
message: \`agentuity.config.ts must export a default function, got \${typeof configFunction}\`
|
|
35
|
+
}));
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Output success marker
|
|
40
|
+
console.log('__CONFIG_LOADED__');
|
|
41
|
+
`;
|
|
42
|
+
writeFileSync(wrapperPath, wrapperCode);
|
|
43
|
+
// Run the wrapper script with Bun
|
|
44
|
+
// Note: stdout/stderr are piped (not inherited) to suppress output from user's screen
|
|
45
|
+
const proc = Bun.spawn(['bun', wrapperPath], {
|
|
46
|
+
cwd: rootDir,
|
|
47
|
+
stdout: 'pipe', // Capture stdout to prevent output to user's terminal
|
|
48
|
+
stderr: 'pipe', // Capture stderr to prevent output to user's terminal
|
|
29
49
|
});
|
|
50
|
+
const output = await new Response(proc.stdout).text();
|
|
51
|
+
const errorOutput = await new Response(proc.stderr).text();
|
|
52
|
+
const exitCode = await proc.exited;
|
|
53
|
+
if (exitCode !== 0) {
|
|
54
|
+
// Try to parse error as JSON
|
|
55
|
+
let errorData = null;
|
|
56
|
+
try {
|
|
57
|
+
errorData = JSON.parse(errorOutput);
|
|
58
|
+
}
|
|
59
|
+
catch (_parseError) {
|
|
60
|
+
// Not JSON, will treat as regular error below
|
|
61
|
+
}
|
|
62
|
+
// If we successfully parsed a BuildConfigValidationError, throw it
|
|
63
|
+
if (errorData?.error === 'BuildConfigValidationError') {
|
|
64
|
+
throw new BuildConfigValidationError({
|
|
65
|
+
message: errorData.message,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
// Otherwise, throw a generic load error with the raw error output
|
|
69
|
+
throw new BuildConfigLoadError({
|
|
70
|
+
message: `Failed to load agentuity.config.ts:\n${errorOutput}`,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
// Verify the success marker
|
|
74
|
+
if (!output.includes('__CONFIG_LOADED__')) {
|
|
75
|
+
throw new BuildConfigLoadError({
|
|
76
|
+
message: 'Config file loaded but did not output expected marker',
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
// Now import the config file directly - it's been validated
|
|
80
|
+
const configModule = await import(configPath);
|
|
81
|
+
const configFunction = configModule.default;
|
|
82
|
+
// Double-check it's a function (should always pass if wrapper succeeded)
|
|
83
|
+
if (typeof configFunction !== 'function') {
|
|
84
|
+
throw new BuildConfigValidationError({
|
|
85
|
+
message: `agentuity.config.ts must export a default function, got ${typeof configFunction}`,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
return configFunction;
|
|
89
|
+
}
|
|
90
|
+
finally {
|
|
91
|
+
// Clean up temp wrapper file
|
|
92
|
+
rmSync(wrapperPath, { force: true });
|
|
30
93
|
}
|
|
31
|
-
return configFunction;
|
|
32
94
|
}
|
|
33
95
|
catch (error) {
|
|
34
96
|
// If it's already our error, re-throw
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-loader.js","sourceRoot":"","sources":["../../../src/cmd/build/config-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAGlD,MAAM,oBAAoB,GAAG,eAAe,CAAC,sBAAsB,CAAC,CAAC;AACrE,MAAM,0BAA0B,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,0CAA0C;IAC1C,IAAI,UAAU,CAAC,QAAQ,IAAI,UAAU,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC3D,MAAM,gBAAgB,GAAG,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC;YAC1D,CAAC,CAAC,UAAU,CAAC,QAAQ;YACrB,CAAC,CAAC,UAAU,CAAC,QAAQ;gBACpB,CAAC,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC;gBACvB,CAAC,CAAC,EAAE,CAAC;QACP,MAAM,CAAC,QAAQ,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,gBAAgB,EAAE,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC/E,CAAC;IAED,4EAA4E;IAC5E,IAAI,UAAU,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpE,MAAM,CAAC,MAAM,GAAG;YACf,GAAG,UAAU,CAAC,MAAM;YACpB,GAAG,UAAU,CAAC,MAAM;SACpB,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AACf,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentuity/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.91",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"author": "Agentuity employees and contributors",
|
|
6
6
|
"type": "module",
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"prepublishOnly": "bun run clean && bun run build"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@agentuity/core": "0.0.
|
|
39
|
-
"@agentuity/server": "0.0.
|
|
38
|
+
"@agentuity/core": "0.0.91",
|
|
39
|
+
"@agentuity/server": "0.0.91",
|
|
40
40
|
"@datasert/cronjs-parser": "^1.4.0",
|
|
41
41
|
"@terascope/fetch-github-release": "^2.2.1",
|
|
42
42
|
"acorn-loose": "^8.5.2",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { join } from 'node:path';
|
|
2
|
+
import { rmSync, writeFileSync } from 'node:fs';
|
|
2
3
|
import { StructuredError } from '@agentuity/core';
|
|
3
4
|
import type { BuildConfigFunction, BuildPhase, BuildContext, BuildConfig } from '../../types';
|
|
4
5
|
|
|
@@ -23,21 +24,88 @@ export async function loadBuildConfig(rootDir: string): Promise<BuildConfigFunct
|
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
try {
|
|
26
|
-
//
|
|
27
|
-
//
|
|
28
|
-
const
|
|
27
|
+
// Create wrapper script in project root so imports resolve correctly
|
|
28
|
+
// Using a hidden temp file to avoid conflicts with user files
|
|
29
|
+
const wrapperPath = join(rootDir, `.agentuity-config-loader-${Date.now()}.mts`);
|
|
29
30
|
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
try {
|
|
32
|
+
// Create a wrapper script that imports the config and outputs it as JSON
|
|
33
|
+
// Using relative import so Bun can resolve dependencies from project's node_modules
|
|
34
|
+
const wrapperCode = `
|
|
35
|
+
import configFunction from './agentuity.config.ts';
|
|
32
36
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
+
// Validate it's a function
|
|
38
|
+
if (typeof configFunction !== 'function') {
|
|
39
|
+
console.error(JSON.stringify({
|
|
40
|
+
error: 'BuildConfigValidationError',
|
|
41
|
+
message: \`agentuity.config.ts must export a default function, got \${typeof configFunction}\`
|
|
42
|
+
}));
|
|
43
|
+
process.exit(1);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Output success marker
|
|
47
|
+
console.log('__CONFIG_LOADED__');
|
|
48
|
+
`;
|
|
49
|
+
|
|
50
|
+
writeFileSync(wrapperPath, wrapperCode);
|
|
51
|
+
|
|
52
|
+
// Run the wrapper script with Bun
|
|
53
|
+
// Note: stdout/stderr are piped (not inherited) to suppress output from user's screen
|
|
54
|
+
const proc = Bun.spawn(['bun', wrapperPath], {
|
|
55
|
+
cwd: rootDir,
|
|
56
|
+
stdout: 'pipe', // Capture stdout to prevent output to user's terminal
|
|
57
|
+
stderr: 'pipe', // Capture stderr to prevent output to user's terminal
|
|
37
58
|
});
|
|
38
|
-
}
|
|
39
59
|
|
|
40
|
-
|
|
60
|
+
const output = await new Response(proc.stdout).text();
|
|
61
|
+
const errorOutput = await new Response(proc.stderr).text();
|
|
62
|
+
const exitCode = await proc.exited;
|
|
63
|
+
|
|
64
|
+
if (exitCode !== 0) {
|
|
65
|
+
// Try to parse error as JSON
|
|
66
|
+
let errorData = null;
|
|
67
|
+
try {
|
|
68
|
+
errorData = JSON.parse(errorOutput);
|
|
69
|
+
} catch (_parseError) {
|
|
70
|
+
// Not JSON, will treat as regular error below
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// If we successfully parsed a BuildConfigValidationError, throw it
|
|
74
|
+
if (errorData?.error === 'BuildConfigValidationError') {
|
|
75
|
+
throw new BuildConfigValidationError({
|
|
76
|
+
message: errorData.message,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Otherwise, throw a generic load error with the raw error output
|
|
81
|
+
throw new BuildConfigLoadError({
|
|
82
|
+
message: `Failed to load agentuity.config.ts:\n${errorOutput}`,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Verify the success marker
|
|
87
|
+
if (!output.includes('__CONFIG_LOADED__')) {
|
|
88
|
+
throw new BuildConfigLoadError({
|
|
89
|
+
message: 'Config file loaded but did not output expected marker',
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Now import the config file directly - it's been validated
|
|
94
|
+
const configModule = await import(configPath);
|
|
95
|
+
const configFunction = configModule.default;
|
|
96
|
+
|
|
97
|
+
// Double-check it's a function (should always pass if wrapper succeeded)
|
|
98
|
+
if (typeof configFunction !== 'function') {
|
|
99
|
+
throw new BuildConfigValidationError({
|
|
100
|
+
message: `agentuity.config.ts must export a default function, got ${typeof configFunction}`,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return configFunction as BuildConfigFunction;
|
|
105
|
+
} finally {
|
|
106
|
+
// Clean up temp wrapper file
|
|
107
|
+
rmSync(wrapperPath, { force: true });
|
|
108
|
+
}
|
|
41
109
|
} catch (error) {
|
|
42
110
|
// If it's already our error, re-throw
|
|
43
111
|
if (error instanceof BuildConfigValidationError || error instanceof BuildConfigLoadError) {
|