@h-rig/cli 0.0.6-alpha.90 → 0.0.6-alpha.91
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,681 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
// packages/cli/src/commands/_server-client.ts
|
|
3
|
-
import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
|
|
4
|
-
import { resolve as resolve2 } from "path";
|
|
5
|
-
|
|
6
|
-
// packages/cli/src/runner.ts
|
|
7
|
-
import { EventBus } from "@rig/runtime/control-plane/runtime/events";
|
|
8
|
-
import { CliError as RuntimeCliError } from "@rig/runtime/control-plane/errors";
|
|
9
|
-
import { evaluate, loadPolicy, resolveAction } from "@rig/runtime/control-plane/runtime/guard";
|
|
10
|
-
import { buildBinary } from "@rig/runtime/control-plane/runtime/isolation";
|
|
11
|
-
|
|
12
|
-
class CliError extends RuntimeCliError {
|
|
13
|
-
hint;
|
|
14
|
-
constructor(message, exitCode = 1, options = {}) {
|
|
15
|
-
super(message, exitCode);
|
|
16
|
-
if (options.hint?.trim()) {
|
|
17
|
-
this.hint = options.hint.trim();
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// packages/cli/src/commands/_server-client.ts
|
|
23
|
-
import { ensureLocalRigServerConnection } from "@rig/runtime/local-server";
|
|
24
|
-
|
|
25
|
-
// packages/cli/src/commands/_connection-state.ts
|
|
26
|
-
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
27
|
-
import { homedir } from "os";
|
|
28
|
-
import { dirname, resolve } from "path";
|
|
29
|
-
function resolveGlobalConnectionsPath(env = process.env) {
|
|
30
|
-
const explicit = env.RIG_CONNECTIONS_FILE?.trim();
|
|
31
|
-
if (explicit)
|
|
32
|
-
return resolve(explicit);
|
|
33
|
-
const stateDir = env.RIG_GLOBAL_STATE_DIR?.trim();
|
|
34
|
-
if (stateDir)
|
|
35
|
-
return resolve(stateDir, "connections.json");
|
|
36
|
-
return resolve(homedir(), ".rig", "connections.json");
|
|
37
|
-
}
|
|
38
|
-
function resolveRepoConnectionPath(projectRoot) {
|
|
39
|
-
return resolve(projectRoot, ".rig", "state", "connection.json");
|
|
40
|
-
}
|
|
41
|
-
function readJsonFile(path) {
|
|
42
|
-
if (!existsSync(path))
|
|
43
|
-
return null;
|
|
44
|
-
try {
|
|
45
|
-
return JSON.parse(readFileSync(path, "utf8"));
|
|
46
|
-
} catch (error) {
|
|
47
|
-
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>`." });
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
function writeJsonFile(path, value) {
|
|
51
|
-
mkdirSync(dirname(path), { recursive: true });
|
|
52
|
-
writeFileSync(path, `${JSON.stringify(value, null, 2)}
|
|
53
|
-
`, "utf8");
|
|
54
|
-
}
|
|
55
|
-
function normalizeConnection(value) {
|
|
56
|
-
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
57
|
-
return null;
|
|
58
|
-
const record = value;
|
|
59
|
-
if (record.kind === "local")
|
|
60
|
-
return { kind: "local", mode: "auto" };
|
|
61
|
-
if (record.kind === "remote" && typeof record.baseUrl === "string" && record.baseUrl.trim()) {
|
|
62
|
-
const baseUrl = record.baseUrl.trim().replace(/\/+$/, "");
|
|
63
|
-
return { kind: "remote", baseUrl };
|
|
64
|
-
}
|
|
65
|
-
return null;
|
|
66
|
-
}
|
|
67
|
-
function readGlobalConnections(options = {}) {
|
|
68
|
-
const path = resolveGlobalConnectionsPath(options.env ?? process.env);
|
|
69
|
-
const payload = readJsonFile(path);
|
|
70
|
-
if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
|
|
71
|
-
return { connections: {} };
|
|
72
|
-
}
|
|
73
|
-
const rawConnections = payload.connections;
|
|
74
|
-
const connections = {};
|
|
75
|
-
if (rawConnections && typeof rawConnections === "object" && !Array.isArray(rawConnections)) {
|
|
76
|
-
for (const [alias, raw] of Object.entries(rawConnections)) {
|
|
77
|
-
const connection = normalizeConnection(raw);
|
|
78
|
-
if (connection)
|
|
79
|
-
connections[alias] = connection;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
return { connections };
|
|
83
|
-
}
|
|
84
|
-
function readRepoConnection(projectRoot) {
|
|
85
|
-
const payload = readJsonFile(resolveRepoConnectionPath(projectRoot));
|
|
86
|
-
if (!payload || typeof payload !== "object" || Array.isArray(payload))
|
|
87
|
-
return null;
|
|
88
|
-
const record = payload;
|
|
89
|
-
const selected = typeof record.selected === "string" ? record.selected.trim() : "";
|
|
90
|
-
if (!selected)
|
|
91
|
-
return null;
|
|
92
|
-
return {
|
|
93
|
-
selected,
|
|
94
|
-
project: typeof record.project === "string" ? record.project : undefined,
|
|
95
|
-
linkedAt: typeof record.linkedAt === "string" ? record.linkedAt : undefined,
|
|
96
|
-
serverProjectRoot: typeof record.serverProjectRoot === "string" && record.serverProjectRoot.trim() ? record.serverProjectRoot.trim() : undefined
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
function writeRepoConnection(projectRoot, state) {
|
|
100
|
-
writeJsonFile(resolveRepoConnectionPath(projectRoot), state);
|
|
101
|
-
}
|
|
102
|
-
function resolveSelectedConnection(projectRoot, options = {}) {
|
|
103
|
-
const repo = readRepoConnection(projectRoot);
|
|
104
|
-
if (!repo)
|
|
105
|
-
return null;
|
|
106
|
-
if (repo.selected === "local")
|
|
107
|
-
return { alias: "local", connection: { kind: "local", mode: "auto" }, serverProjectRoot: repo.serverProjectRoot };
|
|
108
|
-
const global = readGlobalConnections(options);
|
|
109
|
-
const connection = global.connections[repo.selected];
|
|
110
|
-
if (!connection) {
|
|
111
|
-
throw new CliError(`Selected Rig server "${repo.selected}" was not found. Run \`rig server list\` or \`rig server use local\`.`, 1);
|
|
112
|
-
}
|
|
113
|
-
return { alias: repo.selected, connection, serverProjectRoot: repo.serverProjectRoot };
|
|
114
|
-
}
|
|
115
|
-
function writeRepoServerProjectRoot(projectRoot, serverProjectRoot) {
|
|
116
|
-
const repo = readRepoConnection(projectRoot);
|
|
117
|
-
if (!repo)
|
|
118
|
-
return;
|
|
119
|
-
writeRepoConnection(projectRoot, { ...repo, serverProjectRoot });
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// packages/cli/src/commands/_server-client.ts
|
|
123
|
-
var scopedGitHubBearerTokens = new Map;
|
|
124
|
-
var serverPhaseListener = null;
|
|
125
|
-
function setServerPhaseListener(listener) {
|
|
126
|
-
const previous = serverPhaseListener;
|
|
127
|
-
serverPhaseListener = listener;
|
|
128
|
-
return previous;
|
|
129
|
-
}
|
|
130
|
-
function reportServerPhase(label) {
|
|
131
|
-
serverPhaseListener?.(label);
|
|
132
|
-
}
|
|
133
|
-
function cleanToken(value) {
|
|
134
|
-
const trimmed = value?.trim();
|
|
135
|
-
return trimmed ? trimmed : null;
|
|
136
|
-
}
|
|
137
|
-
function setGitHubBearerTokenForCurrentProcess(token, projectRoot) {
|
|
138
|
-
const scopedKey = resolve2(projectRoot ?? process.cwd());
|
|
139
|
-
scopedGitHubBearerTokens.set(scopedKey, cleanToken(token ?? undefined));
|
|
140
|
-
}
|
|
141
|
-
function readPrivateRemoteSessionToken(projectRoot) {
|
|
142
|
-
const path = resolve2(projectRoot, ".rig", "state", "github-auth.json");
|
|
143
|
-
if (!existsSync2(path))
|
|
144
|
-
return null;
|
|
145
|
-
try {
|
|
146
|
-
const parsed = JSON.parse(readFileSync2(path, "utf8"));
|
|
147
|
-
return cleanToken(typeof parsed.apiSessionToken === "string" ? parsed.apiSessionToken : typeof parsed.sessionToken === "string" ? parsed.sessionToken : undefined);
|
|
148
|
-
} catch {
|
|
149
|
-
return null;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
function readGitHubBearerTokenForRemote(projectRoot) {
|
|
153
|
-
const scopedKey = resolve2(projectRoot);
|
|
154
|
-
if (scopedGitHubBearerTokens.has(scopedKey))
|
|
155
|
-
return scopedGitHubBearerTokens.get(scopedKey) ?? null;
|
|
156
|
-
const privateSession = readPrivateRemoteSessionToken(projectRoot);
|
|
157
|
-
if (privateSession)
|
|
158
|
-
return privateSession;
|
|
159
|
-
return cleanToken(process.env.RIG_SERVER_AUTH_TOKEN) ?? cleanToken(process.env.RIG_REMOTE_AUTH_TOKEN);
|
|
160
|
-
}
|
|
161
|
-
function readStoredGitHubAuthToken(projectRoot) {
|
|
162
|
-
const path = resolve2(projectRoot, ".rig", "state", "github-auth.json");
|
|
163
|
-
if (!existsSync2(path))
|
|
164
|
-
return null;
|
|
165
|
-
try {
|
|
166
|
-
const parsed = JSON.parse(readFileSync2(path, "utf8"));
|
|
167
|
-
return cleanToken(typeof parsed.token === "string" ? parsed.token : undefined);
|
|
168
|
-
} catch {
|
|
169
|
-
return null;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
function readLocalConnectionFallbackToken(projectRoot) {
|
|
173
|
-
return readGitHubBearerTokenForRemote(projectRoot) ?? cleanToken(process.env.RIG_GITHUB_TOKEN) ?? readStoredGitHubAuthToken(projectRoot);
|
|
174
|
-
}
|
|
175
|
-
async function ensureServerForCli(projectRoot) {
|
|
176
|
-
try {
|
|
177
|
-
const selected = resolveSelectedConnection(projectRoot);
|
|
178
|
-
if (selected?.connection.kind === "remote") {
|
|
179
|
-
reportServerPhase(`Connecting to ${selected.alias}\u2026`);
|
|
180
|
-
const authToken = readGitHubBearerTokenForRemote(projectRoot);
|
|
181
|
-
const serverProjectRoot = selected.serverProjectRoot ?? await backfillRemoteServerProjectRoot(projectRoot, selected.connection.baseUrl, authToken);
|
|
182
|
-
return {
|
|
183
|
-
baseUrl: selected.connection.baseUrl,
|
|
184
|
-
authToken,
|
|
185
|
-
connectionKind: "remote",
|
|
186
|
-
serverProjectRoot
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
reportServerPhase("Starting local Rig server\u2026");
|
|
190
|
-
const connection = await ensureLocalRigServerConnection(projectRoot);
|
|
191
|
-
return {
|
|
192
|
-
baseUrl: connection.baseUrl,
|
|
193
|
-
authToken: connection.authToken ?? readLocalConnectionFallbackToken(projectRoot),
|
|
194
|
-
connectionKind: "local",
|
|
195
|
-
serverProjectRoot: resolve2(projectRoot)
|
|
196
|
-
};
|
|
197
|
-
} catch (error) {
|
|
198
|
-
if (error instanceof Error) {
|
|
199
|
-
throw new CliError(error.message, 1);
|
|
200
|
-
}
|
|
201
|
-
throw error;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
async function backfillRemoteServerProjectRoot(projectRoot, baseUrl, authToken) {
|
|
205
|
-
const repo = readRepoConnection(projectRoot);
|
|
206
|
-
const slug = repo?.project?.trim();
|
|
207
|
-
if (!slug)
|
|
208
|
-
return null;
|
|
209
|
-
try {
|
|
210
|
-
const response = await fetch(`${baseUrl}/api/projects/${encodeURIComponent(slug)}`, {
|
|
211
|
-
headers: mergeHeaders(undefined, authToken)
|
|
212
|
-
});
|
|
213
|
-
if (!response.ok)
|
|
214
|
-
return null;
|
|
215
|
-
const payload = await response.json();
|
|
216
|
-
const project = payload.project && typeof payload.project === "object" && !Array.isArray(payload.project) ? payload.project : null;
|
|
217
|
-
const checkouts = Array.isArray(project?.checkouts) ? project.checkouts : [];
|
|
218
|
-
const latestCheckout = [...checkouts].reverse().find((entry) => Boolean(entry && typeof entry === "object" && !Array.isArray(entry) && typeof entry.path === "string"));
|
|
219
|
-
const path = typeof latestCheckout?.path === "string" && latestCheckout.path.trim() ? latestCheckout.path.trim() : null;
|
|
220
|
-
if (path)
|
|
221
|
-
writeRepoServerProjectRoot(projectRoot, path);
|
|
222
|
-
return path;
|
|
223
|
-
} catch {
|
|
224
|
-
return null;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
function appendTaskFilterParams(url, filters) {
|
|
228
|
-
if (filters.assignee)
|
|
229
|
-
url.searchParams.set("assignee", filters.assignee);
|
|
230
|
-
if (filters.state)
|
|
231
|
-
url.searchParams.set("state", filters.state);
|
|
232
|
-
if (filters.status)
|
|
233
|
-
url.searchParams.set("status", filters.status);
|
|
234
|
-
if (filters.limit !== undefined)
|
|
235
|
-
url.searchParams.set("limit", String(filters.limit));
|
|
236
|
-
}
|
|
237
|
-
function mergeHeaders(headers, authToken) {
|
|
238
|
-
const merged = new Headers(headers);
|
|
239
|
-
if (authToken) {
|
|
240
|
-
merged.set("authorization", `Bearer ${authToken}`);
|
|
241
|
-
}
|
|
242
|
-
return merged;
|
|
243
|
-
}
|
|
244
|
-
function diagnosticMessage(payload) {
|
|
245
|
-
if (!payload || typeof payload !== "object" || Array.isArray(payload))
|
|
246
|
-
return null;
|
|
247
|
-
const record = payload;
|
|
248
|
-
const diagnostics = Array.isArray(record.diagnostics) ? record.diagnostics : [];
|
|
249
|
-
const messages = diagnostics.flatMap((entry) => {
|
|
250
|
-
if (!entry || typeof entry !== "object" || Array.isArray(entry))
|
|
251
|
-
return [];
|
|
252
|
-
const diagnostic = entry;
|
|
253
|
-
const kind = typeof diagnostic.kind === "string" ? diagnostic.kind : "task-source";
|
|
254
|
-
const message = typeof diagnostic.message === "string" ? diagnostic.message : null;
|
|
255
|
-
return message ? [`${kind}: ${message}`] : [];
|
|
256
|
-
});
|
|
257
|
-
return messages.length > 0 ? messages.join("; ") : null;
|
|
258
|
-
}
|
|
259
|
-
var serverReachabilityCache = new Map;
|
|
260
|
-
async function probeServerReachability(baseUrl, authToken) {
|
|
261
|
-
try {
|
|
262
|
-
const response = await fetch(`${baseUrl.replace(/\/+$/, "")}/api/server/status`, {
|
|
263
|
-
headers: mergeHeaders(undefined, authToken),
|
|
264
|
-
signal: AbortSignal.timeout(1500)
|
|
265
|
-
});
|
|
266
|
-
return response.ok;
|
|
267
|
-
} catch {
|
|
268
|
-
return false;
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
function cachedServerReachability(projectRoot, baseUrl, authToken) {
|
|
272
|
-
const key = resolve2(projectRoot);
|
|
273
|
-
const cached = serverReachabilityCache.get(key);
|
|
274
|
-
if (cached)
|
|
275
|
-
return cached;
|
|
276
|
-
const probe = probeServerReachability(baseUrl, authToken);
|
|
277
|
-
serverReachabilityCache.set(key, probe);
|
|
278
|
-
return probe;
|
|
279
|
-
}
|
|
280
|
-
function describeSelectedServer(projectRoot, server) {
|
|
281
|
-
try {
|
|
282
|
-
const selected = resolveSelectedConnection(projectRoot);
|
|
283
|
-
if (selected) {
|
|
284
|
-
return {
|
|
285
|
-
alias: selected.alias,
|
|
286
|
-
target: selected.connection.kind === "remote" ? selected.connection.baseUrl : server.baseUrl
|
|
287
|
-
};
|
|
288
|
-
}
|
|
289
|
-
} catch {}
|
|
290
|
-
return { alias: server.connectionKind === "remote" ? "remote" : "local", target: server.baseUrl };
|
|
291
|
-
}
|
|
292
|
-
async function buildServerFailureContext(projectRoot, server) {
|
|
293
|
-
const { alias, target } = describeSelectedServer(projectRoot, server);
|
|
294
|
-
const reachable = await cachedServerReachability(projectRoot, server.baseUrl, server.authToken);
|
|
295
|
-
const reachability = reachable ? "server is reachable" : "server is unreachable";
|
|
296
|
-
return {
|
|
297
|
-
contextLine: `Currently connected to: ${alias} at ${target} (${reachability}).`,
|
|
298
|
-
hint: "Check the selected server with `rig server status`, or switch with `rig server use <alias|local>`."
|
|
299
|
-
};
|
|
300
|
-
}
|
|
301
|
-
async function requestServerJson(context, pathname, init = {}) {
|
|
302
|
-
const server = await ensureServerForCli(context.projectRoot);
|
|
303
|
-
const headers = mergeHeaders(init.headers, server.authToken);
|
|
304
|
-
if (server.serverProjectRoot)
|
|
305
|
-
headers.set("x-rig-project-root", server.serverProjectRoot);
|
|
306
|
-
reportServerPhase(`${(init.method ?? "GET").toUpperCase()} ${pathname.split("?")[0]}\u2026`);
|
|
307
|
-
let response;
|
|
308
|
-
try {
|
|
309
|
-
response = await fetch(`${server.baseUrl}${pathname}`, {
|
|
310
|
-
...init,
|
|
311
|
-
headers
|
|
312
|
-
});
|
|
313
|
-
} catch (error) {
|
|
314
|
-
const failure = await buildServerFailureContext(context.projectRoot, server);
|
|
315
|
-
throw new CliError(`Rig server request failed: ${error instanceof Error ? error.message : String(error)}
|
|
316
|
-
${failure.contextLine}`, 1, { hint: failure.hint });
|
|
317
|
-
}
|
|
318
|
-
const text = await response.text();
|
|
319
|
-
const payload = text.trim().length > 0 ? (() => {
|
|
320
|
-
try {
|
|
321
|
-
return JSON.parse(text);
|
|
322
|
-
} catch {
|
|
323
|
-
return null;
|
|
324
|
-
}
|
|
325
|
-
})() : null;
|
|
326
|
-
if (!response.ok) {
|
|
327
|
-
const diagnostics = diagnosticMessage(payload);
|
|
328
|
-
const rawDetail = diagnostics ?? (text || response.statusText);
|
|
329
|
-
const detail = diagnostics ? rawDetail : rawDetail.split(`
|
|
330
|
-
`).map((line) => line.trim()).find((line) => line.length > 0)?.slice(0, 200) ?? response.statusText;
|
|
331
|
-
const failure = await buildServerFailureContext(context.projectRoot, server);
|
|
332
|
-
throw new CliError(`Rig server request failed (${response.status}): ${detail}
|
|
333
|
-
${failure.contextLine}`, 1, { hint: failure.hint });
|
|
334
|
-
}
|
|
335
|
-
return payload;
|
|
336
|
-
}
|
|
337
|
-
async function listWorkspaceTasksViaServer(context, filters = {}) {
|
|
338
|
-
const url = new URL("http://rig.local/api/workspace/tasks");
|
|
339
|
-
appendTaskFilterParams(url, filters);
|
|
340
|
-
const payload = await requestServerJson(context, `${url.pathname}${url.search}`);
|
|
341
|
-
if (!Array.isArray(payload)) {
|
|
342
|
-
throw new CliError("Rig server returned an invalid task list payload.", 1, { hint: "Check the selected server with `rig server status`; mixed CLI/server versions can mismatch \u2014 try `rig doctor`." });
|
|
343
|
-
}
|
|
344
|
-
return payload.flatMap((entry) => entry && typeof entry === "object" && !Array.isArray(entry) ? [entry] : []);
|
|
345
|
-
}
|
|
346
|
-
async function getWorkspaceTaskViaServer(context, taskId) {
|
|
347
|
-
const payload = await requestServerJson(context, `/api/workspace/tasks/${encodeURIComponent(taskId)}`);
|
|
348
|
-
if (!payload || typeof payload !== "object" || Array.isArray(payload))
|
|
349
|
-
return null;
|
|
350
|
-
const task = payload.task;
|
|
351
|
-
return task && typeof task === "object" && !Array.isArray(task) ? task : null;
|
|
352
|
-
}
|
|
353
|
-
async function selectNextWorkspaceTaskViaServer(context, filters = {}) {
|
|
354
|
-
const url = new URL("http://rig.local/api/workspace/tasks/next");
|
|
355
|
-
appendTaskFilterParams(url, filters);
|
|
356
|
-
const payload = await requestServerJson(context, `${url.pathname}${url.search}`);
|
|
357
|
-
if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
|
|
358
|
-
throw new CliError("Rig server returned an invalid next-task payload.", 1, { hint: "Check the selected server with `rig server status`; try `rig task list` to see the raw task set." });
|
|
359
|
-
}
|
|
360
|
-
const record = payload;
|
|
361
|
-
const rawTask = record.task;
|
|
362
|
-
const task = rawTask && typeof rawTask === "object" && !Array.isArray(rawTask) ? rawTask : null;
|
|
363
|
-
const count = typeof record.count === "number" && Number.isFinite(record.count) ? record.count : task ? 1 : 0;
|
|
364
|
-
return { task, count };
|
|
365
|
-
}
|
|
366
|
-
async function getGitHubAuthStatusViaServer(context) {
|
|
367
|
-
const payload = await requestServerJson(context, "/api/github/auth/status");
|
|
368
|
-
return payload && typeof payload === "object" && !Array.isArray(payload) ? payload : {};
|
|
369
|
-
}
|
|
370
|
-
async function postGitHubTokenViaServer(context, token, options = {}) {
|
|
371
|
-
const payload = await requestServerJson(context, "/api/github/auth/token", {
|
|
372
|
-
method: "POST",
|
|
373
|
-
headers: { "content-type": "application/json" },
|
|
374
|
-
body: JSON.stringify({ token, selectedRepo: options.selectedRepo, projectRoot: options.projectRoot })
|
|
375
|
-
});
|
|
376
|
-
return payload && typeof payload === "object" && !Array.isArray(payload) ? payload : {};
|
|
377
|
-
}
|
|
378
|
-
async function prepareRemoteCheckoutViaServer(context, input) {
|
|
379
|
-
const payload = await requestServerJson(context, `/api/projects/${encodeURIComponent(input.repoSlug)}/prepare-checkout`, {
|
|
380
|
-
method: "POST",
|
|
381
|
-
headers: { "content-type": "application/json" },
|
|
382
|
-
body: JSON.stringify({ checkout: input.checkout, repoUrl: input.repoUrl, baseDir: input.baseDir })
|
|
383
|
-
});
|
|
384
|
-
return payload && typeof payload === "object" && !Array.isArray(payload) ? payload : {};
|
|
385
|
-
}
|
|
386
|
-
async function registerProjectViaServer(context, input) {
|
|
387
|
-
const payload = await requestServerJson(context, "/api/projects", {
|
|
388
|
-
method: "POST",
|
|
389
|
-
headers: { "content-type": "application/json" },
|
|
390
|
-
body: JSON.stringify(input)
|
|
391
|
-
});
|
|
392
|
-
return payload && typeof payload === "object" && !Array.isArray(payload) ? payload : {};
|
|
393
|
-
}
|
|
394
|
-
function sleep(ms) {
|
|
395
|
-
return new Promise((resolve3) => setTimeout(resolve3, ms));
|
|
396
|
-
}
|
|
397
|
-
function isRetryableProjectRootSwitchError(error) {
|
|
398
|
-
if (!(error instanceof Error))
|
|
399
|
-
return false;
|
|
400
|
-
const message = error.message.toLowerCase();
|
|
401
|
-
return message.includes("rig server request failed (401): auth-required") || message.includes("rig server request failed (401): github-token-required") || message.includes("rig server request failed (502)") || message.includes("rig server request failed (503)") || message.includes("bad gateway") || message.includes("fetch failed") || message.includes("econnrefused") || message.includes("connection refused");
|
|
402
|
-
}
|
|
403
|
-
async function switchServerProjectRootViaServer(context, projectRoot, options = {}) {
|
|
404
|
-
const timeoutMs = options.timeoutMs ?? 30000;
|
|
405
|
-
const pollMs = options.pollMs ?? 1000;
|
|
406
|
-
const deadline = Date.now() + timeoutMs;
|
|
407
|
-
let lastError;
|
|
408
|
-
let switched = null;
|
|
409
|
-
while (Date.now() < deadline) {
|
|
410
|
-
try {
|
|
411
|
-
switched = await requestServerJson(context, "/api/server/project-root", {
|
|
412
|
-
method: "POST",
|
|
413
|
-
headers: { "content-type": "application/json" },
|
|
414
|
-
body: JSON.stringify({ projectRoot })
|
|
415
|
-
});
|
|
416
|
-
break;
|
|
417
|
-
} catch (error) {
|
|
418
|
-
lastError = error;
|
|
419
|
-
if (!isRetryableProjectRootSwitchError(error))
|
|
420
|
-
throw error;
|
|
421
|
-
await sleep(pollMs);
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
if (!switched) {
|
|
425
|
-
throw new CliError(`Rig server did not accept project-root switch to ${projectRoot} before timeout (${lastError instanceof Error ? lastError.message : String(lastError ?? "no response")}).`, 1);
|
|
426
|
-
}
|
|
427
|
-
const record = switched && typeof switched === "object" && !Array.isArray(switched) ? switched : {};
|
|
428
|
-
if (record.ok === true) {
|
|
429
|
-
writeRepoServerProjectRoot(context.projectRoot, projectRoot);
|
|
430
|
-
return { ok: true, switched: record };
|
|
431
|
-
}
|
|
432
|
-
throw new CliError(`Rig server rejected project-root scope ${projectRoot}: ${String(record.message ?? record.error ?? "unknown error")}`, 1);
|
|
433
|
-
}
|
|
434
|
-
async function listRunsViaServer(context, options = {}) {
|
|
435
|
-
const url = new URL("http://rig.local/api/runs");
|
|
436
|
-
if (options.limit !== undefined)
|
|
437
|
-
url.searchParams.set("limit", String(options.limit));
|
|
438
|
-
const payload = await requestServerJson(context, `${url.pathname}${url.search}`);
|
|
439
|
-
const runs = Array.isArray(payload) ? payload : payload && typeof payload === "object" && !Array.isArray(payload) && Array.isArray(payload.runs) ? payload.runs : [];
|
|
440
|
-
return runs.filter((entry) => Boolean(entry && typeof entry === "object" && !Array.isArray(entry)));
|
|
441
|
-
}
|
|
442
|
-
async function getRunDetailsViaServer(context, runId) {
|
|
443
|
-
const payload = await requestServerJson(context, `/api/runs/${encodeURIComponent(runId)}`);
|
|
444
|
-
return payload && typeof payload === "object" && !Array.isArray(payload) ? payload : {};
|
|
445
|
-
}
|
|
446
|
-
async function getRunLogsViaServer(context, runId, options = {}) {
|
|
447
|
-
const url = new URL(`http://rig.local/api/runs/${encodeURIComponent(runId)}/logs`);
|
|
448
|
-
if (options.limit !== undefined)
|
|
449
|
-
url.searchParams.set("limit", String(options.limit));
|
|
450
|
-
if (options.cursor)
|
|
451
|
-
url.searchParams.set("cursor", options.cursor);
|
|
452
|
-
const payload = await requestServerJson(context, `${url.pathname}${url.search}`);
|
|
453
|
-
return payload && typeof payload === "object" && !Array.isArray(payload) ? payload : { entries: [] };
|
|
454
|
-
}
|
|
455
|
-
async function getRunTimelineViaServer(context, runId, options = {}) {
|
|
456
|
-
const url = new URL(`http://rig.local/api/runs/${encodeURIComponent(runId)}/timeline`);
|
|
457
|
-
if (options.limit !== undefined)
|
|
458
|
-
url.searchParams.set("limit", String(options.limit));
|
|
459
|
-
if (options.cursor)
|
|
460
|
-
url.searchParams.set("cursor", options.cursor);
|
|
461
|
-
const payload = await requestServerJson(context, `${url.pathname}${url.search}`);
|
|
462
|
-
return payload && typeof payload === "object" && !Array.isArray(payload) ? payload : { entries: [] };
|
|
463
|
-
}
|
|
464
|
-
async function ensureTaskLabelsViaServer(context) {
|
|
465
|
-
const payload = await requestServerJson(context, "/api/workspace/task-labels", { method: "POST" });
|
|
466
|
-
return payload && typeof payload === "object" && !Array.isArray(payload) ? payload : {};
|
|
467
|
-
}
|
|
468
|
-
async function listGitHubProjectsViaServer(context, owner) {
|
|
469
|
-
const url = new URL("http://rig.local/api/github/projects");
|
|
470
|
-
url.searchParams.set("owner", owner);
|
|
471
|
-
const payload = await requestServerJson(context, `${url.pathname}${url.search}`);
|
|
472
|
-
return payload && typeof payload === "object" && !Array.isArray(payload) ? payload : { projects: [] };
|
|
473
|
-
}
|
|
474
|
-
async function getGitHubProjectStatusFieldViaServer(context, projectId) {
|
|
475
|
-
const payload = await requestServerJson(context, `/api/github/projects/${encodeURIComponent(projectId)}/status-field`);
|
|
476
|
-
return payload && typeof payload === "object" && !Array.isArray(payload) ? payload : {};
|
|
477
|
-
}
|
|
478
|
-
async function updateWorkspaceTaskViaServer(context, input) {
|
|
479
|
-
const payload = await requestServerJson(context, "/api/tasks/update", {
|
|
480
|
-
method: "POST",
|
|
481
|
-
headers: { "content-type": "application/json" },
|
|
482
|
-
body: JSON.stringify(input)
|
|
483
|
-
});
|
|
484
|
-
return payload && typeof payload === "object" && !Array.isArray(payload) ? payload : { ok: true };
|
|
485
|
-
}
|
|
486
|
-
var RESUMABLE_RUN_STATUSES = new Set([
|
|
487
|
-
"created",
|
|
488
|
-
"preparing",
|
|
489
|
-
"running",
|
|
490
|
-
"validating",
|
|
491
|
-
"reviewing",
|
|
492
|
-
"stopped",
|
|
493
|
-
"failed",
|
|
494
|
-
"needs-attention",
|
|
495
|
-
"needs_attention"
|
|
496
|
-
]);
|
|
497
|
-
async function resumeRunViaServer(context, runId, options) {
|
|
498
|
-
let targetRunId = runId?.trim() || null;
|
|
499
|
-
if (!targetRunId) {
|
|
500
|
-
const candidates = (await listRunsViaServer(context)).filter((run) => RESUMABLE_RUN_STATUSES.has(String(run.status ?? ""))).sort((left, right) => String(right.updatedAt ?? "").localeCompare(String(left.updatedAt ?? "")));
|
|
501
|
-
targetRunId = typeof candidates[0]?.runId === "string" ? candidates[0].runId : null;
|
|
502
|
-
}
|
|
503
|
-
if (!targetRunId) {
|
|
504
|
-
throw new CliError(options.restart ? "No run is available to restart." : "No resumable run is available.", 2, { hint: "List runs with `rig run list`, then pass an explicit id: `rig run resume <run-id>`." });
|
|
505
|
-
}
|
|
506
|
-
const payload = await requestServerJson(context, "/api/runs/resume", {
|
|
507
|
-
method: "POST",
|
|
508
|
-
headers: { "content-type": "application/json" },
|
|
509
|
-
body: JSON.stringify({ runId: targetRunId, createdAt: new Date().toISOString(), restart: options.restart })
|
|
510
|
-
});
|
|
511
|
-
const record = payload && typeof payload === "object" && !Array.isArray(payload) ? payload : {};
|
|
512
|
-
if (record.ok === false) {
|
|
513
|
-
const message = typeof record.error === "string" && record.error.trim() ? record.error : "run resume failed";
|
|
514
|
-
throw new CliError(`${options.restart ? "restart" : "resume"} failed for ${targetRunId}: ${message}`, 1);
|
|
515
|
-
}
|
|
516
|
-
return { ok: true, runId: targetRunId, ...record };
|
|
517
|
-
}
|
|
518
|
-
async function resolveServerConnectionLabel(projectRoot) {
|
|
519
|
-
try {
|
|
520
|
-
const selected = resolveSelectedConnection(projectRoot);
|
|
521
|
-
if (!selected)
|
|
522
|
-
return "no server selected";
|
|
523
|
-
if (selected.connection.kind === "remote") {
|
|
524
|
-
return selected.connection.baseUrl.replace(/^https?:\/\//, "");
|
|
525
|
-
}
|
|
526
|
-
return `local (${selected.alias})`;
|
|
527
|
-
} catch {
|
|
528
|
-
return "no server selected";
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
async function stopRunViaServer(context, runId) {
|
|
532
|
-
const payload = await requestServerJson(context, "/api/runs/stop", {
|
|
533
|
-
method: "POST",
|
|
534
|
-
headers: { "content-type": "application/json" },
|
|
535
|
-
body: JSON.stringify({ runId })
|
|
536
|
-
});
|
|
537
|
-
return payload && typeof payload === "object" && !Array.isArray(payload) ? payload : { ok: true, runId };
|
|
538
|
-
}
|
|
539
|
-
async function steerRunViaServer(context, runId, message) {
|
|
540
|
-
const payload = await requestServerJson(context, `/api/runs/${encodeURIComponent(runId)}/steer`, {
|
|
541
|
-
method: "POST",
|
|
542
|
-
headers: { "content-type": "application/json" },
|
|
543
|
-
body: JSON.stringify({ message })
|
|
544
|
-
});
|
|
545
|
-
return payload && typeof payload === "object" && !Array.isArray(payload) ? payload : { ok: true };
|
|
546
|
-
}
|
|
547
|
-
async function getRunPiSessionViaServer(context, runId) {
|
|
548
|
-
const payload = await requestServerJson(context, `/api/runs/${encodeURIComponent(runId)}/pi`);
|
|
549
|
-
return payload && typeof payload === "object" && !Array.isArray(payload) ? payload : {};
|
|
550
|
-
}
|
|
551
|
-
async function getRunPiMessagesViaServer(context, runId) {
|
|
552
|
-
const payload = await requestServerJson(context, `/api/runs/${encodeURIComponent(runId)}/pi/messages`);
|
|
553
|
-
return payload && typeof payload === "object" && !Array.isArray(payload) ? payload : { messages: [] };
|
|
554
|
-
}
|
|
555
|
-
async function getRunPiStatusViaServer(context, runId) {
|
|
556
|
-
const payload = await requestServerJson(context, `/api/runs/${encodeURIComponent(runId)}/pi/status`);
|
|
557
|
-
return payload && typeof payload === "object" && !Array.isArray(payload) ? payload : {};
|
|
558
|
-
}
|
|
559
|
-
async function getRunPiCommandsViaServer(context, runId) {
|
|
560
|
-
const payload = await requestServerJson(context, `/api/runs/${encodeURIComponent(runId)}/pi/commands`);
|
|
561
|
-
return payload && typeof payload === "object" && !Array.isArray(payload) ? payload : { commands: [] };
|
|
562
|
-
}
|
|
563
|
-
async function getRunPiCapabilitiesViaServer(context, runId) {
|
|
564
|
-
const payload = await requestServerJson(context, `/api/runs/${encodeURIComponent(runId)}/pi/capabilities`);
|
|
565
|
-
return payload && typeof payload === "object" && !Array.isArray(payload) ? payload : { capabilities: null };
|
|
566
|
-
}
|
|
567
|
-
async function sendRunPiPromptViaServer(context, runId, text, streamingBehavior) {
|
|
568
|
-
const payload = await requestServerJson(context, `/api/runs/${encodeURIComponent(runId)}/pi/prompt`, {
|
|
569
|
-
method: "POST",
|
|
570
|
-
headers: { "content-type": "application/json" },
|
|
571
|
-
body: JSON.stringify({ text, streamingBehavior })
|
|
572
|
-
});
|
|
573
|
-
return payload && typeof payload === "object" && !Array.isArray(payload) ? payload : { accepted: true };
|
|
574
|
-
}
|
|
575
|
-
async function sendRunPiShellViaServer(context, runId, text) {
|
|
576
|
-
const payload = await requestServerJson(context, `/api/runs/${encodeURIComponent(runId)}/pi/shell`, {
|
|
577
|
-
method: "POST",
|
|
578
|
-
headers: { "content-type": "application/json" },
|
|
579
|
-
body: JSON.stringify({ text })
|
|
580
|
-
});
|
|
581
|
-
return payload && typeof payload === "object" && !Array.isArray(payload) ? payload : { accepted: true };
|
|
582
|
-
}
|
|
583
|
-
async function runRunPiCommandViaServer(context, runId, text) {
|
|
584
|
-
const payload = await requestServerJson(context, `/api/runs/${encodeURIComponent(runId)}/pi/commands/run`, {
|
|
585
|
-
method: "POST",
|
|
586
|
-
headers: { "content-type": "application/json" },
|
|
587
|
-
body: JSON.stringify({ text })
|
|
588
|
-
});
|
|
589
|
-
return payload && typeof payload === "object" && !Array.isArray(payload) ? payload : { type: "done" };
|
|
590
|
-
}
|
|
591
|
-
async function respondRunPiExtensionUiViaServer(context, runId, requestId, valueOrCancel) {
|
|
592
|
-
const payload = await requestServerJson(context, `/api/runs/${encodeURIComponent(runId)}/pi/extension-ui/respond`, {
|
|
593
|
-
method: "POST",
|
|
594
|
-
headers: { "content-type": "application/json" },
|
|
595
|
-
body: JSON.stringify({ requestId, ...valueOrCancel })
|
|
596
|
-
});
|
|
597
|
-
return payload && typeof payload === "object" && !Array.isArray(payload) ? payload : { accepted: true };
|
|
598
|
-
}
|
|
599
|
-
async function abortRunPiViaServer(context, runId) {
|
|
600
|
-
const payload = await requestServerJson(context, `/api/runs/${encodeURIComponent(runId)}/pi/abort`, { method: "POST" });
|
|
601
|
-
return payload && typeof payload === "object" && !Array.isArray(payload) ? payload : { aborted: true };
|
|
602
|
-
}
|
|
603
|
-
async function buildRunPiEventsWebSocketUrl(context, runId) {
|
|
604
|
-
const server = await ensureServerForCli(context.projectRoot);
|
|
605
|
-
const url = new URL(`${server.baseUrl.replace(/\/+$/, "")}/api/runs/${encodeURIComponent(runId)}/pi/events`);
|
|
606
|
-
url.protocol = url.protocol === "https:" ? "wss:" : "ws:";
|
|
607
|
-
if (server.authToken)
|
|
608
|
-
url.searchParams.set("token", server.authToken);
|
|
609
|
-
if (server.serverProjectRoot)
|
|
610
|
-
url.searchParams.set("rigProjectRoot", server.serverProjectRoot);
|
|
611
|
-
return url.toString();
|
|
612
|
-
}
|
|
613
|
-
async function submitTaskRunViaServer(context, input) {
|
|
614
|
-
const isTaskRun = Boolean(input.taskId);
|
|
615
|
-
const endpoint = isTaskRun ? "/api/runs/task" : "/api/runs/adhoc";
|
|
616
|
-
const payload = await requestServerJson(context, endpoint, {
|
|
617
|
-
method: "POST",
|
|
618
|
-
headers: {
|
|
619
|
-
"content-type": "application/json"
|
|
620
|
-
},
|
|
621
|
-
body: JSON.stringify({
|
|
622
|
-
runId: input.runId,
|
|
623
|
-
taskId: input.taskId,
|
|
624
|
-
title: input.title,
|
|
625
|
-
runtimeAdapter: input.runtimeAdapter,
|
|
626
|
-
model: input.model,
|
|
627
|
-
runtimeMode: input.runtimeMode,
|
|
628
|
-
interactionMode: input.interactionMode,
|
|
629
|
-
initialPrompt: input.initialPrompt,
|
|
630
|
-
baselineMode: input.baselineMode,
|
|
631
|
-
prMode: input.prMode,
|
|
632
|
-
executionTarget: "local"
|
|
633
|
-
})
|
|
634
|
-
});
|
|
635
|
-
if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
|
|
636
|
-
throw new CliError("Rig server returned an invalid run submission payload.", 1, { hint: "Check `rig server status` and retry; `rig run list` shows whether the run was created anyway." });
|
|
637
|
-
}
|
|
638
|
-
const runId = payload.runId;
|
|
639
|
-
if (typeof runId !== "string" || runId.trim().length === 0) {
|
|
640
|
-
throw new CliError("Rig server returned no runId for the submitted run.", 1, { hint: "Check `rig run list` \u2014 the run may still have been created; otherwise retry the submission." });
|
|
641
|
-
}
|
|
642
|
-
return { runId };
|
|
643
|
-
}
|
|
644
|
-
export {
|
|
645
|
-
updateWorkspaceTaskViaServer,
|
|
646
|
-
switchServerProjectRootViaServer,
|
|
647
|
-
submitTaskRunViaServer,
|
|
648
|
-
stopRunViaServer,
|
|
649
|
-
steerRunViaServer,
|
|
650
|
-
setServerPhaseListener,
|
|
651
|
-
setGitHubBearerTokenForCurrentProcess,
|
|
652
|
-
sendRunPiShellViaServer,
|
|
653
|
-
sendRunPiPromptViaServer,
|
|
654
|
-
selectNextWorkspaceTaskViaServer,
|
|
655
|
-
runRunPiCommandViaServer,
|
|
656
|
-
resumeRunViaServer,
|
|
657
|
-
respondRunPiExtensionUiViaServer,
|
|
658
|
-
resolveServerConnectionLabel,
|
|
659
|
-
requestServerJson,
|
|
660
|
-
registerProjectViaServer,
|
|
661
|
-
prepareRemoteCheckoutViaServer,
|
|
662
|
-
postGitHubTokenViaServer,
|
|
663
|
-
listWorkspaceTasksViaServer,
|
|
664
|
-
listRunsViaServer,
|
|
665
|
-
listGitHubProjectsViaServer,
|
|
666
|
-
getWorkspaceTaskViaServer,
|
|
667
|
-
getRunTimelineViaServer,
|
|
668
|
-
getRunPiStatusViaServer,
|
|
669
|
-
getRunPiSessionViaServer,
|
|
670
|
-
getRunPiMessagesViaServer,
|
|
671
|
-
getRunPiCommandsViaServer,
|
|
672
|
-
getRunPiCapabilitiesViaServer,
|
|
673
|
-
getRunLogsViaServer,
|
|
674
|
-
getRunDetailsViaServer,
|
|
675
|
-
getGitHubProjectStatusFieldViaServer,
|
|
676
|
-
getGitHubAuthStatusViaServer,
|
|
677
|
-
ensureTaskLabelsViaServer,
|
|
678
|
-
ensureServerForCli,
|
|
679
|
-
buildRunPiEventsWebSocketUrl,
|
|
680
|
-
abortRunPiViaServer
|
|
681
|
-
};
|