robisie 0.1.4 → 0.2.1
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/CHANGELOG.md +29 -0
- package/README.md +39 -11
- package/dist/agents.d.ts +1 -1
- package/dist/agents.js +1 -1
- package/dist/ci-failure-result.js +1 -1
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +45 -8
- package/dist/codex-env.d.ts +9 -0
- package/dist/codex-env.js +60 -0
- package/dist/commands.js +145 -16
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/dist/delivery-local.d.ts +124 -0
- package/dist/delivery-local.js +286 -0
- package/dist/disk-guard.d.ts +20 -0
- package/dist/disk-guard.js +63 -0
- package/dist/done-evidence.d.ts +25 -1
- package/dist/done-evidence.js +59 -1
- package/dist/engine/bundle-report.json +1687 -0
- package/dist/engine/tick.cjs +324787 -0
- package/dist/engine-config.d.ts +3 -1
- package/dist/engine-config.js +3 -3
- package/dist/factory-run.d.ts +17 -0
- package/dist/factory-run.js +262 -0
- package/dist/helpers.js +1 -1
- package/dist/k3-codex-job.d.ts +49 -0
- package/dist/k3-codex-job.js +324 -0
- package/dist/k3-codex-role.js +4 -1
- package/dist/k3-helper-cli.d.ts +5 -0
- package/dist/k3-helper-cli.js +193 -0
- package/dist/local-usage.d.ts +47 -0
- package/dist/local-usage.js +230 -0
- package/dist/manifest.d.ts +5 -2
- package/dist/manifest.js +6 -6
- package/dist/planer-client.d.ts +45 -4
- package/dist/planer-client.js +120 -14
- package/dist/roles.d.ts +1 -1
- package/dist/select-fingerprint.d.ts +19 -0
- package/dist/select-fingerprint.js +46 -0
- package/dist/test-report.d.ts +9 -0
- package/dist/test-report.js +139 -0
- package/dist/tester-result-reader.d.ts +87 -0
- package/dist/tester-result-reader.js +122 -0
- package/docs/ENGINE-API.md +9 -1
- package/docs/README.en.md +58 -17
- package/docs/README.md +56 -17
- package/docs/RELEASE-0.1.0.md +28 -5
- package/helpers/ceo-client-launcher-mcp.mjs +76 -5
- package/package.json +6 -2
- package/roles/ceo-client.md +10 -8
package/dist/engine-config.d.ts
CHANGED
|
@@ -53,8 +53,10 @@ export interface EngineConfig extends InstanceConfig {
|
|
|
53
53
|
lint: string[];
|
|
54
54
|
build: string[];
|
|
55
55
|
};
|
|
56
|
+
/** Dla `delivered|pr` niepusta; dla `local` dopuszczalna pusta tablica. */
|
|
56
57
|
requiredChecks: string[];
|
|
57
|
-
|
|
58
|
+
/** `local` = wynik zostaje w repo docelowym (bez PR i bez dostarczenia); sam odczyt nic nie uruchamia. */
|
|
59
|
+
delivery: 'delivered' | 'pr' | 'local';
|
|
58
60
|
};
|
|
59
61
|
}
|
|
60
62
|
export declare const CONFIG_FILE = "robisie.config.json";
|
package/dist/engine-config.js
CHANGED
|
@@ -128,9 +128,9 @@ export function parseEngineConfig(raw, configPath) {
|
|
|
128
128
|
const test = textList(commands.test, 'engine.commands.test', label);
|
|
129
129
|
const lint = textList(commands.lint, 'engine.commands.lint', label);
|
|
130
130
|
const build = textList(commands.build, 'engine.commands.build', label);
|
|
131
|
-
const requiredChecks = textList(value.requiredChecks, 'engine.requiredChecks', label);
|
|
132
|
-
if (value.delivery !== 'delivered' && value.delivery !== 'pr')
|
|
133
|
-
fail(label, 'engine.delivery: wymagane delivered|pr');
|
|
131
|
+
const requiredChecks = value.delivery === 'local' && Array.isArray(value.requiredChecks) && !value.requiredChecks.length ? [] : textList(value.requiredChecks, 'engine.requiredChecks', label);
|
|
132
|
+
if (value.delivery !== 'delivered' && value.delivery !== 'pr' && value.delivery !== 'local')
|
|
133
|
+
fail(label, 'engine.delivery: wymagane delivered|pr|local');
|
|
134
134
|
return { ...config, engine: { repo, branch, commands: { test, lint, build }, requiredChecks, delivery: value.delivery } };
|
|
135
135
|
}
|
|
136
136
|
export function loadEngineConfig(path) {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ChildProcess, type SpawnOptions } from "node:child_process";
|
|
2
|
+
import { type Ctx } from "./context.js";
|
|
3
|
+
export interface FactoryOptions {
|
|
4
|
+
engineConfig: string | null;
|
|
5
|
+
interval: number;
|
|
6
|
+
once: boolean;
|
|
7
|
+
}
|
|
8
|
+
/** Only external effects are replaceable; the CLI has no alternate engine or tick-limit option. */
|
|
9
|
+
export interface FactoryRuntime {
|
|
10
|
+
spawn: (command: string, args: readonly string[], options: SpawnOptions) => ChildProcess;
|
|
11
|
+
kill: typeof process.kill;
|
|
12
|
+
signals: Pick<NodeJS.Process, "on" | "off">;
|
|
13
|
+
sleep: (ms: number, signal: AbortSignal) => Promise<void>;
|
|
14
|
+
nodeVersion: string;
|
|
15
|
+
moduleUrl: string;
|
|
16
|
+
}
|
|
17
|
+
export declare function runFactory(ctx: Ctx, options: FactoryOptions, overrides?: Partial<FactoryRuntime>): Promise<number>;
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { randomUUID } from "node:crypto";
|
|
3
|
+
import { closeSync, fstatSync, lstatSync, mkdirSync, openSync, readFileSync, realpathSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { constants } from "node:os";
|
|
5
|
+
import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
|
+
import { RobisieError } from "./context.js";
|
|
8
|
+
import { loadEngineConfig } from "./engine-config.js";
|
|
9
|
+
function sleep(ms, signal) {
|
|
10
|
+
return new Promise(done => {
|
|
11
|
+
if (signal.aborted)
|
|
12
|
+
return done();
|
|
13
|
+
const finish = () => { clearTimeout(timer); signal.removeEventListener("abort", finish); done(); };
|
|
14
|
+
const timer = setTimeout(finish, ms);
|
|
15
|
+
signal.addEventListener("abort", finish, { once: true });
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function errorCode(error) {
|
|
19
|
+
return typeof error === "object" && error !== null && "code" in error ? error.code : undefined;
|
|
20
|
+
}
|
|
21
|
+
/** A dangling symlink is an error, not a nonexistent ancestor we may create through. */
|
|
22
|
+
function physical(path) {
|
|
23
|
+
try {
|
|
24
|
+
lstatSync(path);
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
if (errorCode(error) !== "ENOENT" || dirname(path) === path)
|
|
28
|
+
throw error;
|
|
29
|
+
return join(physical(dirname(path)), basename(path));
|
|
30
|
+
}
|
|
31
|
+
return realpathSync(path);
|
|
32
|
+
}
|
|
33
|
+
function within(repo, state) {
|
|
34
|
+
const rel = relative(repo, state);
|
|
35
|
+
return rel === "" || (rel !== ".." && !rel.startsWith(`..${sep}`) && !isAbsolute(rel));
|
|
36
|
+
}
|
|
37
|
+
function optionalFile(path) {
|
|
38
|
+
try {
|
|
39
|
+
return statSync(path).isFile();
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
if (errorCode(error) === "ENOENT")
|
|
43
|
+
return false;
|
|
44
|
+
throw error;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const ENV_NAMES = [
|
|
48
|
+
"HOME", "PATH", "TMPDIR", "USER", "LOGNAME", "LANG", "LC_ALL", "TERM", "NO_COLOR",
|
|
49
|
+
"CODEX_HOME", "XDG_CONFIG_HOME", "XDG_DATA_HOME", "XDG_CACHE_HOME",
|
|
50
|
+
"ROBISIE_KEY", "ROBISIE_REVIEW_KEY", "PLANNER_USER_ID", "MASZYNISTA_PLANNER_ORIGIN", "ROBISIE_CODEX_HELPER",
|
|
51
|
+
];
|
|
52
|
+
export async function runFactory(ctx, options, overrides = {}) {
|
|
53
|
+
const runtime = { spawn, kill: process.kill, signals: process, sleep,
|
|
54
|
+
nodeVersion: process.versions.node, moduleUrl: import.meta.url, ...overrides };
|
|
55
|
+
const controller = new AbortController();
|
|
56
|
+
let stopSignal = null;
|
|
57
|
+
let forced = false;
|
|
58
|
+
let child = null;
|
|
59
|
+
let killTimer;
|
|
60
|
+
let lock;
|
|
61
|
+
let exitCode = 2;
|
|
62
|
+
let result = 2;
|
|
63
|
+
const report = (message, nextStep) => {
|
|
64
|
+
ctx.err(`✗ ${message}`);
|
|
65
|
+
ctx.err(`Następny krok: ${nextStep}`);
|
|
66
|
+
};
|
|
67
|
+
const fail = (code, message, nextStep) => {
|
|
68
|
+
exitCode = code;
|
|
69
|
+
throw new RobisieError(message, nextStep);
|
|
70
|
+
};
|
|
71
|
+
const signalChild = (signal) => {
|
|
72
|
+
const active = child;
|
|
73
|
+
if (!active?.pid)
|
|
74
|
+
return;
|
|
75
|
+
try {
|
|
76
|
+
runtime.kill(-active.pid, signal);
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
if (errorCode(error) !== "ESRCH")
|
|
80
|
+
report("Nie udało się przekazać sygnału do grupy taktu.", "Sprawdź proces taktu i jego uprawnienia; nie usuwaj blokady przed potwierdzeniem zakończenia.");
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
const stopChild = () => {
|
|
84
|
+
if (!child?.pid || !stopSignal)
|
|
85
|
+
return;
|
|
86
|
+
// Arm before kill: a child can close while a signal is being delivered.
|
|
87
|
+
if (!forced && killTimer === undefined)
|
|
88
|
+
killTimer = setTimeout(() => { killTimer = undefined; forced = true; signalChild("SIGKILL"); }, 5000);
|
|
89
|
+
signalChild(forced ? "SIGKILL" : stopSignal);
|
|
90
|
+
};
|
|
91
|
+
const stop = (signal) => {
|
|
92
|
+
if (stopSignal) {
|
|
93
|
+
forced = true;
|
|
94
|
+
clearTimeout(killTimer);
|
|
95
|
+
killTimer = undefined;
|
|
96
|
+
}
|
|
97
|
+
else
|
|
98
|
+
stopSignal = signal;
|
|
99
|
+
controller.abort();
|
|
100
|
+
stopChild();
|
|
101
|
+
};
|
|
102
|
+
const interrupt = () => stop("SIGINT");
|
|
103
|
+
const terminate = () => stop("SIGTERM");
|
|
104
|
+
const stoppedCode = () => stopSignal === "SIGINT" ? 130 : 143;
|
|
105
|
+
runtime.signals.on("SIGINT", interrupt);
|
|
106
|
+
runtime.signals.on("SIGTERM", terminate);
|
|
107
|
+
try {
|
|
108
|
+
if (ctx.platform !== "linux" || Number(runtime.nodeVersion.split(".")[0]) < 24) {
|
|
109
|
+
fail(2, "Factory run wymaga systemu Linux i Node.js >=24.", "Uruchom polecenie na Linuxie z Node.js 24 lub nowszym.");
|
|
110
|
+
}
|
|
111
|
+
const selected = options.engineConfig ?? ctx.env.ROBISIE_ENGINE_CONFIG;
|
|
112
|
+
const configStep = "Popraw konfigurację i sprawdź ją poleceniem `npx robisie doctor --engine-config <path>`, podstawiając ścieżkę pliku; następnie ponów factory run.";
|
|
113
|
+
if (!selected?.trim())
|
|
114
|
+
fail(78, "Brak konfiguracji silnika dla factory run.", "Podaj `npx robisie factory run --engine-config <path>` ze ścieżką pliku konfiguracji.");
|
|
115
|
+
const selectedPath = resolve(ctx.cwd, selected);
|
|
116
|
+
let config;
|
|
117
|
+
let configBytes;
|
|
118
|
+
try {
|
|
119
|
+
config = loadEngineConfig(selectedPath);
|
|
120
|
+
configBytes = readFileSync(config.configPath);
|
|
121
|
+
}
|
|
122
|
+
catch {
|
|
123
|
+
fail(78, "Nie można wczytać konfiguracji silnika.", configStep);
|
|
124
|
+
}
|
|
125
|
+
if (config.engine.delivery !== "local")
|
|
126
|
+
fail(78, "Factory run wymaga engine.delivery: local.", configStep);
|
|
127
|
+
let repo;
|
|
128
|
+
let state;
|
|
129
|
+
try {
|
|
130
|
+
repo = realpathSync(config.engine.repo);
|
|
131
|
+
if (!statSync(repo).isDirectory())
|
|
132
|
+
throw new Error("repo is not a directory");
|
|
133
|
+
state = physical(config.stateDir);
|
|
134
|
+
if (within(repo, state))
|
|
135
|
+
throw new Error("state inside repository");
|
|
136
|
+
}
|
|
137
|
+
catch {
|
|
138
|
+
fail(78, "Nie można potwierdzić repo i katalogu stanu poza repozytorium.", configStep);
|
|
139
|
+
}
|
|
140
|
+
const bundle = fileURLToPath(new URL("./engine/tick.cjs", runtime.moduleUrl));
|
|
141
|
+
if (!optionalFile(bundle))
|
|
142
|
+
fail(2, "Nie znaleziono silnika w zainstalowanej paczce.", "Zainstaluj kompletną paczkę robisie i ponów polecenie.");
|
|
143
|
+
const env = {};
|
|
144
|
+
for (const name of ENV_NAMES)
|
|
145
|
+
if (ctx.env[name] !== undefined)
|
|
146
|
+
env[name] = ctx.env[name];
|
|
147
|
+
env.ROBISIE_ENGINE_CONFIG = config.configPath;
|
|
148
|
+
env.MASZYNISTA_PLANNER_TRANSPORT = "api";
|
|
149
|
+
const helper = fileURLToPath(new URL("./k3-helper-cli.js", runtime.moduleUrl));
|
|
150
|
+
if (env.ROBISIE_CODEX_HELPER === undefined && optionalFile(helper))
|
|
151
|
+
env.ROBISIE_CODEX_HELPER = helper;
|
|
152
|
+
const checkInstallation = () => {
|
|
153
|
+
try {
|
|
154
|
+
if (realpathSync(selectedPath) !== config.configPath || !readFileSync(config.configPath).equals(configBytes)
|
|
155
|
+
|| realpathSync(config.stateDir) !== state || realpathSync(config.engine.repo) !== repo) {
|
|
156
|
+
fail(78, "Konfiguracja lub ścieżki instalacji zmieniły się podczas pracy.", configStep);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
catch (error) {
|
|
160
|
+
if (error instanceof RobisieError)
|
|
161
|
+
throw error;
|
|
162
|
+
fail(78, "Nie można ponownie potwierdzić konfiguracji instalacji.", configStep);
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
if (stopSignal)
|
|
166
|
+
return stoppedCode();
|
|
167
|
+
mkdirSync(state, { recursive: true, mode: 0o700 });
|
|
168
|
+
checkInstallation();
|
|
169
|
+
const lockPath = join(state, ".factory-run.lock");
|
|
170
|
+
const lockStep = `Potwierdź, że poprzedni nadzorca i jego takt nie działają; dopiero wtedy usuń blokadę „${lockPath}” i ponów polecenie.`;
|
|
171
|
+
let fd;
|
|
172
|
+
try {
|
|
173
|
+
fd = openSync(lockPath, "wx", 0o600);
|
|
174
|
+
}
|
|
175
|
+
catch (error) {
|
|
176
|
+
if (errorCode(error) === "EEXIST")
|
|
177
|
+
fail(2, "Blokada factory run już istnieje.", lockStep);
|
|
178
|
+
throw error;
|
|
179
|
+
}
|
|
180
|
+
try {
|
|
181
|
+
lock = { path: lockPath, stat: fstatSync(fd), token: `${process.pid} ${randomUUID()}\n` };
|
|
182
|
+
writeFileSync(fd, lock.token);
|
|
183
|
+
}
|
|
184
|
+
finally {
|
|
185
|
+
closeSync(fd);
|
|
186
|
+
}
|
|
187
|
+
while (!stopSignal) {
|
|
188
|
+
checkInstallation();
|
|
189
|
+
if (stopSignal)
|
|
190
|
+
break;
|
|
191
|
+
const outcome = await new Promise(done => {
|
|
192
|
+
let active;
|
|
193
|
+
try {
|
|
194
|
+
active = runtime.spawn(process.execPath, [bundle], { cwd: repo, env, shell: false, detached: true, stdio: ["ignore", "inherit", "inherit"] });
|
|
195
|
+
}
|
|
196
|
+
catch {
|
|
197
|
+
done({ code: null, signal: null, failed: true });
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
child = active;
|
|
201
|
+
let failed = false;
|
|
202
|
+
const awaitingPid = active.pid === undefined;
|
|
203
|
+
const onSpawn = () => { if (awaitingPid && stopSignal)
|
|
204
|
+
stopChild(); };
|
|
205
|
+
const onError = () => { failed = true; signalChild("SIGTERM"); };
|
|
206
|
+
const onClose = (code, signal) => {
|
|
207
|
+
clearTimeout(killTimer);
|
|
208
|
+
killTimer = undefined;
|
|
209
|
+
child = null;
|
|
210
|
+
active.off("spawn", onSpawn);
|
|
211
|
+
active.off("error", onError);
|
|
212
|
+
active.off("close", onClose);
|
|
213
|
+
done({ code, signal, failed });
|
|
214
|
+
};
|
|
215
|
+
active.once("spawn", onSpawn);
|
|
216
|
+
active.once("error", onError);
|
|
217
|
+
active.once("close", onClose);
|
|
218
|
+
if (stopSignal)
|
|
219
|
+
stopChild();
|
|
220
|
+
});
|
|
221
|
+
if (stopSignal)
|
|
222
|
+
break;
|
|
223
|
+
const logStep = `Sprawdź stderr i ostatni błąd w „${join(state, "ticks.log")}”, usuń przyczynę i ponów polecenie.`;
|
|
224
|
+
if (outcome.failed || (outcome.code === null && outcome.signal === null))
|
|
225
|
+
fail(2, "Fabryka zatrzymana: błąd uruchomienia taktu.", logStep);
|
|
226
|
+
if (outcome.signal)
|
|
227
|
+
fail(128 + (constants.signals[outcome.signal] ?? 1), `Fabryka zatrzymana: takt zakończył się sygnałem ${outcome.signal}.`, logStep);
|
|
228
|
+
if (outcome.code !== 0)
|
|
229
|
+
fail(outcome.code, `Fabryka zatrzymana: takt zakończył się kodem ${outcome.code}.`, outcome.code === 78 ? configStep : logStep);
|
|
230
|
+
if (options.once)
|
|
231
|
+
break;
|
|
232
|
+
await runtime.sleep(options.interval * 1000, controller.signal);
|
|
233
|
+
}
|
|
234
|
+
result = stopSignal ? stoppedCode() : 0;
|
|
235
|
+
}
|
|
236
|
+
catch (error) {
|
|
237
|
+
result = stopSignal ? stoppedCode() : error instanceof RobisieError ? exitCode : 2;
|
|
238
|
+
if (error instanceof RobisieError)
|
|
239
|
+
report(error.message, error.nextStep);
|
|
240
|
+
else
|
|
241
|
+
report("Fabryka zatrzymana: błąd operacji nadzorcy.", "Sprawdź uprawnienia plików konfiguracji, paczki i katalogu stanu oraz stderr; usuń przyczynę i ponów polecenie.");
|
|
242
|
+
}
|
|
243
|
+
finally {
|
|
244
|
+
clearTimeout(killTimer);
|
|
245
|
+
runtime.signals.off("SIGINT", interrupt);
|
|
246
|
+
runtime.signals.off("SIGTERM", terminate);
|
|
247
|
+
if (lock && !child) {
|
|
248
|
+
try {
|
|
249
|
+
const current = lstatSync(lock.path);
|
|
250
|
+
if (!current.isSymbolicLink() && current.dev === lock.stat.dev && current.ino === lock.stat.ino && readFileSync(lock.path, "utf8") === lock.token)
|
|
251
|
+
unlinkSync(lock.path);
|
|
252
|
+
}
|
|
253
|
+
catch (error) {
|
|
254
|
+
if (errorCode(error) !== "ENOENT") {
|
|
255
|
+
report("Nie udało się zwolnić blokady factory run.", "Potwierdź zakończenie nadzorcy i taktu, sprawdź uprawnienia katalogu stanu i usuń pozostawioną blokadę przed ponownym startem.");
|
|
256
|
+
result = stopSignal ? stoppedCode() : 2;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
return result;
|
|
262
|
+
}
|
package/dist/helpers.js
CHANGED
|
@@ -10,7 +10,7 @@ import { RobisieError } from "./context.js";
|
|
|
10
10
|
*/
|
|
11
11
|
export const HELPER_TOOLS = {
|
|
12
12
|
"client-launch-context": ["get_launch_context", "get_project_context", "run_project_check", "prepare_review", "create_review_receipt", "verify_stored_review"],
|
|
13
|
-
"ceo-client-launcher": ["spawn_builder", "verify_review_receipt"],
|
|
13
|
+
"ceo-client-launcher": ["spawn_builder", "spawn_quality", "verify_review_receipt"],
|
|
14
14
|
};
|
|
15
15
|
export function isHelperServer(value) {
|
|
16
16
|
return HELPER_SERVERS.includes(value);
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { type SpawnOptions } from "node:child_process";
|
|
2
|
+
import { runK3CodexRole, type K3CodexRoleOptions } from "./k3-codex-role.js";
|
|
3
|
+
/** The same prepared bundle accepted by the synchronous role runner. */
|
|
4
|
+
export type K3CodexJobBundle = Parameters<typeof runK3CodexRole>[0];
|
|
5
|
+
/** Durable locations, safe to pass to a separate reader after the starter exits. */
|
|
6
|
+
export interface K3CodexJobHandle {
|
|
7
|
+
jobId: string;
|
|
8
|
+
stateDir: string;
|
|
9
|
+
statePath: string;
|
|
10
|
+
logPath: string;
|
|
11
|
+
stderrPath: string;
|
|
12
|
+
}
|
|
13
|
+
/** Optional process boundary for isolated callers/tests; defaults use Node POSIX operations.
|
|
14
|
+
* isAlive must return false only for ESRCH and throw on permission/inspection errors.
|
|
15
|
+
* command returns ps's `pgid=,command=` row for the requested leader.
|
|
16
|
+
*/
|
|
17
|
+
export interface K3CodexJobProcesses {
|
|
18
|
+
spawn?: (binary: string, argv: string[], options: SpawnOptions) => {
|
|
19
|
+
pid?: number;
|
|
20
|
+
once(event: "spawn" | "error", listener: (error?: unknown) => void): unknown;
|
|
21
|
+
unref(): void;
|
|
22
|
+
};
|
|
23
|
+
kill?: typeof process.kill;
|
|
24
|
+
isAlive?: (pid: number) => boolean;
|
|
25
|
+
command?: (pid: number) => string;
|
|
26
|
+
}
|
|
27
|
+
/** Failure reasons contain metadata only, never provider output or environment. */
|
|
28
|
+
export type K3CodexJobFailure = "invalid_output" | "process_failed" | "ENOENT" | "EACCES" | "ETIMEDOUT" | "runner_io";
|
|
29
|
+
/** A process result is not an independent review verdict. Unknown is never success. */
|
|
30
|
+
export type K3CodexJobResult = {
|
|
31
|
+
status: "running";
|
|
32
|
+
} | {
|
|
33
|
+
status: "completed";
|
|
34
|
+
report: string;
|
|
35
|
+
} | {
|
|
36
|
+
status: "failed";
|
|
37
|
+
reason: K3CodexJobFailure;
|
|
38
|
+
} | {
|
|
39
|
+
status: "cancelled";
|
|
40
|
+
} | {
|
|
41
|
+
status: "unknown";
|
|
42
|
+
reason: string;
|
|
43
|
+
};
|
|
44
|
+
/** Validate without CLI, persist private input, and detach a Node supervisor. Env is passed only to spawn. */
|
|
45
|
+
export declare function startK3CodexJob(bundle: K3CodexJobBundle, options: K3CodexRoleOptions, stateDir: string, deps?: K3CodexJobProcesses): Promise<K3CodexJobHandle>;
|
|
46
|
+
/** Read durable state from any caller; unsupported, corrupt, dead or unreadable jobs remain unknown. */
|
|
47
|
+
export declare function readK3CodexJob(stateDir: string, jobId: string, deps?: K3CodexJobProcesses): Promise<K3CodexJobResult>;
|
|
48
|
+
/** Signal only a verified own POSIX group; cancelled is published only after ESRCH. */
|
|
49
|
+
export declare function cancelK3CodexJob(stateDir: string, jobId: string, deps?: K3CodexJobProcesses): Promise<K3CodexJobResult>;
|