@h-rig/cli 0.0.6-alpha.68 → 0.0.6-alpha.69

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.
package/dist/bin/rig.js CHANGED
@@ -3293,6 +3293,38 @@ async function updateWorkspaceTaskViaServer(context, input) {
3293
3293
  });
3294
3294
  return payload && typeof payload === "object" && !Array.isArray(payload) ? payload : { ok: true };
3295
3295
  }
3296
+ var RESUMABLE_RUN_STATUSES = new Set([
3297
+ "created",
3298
+ "preparing",
3299
+ "running",
3300
+ "validating",
3301
+ "reviewing",
3302
+ "stopped",
3303
+ "failed",
3304
+ "needs-attention",
3305
+ "needs_attention"
3306
+ ]);
3307
+ async function resumeRunViaServer(context, runId, options) {
3308
+ let targetRunId = runId?.trim() || null;
3309
+ if (!targetRunId) {
3310
+ const candidates = (await listRunsViaServer(context)).filter((run) => RESUMABLE_RUN_STATUSES.has(String(run.status ?? ""))).sort((left, right) => String(right.updatedAt ?? "").localeCompare(String(left.updatedAt ?? "")));
3311
+ targetRunId = typeof candidates[0]?.runId === "string" ? candidates[0].runId : null;
3312
+ }
3313
+ if (!targetRunId) {
3314
+ throw new CliError(options.restart ? "No run is available to restart." : "No resumable run is available.", 2, { hint: "List runs with `rig run list`, then pass an explicit id: `rig run resume <run-id>`." });
3315
+ }
3316
+ const payload = await requestServerJson(context, "/api/runs/resume", {
3317
+ method: "POST",
3318
+ headers: { "content-type": "application/json" },
3319
+ body: JSON.stringify({ runId: targetRunId, createdAt: new Date().toISOString(), restart: options.restart })
3320
+ });
3321
+ const record = payload && typeof payload === "object" && !Array.isArray(payload) ? payload : {};
3322
+ if (record.ok === false) {
3323
+ const message = typeof record.error === "string" && record.error.trim() ? record.error : "run resume failed";
3324
+ throw new CliError(`${options.restart ? "restart" : "resume"} failed for ${targetRunId}: ${message}`, 1);
3325
+ }
3326
+ return { ok: true, runId: targetRunId, ...record };
3327
+ }
3296
3328
  async function stopRunViaServer(context, runId) {
3297
3329
  const payload = await requestServerJson(context, "/api/runs/stop", {
3298
3330
  method: "POST",
@@ -7469,8 +7501,6 @@ import {
7469
7501
  deleteRunState,
7470
7502
  listOpenEpics,
7471
7503
  resolveDefaultEpic,
7472
- runResume,
7473
- runRestart,
7474
7504
  runStatus,
7475
7505
  runStop,
7476
7506
  startRun,
@@ -8372,7 +8402,7 @@ async function executeRun(context, args) {
8372
8402
  }
8373
8403
  return { ok: true, group: "run", command };
8374
8404
  }
8375
- const resumed = await runResume(context.projectRoot, runtimeContext, targetRunId);
8405
+ const resumed = await withSpinner(targetRunId ? `Resuming run ${targetRunId}\u2026` : "Resuming latest resumable run\u2026", () => resumeRunViaServer(context, targetRunId, { restart: false }), { outputMode: context.outputMode });
8376
8406
  if (context.outputMode === "text") {
8377
8407
  console.log(`Resumed run: ${resumed.runId}`);
8378
8408
  }
@@ -8391,7 +8421,7 @@ async function executeRun(context, args) {
8391
8421
  }
8392
8422
  return { ok: true, group: "run", command };
8393
8423
  }
8394
- const restarted = await runRestart(context.projectRoot, runtimeContext, targetRunId);
8424
+ const restarted = await withSpinner(targetRunId ? `Restarting run ${targetRunId}\u2026` : "Restarting latest run\u2026", () => resumeRunViaServer(context, targetRunId, { restart: true }), { outputMode: context.outputMode });
8395
8425
  if (context.outputMode === "text") {
8396
8426
  console.log(`Restarted run: ${restarted.runId}`);
8397
8427
  }
@@ -79,6 +79,17 @@ function setServerPhaseListener(listener) {
79
79
  return previous;
80
80
  }
81
81
  var serverReachabilityCache = new Map;
82
+ var RESUMABLE_RUN_STATUSES = new Set([
83
+ "created",
84
+ "preparing",
85
+ "running",
86
+ "validating",
87
+ "reviewing",
88
+ "stopped",
89
+ "failed",
90
+ "needs-attention",
91
+ "needs_attention"
92
+ ]);
82
93
 
83
94
  // packages/cli/src/commands/_async-ui.ts
84
95
  var CLACK_SPINNER_FRAMES = ["\u25D2", "\u25D0", "\u25D3", "\u25D1"];
@@ -318,6 +318,17 @@ ${failure.contextLine}`, 1, { hint: failure.hint });
318
318
  }
319
319
  return payload;
320
320
  }
321
+ var RESUMABLE_RUN_STATUSES = new Set([
322
+ "created",
323
+ "preparing",
324
+ "running",
325
+ "validating",
326
+ "reviewing",
327
+ "stopped",
328
+ "failed",
329
+ "needs-attention",
330
+ "needs_attention"
331
+ ]);
321
332
 
322
333
  // packages/cli/src/commands/_parsers.ts
323
334
  async function loadRigConfigOrNull(projectRoot) {
@@ -340,6 +340,17 @@ async function getRunTimelineViaServer(context, runId, options = {}) {
340
340
  const payload = await requestServerJson(context, `${url.pathname}${url.search}`);
341
341
  return payload && typeof payload === "object" && !Array.isArray(payload) ? payload : { entries: [] };
342
342
  }
343
+ var RESUMABLE_RUN_STATUSES = new Set([
344
+ "created",
345
+ "preparing",
346
+ "running",
347
+ "validating",
348
+ "reviewing",
349
+ "stopped",
350
+ "failed",
351
+ "needs-attention",
352
+ "needs_attention"
353
+ ]);
343
354
  async function stopRunViaServer(context, runId) {
344
355
  const payload = await requestServerJson(context, "/api/runs/stop", {
345
356
  method: "POST",
@@ -324,6 +324,17 @@ async function getRunDetailsViaServer(context, runId) {
324
324
  const payload = await requestServerJson(context, `/api/runs/${encodeURIComponent(runId)}`);
325
325
  return payload && typeof payload === "object" && !Array.isArray(payload) ? payload : {};
326
326
  }
327
+ var RESUMABLE_RUN_STATUSES = new Set([
328
+ "created",
329
+ "preparing",
330
+ "running",
331
+ "validating",
332
+ "reviewing",
333
+ "stopped",
334
+ "failed",
335
+ "needs-attention",
336
+ "needs_attention"
337
+ ]);
327
338
 
328
339
  // packages/cli/src/commands/_pi-frontend.ts
329
340
  function setTemporaryEnv(updates) {
@@ -312,6 +312,17 @@ ${failure.contextLine}`, 1, { hint: failure.hint });
312
312
  }
