@h-rig/cli 0.0.6-alpha.77 → 0.0.6-alpha.79

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 (91) hide show
  1. package/dist/bin/build-rig-binaries.d.ts +2 -0
  2. package/dist/bin/rig.d.ts +2 -0
  3. package/dist/bin/rig.js +10214 -9309
  4. package/dist/src/app/board.d.ts +23 -0
  5. package/dist/src/app/board.js +1786 -0
  6. package/dist/src/app/drone-ui.d.ts +37 -0
  7. package/dist/src/app/drone-ui.js +294 -0
  8. package/dist/src/app/theme.d.ts +47 -0
  9. package/dist/src/{commands/_tui-theme.js → app/theme.js} +16 -1
  10. package/dist/src/commands/_async-ui.d.ts +13 -0
  11. package/dist/src/commands/_async-ui.js +74 -3
  12. package/dist/src/commands/_authority-runs.d.ts +22 -0
  13. package/dist/src/commands/_cli-format.d.ts +49 -0
  14. package/dist/src/commands/_cli-format.js +26 -8
  15. package/dist/src/commands/_connection-state.d.ts +44 -0
  16. package/dist/src/commands/_doctor-checks.d.ts +52 -0
  17. package/dist/src/commands/_doctor-checks.js +3 -1
  18. package/dist/src/commands/_help-catalog.d.ts +51 -0
  19. package/dist/src/commands/_help-catalog.js +9 -70
  20. package/dist/src/commands/_json-output.d.ts +11 -0
  21. package/dist/src/commands/_operator-surface.d.ts +34 -0
  22. package/dist/src/commands/_operator-view.d.ts +30 -0
  23. package/dist/src/commands/_operator-view.js +184 -7
  24. package/dist/src/commands/_parsers.d.ts +15 -0
  25. package/dist/src/commands/_paths.d.ts +11 -0
  26. package/dist/src/commands/_pi-frontend.d.ts +27 -0
  27. package/dist/src/commands/_pi-frontend.js +184 -7
  28. package/dist/src/commands/_pi-install.d.ts +42 -0
  29. package/dist/src/commands/_pi-install.js +1 -1
  30. package/dist/src/commands/_policy.d.ts +8 -0
  31. package/dist/src/commands/_preflight.d.ts +22 -0
  32. package/dist/src/commands/_preflight.js +3 -1
  33. package/dist/src/commands/_probes.d.ts +1 -0
  34. package/dist/src/commands/_run-driver-helpers.d.ts +99 -0
  35. package/dist/src/commands/_run-replay.d.ts +24 -0
  36. package/dist/src/commands/_server-client.d.ts +186 -0
  37. package/dist/src/commands/_server-client.js +3 -1
  38. package/dist/src/commands/_snapshot-upload.d.ts +39 -0
  39. package/dist/src/commands/_snapshot-upload.js +3 -1
  40. package/dist/src/commands/_spinner.d.ts +25 -0
  41. package/dist/src/commands/_task-picker.d.ts +9 -0
  42. package/dist/src/commands/_task-picker.js +132 -7
  43. package/dist/src/commands/agent.d.ts +3 -0
  44. package/dist/src/commands/browser.d.ts +65 -0
  45. package/dist/src/commands/browser.js +306 -30
  46. package/dist/src/commands/connect.d.ts +7 -0
  47. package/dist/src/commands/connect.js +130 -64
  48. package/dist/src/commands/dist.d.ts +28 -0
  49. package/dist/src/commands/doctor.d.ts +3 -0
  50. package/dist/src/commands/doctor.js +77 -4
  51. package/dist/src/commands/github.d.ts +3 -0
  52. package/dist/src/commands/github.js +77 -4
  53. package/dist/src/commands/inbox.d.ts +30 -0
  54. package/dist/src/commands/inbox.js +101 -78
  55. package/dist/src/commands/init.d.ts +74 -0
  56. package/dist/src/commands/init.js +350 -10
  57. package/dist/src/commands/inspect.d.ts +3 -0
  58. package/dist/src/commands/inspect.js +77 -4
  59. package/dist/src/commands/inspector.d.ts +3 -0
  60. package/dist/src/commands/pi.d.ts +3 -0
  61. package/dist/src/commands/plugin.d.ts +16 -0
  62. package/dist/src/commands/profile-and-review.d.ts +4 -0
  63. package/dist/src/commands/queue.d.ts +3 -0
  64. package/dist/src/commands/remote.d.ts +3 -0
  65. package/dist/src/commands/repo-git-harness.d.ts +5 -0
  66. package/dist/src/commands/run.d.ts +3 -0
  67. package/dist/src/commands/run.js +195 -69
  68. package/dist/src/commands/server.d.ts +7 -0
  69. package/dist/src/commands/server.js +133 -65
  70. package/dist/src/commands/setup.d.ts +16 -0
  71. package/dist/src/commands/setup.js +77 -4
  72. package/dist/src/commands/stats.d.ts +12 -0
  73. package/dist/src/commands/stats.js +57 -113
  74. package/dist/src/commands/task-report-bug.d.ts +19 -0
  75. package/dist/src/commands/task-report-bug.js +231 -40
  76. package/dist/src/commands/task-run-driver.d.ts +132 -0
  77. package/dist/src/commands/task-run-driver.js +26 -3
  78. package/dist/src/commands/task.d.ts +14 -0
  79. package/dist/src/commands/task.js +341 -229
  80. package/dist/src/commands/test.d.ts +3 -0
  81. package/dist/src/commands/workspace.d.ts +3 -0
  82. package/dist/src/commands.d.ts +29 -0
  83. package/dist/src/commands.js +10194 -9289
  84. package/dist/src/index.d.ts +4 -0
  85. package/dist/src/index.js +10200 -9295
  86. package/dist/src/launcher.d.ts +61 -0
  87. package/dist/src/report-bug.d.ts +44 -0
  88. package/dist/src/runner.d.ts +47 -0
  89. package/dist/src/withMutedConsole.d.ts +2 -0
  90. package/package.json +10 -9
  91. package/dist/src/commands/_operator-board.js +0 -730
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  // packages/cli/src/commands/_pi-frontend.ts
3
- import { mkdtempSync, rmSync, writeFileSync as writeFileSync2 } from "fs";
4
- import { tmpdir } from "os";
3
+ import { existsSync as existsSync3, mkdirSync as mkdirSync2, mkdtempSync, readFileSync as readFileSync3, rmSync, writeFileSync as writeFileSync2 } from "fs";
4
+ import { homedir as homedir2, tmpdir } from "os";
5
5
  import { join } from "path";
