tryharness 0.7.71 → 0.7.73
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/assets/opencode-plugin.js +70 -3
- package/cli.mjs +27 -12
- package/lib/asks.mjs +4 -0
- package/lib/boardCommands.mjs +9 -1
- package/lib/boardProtocol.json +23 -19
- package/lib/bridge.mjs +2 -0
- package/lib/capabilityCheck.mjs +86 -0
- package/lib/computerAddress.mjs +6 -14
- package/lib/coordinator.mjs +259 -30
- package/lib/daemon.mjs +164 -133
- package/lib/dispatchContract.json +1 -31
- package/lib/dispatchTools.js +8 -39
- package/lib/dispatches.mjs +27 -285
- package/lib/goalCommands.mjs +21 -38
- package/lib/herdr.mjs +159 -0
- package/lib/hookDialects.mjs +36 -2
- package/lib/jobAnswers.mjs +3 -0
- package/lib/kanban.mjs +256 -0
- package/lib/live.mjs +25 -3
- package/lib/localAgentAsk.mjs +20 -29
- package/lib/machineRoutes.mjs +1 -5
- package/lib/machineRuns.mjs +42 -22
- package/lib/manager.mjs +254 -0
- package/lib/mcp-stdio.mjs +58 -39
- package/lib/moves.mjs +365 -0
- package/lib/nudge.mjs +13 -3
- package/lib/ownMachines.mjs +122 -12
- package/lib/places.mjs +29 -2
- package/lib/plans.mjs +7 -1
- package/lib/projectSettings.mjs +11 -1
- package/lib/projects.mjs +20 -4
- package/lib/runAuthority.mjs +104 -35
- package/lib/runBrief.mjs +14 -1
- package/lib/runWorker.mjs +48 -24
- package/lib/runner.mjs +184 -75
- package/lib/selfUpdate.mjs +41 -0
- package/lib/serverWords.mjs +11 -11
- package/lib/sessionControl.mjs +68 -3
- package/lib/steerHook.mjs +124 -0
- package/lib/steerQueue.mjs +176 -0
- package/lib/store.mjs +34 -34
- package/lib/subagentSteering.mjs +363 -0
- package/lib/subagents.mjs +138 -29
- package/lib/swarm.mjs +16 -3
- package/lib/taskCommands.mjs +36 -71
- package/lib/threadActions.mjs +13 -3
- package/lib/threadAuthority.mjs +21 -14
- package/lib/threadBriefs.mjs +9 -3
- package/lib/threadRuns.mjs +35 -8
- package/npm-shrinkwrap.json +14 -14
- package/package.json +4 -4
- package/release.json +54 -49
- package/lib/comfyExecution.mjs +0 -545
- package/lib/promptDecider.mjs +0 -471
- package/lib/promptFlow.mjs +0 -562
- package/lib/promptScopes.mjs +0 -670
package/lib/coordinator.mjs
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { LOCAL_DECIDERS, askLocalAgent } from "./localAgentAsk.mjs";
|
|
2
2
|
import { roundFields } from "./cards.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
CLOUD_HOMED,
|
|
5
|
+
MACHINE_RUNNERS,
|
|
6
|
+
MEMBERS,
|
|
7
|
+
TAGGED_ONLY,
|
|
8
|
+
nameOf,
|
|
9
|
+
} from "./members.mjs";
|
|
4
10
|
import { LEAD_TIMES } from "./schedules.mjs";
|
|
5
11
|
import { SPECIALTIES, pinnedFor, specialtyName } from "./specialties.mjs";
|
|
6
12
|
import { TEAM } from "./team.mjs";
|
|
@@ -65,7 +71,7 @@ export const speakerOf = (store, thread, post) =>
|
|
|
65
71
|
// Harness's part with no Harness window open waits on the board for one (daemon.mjs offerToServer); the thread goes on.
|
|
66
72
|
const waitsForWindow = (run) =>
|
|
67
73
|
run.status === "open" && run.target_agent === "harness";
|
|
68
|
-
const going = (run) =>
|
|
74
|
+
export const going = (run) =>
|
|
69
75
|
["open", "claimed", "running"].includes(run.status) && !waitsForWindow(run);
|
|
70
76
|
|
|
71
77
|
// The privacy setting: the round's facts go to an agent on this machine with its tools off, which answers in the
|
|
@@ -82,6 +88,7 @@ Decide the next step and answer with one JSON object only:
|
|
|
82
88
|
)}, "text": what to look at then, in one or two sentences} only when the thread must wait on something that is not ready yet (a render, a deploy, a reply, a market, work that runs for hours) or the person asked for work over a long period, and \`checkIns\` has none by the lead}
|
|
83
89
|
hand_on: the request needs more work an agent can do and none is working; that includes a next step an agent's result names for another agent, and a choice an agent can make with a sensible default. ask_person: only for spending above what the thread may spend (category spend), something outward-facing or hard to undo such as deploying, publishing, moving money or changing production data (outward), a secret only the person has (secret), or changing what the goal is for (scope). Never ask the person a taste or technical choice, a fact an agent could find, or something already answered in the transcript: hand it to an agent to decide with its best default. Never ask for a password or key in the thread. wait: an agent is working, a question to the person is open, the request is answered, or what is left is in waitingForWindow. pause: nothing more can be done without the person.
|
|
84
90
|
Work in progress.waitingForWindow is already Harness's and only waits for the person's Harness window to open: never hand it on. Image and video generation is Harness's.
|
|
91
|
+
When \`moves\` is given, the action may also be one of these, each only with what \`moves\` offers: "inspect" with "lookUp": one of moves.lookUps, to read more before deciding (you are asked again with moves.lookedUp); "continue" with "agent": an agent in moves.conversations, to send the person's newest message as they wrote it on in that agent's conversation here; "execute" with "ref": the id of a turn in moves.held that the person's newest message gives its go; "deliver" with "ref": the id of a result in moves.results the person asks to see or have again; "cancel" with "stop": ids from moves.running the person asked to stop or that their newest message makes pointless; "finish" only when moves.finishable is true and the request is done or the person said they are finished.
|
|
85
92
|
In briefs, refer to earlier posts by their seq number instead of restating figures or ids, and never say the person approved something unless you quote their words.
|
|
86
93
|
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.
|
|
87
94
|
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.
|
|
@@ -161,6 +168,12 @@ export function createCoordinator({
|
|
|
161
168
|
// (ownMachines.mjs), and whether one of them can take the thread's turn at all.
|
|
162
169
|
machinesOf = () => undefined,
|
|
163
170
|
placeable = () => true,
|
|
171
|
+
// Whether each of the person's computers can do a piece of work, an agent there looking (capabilityCheck.mjs).
|
|
172
|
+
capabilities = null,
|
|
173
|
+
// The moves beyond bringing agents in (moves.mjs): look up, continue, start a held turn, show a result, stop, close.
|
|
174
|
+
moves = null,
|
|
175
|
+
// The person's open asks in a thread (manager.mjs): while any is open, the goal is not met nor ready for review.
|
|
176
|
+
openAsks = () => [],
|
|
164
177
|
computerOf = (goalId) => store.meta(`thread-work-computer:${goalId}`) || null,
|
|
165
178
|
// A post from the other side of a shared project (projects.mjs): their own swarm sorts it, so it starts no round here.
|
|
166
179
|
fromPartner = () => false,
|
|
@@ -170,6 +183,33 @@ export function createCoordinator({
|
|
|
170
183
|
// not, and reads first what Harness's server decided.
|
|
171
184
|
pick = () => null,
|
|
172
185
|
}) {
|
|
186
|
+
// Agents on Harness's server (Bankr, Quotient, Muse) keep their tasks there, not on this board (asks.mjs), so whether
|
|
187
|
+
// one is at work in a thread is read from the thread itself: a job posted for it that it has not answered since. Its
|
|
188
|
+
// result, its question and its failure each land as its own post (jobAnswers.mjs); an ask that never reached Harness
|
|
189
|
+
// is a failed ask. Read from the board alone, Bankr looked idle while it worked, and the round handed it the same
|
|
190
|
+
// purchase again.
|
|
191
|
+
const hostedAtWork = (goalId) => {
|
|
192
|
+
const { posts } = store.recentRoomPosts(goalId, { limit: 500 });
|
|
193
|
+
const answeredAt = (agent) =>
|
|
194
|
+
[
|
|
195
|
+
posts.findLast((post) => post.author === agent)?.created_at,
|
|
196
|
+
...failedAsks(goalId)
|
|
197
|
+
.filter((failure) => failure.agent === agent)
|
|
198
|
+
.map((failure) => failure.at),
|
|
199
|
+
].reduce((newest, at) => (at && at > newest ? at : newest), "");
|
|
200
|
+
return CLOUD_HOMED.filter((agent) => {
|
|
201
|
+
const job = posts.findLast(
|
|
202
|
+
(post) => post.kind === "job" && post.mentions.includes(agent)
|
|
203
|
+
);
|
|
204
|
+
return Boolean(job) && job.created_at > answeredAt(agent);
|
|
205
|
+
});
|
|
206
|
+
};
|
|
207
|
+
// Whether the agent already holds work in the thread, here or on Harness's server.
|
|
208
|
+
const holdsWork = (goalId, agent) =>
|
|
209
|
+
store
|
|
210
|
+
.threadRuns(goalId)
|
|
211
|
+
.some((run) => run.target_agent === agent && going(run)) ||
|
|
212
|
+
hostedAtWork(goalId).includes(agent);
|
|
173
213
|
const failedHereLately = (threadId, agent) => {
|
|
174
214
|
const at = Date.parse(store.meta(`job-failed:${threadId}:${agent}`) || "");
|
|
175
215
|
return Date.now() - at < FAILED_REST_MS;
|
|
@@ -190,6 +230,31 @@ export function createCoordinator({
|
|
|
190
230
|
Boolean(team) && (mode() === "local" || serverHas("swarm_routes"));
|
|
191
231
|
const keepsPlacement = () =>
|
|
192
232
|
mode() === "local" || serverHas("swarm_placement");
|
|
233
|
+
// The moves go to a coordinator that takes them: this computer's, or a Harness with swarm_moves.
|
|
234
|
+
const movesTaken = () =>
|
|
235
|
+
Boolean(moves) && (mode() === "local" || serverHas("swarm_moves"));
|
|
236
|
+
// What each computer said it can do with the person's newest message to the swarm (capabilityCheck.mjs), by computer
|
|
237
|
+
// id: asked once per message, kept for the thread's rounds until the next one, sent to a coordinator that reads it.
|
|
238
|
+
const canDo = async (thread, posts, asked) => {
|
|
239
|
+
if (
|
|
240
|
+
!capabilities ||
|
|
241
|
+
!(mode() === "local" || serverHas("capability_checks"))
|
|
242
|
+
)
|
|
243
|
+
return new Map();
|
|
244
|
+
const key = `capabilities:${thread.id}`;
|
|
245
|
+
let kept = JSON.parse(store.meta(key) || "null");
|
|
246
|
+
const message = asked && posts.find((post) => post.seq === asked.seq);
|
|
247
|
+
if (message && kept?.seq !== message.seq) {
|
|
248
|
+
kept = {
|
|
249
|
+
seq: message.seq,
|
|
250
|
+
answers: await capabilities.check(message.text),
|
|
251
|
+
};
|
|
252
|
+
store.meta(key, JSON.stringify(kept));
|
|
253
|
+
}
|
|
254
|
+
return new Map(
|
|
255
|
+
(kept?.answers ?? []).map(({ id, answer, why }) => [id, { answer, why }])
|
|
256
|
+
);
|
|
257
|
+
};
|
|
193
258
|
// The person's pins: specialty -> the agent that holds it when a step asks for it.
|
|
194
259
|
const pinsNow = () =>
|
|
195
260
|
Object.fromEntries(
|
|
@@ -251,7 +316,11 @@ export function createCoordinator({
|
|
|
251
316
|
seq: post.seq,
|
|
252
317
|
author: speakerOf(store, thread, post),
|
|
253
318
|
kind: post.kind,
|
|
254
|
-
|
|
319
|
+
// The person's own words whole; an agent's cut to the limit.
|
|
320
|
+
text:
|
|
321
|
+
post.author === "user"
|
|
322
|
+
? post.text
|
|
323
|
+
: (serverWords?.agentText(post) ?? post.text).slice(0, POST_CHARS),
|
|
255
324
|
}));
|
|
256
325
|
const runs = store.threadRuns(thread.id);
|
|
257
326
|
const since = state.lastRoundAt ?? "";
|
|
@@ -273,7 +342,11 @@ export function createCoordinator({
|
|
|
273
342
|
objective: run.objective,
|
|
274
343
|
result: String(run.result || ""),
|
|
275
344
|
})),
|
|
276
|
-
...failedAsks(thread.id),
|
|
345
|
+
...failedAsks(thread.id).map(({ agent, objective, result }) => ({
|
|
346
|
+
agent,
|
|
347
|
+
objective,
|
|
348
|
+
result,
|
|
349
|
+
})),
|
|
277
350
|
]
|
|
278
351
|
.slice(-5)
|
|
279
352
|
.map((job) => ({
|
|
@@ -302,11 +375,11 @@ export function createCoordinator({
|
|
|
302
375
|
// Each card's specialties, pins and offices go only to a Harness that reads them (feature team_specialties).
|
|
303
376
|
const specialtiesTaken =
|
|
304
377
|
mode() === "local" || serverHas("team_specialties");
|
|
378
|
+
const can = await canDo(thread, posts, asked);
|
|
305
379
|
// Who could hold a role on the thread's team: the candidates and the agents the person named.
|
|
306
380
|
const eligible = roster()
|
|
307
381
|
.filter(
|
|
308
382
|
(candidate) =>
|
|
309
|
-
(!CODING.has(candidate.id) || thread.goal.workspace) &&
|
|
310
383
|
!failedHereLately(thread.id, candidate.id) &&
|
|
311
384
|
(!CODING.has(candidate.id) ||
|
|
312
385
|
placeable(candidate.id, thread.goal.workspace)) &&
|
|
@@ -352,6 +425,7 @@ export function createCoordinator({
|
|
|
352
425
|
? { thread_repository }
|
|
353
426
|
: {}),
|
|
354
427
|
...(keepsPlacement() ? { id } : {}),
|
|
428
|
+
...(can.has(id) ? { can_do: can.get(id) } : {}),
|
|
355
429
|
})
|
|
356
430
|
)
|
|
357
431
|
: undefined,
|
|
@@ -416,6 +490,7 @@ export function createCoordinator({
|
|
|
416
490
|
const framed = await frame(thread.id);
|
|
417
491
|
return {
|
|
418
492
|
...(framed ? { frame: framed } : {}),
|
|
493
|
+
...(movesTaken() ? { moves: moves.offered(thread, { candidates }) } : {}),
|
|
419
494
|
...teamFacts,
|
|
420
495
|
thread: {
|
|
421
496
|
id: thread.id,
|
|
@@ -436,7 +511,8 @@ export function createCoordinator({
|
|
|
436
511
|
progress: {
|
|
437
512
|
runsFinished,
|
|
438
513
|
newResults,
|
|
439
|
-
stillRunning:
|
|
514
|
+
stillRunning:
|
|
515
|
+
runs.filter(going).length + hostedAtWork(thread.id).length,
|
|
440
516
|
roundsWithoutProgress: state.withoutProgress,
|
|
441
517
|
failedJobs,
|
|
442
518
|
// A Harness that does not know the field would refuse the round: it goes only to one that takes Harness's tasks.
|
|
@@ -492,7 +568,6 @@ export function createCoordinator({
|
|
|
492
568
|
(agent) =>
|
|
493
569
|
agent !== "harness" &&
|
|
494
570
|
!asked.named.includes(agent) &&
|
|
495
|
-
(!CODING.has(agent) || thread.goal.workspace) &&
|
|
496
571
|
(!TAGGED.has(agent) || inThread.includes(agent)) &&
|
|
497
572
|
(reachable || CODING.has(agent))
|
|
498
573
|
);
|
|
@@ -581,7 +656,8 @@ export function createCoordinator({
|
|
|
581
656
|
// change since, or no passing check yet, leaves the goal working ("Ready for your review" was once posted
|
|
582
657
|
// with 1 of 3 checks met).
|
|
583
658
|
const unchecked =
|
|
584
|
-
keepsTeams() && !team.checkedNow(thread.id, headOf(thread.id))
|
|
659
|
+
(keepsTeams() && !team.checkedNow(thread.id, headOf(thread.id))) ||
|
|
660
|
+
openAsks(thread.id).length > 0;
|
|
585
661
|
const settles =
|
|
586
662
|
decision.goalState === "met" ||
|
|
587
663
|
decision.goalState === "ready_for_review" ||
|
|
@@ -789,9 +865,18 @@ export function createCoordinator({
|
|
|
789
865
|
store.setGoalTeam(thread.id, [...thread.goal.team, agent]);
|
|
790
866
|
}
|
|
791
867
|
}
|
|
868
|
+
// The route's computer for its step, else the one Jev picked for this agent, when it is one of the agent's online
|
|
869
|
+
// computers.
|
|
870
|
+
const picked =
|
|
871
|
+
options.computer &&
|
|
872
|
+
(machinesOf(agent, thread.goal.workspace) ?? []).some(
|
|
873
|
+
(computer) => computer.id === options.computer && computer.online
|
|
874
|
+
)
|
|
875
|
+
? options.computer
|
|
876
|
+
: null;
|
|
792
877
|
options = {
|
|
793
878
|
...options,
|
|
794
|
-
routeMachine: team?.machineFor(thread.id, agent) ??
|
|
879
|
+
routeMachine: team?.machineFor(thread.id, agent) ?? picked,
|
|
795
880
|
};
|
|
796
881
|
const step = keepsTeams() ? team.pinnedStep(thread.id, agent) : null;
|
|
797
882
|
if (!step || !store.busyElsewhere(agent, thread.id)) {
|
|
@@ -851,6 +936,8 @@ export function createCoordinator({
|
|
|
851
936
|
endRoute(thread, given);
|
|
852
937
|
if (applyGoal(thread, given, coordinator)) return;
|
|
853
938
|
applyCheckIn(thread, given, coordinator);
|
|
939
|
+
// A move carries the person's own words or an agent's own result (moves.mjs), outside the route and the briefs.
|
|
940
|
+
if (moves?.apply(thread, given, coordinator)) return;
|
|
854
941
|
const planned = applyTeamPlan(thread, given, coordinator, asked);
|
|
855
942
|
if (
|
|
856
943
|
given.team?.plan &&
|
|
@@ -985,7 +1072,11 @@ export function createCoordinator({
|
|
|
985
1072
|
withheld
|
|
986
1073
|
? part.text
|
|
987
1074
|
: `${coordinator} asked you: ${part.text.slice(0, 300)}`,
|
|
988
|
-
{
|
|
1075
|
+
{
|
|
1076
|
+
review: part.review,
|
|
1077
|
+
words: part.text,
|
|
1078
|
+
computer: part.computer ?? null,
|
|
1079
|
+
},
|
|
989
1080
|
coordinator
|
|
990
1081
|
);
|
|
991
1082
|
if (withheld)
|
|
@@ -1021,6 +1112,14 @@ export function createCoordinator({
|
|
|
1021
1112
|
const agent = review
|
|
1022
1113
|
? independentReviewer(thread, decision.agent, candidates, coordinator)
|
|
1023
1114
|
: decision.agent;
|
|
1115
|
+
// Work that became the agent's while the round was decided (a reading of the server's words takes seconds) is
|
|
1116
|
+
// not handed to it again: Bankr was handed the same purchase twice, and a round begun on a new thread's title
|
|
1117
|
+
// posted "@claude-code (review, no changes)" after the person's own ask had started Claude Code, whose turn did
|
|
1118
|
+
// the review instead (live, October 31). The person's new message is new work, and still reaches it.
|
|
1119
|
+
if (!asked && holdsWork(thread.id, agent)) {
|
|
1120
|
+
notifyBoard(store.getTask(thread.id));
|
|
1121
|
+
return;
|
|
1122
|
+
}
|
|
1024
1123
|
if (!thread.goal.team.includes(agent))
|
|
1025
1124
|
store.setGoalTeam(thread.id, [...thread.goal.team, agent]);
|
|
1026
1125
|
const text = String(decision.text).slice(0, 4_000);
|
|
@@ -1039,7 +1138,7 @@ export function createCoordinator({
|
|
|
1039
1138
|
thread,
|
|
1040
1139
|
agent,
|
|
1041
1140
|
withheld ? text : `${coordinator} asked you: ${text.slice(0, 300)}`,
|
|
1042
|
-
{ review, words: text },
|
|
1141
|
+
{ review, words: text, computer: decision.computer ?? null },
|
|
1043
1142
|
coordinator
|
|
1044
1143
|
);
|
|
1045
1144
|
if (withheld) saidWithheld(thread, withheld, [agent]);
|
|
@@ -1121,6 +1220,98 @@ export function createCoordinator({
|
|
|
1121
1220
|
store.meta(`goal-kept:${thread.id}`, String(newest));
|
|
1122
1221
|
};
|
|
1123
1222
|
|
|
1223
|
+
// One coordinator's decision for the round's facts: Harness's server, or a coding agent here with its tools off.
|
|
1224
|
+
const decideWith = async (coordinator, gathered) => {
|
|
1225
|
+
if (coordinator !== "harness") return localDecision(coordinator, gathered);
|
|
1226
|
+
// No deadline of its own: the round ends when Harness answers or the connection drops.
|
|
1227
|
+
const reply = await askHarness("coordinate", gathered, null);
|
|
1228
|
+
if (!reply.ok)
|
|
1229
|
+
throw new Error(reply.error || "Harness did not coordinate this round");
|
|
1230
|
+
return reply.result ?? reply;
|
|
1231
|
+
};
|
|
1232
|
+
|
|
1233
|
+
// A decision being carried out, kept until it is (the contract's outbox): a restart in the middle finishes it once.
|
|
1234
|
+
const OUTBOX = "round-outbox";
|
|
1235
|
+
const outbox = () => {
|
|
1236
|
+
try {
|
|
1237
|
+
return JSON.parse(store.meta(OUTBOX) || "{}");
|
|
1238
|
+
} catch {
|
|
1239
|
+
return {};
|
|
1240
|
+
}
|
|
1241
|
+
};
|
|
1242
|
+
const keepIntent = (goalId, intent) =>
|
|
1243
|
+
store.meta(
|
|
1244
|
+
OUTBOX,
|
|
1245
|
+
JSON.stringify({ ...outbox(), [goalId]: intent ?? undefined })
|
|
1246
|
+
);
|
|
1247
|
+
// The agents a decision wakes, each with its own words.
|
|
1248
|
+
const wokenBy = (decision) =>
|
|
1249
|
+
decision.action === "assemble"
|
|
1250
|
+
? (decision.parts ?? []).map((part) => part.agent)
|
|
1251
|
+
: ["hand_on", "continue"].includes(decision.action) && decision.agent
|
|
1252
|
+
? [decision.agent]
|
|
1253
|
+
: [];
|
|
1254
|
+
// Whether an agent has work in the thread that began at or after `at`: its wake from this decision got out.
|
|
1255
|
+
const wokenSince = (goalId, agent, at) =>
|
|
1256
|
+
store
|
|
1257
|
+
.threadRuns(goalId)
|
|
1258
|
+
.some((run) => run.target_agent === agent && run.created_at >= at) ||
|
|
1259
|
+
store
|
|
1260
|
+
.roomPosts(goalId, 0, 500)
|
|
1261
|
+
.some(
|
|
1262
|
+
(post) =>
|
|
1263
|
+
post.kind === "job" &&
|
|
1264
|
+
post.mentions.includes(agent) &&
|
|
1265
|
+
post.created_at >= at
|
|
1266
|
+
);
|
|
1267
|
+
/**
|
|
1268
|
+
* After a restart: each decision that was being carried out. Not begun (nothing posted since), it is carried out
|
|
1269
|
+
* whole; begun, only the agents it woke that have nothing since are woken, with the words it gave them.
|
|
1270
|
+
*/
|
|
1271
|
+
const recover = () => {
|
|
1272
|
+
for (const [goalId, intent] of Object.entries(outbox())) {
|
|
1273
|
+
keepIntent(goalId, null);
|
|
1274
|
+
const thread = store.getTask(goalId);
|
|
1275
|
+
if (!thread || thread.status !== "open") continue;
|
|
1276
|
+
const begun = store
|
|
1277
|
+
.roomPosts(goalId, 0, 500)
|
|
1278
|
+
.some(
|
|
1279
|
+
(post) =>
|
|
1280
|
+
post.created_at >= intent.at &&
|
|
1281
|
+
store.meta(`coordinator-post:${post.id}`)
|
|
1282
|
+
);
|
|
1283
|
+
if (!begun) {
|
|
1284
|
+
apply(
|
|
1285
|
+
thread,
|
|
1286
|
+
intent.decision,
|
|
1287
|
+
intent.coordinator,
|
|
1288
|
+
intent.candidates,
|
|
1289
|
+
intent.asked,
|
|
1290
|
+
intent.rules,
|
|
1291
|
+
intent.withheld
|
|
1292
|
+
);
|
|
1293
|
+
continue;
|
|
1294
|
+
}
|
|
1295
|
+
for (const agent of wokenBy(intent.decision)) {
|
|
1296
|
+
if (wokenSince(goalId, agent, intent.at)) continue;
|
|
1297
|
+
const words =
|
|
1298
|
+
intent.decision.action === "assemble"
|
|
1299
|
+
? intent.decision.parts.find((part) => part.agent === agent)?.text
|
|
1300
|
+
: intent.decision.text;
|
|
1301
|
+
if (intent.decision.action === "continue")
|
|
1302
|
+
moves.apply(thread, intent.decision, intent.coordinator);
|
|
1303
|
+
else if (words)
|
|
1304
|
+
handOnOrHold(
|
|
1305
|
+
thread,
|
|
1306
|
+
agent,
|
|
1307
|
+
`${intent.coordinator} asked you: ${String(words).slice(0, 300)}`,
|
|
1308
|
+
{ words, computer: intent.decision.computer ?? null },
|
|
1309
|
+
intent.coordinator
|
|
1310
|
+
);
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
1313
|
+
};
|
|
1314
|
+
|
|
1124
1315
|
const round = async (goalId) => {
|
|
1125
1316
|
releaseHeld();
|
|
1126
1317
|
const thread = store.getTask(goalId);
|
|
@@ -1138,7 +1329,9 @@ export function createCoordinator({
|
|
|
1138
1329
|
// A turn T3 Code is running for one of the thread's agents counts as work going on, though Harness did not start it
|
|
1139
1330
|
// (the coordinator once told Claude Code to "continue" three times while it worked in T3).
|
|
1140
1331
|
const active =
|
|
1141
|
-
store.threadRuns(goalId).some(going) ||
|
|
1332
|
+
store.threadRuns(goalId).some(going) ||
|
|
1333
|
+
hostedAtWork(goalId).length > 0 ||
|
|
1334
|
+
busyInT3(thread).length > 0;
|
|
1142
1335
|
// A thread started through Harness by an agent that runs elsewhere gets no rounds until the person sets a spend ceiling.
|
|
1143
1336
|
if (store.meta(`hosted-thread:${goalId}`)) return;
|
|
1144
1337
|
const local = mode() === "local";
|
|
@@ -1268,7 +1461,7 @@ export function createCoordinator({
|
|
|
1268
1461
|
if (opening)
|
|
1269
1462
|
gathered.thread = {
|
|
1270
1463
|
...gathered.thread,
|
|
1271
|
-
opening: opening.text
|
|
1464
|
+
opening: opening.text,
|
|
1272
1465
|
};
|
|
1273
1466
|
}
|
|
1274
1467
|
const lastSeq = seenUpTo();
|
|
@@ -1281,20 +1474,11 @@ export function createCoordinator({
|
|
|
1281
1474
|
const failures = [];
|
|
1282
1475
|
for (const coordinator of chain) {
|
|
1283
1476
|
try {
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
throw new Error(
|
|
1289
|
-
reply.error || "Harness did not coordinate this round"
|
|
1290
|
-
);
|
|
1291
|
-
decision = reply.result ?? reply;
|
|
1292
|
-
} else {
|
|
1293
|
-
// A backup decides a plain round: an assembly is Harness's, and the person's message goes to everyone instead.
|
|
1294
|
-
if (assembling) break;
|
|
1295
|
-
decision = await localDecision(coordinator, gathered);
|
|
1477
|
+
// A backup decides a plain round: an assembly is Harness's, and the person's message goes to everyone instead.
|
|
1478
|
+
if (coordinator !== "harness" && assembling) break;
|
|
1479
|
+
decision = await decideWith(coordinator, gathered);
|
|
1480
|
+
if (coordinator !== "harness")
|
|
1296
1481
|
store.meta(`coordinator-backup-failed:${coordinator}`, "");
|
|
1297
|
-
}
|
|
1298
1482
|
decidedBy = coordinator;
|
|
1299
1483
|
break;
|
|
1300
1484
|
} catch (failure) {
|
|
@@ -1303,6 +1487,32 @@ export function createCoordinator({
|
|
|
1303
1487
|
store.meta(`coordinator-backup-failed:${coordinator}`, "1");
|
|
1304
1488
|
}
|
|
1305
1489
|
}
|
|
1490
|
+
// A look-up first: what it found goes into the same round, which the same coordinator decides once more, with no
|
|
1491
|
+
// look-up offered then.
|
|
1492
|
+
if (
|
|
1493
|
+
decision?.action === "inspect" &&
|
|
1494
|
+
gathered.moves?.lookUps.includes(decision.lookUp)
|
|
1495
|
+
) {
|
|
1496
|
+
const request =
|
|
1497
|
+
store
|
|
1498
|
+
.roomPosts(goalId, 0, 500)
|
|
1499
|
+
.findLast((post) => post.author === "user" && post.kind === "post")
|
|
1500
|
+
?.text ?? thread.objective;
|
|
1501
|
+
gathered.moves = moves.offered(thread, {
|
|
1502
|
+
candidates: gathered.candidates,
|
|
1503
|
+
looked: moves.lookUp(
|
|
1504
|
+
thread,
|
|
1505
|
+
decision.lookUp,
|
|
1506
|
+
request,
|
|
1507
|
+
decision.before ?? null
|
|
1508
|
+
),
|
|
1509
|
+
});
|
|
1510
|
+
decision = await decideWith(decidedBy, gathered).catch((failure) => {
|
|
1511
|
+
failures.push({ coordinator: decidedBy, error: failure.message });
|
|
1512
|
+
return null;
|
|
1513
|
+
});
|
|
1514
|
+
if (!decision) decidedBy = null;
|
|
1515
|
+
}
|
|
1306
1516
|
const error =
|
|
1307
1517
|
failures.find((entry) => entry.coordinator === "harness")?.error ??
|
|
1308
1518
|
failures[0]?.error ??
|
|
@@ -1371,15 +1581,26 @@ export function createCoordinator({
|
|
|
1371
1581
|
withheld = { reason, asks, forPerson: stripped.forPerson };
|
|
1372
1582
|
}
|
|
1373
1583
|
}
|
|
1584
|
+
const intent = {
|
|
1585
|
+
at: new Date().toISOString(),
|
|
1586
|
+
decision,
|
|
1587
|
+
coordinator: thread.goal.facilitator,
|
|
1588
|
+
candidates: gathered.candidates,
|
|
1589
|
+
asked,
|
|
1590
|
+
rules: decidedBy === "harness" ? keepsGoals() : true,
|
|
1591
|
+
withheld,
|
|
1592
|
+
};
|
|
1593
|
+
keepIntent(goalId, intent);
|
|
1374
1594
|
apply(
|
|
1375
1595
|
store.getTask(goalId),
|
|
1376
1596
|
decision,
|
|
1377
|
-
|
|
1378
|
-
|
|
1597
|
+
intent.coordinator,
|
|
1598
|
+
intent.candidates,
|
|
1379
1599
|
asked,
|
|
1380
|
-
|
|
1600
|
+
intent.rules,
|
|
1381
1601
|
withheld
|
|
1382
1602
|
);
|
|
1603
|
+
keepIntent(goalId, null);
|
|
1383
1604
|
};
|
|
1384
1605
|
|
|
1385
1606
|
// Why Harness did not decide, as one clause: its own words when it said why, else the failure behind it.
|
|
@@ -1441,5 +1662,13 @@ export function createCoordinator({
|
|
|
1441
1662
|
})
|
|
1442
1663
|
);
|
|
1443
1664
|
};
|
|
1444
|
-
return {
|
|
1665
|
+
return {
|
|
1666
|
+
poke,
|
|
1667
|
+
heard,
|
|
1668
|
+
resumed,
|
|
1669
|
+
assembles,
|
|
1670
|
+
recover,
|
|
1671
|
+
hostedAtWork,
|
|
1672
|
+
state: stateOf,
|
|
1673
|
+
};
|
|
1445
1674
|
}
|