@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,13 +1,9 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
// packages/cli/src/commands/_pi-install.ts
|
|
3
|
-
import { existsSync
|
|
3
|
+
import { existsSync } from "fs";
|
|
4
4
|
import { homedir } from "os";
|
|
5
5
|
import { resolve } from "path";
|
|
6
6
|
var PI_RIG_PACKAGE_NAME = "@h-rig/pi-rig";
|
|
7
|
-
var LEGACY_PI_RIG_PACKAGE_NAME = "@rig/pi-rig";
|
|
8
|
-
var LEGACY_PI_RIG_MARKER = `// Managed by Rig. Source package: @rig/pi-rig.
|
|
9
|
-
export { default } from '@rig/pi-rig';
|
|
10
|
-
`;
|
|
11
7
|
async function defaultCommandRunner(command, options = {}) {
|
|
12
8
|
const proc = Bun.spawn(command, { cwd: options.cwd, stdout: "pipe", stderr: "pipe" });
|
|
13
9
|
const [stdout, stderr, exitCode] = await Promise.all([
|
|
@@ -32,7 +28,7 @@ function resolvePiHomeDir(inputHomeDir) {
|
|
|
32
28
|
function piListContainsPiRig(output) {
|
|
33
29
|
return output.split(/\r?\n/).some((line) => {
|
|
34
30
|
const normalized = line.trim();
|
|
35
|
-
return normalized.includes(PI_RIG_PACKAGE_NAME) ||
|
|
31
|
+
return normalized.includes(PI_RIG_PACKAGE_NAME) || /(?:^|[\\/])packages[\\/]pi-rig(?:$|\s)/.test(normalized);
|
|
36
32
|
});
|
|
37
33
|
}
|
|
38
34
|
async function safeRun(runner, command, options) {
|
|
@@ -56,7 +52,13 @@ async function ensurePiBinaryAvailable(input) {
|
|
|
56
52
|
}
|
|
57
53
|
return { ok: true, detail: (current.stdout || current.stderr).trim() || undefined };
|
|
58
54
|
}
|
|
59
|
-
const installCommand = process.env.RIG_PI_INSTALL_COMMAND?.trim()
|
|
55
|
+
const installCommand = process.env.RIG_PI_INSTALL_COMMAND?.trim();
|
|
56
|
+
if (!installCommand) {
|
|
57
|
+
return {
|
|
58
|
+
ok: false,
|
|
59
|
+
error: `${(current.stderr || current.stdout).trim() || "pi --version failed"}. Set RIG_PI_INSTALL_COMMAND to a supported installer or install Pi manually.`
|
|
60
|
+
};
|
|
61
|
+
}
|
|
60
62
|
const parts = splitInstallCommand(installCommand);
|
|
61
63
|
if (parts.length === 0) {
|
|
62
64
|
return { ok: false, error: (current.stderr || current.stdout).trim() || "pi --version failed" };
|
|
@@ -73,18 +75,6 @@ async function ensurePiBinaryAvailable(input) {
|
|
|
73
75
|
...next.exitCode === 0 ? {} : { error: (next.stderr || next.stdout).trim() || "pi --version failed after install" }
|
|
74
76
|
};
|
|
75
77
|
}
|
|
76
|
-
function removeManagedLegacyPiRigBridge(homeDir, exists = existsSync) {
|
|
77
|
-
const extensionPath = resolvePiRigExtensionPath(homeDir);
|
|
78
|
-
const indexPath = resolve(extensionPath, "index.ts");
|
|
79
|
-
if (!exists(indexPath))
|
|
80
|
-
return;
|
|
81
|
-
try {
|
|
82
|
-
const content = readFileSync(indexPath, "utf8");
|
|
83
|
-
if (content === LEGACY_PI_RIG_MARKER || content.includes("Managed by Rig. Source package: @rig/pi-rig")) {
|
|
84
|
-
rmSync(extensionPath, { recursive: true, force: true });
|
|
85
|
-
}
|
|
86
|
-
} catch {}
|
|
87
|
-
}
|
|
88
78
|
async function checkPiRigInstall(input = {}) {
|
|
89
79
|
const home = resolvePiHomeDir(input.homeDir);
|
|
90
80
|
const extensionPath = resolvePiRigExtensionPath(home);
|
|
@@ -95,48 +85,40 @@ async function checkPiRigInstall(input = {}) {
|
|
|
95
85
|
piRig: { ok: true, label: "pi-rig global extension", detail: extensionPath }
|
|
96
86
|
};
|
|
97
87
|
}
|
|
98
|
-
const exists = input.exists ?? existsSync;
|
|
99
88
|
const runner = input.commandRunner ?? defaultCommandRunner;
|
|
100
89
|
const piResult = await safeRun(runner, ["pi", "--version"]);
|
|
101
90
|
const piListResult = piResult.exitCode === 0 ? await safeRun(runner, ["pi", "list"]) : { exitCode: 1, stdout: "", stderr: "" };
|
|
102
|
-
const
|
|
91
|
+
const hasPiRig = piListResult.exitCode === 0 && piListContainsPiRig(`${piListResult.stdout}
|
|
103
92
|
${piListResult.stderr}`);
|
|
104
|
-
const
|
|
105
|
-
const hasPiRig = listedPiRig;
|
|
93
|
+
const hasLegacyBridgeScaffold = !hasPiRig && (input.exists ?? existsSync)(extensionPath);
|
|
106
94
|
return {
|
|
107
95
|
extensionPath,
|
|
108
96
|
pi: {
|
|
109
97
|
ok: piResult.exitCode === 0,
|
|
110
98
|
label: "pi",
|
|
111
99
|
detail: (piResult.stdout || piResult.stderr).trim() || undefined,
|
|
112
|
-
hint: piResult.exitCode === 0 ? undefined : "Install Pi or
|
|
100
|
+
hint: piResult.exitCode === 0 ? undefined : "Install Pi/OMP manually or set RIG_PI_INSTALL_COMMAND before verifying with bare `rig` / Cockpit \u2192 Doctor."
|
|
113
101
|
},
|
|
114
102
|
piRig: {
|
|
115
103
|
ok: hasPiRig,
|
|
116
104
|
label: "pi-rig global extension",
|
|
117
|
-
detail: hasPiRig ? piListResult.stdout.trim() || PI_RIG_PACKAGE_NAME :
|
|
118
|
-
hint: hasPiRig ? undefined :
|
|
105
|
+
detail: hasPiRig ? piListResult.stdout.trim() || PI_RIG_PACKAGE_NAME : hasLegacyBridgeScaffold ? `legacy bridge scaffold at ${extensionPath}` : undefined,
|
|
106
|
+
hint: hasPiRig ? undefined : `Install the Rig OMP extension with \`pi install ${PI_RIG_PACKAGE_NAME}\`, then verify with bare \`rig\` / Cockpit \u2192 Doctor.`
|
|
119
107
|
}
|
|
120
108
|
};
|
|
121
109
|
}
|
|
122
110
|
async function ensurePiRigInstalled(input) {
|
|
123
111
|
const home = resolvePiHomeDir(input.homeDir);
|
|
124
112
|
if (process.env.RIG_TEST_FAKE_PI_INSTALL === "1") {
|
|
125
|
-
const
|
|
126
|
-
return { ...
|
|
113
|
+
const status = await checkPiRigInstall({ homeDir: home, commandRunner: input.commandRunner });
|
|
114
|
+
return { ...status, installedPath: status.extensionPath };
|
|
127
115
|
}
|
|
128
116
|
const runner = input.commandRunner ?? defaultCommandRunner;
|
|
129
117
|
const piAvailable = await ensurePiBinaryAvailable({ runner, projectRoot: input.projectRoot });
|
|
130
|
-
const status = piAvailable.ok ? await checkPiRigInstall({ homeDir: home, commandRunner: runner }) : {
|
|
131
|
-
extensionPath: resolvePiRigExtensionPath(home),
|
|
132
|
-
pi: { ok: false, label: "pi", detail: piAvailable.error, hint: "Install/update Pi with RIG_PI_INSTALL_COMMAND or install Pi manually." },
|
|
133
|
-
piRig: { ok: false, label: "pi-rig global extension", hint: "Pi is required before pi-rig can be installed." }
|
|
134
|
-
};
|
|
135
118
|
if (!piAvailable.ok) {
|
|
136
119
|
throw new Error(`Pi install/update failed: ${piAvailable.error ?? "pi unavailable"}`);
|
|
137
120
|
}
|
|
138
121
|
const packageSource = resolvePiRigPackageSource(input.projectRoot);
|
|
139
|
-
removeManagedLegacyPiRigBridge(home);
|
|
140
122
|
const install = await runner(["pi", "install", packageSource], { cwd: input.projectRoot });
|
|
141
123
|
if (install.exitCode !== 0) {
|
|
142
124
|
throw new Error(`pi-rig install failed: ${(install.stderr || install.stdout).trim() || `exit ${install.exitCode}`}`);
|
|
@@ -161,13 +143,13 @@ async function ensureRemotePiRigInstalled(input) {
|
|
|
161
143
|
ok: piOk,
|
|
162
144
|
label: "pi",
|
|
163
145
|
detail: typeof record.piVersion === "string" ? record.piVersion : undefined,
|
|
164
|
-
hint: piOk ? undefined : "Install/update Pi on the selected remote
|
|
146
|
+
hint: piOk ? undefined : "Install/update Pi on the selected remote control host, then verify with bare `rig` / Cockpit \u2192 Doctor."
|
|
165
147
|
},
|
|
166
148
|
piRig: {
|
|
167
149
|
ok: piRigOk,
|
|
168
150
|
label: "pi-rig global extension",
|
|
169
151
|
detail: extensionPath,
|
|
170
|
-
hint: piRigOk ? undefined :
|
|
152
|
+
hint: piRigOk ? undefined : `Install/enable the Rig OMP extension (${PI_RIG_PACKAGE_NAME}) on the selected remote control host, then verify with bare \`rig\` / Cockpit \u2192 Doctor.`
|
|
171
153
|
}
|
|
172
154
|
};
|
|
173
155
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type RunnerContext } from "../runner";
|
|
2
|
-
|
|
2
|
+
export type PolicyMode = "off" | "observe" | "enforce";
|
|
3
3
|
export declare function resolveEffectivePolicyMode(context: RunnerContext): PolicyMode;
|
|
4
4
|
export declare function appendControlledBashAudit(context: RunnerContext, mode: PolicyMode, command: string, args: string[], matchedRuleIds: string[], action?: "warn" | "blocked"): void;
|
|
5
5
|
export declare function enforceNativeCommandPolicy(context: RunnerContext, args: string[], options: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
// packages/cli/src/commands/_policy.ts
|
|
3
|
-
import { appendFileSync, mkdirSync } from "fs";
|
|
4
|
-
import { resolve } from "path";
|
|
3
|
+
import { appendFileSync, existsSync, mkdirSync, readFileSync } from "fs";
|
|
4
|
+
import { resolve as resolve2 } from "path";
|
|
5
5
|
|
|
6
6
|
// packages/cli/src/runner.ts
|
|
7
7
|
import { EventBus } from "@rig/runtime/control-plane/runtime/events";
|
|
@@ -22,22 +22,64 @@ function formatCommand(parts) {
|
|
|
22
22
|
return parts.map((part) => /[^a-zA-Z0-9_./:-]/.test(part) ? JSON.stringify(part) : part).join(" ");
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
// packages/cli/src/commands/_paths.ts
|
|
26
|
+
import { resolve } from "path";
|
|
27
|
+
import { resolveMonorepoRoot } from "@rig/runtime/layout";
|
|
28
|
+
function resolveControlPlaneHostStateRoot(projectRoot) {
|
|
29
|
+
return resolve(projectRoot, ".rig");
|
|
30
|
+
}
|
|
31
|
+
function resolveControlPlaneHostLogsDir(projectRoot) {
|
|
32
|
+
return resolve(resolveControlPlaneHostStateRoot(projectRoot), "logs");
|
|
33
|
+
}
|
|
34
|
+
function resolveControlPlaneDefinitionRoot(projectRoot) {
|
|
35
|
+
return resolve(projectRoot, "rig");
|
|
36
|
+
}
|
|
37
|
+
|
|
25
38
|
// packages/cli/src/commands/_policy.ts
|
|
26
|
-
|
|
27
|
-
|
|
39
|
+
function loadPolicyFile(projectRoot) {
|
|
40
|
+
const policyPath = resolve2(resolveControlPlaneDefinitionRoot(projectRoot), "policy", "policy.json");
|
|
41
|
+
if (!existsSync(policyPath)) {
|
|
42
|
+
return { mode: "observe", rules: [] };
|
|
43
|
+
}
|
|
44
|
+
try {
|
|
45
|
+
const parsed = JSON.parse(readFileSync(policyPath, "utf8"));
|
|
46
|
+
const mode = parsed.mode === "off" || parsed.mode === "observe" || parsed.mode === "enforce" ? parsed.mode : "observe";
|
|
47
|
+
const rules = Array.isArray(parsed.rules) ? parsed.rules.filter((value) => Boolean(value && typeof value === "object" && !Array.isArray(value))).map((value, index) => ({
|
|
48
|
+
id: typeof value.id === "string" && value.id.trim() ? value.id.trim() : `rule-${index + 1}`,
|
|
49
|
+
reason: typeof value.reason === "string" && value.reason.trim() ? value.reason.trim() : undefined,
|
|
50
|
+
match: typeof value.match === "string" && value.match.trim() ? value.match.trim() : undefined,
|
|
51
|
+
command: typeof value.command === "string" && value.command.trim() ? value.command.trim() : undefined
|
|
52
|
+
})) : [];
|
|
53
|
+
return { mode, rules };
|
|
54
|
+
} catch {
|
|
55
|
+
return { mode: "observe", rules: [] };
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function matchingRules(command, rules) {
|
|
59
|
+
return rules.filter((rule) => {
|
|
60
|
+
const rawPattern = rule.command ?? rule.match;
|
|
61
|
+
if (!rawPattern)
|
|
62
|
+
return false;
|
|
63
|
+
try {
|
|
64
|
+
return new RegExp(rawPattern, "i").test(command);
|
|
65
|
+
} catch {
|
|
66
|
+
return command.includes(rawPattern);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
28
70
|
function resolveEffectivePolicyMode(context) {
|
|
29
71
|
const envMode = process.env.RIG_BASH_MODE;
|
|
30
72
|
if (envMode === "off" || envMode === "observe" || envMode === "enforce") {
|
|
31
73
|
return envMode;
|
|
32
74
|
}
|
|
33
|
-
return context.policyMode
|
|
75
|
+
return context.policyMode ?? loadPolicyFile(context.projectRoot).mode;
|
|
34
76
|
}
|
|
35
77
|
function appendControlledBashAudit(context, mode, command, args, matchedRuleIds, action) {
|
|
36
78
|
if (mode === "off") {
|
|
37
79
|
return;
|
|
38
80
|
}
|
|
39
|
-
const logsDir =
|
|
40
|
-
const logFile =
|
|
81
|
+
const logsDir = resolveControlPlaneHostLogsDir(context.projectRoot);
|
|
82
|
+
const logFile = resolve2(logsDir, "controlled-bash.jsonl");
|
|
41
83
|
mkdirSync(logsDir, { recursive: true });
|
|
42
84
|
const payload = {
|
|
43
85
|
timestamp: new Date().toISOString(),
|
|
@@ -58,25 +100,24 @@ function appendControlledBashAudit(context, mode, command, args, matchedRuleIds,
|
|
|
58
100
|
async function enforceNativeCommandPolicy(context, args, options) {
|
|
59
101
|
const mode = resolveEffectivePolicyMode(context);
|
|
60
102
|
const command = formatCommand([options.commandPrefix, ...args]);
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
});
|
|
65
|
-
const action = resolveAction2(mode, decision.matchedRules);
|
|
66
|
-
const matchedRuleIds = decision.matchedRules.map((rule) => rule.id);
|
|
103
|
+
const rules = matchingRules(command, loadPolicyFile(context.projectRoot).rules);
|
|
104
|
+
const matchedRuleIds = rules.map((rule) => rule.id);
|
|
105
|
+
const action = rules.length === 0 ? "allow" : mode === "enforce" ? "block" : "warn";
|
|
67
106
|
await context.emitEvent("policy.decision", {
|
|
68
107
|
target: "command",
|
|
69
108
|
command,
|
|
70
109
|
mode,
|
|
71
110
|
allowed: action !== "block",
|
|
72
111
|
matchedRuleIds,
|
|
73
|
-
reasons:
|
|
112
|
+
reasons: rules.map((rule) => rule.reason).filter(Boolean)
|
|
74
113
|
});
|
|
75
114
|
if (options.writeAuditLog) {
|
|
76
115
|
appendControlledBashAudit(context, mode, command, args, matchedRuleIds, action === "block" ? "blocked" : action === "warn" ? "warn" : undefined);
|
|
77
116
|
}
|
|
78
117
|
if (action === "block") {
|
|
79
|
-
throw new CliError(`Policy blocked command: ${command}`, 126, {
|
|
118
|
+
throw new CliError(`Policy blocked command: ${command}`, 126, {
|
|
119
|
+
hint: "Review rig/policy/policy.json, or re-run with `--policy-mode observe` to log instead of block."
|
|
120
|
+
});
|
|
80
121
|
}
|
|
81
122
|
}
|
|
82
123
|
export {
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import type { ChildProcess, SpawnOptions } from "node:child_process";
|
|
2
|
+
import { type RegisteredTaskSource } from "@rig/contracts";
|
|
3
|
+
import { type CollabRegistryFilter, type LiveCollabProjection } from "@oh-my-pi/pi-coding-agent/collab/api";
|
|
4
|
+
export type RigExtensionTask = {
|
|
5
|
+
readonly id: string;
|
|
6
|
+
readonly title?: string | null;
|
|
7
|
+
readonly status?: string | null;
|
|
8
|
+
readonly source?: string | null;
|
|
9
|
+
readonly url?: string | null;
|
|
10
|
+
readonly body?: string | null;
|
|
11
|
+
};
|
|
12
|
+
export type RigExtensionServerState = {
|
|
13
|
+
readonly alias: string;
|
|
14
|
+
readonly kind: "local" | "remote";
|
|
15
|
+
readonly baseUrl?: string | null;
|
|
16
|
+
readonly projectRoot?: string | null;
|
|
17
|
+
readonly status?: string | null;
|
|
18
|
+
readonly taskSource?: string | null;
|
|
19
|
+
};
|
|
20
|
+
export type RigExtensionAttachResult = {
|
|
21
|
+
readonly sessionPath?: string | null;
|
|
22
|
+
readonly joinLink?: string | null;
|
|
23
|
+
readonly collabSessionId?: string | null;
|
|
24
|
+
};
|
|
25
|
+
export type RunRunProcessInput = {
|
|
26
|
+
readonly projectRoot?: string;
|
|
27
|
+
readonly taskId: string;
|
|
28
|
+
readonly runId?: string;
|
|
29
|
+
readonly title?: string | null;
|
|
30
|
+
readonly model?: string | null;
|
|
31
|
+
readonly prompt?: string | null;
|
|
32
|
+
readonly rigRunBin?: string;
|
|
33
|
+
readonly writeStdout?: (text: string) => void;
|
|
34
|
+
};
|
|
35
|
+
export type RunRunProcessResult = {
|
|
36
|
+
readonly runId: string;
|
|
37
|
+
readonly pid: number;
|
|
38
|
+
readonly sessionName: string;
|
|
39
|
+
readonly runtime: unknown;
|
|
40
|
+
};
|
|
41
|
+
export type RunRunProcess = (input: RunRunProcessInput) => Promise<RunRunProcessResult>;
|
|
42
|
+
type SpawnFunction = (command: string, args: readonly string[], options: SpawnOptions) => ChildProcess;
|
|
43
|
+
type ListTasksDeps = {
|
|
44
|
+
readonly loadTaskSource?: (projectRoot: string) => Promise<{
|
|
45
|
+
readonly kind: string;
|
|
46
|
+
readonly source: RegisteredTaskSource;
|
|
47
|
+
}>;
|
|
48
|
+
};
|
|
49
|
+
type SpawnRunProcessDeps = {
|
|
50
|
+
readonly runRunProcess?: RunRunProcess;
|
|
51
|
+
readonly spawn?: SpawnFunction;
|
|
52
|
+
readonly uuid?: () => string;
|
|
53
|
+
readonly resolveRigRunBin?: () => string;
|
|
54
|
+
readonly env?: NodeJS.ProcessEnv;
|
|
55
|
+
};
|
|
56
|
+
type AttachViaRelayDeps = {
|
|
57
|
+
readonly listActiveCollabSessions?: (filter: CollabRegistryFilter) => Promise<readonly LiveCollabProjection[]>;
|
|
58
|
+
readonly sleep?: (ms: number) => Promise<void>;
|
|
59
|
+
readonly now?: () => number;
|
|
60
|
+
};
|
|
61
|
+
export type SpawnRunProcessInput = {
|
|
62
|
+
readonly projectRoot: string;
|
|
63
|
+
readonly taskId: string;
|
|
64
|
+
readonly title?: string | null;
|
|
65
|
+
};
|
|
66
|
+
export type AttachViaRelayInput = {
|
|
67
|
+
readonly runId: string;
|
|
68
|
+
readonly taskId?: string | null;
|
|
69
|
+
readonly identityFilter: CollabRegistryFilter;
|
|
70
|
+
readonly timeoutMs?: number;
|
|
71
|
+
readonly pollIntervalMs?: number;
|
|
72
|
+
};
|
|
73
|
+
export declare function listTasksFromSource(projectRoot: string, deps?: ListTasksDeps): Promise<readonly RigExtensionTask[]>;
|
|
74
|
+
export declare function getTaskFromSource(projectRoot: string, taskId: string, deps?: ListTasksDeps): Promise<RigExtensionTask | null>;
|
|
75
|
+
export declare function readSelectedTarget(projectRoot: string, env?: NodeJS.ProcessEnv): Promise<RigExtensionServerState>;
|
|
76
|
+
export declare function resolveRigRunBin(): string;
|
|
77
|
+
export declare function spawnRunProcess(input: SpawnRunProcessInput, deps?: SpawnRunProcessDeps): Promise<{
|
|
78
|
+
readonly runId: string;
|
|
79
|
+
}>;
|
|
80
|
+
export type RunControl = {
|
|
81
|
+
readonly kind: "steer";
|
|
82
|
+
readonly message: string;
|
|
83
|
+
} | {
|
|
84
|
+
readonly kind: "stop";
|
|
85
|
+
readonly reason: string;
|
|
86
|
+
};
|
|
87
|
+
export interface DeliverRemoteControlDeps {
|
|
88
|
+
readonly env?: NodeJS.ProcessEnv;
|
|
89
|
+
readonly spawn?: SpawnFunction;
|
|
90
|
+
}
|
|
91
|
+
interface RemoteControlContext {
|
|
92
|
+
readonly checkout?: string | null;
|
|
93
|
+
readonly registryBaseUrl?: string | null;
|
|
94
|
+
readonly namespaceKey?: string | null;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Build the remote shell command that re-runs the operator's control VERB on the
|
|
98
|
+
* remote host. The run is LOCAL there (its session journal lives on the remote
|
|
99
|
+
* disk), so `rig run steer/stop <runId>` resolves it locally and the remote
|
|
100
|
+
* worker's own localRunChanges consumer applies it — fully symmetric with local
|
|
101
|
+
* placement. We SSH the verb (not a pre-built sentinel) so the remote rebuilds via
|
|
102
|
+
* its canonical stop path. Identity is passed inline (SSH does not forward local
|
|
103
|
+
* env); the registry HMAC secret is read from the remote env, never sent over argv.
|
|
104
|
+
*/
|
|
105
|
+
export declare function buildRemoteControlCommand(runId: string, control: RunControl, ctx: RemoteControlContext): string;
|
|
106
|
+
/**
|
|
107
|
+
* Deliver a steer/stop control to a REMOTE run by running the verb on the remote
|
|
108
|
+
* host over SSH (login shell, identical to spawnRunProcess). Awaits the remote
|
|
109
|
+
* exit code so the operator gets an honest success/failure — not fire-and-forget.
|
|
110
|
+
*/
|
|
111
|
+
export declare function deliverRemoteRunControl(projectRoot: string, runId: string, control: RunControl, deps?: DeliverRemoteControlDeps): Promise<void>;
|
|
112
|
+
export declare function listActiveRunCollab(filter: CollabRegistryFilter): Promise<readonly LiveCollabProjection[]>;
|
|
113
|
+
export declare function attachViaRelay(input: AttachViaRelayInput, deps?: AttachViaRelayDeps): Promise<RigExtensionAttachResult | null>;
|
|
114
|
+
export {};
|