agent-supervisor-mcp 0.0.0-stage → 2.0.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/LICENSE +21 -0
- package/README.en.md +208 -0
- package/README.md +206 -2
- package/package.json +76 -4
- package/skills/agent-supervisor/SKILL.md +139 -0
- package/src/app/acceptance.js +263 -0
- package/src/app/auto-cleanup.js +91 -0
- package/src/app/cancel.js +57 -0
- package/src/app/cleanup-facts.js +101 -0
- package/src/app/cleanup-plan.js +166 -0
- package/src/app/compose.js +17 -0
- package/src/app/context-compiler.js +83 -0
- package/src/app/dispatch.js +398 -0
- package/src/app/followup.js +104 -0
- package/src/app/land-chain.js +134 -0
- package/src/app/landing.js +357 -0
- package/src/app/ownership.js +57 -0
- package/src/app/rebase.js +216 -0
- package/src/app/restore-worktree.js +51 -0
- package/src/app/resume.js +179 -0
- package/src/app/run-state.js +26 -0
- package/src/app/settled.js +28 -0
- package/src/app/side-chat.js +370 -0
- package/src/app/sse.js +20 -0
- package/src/app/start-run.js +77 -0
- package/src/app/verify-push.js +114 -0
- package/src/app/worktree-setup.js +218 -0
- package/src/domain/acceptance-baseline.js +65 -0
- package/src/domain/acceptance-spec.js +30 -0
- package/src/domain/cleanup-policy.js +44 -0
- package/src/domain/command-outcome.js +6 -0
- package/src/domain/failure-class.js +63 -0
- package/src/domain/owned-changes.js +27 -0
- package/src/domain/prompt.js +161 -0
- package/src/domain/side-turn-view.js +73 -0
- package/src/domain/status.js +50 -0
- package/src/domain/thread-health.js +33 -0
- package/src/domain/truncate.js +148 -0
- package/src/domain/worker-branch.js +6 -0
- package/src/domain/worker-changes.js +58 -0
- package/src/domain/worker-env.js +14 -0
- package/src/domain/worker-preflight.js +167 -0
- package/src/domain/worker-report.js +85 -0
- package/src/domain/worker-report.schema.json +10 -0
- package/src/infra/bin-resolver.js +287 -0
- package/src/infra/cleanup-hint.js +29 -0
- package/src/infra/crash-guard.js +44 -0
- package/src/infra/external-output.js +29 -0
- package/src/infra/git.js +61 -0
- package/src/infra/handoff.js +38 -0
- package/src/infra/paths.js +34 -0
- package/src/infra/process.js +59 -0
- package/src/infra/sandbox-roots.js +106 -0
- package/src/infra/skill-sync.js +109 -0
- package/src/infra/stage-store.js +39 -0
- package/src/infra/store/db.js +265 -0
- package/src/infra/store/event-body.js +82 -0
- package/src/infra/store/events.js +149 -0
- package/src/infra/store/facts.js +338 -0
- package/src/infra/store/reconcile.js +173 -0
- package/src/infra/store/records.js +171 -0
- package/src/infra/store/runner-readers.js +16 -0
- package/src/infra/store/schema.js +306 -0
- package/src/infra/store/sessions.js +138 -0
- package/src/infra/store/tasks.js +351 -0
- package/src/infra/update/auto-update-worker.js +186 -0
- package/src/infra/update/auto-update.js +143 -0
- package/src/infra/update/update-check.js +246 -0
- package/src/infra/workspace-kind.js +165 -0
- package/src/infra/worktree.js +361 -0
- package/src/interface/bin/acceptance-cli.js +62 -0
- package/src/interface/bin/cleanup.js +81 -0
- package/src/interface/bin/monitor.jsx +301 -0
- package/src/interface/bin/setup.js +342 -0
- package/src/interface/bin/stage.js +17 -0
- package/src/interface/bin/web-server.js +53 -0
- package/src/interface/mcp/handlers/delivery.js +165 -0
- package/src/interface/mcp/handlers/dispatch.js +236 -0
- package/src/interface/mcp/handlers/facts.js +204 -0
- package/src/interface/mcp/handlers/overview.js +106 -0
- package/src/interface/mcp/handlers/results.js +262 -0
- package/src/interface/mcp/handlers/review.js +115 -0
- package/src/interface/mcp/handlers/wait.js +141 -0
- package/src/interface/mcp/meta.js +7 -0
- package/src/interface/mcp/result.js +34 -0
- package/src/interface/mcp/schemas.js +24 -0
- package/src/interface/mcp/server.js +64 -0
- package/src/interface/mcp/tools/deliver.js +48 -0
- package/src/interface/mcp/tools/dispatch.js +90 -0
- package/src/interface/mcp/tools/optional.js +57 -0
- package/src/interface/mcp/tools/read.js +115 -0
- package/src/interface/mcp/tools/run.js +57 -0
- package/src/interface/mcp/tools/shapes.js +67 -0
- package/src/interface/mcp/tools/track.js +84 -0
- package/src/interface/mcp/update-state.js +34 -0
- package/src/interface/mcp/views/overview.js +183 -0
- package/src/interface/mcp/views/task.js +224 -0
- package/src/interface/web/app.js +226 -0
- package/src/interface/web/views.js +227 -0
- package/src/mcp-server.js +4 -0
- package/src/run-host/entry.js +26 -0
- package/src/run-host/finalize.js +243 -0
- package/src/run-host/launch.js +49 -0
- package/src/run-host/live-run.js +76 -0
- package/src/run-host/outcome-facts.js +61 -0
- package/src/run-host/streams.js +102 -0
- package/src/run-host/track.js +132 -0
- package/src/runners/claude/adapter.js +118 -0
- package/src/runners/claude/events.js +100 -0
- package/src/runners/claude/tool-guard.js +48 -0
- package/src/runners/codex/adapter.js +157 -0
- package/src/runners/codex/chat-chunks.js +97 -0
- package/src/runners/codex/event-parser.js +266 -0
- package/src/runners/codex/goal-store.js +54 -0
- package/src/runners/codex/mcp-config.js +39 -0
- package/src/runners/codex/tool-guard.js +184 -0
- package/src/runners/contract-check.js +82 -0
- package/src/runners/contract.js +53 -0
- package/src/runners/registry.js +45 -0
- package/web/dist/assets/index-D-A2xlpx.js +154 -0
- package/web/dist/assets/index-f8esISCp.css +2 -0
- package/web/dist/index.html +15 -0
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
import { ACTIVE_STATUSES, TERMINAL_STATUSES } from "../../domain/status.js";
|
|
2
|
+
import { readPreflightResult } from "../../domain/worker-preflight.js";
|
|
3
|
+
import { runsDir } from "../paths.js";
|
|
4
|
+
import { canonicalRemoteForRoot, decodeJson, encodeJson, ensureControlRecords, ensureFilesystem, openDb, runWithRetry } from "./db.js";
|
|
5
|
+
import { readNativeGoal } from "./runner-readers.js";
|
|
6
|
+
import { TASK_COLUMNS } from "./schema.js";
|
|
7
|
+
import { randomUUID } from "node:crypto";
|
|
8
|
+
import { join, resolve } from "node:path";
|
|
9
|
+
|
|
10
|
+
export function rowToTask(row) {
|
|
11
|
+
if (!row) return null;
|
|
12
|
+
const nativeGoal = readNativeGoal(row.thread_id, row.worker);
|
|
13
|
+
return {
|
|
14
|
+
...row,
|
|
15
|
+
workspace_kind: row.workspace_kind ?? "legacy",
|
|
16
|
+
skip_git_repo_check: Boolean(row.skip_git_repo_check),
|
|
17
|
+
changed_files: decodeJson(row.changed_files, []),
|
|
18
|
+
commands: decodeJson(row.commands, []),
|
|
19
|
+
owned_paths: decodeJson(row.owned_paths, []),
|
|
20
|
+
depends_on: decodeJson(row.depends_on, []),
|
|
21
|
+
acceptance: decodeJson(row.acceptance, null),
|
|
22
|
+
acceptance_local: decodeJson(row.acceptance_local, null),
|
|
23
|
+
acceptance_results: decodeJson(row.acceptance_results, null),
|
|
24
|
+
run_evidence: decodeJson(row.run_evidence, null),
|
|
25
|
+
guard_policy: decodeJson(row.guard_policy, null),
|
|
26
|
+
input_context: decodeJson(row.input_context, null),
|
|
27
|
+
workspace_metadata: decodeJson(row.workspace_metadata, null),
|
|
28
|
+
pid: row.pid ?? null,
|
|
29
|
+
exit_code: row.exit_code ?? null,
|
|
30
|
+
phase: row.phase ?? null,
|
|
31
|
+
goal_token_budget: row.goal_token_budget ?? null,
|
|
32
|
+
goal_status: nativeGoal?.storage_status ?? row.goal_status ?? null,
|
|
33
|
+
goal_tokens_used: nativeGoal?.tokens_used ?? row.goal_tokens_used ?? null,
|
|
34
|
+
goal_time_used_seconds: nativeGoal?.time_used_seconds ?? row.goal_time_used_seconds ?? null,
|
|
35
|
+
goal_updated_at: nativeGoal?.updated_at ?? row.goal_updated_at ?? null
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function isPidAlive(pid) {
|
|
40
|
+
if (!pid) return false;
|
|
41
|
+
try {
|
|
42
|
+
process.kill(pid, 0);
|
|
43
|
+
return true;
|
|
44
|
+
} catch {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// The run host leads its own process group and the worker runs inside it. A
|
|
50
|
+
// worker CLI is often a launcher around the real binary, so the recorded pid
|
|
51
|
+
// can be gone while the binary is still writing to the session. True while
|
|
52
|
+
// anything in the group is left. Windows has no process groups.
|
|
53
|
+
export function isGroupAlive(leaderPid) {
|
|
54
|
+
if (!leaderPid || process.platform === "win32") return false;
|
|
55
|
+
try {
|
|
56
|
+
process.kill(-leaderPid, 0);
|
|
57
|
+
return true;
|
|
58
|
+
} catch (error) {
|
|
59
|
+
return error.code === "EPERM";
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export async function readTasks() {
|
|
64
|
+
await ensureFilesystem();
|
|
65
|
+
const rows = openDb().prepare("SELECT * FROM tasks ORDER BY created_at ASC").all();
|
|
66
|
+
return rows.map(rowToTask);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export async function readActiveTasks() {
|
|
70
|
+
const tasks = await readTasks();
|
|
71
|
+
return tasks.filter((task) => ACTIVE_STATUSES.has(task.status));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// A worker whose process is gone and that never wrote a terminal event is not
|
|
75
|
+
// "failed": nothing told us it failed. It is lost, and the fix is to re-run it.
|
|
76
|
+
// A row can also be active without ever having had a process: the dispatch
|
|
77
|
+
// wrote the row and then died before the spawn was recorded (one real store
|
|
78
|
+
// carried such a row for days, pid 0 and no created_at, forever "running").
|
|
79
|
+
// Only a row old enough that the dispatch cannot still be in flight is judged
|
|
80
|
+
// this way; a row with an unreadable created_at is treated as old.
|
|
81
|
+
const NEVER_STARTED_GRACE_MS = 5 * 60 * 1000;
|
|
82
|
+
|
|
83
|
+
export function neverStarted(task, now = Date.now()) {
|
|
84
|
+
if (task.pid) return false;
|
|
85
|
+
if (task.started_at) return false;
|
|
86
|
+
const created = Date.parse(task.created_at ?? "");
|
|
87
|
+
if (Number.isNaN(created)) return true;
|
|
88
|
+
return now - created > NEVER_STARTED_GRACE_MS;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export async function writeTask(task) {
|
|
92
|
+
await ensureFilesystem();
|
|
93
|
+
return runWithRetry(openDb(), () => writeTaskNow(task));
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function writeTaskNow(task, { refreshRepo = false, canonicalRemote = undefined } = {}) {
|
|
97
|
+
const placeholders = TASK_COLUMNS.map((name) => `@${name}`).join(", ");
|
|
98
|
+
const updates = TASK_COLUMNS
|
|
99
|
+
.filter((name) => name !== "id" && name !== "created_at")
|
|
100
|
+
.map((name) => `${name} = excluded.${name}`)
|
|
101
|
+
.join(",\n ");
|
|
102
|
+
const stmt = openDb().prepare(`
|
|
103
|
+
INSERT INTO tasks (${TASK_COLUMNS.join(", ")}) VALUES (${placeholders})
|
|
104
|
+
ON CONFLICT(id) DO UPDATE SET
|
|
105
|
+
${updates}
|
|
106
|
+
`);
|
|
107
|
+
|
|
108
|
+
const params = {};
|
|
109
|
+
for (const name of TASK_COLUMNS) params[name] = task[name] ?? null;
|
|
110
|
+
params.reasoning_effort = task.reasoning_effort ?? "high";
|
|
111
|
+
params.workspace_kind = task.workspace_kind ?? "legacy";
|
|
112
|
+
params.skip_git_repo_check = task.skip_git_repo_check ? 1 : 0;
|
|
113
|
+
params.changed_files = encodeJson(task.changed_files);
|
|
114
|
+
params.commands = encodeJson(task.commands);
|
|
115
|
+
params.owned_paths = encodeJson(task.owned_paths);
|
|
116
|
+
params.depends_on = encodeJson(task.depends_on);
|
|
117
|
+
// JSON columns: node:sqlite refuses to bind an array or object, and a
|
|
118
|
+
// refused bind drops the whole row update.
|
|
119
|
+
params.acceptance = task.acceptance ? JSON.stringify(task.acceptance) : null;
|
|
120
|
+
params.acceptance_local = task.acceptance_local ? JSON.stringify(task.acceptance_local) : null;
|
|
121
|
+
params.acceptance_results = task.acceptance_results ? JSON.stringify(task.acceptance_results) : null;
|
|
122
|
+
params.run_evidence = task.run_evidence ? JSON.stringify(task.run_evidence) : null;
|
|
123
|
+
params.guard_policy = task.guard_policy ? JSON.stringify(task.guard_policy) : null;
|
|
124
|
+
params.input_context = task.input_context ? JSON.stringify(task.input_context) : null;
|
|
125
|
+
params.workspace_metadata = task.workspace_metadata ? JSON.stringify(task.workspace_metadata) : null;
|
|
126
|
+
params.run_count = task.run_count ?? 0;
|
|
127
|
+
params.phase = task.phase ?? null;
|
|
128
|
+
|
|
129
|
+
stmt.run(params);
|
|
130
|
+
ensureControlRecords(openDb(), task, { refreshRepo, canonicalRemote });
|
|
131
|
+
return task;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function checkOwnership(taskId, incoming) {
|
|
135
|
+
const normalized = (value) => process.platform === "win32" ? value.replace(/\\/g, "/").toLowerCase() : value;
|
|
136
|
+
const overlaps = (left, right) => {
|
|
137
|
+
const a=normalized(left).replace(/\/$/,""),b=normalized(right).replace(/\/$/,"");
|
|
138
|
+
return a===b || a.startsWith(`${b}/`) || b.startsWith(`${a}/`);
|
|
139
|
+
};
|
|
140
|
+
const conflicts = [];
|
|
141
|
+
const pending = openDb().prepare("SELECT t.id,t.title,t.status,t.owned_paths,t.acceptance_results,t.started_at,t.exit_code,t.guard_policy,t.commands,t.attention_reason,c.owner_pid FROM tasks t LEFT JOIN run_claims c ON c.task_id=t.id WHERE t.id<>? AND (c.owner_pid IS NOT NULL OR status IN ('queued','running') OR json_extract(acceptance_results,'$.status')='running' OR (status IN ('completed','failed') AND started_at IS NOT NULL AND exit_code IS NULL AND acceptance_results IS NULL))").all(taskId);
|
|
142
|
+
for (const row of pending) {
|
|
143
|
+
const settling = decodeJson(row.acceptance_results,null)?.status === "running"
|
|
144
|
+
|| (["completed","failed"].includes(row.status) && row.started_at && row.exit_code == null && !row.acceptance_results);
|
|
145
|
+
if (row.owner_pid && !ACTIVE_STATUSES.has(row.status) && !settling && !isPidAlive(row.owner_pid)) continue;
|
|
146
|
+
const preflightTask = {
|
|
147
|
+
...row,
|
|
148
|
+
guard_policy: decodeJson(row.guard_policy, null),
|
|
149
|
+
commands: decodeJson(row.commands, [])
|
|
150
|
+
};
|
|
151
|
+
if (preflightTask.guard_policy?.preflight && readPreflightResult(preflightTask).status === "passed") continue;
|
|
152
|
+
const paths=decodeJson(row.owned_paths,[]);
|
|
153
|
+
const matching=incoming.flatMap(path=>paths.filter(other=>overlaps(path,other)).map(other=>({incoming:path,existing:other})));
|
|
154
|
+
if(matching.length)conflicts.push({task_id:row.id,title:row.title,status:row.status,overlapping_paths:matching});
|
|
155
|
+
}
|
|
156
|
+
if(conflicts.length){const error=new Error("owned_paths overlap with an active worker claimed by another dispatcher");error.code="ownership_conflict";error.conflicts=conflicts;throw error;}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export async function reserveTaskOwnership(task) {
|
|
160
|
+
await ensureFilesystem();
|
|
161
|
+
const canonicalRemote = task?.project_root ? canonicalRemoteForRoot(resolve(task.project_root)) : null;
|
|
162
|
+
const connection=openDb();
|
|
163
|
+
return runWithRetry(connection,()=>{
|
|
164
|
+
connection.exec("BEGIN IMMEDIATE");
|
|
165
|
+
try { checkOwnership(task.id,task.owned_paths??[]);writeTaskNow(task, { refreshRepo: true, canonicalRemote });connection.exec("COMMIT");return task; }
|
|
166
|
+
catch(error){connection.exec("ROLLBACK");throw error;}
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export async function upsertTask(task) {
|
|
171
|
+
await writeTask(task);
|
|
172
|
+
return task;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export async function getTask(taskId) {
|
|
176
|
+
await ensureFilesystem();
|
|
177
|
+
const row = openDb().prepare("SELECT * FROM tasks WHERE id = ?").get(taskId);
|
|
178
|
+
return rowToTask(row);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// Compare and claim under one write lock before rebase or spawning. A claim
|
|
182
|
+
// whose dispatcher died can be replaced; a different run cannot be resumed
|
|
183
|
+
// using an earlier snapshot, even when both dispatchers read it together.
|
|
184
|
+
export async function claimTaskRun(taskId, expectedRun) {
|
|
185
|
+
await ensureFilesystem();
|
|
186
|
+
const connection = openDb();
|
|
187
|
+
return runWithRetry(connection, () => {
|
|
188
|
+
connection.exec("BEGIN IMMEDIATE");
|
|
189
|
+
try {
|
|
190
|
+
const row = connection.prepare("SELECT * FROM tasks WHERE id=?").get(taskId);
|
|
191
|
+
const claim = connection.prepare("SELECT * FROM run_claims WHERE task_id=?").get(taskId);
|
|
192
|
+
const busy = !row || row.run_count !== expectedRun || ACTIVE_STATUSES.has(row.status)
|
|
193
|
+
|| (["completed", "failed"].includes(row.status) && row.exit_code == null)
|
|
194
|
+
|| decodeJson(row.acceptance_results, null)?.status === "running"
|
|
195
|
+
|| (claim && isPidAlive(claim.owner_pid));
|
|
196
|
+
let token = null;
|
|
197
|
+
if (!busy) {
|
|
198
|
+
checkOwnership(taskId,decodeJson(row.owned_paths,[]));
|
|
199
|
+
token = randomUUID();
|
|
200
|
+
connection.prepare("INSERT INTO run_claims VALUES (?,?,?) ON CONFLICT(task_id) DO UPDATE SET token=excluded.token,owner_pid=excluded.owner_pid")
|
|
201
|
+
.run(taskId, token, process.pid);
|
|
202
|
+
}
|
|
203
|
+
connection.exec("COMMIT");
|
|
204
|
+
return token;
|
|
205
|
+
} catch (error) { connection.exec("ROLLBACK"); throw error; }
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// The same lock a dispatcher takes before it runs a task, for work that needs
|
|
210
|
+
// the task to stay idle without running it (removing its worktree). Null when
|
|
211
|
+
// the task is running, settling, or held by a live dispatcher.
|
|
212
|
+
export async function claimIdleTask(taskId) {
|
|
213
|
+
await ensureFilesystem();
|
|
214
|
+
const connection = openDb();
|
|
215
|
+
return runWithRetry(connection, () => {
|
|
216
|
+
connection.exec("BEGIN IMMEDIATE");
|
|
217
|
+
try {
|
|
218
|
+
const row = connection.prepare("SELECT * FROM tasks WHERE id=?").get(taskId);
|
|
219
|
+
const claim = connection.prepare("SELECT * FROM run_claims WHERE task_id=?").get(taskId);
|
|
220
|
+
const busy = !row || ACTIVE_STATUSES.has(row.status)
|
|
221
|
+
|| (["completed", "failed"].includes(row.status) && row.exit_code == null)
|
|
222
|
+
|| decodeJson(row.acceptance_results, null)?.status === "running"
|
|
223
|
+
|| (claim && isPidAlive(claim.owner_pid));
|
|
224
|
+
let token = null;
|
|
225
|
+
if (!busy) {
|
|
226
|
+
token = randomUUID();
|
|
227
|
+
connection.prepare("INSERT INTO run_claims VALUES (?,?,?) ON CONFLICT(task_id) DO UPDATE SET token=excluded.token,owner_pid=excluded.owner_pid")
|
|
228
|
+
.run(taskId, token, process.pid);
|
|
229
|
+
}
|
|
230
|
+
connection.exec("COMMIT");
|
|
231
|
+
return token;
|
|
232
|
+
} catch (error) {
|
|
233
|
+
connection.exec("ROLLBACK");
|
|
234
|
+
throw error;
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
export async function releaseTaskRun(taskId, token) {
|
|
240
|
+
openDb().prepare("DELETE FROM run_claims WHERE task_id=? AND token=?").run(taskId, token);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
export async function readObserverCursor(observerId) {
|
|
244
|
+
await ensureFilesystem();
|
|
245
|
+
return decodeJson(openDb().prepare("SELECT cursor FROM observer_cursors WHERE id=?").get(observerId)?.cursor, {});
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export async function writeObserverCursor(observerId, cursor) {
|
|
249
|
+
await ensureFilesystem();
|
|
250
|
+
runWithRetry(openDb(), () => openDb().prepare("INSERT INTO observer_cursors VALUES (?,?,?) ON CONFLICT(id) DO UPDATE SET cursor=excluded.cursor,updated_at=excluded.updated_at")
|
|
251
|
+
.run(observerId, JSON.stringify(cursor), new Date().toISOString()));
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// Keyword search over the fields that describe what a work was for and how it
|
|
255
|
+
// ended. Substring match, newest first. Deliberately not full-text and not
|
|
256
|
+
// vector search: at this scale a LIKE scan over a few hundred rows is faster
|
|
257
|
+
// than any index would be to maintain.
|
|
258
|
+
export async function searchTasks(query, limit = 20) {
|
|
259
|
+
await ensureFilesystem();
|
|
260
|
+
const pattern = `%${String(query).trim()}%`;
|
|
261
|
+
const rows = openDb().prepare(`
|
|
262
|
+
SELECT * FROM tasks
|
|
263
|
+
WHERE title LIKE @pattern
|
|
264
|
+
OR goal_objective LIKE @pattern
|
|
265
|
+
OR prompt LIKE @pattern
|
|
266
|
+
OR last_message LIKE @pattern
|
|
267
|
+
ORDER BY created_at DESC
|
|
268
|
+
LIMIT @limit
|
|
269
|
+
`).all({ pattern, limit });
|
|
270
|
+
return rows.map(rowToTask);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
export async function readTasksBySession(sessionId) {
|
|
274
|
+
await ensureFilesystem();
|
|
275
|
+
const rows = openDb()
|
|
276
|
+
.prepare("SELECT * FROM tasks WHERE session_id = ? ORDER BY created_at ASC")
|
|
277
|
+
.all(sessionId);
|
|
278
|
+
return rows.map(rowToTask);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
// Record the files a terminal worker changed, and nothing else. The summary
|
|
282
|
+
// read used to upsert the whole row, which on a running worker put stale
|
|
283
|
+
// copies of every live field (phase, current_action, exit_code) back over
|
|
284
|
+
// what the runner had just written. A terminal row has no writer left, and
|
|
285
|
+
// even then only this one column is touched.
|
|
286
|
+
export async function recordTerminalChangedFiles(taskId, changedFiles) {
|
|
287
|
+
await ensureFilesystem();
|
|
288
|
+
const terminal = Array.from(TERMINAL_STATUSES).map((s) => `'${s}'`).join(", ");
|
|
289
|
+
const result = openDb()
|
|
290
|
+
.prepare(`UPDATE tasks SET changed_files = @files WHERE id = @id AND status IN (${terminal})`)
|
|
291
|
+
.run({ id: taskId, files: encodeJson(changedFiles) });
|
|
292
|
+
return result.changes > 0;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
export async function getTasks(taskIds) {
|
|
296
|
+
await ensureFilesystem();
|
|
297
|
+
return taskIds.map((taskId) => {
|
|
298
|
+
const row = openDb().prepare("SELECT * FROM tasks WHERE id = ?").get(taskId);
|
|
299
|
+
return rowToTask(row);
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
export function taskRunPath(taskId) {
|
|
304
|
+
return join(runsDir, `${taskId}.jsonl`);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
export async function taskCount() {
|
|
308
|
+
await ensureFilesystem();
|
|
309
|
+
const row = openDb().prepare("SELECT COUNT(*) AS count FROM tasks").get();
|
|
310
|
+
return row.count;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
export async function taskExists(taskId) {
|
|
314
|
+
return Boolean(await getTask(taskId));
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
export async function taskHasEvents(taskId) {
|
|
318
|
+
await ensureFilesystem();
|
|
319
|
+
const row = openDb().prepare("SELECT 1 FROM task_events WHERE task_id = ? LIMIT 1").get(taskId);
|
|
320
|
+
return Boolean(row);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
export async function taskEventCount(taskId) {
|
|
324
|
+
await ensureFilesystem();
|
|
325
|
+
const row = openDb().prepare("SELECT COUNT(*) AS count FROM task_events WHERE task_id = ?").get(taskId);
|
|
326
|
+
return row.count;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
export async function deleteTasks(taskIds) {
|
|
330
|
+
await ensureFilesystem();
|
|
331
|
+
if (taskIds.length === 0) return;
|
|
332
|
+
const dbInstance = openDb();
|
|
333
|
+
const deleteEvents = dbInstance.prepare("DELETE FROM task_events WHERE task_id = ?");
|
|
334
|
+
const deleteTask = dbInstance.prepare("DELETE FROM tasks WHERE id = ?");
|
|
335
|
+
dbInstance.exec("BEGIN IMMEDIATE;");
|
|
336
|
+
try {
|
|
337
|
+
for (const taskId of taskIds) {
|
|
338
|
+
deleteEvents.run(taskId);
|
|
339
|
+
deleteTask.run(taskId);
|
|
340
|
+
}
|
|
341
|
+
dbInstance.exec("COMMIT;");
|
|
342
|
+
} catch (error) {
|
|
343
|
+
dbInstance.exec("ROLLBACK;");
|
|
344
|
+
throw error;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
export async function vacuumStore() {
|
|
349
|
+
await ensureFilesystem();
|
|
350
|
+
openDb().exec("VACUUM;");
|
|
351
|
+
}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// The detached half of auto-update.js. Runs outside the MCP process so a
|
|
3
|
+
// session that ends mid-install does not leave npm half way through.
|
|
4
|
+
//
|
|
5
|
+
// node auto-update-worker.js --version 0.7.0 --package-root <dir> [--registry <url>]
|
|
6
|
+
//
|
|
7
|
+
// Writes data/auto-update.json at every step so the server (and a human)
|
|
8
|
+
// can see what happened without a terminal: running -> done | failed | skipped.
|
|
9
|
+
import { runFile } from "../process.js";
|
|
10
|
+
import { existsSync, readFileSync, realpathSync } from "node:fs";
|
|
11
|
+
import { mkdir, open, readFile, rm, writeFile } from "node:fs/promises";
|
|
12
|
+
import { dirname, join } from "node:path";
|
|
13
|
+
import { promisify } from "node:util";
|
|
14
|
+
import { dataDir } from "../paths.js";
|
|
15
|
+
import { resolveCommand } from "../bin-resolver.js";
|
|
16
|
+
|
|
17
|
+
const run = promisify(runFile);
|
|
18
|
+
const PACKAGE_NAME = "agent-supervisor-mcp";
|
|
19
|
+
const statePath = join(dataDir, "auto-update.json");
|
|
20
|
+
const lockPath = join(dataDir, "auto-update.lock");
|
|
21
|
+
const LOCK_STALE_MS = 10 * 60 * 1000;
|
|
22
|
+
const NPM_TIMEOUT_MS = 10 * 60 * 1000;
|
|
23
|
+
|
|
24
|
+
function parseArgs(argv) {
|
|
25
|
+
const options = { version: null, packageRoot: null, registry: null };
|
|
26
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
27
|
+
const arg = argv[index];
|
|
28
|
+
if (arg === "--version") options.version = argv[++index];
|
|
29
|
+
else if (arg === "--package-root") options.packageRoot = argv[++index];
|
|
30
|
+
else if (arg === "--registry") options.registry = argv[++index];
|
|
31
|
+
else throw new Error(`Unknown argument: ${arg}`);
|
|
32
|
+
}
|
|
33
|
+
if (!options.version || !options.packageRoot) throw new Error("--version and --package-root are required");
|
|
34
|
+
return options;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async function writeState(patch) {
|
|
38
|
+
await mkdir(dataDir, { recursive: true });
|
|
39
|
+
let current = {};
|
|
40
|
+
try {
|
|
41
|
+
current = JSON.parse(await readFile(statePath, "utf8"));
|
|
42
|
+
} catch {
|
|
43
|
+
// first write
|
|
44
|
+
}
|
|
45
|
+
const next = { ...current, ...patch, updated_at: new Date().toISOString() };
|
|
46
|
+
await writeFile(statePath, JSON.stringify(next, null, 2));
|
|
47
|
+
return next;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function alive(pid) {
|
|
51
|
+
try {
|
|
52
|
+
process.kill(pid, 0);
|
|
53
|
+
return true;
|
|
54
|
+
} catch (error) {
|
|
55
|
+
return error.code === "EPERM";
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// One updater at a time. A lock whose process is gone, or that is older
|
|
60
|
+
// than LOCK_STALE_MS, is taken over.
|
|
61
|
+
async function acquireLock() {
|
|
62
|
+
await mkdir(dataDir, { recursive: true });
|
|
63
|
+
for (let attempt = 0; attempt < 2; attempt += 1) {
|
|
64
|
+
try {
|
|
65
|
+
const handle = await open(lockPath, "wx");
|
|
66
|
+
await handle.writeFile(JSON.stringify({ pid: process.pid, at: Date.now() }));
|
|
67
|
+
await handle.close();
|
|
68
|
+
return true;
|
|
69
|
+
} catch (error) {
|
|
70
|
+
if (error.code !== "EEXIST") throw error;
|
|
71
|
+
let holder = null;
|
|
72
|
+
try {
|
|
73
|
+
holder = JSON.parse(await readFile(lockPath, "utf8"));
|
|
74
|
+
} catch {
|
|
75
|
+
// unreadable lock counts as stale
|
|
76
|
+
}
|
|
77
|
+
const stale = !holder || !alive(holder.pid) || Date.now() - (holder.at ?? 0) > LOCK_STALE_MS;
|
|
78
|
+
if (!stale) return false;
|
|
79
|
+
await rm(lockPath, { force: true });
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// npm as `node npm-cli.js`: steps over the npm.cmd shim on Windows and uses
|
|
86
|
+
// the npm that belongs to the node running this server. AGENT_SUPERVISOR_NPM
|
|
87
|
+
// points at another npm-cli.js (or any executable) when that is wrong.
|
|
88
|
+
function npmCommand() {
|
|
89
|
+
const override = process.env.AGENT_SUPERVISOR_NPM?.trim();
|
|
90
|
+
if (override) {
|
|
91
|
+
const target = resolveCommand(override);
|
|
92
|
+
return [target.cmd, ...target.prefixArgs];
|
|
93
|
+
}
|
|
94
|
+
const nodeDir = dirname(process.execPath);
|
|
95
|
+
const candidates = [
|
|
96
|
+
join(nodeDir, "..", "lib", "node_modules", "npm", "bin", "npm-cli.js"),
|
|
97
|
+
join(nodeDir, "node_modules", "npm", "bin", "npm-cli.js")
|
|
98
|
+
];
|
|
99
|
+
const found = candidates.find((candidate) => existsSync(candidate));
|
|
100
|
+
if (found) return [process.execPath, found];
|
|
101
|
+
const target = resolveCommand("npm", { npmEntry: { pkg: "npm", bin: "bin/npm-cli.js" } });
|
|
102
|
+
return [target.cmd, ...target.prefixArgs];
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
async function npm(args, { registry, timeout = NPM_TIMEOUT_MS } = {}) {
|
|
106
|
+
const [cmd, ...prefix] = npmCommand();
|
|
107
|
+
const full = [...prefix, ...args, "--no-fund", "--no-audit", "--loglevel=error"];
|
|
108
|
+
if (registry) full.push(`--registry=${registry}`);
|
|
109
|
+
const env = { ...process.env, AGENT_SUPERVISOR_NO_AUTO_UPDATE: "1" };
|
|
110
|
+
return run(cmd, full, { timeout, env, maxBuffer: 4 * 1024 * 1024, windowsHide: true });
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function samePath(a, b) {
|
|
114
|
+
try {
|
|
115
|
+
return realpathSync(a) === realpathSync(b);
|
|
116
|
+
} catch {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
async function main() {
|
|
122
|
+
const options = parseArgs(process.argv.slice(2));
|
|
123
|
+
const stamp = { version: options.version, pid: process.pid, started_at: new Date().toISOString() };
|
|
124
|
+
|
|
125
|
+
if (!(await acquireLock())) {
|
|
126
|
+
console.log(`auto-update: another updater holds ${lockPath}; leaving it to that one`);
|
|
127
|
+
return 0;
|
|
128
|
+
}
|
|
129
|
+
try {
|
|
130
|
+
await writeState({ ...stamp, state: "running", reason: null, installed_path: null, exit_code: null, log: null });
|
|
131
|
+
|
|
132
|
+
const { stdout: rootOut } = await npm(["root", "-g"], { registry: options.registry, timeout: 60_000 });
|
|
133
|
+
const globalRoot = rootOut.trim();
|
|
134
|
+
const expected = join(globalRoot, PACKAGE_NAME);
|
|
135
|
+
if (!samePath(expected, options.packageRoot)) {
|
|
136
|
+
await writeState({
|
|
137
|
+
state: "skipped",
|
|
138
|
+
reason: `the running copy (${options.packageRoot}) is not npm's global install (${expected}); nothing was changed`
|
|
139
|
+
});
|
|
140
|
+
return 0;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
let output = "";
|
|
144
|
+
try {
|
|
145
|
+
const result = await npm(["install", "-g", `${PACKAGE_NAME}@${options.version}`], { registry: options.registry });
|
|
146
|
+
output = `${result.stdout}${result.stderr}`;
|
|
147
|
+
} catch (error) {
|
|
148
|
+
const tail = `${error.stdout ?? ""}${error.stderr ?? ""}`.trim().split("\n").slice(-12).join("\n");
|
|
149
|
+
await writeState({ state: "failed", reason: `npm install exited ${error.code ?? "?"}`, exit_code: error.code ?? null, log: tail });
|
|
150
|
+
return 1;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
let installed = null;
|
|
154
|
+
try {
|
|
155
|
+
installed = JSON.parse(readFileSync(join(expected, "package.json"), "utf8")).version;
|
|
156
|
+
} catch {
|
|
157
|
+
// verified below
|
|
158
|
+
}
|
|
159
|
+
if (installed !== options.version) {
|
|
160
|
+
await writeState({
|
|
161
|
+
state: "failed",
|
|
162
|
+
reason: `npm reported success but ${expected} holds ${installed ?? "nothing"}, not ${options.version}`,
|
|
163
|
+
exit_code: 0,
|
|
164
|
+
log: output.trim().split("\n").slice(-12).join("\n")
|
|
165
|
+
});
|
|
166
|
+
return 1;
|
|
167
|
+
}
|
|
168
|
+
await writeState({ state: "done", reason: null, installed_path: expected, exit_code: 0, finished_at: new Date().toISOString() });
|
|
169
|
+
console.log(`auto-update: installed ${PACKAGE_NAME}@${options.version} at ${expected}`);
|
|
170
|
+
return 0;
|
|
171
|
+
} finally {
|
|
172
|
+
await rm(lockPath, { force: true });
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
try {
|
|
177
|
+
process.exitCode = await main();
|
|
178
|
+
} catch (error) {
|
|
179
|
+
try {
|
|
180
|
+
await writeState({ state: "failed", reason: error.message });
|
|
181
|
+
} catch {
|
|
182
|
+
// nothing left to record to
|
|
183
|
+
}
|
|
184
|
+
console.error(`auto-update: ${error.message}`);
|
|
185
|
+
process.exitCode = 1;
|
|
186
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
// Keeps a global npm install current without anyone typing `npm i -g`.
|
|
2
|
+
//
|
|
3
|
+
// The server never blocks on this. When the update check says a newer
|
|
4
|
+
// version is published, a detached worker process (auto-update-worker.js)
|
|
5
|
+
// runs `npm install -g agent-supervisor-mcp@<that version>` and writes what
|
|
6
|
+
// happened to data/auto-update.json. The running server keeps its own
|
|
7
|
+
// already-loaded code; the next MCP session starts on the new files. This is
|
|
8
|
+
// the same shape as Claude Code's and opencode's updaters: check in the
|
|
9
|
+
// background, install in the background, take effect on the next launch.
|
|
10
|
+
//
|
|
11
|
+
// It only ever touches a copy that npm installed globally. A git checkout,
|
|
12
|
+
// an `npm link`, a project-local dependency and an npx cache copy are left
|
|
13
|
+
// alone, and the worker double-checks against `npm root -g` before writing.
|
|
14
|
+
import { spawnProcess } from "../process.js";
|
|
15
|
+
import { closeSync, openSync } from "node:fs";
|
|
16
|
+
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
17
|
+
import { dirname, join } from "node:path";
|
|
18
|
+
import { fileURLToPath } from "node:url";
|
|
19
|
+
import { dataDir } from "../paths.js";
|
|
20
|
+
|
|
21
|
+
export const statePath = join(dataDir, "auto-update.json");
|
|
22
|
+
export const lockPath = join(dataDir, "auto-update.lock");
|
|
23
|
+
export const logPath = join(dataDir, "auto-update.log");
|
|
24
|
+
const workerEntry = join(dirname(fileURLToPath(import.meta.url)), "auto-update-worker.js");
|
|
25
|
+
|
|
26
|
+
export function autoUpdateDisabled(env = process.env) {
|
|
27
|
+
return /^(1|true|yes)$/i.test(env.AGENT_SUPERVISOR_NO_AUTO_UPDATE?.trim() ?? "");
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Pure. The reason not to install, or null when an install should start.
|
|
31
|
+
export function autoUpdateBlocker(update, env = process.env) {
|
|
32
|
+
if (!update) return "no update check result yet";
|
|
33
|
+
if (autoUpdateDisabled(env)) return "disabled by AGENT_SUPERVISOR_NO_AUTO_UPDATE";
|
|
34
|
+
if (env.CI) return "CI environment";
|
|
35
|
+
if (update.disabled) return "update check is disabled";
|
|
36
|
+
if (!update.update_available) return "already current";
|
|
37
|
+
if (!update.latest?.version) return "registry gave no version";
|
|
38
|
+
const source = update.installed?.source;
|
|
39
|
+
if (source === "npx") return "started through npx, which fetches the latest version itself";
|
|
40
|
+
if (source !== "npm") return `installed from ${source ?? "an unknown source"}, not a global npm install`;
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export async function readAutoUpdateState() {
|
|
45
|
+
try {
|
|
46
|
+
return JSON.parse(await readFile(statePath, "utf8"));
|
|
47
|
+
} catch {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function processAlive(pid) {
|
|
53
|
+
if (!pid) return false;
|
|
54
|
+
try {
|
|
55
|
+
process.kill(pid, 0);
|
|
56
|
+
return true;
|
|
57
|
+
} catch (error) {
|
|
58
|
+
return error.code === "EPERM";
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Launches the detached worker. Its stdio goes to a log file, not to the MCP
|
|
63
|
+
// transport: anything the updater prints on stdout would corrupt the protocol
|
|
64
|
+
// stream.
|
|
65
|
+
async function launchWorker({ version, packageRoot, registry }) {
|
|
66
|
+
await mkdir(dataDir, { recursive: true });
|
|
67
|
+
const args = [workerEntry, "--version", version, "--package-root", packageRoot];
|
|
68
|
+
if (registry) args.push("--registry", registry);
|
|
69
|
+
const log = openSync(logPath, "a");
|
|
70
|
+
try {
|
|
71
|
+
const child = spawnProcess(process.execPath, args, {
|
|
72
|
+
detached: true,
|
|
73
|
+
stdio: ["ignore", log, log],
|
|
74
|
+
env: { ...process.env, AGENT_SUPERVISOR_NO_AUTO_UPDATE: "1" },
|
|
75
|
+
windowsHide: true
|
|
76
|
+
});
|
|
77
|
+
child.unref();
|
|
78
|
+
return child.pid;
|
|
79
|
+
} finally {
|
|
80
|
+
closeSync(log);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Decides and, at most once per published version, starts the install.
|
|
85
|
+
// Returns the auto-update record to show in tool results:
|
|
86
|
+
// { state: "started" | "running" | "done" | "failed" | "skipped", version, reason?, ... }
|
|
87
|
+
//
|
|
88
|
+
// Calls are serialised: the startup check and a forced check_for_update can
|
|
89
|
+
// finish in the same tick, and the second must see the record the first
|
|
90
|
+
// wrote rather than launch a worker of its own.
|
|
91
|
+
let queue = Promise.resolve();
|
|
92
|
+
export function maybeAutoUpdate(update, options = {}) {
|
|
93
|
+
const next = queue.then(() => decide(update, options));
|
|
94
|
+
queue = next.catch(() => {});
|
|
95
|
+
return next;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
async function decide(update, { env = process.env, launch = launchWorker } = {}) {
|
|
99
|
+
const blocker = autoUpdateBlocker(update, env);
|
|
100
|
+
if (blocker) return { state: "skipped", version: update?.latest?.version ?? null, reason: blocker };
|
|
101
|
+
|
|
102
|
+
const version = update.latest.version;
|
|
103
|
+
const prior = await readAutoUpdateState();
|
|
104
|
+
const inFlight = prior && ["started", "running"].includes(prior.state) && processAlive(prior.pid);
|
|
105
|
+
if (prior && prior.version === version) {
|
|
106
|
+
// One attempt per published version: a finished record stands, a live
|
|
107
|
+
// worker is left alone, a worker that died without a verdict gets one retry
|
|
108
|
+
// per check.
|
|
109
|
+
if (inFlight || ["done", "failed", "skipped"].includes(prior.state)) return prior;
|
|
110
|
+
} else if (inFlight) {
|
|
111
|
+
return { ...prior, reason: `an updater for ${prior.version} is still running` };
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
let record;
|
|
115
|
+
try {
|
|
116
|
+
const pid = await launch({
|
|
117
|
+
version,
|
|
118
|
+
packageRoot: update.installed.path,
|
|
119
|
+
registry: env.AGENT_SUPERVISOR_REGISTRY?.trim() || null
|
|
120
|
+
});
|
|
121
|
+
record = { state: "started", version, pid, started_at: new Date().toISOString() };
|
|
122
|
+
} catch (error) {
|
|
123
|
+
record = { state: "failed", version, reason: `could not start the updater: ${error.message}` };
|
|
124
|
+
}
|
|
125
|
+
// Recorded by the server too, so ten servers starting together do not each
|
|
126
|
+
// launch a worker (the worker's lock is the second line of defence).
|
|
127
|
+
try {
|
|
128
|
+
await mkdir(dataDir, { recursive: true });
|
|
129
|
+
await writeFile(statePath, JSON.stringify({ ...record, updated_at: record.started_at ?? new Date().toISOString() }, null, 2));
|
|
130
|
+
} catch {
|
|
131
|
+
// the worker rewrites it anyway
|
|
132
|
+
}
|
|
133
|
+
return record;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// What a tool result says about it. Null when there is nothing worth a line.
|
|
137
|
+
export function autoUpdateSummary(record) {
|
|
138
|
+
if (!record || record.state === "skipped") return null;
|
|
139
|
+
const base = { state: record.state, version: record.version };
|
|
140
|
+
if (record.reason) base.reason = record.reason;
|
|
141
|
+
if (record.state === "done") base.installed_path = record.installed_path ?? null;
|
|
142
|
+
return base;
|
|
143
|
+
}
|