313
313
  return payload;
314
314
  }
315
+ var RESUMABLE_RUN_STATUSES = new Set([
316
+ "created",
317
+ "preparing",
318
+ "running",
319
+ "validating",
320
+ "reviewing",
321
+ "stopped",
322
+ "failed",
323
+ "needs-attention",
324
+ "needs_attention"
325
+ ]);
315
326
 
316
327
  // packages/cli/src/commands/_preflight.ts
317
328
  function preflightCheck(id, label, status, detail, remediation) {
@@ -481,6 +481,38 @@ async function updateWorkspaceTaskViaServer(context, input) {
481
481
  });
482
482
  return payload && typeof payload === "object" && !Array.isArray(payload) ? payload : { ok: true };
483
483
  }
484
+ var RESUMABLE_RUN_STATUSES = new Set([
485
+ "created",
486
+ "preparing",
487
+ "running",
488
+ "validating",
489
+ "reviewing",
490
+ "stopped",
491
+ "failed",
492
+ "needs-attention",
493
+ "needs_attention"
494
+ ]);
495
+ async function resumeRunViaServer(context, runId, options) {
496
+ let targetRunId = runId?.trim() || null;
497
+ if (!targetRunId) {
498
+ const candidates = (await listRunsViaServer(context)).filter((run) => RESUMABLE_RUN_STATUSES.has(String(run.status ?? ""))).sort((left, right) => String(right.updatedAt ?? "").localeCompare(String(left.updatedAt ?? "")));
499
+ targetRunId = typeof candidates[0]?.runId === "string" ? candidates[0].runId : null;
500
+ }
501
+ if (!targetRunId) {
502
+ throw new CliError(options.restart ? "No run is available to restart." : "No resumable run is available.", 2, { hint: "List runs with `rig run list`, then pass an explicit id: `rig run resume <run-id>`." });
503
+ }
504
+ const payload = await requestServerJson(context, "/api/runs/resume", {
505
+ method: "POST",
506
+ headers: { "content-type": "application/json" },
507
+ body: JSON.stringify({ runId: targetRunId, createdAt: new Date().toISOString(), restart: options.restart })
508
+ });
509
+ const record = payload && typeof payload === "object" && !Array.isArray(payload) ? payload : {};
510
+ if (record.ok === false) {
511
+ const message = typeof record.error === "string" && record.error.trim() ? record.error : "run resume failed";
512
+ throw new CliError(`${options.restart ? "restart" : "resume"} failed for ${targetRunId}: ${message}`, 1);
513
+ }
514
+ return { ok: true, runId: targetRunId, ...record };
515
+ }
484
516
  async function stopRunViaServer(context, runId) {
485
517
  const payload = await requestServerJson(context, "/api/runs/stop", {
486
518
  method: "POST",
@@ -606,6 +638,7 @@ export {
606
638
  sendRunPiPromptViaServer,
607
639
  selectNextWorkspaceTaskViaServer,
608
640
  runRunPiCommandViaServer,
641
+ resumeRunViaServer,
609
642
  respondRunPiExtensionUiViaServer,
610
643
  requestServerJson,
611
644
  registerProjectViaServer,
@@ -317,6 +317,17 @@ ${failure.contextLine}`, 1, { hint: failure.hint });
317
317
  }
318
318
  return payload;
319
319
  }
320
+ var RESUMABLE_RUN_STATUSES = new Set([
321
+ "created",
322
+ "preparing",
323
+ "running",
324
+ "validating",
325
+ "reviewing",
326
+ "stopped",
327
+ "failed",
328
+ "needs-attention",
329
+ "needs_attention"
330
+ ]);
320
331
 
321
332
  // packages/cli/src/commands/_snapshot-upload.ts
322
333
  var UPLOADED_SNAPSHOT_PR_MARKER = "<!-- rig:uploaded-snapshot -->";
@@ -229,6 +229,17 @@ import { ensureProjectMainFreshBeforeRun } from "@rig/runtime/control-plane/proj
229
229
  import { ensureLocalRigServerConnection } from "@rig/runtime/local-server";
230
230
  var scopedGitHubBearerTokens = new Map;
231
231
  var serverReachabilityCache = new Map;
232
+ var RESUMABLE_RUN_STATUSES = new Set([
233
+ "created",
234
+ "preparing",
235
+ "running",
236
+ "validating",
237
+ "reviewing",
238
+ "stopped",
239
+ "failed",
240
+ "needs-attention",
241
+ "needs_attention"
242
+ ]);
232
243
 
233
244
  // packages/cli/src/commands/_preflight.ts
234
245
  async function runProjectMainSyncPreflight(context, options) {
@@ -327,6 +327,17 @@ ${failure.contextLine}`, 1, { hint: failure.hint });
327
327
  }
328
328
  return payload;
329
329
  }
330
+ var RESUMABLE_RUN_STATUSES = new Set([
331
+ "created",
332
+ "preparing",
333
+ "running",
334
+ "validating",
335
+ "reviewing",
336
+ "stopped",
337
+ "failed",
338
+ "needs-attention",
339
+ "needs_attention"
340
+ ]);
330
341
 
331
342
  // packages/cli/src/commands/_parsers.ts
332
343
  async function loadRigConfigOrNull(projectRoot) {
@@ -351,6 +351,17 @@ async function postGitHubTokenViaServer(context, token, options = {}) {
351
351
  });
352
352
  return payload && typeof payload === "object" && !Array.isArray(payload) ? payload : {};
353
353
  }
