@agentuity/cli 1.0.52 → 1.0.53

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.
@@ -0,0 +1,18 @@
1
+ import type { Logger } from '@agentuity/core';
2
+ export interface CIBuildOptions {
3
+ url: string;
4
+ directory?: string;
5
+ trigger?: string;
6
+ event?: string;
7
+ message?: string;
8
+ commit?: string;
9
+ commitUrl?: string;
10
+ branch?: string;
11
+ repo?: string;
12
+ provider?: string;
13
+ pullRequestNumber?: number;
14
+ pullRequestUrl?: string;
15
+ logsUrl?: string;
16
+ }
17
+ export declare function runCIBuild(opts: CIBuildOptions, _logger: Logger): Promise<void>;
18
+ //# sourceMappingURL=ci.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ci.d.ts","sourceRoot":"","sources":["../../../src/cmd/build/ci.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAQ9C,MAAM,WAAW,cAAc;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB;AAmFD,wBAAsB,UAAU,CAAC,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAqHrF"}
@@ -0,0 +1,181 @@
1
+ import { spawn } from 'bun';
2
+ import { mkdir, mkdtemp, readdir, realpath, rm, stat } from 'node:fs/promises';
3
+ import { tmpdir } from 'node:os';
4
+ import { join } from 'node:path';
5
+ import { ErrorCode } from '../../errors';
6
+ import * as tui from '../../tui';
7
+ async function streamProcessOutput(proc) {
8
+ const forwardStream = async (stream, isStderr) => {
9
+ if (typeof stream === 'number')
10
+ return;
11
+ if (!stream)
12
+ return;
13
+ const reader = stream.getReader();
14
+ const target = isStderr ? process.stderr : process.stdout;
15
+ while (true) {
16
+ const { done, value } = await reader.read();
17
+ if (done)
18
+ break;
19
+ target.write(value);
20
+ }
21
+ };
22
+ await Promise.all([
23
+ forwardStream(proc.stdout, false),
24
+ forwardStream(proc.stderr, true),
25
+ proc.exited,
26
+ ]);
27
+ }
28
+ async function runCommand(cmd, cwd) {
29
+ const proc = spawn({
30
+ cmd,
31
+ cwd,
32
+ env: { ...process.env, CI: 'true' },
33
+ stdin: 'ignore',
34
+ stdout: 'pipe',
35
+ stderr: 'pipe',
36
+ });
37
+ await streamProcessOutput(proc);
38
+ return proc.exitCode ?? 1;
39
+ }
40
+ async function downloadSource(url, targetPath) {
41
+ let lastError;
42
+ for (let attempt = 1; attempt <= 3; attempt++) {
43
+ try {
44
+ const response = await fetch(url, { signal: AbortSignal.timeout(60_000) });
45
+ if (!response.ok) {
46
+ throw new Error(`Download failed with status ${response.status}`);
47
+ }
48
+ await Bun.write(targetPath, await response.arrayBuffer());
49
+ return;
50
+ }
51
+ catch (error) {
52
+ lastError = error;
53
+ if (attempt < 3) {
54
+ tui.info(`Download failed (attempt ${attempt}/3), retrying...`);
55
+ }
56
+ }
57
+ }
58
+ throw lastError instanceof Error ? lastError : new Error('Download failed');
59
+ }
60
+ function buildDeployArgs(opts) {
61
+ const args = [];
62
+ if (opts.trigger)
63
+ args.push('--trigger', opts.trigger);
64
+ if (opts.event)
65
+ args.push('--event', opts.event);
66
+ if (opts.message)
67
+ args.push('--message', opts.message);
68
+ if (opts.commit)
69
+ args.push('--commit', opts.commit);
70
+ if (opts.commitUrl)
71
+ args.push('--commit-url', opts.commitUrl);
72
+ if (opts.branch)
73
+ args.push('--branch', opts.branch);
74
+ if (opts.repo)
75
+ args.push('--repo', opts.repo);
76
+ if (opts.provider)
77
+ args.push('--provider', opts.provider);
78
+ if (opts.pullRequestNumber !== undefined) {
79
+ args.push('--pull-request-number', String(opts.pullRequestNumber));
80
+ }
81
+ if (opts.pullRequestUrl)
82
+ args.push('--pull-request-url', opts.pullRequestUrl);
83
+ if (opts.logsUrl)
84
+ args.push('--logs-url', opts.logsUrl);
85
+ return args;
86
+ }
87
+ export async function runCIBuild(opts, _logger) {
88
+ let tempDir = '';
89
+ try {
90
+ tempDir = await mkdtemp(join(tmpdir(), 'agentuity-ci-build-'));
91
+ const sourceZipPath = join(tempDir, 'source.zip');
92
+ const extractPath = join(tempDir, 'build');
93
+ tui.info('1️⃣ Downloading source code from GitHub...');
94
+ await downloadSource(opts.url, sourceZipPath);
95
+ tui.info('2️⃣ Unzipping source code from GitHub...');
96
+ await mkdir(extractPath, { recursive: true });
97
+ const unzipExit = await runCommand(['unzip', '-q', sourceZipPath, '-d', extractPath], tempDir);
98
+ if (unzipExit !== 0 && unzipExit !== 1) {
99
+ tui.fatal(`Failed to unzip source archive (exit ${unzipExit})`, ErrorCode.BUILD_FAILED);
100
+ }
101
+ const extractedEntries = await readdir(extractPath, { withFileTypes: true });
102
+ const extractedDirs = extractedEntries.filter((entry) => entry.isDirectory());
103
+ if (extractedDirs.length !== 1) {
104
+ tui.fatal(`Expected one root directory after unzip, found ${extractedDirs.length}`, ErrorCode.BUILD_FAILED);
105
+ }
106
+ const sourceRoot = extractedDirs.at(0);
107
+ if (!sourceRoot) {
108
+ tui.fatal('Could not determine extracted source directory', ErrorCode.BUILD_FAILED);
109
+ }
110
+ const sourceRootDir = join(extractPath, sourceRoot.name);
111
+ let projectDir = sourceRootDir;
112
+ if (opts.directory) {
113
+ projectDir = join(sourceRootDir, opts.directory);
114
+ }
115
+ const projectStats = await stat(projectDir).catch(() => null);
116
+ if (!projectStats?.isDirectory()) {
117
+ tui.fatal(`Build directory not found: ${projectDir}`, ErrorCode.CONFIG_INVALID);
118
+ }
119
+ // Resolve symlinks and verify the project dir is within the source root
120
+ const realProjectDir = await realpath(projectDir).catch(() => null);
121
+ const realSourceRoot = await realpath(sourceRootDir).catch(() => null);
122
+ if (!realProjectDir || !realSourceRoot || !realProjectDir.startsWith(realSourceRoot)) {
123
+ tui.fatal('Directory path escapes the source root (path traversal denied)', ErrorCode.CONFIG_INVALID);
124
+ }
125
+ projectDir = realProjectDir;
126
+ const sdkKey = process.env.AGENTUITY_SDK_KEY;
127
+ if (sdkKey) {
128
+ await Bun.write(join(projectDir, '.env'), `AGENTUITY_SDK_KEY=${sdkKey}\n`);
129
+ }
130
+ tui.info('3️⃣ Installing your project dependencies...');
131
+ const installExit = await runCommand(['bun', 'install'], projectDir);
132
+ if (installExit !== 0) {
133
+ tui.fatal(`Dependency installation failed (exit ${installExit})`, ErrorCode.BUILD_FAILED);
134
+ }
135
+ const packageJsonPath = join(projectDir, 'package.json');
136
+ const packageJsonFile = Bun.file(packageJsonPath);
137
+ let scripts;
138
+ if (await packageJsonFile.exists()) {
139
+ const packageJson = (await packageJsonFile.json());
140
+ scripts = packageJson.scripts;
141
+ }
142
+ if (scripts?.predeploy) {
143
+ tui.info('🔧 Running predeploy script...');
144
+ const predeployExit = await runCommand(['bun', 'run', '--bun', 'predeploy'], projectDir);
145
+ if (predeployExit !== 0) {
146
+ tui.fatal(`Predeploy failed (exit ${predeployExit})`, ErrorCode.BUILD_FAILED);
147
+ }
148
+ }
149
+ tui.info('4️⃣ Deploying your project...');
150
+ // Use the locally installed CLI binary instead of bunx to avoid
151
+ // bunx resolution crashes on certain Bun versions (e.g. arm64 segfaults)
152
+ const localCliBin = join(projectDir, 'node_modules', '.bin', 'agentuity');
153
+ const cliExists = await stat(localCliBin).catch(() => null);
154
+ const deployCmd = cliExists
155
+ ? ['bun', localCliBin, 'deploy', ...buildDeployArgs(opts)]
156
+ : ['bunx', '--bun', 'agentuity', 'deploy', ...buildDeployArgs(opts)];
157
+ tui.info(`Using CLI: ${cliExists ? localCliBin : 'bunx --bun agentuity'}`);
158
+ const deployExit = await runCommand(deployCmd, projectDir);
159
+ if (deployExit !== 0) {
160
+ tui.fatal(`Deploy failed (exit ${deployExit})`, ErrorCode.BUILD_FAILED);
161
+ }
162
+ if (scripts?.postdeploy) {
163
+ tui.info('🔧 Running postdeploy script...');
164
+ const postdeployExit = await runCommand(['bun', 'run', '--bun', 'postdeploy'], projectDir);
165
+ if (postdeployExit !== 0) {
166
+ tui.fatal(`Postdeploy failed (exit ${postdeployExit})`, ErrorCode.BUILD_FAILED);
167
+ }
168
+ }
169
+ tui.success('✅ Your project has been built...');
170
+ }
171
+ catch (error) {
172
+ const message = error instanceof Error ? error.message : String(error);
173
+ tui.fatal(`CI build failed: ${message}`, ErrorCode.BUILD_FAILED);
174
+ }
175
+ finally {
176
+ if (tempDir) {
177
+ await rm(tempDir, { recursive: true, force: true });
178
+ }
179
+ }
180
+ }
181
+ //# sourceMappingURL=ci.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ci.js","sourceRoot":"","sources":["../../../src/cmd/build/ci.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,KAAK,CAAC;AAC5B,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC/E,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,GAAG,MAAM,WAAW,CAAC;AAkBjC,KAAK,UAAU,mBAAmB,CAAC,IAA8B;IAChE,MAAM,aAAa,GAAG,KAAK,EA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version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cmd/build/index.ts"],"names":[],"mappings":"AAkBA,eAAO,MAAM,OAAO,mCA0JlB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cmd/build/index.ts"],"names":[],"mappings":"AAkCA,eAAO,MAAM,OAAO,mCAmLlB,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { resolve, join, relative } from 'node:path';
3
- import { createCommand } from '../../types';
3
+ import { createCommand, DeployOptionsSchema } from '../../types';
4
4
  import { viteBundle } from './vite-bundler';
