@vm0/cli 6.2.1 → 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 +87 -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
  }
@@ -4670,6 +4662,7 @@ var CodexEventParser = class {
4670
4662
  }
4671
4663
  };
4672
4664
  }
4665
+ // eslint-disable-next-line complexity -- TODO: refactor complex function
4673
4666
  static parseItemEvent(event) {
4674
4667
  const item = event.item;
4675
4668
  if (!item) {
@@ -4876,6 +4869,7 @@ var CodexEventRenderer = class {
4876
4869
  chalk4.red("[turn.failed]") + (event.error ? ` ${event.error}` : "")
4877
4870
  );
4878
4871
  }
4872
+ // eslint-disable-next-line complexity -- TODO: refactor complex function
4879
4873
  static renderItem(event) {
4880
4874
  const item = event.item;
4881
4875
  if (!item) return;
@@ -5072,7 +5066,7 @@ var ApiClient = class {
5072
5066
  const result = await client.getEvents({
5073
5067
  params: { id: runId },
5074
5068
  query: {
5075
- since: options?.since ?? 0,
5069
+ since: options?.since ?? -1,
5076
5070
  limit: options?.limit ?? 100
5077
5071
  }
5078
5072
  });
@@ -6020,7 +6014,7 @@ async function streamRealtimeEvents(runId, options) {
6020
6014
  });
6021
6015
  }
6022
6016
  async function pollEvents(runId, options) {
6023
- let nextSequence = 0;
6017
+ let nextSequence = -1;
6024
6018
  let complete = false;
6025
6019
  let result = { succeeded: true, runId };
6026
6020
  const pollIntervalMs = 1e3;
@@ -6145,6 +6139,7 @@ var mainRunCommand = new Command2().name("run").description("Execute an agent").
6145
6139
  "--model-provider <type>",
6146
6140
  "Override model provider for LLM credentials (e.g., anthropic-api-key)"
6147
6141
  ).addOption(new Option("--debug-no-mock-claude").hideHelp()).action(
6142
+ // eslint-disable-next-line complexity -- TODO: refactor complex function
6148
6143
  async (identifier, prompt, options) => {
6149
6144
  const startTimestamp = /* @__PURE__ */ new Date();
6150
6145
  const verbose = options.verbose;
@@ -6329,6 +6324,7 @@ var resumeCommand = new Command3().name("resume").description("Resume an agent r
6329
6324
  "--model-provider <type>",
6330
6325
  "Override model provider for LLM credentials (e.g., anthropic-api-key)"
6331
6326
  ).addOption(new Option2("--debug-no-mock-claude").hideHelp()).action(
6327
+ // eslint-disable-next-line complexity -- TODO: refactor complex function
6332
6328
  async (checkpointId, prompt, options, command) => {
6333
6329
  const startTimestamp = /* @__PURE__ */ new Date();
6334
6330
  const allOpts = command.optsWithGlobals();
@@ -6449,6 +6445,7 @@ var continueCommand = new Command4().name("continue").description(
6449
6445
  "--model-provider <type>",
6450
6446
  "Override model provider for LLM credentials (e.g., anthropic-api-key)"
6451
6447
  ).addOption(new Option3("--debug-no-mock-claude").hideHelp()).action(
6448
+ // eslint-disable-next-line complexity -- TODO: refactor complex function
6452
6449
  async (agentSessionId, prompt, options, command) => {
6453
6450
  const startTimestamp = /* @__PURE__ */ new Date();
6454
6451
  const allOpts = command.optsWithGlobals();
@@ -7507,7 +7504,34 @@ function detectPackageManager() {
7507
7504
  if (execPath.includes("pnpm")) {
7508
7505
  return "pnpm";
7509
7506
  }
7510
- 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
+ }
7511
7535
  }
7512
7536
  function escapeForShell(str) {
7513
7537
  return `"${str.replace(/"/g, '\\"')}"`;
@@ -7575,6 +7599,21 @@ async function checkAndUpgrade(currentVersion, prompt) {
7575
7599
  );
7576
7600
  console.log();
7577
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
+ }
7578
7617
  console.log(`Upgrading via ${packageManager}...`);
7579
7618
  const success = await performUpgrade(packageManager);
7580
7619
  if (success) {
@@ -7586,9 +7625,7 @@ async function checkAndUpgrade(currentVersion, prompt) {
7586
7625
  }
7587
7626
  console.log();
7588
7627
  console.log(chalk23.red("Upgrade failed. Please run manually:"));
7589
- console.log(chalk23.cyan(` npm install -g ${PACKAGE_NAME}@latest`));
7590
- console.log(chalk23.dim(" # or"));
7591
- console.log(chalk23.cyan(` pnpm add -g ${PACKAGE_NAME}@latest`));
7628
+ console.log(chalk23.cyan(` ${getManualUpgradeCommand(packageManager)}`));
7592
7629
  console.log();
7593
7630
  console.log("Then re-run:");
7594
7631
  console.log(chalk23.cyan(` ${buildRerunCommand(prompt)}`));
@@ -7820,9 +7857,10 @@ async function autoPullArtifact(runOutput, artifactDir) {
7820
7857
  }
7821
7858
  var cookCmd = new Command19().name("cook").description("One-click agent preparation and execution from vm0.yaml");
7822
7859
  cookCmd.argument("[prompt]", "Prompt for the agent").option("-y, --yes", "Skip confirmation prompts").addOption(new Option4("--debug-no-mock-claude").hideHelp()).addOption(new Option4("--no-auto-update").hideHelp()).action(
7860
+ // eslint-disable-next-line complexity -- TODO: refactor complex function
7823
7861
  async (prompt, options) => {
7824
7862
  if (!options.noAutoUpdate) {
7825
- const shouldExit = await checkAndUpgrade("6.2.1", prompt);
7863
+ const shouldExit = await checkAndUpgrade("6.3.1", prompt);
7826
7864
  if (shouldExit) {
7827
7865
  process.exit(0);
7828
7866
  }
@@ -9254,6 +9292,7 @@ function showWorkflowsCreatedMessage() {
9254
9292
  console.log("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518");
9255
9293
  }
9256
9294
  var setupGithubCommand = new Command28().name("setup-github").description("Initialize GitHub Actions workflows for agent deployment").option("-f, --force", "Overwrite existing workflow files").option("-y, --yes", "Auto-confirm all prompts").option("--skip-secrets", "Skip automatic secrets/variables setup").action(
9295
+ // eslint-disable-next-line complexity -- TODO: refactor complex function
9257
9296
  async (options) => {
9258
9297
  const prereqs = await checkPrerequisites();
9259
9298
  if (!prereqs) {
@@ -9602,6 +9641,18 @@ function toISODateTime(dateTimeStr) {
9602
9641
  const date = new Date(isoStr);
9603
9642
  return date.toISOString();
9604
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
+ }
9605
9656
 
9606
9657
  // src/commands/schedule/init.ts
9607
9658
  var SCHEDULE_FILE2 = "schedule.yaml";
@@ -9653,6 +9704,7 @@ function parseDayOption(day, frequency) {
9653
9704
  return void 0;
9654
9705
  }
9655
9706
  var initCommand4 = new Command29().name("init").description("Create a schedule.yaml interactively").option("-n, --name <name>", "Schedule name").option("-f, --frequency <type>", "Frequency: daily|weekly|monthly|once").option("-t, --time <HH:MM>", "Time to run (24-hour format)").option("-d, --day <day>", "Day of week (mon-sun) or day of month (1-31)").option("-z, --timezone <tz>", "IANA timezone").option("-p, --prompt <text>", "Prompt to run").option("--no-vars", "Don't include vars from vm0.yaml").option("--force", "Overwrite existing schedule.yaml").action(
9707
+ // eslint-disable-next-line complexity -- TODO: refactor complex function
9656
9708
  async (options) => {
9657
9709
  try {
9658
9710
  const { agentName, error } = loadAgentName();
@@ -10188,26 +10240,8 @@ var statusCommand4 = new Command32().name("status").description("Show detailed s
10188
10240
  }
10189
10241
  name = scheduleResult.scheduleName;
10190
10242
  }
10191
- const result = loadAgentName();
10192
- if (result.error) {
10193
- console.error(chalk35.red(`\u2717 Invalid vm0.yaml: ${result.error}`));
10194
- process.exit(1);
10195
- }
10196
- if (!result.agentName) {
10197
- console.error(chalk35.red("\u2717 No vm0.yaml found in current directory"));
10198
- console.error(chalk35.dim(" Run this command from the agent directory"));
10199
- process.exit(1);
10200
- }
10201
- const agentName = result.agentName;
10202
- let composeId;
10203
- try {
10204
- const compose = await getComposeByName(agentName);
10205
- composeId = compose.id;
10206
- } catch {
10207
- console.error(chalk35.red(`\u2717 Agent not found: ${agentName}`));
10208
- console.error(chalk35.dim(" Make sure the agent is pushed first"));
10209
- process.exit(1);
10210
- }
10243
+ const resolved = await resolveScheduleByName(name);
10244
+ const composeId = resolved.composeId;
10211
10245
  const schedule = await getScheduleByName({ name, composeId });
10212
10246
  console.log();
10213
10247
  console.log(`Schedule: ${chalk35.cyan(schedule.name)}`);
@@ -10287,6 +10321,7 @@ var statusCommand4 = new Command32().name("status").description("Show detailed s
10287
10321
  console.error(
10288
10322
  chalk35.dim(` Schedule "${nameArg ?? "unknown"}" not found`)
10289
10323
  );
10324
+ console.error(chalk35.dim(" Run: vm0 schedule list"));
10290
10325
  } else {
10291
10326
  console.error(chalk35.dim(` ${error.message}`));
10292
10327
  }
@@ -10334,26 +10369,7 @@ var deleteCommand = new Command33().name("delete").alias("rm").description("Dele
10334
10369
  }
10335
10370
  name = scheduleResult.scheduleName;
10336
10371
  }
10337
- const result = loadAgentName();
10338
- if (result.error) {
10339
- console.error(chalk36.red(`\u2717 Invalid vm0.yaml: ${result.error}`));
10340
- process.exit(1);
10341
- }
10342
- if (!result.agentName) {
10343
- console.error(chalk36.red("\u2717 No vm0.yaml found in current directory"));
10344
- console.error(chalk36.dim(" Run this command from the agent directory"));
10345
- process.exit(1);
10346
- }
10347
- const agentName = result.agentName;
10348
- let composeId;
10349
- try {
10350
- const compose = await getComposeByName(agentName);
10351
- composeId = compose.id;
10352
- } catch {
10353
- console.error(chalk36.red(`\u2717 Agent not found: ${agentName}`));
10354
- console.error(chalk36.dim(" Make sure the agent is pushed first"));
10355
- process.exit(1);
10356
- }
10372
+ const resolved = await resolveScheduleByName(name);
10357
10373
  if (!options.force) {
10358
10374
  const confirmed = await confirm(`Delete schedule ${chalk36.cyan(name)}?`);
10359
10375
  if (!confirmed) {
@@ -10361,7 +10377,7 @@ var deleteCommand = new Command33().name("delete").alias("rm").description("Dele
10361
10377
  return;
10362
10378
  }
10363
10379
  }
10364
- await deleteSchedule({ name, composeId });
10380
+ await deleteSchedule({ name, composeId: resolved.composeId });
10365
10381
  console.log(chalk36.green(`\u2713 Deleted schedule ${chalk36.cyan(name)}`));
10366
10382
  } catch (error) {
10367
10383
  console.error(chalk36.red("\u2717 Failed to delete schedule"));
@@ -10370,6 +10386,7 @@ var deleteCommand = new Command33().name("delete").alias("rm").description("Dele
10370
10386
  console.error(chalk36.dim(" Run: vm0 auth login"));
10371
10387
  } else if (error.message.toLowerCase().includes("not found")) {
10372
10388
  console.error(chalk36.dim(` Schedule "${name}" not found`));
10389
+ console.error(chalk36.dim(" Run: vm0 schedule list"));
10373
10390
  } else {
10374
10391
  console.error(chalk36.dim(` ${error.message}`));
10375
10392
  }
@@ -10404,33 +10421,17 @@ var enableCommand = new Command34().name("enable").description("Enable a schedul
10404
10421
  }
10405
10422
  name = scheduleResult.scheduleName;
10406
10423
  }
10407
- const result = loadAgentName();
10408
- if (result.error) {
10409
- console.error(chalk37.red(`\u2717 Invalid vm0.yaml: ${result.error}`));
10410
- process.exit(1);
10411
- }
10412
- if (!result.agentName) {
10413
- console.error(chalk37.red("\u2717 No vm0.yaml found in current directory"));
10414
- console.error(chalk37.dim(" Run this command from the agent directory"));
10415
- process.exit(1);
10416
- }
10417
- const agentName = result.agentName;
10418
- let composeId;
10419
- try {
10420
- const compose = await getComposeByName(agentName);
10421
- composeId = compose.id;
10422
- } catch {
10423
- console.error(chalk37.red(`\u2717 Agent not found: ${agentName}`));
10424
- console.error(chalk37.dim(" Make sure the agent is pushed first"));
10425
- process.exit(1);
10426
- }
10427
- await enableSchedule({ name, composeId });
10424
+ const resolved = await resolveScheduleByName(name);
10425
+ await enableSchedule({ name, composeId: resolved.composeId });
10428
10426
  console.log(chalk37.green(`\u2713 Enabled schedule ${chalk37.cyan(name)}`));
10429
10427
  } catch (error) {
10430
10428
  console.error(chalk37.red("\u2717 Failed to enable schedule"));
10431
10429
  if (error instanceof Error) {
10432
10430
  if (error.message.includes("Not authenticated")) {
10433
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"));
10434
10435
  } else {
10435
10436
  console.error(chalk37.dim(` ${error.message}`));
10436
10437
  }
@@ -10465,33 +10466,17 @@ var disableCommand = new Command35().name("disable").description("Disable a sche
10465
10466
  }
10466
10467
  name = scheduleResult.scheduleName;
10467
10468
  }
10468
- const result = loadAgentName();
10469
- if (result.error) {
10470
- console.error(chalk38.red(`\u2717 Invalid vm0.yaml: ${result.error}`));
10471
- process.exit(1);
10472
- }
10473
- if (!result.agentName) {
10474
- console.error(chalk38.red("\u2717 No vm0.yaml found in current directory"));
10475
- console.error(chalk38.dim(" Run this command from the agent directory"));
10476
- process.exit(1);
10477
- }
10478
- const agentName = result.agentName;
10479
- let composeId;
10480
- try {
10481
- const compose = await getComposeByName(agentName);
10482
- composeId = compose.id;
10483
- } catch {
10484
- console.error(chalk38.red(`\u2717 Agent not found: ${agentName}`));
10485
- console.error(chalk38.dim(" Make sure the agent is pushed first"));
10486
- process.exit(1);
10487
- }
10488
- await disableSchedule({ name, composeId });
10469
+ const resolved = await resolveScheduleByName(name);
10470
+ await disableSchedule({ name, composeId: resolved.composeId });
10489
10471
  console.log(chalk38.green(`\u2713 Disabled schedule ${chalk38.cyan(name)}`));
10490
10472
  } catch (error) {
10491
10473
  console.error(chalk38.red("\u2717 Failed to disable schedule"));
10492
10474
  if (error instanceof Error) {
10493
10475
  if (error.message.includes("Not authenticated")) {
10494
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"));
10495
10480
  } else {
10496
10481
  console.error(chalk38.dim(` ${error.message}`));
10497
10482
  }
@@ -11078,7 +11063,7 @@ var modelProviderCommand = new Command46().name("model-provider").description("M
11078
11063
 
11079
11064
  // src/index.ts
11080
11065
  var program = new Command47();
11081
- program.name("vm0").description("VM0 CLI - Build and run agents with natural language").version("6.2.1");
11066
+ program.name("vm0").description("VM0 CLI - Build and run agents with natural language").version("6.3.1");
11082
11067
  program.command("info").description("Display environment information").action(async () => {
11083
11068
  console.log(chalk47.bold("System Information:"));
11084
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.2.1",
3
+ "version": "6.3.1",
4
4
  "description": "CLI application",
5
5
  "repository": {
6
6
  "type": "git",