@h-rig/cli 0.0.6-alpha.90 → 0.0.6-alpha.92

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 (118) hide show
  1. package/README.md +18 -19
  2. package/dist/bin/build-rig-binaries.js +22 -10
  3. package/dist/bin/rig.d.ts +71 -1
  4. package/dist/bin/rig.js +15078 -11169
  5. package/dist/config/rig-default-config.yml +5 -0
  6. package/dist/src/app/drone-ui.d.ts +11 -14
  7. package/dist/src/app/drone-ui.js +70 -86
  8. package/dist/src/commands/_async-ui.d.ts +1 -4
  9. package/dist/src/commands/_async-ui.js +9 -111
  10. package/dist/src/commands/_cli-format.d.ts +16 -9
  11. package/dist/src/commands/_cli-format.js +167 -295
  12. package/dist/src/commands/_connection-state.d.ts +11 -1
  13. package/dist/src/commands/_connection-state.js +50 -5
  14. package/dist/src/commands/_doctor-checks.d.ts +0 -6
  15. package/dist/src/commands/_doctor-checks.js +79 -382
  16. package/dist/src/commands/_help-catalog.d.ts +1 -1
  17. package/dist/src/commands/_help-catalog.js +217 -157
  18. package/dist/src/commands/_inprocess-services.d.ts +33 -0
  19. package/dist/src/commands/_inprocess-services.js +102 -0
  20. package/dist/src/commands/_json-output.js +4 -0
  21. package/dist/src/commands/_lazy-reconcile.d.ts +34 -0
  22. package/dist/src/commands/_lazy-reconcile.js +102 -0
  23. package/dist/src/commands/_paths.js +1 -1
  24. package/dist/src/commands/_pi-frontend.d.ts +18 -10
  25. package/dist/src/commands/_pi-frontend.js +37 -715
  26. package/dist/src/commands/_pi-install.js +18 -36
  27. package/dist/src/commands/_policy.d.ts +1 -1
  28. package/dist/src/commands/_policy.js +56 -15
  29. package/dist/src/commands/_run-bridge.d.ts +114 -0
  30. package/dist/src/commands/_run-bridge.js +387 -0
  31. package/dist/src/commands/_run-diagnostics.d.ts +9 -0
  32. package/dist/src/commands/_run-diagnostics.js +51 -0
  33. package/dist/src/commands/_run-driver-helpers.d.ts +8 -81
  34. package/dist/src/commands/_run-driver-helpers.js +79 -283
  35. package/dist/src/commands/_run-projection.d.ts +50 -0
  36. package/dist/src/commands/_run-projection.js +349 -0
  37. package/dist/src/commands/_run-subcommands.d.ts +3 -0
  38. package/dist/src/commands/_run-subcommands.js +31 -0
  39. package/dist/src/commands/_spinner.js +1 -1
  40. package/dist/src/commands/agent.d.ts +1 -1
  41. package/dist/src/commands/agent.js +8559 -239
  42. package/dist/src/commands/dist.d.ts +1 -1
  43. package/dist/src/commands/dist.js +27 -19
  44. package/dist/src/commands/doctor.d.ts +1 -1
  45. package/dist/src/commands/doctor.js +93 -475
  46. package/dist/src/commands/github.d.ts +1 -1
  47. package/dist/src/commands/github.js +113 -387
  48. package/dist/src/commands/inbox.d.ts +22 -24
  49. package/dist/src/commands/inbox.js +420 -691
  50. package/dist/src/commands/init.d.ts +6 -16
  51. package/dist/src/commands/init.js +334 -971
  52. package/dist/src/commands/inspect.d.ts +19 -2
  53. package/dist/src/commands/inspect.js +644 -610
  54. package/dist/src/commands/pi.d.ts +1 -1
  55. package/dist/src/commands/plugin.d.ts +1 -1
  56. package/dist/src/commands/plugin.js +486 -7
  57. package/dist/src/commands/profile-and-review.d.ts +1 -1
  58. package/dist/src/commands/profile-and-review.js +94 -56
  59. package/dist/src/commands/queue.js +1 -21
  60. package/dist/src/commands/remote.d.ts +1 -1
  61. package/dist/src/commands/remote.js +837 -14
  62. package/dist/src/commands/repo-git-harness.d.ts +1 -1
  63. package/dist/src/commands/repo-git-harness.js +57 -14
  64. package/dist/src/commands/run.d.ts +20 -2
  65. package/dist/src/commands/run.js +17579 -1759
  66. package/dist/src/commands/server.d.ts +2 -6
  67. package/dist/src/commands/server.js +141 -723
  68. package/dist/src/commands/setup.d.ts +1 -1
  69. package/dist/src/commands/setup.js +102 -484
  70. package/dist/src/commands/stats.d.ts +13 -10
  71. package/dist/src/commands/stats.js +689 -761
  72. package/dist/src/commands/task-run-driver.d.ts +50 -88
  73. package/dist/src/commands/task-run-driver.js +116 -2717
  74. package/dist/src/commands/task.d.ts +34 -13
  75. package/dist/src/commands/task.js +668 -2523
  76. package/dist/src/commands/test.d.ts +1 -1
  77. package/dist/src/commands/triage.d.ts +11 -0
  78. package/dist/src/commands/triage.js +227 -0
  79. package/dist/src/commands/workspace.d.ts +1 -1
  80. package/dist/src/commands.d.ts +0 -16
  81. package/dist/src/commands.js +16657 -12250
  82. package/dist/src/index.js +16528 -12497
  83. package/dist/src/launcher.js +4 -0
  84. package/dist/src/operator-cli.d.ts +2 -0
  85. package/dist/src/operator-cli.js +17837 -0
  86. package/dist/src/operator-entry.d.ts +1 -0
  87. package/dist/src/operator-entry.js +3 -0
  88. package/package.json +18 -12
  89. package/dist/src/app/board.d.ts +0 -23
  90. package/dist/src/app/board.js +0 -1786
  91. package/dist/src/app/theme.d.ts +0 -47
  92. package/dist/src/app/theme.js +0 -150
  93. package/dist/src/commands/_authority-runs.d.ts +0 -22
  94. package/dist/src/commands/_authority-runs.js +0 -110
  95. package/dist/src/commands/_operator-surface.d.ts +0 -34
  96. package/dist/src/commands/_operator-surface.js +0 -220
  97. package/dist/src/commands/_operator-view.d.ts +0 -30
  98. package/dist/src/commands/_operator-view.js +0 -1070
  99. package/dist/src/commands/_preflight.d.ts +0 -22
  100. package/dist/src/commands/_preflight.js +0 -540
  101. package/dist/src/commands/_run-replay.d.ts +0 -24
  102. package/dist/src/commands/_run-replay.js +0 -142
  103. package/dist/src/commands/_server-client.d.ts +0 -186
  104. package/dist/src/commands/_server-client.js +0 -681
  105. package/dist/src/commands/_snapshot-upload.d.ts +0 -39
  106. package/dist/src/commands/_snapshot-upload.js +0 -455
  107. package/dist/src/commands/_task-picker.d.ts +0 -9
  108. package/dist/src/commands/_task-picker.js +0 -201
  109. package/dist/src/commands/browser.d.ts +0 -65
  110. package/dist/src/commands/browser.js +0 -1173
  111. package/dist/src/commands/connect.d.ts +0 -7
  112. package/dist/src/commands/connect.js +0 -419
  113. package/dist/src/commands/inspector.d.ts +0 -3
  114. package/dist/src/commands/inspector.js +0 -263
  115. package/dist/src/commands/task-report-bug.d.ts +0 -19
  116. package/dist/src/commands/task-report-bug.js +0 -1281
  117. package/dist/src/report-bug.d.ts +0 -44
  118. package/dist/src/report-bug.js +0 -260