354
+ var RESUMABLE_RUN_STATUSES = new Set([
355
+ "created",
356
+ "preparing",
357
+ "running",
358
+ "validating",
359
+ "reviewing",
360
+ "stopped",
361
+ "failed",
362
+ "needs-attention",
363
+ "needs_attention"
364
+ ]);
354
365
 
355
366
  // packages/cli/src/commands/_async-ui.ts
356
367
  import pc from "picocolors";
@@ -424,6 +424,17 @@ ${failure.contextLine}`, 1, { hint: failure.hint });
424
424
  }
425
425
  return payload;
426
426
  }
427
+ var RESUMABLE_RUN_STATUSES = new Set([
428
+ "created",
429
+ "preparing",
430
+ "running",
431
+ "validating",
432
+ "reviewing",
433
+ "stopped",
434
+ "failed",
435
+ "needs-attention",
436
+ "needs_attention"
437
+ ]);
427
438
 
428
439
  // packages/cli/src/commands/_async-ui.ts
429
440
  import pc2 from "picocolors";
@@ -446,6 +446,17 @@ async function getGitHubProjectStatusFieldViaServer(context, projectId) {
446
446
  const payload = await requestServerJson(context, `/api/github/projects/${encodeURIComponent(projectId)}/status-field`);
447
447
  return payload && typeof payload === "object" && !Array.isArray(payload) ? payload : {};
448
448
  }
449
+ var RESUMABLE_RUN_STATUSES = new Set([
450
+ "created",
451
+ "preparing",
452
+ "running",
453
+ "validating",
454
+ "reviewing",
455
+ "stopped",
456
+ "failed",
457
+ "needs-attention",
458
+ "needs_attention"
459
+ ]);
449
460
 
450
461
  // packages/cli/src/commands/_pi-install.ts
451
462
  import { existsSync as existsSync3, readFileSync as readFileSync3, rmSync } from "fs";
@@ -381,6 +381,17 @@ async function getRunLogsViaServer(context, runId, options = {}) {
381
381
  const payload = await requestServerJson(context, `${url.pathname}${url.search}`);
382
382
  return payload && typeof payload === "object" && !Array.isArray(payload) ? payload : { entries: [] };
383
383
  }
384
+ var RESUMABLE_RUN_STATUSES = new Set([
385
+ "created",
386
+ "preparing",
387
+ "running",
388
+ "validating",
389
+ "reviewing",
390
+ "stopped",
391
+ "failed",
392
+ "needs-attention",
393
+ "needs_attention"
394
+ ]);
384
395
 
385
396
  // packages/cli/src/commands/_async-ui.ts
386
397
  import pc from "picocolors";
@@ -99,6 +99,17 @@ import { ensureProjectMainFreshBeforeRun } from "@rig/runtime/control-plane/proj
99
99
  import { ensureLocalRigServerConnection } from "@rig/runtime/local-server";
100
100
  var scopedGitHubBearerTokens = new Map;
101
101
  var serverReachabilityCache = new Map;
102
+ var RESUMABLE_RUN_STATUSES = new Set([
103
+ "created",
104
+ "preparing",
105
+ "running",
106
+ "validating",
107
+ "reviewing",
108
+ "stopped",
109
+ "failed",
110
+ "needs-attention",
111
+ "needs_attention"
112
+ ]);
102
113
 
103
114
  // packages/cli/src/commands/_preflight.ts
104
115
  async function runProjectMainSyncPreflight(context, options) {
@@ -66,8 +66,6 @@ import {
66
66
  deleteRunState,
67
67
  listOpenEpics,
68
68
  resolveDefaultEpic,
69
- runResume,
70
- runRestart,
71
69
  runStatus,
72
70
  runStop,
73
71
  startRun,
@@ -421,6 +419,38 @@ async function getRunTimelineViaServer(context, runId, options = {}) {
421
419
  const payload = await requestServerJson(context, `${url.pathname}${url.search}`);
422
420
  return payload && typeof payload === "object" && !Array.isArray(payload) ? payload : { entries: [] };
423
421
  }
422
+ var RESUMABLE_RUN_STATUSES = new Set([
423
+ "created",
424
+ "preparing",
425
+ "running",
426
+ "validating",
427
+ "reviewing",
428
+ "stopped",
429
+ "failed",
430
+ "needs-attention",
431
+ "needs_attention"
432
+ ]);
433
+ async function resumeRunViaServer(context, runId, options) {
434
+ let targetRunId = runId?.trim() || null;
435
+ if (!targetRunId) {
436
+ const candidates = (await listRunsViaServer(context)).filter((run) => RESUMABLE_RUN_STATUSES.has(String(run.status ?? ""))).sort((left, right) => String(right.updatedAt ?? "").localeCompare(String(left.updatedAt ?? "")));
437
+ targetRunId = typeof candidates[0]?.runId === "string" ? candidates[0].runId : null;
438
+ }
439
+ if (!targetRunId) {
440
+ throw new CliError(options.restart ? "No run is available to restart." : "No resumable run is available.", 2, { hint: "List runs with `rig run list`, then pass an explicit id: `rig run resume <run-id>`." });
441
+ }
442
+ const payload = await requestServerJson(context, "/api/runs/resume", {
443
+ method: "POST",
444
+ headers: { "content-type": "application/json" },
445
+ body: JSON.stringify({ runId: targetRunId, createdAt: new Date().toISOString(), restart: options.restart })
446
+ });
447
+ const record = payload && typeof payload === "object" && !Array.isArray(payload) ? payload : {};
448
+ if (record.ok === false) {
449
+ const message = typeof record.error === "string" && record.error.trim() ? record.error : "run resume failed";
450
+ throw new CliError(`${options.restart ? "restart" : "resume"} failed for ${targetRunId}: ${message}`, 1);
451
+ }
452
+ return { ok: true, runId: targetRunId, ...record };
453
+ }
424
454
  async function stopRunViaServer(context, runId) {
425
455
  const payload = await requestServerJson(context, "/api/runs/stop", {
426
456
  method: "POST",
@@ -1672,7 +1702,7 @@ async function executeRun(context, args) {
1672
1702
  }
1673
1703
  return { ok: true, group: "run", command };
1674
1704
  }
1675
- const resumed = await runResume(context.projectRoot, runtimeContext, targetRunId);
1705
+ const resumed = await withSpinner(targetRunId ? `Resuming run ${targetRunId}\u2026` : "Resuming latest resumable run\u2026", () => resumeRunViaServer(context, targetRunId, { restart: false }), { outputMode: context.outputMode });
1676
1706
  if (context.outputMode === "text") {
1677
1707
  console.log(`Resumed run: ${resumed.runId}`);
1678
1708
  }
@@ -1691,7 +1721,7 @@ async function executeRun(context, args) {
1691
1721
  }
1692
1722
  return { ok: true, group: "run", command };
1693
1723
  }
1694
- const restarted = await runRestart(context.projectRoot, runtimeContext, targetRunId);
1724
+ const restarted = await withSpinner(targetRunId ? `Restarting run ${targetRunId}\u2026` : "Restarting latest run\u2026", () => resumeRunViaServer(context, targetRunId, { restart: true }), { outputMode: context.outputMode });
1695
1725
  if (context.outputMode === "text") {
1696
1726
  console.log(`Restarted run: ${restarted.runId}`);
1697
1727
  }
@@ -553,6 +553,17 @@ ${failure.contextLine}`, 1, { hint: failure.hint });
553
553
  }