5
5
  import * as tui from '../../tui';
6
6
  import { getCommand } from '../../command-prefix';
@@ -14,6 +14,18 @@ const BuildResponseSchema = z.object({
14
14
  dev: z.boolean().describe('Whether dev mode was enabled'),
15
15
  size: z.number().optional().describe('Build size in bytes'),
16
16
  });
17
+ const BuildOptionsSchema = z.intersection(DeployOptionsSchema, z.object({
18
+ dev: z.boolean().optional().describe('Enable development mode'),
19
+ outdir: z.string().optional().describe('Output directory for build artifacts'),
20
+ skipTypeCheck: z.boolean().default(false).optional().describe('Skip typecheck after build'),
21
+ reportFile: z
22
+ .string()
23
+ .optional()
24
+ .describe('file path to save build report JSON with errors, warnings, and diagnostics'),
25
+ ci: z.boolean().optional().describe('Enable CI build mode'),
26
+ url: z.string().optional().describe('Source code download URL (required with --ci)'),
27
+ directory: z.string().optional().describe('Subdirectory within extracted source'),
28
+ }));
17
29
  export const command = createCommand({
18
30
  name: 'build',
19
31
  description: 'Build Agentuity application for deployment',
@@ -24,26 +36,45 @@ export const command = createCommand({
24
36
  examples: [
25
37
  { command: getCommand('build'), description: 'Build the project' },
26
38
  { command: getCommand('build --dev'), description: 'Run in development mode' },
39
+ {
40
+ command: getCommand('build --ci --url https://example.com/source.zip'),
41
+ description: 'Run CI build from source URL',
42
+ },
27
43
  { command: getCommand('bundle'), description: 'Bundle the project' },
28
44
  ],
29
45
  schema: {
30
- options: z.object({
31
- dev: z.boolean().optional().describe('Enable development mode'),
32
- outdir: z.string().optional().describe('Output directory for build artifacts'),
33
- skipTypeCheck: z
34
- .boolean()
35
- .default(false)
36
- .optional()
37
- .describe('Skip typecheck after build'),
38
- reportFile: z
39
- .string()
40
- .optional()
41
- .describe('file path to save build report JSON with errors, warnings, and diagnostics'),
42
- }),
46
+ options: BuildOptionsSchema,
43
47
  response: BuildResponseSchema,
44
48
  },
45
49
  async handler(ctx) {
46
50
  const { opts, projectDir, project } = ctx;
51
+ if (opts.ci) {
52
+ if (!opts.url) {
53
+ tui.fatal('--url is required when using --ci mode', ErrorCode.CONFIG_INVALID);
54
+ }
55
+ const { runCIBuild } = await import('./ci');
56
+ await runCIBuild({
57
+ url: opts.url,
58
+ directory: opts.directory,
59
+ trigger: opts.trigger,
60
+ event: opts.event,
61
+ message: opts.message,
62
+ commit: opts.commit,
63
+ commitUrl: opts.commitUrl,
64
+ branch: opts.branch,
65
+ repo: opts.repo,
66
+ provider: opts.provider,
67
+ pullRequestNumber: opts.pullRequestNumber,
68
+ pullRequestUrl: opts.pullRequestUrl,
69
+ logsUrl: opts.logsUrl,
70
+ }, ctx.logger);
71
+ return {
72
+ success: true,
73
+ bundlePath: projectDir,
74
+ projectName: project?.projectId || 'unknown',
75
+ dev: false,
76
+ };
77
+ }
47
78
  // Initialize build report collector if reportFile is specified
48
79
  const collector = new BuildReportCollector();
49
80
  if (opts.reportFile) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/cmd/build/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,GAAG,MAAM,WAAW,CAAC;AACjC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IAAI,KAAK;aACtB,CAAC;QACH,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACzB,yBAAyB;YACzB,IAAI,KAAK,YAAY,cAAc,EAAE,CAAC;gBACrC,MAAM,EAAE,GAAG,KAAuB,CAAC;gBACnC,KAAK,MAAM,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,CAAC;oBAC3B,SAAS,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;oBAC1D,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;gBACtB,CAAC;YACF,CAAC;iBAAM,CAAC;gBACP,SAAS,CAAC,eAAe,CAAC,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC,CAAC;YAC/D,CAAC;YAED,iCAAiC;YACjC,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;gBACrB,MAAM,SAAS,CAAC,UAAU,EAAE,CAAC;YAC9B,CAAC;YACD,oBAAoB,EAAE,CAAC;YAEvB,IAAI,KAAK,YAAY,cAAc,EAAE,CAAC;gBACrC,GAAG,CAAC,KAAK,CAAC,cAAc,EAAE,SAAS,CAAC,YAAY,CAAC,CAAC;YACnD,CAAC;iBAAM,CAAC;gBACP,GAAG,CAAC,KAAK,CAAC,iBAAiB,KAAK,EAAE,EAAE,SAAS,CAAC,YAAY,CAAC,CAAC;YAC7D,CAAC;QACF,CAAC;IACF,CAAC;CACD,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentuity/cli",
3
- "version": "1.0.52",
3
+ "version": "1.0.53",
4
4
  "license": "Apache-2.0",
5
5
  "author": "Agentuity employees and contributors",
6
6
  "type": "module",
@@ -41,9 +41,9 @@
41
41
  "prepublishOnly": "bun run clean && bun run build"
42
42
  },
43
43
  "dependencies": {
44
- "@agentuity/auth": "1.0.52",
45
- "@agentuity/core": "1.0.52",
46
- "@agentuity/server": "1.0.52",
44
+ "@agentuity/auth": "1.0.53",
45
+ "@agentuity/core": "1.0.53",
46
+ "@agentuity/server": "1.0.53",
47
47
  "@datasert/cronjs-parser": "^1.4.0",
48
48
  "@vitejs/plugin-react": "^5.1.2",
49
49
  "acorn-loose": "^8.5.2",
@@ -59,10 +59,10 @@
59
59
  "typescript": "^5.9.0",
60
60
  "vite": "^7.2.7",
61
61
  "zod": "^4.3.5",
62
- "@agentuity/frontend": "1.0.52"
62
+ "@agentuity/frontend": "1.0.53"
63
63
  },
64
64
  "devDependencies": {
65
- "@agentuity/test-utils": "1.0.52",
65
+ "@agentuity/test-utils": "1.0.53",
66
66
  "@types/adm-zip": "^0.5.7",
67
67
  "@types/bun": "latest",
68
68
  "@types/tar-fs": "^2.0.4",
@@ -0,0 +1,223 @@
1
+ import type { Logger } from '@agentuity/core';
2
+ import { spawn } from 'bun';
3
+ import { mkdir, mkdtemp, readdir, realpath, rm, stat } from 'node:fs/promises';
4
+ import { tmpdir } from 'node:os';
5
+ import { join } from 'node:path';
6
+ import { ErrorCode } from '../../errors';
7
+ import * as tui from '../../tui';
8
+
9
+ export interface CIBuildOptions {
10
+ url: string;
11
+ directory?: string;
12
+ trigger?: string;
13
+ event?: string;
14
+ message?: string;
15
+ commit?: string;
16
+ commitUrl?: string;
17
+ branch?: string;
18
+ repo?: string;
19
+ provider?: string;
20
+ pullRequestNumber?: number;
21
+ pullRequestUrl?: string;
22
+ logsUrl?: string;
23
+ }
24
+
25
+ async function streamProcessOutput(proc: ReturnType<typeof spawn>): Promise<void> {
26
+ const forwardStream = async (
27
+ stream: ReadableStream<Uint8Array> | number | undefined,
28
+ isStderr: boolean
29
+ ) => {
30
+ if (typeof stream === 'number') return;
31
+ if (!stream) return;
32
+ const reader = stream.getReader();
33
+ const target = isStderr ? process.stderr : process.stdout;
34
+
35
+ while (true) {
36
+ const { done, value } = await reader.read();
37
+ if (done) break;
38
+ target.write(value);
39
+ }
40
+ };
41
+
42
+ await Promise.all([
43
+ forwardStream(proc.stdout, false),
44
+ forwardStream(proc.stderr, true),
45
+ proc.exited,
46
+ ]);
47
+ }
48
+
49
+ async function runCommand(cmd: string[], cwd: string): Promise<number> {
50
+ const proc = spawn({
51
+ cmd,
52
+ cwd,
53
+ env: { ...process.env, CI: 'true' },
54
+ stdin: 'ignore',
55
+ stdout: 'pipe',
56
+ stderr: 'pipe',
57
+ });
58
+
59
+ await streamProcessOutput(proc);
60
+ return proc.exitCode ?? 1;
61
+ }
62
+
63
+ async function downloadSource(url: string, targetPath: string): Promise<void> {
64
+ let lastError: unknown;
65
+
66
+ for (let attempt = 1; attempt <= 3; attempt++) {
67
+ try {
68
+ const response = await fetch(url, { signal: AbortSignal.timeout(60_000) });
69
+ if (!response.ok) {
70
+ throw new Error(`Download failed with status ${response.status}`);
71
+ }
72
+
73
+ await Bun.write(targetPath, await response.arrayBuffer());
74
+ return;
75
+ } catch (error) {
76
+ lastError = error;
77
+ if (attempt < 3) {
78
+ tui.info(`Download failed (attempt ${attempt}/3), retrying...`);
79
+ }
80
+ }
81
+ }
82
+
83
+ throw lastError instanceof Error ? lastError : new Error('Download failed');
84
+ }
85
+
86
+ function buildDeployArgs(opts: CIBuildOptions): string[] {
87
+ const args: string[] = [];
88
+
89
+ if (opts.trigger) args.push('--trigger', opts.trigger);
90
+ if (opts.event) args.push('--event', opts.event);
91
+ if (opts.message) args.push('--message', opts.message);
92
+ if (opts.commit) args.push('--commit', opts.commit);
93
+ if (opts.commitUrl) args.push('--commit-url', opts.commitUrl);
94
+ if (opts.branch) args.push('--branch', opts.branch);
95
+ if (opts.repo) args.push('--repo', opts.repo);
96
+ if (opts.provider) args.push('--provider', opts.provider);
97
+ if (opts.pullRequestNumber !== undefined) {
98
+ args.push('--pull-request-number', String(opts.pullRequestNumber));
99
+ }
100
+ if (opts.pullRequestUrl) args.push('--pull-request-url', opts.pullRequestUrl);
101
+ if (opts.logsUrl) args.push('--logs-url', opts.logsUrl);
102
+
103
+ return args;
104
+ }
105
+
106
+ export async function runCIBuild(opts: CIBuildOptions, _logger: Logger): Promise<void> {
107
+ let tempDir = '';
108
+
109
+ try {
110
+ tempDir = await mkdtemp(join(tmpdir(), 'agentuity-ci-build-'));
111
+ const sourceZipPath = join(tempDir, 'source.zip');
112
+ const extractPath = join(tempDir, 'build');
113
+
114
+ tui.info('1️⃣ Downloading source code from GitHub...');
115
+ await downloadSource(opts.url, sourceZipPath);
116
+
117
+ tui.info('2️⃣ Unzipping source code from GitHub...');
118
+ await mkdir(extractPath, { recursive: true });
119
+ const unzipExit = await runCommand(
120
+ ['unzip', '-q', sourceZipPath, '-d', extractPath],
121
+ tempDir
122
+ );
123
+ if (unzipExit !== 0 && unzipExit !== 1) {
124
+ tui.fatal(`Failed to unzip source archive (exit ${unzipExit})`, ErrorCode.BUILD_FAILED);
125
+ }
126
+
127
+ const extractedEntries = await readdir(extractPath, { withFileTypes: true });
128
+ const extractedDirs = extractedEntries.filter((entry) => entry.isDirectory());
129
+ if (extractedDirs.length !== 1) {
130
+ tui.fatal(
131
+ `Expected one root directory after unzip, found ${extractedDirs.length}`,
132
+ ErrorCode.BUILD_FAILED
133
+ );
134
+ }
135
+
136
+ const sourceRoot = extractedDirs.at(0);
137
+ if (!sourceRoot) {
138
+ tui.fatal('Could not determine extracted source directory', ErrorCode.BUILD_FAILED);
139
+ }
140
+
141
+ const sourceRootDir = join(extractPath, sourceRoot.name);
142
+ let projectDir = sourceRootDir;
143
+ if (opts.directory) {
144
+ projectDir = join(sourceRootDir, opts.directory);
145
+ }
146
+
147
+ const projectStats = await stat(projectDir).catch(() => null);
148
+ if (!projectStats?.isDirectory()) {
149
+ tui.fatal(`Build directory not found: ${projectDir}`, ErrorCode.CONFIG_INVALID);
150
+ }
151
+
152
+ // Resolve symlinks and verify the project dir is within the source root
153
+ const realProjectDir = await realpath(projectDir).catch(() => null);
154
+ const realSourceRoot = await realpath(sourceRootDir).catch(() => null);
155
+ if (!realProjectDir || !realSourceRoot || !realProjectDir.startsWith(realSourceRoot)) {
156
+ tui.fatal(
157
+ 'Directory path escapes the source root (path traversal denied)',
158
+ ErrorCode.CONFIG_INVALID
159
+ );
160
+ }
161
+ projectDir = realProjectDir;
162
+
163
+ const sdkKey = process.env.AGENTUITY_SDK_KEY;
164
+ if (sdkKey) {
165
+ await Bun.write(join(projectDir, '.env'), `AGENTUITY_SDK_KEY=${sdkKey}\n`);
166
+ }
167
+
168
+ tui.info('3️⃣ Installing your project dependencies...');
169
+ const installExit = await runCommand(['bun', 'install'], projectDir);
170
+ if (installExit !== 0) {
171
+ tui.fatal(`Dependency installation failed (exit ${installExit})`, ErrorCode.BUILD_FAILED);
172
+ }
173
+
174
+ const packageJsonPath = join(projectDir, 'package.json');
175
+ const packageJsonFile = Bun.file(packageJsonPath);
176
+ let scripts: Record<string, string> | undefined;
177
+ if (await packageJsonFile.exists()) {
178
+ const packageJson = (await packageJsonFile.json()) as {
179
+ scripts?: Record<string, string>;
180
+ };
181
+ scripts = packageJson.scripts;
182
+ }
183
+
184
+ if (scripts?.predeploy) {
185
+ tui.info('🔧 Running predeploy script...');
186
+ const predeployExit = await runCommand(['bun', 'run', '--bun', 'predeploy'], projectDir);
187
+ if (predeployExit !== 0) {
188
+ tui.fatal(`Predeploy failed (exit ${predeployExit})`, ErrorCode.BUILD_FAILED);
189
+ }
190
+ }
191
+
192
+ tui.info('4️⃣ Deploying your project...');
193
+ // Use the locally installed CLI binary instead of bunx to avoid
194
+ // bunx resolution crashes on certain Bun versions (e.g. arm64 segfaults)
195
+ const localCliBin = join(projectDir, 'node_modules', '.bin', 'agentuity');
196
+ const cliExists = await stat(localCliBin).catch(() => null);
197
+ const deployCmd = cliExists
198
+ ? ['bun', localCliBin, 'deploy', ...buildDeployArgs(opts)]
199
+ : ['bunx', '--bun', 'agentuity', 'deploy', ...buildDeployArgs(opts)];
200
+ tui.info(`Using CLI: ${cliExists ? localCliBin : 'bunx --bun agentuity'}`);
201
+ const deployExit = await runCommand(deployCmd, projectDir);
202
+ if (deployExit !== 0) {
203
+ tui.fatal(`Deploy failed (exit ${deployExit})`, ErrorCode.BUILD_FAILED);
204
+ }
205
+
206
+ if (scripts?.postdeploy) {
207
+ tui.info('🔧 Running postdeploy script...');
208
+ const postdeployExit = await runCommand(['bun', 'run', '--bun', 'postdeploy'], projectDir);
209
+ if (postdeployExit !== 0) {
210
+ tui.fatal(`Postdeploy failed (exit ${postdeployExit})`, ErrorCode.BUILD_FAILED);
211
+ }
212
+ }
213
+
214
+ tui.success('✅ Your project has been built...');
215
+ } catch (error) {
216
+ const message = error instanceof Error ? error.message : String(error);
217
+ tui.fatal(`CI build failed: ${message}`, ErrorCode.BUILD_FAILED);
218
+ } finally {
219
+ if (tempDir) {
220
+ await rm(tempDir, { recursive: true, force: true });
221
+ }
222
+ }
223
+ }
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { resolve, join, relative } from 'node:path';
3
- import { createCommand } from '../../types';
3
+ import { createCommand, DeployOptionsSchema } from '../../types';
4
4
  import { viteBundle } from './vite-bundler';
5
5
  import * as tui from '../../tui';
6
6
  import { getCommand } from '../../command-prefix';
@@ -16,6 +16,22 @@ const BuildResponseSchema = z.object({
16
16
  size: z.number().optional().describe('Build size in bytes'),
17
17
  });
18
18
 
19
+ const BuildOptionsSchema = z.intersection(
20
+ DeployOptionsSchema,
21
+ z.object({
22
+ dev: z.boolean().optional().describe('Enable development mode'),
23
+ outdir: z.string().optional().describe('Output directory for build artifacts'),
24
+ skipTypeCheck: z.boolean().default(false).optional().describe('Skip typecheck after build'),
25
+ reportFile: z
26
+ .string()
27
+ .optional()
28
+ .describe('file path to save build report JSON with errors, warnings, and diagnostics'),
29
+ ci: z.boolean().optional().describe('Enable CI build mode'),
30
+ url: z.string().optional().describe('Source code download URL (required with --ci)'),
31
+ directory: z.string().optional().describe('Subdirectory within extracted source'),
32
+ })
33
+ );
34
+
19
35
  export const command = createCommand({
20
36
  name: 'build',
21
37
  description: 'Build Agentuity application for deployment',
@@ -26,28 +42,53 @@ export const command = createCommand({
26
42
  examples: [
27
43
  { command: getCommand('build'), description: 'Build the project' },
28
44
  { command: getCommand('build --dev'), description: 'Run in development mode' },
45
+ {
46
+ command: getCommand('build --ci --url https://example.com/source.zip'),
47
+ description: 'Run CI build from source URL',
48
+ },
29
49
  { command: getCommand('bundle'), description: 'Bundle the project' },
30
50
  ],
31
51
  schema: {
32
- options: z.object({
33
- dev: z.boolean().optional().describe('Enable development mode'),
34
- outdir: z.string().optional().describe('Output directory for build artifacts'),
35
- skipTypeCheck: z
36
- .boolean()
37
- .default(false)
38
- .optional()
39
- .describe('Skip typecheck after build'),
40
- reportFile: z
41
- .string()
42
- .optional()
43
- .describe('file path to save build report JSON with errors, warnings, and diagnostics'),
44
- }),
52
+ options: BuildOptionsSchema,
45
53
  response: BuildResponseSchema,
46
54
  },
47
55
 
48
56
  async handler(ctx) {
49
57
  const { opts, projectDir, project } = ctx;
50
58
 
59
+ if (opts.ci) {
60
+ if (!opts.url) {
61
+ tui.fatal('--url is required when using --ci mode', ErrorCode.CONFIG_INVALID);
62
+ }
63
+
64
+ const { runCIBuild } = await import('./ci');
65
+ await runCIBuild(
66
+ {
67
+ url: opts.url,
68
+ directory: opts.directory,
69
+ trigger: opts.trigger,
70
+ event: opts.event,
71
+ message: opts.message,
72
+ commit: opts.commit,
73
+ commitUrl: opts.commitUrl,
74
+ branch: opts.branch,
75
+ repo: opts.repo,
76
+ provider: opts.provider,
77
+ pullRequestNumber: opts.pullRequestNumber,
78
+ pullRequestUrl: opts.pullRequestUrl,
79
+ logsUrl: opts.logsUrl,
80
+ },
81
+ ctx.logger
82
+ );
83
+
84
+ return {
85
+ success: true,
86
+ bundlePath: projectDir,
87
+ projectName: project?.projectId || 'unknown',
88
+ dev: false,
89
+ };
90
+ }
91
+
51
92
  // Initialize build report collector if reportFile is specified
52
93
  const collector = new BuildReportCollector();
53
94
  if (opts.reportFile) {