parallel-codex-tui 0.4.0 → 0.4.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/README.md +34 -4
- package/dist/cli-args.js +45 -2
- package/dist/cli-help.js +3 -0
- package/dist/cli.js +25 -0
- package/dist/supervisor/operations.js +116 -0
- package/dist/supervisor/store.js +4 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,7 +6,9 @@ Built with Codex-assisted development.
|
|
|
6
6
|
|
|
7
7
|
## Current Release
|
|
8
8
|
|
|
9
|
-
`v0.4.
|
|
9
|
+
`v0.4.1` is available from [npm](https://www.npmjs.com/package/parallel-codex-tui/v/0.4.1) and as a [GitHub Release](https://github.com/allendred/parallel-codex-tui/releases/tag/v0.4.1). It adds a non-interactive Supervisor control plane: `--runs` lists persisted background runs, `--runs --json` provides versioned machine-readable status, and `--cancel-run [id]` cancels a selected or latest active run without opening the TUI. The status payload excludes requests, prompts, logs, command arguments, and environment values.
|
|
10
|
+
|
|
11
|
+
Main and parallel executions run in a detached, per-request Supervisor after the Router resolves in the foreground. `Ctrl+C` closes the outer TUI without stopping an attached run, reopening the same workspace restores its live events or terminal result, and `Esc` remains the explicit cancellation command. One TUI owns the control lease while additional TUIs observe the same run; an observer takes control automatically after the prior controller detaches or exits.
|
|
10
12
|
|
|
11
13
|
Supervisor requests, state, events, commands, controller ownership, acknowledgements, and diagnostic output are retained under `.parallel-codex/supervisor/runs/<run-id>/`. The Supervisor writes the final chat result itself, so completion survives a closed terminal without duplicate history when the TUI is reopened. Unexpected Supervisor exit is converted into a durable failed state instead of leaving an indefinitely running UI.
|
|
12
14
|
|
|
@@ -37,7 +39,7 @@ Highlights:
|
|
|
37
39
|
- Named Worker Providers support Codex-compatible, Claude-compatible, OpenAI-compatible, Anthropic-compatible, and custom generic commands with independent role, model, environment, permission, resume, and interactive settings.
|
|
38
40
|
- Worker overview, Feature board, collaboration timeline, Task and Main conversation centers, status details, rendered Markdown/Diff/error logs, Unicode search, keyboard navigation, mouse scrolling, and configurable themes share one terminal UI system.
|
|
39
41
|
|
|
40
|
-
Release acceptance includes a real three-Feature Tetris task with parallel Actor/Critic waves and final integration review. A clean `v0.2.5` task also ran Codex Judge and Actor, a buffered Claude Critic that independently executed `node --test` and `npm test`, atomic integration, and a resumed Codex Judge that independently passed all seven acceptance criteria. Real Codex and Claude probes both proved fresh and same-session resume calls; Codex fresh and resume runs executed workspace writes with root-level `-a never`, and Claude automated sessions executed safe Bash tools with `auto` permissions. The semantic Router completed a live classification, and one TUI completed Main calls in two workspaces before restoring the first workspace without leaking chat state. PTY coverage runs in Apple Terminal, tmux, and Zellij profiles at narrow and wide sizes, including status/log equivalence, preserving the native output tail across status-detail round trips, and proving both inline and on-demand file memory after native-session rollover. Supervisor PTY coverage proves detached Main and complex execution, restart recovery, controller/observer takeover, explicit cancellation,
|
|
42
|
+
Release acceptance includes a real three-Feature Tetris task with parallel Actor/Critic waves and final integration review. A clean `v0.2.5` task also ran Codex Judge and Actor, a buffered Claude Critic that independently executed `node --test` and `npm test`, atomic integration, and a resumed Codex Judge that independently passed all seven acceptance criteria. Real Codex and Claude probes both proved fresh and same-session resume calls; Codex fresh and resume runs executed workspace writes with root-level `-a never`, and Claude automated sessions executed safe Bash tools with `auto` permissions. The semantic Router completed a live classification, and one TUI completed Main calls in two workspaces before restoring the first workspace without leaking chat state. PTY coverage runs in Apple Terminal, tmux, and Zellij profiles at narrow and wide sizes, including status/log equivalence, preserving the native output tail across status-detail round trips, and proving both inline and on-demand file memory after native-session rollover. Supervisor PTY coverage proves detached Main and complex execution, restart recovery, controller/observer takeover, explicit cancellation, process-owner crash recovery, and out-of-process status/cancellation commands. The deterministic repository suite contains 1,363 tests across 143 files: 1,362 pass by default, while one quota-consuming real-Agent test is skipped and passes through `npm run test:real-agents`.
|
|
41
43
|
|
|
42
44
|
Real Provider probes depend on valid local CLI credentials. In particular, authenticate the Claude CLI before selecting a Claude-compatible Worker, then run `parallel-codex-tui --doctor --probe-agents` to prove fresh and resumed calls on that machine.
|
|
43
45
|
|
|
@@ -65,6 +67,9 @@ parallel-codex-tui --doctor --probe-agents
|
|
|
65
67
|
parallel-codex-tui --doctor --probe-router
|
|
66
68
|
parallel-codex-tui --diagnostics
|
|
67
69
|
parallel-codex-tui --diagnostics ./support-bundle
|
|
70
|
+
parallel-codex-tui --workspace /path/to/project --runs
|
|
71
|
+
parallel-codex-tui --workspace /path/to/project --runs --json
|
|
72
|
+
parallel-codex-tui --workspace /path/to/project --cancel-run
|
|
68
73
|
parallel-codex-tui --workspace /path/to/project
|
|
69
74
|
parallel-codex-tui --theme aurora --workspace /path/to/project
|
|
70
75
|
parallel-codex-tui --theme studio --workspace /path/to/project
|
|
@@ -107,6 +112,10 @@ parallel-codex-tui --doctor --probe-agents
|
|
|
107
112
|
parallel-codex-tui --doctor --probe-router
|
|
108
113
|
parallel-codex-tui --diagnostics
|
|
109
114
|
parallel-codex-tui --diagnostics ./support-bundle
|
|
115
|
+
parallel-codex-tui --workspace /path/to/project --runs
|
|
116
|
+
parallel-codex-tui --workspace /path/to/project --runs --json
|
|
117
|
+
parallel-codex-tui --workspace /path/to/project --cancel-run
|
|
118
|
+
parallel-codex-tui --workspace /path/to/project --cancel-run run-20260721T000000Z-deadbeef
|
|
110
119
|
parallel-codex-tui --version
|
|
111
120
|
```
|
|
112
121
|
|
|
@@ -125,6 +134,27 @@ Without an explicit destination, the bundle is created under `.parallel-codex/di
|
|
|
125
134
|
|
|
126
135
|
The bundle contains `manifest.json`, `report.md`, `report.json`, `doctor.txt`, `tasks.json`, `workers.json`, `router-audit.jsonl`, and bounded Worker log tails. It exports at most the latest 20 tasks, 200 Workers, 100 Router rows, and 200 lines or 64 KiB per Worker log. Workspace, app-root, and home paths are aliased; URL credentials and paths, authorization values, secret assignments, common token formats, and environment-variable values are redacted. Prompts, role instructions, command arguments, source files, and lifetime logs are excluded. Review the bundle before sharing it, because application output can still contain project-specific text that no automatic redactor can fully understand.
|
|
127
136
|
|
|
137
|
+
## Background Runs
|
|
138
|
+
|
|
139
|
+
Inspect a Workspace without opening the TUI:
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
parallel-codex-tui --workspace /path/to/project --runs
|
|
143
|
+
parallel-codex-tui --workspace /path/to/project --runs --json
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Runs are ordered newest first. Text and JSON output include the run and Task ids, operation kind, lifecycle status, control state, timestamps, Supervisor PID, process liveness, controller PID/liveness, and whether the terminal result has been acknowledged by a TUI. Control states distinguish `starting`, `controlled`, `detached`, `settled`, and `stale`. The JSON document is versioned as `1` and intentionally excludes the original request, prompts, Worker logs, command arguments, and environment values.
|
|
147
|
+
|
|
148
|
+
Cancel the latest active run, or address one explicitly:
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
parallel-codex-tui --workspace /path/to/project --cancel-run
|
|
152
|
+
parallel-codex-tui --workspace /path/to/project --cancel-run run-20260721T000000Z-deadbeef
|
|
153
|
+
parallel-codex-tui --workspace /path/to/project --cancel-run run-20260721T000000Z-deadbeef --json
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Cancellation appends a checked command to the run's existing Supervisor command stream. It does not signal Worker PIDs directly, so the normal orchestrator cancellation, process-tree cleanup, terminal state, chat persistence, and retry evidence remain authoritative. An explicit administrative cancellation can be sent while a TUI is observing or controlling the run. Missing, stale, and already-terminal targets fail without creating a new Workspace or changing historical run evidence.
|
|
157
|
+
|
|
128
158
|
## Quick Start
|
|
129
159
|
|
|
130
160
|
Create a local config in the app root:
|
|
@@ -549,12 +579,12 @@ The release job installs npm `^11.5.1`, runs on Node `24.15.x`, publishes the pr
|
|
|
549
579
|
To publish a release, update `package.json` and `src/version.ts` to the same version, then push a matching tag:
|
|
550
580
|
|
|
551
581
|
```bash
|
|
552
|
-
VERSION=0.4.
|
|
582
|
+
VERSION=0.4.1
|
|
553
583
|
git tag "v$VERSION"
|
|
554
584
|
git push origin "v$VERSION"
|
|
555
585
|
```
|
|
556
586
|
|
|
557
|
-
You can also run the Release workflow manually and enter the same tag value. The release tag must match `package.json`; for example, package version `0.4.
|
|
587
|
+
You can also run the Release workflow manually and enter the same tag value. The release tag must match `package.json`; for example, package version `0.4.1` requires tag `v0.4.1`. Published tags such as `v0.2.10` are immutable and must not be moved or reused.
|
|
558
588
|
|
|
559
589
|
## Publishing Hygiene
|
|
560
590
|
|
package/dist/cli-args.js
CHANGED
|
@@ -2,8 +2,29 @@ import { resolve } from "node:path";
|
|
|
2
2
|
import { homedir } from "node:os";
|
|
3
3
|
import { normalizeTuiThemeName, TUI_THEME_NAMES } from "./tui/theme.js";
|
|
4
4
|
import { TaskIdSchema } from "./domain/schemas.js";
|
|
5
|
-
const allowedValueOptions = new Set([
|
|
6
|
-
|
|
5
|
+
const allowedValueOptions = new Set([
|
|
6
|
+
"--app-root",
|
|
7
|
+
"--workspace",
|
|
8
|
+
"-w",
|
|
9
|
+
"--task",
|
|
10
|
+
"-t",
|
|
11
|
+
"--theme",
|
|
12
|
+
"--diagnostics",
|
|
13
|
+
"--cancel-run"
|
|
14
|
+
]);
|
|
15
|
+
const allowedBooleanOptions = new Set([
|
|
16
|
+
"--doctor",
|
|
17
|
+
"--help",
|
|
18
|
+
"-h",
|
|
19
|
+
"--init",
|
|
20
|
+
"--json",
|
|
21
|
+
"--probe-agents",
|
|
22
|
+
"--probe-router",
|
|
23
|
+
"--runs",
|
|
24
|
+
"--themes",
|
|
25
|
+
"--version",
|
|
26
|
+
"-v"
|
|
27
|
+
]);
|
|
7
28
|
export function parseCliArgs(args, cwd) {
|
|
8
29
|
const optionArgs = argsBeforeTerminator(args);
|
|
9
30
|
const appRootFlagIndex = lastFlagIndex(optionArgs, (arg) => arg === "--app-root" || arg.startsWith("--app-root="));
|
|
@@ -11,12 +32,17 @@ export function parseCliArgs(args, cwd) {
|
|
|
11
32
|
const taskFlagIndex = lastFlagIndex(optionArgs, (arg) => arg === "--task" || arg.startsWith("--task=") || arg === "-t" || arg.startsWith("-t="));
|
|
12
33
|
const themeFlagIndex = lastFlagIndex(optionArgs, (arg) => arg === "--theme" || arg.startsWith("--theme="));
|
|
13
34
|
const diagnosticsFlagIndex = lastFlagIndex(optionArgs, (arg) => arg === "--diagnostics" || arg.startsWith("--diagnostics="));
|
|
35
|
+
const cancelRunFlagIndex = lastFlagIndex(optionArgs, (arg) => arg === "--cancel-run" || arg.startsWith("--cancel-run="));
|
|
36
|
+
const cancelRun = cancelRunFlagIndex >= 0;
|
|
37
|
+
const cancelRunId = flagValue(optionArgs, cancelRunFlagIndex);
|
|
14
38
|
const diagnostics = diagnosticsFlagIndex >= 0;
|
|
15
39
|
const doctor = optionArgs.includes("--doctor");
|
|
16
40
|
const help = optionArgs.includes("--help") || optionArgs.includes("-h");
|
|
17
41
|
const init = optionArgs.includes("--init");
|
|
42
|
+
const json = optionArgs.includes("--json");
|
|
18
43
|
const probeAgents = optionArgs.includes("--probe-agents");
|
|
19
44
|
const probeRouter = optionArgs.includes("--probe-router");
|
|
45
|
+
const runs = optionArgs.includes("--runs");
|
|
20
46
|
const themes = optionArgs.includes("--themes");
|
|
21
47
|
const version = optionArgs.includes("--version") || optionArgs.includes("-v");
|
|
22
48
|
const appRootValue = flagValue(optionArgs, appRootFlagIndex);
|
|
@@ -29,14 +55,18 @@ export function parseCliArgs(args, cwd) {
|
|
|
29
55
|
const diagnosticsPath = diagnosticsValue ? resolvePathArg(cwd, diagnosticsValue) : null;
|
|
30
56
|
return {
|
|
31
57
|
appRoot,
|
|
58
|
+
cancelRun,
|
|
59
|
+
cancelRunId,
|
|
32
60
|
diagnostics,
|
|
33
61
|
diagnosticsPath,
|
|
34
62
|
doctor,
|
|
35
63
|
explicitWorkspace,
|
|
36
64
|
help,
|
|
37
65
|
init,
|
|
66
|
+
json,
|
|
38
67
|
probeAgents,
|
|
39
68
|
probeRouter,
|
|
69
|
+
runs,
|
|
40
70
|
workspaceRoot,
|
|
41
71
|
taskId,
|
|
42
72
|
theme,
|
|
@@ -86,6 +116,19 @@ export function validateCliArgs(args) {
|
|
|
86
116
|
if (optionArgs.includes("--probe-agents") && !optionArgs.includes("--doctor")) {
|
|
87
117
|
errors.push("--probe-agents requires --doctor");
|
|
88
118
|
}
|
|
119
|
+
const runs = optionArgs.includes("--runs");
|
|
120
|
+
const cancelRunFlagIndex = lastFlagIndex(optionArgs, (arg) => arg === "--cancel-run" || arg.startsWith("--cancel-run="));
|
|
121
|
+
const cancelRun = cancelRunFlagIndex >= 0;
|
|
122
|
+
const cancelRunId = flagValue(optionArgs, cancelRunFlagIndex);
|
|
123
|
+
if (runs && cancelRun) {
|
|
124
|
+
errors.push("--runs and --cancel-run cannot be used together");
|
|
125
|
+
}
|
|
126
|
+
if (optionArgs.includes("--json") && !runs && !cancelRun) {
|
|
127
|
+
errors.push("--json requires --runs or --cancel-run");
|
|
128
|
+
}
|
|
129
|
+
if (cancelRunId && !/^run-[A-Za-z0-9._-]+$/.test(cancelRunId)) {
|
|
130
|
+
errors.push("Invalid --cancel-run: expected run- followed by letters, numbers, dot, underscore, or hyphen");
|
|
131
|
+
}
|
|
89
132
|
return errors;
|
|
90
133
|
}
|
|
91
134
|
function argsBeforeTerminator(args) {
|
package/dist/cli-help.js
CHANGED
|
@@ -11,6 +11,9 @@ Options:
|
|
|
11
11
|
--init Write .parallel-codex/config.toml if missing
|
|
12
12
|
--doctor Check config, agent commands, and theme palette preview
|
|
13
13
|
--diagnostics [dir] Export a sanitized support bundle; defaults inside the workspace
|
|
14
|
+
--runs List persisted Supervisor runs without opening the TUI
|
|
15
|
+
--cancel-run [id] Cancel a run by id, or the latest active run when omitted
|
|
16
|
+
--json Emit machine-readable output with --runs or --cancel-run
|
|
14
17
|
--probe-agents With --doctor, run fresh + resume probes (uses model quota)
|
|
15
18
|
--probe-router With --doctor, run one live Codex Router request
|
|
16
19
|
-v, --version Print the current version
|
package/dist/cli.js
CHANGED
|
@@ -28,6 +28,7 @@ import { configureTuiTheme } from "./tui/theme.js";
|
|
|
28
28
|
import { routerDiagnosticsPolicy } from "./tui/RouterDiagnosticsView.js";
|
|
29
29
|
import { version } from "./version.js";
|
|
30
30
|
import { SupervisorOrchestrator } from "./supervisor/client.js";
|
|
31
|
+
import { formatSupervisorCancellation, formatSupervisorRuns, inspectSupervisorRuns, requestSupervisorRunCancellation } from "./supervisor/operations.js";
|
|
31
32
|
import { runSupervisorJob } from "./supervisor/runner.js";
|
|
32
33
|
main().catch((error) => {
|
|
33
34
|
if (error instanceof WorkspaceSelectionCancelledError) {
|
|
@@ -99,6 +100,30 @@ async function main() {
|
|
|
99
100
|
runtime.index.close();
|
|
100
101
|
}
|
|
101
102
|
}
|
|
103
|
+
else if (cliArgs.runs || cliArgs.cancelRun) {
|
|
104
|
+
const workspaceRoot = await selectWorkspaceForCli({
|
|
105
|
+
appRoot: cliArgs.appRoot,
|
|
106
|
+
cwd: process.cwd(),
|
|
107
|
+
explicitWorkspace: cliArgs.explicitWorkspace,
|
|
108
|
+
interactive: false
|
|
109
|
+
});
|
|
110
|
+
const config = await loadConfig(cliArgs.appRoot);
|
|
111
|
+
try {
|
|
112
|
+
if (cliArgs.runs) {
|
|
113
|
+
const report = await inspectSupervisorRuns(workspaceRoot, config.dataDir);
|
|
114
|
+
console.log(cliArgs.json ? JSON.stringify(report, null, 2) : formatSupervisorRuns(report));
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
const result = await requestSupervisorRunCancellation(workspaceRoot, config.dataDir, cliArgs.cancelRunId);
|
|
118
|
+
console.log(cliArgs.json ? JSON.stringify(result, null, 2) : formatSupervisorCancellation(result));
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
catch (error) {
|
|
122
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
123
|
+
process.stderr.write(`Supervisor error: ${message}\n`);
|
|
124
|
+
process.exitCode = 1;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
102
127
|
else if (cliArgs.init) {
|
|
103
128
|
if (await pathExists(localConfigPath)) {
|
|
104
129
|
console.log(`Config already exists: ${localConfigPath}`);
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { appendSupervisorCommand, listSupervisorRuns, readSupervisorController, supervisorControllerIsActive, supervisorRunIsAcknowledged, supervisorRunIsTerminal, supervisorRunProcessIsActive } from "./store.js";
|
|
3
|
+
const QUEUED_START_GRACE_MS = 5000;
|
|
4
|
+
export async function inspectSupervisorRuns(workspaceRoot, dataDir, now = new Date()) {
|
|
5
|
+
const records = await listSupervisorRuns(workspaceRoot, dataDir);
|
|
6
|
+
const runs = await Promise.all(records.map((record) => inspectSupervisorRun(record, now)));
|
|
7
|
+
return {
|
|
8
|
+
version: 1,
|
|
9
|
+
workspace_root: workspaceRoot,
|
|
10
|
+
generated_at: now.toISOString(),
|
|
11
|
+
runs: runs.reverse()
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export async function requestSupervisorRunCancellation(workspaceRoot, dataDir, runId, now = new Date()) {
|
|
15
|
+
const records = await listSupervisorRuns(workspaceRoot, dataDir);
|
|
16
|
+
const inspected = await Promise.all(records.map(async (record) => ({
|
|
17
|
+
record,
|
|
18
|
+
view: await inspectSupervisorRun(record, now)
|
|
19
|
+
})));
|
|
20
|
+
const newestFirst = inspected.reverse();
|
|
21
|
+
const selected = runId
|
|
22
|
+
? newestFirst.find(({ view }) => view.run_id === runId)
|
|
23
|
+
: newestFirst.find(({ view }) => !isTerminalStatus(view.status) && view.control !== "stale");
|
|
24
|
+
if (!selected) {
|
|
25
|
+
if (runId) {
|
|
26
|
+
throw new Error(`Supervisor run not found: ${runId}`);
|
|
27
|
+
}
|
|
28
|
+
const stale = newestFirst.find(({ view }) => !isTerminalStatus(view.status));
|
|
29
|
+
if (stale) {
|
|
30
|
+
throw new Error(`Supervisor run is not active: ${stale.view.run_id} (${stale.view.status})`);
|
|
31
|
+
}
|
|
32
|
+
throw new Error(`No active Supervisor run in workspace ${workspaceRoot}`);
|
|
33
|
+
}
|
|
34
|
+
if (isTerminalStatus(selected.view.status)) {
|
|
35
|
+
throw new Error(`Supervisor run is already ${selected.view.status}: ${selected.view.run_id}`);
|
|
36
|
+
}
|
|
37
|
+
if (selected.view.control === "stale") {
|
|
38
|
+
throw new Error(`Supervisor run is not active: ${selected.view.run_id} (${selected.view.status})`);
|
|
39
|
+
}
|
|
40
|
+
const requestedAt = now.toISOString();
|
|
41
|
+
const commandId = randomUUID();
|
|
42
|
+
await appendSupervisorCommand(selected.record.files, {
|
|
43
|
+
version: 1,
|
|
44
|
+
id: commandId,
|
|
45
|
+
at: requestedAt,
|
|
46
|
+
type: "cancel-run"
|
|
47
|
+
});
|
|
48
|
+
return {
|
|
49
|
+
version: 1,
|
|
50
|
+
command_id: commandId,
|
|
51
|
+
requested_at: requestedAt,
|
|
52
|
+
run: selected.view
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
export function formatSupervisorRuns(report) {
|
|
56
|
+
if (report.runs.length === 0) {
|
|
57
|
+
return `No Supervisor runs in ${report.workspace_root}.`;
|
|
58
|
+
}
|
|
59
|
+
const lines = [`Supervisor runs · ${report.workspace_root}`];
|
|
60
|
+
for (const run of report.runs) {
|
|
61
|
+
const acknowledgement = run.acknowledged ? "seen" : "unread";
|
|
62
|
+
lines.push(`${run.status} · ${run.control} · ${acknowledgement} · ${run.run_id}`);
|
|
63
|
+
lines.push([
|
|
64
|
+
run.task_id ? `task ${run.task_id}` : `kind ${run.kind}`,
|
|
65
|
+
`updated ${run.updated_at}`,
|
|
66
|
+
...(run.pid ? [`pid ${run.pid}`] : [])
|
|
67
|
+
].join(" · "));
|
|
68
|
+
}
|
|
69
|
+
return lines.join("\n");
|
|
70
|
+
}
|
|
71
|
+
export function formatSupervisorCancellation(result) {
|
|
72
|
+
const target = result.run.task_id ? `task ${result.run.task_id}` : result.run.kind;
|
|
73
|
+
return `Cancellation requested · ${result.run.run_id} · ${target}`;
|
|
74
|
+
}
|
|
75
|
+
async function inspectSupervisorRun(record, now) {
|
|
76
|
+
const controller = await readSupervisorController(record.files);
|
|
77
|
+
const [processActive, controllerActive, acknowledged] = await Promise.all([
|
|
78
|
+
supervisorRunProcessIsActive(record.state),
|
|
79
|
+
controller ? supervisorControllerIsActive(controller) : Promise.resolve(false),
|
|
80
|
+
supervisorRunIsAcknowledged(record.files)
|
|
81
|
+
]);
|
|
82
|
+
return {
|
|
83
|
+
run_id: record.state.run_id,
|
|
84
|
+
kind: record.state.kind,
|
|
85
|
+
status: record.state.status,
|
|
86
|
+
control: controlState(record, processActive, controllerActive, now),
|
|
87
|
+
task_id: record.state.task_id ?? null,
|
|
88
|
+
created_at: record.state.created_at,
|
|
89
|
+
updated_at: record.state.updated_at,
|
|
90
|
+
finished_at: record.state.finished_at ?? null,
|
|
91
|
+
pid: record.state.pid ?? null,
|
|
92
|
+
process_active: processActive,
|
|
93
|
+
controller_pid: controller?.pid ?? null,
|
|
94
|
+
controller_active: controllerActive,
|
|
95
|
+
acknowledged
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
function controlState(record, processActive, controllerActive, now) {
|
|
99
|
+
if (supervisorRunIsTerminal(record.state)) {
|
|
100
|
+
return "settled";
|
|
101
|
+
}
|
|
102
|
+
if (controllerActive) {
|
|
103
|
+
return "controlled";
|
|
104
|
+
}
|
|
105
|
+
if (processActive) {
|
|
106
|
+
return "detached";
|
|
107
|
+
}
|
|
108
|
+
if (record.state.status === "queued"
|
|
109
|
+
&& now.getTime() - Date.parse(record.state.updated_at) <= QUEUED_START_GRACE_MS) {
|
|
110
|
+
return "starting";
|
|
111
|
+
}
|
|
112
|
+
return "stale";
|
|
113
|
+
}
|
|
114
|
+
function isTerminalStatus(status) {
|
|
115
|
+
return status === "completed" || status === "failed" || status === "cancelled";
|
|
116
|
+
}
|
package/dist/supervisor/store.js
CHANGED
|
@@ -91,6 +91,9 @@ export async function acknowledgeSupervisorRun(files) {
|
|
|
91
91
|
export async function supervisorRunIsAcknowledged(files) {
|
|
92
92
|
return pathExists(files.acknowledgedPath);
|
|
93
93
|
}
|
|
94
|
+
export async function readSupervisorController(files) {
|
|
95
|
+
return readValidJson(files.controllerPath, SupervisorControllerSchema);
|
|
96
|
+
}
|
|
94
97
|
export async function listSupervisorRuns(workspaceRoot, dataDir) {
|
|
95
98
|
const root = supervisorRunsRoot(workspaceRoot, dataDir);
|
|
96
99
|
if (!(await pathExists(root))) {
|
|
@@ -158,7 +161,7 @@ async function removeControllerIfOwned(path, controllerId) {
|
|
|
158
161
|
}
|
|
159
162
|
await removeIfExists(path);
|
|
160
163
|
}
|
|
161
|
-
async function supervisorControllerIsActive(controller) {
|
|
164
|
+
export async function supervisorControllerIsActive(controller) {
|
|
162
165
|
if (!processIsAlive(controller.pid)) {
|
|
163
166
|
return false;
|
|
164
167
|
}
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = "0.4.
|
|
1
|
+
export const version = "0.4.1";
|