554
554
  return payload;
555
555
  }
556
+ var RESUMABLE_RUN_STATUSES = new Set([
557
+ "created",
558
+ "preparing",
559
+ "running",
560
+ "validating",
561
+ "reviewing",
562
+ "stopped",
563
+ "failed",
564
+ "needs-attention",
565
+ "needs_attention"
566
+ ]);
556
567
  async function submitTaskRunViaServer(context, input) {
557
568
  const isTaskRun = Boolean(input.taskId);
558
569
  const endpoint = isTaskRun ? "/api/runs/task" : "/api/runs/adhoc";
@@ -482,6 +482,17 @@ ${failure.contextLine}`, 1, { hint: failure.hint });
482
482
  }
483
483
  return payload;
484
484
  }
485
+ var RESUMABLE_RUN_STATUSES = new Set([
486
+ "created",
487
+ "preparing",
488
+ "running",
489
+ "validating",
490
+ "reviewing",
491
+ "stopped",
492
+ "failed",
493
+ "needs-attention",
494
+ "needs_attention"
495
+ ]);
485
496
 
486
497
  // packages/cli/src/commands/_doctor-checks.ts
487
498
  function check(id, label, status, detail, remediation) {
@@ -349,6 +349,17 @@ ${failure.contextLine}`, 1, { hint: failure.hint });
349
349
  }
