tryharness 0.7.70 → 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 +32 -14
- package/lib/agentSignIn.mjs +2 -2
- package/lib/asks.mjs +2 -0
- package/lib/coordinator.mjs +77 -12
- package/lib/daemon.mjs +14 -8
- package/lib/firewall.mjs +4 -5
- package/lib/goalCommands.mjs +14 -35
- package/lib/live.mjs +25 -3
- package/lib/machineRuns.mjs +42 -22
- package/lib/members.mjs +16 -0
- 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/redact.mjs +5 -5
- package/lib/runAuthority.mjs +119 -36
- package/lib/runWorker.mjs +44 -14
- package/lib/runner.mjs +183 -26
- package/lib/secretPatterns.json +8 -2
- package/lib/secrets.mjs +19 -3
- package/lib/selfUpdate.mjs +41 -0
- package/lib/serverWords.mjs +11 -11
- package/lib/sessionControl.mjs +3 -2
- package/lib/store.mjs +47 -18
- package/lib/swarm.mjs +3 -0
- package/lib/taskCommands.mjs +47 -12
- package/lib/team.mjs +18 -0
- package/lib/threadActions.mjs +12 -4
- package/lib/threadAuthority.mjs +30 -25
- package/lib/threadRuns.mjs +22 -8
- package/npm-shrinkwrap.json +10 -10
- package/package.json +3 -3
- package/release.json +36 -35
package/lib/secretPatterns.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"about": "What must never leave in a message to someone else's agent or an outside place: keys and tokens by their well-known shapes, private-key blocks, env-style assignments of secrets, and anything that announces itself as a seed phrase. Read by the daemon (cli/lib/secrets.mjs) and by Harness's server, so both check the same list.",
|
|
2
|
+
"about": "What must never leave in a message to someone else's agent or an outside place: keys and tokens by their well-known shapes, private-key blocks, env-style assignments of secrets, and anything that announces itself as a seed phrase. A bare 64-hex value is far more often a SHA-256 or transaction hash than a key, so it holds a message only when labelled as a key; unlabelled (maskOnly) it is still masked wherever text or an image is masked before it leaves, where hiding a hash costs nothing. Read by the daemon (cli/lib/secrets.mjs) and by Harness's server, so both check the same list.",
|
|
3
3
|
"patterns": [
|
|
4
4
|
{
|
|
5
5
|
"reason": "a private key block",
|
|
@@ -31,10 +31,16 @@
|
|
|
31
31
|
"source": "\\beyJ[A-Za-z0-9_-]{10,}\\.[A-Za-z0-9_-]{10,}\\.[A-Za-z0-9_-]{10,}\\b",
|
|
32
32
|
"flags": ""
|
|
33
33
|
},
|
|
34
|
+
{
|
|
35
|
+
"reason": "a 32-byte hex key",
|
|
36
|
+
"source": "\\b(private|priv|secret|signing|wallet)[ _-]?key\\b[^\\n]{0,40}?\\b(0x)?[0-9a-fA-F]{64}\\b",
|
|
37
|
+
"flags": "i"
|
|
38
|
+
},
|
|
34
39
|
{
|
|
35
40
|
"reason": "a 32-byte hex key",
|
|
36
41
|
"source": "\\b(0x)?[0-9a-fA-F]{64}\\b",
|
|
37
|
-
"flags": ""
|
|
42
|
+
"flags": "",
|
|
43
|
+
"maskOnly": true
|
|
38
44
|
},
|
|
39
45
|
{
|
|
40
46
|
"reason": "a Harness connection token",
|
package/lib/secrets.mjs
CHANGED
|
@@ -9,13 +9,29 @@ const PATTERNS = JSON.parse(
|
|
|
9
9
|
readFileSync(new URL("./secretPatterns.json", import.meta.url), "utf8")
|
|
10
10
|
).patterns.map((pattern) => ({
|
|
11
11
|
reason: pattern.reason,
|
|
12
|
+
maskOnly: pattern.maskOnly === true,
|
|
12
13
|
test: new RegExp(pattern.source, pattern.flags),
|
|
13
14
|
}));
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
const HOLDING = PATTERNS.filter((pattern) => !pattern.maskOnly);
|
|
17
|
+
|
|
18
|
+
const firstReason = (patterns, text) => {
|
|
17
19
|
const value = String(text || "");
|
|
18
|
-
for (const pattern of
|
|
20
|
+
for (const pattern of patterns)
|
|
19
21
|
if (pattern.test.test(value)) return pattern.reason;
|
|
20
22
|
return null;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/** The reason a text must be held, or null when nothing in it looks like a secret. */
|
|
26
|
+
export function secretReason(text) {
|
|
27
|
+
return firstReason(HOLDING, text);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The reason a value is masked before it leaves (the firewall, image redaction, a sign-in's output), or null. Wider
|
|
32
|
+
* than secretReason: a shape that is a hash as often as a key is hidden here, where hiding a hash costs nothing, but
|
|
33
|
+
* does not hold a whole message.
|
|
34
|
+
*/
|
|
35
|
+
export function maskReason(text) {
|
|
36
|
+
return firstReason(PATTERNS, text);
|
|
21
37
|
}
|
|
@@ -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
|
@@ -4,6 +4,7 @@ import sqliteWasm from "node-sqlite3-wasm";
|
|
|
4
4
|
import { parseSession } from "./parsers.mjs";
|
|
5
5
|
import { provenanceFor } from "./provenance.mjs";
|
|
6
6
|
import { BOOK_TABLES } from "./book.mjs";
|
|
7
|
+
import { PROPOSERS } from "./members.mjs";
|
|
7
8
|
|
|
8
9
|
const SCHEMA_VERSION = 11;
|
|
9
10
|
const INDEX_FORMAT_VERSION = 2;
|
|
@@ -182,7 +183,8 @@ export function openStore(file) {
|
|
|
182
183
|
workspaces text not null,
|
|
183
184
|
daily_cap integer not null,
|
|
184
185
|
set_at text not null,
|
|
185
|
-
proposers text not null default '[]'
|
|
186
|
+
proposers text not null default '[]',
|
|
187
|
+
proposers_set integer not null default 0
|
|
186
188
|
);
|
|
187
189
|
create table if not exists board_goals (
|
|
188
190
|
goal_id text primary key,
|
|
@@ -462,6 +464,16 @@ export function openStore(file) {
|
|
|
462
464
|
db.exec(
|
|
463
465
|
"alter table board_standing add column proposers text not null default '[]'"
|
|
464
466
|
);
|
|
467
|
+
// Until October 31 nobody started a coding agent unless named; a rule naming someone is the person's own choice, except
|
|
468
|
+
// one naming both agents that could then be named (Grok Bot and Muse), which meant all of them.
|
|
469
|
+
if (
|
|
470
|
+
!db
|
|
471
|
+
.all("pragma table_info(board_standing)")
|
|
472
|
+
.some((column) => column.name === "proposers_set")
|
|
473
|
+
)
|
|
474
|
+
db.exec(
|
|
475
|
+
'alter table board_standing add column proposers_set integer not null default 0; update board_standing set proposers_set = 1 where proposers not in (\'[]\', \'["grok-bot","muse"]\', \'["muse","grok-bot"]\')'
|
|
476
|
+
);
|
|
465
477
|
if (
|
|
466
478
|
!db
|
|
467
479
|
.all("pragma table_info(board_contributions)")
|
|
@@ -1133,8 +1145,10 @@ export function openStore(file) {
|
|
|
1133
1145
|
});
|
|
1134
1146
|
return this.getTask(parentId);
|
|
1135
1147
|
},
|
|
1136
|
-
// Run authority is a separate write from the post: an agent may ask for a run, only the user grants it.
|
|
1137
|
-
|
|
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 } = {}) {
|
|
1138
1152
|
if (this.getThread(id))
|
|
1139
1153
|
return {
|
|
1140
1154
|
ok: false,
|
|
@@ -1153,9 +1167,12 @@ export function openStore(file) {
|
|
|
1153
1167
|
const now = new Date().toISOString();
|
|
1154
1168
|
const written = execute(
|
|
1155
1169
|
"run",
|
|
1156
|
-
`update board_tasks set run_authorized_by = @agent, run_authorized_at = @now, updated_at = @now, version = version + 1
|
|
1157
|
-
|
|
1158
|
-
|
|
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 }
|
|
1159
1176
|
);
|
|
1160
1177
|
if (written.changes === 1) return { ok: true, task: this.getTask(id) };
|
|
1161
1178
|
return conflict(this.getTask(id), agent, null, (task) =>
|
|
@@ -1166,9 +1183,9 @@ export function openStore(file) {
|
|
|
1166
1183
|
: `task is ${task.status}`
|
|
1167
1184
|
);
|
|
1168
1185
|
},
|
|
1169
|
-
// Standing permission: an agent starts the work the person or
|
|
1170
|
-
// default it covers
|
|
1171
|
-
//
|
|
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.
|
|
1172
1189
|
setStanding(agent, mode, workspaces = [], dailyCap = DEFAULT_DAILY_RUNS) {
|
|
1173
1190
|
execute(
|
|
1174
1191
|
"run",
|
|
@@ -1185,11 +1202,11 @@ export function openStore(file) {
|
|
|
1185
1202
|
resetStanding(agent) {
|
|
1186
1203
|
const row = execute(
|
|
1187
1204
|
"get",
|
|
1188
|
-
"select
|
|
1205
|
+
"select proposers_set from board_standing where agent = ?",
|
|
1189
1206
|
agent
|
|
1190
1207
|
);
|
|
1191
1208
|
if (!row) return false;
|
|
1192
|
-
if (
|
|
1209
|
+
if (row.proposers_set)
|
|
1193
1210
|
return (
|
|
1194
1211
|
execute(
|
|
1195
1212
|
"run",
|
|
@@ -1205,12 +1222,13 @@ export function openStore(file) {
|
|
|
1205
1222
|
);
|
|
1206
1223
|
},
|
|
1207
1224
|
// The person's own agents elsewhere whose clean asks in a thread start this agent's turn on its standing permission
|
|
1208
|
-
// (runAuthority.mjs admitProposed). Its mode, folders and daily limit stay as
|
|
1225
|
+
// (runAuthority.mjs admitProposed), all of them until the person chooses. Its mode, folders and daily limit stay as
|
|
1226
|
+
// they are.
|
|
1209
1227
|
setStandingProposers(agent, proposers) {
|
|
1210
1228
|
execute(
|
|
1211
1229
|
"run",
|
|
1212
|
-
`insert into board_standing(agent, mode, workspaces, daily_cap, set_at, proposers) values(?, 'default', '[]', ?, ?,
|
|
1213
|
-
on conflict(agent) do update set proposers = excluded.proposers, set_at = excluded.set_at`,
|
|
1230
|
+
`insert into board_standing(agent, mode, workspaces, daily_cap, set_at, proposers, proposers_set) values(?, 'default', '[]', ?, ?, ?, 1)
|
|
1231
|
+
on conflict(agent) do update set proposers = excluded.proposers, proposers_set = 1, set_at = excluded.set_at`,
|
|
1214
1232
|
agent,
|
|
1215
1233
|
DEFAULT_DAILY_RUNS,
|
|
1216
1234
|
new Date().toISOString(),
|
|
@@ -1242,7 +1260,9 @@ export function openStore(file) {
|
|
|
1242
1260
|
workspaces,
|
|
1243
1261
|
daily_cap: row ? Number(row.daily_cap) : DEFAULT_DAILY_RUNS,
|
|
1244
1262
|
set_at: row?.set_at || null,
|
|
1245
|
-
proposers:
|
|
1263
|
+
proposers: row?.proposers_set
|
|
1264
|
+
? JSON.parse(row.proposers)
|
|
1265
|
+
: [...PROPOSERS],
|
|
1246
1266
|
runs_today:
|
|
1247
1267
|
Number(this.meta(`prompt-quota:${since}:${agent}`) || "0") +
|
|
1248
1268
|
Number(
|
|
@@ -2989,7 +3009,8 @@ export function openStore(file) {
|
|
|
2989
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
|
|
2990
3010
|
* agent, started on its agent's standing permission: the rule read, the day's runs counted and the row authorized in
|
|
2991
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
|
|
2992
|
-
* 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).
|
|
2993
3014
|
* `scratch`: where a posted task naming no folder runs on this computer; another computer's makes its own. The
|
|
2994
3015
|
* receipt keeps the rule's revision, the folder checked, and the agent, folder and computer it was admitted to run
|
|
2995
3016
|
* with, for the check again before it starts (runAuthority.mjs proposedHold). Null when
|
|
@@ -2997,7 +3018,15 @@ export function openStore(file) {
|
|
|
2997
3018
|
*/
|
|
2998
3019
|
authorizeProposed(
|
|
2999
3020
|
id,
|
|
3000
|
-
{
|
|
3021
|
+
{
|
|
3022
|
+
agent,
|
|
3023
|
+
proposer,
|
|
3024
|
+
since,
|
|
3025
|
+
covered,
|
|
3026
|
+
pastLimit,
|
|
3027
|
+
folder = null,
|
|
3028
|
+
scratch = null,
|
|
3029
|
+
}
|
|
3001
3030
|
) {
|
|
3002
3031
|
db.exec("begin immediate");
|
|
3003
3032
|
try {
|
|
@@ -3009,7 +3038,7 @@ export function openStore(file) {
|
|
|
3009
3038
|
? "not-proposer"
|
|
3010
3039
|
: !covered(rule)
|
|
3011
3040
|
? "outside"
|
|
3012
|
-
: rule
|
|
3041
|
+
: pastLimit(rule)
|
|
3013
3042
|
? "cap"
|
|
3014
3043
|
: null;
|
|
3015
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
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
member,
|
|
11
11
|
nameOf,
|
|
12
12
|
resolveMember,
|
|
13
|
+
speaksThroughHarness,
|
|
13
14
|
} from "./members.mjs";
|
|
14
15
|
import { LIVE_AGENTS, sessionOfProcess } from "./live.mjs";
|
|
15
16
|
import {
|
|
@@ -511,6 +512,7 @@ export function createTaskCommands({
|
|
|
511
512
|
!goalParent &&
|
|
512
513
|
!posterFolder &&
|
|
513
514
|
!request.thread &&
|
|
515
|
+
request.inSession !== true &&
|
|
514
516
|
provenance.trust === "user" &&
|
|
515
517
|
authority.RUNNERS.has(target) &&
|
|
516
518
|
installedAgents.includes(target)
|
|
@@ -653,6 +655,12 @@ export function createTaskCommands({
|
|
|
653
655
|
getProjects()?.channelOpened(task.id);
|
|
654
656
|
}
|
|
655
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));
|
|
656
664
|
if (deferred) {
|
|
657
665
|
try {
|
|
658
666
|
if (!dispatches) throw new Error("typed dispatch is unavailable");
|
|
@@ -751,15 +759,25 @@ export function createTaskCommands({
|
|
|
751
759
|
...(started ? { standing: started } : {}),
|
|
752
760
|
...(note ? { note } : {}),
|
|
753
761
|
});
|
|
754
|
-
// A task one of the person's own agents
|
|
755
|
-
//
|
|
756
|
-
// was placed on (runAuthority.mjs admitPosted),
|
|
762
|
+
// A task one of the person's own agents posted for a coding agent, the way that agent speaks (through Harness's
|
|
763
|
+
// server, or from a process here): when the person has not taken that agent off the coding agent's standing
|
|
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.
|
|
768
|
+
const cameAsItSpeaks = speaksThroughHarness(agent)
|
|
769
|
+
? request[HOSTED_CALLER] === true
|
|
770
|
+
: !noGo;
|
|
757
771
|
const proposed =
|
|
758
|
-
|
|
772
|
+
cameAsItSpeaks &&
|
|
759
773
|
PROPOSERS.includes(agent) &&
|
|
774
|
+
task.trust === "agent" &&
|
|
760
775
|
!thread &&
|
|
761
|
-
|
|
762
|
-
|
|
776
|
+
(goalParent ||
|
|
777
|
+
!request.parentId ||
|
|
778
|
+
(parentTask?.kind === "task" && !store.getThread(parentTask.id))) &&
|
|
779
|
+
!standing?.started &&
|
|
780
|
+
request.inSession !== true &&
|
|
763
781
|
authority.RUNNERS.has(target)
|
|
764
782
|
? store.getTask(task.id)
|
|
765
783
|
: null;
|
|
@@ -776,10 +794,12 @@ export function createTaskCommands({
|
|
|
776
794
|
proposed,
|
|
777
795
|
{
|
|
778
796
|
proposer: agent,
|
|
779
|
-
hosted: true,
|
|
797
|
+
hosted: request[HOSTED_CALLER] === true,
|
|
798
|
+
here: !noGo,
|
|
780
799
|
guard,
|
|
781
800
|
limited,
|
|
782
801
|
window: request.fromWindow === true,
|
|
802
|
+
handoffs,
|
|
783
803
|
},
|
|
784
804
|
{ scratch }
|
|
785
805
|
);
|
|
@@ -794,6 +814,9 @@ export function createTaskCommands({
|
|
|
794
814
|
notifyBoard(store.getTask(task.id));
|
|
795
815
|
return posted(started);
|
|
796
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,
|
|
797
820
|
};
|
|
798
821
|
}
|
|
799
822
|
outcome = posted(standing);
|
|
@@ -1222,11 +1245,23 @@ export function createTaskCommands({
|
|
|
1222
1245
|
notifyBoard(gone);
|
|
1223
1246
|
}
|
|
1224
1247
|
return { ok: true, removed: removed.ids };
|
|
1225
|
-
} else if (request.command === "board.run")
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
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
|
+
}
|
|
1230
1265
|
// A worker running the work meant for it (machineRuns.mjs): what is authorized for its agents, taking one in its
|
|
1231
1266
|
// agent's name, the run's session, and its end. Only for that computer; the Start stays home's.
|
|
1232
1267
|
else if (
|
package/lib/team.mjs
CHANGED
|
@@ -316,6 +316,20 @@ export function createTeam({ store, log = () => {} }) {
|
|
|
316
316
|
const pieceOf = (current) => current.pieces[current.piece];
|
|
317
317
|
const stepsOfNow = (current) => pieceOf(current)?.steps ?? [];
|
|
318
318
|
|
|
319
|
+
// Old boards can predate the capability check used when accepting a route.
|
|
320
|
+
// Temporary computer availability is handled by place; an impossible saved
|
|
321
|
+
// assignment needs a new model-selected route, rather than repeated Resume.
|
|
322
|
+
const needsRouting = (goalId) => {
|
|
323
|
+
const current = read(goalId);
|
|
324
|
+
if (!current || current.step === "done") return false;
|
|
325
|
+
return stepsOfNow(current).some(
|
|
326
|
+
(step) =>
|
|
327
|
+
step.id === "make" &&
|
|
328
|
+
TEAM.fileSpecialties.includes(step.specialty) &&
|
|
329
|
+
step.agents.some((agent) => member(agent)?.runs !== "machine")
|
|
330
|
+
);
|
|
331
|
+
};
|
|
332
|
+
|
|
319
333
|
// A routed handoff that never started need not outlive the step that asked
|
|
320
334
|
// for it. Other jobs are independent work: their mere presence in this room
|
|
321
335
|
// is not permission to cancel them.
|
|
@@ -520,6 +534,7 @@ export function createTeam({ store, log = () => {} }) {
|
|
|
520
534
|
return null;
|
|
521
535
|
}
|
|
522
536
|
const { unfilled, steps, rigor, split } = checked;
|
|
537
|
+
const previous = needsRouting(goalId) ? read(goalId) : null;
|
|
523
538
|
const fresh = {
|
|
524
539
|
version: 2,
|
|
525
540
|
rigor,
|
|
@@ -537,6 +552,8 @@ export function createTeam({ store, log = () => {} }) {
|
|
|
537
552
|
stepAt: begun,
|
|
538
553
|
history: started(fresh, steps[0].id, begun),
|
|
539
554
|
};
|
|
555
|
+
if (previous)
|
|
556
|
+
store.meta(`team-retired:${goalId}:${kept.at}`, JSON.stringify(previous));
|
|
540
557
|
write(goalId, kept);
|
|
541
558
|
post?.(
|
|
542
559
|
[
|
|
@@ -1078,6 +1095,7 @@ export function createTeam({ store, log = () => {} }) {
|
|
|
1078
1095
|
|
|
1079
1096
|
return {
|
|
1080
1097
|
plan,
|
|
1098
|
+
needsRouting,
|
|
1081
1099
|
machineFor,
|
|
1082
1100
|
place,
|
|
1083
1101
|
sendBack,
|
package/lib/threadActions.mjs
CHANGED
|
@@ -225,13 +225,14 @@ 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
|
-
// How the ask came, for one from the person's own agents
|
|
230
|
-
//
|
|
230
|
+
// How the ask came, for one from the person's own agents: in a thread another agent wrote, its turn may start
|
|
231
|
+
// on the agent's standing permission (threadRuns.mjs admitProposal). `here`: from a process on this computer.
|
|
231
232
|
proposal:
|
|
232
233
|
guard === undefined
|
|
233
234
|
? null
|
|
234
|
-
: { hosted: server, guard, limited, window },
|
|
235
|
+
: { hosted: server, here: !hosted, guard, limited, window },
|
|
235
236
|
});
|
|
236
237
|
const original =
|
|
237
238
|
typeof assigned === "string" ? store.getTask(assigned) : null;
|
|
@@ -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.
|
package/lib/threadAuthority.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { member, nameOf } from "./members.mjs";
|
|
1
|
+
import { member, nameOf, speaksThroughHarness } from "./members.mjs";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Whose go a run in a thread carries. Work a thread starts on its own runs on the thread's authority only when the
|
|
@@ -6,16 +6,16 @@ import { member, nameOf } from "./members.mjs";
|
|
|
6
6
|
* Start like any agent-written run.
|
|
7
7
|
*
|
|
8
8
|
* In such a thread the person's own agents asking for work carry the person's go, as the person's @mention does:
|
|
9
|
-
* Harness in the person's own window (its words come sealed from their device), and the
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* thread's authority only where it can be held in: Claude Code
|
|
18
|
-
* made. Anything else waits.
|
|
9
|
+
* Harness in the person's own window (its words come sealed from their device), and the agents on this computer
|
|
10
|
+
* (coding agents, OpenClaw, Hermes); full permissions, Stop always there. The rounds it coordinates keep the go (the
|
|
11
|
+
* daemon's handOn). An agent the person set to wait still waits. The person's agents whose words come through Harness's
|
|
12
|
+
* server (Grok Bot, Muse, Bankr, Quotient, and Harness's server answering for a closed window) carry it too, for words the
|
|
13
|
+
* injection guard on this computer read, since only what actually needs the person should wait for them; Bankr spends
|
|
14
|
+
* only under its own approval and limits. A flag is a label for readers and still carries the go: the guard cannot tell
|
|
15
|
+
* agents coordinating from planted orders, so most posts it flags are ordinary work. Words it reads as orders (a hold)
|
|
16
|
+
* carry no go from any agent. Harness's files and renders arrive unread and carry none. Work any other agent asked for
|
|
17
|
+
* (another person's agent, orders) runs on a thread's authority only where it can be held in: Claude Code or Codex in
|
|
18
|
+
* restricted mode, in a copy of the folder this daemon made. Anything else waits.
|
|
19
19
|
*
|
|
20
20
|
* `standingRules()` and `within(folder, root)` come from the run authority (runAuthority.mjs); `worktreeRoot` is where
|
|
21
21
|
* this daemon makes its copies of folders, and `projectRoot` where it makes a shared project's lanes (projects.mjs,
|
|
@@ -28,8 +28,9 @@ export function createThreadAuthority({
|
|
|
28
28
|
worktreeRoot,
|
|
29
29
|
projectRoot,
|
|
30
30
|
}) {
|
|
31
|
+
// The agents with a restricted mode (runner.mjs): Claude Code and Codex.
|
|
31
32
|
const restrictable = (agent, folder) =>
|
|
32
|
-
agent === "claude-code" &&
|
|
33
|
+
(agent === "claude-code" || agent === "codex") &&
|
|
33
34
|
Boolean(folder) &&
|
|
34
35
|
(within(folder, worktreeRoot) ||
|
|
35
36
|
(Boolean(projectRoot) && within(folder, projectRoot)));
|
|
@@ -43,13 +44,14 @@ export function createThreadAuthority({
|
|
|
43
44
|
return entry?.road === "hosted" && entry.runs === "self" && entry.target;
|
|
44
45
|
};
|
|
45
46
|
|
|
46
|
-
const
|
|
47
|
-
guard
|
|
47
|
+
const guardPasses = (guard) =>
|
|
48
|
+
Boolean(guard) && !guard.unavailable && guard.verdict !== "hold";
|
|
49
|
+
const readAsOrders = (guard) => guard?.verdict === "hold";
|
|
48
50
|
|
|
49
|
-
// Whose asks carry the person's go on the guard's reading: the person's agents
|
|
50
|
-
//
|
|
51
|
+
// Whose asks carry the person's go on the guard's reading: the person's agents whose words come through Harness's
|
|
52
|
+
// server, Harness's own among them while their window is closed.
|
|
51
53
|
const readByGuard = (asker, hosted) =>
|
|
52
|
-
fromElsewhere(asker) || (
|
|
54
|
+
fromElsewhere(asker) || (hosted && speaksThroughHarness(asker));
|
|
53
55
|
|
|
54
56
|
/** Whether `asker`'s request for `agent` carries the person's go. `hosted`: the request came through Harness. */
|
|
55
57
|
// A coding agent here asking from a restricted run or a review carries no go: that run had none to pass on.
|
|
@@ -62,25 +64,26 @@ export function createThreadAuthority({
|
|
|
62
64
|
) =>
|
|
63
65
|
asker === "user" ||
|
|
64
66
|
(!window &&
|
|
67
|
+
!readAsOrders(guard) &&
|
|
65
68
|
((asker === "harness" && !hosted && !limited) ||
|
|
66
|
-
(!hosted && !limited && member(asker)?.
|
|
67
|
-
(readByGuard(asker, hosted) &&
|
|
69
|
+
(!hosted && !limited && member(asker)?.road === "local") ||
|
|
70
|
+
(readByGuard(asker, hosted) && guardPasses(guard))) &&
|
|
68
71
|
!setToWait(agent));
|
|
69
72
|
|
|
70
73
|
/** What the thread says when the guard keeps an agent's request from carrying the person's go; null otherwise. */
|
|
71
74
|
const guardWait = (asker, agent, guard, { hosted = false } = {}) => {
|
|
72
|
-
if (
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
if (asker === "user" || setToWait(agent)) return null;
|
|
76
|
+
if (readAsOrders(guard))
|
|
77
|
+
return `The guard read ${nameOf(asker)}'s words as orders aimed at your agents, so ${nameOf(agent)} waits for your Start. Read them before you start it.`;
|
|
78
|
+
if (!readByGuard(asker, hosted) || guardPasses(guard)) return null;
|
|
79
|
+
return `The guard that reads ${nameOf(asker)}'s words for planted instructions is not running on this computer, so ${nameOf(agent)} waits for your Start.`;
|
|
77
80
|
};
|
|
78
81
|
|
|
79
82
|
/** Why work another agent asked of `agent` waits for the person's Start. */
|
|
80
83
|
const restrictedWait = (agent) =>
|
|
81
84
|
setToWait(agent)
|
|
82
85
|
? `${nameOf(agent)} is set to wait for your Start.`
|
|
83
|
-
: agent === "claude-code"
|
|
86
|
+
: agent === "claude-code" || agent === "codex"
|
|
84
87
|
? `${nameOf(agent)} would work in your own folder here, not a copy, so work another agent asked for waits for your Start.`
|
|
85
88
|
: `${nameOf(agent)} has no restricted mode, so work another agent asked of it waits for your Start.`;
|
|
86
89
|
|
|
@@ -101,6 +104,8 @@ export function createThreadAuthority({
|
|
|
101
104
|
fromElsewhere,
|
|
102
105
|
personsGo,
|
|
103
106
|
guardWait,
|
|
107
|
+
guardPasses,
|
|
108
|
+
readAsOrders,
|
|
104
109
|
restrictedWait,
|
|
105
110
|
threadMayRun,
|
|
106
111
|
};
|