@vm0/cli 3.0.0 → 3.1.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 +134 -87
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -12869,39 +12869,67 @@ var ClaudeEventParser = class {
12869
12869
  // src/lib/event-renderer.ts
12870
12870
  import chalk3 from "chalk";
12871
12871
  var EventRenderer = class {
12872
+ /**
12873
+ * Format elapsed time between two timestamps
12874
+ * Returns [+Nms] for < 1000ms, [+N.Ns] for >= 1000ms
12875
+ */
12876
+ static formatElapsed(previous, current) {
12877
+ const elapsedMs = current.getTime() - previous.getTime();
12878
+ if (elapsedMs < 1e3) {
12879
+ return `[+${elapsedMs}ms]`;
12880
+ }
12881
+ return `[+${(elapsedMs / 1e3).toFixed(1)}s]`;
12882
+ }
12883
+ /**
12884
+ * Format total elapsed time
12885
+ * Returns N.Ns format
12886
+ */
12887
+ static formatTotalTime(start, end) {
12888
+ const elapsedMs = end.getTime() - start.getTime();
12889
+ return `${(elapsedMs / 1e3).toFixed(1)}s`;
12890
+ }
12872
12891
  /**
12873
12892
  * Render a parsed event to console
12874
12893
  */
12875
- static render(event) {
12894
+ static render(event, options) {
12895
+ const elapsedPrefix = options?.verbose && options?.previousTimestamp ? chalk3.gray(
12896
+ this.formatElapsed(options.previousTimestamp, event.timestamp)
12897
+ ) : "";
12876
12898
  switch (event.type) {
12877
12899
  case "init":
12878
- this.renderInit(event);
12900
+ this.renderInit(event, elapsedPrefix);
12879
12901
  break;
12880
12902
  case "text":
12881
- this.renderText(event);
12903
+ this.renderText(event, elapsedPrefix);
12882
12904
  break;
12883
12905
  case "tool_use":
12884
- this.renderToolUse(event);
12906
+ this.renderToolUse(event, elapsedPrefix);
12885
12907
  break;
12886
12908
  case "tool_result":
12887
- this.renderToolResult(event);
12909
+ this.renderToolResult(event, elapsedPrefix);
12888
12910
  break;
12889
12911
  case "result":
12890
- this.renderResult(event);
12912
+ this.renderResult(event, elapsedPrefix);
12891
12913
  break;
12892
12914
  case "vm0_start":
12893
- this.renderVm0Start(event);
12915
+ this.renderVm0Start(event, elapsedPrefix);
12894
12916
  break;
12895
12917
  case "vm0_result":
12896
- this.renderVm0Result(event);
12918
+ this.renderVm0Result(
12919
+ event,
12920
+ elapsedPrefix,
12921
+ options?.verbose ? options?.startTimestamp : void 0
12922
+ );
12897
12923
  break;
12898
12924
  case "vm0_error":
12899
- this.renderVm0Error(event);
12925
+ this.renderVm0Error(event, elapsedPrefix);
12900
12926
  break;
12901
12927
  }
12902
12928
  }
12903
- static renderInit(event) {
12904
- console.log(chalk3.cyan("[init]") + " Starting Claude Code agent");
12929
+ static renderInit(event, elapsedPrefix) {
12930
+ console.log(
12931
+ chalk3.cyan("[init]") + elapsedPrefix + " Starting Claude Code agent"
12932
+ );
12905
12933
  console.log(` Session: ${chalk3.gray(String(event.data.sessionId || ""))}`);
12906
12934
  console.log(` Model: ${chalk3.gray(String(event.data.model || ""))}`);
12907
12935
  console.log(
@@ -12910,13 +12938,13 @@ var EventRenderer = class {
12910
12938
  )}`
12911
12939
  );
12912
12940
  }
12913
- static renderText(event) {
12941
+ static renderText(event, elapsedPrefix) {
12914
12942
  const text = String(event.data.text || "");
12915
- console.log(chalk3.blue("[text]") + " " + text);
12943
+ console.log(chalk3.blue("[text]") + elapsedPrefix + " " + text);
12916
12944
  }
12917
- static renderToolUse(event) {
12945
+ static renderToolUse(event, elapsedPrefix) {
12918
12946
  const tool = String(event.data.tool || "");
12919
- console.log(chalk3.yellow("[tool_use]") + " " + tool);
12947
+ console.log(chalk3.yellow("[tool_use]") + elapsedPrefix + " " + tool);
12920
12948
  const input = event.data.input;
12921
12949
  if (input && typeof input === "object") {
12922
12950
  for (const [key, value] of Object.entries(input)) {
@@ -12926,19 +12954,19 @@ var EventRenderer = class {
12926
12954
  }
12927
12955
  }
12928
12956
  }
12929
- static renderToolResult(event) {
12957
+ static renderToolResult(event, elapsedPrefix) {
12930
12958
  const isError = Boolean(event.data.isError);
12931
12959
  const status = isError ? "Error" : "Completed";
12932
12960
  const color = isError ? chalk3.red : chalk3.green;
12933
- console.log(color("[tool_result]") + " " + status);
12961
+ console.log(color("[tool_result]") + elapsedPrefix + " " + status);
12934
12962
  const result = String(event.data.result || "");
12935
12963
  console.log(` ${chalk3.gray(result)}`);
12936
12964
  }
12937
- static renderResult(event) {
12965
+ static renderResult(event, elapsedPrefix) {
12938
12966
  const success2 = Boolean(event.data.success);
12939
12967
  const status = success2 ? "\u2713 completed successfully" : "\u2717 failed";
12940
12968
  const color = success2 ? chalk3.green : chalk3.red;
12941
- console.log(color("[result]") + " " + status);
12969
+ console.log(color("[result]") + elapsedPrefix + " " + status);
12942
12970
  const durationMs = Number(event.data.durationMs || 0);
12943
12971
  const durationSec = (durationMs / 1e3).toFixed(1);
12944
12972
  console.log(` Duration: ${chalk3.gray(durationSec + "s")}`);
@@ -12963,8 +12991,8 @@ var EventRenderer = class {
12963
12991
  );
12964
12992
  }
12965
12993
  }
12966
- static renderVm0Start(event) {
12967
- console.log(chalk3.cyan("[vm0_start]") + " Run starting");
12994
+ static renderVm0Start(event, elapsedPrefix) {
12995
+ console.log(chalk3.cyan("[vm0_start]") + elapsedPrefix + " Run starting");
12968
12996
  if (event.data.runId) {
12969
12997
  console.log(` Run ID: ${chalk3.gray(String(event.data.runId))}`);
12970
12998
  }
@@ -12975,8 +13003,10 @@ var EventRenderer = class {
12975
13003
  }
12976
13004
  this.renderArtifactAndVolumes(event.data);
12977
13005
  }
12978
- static renderVm0Result(event) {
12979
- console.log(chalk3.green("[vm0_result]") + " \u2713 Run completed successfully");
13006
+ static renderVm0Result(event, elapsedPrefix, startTimestamp) {
13007
+ console.log(
13008
+ chalk3.green("[vm0_result]") + elapsedPrefix + " \u2713 Run completed successfully"
13009
+ );
12980
13010
  console.log(
12981
13011
  ` Checkpoint: ${chalk3.gray(String(event.data.checkpointId || ""))}`
12982
13012
  );
@@ -12987,6 +13017,10 @@ var EventRenderer = class {
12987
13017
  ` Conversation: ${chalk3.gray(String(event.data.conversationId || ""))}`
12988
13018
  );
12989
13019
  this.renderArtifactAndVolumes(event.data);
13020
+ if (startTimestamp) {
13021
+ const totalTime = this.formatTotalTime(startTimestamp, event.timestamp);
13022
+ console.log(` Total time: ${chalk3.gray(totalTime)}`);
13023
+ }
12990
13024
  }
12991
13025
  /**
12992
13026
  * Format version ID for display (show short 8-character prefix)
@@ -13017,8 +13051,8 @@ var EventRenderer = class {
13017
13051
  }
13018
13052
  }
13019
13053
  }
13020
- static renderVm0Error(event) {
13021
- console.log(chalk3.red("[vm0_error]") + " \u2717 Run failed");
13054
+ static renderVm0Error(event, elapsedPrefix) {
13055
+ console.log(chalk3.red("[vm0_error]") + elapsedPrefix + " \u2717 Run failed");
13022
13056
  let errorMessage = "";
13023
13057
  if (typeof event.data.error === "string") {
13024
13058
  errorMessage = event.data.error;
@@ -13060,12 +13094,15 @@ function isUUID(str) {
13060
13094
  return /^[0-9a-f-]{36}$/i.test(str);
13061
13095
  }
13062
13096
  var DEFAULT_TIMEOUT_SECONDS = 120;
13063
- async function pollEvents(runId, timeoutSeconds) {
13097
+ async function pollEvents(runId, timeoutSeconds, options) {
13064
13098
  let nextSequence = -1;
13065
13099
  let complete = false;
13066
13100
  const pollIntervalMs = 500;
13067
13101
  const timeoutMs = timeoutSeconds * 1e3;
13068
13102
  const startTime = Date.now();
13103
+ const startTimestamp = /* @__PURE__ */ new Date();
13104
+ let previousTimestamp = startTimestamp;
13105
+ const verbose = options?.verbose;
13069
13106
  while (!complete) {
13070
13107
  const elapsed = Date.now() - startTime;
13071
13108
  if (elapsed > timeoutMs) {
@@ -13085,7 +13122,12 @@ async function pollEvents(runId, timeoutSeconds) {
13085
13122
  event.eventData
13086
13123
  );
13087
13124
  if (parsed) {
13088
- EventRenderer.render(parsed);
13125
+ EventRenderer.render(parsed, {
13126
+ verbose,
13127
+ previousTimestamp,
13128
+ startTimestamp
13129
+ });
13130
+ previousTimestamp = parsed.timestamp;
13089
13131
  if (parsed.type === "vm0_result" || parsed.type === "vm0_error") {
13090
13132
  complete = true;
13091
13133
  }
@@ -13097,6 +13139,18 @@ async function pollEvents(runId, timeoutSeconds) {
13097
13139
  }
13098
13140
  }
13099
13141
  }
13142
+ function logVerbosePreFlight(action, details) {
13143
+ console.log(chalk4.blue(`
13144
+ ${action}...`));
13145
+ for (const { label, value } of details) {
13146
+ if (value !== void 0) {
13147
+ console.log(chalk4.gray(` ${label}: ${value}`));
13148
+ }
13149
+ }
13150
+ console.log();
13151
+ console.log(chalk4.blue("Executing in sandbox..."));
13152
+ console.log();
13153
+ }
13100
13154
  var runCmd = new Command2().name("run").description("Execute an agent").argument(
13101
13155
  "<identifier>",
13102
13156
  "Agent name or config ID (e.g., 'my-agent' or 'cfg-abc-123')"
@@ -13120,7 +13174,7 @@ var runCmd = new Command2().name("run").description("Execute an agent").argument
13120
13174
  "-t, --timeout <seconds>",
13121
13175
  "Polling timeout in seconds (default: 120)",
13122
13176
  String(DEFAULT_TIMEOUT_SECONDS)
13123
- ).action(
13177
+ ).option("-v, --verbose", "Show verbose output with timing information").action(
13124
13178
  async (identifier, prompt, options) => {
13125
13179
  const timeoutSeconds = parseInt(options.timeout, 10);
13126
13180
  if (isNaN(timeoutSeconds) || timeoutSeconds <= 0) {
@@ -13138,17 +13192,24 @@ var runCmd = new Command2().name("run").description("Execute an agent").argument
13138
13192
  );
13139
13193
  process.exit(1);
13140
13194
  }
13195
+ const verbose = options.verbose;
13141
13196
  try {
13142
13197
  let configId;
13143
13198
  if (isUUID(identifier)) {
13144
13199
  configId = identifier;
13145
- console.log(chalk4.gray(` Using config ID: ${configId}`));
13200
+ if (verbose) {
13201
+ console.log(chalk4.gray(` Using config ID: ${configId}`));
13202
+ }
13146
13203
  } else {
13147
- console.log(chalk4.gray(` Resolving agent name: ${identifier}`));
13204
+ if (verbose) {
13205
+ console.log(chalk4.gray(` Resolving agent name: ${identifier}`));
13206
+ }
13148
13207
  try {
13149
13208
  const config2 = await apiClient.getConfigByName(identifier);
13150
13209
  configId = config2.id;
13151
- console.log(chalk4.gray(` Resolved to config ID: ${configId}`));
13210
+ if (verbose) {
13211
+ console.log(chalk4.gray(` Resolved to config ID: ${configId}`));
13212
+ }
13152
13213
  } catch (error43) {
13153
13214
  if (error43 instanceof Error) {
13154
13215
  console.error(chalk4.red(`\u2717 Agent not found: ${identifier}`));
@@ -13161,32 +13222,22 @@ var runCmd = new Command2().name("run").description("Execute an agent").argument
13161
13222
  process.exit(1);
13162
13223
  }
13163
13224
  }
13164
- console.log(chalk4.blue("\nCreating agent run..."));
13165
- console.log(chalk4.gray(` Prompt: ${prompt}`));
13166
- if (Object.keys(options.vars).length > 0) {
13167
- console.log(
13168
- chalk4.gray(` Variables: ${JSON.stringify(options.vars)}`)
13169
- );
13170
- }
13171
- console.log(chalk4.gray(` Artifact: ${options.artifactName}`));
13172
- if (options.artifactVersion) {
13173
- console.log(
13174
- chalk4.gray(` Artifact version: ${options.artifactVersion}`)
13175
- );
13176
- }
13177
- if (Object.keys(options.volumeVersion).length > 0) {
13178
- console.log(
13179
- chalk4.gray(
13180
- ` Volume versions: ${JSON.stringify(options.volumeVersion)}`
13181
- )
13182
- );
13183
- }
13184
- if (options.conversation) {
13185
- console.log(chalk4.gray(` Conversation: ${options.conversation}`));
13225
+ if (verbose) {
13226
+ logVerbosePreFlight("Creating agent run", [
13227
+ { label: "Prompt", value: prompt },
13228
+ {
13229
+ label: "Variables",
13230
+ value: Object.keys(options.vars).length > 0 ? JSON.stringify(options.vars) : void 0
13231
+ },
13232
+ { label: "Artifact", value: options.artifactName },
13233
+ { label: "Artifact version", value: options.artifactVersion },
13234
+ {
13235
+ label: "Volume versions",
13236
+ value: Object.keys(options.volumeVersion).length > 0 ? JSON.stringify(options.volumeVersion) : void 0
13237
+ },
13238
+ { label: "Conversation", value: options.conversation }
13239
+ ]);
13186
13240
  }
13187
- console.log();
13188
- console.log(chalk4.blue("Executing in sandbox..."));
13189
- console.log();
13190
13241
  const response = await apiClient.createRun({
13191
13242
  agentConfigId: configId,
13192
13243
  prompt,
@@ -13196,7 +13247,7 @@ var runCmd = new Command2().name("run").description("Execute an agent").argument
13196
13247
  volumeVersions: Object.keys(options.volumeVersion).length > 0 ? options.volumeVersion : void 0,
13197
13248
  conversationId: options.conversation
13198
13249
  });
13199
- await pollEvents(response.runId, timeoutSeconds);
13250
+ await pollEvents(response.runId, timeoutSeconds, { verbose });
13200
13251
  } catch (error43) {
13201
13252
  if (error43 instanceof Error) {
13202
13253
  if (error43.message.includes("Not authenticated")) {
@@ -13228,7 +13279,7 @@ runCmd.command("resume").description("Resume an agent run from a checkpoint (use
13228
13279
  "-t, --timeout <seconds>",
13229
13280
  "Polling timeout in seconds (default: 120)",
13230
13281
  String(DEFAULT_TIMEOUT_SECONDS)
13231
- ).action(
13282
+ ).option("-v, --verbose", "Show verbose output with timing information").action(
13232
13283
  async (checkpointId, prompt, options, command) => {
13233
13284
  const allOpts = command.optsWithGlobals();
13234
13285
  const timeoutSeconds = parseInt(options.timeout, 10);
@@ -13238,6 +13289,7 @@ runCmd.command("resume").description("Resume an agent run from a checkpoint (use
13238
13289
  );
13239
13290
  process.exit(1);
13240
13291
  }
13292
+ const verbose = options.verbose || allOpts.verbose;
13241
13293
  try {
13242
13294
  if (!isUUID(checkpointId)) {
13243
13295
  console.error(
@@ -13246,25 +13298,22 @@ runCmd.command("resume").description("Resume an agent run from a checkpoint (use
13246
13298
  console.error(chalk4.gray(" Checkpoint ID must be a valid UUID"));
13247
13299
  process.exit(1);
13248
13300
  }
13249
- console.log(chalk4.blue("\nResuming agent run from checkpoint..."));
13250
- console.log(chalk4.gray(` Checkpoint ID: ${checkpointId}`));
13251
- console.log(chalk4.gray(` Prompt: ${prompt}`));
13252
- if (Object.keys(allOpts.volumeVersion).length > 0) {
13253
- console.log(
13254
- chalk4.gray(
13255
- ` Volume overrides: ${JSON.stringify(allOpts.volumeVersion)}`
13256
- )
13257
- );
13301
+ if (verbose) {
13302
+ logVerbosePreFlight("Resuming agent run from checkpoint", [
13303
+ { label: "Checkpoint ID", value: checkpointId },
13304
+ { label: "Prompt", value: prompt },
13305
+ {
13306
+ label: "Volume overrides",
13307
+ value: Object.keys(allOpts.volumeVersion).length > 0 ? JSON.stringify(allOpts.volumeVersion) : void 0
13308
+ }
13309
+ ]);
13258
13310
  }
13259
- console.log();
13260
- console.log(chalk4.blue("Executing in sandbox..."));
13261
- console.log();
13262
13311
  const response = await apiClient.createRun({
13263
13312
  checkpointId,
13264
13313
  prompt,
13265
13314
  volumeVersions: Object.keys(allOpts.volumeVersion).length > 0 ? allOpts.volumeVersion : void 0
13266
13315
  });
13267
- await pollEvents(response.runId, timeoutSeconds);
13316
+ await pollEvents(response.runId, timeoutSeconds, { verbose });
13268
13317
  } catch (error43) {
13269
13318
  if (error43 instanceof Error) {
13270
13319
  if (error43.message.includes("Not authenticated")) {
@@ -13295,7 +13344,7 @@ runCmd.command("continue").description(
13295
13344
  "-t, --timeout <seconds>",
13296
13345
  "Polling timeout in seconds (default: 120)",
13297
13346
  String(DEFAULT_TIMEOUT_SECONDS)
13298
- ).action(
13347
+ ).option("-v, --verbose", "Show verbose output with timing information").action(
13299
13348
  async (agentSessionId, prompt, options, command) => {
13300
13349
  const allOpts = command.optsWithGlobals();
13301
13350
  const timeoutSeconds = parseInt(options.timeout, 10);
@@ -13305,6 +13354,7 @@ runCmd.command("continue").description(
13305
13354
  );
13306
13355
  process.exit(1);
13307
13356
  }
13357
+ const verbose = options.verbose || allOpts.verbose;
13308
13358
  try {
13309
13359
  if (!isUUID(agentSessionId)) {
13310
13360
  console.error(
@@ -13313,26 +13363,23 @@ runCmd.command("continue").description(
13313
13363
  console.error(chalk4.gray(" Agent session ID must be a valid UUID"));
13314
13364
  process.exit(1);
13315
13365
  }
13316
- console.log(chalk4.blue("\nContinuing agent run from session..."));
13317
- console.log(chalk4.gray(` Session ID: ${agentSessionId}`));
13318
- console.log(chalk4.gray(` Prompt: ${prompt}`));
13319
- console.log(chalk4.gray(` Note: Using latest artifact version`));
13320
- if (Object.keys(allOpts.volumeVersion).length > 0) {
13321
- console.log(
13322
- chalk4.gray(
13323
- ` Volume overrides: ${JSON.stringify(allOpts.volumeVersion)}`
13324
- )
13325
- );
13366
+ if (verbose) {
13367
+ logVerbosePreFlight("Continuing agent run from session", [
13368
+ { label: "Session ID", value: agentSessionId },
13369
+ { label: "Prompt", value: prompt },
13370
+ { label: "Note", value: "Using latest artifact version" },
13371
+ {
13372
+ label: "Volume overrides",
13373
+ value: Object.keys(allOpts.volumeVersion).length > 0 ? JSON.stringify(allOpts.volumeVersion) : void 0
13374
+ }
13375
+ ]);
13326
13376
  }
13327
- console.log();
13328
- console.log(chalk4.blue("Executing in sandbox..."));
13329
- console.log();
13330
13377
  const response = await apiClient.createRun({
13331
13378
  sessionId: agentSessionId,
13332
13379
  prompt,
13333
13380
  volumeVersions: Object.keys(allOpts.volumeVersion).length > 0 ? allOpts.volumeVersion : void 0
13334
13381
  });
13335
- await pollEvents(response.runId, timeoutSeconds);
13382
+ await pollEvents(response.runId, timeoutSeconds, { verbose });
13336
13383
  } catch (error43) {
13337
13384
  if (error43 instanceof Error) {
13338
13385
  if (error43.message.includes("Not authenticated")) {
@@ -14059,7 +14106,7 @@ var artifactCommand = new Command10().name("artifact").description("Manage cloud
14059
14106
 
14060
14107
  // src/index.ts
14061
14108
  var program = new Command11();
14062
- program.name("vm0").description("VM0 CLI - A modern build tool").version("3.0.0");
14109
+ program.name("vm0").description("VM0 CLI - A modern build tool").version("3.1.0");
14063
14110
  program.command("hello").description("Say hello from the App").action(() => {
14064
14111
  console.log(chalk11.blue("Welcome to the VM0 CLI!"));
14065
14112
  console.log(chalk11.green(`Core says: ${FOO}`));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vm0/cli",
3
- "version": "3.0.0",
3
+ "version": "3.1.0",
4
4
  "description": "CLI application",
5
5
  "repository": {
6
6
  "type": "git",