6
6
  import { main as runPiMain } from "@earendil-works/pi-coding-agent";
7
7
  import createPiRigExtension from "@rig/pi-rig";
@@ -318,7 +318,9 @@ ${failure.contextLine}`, 1, { hint: failure.hint });
318
318
  })() : null;
319
319
  if (!response.ok) {
320
320
  const diagnostics = diagnosticMessage(payload);
321
- const detail = diagnostics ?? (text || response.statusText);
321
+ const rawDetail = diagnostics ?? (text || response.statusText);
322
+ const detail = diagnostics ? rawDetail : rawDetail.split(`
323
+ `).map((line) => line.trim()).find((line) => line.length > 0)?.slice(0, 200) ?? response.statusText;
322
324
  const failure = await buildServerFailureContext(context.projectRoot, server);
323
325
  throw new CliError(`Rig server request failed (${response.status}): ${detail}
324
326
  ${failure.contextLine}`, 1, { hint: failure.hint });
@@ -405,8 +407,79 @@ function createTtySpinner(input) {
405
407
  };
406
408
  }
407
409
 
410
+ // packages/cli/src/app/theme.ts
411
+ var RIG_PALETTE = {
412
+ ink: "#f2f3f6",
413
+ ink2: "#aeb0ba",
414
+ ink3: "#6c6e79",
415
+ ink4: "#44464f",
416
+ accent: "#ccff4d",
417
+ accentDim: "#a9d63f",
418
+ cyan: "#56d8ff",
419
+ red: "#ff5d5d",
420
+ yellow: "#ffd24d"
421
+ };
422
+ function hexToRgb(hex) {
423
+ const value = hex.replace("#", "");
424
+ return [
425
+ Number.parseInt(value.slice(0, 2), 16),
426
+ Number.parseInt(value.slice(2, 4), 16),
427
+ Number.parseInt(value.slice(4, 6), 16)
428
+ ];
429
+ }
430
+ function fg(hex) {
431
+ const [r, g, b] = hexToRgb(hex);
432
+ return (text) => `\x1B[38;2;${r};${g};${b}m${text}\x1B[39m`;
433
+ }
434
+ var ink = fg(RIG_PALETTE.ink);
435
+ var ink2 = fg(RIG_PALETTE.ink2);
436
+ var ink3 = fg(RIG_PALETTE.ink3);
437
+ var ink4 = fg(RIG_PALETTE.ink4);
438
+ var accent = fg(RIG_PALETTE.accent);
439
+ var accentDim = fg(RIG_PALETTE.accentDim);
440
+ var cyan = fg(RIG_PALETTE.cyan);
441
+ var red = fg(RIG_PALETTE.red);
442
+ var yellow = fg(RIG_PALETTE.yellow);
443
+ function bold(text) {
444
+ return `\x1B[1m${text}\x1B[22m`;
445
+ }
446
+ var DRONE_ART = [
447
+ " .-=-. .-=-. ",
448
+ " ( !!! ) ( !!! ) ",
449
+ " '-=-'._ _.'-=-' ",
450
+ " '._ _.' ",
451
+ " '=$$$$$$$=.' ",
452
+ " =$$$$$$$$$$$= ",
453
+ " $$$@@@@@@@@@@$$$ ",
454
+ " $$$@@ @@$$$ ",
455
+ " $$@ ? @$$$ ",
456
+ " $$$@ '-' @$$$ ",
457
+ " $$$@@ @@$$$ ",
458
+ " $$$@@@@@@@@@@$$$ ",
459
+ " =$$$$$$$$$$$= ",
460
+ " '=$$$$$$$=.' ",
461
+ " _.' '._ ",
462
+ " .-=-.' '.-=-. ",
463
+ " ( !!! ) ( !!! ) ",
464
+ " '-=-' '-=-' "
465
+ ];
466
+ var EYE_FRAMES = ["@", "o", "."];
467
+ var DRONE_WIDTH = DRONE_ART[0].length;
468
+ var DRONE_HEIGHT = DRONE_ART.length;
469
+ var MICRO_BLADES = ["---", "\\\\\\", "|||", "///"];
470
+ function microDroneFrame(tick) {
471
+ const blade = MICRO_BLADES[tick % MICRO_BLADES.length];
472
+ const eye = EYE_FRAMES[Math.floor(tick / 2) % EYE_FRAMES.length];
473
+ return `(${blade})${eye}(${blade})`;
474
+ }
475
+ var MICRO_DRONE_FRAMES = Array.from({ length: 12 }, (_, index) => microDroneFrame(index));
476
+ function renderMicroDroneFrame(tick) {
477
+ const blade = MICRO_BLADES[tick % MICRO_BLADES.length];
478
+ const eye = EYE_FRAMES[Math.floor(tick / 2) % EYE_FRAMES.length];
479
+ return `${ink4("(")}${cyan(blade)}${ink4(")")}${bold(accent(eye))}${ink4("(")}${cyan(blade)}${ink4(")")}`;
480
+ }
481
+
408
482
  // packages/cli/src/commands/_async-ui.ts
409
- var CLACK_SPINNER_FRAMES = ["\u25D2", "\u25D0", "\u25D3", "\u25D1"];
410
483
  var DONE_SYMBOL = pc.green("\u25C7");
411
484
  var FAIL_SYMBOL = pc.red("\u25A0");
412
485
  var activeUpdate = null;
@@ -440,8 +513,8 @@ async function withSpinner(label, work, options = {}) {
440
513
  const spinner = createTtySpinner({
441
514
  label,
442
515
  output,
443
- frames: CLACK_SPINNER_FRAMES,
444
- styleFrame: (frame) => pc.magenta(frame)
516
+ frames: MICRO_DRONE_FRAMES,
517
+ styleFrame: (frame) => renderMicroDroneFrame(Math.max(0, MICRO_DRONE_FRAMES.indexOf(frame)))
445
518
  });
446
519
  const update = (next) => {
447
520
  lastLabel = next;
@@ -482,6 +555,7 @@ function buildOperatorPiEnv(input) {
482
555
  return {
483
556
  PI_CODING_AGENT_SESSION_DIR: input.sessionDir,
484
557
  PI_SKIP_VERSION_CHECK: "1",
558
+ PI_HIDDEN_COMMANDS: "import,fork,clone,tree,new,resume,trust",
485
559
  RIG_PI_OPERATOR_SESSION: "1",
486
560
  RIG_RUN_ID: input.runId,
487
561
  RIG_SERVER_URL: input.serverUrl,
@@ -491,6 +565,10 @@ function buildOperatorPiEnv(input) {
491
565
  }
492
566
  async function prepareOperatorConsole(context, runId, tempSessionDir) {
493
567
  const server = await ensureServerForCli(context.projectRoot);
568
+ const localCwd = join(homedir2(), ".rig", "drones", runId.slice(0, 8));
569
+ mkdirSync2(localCwd, { recursive: true });
570
+ trustDroneCwd(localCwd);
571
+ installRigPiTheme();
494
572
  let sessionFileArg = [];
495
573
  try {
496
574
  const payload = await requestServerJson(context, `/api/runs/${encodeURIComponent(runId)}/session-file`);
@@ -504,7 +582,7 @@ async function prepareOperatorConsole(context, runId, tempSessionDir) {
504
582
  try {
505
583
  const header = JSON.parse(line);
506
584
  if (header.type === "session" && typeof header.cwd === "string") {
507
- return JSON.stringify({ ...header, cwd: process.cwd() });
585
+ return JSON.stringify({ ...header, cwd: localCwd });
508
586
  }
509
587
  } catch {}
510
588
  return line;
@@ -516,6 +594,105 @@ async function prepareOperatorConsole(context, runId, tempSessionDir) {
516
594
  } catch {}
517
595
  return { server, sessionFileArg };
518
596
  }
597
+ var RIG_PI_THEME = {
598
+ $schema: "https://raw.githubusercontent.com/earendil-works/pi/main/packages/coding-agent/src/modes/interactive/theme/theme-schema.json",
599
+ name: "rig",
600
+ vars: {
601
+ acid: "#ccff4d",
602
+ acidDim: "#a9d63f",
603
+ cyan: "#56d8ff",
604
+ red: "#ff5d5d",
605
+ yellow: "#ffd24d",
606
+ ink: "#f2f3f6",
607
+ ink2: "#aeb0ba",
608
+ ink3: "#6c6e79",
609
+ ink4: "#44464f",
610
+ panel: "#101115",
611
+ panelUser: "#14161b",
612
+ toolPending: "#0e1013",
613
+ toolSuccess: "#10150c",
614
+ toolError: "#1a0f0f",
615
+ customMsg: "#0f1410"
616
+ },
617
+ colors: {
618
+ accent: "acid",
619
+ border: "ink4",
620
+ borderAccent: "acid",
621
+ borderMuted: "ink4",
622
+ success: "acid",
623
+ error: "red",
624
+ warning: "yellow",
625
+ muted: "ink3",
626
+ dim: "ink4",
627
+ text: "ink",
628
+ thinkingText: "ink3",
629
+ selectedBg: "panel",
630
+ userMessageBg: "panelUser",
631
+ userMessageText: "ink",
632
+ customMessageBg: "customMsg",
633
+ customMessageText: "ink2",
634
+ customMessageLabel: "acidDim",
635
+ toolPendingBg: "toolPending",
636
+ toolSuccessBg: "toolSuccess",
637
+ toolErrorBg: "toolError",
638
+ toolTitle: "ink",
639
+ toolOutput: "ink3",
640
+ mdHeading: "acid",
641
+ mdLink: "cyan",
642
+ mdLinkUrl: "ink4",
643
+ mdCode: "acidDim",
644
+ mdCodeBlock: "ink2",
645
+ mdCodeBlockBorder: "ink4",
646
+ mdQuote: "ink3",
647
+ mdQuoteBorder: "ink4",
648
+ mdHr: "ink4",
649
+ mdListBullet: "acid",
650
+ toolDiffAdded: "acid",
651
+ toolDiffRemoved: "red",
652
+ toolDiffContext: "ink3",
653
+ syntaxComment: "ink3",
654
+ syntaxKeyword: "cyan",
655
+ syntaxFunction: "acid",
656
+ syntaxVariable: "ink",
657
+ syntaxString: "acidDim",
658
+ syntaxNumber: "yellow",
659
+ syntaxType: "cyan",
660
+ syntaxOperator: "ink2",
661
+ syntaxPunctuation: "ink3",
662
+ thinkingOff: "ink4",
663
+ thinkingMinimal: "ink3",
664
+ thinkingLow: "ink2",
665
+ thinkingMedium: "cyan",
666
+ thinkingHigh: "acidDim",
667
+ thinkingXhigh: "acid",
668
+ bashMode: "cyan"
669
+ }
670
+ };
671
+ function trustDroneCwd(localCwd) {
672
+ try {
673
+ const agentDir = join(homedir2(), ".pi", "agent");
674
+ mkdirSync2(agentDir, { recursive: true });
675
+ const trustPath = join(agentDir, "trust.json");
676
+ const store = existsSync3(trustPath) ? JSON.parse(readFileSync3(trustPath, "utf8")) : {};
677
+ if (store[localCwd] !== true) {
678
+ store[localCwd] = true;
679
+ writeFileSync2(trustPath, `${JSON.stringify(store, null, "\t")}
680
+ `);
681
+ }
682
+ } catch {}
683
+ }
684
+ function installRigPiTheme() {
685
+ try {
686
+ const themesDir = join(homedir2(), ".pi", "agent", "themes");
687
+ mkdirSync2(themesDir, { recursive: true });
688
+ const themePath = join(themesDir, "rig.json");
689
+ const next = `${JSON.stringify(RIG_PI_THEME, null, "\t")}
690
+ `;
691
+ if (!existsSync3(themePath) || readFileSync3(themePath, "utf8") !== next) {
692
+ writeFileSync2(themePath, next);
693
+ }
694
+ } catch {}
695
+ }
519
696
  async function attachRunBundledPiFrontend(context, input) {
520
697
  const tempSessionDir = mkdtempSync(join(tmpdir(), "rig-pi-frontend-sessions-"));
521
698
  const { server, sessionFileArg } = await withSpinner(`Opening Pi console for run ${input.runId}\u2026`, () => prepareOperatorConsole(context, input.runId, tempSessionDir), { outputMode: context.outputMode });
@@ -0,0 +1,42 @@
1
+ export type PiInstallCheck = {
2
+ readonly ok: boolean;
3
+ readonly label: string;
4
+ readonly detail?: string;
5
+ readonly hint?: string;
6
+ };
7
+ export type CommandRunner = (command: string[], options?: {
8
+ cwd?: string;
9
+ }) => Promise<{
10
+ exitCode: number;
11
+ stdout: string;
12
+ stderr: string;
13
+ }>;
14
+ export type PiRigInstallStatus = {
15
+ readonly pi: PiInstallCheck;
16
+ readonly piRig: PiInstallCheck;
17
+ readonly extensionPath: string;
18
+ };
19
+ export declare function resolvePiRigExtensionPath(homeDir: string): string;
20
+ export declare function resolvePiRigPackageSource(projectRoot: string, exists?: (path: string) => boolean): string;
21
+ export declare function checkPiRigInstall(input?: {
22
+ readonly homeDir?: string;
23
+ readonly commandRunner?: CommandRunner;
24
+ readonly exists?: (path: string) => boolean;
25
+ }): Promise<PiRigInstallStatus>;
26
+ export declare function ensurePiRigInstalled(input: {
27
+ readonly projectRoot: string;
28
+ readonly homeDir?: string;
29
+ readonly commandRunner?: CommandRunner;
30
+ }): Promise<PiRigInstallStatus & {
31
+ installedPath: string;
32
+ }>;
33
+ export declare function ensureRemotePiRigInstalled(input: {
34
+ readonly requestJson: (pathname: string, init?: RequestInit) => Promise<unknown>;
35
+ }): Promise<PiRigInstallStatus & {
36
+ readonly remote: true;
37
+ }>;
38
+ export declare function buildPiSetupChecks(input?: {
39
+ readonly homeDir?: string;
40
+ readonly commandRunner?: CommandRunner;
41
+ readonly exists?: (path: string) => boolean;
42
+ }): Promise<PiInstallCheck[]>;
@@ -56,7 +56,7 @@ async function ensurePiBinaryAvailable(input) {
56
56
  }
57
57
  return { ok: true, detail: (current.stdout || current.stderr).trim() || undefined };
58
58
  }
59
- const installCommand = process.env.RIG_PI_INSTALL_COMMAND?.trim() || "bunx @earendil-works/pi@latest install";
59
+ const installCommand = process.env.RIG_PI_INSTALL_COMMAND?.trim() || "bunx @earendil-works/pi-coding-agent@latest install";
60
60
  const parts = splitInstallCommand(installCommand);
61
61
  if (parts.length === 0) {
62
62
  return { ok: false, error: (current.stderr || current.stdout).trim() || "pi --version failed" };
@@ -0,0 +1,8 @@
1
+ import { type RunnerContext } from "../runner";
2
+ import type { PolicyMode } from "@rig/runtime/control-plane/runtime/guard-types";
3
+ export declare function resolveEffectivePolicyMode(context: RunnerContext): PolicyMode;
4
+ export declare function appendControlledBashAudit(context: RunnerContext, mode: PolicyMode, command: string, args: string[], matchedRuleIds: string[], action?: "warn" | "blocked"): void;
5
+ export declare function enforceNativeCommandPolicy(context: RunnerContext, args: string[], options: {
6
+ commandPrefix: string;
7
+ writeAuditLog: boolean;
8
+ }): Promise<void>;
@@ -0,0 +1,22 @@
1
+ import { type RunnerContext } from "../runner";
2
+ export type TaskRunPreflightStatus = "pass" | "warn" | "fail";
3
+ export type TaskRunPreflightCheck = {
4
+ readonly id: string;
5
+ readonly label: string;
6
+ readonly status: TaskRunPreflightStatus;
7
+ readonly detail?: string;
8
+ readonly remediation?: string;
9
+ };
10
+ export type TaskRunPreflightResult = {
11
+ readonly ok: boolean;
12
+ readonly checks: readonly TaskRunPreflightCheck[];
13
+ };
14
+ export type TaskRunPreflightOptions = {
15
+ readonly taskId?: string | null;
16
+ readonly runtimeAdapter?: "claude-code" | "codex" | "pi";
17
+ readonly requestJson?: (pathname: string, init?: RequestInit) => Promise<unknown>;
18
+ };
19
+ export declare function runFastTaskRunPreflight(context: RunnerContext, options?: TaskRunPreflightOptions): Promise<TaskRunPreflightResult>;
20
+ export declare function runProjectMainSyncPreflight(context: RunnerContext, options: {
21
+ disabled: boolean;
22
+ }): Promise<void>;
@@ -305,7 +305,9 @@ ${failure.contextLine}`, 1, { hint: failure.hint });
305
305
  })() : null;
306
306
  if (!response.ok) {
307
307
  const diagnostics = diagnosticMessage(payload);
308
- const detail = diagnostics ?? (text || response.statusText);
308
+ const rawDetail = diagnostics ?? (text || response.statusText);
309
+ const detail = diagnostics ? rawDetail : rawDetail.split(`
310
+ `).map((line) => line.trim()).find((line) => line.length > 0)?.slice(0, 200) ?? response.statusText;
309
311
  const failure = await buildServerFailureContext(context.projectRoot, server);
310
312
  throw new CliError(`Rig server request failed (${response.status}): ${detail}
311
313
  ${failure.contextLine}`, 1, { hint: failure.hint });
@@ -0,0 +1 @@
1
+ export declare function runQuietBinaryProbe(binaryPath: string, args: string[], cwd: string): Promise<boolean>;
@@ -0,0 +1,99 @@
1
+ import { type AuthorityRunPatch, type AuthorityRunRecord } from "@rig/runtime/control-plane/authority-files";
2
+ import type { RunStatus } from "@rig/contracts";
3
+ export type SourceTaskContract = {
4
+ id: string;
5
+ title?: string | null;
6
+ description?: string | null;
7
+ body?: string | null;
8
+ acceptanceCriteria?: string | null;
9
+ acceptance_criteria?: string | null;
10
+ sourceIssueId?: string | null;
11
+ status?: string | null;
12
+ issueType?: string | null;
13
+ role?: string | null;
14
+ externalRef?: string | null;
15
+ scope?: readonly string[];
16
+ validation?: readonly string[];
17
+ validators?: readonly string[];
18
+ labels?: readonly string[];
19
+ };
20
+ export declare function patchAuthorityRun(projectRoot: string, runId: string, patch: AuthorityRunPatch): AuthorityRunRecord;
21
+ /**
22
+ * THE status mutation on the CLI driver side: transition-checked and
23
+ * journaled as a status-changed event (see @rig/contracts run-journal).
24
+ */
25
+ export declare function setRunStatusOrFail(projectRoot: string, runId: string, to: RunStatus, options?: {
26
+ reason?: string | null;
27
+ errorText?: string | null;
28
+ }): AuthorityRunRecord;
29
+ export declare function touchAuthorityRun(projectRoot: string, runId: string): void;
30
+ export declare function appendRunTimeline(projectRoot: string, runId: string, value: Record<string, unknown>): void;
31
+ export declare function appendRunLog(projectRoot: string, runId: string, value: Record<string, unknown>): void;
32
+ type RunActionInput = {
33
+ id: string;
34
+ actionType: string;
35
+ title: string;
36
+ detail?: string | null;
37
+ state: "running" | "completed" | "failed";
38
+ startedAt: string;
39
+ completedAt?: string | null;
40
+ payload?: Record<string, unknown>;
41
+ };
42
+ export declare function appendRunAction(projectRoot: string, runId: string, value: RunActionInput): void;
43
+ export type RunActionHandle = {
44
+ startedAt: string;
45
+ complete: (detail?: string | null, payload?: Record<string, unknown>) => void;
46
+ fail: (detail: string, payload?: Record<string, unknown>) => void;
47
+ };
48
+ export declare function startRunAction(projectRoot: string, runId: string, input: {
49
+ actionId: string;
50
+ actionType: string;
51
+ title: string;
52
+ detail?: string | null;
53
+ payload?: Record<string, unknown>;
54
+ }): RunActionHandle;
55
+ export type RunEvent = {
56
+ type: "status";
57
+ runId: string;
58
+ status: string;
59
+ detail?: string | null;
60
+ sessionId?: string | null;
61
+ } | {
62
+ type: "timeline";
63
+ runId: string;
64
+ } | {
65
+ type: "log";
66
+ runId: string;
67
+ title?: string;
68
+ } | {
69
+ type: "completed";
70
+ runId: string;
71
+ } | {
72
+ type: "failed";
73
+ runId: string;
74
+ error: string;
75
+ };
76
+ /**
77
+ * Route emitServerRunEvent through the run.jsonl lifecycle log + doorbell in
78
+ * addition to stdout. Called once at the start of executeRigOwnedTaskRun.
79
+ */
80
+ export declare function configureRunEventSink(projectRoot: string): void;
81
+ /**
82
+ * Print a parseable status line to stdout that the server's spawn-and-watch
83
+ * path reads to update its own state. Format: `__RIG_RUN_EVENT__<json>`.
84
+ *
85
+ * When `configureRunEventSink` has run, the same event is also appended to
86
+ * the run's `run.jsonl` lifecycle log and the server doorbell is rung.
87
+ */
88
+ export declare function emitServerRunEvent(event: RunEvent): void;
89
+ export declare function buildRunPrompt(input: {
90
+ projectRoot: string;
91
+ taskId?: string;
92
+ fallbackTitle?: string | null;
93
+ fallbackDescription?: string | null;
94
+ fallbackAcceptanceCriteria?: string | null;
95
+ sourceTask?: SourceTaskContract | null;
96
+ initialPrompt?: string;
97
+ runtimeAdapter: "claude-code" | "codex" | "pi";
98
+ }): string;
99
+ export {};
@@ -0,0 +1,24 @@
1
+ import { type AuthorityRunRecord } from "@rig/runtime/control-plane/authority-files";
2
+ export type RunReplayLine = {
3
+ at: string | null;
4
+ source: "run" | "session";
5
+ summary: string;
6
+ };
7
+ export type RunReplayResult = {
8
+ runId: string;
9
+ logPath: string;
10
+ sessionFile: string | null;
11
+ entryCount: number;
12
+ sessionEntryCount: number;
13
+ lines: string[];
14
+ };
15
+ /**
16
+ * Locate the worker Pi session.jsonl for a run, without ever reading the file
17
+ * during the run lifecycle — replay-time only. Prefers the exact
18
+ * piSession.sessionFile recorded on the run record; falls back to scanning
19
+ * `<piSession.cwd>/.rig/session/` for `*_<sessionId>.jsonl`.
20
+ */
21
+ export declare function resolveRunSessionFile(record: AuthorityRunRecord | null): string | null;
22
+ export declare function buildRunReplay(projectRoot: string, runId: string, options?: {
23
+ withSession?: boolean;
24
+ }): RunReplayResult;
@@ -0,0 +1,186 @@
1
+ type ServerPhaseListener = (label: string) => void;
2
+ /** Returns the previously registered listener so scopes can restore it. */
3
+ export declare function setServerPhaseListener(listener: ServerPhaseListener | null): ServerPhaseListener | null;
4
+ export declare function setGitHubBearerTokenForCurrentProcess(token: string | null, projectRoot?: string): void;
5
+ export declare function ensureServerForCli(projectRoot: string): Promise<{
6
+ baseUrl: string;
7
+ authToken: string | null;
8
+ connectionKind: "local" | "remote";
9
+ serverProjectRoot: string | null;
10
+ }>;
11
+ export interface WorkspaceTaskFilters {
12
+ readonly assignee?: string;
13
+ readonly state?: string;
14
+ readonly status?: string;
15
+ readonly limit?: number;
16
+ }
17
+ export type WorkspaceTaskRecord = Record<string, unknown> & {
18
+ readonly id?: unknown;
19
+ readonly title?: unknown;
20
+ readonly status?: unknown;
21
+ };
22
+ export type SubmitTaskRunInput = {
23
+ runId: string;
24
+ taskId?: string;
25
+ title?: string;
26
+ runtimeAdapter: "claude-code" | "codex" | "pi";
27
+ model?: string;
28
+ runtimeMode: string;
29
+ interactionMode: string;
30
+ initialPrompt?: string;
31
+ baselineMode?: "head" | "dirty-snapshot";
32
+ prMode?: "auto" | "ask" | "off";
33
+ };
34
+ export declare function requestServerJson(context: {
35
+ projectRoot: string;
36
+ }, pathname: string, init?: RequestInit): Promise<unknown>;
37
+ export declare function listWorkspaceTasksViaServer(context: {
38
+ projectRoot: string;
39
+ }, filters?: WorkspaceTaskFilters): Promise<WorkspaceTaskRecord[]>;
40
+ export declare function getWorkspaceTaskViaServer(context: {
41
+ projectRoot: string;
42
+ }, taskId: string): Promise<WorkspaceTaskRecord | null>;
43
+ export declare function selectNextWorkspaceTaskViaServer(context: {
44
+ projectRoot: string;
45
+ }, filters?: WorkspaceTaskFilters): Promise<{
46
+ task: WorkspaceTaskRecord | null;
47
+ count: number;
48
+ }>;
49
+ /**
50
+ * Submit a run (task or ad-hoc) to the local rig server. Routes to
51
+ * /api/runs/task vs /api/runs/adhoc based on whether a taskId is provided.
52
+ *
53
+ * Caller is responsible for any pre-flight (e.g. project sync). This helper
54
+ * only performs the POST and surfaces server errors as CliError.
55
+ */
56
+ export declare function getGitHubAuthStatusViaServer(context: {
57
+ projectRoot: string;
58
+ }): Promise<Record<string, unknown>>;
59
+ export declare function postGitHubTokenViaServer(context: {
60
+ projectRoot: string;
61
+ }, token: string, options?: {
62
+ readonly selectedRepo?: string;
63
+ readonly projectRoot?: string;
64
+ }): Promise<Record<string, unknown>>;
65
+ export declare function prepareRemoteCheckoutViaServer(context: {
66
+ projectRoot: string;
67
+ }, input: {
68
+ repoSlug: string;
69
+ checkout: Record<string, unknown>;
70
+ repoUrl?: string;
71
+ baseDir?: string;
72
+ }): Promise<Record<string, unknown>>;
73
+ export declare function registerProjectViaServer(context: {
74
+ projectRoot: string;
75
+ }, input: {
76
+ repoSlug: string;
77
+ checkout?: Record<string, unknown>;
78
+ }): Promise<Record<string, unknown>>;
79
+ export declare function switchServerProjectRootViaServer(context: {
80
+ projectRoot: string;
81
+ }, projectRoot: string, options?: {
82
+ timeoutMs?: number;
83
+ pollMs?: number;
84
+ }): Promise<Record<string, unknown>>;
85
+ export declare function listRunsViaServer(context: {
86
+ projectRoot: string;
87
+ }, options?: {
88
+ limit?: number;
89
+ }): Promise<Record<string, unknown>[]>;
90
+ export declare function getRunDetailsViaServer(context: {
91
+ projectRoot: string;
92
+ }, runId: string): Promise<Record<string, unknown>>;
93
+ export declare function getRunLogsViaServer(context: {
94
+ projectRoot: string;
95
+ }, runId: string, options?: {
96
+ limit?: number;
97
+ cursor?: string;
98
+ }): Promise<Record<string, unknown>>;
99
+ export declare function getRunTimelineViaServer(context: {
100
+ projectRoot: string;
101
+ }, runId: string, options?: {
102
+ limit?: number;
103
+ cursor?: string;
104
+ }): Promise<Record<string, unknown>>;
105
+ export declare function ensureTaskLabelsViaServer(context: {
106
+ projectRoot: string;
107
+ }): Promise<Record<string, unknown>>;
108
+ export declare function listGitHubProjectsViaServer(context: {
109
+ projectRoot: string;
110
+ }, owner: string): Promise<Record<string, unknown>>;
111
+ export declare function getGitHubProjectStatusFieldViaServer(context: {
112
+ projectRoot: string;
113
+ }, projectId: string): Promise<Record<string, unknown>>;
114
+ export declare function updateWorkspaceTaskViaServer(context: {
115
+ projectRoot: string;
116
+ }, input: {
117
+ id: string;
118
+ status?: string;
119
+ comment?: string;
120
+ title?: string;
121
+ body?: string;
122
+ issueNodeId?: string | null;
123
+ }): Promise<Record<string, unknown>>;
124
+ /**
125
+ * Resume (or restart) a run through the selected server — works against the
126
+ * auto-started local daemon AND a remote connection, unlike the old
127
+ * runtime-side path that could only spawn a local engine-checkout server.
128
+ * Without an explicit run id, targets the most recently updated resumable
129
+ * run known to the server.
130
+ */
131
+ export declare function resumeRunViaServer(context: {
132
+ projectRoot: string;
133
+ }, runId: string | null, options: {
134
+ restart: boolean;
135
+ }): Promise<Record<string, unknown>>;
136
+ /** Short human label for the selected server — board/header decoration. */
137
+ export declare function resolveServerConnectionLabel(projectRoot: string): Promise<string>;
138
+ export declare function stopRunViaServer(context: {
139
+ projectRoot: string;
140
+ }, runId: string): Promise<Record<string, unknown>>;
141
+ export declare function steerRunViaServer(context: {
142
+ projectRoot: string;
143
+ }, runId: string, message: string): Promise<Record<string, unknown>>;
144
+ export declare function getRunPiSessionViaServer(context: {
145
+ projectRoot: string;
146
+ }, runId: string): Promise<Record<string, unknown>>;
147
+ export declare function getRunPiMessagesViaServer(context: {
148
+ projectRoot: string;
149
+ }, runId: string): Promise<Record<string, unknown>>;
150
+ export declare function getRunPiStatusViaServer(context: {
151
+ projectRoot: string;
152
+ }, runId: string): Promise<Record<string, unknown>>;
153
+ export declare function getRunPiCommandsViaServer(context: {
154
+ projectRoot: string;
155
+ }, runId: string): Promise<Record<string, unknown>>;
156
+ export declare function getRunPiCapabilitiesViaServer(context: {
157
+ projectRoot: string;
158
+ }, runId: string): Promise<Record<string, unknown>>;
159
+ export declare function sendRunPiPromptViaServer(context: {
160
+ projectRoot: string;
161
+ }, runId: string, text: string, streamingBehavior?: "steer" | "followUp"): Promise<Record<string, unknown>>;
162
+ export declare function sendRunPiShellViaServer(context: {
163
+ projectRoot: string;
164
+ }, runId: string, text: string): Promise<Record<string, unknown>>;
165
+ export declare function runRunPiCommandViaServer(context: {
166
+ projectRoot: string;
167
+ }, runId: string, text: string): Promise<Record<string, unknown>>;
168
+ export declare function respondRunPiExtensionUiViaServer(context: {
169
+ projectRoot: string;
170
+ }, runId: string, requestId: string, valueOrCancel: {
171
+ value?: unknown;
172
+ confirmed?: boolean;
173
+ cancelled?: boolean;
174
+ }): Promise<Record<string, unknown>>;
175
+ export declare function abortRunPiViaServer(context: {
176
+ projectRoot: string;
177
+ }, runId: string): Promise<Record<string, unknown>>;
178
+ export declare function buildRunPiEventsWebSocketUrl(context: {
179
+ projectRoot: string;
180
+ }, runId: string): Promise<string>;
181
+ export declare function submitTaskRunViaServer(context: {
182
+ projectRoot: string;
183
+ }, input: SubmitTaskRunInput): Promise<{
184
+ runId: string;
185
+ }>;
186
+ export {};
@@ -325,7 +325,9 @@ ${failure.contextLine}`, 1, { hint: failure.hint });
325
325
  })() : null;
326
326
  if (!response.ok) {
327
327
  const diagnostics = diagnosticMessage(payload);
328
- const detail = diagnostics ?? (text || response.statusText);
328
+ const rawDetail = diagnostics ?? (text || response.statusText);
329
+ const detail = diagnostics ? rawDetail : rawDetail.split(`
330
+ `).map((line) => line.trim()).find((line) => line.length > 0)?.slice(0, 200) ?? response.statusText;
329
331
  const failure = await buildServerFailureContext(context.projectRoot, server);
330
332
  throw new CliError(`Rig server request failed (${response.status}): ${detail}
331
333
  ${failure.contextLine}`, 1, { hint: failure.hint });