@vm0/cli 6.3.0 → 6.3.1

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 +79 -102
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -747,7 +747,7 @@ var runEventsContract = c3.router({
747
747
  id: z4.string().min(1, "Run ID is required")
748
748
  }),
749
749
  query: z4.object({
750
- since: z4.coerce.number().default(0),
750
+ since: z4.coerce.number().default(-1),
751
751
  limit: z4.coerce.number().default(100)
752
752
  }),
753
753
  responses: {
@@ -1130,7 +1130,7 @@ import { z as z6 } from "zod";
1130
1130
  var c5 = initContract();
1131
1131
  var agentEventSchema = z6.object({
1132
1132
  type: z6.string(),
1133
- sequenceNumber: z6.number().int().positive()
1133
+ sequenceNumber: z6.number().int().nonnegative()
1134
1134
  }).passthrough();
1135
1135
  var artifactSnapshotSchema = z6.object({
1136
1136
  artifactName: z6.string(),
@@ -3004,7 +3004,7 @@ async function getEvents(runId, options) {
3004
3004
  const result = await client.getEvents({
3005
3005
  params: { id: runId },
3006
3006
  query: {
3007
- since: options?.since ?? 0,
3007
+ since: options?.since ?? -1,
3008
3008
  limit: options?.limit ?? 100
3009
3009
  }
3010
3010
  });
@@ -4120,18 +4120,10 @@ var composeCommand = new Command().name("compose").description("Create or update
4120
4120
  );
4121
4121
  if (defaultImage) {
4122
4122
  agent.image = defaultImage;
4123
- console.log(
4124
- chalk2.dim(` Auto-configured image: ${defaultImage}`)
4125
- );
4126
4123
  }
4127
4124
  }
4128
4125
  if (!agent.working_dir) {
4129
4126
  agent.working_dir = defaults.workingDir;
4130
- console.log(
4131
- chalk2.dim(
4132
- ` Auto-configured working_dir: ${defaults.workingDir}`
4133
- )
4134
- );
4135
4127
  }
4136
4128
  }
4137
4129
  }
@@ -5074,7 +5066,7 @@ var ApiClient = class {
5074
5066
  const result = await client.getEvents({
5075
5067
  params: { id: runId },
5076
5068
  query: {
5077
- since: options?.since ?? 0,
5069
+ since: options?.since ?? -1,
5078
5070
  limit: options?.limit ?? 100
5079
5071
  }
5080
5072
  });
@@ -6022,7 +6014,7 @@ async function streamRealtimeEvents(runId, options) {
6022
6014
  });
6023
6015
  }
