@h-rig/cli 0.0.6-alpha.83 → 0.0.6-alpha.84

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 (163) hide show
  1. package/dist/bin/rig.js +22085 -14618
  2. package/dist/src/app/board.js +155 -28
  3. package/dist/src/app-opentui/adapters/doctor.d.ts +0 -2
  4. package/dist/src/app-opentui/adapters/doctor.js +1 -25
  5. package/dist/src/app-opentui/adapters/family.d.ts +62 -0
  6. package/dist/src/app-opentui/adapters/family.js +14305 -0
  7. package/dist/src/app-opentui/adapters/fleet.d.ts +0 -2
  8. package/dist/src/app-opentui/adapters/fleet.js +6 -40
  9. package/dist/src/app-opentui/adapters/inbox.d.ts +12 -2
  10. package/dist/src/app-opentui/adapters/inbox.js +54 -59
  11. package/dist/src/app-opentui/adapters/init.d.ts +0 -2
  12. package/dist/src/app-opentui/adapters/init.js +0 -26
  13. package/dist/src/app-opentui/adapters/inspect.d.ts +52 -0
  14. package/dist/src/app-opentui/adapters/inspect.js +1024 -0
  15. package/dist/src/app-opentui/adapters/pi-attach.d.ts +15 -6
  16. package/dist/src/app-opentui/adapters/pi-attach.js +348 -93
  17. package/dist/src/app-opentui/adapters/pi.d.ts +23 -0
  18. package/dist/src/app-opentui/adapters/pi.js +363 -0
  19. package/dist/src/app-opentui/adapters/plugin.d.ts +84 -0
  20. package/dist/src/app-opentui/adapters/plugin.js +544 -0
  21. package/dist/src/app-opentui/adapters/repo.d.ts +37 -0
  22. package/dist/src/app-opentui/adapters/repo.js +186 -0
  23. package/dist/src/app-opentui/adapters/run-detail.d.ts +9 -2
  24. package/dist/src/app-opentui/adapters/run-detail.js +97 -44
  25. package/dist/src/app-opentui/adapters/server.d.ts +10 -2
  26. package/dist/src/app-opentui/adapters/server.js +96 -27
  27. package/dist/src/app-opentui/adapters/tasks.d.ts +0 -2
  28. package/dist/src/app-opentui/adapters/tasks.js +437 -105
  29. package/dist/src/app-opentui/adapters/workspace.d.ts +49 -0
  30. package/dist/src/app-opentui/adapters/workspace.js +333 -0
  31. package/dist/src/app-opentui/autocomplete.d.ts +20 -0
  32. package/dist/src/app-opentui/autocomplete.js +576 -0
  33. package/dist/src/app-opentui/bootstrap.js +24296 -16919
  34. package/dist/src/app-opentui/command-palette.d.ts +3 -0
  35. package/dist/src/app-opentui/command-palette.js +1010 -0
  36. package/dist/src/app-opentui/drone.js +8 -6
  37. package/dist/src/app-opentui/fleet-stats.d.ts +32 -0
  38. package/dist/src/app-opentui/fleet-stats.js +114 -0
  39. package/dist/src/app-opentui/index.js +3438 -1724
  40. package/dist/src/app-opentui/intent.js +71 -48
  41. package/dist/src/app-opentui/keymap.d.ts +6 -5
  42. package/dist/src/app-opentui/keymap.js +1064 -23
  43. package/dist/src/app-opentui/layout.d.ts +7 -0
  44. package/dist/src/app-opentui/layout.js +13 -6
  45. package/dist/src/app-opentui/list-search.d.ts +24 -0
  46. package/dist/src/app-opentui/list-search.js +88 -1
  47. package/dist/src/app-opentui/pi-host-child.js +33 -1
  48. package/dist/src/app-opentui/pi-pty-host.d.ts +5 -0
  49. package/dist/src/app-opentui/pi-pty-host.js +21 -3
  50. package/dist/src/app-opentui/react/App.d.ts +9 -0
  51. package/dist/src/app-opentui/react/App.js +5144 -0
  52. package/dist/src/app-opentui/react/Backdrop.d.ts +5 -0
  53. package/dist/src/app-opentui/react/Backdrop.js +1834 -0
  54. package/dist/src/app-opentui/react/ChromeHost.d.ts +5 -0
  55. package/dist/src/app-opentui/react/ChromeHost.js +2942 -0
  56. package/dist/src/app-opentui/react/SceneFrameView.d.ts +7 -0
  57. package/dist/src/app-opentui/react/SceneFrameView.js +529 -0
  58. package/dist/src/app-opentui/react/context.d.ts +17 -0
  59. package/dist/src/app-opentui/react/context.js +37 -0
  60. package/dist/src/app-opentui/react/launch.d.ts +2 -0
  61. package/dist/src/app-opentui/react/launch.js +5743 -0
  62. package/dist/src/app-opentui/react/nav.d.ts +18 -0
  63. package/dist/src/app-opentui/react/nav.js +54 -0
  64. package/dist/src/app-opentui/react/scroll.d.ts +12 -0
  65. package/dist/src/app-opentui/react/scroll.js +21 -0
  66. package/dist/src/app-opentui/react/syntax.d.ts +2 -0
  67. package/dist/src/app-opentui/react/syntax.js +64 -0
  68. package/dist/src/app-opentui/registry.js +19923 -5151
  69. package/dist/src/app-opentui/render/constants.d.ts +31 -0
  70. package/dist/src/app-opentui/render/constants.js +66 -0
  71. package/dist/src/app-opentui/render/graphics.d.ts +2 -1
  72. package/dist/src/app-opentui/render/graphics.js +106 -39
  73. package/dist/src/app-opentui/render/image-visual-layer-worker.js +108 -20
  74. package/dist/src/app-opentui/render/image-visual-layer.d.ts +7 -0
  75. package/dist/src/app-opentui/render/image-visual-layer.js +109 -20
  76. package/dist/src/app-opentui/render/native-host.d.ts +37 -0
  77. package/dist/src/app-opentui/render/native-host.js +179 -0
  78. package/dist/src/app-opentui/render/panels.js +18 -11
  79. package/dist/src/app-opentui/render/preloader.js +8 -6
  80. package/dist/src/app-opentui/render/scene.d.ts +50 -1
  81. package/dist/src/app-opentui/render/scene.js +183 -6
  82. package/dist/src/app-opentui/render/text.d.ts +7 -1
  83. package/dist/src/app-opentui/render/text.js +10 -7
  84. package/dist/src/app-opentui/render/type-bar.js +69 -30
  85. package/dist/src/app-opentui/runtime.d.ts +44 -1
  86. package/dist/src/app-opentui/runtime.js +3231 -1363
  87. package/dist/src/app-opentui/scenes/command.js +20 -6
  88. package/dist/src/app-opentui/scenes/doctor.js +176 -11
  89. package/dist/src/app-opentui/scenes/error.js +20 -10
  90. package/dist/src/app-opentui/scenes/family-domains/agent.d.ts +2 -0
  91. package/dist/src/app-opentui/scenes/family-domains/agent.js +348 -0
  92. package/dist/src/app-opentui/scenes/family-domains/browser.d.ts +2 -0
  93. package/dist/src/app-opentui/scenes/family-domains/browser.js +195 -0
  94. package/dist/src/app-opentui/scenes/family-domains/dist.d.ts +2 -0
  95. package/dist/src/app-opentui/scenes/family-domains/dist.js +243 -0
  96. package/dist/src/app-opentui/scenes/family-domains/git.d.ts +2 -0
  97. package/dist/src/app-opentui/scenes/family-domains/git.js +195 -0
  98. package/dist/src/app-opentui/scenes/family-domains/github.d.ts +2 -0
  99. package/dist/src/app-opentui/scenes/family-domains/github.js +274 -0
  100. package/dist/src/app-opentui/scenes/family-domains/harness.d.ts +2 -0
  101. package/dist/src/app-opentui/scenes/family-domains/harness.js +152 -0
  102. package/dist/src/app-opentui/scenes/family-domains/index.d.ts +4 -0
  103. package/dist/src/app-opentui/scenes/family-domains/index.js +1679 -0
  104. package/dist/src/app-opentui/scenes/family-domains/kit.d.ts +76 -0
  105. package/dist/src/app-opentui/scenes/family-domains/kit.js +305 -0
  106. package/dist/src/app-opentui/scenes/family-domains/profile.d.ts +2 -0
  107. package/dist/src/app-opentui/scenes/family-domains/profile.js +212 -0
  108. package/dist/src/app-opentui/scenes/family-domains/queue.d.ts +2 -0
  109. package/dist/src/app-opentui/scenes/family-domains/queue.js +146 -0
  110. package/dist/src/app-opentui/scenes/family-domains/remote.d.ts +2 -0
  111. package/dist/src/app-opentui/scenes/family-domains/remote.js +518 -0
  112. package/dist/src/app-opentui/scenes/family-domains/review.d.ts +2 -0
  113. package/dist/src/app-opentui/scenes/family-domains/review.js +280 -0
  114. package/dist/src/app-opentui/scenes/family-domains/setup.d.ts +2 -0
  115. package/dist/src/app-opentui/scenes/family-domains/setup.js +267 -0
  116. package/dist/src/app-opentui/scenes/family-domains/stats.d.ts +2 -0
  117. package/dist/src/app-opentui/scenes/family-domains/stats.js +370 -0
  118. package/dist/src/app-opentui/scenes/family.d.ts +3 -0
  119. package/dist/src/app-opentui/scenes/family.js +2144 -0
  120. package/dist/src/app-opentui/scenes/fleet.js +521 -31
  121. package/dist/src/app-opentui/scenes/handoff.js +204 -12
  122. package/dist/src/app-opentui/scenes/help.js +609 -40
  123. package/dist/src/app-opentui/scenes/inbox.js +278 -17
  124. package/dist/src/app-opentui/scenes/init.js +84 -39
  125. package/dist/src/app-opentui/scenes/inspect.d.ts +3 -0
  126. package/dist/src/app-opentui/scenes/inspect.js +793 -0
  127. package/dist/src/app-opentui/scenes/main.js +218 -39
  128. package/dist/src/app-opentui/scenes/pi.d.ts +3 -0
  129. package/dist/src/app-opentui/scenes/pi.js +508 -0
  130. package/dist/src/app-opentui/scenes/plugin.d.ts +3 -0
  131. package/dist/src/app-opentui/scenes/plugin.js +486 -0
  132. package/dist/src/app-opentui/scenes/repo.d.ts +3 -0
  133. package/dist/src/app-opentui/scenes/repo.js +424 -0
  134. package/dist/src/app-opentui/scenes/run-detail.js +333 -20
  135. package/dist/src/app-opentui/scenes/server.js +181 -15
  136. package/dist/src/app-opentui/scenes/tasks.js +486 -31
  137. package/dist/src/app-opentui/scenes/workspace.d.ts +3 -0
  138. package/dist/src/app-opentui/scenes/workspace.js +426 -0
  139. package/dist/src/app-opentui/selectable.d.ts +19 -0
  140. package/dist/src/app-opentui/selectable.js +79 -0
  141. package/dist/src/app-opentui/state.js +83 -30
  142. package/dist/src/app-opentui/surface-catalog.d.ts +20 -0
  143. package/dist/src/app-opentui/surface-catalog.js +540 -0
  144. package/dist/src/app-opentui/theme.d.ts +28 -6
  145. package/dist/src/app-opentui/theme.js +61 -8
  146. package/dist/src/app-opentui/types.d.ts +121 -4
  147. package/dist/src/commands/_authority-runs.d.ts +1 -1
  148. package/dist/src/commands/_authority-runs.js +2 -12
  149. package/dist/src/commands/_help-catalog.js +95 -15
  150. package/dist/src/commands/_operator-view.js +34 -2
  151. package/dist/src/commands/_pi-frontend.d.ts +2 -0
  152. package/dist/src/commands/_pi-frontend.js +34 -0
  153. package/dist/src/commands/_server-events.d.ts +26 -0
  154. package/dist/src/commands/_server-events.js +310 -0
  155. package/dist/src/commands/agent.js +2 -12
  156. package/dist/src/commands/run.js +34 -2
  157. package/dist/src/commands/server.js +2 -12
  158. package/dist/src/commands/stats.js +95 -15
  159. package/dist/src/commands/task-run-driver.js +2 -12
  160. package/dist/src/commands/task.js +131 -29
  161. package/dist/src/commands.js +192 -31
  162. package/dist/src/index.js +192 -31
  163. package/package.json +11 -9
