@vm0/cli 1.1.0 → 1.2.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.
Files changed (2) hide show
  1. package/index.js +68 -6
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -12348,7 +12348,7 @@ var ApiClient = class {
12348
12348
  );
12349
12349
  if (!response.ok) {
12350
12350
  const error43 = await response.json();
12351
- throw new Error(error43.error || `Config not found: ${name}`);
12351
+ throw new Error(error43.error?.message || `Config not found: ${name}`);
12352
12352
  }
12353
12353
  return await response.json();
12354
12354
  }
@@ -12362,7 +12362,7 @@ var ApiClient = class {
12362
12362
  });
12363
12363
  if (!response.ok) {
12364
12364
  const error43 = await response.json();
12365
- throw new Error(error43.error || "Failed to create config");
12365
+ throw new Error(error43.error?.message || "Failed to create config");
12366
12366
  }
12367
12367
  return await response.json();
12368
12368
  }
@@ -12376,7 +12376,8 @@ var ApiClient = class {
12376
12376
  });
12377
12377
  if (!response.ok) {
12378
12378
  const error43 = await response.json();
12379
- throw new Error(error43.error || "Failed to create run");
12379
+ const message = error43.error?.message || "Failed to create run";
12380
+ throw new Error(message);
12380
12381
  }
12381
12382
  return await response.json();
12382
12383
  }
@@ -12394,7 +12395,7 @@ var ApiClient = class {
12394
12395
  );
12395
12396
  if (!response.ok) {
12396
12397
  const error43 = await response.json();
12397
- throw new Error(error43.error || "Failed to fetch events");
12398
+ throw new Error(error43.error?.message || "Failed to fetch events");
12398
12399
  }
12399
12400
  return await response.json();
12400
12401
  }
@@ -12408,7 +12409,7 @@ var ApiClient = class {
12408
12409
  });
12409
12410
  if (!response.ok) {
12410
12411
  const error43 = await response.json();
12411
- throw new Error(error43.error || "Failed to resume run");
12412
+ throw new Error(error43.error?.message || "Failed to resume run");
12412
12413
  }
12413
12414
  return await response.json();
12414
12415
  }
@@ -12453,6 +12454,39 @@ function expandEnvVars(value) {
12453
12454
  return process.env[varName] ?? "";
12454
12455
  });
12455
12456
  }
12457
+ function extractEnvVarReferences(obj) {
12458
+ const varNames = /* @__PURE__ */ new Set();
12459
+ function scan(value) {
12460
+ if (typeof value === "string") {
12461
+ const matches = value.matchAll(/\$\{([^}]+)\}/g);
12462
+ for (const match of matches) {
12463
+ const varName = match[1];
12464
+ if (varName) {
12465
+ varNames.add(varName);
12466
+ }
12467
+ }
12468
+ } else if (Array.isArray(value)) {
12469
+ for (const item of value) {
12470
+ scan(item);
12471
+ }
12472
+ } else if (value !== null && typeof value === "object") {
12473
+ for (const val of Object.values(value)) {
12474
+ scan(val);
12475
+ }
12476
+ }
12477
+ }
12478
+ scan(obj);
12479
+ return Array.from(varNames);
12480
+ }
12481
+ function validateEnvVars(varNames) {
12482
+ const missing = [];
12483
+ for (const varName of varNames) {
12484
+ if (process.env[varName] === void 0) {
12485
+ missing.push(varName);
12486
+ }
12487
+ }
12488
+ return missing;
12489
+ }
12456
12490
  function expandEnvVarsInObject(obj) {
12457
12491
  if (typeof obj === "string") {
12458
12492
  return expandEnvVars(obj);
@@ -12488,6 +12522,23 @@ var buildCommand = new Command().name("build").description("Create or update age
12488
12522
  }
12489
12523
  process.exit(1);
12490
12524
  }
12525
+ const referencedVars = extractEnvVarReferences(config2);
12526
+ const missingVars = validateEnvVars(referencedVars);
12527
+ if (missingVars.length > 0) {
12528
+ console.error(chalk2.red("\u2717 Missing required environment variables:"));
12529
+ for (const varName of missingVars) {
12530
+ console.error(chalk2.red(` - ${varName}`));
12531
+ }
12532
+ console.error();
12533
+ console.error(
12534
+ chalk2.gray("Please set these variables before running 'vm0 build'.")
12535
+ );
12536
+ console.error(chalk2.gray("Example:"));
12537
+ for (const varName of missingVars) {
12538
+ console.error(chalk2.gray(` export ${varName}=your-value`));
12539
+ }
12540
+ process.exit(1);
12541
+ }
12491
12542
  config2 = expandEnvVarsInObject(config2);
12492
12543
  const validation = validateAgentConfig(config2);
12493
12544
  if (!validation.valid) {
@@ -12793,7 +12844,18 @@ var EventRenderer = class {
12793
12844
  }
12794
12845
  static renderVm0Error(event) {
12795
12846
  console.log(chalk3.red("[vm0_error]") + " \u2717 Run failed");
12796
- console.log(` Error: ${chalk3.red(String(event.data.error || ""))}`);
12847
+ let errorMessage = "";
12848
+ if (typeof event.data.error === "string") {
12849
+ errorMessage = event.data.error;
12850
+ } else if (event.data.error && typeof event.data.error === "object") {
12851
+ const errorObj = event.data.error;
12852
+ if ("message" in errorObj && typeof errorObj.message === "string") {
12853
+ errorMessage = errorObj.message;
12854
+ } else {
12855
+ errorMessage = JSON.stringify(event.data.error);
12856
+ }
12857
+ }
12858
+ console.log(` Error: ${chalk3.red(errorMessage || "Unknown error")}`);
12797
12859
  if (event.data.errorType) {
12798
12860
  console.log(` Type: ${chalk3.gray(String(event.data.errorType))}`);
12799
12861
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vm0/cli",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "CLI application",
5
5
  "type": "module",
6
6
  "bin": {