6024
6016
  async function pollEvents(runId, options) {
6025
- let nextSequence = 0;
6017
+ let nextSequence = -1;
6026
6018
  let complete = false;
6027
6019
  let result = { succeeded: true, runId };
6028
6020
  const pollIntervalMs = 1e3;
@@ -7512,7 +7504,34 @@ function detectPackageManager() {
7512
7504
  if (execPath.includes("pnpm")) {
7513
7505
  return "pnpm";
7514
7506
  }
7515
- return "npm";
7507
+ if (execPath.includes("/.bun/") || execPath.includes("/bun/")) {
7508
+ return "bun";
7509
+ }
7510
+ if (execPath.includes("/.yarn/") || execPath.includes("/yarn/")) {
7511
+ return "yarn";
7512
+ }
7513
+ if (execPath.includes("/usr/local/") || execPath.includes("/.nvm/") || execPath.includes("/.fnm/") || execPath.includes("/.volta/") || execPath.includes("/.nodenv/") || execPath.includes("/.n/") || execPath.includes("/node_modules/") || execPath.includes("\\npm\\") || // Windows: AppData\Roaming\npm
7514
+ execPath.includes("\\nodejs\\")) {
7515
+ return "npm";
7516
+ }
7517
+ return "unknown";
7518
+ }
7519
+ function isAutoUpgradeSupported(pm) {
7520
+ return pm === "npm" || pm === "pnpm";
7521
+ }
7522
+ function getManualUpgradeCommand(pm) {
7523
+ switch (pm) {
7524
+ case "bun":
7525
+ return `bun add -g ${PACKAGE_NAME}@latest`;
7526
+ case "yarn":
7527
+ return `yarn global add ${PACKAGE_NAME}@latest`;
7528
+ case "pnpm":
7529
+ return `pnpm add -g ${PACKAGE_NAME}@latest`;
7530
+ case "npm":
7531
+ return `npm install -g ${PACKAGE_NAME}@latest`;
7532
+ case "unknown":
7533
+ return `npm install -g ${PACKAGE_NAME}@latest`;
7534
+ }
7516
7535
  }
7517
7536
  function escapeForShell(str) {
7518
7537
  return `"${str.replace(/"/g, '\\"')}"`;
@@ -7580,6 +7599,21 @@ async function checkAndUpgrade(currentVersion, prompt) {
7580
7599
  );
7581
7600
  console.log();
7582
7601
  const packageManager = detectPackageManager();
7602
+ if (!isAutoUpgradeSupported(packageManager)) {
7603
+ if (packageManager === "unknown") {
7604
+ console.log(
7605
+ chalk23.yellow("Could not detect your package manager for auto-upgrade.")
7606
+ );
7607
+ } else {
7608
+ console.log(
7609
+ chalk23.yellow(`Auto-upgrade is not supported for ${packageManager}.`)
7610
+ );
7611
+ }
7612
+ console.log(chalk23.yellow("Please upgrade manually:"));
7613
+ console.log(chalk23.cyan(` ${getManualUpgradeCommand(packageManager)}`));
7614
+ console.log();
7615
+ return false;
7616
+ }
7583
7617
  console.log(`Upgrading via ${packageManager}...`);
7584
7618
  const success = await performUpgrade(packageManager);
7585
7619
  if (success) {
@@ -7591,9 +7625,7 @@ async function checkAndUpgrade(currentVersion, prompt) {
7591
7625
  }
7592
7626
  console.log();
7593
7627
  console.log(chalk23.red("Upgrade failed. Please run manually:"));
7594
- console.log(chalk23.cyan(` npm install -g ${PACKAGE_NAME}@latest`));
7595
- console.log(chalk23.dim(" # or"));
7596
- console.log(chalk23.cyan(` pnpm add -g ${PACKAGE_NAME}@latest`));
7628
+ console.log(chalk23.cyan(` ${getManualUpgradeCommand(packageManager)}`));
7597
7629
  console.log();
7598
7630
  console.log("Then re-run:");
7599
7631
  console.log(chalk23.cyan(` ${buildRerunCommand(prompt)}`));
@@ -7828,7 +7860,7 @@ cookCmd.argument("[prompt]", "Prompt for the agent").option("-y, --yes", "Skip c
7828
7860
  // eslint-disable-next-line complexity -- TODO: refactor complex function
7829
7861
  async (prompt, options) => {
7830
7862
  if (!options.noAutoUpdate) {
7831
- const shouldExit = await checkAndUpgrade("6.3.0", prompt);
7863
+ const shouldExit = await checkAndUpgrade("6.3.1", prompt);
7832
7864
  if (shouldExit) {
7833
7865
  process.exit(0);
7834
7866
  }
@@ -9609,6 +9641,18 @@ function toISODateTime(dateTimeStr) {
9609
9641
  const date = new Date(isoStr);
9610
9642
  return date.toISOString();
9611
9643
  }
9644
+ async function resolveScheduleByName(name) {
9645
+ const { schedules } = await listSchedules();
9646
+ const schedule = schedules.find((s) => s.name === name);
9647
+ if (!schedule) {
9648
+ throw new Error(`Schedule "${name}" not found`);
9649
+ }
9650
+ return {
9651
+ name: schedule.name,
9652
+ composeId: schedule.composeId,
9653
+ composeName: schedule.composeName
9654
+ };
9655
+ }
9612
9656
 
9613
9657
  // src/commands/schedule/init.ts
9614
9658
  var SCHEDULE_FILE2 = "schedule.yaml";
@@ -10196,26 +10240,8 @@ var statusCommand4 = new Command32().name("status").description("Show detailed s
10196
10240
  }
10197
10241
  name = scheduleResult.scheduleName;
10198
10242
  }
10199
- const result = loadAgentName();
10200
- if (result.error) {
10201
- console.error(chalk35.red(`\u2717 Invalid vm0.yaml: ${result.error}`));
10202
- process.exit(1);
10203
- }
10204
- if (!result.agentName) {
10205
- console.error(chalk35.red("\u2717 No vm0.yaml found in current directory"));
10206
- console.error(chalk35.dim(" Run this command from the agent directory"));
10207
- process.exit(1);
10208
- }
10209
- const agentName = result.agentName;
10210
- let composeId;
10211
- try {
10212
- const compose = await getComposeByName(agentName);
10213
- composeId = compose.id;
10214
- } catch {
10215
- console.error(chalk35.red(`\u2717 Agent not found: ${agentName}`));
10216
- console.error(chalk35.dim(" Make sure the agent is pushed first"));
10217
- process.exit(1);
10218
- }
10243
+ const resolved = await resolveScheduleByName(name);
10244
+ const composeId = resolved.composeId;
10219
10245
  const schedule = await getScheduleByName({ name, composeId });
10220
10246
  console.log();
10221
10247
  console.log(`Schedule: ${chalk35.cyan(schedule.name)}`);
@@ -10295,6 +10321,7 @@ var statusCommand4 = new Command32().name("status").description("Show detailed s
10295
10321
  console.error(
10296
10322
  chalk35.dim(` Schedule "${nameArg ?? "unknown"}" not found`)
10297
10323
  );
10324
+ console.error(chalk35.dim(" Run: vm0 schedule list"));
10298
10325
  } else {
10299
10326
  console.error(chalk35.dim(` ${error.message}`));
10300
10327
  }
@@ -10342,26 +10369,7 @@ var deleteCommand = new Command33().name("delete").alias("rm").description("Dele
10342
10369
  }
10343
10370
  name = scheduleResult.scheduleName;
10344
10371
  }
10345
- const result = loadAgentName();
10346
- if (result.error) {
10347
- console.error(chalk36.red(`\u2717 Invalid vm0.yaml: ${result.error}`));
10348
- process.exit(1);
10349
- }
10350
- if (!result.agentName) {
10351
- console.error(chalk36.red("\u2717 No vm0.yaml found in current directory"));
10352
- console.error(chalk36.dim(" Run this command from the agent directory"));
10353
- process.exit(1);
10354
- }
10355
- const agentName = result.agentName;
10356
- let composeId;
10357
- try {
10358
- const compose = await getComposeByName(agentName);
10359
- composeId = compose.id;
10360
- } catch {
10361
- console.error(chalk36.red(`\u2717 Agent not found: ${agentName}`));
10362
- console.error(chalk36.dim(" Make sure the agent is pushed first"));
10363
- process.exit(1);
10364
- }
10372
+ const resolved = await resolveScheduleByName(name);
10365
10373
  if (!options.force) {
10366
10374
  const confirmed = await confirm(`Delete schedule ${chalk36.cyan(name)}?`);
10367
10375
  if (!confirmed) {
@@ -10369,7 +10377,7 @@ var deleteCommand = new Command33().name("delete").alias("rm").description("Dele
10369
10377
  return;
10370
10378
  }
10371
10379
  }
10372
- await deleteSchedule({ name, composeId });
10380
+ await deleteSchedule({ name, composeId: resolved.composeId });
10373
10381
  console.log(chalk36.green(`\u2713 Deleted schedule ${chalk36.cyan(name)}`));
10374
10382
  } catch (error) {
10375
10383
  console.error(chalk36.red("\u2717 Failed to delete schedule"));
@@ -10378,6 +10386,7 @@ var deleteCommand = new Command33().name("delete").alias("rm").description("Dele
10378
10386
  console.error(chalk36.dim(" Run: vm0 auth login"));
10379
10387
  } else if (error.message.toLowerCase().includes("not found")) {
10380
10388
  console.error(chalk36.dim(` Schedule "${name}" not found`));
10389
+ console.error(chalk36.dim(" Run: vm0 schedule list"));
10381
10390
  } else {
10382
10391
  console.error(chalk36.dim(` ${error.message}`));
10383
10392
  }
@@ -10412,33 +10421,17 @@ var enableCommand = new Command34().name("enable").description("Enable a schedul
10412
10421
  }
10413
10422
  name = scheduleResult.scheduleName;
10414
10423
  }
10415
- const result = loadAgentName();
10416
- if (result.error) {
10417
- console.error(chalk37.red(`\u2717 Invalid vm0.yaml: ${result.error}`));
10418
- process.exit(1);
10419
- }
10420
- if (!result.agentName) {
10421
- console.error(chalk37.red("\u2717 No vm0.yaml found in current directory"));
10422
- console.error(chalk37.dim(" Run this command from the agent directory"));
10423
- process.exit(1);
10424
- }
10425
- const agentName = result.agentName;
10426
- let composeId;
10427
- try {
10428
- const compose = await getComposeByName(agentName);
10429
- composeId = compose.id;
10430
- } catch {
10431
- console.error(chalk37.red(`\u2717 Agent not found: ${agentName}`));
10432
- console.error(chalk37.dim(" Make sure the agent is pushed first"));
10433
- process.exit(1);
10434
- }
10435
- await enableSchedule({ name, composeId });
10424
+ const resolved = await resolveScheduleByName(name);
10425
+ await enableSchedule({ name, composeId: resolved.composeId });
10436
10426
  console.log(chalk37.green(`\u2713 Enabled schedule ${chalk37.cyan(name)}`));
10437
10427
  } catch (error) {
10438
10428
  console.error(chalk37.red("\u2717 Failed to enable schedule"));
10439
10429
  if (error instanceof Error) {
10440
10430
  if (error.message.includes("Not authenticated")) {
10441
10431
  console.error(chalk37.dim(" Run: vm0 auth login"));
10432
+ } else if (error.message.toLowerCase().includes("not found")) {
10433
+ console.error(chalk37.dim(` Schedule "${nameArg}" not found`));
10434
+ console.error(chalk37.dim(" Run: vm0 schedule list"));
10442
10435
  } else {
10443
10436
  console.error(chalk37.dim(` ${error.message}`));
10444
10437
  }
@@ -10473,33 +10466,17 @@ var disableCommand = new Command35().name("disable").description("Disable a sche
10473
10466
  }
10474
10467
  name = scheduleResult.scheduleName;
10475
10468
  }
10476
- const result = loadAgentName();
10477
- if (result.error) {
10478
- console.error(chalk38.red(`\u2717 Invalid vm0.yaml: ${result.error}`));
10479
- process.exit(1);
10480
- }
10481
- if (!result.agentName) {
10482
- console.error(chalk38.red("\u2717 No vm0.yaml found in current directory"));
10483
- console.error(chalk38.dim(" Run this command from the agent directory"));
10484
- process.exit(1);
10485
- }
10486
- const agentName = result.agentName;
10487
- let composeId;
10488
- try {
10489
- const compose = await getComposeByName(agentName);
10490
- composeId = compose.id;
10491
- } catch {
10492
- console.error(chalk38.red(`\u2717 Agent not found: ${agentName}`));
10493
- console.error(chalk38.dim(" Make sure the agent is pushed first"));
10494
- process.exit(1);
10495
- }
10496
- await disableSchedule({ name, composeId });
10469
+ const resolved = await resolveScheduleByName(name);
10470
+ await disableSchedule({ name, composeId: resolved.composeId });
10497
10471
  console.log(chalk38.green(`\u2713 Disabled schedule ${chalk38.cyan(name)}`));
10498
10472
  } catch (error) {
10499
10473
  console.error(chalk38.red("\u2717 Failed to disable schedule"));
10500
10474
  if (error instanceof Error) {
10501
10475
  if (error.message.includes("Not authenticated")) {
10502
10476
  console.error(chalk38.dim(" Run: vm0 auth login"));
10477
+ } else if (error.message.toLowerCase().includes("not found")) {
10478
+ console.error(chalk38.dim(` Schedule "${nameArg}" not found`));
10479
+ console.error(chalk38.dim(" Run: vm0 schedule list"));
10503
10480
  } else {
10504
10481
  console.error(chalk38.dim(` ${error.message}`));
10505
10482
  }
@@ -11086,7 +11063,7 @@ var modelProviderCommand = new Command46().name("model-provider").description("M
11086
11063
 
11087
11064
  // src/index.ts
11088
11065
  var program = new Command47();
11089
- program.name("vm0").description("VM0 CLI - Build and run agents with natural language").version("6.3.0");
11066
+ program.name("vm0").description("VM0 CLI - Build and run agents with natural language").version("6.3.1");
11090
11067
  program.command("info").description("Display environment information").action(async () => {
11091
11068
  console.log(chalk47.bold("System Information:"));
11092
11069
  console.log(`Node Version: ${process.version}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vm0/cli",
3
- "version": "6.3.0",
3
+ "version": "6.3.1",
4
4
  "description": "CLI application",
5
5
  "repository": {
6
6
  "type": "git",