@@ -1,4 +1,3 @@
1
- import type { AppAdapter } from "../types";
2
1
  import { type AppAdapterContext } from "./common";
3
2
  export type AppRunRecord = {
4
3
  readonly runId: string;
@@ -12,5 +11,4 @@ export declare function normalizeRunRecord(record: Record<string, unknown>): App
12
11
  export declare function refreshFleet(ctx: AppAdapterContext, options?: {
13
12
  readonly limit?: number;
14
13
  }): Promise<AppRunRecord[]>;
15
- export declare function createFleetAdapter(): AppAdapter;
16
14
  export declare function stopFleetRun(ctx: AppAdapterContext, runId: string): Promise<Record<string, unknown>>;
@@ -767,15 +767,6 @@ var init__server_client = __esm(() => {
767
767
  });
768
768
 
769
769
  // packages/cli/src/app-opentui/adapters/common.ts
770
- function adapterContextFromRuntime(runtime, renderer) {
771
- return {
772
- projectRoot: runtime.getState().projectRoot,
773
- renderer,
774
- ensureRuntime: () => runtime.getRunnerContext(),
775
- emit: (event) => runtime.emit(event),
776
- getState: () => runtime.getState()
777
- };
778
- }
779
770
  function projectRootOf(ctx) {
780
771
  const root = ctx.rig?.projectRoot ?? ctx.projectRoot ?? ctx.getState().projectRoot;
781
772
  if (typeof root === "string" && root.trim())
@@ -836,10 +827,6 @@ function compactRecord(record, keys) {
836
827
  }
837
828
  return out;
838
829
  }
839
- function payloadString(intent, key) {
840
- const value = intent.action.payload?.[key];
841
- return typeof value === "string" && value.trim() ? value.trim() : undefined;
842
- }
843
830
 
844
831
  // packages/cli/src/app-opentui/adapters/fleet.ts
845
832
  function normalizeRunRecord(record) {
@@ -873,7 +860,7 @@ async function refreshFleet(ctx, options = {}) {
873
860
  const entry = normalizeRunRecord(run);
874
861
  return entry ? [entry] : [];
875
862
  });
876
- patchData(ctx, { fleet: { runs: normalized, refreshedAt: new Date().toISOString() } });
863
+ patchData(ctx, { fleet: { runs: normalized, refreshedAt: new Date().toISOString() }, lastRefreshError: undefined });
877
864
  patchFooter(ctx, { server: serverLabel, runs: String(normalized.length) });
878
865
  emitCompleted(ctx, label, { count: normalized.length });
879
866
  return normalized;
@@ -882,29 +869,6 @@ async function refreshFleet(ctx, options = {}) {
882
869
  throw error;
883
870
  }
884
871
  }
