@vm0/cli 3.5.0 → 3.6.0
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/index.js +195 -22
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -736,10 +736,10 @@ function mergeDefs(...defs) {
|
|
|
736
736
|
function cloneDef(schema) {
|
|
737
737
|
return mergeDefs(schema._zod.def);
|
|
738
738
|
}
|
|
739
|
-
function getElementAtPath(obj,
|
|
740
|
-
if (!
|
|
739
|
+
function getElementAtPath(obj, path10) {
|
|
740
|
+
if (!path10)
|
|
741
741
|
return obj;
|
|
742
|
-
return
|
|
742
|
+
return path10.reduce((acc, key) => acc?.[key], obj);
|
|
743
743
|
}
|
|
744
744
|
function promiseAllObject(promisesObj) {
|
|
745
745
|
const keys = Object.keys(promisesObj);
|
|
@@ -1098,11 +1098,11 @@ function aborted(x, startIndex = 0) {
|
|
|
1098
1098
|
}
|
|
1099
1099
|
return false;
|
|
1100
1100
|
}
|
|
1101
|
-
function prefixIssues(
|
|
1101
|
+
function prefixIssues(path10, issues) {
|
|
1102
1102
|
return issues.map((iss) => {
|
|
1103
1103
|
var _a;
|
|
1104
1104
|
(_a = iss).path ?? (_a.path = []);
|
|
1105
|
-
iss.path.unshift(
|
|
1105
|
+
iss.path.unshift(path10);
|
|
1106
1106
|
return iss;
|
|
1107
1107
|
});
|
|
1108
1108
|
}
|
|
@@ -1270,7 +1270,7 @@ function treeifyError(error43, _mapper) {
|
|
|
1270
1270
|
return issue2.message;
|
|
1271
1271
|
};
|
|
1272
1272
|
const result = { errors: [] };
|
|
1273
|
-
const processError = (error44,
|
|
1273
|
+
const processError = (error44, path10 = []) => {
|
|
1274
1274
|
var _a, _b;
|
|
1275
1275
|
for (const issue2 of error44.issues) {
|
|
1276
1276
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
@@ -1280,7 +1280,7 @@ function treeifyError(error43, _mapper) {
|
|
|
1280
1280
|
} else if (issue2.code === "invalid_element") {
|
|
1281
1281
|
processError({ issues: issue2.issues }, issue2.path);
|
|
1282
1282
|
} else {
|
|
1283
|
-
const fullpath = [...
|
|
1283
|
+
const fullpath = [...path10, ...issue2.path];
|
|
1284
1284
|
if (fullpath.length === 0) {
|
|
1285
1285
|
result.errors.push(mapper(issue2));
|
|
1286
1286
|
continue;
|
|
@@ -1312,8 +1312,8 @@ function treeifyError(error43, _mapper) {
|
|
|
1312
1312
|
}
|
|
1313
1313
|
function toDotPath(_path) {
|
|
1314
1314
|
const segs = [];
|
|
1315
|
-
const
|
|
1316
|
-
for (const seg of
|
|
1315
|
+
const path10 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
1316
|
+
for (const seg of path10) {
|
|
1317
1317
|
if (typeof seg === "number")
|
|
1318
1318
|
segs.push(`[${seg}]`);
|
|
1319
1319
|
else if (typeof seg === "symbol")
|
|
@@ -12147,8 +12147,8 @@ var helloContract = c.router({
|
|
|
12147
12147
|
var FOO = "hello";
|
|
12148
12148
|
|
|
12149
12149
|
// src/index.ts
|
|
12150
|
-
import { Command as
|
|
12151
|
-
import
|
|
12150
|
+
import { Command as Command16 } from "commander";
|
|
12151
|
+
import chalk15 from "chalk";
|
|
12152
12152
|
|
|
12153
12153
|
// src/lib/auth.ts
|
|
12154
12154
|
import chalk from "chalk";
|
|
@@ -12453,7 +12453,7 @@ var ApiClient = class {
|
|
|
12453
12453
|
/**
|
|
12454
12454
|
* Generic GET request
|
|
12455
12455
|
*/
|
|
12456
|
-
async get(
|
|
12456
|
+
async get(path10) {
|
|
12457
12457
|
const baseUrl = await this.getBaseUrl();
|
|
12458
12458
|
const token = await getToken();
|
|
12459
12459
|
if (!token) {
|
|
@@ -12466,7 +12466,7 @@ var ApiClient = class {
|
|
|
12466
12466
|
if (bypassSecret) {
|
|
12467
12467
|
headers["x-vercel-protection-bypass"] = bypassSecret;
|
|
12468
12468
|
}
|
|
12469
|
-
return fetch(`${baseUrl}${
|
|
12469
|
+
return fetch(`${baseUrl}${path10}`, {
|
|
12470
12470
|
method: "GET",
|
|
12471
12471
|
headers
|
|
12472
12472
|
});
|
|
@@ -12474,7 +12474,7 @@ var ApiClient = class {
|
|
|
12474
12474
|
/**
|
|
12475
12475
|
* Generic POST request
|
|
12476
12476
|
*/
|
|
12477
|
-
async post(
|
|
12477
|
+
async post(path10, options) {
|
|
12478
12478
|
const baseUrl = await this.getBaseUrl();
|
|
12479
12479
|
const token = await getToken();
|
|
12480
12480
|
if (!token) {
|
|
@@ -12487,7 +12487,7 @@ var ApiClient = class {
|
|
|
12487
12487
|
if (bypassSecret) {
|
|
12488
12488
|
headers["x-vercel-protection-bypass"] = bypassSecret;
|
|
12489
12489
|
}
|
|
12490
|
-
return fetch(`${baseUrl}${
|
|
12490
|
+
return fetch(`${baseUrl}${path10}`, {
|
|
12491
12491
|
method: "POST",
|
|
12492
12492
|
headers,
|
|
12493
12493
|
body: options?.body
|
|
@@ -12496,7 +12496,7 @@ var ApiClient = class {
|
|
|
12496
12496
|
/**
|
|
12497
12497
|
* Generic DELETE request
|
|
12498
12498
|
*/
|
|
12499
|
-
async delete(
|
|
12499
|
+
async delete(path10) {
|
|
12500
12500
|
const baseUrl = await this.getBaseUrl();
|
|
12501
12501
|
const token = await getToken();
|
|
12502
12502
|
if (!token) {
|
|
@@ -12509,7 +12509,7 @@ var ApiClient = class {
|
|
|
12509
12509
|
if (bypassSecret) {
|
|
12510
12510
|
headers["x-vercel-protection-bypass"] = bypassSecret;
|
|
12511
12511
|
}
|
|
12512
|
-
return fetch(`${baseUrl}${
|
|
12512
|
+
return fetch(`${baseUrl}${path10}`, {
|
|
12513
12513
|
method: "DELETE",
|
|
12514
12514
|
headers
|
|
12515
12515
|
});
|
|
@@ -14293,15 +14293,187 @@ var deleteCommand = new Command13().name("delete").alias("rm").description("Dele
|
|
|
14293
14293
|
// src/commands/secret/index.ts
|
|
14294
14294
|
var secretCommand = new Command14().name("secret").description("Manage secrets for agent compose configurations").addCommand(setCommand).addCommand(listCommand).addCommand(deleteCommand);
|
|
14295
14295
|
|
|
14296
|
+
// src/commands/cook.ts
|
|
14297
|
+
import { Command as Command15 } from "commander";
|
|
14298
|
+
import chalk14 from "chalk";
|
|
14299
|
+
import { readFile as readFile4, mkdir as mkdir3 } from "fs/promises";
|
|
14300
|
+
import { existsSync as existsSync4 } from "fs";
|
|
14301
|
+
import path9 from "path";
|
|
14302
|
+
import { spawn } from "child_process";
|
|
14303
|
+
import { parse as parseYaml3 } from "yaml";
|
|
14304
|
+
var CONFIG_FILE3 = "vm0.yaml";
|
|
14305
|
+
var ARTIFACT_DIR = "artifact";
|
|
14306
|
+
function execVm0Command(args, options = {}) {
|
|
14307
|
+
return new Promise((resolve, reject) => {
|
|
14308
|
+
const proc = spawn("vm0", args, {
|
|
14309
|
+
cwd: options.cwd,
|
|
14310
|
+
stdio: options.silent ? "pipe" : ["inherit", "inherit", "inherit"],
|
|
14311
|
+
shell: process.platform === "win32"
|
|
14312
|
+
});
|
|
14313
|
+
let stdout = "";
|
|
14314
|
+
let stderr = "";
|
|
14315
|
+
if (options.silent) {
|
|
14316
|
+
proc.stdout?.on("data", (data) => {
|
|
14317
|
+
stdout += data.toString();
|
|
14318
|
+
});
|
|
14319
|
+
proc.stderr?.on("data", (data) => {
|
|
14320
|
+
stderr += data.toString();
|
|
14321
|
+
});
|
|
14322
|
+
}
|
|
14323
|
+
proc.on("close", (code) => {
|
|
14324
|
+
if (code === 0) {
|
|
14325
|
+
resolve(stdout);
|
|
14326
|
+
} else {
|
|
14327
|
+
reject(new Error(stderr || `Command failed with exit code ${code}`));
|
|
14328
|
+
}
|
|
14329
|
+
});
|
|
14330
|
+
proc.on("error", (err) => {
|
|
14331
|
+
reject(err);
|
|
14332
|
+
});
|
|
14333
|
+
});
|
|
14334
|
+
}
|
|
14335
|
+
var cookCommand = new Command15().name("cook").description("One-click agent preparation and execution from vm0.yaml").argument("[prompt]", "Prompt for the agent").action(async (prompt) => {
|
|
14336
|
+
const cwd = process.cwd();
|
|
14337
|
+
console.log(chalk14.blue(`Reading config: ${CONFIG_FILE3}`));
|
|
14338
|
+
if (!existsSync4(CONFIG_FILE3)) {
|
|
14339
|
+
console.error(chalk14.red(`\u2717 Config file not found: ${CONFIG_FILE3}`));
|
|
14340
|
+
process.exit(1);
|
|
14341
|
+
}
|
|
14342
|
+
let config2;
|
|
14343
|
+
try {
|
|
14344
|
+
const content = await readFile4(CONFIG_FILE3, "utf8");
|
|
14345
|
+
config2 = parseYaml3(content);
|
|
14346
|
+
} catch (error43) {
|
|
14347
|
+
console.error(chalk14.red("\u2717 Invalid YAML format"));
|
|
14348
|
+
if (error43 instanceof Error) {
|
|
14349
|
+
console.error(chalk14.gray(` ${error43.message}`));
|
|
14350
|
+
}
|
|
14351
|
+
process.exit(1);
|
|
14352
|
+
}
|
|
14353
|
+
const validation = validateAgentCompose(config2);
|
|
14354
|
+
if (!validation.valid) {
|
|
14355
|
+
console.error(chalk14.red(`\u2717 ${validation.error}`));
|
|
14356
|
+
process.exit(1);
|
|
14357
|
+
}
|
|
14358
|
+
const agentNames = Object.keys(config2.agents);
|
|
14359
|
+
const agentName = agentNames[0];
|
|
14360
|
+
const volumeCount = config2.volumes ? Object.keys(config2.volumes).length : 0;
|
|
14361
|
+
console.log(
|
|
14362
|
+
chalk14.green(`\u2713 Config validated: 1 agent, ${volumeCount} volume(s)`)
|
|
14363
|
+
);
|
|
14364
|
+
if (config2.volumes && Object.keys(config2.volumes).length > 0) {
|
|
14365
|
+
console.log();
|
|
14366
|
+
console.log(chalk14.blue("Processing volumes..."));
|
|
14367
|
+
for (const volumeConfig of Object.values(config2.volumes)) {
|
|
14368
|
+
const volumeDir = path9.join(cwd, volumeConfig.name);
|
|
14369
|
+
console.log(chalk14.gray(` ${volumeConfig.name}/`));
|
|
14370
|
+
if (!existsSync4(volumeDir)) {
|
|
14371
|
+
console.error(
|
|
14372
|
+
chalk14.red(
|
|
14373
|
+
` \u2717 Directory not found. Create the directory and add files first.`
|
|
14374
|
+
)
|
|
14375
|
+
);
|
|
14376
|
+
process.exit(1);
|
|
14377
|
+
}
|
|
14378
|
+
try {
|
|
14379
|
+
const existingConfig = await readStorageConfig(volumeDir);
|
|
14380
|
+
if (!existingConfig) {
|
|
14381
|
+
await execVm0Command(["volume", "init"], {
|
|
14382
|
+
cwd: volumeDir,
|
|
14383
|
+
silent: true
|
|
14384
|
+
});
|
|
14385
|
+
console.log(chalk14.green(` \u2713 Initialized`));
|
|
14386
|
+
}
|
|
14387
|
+
await execVm0Command(["volume", "push"], {
|
|
14388
|
+
cwd: volumeDir,
|
|
14389
|
+
silent: true
|
|
14390
|
+
});
|
|
14391
|
+
console.log(chalk14.green(` \u2713 Pushed`));
|
|
14392
|
+
} catch (error43) {
|
|
14393
|
+
console.error(chalk14.red(` \u2717 Failed`));
|
|
14394
|
+
if (error43 instanceof Error) {
|
|
14395
|
+
console.error(chalk14.gray(` ${error43.message}`));
|
|
14396
|
+
}
|
|
14397
|
+
process.exit(1);
|
|
14398
|
+
}
|
|
14399
|
+
}
|
|
14400
|
+
}
|
|
14401
|
+
console.log();
|
|
14402
|
+
console.log(chalk14.blue("Processing artifact..."));
|
|
14403
|
+
const artifactDir = path9.join(cwd, ARTIFACT_DIR);
|
|
14404
|
+
console.log(chalk14.gray(` ${ARTIFACT_DIR}/`));
|
|
14405
|
+
try {
|
|
14406
|
+
if (!existsSync4(artifactDir)) {
|
|
14407
|
+
await mkdir3(artifactDir, { recursive: true });
|
|
14408
|
+
console.log(chalk14.green(` \u2713 Created directory`));
|
|
14409
|
+
}
|
|
14410
|
+
const existingConfig = await readStorageConfig(artifactDir);
|
|
14411
|
+
if (!existingConfig) {
|
|
14412
|
+
await execVm0Command(["artifact", "init"], {
|
|
14413
|
+
cwd: artifactDir,
|
|
14414
|
+
silent: true
|
|
14415
|
+
});
|
|
14416
|
+
console.log(chalk14.green(` \u2713 Initialized`));
|
|
14417
|
+
}
|
|
14418
|
+
await execVm0Command(["artifact", "push"], {
|
|
14419
|
+
cwd: artifactDir,
|
|
14420
|
+
silent: true
|
|
14421
|
+
});
|
|
14422
|
+
console.log(chalk14.green(` \u2713 Pushed`));
|
|
14423
|
+
} catch (error43) {
|
|
14424
|
+
console.error(chalk14.red(` \u2717 Failed`));
|
|
14425
|
+
if (error43 instanceof Error) {
|
|
14426
|
+
console.error(chalk14.gray(` ${error43.message}`));
|
|
14427
|
+
}
|
|
14428
|
+
process.exit(1);
|
|
14429
|
+
}
|
|
14430
|
+
console.log();
|
|
14431
|
+
console.log(chalk14.blue("Building compose..."));
|
|
14432
|
+
try {
|
|
14433
|
+
await execVm0Command(["build", CONFIG_FILE3], {
|
|
14434
|
+
cwd,
|
|
14435
|
+
silent: true
|
|
14436
|
+
});
|
|
14437
|
+
console.log(chalk14.green(`\u2713 Compose built: ${agentName}`));
|
|
14438
|
+
} catch (error43) {
|
|
14439
|
+
console.error(chalk14.red(`\u2717 Build failed`));
|
|
14440
|
+
if (error43 instanceof Error) {
|
|
14441
|
+
console.error(chalk14.gray(` ${error43.message}`));
|
|
14442
|
+
}
|
|
14443
|
+
process.exit(1);
|
|
14444
|
+
}
|
|
14445
|
+
if (prompt) {
|
|
14446
|
+
console.log();
|
|
14447
|
+
console.log(chalk14.blue(`Running agent: ${agentName}`));
|
|
14448
|
+
console.log();
|
|
14449
|
+
try {
|
|
14450
|
+
await execVm0Command(
|
|
14451
|
+
["run", agentName, "--artifact-name", ARTIFACT_DIR, prompt],
|
|
14452
|
+
{ cwd, silent: false }
|
|
14453
|
+
);
|
|
14454
|
+
} catch {
|
|
14455
|
+
process.exit(1);
|
|
14456
|
+
}
|
|
14457
|
+
} else {
|
|
14458
|
+
console.log();
|
|
14459
|
+
console.log(" Run your agent:");
|
|
14460
|
+
console.log(
|
|
14461
|
+
chalk14.cyan(
|
|
14462
|
+
` vm0 run ${agentName} --artifact-name ${ARTIFACT_DIR} "your prompt"`
|
|
14463
|
+
)
|
|
14464
|
+
);
|
|
14465
|
+
}
|
|
14466
|
+
});
|
|
14467
|
+
|
|
14296
14468
|
// src/index.ts
|
|
14297
|
-
var program = new
|
|
14298
|
-
program.name("vm0").description("VM0 CLI - A modern build tool").version("3.
|
|
14469
|
+
var program = new Command16();
|
|
14470
|
+
program.name("vm0").description("VM0 CLI - A modern build tool").version("3.6.0");
|
|
14299
14471
|
program.command("hello").description("Say hello from the App").action(() => {
|
|
14300
|
-
console.log(
|
|
14301
|
-
console.log(
|
|
14472
|
+
console.log(chalk15.blue("Welcome to the VM0 CLI!"));
|
|
14473
|
+
console.log(chalk15.green(`Core says: ${FOO}`));
|
|
14302
14474
|
});
|
|
14303
14475
|
program.command("info").description("Display environment information").action(async () => {
|
|
14304
|
-
console.log(
|
|
14476
|
+
console.log(chalk15.cyan("System Information:"));
|
|
14305
14477
|
console.log(`Node Version: ${process.version}`);
|
|
14306
14478
|
console.log(`Platform: ${process.platform}`);
|
|
14307
14479
|
console.log(`Architecture: ${process.arch}`);
|
|
@@ -14323,6 +14495,7 @@ program.addCommand(runCommand);
|
|
|
14323
14495
|
program.addCommand(volumeCommand);
|
|
14324
14496
|
program.addCommand(artifactCommand);
|
|
14325
14497
|
program.addCommand(secretCommand);
|
|
14498
|
+
program.addCommand(cookCommand);
|
|
14326
14499
|
if (process.argv[1]?.endsWith("index.js") || process.argv[1]?.endsWith("index.ts") || process.argv[1]?.endsWith("vm0")) {
|
|
14327
14500
|
program.parse();
|
|
14328
14501
|
}
|