@h-rig/cli 0.0.6-alpha.90 → 0.0.6-alpha.92
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -19
- package/dist/bin/build-rig-binaries.js +22 -10
- package/dist/bin/rig.d.ts +71 -1
- package/dist/bin/rig.js +15078 -11169
- package/dist/config/rig-default-config.yml +5 -0
- package/dist/src/app/drone-ui.d.ts +11 -14
- package/dist/src/app/drone-ui.js +70 -86
- package/dist/src/commands/_async-ui.d.ts +1 -4
- package/dist/src/commands/_async-ui.js +9 -111
- package/dist/src/commands/_cli-format.d.ts +16 -9
- package/dist/src/commands/_cli-format.js +167 -295
- package/dist/src/commands/_connection-state.d.ts +11 -1
- package/dist/src/commands/_connection-state.js +50 -5
- package/dist/src/commands/_doctor-checks.d.ts +0 -6
- package/dist/src/commands/_doctor-checks.js +79 -382
- package/dist/src/commands/_help-catalog.d.ts +1 -1
- package/dist/src/commands/_help-catalog.js +217 -157
- package/dist/src/commands/_inprocess-services.d.ts +33 -0
- package/dist/src/commands/_inprocess-services.js +102 -0
- package/dist/src/commands/_json-output.js +4 -0
- package/dist/src/commands/_lazy-reconcile.d.ts +34 -0
- package/dist/src/commands/_lazy-reconcile.js +102 -0
- package/dist/src/commands/_paths.js +1 -1
- package/dist/src/commands/_pi-frontend.d.ts +18 -10
- package/dist/src/commands/_pi-frontend.js +37 -715
- package/dist/src/commands/_pi-install.js +18 -36
- package/dist/src/commands/_policy.d.ts +1 -1
- package/dist/src/commands/_policy.js +56 -15
- package/dist/src/commands/_run-bridge.d.ts +114 -0
- package/dist/src/commands/_run-bridge.js +387 -0
- package/dist/src/commands/_run-diagnostics.d.ts +9 -0
- package/dist/src/commands/_run-diagnostics.js +51 -0
- package/dist/src/commands/_run-driver-helpers.d.ts +8 -81
- package/dist/src/commands/_run-driver-helpers.js +79 -283
- package/dist/src/commands/_run-projection.d.ts +50 -0
- package/dist/src/commands/_run-projection.js +349 -0
- package/dist/src/commands/_run-subcommands.d.ts +3 -0
- package/dist/src/commands/_run-subcommands.js +31 -0
- package/dist/src/commands/_spinner.js +1 -1
- package/dist/src/commands/agent.d.ts +1 -1
- package/dist/src/commands/agent.js +8559 -239
- package/dist/src/commands/dist.d.ts +1 -1
- package/dist/src/commands/dist.js +27 -19
- package/dist/src/commands/doctor.d.ts +1 -1
- package/dist/src/commands/doctor.js +93 -475
- package/dist/src/commands/github.d.ts +1 -1
- package/dist/src/commands/github.js +113 -387
- package/dist/src/commands/inbox.d.ts +22 -24
- package/dist/src/commands/inbox.js +420 -691
- package/dist/src/commands/init.d.ts +6 -16
- package/dist/src/commands/init.js +334 -971
- package/dist/src/commands/inspect.d.ts +19 -2
- package/dist/src/commands/inspect.js +644 -610
- package/dist/src/commands/pi.d.ts +1 -1
- package/dist/src/commands/plugin.d.ts +1 -1
- package/dist/src/commands/plugin.js +486 -7
- package/dist/src/commands/profile-and-review.d.ts +1 -1
- package/dist/src/commands/profile-and-review.js +94 -56
- package/dist/src/commands/queue.js +1 -21
- package/dist/src/commands/remote.d.ts +1 -1
- package/dist/src/commands/remote.js +837 -14
- package/dist/src/commands/repo-git-harness.d.ts +1 -1
- package/dist/src/commands/repo-git-harness.js +57 -14
- package/dist/src/commands/run.d.ts +20 -2
- package/dist/src/commands/run.js +17579 -1759
- package/dist/src/commands/server.d.ts +2 -6
- package/dist/src/commands/server.js +141 -723
- package/dist/src/commands/setup.d.ts +1 -1
- package/dist/src/commands/setup.js +102 -484
- package/dist/src/commands/stats.d.ts +13 -10
- package/dist/src/commands/stats.js +689 -761
- package/dist/src/commands/task-run-driver.d.ts +50 -88
- package/dist/src/commands/task-run-driver.js +116 -2717
- package/dist/src/commands/task.d.ts +34 -13
- package/dist/src/commands/task.js +668 -2523
- package/dist/src/commands/test.d.ts +1 -1
- package/dist/src/commands/triage.d.ts +11 -0
- package/dist/src/commands/triage.js +227 -0
- package/dist/src/commands/workspace.d.ts +1 -1
- package/dist/src/commands.d.ts +0 -16
- package/dist/src/commands.js +16657 -12250
- package/dist/src/index.js +16528 -12497
- package/dist/src/launcher.js +4 -0
- package/dist/src/operator-cli.d.ts +2 -0
- package/dist/src/operator-cli.js +17837 -0
- package/dist/src/operator-entry.d.ts +1 -0
- package/dist/src/operator-entry.js +3 -0
- package/package.json +18 -12
- package/dist/src/app/board.d.ts +0 -23
- package/dist/src/app/board.js +0 -1786
- package/dist/src/app/theme.d.ts +0 -47
- package/dist/src/app/theme.js +0 -150
- package/dist/src/commands/_authority-runs.d.ts +0 -22
- package/dist/src/commands/_authority-runs.js +0 -110
- package/dist/src/commands/_operator-surface.d.ts +0 -34
- package/dist/src/commands/_operator-surface.js +0 -220
- package/dist/src/commands/_operator-view.d.ts +0 -30
- package/dist/src/commands/_operator-view.js +0 -1070
- package/dist/src/commands/_preflight.d.ts +0 -22
- package/dist/src/commands/_preflight.js +0 -540
- package/dist/src/commands/_run-replay.d.ts +0 -24
- package/dist/src/commands/_run-replay.js +0 -142
- package/dist/src/commands/_server-client.d.ts +0 -186
- package/dist/src/commands/_server-client.js +0 -681
- package/dist/src/commands/_snapshot-upload.d.ts +0 -39
- package/dist/src/commands/_snapshot-upload.js +0 -455
- package/dist/src/commands/_task-picker.d.ts +0 -9
- package/dist/src/commands/_task-picker.js +0 -201
- package/dist/src/commands/browser.d.ts +0 -65
- package/dist/src/commands/browser.js +0 -1173
- package/dist/src/commands/connect.d.ts +0 -7
- package/dist/src/commands/connect.js +0 -419
- package/dist/src/commands/inspector.d.ts +0 -3
- package/dist/src/commands/inspector.js +0 -263
- package/dist/src/commands/task-report-bug.d.ts +0 -19
- package/dist/src/commands/task-report-bug.js +0 -1281
- package/dist/src/report-bug.d.ts +0 -44
- package/dist/src/report-bug.js +0 -260
|
@@ -1,555 +1,13 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
// packages/cli/src/commands/_pi-frontend.ts
|
|
3
|
-
import { existsSync as existsSync3, mkdirSync as mkdirSync2, mkdtempSync, readFileSync as readFileSync3, rmSync, writeFileSync as writeFileSync2 } from "fs";
|
|
4
|
-
import { homedir as homedir2, tmpdir } from "os";
|
|
5
|
-
import { join } from "path";
|
|
6
|
-
import { main as runPiMain } from "@earendil-works/pi-coding-agent";
|
|
7
|
-
import createPiRigExtension from "@rig/pi-rig";
|
|
8
|
-
|
|
9
|
-
// packages/cli/src/commands/_server-client.ts
|
|
10
|
-
import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
|
|
11
|
-
import { resolve as resolve2 } from "path";
|
|
12
|
-
|
|
13
|
-
// packages/cli/src/runner.ts
|
|
14
|
-
import { EventBus } from "@rig/runtime/control-plane/runtime/events";
|
|
15
|
-
import { CliError as RuntimeCliError } from "@rig/runtime/control-plane/errors";
|
|
16
|
-
import { evaluate, loadPolicy, resolveAction } from "@rig/runtime/control-plane/runtime/guard";
|
|
17
|
-
import { buildBinary } from "@rig/runtime/control-plane/runtime/isolation";
|
|
18
|
-
|
|
19
|
-
class CliError extends RuntimeCliError {
|
|
20
|
-
hint;
|
|
21
|
-
constructor(message, exitCode = 1, options = {}) {
|
|
22
|
-
super(message, exitCode);
|
|
23
|
-
if (options.hint?.trim()) {
|
|
24
|
-
this.hint = options.hint.trim();
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// packages/cli/src/commands/_server-client.ts
|
|
30
|
-
import { ensureLocalRigServerConnection } from "@rig/runtime/local-server";
|
|
31
|
-
|
|
32
|
-
// packages/cli/src/commands/_connection-state.ts
|
|
33
|
-
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
34
3
|
import { homedir } from "os";
|
|
35
|
-
import {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
return resolve(stateDir, "connections.json");
|
|
43
|
-
return resolve(homedir(), ".rig", "connections.json");
|
|
44
|
-
}
|
|
45
|
-
function resolveRepoConnectionPath(projectRoot) {
|
|
46
|
-
return resolve(projectRoot, ".rig", "state", "connection.json");
|
|
47
|
-
}
|
|
48
|
-
function readJsonFile(path) {
|
|
49
|
-
if (!existsSync(path))
|
|
50
|
-
return null;
|
|
51
|
-
try {
|
|
52
|
-
return JSON.parse(readFileSync(path, "utf8"));
|
|
53
|
-
} catch (error) {
|
|
54
|
-
throw new CliError(`Invalid Rig connection state at ${path}: ${error instanceof Error ? error.message : String(error)}`, 1, { hint: "Fix or delete that file, then re-select a server with `rig server use <alias|local>`." });
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
function writeJsonFile(path, value) {
|
|
58
|
-
mkdirSync(dirname(path), { recursive: true });
|
|
59
|
-
writeFileSync(path, `${JSON.stringify(value, null, 2)}
|
|
60
|
-
`, "utf8");
|
|
61
|
-
}
|
|
62
|
-
function normalizeConnection(value) {
|
|
63
|
-
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
64
|
-
return null;
|
|
65
|
-
const record = value;
|
|
66
|
-
if (record.kind === "local")
|
|
67
|
-
return { kind: "local", mode: "auto" };
|
|
68
|
-
if (record.kind === "remote" && typeof record.baseUrl === "string" && record.baseUrl.trim()) {
|
|
69
|
-
const baseUrl = record.baseUrl.trim().replace(/\/+$/, "");
|
|
70
|
-
return { kind: "remote", baseUrl };
|
|
71
|
-
}
|
|
72
|
-
return null;
|
|
73
|
-
}
|
|
74
|
-
function readGlobalConnections(options = {}) {
|
|
75
|
-
const path = resolveGlobalConnectionsPath(options.env ?? process.env);
|
|
76
|
-
const payload = readJsonFile(path);
|
|
77
|
-
if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
|
|
78
|
-
return { connections: {} };
|
|
79
|
-
}
|
|
80
|
-
const rawConnections = payload.connections;
|
|
81
|
-
const connections = {};
|
|
82
|
-
if (rawConnections && typeof rawConnections === "object" && !Array.isArray(rawConnections)) {
|
|
83
|
-
for (const [alias, raw] of Object.entries(rawConnections)) {
|
|
84
|
-
const connection = normalizeConnection(raw);
|
|
85
|
-
if (connection)
|
|
86
|
-
connections[alias] = connection;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
return { connections };
|
|
90
|
-
}
|
|
91
|
-
function readRepoConnection(projectRoot) {
|
|
92
|
-
const payload = readJsonFile(resolveRepoConnectionPath(projectRoot));
|
|
93
|
-
if (!payload || typeof payload !== "object" || Array.isArray(payload))
|
|
94
|
-
return null;
|
|
95
|
-
const record = payload;
|
|
96
|
-
const selected = typeof record.selected === "string" ? record.selected.trim() : "";
|
|
97
|
-
if (!selected)
|
|
98
|
-
return null;
|
|
99
|
-
return {
|
|
100
|
-
selected,
|
|
101
|
-
project: typeof record.project === "string" ? record.project : undefined,
|
|
102
|
-
linkedAt: typeof record.linkedAt === "string" ? record.linkedAt : undefined,
|
|
103
|
-
serverProjectRoot: typeof record.serverProjectRoot === "string" && record.serverProjectRoot.trim() ? record.serverProjectRoot.trim() : undefined
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
function writeRepoConnection(projectRoot, state) {
|
|
107
|
-
writeJsonFile(resolveRepoConnectionPath(projectRoot), state);
|
|
108
|
-
}
|
|
109
|
-
function resolveSelectedConnection(projectRoot, options = {}) {
|
|
110
|
-
const repo = readRepoConnection(projectRoot);
|
|
111
|
-
if (!repo)
|
|
112
|
-
return null;
|
|
113
|
-
if (repo.selected === "local")
|
|
114
|
-
return { alias: "local", connection: { kind: "local", mode: "auto" }, serverProjectRoot: repo.serverProjectRoot };
|
|
115
|
-
const global = readGlobalConnections(options);
|
|
116
|
-
const connection = global.connections[repo.selected];
|
|
117
|
-
if (!connection) {
|
|
118
|
-
throw new CliError(`Selected Rig server "${repo.selected}" was not found. Run \`rig server list\` or \`rig server use local\`.`, 1);
|
|
119
|
-
}
|
|
120
|
-
return { alias: repo.selected, connection, serverProjectRoot: repo.serverProjectRoot };
|
|
121
|
-
}
|
|
122
|
-
function writeRepoServerProjectRoot(projectRoot, serverProjectRoot) {
|
|
123
|
-
const repo = readRepoConnection(projectRoot);
|
|
124
|
-
if (!repo)
|
|
125
|
-
return;
|
|
126
|
-
writeRepoConnection(projectRoot, { ...repo, serverProjectRoot });
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
// packages/cli/src/commands/_server-client.ts
|
|
130
|
-
var scopedGitHubBearerTokens = new Map;
|
|
131
|
-
var serverPhaseListener = null;
|
|
132
|
-
function setServerPhaseListener(listener) {
|
|
133
|
-
const previous = serverPhaseListener;
|
|
134
|
-
serverPhaseListener = listener;
|
|
135
|
-
return previous;
|
|
136
|
-
}
|
|
137
|
-
function reportServerPhase(label) {
|
|
138
|
-
serverPhaseListener?.(label);
|
|
139
|
-
}
|
|
140
|
-
function cleanToken(value) {
|
|
141
|
-
const trimmed = value?.trim();
|
|
142
|
-
return trimmed ? trimmed : null;
|
|
143
|
-
}
|
|
144
|
-
function readPrivateRemoteSessionToken(projectRoot) {
|
|
145
|
-
const path = resolve2(projectRoot, ".rig", "state", "github-auth.json");
|
|
146
|
-
if (!existsSync2(path))
|
|
147
|
-
return null;
|
|
148
|
-
try {
|
|
149
|
-
const parsed = JSON.parse(readFileSync2(path, "utf8"));
|
|
150
|
-
return cleanToken(typeof parsed.apiSessionToken === "string" ? parsed.apiSessionToken : typeof parsed.sessionToken === "string" ? parsed.sessionToken : undefined);
|
|
151
|
-
} catch {
|
|
152
|
-
return null;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
function readGitHubBearerTokenForRemote(projectRoot) {
|
|
156
|
-
const scopedKey = resolve2(projectRoot);
|
|
157
|
-
if (scopedGitHubBearerTokens.has(scopedKey))
|
|
158
|
-
return scopedGitHubBearerTokens.get(scopedKey) ?? null;
|
|
159
|
-
const privateSession = readPrivateRemoteSessionToken(projectRoot);
|
|
160
|
-
if (privateSession)
|
|
161
|
-
return privateSession;
|
|
162
|
-
return cleanToken(process.env.RIG_SERVER_AUTH_TOKEN) ?? cleanToken(process.env.RIG_REMOTE_AUTH_TOKEN);
|
|
163
|
-
}
|
|
164
|
-
function readStoredGitHubAuthToken(projectRoot) {
|
|
165
|
-
const path = resolve2(projectRoot, ".rig", "state", "github-auth.json");
|
|
166
|
-
if (!existsSync2(path))
|
|
167
|
-
return null;
|
|
168
|
-
try {
|
|
169
|
-
const parsed = JSON.parse(readFileSync2(path, "utf8"));
|
|
170
|
-
return cleanToken(typeof parsed.token === "string" ? parsed.token : undefined);
|
|
171
|
-
} catch {
|
|
172
|
-
return null;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
function readLocalConnectionFallbackToken(projectRoot) {
|
|
176
|
-
return readGitHubBearerTokenForRemote(projectRoot) ?? cleanToken(process.env.RIG_GITHUB_TOKEN) ?? readStoredGitHubAuthToken(projectRoot);
|
|
177
|
-
}
|
|
178
|
-
async function ensureServerForCli(projectRoot) {
|
|
179
|
-
try {
|
|
180
|
-
const selected = resolveSelectedConnection(projectRoot);
|
|
181
|
-
if (selected?.connection.kind === "remote") {
|
|
182
|
-
reportServerPhase(`Connecting to ${selected.alias}\u2026`);
|
|
183
|
-
const authToken = readGitHubBearerTokenForRemote(projectRoot);
|
|
184
|
-
const serverProjectRoot = selected.serverProjectRoot ?? await backfillRemoteServerProjectRoot(projectRoot, selected.connection.baseUrl, authToken);
|
|
185
|
-
return {
|
|
186
|
-
baseUrl: selected.connection.baseUrl,
|
|
187
|
-
authToken,
|
|
188
|
-
connectionKind: "remote",
|
|
189
|
-
serverProjectRoot
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
reportServerPhase("Starting local Rig server\u2026");
|
|
193
|
-
const connection = await ensureLocalRigServerConnection(projectRoot);
|
|
194
|
-
return {
|
|
195
|
-
baseUrl: connection.baseUrl,
|
|
196
|
-
authToken: connection.authToken ?? readLocalConnectionFallbackToken(projectRoot),
|
|
197
|
-
connectionKind: "local",
|
|
198
|
-
serverProjectRoot: resolve2(projectRoot)
|
|
199
|
-
};
|
|
200
|
-
} catch (error) {
|
|
201
|
-
if (error instanceof Error) {
|
|
202
|
-
throw new CliError(error.message, 1);
|
|
203
|
-
}
|
|
204
|
-
throw error;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
async function backfillRemoteServerProjectRoot(projectRoot, baseUrl, authToken) {
|
|
208
|
-
const repo = readRepoConnection(projectRoot);
|
|
209
|
-
const slug = repo?.project?.trim();
|
|
210
|
-
if (!slug)
|
|
211
|
-
return null;
|
|
212
|
-
try {
|
|
213
|
-
const response = await fetch(`${baseUrl}/api/projects/${encodeURIComponent(slug)}`, {
|
|
214
|
-
headers: mergeHeaders(undefined, authToken)
|
|
215
|
-
});
|
|
216
|
-
if (!response.ok)
|
|
217
|
-
return null;
|
|
218
|
-
const payload = await response.json();
|
|
219
|
-
const project = payload.project && typeof payload.project === "object" && !Array.isArray(payload.project) ? payload.project : null;
|
|
220
|
-
const checkouts = Array.isArray(project?.checkouts) ? project.checkouts : [];
|
|
221
|
-
const latestCheckout = [...checkouts].reverse().find((entry) => Boolean(entry && typeof entry === "object" && !Array.isArray(entry) && typeof entry.path === "string"));
|
|
222
|
-
const path = typeof latestCheckout?.path === "string" && latestCheckout.path.trim() ? latestCheckout.path.trim() : null;
|
|
223
|
-
if (path)
|
|
224
|
-
writeRepoServerProjectRoot(projectRoot, path);
|
|
225
|
-
return path;
|
|
226
|
-
} catch {
|
|
227
|
-
return null;
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
function mergeHeaders(headers, authToken) {
|
|
231
|
-
const merged = new Headers(headers);
|
|
232
|
-
if (authToken) {
|
|
233
|
-
merged.set("authorization", `Bearer ${authToken}`);
|
|
234
|
-
}
|
|
235
|
-
return merged;
|
|
236
|
-
}
|
|
237
|
-
function diagnosticMessage(payload) {
|
|
238
|
-
if (!payload || typeof payload !== "object" || Array.isArray(payload))
|
|
239
|
-
return null;
|
|
240
|
-
const record = payload;
|
|
241
|
-
const diagnostics = Array.isArray(record.diagnostics) ? record.diagnostics : [];
|
|
242
|
-
const messages = diagnostics.flatMap((entry) => {
|
|
243
|
-
if (!entry || typeof entry !== "object" || Array.isArray(entry))
|
|
244
|
-
return [];
|
|
245
|
-
const diagnostic = entry;
|
|
246
|
-
const kind = typeof diagnostic.kind === "string" ? diagnostic.kind : "task-source";
|
|
247
|
-
const message = typeof diagnostic.message === "string" ? diagnostic.message : null;
|
|
248
|
-
return message ? [`${kind}: ${message}`] : [];
|
|
249
|
-
});
|
|
250
|
-
return messages.length > 0 ? messages.join("; ") : null;
|
|
251
|
-
}
|
|
252
|
-
var serverReachabilityCache = new Map;
|
|
253
|
-
async function probeServerReachability(baseUrl, authToken) {
|
|
254
|
-
try {
|
|
255
|
-
const response = await fetch(`${baseUrl.replace(/\/+$/, "")}/api/server/status`, {
|
|
256
|
-
headers: mergeHeaders(undefined, authToken),
|
|
257
|
-
signal: AbortSignal.timeout(1500)
|
|
258
|
-
});
|
|
259
|
-
return response.ok;
|
|
260
|
-
} catch {
|
|
261
|
-
return false;
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
function cachedServerReachability(projectRoot, baseUrl, authToken) {
|
|
265
|
-
const key = resolve2(projectRoot);
|
|
266
|
-
const cached = serverReachabilityCache.get(key);
|
|
267
|
-
if (cached)
|
|
268
|
-
return cached;
|
|
269
|
-
const probe = probeServerReachability(baseUrl, authToken);
|
|
270
|
-
serverReachabilityCache.set(key, probe);
|
|
271
|
-
return probe;
|
|
272
|
-
}
|
|
273
|
-
function describeSelectedServer(projectRoot, server) {
|
|
274
|
-
try {
|
|
275
|
-
const selected = resolveSelectedConnection(projectRoot);
|
|
276
|
-
if (selected) {
|
|
277
|
-
return {
|
|
278
|
-
alias: selected.alias,
|
|
279
|
-
target: selected.connection.kind === "remote" ? selected.connection.baseUrl : server.baseUrl
|
|
280
|
-
};
|
|
281
|
-
}
|
|
282
|
-
} catch {}
|
|
283
|
-
return { alias: server.connectionKind === "remote" ? "remote" : "local", target: server.baseUrl };
|
|
284
|
-
}
|
|
285
|
-
async function buildServerFailureContext(projectRoot, server) {
|
|
286
|
-
const { alias, target } = describeSelectedServer(projectRoot, server);
|
|
287
|
-
const reachable = await cachedServerReachability(projectRoot, server.baseUrl, server.authToken);
|
|
288
|
-
const reachability = reachable ? "server is reachable" : "server is unreachable";
|
|
289
|
-
return {
|
|
290
|
-
contextLine: `Currently connected to: ${alias} at ${target} (${reachability}).`,
|
|
291
|
-
hint: "Check the selected server with `rig server status`, or switch with `rig server use <alias|local>`."
|
|
292
|
-
};
|
|
293
|
-
}
|
|
294
|
-
async function requestServerJson(context, pathname, init = {}) {
|
|
295
|
-
const server = await ensureServerForCli(context.projectRoot);
|
|
296
|
-
const headers = mergeHeaders(init.headers, server.authToken);
|
|
297
|
-
if (server.serverProjectRoot)
|
|
298
|
-
headers.set("x-rig-project-root", server.serverProjectRoot);
|
|
299
|
-
reportServerPhase(`${(init.method ?? "GET").toUpperCase()} ${pathname.split("?")[0]}\u2026`);
|
|
300
|
-
let response;
|
|
301
|
-
try {
|
|
302
|
-
response = await fetch(`${server.baseUrl}${pathname}`, {
|
|
303
|
-
...init,
|
|
304
|
-
headers
|
|
305
|
-
});
|
|
306
|
-
} catch (error) {
|
|
307
|
-
const failure = await buildServerFailureContext(context.projectRoot, server);
|
|
308
|
-
throw new CliError(`Rig server request failed: ${error instanceof Error ? error.message : String(error)}
|
|
309
|
-
${failure.contextLine}`, 1, { hint: failure.hint });
|
|
310
|
-
}
|
|
311
|
-
const text = await response.text();
|
|
312
|
-
const payload = text.trim().length > 0 ? (() => {
|
|
313
|
-
try {
|
|
314
|
-
return JSON.parse(text);
|
|
315
|
-
} catch {
|
|
316
|
-
return null;
|
|
317
|
-
}
|
|
318
|
-
})() : null;
|
|
319
|
-
if (!response.ok) {
|
|
320
|
-
const diagnostics = diagnosticMessage(payload);
|
|
321
|
-
const rawDetail = diagnostics ?? (text || response.statusText);
|
|
322
|
-
const detail = diagnostics ? rawDetail : rawDetail.split(`
|
|
323
|
-
`).map((line) => line.trim()).find((line) => line.length > 0)?.slice(0, 200) ?? response.statusText;
|
|
324
|
-
const failure = await buildServerFailureContext(context.projectRoot, server);
|
|
325
|
-
throw new CliError(`Rig server request failed (${response.status}): ${detail}
|
|
326
|
-
${failure.contextLine}`, 1, { hint: failure.hint });
|
|
327
|
-
}
|
|
328
|
-
return payload;
|
|
329
|
-
}
|
|
330
|
-
async function getRunDetailsViaServer(context, runId) {
|
|
331
|
-
const payload = await requestServerJson(context, `/api/runs/${encodeURIComponent(runId)}`);
|
|
332
|
-
return payload && typeof payload === "object" && !Array.isArray(payload) ? payload : {};
|
|
333
|
-
}
|
|
334
|
-
var RESUMABLE_RUN_STATUSES = new Set([
|
|
335
|
-
"created",
|
|
336
|
-
"preparing",
|
|
337
|
-
"running",
|
|
338
|
-
"validating",
|
|
339
|
-
"reviewing",
|
|
340
|
-
"stopped",
|
|
341
|
-
"failed",
|
|
342
|
-
"needs-attention",
|
|
343
|
-
"needs_attention"
|
|
344
|
-
]);
|
|
345
|
-
|
|
346
|
-
// packages/cli/src/commands/_async-ui.ts
|
|
347
|
-
import pc from "picocolors";
|
|
348
|
-
|
|
349
|
-
// packages/cli/src/commands/_spinner.ts
|
|
350
|
-
var SPINNER_FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
|
|
351
|
-
function createTtySpinner(input) {
|
|
352
|
-
const output = input.output ?? process.stdout;
|
|
353
|
-
const isTty = output.isTTY === true;
|
|
354
|
-
const frames = input.frames && input.frames.length > 0 ? input.frames : SPINNER_FRAMES;
|
|
355
|
-
let label = input.label;
|
|
356
|
-
let frame = 0;
|
|
357
|
-
let paused = false;
|
|
358
|
-
let stopped = false;
|
|
359
|
-
let lastPrintedLabel = "";
|
|
360
|
-
const render = () => {
|
|
361
|
-
if (stopped || paused)
|
|
362
|
-
return;
|
|
363
|
-
if (!isTty) {
|
|
364
|
-
if (label !== lastPrintedLabel) {
|
|
365
|
-
output.write(`${label}
|
|
366
|
-
`);
|
|
367
|
-
lastPrintedLabel = label;
|
|
368
|
-
}
|
|
369
|
-
return;
|
|
370
|
-
}
|
|
371
|
-
frame = (frame + 1) % frames.length;
|
|
372
|
-
const glyph = frames[frame] ?? frames[0] ?? "";
|
|
373
|
-
output.write(`\r\x1B[2K${input.styleFrame ? input.styleFrame(glyph) : glyph} ${label}`);
|
|
374
|
-
};
|
|
375
|
-
const clearLine = () => {
|
|
376
|
-
if (isTty)
|
|
377
|
-
output.write("\r\x1B[2K");
|
|
378
|
-
};
|
|
379
|
-
render();
|
|
380
|
-
const timer = isTty ? setInterval(render, input.intervalMs ?? 120) : null;
|
|
381
|
-
return {
|
|
382
|
-
setLabel(next) {
|
|
383
|
-
label = next;
|
|
384
|
-
render();
|
|
385
|
-
},
|
|
386
|
-
pause() {
|
|
387
|
-
paused = true;
|
|
388
|
-
clearLine();
|
|
389
|
-
},
|
|
390
|
-
resume() {
|
|
391
|
-
if (stopped)
|
|
392
|
-
return;
|
|
393
|
-
paused = false;
|
|
394
|
-
render();
|
|
395
|
-
},
|
|
396
|
-
stop(finalLine) {
|
|
397
|
-
if (stopped)
|
|
398
|
-
return;
|
|
399
|
-
stopped = true;
|
|
400
|
-
if (timer)
|
|
401
|
-
clearInterval(timer);
|
|
402
|
-
clearLine();
|
|
403
|
-
if (finalLine)
|
|
404
|
-
output.write(`${finalLine}
|
|
405
|
-
`);
|
|
406
|
-
}
|
|
407
|
-
};
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
// packages/cli/src/app/theme.ts
|
|
411
|
-
var RIG_PALETTE = {
|
|
412
|
-
ink: "#f2f3f6",
|
|
413
|
-
ink2: "#aeb0ba",
|
|
414
|
-
ink3: "#6c6e79",
|
|
415
|
-
ink4: "#44464f",
|
|
416
|
-
accent: "#ccff4d",
|
|
417
|
-
accentDim: "#a9d63f",
|
|
418
|
-
cyan: "#56d8ff",
|
|
419
|
-
red: "#ff5d5d",
|
|
420
|
-
yellow: "#ffd24d"
|
|
421
|
-
};
|
|
422
|
-
function hexToRgb(hex) {
|
|
423
|
-
const value = hex.replace("#", "");
|
|
424
|
-
return [
|
|
425
|
-
Number.parseInt(value.slice(0, 2), 16),
|
|
426
|
-
Number.parseInt(value.slice(2, 4), 16),
|
|
427
|
-
Number.parseInt(value.slice(4, 6), 16)
|
|
428
|
-
];
|
|
429
|
-
}
|
|
430
|
-
function fg(hex) {
|
|
431
|
-
const [r, g, b] = hexToRgb(hex);
|
|
432
|
-
return (text) => `\x1B[38;2;${r};${g};${b}m${text}\x1B[39m`;
|
|
433
|
-
}
|
|
434
|
-
var ink = fg(RIG_PALETTE.ink);
|
|
435
|
-
var ink2 = fg(RIG_PALETTE.ink2);
|
|
436
|
-
var ink3 = fg(RIG_PALETTE.ink3);
|
|
437
|
-
var ink4 = fg(RIG_PALETTE.ink4);
|
|
438
|
-
var accent = fg(RIG_PALETTE.accent);
|
|
439
|
-
var accentDim = fg(RIG_PALETTE.accentDim);
|
|
440
|
-
var cyan = fg(RIG_PALETTE.cyan);
|
|
441
|
-
var red = fg(RIG_PALETTE.red);
|
|
442
|
-
var yellow = fg(RIG_PALETTE.yellow);
|
|
443
|
-
function bold(text) {
|
|
444
|
-
return `\x1B[1m${text}\x1B[22m`;
|
|
445
|
-
}
|
|
446
|
-
var DRONE_ART = [
|
|
447
|
-
" .-=-. .-=-. ",
|
|
448
|
-
" ( !!! ) ( !!! ) ",
|
|
449
|
-
" '-=-'._ _.'-=-' ",
|
|
450
|
-
" '._ _.' ",
|
|
451
|
-
" '=$$$$$$$=.' ",
|
|
452
|
-
" =$$$$$$$$$$$= ",
|
|
453
|
-
" $$$@@@@@@@@@@$$$ ",
|
|
454
|
-
" $$$@@ @@$$$ ",
|
|
455
|
-
" $$@ ? @$$$ ",
|
|
456
|
-
" $$$@ '-' @$$$ ",
|
|
457
|
-
" $$$@@ @@$$$ ",
|
|
458
|
-
" $$$@@@@@@@@@@$$$ ",
|
|
459
|
-
" =$$$$$$$$$$$= ",
|
|
460
|
-
" '=$$$$$$$=.' ",
|
|
461
|
-
" _.' '._ ",
|
|
462
|
-
" .-=-.' '.-=-. ",
|
|
463
|
-
" ( !!! ) ( !!! ) ",
|
|
464
|
-
" '-=-' '-=-' "
|
|
465
|
-
];
|
|
466
|
-
var EYE_FRAMES = ["@", "o", "."];
|
|
467
|
-
var DRONE_WIDTH = DRONE_ART[0].length;
|
|
468
|
-
var DRONE_HEIGHT = DRONE_ART.length;
|
|
469
|
-
var MICRO_BLADES = ["---", "\\\\\\", "|||", "///"];
|
|
470
|
-
function microDroneFrame(tick) {
|
|
471
|
-
const blade = MICRO_BLADES[tick % MICRO_BLADES.length];
|
|
472
|
-
const eye = EYE_FRAMES[Math.floor(tick / 2) % EYE_FRAMES.length];
|
|
473
|
-
return `(${blade})${eye}(${blade})`;
|
|
474
|
-
}
|
|
475
|
-
var MICRO_DRONE_FRAMES = Array.from({ length: 12 }, (_, index) => microDroneFrame(index));
|
|
476
|
-
function renderMicroDroneFrame(tick) {
|
|
477
|
-
const blade = MICRO_BLADES[tick % MICRO_BLADES.length];
|
|
478
|
-
const eye = EYE_FRAMES[Math.floor(tick / 2) % EYE_FRAMES.length];
|
|
479
|
-
return `${ink4("(")}${cyan(blade)}${ink4(")")}${bold(accent(eye))}${ink4("(")}${cyan(blade)}${ink4(")")}`;
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
// packages/cli/src/commands/_async-ui.ts
|
|
483
|
-
var DONE_SYMBOL = pc.green("\u25C7");
|
|
484
|
-
var FAIL_SYMBOL = pc.red("\u25A0");
|
|
485
|
-
var activeUpdate = null;
|
|
486
|
-
async function withSpinner(label, work, options = {}) {
|
|
487
|
-
if (options.outputMode === "json") {
|
|
488
|
-
return work(() => {});
|
|
489
|
-
}
|
|
490
|
-
if (activeUpdate) {
|
|
491
|
-
const outer = activeUpdate;
|
|
492
|
-
outer(label);
|
|
493
|
-
return work(outer);
|
|
494
|
-
}
|
|
495
|
-
const output = options.output ?? process.stderr;
|
|
496
|
-
const isTty = output.isTTY === true;
|
|
497
|
-
let lastLabel = label;
|
|
498
|
-
if (!isTty) {
|
|
499
|
-
output.write(`${label}
|
|
500
|
-
`);
|
|
501
|
-
const update2 = (next) => {
|
|
502
|
-
lastLabel = next;
|
|
503
|
-
};
|
|
504
|
-
activeUpdate = update2;
|
|
505
|
-
const previousListener2 = setServerPhaseListener(update2);
|
|
506
|
-
try {
|
|
507
|
-
return await work(update2);
|
|
508
|
-
} finally {
|
|
509
|
-
activeUpdate = null;
|
|
510
|
-
setServerPhaseListener(previousListener2);
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
const spinner = createTtySpinner({
|
|
514
|
-
label,
|
|
515
|
-
output,
|
|
516
|
-
frames: MICRO_DRONE_FRAMES,
|
|
517
|
-
styleFrame: (frame) => renderMicroDroneFrame(Math.max(0, MICRO_DRONE_FRAMES.indexOf(frame)))
|
|
518
|
-
});
|
|
519
|
-
const update = (next) => {
|
|
520
|
-
lastLabel = next;
|
|
521
|
-
spinner.setLabel(next);
|
|
522
|
-
};
|
|
523
|
-
activeUpdate = update;
|
|
524
|
-
const previousListener = setServerPhaseListener(update);
|
|
525
|
-
try {
|
|
526
|
-
const result = await work(update);
|
|
527
|
-
spinner.stop(options.doneLabel ? `${DONE_SYMBOL} ${options.doneLabel}` : undefined);
|
|
528
|
-
return result;
|
|
529
|
-
} catch (error) {
|
|
530
|
-
spinner.stop(`${FAIL_SYMBOL} ${lastLabel}`);
|
|
531
|
-
throw error;
|
|
532
|
-
} finally {
|
|
533
|
-
activeUpdate = null;
|
|
534
|
-
setServerPhaseListener(previousListener);
|
|
535
|
-
}
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
// packages/cli/src/commands/_pi-frontend.ts
|
|
539
|
-
function setTemporaryEnv(updates) {
|
|
540
|
-
const previous = new Map;
|
|
541
|
-
for (const [key, value] of Object.entries(updates)) {
|
|
542
|
-
previous.set(key, process.env[key]);
|
|
543
|
-
process.env[key] = value;
|
|
544
|
-
}
|
|
545
|
-
return () => {
|
|
546
|
-
for (const [key, value] of previous) {
|
|
547
|
-
if (value === undefined)
|
|
548
|
-
delete process.env[key];
|
|
549
|
-
else
|
|
550
|
-
process.env[key] = value;
|
|
551
|
-
}
|
|
552
|
-
};
|
|
4
|
+
import { join } from "path";
|
|
5
|
+
import { assertPathInsideRoot, assertSafeRunId, safePathSegment } from "@rig/shared/safe-identifiers";
|
|
6
|
+
var TERMINAL_RUN_STATUSES = { completed: true, failed: true, stopped: true, cancelled: true, canceled: true, closed: true, merged: true, needs_attention: true, "needs-attention": true };
|
|
7
|
+
function resolveOperatorDroneCwd(runId, homeDir = homedir()) {
|
|
8
|
+
const safeRunId = assertSafeRunId(runId);
|
|
9
|
+
const dronesRoot = join(homeDir, ".rig", "drones");
|
|
10
|
+
return assertPathInsideRoot(dronesRoot, join(dronesRoot, safePathSegment(String(safeRunId).slice(0, 8), { fallback: "run", maxLength: 32 })), "operator drone cwd");
|
|
553
11
|
}
|
|
554
12
|
function buildOperatorPiEnv(input) {
|
|
555
13
|
return {
|
|
@@ -563,180 +21,44 @@ function buildOperatorPiEnv(input) {
|
|
|
563
21
|
...input.serverProjectRoot ? { RIG_PROJECT_ROOT: input.serverProjectRoot } : {}
|
|
564
22
|
};
|
|
565
23
|
}
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
const localCwd = join(homedir2(), ".rig", "drones", runId.slice(0, 8));
|
|
569
|
-
mkdirSync2(localCwd, { recursive: true });
|
|
570
|
-
trustDroneCwd(localCwd);
|
|
571
|
-
installRigPiTheme();
|
|
572
|
-
let sessionFileArg = [];
|
|
573
|
-
try {
|
|
574
|
-
const payload = await requestServerJson(context, `/api/runs/${encodeURIComponent(runId)}/session-file`);
|
|
575
|
-
if (payload?.ok && typeof payload.content === "string" && payload.content.trim()) {
|
|
576
|
-
const fileName = typeof payload.fileName === "string" && payload.fileName.trim() ? payload.fileName.replace(/[^A-Za-z0-9._-]/g, "_") : `rig-run-${runId}.jsonl`;
|
|
577
|
-
const localSessionPath = join(tempSessionDir, fileName);
|
|
578
|
-
const content = payload.content.split(`
|
|
579
|
-
`).map((line, index) => {
|
|
580
|
-
if (index > 0 || !line.trim())
|
|
581
|
-
return line;
|
|
582
|
-
try {
|
|
583
|
-
const header = JSON.parse(line);
|
|
584
|
-
if (header.type === "session" && typeof header.cwd === "string") {
|
|
585
|
-
return JSON.stringify({ ...header, cwd: localCwd });
|
|
586
|
-
}
|
|
587
|
-
} catch {}
|
|
588
|
-
return line;
|
|
589
|
-
}).join(`
|
|
590
|
-
`);
|
|
591
|
-
writeFileSync2(localSessionPath, content);
|
|
592
|
-
sessionFileArg = ["--session", localSessionPath];
|
|
593
|
-
}
|
|
594
|
-
} catch {}
|
|
595
|
-
return { server, sessionFileArg };
|
|
24
|
+
function shouldRequireOperatorTranscript(status) {
|
|
25
|
+
return typeof status === "string" && TERMINAL_RUN_STATUSES[status.trim().toLowerCase()] === true;
|
|
596
26
|
}
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
acid: "#ccff4d",
|
|
602
|
-
acidDim: "#a9d63f",
|
|
603
|
-
cyan: "#56d8ff",
|
|
604
|
-
red: "#ff5d5d",
|
|
605
|
-
yellow: "#ffd24d",
|
|
606
|
-
ink: "#f2f3f6",
|
|
607
|
-
ink2: "#aeb0ba",
|
|
608
|
-
ink3: "#6c6e79",
|
|
609
|
-
ink4: "#44464f",
|
|
610
|
-
panel: "#101115",
|
|
611
|
-
panelUser: "#14161b",
|
|
612
|
-
toolPending: "#0e1013",
|
|
613
|
-
toolSuccess: "#10150c",
|
|
614
|
-
toolError: "#1a0f0f",
|
|
615
|
-
customMsg: "#0f1410"
|
|
616
|
-
},
|
|
617
|
-
colors: {
|
|
618
|
-
accent: "acid",
|
|
619
|
-
border: "ink4",
|
|
620
|
-
borderAccent: "acid",
|
|
621
|
-
borderMuted: "ink4",
|
|
622
|
-
success: "acid",
|
|
623
|
-
error: "red",
|
|
624
|
-
warning: "yellow",
|
|
625
|
-
muted: "ink3",
|
|
626
|
-
dim: "ink4",
|
|
627
|
-
text: "ink",
|
|
628
|
-
thinkingText: "ink3",
|
|
629
|
-
selectedBg: "panel",
|
|
630
|
-
userMessageBg: "panelUser",
|
|
631
|
-
userMessageText: "ink",
|
|
632
|
-
customMessageBg: "customMsg",
|
|
633
|
-
customMessageText: "ink2",
|
|
634
|
-
customMessageLabel: "acidDim",
|
|
635
|
-
toolPendingBg: "toolPending",
|
|
636
|
-
toolSuccessBg: "toolSuccess",
|
|
637
|
-
toolErrorBg: "toolError",
|
|
638
|
-
toolTitle: "ink",
|
|
639
|
-
toolOutput: "ink3",
|
|
640
|
-
mdHeading: "acid",
|
|
641
|
-
mdLink: "cyan",
|
|
642
|
-
mdLinkUrl: "ink4",
|
|
643
|
-
mdCode: "acidDim",
|
|
644
|
-
mdCodeBlock: "ink2",
|
|
645
|
-
mdCodeBlockBorder: "ink4",
|
|
646
|
-
mdQuote: "ink3",
|
|
647
|
-
mdQuoteBorder: "ink4",
|
|
648
|
-
mdHr: "ink4",
|
|
649
|
-
mdListBullet: "acid",
|
|
650
|
-
toolDiffAdded: "acid",
|
|
651
|
-
toolDiffRemoved: "red",
|
|
652
|
-
toolDiffContext: "ink3",
|
|
653
|
-
syntaxComment: "ink3",
|
|
654
|
-
syntaxKeyword: "cyan",
|
|
655
|
-
syntaxFunction: "acid",
|
|
656
|
-
syntaxVariable: "ink",
|
|
657
|
-
syntaxString: "acidDim",
|
|
658
|
-
syntaxNumber: "yellow",
|
|
659
|
-
syntaxType: "cyan",
|
|
660
|
-
syntaxOperator: "ink2",
|
|
661
|
-
syntaxPunctuation: "ink3",
|
|
662
|
-
thinkingOff: "ink4",
|
|
663
|
-
thinkingMinimal: "ink3",
|
|
664
|
-
thinkingLow: "ink2",
|
|
665
|
-
thinkingMedium: "cyan",
|
|
666
|
-
thinkingHigh: "acidDim",
|
|
667
|
-
thinkingXhigh: "acid",
|
|
668
|
-
bashMode: "cyan"
|
|
669
|
-
}
|
|
670
|
-
};
|
|
671
|
-
function trustDroneCwd(localCwd) {
|
|
672
|
-
try {
|
|
673
|
-
const agentDir = join(homedir2(), ".pi", "agent");
|
|
674
|
-
mkdirSync2(agentDir, { recursive: true });
|
|
675
|
-
const trustPath = join(agentDir, "trust.json");
|
|
676
|
-
const store = existsSync3(trustPath) ? JSON.parse(readFileSync3(trustPath, "utf8")) : {};
|
|
677
|
-
if (store[localCwd] !== true) {
|
|
678
|
-
store[localCwd] = true;
|
|
679
|
-
writeFileSync2(trustPath, `${JSON.stringify(store, null, "\t")}
|
|
680
|
-
`);
|
|
681
|
-
}
|
|
682
|
-
} catch {}
|
|
683
|
-
}
|
|
684
|
-
function installRigPiTheme() {
|
|
685
|
-
try {
|
|
686
|
-
const themesDir = join(homedir2(), ".pi", "agent", "themes");
|
|
687
|
-
mkdirSync2(themesDir, { recursive: true });
|
|
688
|
-
const themePath = join(themesDir, "rig.json");
|
|
689
|
-
const next = `${JSON.stringify(RIG_PI_THEME, null, "\t")}
|
|
690
|
-
`;
|
|
691
|
-
if (!existsSync3(themePath) || readFileSync3(themePath, "utf8") !== next) {
|
|
692
|
-
writeFileSync2(themePath, next);
|
|
693
|
-
}
|
|
694
|
-
} catch {}
|
|
27
|
+
function missingOperatorTranscriptMessage(runId, status) {
|
|
28
|
+
const shortRun = runId.trim().slice(0, 8) || "unknown";
|
|
29
|
+
const statusText = typeof status === "string" && status.trim() ? status.trim() : "terminal";
|
|
30
|
+
return `Run ${shortRun} is ${statusText}, but no worker Pi session transcript is recorded for this run. It likely failed before Pi started or predates full-session capture. Use \`rig run show ${runId}\` and \`rig run logs ${runId}\` for the lifecycle details.`;
|
|
695
31
|
}
|
|
696
|
-
async function
|
|
697
|
-
const
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
createPiRigExtension(pi);
|
|
32
|
+
async function runWithProcessExitGuard(body) {
|
|
33
|
+
const realExit = process.exit;
|
|
34
|
+
let exitCode = 0;
|
|
35
|
+
let signalQuit = () => {};
|
|
36
|
+
const quit = new Promise((resolve) => {
|
|
37
|
+
signalQuit = resolve;
|
|
38
|
+
});
|
|
39
|
+
const guardedExit = (code) => {
|
|
40
|
+
exitCode = typeof code === "number" ? code : 0;
|
|
41
|
+
signalQuit();
|
|
42
|
+
return;
|
|
708
43
|
};
|
|
709
|
-
|
|
44
|
+
process.exit = guardedExit;
|
|
710
45
|
try {
|
|
711
|
-
await
|
|
712
|
-
"--no-extensions",
|
|
713
|
-
"--no-skills",
|
|
714
|
-
"--no-prompt-templates",
|
|
715
|
-
"--no-context-files",
|
|
716
|
-
...sessionFileArg
|
|
717
|
-
], {
|
|
718
|
-
extensionFactories: [piRigExtensionFactory]
|
|
719
|
-
});
|
|
720
|
-
detached = true;
|
|
46
|
+
await Promise.race([Promise.resolve().then(body), quit]);
|
|
721
47
|
} finally {
|
|
722
|
-
|
|
723
|
-
rmSync(tempSessionDir, { recursive: true, force: true });
|
|
48
|
+
process.exit = realExit;
|
|
724
49
|
}
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
logs: [],
|
|
732
|
-
timeline: [],
|
|
733
|
-
timelineCursor: null,
|
|
734
|
-
steered: input.steered === true,
|
|
735
|
-
detached,
|
|
736
|
-
rendered: "stock Pi operator console with the pi-rig extension"
|
|
737
|
-
};
|
|
50
|
+
return exitCode;
|
|
51
|
+
}
|
|
52
|
+
async function attachRunBundledPiFrontend(context, input) {
|
|
53
|
+
input.steered;
|
|
54
|
+
input.returnOnQuit;
|
|
55
|
+
throw new Error(`Interactive Pi attach for run ${input.runId} was removed in the OMP-collab cutover. Run bare \`rig\` and use the OMP cockpit run detail for the live session; legacy automation can request a non-interactive text snapshot with --once or --json.`);
|
|
738
56
|
}
|
|
739
57
|
export {
|
|
58
|
+
shouldRequireOperatorTranscript,
|
|
59
|
+
runWithProcessExitGuard,
|
|
60
|
+
resolveOperatorDroneCwd,
|
|
61
|
+
missingOperatorTranscriptMessage,
|
|
740
62
|
buildOperatorPiEnv,
|
|
741
63
|
attachRunBundledPiFrontend
|
|
742
64
|
};
|