@h-rig/run-plugin 0.0.6-alpha.186
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/README.md +1 -0
- package/dist/src/plugin.d.ts +4 -0
- package/dist/src/plugin.js +4319 -0
- package/dist/src/read-model/inspect-command.d.ts +19 -0
- package/dist/src/read-model/inspect-command.js +341 -0
- package/dist/src/read-model/plugin.d.ts +4 -0
- package/dist/src/read-model/plugin.js +2550 -0
- package/dist/src/read-model/read-model-backend/diagnostics.d.ts +9 -0
- package/dist/src/read-model/read-model-backend/diagnostics.js +51 -0
- package/dist/src/read-model/read-model-backend/guard.d.ts +4 -0
- package/dist/src/read-model/read-model-backend/guard.js +25 -0
- package/dist/src/read-model/read-model-backend/inbox.d.ts +23 -0
- package/dist/src/read-model/read-model-backend/inbox.js +669 -0
- package/dist/src/read-model/read-model-backend/index.d.ts +8 -0
- package/dist/src/read-model/read-model-backend/index.js +1163 -0
- package/dist/src/read-model/read-model-backend/inspect.d.ts +26 -0
- package/dist/src/read-model/read-model-backend/inspect.js +770 -0
- package/dist/src/read-model/read-model-backend/projection.d.ts +39 -0
- package/dist/src/read-model/read-model-backend/projection.js +669 -0
- package/dist/src/read-model/read-model-backend/run-status.d.ts +27 -0
- package/dist/src/read-model/read-model-backend/run-status.js +237 -0
- package/dist/src/read-model/read-model-backend/stats.d.ts +12 -0
- package/dist/src/read-model/read-model-backend/stats.js +800 -0
- package/dist/src/read-model/read-model-service.d.ts +2 -0
- package/dist/src/read-model/read-model-service.js +1725 -0
- package/dist/src/read-model/reconcile.d.ts +23 -0
- package/dist/src/read-model/reconcile.js +306 -0
- package/dist/src/read-model/run-format.d.ts +23 -0
- package/dist/src/read-model/run-format.js +202 -0
- package/dist/src/read-model/runs-screen.d.ts +14 -0
- package/dist/src/read-model/runs-screen.js +217 -0
- package/dist/src/read-model/session-journal.d.ts +26 -0
- package/dist/src/read-model/session-journal.js +355 -0
- package/dist/src/read-model/stats-command.d.ts +16 -0
- package/dist/src/read-model/stats-command.js +88 -0
- package/dist/src/read-model/stats-format.d.ts +1 -0
- package/dist/src/read-model/stats-format.js +8 -0
- package/dist/src/worker/autohost.d.ts +11 -0
- package/dist/src/worker/autohost.js +858 -0
- package/dist/src/worker/constants.d.ts +3 -0
- package/dist/src/worker/constants.js +10 -0
- package/dist/src/worker/extension.d.ts +14 -0
- package/dist/src/worker/extension.js +881 -0
- package/dist/src/worker/host.d.ts +1 -0
- package/dist/src/worker/host.js +1 -0
- package/dist/src/worker/inbox-command.d.ts +23 -0
- package/dist/src/worker/inbox-command.js +163 -0
- package/dist/src/worker/index.d.ts +2 -0
- package/dist/src/worker/index.js +1767 -0
- package/dist/src/worker/local-run-changes.d.ts +3 -0
- package/dist/src/worker/local-run-changes.js +65 -0
- package/dist/src/worker/notifications.d.ts +1 -0
- package/dist/src/worker/notifications.js +27 -0
- package/dist/src/worker/notify-cap.d.ts +11 -0
- package/dist/src/worker/notify-cap.js +13 -0
- package/dist/src/worker/panel-plugin.d.ts +11 -0
- package/dist/src/worker/panel-plugin.js +37 -0
- package/dist/src/worker/plugin.d.ts +3 -0
- package/dist/src/worker/plugin.js +1761 -0
- package/dist/src/worker/run-control-service.d.ts +2 -0
- package/dist/src/worker/run-control-service.js +210 -0
- package/dist/src/worker/session-journal-writer.d.ts +4 -0
- package/dist/src/worker/session-journal-writer.js +184 -0
- package/dist/src/worker/stall.d.ts +21 -0
- package/dist/src/worker/stall.js +55 -0
- package/dist/src/worker/utils.d.ts +21 -0
- package/dist/src/worker/utils.js +29 -0
- package/dist/src/worker/workflow-journal-writer.d.ts +7 -0
- package/dist/src/worker/workflow-journal-writer.js +76 -0
- package/package.json +47 -0
|
@@ -0,0 +1,1761 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __returnValue = (v) => v;
|
|
4
|
+
function __exportSetter(name, newValue) {
|
|
5
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
6
|
+
}
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: true,
|
|
12
|
+
configurable: true,
|
|
13
|
+
set: __exportSetter.bind(all, name)
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
17
|
+
var __require = import.meta.require;
|
|
18
|
+
|
|
19
|
+
// packages/run-plugin/src/worker/inbox-command.ts
|
|
20
|
+
var exports_inbox_command = {};
|
|
21
|
+
__export(exports_inbox_command, {
|
|
22
|
+
readPendingInboxCounts: () => readPendingInboxCounts,
|
|
23
|
+
listInboxRecords: () => listInboxRecords,
|
|
24
|
+
listInbox: () => listInbox,
|
|
25
|
+
executeInbox: () => executeInbox
|
|
26
|
+
});
|
|
27
|
+
import { RUN_CONTROL, RUN_READ_MODEL } from "@rig/contracts";
|
|
28
|
+
import { defineCapability } from "@rig/core/capability";
|
|
29
|
+
import { requireCapabilityForRoot } from "@rig/core/capability-loaders";
|
|
30
|
+
import { CliError, requireNoExtraArgs, takeOption } from "@rig/std-shared/cli-args";
|
|
31
|
+
import { printFormattedOutput } from "@rig/std-shared/cli-format";
|
|
32
|
+
async function loadRunControl(projectRoot) {
|
|
33
|
+
return requireCapabilityForRoot(projectRoot, RunControlCap, "RUN_CONTROL capability unavailable for this project root: load @rig/run-plugin (standard bundle).");
|
|
34
|
+
}
|
|
35
|
+
async function loadRunReadModel(projectRoot) {
|
|
36
|
+
return requireCapabilityForRoot(projectRoot, RunReadModelCap, "RUN_READ_MODEL capability unavailable for this project root: load @rig/run-plugin (standard bundle).");
|
|
37
|
+
}
|
|
38
|
+
function readModelKind(kind) {
|
|
39
|
+
return kind === "approvals" ? "approval" : "input";
|
|
40
|
+
}
|
|
41
|
+
async function listInboxRecords(context, kind, filters = {}, deps = {}) {
|
|
42
|
+
if (deps.listInbox)
|
|
43
|
+
return deps.listInbox(context.projectRoot, kind, filters);
|
|
44
|
+
const readModel = await loadRunReadModel(context.projectRoot);
|
|
45
|
+
return readModel.listInboxRecords({
|
|
46
|
+
projectRoot: context.projectRoot,
|
|
47
|
+
kind: readModelKind(kind),
|
|
48
|
+
...filters.run ? { runId: filters.run } : {},
|
|
49
|
+
...filters.task ? { taskId: filters.task } : {}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
async function listInbox(context, kind, filters = {}, deps = {}) {
|
|
53
|
+
return listInboxRecords(context, kind, filters, deps);
|
|
54
|
+
}
|
|
55
|
+
async function readPendingInboxCounts(context, deps = {}) {
|
|
56
|
+
if (deps.getInboxCounts)
|
|
57
|
+
return deps.getInboxCounts(context.projectRoot);
|
|
58
|
+
try {
|
|
59
|
+
const counts = await (await loadRunReadModel(context.projectRoot)).getInboxCounts({ projectRoot: context.projectRoot, kind: "all" });
|
|
60
|
+
return { approvals: counts.approvals, inputs: counts.inputs };
|
|
61
|
+
} catch {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function resolutionAttachError(runId, verb, error) {
|
|
66
|
+
const target = runId ?? "<run-id>";
|
|
67
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
68
|
+
throw new CliError(`rig inbox ${verb} could not deliver a resolution from this one-shot command.`, 2, {
|
|
69
|
+
hint: `${detail}
|
|
70
|
+
Attach to resolve interactively: rig run attach ${target}`
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
async function readInboxSnapshot(context, filters, deps) {
|
|
74
|
+
const [approvals, inputs] = await Promise.all([
|
|
75
|
+
listInbox(context, "approvals", filters, deps),
|
|
76
|
+
listInbox(context, "inputs", filters, deps)
|
|
77
|
+
]);
|
|
78
|
+
return { approvals, inputs };
|
|
79
|
+
}
|
|
80
|
+
function renderInboxSnapshot(readModel, snapshot) {
|
|
81
|
+
console.clear();
|
|
82
|
+
console.log(`rig inbox \u2014 watching (Ctrl-C to stop) \u2014 ${new Date().toLocaleTimeString()}`);
|
|
83
|
+
printFormattedOutput(readModel.formatInboxList("approvals", snapshot.approvals.map((entry) => ({ ...entry }))));
|
|
84
|
+
printFormattedOutput(readModel.formatInboxList("inputs", snapshot.inputs.map((entry) => ({ ...entry }))));
|
|
85
|
+
if (snapshot.approvals.length === 0 && snapshot.inputs.length === 0)
|
|
86
|
+
console.log("Nothing pending.");
|
|
87
|
+
}
|
|
88
|
+
function sleep(ms) {
|
|
89
|
+
const { promise, resolve } = Promise.withResolvers();
|
|
90
|
+
setTimeout(resolve, ms);
|
|
91
|
+
return promise;
|
|
92
|
+
}
|
|
93
|
+
async function watchInbox(context, filters, deps) {
|
|
94
|
+
const snapshot = await readInboxSnapshot(context, filters, deps);
|
|
95
|
+
if (context.outputMode !== "text")
|
|
96
|
+
return { ok: true, group: "inbox", command: "watch", details: snapshot };
|
|
97
|
+
const readModel = await loadRunReadModel(context.projectRoot);
|
|
98
|
+
renderInboxSnapshot(readModel, snapshot);
|
|
99
|
+
while (true) {
|
|
100
|
+
await sleep(500);
|
|
101
|
+
renderInboxSnapshot(readModel, await readInboxSnapshot(context, filters, deps));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
async function deliverInboxResolution(context, runId, resolution, deps) {
|
|
105
|
+
const result = deps.resolveInboxRequest ? await deps.resolveInboxRequest(context.projectRoot, runId, resolution) : await (await loadRunControl(context.projectRoot)).resolveInboxRequest({ projectRoot: context.projectRoot, runId, resolution });
|
|
106
|
+
if (!result.delivered)
|
|
107
|
+
throw new Error(result.detail ?? `Inbox request ${resolution.requestId} was not delivered.`);
|
|
108
|
+
return result;
|
|
109
|
+
}
|
|
110
|
+
async function executeInbox(context, args, deps = {}) {
|
|
111
|
+
const [command = "approvals", ...rest] = args;
|
|
112
|
+
const text = context.outputMode === "text";
|
|
113
|
+
switch (command) {
|
|
114
|
+
case "approvals":
|
|
115
|
+
case "inputs": {
|
|
116
|
+
const run = takeOption(rest, "--run");
|
|
117
|
+
const task = takeOption(run.rest, "--task");
|
|
118
|
+
requireNoExtraArgs(task.rest, `rig inbox ${command} [--run <id>] [--task <id>]`);
|
|
119
|
+
const kind = command === "approvals" ? "approvals" : "inputs";
|
|
120
|
+
const filters = { ...run.value ? { run: run.value } : {}, ...task.value ? { task: task.value } : {} };
|
|
121
|
+
const entries = await listInbox(context, kind, filters, deps);
|
|
122
|
+
if (text) {
|
|
123
|
+
const readModel = await loadRunReadModel(context.projectRoot);
|
|
124
|
+
printFormattedOutput(readModel.formatInboxList(kind, entries.map((entry) => ({ ...entry }))));
|
|
125
|
+
}
|
|
126
|
+
return { ok: true, group: "inbox", command, details: { entries } };
|
|
127
|
+
}
|
|
128
|
+
case "approve": {
|
|
129
|
+
const run = takeOption(rest, "--run");
|
|
130
|
+
const request = takeOption(run.rest, "--request");
|
|
131
|
+
const decision = takeOption(request.rest, "--decision");
|
|
132
|
+
requireNoExtraArgs(decision.rest, "rig inbox approve --run <id> --request <id> --decision approve|reject");
|
|
133
|
+
if (!run.value || !request.value)
|
|
134
|
+
throw new CliError("rig inbox approve requires --run and --request.", 2);
|
|
135
|
+
const rawDecision = (decision.value ?? "approve").trim().toLowerCase();
|
|
136
|
+
if (rawDecision !== "approve" && rawDecision !== "approved" && rawDecision !== "reject" && rawDecision !== "rejected")
|
|
137
|
+
throw new CliError("--decision must be approve or reject.", 2);
|
|
138
|
+
const normalizedDecision = rawDecision === "approved" ? "approve" : rawDecision === "rejected" ? "reject" : rawDecision;
|
|
139
|
+
try {
|
|
140
|
+
await deliverInboxResolution(context, run.value, { kind: "approval", requestId: request.value, decision: normalizedDecision }, deps);
|
|
141
|
+
} catch (error) {
|
|
142
|
+
resolutionAttachError(run.value, "approve", error);
|
|
143
|
+
}
|
|
144
|
+
if (text)
|
|
145
|
+
printFormattedOutput(`Resolved approval ${request.value} for run ${run.value}.`);
|
|
146
|
+
return { ok: true, group: "inbox", command, details: { runId: run.value, requestId: request.value, decision: normalizedDecision } };
|
|
147
|
+
}
|
|
148
|
+
case "respond":
|
|
149
|
+
case "answer": {
|
|
150
|
+
const run = takeOption(rest, "--run");
|
|
151
|
+
const request = takeOption(run.rest, "--request");
|
|
152
|
+
const textResult = takeOption(request.rest, "--text");
|
|
153
|
+
const answerResult = takeOption(textResult.rest, "--answer");
|
|
154
|
+
requireNoExtraArgs(answerResult.rest, `rig inbox ${command} --run <id> --request <id> (--text|--answer) <answer>`);
|
|
155
|
+
if (textResult.value && answerResult.value)
|
|
156
|
+
throw new CliError("Pass only one of --text or --answer.", 2);
|
|
157
|
+
const answer = textResult.value ?? answerResult.value;
|
|
158
|
+
if (!run.value || !request.value || !answer)
|
|
159
|
+
resolutionAttachError(run.value, "respond", new Error(`rig inbox ${command} requires --run, --request, and --text/--answer.`));
|
|
160
|
+
try {
|
|
161
|
+
await deliverInboxResolution(context, run.value, { kind: "input", requestId: request.value, answers: { answer } }, deps);
|
|
162
|
+
} catch (error) {
|
|
163
|
+
resolutionAttachError(run.value, "respond", error);
|
|
164
|
+
}
|
|
165
|
+
if (text)
|
|
166
|
+
printFormattedOutput(`Sent response ${request.value} for run ${run.value}.`);
|
|
167
|
+
return { ok: true, group: "inbox", command, details: { runId: run.value, requestId: request.value, responded: true } };
|
|
168
|
+
}
|
|
169
|
+
case "watch": {
|
|
170
|
+
const run = takeOption(rest, "--run");
|
|
171
|
+
const task = takeOption(run.rest, "--task");
|
|
172
|
+
requireNoExtraArgs(task.rest, "rig inbox watch [--run <id>] [--task <id>]");
|
|
173
|
+
const filters = { ...run.value ? { run: run.value } : {}, ...task.value ? { task: task.value } : {} };
|
|
174
|
+
return watchInbox(context, filters, deps);
|
|
175
|
+
}
|
|
176
|
+
default:
|
|
177
|
+
throw new CliError(`Unknown inbox command: ${command}`, 1, { hint: "Run `rig inbox --help` to list inbox commands." });
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
var RunControlCap, RunReadModelCap;
|
|
181
|
+
var init_inbox_command = __esm(() => {
|
|
182
|
+
RunControlCap = defineCapability(RUN_CONTROL);
|
|
183
|
+
RunReadModelCap = defineCapability(RUN_READ_MODEL);
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
// packages/run-plugin/src/worker/session-journal-writer.ts
|
|
187
|
+
var exports_session_journal_writer = {};
|
|
188
|
+
__export(exports_session_journal_writer, {
|
|
189
|
+
runSessionJournalWriterService: () => runSessionJournalWriterService,
|
|
190
|
+
reconcileDeadPid: () => reconcileDeadPid,
|
|
191
|
+
createRunJournal: () => createRunJournal
|
|
192
|
+
});
|
|
193
|
+
import { defineCapability as defineCapability2 } from "@rig/core/capability";
|
|
194
|
+
import { getInstalledCapability, installCapability, loadCapabilityForRoot } from "@rig/core/capability-loaders";
|
|
195
|
+
import {
|
|
196
|
+
CUSTOM_TYPE_FOR,
|
|
197
|
+
RUN_SESSION_JOURNAL
|
|
198
|
+
} from "@rig/contracts";
|
|
199
|
+
function requireReadCodec() {
|
|
200
|
+
const codec = getInstalledCapability(RunSessionJournalCap);
|
|
201
|
+
if (!codec) {
|
|
202
|
+
throw new Error("RUN_SESSION_JOURNAL codec capability unavailable: the run-worker autohost / run-host preboot install it before binding the journal writer; ensure @rig/run-plugin (default bundle) is installed.");
|
|
203
|
+
}
|
|
204
|
+
return codec;
|
|
205
|
+
}
|
|
206
|
+
function asCustomEntries(entries) {
|
|
207
|
+
return entries.filter((entry) => Boolean(entry && typeof entry === "object" && entry.type === "custom"));
|
|
208
|
+
}
|
|
209
|
+
function dataRecord(entry) {
|
|
210
|
+
return entry.data && typeof entry.data === "object" && !Array.isArray(entry.data) ? entry.data : null;
|
|
211
|
+
}
|
|
212
|
+
function entryBelongsToRun(entry, runId, defaultRunId) {
|
|
213
|
+
const data = dataRecord(entry);
|
|
214
|
+
if (!data)
|
|
215
|
+
return runId === defaultRunId;
|
|
216
|
+
const candidate = data.runId;
|
|
217
|
+
return candidate === undefined ? runId === defaultRunId : candidate === runId;
|
|
218
|
+
}
|
|
219
|
+
function isRunJournalEventInit(event) {
|
|
220
|
+
if (event === null || typeof event !== "object")
|
|
221
|
+
return false;
|
|
222
|
+
const type = event.type;
|
|
223
|
+
return typeof type === "string" && Object.hasOwn(CUSTOM_TYPE_FOR, type);
|
|
224
|
+
}
|
|
225
|
+
function createJournalSessionProvider(options) {
|
|
226
|
+
const now = options.now ?? (() => new Date);
|
|
227
|
+
const appendRunEvent = async (event, runId = options.runId) => {
|
|
228
|
+
options.store.appendCustomEntry(CUSTOM_TYPE_FOR[event.type], { ...event, runId, at: now().toISOString() });
|
|
229
|
+
};
|
|
230
|
+
const readEntries = () => asCustomEntries(options.store.getEntries());
|
|
231
|
+
const entriesForRun = (runId) => readEntries().filter((entry) => entryBelongsToRun(entry, runId, options.runId));
|
|
232
|
+
const readProjection = () => {
|
|
233
|
+
const entries = entriesForRun(options.runId);
|
|
234
|
+
return requireReadCodec().projectRunFromSession(entries, options.runId);
|
|
235
|
+
};
|
|
236
|
+
return {
|
|
237
|
+
runId: options.runId,
|
|
238
|
+
async append(event) {
|
|
239
|
+
if (isRunJournalEventInit(event))
|
|
240
|
+
await appendRunEvent(event);
|
|
241
|
+
},
|
|
242
|
+
appendRunEvent,
|
|
243
|
+
async recordPipeline(runId, pipeline) {
|
|
244
|
+
await appendRunEvent({ type: "pipeline-resolved", pipeline }, runId);
|
|
245
|
+
},
|
|
246
|
+
async recordStageOutcome(runId, outcome) {
|
|
247
|
+
await appendRunEvent({ type: "stage-outcome", outcome }, runId);
|
|
248
|
+
},
|
|
249
|
+
async read(runId) {
|
|
250
|
+
return entriesForRun(runId);
|
|
251
|
+
},
|
|
252
|
+
readEntries,
|
|
253
|
+
readProjection
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
class RunSessionJournal {
|
|
258
|
+
sm;
|
|
259
|
+
runId;
|
|
260
|
+
readProjection;
|
|
261
|
+
constructor(sm, runId, readProjection) {
|
|
262
|
+
this.sm = sm;
|
|
263
|
+
this.runId = runId;
|
|
264
|
+
this.readProjection = readProjection;
|
|
265
|
+
}
|
|
266
|
+
#append(init) {
|
|
267
|
+
this.sm.appendCustomEntry(CUSTOM_TYPE_FOR[init.type], { ...init, at: new Date().toISOString() });
|
|
268
|
+
}
|
|
269
|
+
appendStatus(to, opts = {}) {
|
|
270
|
+
const from = this.readProjection().status;
|
|
271
|
+
if (!opts.force)
|
|
272
|
+
requireReadCodec().assertRunStatusTransition(from, to);
|
|
273
|
+
if (opts.errorText !== undefined)
|
|
274
|
+
this.#append({ type: "record-patch", patch: { errorText: opts.errorText } });
|
|
275
|
+
this.#append({
|
|
276
|
+
type: "status-changed",
|
|
277
|
+
from,
|
|
278
|
+
to,
|
|
279
|
+
...opts.reason !== undefined ? { reason: opts.reason } : {},
|
|
280
|
+
...opts.actor !== undefined ? { actor: opts.actor } : {}
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
appendTimeline(payload) {
|
|
284
|
+
this.#append({ type: "timeline-entry", payload });
|
|
285
|
+
}
|
|
286
|
+
appendCloseoutPhase(input) {
|
|
287
|
+
this.#append({
|
|
288
|
+
type: "closeout-phase",
|
|
289
|
+
phase: input.phase,
|
|
290
|
+
outcome: input.outcome,
|
|
291
|
+
...input.detail !== undefined ? { detail: input.detail } : {}
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
appendApprovalResolved(input) {
|
|
295
|
+
this.#append({
|
|
296
|
+
type: "approval-resolved",
|
|
297
|
+
requestId: input.requestId,
|
|
298
|
+
decision: input.decision,
|
|
299
|
+
actor: input.actor,
|
|
300
|
+
...input.note !== undefined ? { note: input.note } : {}
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
appendInputResolved(input) {
|
|
304
|
+
this.#append({ type: "input-resolved", requestId: input.requestId, answers: input.answers, actor: input.actor });
|
|
305
|
+
}
|
|
306
|
+
appendStall(input) {
|
|
307
|
+
this.#append({ type: "stall-detected", detail: input.detail });
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
async function createRunJournal(sessionManager, runId) {
|
|
311
|
+
try {
|
|
312
|
+
const writableSessionManager = sessionManager;
|
|
313
|
+
if (typeof writableSessionManager.appendCustomEntry !== "function")
|
|
314
|
+
return null;
|
|
315
|
+
const kernel = createJournalSessionProvider({
|
|
316
|
+
runId,
|
|
317
|
+
store: {
|
|
318
|
+
appendCustomEntry: (customType, data) => writableSessionManager.appendCustomEntry(customType, data),
|
|
319
|
+
getEntries: () => sessionManager.getEntries?.() ?? sessionManager.getBranch?.() ?? []
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
const journal = new RunSessionJournal(writableSessionManager, runId, kernel.readProjection);
|
|
323
|
+
return {
|
|
324
|
+
kernel,
|
|
325
|
+
appendStatus: journal.appendStatus.bind(journal),
|
|
326
|
+
appendTimeline: journal.appendTimeline.bind(journal),
|
|
327
|
+
appendCloseoutPhase: journal.appendCloseoutPhase.bind(journal),
|
|
328
|
+
appendApprovalResolved: journal.appendApprovalResolved.bind(journal),
|
|
329
|
+
appendInputResolved: journal.appendInputResolved.bind(journal),
|
|
330
|
+
appendStall: journal.appendStall.bind(journal)
|
|
331
|
+
};
|
|
332
|
+
} catch (error) {
|
|
333
|
+
console.warn(`[rig-run] RunSessionJournal writer unavailable; run-state arming deferred: ${error instanceof Error ? error.message : String(error)}`);
|
|
334
|
+
return null;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
async function reconcileDeadPid(input) {
|
|
338
|
+
if (!input.sessionPath.trim()) {
|
|
339
|
+
return { runId: input.runId, updated: false, status: "not-found", detail: "session path missing" };
|
|
340
|
+
}
|
|
341
|
+
try {
|
|
342
|
+
const codec = await loadCapabilityForRoot(input.projectRoot, RunSessionJournalCap);
|
|
343
|
+
if (!codec) {
|
|
344
|
+
return { runId: input.runId, updated: false, status: "unavailable", detail: "RUN_SESSION_JOURNAL codec capability unavailable" };
|
|
345
|
+
}
|
|
346
|
+
installCapability(RunSessionJournalCap, codec);
|
|
347
|
+
const { SessionManager } = await import("@oh-my-pi/pi-coding-agent/session/session-manager");
|
|
348
|
+
const session = await SessionManager.open(input.sessionPath, undefined, undefined, { suppressBreadcrumb: true });
|
|
349
|
+
const journal = await createRunJournal(session, input.runId);
|
|
350
|
+
if (!journal) {
|
|
351
|
+
return { runId: input.runId, updated: false, status: "not-found", detail: "run journal not found" };
|
|
352
|
+
}
|
|
353
|
+
journal.appendStatus("failed", {
|
|
354
|
+
reason: input.reason ?? "lazy-reconcile:dead-pid",
|
|
355
|
+
actor: { kind: "agent" },
|
|
356
|
+
force: true
|
|
357
|
+
});
|
|
358
|
+
return { runId: input.runId, updated: true, status: "reconciled" };
|
|
359
|
+
} catch (error) {
|
|
360
|
+
return { runId: input.runId, updated: false, status: "unavailable", detail: error instanceof Error ? error.message : String(error) };
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
var RunSessionJournalCap, runSessionJournalWriterService;
|
|
364
|
+
var init_session_journal_writer = __esm(() => {
|
|
365
|
+
RunSessionJournalCap = defineCapability2(RUN_SESSION_JOURNAL);
|
|
366
|
+
runSessionJournalWriterService = {
|
|
367
|
+
createRunJournal,
|
|
368
|
+
reconcileDeadPid
|
|
369
|
+
};
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
// packages/run-plugin/src/worker/workflow-journal-writer.ts
|
|
373
|
+
var exports_workflow_journal_writer = {};
|
|
374
|
+
__export(exports_workflow_journal_writer, {
|
|
375
|
+
workflowJournalWriterService: () => workflowJournalWriterService,
|
|
376
|
+
createWorkflowTaskSelected: () => createWorkflowTaskSelected,
|
|
377
|
+
createWorkflowTargetSelected: () => createWorkflowTargetSelected,
|
|
378
|
+
createWorkflowStatusChanged: () => createWorkflowStatusChanged,
|
|
379
|
+
createWorkflowStarted: () => createWorkflowStarted,
|
|
380
|
+
createWorkflowOperatorNote: () => createWorkflowOperatorNote
|
|
381
|
+
});
|
|
382
|
+
import {
|
|
383
|
+
RIG_WORKFLOW_OPERATOR_NOTE,
|
|
384
|
+
RIG_WORKFLOW_STARTED,
|
|
385
|
+
RIG_WORKFLOW_STATUS_CHANGED,
|
|
386
|
+
RIG_WORKFLOW_TARGET_SELECTED,
|
|
387
|
+
RIG_WORKFLOW_TASK_SELECTED
|
|
388
|
+
} from "@rig/contracts";
|
|
389
|
+
function createWorkflowStarted(input) {
|
|
390
|
+
return {
|
|
391
|
+
schemaVersion: 1,
|
|
392
|
+
workflowId: input.workflowId,
|
|
393
|
+
target: input.target,
|
|
394
|
+
selectedRepo: input.selectedRepo,
|
|
395
|
+
owner: input.owner,
|
|
396
|
+
createdAt: input.createdAt ?? new Date().toISOString()
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
function createWorkflowTargetSelected(input) {
|
|
400
|
+
return {
|
|
401
|
+
schemaVersion: 1,
|
|
402
|
+
target: input.target,
|
|
403
|
+
...input.reason ? { reason: input.reason } : {},
|
|
404
|
+
selectedAt: input.selectedAt ?? new Date().toISOString()
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
function createWorkflowTaskSelected(input) {
|
|
408
|
+
return {
|
|
409
|
+
schemaVersion: 1,
|
|
410
|
+
taskId: input.taskId,
|
|
411
|
+
...input.title ? { title: input.title } : {},
|
|
412
|
+
selectedAt: input.selectedAt ?? new Date().toISOString()
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
function createWorkflowStatusChanged(input) {
|
|
416
|
+
return {
|
|
417
|
+
schemaVersion: 1,
|
|
418
|
+
status: input.status,
|
|
419
|
+
...input.detail ? { detail: input.detail } : {},
|
|
420
|
+
changedAt: input.changedAt ?? new Date().toISOString()
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
function createWorkflowOperatorNote(input) {
|
|
424
|
+
return {
|
|
425
|
+
schemaVersion: 1,
|
|
426
|
+
...input.noteId ? { noteId: input.noteId } : {},
|
|
427
|
+
note: input.note,
|
|
428
|
+
notedAt: input.notedAt ?? new Date().toISOString()
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
var workflowJournalWriterService;
|
|
432
|
+
var init_workflow_journal_writer = __esm(() => {
|
|
433
|
+
workflowJournalWriterService = {
|
|
434
|
+
appendStarted(appender, input) {
|
|
435
|
+
appender.appendEntry(RIG_WORKFLOW_STARTED, createWorkflowStarted(input));
|
|
436
|
+
},
|
|
437
|
+
appendTargetSelected(appender, input) {
|
|
438
|
+
appender.appendEntry(RIG_WORKFLOW_TARGET_SELECTED, createWorkflowTargetSelected(input));
|
|
439
|
+
},
|
|
440
|
+
appendTaskSelected(appender, input) {
|
|
441
|
+
appender.appendEntry(RIG_WORKFLOW_TASK_SELECTED, createWorkflowTaskSelected(input));
|
|
442
|
+
},
|
|
443
|
+
appendStatusChanged(appender, input) {
|
|
444
|
+
appender.appendEntry(RIG_WORKFLOW_STATUS_CHANGED, createWorkflowStatusChanged(input));
|
|
445
|
+
},
|
|
446
|
+
appendOperatorNote(appender, input) {
|
|
447
|
+
appender.appendEntry(RIG_WORKFLOW_OPERATOR_NOTE, createWorkflowOperatorNote(input));
|
|
448
|
+
}
|
|
449
|
+
};
|
|
450
|
+
});
|
|
451
|
+
|
|
452
|
+
// packages/run-plugin/src/worker/run-control-service.ts
|
|
453
|
+
var exports_run_control_service = {};
|
|
454
|
+
__export(exports_run_control_service, {
|
|
455
|
+
runControlService: () => runControlService
|
|
456
|
+
});
|
|
457
|
+
import { defineCapability as defineCapability3 } from "@rig/core/capability";
|
|
458
|
+
import { loadCapabilityForRoot as loadCapabilityForRoot2 } from "@rig/core/capability-loaders";
|
|
459
|
+
import {
|
|
460
|
+
RIG_CONTROL_SENTINEL_END,
|
|
461
|
+
RIG_INBOX_RESOLUTION_SENTINEL,
|
|
462
|
+
RIG_PAUSE_SENTINEL,
|
|
463
|
+
RIG_RESUME_SENTINEL,
|
|
464
|
+
RIG_STOP_SENTINEL,
|
|
465
|
+
RIG_STOP_SENTINEL_END,
|
|
466
|
+
RUN_READ_MODEL as RUN_READ_MODEL2,
|
|
467
|
+
RUN_SESSION_JOURNAL_WRITER
|
|
468
|
+
} from "@rig/contracts";
|
|
469
|
+
async function readModel(projectRoot) {
|
|
470
|
+
const service = await loadCapabilityForRoot2(projectRoot, RunReadModelCap2);
|
|
471
|
+
if (!service)
|
|
472
|
+
throw new Error("RUN_READ_MODEL capability unavailable: load @rig/run-plugin before using run control.");
|
|
473
|
+
return service;
|
|
474
|
+
}
|
|
475
|
+
function buildPauseSentinel(runId) {
|
|
476
|
+
return `${RIG_PAUSE_SENTINEL} runId=${runId} requestedBy=operator ${RIG_CONTROL_SENTINEL_END}`;
|
|
477
|
+
}
|
|
478
|
+
function buildResumeSentinel(runId) {
|
|
479
|
+
return `${RIG_RESUME_SENTINEL} runId=${runId} requestedBy=operator ${RIG_CONTROL_SENTINEL_END}`;
|
|
480
|
+
}
|
|
481
|
+
function buildStopSentinel(runId, reason) {
|
|
482
|
+
return `${RIG_STOP_SENTINEL} runId=${runId} reason=${reason} ${RIG_STOP_SENTINEL_END}`;
|
|
483
|
+
}
|
|
484
|
+
function buildInboxResolutionSentinel(runId, payload) {
|
|
485
|
+
return `${RIG_INBOX_RESOLUTION_SENTINEL} runId=${runId} data=${encodeURIComponent(JSON.stringify(payload))} requestedBy=operator ${RIG_CONTROL_SENTINEL_END}`;
|
|
486
|
+
}
|
|
487
|
+
function collabControlFrames(runId, control) {
|
|
488
|
+
switch (control.kind) {
|
|
489
|
+
case "steer":
|
|
490
|
+
return [{ t: "prompt", text: control.message }];
|
|
491
|
+
case "resume":
|
|
492
|
+
return [{ t: "prompt", text: `${buildResumeSentinel(runId)}
|
|
493
|
+
Continue the run from where it paused.` }];
|
|
494
|
+
case "pause":
|
|
495
|
+
return [
|
|
496
|
+
{ t: "prompt", text: `${buildPauseSentinel(runId)}
|
|
497
|
+
Pause this run after the current interruption settles.` },
|
|
498
|
+
{ t: "abort" }
|
|
499
|
+
];
|
|
500
|
+
case "stop":
|
|
501
|
+
return [
|
|
502
|
+
{ t: "prompt", text: `${buildStopSentinel(runId, control.reason)}
|
|
503
|
+
Stop this run and do not continue after the interruption settles.` },
|
|
504
|
+
{ t: "abort" }
|
|
505
|
+
];
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
async function loadCollabControlDeps() {
|
|
509
|
+
const [{ importRoomKey, seal }, { COLLAB_PROTO, packEnvelope, parseCollabLink }] = await Promise.all([
|
|
510
|
+
import("@oh-my-pi/pi-coding-agent/collab/crypto"),
|
|
511
|
+
import("@oh-my-pi/pi-coding-agent/collab/protocol")
|
|
512
|
+
]);
|
|
513
|
+
return { importRoomKey, seal, COLLAB_PROTO, packEnvelope, parseCollabLink };
|
|
514
|
+
}
|
|
515
|
+
async function sendSealedCollabFrames(joinLink, frames) {
|
|
516
|
+
const { importRoomKey, seal, COLLAB_PROTO, packEnvelope, parseCollabLink } = await loadCollabControlDeps();
|
|
517
|
+
const parsed = parseCollabLink(joinLink);
|
|
518
|
+
if ("error" in parsed)
|
|
519
|
+
throw new Error(parsed.error);
|
|
520
|
+
if (!parsed.writeToken)
|
|
521
|
+
throw new Error("Run collab link is read-only; cannot send control.");
|
|
522
|
+
const key = await importRoomKey(parsed.key);
|
|
523
|
+
const ws = new WebSocket(`${parsed.wsUrl}?role=guest`);
|
|
524
|
+
await new Promise((resolveOpen, rejectOpen) => {
|
|
525
|
+
ws.addEventListener("open", () => resolveOpen(), { once: true });
|
|
526
|
+
ws.addEventListener("error", () => rejectOpen(new Error("collab websocket error")), { once: true });
|
|
527
|
+
});
|
|
528
|
+
const hello = {
|
|
529
|
+
t: "hello",
|
|
530
|
+
proto: COLLAB_PROTO,
|
|
531
|
+
name: "rig-operator",
|
|
532
|
+
writeToken: Buffer.from(parsed.writeToken).toString("base64url")
|
|
533
|
+
};
|
|
534
|
+
ws.send(packEnvelope(0, await seal(key, hello)));
|
|
535
|
+
for (const frame of frames)
|
|
536
|
+
ws.send(packEnvelope(0, await seal(key, frame)));
|
|
537
|
+
try {
|
|
538
|
+
ws.close();
|
|
539
|
+
} catch {}
|
|
540
|
+
}
|
|
541
|
+
function isSteerableStatus(status, classification) {
|
|
542
|
+
switch (status) {
|
|
543
|
+
case "needs-attention":
|
|
544
|
+
case "waiting-approval":
|
|
545
|
+
case "waiting-user-input":
|
|
546
|
+
case "paused":
|
|
547
|
+
return false;
|
|
548
|
+
default:
|
|
549
|
+
return classification.isActive;
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
function controlAffordance(readModel2, run, purpose) {
|
|
553
|
+
const writable = Boolean(run.joinLink && !run.stale);
|
|
554
|
+
if (!writable)
|
|
555
|
+
return { allowed: false, reason: run.stale ? "run is stale" : "run has no join link" };
|
|
556
|
+
const classification = readModel2.classifyRun(run);
|
|
557
|
+
switch (purpose) {
|
|
558
|
+
case "steer":
|
|
559
|
+
return classification.phase === "active" || classification.phase === "starting" || classification.isNeedsAttention && isSteerableStatus(classification.status, classification) ? { allowed: true } : { allowed: false, reason: "run cannot be steered in its current phase" };
|
|
560
|
+
case "stop":
|
|
561
|
+
return classification.isActive && !classification.isTerminal ? { allowed: true } : { allowed: false, reason: "run cannot be stopped in its current phase" };
|
|
562
|
+
case "pause":
|
|
563
|
+
return classification.phase === "active" || classification.phase === "starting" ? { allowed: true } : { allowed: false, reason: "run cannot be paused in its current phase" };
|
|
564
|
+
case "resume":
|
|
565
|
+
return classification.phase === "paused" ? { allowed: true } : { allowed: false, reason: "run cannot be resumed in its current phase" };
|
|
566
|
+
case "restart":
|
|
567
|
+
case "delete":
|
|
568
|
+
case "prune":
|
|
569
|
+
return !run.live || run.stale ? { allowed: true } : { allowed: false, reason: "run is still live" };
|
|
570
|
+
case "attach":
|
|
571
|
+
case "resolve-inbox":
|
|
572
|
+
case undefined:
|
|
573
|
+
return { allowed: true };
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
async function selectedRun(projectRoot, runId, discoveryFilter) {
|
|
577
|
+
const service = await readModel(projectRoot);
|
|
578
|
+
const run = await service.getRun({ projectRoot, selector: { id: runId, kind: "any" }, ...discoveryFilter !== undefined ? { discoveryFilter } : {} });
|
|
579
|
+
return { service, run };
|
|
580
|
+
}
|
|
581
|
+
function targetFromRun(service, run, purpose) {
|
|
582
|
+
const affordance = controlAffordance(service, run, purpose);
|
|
583
|
+
return {
|
|
584
|
+
runId: run.runId,
|
|
585
|
+
taskId: run.taskId,
|
|
586
|
+
sessionId: run.runId,
|
|
587
|
+
sessionPath: run.sessionPath,
|
|
588
|
+
joinLink: run.joinLink,
|
|
589
|
+
webLink: run.webLink,
|
|
590
|
+
relayUrl: run.relayUrl,
|
|
591
|
+
collabCwd: run.collabCwd,
|
|
592
|
+
live: run.live,
|
|
593
|
+
stale: run.stale,
|
|
594
|
+
canDeliver: affordance.allowed,
|
|
595
|
+
reason: affordance.allowed ? null : affordance.reason ?? null
|
|
596
|
+
};
|
|
597
|
+
}
|
|
598
|
+
function inboxResolutionControl(runId, resolution) {
|
|
599
|
+
return { kind: "steer", message: buildInboxResolutionSentinel(runId, resolution) };
|
|
600
|
+
}
|
|
601
|
+
var RunReadModelCap2, runControlService;
|
|
602
|
+
var init_run_control_service = __esm(() => {
|
|
603
|
+
RunReadModelCap2 = defineCapability3(RUN_READ_MODEL2);
|
|
604
|
+
runControlService = {
|
|
605
|
+
async resolveControlTarget(input) {
|
|
606
|
+
const { service, run } = await selectedRun(input.projectRoot, input.runId, input.discoveryFilter);
|
|
607
|
+
return run ? targetFromRun(service, run, input.purpose) : null;
|
|
608
|
+
},
|
|
609
|
+
async deliverControl(input) {
|
|
610
|
+
const { service, run } = await selectedRun(input.projectRoot, input.runId, input.discoveryFilter);
|
|
611
|
+
if (!run)
|
|
612
|
+
return { runId: input.runId, kind: input.control.kind, status: "not-found", delivered: false, detail: "run not found" };
|
|
613
|
+
const affordance = controlAffordance(service, run, input.control.kind);
|
|
614
|
+
if (!affordance.allowed) {
|
|
615
|
+
return { runId: run.runId, kind: input.control.kind, status: run.joinLink && !run.stale ? "unsupported" : "not-live", delivered: false, detail: affordance.reason ?? `Run ${run.runId} is not writable in its current phase.` };
|
|
616
|
+
}
|
|
617
|
+
try {
|
|
618
|
+
if (!run.joinLink)
|
|
619
|
+
throw new Error(`Run ${run.runId} has no writable collab join link; attach interactively to ${input.control.kind}.`);
|
|
620
|
+
await sendSealedCollabFrames(run.joinLink, collabControlFrames(run.runId, input.control));
|
|
621
|
+
return { runId: run.runId, kind: input.control.kind, status: "delivered", delivered: true };
|
|
622
|
+
} catch (error) {
|
|
623
|
+
return { runId: run.runId, kind: input.control.kind, status: "unsupported", delivered: false, detail: error instanceof Error ? error.message : String(error) };
|
|
624
|
+
}
|
|
625
|
+
},
|
|
626
|
+
async resolveInboxRequest(input) {
|
|
627
|
+
const target = await this.resolveControlTarget({ projectRoot: input.projectRoot, runId: input.runId, purpose: "resolve-inbox", ...input.discoveryFilter !== undefined ? { discoveryFilter: input.discoveryFilter } : {} });
|
|
628
|
+
if (!target)
|
|
629
|
+
return { runId: input.runId, requestId: input.resolution.requestId, kind: input.resolution.kind, status: "not-found", delivered: false, detail: "run not found" };
|
|
630
|
+
if (!target.canDeliver)
|
|
631
|
+
return { runId: target.runId, requestId: input.resolution.requestId, kind: input.resolution.kind, status: "not-live", delivered: false, detail: target.reason ?? "run is not deliverable" };
|
|
632
|
+
const result = await this.deliverControl({ projectRoot: input.projectRoot, runId: target.runId, control: inboxResolutionControl(target.runId, input.resolution), ...input.discoveryFilter !== undefined ? { discoveryFilter: input.discoveryFilter } : {} });
|
|
633
|
+
const status = result.delivered ? "resolved" : result.status === "delivered" ? "resolved" : result.status;
|
|
634
|
+
return { runId: target.runId, requestId: input.resolution.requestId, kind: input.resolution.kind, status, delivered: result.delivered, ...result.detail !== undefined ? { detail: result.detail } : {} };
|
|
635
|
+
},
|
|
636
|
+
async resolveResumePlan(input) {
|
|
637
|
+
const { service, run } = await selectedRun(input.projectRoot, input.runId, input.discoveryFilter);
|
|
638
|
+
if (!run)
|
|
639
|
+
return null;
|
|
640
|
+
const affordance = controlAffordance(service, run, "resume");
|
|
641
|
+
if (affordance.allowed)
|
|
642
|
+
return { kind: "deliver-control", runId: run.runId, run };
|
|
643
|
+
if (!run.live || run.stale) {
|
|
644
|
+
return run.taskId ? { kind: "redispatch-task", runId: run.runId, taskId: run.taskId, title: run.title } : { kind: "unavailable", runId: run.runId, reason: "run is not live and has no task id to re-dispatch" };
|
|
645
|
+
}
|
|
646
|
+
return { kind: "unavailable", runId: run.runId, reason: affordance.reason ?? "run cannot be resumed in its current phase" };
|
|
647
|
+
},
|
|
648
|
+
async reconcileDeadPid(input) {
|
|
649
|
+
const RunSessionJournalWriterCap = defineCapability3(RUN_SESSION_JOURNAL_WRITER);
|
|
650
|
+
const writer = await loadCapabilityForRoot2(input.projectRoot, RunSessionJournalWriterCap);
|
|
651
|
+
if (!writer) {
|
|
652
|
+
return { runId: input.runId, updated: false, status: "unavailable", detail: "RUN_SESSION_JOURNAL_WRITER capability unavailable" };
|
|
653
|
+
}
|
|
654
|
+
return writer.reconcileDeadPid({
|
|
655
|
+
projectRoot: input.projectRoot,
|
|
656
|
+
runId: input.runId,
|
|
657
|
+
sessionPath: input.sessionPath,
|
|
658
|
+
...input.reason !== undefined ? { reason: input.reason } : {}
|
|
659
|
+
});
|
|
660
|
+
}
|
|
661
|
+
};
|
|
662
|
+
});
|
|
663
|
+
|
|
664
|
+
// packages/run-plugin/src/worker/local-run-changes.ts
|
|
665
|
+
import { existsSync, mkdirSync, watch } from "fs";
|
|
666
|
+
import { dirname, resolve } from "path";
|
|
667
|
+
import { Effect, Queue, Stream } from "effect";
|
|
668
|
+
function findNearestGitCheckoutRoot(startDir) {
|
|
669
|
+
let current = resolve(startDir);
|
|
670
|
+
for (;; ) {
|
|
671
|
+
if (existsSync(resolve(current, ".git")))
|
|
672
|
+
return current;
|
|
673
|
+
const parent = dirname(current);
|
|
674
|
+
if (parent === current)
|
|
675
|
+
return null;
|
|
676
|
+
current = parent;
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
function resolveCheckoutRoot(projectRoot) {
|
|
680
|
+
const normalizedProjectRoot = resolve(projectRoot);
|
|
681
|
+
const explicit = process.env.MONOREPO_ROOT?.trim();
|
|
682
|
+
if (explicit) {
|
|
683
|
+
const explicitRoot = resolve(explicit);
|
|
684
|
+
const gitRoot = findNearestGitCheckoutRoot(explicitRoot);
|
|
685
|
+
if (gitRoot)
|
|
686
|
+
return gitRoot;
|
|
687
|
+
throw new Error(`MONOREPO_ROOT points to ${explicitRoot}, but no git checkout was found there or above it.`);
|
|
688
|
+
}
|
|
689
|
+
return findNearestGitCheckoutRoot(normalizedProjectRoot) ?? normalizedProjectRoot;
|
|
690
|
+
}
|
|
691
|
+
function isRelevantLocalRunChange(filename) {
|
|
692
|
+
if (filename === null || filename === undefined)
|
|
693
|
+
return true;
|
|
694
|
+
const raw = filename.toString();
|
|
695
|
+
if (!raw.trim())
|
|
696
|
+
return true;
|
|
697
|
+
const segments = raw.split(/[\\/]+/).filter(Boolean);
|
|
698
|
+
if (segments.some((segment) => segment === ".git" || segment === "node_modules" || segment === "build" || segment === "dist" || segment === "out" || segment === ".next" || segment === "coverage")) {
|
|
699
|
+
return false;
|
|
700
|
+
}
|
|
701
|
+
const rigIndex = segments.lastIndexOf(".rig");
|
|
702
|
+
if (rigIndex < 0)
|
|
703
|
+
return false;
|
|
704
|
+
const rigChild = segments[rigIndex + 1];
|
|
705
|
+
if (rigChild === "session")
|
|
706
|
+
return true;
|
|
707
|
+
return rigChild === "runtime-context.json" && segments[rigIndex + 2] === undefined;
|
|
708
|
+
}
|
|
709
|
+
var localRunChanges = (projectRoot) => Stream.callback((queue) => Effect.gen(function* () {
|
|
710
|
+
const worktreesRoot = resolve(resolveCheckoutRoot(projectRoot), ".worktrees");
|
|
711
|
+
if (!existsSync(worktreesRoot)) {
|
|
712
|
+
try {
|
|
713
|
+
mkdirSync(worktreesRoot, { recursive: true });
|
|
714
|
+
} catch {}
|
|
715
|
+
}
|
|
716
|
+
const watcher = watch(worktreesRoot, { recursive: true }, (_event, filename) => {
|
|
717
|
+
if (!isRelevantLocalRunChange(filename))
|
|
718
|
+
return;
|
|
719
|
+
Queue.offerUnsafe(queue, undefined);
|
|
720
|
+
});
|
|
721
|
+
watcher.on("error", () => {});
|
|
722
|
+
yield* Effect.addFinalizer(() => Effect.sync(() => watcher.close()));
|
|
723
|
+
}), { bufferSize: 1, strategy: "sliding" });
|
|
724
|
+
var init_local_run_changes = () => {};
|
|
725
|
+
|
|
726
|
+
// packages/run-plugin/src/worker/notify-cap.ts
|
|
727
|
+
import { NOTIFY_SERVICE_CAPABILITY } from "@rig/contracts";
|
|
728
|
+
import { defineCapability as defineCapability4 } from "@rig/core/capability";
|
|
729
|
+
import { resolvePluginHost } from "@rig/core/project-plugins";
|
|
730
|
+
async function resolveNotifyService(projectRoot) {
|
|
731
|
+
const { host } = await resolvePluginHost(projectRoot);
|
|
732
|
+
return NotifyCap.resolve(host);
|
|
733
|
+
}
|
|
734
|
+
var NotifyCap;
|
|
735
|
+
var init_notify_cap = __esm(() => {
|
|
736
|
+
NotifyCap = defineCapability4(NOTIFY_SERVICE_CAPABILITY);
|
|
737
|
+
});
|
|
738
|
+
|
|
739
|
+
// packages/run-plugin/src/worker/notifications.ts
|
|
740
|
+
async function dispatchRunNotifications(projectRoot, runId, taskId, outcome, detail) {
|
|
741
|
+
try {
|
|
742
|
+
const notifier = await resolveNotifyService(projectRoot);
|
|
743
|
+
if (!notifier)
|
|
744
|
+
return;
|
|
745
|
+
const event = { runId, type: `run.${outcome}`, timestamp: new Date().toISOString(), payload: { taskId, detail } };
|
|
746
|
+
await Promise.race([
|
|
747
|
+
notifier.notify(event),
|
|
748
|
+
new Promise((resolveCap) => setTimeout(resolveCap, 5000))
|
|
749
|
+
]);
|
|
750
|
+
} catch {}
|
|
751
|
+
}
|
|
752
|
+
var init_notifications = __esm(() => {
|
|
753
|
+
init_notify_cap();
|
|
754
|
+
});
|
|
755
|
+
|
|
756
|
+
// packages/run-plugin/src/worker/panel-plugin.ts
|
|
757
|
+
import { createProjectPluginHost } from "@rig/core/project-plugins";
|
|
758
|
+
import { RIG_CAPABILITY_PANEL_SLOT, RIG_RUN_STOP_PANEL_ACTION, RIG_SUPERVISOR_PANEL_ID } from "@rig/contracts";
|
|
759
|
+
async function produceWorkerPanelPayload(producer, context) {
|
|
760
|
+
if (!producer.produce)
|
|
761
|
+
return;
|
|
762
|
+
let timeout;
|
|
763
|
+
try {
|
|
764
|
+
return await Promise.race([
|
|
765
|
+
Promise.resolve(producer.produce(context)),
|
|
766
|
+
new Promise((resolve2) => {
|
|
767
|
+
timeout = setTimeout(() => resolve2(undefined), PANEL_PRODUCER_TIMEOUT_MS);
|
|
768
|
+
})
|
|
769
|
+
]);
|
|
770
|
+
} finally {
|
|
771
|
+
clearTimeout(timeout);
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
async function loadWorkerPanelRegistry(projectRoot) {
|
|
775
|
+
const { host } = await createProjectPluginHost(projectRoot, {
|
|
776
|
+
mode: "strict-config-only"
|
|
777
|
+
});
|
|
778
|
+
return {
|
|
779
|
+
registrations: host.listPanels().filter((registration) => registration.slot === RIG_CAPABILITY_PANEL_SLOT),
|
|
780
|
+
producers: host.listExecutablePanels().filter((registration) => registration.slot === RIG_CAPABILITY_PANEL_SLOT)
|
|
781
|
+
};
|
|
782
|
+
}
|
|
783
|
+
var RIG_PANELS_CUSTOM_MESSAGE_TYPE = "rig-panels", PANEL_PRODUCER_TIMEOUT_MS = 2000;
|
|
784
|
+
var init_panel_plugin = () => {};
|
|
785
|
+
|
|
786
|
+
// packages/run-plugin/src/worker/constants.ts
|
|
787
|
+
var TRACKED_RUN_STALL_MS, RUN_PROCESS_STALL_SWEEP_MS, RUN_PROCESS_STALL_DETAIL = "Run process made no OMP session progress for 20+ minutes; recording a stall so recovery can requeue or resume the session.";
|
|
788
|
+
var init_constants = __esm(() => {
|
|
789
|
+
TRACKED_RUN_STALL_MS = 20 * 60 * 1000;
|
|
790
|
+
RUN_PROCESS_STALL_SWEEP_MS = 60 * 1000;
|
|
791
|
+
});
|
|
792
|
+
|
|
793
|
+
// packages/run-plugin/src/worker/stall.ts
|
|
794
|
+
function timestampMs(value) {
|
|
795
|
+
if (value === null || value === undefined)
|
|
796
|
+
return null;
|
|
797
|
+
const ms = value instanceof Date ? value.getTime() : typeof value === "number" ? value : Date.parse(value);
|
|
798
|
+
return Number.isFinite(ms) ? ms : null;
|
|
799
|
+
}
|
|
800
|
+
function computeRunStall(input) {
|
|
801
|
+
const lastActivityAt = timestampMs(input.lastActivityAt);
|
|
802
|
+
const now = timestampMs(input.now);
|
|
803
|
+
if (lastActivityAt === null || now === null || input.thresholdMs <= 0)
|
|
804
|
+
return false;
|
|
805
|
+
return now - lastActivityAt >= input.thresholdMs;
|
|
806
|
+
}
|
|
807
|
+
function appendRunStallDetected(journal, detail = RUN_PROCESS_STALL_DETAIL) {
|
|
808
|
+
if (!journal)
|
|
809
|
+
return false;
|
|
810
|
+
try {
|
|
811
|
+
journal.appendStall({ detail });
|
|
812
|
+
return true;
|
|
813
|
+
} catch (error) {
|
|
814
|
+
console.warn(`[rig-run] stall-detected append failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
815
|
+
return false;
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
function startRunProcessStallMonitor(opts) {
|
|
819
|
+
if (!opts.journal)
|
|
820
|
+
return () => {};
|
|
821
|
+
let stallDetected = opts.alreadyStalled === true;
|
|
822
|
+
const thresholdMs = opts.thresholdMs ?? TRACKED_RUN_STALL_MS;
|
|
823
|
+
const now = opts.now ?? (() => Date.now());
|
|
824
|
+
const timer = setInterval(() => {
|
|
825
|
+
if (stallDetected)
|
|
826
|
+
return;
|
|
827
|
+
if (!computeRunStall({ lastActivityAt: opts.lastActivityAt(), now: now(), thresholdMs }))
|
|
828
|
+
return;
|
|
829
|
+
stallDetected = true;
|
|
830
|
+
appendRunStallDetected(opts.journal);
|
|
831
|
+
}, opts.intervalMs ?? RUN_PROCESS_STALL_SWEEP_MS);
|
|
832
|
+
if (typeof timer.unref === "function")
|
|
833
|
+
timer.unref();
|
|
834
|
+
return () => clearInterval(timer);
|
|
835
|
+
}
|
|
836
|
+
var init_stall = __esm(() => {
|
|
837
|
+
init_constants();
|
|
838
|
+
});
|
|
839
|
+
|
|
840
|
+
// packages/run-plugin/src/worker/utils.ts
|
|
841
|
+
import { RIG_WORKFLOW_STATUS_CHANGED as RIG_WORKFLOW_STATUS_CHANGED2 } from "@rig/contracts";
|
|
842
|
+
import { rigProjectRootFromEnv } from "@rig/core/root-resolver";
|
|
843
|
+
function customEntries(entries) {
|
|
844
|
+
const customs = [];
|
|
845
|
+
for (const entry of entries) {
|
|
846
|
+
if (entry.type === "custom")
|
|
847
|
+
customs.push(entry);
|
|
848
|
+
}
|
|
849
|
+
return customs;
|
|
850
|
+
}
|
|
851
|
+
var init_utils = () => {};
|
|
852
|
+
|
|
853
|
+
// packages/run-plugin/src/worker/autohost.ts
|
|
854
|
+
import {
|
|
855
|
+
PLACEMENT_RUN_TRANSPORT,
|
|
856
|
+
RIG_RUN_STOP_PANEL_ACTION as RIG_RUN_STOP_PANEL_ACTION2,
|
|
857
|
+
RUN_IDENTITY_ENV,
|
|
858
|
+
RUN_REGISTRY_BACKBONE,
|
|
859
|
+
LIFECYCLE_VERIFICATION_SERVICE,
|
|
860
|
+
RUN_READ_MODEL as RUN_READ_MODEL3,
|
|
861
|
+
RUN_SESSION_JOURNAL as RUN_SESSION_JOURNAL2,
|
|
862
|
+
RUN_SESSION_JOURNAL_WRITER as RUN_SESSION_JOURNAL_WRITER2,
|
|
863
|
+
TRANSPORT_CONFIG,
|
|
864
|
+
GITHUB_CLI,
|
|
865
|
+
GITHUB_TOKEN_RESOLVER,
|
|
866
|
+
REPO_CHANGE_SET,
|
|
867
|
+
REPO_GIT_WORKFLOW,
|
|
868
|
+
REPO_NATIVE_GIT,
|
|
869
|
+
TASK_ARTIFACTS,
|
|
870
|
+
TASK_SOURCE_REFLECTION,
|
|
871
|
+
TASK_STATE_STORE
|
|
872
|
+
} from "@rig/contracts";
|
|
873
|
+
import { Duration, Effect as Effect2, Fiber, Stream as Stream2 } from "effect";
|
|
874
|
+
import { defineCapability as defineCapability5, defineServiceCapability } from "@rig/core/capability";
|
|
875
|
+
import { installCapability as installCapability2, loadCapabilityForRoot as loadCapabilityForRoot3, requireInstalledCapability } from "@rig/core/capability-loaders";
|
|
876
|
+
import { adopt as adoptRunWorkerKernel } from "@rig/core/kernel-entrypoint";
|
|
877
|
+
async function resolveRunRegistryNamespace(projectRoot, identityNamespaceKey) {
|
|
878
|
+
if (identityNamespaceKey)
|
|
879
|
+
return identityNamespaceKey;
|
|
880
|
+
const transportConfig = await loadCapabilityForRoot3(projectRoot, TransportConfigCap);
|
|
881
|
+
return transportConfig?.resolveOwnerNamespaceKey({ projectRoot }) ?? "anonymous";
|
|
882
|
+
}
|
|
883
|
+
function syntheticRegistryOwner(namespaceKey) {
|
|
884
|
+
const githubUserId = namespaceKey.startsWith("gh:") ? namespaceKey.slice(3) : namespaceKey;
|
|
885
|
+
return {
|
|
886
|
+
githubUserId: githubUserId || "anonymous",
|
|
887
|
+
login: "anonymous",
|
|
888
|
+
namespaceKey
|
|
889
|
+
};
|
|
890
|
+
}
|
|
891
|
+
function sanitizeRegistryProjectionValue(value) {
|
|
892
|
+
if (Array.isArray(value))
|
|
893
|
+
return value.map(sanitizeRegistryProjectionValue);
|
|
894
|
+
if (!value || typeof value !== "object")
|
|
895
|
+
return value;
|
|
896
|
+
const sanitized = {};
|
|
897
|
+
for (const [key, child] of Object.entries(value)) {
|
|
898
|
+
sanitized[key] = REGISTRY_SECRET_LINK_FIELDS.has(key) ? null : sanitizeRegistryProjectionValue(child);
|
|
899
|
+
}
|
|
900
|
+
return sanitized;
|
|
901
|
+
}
|
|
902
|
+
function sanitizeRegistryProjection(projection) {
|
|
903
|
+
return sanitizeRegistryProjectionValue(projection);
|
|
904
|
+
}
|
|
905
|
+
function textFromContent(content) {
|
|
906
|
+
if (typeof content === "string")
|
|
907
|
+
return content;
|
|
908
|
+
if (!Array.isArray(content))
|
|
909
|
+
return null;
|
|
910
|
+
const text = content.map((part) => part && typeof part === "object" && ("text" in part) && typeof part.text === "string" ? part.text : "").filter(Boolean).join(`
|
|
911
|
+
`).trim();
|
|
912
|
+
return text || null;
|
|
913
|
+
}
|
|
914
|
+
function textFromSessionEntry(entry) {
|
|
915
|
+
if (!entry || typeof entry !== "object")
|
|
916
|
+
return null;
|
|
917
|
+
const record = entry;
|
|
918
|
+
if (record.type === "custom_message")
|
|
919
|
+
return textFromContent(record.content);
|
|
920
|
+
if (record.type === "message")
|
|
921
|
+
return textFromAgentMessage(record.message);
|
|
922
|
+
return null;
|
|
923
|
+
}
|
|
924
|
+
function textFromAgentMessage(message) {
|
|
925
|
+
if (!message || typeof message !== "object")
|
|
926
|
+
return null;
|
|
927
|
+
return textFromContent(message.content);
|
|
928
|
+
}
|
|
929
|
+
function detectRunControlText(codec, text, runId) {
|
|
930
|
+
const stop = codec.parseStopSentinel(text, runId);
|
|
931
|
+
if (stop)
|
|
932
|
+
return { kind: "stop", reason: stop.reason };
|
|
933
|
+
if (codec.parsePauseSentinel(text, runId))
|
|
934
|
+
return { kind: "pause" };
|
|
935
|
+
if (codec.parseResumeSentinel(text, runId))
|
|
936
|
+
return { kind: "resume" };
|
|
937
|
+
const resolution = codec.parseInboxResolutionSentinel(text, runId);
|
|
938
|
+
if (resolution)
|
|
939
|
+
return { kind: "inbox", resolution };
|
|
940
|
+
return null;
|
|
941
|
+
}
|
|
942
|
+
async function installIfResolved(projectRoot, capability) {
|
|
943
|
+
const impl = await loadCapabilityForRoot3(projectRoot, capability);
|
|
944
|
+
if (impl)
|
|
945
|
+
installCapability2(capability, impl);
|
|
946
|
+
}
|
|
947
|
+
async function installRunWorkerSemanticCapabilities(projectRoot) {
|
|
948
|
+
await installIfResolved(projectRoot, GitHubCliCap);
|
|
949
|
+
await installIfResolved(projectRoot, GitHubTokenResolverCap);
|
|
950
|
+
await installIfResolved(projectRoot, RepoChangeSetCap);
|
|
951
|
+
await installIfResolved(projectRoot, RepoGitWorkflowCap);
|
|
952
|
+
await installIfResolved(projectRoot, RepoNativeGitCap);
|
|
953
|
+
await installIfResolved(projectRoot, TaskArtifactsCap);
|
|
954
|
+
await installIfResolved(projectRoot, TaskStateStoreCap);
|
|
955
|
+
}
|
|
956
|
+
async function maybeStartRunProcessAutohost(api, ctx) {
|
|
957
|
+
if (process.env.RIG_RUN_PROCESS !== "1")
|
|
958
|
+
return null;
|
|
959
|
+
const envRunId = process.env.RIG_RUN_ID?.trim();
|
|
960
|
+
if (!envRunId)
|
|
961
|
+
throw new Error("RIG_RUN_ID is required when RIG_RUN_PROCESS=1");
|
|
962
|
+
const projectRoot = process.env.PROJECT_RIG_ROOT ?? process.cwd();
|
|
963
|
+
const sessionJournal = await loadCapabilityForRoot3(projectRoot, RunSessionJournalCap2);
|
|
964
|
+
if (!sessionJournal) {
|
|
965
|
+
throw new Error("RUN_SESSION_JOURNAL capability unavailable in run-worker autohost: ensure @rig/run-plugin (default bundle) is installed.");
|
|
966
|
+
}
|
|
967
|
+
installCapability2(RunSessionJournalCap2, sessionJournal);
|
|
968
|
+
const sessionManagerRunId = typeof ctx.sessionManager.getSessionId === "function" ? ctx.sessionManager.getSessionId().trim() : "";
|
|
969
|
+
const runId = sessionJournal.sessionIdFromSessionFile(ctx.sessionManager.getSessionFile()) || sessionManagerRunId;
|
|
970
|
+
if (!runId)
|
|
971
|
+
throw new Error("OMP session id is required when RIG_RUN_PROCESS=1; RIG_RUN_ID is only a dispatch handle.");
|
|
972
|
+
await installRunWorkerSemanticCapabilities(projectRoot);
|
|
973
|
+
const verificationService = await loadCapabilityForRoot3(projectRoot, LifecycleVerificationServiceCap);
|
|
974
|
+
if (verificationService) {
|
|
975
|
+
installCapability2(LifecycleVerificationServiceCap, verificationService);
|
|
976
|
+
}
|
|
977
|
+
const taskSourceReflectionService = await loadCapabilityForRoot3(projectRoot, TaskSourceReflectionCap);
|
|
978
|
+
const journalWriter = await loadCapabilityForRoot3(projectRoot, RunSessionJournalWriterCap);
|
|
979
|
+
if (!journalWriter) {
|
|
980
|
+
throw new Error("RUN_SESSION_JOURNAL_WRITER capability unavailable in run-worker autohost: ensure @rig/run-plugin is installed.");
|
|
981
|
+
}
|
|
982
|
+
installCapability2(RunSessionJournalWriterCap, journalWriter);
|
|
983
|
+
const journal = await journalWriter.createRunJournal(ctx.sessionManager, runId);
|
|
984
|
+
const placementTransport = await loadCapabilityForRoot3(projectRoot, PlacementTransportCap);
|
|
985
|
+
if (!placementTransport) {
|
|
986
|
+
throw new Error("placement run transport capability unavailable: ensure @rig/transport-plugin is installed.");
|
|
987
|
+
}
|
|
988
|
+
await adoptRunWorkerKernel(projectRoot, {
|
|
989
|
+
entrypoint: "run-worker",
|
|
990
|
+
hydrateEnv: true,
|
|
991
|
+
transport: placementTransport,
|
|
992
|
+
...journal ? { journal: journal.kernel } : {}
|
|
993
|
+
});
|
|
994
|
+
if (!ctx.hasUI)
|
|
995
|
+
return null;
|
|
996
|
+
const collab = ctx.collab;
|
|
997
|
+
const startHost = collab?.startCollabHost ?? collab?.startHost;
|
|
998
|
+
if (!startHost)
|
|
999
|
+
throw new Error("OMP collab host facade is unavailable for Rig run process.");
|
|
1000
|
+
const identityEnv = await loadCapabilityForRoot3(projectRoot, RunIdentityEnvCap);
|
|
1001
|
+
const identity = identityEnv?.resolveRigIdentity(ctx) ?? null;
|
|
1002
|
+
const runReadModel = await loadCapabilityForRoot3(projectRoot, RunReadModelCap3);
|
|
1003
|
+
if (!runReadModel) {
|
|
1004
|
+
throw new Error("RUN_READ_MODEL capability unavailable in run-worker autohost: ensure @rig/run-plugin (default bundle) is installed.");
|
|
1005
|
+
}
|
|
1006
|
+
const registryBackbone = await loadCapabilityForRoot3(projectRoot, RunRegistryBackboneCap);
|
|
1007
|
+
if (registryBackbone)
|
|
1008
|
+
installCapability2(RunRegistryBackboneCap, registryBackbone);
|
|
1009
|
+
const panelRegistry = await loadWorkerPanelRegistry(projectRoot);
|
|
1010
|
+
let cachedProjectionParts = null;
|
|
1011
|
+
const currentProjectionEntries = () => {
|
|
1012
|
+
const branch = ctx.sessionManager.getBranch();
|
|
1013
|
+
const lastBranchEntry = branch.at(-1);
|
|
1014
|
+
const lastBranchObject = lastBranchEntry && typeof lastBranchEntry === "object" ? lastBranchEntry : null;
|
|
1015
|
+
if (!cachedProjectionParts || cachedProjectionParts.branchLength !== branch.length || cachedProjectionParts.lastBranchEntry !== lastBranchObject) {
|
|
1016
|
+
const entries = customEntries(branch);
|
|
1017
|
+
cachedProjectionParts = {
|
|
1018
|
+
branchLength: branch.length,
|
|
1019
|
+
lastBranchEntry: lastBranchObject,
|
|
1020
|
+
entries
|
|
1021
|
+
};
|
|
1022
|
+
}
|
|
1023
|
+
return cachedProjectionParts.entries;
|
|
1024
|
+
};
|
|
1025
|
+
let runProjection = runReadModel.buildSessionProjection({ runId, entries: currentProjectionEntries() });
|
|
1026
|
+
const buildWorkerBootstrapProjection = () => {
|
|
1027
|
+
runProjection = runReadModel.buildSessionProjection({ runId, entries: currentProjectionEntries() });
|
|
1028
|
+
return runProjection;
|
|
1029
|
+
};
|
|
1030
|
+
const taskIdAtStart = process.env.RIG_TASK_ID?.trim() || runProjection.record.taskId;
|
|
1031
|
+
const runDisplayTitle = (() => {
|
|
1032
|
+
const base = process.env.RIG_RUN_TITLE?.trim() || `Rig run ${runId}`;
|
|
1033
|
+
return taskIdAtStart && !base.includes(taskIdAtStart) ? `[${taskIdAtStart}] ${base}` : base;
|
|
1034
|
+
})();
|
|
1035
|
+
collab?.stopHost;
|
|
1036
|
+
let closeoutStarted = false;
|
|
1037
|
+
let forcedSteerUsed = false;
|
|
1038
|
+
let lastRunActivityAt = Date.now();
|
|
1039
|
+
const markRunActivity = () => {
|
|
1040
|
+
lastRunActivityAt = Date.now();
|
|
1041
|
+
};
|
|
1042
|
+
let runRegistryHeartbeat = null;
|
|
1043
|
+
let runRegistryRoomId = null;
|
|
1044
|
+
let workerProjectionConnection = null;
|
|
1045
|
+
let workerProjectionFiber = null;
|
|
1046
|
+
const projectRootForTransport = rigProjectRootFromEnv();
|
|
1047
|
+
const transportConfig = await loadCapabilityForRoot3(projectRootForTransport, TransportConfigCap);
|
|
1048
|
+
const runRegistryNamespace = await resolveRunRegistryNamespace(projectRootForTransport, identity?.owner?.namespaceKey);
|
|
1049
|
+
const runRegistryBaseUrl = transportConfig?.resolveRegistryBaseUrl({ projectRoot: projectRootForTransport }) ?? "";
|
|
1050
|
+
const runRelayUrl = transportConfig?.resolveRelayUrl() ?? "";
|
|
1051
|
+
const runRegistryOwner = identity?.owner ?? syntheticRegistryOwner(runRegistryNamespace);
|
|
1052
|
+
const runRegistryRepo = identity?.selectedRepo ?? "";
|
|
1053
|
+
const runRegistry = registryBackbone?.createRegistryClient({ baseUrl: runRegistryBaseUrl, namespaceKey: runRegistryNamespace }) ?? null;
|
|
1054
|
+
let runRegistryLinks = {};
|
|
1055
|
+
const processedControlEntryIds = new Set((ctx.sessionManager.getEntries?.() ?? []).map((entry) => entry && typeof entry === "object" && typeof entry.id === "string" ? entry.id : null).filter((id) => id !== null));
|
|
1056
|
+
const processedControlEntryObjects = new WeakSet;
|
|
1057
|
+
let pendingPause = false;
|
|
1058
|
+
let pendingStopReason;
|
|
1059
|
+
const buildCurrentRegistryProjection = (links = runRegistryLinks) => {
|
|
1060
|
+
const entries = currentProjectionEntries();
|
|
1061
|
+
const cwd = process.cwd();
|
|
1062
|
+
const projectionInput = {
|
|
1063
|
+
runId,
|
|
1064
|
+
entries,
|
|
1065
|
+
title: runDisplayTitle,
|
|
1066
|
+
taskId: taskIdAtStart ?? null,
|
|
1067
|
+
joinLink: links.joinLink ?? null,
|
|
1068
|
+
webLink: links.webLink ?? null,
|
|
1069
|
+
relayUrl: links.relayUrl ?? null,
|
|
1070
|
+
sessionPath: ctx.sessionManager.getSessionFile() ?? null,
|
|
1071
|
+
cwd,
|
|
1072
|
+
collabCwd: cwd,
|
|
1073
|
+
dispatchHandle: process.env.RIG_RUN_ID?.trim() || null,
|
|
1074
|
+
timelineLimit: REGISTRY_PROJECTION_TIMELINE_LIMIT
|
|
1075
|
+
};
|
|
1076
|
+
return sanitizeRegistryProjection(runReadModel.buildRegistryProjection(projectionInput));
|
|
1077
|
+
};
|
|
1078
|
+
let lastRigPanelsSnapshotJson = "";
|
|
1079
|
+
const publishRigPanelsSnapshot = async () => {
|
|
1080
|
+
const appendCustomMessageEntry = ctx.sessionManager.appendCustomMessageEntry?.bind(ctx.sessionManager);
|
|
1081
|
+
if (!appendCustomMessageEntry)
|
|
1082
|
+
return;
|
|
1083
|
+
const folded = buildWorkerBootstrapProjection();
|
|
1084
|
+
const producerContext = {
|
|
1085
|
+
projectRoot,
|
|
1086
|
+
runId,
|
|
1087
|
+
folded,
|
|
1088
|
+
...taskIdAtStart !== undefined ? { taskIdAtStart } : {},
|
|
1089
|
+
runDisplayTitle
|
|
1090
|
+
};
|
|
1091
|
+
const payloadEntries = await Promise.all(panelRegistry.producers.map(async (producer) => {
|
|
1092
|
+
try {
|
|
1093
|
+
const payload = await produceWorkerPanelPayload(producer, producerContext);
|
|
1094
|
+
return payload === undefined ? null : [producer.id, payload];
|
|
1095
|
+
} catch (error) {
|
|
1096
|
+
console.error(`[rig-run] panel-producer-failed panel=${producer.id} ${error instanceof Error ? error.message : String(error)}`);
|
|
1097
|
+
return null;
|
|
1098
|
+
}
|
|
1099
|
+
}));
|
|
1100
|
+
const payloads = Object.fromEntries(payloadEntries.filter((entry) => entry !== null));
|
|
1101
|
+
const registrations = panelRegistry.registrations.map((panel) => ({
|
|
1102
|
+
id: panel.id,
|
|
1103
|
+
slot: panel.slot,
|
|
1104
|
+
title: panel.title,
|
|
1105
|
+
capabilityId: panel.capabilityId,
|
|
1106
|
+
description: panel.description,
|
|
1107
|
+
badge: panel.badge,
|
|
1108
|
+
disabled: panel.disabled
|
|
1109
|
+
}));
|
|
1110
|
+
const frameBody = {
|
|
1111
|
+
kind: "snapshot",
|
|
1112
|
+
activePanel: null,
|
|
1113
|
+
registrations,
|
|
1114
|
+
payloads
|
|
1115
|
+
};
|
|
1116
|
+
const serialized = JSON.stringify(frameBody);
|
|
1117
|
+
if (serialized === lastRigPanelsSnapshotJson)
|
|
1118
|
+
return;
|
|
1119
|
+
lastRigPanelsSnapshotJson = serialized;
|
|
1120
|
+
appendCustomMessageEntry(RIG_PANELS_CUSTOM_MESSAGE_TYPE, "", false, { ...frameBody, updatedAt: new Date().toISOString() }, "agent");
|
|
1121
|
+
};
|
|
1122
|
+
const publishRigPanelsSnapshotBestEffort = () => {
|
|
1123
|
+
publishRigPanelsSnapshot().catch((error) => {
|
|
1124
|
+
console.error(`[rig-run] panel-snapshot-publish-failed ${error instanceof Error ? error.message : String(error)}`);
|
|
1125
|
+
});
|
|
1126
|
+
};
|
|
1127
|
+
const pushWorkerProjection = (links = runRegistryLinks) => {
|
|
1128
|
+
if (!workerProjectionConnection)
|
|
1129
|
+
return;
|
|
1130
|
+
workerProjectionConnection.push(buildCurrentRegistryProjection(links));
|
|
1131
|
+
};
|
|
1132
|
+
const publishRunProjection = async (status) => {
|
|
1133
|
+
const projection = buildCurrentRegistryProjection();
|
|
1134
|
+
if (workerProjectionConnection)
|
|
1135
|
+
workerProjectionConnection.push(projection);
|
|
1136
|
+
if (runRegistry && runRegistryRoomId) {
|
|
1137
|
+
await runRegistry.heartbeatRoom(runRegistryRoomId, status, projection).catch((err) => console.error(`[rig-run] registry-heartbeat-failed ${err instanceof Error ? err.message : String(err)}`));
|
|
1138
|
+
}
|
|
1139
|
+
publishRigPanelsSnapshotBestEffort();
|
|
1140
|
+
};
|
|
1141
|
+
const stopRunRegistry = (opts = {}) => {
|
|
1142
|
+
if (runRegistryHeartbeat) {
|
|
1143
|
+
clearInterval(runRegistryHeartbeat);
|
|
1144
|
+
runRegistryHeartbeat = null;
|
|
1145
|
+
}
|
|
1146
|
+
if (workerProjectionFiber) {
|
|
1147
|
+
Effect2.runFork(Fiber.interrupt(workerProjectionFiber));
|
|
1148
|
+
workerProjectionFiber = null;
|
|
1149
|
+
}
|
|
1150
|
+
if (workerProjectionConnection) {
|
|
1151
|
+
workerProjectionConnection.close();
|
|
1152
|
+
workerProjectionConnection = null;
|
|
1153
|
+
}
|
|
1154
|
+
if ((opts.removeRoom ?? true) && registryBackbone && runRegistryRoomId) {
|
|
1155
|
+
registryBackbone.removeRoom({ baseUrl: runRegistryBaseUrl, namespaceKey: runRegistryNamespace }, runRegistryRoomId).catch(() => {});
|
|
1156
|
+
}
|
|
1157
|
+
};
|
|
1158
|
+
const stopRunStallMonitor = startRunProcessStallMonitor({
|
|
1159
|
+
journal,
|
|
1160
|
+
lastActivityAt: () => lastRunActivityAt,
|
|
1161
|
+
alreadyStalled: runProjection.stallCount > 0
|
|
1162
|
+
});
|
|
1163
|
+
const appendRunStatus = (status, reason, force = false) => {
|
|
1164
|
+
journal?.appendStatus(status, { actor: OPERATOR_ACTOR, reason, force });
|
|
1165
|
+
};
|
|
1166
|
+
const applyInboxResolution = (resolution) => {
|
|
1167
|
+
if (resolution.kind === "approval") {
|
|
1168
|
+
journal?.appendApprovalResolved({
|
|
1169
|
+
requestId: resolution.requestId,
|
|
1170
|
+
decision: resolution.decision,
|
|
1171
|
+
...resolution.note !== undefined ? { note: resolution.note } : {},
|
|
1172
|
+
actor: OPERATOR_ACTOR
|
|
1173
|
+
});
|
|
1174
|
+
journal?.appendTimeline({ type: "inbox-resolution", kind: "approval", requestId: resolution.requestId, decision: resolution.decision });
|
|
1175
|
+
return;
|
|
1176
|
+
}
|
|
1177
|
+
journal?.appendInputResolved({ requestId: resolution.requestId, answers: resolution.answers, actor: OPERATOR_ACTOR });
|
|
1178
|
+
journal?.appendTimeline({ type: "inbox-resolution", kind: "input", requestId: resolution.requestId });
|
|
1179
|
+
};
|
|
1180
|
+
const applyRunControlText = (text) => {
|
|
1181
|
+
const control = detectRunControlText(sessionJournal, text, runId);
|
|
1182
|
+
if (!control)
|
|
1183
|
+
return;
|
|
1184
|
+
markRunActivity();
|
|
1185
|
+
if (control.kind === "pause") {
|
|
1186
|
+
pendingPause = true;
|
|
1187
|
+
return;
|
|
1188
|
+
}
|
|
1189
|
+
if (control.kind === "resume") {
|
|
1190
|
+
pendingPause = false;
|
|
1191
|
+
pendingStopReason = undefined;
|
|
1192
|
+
appendRunStatus("running", "operator resumed run", true);
|
|
1193
|
+
publishRunProjection("running");
|
|
1194
|
+
return;
|
|
1195
|
+
}
|
|
1196
|
+
if (control.kind === "stop") {
|
|
1197
|
+
pendingStopReason = control.reason ?? "operator requested stop";
|
|
1198
|
+
return;
|
|
1199
|
+
}
|
|
1200
|
+
applyInboxResolution(control.resolution);
|
|
1201
|
+
};
|
|
1202
|
+
const processRunControlMessages = () => {
|
|
1203
|
+
for (const entry of ctx.sessionManager.getEntries?.() ?? []) {
|
|
1204
|
+
const entryObject = entry && typeof entry === "object" ? entry : null;
|
|
1205
|
+
const id = entryObject && typeof entryObject.id === "string" ? entryObject.id : null;
|
|
1206
|
+
if (id && processedControlEntryIds.has(id))
|
|
1207
|
+
continue;
|
|
1208
|
+
if (!id && entryObject && processedControlEntryObjects.has(entryObject))
|
|
1209
|
+
continue;
|
|
1210
|
+
const text = textFromSessionEntry(entry);
|
|
1211
|
+
if (id)
|
|
1212
|
+
processedControlEntryIds.add(id);
|
|
1213
|
+
else if (entryObject)
|
|
1214
|
+
processedControlEntryObjects.add(entryObject);
|
|
1215
|
+
if (text)
|
|
1216
|
+
applyRunControlText(text);
|
|
1217
|
+
}
|
|
1218
|
+
};
|
|
1219
|
+
let fatalTerminalPublishing = false;
|
|
1220
|
+
const publishFatalTerminal = (error) => {
|
|
1221
|
+
if (fatalTerminalPublishing)
|
|
1222
|
+
return;
|
|
1223
|
+
fatalTerminalPublishing = true;
|
|
1224
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
1225
|
+
journal?.appendStatus("failed", { actor: { kind: "agent" }, errorText: detail, force: true });
|
|
1226
|
+
publishRunProjection("failed").catch((publishError) => {
|
|
1227
|
+
console.error(`[rig-run] fatal-terminal-publish-failed ${publishError instanceof Error ? publishError.message : String(publishError)}`);
|
|
1228
|
+
}).finally(() => {
|
|
1229
|
+
stopRunStallMonitor();
|
|
1230
|
+
stopRunRegistry({ removeRoom: false });
|
|
1231
|
+
process.exitCode = 1;
|
|
1232
|
+
setTimeout(() => process.exit(1), 0);
|
|
1233
|
+
});
|
|
1234
|
+
};
|
|
1235
|
+
process.once("uncaughtException", publishFatalTerminal);
|
|
1236
|
+
process.once("unhandledRejection", publishFatalTerminal);
|
|
1237
|
+
const handlePanelAction = async (input) => {
|
|
1238
|
+
if (input.actionId !== RIG_RUN_STOP_PANEL_ACTION2 && input.actionId !== "stop-supervisor") {
|
|
1239
|
+
throw new Error(`Unsupported Rig panel action: ${input.actionId}`);
|
|
1240
|
+
}
|
|
1241
|
+
pendingStopReason = `operator ${input.from.name} requested stop`;
|
|
1242
|
+
journal?.appendTimeline({ type: "interrupted", stage: "panel-action", status: "running", detail: pendingStopReason });
|
|
1243
|
+
ctx.abort();
|
|
1244
|
+
await publishRunProjection("running");
|
|
1245
|
+
};
|
|
1246
|
+
const startRunCollabHost = async () => {
|
|
1247
|
+
try {
|
|
1248
|
+
const projection = await startHost.call(collab, {
|
|
1249
|
+
title: runDisplayTitle,
|
|
1250
|
+
...identity?.owner ? { owner: identity.owner } : {},
|
|
1251
|
+
...identity?.selectedRepo ? { selectedRepo: identity.selectedRepo } : {},
|
|
1252
|
+
relayUrl: runRelayUrl,
|
|
1253
|
+
onPanelAction: handlePanelAction
|
|
1254
|
+
});
|
|
1255
|
+
const roomId = projection.sessionId?.trim() || runId;
|
|
1256
|
+
if (roomId !== runId) {
|
|
1257
|
+
throw new Error(`Collab host session id mismatch: expected ${runId}, got ${roomId}`);
|
|
1258
|
+
}
|
|
1259
|
+
runRegistryLinks = { joinLink: projection.joinLink ?? null, webLink: projection.webLink ?? null, relayUrl: projection.relayUrl ?? runRelayUrl };
|
|
1260
|
+
const timeline = {
|
|
1261
|
+
type: "collab-host-started",
|
|
1262
|
+
roomId,
|
|
1263
|
+
joinLink: projection.joinLink,
|
|
1264
|
+
webLink: projection.webLink,
|
|
1265
|
+
relayUrl: projection.relayUrl
|
|
1266
|
+
};
|
|
1267
|
+
journal?.appendTimeline(timeline);
|
|
1268
|
+
console.log(`[rig-run] collab-host-started joinLink=${projection.joinLink ? "(redacted)" : "(empty)"} relayUrl=${projection.relayUrl || "(empty)"}`);
|
|
1269
|
+
ctx.ui.notify("Rig run collab host started.", "info");
|
|
1270
|
+
publishRigPanelsSnapshotBestEffort();
|
|
1271
|
+
if (!runRegistry || !registryBackbone) {
|
|
1272
|
+
const detail = "Rig run discovery registry is unavailable.";
|
|
1273
|
+
console.error(`[rig-run] registry-unavailable ${detail}`);
|
|
1274
|
+
journal?.appendTimeline({ type: "registry-register-failed", status: "failed", detail });
|
|
1275
|
+
ctx.ui.notify("Rig run discovery registry is unavailable; failing run.", "error");
|
|
1276
|
+
publishFatalTerminal(new Error(detail));
|
|
1277
|
+
return false;
|
|
1278
|
+
}
|
|
1279
|
+
if (runRegistry && registryBackbone) {
|
|
1280
|
+
try {
|
|
1281
|
+
runRegistryRoomId = roomId;
|
|
1282
|
+
const initialProjection = buildCurrentRegistryProjection();
|
|
1283
|
+
const sessionPath = ctx.sessionManager.getSessionFile();
|
|
1284
|
+
await registryBackbone.registerRoom({ baseUrl: runRegistryBaseUrl, namespaceKey: runRegistryNamespace }, {
|
|
1285
|
+
roomId,
|
|
1286
|
+
owner: runRegistryOwner,
|
|
1287
|
+
repo: runRegistryRepo,
|
|
1288
|
+
title: runDisplayTitle,
|
|
1289
|
+
status: "running",
|
|
1290
|
+
joinLink: projection.joinLink ?? "",
|
|
1291
|
+
webLink: projection.webLink ?? "",
|
|
1292
|
+
relayUrl: projection.relayUrl ?? runRelayUrl,
|
|
1293
|
+
startedAt: new Date().toISOString(),
|
|
1294
|
+
cwd: process.cwd(),
|
|
1295
|
+
...sessionPath ? { sessionPath } : {},
|
|
1296
|
+
pid: process.pid,
|
|
1297
|
+
projection: initialProjection
|
|
1298
|
+
});
|
|
1299
|
+
workerProjectionConnection = registryBackbone.connectWorkerProjection({ baseUrl: runRegistryBaseUrl, namespaceKey: runRegistryNamespace, runId: roomId });
|
|
1300
|
+
workerProjectionConnection.ready.catch((err) => console.error(`[rig-run] worker-projection-degraded (heartbeat remains authoritative): ${err instanceof Error ? err.message : String(err)}`));
|
|
1301
|
+
pushWorkerProjection();
|
|
1302
|
+
workerProjectionFiber = Effect2.runFork(localRunChanges(projectRoot).pipe(Stream2.debounce(Duration.millis(500)), Stream2.runForEach(() => Effect2.sync(() => pushWorkerProjection()))));
|
|
1303
|
+
journal?.appendTimeline({ type: "registry-registered", roomId });
|
|
1304
|
+
console.log(`[rig-run] registry-registered roomId=${roomId}`);
|
|
1305
|
+
runRegistryHeartbeat = setInterval(() => {
|
|
1306
|
+
const heartbeatProjection = buildCurrentRegistryProjection();
|
|
1307
|
+
runRegistry.heartbeatRoom(roomId, registryBackbone.coerceRegistryStatus(heartbeatProjection.status, "running"), heartbeatProjection).catch((err) => console.error(`[rig-run] registry-heartbeat-failed ${err instanceof Error ? err.message : String(err)}`));
|
|
1308
|
+
}, 15000);
|
|
1309
|
+
if (typeof runRegistryHeartbeat.unref === "function")
|
|
1310
|
+
runRegistryHeartbeat.unref();
|
|
1311
|
+
} catch (error) {
|
|
1312
|
+
const cause = error instanceof Error ? error.message : String(error);
|
|
1313
|
+
const detail = `Rig run discovery registry registration failed: ${cause}`;
|
|
1314
|
+
console.error(`[rig-run] registry-register-failed ${detail}`);
|
|
1315
|
+
journal?.appendTimeline({ type: "registry-register-failed", status: "failed", detail });
|
|
1316
|
+
ctx.ui.notify("Rig run could not register to the discovery registry; failing run.", "error");
|
|
1317
|
+
publishFatalTerminal(new Error(detail));
|
|
1318
|
+
return false;
|
|
1319
|
+
}
|
|
1320
|
+
}
|
|
1321
|
+
return true;
|
|
1322
|
+
} catch (error) {
|
|
1323
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
1324
|
+
console.error(`[rig-run] collab-host-start-failed ${detail}`);
|
|
1325
|
+
ctx.ui.notify("Rig run collab host could not reach the relay; failing run.", "error");
|
|
1326
|
+
publishFatalTerminal(error);
|
|
1327
|
+
return false;
|
|
1328
|
+
}
|
|
1329
|
+
};
|
|
1330
|
+
journal?.appendTimeline({ type: "stage", stage: "Connect", status: "running", detail: "run process session_start" });
|
|
1331
|
+
journal?.appendTimeline({ type: "stage", stage: "Prepare", status: "completed", detail: "run process prepared" });
|
|
1332
|
+
journal?.appendStatus("running", { actor: { kind: "agent" }, reason: "run process session started", force: true });
|
|
1333
|
+
if (!await startRunCollabHost())
|
|
1334
|
+
return null;
|
|
1335
|
+
if (taskIdAtStart) {
|
|
1336
|
+
journal?.appendTimeline({ type: "stage", stage: "GitHub-sync", status: "running", detail: "reflecting run start to task source" });
|
|
1337
|
+
try {
|
|
1338
|
+
await taskSourceReflectionService?.reflectRunStarted(projectRoot, {
|
|
1339
|
+
runId,
|
|
1340
|
+
taskId: taskIdAtStart,
|
|
1341
|
+
...runProjection.record.sourceTask !== undefined ? { sourceTask: runProjection.record.sourceTask } : {},
|
|
1342
|
+
worktreePath: process.cwd(),
|
|
1343
|
+
logRoot: runProjection.record.logRoot ?? null,
|
|
1344
|
+
sessionPath: runProjection.record.sessionPath ?? null
|
|
1345
|
+
});
|
|
1346
|
+
journal?.appendTimeline({ type: "stage", stage: "GitHub-sync", status: "completed", detail: "reflected run start" });
|
|
1347
|
+
} catch (error) {
|
|
1348
|
+
journal?.appendTimeline({ type: "stage", stage: "GitHub-sync", status: "failed", detail: error instanceof Error ? error.message : String(error) });
|
|
1349
|
+
console.error(`[rig-run] start-reflection-failed ${error instanceof Error ? error.message : String(error)}`);
|
|
1350
|
+
}
|
|
1351
|
+
}
|
|
1352
|
+
const steerPi = async (message) => {
|
|
1353
|
+
journal?.appendTimeline({ type: "closeout-steer", message });
|
|
1354
|
+
api.sendUserMessage(message, { deliverAs: "steer" });
|
|
1355
|
+
};
|
|
1356
|
+
const agentEnd = async (event) => {
|
|
1357
|
+
markRunActivity();
|
|
1358
|
+
processRunControlMessages();
|
|
1359
|
+
for (const message of event.messages) {
|
|
1360
|
+
const text = textFromAgentMessage(message);
|
|
1361
|
+
if (text)
|
|
1362
|
+
applyRunControlText(text);
|
|
1363
|
+
}
|
|
1364
|
+
const aborted = event.messages.some((message) => message.role === "assistant" && message.stopReason === "aborted");
|
|
1365
|
+
if (pendingStopReason !== undefined) {
|
|
1366
|
+
const reason = pendingStopReason ?? "operator requested stop";
|
|
1367
|
+
pendingStopReason = undefined;
|
|
1368
|
+
closeoutStarted = true;
|
|
1369
|
+
journal?.appendTimeline({ type: "interrupted", stage: "stopped", status: "stopped", detail: reason });
|
|
1370
|
+
journal?.appendStatus("stopped", { actor: OPERATOR_ACTOR, reason, force: true });
|
|
1371
|
+
if (taskIdAtStart) {
|
|
1372
|
+
journal?.appendTimeline({ type: "stage", stage: "Task-source", status: "running", detail: "reflecting run stop to task source" });
|
|
1373
|
+
try {
|
|
1374
|
+
await taskSourceReflectionService?.reflectRunStopped(projectRoot, {
|
|
1375
|
+
runId,
|
|
1376
|
+
taskId: taskIdAtStart,
|
|
1377
|
+
...runProjection.record.sourceTask !== undefined ? { sourceTask: runProjection.record.sourceTask } : {},
|
|
1378
|
+
worktreePath: process.cwd(),
|
|
1379
|
+
logRoot: runProjection.record.logRoot ?? null,
|
|
1380
|
+
sessionPath: runProjection.record.sessionPath ?? null
|
|
1381
|
+
}, { reason });
|
|
1382
|
+
journal?.appendTimeline({ type: "stage", stage: "Task-source", status: "completed", detail: "reflected run stop" });
|
|
1383
|
+
} catch (error) {
|
|
1384
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
1385
|
+
journal?.appendTimeline({ type: "stage", stage: "Task-source", status: "failed", detail });
|
|
1386
|
+
console.error(`[rig-run] stopped-reflection-failed ${detail}`);
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1389
|
+
await publishRunProjection("stopped");
|
|
1390
|
+
stopRunStallMonitor();
|
|
1391
|
+
stopRunRegistry({ removeRoom: false });
|
|
1392
|
+
process.exitCode = 0;
|
|
1393
|
+
setTimeout(() => process.exit(0), 0);
|
|
1394
|
+
return;
|
|
1395
|
+
}
|
|
1396
|
+
if (aborted) {
|
|
1397
|
+
if (pendingPause) {
|
|
1398
|
+
pendingPause = false;
|
|
1399
|
+
appendRunStatus("paused", "operator paused run", true);
|
|
1400
|
+
journal?.appendTimeline({ type: "interrupted", stage: "paused", status: "paused", detail: "operator paused run; parked for native collab resume" });
|
|
1401
|
+
await publishRunProjection("paused");
|
|
1402
|
+
return;
|
|
1403
|
+
}
|
|
1404
|
+
journal?.appendTimeline({ type: "interrupted", stage: "aborted", status: "running", detail: "operator interrupted run without a Rig control sentinel" });
|
|
1405
|
+
return;
|
|
1406
|
+
}
|
|
1407
|
+
if (closeoutStarted)
|
|
1408
|
+
return;
|
|
1409
|
+
if (process.env.RIG_RUN_FORCE_STEER_ONCE === "1" && !forcedSteerUsed) {
|
|
1410
|
+
forcedSteerUsed = true;
|
|
1411
|
+
journal?.appendTimeline({ type: "force-steer-once-started" });
|
|
1412
|
+
await steerPi("now reply with the word FIXED");
|
|
1413
|
+
journal?.appendTimeline({ type: "force-steer-once-completed" });
|
|
1414
|
+
}
|
|
1415
|
+
closeoutStarted = true;
|
|
1416
|
+
buildWorkerBootstrapProjection();
|
|
1417
|
+
const taskId = process.env.RIG_TASK_ID?.trim() || runProjection.record.taskId;
|
|
1418
|
+
if (!taskId) {
|
|
1419
|
+
const reason = "missing task id for closeout";
|
|
1420
|
+
journal?.appendTimeline({ type: "closeout-skipped", reason: "missing-task-id" });
|
|
1421
|
+
journal?.appendStatus("failed", { actor: { kind: "agent" }, reason, errorText: reason, force: true });
|
|
1422
|
+
await publishRunProjection("failed");
|
|
1423
|
+
stopRunStallMonitor();
|
|
1424
|
+
stopRunRegistry({ removeRoom: false });
|
|
1425
|
+
process.exitCode = 1;
|
|
1426
|
+
setTimeout(() => process.exit(1), 0);
|
|
1427
|
+
return;
|
|
1428
|
+
}
|
|
1429
|
+
let closeoutStatusAdvanced = false;
|
|
1430
|
+
try {
|
|
1431
|
+
await requireInstalledCapability(LifecycleVerificationServiceCap, "run-closeout capability unavailable in run-worker autohost: ensure @rig/lifecycle-plugin (default bundle) is installed.").closeout({
|
|
1432
|
+
projectRoot,
|
|
1433
|
+
runId,
|
|
1434
|
+
taskId,
|
|
1435
|
+
branch: runProjection.record.branch ?? `rig/${taskId}-${runId}`,
|
|
1436
|
+
workspace: process.cwd(),
|
|
1437
|
+
artifactRoot: runProjection.record.artifactRoot ?? null,
|
|
1438
|
+
sourceTask: runProjection.record.sourceTask && typeof runProjection.record.sourceTask === "object" && !Array.isArray(runProjection.record.sourceTask) ? runProjection.record.sourceTask : null,
|
|
1439
|
+
steerPi,
|
|
1440
|
+
onValidationStart: async () => {
|
|
1441
|
+
journal?.appendStatus("validating", { actor: { kind: "agent" }, reason: "validating task before closeout", force: true });
|
|
1442
|
+
await publishRunProjection("validating");
|
|
1443
|
+
},
|
|
1444
|
+
kernelJournal: journal?.kernel ?? null,
|
|
1445
|
+
journalPhase: async (phase, outcome, detail) => {
|
|
1446
|
+
journal?.appendCloseoutPhase({ phase, outcome, detail: detail ?? null });
|
|
1447
|
+
if (!closeoutStatusAdvanced && phase !== "queued" && outcome === "started") {
|
|
1448
|
+
closeoutStatusAdvanced = true;
|
|
1449
|
+
journal?.appendStatus("closing-out", { actor: { kind: "agent" }, reason: "validation passed; running closeout automation", force: true });
|
|
1450
|
+
await publishRunProjection("closing-out");
|
|
1451
|
+
}
|
|
1452
|
+
},
|
|
1453
|
+
reflect: async (status, summary, opts) => {
|
|
1454
|
+
await taskSourceReflectionService?.updateRunTaskSourceLifecycle(projectRoot, {
|
|
1455
|
+
runId,
|
|
1456
|
+
taskId,
|
|
1457
|
+
...runProjection.record.sourceTask !== undefined ? { sourceTask: runProjection.record.sourceTask } : {},
|
|
1458
|
+
worktreePath: process.cwd(),
|
|
1459
|
+
logRoot: runProjection.record.logRoot ?? null,
|
|
1460
|
+
sessionPath: runProjection.record.sessionPath ?? null
|
|
1461
|
+
}, status, summary, opts);
|
|
1462
|
+
}
|
|
1463
|
+
});
|
|
1464
|
+
journal?.appendStatus("completed", { actor: { kind: "agent" }, reason: "closeout completed" });
|
|
1465
|
+
await publishRunProjection("completed");
|
|
1466
|
+
await dispatchRunNotifications(projectRoot, runId, taskId, "completed", "closeout completed");
|
|
1467
|
+
stopRunStallMonitor();
|
|
1468
|
+
stopRunRegistry({ removeRoom: false });
|
|
1469
|
+
process.exitCode = 0;
|
|
1470
|
+
setTimeout(() => process.exit(0), 0);
|
|
1471
|
+
} catch (error) {
|
|
1472
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
1473
|
+
const status = error instanceof Error && error.name === "CloseoutValidationError" ? "needs-attention" : "failed";
|
|
1474
|
+
journal?.appendStatus(status, { actor: { kind: "agent" }, errorText: detail, force: true });
|
|
1475
|
+
await publishRunProjection(status);
|
|
1476
|
+
await dispatchRunNotifications(projectRoot, runId, taskId, "failed", detail);
|
|
1477
|
+
stopRunStallMonitor();
|
|
1478
|
+
stopRunRegistry({ removeRoom: false });
|
|
1479
|
+
process.exitCode = 1;
|
|
1480
|
+
setTimeout(() => process.exit(1), 0);
|
|
1481
|
+
}
|
|
1482
|
+
};
|
|
1483
|
+
const handleRunActivity = () => {
|
|
1484
|
+
markRunActivity();
|
|
1485
|
+
processRunControlMessages();
|
|
1486
|
+
};
|
|
1487
|
+
return { beforeAgentStart: handleRunActivity, messageStart: handleRunActivity, agentEnd };
|
|
1488
|
+
}
|
|
1489
|
+
async function maybeStartSpikeAutohost(ctx) {
|
|
1490
|
+
if (process.env.RIG_SPIKE_AUTOHOST !== "1")
|
|
1491
|
+
return;
|
|
1492
|
+
const relayUrl = process.env.RIG_SPIKE_RELAY?.trim();
|
|
1493
|
+
if (!relayUrl)
|
|
1494
|
+
throw new Error("RIG_SPIKE_RELAY is required when RIG_SPIKE_AUTOHOST=1");
|
|
1495
|
+
const collab = ctx.collab;
|
|
1496
|
+
const startHost = collab?.startHost ?? collab?.startCollabHost;
|
|
1497
|
+
if (!startHost)
|
|
1498
|
+
throw new Error("OMP collab host facade is unavailable for detached PTY spike.");
|
|
1499
|
+
const identity = (await loadCapabilityForRoot3(rigProjectRootFromEnv(), RunIdentityEnvCap))?.resolveRigIdentity(ctx) ?? null;
|
|
1500
|
+
await startHost.call(collab, {
|
|
1501
|
+
relayUrl,
|
|
1502
|
+
title: "Rig detached PTY spike",
|
|
1503
|
+
...identity?.owner ? { owner: identity.owner } : {},
|
|
1504
|
+
...identity?.selectedRepo ? { selectedRepo: identity.selectedRepo } : {}
|
|
1505
|
+
});
|
|
1506
|
+
}
|
|
1507
|
+
var GitHubCliCap, GitHubTokenResolverCap, RepoChangeSetCap, RepoGitWorkflowCap, RepoNativeGitCap, TaskArtifactsCap, TaskStateStoreCap, PlacementTransportCap, RunIdentityEnvCap, RunRegistryBackboneCap, RunReadModelCap3, RunSessionJournalCap2, RunSessionJournalWriterCap, LifecycleVerificationServiceCap, TransportConfigCap, TaskSourceReflectionCap, REGISTRY_PROJECTION_TIMELINE_LIMIT = 100, OPERATOR_ACTOR, REGISTRY_SECRET_LINK_FIELDS;
|
|
1508
|
+
var init_autohost = __esm(() => {
|
|
1509
|
+
init_local_run_changes();
|
|
1510
|
+
init_notifications();
|
|
1511
|
+
init_panel_plugin();
|
|
1512
|
+
init_stall();
|
|
1513
|
+
init_utils();
|
|
1514
|
+
GitHubCliCap = defineCapability5(GITHUB_CLI);
|
|
1515
|
+
GitHubTokenResolverCap = defineCapability5(GITHUB_TOKEN_RESOLVER);
|
|
1516
|
+
RepoChangeSetCap = defineCapability5(REPO_CHANGE_SET);
|
|
1517
|
+
RepoGitWorkflowCap = defineCapability5(REPO_GIT_WORKFLOW);
|
|
1518
|
+
RepoNativeGitCap = defineCapability5(REPO_NATIVE_GIT);
|
|
1519
|
+
TaskArtifactsCap = defineCapability5(TASK_ARTIFACTS);
|
|
1520
|
+
TaskStateStoreCap = defineCapability5(TASK_STATE_STORE);
|
|
1521
|
+
PlacementTransportCap = defineCapability5(PLACEMENT_RUN_TRANSPORT);
|
|
1522
|
+
RunIdentityEnvCap = defineCapability5(RUN_IDENTITY_ENV);
|
|
1523
|
+
RunRegistryBackboneCap = defineCapability5(RUN_REGISTRY_BACKBONE);
|
|
1524
|
+
RunReadModelCap3 = defineCapability5(RUN_READ_MODEL3);
|
|
1525
|
+
RunSessionJournalCap2 = defineCapability5(RUN_SESSION_JOURNAL2);
|
|
1526
|
+
RunSessionJournalWriterCap = defineCapability5(RUN_SESSION_JOURNAL_WRITER2);
|
|
1527
|
+
LifecycleVerificationServiceCap = defineServiceCapability(LIFECYCLE_VERIFICATION_SERVICE);
|
|
1528
|
+
TransportConfigCap = defineCapability5(TRANSPORT_CONFIG);
|
|
1529
|
+
TaskSourceReflectionCap = defineCapability5(TASK_SOURCE_REFLECTION);
|
|
1530
|
+
OPERATOR_ACTOR = { kind: "operator" };
|
|
1531
|
+
REGISTRY_SECRET_LINK_FIELDS = new Set(["joinLink", "webLink"]);
|
|
1532
|
+
});
|
|
1533
|
+
|
|
1534
|
+
// packages/run-plugin/src/worker/extension.ts
|
|
1535
|
+
var exports_extension = {};
|
|
1536
|
+
__export(exports_extension, {
|
|
1537
|
+
default: () => rigWorkerExtension,
|
|
1538
|
+
__rigRunWorkerTest: () => __rigRunWorkerTest,
|
|
1539
|
+
__rigExtensionTest: () => __rigExtensionTest
|
|
1540
|
+
});
|
|
1541
|
+
function rigWorkerExtension(api) {
|
|
1542
|
+
let hooks = null;
|
|
1543
|
+
api.on("session_start", async (_event, ctx) => {
|
|
1544
|
+
hooks = await maybeStartRunProcessAutohost(api, ctx);
|
|
1545
|
+
await maybeStartSpikeAutohost(ctx);
|
|
1546
|
+
});
|
|
1547
|
+
api.on("before_agent_start", () => {
|
|
1548
|
+
hooks?.beforeAgentStart();
|
|
1549
|
+
});
|
|
1550
|
+
api.on("message_start", () => {
|
|
1551
|
+
hooks?.messageStart();
|
|
1552
|
+
});
|
|
1553
|
+
api.on("agent_end", async (event) => {
|
|
1554
|
+
await hooks?.agentEnd(event);
|
|
1555
|
+
});
|
|
1556
|
+
}
|
|
1557
|
+
var __rigRunWorkerTest, __rigExtensionTest;
|
|
1558
|
+
var init_extension = __esm(() => {
|
|
1559
|
+
init_autohost();
|
|
1560
|
+
init_stall();
|
|
1561
|
+
__rigRunWorkerTest = {
|
|
1562
|
+
computeRunStall,
|
|
1563
|
+
appendRunStallDetected,
|
|
1564
|
+
detectRunControlText
|
|
1565
|
+
};
|
|
1566
|
+
__rigExtensionTest = __rigRunWorkerTest;
|
|
1567
|
+
});
|
|
1568
|
+
|
|
1569
|
+
// packages/run-plugin/src/worker/plugin.ts
|
|
1570
|
+
import { defineCapability as defineCapability6 } from "@rig/core/capability";
|
|
1571
|
+
import { definePlugin } from "@rig/core/config";
|
|
1572
|
+
import {
|
|
1573
|
+
RIG_WORKFLOW_JOURNAL_WRITER,
|
|
1574
|
+
RUN_CONTROL as RUN_CONTROL2,
|
|
1575
|
+
RUN_SESSION_JOURNAL_WRITER as RUN_SESSION_JOURNAL_WRITER3,
|
|
1576
|
+
SESSION_RUN_ADAPTER
|
|
1577
|
+
} from "@rig/contracts";
|
|
1578
|
+
async function installWorkerInboxIfPresent(parentPort) {
|
|
1579
|
+
if (!parentPort)
|
|
1580
|
+
return;
|
|
1581
|
+
const { installWorkerInbox } = await import("@oh-my-pi/pi-utils/worker-host");
|
|
1582
|
+
installWorkerInbox(parentPort);
|
|
1583
|
+
}
|
|
1584
|
+
var RunSessionJournalWriterCap2 = defineCapability6(RUN_SESSION_JOURNAL_WRITER3);
|
|
1585
|
+
var WorkflowJournalWriterCap = defineCapability6(RIG_WORKFLOW_JOURNAL_WRITER);
|
|
1586
|
+
var RunControlCap2 = defineCapability6(RUN_CONTROL2);
|
|
1587
|
+
var SessionRunAdapterCap = defineCapability6(SESSION_RUN_ADAPTER);
|
|
1588
|
+
var RUN_WORKER_SEED_ENTRYPOINTS = [
|
|
1589
|
+
{
|
|
1590
|
+
id: "@rig/run-worker:stats-sync-worker",
|
|
1591
|
+
workerArg: "__omp_worker_stats_sync",
|
|
1592
|
+
description: "OMP stats sync self-exec worker.",
|
|
1593
|
+
run: async () => {
|
|
1594
|
+
const scope = globalThis;
|
|
1595
|
+
const pending = [];
|
|
1596
|
+
const buffer = (event) => {
|
|
1597
|
+
pending.push(event);
|
|
1598
|
+
};
|
|
1599
|
+
scope.onmessage = buffer;
|
|
1600
|
+
await import("@oh-my-pi/omp-stats/sync-worker");
|
|
1601
|
+
const handler = scope.onmessage;
|
|
1602
|
+
if (handler && handler !== buffer) {
|
|
1603
|
+
for (const event of pending)
|
|
1604
|
+
handler.call(scope, event);
|
|
1605
|
+
}
|
|
1606
|
+
}
|
|
1607
|
+
},
|
|
1608
|
+
{
|
|
1609
|
+
id: "@rig/run-worker:tab-worker",
|
|
1610
|
+
workerArg: "__omp_worker_tab",
|
|
1611
|
+
description: "Browser tab tool self-exec worker.",
|
|
1612
|
+
run: async ({ parentPort }) => {
|
|
1613
|
+
await installWorkerInboxIfPresent(parentPort);
|
|
1614
|
+
await import("@oh-my-pi/pi-coding-agent/tools/browser/tab-worker-entry");
|
|
1615
|
+
}
|
|
1616
|
+
},
|
|
1617
|
+
{
|
|
1618
|
+
id: "@rig/run-worker:js-eval-worker",
|
|
1619
|
+
workerArg: "__omp_worker_js_eval",
|
|
1620
|
+
description: "JavaScript eval tool self-exec worker.",
|
|
1621
|
+
run: async ({ parentPort }) => {
|
|
1622
|
+
await installWorkerInboxIfPresent(parentPort);
|
|
1623
|
+
await import("@oh-my-pi/pi-coding-agent/eval/js/worker-entry");
|
|
1624
|
+
}
|
|
1625
|
+
},
|
|
1626
|
+
{
|
|
1627
|
+
id: "@rig/run-worker:tiny-inference-worker",
|
|
1628
|
+
workerArg: "__omp_worker_tiny_inference",
|
|
1629
|
+
description: "Tiny-model (titles) transformers.js IPC subprocess worker.",
|
|
1630
|
+
run: async () => {
|
|
1631
|
+
const { startTinyTitleWorker } = await import("@oh-my-pi/pi-coding-agent/tiny/worker");
|
|
1632
|
+
await runIpcSubprocessWorker(startTinyTitleWorker);
|
|
1633
|
+
}
|
|
1634
|
+
},
|
|
1635
|
+
{
|
|
1636
|
+
id: "@rig/run-worker:stt-worker",
|
|
1637
|
+
workerArg: "__omp_worker_stt",
|
|
1638
|
+
description: "Speech-to-text transformers.js IPC subprocess worker.",
|
|
1639
|
+
run: async () => {
|
|
1640
|
+
const { startSttWorker } = await import("@oh-my-pi/pi-coding-agent/stt/asr-worker");
|
|
1641
|
+
await runIpcSubprocessWorker(startSttWorker);
|
|
1642
|
+
}
|
|
1643
|
+
},
|
|
1644
|
+
{
|
|
1645
|
+
id: "@rig/run-worker:tts-worker",
|
|
1646
|
+
workerArg: "__omp_worker_tts",
|
|
1647
|
+
description: "Text-to-speech transformers.js IPC subprocess worker.",
|
|
1648
|
+
run: async () => {
|
|
1649
|
+
const { startTtsWorker } = await import("@oh-my-pi/pi-coding-agent/tts/tts-worker");
|
|
1650
|
+
await runIpcSubprocessWorker(startTtsWorker);
|
|
1651
|
+
}
|
|
1652
|
+
},
|
|
1653
|
+
{
|
|
1654
|
+
id: "@rig/run-worker:mnemopi-embed-worker",
|
|
1655
|
+
workerArg: "__omp_worker_mnemopi_embed",
|
|
1656
|
+
description: "Mnemopi embedding IPC subprocess worker.",
|
|
1657
|
+
run: async () => {
|
|
1658
|
+
const { startMnemopiEmbedWorker } = await import("@oh-my-pi/pi-coding-agent/mnemopi/embed-worker");
|
|
1659
|
+
await runIpcSubprocessWorker(startMnemopiEmbedWorker);
|
|
1660
|
+
}
|
|
1661
|
+
}
|
|
1662
|
+
];
|
|
1663
|
+
async function runIpcSubprocessWorker(start) {
|
|
1664
|
+
const { promise: shuttingDown, resolve: shutdown } = Promise.withResolvers();
|
|
1665
|
+
const send = (message) => {
|
|
1666
|
+
const sender = process.send;
|
|
1667
|
+
if (!sender) {
|
|
1668
|
+
shutdown();
|
|
1669
|
+
return;
|
|
1670
|
+
}
|
|
1671
|
+
try {
|
|
1672
|
+
sender.call(process, message);
|
|
1673
|
+
} catch {
|
|
1674
|
+
shutdown();
|
|
1675
|
+
}
|
|
1676
|
+
};
|
|
1677
|
+
start({
|
|
1678
|
+
send,
|
|
1679
|
+
onMessage(handler) {
|
|
1680
|
+
const wrap = (data) => handler(data);
|
|
1681
|
+
process.on("message", wrap);
|
|
1682
|
+
return () => {
|
|
1683
|
+
process.off("message", wrap);
|
|
1684
|
+
};
|
|
1685
|
+
}
|
|
1686
|
+
});
|
|
1687
|
+
const keepalive = setInterval(() => {}, 1073741824);
|
|
1688
|
+
process.on("disconnect", () => shutdown());
|
|
1689
|
+
try {
|
|
1690
|
+
await shuttingDown;
|
|
1691
|
+
} finally {
|
|
1692
|
+
clearInterval(keepalive);
|
|
1693
|
+
}
|
|
1694
|
+
process.kill(process.pid, "SIGKILL");
|
|
1695
|
+
}
|
|
1696
|
+
var inboxCommand = {
|
|
1697
|
+
id: "@rig/run-worker:inbox",
|
|
1698
|
+
family: "inbox",
|
|
1699
|
+
description: "Inspect and resolve run inbox items.",
|
|
1700
|
+
projectRequired: true,
|
|
1701
|
+
run: async (context, args) => (await Promise.resolve().then(() => (init_inbox_command(), exports_inbox_command))).executeInbox(context, [...args]),
|
|
1702
|
+
helpDoc: {
|
|
1703
|
+
name: "inbox",
|
|
1704
|
+
summary: "Legacy automation-only request view; normal UX is the OMP Inbox screen.",
|
|
1705
|
+
usage: ["rig inbox <approvals|approve|inputs|respond> [options]"],
|
|
1706
|
+
commands: [
|
|
1707
|
+
{ command: "approvals [--run <id>] [--task <id>]", description: "Legacy automation-only: list pending approval records.", primary: true },
|
|
1708
|
+
{ command: "inputs [--run <id>] [--task <id>]", description: "Legacy automation-only: list pending user-input records.", primary: true },
|
|
1709
|
+
{ command: "approve --run <id> --request <id> --decision approve|reject", description: "Legacy automation-only: resolve an approval record." },
|
|
1710
|
+
{ command: "respond --run <id> --request <id> --text <answer> | --answer <answer>", description: "Legacy automation-only: answer a user-input record." }
|
|
1711
|
+
],
|
|
1712
|
+
examples: [
|
|
1713
|
+
"rig inbox approvals # legacy automation only"
|
|
1714
|
+
],
|
|
1715
|
+
next: ["For normal UX, use bare `rig`, then the OMP Inbox screen."]
|
|
1716
|
+
}
|
|
1717
|
+
};
|
|
1718
|
+
var runWorkerPlugin = definePlugin({
|
|
1719
|
+
name: "@rig/run-plugin",
|
|
1720
|
+
version: "0.0.0-alpha.1",
|
|
1721
|
+
effects: {
|
|
1722
|
+
readsFiles: true,
|
|
1723
|
+
writesFiles: true,
|
|
1724
|
+
opensNetwork: true,
|
|
1725
|
+
contributesCliCommands: true
|
|
1726
|
+
},
|
|
1727
|
+
contributes: {
|
|
1728
|
+
cliCommands: [inboxCommand],
|
|
1729
|
+
capabilities: [
|
|
1730
|
+
RunSessionJournalWriterCap2.provide(async () => (await Promise.resolve().then(() => (init_session_journal_writer(), exports_session_journal_writer))).runSessionJournalWriterService, {
|
|
1731
|
+
title: "Run session-journal writer",
|
|
1732
|
+
description: "Bind writable run journals to live OMP sessions for run-worker lifecycle updates."
|
|
1733
|
+
}),
|
|
1734
|
+
WorkflowJournalWriterCap.provide(async () => (await Promise.resolve().then(() => (init_workflow_journal_writer(), exports_workflow_journal_writer))).workflowJournalWriterService, {
|
|
1735
|
+
title: "Workflow journal writer",
|
|
1736
|
+
description: "Mint and append rig.workflow.* session facts; owned by the run-status writer owner (not the read-only read-model)."
|
|
1737
|
+
}),
|
|
1738
|
+
RunControlCap2.provide(async () => (await Promise.resolve().then(() => (init_run_control_service(), exports_run_control_service))).runControlService, {
|
|
1739
|
+
title: "Run control endpoint",
|
|
1740
|
+
description: "Resolve run action targets, deliver operator control/steer/stop/pause/resume, resolve inbox requests, plan resume, and reconcile dead-pid runs."
|
|
1741
|
+
}),
|
|
1742
|
+
SessionRunAdapterCap.provide(async () => {
|
|
1743
|
+
const { default: rigWorkerExtension2 } = await Promise.resolve().then(() => (init_extension(), exports_extension));
|
|
1744
|
+
return {
|
|
1745
|
+
installRunAdapter: (api) => rigWorkerExtension2(api)
|
|
1746
|
+
};
|
|
1747
|
+
}, {
|
|
1748
|
+
title: "Session\u2192run adapter",
|
|
1749
|
+
description: "Install the run-worker session extension, adapting the configured harness session into a running Rig run."
|
|
1750
|
+
})
|
|
1751
|
+
],
|
|
1752
|
+
seedEntrypoints: RUN_WORKER_SEED_ENTRYPOINTS
|
|
1753
|
+
}
|
|
1754
|
+
});
|
|
1755
|
+
function createRunWorkerPlugin() {
|
|
1756
|
+
return runWorkerPlugin;
|
|
1757
|
+
}
|
|
1758
|
+
export {
|
|
1759
|
+
runWorkerPlugin,
|
|
1760
|
+
createRunWorkerPlugin
|
|
1761
|
+
};
|