@vm0/cli 4.25.0 → 4.26.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 +89 -18
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -16520,22 +16520,62 @@ import { readFile as readFile5, writeFile as writeFile5, mkdir as mkdir5 } from
16520
16520
  import { existsSync as existsSync6 } from "fs";
16521
16521
  var CONFIG_DIR3 = join6(homedir2(), ".vm0");
16522
16522
  var COOK_STATE_FILE = join6(CONFIG_DIR3, "cook.json");
16523
- async function loadCookState() {
16523
+ var STALE_THRESHOLD_MS = 48 * 60 * 60 * 1e3;
16524
+ async function loadCookStateFile() {
16524
16525
  if (!existsSync6(COOK_STATE_FILE)) {
16525
- return {};
16526
+ return { ppid: {} };
16526
16527
  }
16527
16528
  try {
16528
16529
  const content = await readFile5(COOK_STATE_FILE, "utf8");
16529
- return JSON.parse(content);
16530
+ const data = JSON.parse(content);
16531
+ if (!data.ppid) {
16532
+ const oldState = data;
16533
+ return {
16534
+ ppid: {
16535
+ [String(process.ppid)]: {
16536
+ lastRunId: oldState.lastRunId,
16537
+ lastSessionId: oldState.lastSessionId,
16538
+ lastCheckpointId: oldState.lastCheckpointId,
16539
+ lastActiveAt: Date.now()
16540
+ }
16541
+ }
16542
+ };
16543
+ }
16544
+ return data;
16530
16545
  } catch {
16531
- return {};
16546
+ return { ppid: {} };
16532
16547
  }
16533
16548
  }
16549
+ async function loadCookState() {
16550
+ const file2 = await loadCookStateFile();
16551
+ const ppid = String(process.ppid);
16552
+ const entry = file2.ppid[ppid];
16553
+ if (!entry) return {};
16554
+ return {
16555
+ lastRunId: entry.lastRunId,
16556
+ lastSessionId: entry.lastSessionId,
16557
+ lastCheckpointId: entry.lastCheckpointId
16558
+ };
16559
+ }
16534
16560
  async function saveCookState(state) {
16535
16561
  await mkdir5(CONFIG_DIR3, { recursive: true });
16536
- const existing = await loadCookState();
16537
- const merged = { ...existing, ...state };
16538
- await writeFile5(COOK_STATE_FILE, JSON.stringify(merged, null, 2), "utf8");
16562
+ const file2 = await loadCookStateFile();
16563
+ const ppid = String(process.ppid);
16564
+ const now = Date.now();
16565
+ for (const key of Object.keys(file2.ppid)) {
16566
+ const entry = file2.ppid[key];
16567
+ if (entry && now - entry.lastActiveAt > STALE_THRESHOLD_MS) {
16568
+ delete file2.ppid[key];
16569
+ }
16570
+ }
16571
+ const existing = file2.ppid[ppid];
16572
+ file2.ppid[ppid] = {
16573
+ lastRunId: state.lastRunId ?? existing?.lastRunId,
16574
+ lastSessionId: state.lastSessionId ?? existing?.lastSessionId,
16575
+ lastCheckpointId: state.lastCheckpointId ?? existing?.lastCheckpointId,
16576
+ lastActiveAt: now
16577
+ };
16578
+ await writeFile5(COOK_STATE_FILE, JSON.stringify(file2, null, 2), "utf8");
16539
16579
  }
16540
16580
 
16541
16581
  // src/commands/cook.ts
@@ -16697,7 +16737,7 @@ async function autoPullArtifact(runOutput, artifactDir) {
16697
16737
  }
16698
16738
  var cookCmd = new Command13().name("cook").description("One-click agent preparation and execution from vm0.yaml");
16699
16739
  cookCmd.argument("[prompt]", "Prompt for the agent").action(async (prompt) => {
16700
- const shouldExit = await checkAndUpgrade("4.25.0", prompt);
16740
+ const shouldExit = await checkAndUpgrade("4.26.0", prompt);
16701
16741
  if (shouldExit) {
16702
16742
  process.exit(0);
16703
16743
  }
@@ -16867,16 +16907,47 @@ cookCmd.argument("[prompt]", "Prompt for the agent").action(async (prompt) => {
16867
16907
  );
16868
16908
  }
16869
16909
  });
16870
- cookCmd.command("logs").description("View logs from the last cook run").action(async () => {
16871
- const state = await loadCookState();
16872
- if (!state.lastRunId) {
16873
- console.error(chalk16.red("\u2717 No previous run found"));
16874
- console.error(chalk16.gray(" Run 'vm0 cook <prompt>' first"));
16875
- process.exit(1);
16910
+ cookCmd.command("logs").description("View logs from the last cook run").option("-a, --agent", "Show agent events (default)").option("-s, --system", "Show system log").option("-m, --metrics", "Show metrics").option("-n, --network", "Show network logs (proxy traffic)").option(
16911
+ "--since <time>",
16912
+ "Show logs since timestamp (e.g., 5m, 2h, 1d, 2024-01-15T10:30:00Z)"
16913
+ ).option("--limit <n>", "Maximum number of entries to show (default: 5)").action(
16914
+ async (options) => {
16915
+ const state = await loadCookState();
16916
+ if (!state.lastRunId) {
16917
+ console.error(chalk16.red("\u2717 No previous run found"));
16918
+ console.error(chalk16.gray(" Run 'vm0 cook <prompt>' first"));
16919
+ process.exit(1);
16920
+ }
16921
+ const args = ["logs", state.lastRunId];
16922
+ const displayArgs = [`vm0 logs ${state.lastRunId}`];
16923
+ if (options.agent) {
16924
+ args.push("--agent");
16925
+ displayArgs.push("--agent");
16926
+ }
16927
+ if (options.system) {
16928
+ args.push("--system");
16929
+ displayArgs.push("--system");
16930
+ }
16931
+ if (options.metrics) {
16932
+ args.push("--metrics");
16933
+ displayArgs.push("--metrics");
16934
+ }
16935
+ if (options.network) {
16936
+ args.push("--network");
16937
+ displayArgs.push("--network");
16938
+ }
16939
+ if (options.since) {
16940
+ args.push("--since", options.since);
16941
+ displayArgs.push(`--since ${options.since}`);
16942
+ }
16943
+ if (options.limit) {
16944
+ args.push("--limit", options.limit);
16945
+ displayArgs.push(`--limit ${options.limit}`);
16946
+ }
16947
+ printCommand(displayArgs.join(" "));
16948
+ await execVm0Command(args);
16876
16949
  }
16877
- printCommand(`vm0 logs ${state.lastRunId}`);
16878
- await execVm0Command(["logs", state.lastRunId]);
16879
- });
16950
+ );
16880
16951
  cookCmd.command("continue").description(
16881
16952
  "Continue from the last session (latest conversation and artifact)"
16882
16953
  ).argument("<prompt>", "Prompt for the continued agent").action(async (prompt) => {
@@ -17806,7 +17877,7 @@ var initCommand3 = new Command23().name("init").description("Initialize a new VM
17806
17877
 
17807
17878
  // src/index.ts
17808
17879
  var program = new Command24();
17809
- program.name("vm0").description("VM0 CLI - A modern build tool").version("4.25.0");
17880
+ program.name("vm0").description("VM0 CLI - A modern build tool").version("4.26.0");
17810
17881
  program.command("info").description("Display environment information").action(async () => {
17811
17882
  console.log(chalk25.cyan("System Information:"));
17812
17883
  console.log(`Node Version: ${process.version}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vm0/cli",
3
- "version": "4.25.0",
3
+ "version": "4.26.0",
4
4
  "description": "CLI application",
5
5
  "repository": {
6
6
  "type": "git",