@@ -1,52 +1,11 @@
1
1
  // @bun
2
2
  // packages/cli/src/commands/_run-driver-helpers.ts
3
- import { readFileSync } from "fs";
4
- import { resolve as resolve3 } from "path";
5
-
6
- // packages/cli/src/runner.ts
7
- import { EventBus } from "@rig/runtime/control-plane/runtime/events";
8
- import { CliError as RuntimeCliError } from "@rig/runtime/control-plane/errors";
9
- import { evaluate, loadPolicy, resolveAction } from "@rig/runtime/control-plane/runtime/guard";
10
- import { buildBinary } from "@rig/runtime/control-plane/runtime/isolation";
11
-
12
- class CliError extends RuntimeCliError {
13
- hint;
14
- constructor(message, exitCode = 1, options = {}) {
15
- super(message, exitCode);
16
- if (options.hint?.trim()) {
17
- this.hint = options.hint.trim();
18
- }
19
- }
20
- }
21
-
22
- // packages/cli/src/commands/_run-driver-helpers.ts
23
- import {
24
- appendRunJournalEvent,
25
- appendRunLogEntry,
26
- appendRunTimelineEntry,
27
- patchAuthorityRunRecord,
28
- readAuthorityRun as readAuthorityRun2,
29
- resolveAuthorityRunDir,
30
- setAuthorityRunStatus,
31
- writeJsonFile
32
- } from "@rig/runtime/control-plane/authority-files";
33
- import { taskLookup } from "@rig/runtime/control-plane/native/task-ops";
34
- import { readPriorPrProgressPromptSection } from "@rig/runtime/control-plane/prompt-context";
35
- import { buildProviderTaskRunInstructionLines } from "@rig/runtime/control-plane/provider/runtime-instructions";
36
- import { loadRigTaskRunSkillBody } from "@rig/runtime/control-plane/provider/rig-task-run-skill";
37
-
38
- // packages/cli/src/commands/_authority-runs.ts
39
- import { existsSync } from "fs";
3
+ import { existsSync, readFileSync } from "fs";
40
4
  import { resolve as resolve2 } from "path";