885
- function createFleetAdapter() {
886
- return {
887
- id: "fleet",
888
- async handleIntent(runtime, intent) {
889
- if (intent.scene !== "fleet" && intent.action.kind !== "run-stop")
890
- return false;
891
- const ctx = adapterContextFromRuntime(runtime);
892
- if (intent.action.kind === "run-stop") {
893
- const runId = payloadString(intent, "runId");
894
- if (runId)
895
- await stopFleetRun(ctx, runId);
896
- else
897
- await refreshFleet(ctx, { limit: 50 });
898
- return true;
899
- }
900
- if (intent.action.kind === "refresh" || intent.action.kind === "navigate") {
901
- await refreshFleet(ctx, { limit: 50 });
902
- return true;
903
- }
904
- return false;
905
- }
906
- };
907
- }
908
872
  async function stopFleetRun(ctx, runId) {
909
873
  const cleanRunId = runId.trim();
910
874
  const label = `Stopping ${cleanRunId.slice(0, 8)}`;
@@ -923,7 +887,10 @@ async function stopFleetRun(ctx, runId) {
923
887
  const { stopRunViaServer: stopRunViaServer2 } = await Promise.resolve().then(() => (init__server_client(), exports__server_client));
924
888
  const result = await stopRunViaServer2({ projectRoot: projectRootOf(ctx) }, cleanRunId);
925
889
  emitCompleted(ctx, label, { runId: cleanRunId, result: compactRecord(result, ["ok", "runId", "status", "stopped"]) });
926
- await refreshFleet(ctx, { limit: 50 }).catch(() => []);
890
+ await refreshFleet(ctx, { limit: 50 }).catch((error) => {
891
+ patchData(ctx, { lastRefreshError: normalizeAppError(error).message });
892
+ return [];
893
+ });
927
894
  return result;
928
895
  } catch (error) {
929
896
  emitFailed(ctx, label, error, { runId: cleanRunId, revert: { status: "unknown" } });
@@ -933,6 +900,5 @@ async function stopFleetRun(ctx, runId) {
933
900
  export {
934
901
  stopFleetRun,
935
902
  refreshFleet,
936
- normalizeRunRecord,
937
- createFleetAdapter
903
+ normalizeRunRecord
938
904
  };
@@ -1,7 +1,11 @@
1
- import type { AppAdapter } from "../types";
2
1
  import { type AppAdapterContext } from "./common";
3
- export declare function createInboxAdapter(): AppAdapter;
4
2
  export type AppInboxKind = "approvals" | "inputs";
3
+ /** One key/value fact extracted from the request payload (tool, command, an
4
+ * argument) so the operator sees WHAT they are approving, not just a glyph. */
5
+ export type AppInboxDetail = {
6
+ readonly label: string;
7
+ readonly value: string;
8
+ };
5
9
  export type AppInboxRecord = {
6
10
  readonly kind: AppInboxKind;
7
11
  readonly runId: string;
@@ -9,6 +13,12 @@ export type AppInboxRecord = {
9
13
  readonly taskId?: string;
10
14
  readonly status: string;
11
15
  readonly title: string;
16
+ /** Structured facts (tool name, command, args, prompt) pulled from the
17
+ * request payload — rendered under the title before the action rows. */
18
+ readonly details: readonly AppInboxDetail[];
19
+ /** A unified diff / multi-line preview from the payload, if present, so a
20
+ * blocking edit/patch is reviewed in full rather than approved blind. */
21
+ readonly diff?: string;
12
22
  readonly raw: Record<string, unknown>;
13
23
  };
14
24
  export declare function normalizeInboxRecord(kind: AppInboxKind, record: Record<string, unknown>): AppInboxRecord | null;
@@ -1309,15 +1309,6 @@ var init_inbox = __esm(() => {
1309
1309
  });
1310
1310
 
1311
1311
  // packages/cli/src/app-opentui/adapters/common.ts
1312
- function adapterContextFromRuntime(runtime, renderer) {
1313
- return {
1314
- projectRoot: runtime.getState().projectRoot,
1315
- renderer,
1316
- ensureRuntime: () => runtime.getRunnerContext(),
1317
- emit: (event) => runtime.emit(event),
1318
- getState: () => runtime.getState()
1319
- };
1320
- }
1321
1312
  function projectRootOf(ctx) {
1322
1313
  const root = ctx.rig?.projectRoot ?? ctx.projectRoot ?? ctx.getState().projectRoot;
1323
1314
  if (typeof root === "string" && root.trim())
@@ -1369,56 +1360,52 @@ function stringField(record, keys, fallback = "") {
1369
1360
  }
1370
1361
  return fallback;
1371
1362
  }
1372
- function payloadString(intent, key) {
1373
- const value = intent.action.payload?.[key];
1374
- return typeof value === "string" && value.trim() ? value.trim() : undefined;
1375
- }
1376
1363
 
1377
1364
  // packages/cli/src/app-opentui/adapters/inbox.ts
1378
- function createInboxAdapter() {
1379
- return {
1380
- id: "inbox",
1381
- async handleIntent(runtime, intent) {
1382
- if (intent.scene !== "inbox" && !intent.action.kind.startsWith("inbox-"))
1383
- return false;
1384
- const ctx = adapterContextFromRuntime(runtime);
1385
- if (intent.action.kind === "inbox-approve" || intent.action.kind === "inbox-reject") {
1386
- const requestId = payloadString(intent, "requestId");
1387
- let match = requestId ? findInboxRecord(ctx, "approvals", requestId) : null;
1388
- if (requestId && !match)
1389
- match = findInRecords((await refreshInbox(ctx)).approvals, requestId);
1390
- if (requestId && match) {
1391
- await resolveApproval(ctx, { runId: match.runId, requestId: match.requestId, decision: intent.action.kind === "inbox-approve" ? "approve" : "reject" });
1392
- return true;
1393
- }
1394
- }
1395
- if (intent.action.kind === "inbox-answer") {
1396
- const requestId = payloadString(intent, "requestId");
1397
- let match = requestId ? findInboxRecord(ctx, "inputs", requestId) : null;
1398
- if (requestId && !match)
1399
- match = findInRecords((await refreshInbox(ctx)).inputs, requestId);
1400
- const answer = payloadString(intent, "answer");
1401
- if (requestId && match && answer) {
1402
- await answerInputRequest(ctx, { runId: match.runId, requestId: match.requestId, answers: { answer } });
1403
- return true;
1404
- }
1405
- }
1406
- await refreshInbox(ctx);
1407
- return true;
1408
- }
1409
- };
1365
+ function asObject(value) {
1366
+ return value && typeof value === "object" && !Array.isArray(value) ? value : null;
1410
1367
  }
1411
- function findInRecords(records, requestId) {
1412
- return records.find((record) => record.requestId === requestId || record.requestId.startsWith(requestId)) ?? null;
1368
+ function payloadOf(nested) {
1369
+ return asObject(nested.payload) ?? nested;
1413
1370
  }
1414
- function findInboxRecord(ctx, kind, requestId) {
1415
- const inbox = ctx.getState().data?.inbox;
1416
- if (!inbox || typeof inbox !== "object" || Array.isArray(inbox))
1371
+ function formatArgs(value) {
1372
+ if (value === undefined || value === null)
1417
1373
  return null;
1418
- const records = inbox[kind];
1419
- if (!Array.isArray(records))
1374
+ if (typeof value === "string")
1375
+ return value.trim() ? value.trim().replace(/\s+/g, " ").slice(0, 200) : null;
1376
+ if (typeof value === "number" || typeof value === "boolean")
1377
+ return String(value);
1378
+ try {
1379
+ const json = JSON.stringify(value);
1380
+ return json && json !== "{}" && json !== "[]" ? json.slice(0, 200) : null;
1381
+ } catch {
1420
1382
  return null;
1421
- return findInRecords(records, requestId);
1383
+ }
1384
+ }
1385
+ function extractInboxFacts(kind, nested) {
1386
+ const payload = payloadOf(nested);
1387
+ const details = [];
1388
+ const tool = stringField(payload, ["toolName", "tool", "name", "action", "actionId"]) || stringField(nested, ["toolName", "tool", "requestKind", "actionId"]);
1389
+ if (tool)
1390
+ details.push({ label: "tool", value: tool });
1391
+ const command = stringField(payload, ["command", "cmd", "commandLine", "commandString", "shell", "script"]);
1392
+ if (command)
1393
+ details.push({ label: "command", value: command.replace(/\s+/g, " ").slice(0, 200) });
1394
+ const argsValue = payload.args ?? payload.arguments ?? payload.input ?? payload.params ?? payload.parameters;
1395
+ const args = formatArgs(argsValue);
1396
+ if (args)
1397
+ details.push({ label: "args", value: args });
1398
+ const path = stringField(payload, ["path", "file", "filePath", "target"]);
1399
+ if (path)
1400
+ details.push({ label: "path", value: path });
1401
+ const prompt = stringField(payload, ["prompt", "message", "reason", "question", "description"]) || stringField(nested, ["prompt", "message", "reason"]);
1402
+ if (prompt)
1403
+ details.push({ label: kind === "inputs" ? "prompt" : "reason", value: prompt.replace(/\s+/g, " ").slice(0, 240) });
1404
+ const diffRaw = stringField(payload, ["diff", "patch", "preview", "content"]);
1405
+ const diff = diffRaw && diffRaw.includes(`
1406
+ `) ? diffRaw : diffRaw || undefined;
1407
+ const title = tool && command ? `${tool} \xB7 ${command.replace(/\s+/g, " ").slice(0, 80)}` : command || tool || stringField(nested, ["title"]) || prompt || (kind === "approvals" ? "approval request" : "input request");
1408
+ return { title, details, ...diff ? { diff } : {} };
1422
1409
  }
1423
1410
  function normalizeInboxRecord(kind, record) {
1424
1411
  const runId = stringField(record, ["runId"]);
@@ -1426,14 +1413,17 @@ function normalizeInboxRecord(kind, record) {
1426
1413
  if (!runId || !requestId)
1427
1414
  return null;
1428
1415
  const taskId = stringField(record, ["taskId"]);
1429
- const nested = record.record && typeof record.record === "object" && !Array.isArray(record.record) ? record.record : {};
1416
+ const nested = asObject(record.record) ?? {};
1417
+ const facts = extractInboxFacts(kind, nested);
1430
1418
  return {
1431
1419
  kind,
1432
1420
  runId,
1433
1421
  requestId,
1434
1422
  status: stringField(record, ["status"], "pending"),
1435
- title: stringField(nested, ["title", "prompt", "message", "toolName"], kind === "approvals" ? "approval request" : "input request"),
1423
+ title: facts.title,
1424
+ details: facts.details,
1436
1425
  raw: record,
1426
+ ...facts.diff ? { diff: facts.diff } : {},
1437
1427
  ...taskId ? { taskId } : {}
1438
1428
  };
1439
1429
  }
@@ -1456,7 +1446,7 @@ async function refreshInbox(ctx, filters = {}) {
1456
1446
  const normalized = normalizeInboxRecord("inputs", entry);
1457
1447
  return normalized ? [normalized] : [];
1458
1448
  });
1459
- patchData(ctx, { inbox: { approvals, inputs, refreshedAt: new Date().toISOString() } });
1449
+ patchData(ctx, { inbox: { approvals, inputs, refreshedAt: new Date().toISOString() }, lastRefreshError: undefined });
1460
1450
  patchFooter(ctx, { inbox: `${approvals.length + inputs.length} pending` });
1461
1451
  emitCompleted(ctx, label, { approvals: approvals.length, inputs: inputs.length });
1462
1452
  return { approvals, inputs };
@@ -1480,7 +1470,10 @@ async function resolveApproval(ctx, input) {
1480
1470
  });
1481
1471
  const record = result && typeof result === "object" && !Array.isArray(result) ? result : { ok: true };
1482
1472
  emitCompleted(ctx, label, { runId: input.runId, requestId: input.requestId, decision: input.decision, result: record });
1483
- await refreshInbox(ctx).catch(() => ({ approvals: [], inputs: [] }));
1473
+ await refreshInbox(ctx).catch((error) => {
1474
+ patchData(ctx, { lastRefreshError: normalizeAppError(error).message });
1475
+ return { approvals: [], inputs: [] };
1476
+ });
1484
1477
  return record;
1485
1478
  } catch (error) {
1486
1479
  emitFailed(ctx, label, error, { runId: input.runId, requestId: input.requestId, revert: { status: "pending" } });
@@ -1502,7 +1495,10 @@ async function answerInputRequest(ctx, input) {
1502
1495
  });
1503
1496
  const record = result && typeof result === "object" && !Array.isArray(result) ? result : { ok: true };
1504
1497
  emitCompleted(ctx, label, { runId: input.runId, requestId: input.requestId, result: record });
1505
- await refreshInbox(ctx).catch(() => ({ approvals: [], inputs: [] }));
1498
+ await refreshInbox(ctx).catch((error) => {
1499
+ patchData(ctx, { lastRefreshError: normalizeAppError(error).message });
1500
+ return { approvals: [], inputs: [] };
1501
+ });
1506
1502
  return record;
1507
1503
  } catch (error) {
1508
1504
  emitFailed(ctx, label, error, { runId: input.runId, requestId: input.requestId, revert: { status: "pending" } });
@@ -1513,6 +1509,5 @@ export {
1513
1509
  resolveApproval,
1514
1510
  refreshInbox,
1515
1511
  normalizeInboxRecord,
1516
- createInboxAdapter,
1517
1512
  answerInputRequest
1518
1513
  };
@@ -1,6 +1,4 @@
1
- import type { AppAdapter } from "../types";
2
1
  import { type AppAdapterContext } from "./common";
3
- export declare function createInitAdapter(): AppAdapter;
4
2
  export type InitFactState = {
5
3
  readonly hasConfig: boolean;
6
4
  readonly configPath?: string;
@@ -2267,15 +2267,6 @@ import { existsSync as existsSync6 } from "fs";
2267
2267
  import { resolve as resolve7 } from "path";
2268
2268
 
2269
2269
  // packages/cli/src/app-opentui/adapters/common.ts
2270
- function adapterContextFromRuntime(runtime, renderer) {
2271
- return {
2272
- projectRoot: runtime.getState().projectRoot,
2273
- renderer,
2274
- ensureRuntime: () => runtime.getRunnerContext(),
2275
- emit: (event) => runtime.emit(event),
2276
- getState: () => runtime.getState()
2277
- };
2278
- }
2279
2270
  function projectRootOf(ctx) {
2280
2271
  const root = ctx.rig?.projectRoot ?? ctx.projectRoot ?? ctx.getState().projectRoot;
2281
2272
  if (typeof root === "string" && root.trim())
@@ -2349,22 +2340,6 @@ async function captureConsole(fn) {
2349
2340
  }
2350
2341
 
2351
2342
  // packages/cli/src/app-opentui/adapters/init.ts
2352
- function createInitAdapter() {
2353
- return {
2354
- id: "init",
2355
- async handleIntent(runtime, intent) {
2356
- if (intent.scene !== "init" && intent.action.kind !== "init-start")
2357
- return false;
2358
- const ctx = adapterContextFromRuntime(runtime);
2359
- if (intent.action.kind === "init-start") {
2360
- await runInitYes(ctx, intent.argv.slice(1));
2361
- return true;
2362
- }
2363
- await loadInitFacts(ctx);
2364
- return true;
2365
- }
2366
- };
2367
- }
2368
2343
  function readInitFacts(ctx) {
2369
2344
  const projectRoot = projectRootOf(ctx);
2370
2345
  const configNames = ["rig.config.ts", "rig.config.mts", "rig.config.json"];
@@ -2416,6 +2391,5 @@ export {
2416
2391
  runInitYes,
2417
2392
  readInitFacts,
2418
2393
  loadInitFacts,
2419
- createInitAdapter,
2420
2394
  buildInitTypeBarSuggestions
2421
2395
  };
@@ -0,0 +1,52 @@
1
+ import { type AppAdapterContext } from "./common";
2
+ export type InspectView = "logs" | "timeline" | "artifacts" | "artifact" | "diff" | "failures" | "graph" | "audit";
3
+ export declare const INSPECT_VIEWS: readonly InspectView[];
4
+ export type AppInspectArtifact = {
5
+ readonly name: string;
6
+ readonly path: string;
7
+ readonly sizeBytes: number;
8
+ readonly isDir: boolean;
9
+ };
10
+ export type AppInspectRunOption = {
11
+ readonly runId: string;
12
+ readonly status: string;
13
+ readonly title: string;
14
+ readonly taskId?: string;
15
+ readonly updatedAt?: string;
16
+ };
17
+ export type AppInspectSnapshot = {
18
+ readonly runId: string;
19
+ readonly taskId?: string;
20
+ readonly status: string;
21
+ readonly title: string;
22
+ readonly logs: readonly Record<string, unknown>[];
23
+ readonly timeline: readonly Record<string, unknown>[];
24
+ /** Unified diff text for the run's working changes (git diff), or "". */
25
+ readonly diff: string;
26
+ /** Log/timeline entries whose status reads as a failure, for the failures tab. */
27
+ readonly failures: readonly Record<string, unknown>[];
28
+ /** Artifact files for the run's task (resolveTaskArtifactDirs), for the artifacts tab. */
29
+ readonly artifacts: readonly AppInspectArtifact[];
30
+ /** Contents of the currently-selected artifact file, for the artifact tab. */
31
+ readonly artifactView?: {
32
+ readonly name: string;
33
+ readonly contents: string;
34
+ readonly truncated: boolean;
35
+ readonly sizeBytes: number;
36
+ };
37
+ /** Task graph (`br list --pretty`) text, for the graph tab. */
38
+ readonly graph: string;
39
+ readonly graphError?: string;
40
+ /** Last audit.jsonl entries, for the audit tab. */
41
+ readonly audit: readonly Record<string, unknown>[];
42
+ readonly refreshedAt: number;
43
+ readonly diffError?: string;
44
+ readonly artifactsError?: string;
45
+ };
46
+ /** The run PICKER data: recent runs the operator can pick to inspect in-place,
47
+ * patched into state.data.inspectRuns. Sourced from the same server run list the
48
+ * runs scene uses — but rendered as inspect targets, never bouncing scenes. */
49
+ export declare function loadInspectRuns(ctx: AppAdapterContext, options?: {
50
+ readonly limit?: number;
51
+ }): Promise<readonly AppInspectRunOption[]>;
52
+ export declare function loadInspect(ctx: AppAdapterContext, runId: string): Promise<AppInspectSnapshot>;