@agentuity/cli 0.0.89 → 0.0.90
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":"AAIA,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,6 @@
|
|
|
1
1
|
import { join } from 'node:path';
|
|
2
|
+
import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { tmpdir } from 'node:os';
|
|
2
4
|
import { StructuredError } from '@agentuity/core';
|
|
3
5
|
const BuildConfigLoadError = StructuredError('BuildConfigLoadError');
|
|
4
6
|
const BuildConfigValidationError = StructuredError('BuildConfigValidationError');
|
|
@@ -17,18 +19,79 @@ export async function loadBuildConfig(rootDir) {
|
|
|
17
19
|
return null; // No config file is OK - it's optional
|
|
18
20
|
}
|
|
19
21
|
try {
|
|
20
|
-
//
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
// Create a temporary directory for the wrapper script
|
|
23
|
+
const tempDir = mkdtempSync(join(tmpdir(), 'agentuity-config-'));
|
|
24
|
+
const wrapperPath = join(tempDir, 'wrapper.ts');
|
|
25
|
+
try {
|
|
26
|
+
// Create a wrapper script that imports the config and outputs it as JSON
|
|
27
|
+
// This approach is simpler and more reliable than bundling + vm context
|
|
28
|
+
const wrapperCode = `
|
|
29
|
+
import configFunction from ${JSON.stringify(configPath)};
|
|
30
|
+
|
|
31
|
+
// Validate it's a function
|
|
32
|
+
if (typeof configFunction !== 'function') {
|
|
33
|
+
console.error(JSON.stringify({
|
|
34
|
+
error: 'BuildConfigValidationError',
|
|
35
|
+
message: \`agentuity.config.ts must export a default function, got \${typeof configFunction}\`
|
|
36
|
+
}));
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Output success marker
|
|
41
|
+
console.log('__CONFIG_LOADED__');
|
|
42
|
+
`;
|
|
43
|
+
writeFileSync(wrapperPath, wrapperCode);
|
|
44
|
+
// Run the wrapper script with Bun
|
|
45
|
+
// Note: stdout/stderr are piped (not inherited) to suppress output from user's screen
|
|
46
|
+
const proc = Bun.spawn(['bun', wrapperPath], {
|
|
47
|
+
cwd: rootDir,
|
|
48
|
+
stdout: 'pipe', // Capture stdout to prevent output to user's terminal
|
|
49
|
+
stderr: 'pipe', // Capture stderr to prevent output to user's terminal
|
|
29
50
|
});
|
|
51
|
+
const output = await new Response(proc.stdout).text();
|
|
52
|
+
const errorOutput = await new Response(proc.stderr).text();
|
|
53
|
+
const exitCode = await proc.exited;
|
|
54
|
+
if (exitCode !== 0) {
|
|
55
|
+
// Try to parse error as JSON
|
|
56
|
+
let errorData = null;
|
|
57
|
+
try {
|
|
58
|
+
errorData = JSON.parse(errorOutput);
|
|
59
|
+
}
|
|
60
|
+
catch (_parseError) {
|
|
61
|
+
// Not JSON, will treat as regular error below
|
|
62
|
+
}
|
|
63
|
+
// If we successfully parsed a BuildConfigValidationError, throw it
|
|
64
|
+
if (errorData?.error === 'BuildConfigValidationError') {
|
|
65
|
+
throw new BuildConfigValidationError({
|
|
66
|
+
message: errorData.message,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
// Otherwise, throw a generic load error with the raw error output
|
|
70
|
+
throw new BuildConfigLoadError({
|
|
71
|
+
message: `Failed to load agentuity.config.ts:\n${errorOutput}`,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
// Verify the success marker
|
|
75
|
+
if (!output.includes('__CONFIG_LOADED__')) {
|
|
76
|
+
throw new BuildConfigLoadError({
|
|
77
|
+
message: 'Config file loaded but did not output expected marker',
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
// Now import the config file directly - it's been validated
|
|
81
|
+
const configModule = await import(configPath);
|
|
82
|
+
const configFunction = configModule.default;
|
|
83
|
+
// Double-check it's a function (should always pass if wrapper succeeded)
|
|
84
|
+
if (typeof configFunction !== 'function') {
|
|
85
|
+
throw new BuildConfigValidationError({
|
|
86
|
+
message: `agentuity.config.ts must export a default function, got ${typeof configFunction}`,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
return configFunction;
|
|
90
|
+
}
|
|
91
|
+
finally {
|
|
92
|
+
// Clean up temp directory
|
|
93
|
+
rmSync(tempDir, { recursive: true, force: true });
|
|
30
94
|
}
|
|
31
|
-
return configFunction;
|
|
32
95
|
}
|
|
33
96
|
catch (error) {
|
|
34
97
|
// 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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AO,IAAI,UAAU,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACzD,MAAM,CAAC,OAAO,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,OAAO,IAAI,EAAE,CAAC,EAAE,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IACzE,CAAC;IAED,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.90",
|
|
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.90",
|
|
39
|
+
"@agentuity/server": "0.0.90",
|
|
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,6 @@
|
|
|
1
1
|
import { join } from 'node:path';
|
|
2
|
+
import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { tmpdir } from 'node:os';
|
|
2
4
|
import { StructuredError } from '@agentuity/core';
|
|
3
5
|
import type { BuildConfigFunction, BuildPhase, BuildContext, BuildConfig } from '../../types';
|
|
4
6
|
|
|
@@ -23,21 +25,88 @@ export async function loadBuildConfig(rootDir: string): Promise<BuildConfigFunct
|
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
try {
|
|
26
|
-
//
|
|
27
|
-
|
|
28
|
-
const
|
|
28
|
+
// Create a temporary directory for the wrapper script
|
|
29
|
+
const tempDir = mkdtempSync(join(tmpdir(), 'agentuity-config-'));
|
|
30
|
+
const wrapperPath = join(tempDir, 'wrapper.ts');
|
|
29
31
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
try {
|
|
33
|
+
// Create a wrapper script that imports the config and outputs it as JSON
|
|
34
|
+
// This approach is simpler and more reliable than bundling + vm context
|
|
35
|
+
const wrapperCode = `
|
|
36
|
+
import configFunction from ${JSON.stringify(configPath)};
|
|
32
37
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
38
|
+
// Validate it's a function
|
|
39
|
+
if (typeof configFunction !== 'function') {
|
|
40
|
+
console.error(JSON.stringify({
|
|
41
|
+
error: 'BuildConfigValidationError',
|
|
42
|
+
message: \`agentuity.config.ts must export a default function, got \${typeof configFunction}\`
|
|
43
|
+
}));
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Output success marker
|
|
48
|
+
console.log('__CONFIG_LOADED__');
|
|
49
|
+
`;
|
|
50
|
+
|
|
51
|
+
writeFileSync(wrapperPath, wrapperCode);
|
|
52
|
+
|
|
53
|
+
// Run the wrapper script with Bun
|
|
54
|
+
// Note: stdout/stderr are piped (not inherited) to suppress output from user's screen
|
|
55
|
+
const proc = Bun.spawn(['bun', wrapperPath], {
|
|
56
|
+
cwd: rootDir,
|
|
57
|
+
stdout: 'pipe', // Capture stdout to prevent output to user's terminal
|
|
58
|
+
stderr: 'pipe', // Capture stderr to prevent output to user's terminal
|
|
37
59
|
});
|
|
38
|
-
}
|
|
39
60
|
|
|
40
|
-
|
|
61
|
+
const output = await new Response(proc.stdout).text();
|
|
62
|
+
const errorOutput = await new Response(proc.stderr).text();
|
|
63
|
+
const exitCode = await proc.exited;
|
|
64
|
+
|
|
65
|
+
if (exitCode !== 0) {
|
|
66
|
+
// Try to parse error as JSON
|
|
67
|
+
let errorData = null;
|
|
68
|
+
try {
|
|
69
|
+
errorData = JSON.parse(errorOutput);
|
|
70
|
+
} catch (_parseError) {
|
|
71
|
+
// Not JSON, will treat as regular error below
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// If we successfully parsed a BuildConfigValidationError, throw it
|
|
75
|
+
if (errorData?.error === 'BuildConfigValidationError') {
|
|
76
|
+
throw new BuildConfigValidationError({
|
|
77
|
+
message: errorData.message,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Otherwise, throw a generic load error with the raw error output
|
|
82
|
+
throw new BuildConfigLoadError({
|
|
83
|
+
message: `Failed to load agentuity.config.ts:\n${errorOutput}`,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Verify the success marker
|
|
88
|
+
if (!output.includes('__CONFIG_LOADED__')) {
|
|
89
|
+
throw new BuildConfigLoadError({
|
|
90
|
+
message: 'Config file loaded but did not output expected marker',
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Now import the config file directly - it's been validated
|
|
95
|
+
const configModule = await import(configPath);
|
|
96
|
+
const configFunction = configModule.default;
|
|
97
|
+
|
|
98
|
+
// Double-check it's a function (should always pass if wrapper succeeded)
|
|
99
|
+
if (typeof configFunction !== 'function') {
|
|
100
|
+
throw new BuildConfigValidationError({
|
|
101
|
+
message: `agentuity.config.ts must export a default function, got ${typeof configFunction}`,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return configFunction as BuildConfigFunction;
|
|
106
|
+
} finally {
|
|
107
|
+
// Clean up temp directory
|
|
108
|
+
rmSync(tempDir, { recursive: true, force: true });
|
|
109
|
+
}
|
|
41
110
|
} catch (error) {
|
|
42
111
|
// If it's already our error, re-throw
|
|
43
112
|
if (error instanceof BuildConfigValidationError || error instanceof BuildConfigLoadError) {
|