tryharness 0.7.71 → 0.7.72
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 +13 -8
- package/cli.mjs +27 -12
- package/lib/asks.mjs +2 -0
- package/lib/coordinator.mjs +52 -4
- package/lib/daemon.mjs +14 -8
- package/lib/goalCommands.mjs +14 -35
- package/lib/live.mjs +25 -3
- package/lib/machineRuns.mjs +42 -22
- package/lib/ownMachines.mjs +79 -6
- package/lib/plans.mjs +7 -1
- package/lib/projectSettings.mjs +11 -1
- package/lib/projects.mjs +20 -4
- package/lib/promptFlow.mjs +36 -1
- package/lib/runAuthority.mjs +103 -22
- package/lib/runWorker.mjs +44 -14
- package/lib/runner.mjs +183 -26
- package/lib/selfUpdate.mjs +41 -0
- package/lib/serverWords.mjs +11 -11
- package/lib/sessionControl.mjs +3 -2
- package/lib/store.mjs +25 -11
- package/lib/swarm.mjs +3 -0
- package/lib/taskCommands.mjs +36 -9
- package/lib/threadActions.mjs +9 -1
- package/lib/threadAuthority.mjs +21 -14
- package/lib/threadRuns.mjs +22 -8
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/release.json +29 -28
package/lib/runner.mjs
CHANGED
|
@@ -25,11 +25,18 @@ const issueCapability = (task) => {
|
|
|
25
25
|
restricted: task.restricted === true || Boolean(task.dispatchScope),
|
|
26
26
|
review: task.readOnly === true,
|
|
27
27
|
dispatchScope: task.dispatchScope ?? null,
|
|
28
|
+
// Work another person asked for (runWorker.mjs ownSettingsOnly), and the folder it works in: such a run reaches
|
|
29
|
+
// none of the person's private things beyond that folder (runAuthority.mjs privateReach).
|
|
30
|
+
forAnotherPerson: task.ownSettingsOnly === true,
|
|
31
|
+
cwd: task.cwd ? path.resolve(task.cwd) : null,
|
|
28
32
|
});
|
|
29
33
|
return token;
|
|
30
34
|
};
|
|
31
35
|
|
|
32
|
-
/**
|
|
36
|
+
/**
|
|
37
|
+
* The run a capability belongs to while that run goes on: its id, agent, whether it is restricted or a review, whether
|
|
38
|
+
* it works for another person, and its folder.
|
|
39
|
+
*/
|
|
33
40
|
export function runCapability(token) {
|
|
34
41
|
return capabilities.get(String(token)) ?? null;
|
|
35
42
|
}
|
|
@@ -159,29 +166,146 @@ const readDenials = (home) =>
|
|
|
159
166
|
? HARNESS_FILES.map((file) => `Read(/${path.join(place, file)})`)
|
|
160
167
|
: [`Read(/${place})`, `Read(/${place}/**)`]
|
|
161
168
|
);
|
|
169
|
+
// A run nobody pressed Start on reads only its own folder (owner, October 31: "nothing outside that without the consent
|
|
170
|
+
// of the user"). Denied: every home folder and the drives and shares mounted from outside, where people keep their
|
|
171
|
+
// files. Still readable: the operating system's own folders, the programs a run builds and tests with, git's settings,
|
|
172
|
+
// and the repository a worktree belongs to, whose history git reads.
|
|
173
|
+
const PERSONAL_ROOTS = ["/Volumes", "/media", "/mnt", "/run/media"];
|
|
174
|
+
const PROGRAM_PLACES = [
|
|
175
|
+
".nvm",
|
|
176
|
+
".volta",
|
|
177
|
+
".bun",
|
|
178
|
+
".deno",
|
|
179
|
+
".cargo/bin",
|
|
180
|
+
".rustup",
|
|
181
|
+
".pyenv",
|
|
182
|
+
".asdf",
|
|
183
|
+
".local/bin",
|
|
184
|
+
".local/share/mise",
|
|
185
|
+
"go/bin",
|
|
186
|
+
// Without its settings git refuses to run at all, and a commit has no author.
|
|
187
|
+
".gitconfig",
|
|
188
|
+
".config/git",
|
|
189
|
+
];
|
|
190
|
+
// The shell snapshot each agent's shell tool sources before every command, kept in that agent's own folder.
|
|
191
|
+
const SHELL_SNAPSHOTS = {
|
|
192
|
+
"claude-code": ".claude/shell-snapshots",
|
|
193
|
+
codex: ".codex/shell_snapshots",
|
|
194
|
+
};
|
|
195
|
+
const personalRoots = (home) => [
|
|
196
|
+
...new Set([path.dirname(home), ...PERSONAL_ROOTS]),
|
|
197
|
+
];
|
|
198
|
+
// A worktree's `.git` is a file naming its git folder inside the checkout it came from; git reads both.
|
|
199
|
+
const gitFolders = (cwd) => {
|
|
200
|
+
let pointer = "";
|
|
201
|
+
try {
|
|
202
|
+
pointer = fs.readFileSync(path.join(cwd, ".git"), "utf8");
|
|
203
|
+
} catch {
|
|
204
|
+
return [];
|
|
205
|
+
}
|
|
206
|
+
const own = pointer.match(/^gitdir: (.+)$/m)?.[1]?.trim();
|
|
207
|
+
if (!own) return [];
|
|
208
|
+
const gitDir = path.resolve(cwd, own);
|
|
209
|
+
let common = gitDir;
|
|
210
|
+
try {
|
|
211
|
+
common = path.resolve(
|
|
212
|
+
gitDir,
|
|
213
|
+
fs.readFileSync(path.join(gitDir, "commondir"), "utf8").trim()
|
|
214
|
+
);
|
|
215
|
+
} catch {}
|
|
216
|
+
return [...new Set([gitDir, common])];
|
|
217
|
+
};
|
|
218
|
+
/** What `agent`'s run held to its folder still reads beneath the places it may not: its folder, git's, programs. */
|
|
219
|
+
export const confinedReads = (
|
|
220
|
+
cwd,
|
|
221
|
+
home = os.homedir(),
|
|
222
|
+
agent = "claude-code"
|
|
223
|
+
) => [
|
|
224
|
+
...(cwd ? [cwd, ...gitFolders(cwd)] : []),
|
|
225
|
+
...[...PROGRAM_PLACES, SHELL_SNAPSHOTS[agent]].map((place) =>
|
|
226
|
+
path.join(home, place)
|
|
227
|
+
),
|
|
228
|
+
];
|
|
229
|
+
const within = (place, root) => {
|
|
230
|
+
const relative = path.relative(root, place);
|
|
231
|
+
return (
|
|
232
|
+
relative === "" ||
|
|
233
|
+
(!relative.startsWith("..") && !path.isAbsolute(relative))
|
|
234
|
+
);
|
|
235
|
+
};
|
|
236
|
+
/**
|
|
237
|
+
* Every place a run held to its folder may not read, as absolute paths. Not a whole home folder with the run's own let
|
|
238
|
+
* back in: git walks up the folders above its own and stops at one it cannot look at, and Claude Code's file tools
|
|
239
|
+
* take no exception inside a deny. So each entry beside the path down to a place it may read is named, as the run
|
|
240
|
+
* starts; the folders on that path show their entries' names and nothing in them. A secret place is denied even where
|
|
241
|
+
* it lies beside an open one.
|
|
242
|
+
*/
|
|
243
|
+
export const fencedPlaces = (
|
|
244
|
+
cwd,
|
|
245
|
+
home = os.homedir(),
|
|
246
|
+
agent = "claude-code"
|
|
247
|
+
) => {
|
|
248
|
+
const open = confinedReads(cwd, home, agent);
|
|
249
|
+
const fenced = [];
|
|
250
|
+
const fence = (place, secret = false) => {
|
|
251
|
+
if (!secret && open.some((root) => within(place, root))) return;
|
|
252
|
+
if (!open.some((root) => root !== place && within(root, place))) {
|
|
253
|
+
fenced.push(place);
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
let entries = [];
|
|
257
|
+
try {
|
|
258
|
+
entries = fs.readdirSync(place);
|
|
259
|
+
} catch {
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
for (const entry of entries) fence(path.join(place, entry));
|
|
263
|
+
};
|
|
264
|
+
for (const root of personalRoots(home)) if (fs.existsSync(root)) fence(root);
|
|
265
|
+
for (const place of secretPlaces(home)) fence(place, true);
|
|
266
|
+
return [...new Set(fenced)];
|
|
267
|
+
};
|
|
162
268
|
// The sandbox holds shell commands to the same places. The run's own folder stays readable even inside Harness's home,
|
|
163
|
-
// where its worktree is, and so do the shell snapshots each agent's shell tool sources before every command.
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
269
|
+
// where its worktree is, and so do the shell snapshots each agent's shell tool sources before every command. A run
|
|
270
|
+
// held to its folder (`confined`) reads nothing else of the person's.
|
|
271
|
+
const sandboxReads = (cwd, home, confined = false) =>
|
|
272
|
+
confined
|
|
273
|
+
? { denyRead: fencedPlaces(cwd, home), allowRead: confinedReads(cwd, home) }
|
|
274
|
+
: {
|
|
275
|
+
denyRead: secretPlaces(home),
|
|
276
|
+
allowRead: [
|
|
277
|
+
...(cwd ? [cwd] : []),
|
|
278
|
+
path.join(home, ".claude", "shell-snapshots"),
|
|
279
|
+
],
|
|
280
|
+
};
|
|
281
|
+
const confinedDenials = (cwd, home, confined) =>
|
|
282
|
+
confined
|
|
283
|
+
? fencedPlaces(cwd, home).flatMap((place) => [
|
|
284
|
+
`Read(/${place})`,
|
|
285
|
+
`Read(/${place}/**)`,
|
|
286
|
+
])
|
|
287
|
+
: [];
|
|
171
288
|
|
|
172
289
|
// A run another agent started without the person's tap (docs/member-runs.md): anything that would ask is refused, file
|
|
173
290
|
// edits only in its worktree, shell commands only inside the operating system's sandbox with no network, nothing read
|
|
174
291
|
// where the person keeps credentials, and no hooks or settings from the repository. A review gets no edits at all.
|
|
175
292
|
export const restrictedClaudeSettings = (cwd, home = os.homedir()) => ({
|
|
176
293
|
disableAllHooks: true,
|
|
177
|
-
permissions: {
|
|
294
|
+
permissions: {
|
|
295
|
+
deny: [
|
|
296
|
+
"WebFetch",
|
|
297
|
+
"WebSearch",
|
|
298
|
+
...readDenials(home),
|
|
299
|
+
...confinedDenials(cwd, home, true),
|
|
300
|
+
],
|
|
301
|
+
},
|
|
178
302
|
sandbox: {
|
|
179
303
|
enabled: true,
|
|
180
304
|
autoAllowBashIfSandboxed: true,
|
|
181
305
|
allowUnsandboxedCommands: false,
|
|
182
306
|
failIfUnavailable: true,
|
|
183
307
|
excludedCommands: [],
|
|
184
|
-
filesystem: sandboxReads(cwd, home),
|
|
308
|
+
filesystem: sandboxReads(cwd, home, true),
|
|
185
309
|
network: { allowedDomains: [], strictAllowlist: true },
|
|
186
310
|
},
|
|
187
311
|
});
|
|
@@ -286,15 +410,26 @@ const modelWindow = ({ limits }) =>
|
|
|
286
410
|
// folder is refused; denying edits everywhere also broke Claude Code's own scratch files under /tmp). It reads nothing
|
|
287
411
|
// where the person keeps credentials, loads no settings or hooks from the repository it reviews, and has no web: what
|
|
288
412
|
// it reviews is in the folder and the thread, and a fetch is a way out for what it read.
|
|
289
|
-
|
|
413
|
+
// A review nobody pressed Start on (`confined`) reads only its folder, as a restricted run does.
|
|
414
|
+
export const readOnlyClaudeSettings = (
|
|
415
|
+
cwd,
|
|
416
|
+
home = os.homedir(),
|
|
417
|
+
confined = false
|
|
418
|
+
) => ({
|
|
290
419
|
permissions: {
|
|
291
|
-
deny: [
|
|
420
|
+
deny: [
|
|
421
|
+
"Edit(./**)",
|
|
422
|
+
"WebFetch",
|
|
423
|
+
"WebSearch",
|
|
424
|
+
...readDenials(home),
|
|
425
|
+
...confinedDenials(cwd, home, confined),
|
|
426
|
+
],
|
|
292
427
|
},
|
|
293
428
|
sandbox: {
|
|
294
429
|
enabled: true,
|
|
295
430
|
autoAllowBashIfSandboxed: true,
|
|
296
431
|
allowUnsandboxedCommands: false,
|
|
297
|
-
filesystem: sandboxReads(cwd, home),
|
|
432
|
+
filesystem: sandboxReads(cwd, home, confined),
|
|
298
433
|
network: { allowedDomains: [], strictAllowlist: true },
|
|
299
434
|
},
|
|
300
435
|
});
|
|
@@ -309,20 +444,30 @@ const readOnlyClaude = (task) => [
|
|
|
309
444
|
"user",
|
|
310
445
|
"--settings",
|
|
311
446
|
JSON.stringify({
|
|
312
|
-
...readOnlyClaudeSettings(task.cwd),
|
|
447
|
+
...readOnlyClaudeSettings(task.cwd, os.homedir(), task.restricted === true),
|
|
313
448
|
...modelWindow(task),
|
|
314
449
|
}),
|
|
315
450
|
];
|
|
316
451
|
|
|
317
452
|
// Codex's review: its read-only permission profile, with the same places denied to every command it runs (the run's
|
|
318
453
|
// own folder stays readable when it lies inside one) and no web search. Probed with `codex sandbox` 0.164: a denied
|
|
319
|
-
// file is "Operation not permitted", the folder reads, writes and the daemon's socket are refused.
|
|
320
|
-
|
|
454
|
+
// file is "Operation not permitted", the folder reads, writes and the daemon's socket are refused. A restricted run
|
|
455
|
+
// (`write`) has the same profile with its own folder writable: probed with `codex sandbox` 0.166, it writes there,
|
|
456
|
+
// ~/.ssh is denied and the network is refused, as for Claude Code's restricted run. A restricted run, or a review
|
|
457
|
+
// nobody pressed Start on, reads only its folder: the more specific place wins, so the folder, git's and the programs
|
|
458
|
+
// under a denied home stay readable.
|
|
459
|
+
const codexReview = (task, executable, home = os.homedir(), write = false) => {
|
|
460
|
+
const confined = write || task.restricted === true;
|
|
321
461
|
const places = Object.fromEntries(
|
|
322
|
-
|
|
462
|
+
(confined ? fencedPlaces(task.cwd, home, "codex") : secretPlaces(home)).map(
|
|
463
|
+
(place) => [place, "deny"]
|
|
464
|
+
)
|
|
323
465
|
);
|
|
466
|
+
if (confined)
|
|
467
|
+
for (const place of confinedReads(task.cwd, home, "codex"))
|
|
468
|
+
places[place] = "read";
|
|
324
469
|
places[path.join(home, ".codex", "shell_snapshots")] = "read";
|
|
325
|
-
if (task.cwd) places[task.cwd] = "read";
|
|
470
|
+
if (task.cwd) places[task.cwd] = write ? "write" : "read";
|
|
326
471
|
// Standalone Codex lives inside its denied credential home and reexecutes
|
|
327
472
|
// itself to load AGENTS.md. Only its confirmed, resolved file needs access.
|
|
328
473
|
if (executable) places[executable] = "read";
|
|
@@ -425,8 +570,9 @@ export function agentInvocation(task, { executable = null } = {}) {
|
|
|
425
570
|
],
|
|
426
571
|
};
|
|
427
572
|
}
|
|
428
|
-
// Only Claude Code
|
|
429
|
-
|
|
573
|
+
// Only Claude Code and Codex have a restricted mode; any other agent's restricted run is refused here, whatever let it
|
|
574
|
+
// start.
|
|
575
|
+
if (task.restricted && task.agent !== "codex")
|
|
430
576
|
throw new Error(
|
|
431
577
|
`${task.agent} has no restricted mode; it runs only after the person's Start`
|
|
432
578
|
);
|
|
@@ -449,7 +595,18 @@ export function agentInvocation(task, { executable = null } = {}) {
|
|
|
449
595
|
"-c",
|
|
450
596
|
'mcp_servers.harness.default_tools_approval_mode="approve"',
|
|
451
597
|
]
|
|
452
|
-
:
|
|
598
|
+
: task.restricted
|
|
599
|
+
? [
|
|
600
|
+
...codexReview(task, executable, os.homedir(), true),
|
|
601
|
+
"-c",
|
|
602
|
+
'approval_policy="never"',
|
|
603
|
+
// Only Harness's board, as for restricted Claude Code: none of the person's other MCP servers.
|
|
604
|
+
"-c",
|
|
605
|
+
`mcp_servers={harness={command=${JSON.stringify(process.execPath)},args=${JSON.stringify([fileURLToPath(new URL("./mcp-stdio.mjs", import.meta.url)), "--agent", "codex", "--restricted"])}}}`,
|
|
606
|
+
"-c",
|
|
607
|
+
'mcp_servers.harness.default_tools_approval_mode="approve"',
|
|
608
|
+
]
|
|
609
|
+
: ["--dangerously-bypass-approvals-and-sandbox"]),
|
|
453
610
|
"--skip-git-repo-check",
|
|
454
611
|
"-",
|
|
455
612
|
],
|
|
@@ -710,17 +867,17 @@ export function readRunSteps(file, limit = 200) {
|
|
|
710
867
|
}
|
|
711
868
|
|
|
712
869
|
export function runAgentTask(task, emit, observe = () => {}, hooks = {}) {
|
|
713
|
-
// One run per folder:
|
|
714
|
-
// A read-only review edits nothing, so it goes beside whoever writes there
|
|
870
|
+
// One run per agent per folder: an agent's session there is one; other agents work beside it, as the person runs them
|
|
871
|
+
// (runWorker.mjs slotOf). A read-only review edits nothing, so it goes beside whoever writes there.
|
|
715
872
|
const slot = task.readOnly
|
|
716
873
|
? `review:${task.agent}:${task.cwd || ""}`
|
|
717
874
|
: task.cwd
|
|
718
|
-
? path.resolve(task.cwd)
|
|
875
|
+
? `${path.resolve(task.cwd)}:${task.agent}`
|
|
719
876
|
: task.agent;
|
|
720
877
|
if (running.has(slot)) {
|
|
721
878
|
emit(
|
|
722
879
|
"failed",
|
|
723
|
-
|
|
880
|
+
`${task.agent} is already working in ${task.cwd || "that folder"}.`,
|
|
724
881
|
{ failure: "start" }
|
|
725
882
|
);
|
|
726
883
|
return;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { spawn } from "node:child_process";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { paths } from "./paths.mjs";
|
|
6
|
+
|
|
7
|
+
const CLI = fileURLToPath(new URL("../cli.mjs", import.meta.url));
|
|
8
|
+
|
|
9
|
+
/** What an update this computer started did, line by line: the upgrade's own words go here too. */
|
|
10
|
+
export const updateLog = () => path.join(paths.home, "update.log");
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* This computer updating itself to a published release, as the person asked from home (ownMachines.mjs update):
|
|
14
|
+
* `tryharness upgrade <spec>`, which fetches it, takes it only signed with Harness's release key and sets it up. It
|
|
15
|
+
* runs on its own, since setting up restarts the daemon that started it, and opens no window on a computer the person
|
|
16
|
+
* may not be at.
|
|
17
|
+
*/
|
|
18
|
+
export function startUpdate(spec, { from, log = () => {} }) {
|
|
19
|
+
const out = fs.openSync(updateLog(), "a");
|
|
20
|
+
try {
|
|
21
|
+
fs.writeSync(
|
|
22
|
+
out,
|
|
23
|
+
`${new Date().toISOString()} updating from ${from} to ${spec}, as the person asked from home\n`
|
|
24
|
+
);
|
|
25
|
+
const child = spawn(
|
|
26
|
+
process.execPath,
|
|
27
|
+
[CLI, "upgrade", spec, "--no-desktop"],
|
|
28
|
+
{ detached: true, stdio: ["ignore", out, out], env: process.env }
|
|
29
|
+
);
|
|
30
|
+
child.unref();
|
|
31
|
+
} finally {
|
|
32
|
+
fs.closeSync(out);
|
|
33
|
+
}
|
|
34
|
+
log(`updating from ${from} to ${spec}, as the person asked from home`);
|
|
35
|
+
return {
|
|
36
|
+
ok: true,
|
|
37
|
+
from,
|
|
38
|
+
to: spec,
|
|
39
|
+
note: `Updating from ${from} to ${spec === "latest" ? "the newest release" : spec}: it restarts on its own in a minute or two.`,
|
|
40
|
+
};
|
|
41
|
+
}
|
package/lib/serverWords.mjs
CHANGED
|
@@ -6,12 +6,13 @@ import { askLocalAgent } from "./localAgentAsk.mjs";
|
|
|
6
6
|
// permissions. Home has the last word on them (owner, October 26: the server finds computers and keeps the backup; the
|
|
7
7
|
// person's own computer decides), without asking the person about ordinary hand-ons.
|
|
8
8
|
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
//
|
|
9
|
+
// A coding agent here with its tools off reads the words against the person's own posts in the thread and lists what
|
|
10
|
+
// they ask for that the person has not: spending, something outward-facing or hard to undo, a secret, a change of what
|
|
11
|
+
// the work is for (the same four things a round may ask the person about). The local guard reads them too: words it
|
|
12
|
+
// reads as orders aimed at the agents are left out, while a flag goes only to the log, since it cannot tell
|
|
13
|
+
// coordination from planted orders (owner, October 31: guard secrets, private data and money, not ordinary work); it
|
|
14
|
+
// saw 0 of 6 plainly worded harmful hand-ons in the security-briefs eval, which is why the agent reads too. Words
|
|
15
|
+
// either stops never reach an agent: the round still
|
|
15
16
|
// routes the work (who, review or not, the team's step), each brief says only that the coordinator handed the thread on,
|
|
16
17
|
// and words meant for the person stay theirs to read but are left out of what agents read (the thread's digest,
|
|
17
18
|
// read_room, swarm_memory and a backup coordinator's transcript). A reading that cannot be had (no guard downloaded, no
|
|
@@ -20,7 +21,7 @@ import { askLocalAgent } from "./localAgentAsk.mjs";
|
|
|
20
21
|
const WITHHELD = "withheld:";
|
|
21
22
|
const LEFT_OUT = {
|
|
22
23
|
flagged:
|
|
23
|
-
"the guard on this computer
|
|
24
|
+
"the guard on this computer read them as orders aimed at your agents",
|
|
24
25
|
beyond: "they asked for something the person has not asked for",
|
|
25
26
|
};
|
|
26
27
|
const KINDS = {
|
|
@@ -98,8 +99,8 @@ export function createServerWords({
|
|
|
98
99
|
};
|
|
99
100
|
|
|
100
101
|
/**
|
|
101
|
-
* Why a decision's words are left out: null (they reach the agents), "flagged" (the guard
|
|
102
|
-
* with what they asked for in `asks`). `person`: the person's own posts in the thread; `readers`: the coding agents
|
|
102
|
+
* Why a decision's words are left out: null (they reach the agents), "flagged" (the guard read them as orders) or
|
|
103
|
+
* "beyond" (the reader, with what they asked for in `asks`). `person`: the person's own posts in the thread; `readers`: the coding agents
|
|
103
104
|
* here that may read, in order.
|
|
104
105
|
*/
|
|
105
106
|
const screen = async (decision, { person = [], readers = [] } = {}) => {
|
|
@@ -118,8 +119,7 @@ export function createServerWords({
|
|
|
118
119
|
`coordinator: the round's words were read in ${Date.now() - startedAt} ms (guard ${reading?.unavailable ? "not here" : (reading?.verdict ?? "clean")}, reader ${asks === null ? "not had" : `${asks.length} beyond`})`
|
|
119
120
|
);
|
|
120
121
|
if (asks?.length) return { reason: "beyond", asks };
|
|
121
|
-
if (reading?.verdict === "
|
|
122
|
-
return { reason: "flagged", asks: [] };
|
|
122
|
+
if (reading?.verdict === "hold") return { reason: "flagged", asks: [] };
|
|
123
123
|
return { reason: null, asks: [] };
|
|
124
124
|
};
|
|
125
125
|
|
package/lib/sessionControl.mjs
CHANGED
|
@@ -355,8 +355,9 @@ export function createSessionControl({
|
|
|
355
355
|
reported: reportedSessions(),
|
|
356
356
|
table,
|
|
357
357
|
});
|
|
358
|
-
// Who started each, when another agent's session or one of Harness's runs did: seen now, else as it started.
|
|
359
|
-
|
|
358
|
+
// Who started each, when another agent's session or one of Harness's runs did: seen now, else as it started. The
|
|
359
|
+
// table again: one a session just started was read into is the kept one now.
|
|
360
|
+
const owners = ownersOf(found, processTable());
|
|
360
361
|
const sessions = found
|
|
361
362
|
.map((session) => ({
|
|
362
363
|
...session,
|
package/lib/store.mjs
CHANGED
|
@@ -1145,8 +1145,10 @@ export function openStore(file) {
|
|
|
1145
1145
|
});
|
|
1146
1146
|
return this.getTask(parentId);
|
|
1147
1147
|
},
|
|
1148
|
-
// Run authority is a separate write from the post: an agent may ask for a run, only the user grants it.
|
|
1149
|
-
|
|
1148
|
+
// Run authority is a separate write from the post: an agent may ask for a run, only the user grants it. A thread's
|
|
1149
|
+
// task naming no folder runs in `scratch`, the thread's scratch folder here, or in the one the computer it is for
|
|
1150
|
+
// makes (machineRuns.mjs), as one started on standing permission does.
|
|
1151
|
+
authorizeRun(id, agent, { scratch = null } = {}) {
|
|
1150
1152
|
if (this.getThread(id))
|
|
1151
1153
|
return {
|
|
1152
1154
|
ok: false,
|
|
@@ -1165,9 +1167,12 @@ export function openStore(file) {
|
|
|
1165
1167
|
const now = new Date().toISOString();
|
|
1166
1168
|
const written = execute(
|
|
1167
1169
|
"run",
|
|
1168
|
-
`update board_tasks set run_authorized_by = @agent, run_authorized_at = @now, updated_at = @now, version = version + 1
|
|
1169
|
-
|
|
1170
|
-
|
|
1170
|
+
`update board_tasks set run_authorized_by = @agent, run_authorized_at = @now, updated_at = @now, version = version + 1,
|
|
1171
|
+
run_workspace = case when kind = 'task' and parent_id is not null then coalesce(run_workspace, @scratch) else run_workspace end
|
|
1172
|
+
where id = @id and status = 'open' and run_authorized_at is null
|
|
1173
|
+
and (run_workspace is not null or (kind = 'wake' and target_machine is not null)
|
|
1174
|
+
or (kind = 'task' and parent_id is not null and coalesce(@scratch, target_machine) is not null))`,
|
|
1175
|
+
{ id, agent, now, scratch }
|
|
1171
1176
|
);
|
|
1172
1177
|
if (written.changes === 1) return { ok: true, task: this.getTask(id) };
|
|
1173
1178
|
return conflict(this.getTask(id), agent, null, (task) =>
|
|
@@ -1178,9 +1183,9 @@ export function openStore(file) {
|
|
|
1178
1183
|
: `task is ${task.status}`
|
|
1179
1184
|
);
|
|
1180
1185
|
},
|
|
1181
|
-
// Standing permission: an agent starts the work the person or
|
|
1182
|
-
// default it covers
|
|
1183
|
-
//
|
|
1186
|
+
// Standing permission: an agent starts the work the person, Harness or their own agents post for it without a Start
|
|
1187
|
+
// each time. By default it covers any folder below home (runAuthority.mjs covers); the person can name folders and a
|
|
1188
|
+
// daily limit instead (mode 'named') or turn it off ('off'). Only the person changes it; the daemon decides each post.
|
|
1184
1189
|
setStanding(agent, mode, workspaces = [], dailyCap = DEFAULT_DAILY_RUNS) {
|
|
1185
1190
|
execute(
|
|
1186
1191
|
"run",
|
|
@@ -3004,7 +3009,8 @@ export function openStore(file) {
|
|
|
3004
3009
|
* A thread's turn that one of the person's own agents elsewhere asked for, or the task it posted itself for a coding
|
|
3005
3010
|
* agent, started on its agent's standing permission: the rule read, the day's runs counted and the row authorized in
|
|
3006
3011
|
* one transaction, so two asks at once never both take the last run of the day. It counts as one of the day's
|
|
3007
|
-
* standing runs, whoever asked. `covered`: whether the rule covers `folder`, the folder checked
|
|
3012
|
+
* standing runs, whoever asked. `covered`: whether the rule covers `folder`, the folder checked, and `pastLimit`
|
|
3013
|
+
* whether the day's runs reach a limit the person set (runAuthority.mjs).
|
|
3008
3014
|
* `scratch`: where a posted task naming no folder runs on this computer; another computer's makes its own. The
|
|
3009
3015
|
* receipt keeps the rule's revision, the folder checked, and the agent, folder and computer it was admitted to run
|
|
3010
3016
|
* with, for the check again before it starts (runAuthority.mjs proposedHold). Null when
|
|
@@ -3012,7 +3018,15 @@ export function openStore(file) {
|
|
|
3012
3018
|
*/
|
|
3013
3019
|
authorizeProposed(
|
|
3014
3020
|
id,
|
|
3015
|
-
{
|
|
3021
|
+
{
|
|
3022
|
+
agent,
|
|
3023
|
+
proposer,
|
|
3024
|
+
since,
|
|
3025
|
+
covered,
|
|
3026
|
+
pastLimit,
|
|
3027
|
+
folder = null,
|
|
3028
|
+
scratch = null,
|
|
3029
|
+
}
|
|
3016
3030
|
) {
|
|
3017
3031
|
db.exec("begin immediate");
|
|
3018
3032
|
try {
|
|
@@ -3024,7 +3038,7 @@ export function openStore(file) {
|
|
|
3024
3038
|
? "not-proposer"
|
|
3025
3039
|
: !covered(rule)
|
|
3026
3040
|
? "outside"
|
|
3027
|
-
: rule
|
|
3041
|
+
: pastLimit(rule)
|
|
3028
3042
|
? "cap"
|
|
3029
3043
|
: null;
|
|
3030
3044
|
const now = new Date().toISOString();
|
package/lib/swarm.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
1
2
|
import fs from "node:fs";
|
|
2
3
|
import os from "node:os";
|
|
3
4
|
import path from "node:path";
|
|
@@ -964,6 +965,8 @@ export function createSwarm({
|
|
|
964
965
|
{
|
|
965
966
|
...request,
|
|
966
967
|
action: command === "board.swarm.stop" ? "stop" : "send",
|
|
968
|
+
// Screens that retry send their own id so a retry is one message; the rest post as to any thread.
|
|
969
|
+
requestId: request.requestId || randomUUID(),
|
|
967
970
|
},
|
|
968
971
|
agent
|
|
969
972
|
)
|
package/lib/taskCommands.mjs
CHANGED
|
@@ -512,6 +512,7 @@ export function createTaskCommands({
|
|
|
512
512
|
!goalParent &&
|
|
513
513
|
!posterFolder &&
|
|
514
514
|
!request.thread &&
|
|
515
|
+
request.inSession !== true &&
|
|
515
516
|
provenance.trust === "user" &&
|
|
516
517
|
authority.RUNNERS.has(target) &&
|
|
517
518
|
installedAgents.includes(target)
|
|
@@ -654,6 +655,12 @@ export function createTaskCommands({
|
|
|
654
655
|
getProjects()?.channelOpened(task.id);
|
|
655
656
|
}
|
|
656
657
|
if (pick) setRunPick(store, task.id, pick, agent);
|
|
658
|
+
// How many times the person's agents have handed this work on since the person last did (runAuthority.mjs
|
|
659
|
+
// MAX_HANDOFFS): one more than the run that posted it, none from a session or a post of the person's own.
|
|
660
|
+
const handoffs = request[RUN_CALLER]
|
|
661
|
+
? Number(store.meta(`handoffs:${request[RUN_CALLER].id}`) || 0) + 1
|
|
662
|
+
: 0;
|
|
663
|
+
if (handoffs) store.meta(`handoffs:${task.id}`, String(handoffs));
|
|
657
664
|
if (deferred) {
|
|
658
665
|
try {
|
|
659
666
|
if (!dispatches) throw new Error("typed dispatch is unavailable");
|
|
@@ -754,9 +761,10 @@ export function createTaskCommands({
|
|
|
754
761
|
});
|
|
755
762
|
// A task one of the person's own agents posted for a coding agent, the way that agent speaks (through Harness's
|
|
756
763
|
// server, or from a process here): when the person has not taken that agent off the coding agent's standing
|
|
757
|
-
// permission, posting it is its start, on the computer it was placed on (runAuthority.mjs admitPosted),
|
|
758
|
-
// guard here reads its words
|
|
759
|
-
// the goal already authorized them; their agent-written text does not borrow the
|
|
764
|
+
// permission, posting it is its start, on the computer it was placed on (runAuthority.mjs admitPosted), unless the
|
|
765
|
+
// guard here reads its words as orders (a flag is only a label). Explicit goal children use the same admission
|
|
766
|
+
// without spending twice when the goal already authorized them; their agent-written text does not borrow the
|
|
767
|
+
// goal's authority.
|
|
760
768
|
const cameAsItSpeaks = speaksThroughHarness(agent)
|
|
761
769
|
? request[HOSTED_CALLER] === true
|
|
762
770
|
: !noGo;
|
|
@@ -765,8 +773,11 @@ export function createTaskCommands({
|
|
|
765
773
|
PROPOSERS.includes(agent) &&
|
|
766
774
|
task.trust === "agent" &&
|
|
767
775
|
!thread &&
|
|
768
|
-
(goalParent ||
|
|
776
|
+
(goalParent ||
|
|
777
|
+
!request.parentId ||
|
|
778
|
+
(parentTask?.kind === "task" && !store.getThread(parentTask.id))) &&
|
|
769
779
|
!standing?.started &&
|
|
780
|
+
request.inSession !== true &&
|
|
770
781
|
authority.RUNNERS.has(target)
|
|
771
782
|
? store.getTask(task.id)
|
|
772
783
|
: null;
|
|
@@ -788,6 +799,7 @@ export function createTaskCommands({
|
|
|
788
799
|
guard,
|
|
789
800
|
limited,
|
|
790
801
|
window: request.fromWindow === true,
|
|
802
|
+
handoffs,
|
|
791
803
|
},
|
|
792
804
|
{ scratch }
|
|
793
805
|
);
|
|
@@ -802,6 +814,9 @@ export function createTaskCommands({
|
|
|
802
814
|
notifyBoard(store.getTask(task.id));
|
|
803
815
|
return posted(started);
|
|
804
816
|
}),
|
|
817
|
+
// The task is on the board already; only whether it may start waits for the guard. A caller that cannot
|
|
818
|
+
// wait for the answer (plans.mjs) takes it from here.
|
|
819
|
+
task: proposed,
|
|
805
820
|
};
|
|
806
821
|
}
|
|
807
822
|
outcome = posted(standing);
|
|
@@ -1230,11 +1245,23 @@ export function createTaskCommands({
|
|
|
1230
1245
|
notifyBoard(gone);
|
|
1231
1246
|
}
|
|
1232
1247
|
return { ok: true, removed: removed.ids };
|
|
1233
|
-
} else if (request.command === "board.run")
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1248
|
+
} else if (request.command === "board.run") {
|
|
1249
|
+
if (agent !== "user")
|
|
1250
|
+
return { ok: false, error: "only the user can authorize a run" };
|
|
1251
|
+
// A thread's task for a coding agent here naming no folder runs in the thread's scratch folder, so the Start the
|
|
1252
|
+
// thread asks for always works (a ComfyUI picture Grok Bot asked Codex for once had none).
|
|
1253
|
+
const task = store.getTask(id);
|
|
1254
|
+
const scratch =
|
|
1255
|
+
task?.kind === "task" &&
|
|
1256
|
+
task.parent_id &&
|
|
1257
|
+
!task.run_workspace &&
|
|
1258
|
+
(!task.target_machine || task.target_machine === machines.self()) &&
|
|
1259
|
+
authority.RUNNERS.has(task.target_agent)
|
|
1260
|
+
? threadScratch(task.parent_id)
|
|
1261
|
+
: null;
|
|
1262
|
+
outcome = store.authorizeRun(id, agent, { scratch });
|
|
1263
|
+
if (outcome.ok && scratch) prepareScratch(task.parent_id);
|
|
1264
|
+
}
|
|
1238
1265
|
// A worker running the work meant for it (machineRuns.mjs): what is authorized for its agents, taking one in its
|
|
1239
1266
|
// agent's name, the run's session, and its end. Only for that computer; the Start stays home's.
|
|
1240
1267
|
else if (
|
package/lib/threadActions.mjs
CHANGED
|
@@ -225,6 +225,7 @@ export function createThreadActions({
|
|
|
225
225
|
guard === undefined
|
|
226
226
|
? null
|
|
227
227
|
: authority.guardWait(author, agent, guard, { hosted }),
|
|
228
|
+
orders: guard !== undefined && authority.readAsOrders(guard),
|
|
228
229
|
answer: agent === answering,
|
|
229
230
|
// How the ask came, for one from the person's own agents: in a thread another agent wrote, its turn may start
|
|
230
231
|
// on the agent's standing permission (threadRuns.mjs admitProposal). `here`: from a process on this computer.
|
|
@@ -239,7 +240,14 @@ export function createThreadActions({
|
|
|
239
240
|
told.push(
|
|
240
241
|
`${nameOf(agent)} already has task ${original.id} (${original.status}). This post did not schedule a new turn or update that task's brief. For additional work, post a new follow-up after it finishes.`
|
|
241
242
|
);
|
|
242
|
-
}
|
|
243
|
+
}
|
|
244
|
+
// Asks through Harness (Bankr, Quotient, Grok Bot, Muse) have no Start to wait on, so words the guard read as
|
|
245
|
+
// orders are not passed to them; the person asks again if they meant it.
|
|
246
|
+
else if (askable(agent) && guard?.verdict === "hold" && author !== "user")
|
|
247
|
+
refuse(
|
|
248
|
+
"the guard read these words as orders aimed at your agents. Ask it yourself if you meant it"
|
|
249
|
+
);
|
|
250
|
+
else if (askable(agent))
|
|
243
251
|
told.push(ask(goalId, agent, reason, author, post.text));
|
|
244
252
|
// Harness by name: the person's @harness or an agent's ask. A message naming no one falls to Harness as
|
|
245
253
|
// coordinator.
|