tryharness 0.7.53 → 0.7.57
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 +23 -19
- package/assets/dsh-plugin.mjs +72 -0
- package/assets/opencode-plugin.js +4 -3
- package/cli.mjs +484 -90
- package/lib/activity.mjs +10 -10
- package/lib/adapters.mjs +173 -222
- package/lib/agentBinaries.mjs +71 -0
- package/lib/agentRuntimeConfig.mjs +1 -1
- package/lib/agentRuntimes.mjs +34 -18
- package/lib/agentSignIn.mjs +456 -0
- package/lib/answers.mjs +5 -5
- package/lib/archetypes.d.ts +64 -0
- package/lib/archetypes.js +989 -0
- package/lib/asks.mjs +4 -4
- package/lib/audit.mjs +666 -0
- package/lib/backupSetup.mjs +143 -0
- package/lib/boardAccess.mjs +24 -11
- package/lib/boardBackup.mjs +283 -0
- package/lib/boardFileCommands.mjs +6 -6
- package/lib/boardFiles.mjs +13 -12
- package/lib/boardMirror.mjs +124 -25
- package/lib/boardProtocol.json +88 -2
- package/lib/boardWaits.mjs +101 -0
- package/lib/book.mjs +659 -0
- package/lib/bridge.mjs +6 -6
- package/lib/cards.mjs +138 -28
- package/lib/cloudAgents.mjs +216 -0
- package/lib/cloudAi.mjs +1312 -0
- package/lib/cloudAssistants.mjs +242 -0
- package/lib/cloudBoot.mjs +119 -0
- package/lib/cloudSave.mjs +197 -0
- package/lib/cloudSsh.mjs +178 -0
- package/lib/commands.mjs +7 -2
- package/lib/context.mjs +19 -5
- package/lib/contractGate.mjs +399 -0
- package/lib/control-client.mjs +9 -1
- package/lib/controlSocket.mjs +86 -0
- package/lib/coordinator.mjs +252 -144
- package/lib/daemon.mjs +1351 -2767
- package/lib/desk.mjs +240 -0
- package/lib/desktop.mjs +178 -74
- package/lib/directLink.mjs +16 -5
- package/lib/environment.mjs +2 -1
- package/lib/environments.mjs +247 -9
- package/lib/firewall.mjs +9 -9
- package/lib/folders.mjs +20 -16
- package/lib/frames.mjs +2 -3
- package/lib/gitHost.mjs +174 -0
- package/lib/goalCommands.mjs +25 -7
- package/lib/goals.mjs +7 -7
- package/lib/guestRequests.mjs +94 -0
- package/lib/handoffs.mjs +8 -7
- package/lib/handover.mjs +4 -4
- package/lib/harnessModel.mjs +6 -6
- package/lib/harnessOffers.mjs +266 -0
- package/lib/hookDialects.mjs +298 -0
- package/lib/inference.mjs +26 -8
- package/lib/jobAnswers.mjs +190 -0
- package/lib/landed.mjs +887 -0
- package/lib/lane.mjs +42 -11
- package/lib/lessons.mjs +16 -16
- package/lib/library.mjs +3 -3
- package/lib/lineup.mjs +3 -0
- package/lib/linkRelay.mjs +574 -0
- package/lib/live.mjs +284 -13
- package/lib/localAgentAsk.mjs +74 -0
- package/lib/localStack.mjs +536 -0
- package/lib/localmodels.mjs +6 -4
- package/lib/loopBackstop.mjs +4 -4
- package/lib/machineIdentity.mjs +9 -1
- package/lib/machineRoutes.mjs +181 -2
- package/lib/machineRuns.mjs +76 -1
- package/lib/machineSeal.mjs +39 -12
- package/lib/mcp-stdio.mjs +163 -27
- package/lib/mcpRelay.mjs +1 -1
- package/lib/members.json +29 -2
- package/lib/members.mjs +1 -1
- package/lib/models.mjs +85 -31
- package/lib/museSession.mjs +21 -13
- package/lib/nativeHost.mjs +36 -8
- package/lib/neovim.mjs +126 -0
- package/lib/network.mjs +50 -5
- package/lib/notify.mjs +7 -5
- package/lib/nudge.mjs +50 -19
- package/lib/ocr.mjs +9 -9
- package/lib/onboard.mjs +26 -20
- package/lib/oneLine.mjs +7 -7
- package/lib/ownMachines.mjs +1223 -140
- package/lib/pairing.mjs +60 -16
- package/lib/paths.mjs +19 -1
- package/lib/peerProcess.mjs +124 -0
- package/lib/personModel.mjs +89 -0
- package/lib/personNotices.mjs +151 -0
- package/lib/phones.mjs +538 -31
- package/lib/placeCommands.mjs +4 -4
- package/lib/places.mjs +400 -12
- package/lib/profile.mjs +67 -14
- package/lib/projectGit.mjs +158 -14
- package/lib/projectPieces.mjs +902 -0
- package/lib/projectSettings.mjs +7 -4
- package/lib/projects.mjs +384 -62
- package/lib/provenance.mjs +5 -1
- package/lib/proxyLinks.mjs +267 -0
- package/lib/reactions.mjs +7 -5
- package/lib/readiness.mjs +145 -23
- package/lib/record.mjs +128 -0
- package/lib/redact.mjs +4 -4
- package/lib/relayLimits.mjs +62 -0
- package/lib/release.mjs +170 -0
- package/lib/releaseKeys.json +6 -0
- package/lib/repoLinks.mjs +4 -4
- package/lib/roomChannels.mjs +24 -0
- package/lib/roomPage.mjs +1 -1
- package/lib/runAuthority.mjs +101 -0
- package/lib/runBrief.mjs +19 -8
- package/lib/runWorker.mjs +31 -7
- package/lib/runner.mjs +223 -29
- package/lib/runtime-install.mjs +143 -9
- package/lib/schedules.mjs +2 -2
- package/lib/screens.mjs +1 -1
- package/lib/sealed.mjs +11 -2
- package/lib/sealedThreads.mjs +671 -0
- package/lib/secretPatterns.json +1 -1
- package/lib/secrets.mjs +4 -4
- package/lib/seen.mjs +6 -6
- package/lib/serverWords.mjs +175 -0
- package/lib/service.mjs +22 -12
- package/lib/sessionControl.mjs +378 -90
- package/lib/specialties.json +74 -0
- package/lib/specialties.mjs +477 -0
- package/lib/specialtyKeys.d.ts +3 -0
- package/lib/specialtyKeys.js +57 -0
- package/lib/specialtyNotice.mjs +147 -0
- package/lib/specialtySnapshot.mjs +138 -0
- package/lib/speech.mjs +5 -5
- package/lib/store.mjs +420 -36
- package/lib/stuck.mjs +1 -1
- package/lib/swarm.mjs +304 -37
- package/lib/swarmDevices.mjs +319 -0
- package/lib/swarmMemory.mjs +27 -25
- package/lib/t3.mjs +24 -15
- package/lib/taskCommands.mjs +80 -20
- package/lib/taskRooms.mjs +125 -0
- package/lib/taskRuns.mjs +45 -3
- package/lib/team.json +255 -148
- package/lib/team.mjs +554 -190
- package/lib/threadActions.mjs +315 -0
- package/lib/threadAuthority.mjs +101 -0
- package/lib/threadBriefs.mjs +178 -0
- package/lib/threadLine.mjs +116 -0
- package/lib/threadRuns.mjs +209 -50
- package/lib/threadView.mjs +20 -7
- package/lib/usageTotals.mjs +2 -3
- package/lib/vault.mjs +101 -10
- package/lib/vaultCloud.mjs +2 -2
- package/lib/vaultCommands.mjs +15 -6
- package/lib/vaultTools.js +2 -2
- package/lib/verdicts.mjs +328 -0
- package/lib/wakes.mjs +1 -1
- package/lib/watches.mjs +2 -2
- package/lib/windowAsks.mjs +13 -5
- package/lib/worktrees.mjs +157 -25
- package/npm-shrinkwrap.json +1093 -0
- package/package.json +12 -11
- package/release.json +220 -0
- package/lib/modelTiers.json +0 -1183
- package/lib/modelTiers.mjs +0 -133
package/lib/coordinator.mjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { LOCAL_DECIDERS, askLocalAgent } from "./localAgentAsk.mjs";
|
|
2
|
+
import { roundFields } from "./cards.mjs";
|
|
3
3
|
import { MACHINE_RUNNERS, MEMBERS, TAGGED_ONLY, nameOf } from "./members.mjs";
|
|
4
4
|
import { LEAD_TIMES } from "./schedules.mjs";
|
|
5
|
+
import { SPECIALTIES, pinnedFor, specialtyName } from "./specialties.mjs";
|
|
6
|
+
import { TEAM } from "./team.mjs";
|
|
5
7
|
|
|
6
8
|
// The swarm's coordinator, run from this machine whether or not a Harness window is open. When a thread goes quiet
|
|
7
9
|
// (no run left going) and has new posts the coordinator has not looked at, it runs one round: it gathers the facts
|
|
@@ -11,13 +13,13 @@ import { LEAD_TIMES } from "./schedules.mjs";
|
|
|
11
13
|
// agent, a question for the person, a part left behind, a pause. Every round is recorded with its facts and cost.
|
|
12
14
|
// The person's own message to the swarm (`@swarm`, or one in a thread that names no agent) gets its round at once, even
|
|
13
15
|
// while agents work, and every agent with a part in it is brought in together (an assembly). When Harness cannot decide
|
|
14
|
-
// that round, or finds no part for anyone in it, every agent that can work there hears the message as the
|
|
15
|
-
//
|
|
16
|
+
// that round, or finds no part for anyone in it, every agent that can work there hears the message as the person wrote
|
|
17
|
+
// it: Harness is never the only way the person's words reach their swarm.
|
|
16
18
|
// A round Harness cannot decide (an error, a dropped connection) is decided by a backup: the person's coding agents on
|
|
17
|
-
// this computer with their tools off, most finished work first
|
|
18
|
-
//
|
|
19
|
-
//
|
|
20
|
-
//
|
|
19
|
+
// this computer with their tools off, most finished work first, because the main orchestrator cannot be flaky and needs
|
|
20
|
+
// a backup. The same rules hold whoever decides: the swarm acts on its own and asks the person only for spending past
|
|
21
|
+
// the thread's limit, something outward-facing or hard to undo, a secret or a change to what the goal is for; a
|
|
22
|
+
// question already put to them waits for its answer.
|
|
21
23
|
|
|
22
24
|
const CODING = new Set(MACHINE_RUNNERS);
|
|
23
25
|
// The agents with a read-only switch (runner.mjs, review in the roster): only they can be handed a review.
|
|
@@ -28,12 +30,14 @@ const REVIEWERS = new Set(
|
|
|
28
30
|
const TAGGED = new Set(TAGGED_ONLY);
|
|
29
31
|
const TRANSCRIPT_POSTS = 30;
|
|
30
32
|
// The goal's own updates go to the round as the goal itself (goals.mjs), not as posts. (A goal room's opening post,
|
|
31
|
-
// kind goal, is the person's request and stays.)
|
|
32
|
-
|
|
33
|
+
// kind goal, is the person's request and stays.) A guest's words are a stranger's: they start no round and are not in
|
|
34
|
+
// one, so a round never hands work on with the person's go because of them (security audit P6, October 25); the
|
|
35
|
+
// agents read them in the thread, marked as another person's.
|
|
36
|
+
const QUIET_KINDS = new Set(["note", "held", "round", "goal_update", "guest"]);
|
|
33
37
|
// What a question to the person may be about (src/server/swarm/coordinator.ts ASK_KIND); anything else an agent decides.
|
|
34
38
|
const ASK_CATEGORIES = new Set(["spend", "outward", "secret", "scope"]);
|
|
35
39
|
// Words cut short of the server's limits: the scrub before sending can make a cut text longer than it was ("$2.40"
|
|
36
|
-
// becomes "[AMOUNT_1]"), which once took a round past the limit
|
|
40
|
+
// becomes "[AMOUNT_1]"), which once took a round past the limit.
|
|
37
41
|
const RELATED_CHARS = 3_600,
|
|
38
42
|
OBJECTIVE_CHARS = 450,
|
|
39
43
|
RESULT_CHARS = 3_600,
|
|
@@ -49,8 +53,8 @@ const COORDINATOR_KINDS = new Set(["question", "open_item"]);
|
|
|
49
53
|
/**
|
|
50
54
|
* Who a post in a thread is from, as a round or a task reads it: "coordinator" for the thread's coordinator (its
|
|
51
55
|
* questions, hand-ons and assemblies), told apart from Harness the agent, whose results, files and progress stay
|
|
52
|
-
* "harness"
|
|
53
|
-
*
|
|
56
|
+
* "harness" in every case: when the two were not told apart, answers to the coordinator's questions brought Harness
|
|
57
|
+
* the agent in.
|
|
54
58
|
*/
|
|
55
59
|
export const speakerOf = (store, thread, post) =>
|
|
56
60
|
post.author === thread.goal.facilitator &&
|
|
@@ -81,71 +85,17 @@ In briefs, refer to earlier posts by their seq number instead of restating figur
|
|
|
81
85
|
The goal: statement is the whole aim in the person's terms; criteria are one to five checks a person or code can verify. A criterion is met only when a post shows the result, not when an agent only says so. goalState met only when every criterion is met.
|
|
82
86
|
If the same attempt or failure keeps coming back, say so in loop and ask the next agent for a different approach in the brief, naming what was tried.
|
|
83
87
|
A check-in brings the thread back to you at that time with a post saying what to look at; checkIns lists the thread's check-ins already set.
|
|
84
|
-
The thread's
|
|
88
|
+
The thread's route, when \`team\` is given: its steps (frame, make, check, combine, judge), who holds each and the step it is at. When \`team.step.finished\` is true and \`team.exits\` lists where the work goes next, hand on along the route unless a question to the person is open: for a step that judges (\`team.step.judges\`), read the newest report and pick the exit whose \`outcome\` it shows (passed, or sent_back when it found something to fix); hand on to that exit's agents and add "team": {"step": the exit's step, "outcome": its outcome} to your answer. An exit to step "stop" means pause and tell the person the work was sent back as often as the route allows; one to step "done" means decide as usual and add "team": {"step": "done", "outcome": "done"}. An exit to step "piece" goes to the next piece in \`team.nextPiece\`: route it as below, hand on to its first step's agents and add "team": {"step": "piece", "outcome": the exit's outcome, "plan": its route}. Never hand a check or a review to the agent that made the work.
|
|
89
|
+
Routing, when \`team\` is null or \`team.nextPiece\` is given, and \`teamMembers\` lists who may hold a step: you choose, you never write the frame. Add "team": {"plan": {"rigor": "light" | "standard" | "careful" | "thorough", "split": true only when the goal needs a framer to split it into pieces for different kinds of agent or one after another (never for a piece), "steps": [{"id": "frame" | "make" | "check" | "combine" | "judge", "specialty": the one specialty id the step asks for, "agents": ids from teamMembers}]}}. Rigor picks the steps: ${Object.entries(
|
|
90
|
+
TEAM.rigor
|
|
91
|
+
)
|
|
92
|
+
.map(([level, rigor]) => `${level}: ${rigor.steps.join(", ")}`)
|
|
93
|
+
.join(
|
|
94
|
+
"; "
|
|
95
|
+
)}; combine also runs when several agents make. At light the work goes straight to one maker. Anything the person depends on, or that moves money, is careful at least. Make may have several agents side by side, only when its parts are independent; every other step has one. Check and judge never go to a maker, judge never to the framer, and combine is one agent, never a vote. An agent the person tagged fills a step, Make unless they said otherwise; a pin in \`pins\` (specialty: agent) holds the step that asks for that specialty. An agent with work running or waiting elsewhere is less available. When you route, hand on to the agents of the route's first step. Specialty ids: ${SPECIALTIES.map((specialty) => specialty.id).join(", ")}.`;
|
|
85
96
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
const prompt = `${LOCAL_PROMPT}\n\n${JSON.stringify(facts)}`;
|
|
89
|
-
const invocation =
|
|
90
|
-
agent === "codex"
|
|
91
|
-
? {
|
|
92
|
-
command: "codex",
|
|
93
|
-
args: [
|
|
94
|
-
"exec",
|
|
95
|
-
"--json",
|
|
96
|
-
"--sandbox",
|
|
97
|
-
"read-only",
|
|
98
|
-
"--skip-git-repo-check",
|
|
99
|
-
"-",
|
|
100
|
-
],
|
|
101
|
-
stdin: prompt,
|
|
102
|
-
}
|
|
103
|
-
: {
|
|
104
|
-
command: "claude",
|
|
105
|
-
args: ["-p", prompt, "--output-format", "json", "--tools", ""],
|
|
106
|
-
};
|
|
107
|
-
let child;
|
|
108
|
-
try {
|
|
109
|
-
child = spawn(invocation.command, invocation.args, { cwd: os.tmpdir() });
|
|
110
|
-
} catch (error) {
|
|
111
|
-
reject(error);
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
// An agent that exits before reading the prompt breaks the pipe; its exit code rejects below.
|
|
115
|
-
child.stdin.on("error", () => {});
|
|
116
|
-
child.stdin.end(invocation.stdin ?? "");
|
|
117
|
-
let out = "";
|
|
118
|
-
child.stdout.on("data", (chunk) => {
|
|
119
|
-
out += chunk;
|
|
120
|
-
});
|
|
121
|
-
child.on("error", reject);
|
|
122
|
-
child.on("close", (code) => {
|
|
123
|
-
if (code !== 0) {
|
|
124
|
-
reject(new Error(`${agent} exited with code ${code}`));
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
// Claude answers one JSON object with its text in `result`; Codex streams events, its words in agent_message.
|
|
128
|
-
let text = "";
|
|
129
|
-
for (const line of out.split("\n")) {
|
|
130
|
-
try {
|
|
131
|
-
const event = JSON.parse(line);
|
|
132
|
-
if (typeof event.result === "string") text = event.result;
|
|
133
|
-
if (
|
|
134
|
-
event.type === "item.completed" &&
|
|
135
|
-
event.item?.type === "agent_message"
|
|
136
|
-
)
|
|
137
|
-
text = event.item.text;
|
|
138
|
-
} catch {}
|
|
139
|
-
}
|
|
140
|
-
const match = text.match(/\{[\s\S]*\}/);
|
|
141
|
-
try {
|
|
142
|
-
resolve(JSON.parse(match ? match[0] : text));
|
|
143
|
-
} catch {
|
|
144
|
-
reject(new Error(`${agent} did not answer in the agreed shape`));
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
});
|
|
148
|
-
}
|
|
97
|
+
const localDecision = (agent, facts) =>
|
|
98
|
+
askLocalAgent(agent, `${LOCAL_PROMPT}\n\n${JSON.stringify(facts)}`);
|
|
149
99
|
|
|
150
100
|
// A question's choices as a coordinator gave them, kept only in the agreed shape: one to four, each with two to four
|
|
151
101
|
// options and at most one recommended.
|
|
@@ -171,7 +121,7 @@ const choicesOf = (value) => {
|
|
|
171
121
|
};
|
|
172
122
|
|
|
173
123
|
// An agent whose job in a thread just failed on its own terms is not offered that thread's next rounds for a while
|
|
174
|
-
// (
|
|
124
|
+
// (the lead once handed Bankr the same over-size job three times in two minutes). The person or another agent
|
|
175
125
|
// can still ask it by name.
|
|
176
126
|
const FAILED_REST_MS = 10 * 60_000;
|
|
177
127
|
|
|
@@ -212,6 +162,11 @@ export function createCoordinator({
|
|
|
212
162
|
placeable = () => true,
|
|
213
163
|
// A post from the other side of a shared project (projects.mjs): their own swarm sorts it, so it starts no round here.
|
|
214
164
|
fromPartner = () => false,
|
|
165
|
+
// This computer's reading of the words a round Harness's server decided (serverWords.mjs).
|
|
166
|
+
serverWords = null,
|
|
167
|
+
// The coding agent here the person picked to coordinate (LOCAL_DECIDERS), or null: decides first when Harness does
|
|
168
|
+
// not, and reads first what Harness's server decided.
|
|
169
|
+
pick = () => null,
|
|
215
170
|
}) {
|
|
216
171
|
const failedHereLately = (threadId, agent) => {
|
|
217
172
|
const at = Date.parse(store.meta(`job-failed:${threadId}:${agent}`) || "");
|
|
@@ -227,24 +182,37 @@ export function createCoordinator({
|
|
|
227
182
|
// Lessons go to a coordinator that reads them: this computer's, or a Harness that has swarm_lessons.
|
|
228
183
|
const readsLessons = () =>
|
|
229
184
|
Boolean(lessons) && (mode() === "local" || serverHas("swarm_lessons"));
|
|
230
|
-
// The
|
|
231
|
-
//
|
|
185
|
+
// The route goes to a coordinator that keeps it: this computer's, or a Harness with swarm_routes, which triages the
|
|
186
|
+
// goal in the thread's first assembly and routes each piece a framer splits off.
|
|
232
187
|
const keepsTeams = () =>
|
|
233
|
-
Boolean(team) && (mode() === "local" || serverHas("
|
|
234
|
-
// The
|
|
235
|
-
|
|
188
|
+
Boolean(team) && (mode() === "local" || serverHas("swarm_routes"));
|
|
189
|
+
// The person's pins: specialty -> the agent that holds it when a step asks for it.
|
|
190
|
+
const pinsNow = () =>
|
|
191
|
+
Object.fromEntries(
|
|
192
|
+
SPECIALTIES.map((specialty) => [
|
|
193
|
+
specialty.id,
|
|
194
|
+
pinnedFor(store, specialty.id),
|
|
195
|
+
]).filter(([, agent]) => agent)
|
|
196
|
+
);
|
|
197
|
+
// The backups, in the order they are tried: coding agents on this computer, the one the person picked first, then most
|
|
198
|
+
// finished work first, one whose last turn as a backup failed after the others.
|
|
236
199
|
const backups = () => {
|
|
237
200
|
const record = new Map(
|
|
238
201
|
roster().map((card) => [card.id, card.record?.done ?? 0])
|
|
239
202
|
);
|
|
203
|
+
const picked = pick();
|
|
240
204
|
return localAgents()
|
|
241
|
-
.filter((agent) => agent
|
|
205
|
+
.filter((agent) => LOCAL_DECIDERS.includes(agent))
|
|
242
206
|
.map((agent) => ({
|
|
243
207
|
agent,
|
|
208
|
+
picked: agent === picked ? 1 : 0,
|
|
244
209
|
done: record.get(agent) ?? 0,
|
|
245
210
|
failedLast: store.meta(`coordinator-backup-failed:${agent}`) ? 1 : 0,
|
|
246
211
|
}))
|
|
247
|
-
.sort(
|
|
212
|
+
.sort(
|
|
213
|
+
(a, b) =>
|
|
214
|
+
b.picked - a.picked || a.failedLast - b.failedLast || b.done - a.done
|
|
215
|
+
)
|
|
248
216
|
.map((entry) => entry.agent);
|
|
249
217
|
};
|
|
250
218
|
const stateOf = (goalId) =>
|
|
@@ -279,7 +247,7 @@ export function createCoordinator({
|
|
|
279
247
|
seq: post.seq,
|
|
280
248
|
author: speakerOf(store, thread, post),
|
|
281
249
|
kind: post.kind,
|
|
282
|
-
text: post.text.slice(0, POST_CHARS),
|
|
250
|
+
text: (serverWords?.agentText(post) ?? post.text).slice(0, POST_CHARS),
|
|
283
251
|
}));
|
|
284
252
|
const runs = store.threadRuns(thread.id);
|
|
285
253
|
const since = state.lastRoundAt ?? "";
|
|
@@ -315,18 +283,20 @@ export function createCoordinator({
|
|
|
315
283
|
...runs.filter(waitsForWindow),
|
|
316
284
|
...harnessQueued(thread.id),
|
|
317
285
|
];
|
|
318
|
-
// Every agent the person can ask, each with its card (cards.mjs); a coding agent only where the thread has a folder
|
|
319
|
-
// to work in. Harness stays one while its part here waits for a window, its card saying so, so that what is
|
|
320
|
-
// is never handed to another agent meanwhile (
|
|
286
|
+
// Every agent the person can ask, each with its card (cards.mjs); a coding agent only where the thread has a folder
|
|
287
|
+
// for it to work in. Harness stays one while its part here waits for a window, its card saying so, so that what is
|
|
288
|
+
// Harness's is never handed to another agent meanwhile (Harness's stills once went to Claude Code).
|
|
321
289
|
// An assembly leaves out the agents the person named, who already have their words, and never offers Bankr or
|
|
322
|
-
// Quotient on a guess: only once they are in the thread (
|
|
323
|
-
//
|
|
290
|
+
// Quotient on a guess: only once they are in the thread (when it did, a message that mentioned Bankr's agent gave
|
|
291
|
+
// Bankr the part meant for Claude Code).
|
|
324
292
|
// Each card's receipts go only to a Harness that takes them (the same release as frames); an older one would refuse the round.
|
|
325
293
|
const framesTaken = mode() === "local" || serverHas("swarm_frame");
|
|
326
294
|
const causesTaken = mode() === "local" || serverHas("swarm_failure_causes");
|
|
327
295
|
const verdictsTaken = mode() === "local" || serverHas("swarm_reactions");
|
|
328
296
|
const machinesTaken = mode() === "local" || serverHas("machines");
|
|
329
|
-
|
|
297
|
+
// Each card's specialties, pins and offices go only to a Harness that reads them (feature team_specialties).
|
|
298
|
+
const specialtiesTaken =
|
|
299
|
+
mode() === "local" || serverHas("team_specialties");
|
|
330
300
|
// Who could hold a role on the thread's team: the candidates and the agents the person named.
|
|
331
301
|
const eligible = roster()
|
|
332
302
|
.filter(
|
|
@@ -335,8 +305,8 @@ export function createCoordinator({
|
|
|
335
305
|
!failedHereLately(thread.id, candidate.id) &&
|
|
336
306
|
(!CODING.has(candidate.id) ||
|
|
337
307
|
placeable(candidate.id, thread.goal.workspace)) &&
|
|
338
|
-
// In every round, not only an assembly
|
|
339
|
-
//
|
|
308
|
+
// In every round, not only an assembly: otherwise Bankr scored 0.33 to 0.38 as the agent to hand a production
|
|
309
|
+
// keeper fix to.
|
|
340
310
|
!(
|
|
341
311
|
TAGGED.has(candidate.id) &&
|
|
342
312
|
!thread.goal.team.includes(candidate.id) &&
|
|
@@ -354,22 +324,35 @@ export function createCoordinator({
|
|
|
354
324
|
},
|
|
355
325
|
}),
|
|
356
326
|
lessons: readsLessons() ? candidate.lessons : undefined,
|
|
357
|
-
|
|
327
|
+
specialties: specialtiesTaken
|
|
328
|
+
? roundFields(candidate).specialties
|
|
329
|
+
: undefined,
|
|
330
|
+
pinned: specialtiesTaken ? roundFields(candidate).pinned : undefined,
|
|
331
|
+
offices: specialtiesTaken ? roundFields(candidate).offices : undefined,
|
|
358
332
|
machines: machinesTaken
|
|
359
333
|
? machinesOf(candidate.id, thread.goal.workspace)
|
|
360
334
|
: undefined,
|
|
335
|
+
// Whether a coding agent took its readiness prompt is for the person's surfaces; the round's card schema does not
|
|
336
|
+
// have it, and a round carrying it was refused as malformed once an agent's check came back.
|
|
337
|
+
readiness: undefined,
|
|
361
338
|
}));
|
|
362
339
|
const candidates = eligible.filter(
|
|
363
340
|
(candidate) => !asked?.named.includes(candidate.id)
|
|
364
341
|
);
|
|
365
|
-
// The
|
|
342
|
+
// The route: where it stands, or none yet, which the person's message to the swarm triages (on the privacy setting,
|
|
343
|
+
// this computer's next round). A round that starts the next piece a framer split off routes it with the same facts.
|
|
366
344
|
const teamView = keepsTeams()
|
|
367
345
|
? team.roundView(thread.id, runs, { head: headOf(thread.id) })
|
|
368
346
|
: null;
|
|
347
|
+
const pins = keepsTeams() ? pinsNow() : {};
|
|
348
|
+
const routing = {
|
|
349
|
+
teamMembers: eligible.slice(0, 16),
|
|
350
|
+
...(Object.keys(pins).length ? { pins } : {}),
|
|
351
|
+
};
|
|
369
352
|
const teamFacts = teamView
|
|
370
|
-
? { team: teamView }
|
|
371
|
-
: keepsTeams() && asked
|
|
372
|
-
? { team: null,
|
|
353
|
+
? { team: teamView, ...(teamView.nextPiece ? routing : {}) }
|
|
354
|
+
: keepsTeams() && (asked || mode() === "local")
|
|
355
|
+
? { team: null, ...routing }
|
|
373
356
|
: {};
|
|
374
357
|
// Earlier words close in meaning to the newest post that the transcript no longer carries, from this thread and the
|
|
375
358
|
// person's sessions on this machine.
|
|
@@ -563,7 +546,7 @@ export function createCoordinator({
|
|
|
563
546
|
}
|
|
564
547
|
if (!decision.met && !decision.goalState) return false;
|
|
565
548
|
// A team that checks its work reaches its goal, or hands it to the person, only on code its last check passed: a
|
|
566
|
-
// change since, or no passing check yet, leaves the goal working (
|
|
549
|
+
// change since, or no passing check yet, leaves the goal working ("Ready for your review" was once posted
|
|
567
550
|
// with 1 of 3 checks met).
|
|
568
551
|
const unchecked =
|
|
569
552
|
keepsTeams() && !team.checkedNow(thread.id, headOf(thread.id));
|
|
@@ -639,30 +622,48 @@ export function createCoordinator({
|
|
|
639
622
|
});
|
|
640
623
|
return other ?? agent;
|
|
641
624
|
};
|
|
642
|
-
// The
|
|
643
|
-
|
|
625
|
+
// The route's part of a decision: one for a thread that had none, said in the thread. The person's tags and pins win
|
|
626
|
+
// over the proposal step by step (team.mjs validPlan).
|
|
627
|
+
const routeFor = (thread, coordinator, named = []) => ({
|
|
628
|
+
members: roster().map((card) => card.id),
|
|
629
|
+
named,
|
|
630
|
+
pins: pinsNow(),
|
|
631
|
+
by: coordinator,
|
|
632
|
+
post: (text) =>
|
|
633
|
+
postAsCoordinator({
|
|
634
|
+
goalId: thread.id,
|
|
635
|
+
author: coordinator,
|
|
636
|
+
kind: "note",
|
|
637
|
+
text,
|
|
638
|
+
}),
|
|
639
|
+
});
|
|
640
|
+
const applyTeamPlan = (thread, decision, coordinator, asked = null) => {
|
|
644
641
|
const proposed = decision.team?.plan;
|
|
645
|
-
if (
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
}),
|
|
658
|
-
});
|
|
642
|
+
if (
|
|
643
|
+
!proposed ||
|
|
644
|
+
decision.team?.step === "piece" ||
|
|
645
|
+
!keepsTeams() ||
|
|
646
|
+
team.plan(thread.id)
|
|
647
|
+
)
|
|
648
|
+
return null;
|
|
649
|
+
return team.set(
|
|
650
|
+
thread.id,
|
|
651
|
+
proposed,
|
|
652
|
+
routeFor(thread, coordinator, asked?.named ?? [])
|
|
653
|
+
);
|
|
659
654
|
};
|
|
660
|
-
// Where the work went: along the route to the step the round chose,
|
|
661
|
-
// who now have it.
|
|
662
|
-
const moveTeam = (thread, decision, agents) => {
|
|
655
|
+
// Where the work went: along the route to the step the round chose, on to the next piece as the round routed it, or,
|
|
656
|
+
// handed outside the route, to the step of the agents who now have it.
|
|
657
|
+
const moveTeam = (thread, decision, agents, coordinator) => {
|
|
663
658
|
if (!keepsTeams()) return;
|
|
664
659
|
const step = decision.team?.step;
|
|
665
|
-
if (step
|
|
660
|
+
if (step === "piece")
|
|
661
|
+
team.routePiece(thread.id, decision.team.plan, {
|
|
662
|
+
...routeFor(thread, coordinator ?? thread.goal.facilitator),
|
|
663
|
+
outcome: decision.team.outcome ?? null,
|
|
664
|
+
head: headOf(thread.id),
|
|
665
|
+
});
|
|
666
|
+
else if (step && step !== "done")
|
|
666
667
|
team.moveTo(thread.id, step, {
|
|
667
668
|
outcome: decision.team.outcome ?? null,
|
|
668
669
|
head: headOf(thread.id),
|
|
@@ -679,22 +680,73 @@ export function createCoordinator({
|
|
|
679
680
|
});
|
|
680
681
|
};
|
|
681
682
|
|
|
683
|
+
// Work routed to an agent the person pinned for the step's specialty waits while that agent works in another thread,
|
|
684
|
+
// and the thread says so (decision 14); it is handed on once the agent is free (releaseHeld, at every round).
|
|
685
|
+
const HELD = "pin-waits";
|
|
686
|
+
const heldWork = () => {
|
|
687
|
+
try {
|
|
688
|
+
return JSON.parse(store.meta(HELD) || "[]");
|
|
689
|
+
} catch {
|
|
690
|
+
return [];
|
|
691
|
+
}
|
|
692
|
+
};
|
|
693
|
+
const handOnOrHold = (thread, agent, reason, options, coordinator) => {
|
|
694
|
+
const step = keepsTeams() ? team.pinnedStep(thread.id, agent) : null;
|
|
695
|
+
if (!step || !store.busyElsewhere(agent, thread.id)) {
|
|
696
|
+
handOn(thread.id, agent, reason, options);
|
|
697
|
+
return;
|
|
698
|
+
}
|
|
699
|
+
store.meta(
|
|
700
|
+
HELD,
|
|
701
|
+
JSON.stringify([
|
|
702
|
+
...heldWork(),
|
|
703
|
+
{
|
|
704
|
+
goalId: thread.id,
|
|
705
|
+
agent,
|
|
706
|
+
reason,
|
|
707
|
+
options,
|
|
708
|
+
at: new Date().toISOString(),
|
|
709
|
+
},
|
|
710
|
+
])
|
|
711
|
+
);
|
|
712
|
+
postAsCoordinator({
|
|
713
|
+
goalId: thread.id,
|
|
714
|
+
author: coordinator,
|
|
715
|
+
kind: "note",
|
|
716
|
+
text: `The ${step.id} step waits for ${nameOf(agent)}, which you pinned for ${specialtyName(step.specialty)}: it is working in another thread, and starts on this when that work ends.`,
|
|
717
|
+
});
|
|
718
|
+
};
|
|
719
|
+
const releaseHeld = () => {
|
|
720
|
+
const waiting = heldWork();
|
|
721
|
+
if (!waiting.length) return;
|
|
722
|
+
const still = [];
|
|
723
|
+
for (const held of waiting) {
|
|
724
|
+
const thread = store.getTask(held.goalId);
|
|
725
|
+
if (!thread || thread.status !== "open") continue;
|
|
726
|
+
if (store.busyElsewhere(held.agent, held.goalId)) still.push(held);
|
|
727
|
+
else handOn(held.goalId, held.agent, held.reason, held.options);
|
|
728
|
+
}
|
|
729
|
+
store.meta(HELD, JSON.stringify(still));
|
|
730
|
+
};
|
|
731
|
+
|
|
732
|
+
// `withheld`: this computer stopped the server's words, which `given` no longer holds ({ reason, asks, forPerson }).
|
|
682
733
|
const apply = (
|
|
683
734
|
thread,
|
|
684
735
|
given,
|
|
685
736
|
coordinator,
|
|
686
737
|
candidates,
|
|
687
738
|
asked = null,
|
|
688
|
-
rules = keepsGoals()
|
|
739
|
+
rules = keepsGoals(),
|
|
740
|
+
withheld = null
|
|
689
741
|
) => {
|
|
690
742
|
endRoute(thread, given);
|
|
691
743
|
if (applyGoal(thread, given, coordinator)) return;
|
|
692
744
|
applyCheckIn(thread, given, coordinator);
|
|
693
|
-
const planned = applyTeamPlan(thread, given, coordinator);
|
|
745
|
+
const planned = applyTeamPlan(thread, given, coordinator, asked);
|
|
694
746
|
const decision = guardQuestion(thread, given, candidates, rules);
|
|
695
747
|
// The person's message is never met with silence: a round that brings no one in and asks them nothing lets the
|
|
696
|
-
// agents hear it as they wrote it, as with `@swarm
|
|
697
|
-
//
|
|
748
|
+
// agents hear it as they wrote it, as with `@swarm`. That is the fallback whenever Jev does not understand the
|
|
749
|
+
// message. A message naming an agent is not silent: that agent has it.
|
|
698
750
|
// A team whose first step the person's named agents hold is under way: they have the message already.
|
|
699
751
|
const unheard =
|
|
700
752
|
Boolean(asked) &&
|
|
@@ -732,7 +784,8 @@ export function createCoordinator({
|
|
|
732
784
|
);
|
|
733
785
|
if (!parts.length) {
|
|
734
786
|
if (unheard) tellEveryone(thread, asked, null, { decided: true });
|
|
735
|
-
else if (planned)
|
|
787
|
+
else if (planned)
|
|
788
|
+
moveTeam(thread, decision, asked?.named ?? [], coordinator);
|
|
736
789
|
notifyBoard(store.getTask(thread.id));
|
|
737
790
|
return;
|
|
738
791
|
}
|
|
@@ -763,16 +816,27 @@ export function createCoordinator({
|
|
|
763
816
|
.join("\n\n"),
|
|
764
817
|
});
|
|
765
818
|
// The team moves first, so each brief says the step its agent now acts in.
|
|
766
|
-
moveTeam(
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
819
|
+
moveTeam(
|
|
820
|
+
thread,
|
|
821
|
+
decision,
|
|
822
|
+
[...worded.map((part) => part.agent), ...(asked?.named ?? [])],
|
|
823
|
+
coordinator
|
|
824
|
+
);
|
|
770
825
|
for (const part of worded)
|
|
771
|
-
|
|
772
|
-
thread
|
|
826
|
+
handOnOrHold(
|
|
827
|
+
thread,
|
|
773
828
|
part.agent,
|
|
774
|
-
|
|
775
|
-
|
|
829
|
+
withheld
|
|
830
|
+
? part.text
|
|
831
|
+
: `${coordinator} asked you: ${part.text.slice(0, 300)}`,
|
|
832
|
+
{ review: part.review, words: part.text },
|
|
833
|
+
coordinator
|
|
834
|
+
);
|
|
835
|
+
if (withheld)
|
|
836
|
+
saidWithheld(
|
|
837
|
+
thread,
|
|
838
|
+
withheld,
|
|
839
|
+
worded.map((part) => part.agent)
|
|
776
840
|
);
|
|
777
841
|
notifyBoard(store.getTask(thread.id));
|
|
778
842
|
return;
|
|
@@ -785,6 +849,8 @@ export function createCoordinator({
|
|
|
785
849
|
text: String(decision.text).slice(0, 4_000),
|
|
786
850
|
});
|
|
787
851
|
// Its decisions as choices a surface can offer as taps (threadView.mjs); the words stand alone without them.
|
|
852
|
+
if (asked && withheld?.forPerson)
|
|
853
|
+
serverWords.mark(asked.id, withheld.reason);
|
|
788
854
|
const choices = choicesOf(decision.choices);
|
|
789
855
|
if (asked && choices.length)
|
|
790
856
|
store.meta(`question-choices:${asked.id}`, JSON.stringify(choices));
|
|
@@ -809,17 +875,36 @@ export function createCoordinator({
|
|
|
809
875
|
kind: "post",
|
|
810
876
|
text: `@${agent} ${review ? "(review, no changes) " : ""}${text}`,
|
|
811
877
|
});
|
|
812
|
-
moveTeam(thread, decision, [agent]);
|
|
813
|
-
|
|
814
|
-
thread
|
|
878
|
+
moveTeam(thread, decision, [agent], coordinator);
|
|
879
|
+
handOnOrHold(
|
|
880
|
+
thread,
|
|
815
881
|
agent,
|
|
816
|
-
`${coordinator} asked you: ${text.slice(0, 300)}`,
|
|
817
|
-
{ review, words: text }
|
|
882
|
+
withheld ? text : `${coordinator} asked you: ${text.slice(0, 300)}`,
|
|
883
|
+
{ review, words: text },
|
|
884
|
+
coordinator
|
|
818
885
|
);
|
|
819
|
-
|
|
886
|
+
if (withheld) saidWithheld(thread, withheld, [agent]);
|
|
887
|
+
} else if (withheld) saidWithheld(thread, withheld, []);
|
|
820
888
|
notifyBoard(store.getTask(thread.id));
|
|
821
889
|
};
|
|
822
890
|
|
|
891
|
+
// The thread says what was left out and why, each time this computer stops the server's words.
|
|
892
|
+
const saidWithheld = (thread, { reason, asks }, agents) =>
|
|
893
|
+
postAsCoordinator({
|
|
894
|
+
goalId: thread.id,
|
|
895
|
+
author: thread.goal.facilitator,
|
|
896
|
+
kind: "note",
|
|
897
|
+
text: serverWords.note(reason, agents.map(nameOf), asks),
|
|
898
|
+
});
|
|
899
|
+
// What this computer reads a server-decided round's words with: the person's own posts in the thread, and the coding
|
|
900
|
+
// agents here that may read them (serverWords.mjs).
|
|
901
|
+
const readingFor = (goalId) => ({
|
|
902
|
+
person: store
|
|
903
|
+
.roomPosts(goalId, 0, 500)
|
|
904
|
+
.filter((post) => post.author === "user" && post.kind === "post"),
|
|
905
|
+
readers: backups(),
|
|
906
|
+
});
|
|
907
|
+
|
|
823
908
|
// The person wrote while agents work: Harness asks only whether that changed what they want, and writes the goal's new
|
|
824
909
|
// version if so; what to do next waits for the thread to go quiet (October 16: a change the person made while Claude
|
|
825
910
|
// Code worked reached the goal 13 minutes later, when Codex's turn after it had ended). Once for each of their posts.
|
|
@@ -866,11 +951,19 @@ export function createCoordinator({
|
|
|
866
951
|
});
|
|
867
952
|
if (!decision?.goal) return;
|
|
868
953
|
const now = store.getTask(thread.id);
|
|
954
|
+
const screened = serverWords
|
|
955
|
+
? await serverWords.screen({ goal: decision.goal }, readingFor(thread.id))
|
|
956
|
+
: { reason: null };
|
|
957
|
+
if (screened.reason) {
|
|
958
|
+
saidWithheld(now, screened, []);
|
|
959
|
+
return;
|
|
960
|
+
}
|
|
869
961
|
applyGoal(now, { goal: decision.goal }, now.goal.facilitator);
|
|
870
962
|
store.meta(`goal-kept:${thread.id}`, String(newest));
|
|
871
963
|
};
|
|
872
964
|
|
|
873
965
|
const round = async (goalId) => {
|
|
966
|
+
releaseHeld();
|
|
874
967
|
const thread = store.getTask(goalId);
|
|
875
968
|
if (!thread || thread.kind !== "goal" || thread.status !== "open") return;
|
|
876
969
|
const state = stateOf(goalId);
|
|
@@ -884,7 +977,7 @@ export function createCoordinator({
|
|
|
884
977
|
!fromPartner(goalId, post)
|
|
885
978
|
);
|
|
886
979
|
// A turn T3 Code is running for one of the thread's agents counts as work going on, though Harness did not start it
|
|
887
|
-
// (
|
|
980
|
+
// (the coordinator once told Claude Code to "continue" three times while it worked in T3).
|
|
888
981
|
const active =
|
|
889
982
|
store.threadRuns(goalId).some(going) || busyInT3(thread).length > 0;
|
|
890
983
|
// A thread started through Harness by an agent that runs elsewhere gets no rounds until the person sets a spend ceiling.
|
|
@@ -1035,13 +1128,28 @@ export function createCoordinator({
|
|
|
1035
1128
|
thread,
|
|
1036
1129
|
`${harnessCould(error)}; ${nameOf(decidedBy)} coordinated it.`
|
|
1037
1130
|
);
|
|
1131
|
+
// A round Harness's server decided keeps the person's go, so its words reach the agents only once this computer read
|
|
1132
|
+
// them (serverWords.mjs); rounds decided on this computer are this computer's own words.
|
|
1133
|
+
let withheld = null;
|
|
1134
|
+
if (decidedBy === "harness" && serverWords) {
|
|
1135
|
+
const { reason, asks } = await serverWords.screen(
|
|
1136
|
+
decision,
|
|
1137
|
+
readingFor(goalId)
|
|
1138
|
+
);
|
|
1139
|
+
if (reason) {
|
|
1140
|
+
const stripped = serverWords.strip(decision, lastSeq);
|
|
1141
|
+
decision = stripped.decision;
|
|
1142
|
+
withheld = { reason, asks, forPerson: stripped.forPerson };
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1038
1145
|
apply(
|
|
1039
1146
|
store.getTask(goalId),
|
|
1040
1147
|
decision,
|
|
1041
1148
|
thread.goal.facilitator,
|
|
1042
1149
|
gathered.candidates,
|
|
1043
1150
|
asked,
|
|
1044
|
-
decidedBy === "harness" ? keepsGoals() : true
|
|
1151
|
+
decidedBy === "harness" ? keepsGoals() : true,
|
|
1152
|
+
withheld
|
|
1045
1153
|
);
|
|
1046
1154
|
};
|
|
1047
1155
|
|
|
@@ -1053,8 +1161,8 @@ export function createCoordinator({
|
|
|
1053
1161
|
: `Harness could not decide this round (${why})`;
|
|
1054
1162
|
};
|
|
1055
1163
|
|
|
1056
|
-
// The coordinator's note, unless the thread's newest post already says the same: a repeat after new work is said
|
|
1057
|
-
// (
|
|
1164
|
+
// The coordinator's note, unless the thread's newest post already says the same: a repeat after new work is said
|
|
1165
|
+
// again (a repeated error once said nothing, and the thread stopped with no one told).
|
|
1058
1166
|
const noteOnce = (thread, text) => {
|
|
1059
1167
|
const newest = store.roomPosts(thread.id, 0, 500).at(-1);
|
|
1060
1168
|
if (newest?.kind === "note" && newest.text === text) return;
|
|
@@ -1080,7 +1188,7 @@ export function createCoordinator({
|
|
|
1080
1188
|
};
|
|
1081
1189
|
|
|
1082
1190
|
/** The person resumed a paused thread: its round looks at where it stands, though only notes came in since
|
|
1083
|
-
* (
|
|
1191
|
+
* (a resume once reopened a thread that then sat with Codex's handoff unread). */
|
|
1084
1192
|
const resumed = (goalId) => {
|
|
1085
1193
|
store.meta(`coordinator-resumed:${goalId}`, "1");
|
|
1086
1194
|
poke(goalId);
|