agex 0.2.2 → 0.2.4
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/assets/assets/cursor.js +106 -2
- package/assets/assets/effects.js +1586 -0
- package/dist/chunk-CY6NF2GO.js +6322 -0
- package/dist/cli.d.ts +4 -2
- package/dist/cli.js +387 -193
- package/dist/index.d.ts +5 -3
- package/dist/index.js +9 -4
- package/package.json +5 -3
- package/assets/cursor.js +0 -88
- package/dist/agents-SBEQWA3C.js +0 -10
- package/dist/chunk-2ZRS4JND.js +0 -849
- package/dist/chunk-H3CMLOXO.js +0 -421
package/dist/cli.d.ts
CHANGED
package/dist/cli.js
CHANGED
|
@@ -1,19 +1,134 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
|
-
|
|
3
|
+
AGENT_NAMES,
|
|
4
|
+
APPROVAL_POLICIES,
|
|
5
|
+
OUTPUT_MODES,
|
|
6
|
+
detectDefaultBranch,
|
|
7
|
+
isAgexError,
|
|
8
|
+
prove,
|
|
9
|
+
proveOptionsSchema,
|
|
10
|
+
provePr,
|
|
4
11
|
runAgent,
|
|
5
|
-
runReview
|
|
6
|
-
|
|
7
|
-
|
|
12
|
+
runReview,
|
|
13
|
+
validate,
|
|
14
|
+
viewportStringSchema
|
|
15
|
+
} from "./chunk-CY6NF2GO.js";
|
|
8
16
|
|
|
9
17
|
// src/cli.ts
|
|
10
|
-
import { defineCommand as
|
|
18
|
+
import { defineCommand as defineCommand6, runMain } from "citty";
|
|
11
19
|
|
|
12
|
-
// src/commands/
|
|
20
|
+
// src/commands/browse.ts
|
|
13
21
|
import { defineCommand } from "citty";
|
|
14
|
-
|
|
22
|
+
import { execa } from "execa";
|
|
23
|
+
async function installBrowser() {
|
|
24
|
+
console.log("[agex browse] Browser not found. Installing Chromium...");
|
|
25
|
+
await execa("npx", ["--yes", "playwright", "install", "chromium"], { stdio: "inherit" });
|
|
26
|
+
console.log("[agex browse] Browser installed successfully.");
|
|
27
|
+
}
|
|
28
|
+
async function runAgentBrowser(browserArgs) {
|
|
29
|
+
try {
|
|
30
|
+
const result = await execa("npx", ["--yes", "agent-browser", ...browserArgs], {
|
|
31
|
+
stdio: "pipe",
|
|
32
|
+
env: { ...process.env }
|
|
33
|
+
});
|
|
34
|
+
if (result.stdout) process.stdout.write(result.stdout);
|
|
35
|
+
if (result.stderr) process.stderr.write(result.stderr);
|
|
36
|
+
return { success: true, needsBrowserInstall: false };
|
|
37
|
+
} catch (error) {
|
|
38
|
+
const execaError = error;
|
|
39
|
+
const output = `${execaError.stdout ?? ""}${execaError.stderr ?? ""}`;
|
|
40
|
+
if (output.includes("Executable doesn't exist") || output.includes("npx playwright install")) {
|
|
41
|
+
return { success: false, needsBrowserInstall: true };
|
|
42
|
+
}
|
|
43
|
+
if (execaError.stdout) process.stdout.write(execaError.stdout);
|
|
44
|
+
if (execaError.stderr) process.stderr.write(execaError.stderr);
|
|
45
|
+
return { success: false, needsBrowserInstall: false };
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
var browse_default = defineCommand({
|
|
49
|
+
meta: {
|
|
50
|
+
name: "browse",
|
|
51
|
+
description: "Browser automation via agent-browser"
|
|
52
|
+
},
|
|
53
|
+
args: {
|
|
54
|
+
install: {
|
|
55
|
+
type: "boolean",
|
|
56
|
+
description: "Force reinstall browser",
|
|
57
|
+
default: false
|
|
58
|
+
},
|
|
59
|
+
_: {
|
|
60
|
+
type: "positional",
|
|
61
|
+
description: "agent-browser command and arguments",
|
|
62
|
+
required: false
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
async run({ args, rawArgs }) {
|
|
66
|
+
const browserArgs = rawArgs.filter((arg) => arg !== "--install");
|
|
67
|
+
if (browserArgs.length === 0) {
|
|
68
|
+
console.log(`
|
|
69
|
+
agex browse - Browser automation via agent-browser
|
|
70
|
+
|
|
71
|
+
USAGE:
|
|
72
|
+
agex browse <command> [options]
|
|
73
|
+
|
|
74
|
+
COMMANDS:
|
|
75
|
+
All agent-browser commands are supported. Common ones:
|
|
76
|
+
|
|
77
|
+
open <url> Navigate to URL
|
|
78
|
+
snapshot [-i] Get accessibility tree (use -i for interactive elements)
|
|
79
|
+
click @e1 Click element by ref
|
|
80
|
+
fill @e2 "text" Fill input by ref
|
|
81
|
+
screenshot [path] Take screenshot
|
|
82
|
+
close Close browser
|
|
83
|
+
|
|
84
|
+
OPTIONS:
|
|
85
|
+
--install Force reinstall browser
|
|
86
|
+
|
|
87
|
+
EXAMPLES:
|
|
88
|
+
agex browse open https://example.com
|
|
89
|
+
agex browse snapshot -i
|
|
90
|
+
agex browse click @e1
|
|
91
|
+
agex browse fill @e2 "hello@example.com"
|
|
92
|
+
agex browse screenshot page.png
|
|
93
|
+
agex browse close
|
|
94
|
+
|
|
95
|
+
For full documentation, run: npx agent-browser --help
|
|
96
|
+
Or visit: https://github.com/vercel-labs/agent-browser
|
|
97
|
+
`);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
if (args.install) {
|
|
101
|
+
await installBrowser();
|
|
102
|
+
if (browserArgs.length === 0) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
const firstRun = await runAgentBrowser(browserArgs);
|
|
107
|
+
if (firstRun.success) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
if (firstRun.needsBrowserInstall) {
|
|
111
|
+
await installBrowser();
|
|
112
|
+
try {
|
|
113
|
+
await execa("npx", ["--yes", "agent-browser", ...browserArgs], {
|
|
114
|
+
stdio: "inherit",
|
|
115
|
+
env: { ...process.env }
|
|
116
|
+
});
|
|
117
|
+
} catch (error) {
|
|
118
|
+
const exitCode = error.exitCode ?? 1;
|
|
119
|
+
process.exit(exitCode);
|
|
120
|
+
}
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
process.exit(1);
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
// src/commands/prove.ts
|
|
128
|
+
import { defineCommand as defineCommand2 } from "citty";
|
|
129
|
+
var prove_default = defineCommand2({
|
|
15
130
|
meta: {
|
|
16
|
-
name: "
|
|
131
|
+
name: "prove",
|
|
17
132
|
description: "Prove visual assertions with screenshots"
|
|
18
133
|
},
|
|
19
134
|
args: {
|
|
@@ -37,7 +152,7 @@ var proov_default = defineCommand({
|
|
|
37
152
|
type: "string",
|
|
38
153
|
alias: "o",
|
|
39
154
|
description: "Output directory",
|
|
40
|
-
default: "./
|
|
155
|
+
default: "./prove-results"
|
|
41
156
|
},
|
|
42
157
|
video: {
|
|
43
158
|
type: "boolean",
|
|
@@ -57,7 +172,8 @@ var proov_default = defineCommand({
|
|
|
57
172
|
timeout: {
|
|
58
173
|
type: "string",
|
|
59
174
|
alias: "t",
|
|
60
|
-
description: "Timeout in milliseconds"
|
|
175
|
+
description: "Timeout in milliseconds",
|
|
176
|
+
default: "300000"
|
|
61
177
|
},
|
|
62
178
|
viewport: {
|
|
63
179
|
type: "string",
|
|
@@ -77,7 +193,15 @@ var proov_default = defineCommand({
|
|
|
77
193
|
}
|
|
78
194
|
},
|
|
79
195
|
async run({ args }) {
|
|
80
|
-
|
|
196
|
+
if (!AGENT_NAMES.includes(args.agent)) {
|
|
197
|
+
console.error(`Invalid agent: "${args.agent}". Must be one of: ${AGENT_NAMES.join(", ")}`);
|
|
198
|
+
process.exit(1);
|
|
199
|
+
}
|
|
200
|
+
const viewportResult = viewportStringSchema.safeParse(args.viewport);
|
|
201
|
+
if (!viewportResult.success) {
|
|
202
|
+
console.error(`Invalid viewport: "${args.viewport}". Use format "WIDTHxHEIGHT" (e.g. "1920x1080")`);
|
|
203
|
+
process.exit(1);
|
|
204
|
+
}
|
|
81
205
|
const options = {
|
|
82
206
|
agent: args.agent,
|
|
83
207
|
url: args.url,
|
|
@@ -86,37 +210,242 @@ var proov_default = defineCommand({
|
|
|
86
210
|
screenshots: args.screenshots,
|
|
87
211
|
model: args.model,
|
|
88
212
|
timeout: args.timeout ? parseInt(args.timeout, 10) : void 0,
|
|
89
|
-
viewport:
|
|
213
|
+
viewport: viewportResult.data,
|
|
90
214
|
headless: args.headless
|
|
91
215
|
};
|
|
216
|
+
const validated = validate(proveOptionsSchema, options);
|
|
217
|
+
if (!validated.success) {
|
|
218
|
+
console.error(`Invalid options: ${validated.error}`);
|
|
219
|
+
process.exit(1);
|
|
220
|
+
}
|
|
92
221
|
console.log("========================================");
|
|
93
|
-
console.log("agex
|
|
222
|
+
console.log("agex prove");
|
|
94
223
|
console.log("========================================");
|
|
224
|
+
console.log(`Workspace: ${process.cwd()}`);
|
|
95
225
|
console.log(`Agent: ${options.agent}`);
|
|
96
226
|
console.log(`Task: ${args.assertion}`);
|
|
97
227
|
if (options.url) {
|
|
98
228
|
console.log(`URL: ${options.url}`);
|
|
99
229
|
}
|
|
100
230
|
console.log("========================================\n");
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
231
|
+
try {
|
|
232
|
+
const result = await prove(args.assertion, options);
|
|
233
|
+
console.log("\n========================================");
|
|
234
|
+
if (result.verdict === "pass") {
|
|
235
|
+
console.log("\u2705 PASS");
|
|
236
|
+
} else if (result.verdict === "fail") {
|
|
237
|
+
console.log("\u274C FAIL");
|
|
238
|
+
} else {
|
|
239
|
+
console.log("\u23ED\uFE0F SKIP");
|
|
240
|
+
}
|
|
241
|
+
console.log(`Reason: ${result.reason}`);
|
|
242
|
+
console.log(`Duration: ${result.durationMs}ms`);
|
|
243
|
+
console.log(`Output: ${result.outputDir}`);
|
|
244
|
+
console.log("========================================");
|
|
245
|
+
process.exit(result.verdict === "pass" ? 0 : 1);
|
|
246
|
+
} catch (err) {
|
|
247
|
+
if (isAgexError(err)) {
|
|
248
|
+
console.error(`Error [${err.code}]: ${err.message}`);
|
|
249
|
+
} else {
|
|
250
|
+
console.error(`Unexpected error: ${err instanceof Error ? err.message : String(err)}`);
|
|
251
|
+
}
|
|
252
|
+
process.exit(1);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
// src/commands/prove-pr.ts
|
|
258
|
+
import { defineCommand as defineCommand3 } from "citty";
|
|
259
|
+
var prove_pr_default = defineCommand3({
|
|
260
|
+
meta: {
|
|
261
|
+
name: "prove-pr",
|
|
262
|
+
description: "Prove PR changes work with screenshots and evidence"
|
|
263
|
+
},
|
|
264
|
+
args: {
|
|
265
|
+
base: {
|
|
266
|
+
type: "string",
|
|
267
|
+
description: "Base branch/commit to compare against (auto-detected if omitted)"
|
|
268
|
+
},
|
|
269
|
+
agent: {
|
|
270
|
+
type: "string",
|
|
271
|
+
alias: "a",
|
|
272
|
+
description: "Agent to use: cursor (default), claude, codex",
|
|
273
|
+
default: "cursor"
|
|
274
|
+
},
|
|
275
|
+
url: {
|
|
276
|
+
type: "string",
|
|
277
|
+
alias: "u",
|
|
278
|
+
description: "Dev server URL for visual testing"
|
|
279
|
+
},
|
|
280
|
+
output: {
|
|
281
|
+
type: "string",
|
|
282
|
+
alias: "o",
|
|
283
|
+
description: "Output directory",
|
|
284
|
+
default: "./prove-pr-results"
|
|
285
|
+
},
|
|
286
|
+
hypotheses: {
|
|
287
|
+
type: "string",
|
|
288
|
+
description: "Number of hypotheses to generate",
|
|
289
|
+
default: "5"
|
|
290
|
+
},
|
|
291
|
+
model: {
|
|
292
|
+
type: "string",
|
|
293
|
+
alias: "m",
|
|
294
|
+
description: "Model to use"
|
|
295
|
+
},
|
|
296
|
+
viewport: {
|
|
297
|
+
type: "string",
|
|
298
|
+
description: "Viewport size (WxH)",
|
|
299
|
+
default: "1920x1080"
|
|
300
|
+
},
|
|
301
|
+
hint: {
|
|
302
|
+
type: "string",
|
|
303
|
+
description: "Additional prompt hint for hypothesis generation"
|
|
304
|
+
},
|
|
305
|
+
timeout: {
|
|
306
|
+
type: "string",
|
|
307
|
+
alias: "t",
|
|
308
|
+
description: "Timeout in milliseconds",
|
|
309
|
+
default: "300000"
|
|
310
|
+
}
|
|
311
|
+
},
|
|
312
|
+
async run({ args }) {
|
|
313
|
+
if (!AGENT_NAMES.includes(args.agent)) {
|
|
314
|
+
console.error(`Invalid agent: "${args.agent}". Must be one of: ${AGENT_NAMES.join(", ")}`);
|
|
315
|
+
process.exit(1);
|
|
109
316
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
317
|
+
const viewportResult = viewportStringSchema.safeParse(args.viewport);
|
|
318
|
+
if (!viewportResult.success) {
|
|
319
|
+
console.error(`Invalid viewport: "${args.viewport}". Use format "WIDTHxHEIGHT" (e.g. "1920x1080")`);
|
|
320
|
+
process.exit(1);
|
|
321
|
+
}
|
|
322
|
+
const hypothesesCount = parseInt(args.hypotheses, 10);
|
|
323
|
+
if (isNaN(hypothesesCount) || hypothesesCount <= 0) {
|
|
324
|
+
console.error(`Invalid hypotheses count: "${args.hypotheses}". Must be a positive integer.`);
|
|
325
|
+
process.exit(1);
|
|
326
|
+
}
|
|
327
|
+
const request = {
|
|
328
|
+
baseRef: args.base,
|
|
329
|
+
agent: args.agent,
|
|
330
|
+
url: args.url,
|
|
331
|
+
outputDir: args.output,
|
|
332
|
+
hypothesesCount,
|
|
333
|
+
model: args.model,
|
|
334
|
+
viewport: viewportResult.data,
|
|
335
|
+
hint: args.hint,
|
|
336
|
+
timeoutMs: args.timeout ? parseInt(args.timeout, 10) : void 0
|
|
337
|
+
};
|
|
338
|
+
console.log("========================================");
|
|
339
|
+
console.log("agex prove-pr");
|
|
113
340
|
console.log("========================================");
|
|
114
|
-
|
|
341
|
+
console.log(`Base: ${request.baseRef || "(auto-detect)"}`);
|
|
342
|
+
console.log(`Agent: ${request.agent}`);
|
|
343
|
+
console.log(`Hypotheses: ${hypothesesCount}`);
|
|
344
|
+
if (request.url) console.log(`URL: ${request.url}`);
|
|
345
|
+
console.log(`Output: ${request.outputDir}`);
|
|
346
|
+
console.log("========================================\n");
|
|
347
|
+
try {
|
|
348
|
+
const result = await provePr(request);
|
|
349
|
+
console.log("\n========================================");
|
|
350
|
+
console.log("RESULTS");
|
|
351
|
+
console.log("========================================");
|
|
352
|
+
console.log(`\u2705 Passed: ${result.summary.pass}`);
|
|
353
|
+
console.log(`\u274C Failed: ${result.summary.fail}`);
|
|
354
|
+
console.log(`\u23ED\uFE0F Skipped: ${result.summary.skip}`);
|
|
355
|
+
console.log(`Duration: ${(result.durationMs / 1e3).toFixed(1)}s`);
|
|
356
|
+
console.log(`Output: ${result.outputDir}`);
|
|
357
|
+
console.log("========================================");
|
|
358
|
+
process.exit(result.summary.fail === 0 ? 0 : 1);
|
|
359
|
+
} catch (err) {
|
|
360
|
+
if (isAgexError(err)) {
|
|
361
|
+
console.error(`Error [${err.code}]: ${err.message}`);
|
|
362
|
+
} else {
|
|
363
|
+
console.error(`Unexpected error: ${err instanceof Error ? err.message : String(err)}`);
|
|
364
|
+
}
|
|
365
|
+
process.exit(1);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
// src/commands/review.ts
|
|
371
|
+
import { defineCommand as defineCommand4 } from "citty";
|
|
372
|
+
var review_default = defineCommand4({
|
|
373
|
+
meta: {
|
|
374
|
+
name: "review",
|
|
375
|
+
description: "Review code changes"
|
|
376
|
+
},
|
|
377
|
+
args: {
|
|
378
|
+
base: {
|
|
379
|
+
type: "string",
|
|
380
|
+
description: "Base branch/commit to compare against (auto-detected if omitted)"
|
|
381
|
+
},
|
|
382
|
+
agent: {
|
|
383
|
+
type: "string",
|
|
384
|
+
alias: "a",
|
|
385
|
+
description: "Agent to use: cursor, claude, codex",
|
|
386
|
+
required: true
|
|
387
|
+
},
|
|
388
|
+
model: {
|
|
389
|
+
type: "string",
|
|
390
|
+
alias: "m",
|
|
391
|
+
description: "Model to use"
|
|
392
|
+
},
|
|
393
|
+
worktree: {
|
|
394
|
+
type: "boolean",
|
|
395
|
+
description: "Include worktree changes",
|
|
396
|
+
default: true
|
|
397
|
+
},
|
|
398
|
+
hypotheses: {
|
|
399
|
+
type: "string",
|
|
400
|
+
description: "Number of hypotheses to generate"
|
|
401
|
+
},
|
|
402
|
+
hint: {
|
|
403
|
+
type: "string",
|
|
404
|
+
description: "Additional prompt hint"
|
|
405
|
+
},
|
|
406
|
+
timeout: {
|
|
407
|
+
type: "string",
|
|
408
|
+
alias: "t",
|
|
409
|
+
description: "Timeout in milliseconds",
|
|
410
|
+
default: "300000"
|
|
411
|
+
}
|
|
412
|
+
},
|
|
413
|
+
async run({ args }) {
|
|
414
|
+
if (!AGENT_NAMES.includes(args.agent)) {
|
|
415
|
+
console.error(`Invalid agent: "${args.agent}". Must be one of: ${AGENT_NAMES.join(", ")}`);
|
|
416
|
+
process.exit(1);
|
|
417
|
+
}
|
|
418
|
+
if (args.hypotheses) {
|
|
419
|
+
const h = parseInt(args.hypotheses, 10);
|
|
420
|
+
if (isNaN(h) || h <= 0) {
|
|
421
|
+
console.error(`Invalid hypotheses count: "${args.hypotheses}". Must be a positive integer.`);
|
|
422
|
+
process.exit(1);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
try {
|
|
426
|
+
const base = args.base || detectDefaultBranch();
|
|
427
|
+
await runReview({
|
|
428
|
+
baseRef: base,
|
|
429
|
+
agent: args.agent,
|
|
430
|
+
model: args.model,
|
|
431
|
+
includeWorktree: args.worktree,
|
|
432
|
+
hypotheses: args.hypotheses ? parseInt(args.hypotheses, 10) : void 0,
|
|
433
|
+
promptHint: args.hint,
|
|
434
|
+
timeoutMs: args.timeout ? parseInt(args.timeout, 10) : void 0
|
|
435
|
+
});
|
|
436
|
+
} catch (err) {
|
|
437
|
+
if (isAgexError(err)) {
|
|
438
|
+
console.error(`Error [${err.code}]: ${err.message}`);
|
|
439
|
+
} else {
|
|
440
|
+
console.error(`Unexpected error: ${err instanceof Error ? err.message : String(err)}`);
|
|
441
|
+
}
|
|
442
|
+
process.exit(1);
|
|
443
|
+
}
|
|
115
444
|
}
|
|
116
445
|
});
|
|
117
446
|
|
|
118
447
|
// src/commands/run.ts
|
|
119
|
-
import { defineCommand as
|
|
448
|
+
import { defineCommand as defineCommand5 } from "citty";
|
|
120
449
|
function formatOutput(result, mode, wasStreamed) {
|
|
121
450
|
switch (mode) {
|
|
122
451
|
case "json":
|
|
@@ -132,7 +461,7 @@ ${JSON.stringify(result.json, null, 2)}`;
|
|
|
132
461
|
return null;
|
|
133
462
|
}
|
|
134
463
|
}
|
|
135
|
-
var run_default =
|
|
464
|
+
var run_default = defineCommand5({
|
|
136
465
|
meta: {
|
|
137
466
|
name: "run",
|
|
138
467
|
description: "Execute AI agent tasks"
|
|
@@ -146,8 +475,7 @@ var run_default = defineCommand2({
|
|
|
146
475
|
agent: {
|
|
147
476
|
type: "string",
|
|
148
477
|
alias: "a",
|
|
149
|
-
description: "Agent to use: cursor, claude, codex"
|
|
150
|
-
required: true
|
|
478
|
+
description: "Agent to use: cursor, claude, codex (auto-detected if not specified)"
|
|
151
479
|
},
|
|
152
480
|
model: {
|
|
153
481
|
type: "string",
|
|
@@ -194,10 +522,23 @@ var run_default = defineCommand2({
|
|
|
194
522
|
},
|
|
195
523
|
timeout: {
|
|
196
524
|
type: "string",
|
|
197
|
-
description: "Timeout in milliseconds"
|
|
525
|
+
description: "Timeout in milliseconds",
|
|
526
|
+
default: "300000"
|
|
198
527
|
}
|
|
199
528
|
},
|
|
200
529
|
async run({ args }) {
|
|
530
|
+
if (args.agent && !AGENT_NAMES.includes(args.agent)) {
|
|
531
|
+
console.error(`Invalid agent: "${args.agent}". Must be one of: ${AGENT_NAMES.join(", ")}`);
|
|
532
|
+
process.exit(1);
|
|
533
|
+
}
|
|
534
|
+
if (!OUTPUT_MODES.includes(args.mode)) {
|
|
535
|
+
console.error(`Invalid mode: "${args.mode}". Must be one of: ${OUTPUT_MODES.join(", ")}`);
|
|
536
|
+
process.exit(1);
|
|
537
|
+
}
|
|
538
|
+
if (args.approval && !APPROVAL_POLICIES.includes(args.approval)) {
|
|
539
|
+
console.error(`Invalid approval policy: "${args.approval}". Must be one of: ${APPROVAL_POLICIES.join(", ")}`);
|
|
540
|
+
process.exit(1);
|
|
541
|
+
}
|
|
201
542
|
const outputMode = args.mode;
|
|
202
543
|
const quietOutput = outputMode === "json";
|
|
203
544
|
const streamOutput = quietOutput ? false : args.stream;
|
|
@@ -215,184 +556,37 @@ var run_default = defineCommand2({
|
|
|
215
556
|
approvalPolicy: args.approval,
|
|
216
557
|
timeoutMs: args.timeout ? parseInt(args.timeout, 10) : void 0
|
|
217
558
|
};
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
559
|
+
try {
|
|
560
|
+
const result = await runAgent(request);
|
|
561
|
+
const output = formatOutput(result, outputMode, streamOutput);
|
|
562
|
+
if (output !== null) {
|
|
563
|
+
process.stdout.write(`${output}
|
|
222
564
|
`);
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
// src/commands/review.ts
|
|
228
|
-
import { defineCommand as defineCommand3 } from "citty";
|
|
229
|
-
var review_default = defineCommand3({
|
|
230
|
-
meta: {
|
|
231
|
-
name: "review",
|
|
232
|
-
description: "Review code changes"
|
|
233
|
-
},
|
|
234
|
-
args: {
|
|
235
|
-
base: {
|
|
236
|
-
type: "string",
|
|
237
|
-
description: "Base branch/commit to compare against",
|
|
238
|
-
required: true
|
|
239
|
-
},
|
|
240
|
-
agent: {
|
|
241
|
-
type: "string",
|
|
242
|
-
alias: "a",
|
|
243
|
-
description: "Agent to use: cursor, claude, codex",
|
|
244
|
-
required: true
|
|
245
|
-
},
|
|
246
|
-
model: {
|
|
247
|
-
type: "string",
|
|
248
|
-
alias: "m",
|
|
249
|
-
description: "Model to use"
|
|
250
|
-
},
|
|
251
|
-
worktree: {
|
|
252
|
-
type: "boolean",
|
|
253
|
-
description: "Include worktree changes",
|
|
254
|
-
default: true
|
|
255
|
-
},
|
|
256
|
-
hypotheses: {
|
|
257
|
-
type: "string",
|
|
258
|
-
description: "Number of hypotheses to generate"
|
|
259
|
-
},
|
|
260
|
-
hint: {
|
|
261
|
-
type: "string",
|
|
262
|
-
description: "Additional prompt hint"
|
|
263
|
-
}
|
|
264
|
-
},
|
|
265
|
-
async run({ args }) {
|
|
266
|
-
await runReview({
|
|
267
|
-
baseRef: args.base,
|
|
268
|
-
agent: args.agent,
|
|
269
|
-
model: args.model,
|
|
270
|
-
includeWorktree: args.worktree,
|
|
271
|
-
hypotheses: args.hypotheses ? parseInt(args.hypotheses, 10) : void 0,
|
|
272
|
-
promptHint: args.hint
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
// src/commands/browse.ts
|
|
278
|
-
import { defineCommand as defineCommand4 } from "citty";
|
|
279
|
-
import { execa } from "execa";
|
|
280
|
-
async function installBrowser() {
|
|
281
|
-
console.log("[agex browse] Browser not found. Installing Chromium...");
|
|
282
|
-
await execa("npx", ["--yes", "playwright", "install", "chromium"], { stdio: "inherit" });
|
|
283
|
-
console.log("[agex browse] Browser installed successfully.");
|
|
284
|
-
}
|
|
285
|
-
async function runAgentBrowser(browserArgs) {
|
|
286
|
-
try {
|
|
287
|
-
const result = await execa("npx", ["--yes", "agent-browser", ...browserArgs], {
|
|
288
|
-
stdio: "pipe",
|
|
289
|
-
env: { ...process.env }
|
|
290
|
-
});
|
|
291
|
-
if (result.stdout) process.stdout.write(result.stdout);
|
|
292
|
-
if (result.stderr) process.stderr.write(result.stderr);
|
|
293
|
-
return { success: true, needsBrowserInstall: false };
|
|
294
|
-
} catch (error) {
|
|
295
|
-
const execaError = error;
|
|
296
|
-
const output = `${execaError.stdout ?? ""}${execaError.stderr ?? ""}`;
|
|
297
|
-
if (output.includes("Executable doesn't exist") || output.includes("npx playwright install")) {
|
|
298
|
-
return { success: false, needsBrowserInstall: true };
|
|
299
|
-
}
|
|
300
|
-
if (execaError.stdout) process.stdout.write(execaError.stdout);
|
|
301
|
-
if (execaError.stderr) process.stderr.write(execaError.stderr);
|
|
302
|
-
return { success: false, needsBrowserInstall: false };
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
var browse_default = defineCommand4({
|
|
306
|
-
meta: {
|
|
307
|
-
name: "browse",
|
|
308
|
-
description: "Browser automation via agent-browser"
|
|
309
|
-
},
|
|
310
|
-
args: {
|
|
311
|
-
install: {
|
|
312
|
-
type: "boolean",
|
|
313
|
-
description: "Force reinstall browser",
|
|
314
|
-
default: false
|
|
315
|
-
},
|
|
316
|
-
_: {
|
|
317
|
-
type: "positional",
|
|
318
|
-
description: "agent-browser command and arguments",
|
|
319
|
-
required: false
|
|
320
|
-
}
|
|
321
|
-
},
|
|
322
|
-
async run({ args, rawArgs }) {
|
|
323
|
-
const browserArgs = rawArgs.filter((arg) => arg !== "--install");
|
|
324
|
-
if (browserArgs.length === 0) {
|
|
325
|
-
console.log(`
|
|
326
|
-
agex browse - Browser automation via agent-browser
|
|
327
|
-
|
|
328
|
-
USAGE:
|
|
329
|
-
agex browse <command> [options]
|
|
330
|
-
|
|
331
|
-
COMMANDS:
|
|
332
|
-
All agent-browser commands are supported. Common ones:
|
|
333
|
-
|
|
334
|
-
open <url> Navigate to URL
|
|
335
|
-
snapshot [-i] Get accessibility tree (use -i for interactive elements)
|
|
336
|
-
click @e1 Click element by ref
|
|
337
|
-
fill @e2 "text" Fill input by ref
|
|
338
|
-
screenshot [path] Take screenshot
|
|
339
|
-
close Close browser
|
|
340
|
-
|
|
341
|
-
OPTIONS:
|
|
342
|
-
--install Force reinstall browser
|
|
343
|
-
|
|
344
|
-
EXAMPLES:
|
|
345
|
-
agex browse open https://example.com
|
|
346
|
-
agex browse snapshot -i
|
|
347
|
-
agex browse click @e1
|
|
348
|
-
agex browse fill @e2 "hello@example.com"
|
|
349
|
-
agex browse screenshot page.png
|
|
350
|
-
agex browse close
|
|
351
|
-
|
|
352
|
-
For full documentation, run: npx agent-browser --help
|
|
353
|
-
Or visit: https://github.com/vercel-labs/agent-browser
|
|
354
|
-
`);
|
|
355
|
-
return;
|
|
356
|
-
}
|
|
357
|
-
if (args.install) {
|
|
358
|
-
await installBrowser();
|
|
359
|
-
if (browserArgs.length === 0) {
|
|
360
|
-
return;
|
|
361
565
|
}
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
if (firstRun.needsBrowserInstall) {
|
|
368
|
-
await installBrowser();
|
|
369
|
-
try {
|
|
370
|
-
await execa("npx", ["--yes", "agent-browser", ...browserArgs], {
|
|
371
|
-
stdio: "inherit",
|
|
372
|
-
env: { ...process.env }
|
|
373
|
-
});
|
|
374
|
-
} catch (error) {
|
|
375
|
-
const exitCode = error.exitCode ?? 1;
|
|
376
|
-
process.exit(exitCode);
|
|
566
|
+
} catch (err) {
|
|
567
|
+
if (isAgexError(err)) {
|
|
568
|
+
console.error(`Error [${err.code}]: ${err.message}`);
|
|
569
|
+
} else {
|
|
570
|
+
console.error(`Unexpected error: ${err instanceof Error ? err.message : String(err)}`);
|
|
377
571
|
}
|
|
378
|
-
|
|
572
|
+
process.exit(1);
|
|
379
573
|
}
|
|
380
|
-
process.exit(1);
|
|
381
574
|
}
|
|
382
575
|
});
|
|
383
576
|
|
|
384
577
|
// src/cli.ts
|
|
385
|
-
var main =
|
|
578
|
+
var main = defineCommand6({
|
|
386
579
|
meta: {
|
|
387
580
|
name: "agex",
|
|
388
581
|
version: "0.1.2",
|
|
389
582
|
description: "AI-powered automation toolkit"
|
|
390
583
|
},
|
|
391
584
|
subCommands: {
|
|
392
|
-
|
|
393
|
-
|
|
585
|
+
browse: browse_default,
|
|
586
|
+
prove: prove_default,
|
|
587
|
+
"prove-pr": prove_pr_default,
|
|
394
588
|
review: review_default,
|
|
395
|
-
|
|
589
|
+
run: run_default
|
|
396
590
|
}
|
|
397
591
|
});
|
|
398
592
|
runMain(main);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
1
|
+
export { ProveOptions, ProveResult, prove } from 'agex-prove';
|
|
2
|
+
export { ProvePrRequest, ProvePrResult, provePr } from 'agex-prove-pr';
|
|
3
|
+
export { AgentName, OutputMode, RunOutput, RunRequest, runAgent } from 'agex-agent';
|
|
4
|
+
export { ReviewOutput, ReviewRequest, runReview } from 'agex-review';
|
|
5
|
+
export { AgexError, Verdict, isAgexError } from 'agex-core';
|