350
350
  return payload;
351
351
  }
352
+ var RESUMABLE_RUN_STATUSES = new Set([
353
+ "created",
354
+ "preparing",
355
+ "running",
356
+ "validating",
357
+ "reviewing",
358
+ "stopped",
359
+ "failed",
360
+ "needs-attention",
361
+ "needs_attention"
362
+ ]);
352
363
 
353
364
  // packages/cli/src/commands/_cli-format.ts
354
365
  import { log, note } from "@clack/prompts";
@@ -743,6 +743,17 @@ async function updateWorkspaceTaskViaServer(context, input) {
743
743
  });
744
744
  return payload && typeof payload === "object" && !Array.isArray(payload) ? payload : { ok: true };
745
745
  }
746
+ var RESUMABLE_RUN_STATUSES = new Set([
747
+ "created",
748
+ "preparing",
749
+ "running",
750
+ "validating",
751
+ "reviewing",
752
+ "stopped",
753
+ "failed",
754
+ "needs-attention",
755
+ "needs_attention"
756
+ ]);
746
757
 
747
758
  // packages/cli/src/commands/task-run-driver.ts
748
759
  var PI_CANONICAL_RUN_STAGES = [
@@ -471,6 +471,17 @@ async function getRunTimelineViaServer(context, runId, options = {}) {
471
471
  const payload = await requestServerJson(context, `${url.pathname}${url.search}`);
472
472
  return payload && typeof payload === "object" && !Array.isArray(payload) ? payload : { entries: [] };
473
473
  }
474
+ var RESUMABLE_RUN_STATUSES = new Set([
475
+ "created",
476
+ "preparing",
477
+ "running",
478
+ "validating",
479
+ "reviewing",
480
+ "stopped",
481
+ "failed",
482
+ "needs-attention",
483
+ "needs_attention"
484
+ ]);
474
485
  async function stopRunViaServer(context, runId) {
475
486
  const payload = await requestServerJson(context, "/api/runs/stop", {
476
487
  method: "POST",
@@ -3100,6 +3100,38 @@ async function updateWorkspaceTaskViaServer(context, input) {
3100
3100
  });
3101
3101
  return payload && typeof payload === "object" && !Array.isArray(payload) ? payload : { ok: true };
3102
3102
  }
3103
+ var RESUMABLE_RUN_STATUSES = new Set([
3104
+ "created",
3105
+ "preparing",
3106
+ "running",
3107
+ "validating",
3108
+ "reviewing",
3109
+ "stopped",
3110
+ "failed",
3111
+ "needs-attention",
3112
+ "needs_attention"
3113
+ ]);
3114
+ async function resumeRunViaServer(context, runId, options) {
3115
+ let targetRunId = runId?.trim() || null;
3116
+ if (!targetRunId) {
3117
+ const candidates = (await listRunsViaServer(context)).filter((run) => RESUMABLE_RUN_STATUSES.has(String(run.status ?? ""))).sort((left, right) => String(right.updatedAt ?? "").localeCompare(String(left.updatedAt ?? "")));
3118
+ targetRunId = typeof candidates[0]?.runId === "string" ? candidates[0].runId : null;
3119
+ }
3120
+ if (!targetRunId) {
3121
+ throw new CliError(options.restart ? "No run is available to restart." : "No resumable run is available.", 2, { hint: "List runs with `rig run list`, then pass an explicit id: `rig run resume <run-id>`." });
3122
+ }
3123
+ const payload = await requestServerJson(context, "/api/runs/resume", {
3124
+ method: "POST",
3125
+ headers: { "content-type": "application/json" },
3126
+ body: JSON.stringify({ runId: targetRunId, createdAt: new Date().toISOString(), restart: options.restart })
3127
+ });
3128
+ const record = payload && typeof payload === "object" && !Array.isArray(payload) ? payload : {};
3129
+ if (record.ok === false) {
3130
+ const message = typeof record.error === "string" && record.error.trim() ? record.error : "run resume failed";
3131
+ throw new CliError(`${options.restart ? "restart" : "resume"} failed for ${targetRunId}: ${message}`, 1);
3132
+ }
3133
+ return { ok: true, runId: targetRunId, ...record };
3134
+ }
3103
3135
  async function stopRunViaServer(context, runId) {
3104
3136
  const payload = await requestServerJson(context, "/api/runs/stop", {
3105
3137
  method: "POST",
@@ -7276,8 +7308,6 @@ import {
7276
7308
  deleteRunState,
7277
7309
  listOpenEpics,
7278
7310
  resolveDefaultEpic,
7279
- runResume,
7280
- runRestart,
7281
7311
  runStatus,
7282
7312
  runStop,
7283
7313
  startRun,
@@ -8179,7 +8209,7 @@ async function executeRun(context, args) {
8179
8209
  }
8180
8210
  return { ok: true, group: "run", command };
8181
8211
  }
8182
- const resumed = await runResume(context.projectRoot, runtimeContext, targetRunId);
8212
+ const resumed = await withSpinner(targetRunId ? `Resuming run ${targetRunId}\u2026` : "Resuming latest resumable run\u2026", () => resumeRunViaServer(context, targetRunId, { restart: false }), { outputMode: context.outputMode });
8183
8213
  if (context.outputMode === "text") {
8184
8214
  console.log(`Resumed run: ${resumed.runId}`);
8185
8215
  }
@@ -8198,7 +8228,7 @@ async function executeRun(context, args) {
8198
8228
  }
8199
8229
  return { ok: true, group: "run", command };
8200
8230
  }
8201
- const restarted = await runRestart(context.projectRoot, runtimeContext, targetRunId);
8231
+ const restarted = await withSpinner(targetRunId ? `Restarting run ${targetRunId}\u2026` : "Restarting latest run\u2026", () => resumeRunViaServer(context, targetRunId, { restart: true }), { outputMode: context.outputMode });
8202
8232
  if (context.outputMode === "text") {
8203
8233
  console.log(`Restarted run: ${restarted.runId}`);
8204
8234
  }
package/dist/src/index.js CHANGED
@@ -3289,6 +3289,38 @@ async function updateWorkspaceTaskViaServer(context, input) {
3289
3289
  });
3290
3290
  return payload && typeof payload === "object" && !Array.isArray(payload) ? payload : { ok: true };
3291
3291
  }
3292
+ var RESUMABLE_RUN_STATUSES = new Set([
3293
+ "created",
3294
+ "preparing",
3295
+ "running",
3296
+ "validating",
3297
+ "reviewing",
3298
+ "stopped",
3299
+ "failed",
3300
+ "needs-attention",
3301
+ "needs_attention"
3302
+ ]);
3303
+ async function resumeRunViaServer(context, runId, options) {
3304
+ let targetRunId = runId?.trim() || null;
3305
+ if (!targetRunId) {
3306
+ const candidates = (await listRunsViaServer(context)).filter((run) => RESUMABLE_RUN_STATUSES.has(String(run.status ?? ""))).sort((left, right) => String(right.updatedAt ?? "").localeCompare(String(left.updatedAt ?? "")));
3307
+ targetRunId = typeof candidates[0]?.runId === "string" ? candidates[0].runId : null;
3308
+ }
3309
+ if (!targetRunId) {
3310
+ throw new CliError(options.restart ? "No run is available to restart." : "No resumable run is available.", 2, { hint: "List runs with `rig run list`, then pass an explicit id: `rig run resume <run-id>`." });
3311
+ }
3312
+ const payload = await requestServerJson(context, "/api/runs/resume", {
3313
+ method: "POST",
3314
+ headers: { "content-type": "application/json" },
3315
+ body: JSON.stringify({ runId: targetRunId, createdAt: new Date().toISOString(), restart: options.restart })
3316
+ });
3317
+ const record = payload && typeof payload === "object" && !Array.isArray(payload) ? payload : {};
3318
+ if (record.ok === false) {
3319
+ const message = typeof record.error === "string" && record.error.trim() ? record.error : "run resume failed";
3320
+ throw new CliError(`${options.restart ? "restart" : "resume"} failed for ${targetRunId}: ${message}`, 1);
3321
+ }
3322
+ return { ok: true, runId: targetRunId, ...record };
3323
+ }
3292
3324
  async function stopRunViaServer(context, runId) {
3293
3325
  const payload = await requestServerJson(context, "/api/runs/stop", {
3294
3326
  method: "POST",
@@ -7465,8 +7497,6 @@ import {
7465
7497
  deleteRunState,
7466
7498
  listOpenEpics,
7467
7499
  resolveDefaultEpic,
7468
- runResume,
7469
- runRestart,
7470
7500
  runStatus,
7471
7501
  runStop,
7472
7502
  startRun,
@@ -8368,7 +8398,7 @@ async function executeRun(context, args) {
8368
8398
  }
8369
8399
  return { ok: true, group: "run", command };
8370
8400
  }
8371
- const resumed = await runResume(context.projectRoot, runtimeContext, targetRunId);
8401
+ const resumed = await withSpinner(targetRunId ? `Resuming run ${targetRunId}\u2026` : "Resuming latest resumable run\u2026", () => resumeRunViaServer(context, targetRunId, { restart: false }), { outputMode: context.outputMode });
8372
8402
  if (context.outputMode === "text") {
8373
8403
  console.log(`Resumed run: ${resumed.runId}`);
8374
8404
  }
@@ -8387,7 +8417,7 @@ async function executeRun(context, args) {
8387
8417
  }
8388
8418
  return { ok: true, group: "run", command };
8389
8419
  }
8390
- const restarted = await runRestart(context.projectRoot, runtimeContext, targetRunId);
8420
+ const restarted = await withSpinner(targetRunId ? `Restarting run ${targetRunId}\u2026` : "Restarting latest run\u2026", () => resumeRunViaServer(context, targetRunId, { restart: true }), { outputMode: context.outputMode });
8391
8421
  if (context.outputMode === "text") {
8392
8422
  console.log(`Restarted run: ${restarted.runId}`);
8393
8423
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@h-rig/cli",
3
- "version": "0.0.6-alpha.68",
3
+ "version": "0.0.6-alpha.69",
4
4
  "type": "module",
5
5
  "description": "Rig package",
6
6
  "license": "UNLICENSED",
@@ -24,13 +24,13 @@
24
24
  "dependencies": {
25
25
  "@clack/prompts": "^1.2.0",
26
26
  "@earendil-works/pi-coding-agent": "0.79.0",
27
- "@rig/client": "npm:@h-rig/client@0.0.6-alpha.68",
28
- "@rig/contracts": "npm:@h-rig/contracts@0.0.6-alpha.68",
29
- "@rig/core": "npm:@h-rig/core@0.0.6-alpha.68",
30
- "@rig/pi-rig": "npm:@h-rig/pi-rig@0.0.6-alpha.68",
31
- "@rig/runtime": "npm:@h-rig/runtime@0.0.6-alpha.68",
32
- "@rig/server": "npm:@h-rig/server@0.0.6-alpha.68",
33
- "@rig/standard-plugin": "npm:@h-rig/standard-plugin@0.0.6-alpha.68",
27
+ "@rig/client": "npm:@h-rig/client@0.0.6-alpha.69",
28
+ "@rig/contracts": "npm:@h-rig/contracts@0.0.6-alpha.69",
29
+ "@rig/core": "npm:@h-rig/core@0.0.6-alpha.69",
30
+ "@rig/pi-rig": "npm:@h-rig/pi-rig@0.0.6-alpha.69",
31
+ "@rig/runtime": "npm:@h-rig/runtime@0.0.6-alpha.69",
32
+ "@rig/server": "npm:@h-rig/server@0.0.6-alpha.69",
33
+ "@rig/standard-plugin": "npm:@h-rig/standard-plugin@0.0.6-alpha.69",
34
34
  "effect": "4.0.0-beta.78",
35
35
  "picocolors": "^1.1.1"
36
36
  }