tryharness 0.7.72 → 0.7.75
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/assets/opencode-plugin.js +70 -3
- package/assets/pi-extension.ts +7 -1
- package/cli.mjs +2 -2
- package/lib/asks.mjs +2 -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 +220 -35
- package/lib/daemon.mjs +160 -126
- package/lib/dispatchContract.json +1 -31
- package/lib/dispatchTools.js +8 -39
- package/lib/dispatches.mjs +27 -285
- package/lib/goalCommands.mjs +7 -3
- 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/library.mjs +83 -7
- package/lib/localAgentAsk.mjs +20 -29
- package/lib/localStack.mjs +19 -3
- package/lib/machineRoutes.mjs +1 -5
- package/lib/manager.mjs +254 -0
- package/lib/mcp-stdio.mjs +72 -46
- package/lib/moves.mjs +365 -0
- package/lib/nudge.mjs +18 -3
- package/lib/ownMachines.mjs +43 -6
- package/lib/places.mjs +29 -2
- package/lib/runAuthority.mjs +2 -14
- package/lib/runBrief.mjs +14 -1
- package/lib/runWorker.mjs +4 -10
- package/lib/runner.mjs +1 -49
- package/lib/sessionControl.mjs +65 -1
- package/lib/steerHook.mjs +124 -0
- package/lib/steerQueue.mjs +176 -0
- package/lib/store.mjs +20 -29
- package/lib/subagentSteering.mjs +363 -0
- package/lib/subagents.mjs +138 -29
- package/lib/swarm.mjs +16 -6
- package/lib/taskCommands.mjs +0 -62
- package/lib/threadActions.mjs +4 -2
- package/lib/threadBriefs.mjs +9 -3
- package/lib/threadRuns.mjs +13 -0
- package/npm-shrinkwrap.json +14 -14
- package/package.json +4 -4
- package/release.json +48 -44
- package/lib/comfyExecution.mjs +0 -545
- package/lib/promptDecider.mjs +0 -471
- package/lib/promptFlow.mjs +0 -597
- package/lib/promptScopes.mjs +0 -670
package/lib/coordinator.mjs
CHANGED
|
@@ -27,6 +27,10 @@ import { TEAM } from "./team.mjs";
|
|
|
27
27
|
// the thread's limit, something outward-facing or hard to undo, a secret or a change to what the goal is for; a
|
|
28
28
|
// question already put to them waits for its answer.
|
|
29
29
|
|
|
30
|
+
// Who decided a round, as its record says: Jev on the server, or a backup coding agent here by its own id. Never
|
|
31
|
+
// "harness": that is the Harness agent, which decides no rounds.
|
|
32
|
+
export const JEV = "jev";
|
|
33
|
+
const deciderName = (id) => (id === JEV ? "Jev" : nameOf(id));
|
|
30
34
|
const CODING = new Set(MACHINE_RUNNERS);
|
|
31
35
|
// The agents with a read-only switch (runner.mjs, review in the roster): only they can be handed a review.
|
|
32
36
|
const REVIEWERS = new Set(
|
|
@@ -71,7 +75,7 @@ export const speakerOf = (store, thread, post) =>
|
|
|
71
75
|
// Harness's part with no Harness window open waits on the board for one (daemon.mjs offerToServer); the thread goes on.
|
|
72
76
|
const waitsForWindow = (run) =>
|
|
73
77
|
run.status === "open" && run.target_agent === "harness";
|
|
74
|
-
const going = (run) =>
|
|
78
|
+
export const going = (run) =>
|
|
75
79
|
["open", "claimed", "running"].includes(run.status) && !waitsForWindow(run);
|
|
76
80
|
|
|
77
81
|
// The privacy setting: the round's facts go to an agent on this machine with its tools off, which answers in the
|
|
@@ -88,6 +92,7 @@ Decide the next step and answer with one JSON object only:
|
|
|
88
92
|
)}, "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}
|
|
89
93
|
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.
|
|
90
94
|
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.
|
|
95
|
+
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.
|
|
91
96
|
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.
|
|
92
97
|
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.
|
|
93
98
|
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.
|
|
@@ -167,6 +172,12 @@ export function createCoordinator({
|
|
|
167
172
|
// (ownMachines.mjs), and whether one of them can take the thread's turn at all.
|
|
168
173
|
machinesOf = () => undefined,
|
|
169
174
|
placeable = () => true,
|
|
175
|
+
// Whether each of the person's computers can do a piece of work, an agent there looking (capabilityCheck.mjs).
|
|
176
|
+
capabilities = null,
|
|
177
|
+
// The moves beyond bringing agents in (moves.mjs): look up, continue, start a held turn, show a result, stop, close.
|
|
178
|
+
moves = null,
|
|
179
|
+
// The person's open asks in a thread (manager.mjs): while any is open, the goal is not met nor ready for review.
|
|
180
|
+
openAsks = () => [],
|
|
170
181
|
computerOf = (goalId) => store.meta(`thread-work-computer:${goalId}`) || null,
|
|
171
182
|
// A post from the other side of a shared project (projects.mjs): their own swarm sorts it, so it starts no round here.
|
|
172
183
|
fromPartner = () => false,
|
|
@@ -223,6 +234,31 @@ export function createCoordinator({
|
|
|
223
234
|
Boolean(team) && (mode() === "local" || serverHas("swarm_routes"));
|
|
224
235
|
const keepsPlacement = () =>
|
|
225
236
|
mode() === "local" || serverHas("swarm_placement");
|
|
237
|
+
// The moves go to a coordinator that takes them: this computer's, or a Harness with swarm_moves.
|
|
238
|
+
const movesTaken = () =>
|
|
239
|
+
Boolean(moves) && (mode() === "local" || serverHas("swarm_moves"));
|
|
240
|
+
// What each computer said it can do with the person's newest message to the swarm (capabilityCheck.mjs), by computer
|
|
241
|
+
// id: asked once per message, kept for the thread's rounds until the next one, sent to a coordinator that reads it.
|
|
242
|
+
const canDo = async (thread, posts, asked) => {
|
|
243
|
+
if (
|
|
244
|
+
!capabilities ||
|
|
245
|
+
!(mode() === "local" || serverHas("capability_checks"))
|
|
246
|
+
)
|
|
247
|
+
return new Map();
|
|
248
|
+
const key = `capabilities:${thread.id}`;
|
|
249
|
+
let kept = JSON.parse(store.meta(key) || "null");
|
|
250
|
+
const message = asked && posts.find((post) => post.seq === asked.seq);
|
|
251
|
+
if (message && kept?.seq !== message.seq) {
|
|
252
|
+
kept = {
|
|
253
|
+
seq: message.seq,
|
|
254
|
+
answers: await capabilities.check(message.text),
|
|
255
|
+
};
|
|
256
|
+
store.meta(key, JSON.stringify(kept));
|
|
257
|
+
}
|
|
258
|
+
return new Map(
|
|
259
|
+
(kept?.answers ?? []).map(({ id, answer, why }) => [id, { answer, why }])
|
|
260
|
+
);
|
|
261
|
+
};
|
|
226
262
|
// The person's pins: specialty -> the agent that holds it when a step asks for it.
|
|
227
263
|
const pinsNow = () =>
|
|
228
264
|
Object.fromEntries(
|
|
@@ -284,7 +320,11 @@ export function createCoordinator({
|
|
|
284
320
|
seq: post.seq,
|
|
285
321
|
author: speakerOf(store, thread, post),
|
|
286
322
|
kind: post.kind,
|
|
287
|
-
|
|
323
|
+
// The person's own words whole; an agent's cut to the limit.
|
|
324
|
+
text:
|
|
325
|
+
post.author === "user"
|
|
326
|
+
? post.text
|
|
327
|
+
: (serverWords?.agentText(post) ?? post.text).slice(0, POST_CHARS),
|
|
288
328
|
}));
|
|
289
329
|
const runs = store.threadRuns(thread.id);
|
|
290
330
|
const since = state.lastRoundAt ?? "";
|
|
@@ -339,11 +379,11 @@ export function createCoordinator({
|
|
|
339
379
|
// Each card's specialties, pins and offices go only to a Harness that reads them (feature team_specialties).
|
|
340
380
|
const specialtiesTaken =
|
|
341
381
|
mode() === "local" || serverHas("team_specialties");
|
|
382
|
+
const can = await canDo(thread, posts, asked);
|
|
342
383
|
// Who could hold a role on the thread's team: the candidates and the agents the person named.
|
|
343
384
|
const eligible = roster()
|
|
344
385
|
.filter(
|
|
345
386
|
(candidate) =>
|
|
346
|
-
(!CODING.has(candidate.id) || thread.goal.workspace) &&
|
|
347
387
|
!failedHereLately(thread.id, candidate.id) &&
|
|
348
388
|
(!CODING.has(candidate.id) ||
|
|
349
389
|
placeable(candidate.id, thread.goal.workspace)) &&
|
|
@@ -389,6 +429,7 @@ export function createCoordinator({
|
|
|
389
429
|
? { thread_repository }
|
|
390
430
|
: {}),
|
|
391
431
|
...(keepsPlacement() ? { id } : {}),
|
|
432
|
+
...(can.has(id) ? { can_do: can.get(id) } : {}),
|
|
392
433
|
})
|
|
393
434
|
)
|
|
394
435
|
: undefined,
|
|
@@ -453,6 +494,7 @@ export function createCoordinator({
|
|
|
453
494
|
const framed = await frame(thread.id);
|
|
454
495
|
return {
|
|
455
496
|
...(framed ? { frame: framed } : {}),
|
|
497
|
+
...(movesTaken() ? { moves: moves.offered(thread, { candidates }) } : {}),
|
|
456
498
|
...teamFacts,
|
|
457
499
|
thread: {
|
|
458
500
|
id: thread.id,
|
|
@@ -530,7 +572,6 @@ export function createCoordinator({
|
|
|
530
572
|
(agent) =>
|
|
531
573
|
agent !== "harness" &&
|
|
532
574
|
!asked.named.includes(agent) &&
|
|
533
|
-
(!CODING.has(agent) || thread.goal.workspace) &&
|
|
534
575
|
(!TAGGED.has(agent) || inThread.includes(agent)) &&
|
|
535
576
|
(reachable || CODING.has(agent))
|
|
536
577
|
);
|
|
@@ -619,7 +660,8 @@ export function createCoordinator({
|
|
|
619
660
|
// change since, or no passing check yet, leaves the goal working ("Ready for your review" was once posted
|
|
620
661
|
// with 1 of 3 checks met).
|
|
621
662
|
const unchecked =
|
|
622
|
-
keepsTeams() && !team.checkedNow(thread.id, headOf(thread.id))
|
|
663
|
+
(keepsTeams() && !team.checkedNow(thread.id, headOf(thread.id))) ||
|
|
664
|
+
openAsks(thread.id).length > 0;
|
|
623
665
|
const settles =
|
|
624
666
|
decision.goalState === "met" ||
|
|
625
667
|
decision.goalState === "ready_for_review" ||
|
|
@@ -827,9 +869,18 @@ export function createCoordinator({
|
|
|
827
869
|
store.setGoalTeam(thread.id, [...thread.goal.team, agent]);
|
|
828
870
|
}
|
|
829
871
|
}
|
|
872
|
+
// The route's computer for its step, else the one Jev picked for this agent, when it is one of the agent's online
|
|
873
|
+
// computers.
|
|
874
|
+
const picked =
|
|
875
|
+
options.computer &&
|
|
876
|
+
(machinesOf(agent, thread.goal.workspace) ?? []).some(
|
|
877
|
+
(computer) => computer.id === options.computer && computer.online
|
|
878
|
+
)
|
|
879
|
+
? options.computer
|
|
880
|
+
: null;
|
|
830
881
|
options = {
|
|
831
882
|
...options,
|
|
832
|
-
routeMachine: team?.machineFor(thread.id, agent) ??
|
|
883
|
+
routeMachine: team?.machineFor(thread.id, agent) ?? picked,
|
|
833
884
|
};
|
|
834
885
|
const step = keepsTeams() ? team.pinnedStep(thread.id, agent) : null;
|
|
835
886
|
if (!step || !store.busyElsewhere(agent, thread.id)) {
|
|
@@ -889,6 +940,8 @@ export function createCoordinator({
|
|
|
889
940
|
endRoute(thread, given);
|
|
890
941
|
if (applyGoal(thread, given, coordinator)) return;
|
|
891
942
|
applyCheckIn(thread, given, coordinator);
|
|
943
|
+
// A move carries the person's own words or an agent's own result (moves.mjs), outside the route and the briefs.
|
|
944
|
+
if (moves?.apply(thread, given, coordinator)) return;
|
|
892
945
|
const planned = applyTeamPlan(thread, given, coordinator, asked);
|
|
893
946
|
if (
|
|
894
947
|
given.team?.plan &&
|
|
@@ -1023,7 +1076,11 @@ export function createCoordinator({
|
|
|
1023
1076
|
withheld
|
|
1024
1077
|
? part.text
|
|
1025
1078
|
: `${coordinator} asked you: ${part.text.slice(0, 300)}`,
|
|
1026
|
-
{
|
|
1079
|
+
{
|
|
1080
|
+
review: part.review,
|
|
1081
|
+
words: part.text,
|
|
1082
|
+
computer: part.computer ?? null,
|
|
1083
|
+
},
|
|
1027
1084
|
coordinator
|
|
1028
1085
|
);
|
|
1029
1086
|
if (withheld)
|
|
@@ -1085,7 +1142,7 @@ export function createCoordinator({
|
|
|
1085
1142
|
thread,
|
|
1086
1143
|
agent,
|
|
1087
1144
|
withheld ? text : `${coordinator} asked you: ${text.slice(0, 300)}`,
|
|
1088
|
-
{ review, words: text },
|
|
1145
|
+
{ review, words: text, computer: decision.computer ?? null },
|
|
1089
1146
|
coordinator
|
|
1090
1147
|
);
|
|
1091
1148
|
if (withheld) saidWithheld(thread, withheld, [agent]);
|
|
@@ -1144,7 +1201,7 @@ export function createCoordinator({
|
|
|
1144
1201
|
}
|
|
1145
1202
|
store.recordRound({
|
|
1146
1203
|
goalId: thread.id,
|
|
1147
|
-
coordinator:
|
|
1204
|
+
coordinator: JEV,
|
|
1148
1205
|
action: decision ? "keep_goal" : null,
|
|
1149
1206
|
agent: null,
|
|
1150
1207
|
loop: null,
|
|
@@ -1152,7 +1209,7 @@ export function createCoordinator({
|
|
|
1152
1209
|
progress: gathered.progress,
|
|
1153
1210
|
estimatedMicroUsd: decision?.estimatedMicroUsd ?? null,
|
|
1154
1211
|
elapsedMs: Date.now() - startedAt,
|
|
1155
|
-
error: error &&
|
|
1212
|
+
error: error && `${deciderName(JEV)}: ${error}`,
|
|
1156
1213
|
});
|
|
1157
1214
|
if (!decision?.goal) return;
|
|
1158
1215
|
const now = store.getTask(thread.id);
|
|
@@ -1167,6 +1224,98 @@ export function createCoordinator({
|
|
|
1167
1224
|
store.meta(`goal-kept:${thread.id}`, String(newest));
|
|
1168
1225
|
};
|
|
1169
1226
|
|
|
1227
|
+
// One coordinator's decision for the round's facts: Harness's server, or a coding agent here with its tools off.
|
|
1228
|
+
const decideWith = async (coordinator, gathered) => {
|
|
1229
|
+
if (coordinator !== JEV) return localDecision(coordinator, gathered);
|
|
1230
|
+
// No deadline of its own: the round ends when Harness answers or the connection drops.
|
|
1231
|
+
const reply = await askHarness("coordinate", gathered, null);
|
|
1232
|
+
if (!reply.ok)
|
|
1233
|
+
throw new Error(reply.error || "Harness did not coordinate this round");
|
|
1234
|
+
return reply.result ?? reply;
|
|
1235
|
+
};
|
|
1236
|
+
|
|
1237
|
+
// A decision being carried out, kept until it is (the contract's outbox): a restart in the middle finishes it once.
|
|
1238
|
+
const OUTBOX = "round-outbox";
|
|
1239
|
+
const outbox = () => {
|
|
1240
|
+
try {
|
|
1241
|
+
return JSON.parse(store.meta(OUTBOX) || "{}");
|
|
1242
|
+
} catch {
|
|
1243
|
+
return {};
|
|
1244
|
+
}
|
|
1245
|
+
};
|
|
1246
|
+
const keepIntent = (goalId, intent) =>
|
|
1247
|
+
store.meta(
|
|
1248
|
+
OUTBOX,
|
|
1249
|
+
JSON.stringify({ ...outbox(), [goalId]: intent ?? undefined })
|
|
1250
|
+
);
|
|
1251
|
+
// The agents a decision wakes, each with its own words.
|
|
1252
|
+
const wokenBy = (decision) =>
|
|
1253
|
+
decision.action === "assemble"
|
|
1254
|
+
? (decision.parts ?? []).map((part) => part.agent)
|
|
1255
|
+
: ["hand_on", "continue"].includes(decision.action) && decision.agent
|
|
1256
|
+
? [decision.agent]
|
|
1257
|
+
: [];
|
|
1258
|
+
// Whether an agent has work in the thread that began at or after `at`: its wake from this decision got out.
|
|
1259
|
+
const wokenSince = (goalId, agent, at) =>
|
|
1260
|
+
store
|
|
1261
|
+
.threadRuns(goalId)
|
|
1262
|
+
.some((run) => run.target_agent === agent && run.created_at >= at) ||
|
|
1263
|
+
store
|
|
1264
|
+
.roomPosts(goalId, 0, 500)
|
|
1265
|
+
.some(
|
|
1266
|
+
(post) =>
|
|
1267
|
+
post.kind === "job" &&
|
|
1268
|
+
post.mentions.includes(agent) &&
|
|
1269
|
+
post.created_at >= at
|
|
1270
|
+
);
|
|
1271
|
+
/**
|
|
1272
|
+
* After a restart: each decision that was being carried out. Not begun (nothing posted since), it is carried out
|
|
1273
|
+
* whole; begun, only the agents it woke that have nothing since are woken, with the words it gave them.
|
|
1274
|
+
*/
|
|
1275
|
+
const recover = () => {
|
|
1276
|
+
for (const [goalId, intent] of Object.entries(outbox())) {
|
|
1277
|
+
keepIntent(goalId, null);
|
|
1278
|
+
const thread = store.getTask(goalId);
|
|
1279
|
+
if (!thread || thread.status !== "open") continue;
|
|
1280
|
+
const begun = store
|
|
1281
|
+
.roomPosts(goalId, 0, 500)
|
|
1282
|
+
.some(
|
|
1283
|
+
(post) =>
|
|
1284
|
+
post.created_at >= intent.at &&
|
|
1285
|
+
store.meta(`coordinator-post:${post.id}`)
|
|
1286
|
+
);
|
|
1287
|
+
if (!begun) {
|
|
1288
|
+
apply(
|
|
1289
|
+
thread,
|
|
1290
|
+
intent.decision,
|
|
1291
|
+
intent.coordinator,
|
|
1292
|
+
intent.candidates,
|
|
1293
|
+
intent.asked,
|
|
1294
|
+
intent.rules,
|
|
1295
|
+
intent.withheld
|
|
1296
|
+
);
|
|
1297
|
+
continue;
|
|
1298
|
+
}
|
|
1299
|
+
for (const agent of wokenBy(intent.decision)) {
|
|
1300
|
+
if (wokenSince(goalId, agent, intent.at)) continue;
|
|
1301
|
+
const words =
|
|
1302
|
+
intent.decision.action === "assemble"
|
|
1303
|
+
? intent.decision.parts.find((part) => part.agent === agent)?.text
|
|
1304
|
+
: intent.decision.text;
|
|
1305
|
+
if (intent.decision.action === "continue")
|
|
1306
|
+
moves.apply(thread, intent.decision, intent.coordinator);
|
|
1307
|
+
else if (words)
|
|
1308
|
+
handOnOrHold(
|
|
1309
|
+
thread,
|
|
1310
|
+
agent,
|
|
1311
|
+
`${intent.coordinator} asked you: ${String(words).slice(0, 300)}`,
|
|
1312
|
+
{ words, computer: intent.decision.computer ?? null },
|
|
1313
|
+
intent.coordinator
|
|
1314
|
+
);
|
|
1315
|
+
}
|
|
1316
|
+
}
|
|
1317
|
+
};
|
|
1318
|
+
|
|
1170
1319
|
const round = async (goalId) => {
|
|
1171
1320
|
releaseHeld();
|
|
1172
1321
|
const thread = store.getTask(goalId);
|
|
@@ -1231,7 +1380,7 @@ export function createCoordinator({
|
|
|
1231
1380
|
// dropped mid-round, not for a computer that is offline.
|
|
1232
1381
|
if (!local && !connected()) return;
|
|
1233
1382
|
// Who decides, in order: Harness (not on the privacy setting), then the coding agents here as backups.
|
|
1234
|
-
const chain = [...(local ? [] : [
|
|
1383
|
+
const chain = [...(local ? [] : [JEV]), ...backups()];
|
|
1235
1384
|
if (!chain.length) {
|
|
1236
1385
|
if (asked) settleAsked(goalId);
|
|
1237
1386
|
if (asked) tellEveryone(thread, asked, "no agent here can coordinate");
|
|
@@ -1316,7 +1465,7 @@ export function createCoordinator({
|
|
|
1316
1465
|
if (opening)
|
|
1317
1466
|
gathered.thread = {
|
|
1318
1467
|
...gathered.thread,
|
|
1319
|
-
opening: opening.text
|
|
1468
|
+
opening: opening.text,
|
|
1320
1469
|
};
|
|
1321
1470
|
}
|
|
1322
1471
|
const lastSeq = seenUpTo();
|
|
@@ -1329,30 +1478,47 @@ export function createCoordinator({
|
|
|
1329
1478
|
const failures = [];
|
|
1330
1479
|
for (const coordinator of chain) {
|
|
1331
1480
|
try {
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
throw new Error(
|
|
1337
|
-
reply.error || "Harness did not coordinate this round"
|
|
1338
|
-
);
|
|
1339
|
-
decision = reply.result ?? reply;
|
|
1340
|
-
} else {
|
|
1341
|
-
// A backup decides a plain round: an assembly is Harness's, and the person's message goes to everyone instead.
|
|
1342
|
-
if (assembling) break;
|
|
1343
|
-
decision = await localDecision(coordinator, gathered);
|
|
1481
|
+
// A backup decides a plain round: an assembly is Harness's, and the person's message goes to everyone instead.
|
|
1482
|
+
if (coordinator !== JEV && assembling) break;
|
|
1483
|
+
decision = await decideWith(coordinator, gathered);
|
|
1484
|
+
if (coordinator !== JEV)
|
|
1344
1485
|
store.meta(`coordinator-backup-failed:${coordinator}`, "");
|
|
1345
|
-
}
|
|
1346
1486
|
decidedBy = coordinator;
|
|
1347
1487
|
break;
|
|
1348
1488
|
} catch (failure) {
|
|
1349
1489
|
failures.push({ coordinator, error: failure.message });
|
|
1350
|
-
if (coordinator !==
|
|
1490
|
+
if (coordinator !== JEV)
|
|
1351
1491
|
store.meta(`coordinator-backup-failed:${coordinator}`, "1");
|
|
1352
1492
|
}
|
|
1353
1493
|
}
|
|
1494
|
+
// A look-up first: what it found goes into the same round, which the same coordinator decides once more, with no
|
|
1495
|
+
// look-up offered then.
|
|
1496
|
+
if (
|
|
1497
|
+
decision?.action === "inspect" &&
|
|
1498
|
+
gathered.moves?.lookUps.includes(decision.lookUp)
|
|
1499
|
+
) {
|
|
1500
|
+
const request =
|
|
1501
|
+
store
|
|
1502
|
+
.roomPosts(goalId, 0, 500)
|
|
1503
|
+
.findLast((post) => post.author === "user" && post.kind === "post")
|
|
1504
|
+
?.text ?? thread.objective;
|
|
1505
|
+
gathered.moves = moves.offered(thread, {
|
|
1506
|
+
candidates: gathered.candidates,
|
|
1507
|
+
looked: moves.lookUp(
|
|
1508
|
+
thread,
|
|
1509
|
+
decision.lookUp,
|
|
1510
|
+
request,
|
|
1511
|
+
decision.before ?? null
|
|
1512
|
+
),
|
|
1513
|
+
});
|
|
1514
|
+
decision = await decideWith(decidedBy, gathered).catch((failure) => {
|
|
1515
|
+
failures.push({ coordinator: decidedBy, error: failure.message });
|
|
1516
|
+
return null;
|
|
1517
|
+
});
|
|
1518
|
+
if (!decision) decidedBy = null;
|
|
1519
|
+
}
|
|
1354
1520
|
const error =
|
|
1355
|
-
failures.find((entry) => entry.coordinator ===
|
|
1521
|
+
failures.find((entry) => entry.coordinator === JEV)?.error ??
|
|
1356
1522
|
failures[0]?.error ??
|
|
1357
1523
|
null;
|
|
1358
1524
|
const next = {
|
|
@@ -1380,7 +1546,7 @@ export function createCoordinator({
|
|
|
1380
1546
|
// What failed before the round was decided: Harness's error even when a backup decided.
|
|
1381
1547
|
error: failures.length
|
|
1382
1548
|
? failures
|
|
1383
|
-
.map((entry) => `${
|
|
1549
|
+
.map((entry) => `${deciderName(entry.coordinator)}: ${entry.error}`)
|
|
1384
1550
|
.join("; ")
|
|
1385
1551
|
: null,
|
|
1386
1552
|
});
|
|
@@ -1391,7 +1557,7 @@ export function createCoordinator({
|
|
|
1391
1557
|
return;
|
|
1392
1558
|
const others = failures
|
|
1393
1559
|
.slice(1)
|
|
1394
|
-
.map((entry) =>
|
|
1560
|
+
.map((entry) => deciderName(entry.coordinator))
|
|
1395
1561
|
.join(" and ");
|
|
1396
1562
|
noteOnce(
|
|
1397
1563
|
thread,
|
|
@@ -1400,7 +1566,7 @@ export function createCoordinator({
|
|
|
1400
1566
|
notifyBoard(store.getTask(goalId));
|
|
1401
1567
|
return;
|
|
1402
1568
|
}
|
|
1403
|
-
if (decidedBy !==
|
|
1569
|
+
if (decidedBy !== JEV && !local)
|
|
1404
1570
|
noteOnce(
|
|
1405
1571
|
thread,
|
|
1406
1572
|
`${harnessCould(error)}; ${nameOf(decidedBy)} coordinated it.`
|
|
@@ -1408,7 +1574,7 @@ export function createCoordinator({
|
|
|
1408
1574
|
// A round Harness's server decided keeps the person's go, so its words reach the agents only once this computer read
|
|
1409
1575
|
// them (serverWords.mjs); rounds decided on this computer are this computer's own words.
|
|
1410
1576
|
let withheld = null;
|
|
1411
|
-
if (decidedBy ===
|
|
1577
|
+
if (decidedBy === JEV && serverWords) {
|
|
1412
1578
|
const { reason, asks } = await serverWords.screen(
|
|
1413
1579
|
decision,
|
|
1414
1580
|
readingFor(goalId)
|
|
@@ -1419,15 +1585,26 @@ export function createCoordinator({
|
|
|
1419
1585
|
withheld = { reason, asks, forPerson: stripped.forPerson };
|
|
1420
1586
|
}
|
|
1421
1587
|
}
|
|
1588
|
+
const intent = {
|
|
1589
|
+
at: new Date().toISOString(),
|
|
1590
|
+
decision,
|
|
1591
|
+
coordinator: thread.goal.facilitator,
|
|
1592
|
+
candidates: gathered.candidates,
|
|
1593
|
+
asked,
|
|
1594
|
+
rules: decidedBy === JEV ? keepsGoals() : true,
|
|
1595
|
+
withheld,
|
|
1596
|
+
};
|
|
1597
|
+
keepIntent(goalId, intent);
|
|
1422
1598
|
apply(
|
|
1423
1599
|
store.getTask(goalId),
|
|
1424
1600
|
decision,
|
|
1425
|
-
|
|
1426
|
-
|
|
1601
|
+
intent.coordinator,
|
|
1602
|
+
intent.candidates,
|
|
1427
1603
|
asked,
|
|
1428
|
-
|
|
1604
|
+
intent.rules,
|
|
1429
1605
|
withheld
|
|
1430
1606
|
);
|
|
1607
|
+
keepIntent(goalId, null);
|
|
1431
1608
|
};
|
|
1432
1609
|
|
|
1433
1610
|
// Why Harness did not decide, as one clause: its own words when it said why, else the failure behind it.
|
|
@@ -1489,5 +1666,13 @@ export function createCoordinator({
|
|
|
1489
1666
|
})
|
|
1490
1667
|
);
|
|
1491
1668
|
};
|
|
1492
|
-
return {
|
|
1669
|
+
return {
|
|
1670
|
+
poke,
|
|
1671
|
+
heard,
|
|
1672
|
+
resumed,
|
|
1673
|
+
assembles,
|
|
1674
|
+
recover,
|
|
1675
|
+
hostedAtWork,
|
|
1676
|
+
state: stateOf,
|
|
1677
|
+
};
|
|
1493
1678
|
}
|