tryharness 0.7.53 → 0.7.54
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 +10 -5
- package/assets/dsh-plugin.mjs +72 -0
- package/assets/opencode-plugin.js +4 -3
- package/cli.mjs +115 -36
- package/lib/adapters.mjs +157 -222
- package/lib/agentRuntimes.mjs +26 -16
- package/lib/agentSignIn.mjs +226 -0
- package/lib/audit.mjs +643 -0
- package/lib/backupSetup.mjs +141 -0
- package/lib/boardAccess.mjs +8 -1
- package/lib/boardBackup.mjs +283 -0
- package/lib/boardMirror.mjs +71 -7
- package/lib/boardProtocol.json +59 -2
- package/lib/boardWaits.mjs +102 -0
- package/lib/book.mjs +659 -0
- package/lib/bridge.mjs +1 -1
- package/lib/cards.mjs +138 -28
- package/lib/cloudBoot.mjs +124 -0
- package/lib/commands.mjs +7 -2
- package/lib/context.mjs +18 -4
- package/lib/contractGate.mjs +377 -0
- package/lib/coordinator.mjs +149 -43
- package/lib/daemon.mjs +349 -28
- package/lib/desk.mjs +239 -0
- package/lib/desktop.mjs +106 -6
- package/lib/environments.mjs +237 -7
- package/lib/folders.mjs +2 -2
- package/lib/gitHost.mjs +174 -0
- package/lib/hookDialects.mjs +298 -0
- package/lib/landed.mjs +887 -0
- package/lib/live.mjs +284 -13
- package/lib/mcp-stdio.mjs +68 -2
- package/lib/members.json +16 -2
- package/lib/models.mjs +8 -8
- package/lib/museSession.mjs +16 -13
- package/lib/nativeHost.mjs +1 -1
- package/lib/neovim.mjs +126 -0
- package/lib/nudge.mjs +47 -16
- package/lib/ownMachines.mjs +343 -39
- package/lib/pairing.mjs +27 -10
- package/lib/paths.mjs +4 -0
- package/lib/personModel.mjs +89 -0
- package/lib/phones.mjs +66 -11
- package/lib/places.mjs +330 -10
- package/lib/readiness.mjs +135 -18
- package/lib/record.mjs +115 -0
- package/lib/runWorker.mjs +17 -2
- package/lib/runner.mjs +8 -4
- package/lib/sessionControl.mjs +377 -89
- package/lib/specialties.json +74 -0
- package/lib/specialties.mjs +477 -0
- package/lib/specialtyKeys.d.ts +3 -0
- package/lib/specialtyKeys.js +58 -0
- package/lib/specialtyNotice.mjs +147 -0
- package/lib/specialtySnapshot.mjs +138 -0
- package/lib/store.mjs +284 -1
- package/lib/swarm.mjs +137 -21
- package/lib/t3.mjs +13 -4
- package/lib/taskCommands.mjs +36 -9
- package/lib/taskRuns.mjs +9 -2
- package/lib/team.json +255 -148
- package/lib/team.mjs +529 -188
- package/lib/threadLine.mjs +116 -0
- package/lib/threadRuns.mjs +75 -11
- package/lib/threadView.mjs +15 -2
- package/lib/worktrees.mjs +51 -13
- package/package.json +4 -4
- package/lib/modelTiers.json +0 -1183
- package/lib/modelTiers.mjs +0 -133
package/lib/readiness.mjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
2
3
|
import fs from "node:fs";
|
|
3
4
|
import path from "node:path";
|
|
4
|
-
import {
|
|
5
|
+
import { runProtocolTask } from "./agentRuntimes.mjs";
|
|
6
|
+
import { MACHINE_RUNNERS, member, nameOf } from "./members.mjs";
|
|
5
7
|
import { paths } from "./paths.mjs";
|
|
6
8
|
import { ensureDir, readJson, writeJsonAtomic } from "./files.mjs";
|
|
7
9
|
|
|
@@ -61,8 +63,16 @@ const CHECKS = {
|
|
|
61
63
|
}),
|
|
62
64
|
};
|
|
63
65
|
|
|
66
|
+
// An agent Harness runs through its own protocol (ACP, or Muse Code's MSP: `runtime` in members.json, and the person's
|
|
67
|
+
// own ACP agents) takes the same prompt the way it takes work (agentRuntimes.mjs), without Harness's tools. Its session
|
|
68
|
+
// can stay in the agent's own history: neither protocol has a switch to keep one out.
|
|
69
|
+
const byProtocol = (agent) => !CHECKS[agent] && Boolean(member(agent)?.runtime);
|
|
70
|
+
|
|
64
71
|
/** The agents Harness can check by sending them a prompt. */
|
|
65
|
-
export const CHECKABLE =
|
|
72
|
+
export const CHECKABLE = [
|
|
73
|
+
...Object.keys(CHECKS),
|
|
74
|
+
...MACHINE_RUNNERS.filter(byProtocol),
|
|
75
|
+
];
|
|
66
76
|
|
|
67
77
|
/** What the person runs to sign an agent in, as setup and the browser say it. */
|
|
68
78
|
export const SIGN_IN = {
|
|
@@ -73,8 +83,10 @@ export const SIGN_IN = {
|
|
|
73
83
|
};
|
|
74
84
|
|
|
75
85
|
// The words each agent prints when it has no sign-in to use: a missing login, a missing key, or a 401 from its provider.
|
|
86
|
+
// Over ACP and MSP: "Authentication required" (auth_required), Muse Code's authRequired, and Cursor's stale login, which
|
|
87
|
+
// it answers as ordinary text ("Please sign in to continue"; Cursor staff, June 2026).
|
|
76
88
|
const SIGNED_OUT =
|
|
77
|
-
/not logged in|please run \/login|use \/login|no api key|api key not found|missing bearer|401|unauthori[sz]ed|invalid api key|authentication/i;
|
|
89
|
+
/not logged in|please run \/login|use \/login|no api key|api key not found|missing bearer|401|unauthori[sz]ed|invalid api key|authentication|auth[ _-]?required|please sign in|sign in to continue/i;
|
|
78
90
|
|
|
79
91
|
const lastLine = (text) =>
|
|
80
92
|
String(text)
|
|
@@ -104,9 +116,12 @@ export function checkAgent(
|
|
|
104
116
|
{
|
|
105
117
|
cwd = path.join(paths.home, "checks"),
|
|
106
118
|
run = spawn,
|
|
119
|
+
runTask = runProtocolTask,
|
|
107
120
|
deadlineMs = CHECK_DEADLINE_MS,
|
|
108
121
|
} = {}
|
|
109
122
|
) {
|
|
123
|
+
if (byProtocol(agent))
|
|
124
|
+
return checkByProtocol(agent, { cwd, runTask, deadlineMs });
|
|
110
125
|
const invocation = CHECKS[agent]?.();
|
|
111
126
|
if (!invocation)
|
|
112
127
|
return Promise.resolve({
|
|
@@ -150,6 +165,59 @@ export function checkAgent(
|
|
|
150
165
|
});
|
|
151
166
|
}
|
|
152
167
|
|
|
168
|
+
async function checkByProtocol(agent, { cwd, runTask, deadlineMs }) {
|
|
169
|
+
ensureDir(cwd);
|
|
170
|
+
const started = Date.now();
|
|
171
|
+
const stop = new AbortController();
|
|
172
|
+
let timedOut = false;
|
|
173
|
+
const timer = setTimeout(() => {
|
|
174
|
+
timedOut = true;
|
|
175
|
+
stop.abort();
|
|
176
|
+
}, deadlineMs);
|
|
177
|
+
let answer = null;
|
|
178
|
+
let failure = null;
|
|
179
|
+
try {
|
|
180
|
+
await runTask(
|
|
181
|
+
{
|
|
182
|
+
agent,
|
|
183
|
+
cwd,
|
|
184
|
+
brief: PROMPT,
|
|
185
|
+
title: "Harness check",
|
|
186
|
+
runId: "readiness",
|
|
187
|
+
withoutHarnessTools: true,
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
emit: (kind, text) => {
|
|
191
|
+
if (kind === "done") answer = text;
|
|
192
|
+
if (kind === "failed") failure = text;
|
|
193
|
+
},
|
|
194
|
+
observe: () => {},
|
|
195
|
+
signal: stop.signal,
|
|
196
|
+
}
|
|
197
|
+
);
|
|
198
|
+
} catch (error) {
|
|
199
|
+
failure = error.message;
|
|
200
|
+
} finally {
|
|
201
|
+
clearTimeout(timer);
|
|
202
|
+
}
|
|
203
|
+
// What agentRuntimes.mjs says when the agent's command is not on this computer.
|
|
204
|
+
const missing =
|
|
205
|
+
answer === null && /^Install and authenticate/.test(failure ?? "");
|
|
206
|
+
return {
|
|
207
|
+
...readCheck({
|
|
208
|
+
code: answer === null ? 1 : 0,
|
|
209
|
+
output: answer ?? failure ?? "",
|
|
210
|
+
timedOut,
|
|
211
|
+
missing,
|
|
212
|
+
}),
|
|
213
|
+
ms: Date.now() - started,
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// An agent signed in where Harness cannot see joins within a quarter of an hour, at the cost of starting a signed-out
|
|
218
|
+
// agent four times an hour.
|
|
219
|
+
export const RECHECK_MS = 15 * 60_000;
|
|
220
|
+
|
|
153
221
|
/**
|
|
154
222
|
* The daemon's record of each agent's last check, kept in a file so setup, the CLI and the browser read the same answer.
|
|
155
223
|
* Each record keeps a stamp of the agent's sign-in files at the time, so a later sign-in is noticed. Two checks of one
|
|
@@ -159,6 +227,8 @@ export function createAgentReadiness({
|
|
|
159
227
|
file = path.join(paths.home, "agent-readiness.json"),
|
|
160
228
|
check = checkAgent,
|
|
161
229
|
stampOf = (agent) => signInStamp(agent),
|
|
230
|
+
watchesSignIn = (agent) =>
|
|
231
|
+
signInFiles(agent, process.env.HOME, process.env).length > 0,
|
|
162
232
|
onChange = () => {},
|
|
163
233
|
now = () => new Date(),
|
|
164
234
|
} = {}) {
|
|
@@ -187,11 +257,24 @@ export function createAgentReadiness({
|
|
|
187
257
|
};
|
|
188
258
|
/** Whether the agent's sign-in files changed since its last check (or it was never checked). */
|
|
189
259
|
const signInChanged = (agent) => of(agent)?.signIn !== stampOf(agent);
|
|
260
|
+
// An agent whose sign-in Harness cannot see (in the keychain, or the person's own ACP agent) is checked again while
|
|
261
|
+
// it is signed out, at most every RECHECK_MS, so signing it in later is noticed. A signed-out check stops before any
|
|
262
|
+
// model is asked, so it costs no tokens.
|
|
263
|
+
const signedOutSince = (agent) => {
|
|
264
|
+
const last = of(agent);
|
|
265
|
+
return last?.state === "signed_out" && !watchesSignIn(agent)
|
|
266
|
+
? now() - new Date(last.checkedAt)
|
|
267
|
+
: -1;
|
|
268
|
+
};
|
|
269
|
+
/** Whether the agent should be checked now: its sign-in changed, or it is signed out where Harness cannot see. */
|
|
270
|
+
const due = (agent) =>
|
|
271
|
+
signInChanged(agent) || signedOutSince(agent) >= RECHECK_MS;
|
|
190
272
|
return {
|
|
191
273
|
check: run,
|
|
192
274
|
of,
|
|
193
275
|
all,
|
|
194
276
|
signInChanged,
|
|
277
|
+
due,
|
|
195
278
|
checking: (agent) => running.has(agent),
|
|
196
279
|
};
|
|
197
280
|
}
|
|
@@ -201,10 +284,7 @@ function signInFiles(agent, home, env) {
|
|
|
201
284
|
const dataHome = env.XDG_DATA_HOME || path.join(home, ".local", "share");
|
|
202
285
|
switch (agent) {
|
|
203
286
|
case "claude-code":
|
|
204
|
-
return [
|
|
205
|
-
path.join(home, ".claude.json"),
|
|
206
|
-
path.join(home, ".claude", ".credentials.json"),
|
|
207
|
-
];
|
|
287
|
+
return [path.join(home, ".claude", ".credentials.json")];
|
|
208
288
|
case "codex":
|
|
209
289
|
return [
|
|
210
290
|
path.join(env.CODEX_HOME || path.join(home, ".codex"), "auth.json"),
|
|
@@ -213,20 +293,57 @@ function signInFiles(agent, home, env) {
|
|
|
213
293
|
return [path.join(home, ".pi", "agent", "auth.json")];
|
|
214
294
|
case "opencode":
|
|
215
295
|
return [path.join(dataHome, "opencode", "auth.json")];
|
|
296
|
+
// Also rewritten when Grok refreshes its token, as Codex's is (xai-org/grok-build, xai-grok-login/src/storage.rs).
|
|
297
|
+
case "grok-build":
|
|
298
|
+
return [
|
|
299
|
+
env.GROK_AUTH_PATH ||
|
|
300
|
+
path.join(env.GROK_HOME || path.join(home, ".grok"), "auth.json"),
|
|
301
|
+
];
|
|
302
|
+
case "kilo":
|
|
303
|
+
return [path.join(dataHome, "kilo", "auth.json")];
|
|
304
|
+
case "dsh":
|
|
305
|
+
return [
|
|
306
|
+
path.join(env.DSH_HOME || path.join(home, ".dsh"), ".credentials.yaml"),
|
|
307
|
+
];
|
|
308
|
+
// Devin's token, which does not expire (its auth docs).
|
|
309
|
+
case "devin":
|
|
310
|
+
return [path.join(dataHome, "devin", "credentials.toml")];
|
|
311
|
+
// Cursor, Antigravity, Copilot and Muse Code keep their sign-in in the macOS keychain, with no file that changes
|
|
312
|
+
// only then.
|
|
216
313
|
default:
|
|
217
314
|
return [];
|
|
218
315
|
}
|
|
219
316
|
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
}
|
|
229
|
-
|
|
317
|
+
// Claude Code rewrites ~/.claude.json in every session, its own check included, so the file's time changed every minute
|
|
318
|
+
// and the daemon checked Claude Code once a minute (October 23: 60 checks an hour, each a session counted where Claude
|
|
319
|
+
// Code lives). Only the account in it says a sign-in changed; on a Mac the token itself is in the keychain.
|
|
320
|
+
function claudeAccount(home) {
|
|
321
|
+
try {
|
|
322
|
+
const config = JSON.parse(
|
|
323
|
+
fs.readFileSync(path.join(home, ".claude.json"), "utf8")
|
|
324
|
+
);
|
|
325
|
+
const account = config.oauthAccount ?? {};
|
|
326
|
+
const signedInAs = [
|
|
327
|
+
account.accountUuid,
|
|
328
|
+
account.organizationUuid,
|
|
329
|
+
config.primaryApiKey ? "key" : "",
|
|
330
|
+
].join("/");
|
|
331
|
+
return createHash("sha256").update(signedInAs).digest("hex").slice(0, 16);
|
|
332
|
+
} catch {
|
|
333
|
+
return "";
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
export function signInStamp(agent, home = process.env.HOME, env = process.env) {
|
|
338
|
+
const fileTimes = signInFiles(agent, home, env).map((file) => {
|
|
339
|
+
try {
|
|
340
|
+
return fs.statSync(file).mtimeMs;
|
|
341
|
+
} catch {
|
|
342
|
+
return 0;
|
|
343
|
+
}
|
|
344
|
+
});
|
|
345
|
+
const account = agent === "claude-code" ? [claudeAccount(home)] : [];
|
|
346
|
+
return [...account, ...fileTimes].join(":");
|
|
230
347
|
}
|
|
231
348
|
|
|
232
349
|
/**
|
|
@@ -247,7 +364,7 @@ export function createAgentWatch({
|
|
|
247
364
|
const scan = async () => {
|
|
248
365
|
for (const agent of installed().filter((id) => CHECKABLE.includes(id))) {
|
|
249
366
|
if (removedByPerson(agent) || readiness.checking(agent)) continue;
|
|
250
|
-
const result = readiness.
|
|
367
|
+
const result = readiness.due(agent)
|
|
251
368
|
? await readiness.check(agent)
|
|
252
369
|
: readiness.of(agent);
|
|
253
370
|
if (result?.state !== "ready" || inSwarm(agent)) continue;
|
package/lib/record.mjs
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
// The record (docs/swarm-organization.md, "The record"): an agent's judged runs in one specialty on one model. A run
|
|
2
|
+
// counts toward the specialty its step asked for (board_tasks.specialty, written by team.mjs when the step is routed),
|
|
3
|
+
// on the model it ran on (board_tasks.run_model). It is judged by, in order:
|
|
4
|
+
// 1. the person's verdict on it (board_reactions), which overrides everything below;
|
|
5
|
+
// 2. a check of it by an agent on a different model (board_tasks.checked): passed is accepted, sent back rejected.
|
|
6
|
+
// A check on the same model does not count, because models favor their own output;
|
|
7
|
+
// 3. the auditor's code (board_tasks.audit, cli/lib/audit.mjs): a report whose own claims its receipts do not bear out
|
|
8
|
+
// is rejected. A change not committed on the thread's branch is not made, so that mismatch rejects the run even when
|
|
9
|
+
// a check passed it.
|
|
10
|
+
// Silence counts neither way. Being tagged by the person is not a verdict.
|
|
11
|
+
|
|
12
|
+
// At least this many judged runs before a record earns, or questions, a specialty.
|
|
13
|
+
const JUDGED = 3;
|
|
14
|
+
const ACCEPTED = new Set(["approves", "approves_with_changes"]);
|
|
15
|
+
|
|
16
|
+
/** Each run the person judged, by run id: the verdict of their latest post after it and before the agent's next run. */
|
|
17
|
+
function verdictsByRun(store) {
|
|
18
|
+
const reports = new Map();
|
|
19
|
+
for (const run of store.threadReports()) {
|
|
20
|
+
const key = `${run.goal_id}\u0000${run.agent}`;
|
|
21
|
+
if (!reports.has(key)) reports.set(key, []);
|
|
22
|
+
reports.get(key).push(run);
|
|
23
|
+
}
|
|
24
|
+
const verdicts = new Map();
|
|
25
|
+
for (const said of store.verdictsSaid()) {
|
|
26
|
+
const runs = reports.get(`${said.goal_id}\u0000${said.agent}`) ?? [];
|
|
27
|
+
const judged = runs.findLast((run) => run.reported_at <= said.said_at);
|
|
28
|
+
if (judged) verdicts.set(judged.id, said.verdict);
|
|
29
|
+
}
|
|
30
|
+
return verdicts;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** A check by an agent on another model: none of its checkers ran on the run's own model, and one's model is known. */
|
|
34
|
+
const checkedElsewhere = (run) =>
|
|
35
|
+
Boolean(run.checked?.outcome) &&
|
|
36
|
+
Boolean(run.model) &&
|
|
37
|
+
run.checked.by?.some((checker) => checker.model) &&
|
|
38
|
+
!run.checked.by.some((checker) => checker.model === run.model);
|
|
39
|
+
|
|
40
|
+
// The auditor's code (audit.mjs) found a claim of the agent's own its receipts do not bear out. A mismatch against the
|
|
41
|
+
// dispatcher (work assigned while the agent was offline) is not the agent's, and receipts still landing (the claims
|
|
42
|
+
// `waiting` lists) count neither way.
|
|
43
|
+
const auditFailed = (audit) =>
|
|
44
|
+
Boolean(audit) &&
|
|
45
|
+
!audit.waiting?.length &&
|
|
46
|
+
(audit.mismatches ?? []).some((mismatch) => mismatch.against === "agent");
|
|
47
|
+
const notCommitted = (audit) =>
|
|
48
|
+
(audit?.mismatches ?? []).some(
|
|
49
|
+
(mismatch) => mismatch.kind === "not_committed"
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
/** How one run was judged: "accepted", "rejected" or null for silence. */
|
|
53
|
+
function judgmentOf(run, verdict) {
|
|
54
|
+
if (verdict) return ACCEPTED.has(verdict) ? "accepted" : "rejected";
|
|
55
|
+
if (notCommitted(run.audit)) return "rejected";
|
|
56
|
+
if (checkedElsewhere(run))
|
|
57
|
+
return run.checked.outcome === "passed" ? "accepted" : "rejected";
|
|
58
|
+
if (auditFailed(run.audit)) return "rejected";
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Every agent's record: agent -> model -> specialty -> { accepted, rejected, judged }. */
|
|
63
|
+
function records(store) {
|
|
64
|
+
const verdicts = verdictsByRun(store);
|
|
65
|
+
const all = new Map();
|
|
66
|
+
for (const run of store.routedRuns()) {
|
|
67
|
+
if (!run.model) continue;
|
|
68
|
+
const judged = judgmentOf(run, verdicts.get(run.id));
|
|
69
|
+
if (!judged) continue;
|
|
70
|
+
const byModel = all.get(run.agent) ?? new Map();
|
|
71
|
+
all.set(run.agent, byModel);
|
|
72
|
+
const bySpecialty = byModel.get(run.model) ?? new Map();
|
|
73
|
+
byModel.set(run.model, bySpecialty);
|
|
74
|
+
const entry = bySpecialty.get(run.specialty) ?? {
|
|
75
|
+
accepted: 0,
|
|
76
|
+
rejected: 0,
|
|
77
|
+
judged: 0,
|
|
78
|
+
};
|
|
79
|
+
entry[judged]++;
|
|
80
|
+
entry.judged++;
|
|
81
|
+
bySpecialty.set(run.specialty, entry);
|
|
82
|
+
}
|
|
83
|
+
return all;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** An agent's record on a model: specialty id -> { accepted, rejected, judged }. */
|
|
87
|
+
export function recordFor(store, agentId, model) {
|
|
88
|
+
return new Map(records(store).get(agentId)?.get(model) ?? []);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** The specialties an agent has earned on a model: at least three judged runs, more accepted than rejected. */
|
|
92
|
+
export function earned(store, agentId, model) {
|
|
93
|
+
return [...recordFor(store, agentId, model)]
|
|
94
|
+
.filter(
|
|
95
|
+
([, entry]) => entry.judged >= JUDGED && entry.accepted > entry.rejected
|
|
96
|
+
)
|
|
97
|
+
.map(([specialty]) => specialty);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** Records that question a specialty: at least three judged runs, more rejected than accepted. */
|
|
101
|
+
export function underperforming(store) {
|
|
102
|
+
const found = [];
|
|
103
|
+
for (const [agent, byModel] of records(store))
|
|
104
|
+
for (const [model, bySpecialty] of byModel)
|
|
105
|
+
for (const [specialty, entry] of bySpecialty)
|
|
106
|
+
if (entry.judged >= JUDGED && entry.rejected > entry.accepted)
|
|
107
|
+
found.push({
|
|
108
|
+
agent,
|
|
109
|
+
model,
|
|
110
|
+
specialty,
|
|
111
|
+
accepted: entry.accepted,
|
|
112
|
+
judged: entry.judged,
|
|
113
|
+
});
|
|
114
|
+
return found;
|
|
115
|
+
}
|
package/lib/runWorker.mjs
CHANGED
|
@@ -33,9 +33,11 @@ export function createRunWorker({
|
|
|
33
33
|
taskRuns,
|
|
34
34
|
threadRuns,
|
|
35
35
|
vaultEnv = () => null,
|
|
36
|
+
// A run's receipt was just kept (audit.mjs audits the run's claims with it).
|
|
37
|
+
onReceipt = () => {},
|
|
36
38
|
}) {
|
|
37
39
|
const { RUNNERS, standingRules } = authority;
|
|
38
|
-
const {
|
|
40
|
+
const { startTurn, commitRun, settleWake, ranOutsideT3, t3Turn, taskInT3 } =
|
|
39
41
|
threadRuns.worker;
|
|
40
42
|
const activeRuns = new Map();
|
|
41
43
|
const lastStepNotice = new Map();
|
|
@@ -121,6 +123,13 @@ export function createRunWorker({
|
|
|
121
123
|
noteWaiting(task, activeRuns.get(slot));
|
|
122
124
|
continue;
|
|
123
125
|
}
|
|
126
|
+
// A task T3 carries out still waits for a run working in its folder, such as the turn of the agent that handed it
|
|
127
|
+
// on: two runs never work one checkout at once.
|
|
128
|
+
const folder =
|
|
129
|
+
task.kind === "task" && slot.startsWith("t3:") && task.run_workspace
|
|
130
|
+
? path.resolve(task.run_workspace)
|
|
131
|
+
: null;
|
|
132
|
+
if (folder && activeRuns.has(folder)) continue;
|
|
124
133
|
// An agent resumes one session per thread: its review waits while its own turn there runs.
|
|
125
134
|
if (slot.startsWith("review:") && runsInThread(agent, task.parent_id))
|
|
126
135
|
continue;
|
|
@@ -164,6 +173,7 @@ export function createRunWorker({
|
|
|
164
173
|
// run's environment, and what it says is scrubbed of them.
|
|
165
174
|
const secrets = restricted ? null : vaultEnv(task, agent);
|
|
166
175
|
const granted = secrets && Object.keys(secrets.env).length ? secrets : null;
|
|
176
|
+
startTurn(task);
|
|
167
177
|
taskRuns.startTask(
|
|
168
178
|
{
|
|
169
179
|
runId: task.id,
|
|
@@ -227,6 +237,8 @@ export function createRunWorker({
|
|
|
227
237
|
// A stopped run's task is already closed, so nothing else frees the agent's next run.
|
|
228
238
|
setImmediate(runBoard);
|
|
229
239
|
if (extra?.usage) store.setRunUsage(task.id, extra.usage);
|
|
240
|
+
// Its changes are committed before it reports, so the audit of its report sees what was not.
|
|
241
|
+
commitRun(task);
|
|
230
242
|
// A run that failed without reaching its agent's own report ended early: the runner says why.
|
|
231
243
|
const reported = store.reportTask(task.id, agent, {
|
|
232
244
|
status: kind,
|
|
@@ -240,7 +252,6 @@ export function createRunWorker({
|
|
|
240
252
|
);
|
|
241
253
|
// A coding agent's finished turn settles once its receipt is read, so the coordinator's round that follows sees
|
|
242
254
|
// what the run's own session shows (frames.mjs); the receipt is posted after the agent's own words.
|
|
243
|
-
if (wake) commitWake(task);
|
|
244
255
|
if (kind === "done" && RUNNERS.has(agent))
|
|
245
256
|
void receiptFor(task.id, agent, { post: !wake }).then((line) => {
|
|
246
257
|
if (wake) {
|
|
@@ -308,6 +319,9 @@ export function createRunWorker({
|
|
|
308
319
|
test:
|
|
309
320
|
result.tests.filter((test) => test.afterChange).at(-1)?.command ??
|
|
310
321
|
null,
|
|
322
|
+
// Whether that last test passed, so a run that changed nothing still shows its tests passing (audit.mjs).
|
|
323
|
+
testOk:
|
|
324
|
+
result.tests.filter((test) => test.afterChange).at(-1)?.ok ?? null,
|
|
311
325
|
repeatedFailures: result.repeatedFailures,
|
|
312
326
|
at: new Date().toISOString(),
|
|
313
327
|
})
|
|
@@ -319,6 +333,7 @@ export function createRunWorker({
|
|
|
319
333
|
text: line,
|
|
320
334
|
source: "receipts",
|
|
321
335
|
});
|
|
336
|
+
onReceipt(taskId);
|
|
322
337
|
localEvent("receipt", `${nameOf(agent)}'s run: ${result.verdict}`);
|
|
323
338
|
void contextEngine.refresh();
|
|
324
339
|
const forThread =
|
package/lib/runner.mjs
CHANGED
|
@@ -49,6 +49,13 @@ export function runningPids() {
|
|
|
49
49
|
return [...children.values()].map((child) => child.pid).filter(Boolean);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
/** Each run in progress with its process, so a session one of them started is known as that run's. */
|
|
53
|
+
export function runningProcesses() {
|
|
54
|
+
return [...children]
|
|
55
|
+
.filter(([run, child]) => child.pid && !run.startsWith("helper:"))
|
|
56
|
+
.map(([run, child]) => ({ run, pid: child.pid }));
|
|
57
|
+
}
|
|
58
|
+
|
|
52
59
|
export function resolveWorkingDirectory(requested) {
|
|
53
60
|
if (!requested || !path.isAbsolute(requested))
|
|
54
61
|
throw new Error("Delegated tasks require an absolute working directory.");
|
|
@@ -619,10 +626,7 @@ export function runAgentTask(task, emit, observe = () => {}, hooks = {}) {
|
|
|
619
626
|
"failed",
|
|
620
627
|
clean(
|
|
621
628
|
`${task.agent} stopped on an error from its model: ${modelError}`
|
|
622
|
-
).slice(
|
|
623
|
-
0,
|
|
624
|
-
4_000
|
|
625
|
-
),
|
|
629
|
+
).slice(0, 4_000),
|
|
626
630
|
{ usage: usage.result(), failure: "exit" }
|
|
627
631
|
);
|
|
628
632
|
else if (code === 0)
|