41
- import {
42
- readAuthorityRun,
43
- readJsonlFile,
44
- writeAuthorityRunRecord
45
- } from "@rig/runtime/control-plane/authority-files";
46
5
 
47
6
  // packages/cli/src/commands/_paths.ts
48
7
  import { resolve } from "path";
49
- import { resolveMonorepoRoot } from "@rig/runtime/control-plane/native/utils";
8
+ import { resolveMonorepoRoot } from "@rig/runtime/layout";
50
9
  function resolveControlPlaneMonorepoRoot(projectRoot) {
51
10
  return resolveMonorepoRoot(projectRoot);
52
11
  }
@@ -54,199 +13,108 @@ function resolveControlPlaneTaskConfigPath(projectRoot) {
54
13
  return resolve(resolveControlPlaneMonorepoRoot(projectRoot), ".rig", "task-config.json");
55
14
  }
56
15
 
57
- // packages/cli/src/commands/_authority-runs.ts
16
+ // packages/cli/src/commands/_run-driver-helpers.ts
58
17
  function readLatestBeadRecord(projectRoot, taskId) {
59
18
  const issuesPath = resolve2(resolveControlPlaneMonorepoRoot(projectRoot), ".beads", "issues.jsonl");
60
19
  if (!existsSync(issuesPath)) {
61
20
  return null;
62
21
  }
63
22
  let latest = null;
64
- for (const issue of readJsonlFile(issuesPath)) {
65
- if (!issue || typeof issue !== "object") {
23
+ for (const line of readFileSync(issuesPath, "utf8").split(/\r?\n/)) {
24
+ const trimmed = line.trim();
25
+ if (!trimmed)
66
26
  continue;
67
- }
68
- const record = issue;
69
- if (record.id === taskId) {
70
- latest = record;
71
- }
27
+ try {
28
+ const parsed = JSON.parse(trimmed);
29
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
30
+ continue;
31
+ const record = parsed;
32
+ if (record.id === taskId)
33
+ latest = record;
34
+ } catch {}
72
35
  }
73
36
  return latest;
74
37
  }
75
-
76
- // packages/cli/src/commands/_run-driver-helpers.ts
77
- function patchAuthorityRun(projectRoot, runId, patch) {
78
- const next = patchAuthorityRunRecord(projectRoot, runId, patch);
79
- if (!next) {
80
- throw new CliError(`Run not found: ${runId}`, 2, { hint: "Run `rig run list` to see recorded runs." });
81
- }
82
- return next;
83
- }
84
- function setRunStatusOrFail(projectRoot, runId, to, options = {}) {
85
- const next = setAuthorityRunStatus(projectRoot, runId, to, {
86
- ...options,
87
- actor: { kind: "agent" }
88
- });
89
- if (!next) {
90
- throw new CliError(`Run not found: ${runId}`, 2, { hint: "Run `rig run list` to see recorded runs." });
91
- }
92
- return next;
93
- }
94
- function touchAuthorityRun(projectRoot, runId) {
95
- const current = readAuthorityRun2(projectRoot, runId);
96
- if (!current) {
97
- return;
38
+ function firstPromptString(...values) {
39
+ for (const value of values) {
40
+ if (typeof value === "string" && value.trim())
41
+ return value.trim();
98
42
  }
99
- writeJsonFile(resolve3(resolveAuthorityRunDir(projectRoot, runId), "run.json"), {
100
- ...current,
101
- updatedAt: new Date().toISOString()
102
- });
103
- }
104
- function appendRunTimeline(projectRoot, runId, value) {
105
- appendRunTimelineEntry(projectRoot, runId, value);
106
- touchAuthorityRun(projectRoot, runId);
107
- }
108
- function appendRunLog(projectRoot, runId, value) {
109
- appendRunLogEntry(projectRoot, runId, value);
110
- touchAuthorityRun(projectRoot, runId);
111
- }
112
- function appendRunAction(projectRoot, runId, value) {
113
- appendRunTimelineEntry(projectRoot, runId, {
114
- id: value.id,
115
- type: "action",
116
- actionType: value.actionType,
117
- title: value.title,
118
- detail: value.detail ?? null,
119
- state: value.state,
120
- createdAt: value.startedAt,
121
- completedAt: value.completedAt ?? null,
122
- payload: value.payload ?? {}
123
- });
43
+ return null;
124
44
  }
125
- function startRunAction(projectRoot, runId, input) {
126
- const startedAt = new Date().toISOString();
127
- appendRunAction(projectRoot, runId, {
128
- id: input.actionId,
129
- actionType: input.actionType,
130
- title: input.title,
131
- detail: input.detail,
132
- state: "running",
133
- startedAt,
134
- payload: input.payload
135
- });
136
- emitServerRunEvent({ type: "timeline", runId });
137
- return {
138
- startedAt,
139
- complete: (detail, payload) => {
140
- appendRunAction(projectRoot, runId, {
141
- id: input.actionId,
142
- actionType: input.actionType,
143
- title: input.title,
144
- detail: detail ?? input.detail ?? null,
145
- state: "completed",
146
- startedAt,
147
- completedAt: new Date().toISOString(),
148
- payload: payload ?? input.payload
149
- });
150
- emitServerRunEvent({ type: "timeline", runId });
151
- },
152
- fail: (detail, payload) => {
153
- appendRunAction(projectRoot, runId, {
154
- id: input.actionId,
155
- actionType: input.actionType,
156
- title: input.title,
157
- detail,
158
- state: "failed",
159
- startedAt,
160
- completedAt: new Date().toISOString(),
161
- payload: payload ?? input.payload
162
- });
163
- emitServerRunEvent({ type: "timeline", runId });
164
- }
165
- };
45
+ function uniqueStrings(values) {
46
+ return Array.from(new Set(values.map((value) => value.trim()).filter(Boolean)));
166
47
  }
167
- var runEventSinkProjectRoot = null;
168
- function configureRunEventSink(projectRoot) {
169
- runEventSinkProjectRoot = projectRoot;
48
+ function renderSourceTaskContract(task, validation) {
49
+ if (!task)
50
+ return validation.length > 0 ? [`Validation: ${validation.join(", ")}`] : [];
51
+ const lines = [`id: ${task.id}`];
52
+ if (task.sourceIssueId)
53
+ lines.push(`source issue: ${task.sourceIssueId}`);
54
+ if (task.status)
55
+ lines.push(`status: ${task.status}`);
56
+ if (task.issueType)
57
+ lines.push(`issue type: ${task.issueType}`);
58
+ if (task.role)
59
+ lines.push(`role: ${task.role}`);
60
+ if (validation.length > 0)
61
+ lines.push(`validation: ${validation.join(", ")}`);
62
+ return lines;
170
63
  }
171
- var lastDoorbellRangAt = 0;
172
- function ringServerRunDoorbell(runId) {
173
- const serverUrl = process.env.RIG_SERVER_URL?.trim();
174
- if (!serverUrl)
175
- return;
176
- const now = Date.now();
177
- if (now - lastDoorbellRangAt < 250)
178
- return;
179
- lastDoorbellRangAt = now;
180
- const token = process.env.RIG_AUTH_TOKEN || process.env.RIG_GITHUB_TOKEN || "";
181
- fetch(`${serverUrl.replace(/\/+$/, "")}/api/runs/doorbell`, {
182
- method: "POST",
183
- headers: {
184
- "content-type": "application/json",
185
- authorization: `Bearer ${token}`
186
- },
187
- body: JSON.stringify({ runId }),
188
- signal: AbortSignal.timeout(1000)
189
- }).catch(() => {});
64
+ function renderSourceScopeValidation(task, validation) {
65
+ if (task || validation.length === 0)
66
+ return "";
67
+ return `Validation:
68
+ - ${validation.join(`
69
+ - `)}`;
70
+ }
71
+ function readTaskScopeText(projectRoot, taskId) {
72
+ try {
73
+ const parsed = JSON.parse(readFileSync(resolveControlPlaneTaskConfigPath(projectRoot), "utf8"));
74
+ const entry = parsed[taskId] ?? {};
75
+ const scope = Array.isArray(entry.scope) ? entry.scope.filter((item) => typeof item === "string") : [];
76
+ const validation = Array.isArray(entry.validation) ? entry.validation.filter((item) => typeof item === "string") : [];
77
+ const lines = [];
78
+ if (scope.length > 0)
79
+ lines.push(`Scope:
80
+ - ${scope.join(`
81
+ - `)}`);
82
+ if (validation.length > 0)
83
+ lines.push(`Validation:
84
+ - ${validation.join(`
85
+ - `)}`);
86
+ return lines.join(`
87
+
88
+ `);
89
+ } catch {
90
+ return "";
91
+ }
190
92
  }
191
- function emitServerRunEvent(event) {
192
- console.log(`__RIG_RUN_EVENT__${JSON.stringify({ ...event, at: new Date().toISOString() })}`);
193
- if (runEventSinkProjectRoot) {
194
- try {
195
- if (event.type === "status" || event.type === "completed" || event.type === "failed") {
196
- appendRunJournalEvent(runEventSinkProjectRoot, event.runId, {
197
- type: "timeline-entry",
198
- payload: { kind: "driver-event", ...event }
199
- });
200
- }
201
- } catch {}
202
- ringServerRunDoorbell(event.runId);
93
+ function providerInstructionLines(runtimeAdapter) {
94
+ if (runtimeAdapter === "pi") {
95
+ return ["Keep file writes inside the scoped task workspace and use the bridged Pi tooling for shell and follow-up prompts."];
96
+ }
97
+ if (runtimeAdapter === "codex") {
98
+ return ["Keep file writes inside the scoped task workspace and prefer compact terminal output."];
203
99
  }
100
+ return ["Keep file writes inside the scoped task workspace and stay within the provided tool surface."];
204
101
  }
205
102
  function buildRunPrompt(input) {
206
103
  const initialPrompt = input.initialPrompt?.trim() || null;
207
104
  if (!input.taskId) {
208
- return initialPrompt ?? input.fallbackTitle?.trim() ?? "Continue the requested Rig run and complete the work.";
105
+ return initialPrompt ?? input.fallbackTitle?.trim() ?? "Continue the requested run and complete the work.";
209
106
  }
210
- const issues = (() => {
211
- try {
212
- return taskLookup(input.projectRoot, input.taskId);
213
- } catch {
214
- return "";
215
- }
216
- })();
217
- const scopeText = (() => {
218
- try {
219
- const parsed = JSON.parse(readFileSync(resolveControlPlaneTaskConfigPath(input.projectRoot), "utf8"));
220
- const entry = parsed[input.taskId] ?? {};
221
- const scope = Array.isArray(entry.scope) ? entry.scope.filter((item) => typeof item === "string") : [];
222
- const validation = Array.isArray(entry.validation) ? entry.validation.filter((item) => typeof item === "string") : [];
223
- const lines = [];
224
- if (scope.length > 0)
225
- lines.push(`Scope:
226
- - ${scope.join(`
227
- - `)}`);
228
- if (validation.length > 0)
229
- lines.push(`Validation:
230
- - ${validation.join(`
231
- - `)}`);
232
- return lines.join(`
233
-
234
- `);
235
- } catch {
236
- return "";
237
- }
238
- })();
239
107
  const bead = readLatestBeadRecord(input.projectRoot, input.taskId);
240
108
  const sourceTask = input.sourceTask ?? null;
241
109
  const sourceDescription = firstPromptString(sourceTask?.description, sourceTask?.body);
242
110
  const sourceAcceptance = firstPromptString(sourceTask?.acceptanceCriteria, sourceTask?.acceptance_criteria);
243
111
  const sourceValidation = uniqueStrings([...sourceTask?.validation ?? [], ...sourceTask?.validators ?? []]);
244
- const title = (bead && typeof bead === "object" && typeof bead.title === "string" ? bead.title : null) ?? firstPromptString(sourceTask?.title) ?? input.fallbackTitle ?? issues ?? input.taskId;
245
- const description = (bead && typeof bead === "object" && typeof bead.description === "string" ? bead.description : null) ?? sourceDescription ?? input.fallbackDescription ?? "";
246
- const acceptance = bead && typeof bead === "object" && typeof bead.acceptance_criteria === "string" ? bead.acceptance_criteria : sourceAcceptance ?? input.fallbackAcceptanceCriteria ?? "";
112
+ const title = (bead && typeof bead.title === "string" ? bead.title : null) ?? firstPromptString(sourceTask?.title) ?? input.fallbackTitle ?? input.taskId;
113
+ const description = (bead && typeof bead.description === "string" ? bead.description : null) ?? sourceDescription ?? input.fallbackDescription ?? "";
114
+ const acceptance = (bead && typeof bead.acceptance_criteria === "string" ? bead.acceptance_criteria : null) ?? sourceAcceptance ?? input.fallbackAcceptanceCriteria ?? "";
115
+ const scopeText = readTaskScopeText(input.projectRoot, input.taskId);
247
116
  const sourceContractLines = renderSourceTaskContract(sourceTask, sourceValidation);
248
- const providerLines = buildProviderTaskRunInstructionLines(input.runtimeAdapter);
249
- const skillBody = loadRigTaskRunSkillBody();
117
+ const providerLines = providerInstructionLines(input.runtimeAdapter);
250
118
  return [
251
119
  `You are working on task ${input.taskId}: ${title}.`,
252
120
  description ? `Description:
@@ -257,86 +125,14 @@ ${acceptance}` : null,
257
125
  ${sourceContractLines.join(`
258
126
  `)}` : null,
259
127
  scopeText || renderSourceScopeValidation(sourceTask, sourceValidation) || null,
260
- readPriorPrProgressPromptSection(input.projectRoot, input.taskId),
261
128
  initialPrompt ? `Additional operator guidance:
262
129
  ${initialPrompt}` : null,
263
130
  providerLines.length > 0 ? `Provider-specific runtime tooling:
264
- ${providerLines.join(" ")}` : null,
265
- skillBody || null
131
+ ${providerLines.join(" ")}` : null
266
132
  ].filter((value) => Boolean(value)).join(`
267
133
 
268
- `);
269
- }
270
- function firstPromptString(...values) {
271
- for (const value of values) {
272
- const trimmed = typeof value === "string" ? value.trim() : "";
273
- if (trimmed.length > 0) {
274
- return trimmed;
275
- }
276
- }
277
- return null;
278
- }
279
- function uniqueStrings(values) {
280
- return Array.from(new Set(values.map((value) => value.trim()).filter(Boolean)));
281
- }
282
- function renderSourceTaskContract(task, validation) {
283
- if (!task) {
284
- return [];
285
- }
286
- const lines = [];
287
- const sourceIssueId = firstPromptString(task.sourceIssueId);
288
- if (sourceIssueId)
289
- lines.push(`Source issue: ${sourceIssueId}`);
290
- const status = firstPromptString(task.status);
291
- if (status)
292
- lines.push(`Source status: ${status}`);
293
- const issueType = firstPromptString(task.issueType);
294
- if (issueType)
295
- lines.push(`Issue type: ${issueType}`);
296
- const role = firstPromptString(task.role);
297
- if (role)
298
- lines.push(`Role: ${role}`);
299
- const externalRef = firstPromptString(task.externalRef);
300
- if (externalRef)
301
- lines.push(`External ref: ${externalRef}`);
302
- const labels = uniqueStrings(task.labels ?? []);
303
- if (labels.length > 0)
304
- lines.push(`Labels:
305
- - ${labels.join(`
306
- - `)}`);
307
- if (validation.length > 0)
308
- lines.push(`Validators:
309
- - ${validation.join(`
310
- - `)}`);
311
- return lines;
312
- }
313
- function renderSourceScopeValidation(task, validation) {
314
- if (!task) {
315
- return "";
316
- }
317
- const lines = [];
318
- const scope = uniqueStrings(task.scope ?? []);
319
- if (scope.length > 0)
320
- lines.push(`Scope:
321
- - ${scope.join(`
322
- - `)}`);
323
- if (validation.length > 0)
324
- lines.push(`Validation:
325
- - ${validation.join(`
326
- - `)}`);
327
- return lines.join(`
328
-
329
134
  `);
330
135
  }
331
136
  export {
332
- touchAuthorityRun,
333
- startRunAction,
334
- setRunStatusOrFail,
335
- patchAuthorityRun,
336
- emitServerRunEvent,
337
- configureRunEventSink,
338
- buildRunPrompt,
339
- appendRunTimeline,
340
- appendRunLog,
341
- appendRunAction
137
+ buildRunPrompt
342
138
  };
@@ -0,0 +1,50 @@
1
+ import { type RunJournalProjection, type RunSessionCustomEntry } from "@rig/contracts";
2
+ import type { CollabRegistryFilter } from "@oh-my-pi/pi-coding-agent/collab/api";
3
+ /** A run as seen by the operator CLI: live-presence facts joined with the folded journal. */
4
+ export interface RunProjectionRecord {
5
+ readonly runId: string;
6
+ readonly taskId: string | null;
7
+ readonly title: string;
8
+ /** RunStatus from the folded journal, or a liveness-derived fallback. */
9
+ readonly status: string;
10
+ readonly source: "local" | "remote";
11
+ /** True when the run is currently discoverable (registry heartbeat or local host). */
12
+ readonly live: boolean;
13
+ readonly stale: boolean;
14
+ readonly startedAt: string | null;
15
+ readonly updatedAt: string | null;
16
+ readonly completedAt: string | null;
17
+ readonly joinLink: string | null;
18
+ readonly webLink: string | null;
19
+ readonly relayUrl: string | null;
20
+ readonly sessionPath: string | null;
21
+ readonly prUrl: string | null;
22
+ readonly worktreePath: string | null;
23
+ readonly pendingApprovals: number;
24
+ readonly pendingInputs: number;
25
+ readonly steeringCount: number;
26
+ readonly stallCount: number;
27
+ readonly errorSummary?: string | null;
28
+ /** The full folded journal (empty projection when no journal was readable). */
29
+ readonly projection: RunJournalProjection;
30
+ }
31
+ /** What an attach/steer caller needs to reach a live run over collab. */
32
+ export interface RunJoinTarget {
33
+ readonly runId: string;
34
+ readonly taskId: string | null;
35
+ readonly joinLink: string;
36
+ readonly cwd: string | null;
37
+ readonly stale: boolean;
38
+ }
39
+ /** Parse an OMP session JSONL into the custom-entry shape `foldRunSessionEntries` expects. */
40
+ export declare function readSessionRunEntries(sessionPath: string | null): RunSessionCustomEntry[];
41
+ /**
42
+ * List every discoverable run: live collab (relay-registry + local hosts) merged
43
+ * with finished/local runs recovered from on-disk agent-runtime session journals.
44
+ * Live entries win on runId collisions (they carry join links + current presence).
45
+ */
46
+ export declare function listRunProjections(projectRoot: string, filter?: CollabRegistryFilter): Promise<RunProjectionRecord[]>;
47
+ /** Resolve a single run by id (or unambiguous prefix). */
48
+ export declare function getRunProjection(projectRoot: string, runId: string, filter?: CollabRegistryFilter): Promise<RunProjectionRecord | null>;
49
+ /** Resolve the live join target for attach/steer; null when the run is not currently joinable. */
50
+ export declare function resolveRunJoinTarget(projectRoot: string, runId: string, filter?: CollabRegistryFilter): Promise<RunJoinTarget | null>;