@giselles-ai/agent-kit 0.1.21 → 0.1.23
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/dist/cli.js +80 -28
- package/package.json +4 -3
package/dist/cli.js
CHANGED
|
@@ -4,9 +4,35 @@
|
|
|
4
4
|
// src/cli.ts
|
|
5
5
|
import process from "process";
|
|
6
6
|
|
|
7
|
+
// src/build-agent.ts
|
|
8
|
+
import { register } from "module";
|
|
9
|
+
import path from "path";
|
|
10
|
+
import { pathToFileURL } from "url";
|
|
11
|
+
async function buildAgent(options) {
|
|
12
|
+
register("tsx/esm", import.meta.url);
|
|
13
|
+
const resolved = path.resolve(options.agentPath);
|
|
14
|
+
const mod = await import(pathToFileURL(resolved).href);
|
|
15
|
+
const agent = mod.agent ?? mod.default;
|
|
16
|
+
if (!agent) {
|
|
17
|
+
throw new Error(
|
|
18
|
+
`No agent config found in ${options.agentPath}. Export a named "agent" or default export.`
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
const { requestBuild } = await import("@giselles-ai/agent");
|
|
22
|
+
const result = await requestBuild(agent, {
|
|
23
|
+
baseUrl: options.baseUrl,
|
|
24
|
+
token: options.token
|
|
25
|
+
});
|
|
26
|
+
if (result.cached) {
|
|
27
|
+
console.log(`[agent-kit] Build cached: snapshot_id=${result.snapshot_id}`);
|
|
28
|
+
} else {
|
|
29
|
+
console.log(`[agent-kit] Build success: snapshot_id=${result.snapshot_id}`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
7
33
|
// src/build-snapshot.ts
|
|
8
34
|
import { readdir, readFile, stat } from "fs/promises";
|
|
9
|
-
import
|
|
35
|
+
import path2 from "path";
|
|
10
36
|
import { Sandbox } from "@vercel/sandbox";
|
|
11
37
|
|
|
12
38
|
// src/sandbox-utils.ts
|
|
@@ -46,7 +72,7 @@ var SKIP_DIR_NAMES = /* @__PURE__ */ new Set([
|
|
|
46
72
|
".jj"
|
|
47
73
|
]);
|
|
48
74
|
function toPosixPath(inputPath) {
|
|
49
|
-
return inputPath.split(
|
|
75
|
+
return inputPath.split(path2.sep).join("/");
|
|
50
76
|
}
|
|
51
77
|
async function collectFiles(targetPath, acc) {
|
|
52
78
|
const targetStat = await stat(targetPath);
|
|
@@ -59,7 +85,7 @@ async function collectFiles(targetPath, acc) {
|
|
|
59
85
|
}
|
|
60
86
|
const entries = await readdir(targetPath, { withFileTypes: true });
|
|
61
87
|
for (const entry of entries) {
|
|
62
|
-
const absolutePath =
|
|
88
|
+
const absolutePath = path2.join(targetPath, entry.name);
|
|
63
89
|
if (entry.isDirectory()) {
|
|
64
90
|
if (SKIP_DIR_NAMES.has(entry.name)) {
|
|
65
91
|
continue;
|
|
@@ -78,7 +104,7 @@ async function collectFiles(targetPath, acc) {
|
|
|
78
104
|
async function buildUploadFileList(repoRoot, includePaths) {
|
|
79
105
|
const files = [];
|
|
80
106
|
for (const relativePath of includePaths) {
|
|
81
|
-
const absolutePath =
|
|
107
|
+
const absolutePath = path2.join(repoRoot, relativePath);
|
|
82
108
|
await collectFiles(absolutePath, files);
|
|
83
109
|
}
|
|
84
110
|
files.sort();
|
|
@@ -129,10 +155,10 @@ async function setupBrowserToolFromLocal(sandbox, sandboxRoot, repoRoot, include
|
|
|
129
155
|
console.log(`[snapshot] files to upload: ${uploadFiles.length}`);
|
|
130
156
|
const filesForSandbox = await Promise.all(
|
|
131
157
|
uploadFiles.map(async (absolutePath) => {
|
|
132
|
-
const relativePath =
|
|
158
|
+
const relativePath = path2.relative(repoRoot, absolutePath);
|
|
133
159
|
const content = await readFile(absolutePath);
|
|
134
160
|
return {
|
|
135
|
-
path: toPosixPath(
|
|
161
|
+
path: toPosixPath(path2.join(sandboxRoot, relativePath)),
|
|
136
162
|
content
|
|
137
163
|
};
|
|
138
164
|
})
|
|
@@ -325,9 +351,19 @@ async function buildSnapshot(options = {}) {
|
|
|
325
351
|
// src/cli.ts
|
|
326
352
|
function printUsage() {
|
|
327
353
|
const usage = `Usage:
|
|
354
|
+
agent-kit build --agent <path> [options]
|
|
328
355
|
agent-kit build-snapshot [options]
|
|
329
356
|
|
|
330
|
-
|
|
357
|
+
Commands:
|
|
358
|
+
build Build an agent snapshot via the API
|
|
359
|
+
build-snapshot Build a base sandbox snapshot locally
|
|
360
|
+
|
|
361
|
+
Build options:
|
|
362
|
+
--agent <path> Path to the agent config file (required)
|
|
363
|
+
--base-url <url> Agent API base URL (env: GISELLE_AGENT_BASE_URL)
|
|
364
|
+
--token <token> API token (env: GISELLE_AGENT_API_KEY)
|
|
365
|
+
|
|
366
|
+
Build-snapshot options:
|
|
331
367
|
--local Copy local files instead of npm install (monorepo only)
|
|
332
368
|
--repo-root <path> Monorepo root directory (required with --local)
|
|
333
369
|
--base-snapshot-id <id> Reuse an existing base snapshot
|
|
@@ -335,6 +371,8 @@ Options:
|
|
|
335
371
|
--runtime <runtime> Sandbox runtime (default: node24)
|
|
336
372
|
--timeout-ms <ms> Sandbox timeout in ms (default: 2700000)
|
|
337
373
|
--browser-tool-version <version> Version of @giselles-ai/browser-tool to install
|
|
374
|
+
|
|
375
|
+
General:
|
|
338
376
|
--help, -h Show this help message
|
|
339
377
|
`;
|
|
340
378
|
process.stderr.write(usage);
|
|
@@ -369,16 +407,19 @@ function parseArgs(argv) {
|
|
|
369
407
|
}
|
|
370
408
|
return { command, options };
|
|
371
409
|
}
|
|
372
|
-
async function
|
|
373
|
-
const
|
|
374
|
-
if (
|
|
375
|
-
|
|
376
|
-
process.exit(
|
|
377
|
-
}
|
|
378
|
-
if (command !== "build-snapshot") {
|
|
379
|
-
printUsage();
|
|
380
|
-
process.exit(command ? 1 : 1);
|
|
410
|
+
async function runBuild(options) {
|
|
411
|
+
const agentPath = options.agent;
|
|
412
|
+
if (!agentPath) {
|
|
413
|
+
console.error("Error: --agent <path> is required for the build command.");
|
|
414
|
+
process.exit(1);
|
|
381
415
|
}
|
|
416
|
+
await buildAgent({
|
|
417
|
+
agentPath,
|
|
418
|
+
baseUrl: options["base-url"] ?? void 0,
|
|
419
|
+
token: options.token ?? void 0
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
async function runBuildSnapshot(options) {
|
|
382
423
|
const isLocal = options.local === true;
|
|
383
424
|
const repoRoot = options["repo-root"] ?? process.env.BROWSER_TOOL_REPO_ROOT?.trim();
|
|
384
425
|
if (isLocal && !repoRoot) {
|
|
@@ -391,18 +432,29 @@ async function main() {
|
|
|
391
432
|
console.error(`Error: Invalid timeout-ms: ${timeoutMsRaw}`);
|
|
392
433
|
process.exit(1);
|
|
393
434
|
}
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
435
|
+
await buildSnapshot({
|
|
436
|
+
local: isLocal,
|
|
437
|
+
repoRoot,
|
|
438
|
+
baseSnapshotId: options["base-snapshot-id"] ?? process.env.BASE_SNAPSHOT_ID?.trim(),
|
|
439
|
+
sandboxRoot: options["sandbox-root"] ?? process.env.BROWSER_TOOL_SANDBOX_ROOT?.trim(),
|
|
440
|
+
runtime: options.runtime ?? process.env.BROWSER_TOOL_SNAPSHOT_RUNTIME?.trim(),
|
|
441
|
+
timeoutMs,
|
|
442
|
+
browserToolVersion: options["browser-tool-version"]
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
async function main() {
|
|
446
|
+
const { command, options } = parseArgs(process.argv);
|
|
447
|
+
if (options.help) {
|
|
448
|
+
printUsage();
|
|
449
|
+
process.exit(0);
|
|
450
|
+
}
|
|
451
|
+
if (command === "build") {
|
|
452
|
+
await runBuild(options);
|
|
453
|
+
} else if (command === "build-snapshot") {
|
|
454
|
+
await runBuildSnapshot(options);
|
|
455
|
+
} else {
|
|
456
|
+
printUsage();
|
|
457
|
+
process.exit(1);
|
|
406
458
|
}
|
|
407
459
|
}
|
|
408
460
|
main().catch((err) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@giselles-ai/agent-kit",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.23",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -36,12 +36,13 @@
|
|
|
36
36
|
"access": "public"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@
|
|
39
|
+
"@giselles-ai/agent": "0.1.23",
|
|
40
|
+
"@vercel/sandbox": "1.8.0",
|
|
41
|
+
"tsx": "4.21.0"
|
|
40
42
|
},
|
|
41
43
|
"devDependencies": {
|
|
42
44
|
"@types/node": "25.3.0",
|
|
43
45
|
"tsup": "8.5.1",
|
|
44
|
-
"tsx": "4.21.0",
|
|
45
46
|
"typescript": "5.9.3"
|
|
46
47
|
}
|
|
47
48
|
}
|