@h-rig/cli 0.0.6-alpha.9 → 0.0.6-alpha.90
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 -1
- package/dist/bin/build-rig-binaries.d.ts +2 -0
- package/dist/bin/rig.d.ts +2 -0
- package/dist/bin/rig.js +11052 -6668
- package/dist/src/app/board.d.ts +23 -0
- package/dist/src/app/board.js +1786 -0
- package/dist/src/app/drone-ui.d.ts +37 -0
- package/dist/src/app/drone-ui.js +294 -0
- package/dist/src/app/theme.d.ts +47 -0
- package/dist/src/app/theme.js +150 -0
- package/dist/src/commands/_async-ui.d.ts +13 -0
- package/dist/src/commands/_async-ui.js +223 -0
- package/dist/src/commands/_authority-runs.d.ts +22 -0
- package/dist/src/commands/_authority-runs.js +2 -3
- package/dist/src/commands/_cli-format.d.ts +49 -0
- package/dist/src/commands/_cli-format.js +447 -0
- package/dist/src/commands/_connection-state.d.ts +44 -0
- package/dist/src/commands/_connection-state.js +30 -11
- package/dist/src/commands/_doctor-checks.d.ts +52 -0
- package/dist/src/commands/_doctor-checks.js +180 -44
- package/dist/src/commands/_help-catalog.d.ts +51 -0
- package/dist/src/commands/_help-catalog.js +442 -0
- package/dist/src/commands/_json-output.d.ts +11 -0
- package/dist/src/commands/_json-output.js +56 -0
- package/dist/src/commands/_operator-surface.d.ts +34 -0
- package/dist/src/commands/_operator-surface.js +220 -0
- package/dist/src/commands/_operator-view.d.ts +30 -0
- package/dist/src/commands/_operator-view.js +803 -73
- package/dist/src/commands/_parsers.d.ts +15 -0
- package/dist/src/commands/_parsers.js +18 -11
- package/dist/src/commands/_paths.d.ts +11 -0
- package/dist/src/commands/_pi-frontend.d.ts +27 -0
- package/dist/src/commands/_pi-frontend.js +742 -0
- package/dist/src/commands/_pi-install.d.ts +42 -0
- package/dist/src/commands/_pi-install.js +5 -4
- package/dist/src/commands/_policy.d.ts +8 -0
- package/dist/src/commands/_policy.js +12 -5
- package/dist/src/commands/_preflight.d.ts +22 -0
- package/dist/src/commands/_preflight.js +190 -128
- package/dist/src/commands/_probes.d.ts +1 -0
- package/dist/src/commands/_run-driver-helpers.d.ts +99 -0
- package/dist/src/commands/_run-driver-helpers.js +75 -22
- package/dist/src/commands/_run-replay.d.ts +24 -0
- package/dist/src/commands/_run-replay.js +142 -0
- package/dist/src/commands/_server-client.d.ts +186 -0
- package/dist/src/commands/_server-client.js +360 -61
- package/dist/src/commands/_snapshot-upload.d.ts +39 -0
- package/dist/src/commands/_snapshot-upload.js +163 -39
- package/dist/src/commands/_spinner.d.ts +25 -0
- package/dist/src/commands/_spinner.js +65 -0
- package/dist/src/commands/_task-picker.d.ts +9 -0
- package/dist/src/commands/_task-picker.js +172 -19
- package/dist/src/commands/agent.d.ts +3 -0
- package/dist/src/commands/agent.js +39 -20
- package/dist/src/commands/browser.d.ts +65 -0
- package/dist/src/commands/browser.js +334 -51
- package/dist/src/commands/connect.d.ts +7 -0
- package/dist/src/commands/connect.js +272 -33
- package/dist/src/commands/dist.d.ts +28 -0
- package/dist/src/commands/dist.js +19 -12
- package/dist/src/commands/doctor.d.ts +3 -0
- package/dist/src/commands/doctor.js +378 -45
- package/dist/src/commands/github.d.ts +3 -0
- package/dist/src/commands/github.js +375 -53
- package/dist/src/commands/inbox.d.ts +30 -0
- package/dist/src/commands/inbox.js +760 -70
- package/dist/src/commands/init.d.ts +74 -0
- package/dist/src/commands/init.js +963 -119
- package/dist/src/commands/inspect.d.ts +3 -0
- package/dist/src/commands/inspect.js +588 -32
- package/dist/src/commands/inspector.d.ts +3 -0
- package/dist/src/commands/inspector.js +20 -13
- package/dist/src/commands/pi.d.ts +3 -0
- package/dist/src/commands/pi.js +177 -0
- package/dist/src/commands/plugin.d.ts +16 -0
- package/dist/src/commands/plugin.js +95 -27
- package/dist/src/commands/profile-and-review.d.ts +4 -0
- package/dist/src/commands/profile-and-review.js +26 -19
- package/dist/src/commands/queue.d.ts +3 -0
- package/dist/src/commands/queue.js +32 -12
- package/dist/src/commands/remote.d.ts +3 -0
- package/dist/src/commands/remote.js +43 -36
- package/dist/src/commands/repo-git-harness.d.ts +5 -0
- package/dist/src/commands/repo-git-harness.js +22 -15
- package/dist/src/commands/run.d.ts +3 -0
- package/dist/src/commands/run.js +1379 -159
- package/dist/src/commands/server.d.ts +7 -0
- package/dist/src/commands/server.js +502 -57
- package/dist/src/commands/setup.d.ts +16 -0
- package/dist/src/commands/setup.js +390 -63
- package/dist/src/commands/stats.d.ts +12 -0
- package/dist/src/commands/stats.js +1051 -0
- package/dist/src/commands/task-report-bug.d.ts +19 -0
- package/dist/src/commands/task-report-bug.js +260 -62
- package/dist/src/commands/task-run-driver.d.ts +132 -0
- package/dist/src/commands/task-run-driver.js +886 -130
- package/dist/src/commands/task.d.ts +14 -0
- package/dist/src/commands/task.js +1644 -314
- package/dist/src/commands/test.d.ts +3 -0
- package/dist/src/commands/test.js +15 -8
- package/dist/src/commands/workspace.d.ts +3 -0
- package/dist/src/commands/workspace.js +18 -11
- package/dist/src/commands.d.ts +29 -0
- package/dist/src/commands.js +10967 -6637
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.js +10168 -5787
- package/dist/src/launcher.d.ts +61 -0
- package/dist/src/launcher.js +77 -13
- package/dist/src/report-bug.d.ts +44 -0
- package/dist/src/report-bug.js +3 -3
- package/dist/src/runner.d.ts +47 -0
- package/dist/src/runner.js +16 -22
- package/dist/src/withMutedConsole.d.ts +2 -0
- package/package.json +13 -6
|
@@ -0,0 +1,742 @@
|
|
|
1
|
+
// @bun
|
|
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
|
+
import { homedir } from "os";
|
|
35
|
+
import { dirname, resolve } from "path";
|
|
36
|
+
function resolveGlobalConnectionsPath(env = process.env) {
|
|
37
|
+
const explicit = env.RIG_CONNECTIONS_FILE?.trim();
|
|
38
|
+
if (explicit)
|
|
39
|
+
return resolve(explicit);
|
|
40
|
+
const stateDir = env.RIG_GLOBAL_STATE_DIR?.trim();
|
|
41
|
+
if (stateDir)
|
|
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
|
+
};
|
|
553
|
+
}
|
|
554
|
+
function buildOperatorPiEnv(input) {
|
|
555
|
+
return {
|
|
556
|
+
PI_CODING_AGENT_SESSION_DIR: input.sessionDir,
|
|
557
|
+
PI_SKIP_VERSION_CHECK: "1",
|
|
558
|
+
PI_HIDDEN_COMMANDS: "import,fork,clone,tree,new,resume,trust",
|
|
559
|
+
RIG_PI_OPERATOR_SESSION: "1",
|
|
560
|
+
RIG_RUN_ID: input.runId,
|
|
561
|
+
RIG_SERVER_URL: input.serverUrl,
|
|
562
|
+
...input.authToken ? { RIG_AUTH_TOKEN: input.authToken } : {},
|
|
563
|
+
...input.serverProjectRoot ? { RIG_PROJECT_ROOT: input.serverProjectRoot } : {}
|
|
564
|
+
};
|
|
565
|
+
}
|
|
566
|
+
async function prepareOperatorConsole(context, runId, tempSessionDir) {
|
|
567
|
+
const server = await ensureServerForCli(context.projectRoot);
|
|
568
|
+
const localCwd = join(homedir2(), ".rig", "drones", runId.slice(0, 8));
|
|
569
|
+
mkdirSync2(localCwd, { recursive: true });
|
|
570
|
+
trustDroneCwd(localCwd);
|
|
571
|
+
installRigPiTheme();
|
|
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 };
|
|
596
|
+
}
|
|
597
|
+
var RIG_PI_THEME = {
|
|
598
|
+
$schema: "https://raw.githubusercontent.com/earendil-works/pi/main/packages/coding-agent/src/modes/interactive/theme/theme-schema.json",
|
|
599
|
+
name: "rig",
|
|
600
|
+
vars: {
|
|
601
|
+
acid: "#ccff4d",
|
|
602
|
+
acidDim: "#a9d63f",
|
|
603
|
+
cyan: "#56d8ff",
|
|
604
|
+
red: "#ff5d5d",
|
|
605
|
+
yellow: "#ffd24d",
|
|
606
|
+
ink: "#f2f3f6",
|
|
607
|
+
ink2: "#aeb0ba",
|
|
608
|
+
ink3: "#6c6e79",
|
|
609
|
+
ink4: "#44464f",
|
|
610
|
+
panel: "#101115",
|
|
611
|
+
panelUser: "#14161b",
|
|
612
|
+
toolPending: "#0e1013",
|
|
613
|
+
toolSuccess: "#10150c",
|
|
614
|
+
toolError: "#1a0f0f",
|
|
615
|
+
customMsg: "#0f1410"
|
|
616
|
+
},
|
|
617
|
+
colors: {
|
|
618
|
+
accent: "acid",
|
|
619
|
+
border: "ink4",
|
|
620
|
+
borderAccent: "acid",
|
|
621
|
+
borderMuted: "ink4",
|
|
622
|
+
success: "acid",
|
|
623
|
+
error: "red",
|
|
624
|
+
warning: "yellow",
|
|
625
|
+
muted: "ink3",
|
|
626
|
+
dim: "ink4",
|
|
627
|
+
text: "ink",
|
|
628
|
+
thinkingText: "ink3",
|
|
629
|
+
selectedBg: "panel",
|
|
630
|
+
userMessageBg: "panelUser",
|
|
631
|
+
userMessageText: "ink",
|
|
632
|
+
customMessageBg: "customMsg",
|
|
633
|
+
customMessageText: "ink2",
|
|
634
|
+
customMessageLabel: "acidDim",
|
|
635
|
+
toolPendingBg: "toolPending",
|
|
636
|
+
toolSuccessBg: "toolSuccess",
|
|
637
|
+
toolErrorBg: "toolError",
|
|
638
|
+
toolTitle: "ink",
|
|
639
|
+
toolOutput: "ink3",
|
|
640
|
+
mdHeading: "acid",
|
|
641
|
+
mdLink: "cyan",
|
|
642
|
+
mdLinkUrl: "ink4",
|
|
643
|
+
mdCode: "acidDim",
|
|
644
|
+
mdCodeBlock: "ink2",
|
|
645
|
+
mdCodeBlockBorder: "ink4",
|
|
646
|
+
mdQuote: "ink3",
|
|
647
|
+
mdQuoteBorder: "ink4",
|
|
648
|
+
mdHr: "ink4",
|
|
649
|
+
mdListBullet: "acid",
|
|
650
|
+
toolDiffAdded: "acid",
|
|
651
|
+
toolDiffRemoved: "red",
|
|
652
|
+
toolDiffContext: "ink3",
|
|
653
|
+
syntaxComment: "ink3",
|
|
654
|
+
syntaxKeyword: "cyan",
|
|
655
|
+
syntaxFunction: "acid",
|
|
656
|
+
syntaxVariable: "ink",
|
|
657
|
+
syntaxString: "acidDim",
|
|
658
|
+
syntaxNumber: "yellow",
|
|
659
|
+
syntaxType: "cyan",
|
|
660
|
+
syntaxOperator: "ink2",
|
|
661
|
+
syntaxPunctuation: "ink3",
|
|
662
|
+
thinkingOff: "ink4",
|
|
663
|
+
thinkingMinimal: "ink3",
|
|
664
|
+
thinkingLow: "ink2",
|
|
665
|
+
thinkingMedium: "cyan",
|
|
666
|
+
thinkingHigh: "acidDim",
|
|
667
|
+
thinkingXhigh: "acid",
|
|
668
|
+
bashMode: "cyan"
|
|
669
|
+
}
|
|
670
|
+
};
|
|
671
|
+
function trustDroneCwd(localCwd) {
|
|
672
|
+
try {
|
|
673
|
+
const agentDir = join(homedir2(), ".pi", "agent");
|
|
674
|
+
mkdirSync2(agentDir, { recursive: true });
|
|
675
|
+
const trustPath = join(agentDir, "trust.json");
|
|
676
|
+
const store = existsSync3(trustPath) ? JSON.parse(readFileSync3(trustPath, "utf8")) : {};
|
|
677
|
+
if (store[localCwd] !== true) {
|
|
678
|
+
store[localCwd] = true;
|
|
679
|
+
writeFileSync2(trustPath, `${JSON.stringify(store, null, "\t")}
|
|
680
|
+
`);
|
|
681
|
+
}
|
|
682
|
+
} catch {}
|
|
683
|
+
}
|
|
684
|
+
function installRigPiTheme() {
|
|
685
|
+
try {
|
|
686
|
+
const themesDir = join(homedir2(), ".pi", "agent", "themes");
|
|
687
|
+
mkdirSync2(themesDir, { recursive: true });
|
|
688
|
+
const themePath = join(themesDir, "rig.json");
|
|
689
|
+
const next = `${JSON.stringify(RIG_PI_THEME, null, "\t")}
|
|
690
|
+
`;
|
|
691
|
+
if (!existsSync3(themePath) || readFileSync3(themePath, "utf8") !== next) {
|
|
692
|
+
writeFileSync2(themePath, next);
|
|
693
|
+
}
|
|
694
|
+
} catch {}
|
|
695
|
+
}
|
|
696
|
+
async function attachRunBundledPiFrontend(context, input) {
|
|
697
|
+
const tempSessionDir = mkdtempSync(join(tmpdir(), "rig-pi-frontend-sessions-"));
|
|
698
|
+
const { server, sessionFileArg } = await withSpinner(`Opening Pi console for run ${input.runId}\u2026`, () => prepareOperatorConsole(context, input.runId, tempSessionDir), { outputMode: context.outputMode });
|
|
699
|
+
const restoreEnv = setTemporaryEnv(buildOperatorPiEnv({
|
|
700
|
+
runId: input.runId,
|
|
701
|
+
serverUrl: server.baseUrl,
|
|
702
|
+
authToken: server.authToken,
|
|
703
|
+
serverProjectRoot: server.serverProjectRoot,
|
|
704
|
+
sessionDir: tempSessionDir
|
|
705
|
+
}));
|
|
706
|
+
const piRigExtensionFactory = (pi) => {
|
|
707
|
+
createPiRigExtension(pi);
|
|
708
|
+
};
|
|
709
|
+
let detached = false;
|
|
710
|
+
try {
|
|
711
|
+
await runPiMain([
|
|
712
|
+
"--no-extensions",
|
|
713
|
+
"--no-skills",
|
|
714
|
+
"--no-prompt-templates",
|
|
715
|
+
"--no-context-files",
|
|
716
|
+
...sessionFileArg
|
|
717
|
+
], {
|
|
718
|
+
extensionFactories: [piRigExtensionFactory]
|
|
719
|
+
});
|
|
720
|
+
detached = true;
|
|
721
|
+
} finally {
|
|
722
|
+
restoreEnv();
|
|
723
|
+
rmSync(tempSessionDir, { recursive: true, force: true });
|
|
724
|
+
}
|
|
725
|
+
let run = { runId: input.runId, status: "unknown" };
|
|
726
|
+
try {
|
|
727
|
+
run = await getRunDetailsViaServer(context, input.runId);
|
|
728
|
+
} catch {}
|
|
729
|
+
return {
|
|
730
|
+
run,
|
|
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
|
+
};
|
|
738
|
+
}
|
|
739
|
+
export {
|
|
740
|
+
buildOperatorPiEnv,
|
|
741
|
+
attachRunBundledPiFrontend
|
|
742
|
+
};
|