tryharness 0.7.73 → 0.7.76
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/pi-extension.ts +7 -1
- package/cli.mjs +67 -4
- package/lib/actorRoster.mjs +20 -9
- package/lib/adoption.mjs +5 -3
- package/lib/audit.mjs +7 -2
- package/lib/boardFiles.mjs +4 -2
- package/lib/boardMirror.mjs +2 -0
- package/lib/boardProtocol.json +4 -0
- package/lib/bridge.mjs +3 -0
- package/lib/capabilityCheck.mjs +39 -3
- package/lib/coordinator.mjs +480 -117
- package/lib/daemon.mjs +74 -21
- package/lib/dispatcher.mjs +568 -0
- package/lib/goalCommands.mjs +21 -6
- package/lib/handoffs.mjs +8 -7
- package/lib/handover.mjs +2 -2
- package/lib/inference.mjs +53 -3
- package/lib/jobAnswers.mjs +7 -6
- package/lib/lessons.mjs +6 -1
- package/lib/library.mjs +83 -7
- package/lib/lineup.mjs +17 -9
- package/lib/localAgentAsk.mjs +68 -29
- package/lib/localStack.mjs +19 -3
- package/lib/localmodels.mjs +59 -25
- package/lib/machineRoutes.mjs +1 -0
- package/lib/manager.mjs +97 -52
- package/lib/mcp-stdio.mjs +14 -7
- package/lib/members.json +5 -1
- package/lib/members.mjs +21 -1
- package/lib/moves.mjs +15 -2
- package/lib/nudge.mjs +5 -0
- package/lib/plans.mjs +2 -1
- package/lib/projects.mjs +16 -9
- package/lib/runAuthority.mjs +2 -1
- package/lib/runBrief.mjs +2 -2
- package/lib/runWorker.mjs +6 -6
- package/lib/snippets.mjs +5 -5
- package/lib/store.mjs +79 -10
- package/lib/swarm.mjs +56 -12
- package/lib/taskCommands.mjs +8 -8
- package/lib/taskRooms.mjs +6 -8
- package/lib/team.mjs +5 -3
- package/lib/threadActions.mjs +6 -30
- package/lib/threadAuthority.mjs +16 -3
- package/lib/threadRuns.mjs +26 -16
- package/lib/verdicts.mjs +2 -2
- package/npm-shrinkwrap.json +14 -14
- package/package.json +4 -4
- package/release.json +50 -49
package/lib/coordinator.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import { LOCAL_DECIDERS, askLocalAgent } from "./localAgentAsk.mjs";
|
|
|
2
2
|
import { roundFields } from "./cards.mjs";
|
|
3
3
|
import {
|
|
4
4
|
CLOUD_HOMED,
|
|
5
|
+
DISPATCHER,
|
|
5
6
|
MACHINE_RUNNERS,
|
|
6
7
|
MEMBERS,
|
|
7
8
|
TAGGED_ONLY,
|
|
@@ -27,6 +28,10 @@ import { TEAM } from "./team.mjs";
|
|
|
27
28
|
// the thread's limit, something outward-facing or hard to undo, a secret or a change to what the goal is for; a
|
|
28
29
|
// question already put to them waits for its answer.
|
|
29
30
|
|
|
31
|
+
// Who decided a round, as its record says: Jev on the server, or a backup coding agent here by its own id. Never
|
|
32
|
+
// "harness": that is the Harness agent, which decides no rounds.
|
|
33
|
+
export const JEV = "jev";
|
|
34
|
+
const deciderName = (id) => (id === JEV ? "Jev" : nameOf(id));
|
|
30
35
|
const CODING = new Set(MACHINE_RUNNERS);
|
|
31
36
|
// The agents with a read-only switch (runner.mjs, review in the roster): only they can be handed a review.
|
|
32
37
|
const REVIEWERS = new Set(
|
|
@@ -139,6 +144,8 @@ export function createCoordinator({
|
|
|
139
144
|
store,
|
|
140
145
|
mode,
|
|
141
146
|
askHarness,
|
|
147
|
+
// The dispatcher slot (dispatcher.mjs): who words a round Jev decides, sent with it to a server that takes it.
|
|
148
|
+
dispatcher = null,
|
|
142
149
|
connected,
|
|
143
150
|
serverHas,
|
|
144
151
|
roster,
|
|
@@ -174,6 +181,8 @@ export function createCoordinator({
|
|
|
174
181
|
moves = null,
|
|
175
182
|
// The person's open asks in a thread (manager.mjs): while any is open, the goal is not met nor ready for review.
|
|
176
183
|
openAsks = () => [],
|
|
184
|
+
// The person's asks the manager has seen done in a thread.
|
|
185
|
+
doneAsks = () => [],
|
|
177
186
|
computerOf = (goalId) => store.meta(`thread-work-computer:${goalId}`) || null,
|
|
178
187
|
// A post from the other side of a shared project (projects.mjs): their own swarm sorts it, so it starts no round here.
|
|
179
188
|
fromPartner = () => false,
|
|
@@ -210,6 +219,113 @@ export function createCoordinator({
|
|
|
210
219
|
.threadRuns(goalId)
|
|
211
220
|
.some((run) => run.target_agent === agent && going(run)) ||
|
|
212
221
|
hostedAtWork(goalId).includes(agent);
|
|
222
|
+
// Everything the person asked is done (the manager's record) and they have said nothing since: a round then wakes no
|
|
223
|
+
// one. In the A1 run (thread a7aa2891, November 1) the manager had posted "Done: ... shown in #5" when a second round
|
|
224
|
+
// asked Claude Code to "finalize" it, and Claude Code posted its answer twice.
|
|
225
|
+
const allDone = (thread, asked) =>
|
|
226
|
+
!asked &&
|
|
227
|
+
openAsks(thread.id).length === 0 &&
|
|
228
|
+
doneAsks(thread.id).length > 0;
|
|
229
|
+
// The person's message a round answers, whole, as they wrote it: the one they sent the swarm, else their newest post
|
|
230
|
+
// that no agent has answered since (a new thread's opening message is one: it is no ask to the swarm, and the live
|
|
231
|
+
// A1 run on November 1 handed Claude Code a brief in its place).
|
|
232
|
+
const personMessage = (thread, asked) => {
|
|
233
|
+
if (asked) return store.roomPosts(thread.id, asked.seq - 1, 1)[0] ?? null;
|
|
234
|
+
const posts = store.roomPosts(thread.id, 0, 500);
|
|
235
|
+
const newest = posts.findLast(
|
|
236
|
+
(post) => post.author === "user" && post.kind === "post"
|
|
237
|
+
);
|
|
238
|
+
if (!newest) return null;
|
|
239
|
+
const answered = posts.some(
|
|
240
|
+
(post) =>
|
|
241
|
+
post.seq > newest.seq &&
|
|
242
|
+
post.author !== "user" &&
|
|
243
|
+
post.author !== thread.goal.facilitator &&
|
|
244
|
+
["post", "result"].includes(post.kind)
|
|
245
|
+
);
|
|
246
|
+
return answered ? null : newest;
|
|
247
|
+
};
|
|
248
|
+
// An agent is handed each of the person's messages once, whichever round hands it on: a new thread's opening round
|
|
249
|
+
// and its message-to-the-swarm round both handed Claude Code the A1 message (live, November 1).
|
|
250
|
+
// A run of the agent that ended after the message was handed to it frees the message for another try (a retry
|
|
251
|
+
// after a failure is new work).
|
|
252
|
+
const deliveredKey = (thread, agent) => `delivered:${thread.id}:${agent}`;
|
|
253
|
+
const delivered = (thread, agent, message) => {
|
|
254
|
+
if (!message) return false;
|
|
255
|
+
let kept = null;
|
|
256
|
+
try {
|
|
257
|
+
kept = JSON.parse(store.meta(deliveredKey(thread, agent)) || "null");
|
|
258
|
+
} catch {
|
|
259
|
+
kept = null;
|
|
260
|
+
}
|
|
261
|
+
if (kept?.seq !== message.seq) return false;
|
|
262
|
+
return !store
|
|
263
|
+
.threadRuns(thread.id)
|
|
264
|
+
.some(
|
|
265
|
+
(run) =>
|
|
266
|
+
run.target_agent === agent &&
|
|
267
|
+
!going(run) &&
|
|
268
|
+
String(run.updated_at) > kept.at
|
|
269
|
+
);
|
|
270
|
+
};
|
|
271
|
+
// Claimed before the capability check, so a round deciding at the same time sees it; let go when the check says no.
|
|
272
|
+
const markDelivered = (thread, agent, message) => {
|
|
273
|
+
if (message)
|
|
274
|
+
store.meta(
|
|
275
|
+
deliveredKey(thread, agent),
|
|
276
|
+
JSON.stringify({ seq: message.seq, at: new Date().toISOString() })
|
|
277
|
+
);
|
|
278
|
+
};
|
|
279
|
+
const unmarkDelivered = (thread, agent, message) => {
|
|
280
|
+
if (delivered(thread, agent, message))
|
|
281
|
+
store.meta(deliveredKey(thread, agent), "");
|
|
282
|
+
};
|
|
283
|
+
// A round decided to answer the person's message, and an agent answered it while the round was worded: handing it
|
|
284
|
+
// on now would be on stale facts.
|
|
285
|
+
const answeredMeanwhile = (thread, decision, asked) =>
|
|
286
|
+
Number.isInteger(decision.answers) && !personMessage(thread, asked);
|
|
287
|
+
const wholeWords = (message) =>
|
|
288
|
+
`The person's message #${message.seq}, as they wrote it:\n\n${message.text.slice(0, 20_000)}`;
|
|
289
|
+
// A review checks an agent's work in the thread; with none there, Jev's "review" is told and shown as a look (the
|
|
290
|
+
// owner's A1 test, November 1: a lookup went out as "Review the current state of post 1"), still run read-only as Jev
|
|
291
|
+
// asked. A server that offers "look" lets Jev say so itself.
|
|
292
|
+
const modeIn = (thread, mode, alongside = []) => {
|
|
293
|
+
if (mode !== "review") return mode === "look" ? "look" : "work";
|
|
294
|
+
// In an assembly a review checks the work being made beside it.
|
|
295
|
+
if (alongside.some((part) => part.mode === "work")) return "review";
|
|
296
|
+
const checkable = store
|
|
297
|
+
.roomPosts(thread.id, 0, 500)
|
|
298
|
+
.some(
|
|
299
|
+
(post) =>
|
|
300
|
+
post.author !== "user" &&
|
|
301
|
+
post.author !== thread.goal.facilitator &&
|
|
302
|
+
["result", "post"].includes(post.kind)
|
|
303
|
+
);
|
|
304
|
+
return checkable ? "review" : "look";
|
|
305
|
+
};
|
|
306
|
+
const modeTag = (mode) =>
|
|
307
|
+
mode === "review"
|
|
308
|
+
? "(review, no changes) "
|
|
309
|
+
: mode === "look"
|
|
310
|
+
? "(look, no changes) "
|
|
311
|
+
: "";
|
|
312
|
+
// The routing line beside the person's words, from code: how Jev picked the agent to work on them.
|
|
313
|
+
const routingLine = ({ mode, decide = false, loop = null }) =>
|
|
314
|
+
[
|
|
315
|
+
mode === "look"
|
|
316
|
+
? "Jev picked you to find out and answer this. Change nothing."
|
|
317
|
+
: mode === "review"
|
|
318
|
+
? "Jev picked you to check the work this is about and report on it. Change nothing."
|
|
319
|
+
: "Jev picked you for this.",
|
|
320
|
+
decide
|
|
321
|
+
? "A choice in it is not the person's to make: decide it with your best default, say in the thread which you chose and why, and carry on."
|
|
322
|
+
: "",
|
|
323
|
+
loop === "repeating" || loop === "stuck_on_part"
|
|
324
|
+
? "What was tried before did not work (see the thread): take a different approach."
|
|
325
|
+
: "",
|
|
326
|
+
]
|
|
327
|
+
.filter(Boolean)
|
|
328
|
+
.join(" ");
|
|
213
329
|
const failedHereLately = (threadId, agent) => {
|
|
214
330
|
const at = Date.parse(store.meta(`job-failed:${threadId}:${agent}`) || "");
|
|
215
331
|
return Date.now() - at < FAILED_REST_MS;
|
|
@@ -233,28 +349,122 @@ export function createCoordinator({
|
|
|
233
349
|
// The moves go to a coordinator that takes them: this computer's, or a Harness with swarm_moves.
|
|
234
350
|
const movesTaken = () =>
|
|
235
351
|
Boolean(moves) && (mode() === "local" || serverHas("swarm_moves"));
|
|
236
|
-
//
|
|
237
|
-
//
|
|
352
|
+
// The capability check runs after delivery (owner, November 1: "The capability check should move to be between
|
|
353
|
+
// delivery and manager"): Jev picks agents and computers from what it knows of them, the computer the work goes to
|
|
354
|
+
// looks whether it can do it before the agent starts, and a "no" comes back to Jev here, beside that computer, for the
|
|
355
|
+
// rounds on the same message from the person.
|
|
356
|
+
const checksTaken = () =>
|
|
357
|
+
Boolean(capabilities) &&
|
|
358
|
+
(mode() === "local" || serverHas("capability_checks"));
|
|
359
|
+
const answersKey = (thread) => `capabilities:${thread.id}`;
|
|
360
|
+
const keptAnswers = (thread) => {
|
|
361
|
+
try {
|
|
362
|
+
return JSON.parse(store.meta(answersKey(thread)) || "null");
|
|
363
|
+
} catch {
|
|
364
|
+
return null;
|
|
365
|
+
}
|
|
366
|
+
};
|
|
238
367
|
const canDo = async (thread, posts, asked) => {
|
|
239
|
-
if (
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
)
|
|
243
|
-
|
|
244
|
-
|
|
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));
|
|
368
|
+
if (!checksTaken()) return new Map();
|
|
369
|
+
let kept = keptAnswers(thread);
|
|
370
|
+
// A new message from the person is new work: what computers said about the last one does not hold for it.
|
|
371
|
+
if (asked && kept?.seq !== asked.seq) {
|
|
372
|
+
kept = { seq: asked.seq, answers: [] };
|
|
373
|
+
store.meta(answersKey(thread), JSON.stringify(kept));
|
|
253
374
|
}
|
|
375
|
+
// Jev hears only the computers that said no to this message; a yes is kept so the same work is not checked twice.
|
|
254
376
|
return new Map(
|
|
255
|
-
(kept?.answers ?? [])
|
|
377
|
+
(kept?.answers ?? [])
|
|
378
|
+
.filter(({ answer }) => answer === "no")
|
|
379
|
+
.map(({ id, answer, why }) => [id, { answer, why }])
|
|
256
380
|
);
|
|
257
381
|
};
|
|
382
|
+
// The computer a coding agent's work goes to when Jev named none: this one where the agent runs here, else the first
|
|
383
|
+
// of its computers online.
|
|
384
|
+
const defaultComputer = (thread, agent) =>
|
|
385
|
+
localAgents().includes(agent)
|
|
386
|
+
? null
|
|
387
|
+
: ((machinesOf(agent, thread.goal.workspace) ?? []).find(
|
|
388
|
+
(computer) => computer.online
|
|
389
|
+
)?.id ?? null);
|
|
390
|
+
// The computer the agent's work lands on, as the run is placed (threadRuns.mjs wake): the computer holding the
|
|
391
|
+
// thread's checkout, else the one this agent or the thread worked on before, else the route's computer for it, else
|
|
392
|
+
// the one Jev picked when it is online, else the agent's default. The check looks at the same computer.
|
|
393
|
+
const placedOn = (thread, agent, computer) => {
|
|
394
|
+
const online = (id) =>
|
|
395
|
+
Boolean(id) &&
|
|
396
|
+
(machinesOf(agent, thread.goal.workspace) ?? []).some(
|
|
397
|
+
(each) => each.id === id && each.online
|
|
398
|
+
);
|
|
399
|
+
return (
|
|
400
|
+
computerOf(thread.id) ||
|
|
401
|
+
store.meta(`thread-computer:${thread.id}:${agent}`) ||
|
|
402
|
+
store.meta(`thread-computer:${thread.id}`) ||
|
|
403
|
+
team?.machineFor?.(thread.id, agent) ||
|
|
404
|
+
(online(computer) ? computer : null) ||
|
|
405
|
+
defaultComputer(thread, agent)
|
|
406
|
+
);
|
|
407
|
+
};
|
|
408
|
+
/**
|
|
409
|
+
* The check after delivery (owner, November 1: "The capability check should move to be between delivery and
|
|
410
|
+
* manager"), for a coding agent's work, on the computer it lands on, before the agent starts. Kept for the person's
|
|
411
|
+
* message, beside that computer, so the same work is not looked at twice. True: the work goes ahead. False: the
|
|
412
|
+
* computer said no and the thread says what it found; the message goes back to Jev when another computer is online,
|
|
413
|
+
* and otherwise the thread waits on the person. A computer picked again after saying no pauses the thread.
|
|
414
|
+
*/
|
|
415
|
+
const checkedOn = async (thread, agent, computer, work, asked) => {
|
|
416
|
+
if (!checksTaken() || !MACHINE_RUNNERS.includes(agent)) return true;
|
|
417
|
+
const target = placedOn(thread, agent, computer);
|
|
418
|
+
const id = target ?? capabilities.here();
|
|
419
|
+
const label = capabilities.labelOf(target);
|
|
420
|
+
const kept = keptAnswers(thread) ?? {
|
|
421
|
+
seq: asked?.seq ?? null,
|
|
422
|
+
answers: [],
|
|
423
|
+
};
|
|
424
|
+
const before = kept.answers.find((each) => each.id === id);
|
|
425
|
+
if (before?.answer === "no") {
|
|
426
|
+
pauseGoal(
|
|
427
|
+
thread.id,
|
|
428
|
+
`${label} said it cannot do this (${before.why}) and was picked again`
|
|
429
|
+
);
|
|
430
|
+
return false;
|
|
431
|
+
}
|
|
432
|
+
if (before) return true;
|
|
433
|
+
const found = await capabilities
|
|
434
|
+
.on(target, String(work))
|
|
435
|
+
.catch((error) => ({ answer: "unknown", why: error.message }));
|
|
436
|
+
// Read again: the other parts of an assembly are checked at the same time and keep their answers too.
|
|
437
|
+
const latest = keptAnswers(thread) ?? kept;
|
|
438
|
+
store.meta(
|
|
439
|
+
answersKey(thread),
|
|
440
|
+
JSON.stringify({
|
|
441
|
+
...latest,
|
|
442
|
+
answers: [
|
|
443
|
+
...latest.answers.filter((each) => each.id !== id),
|
|
444
|
+
{ id, label, answer: found.answer, why: found.why },
|
|
445
|
+
],
|
|
446
|
+
})
|
|
447
|
+
);
|
|
448
|
+
if (found.answer !== "no") return true;
|
|
449
|
+
if (!capabilities.choosing()) {
|
|
450
|
+
pauseGoal(
|
|
451
|
+
thread.id,
|
|
452
|
+
`${label} cannot do this for ${nameOf(agent)}: ${found.why}`
|
|
453
|
+
);
|
|
454
|
+
notifyBoard(store.getTask(thread.id));
|
|
455
|
+
return false;
|
|
456
|
+
}
|
|
457
|
+
postAsCoordinator({
|
|
458
|
+
goalId: thread.id,
|
|
459
|
+
author: thread.goal.facilitator,
|
|
460
|
+
kind: "note",
|
|
461
|
+
text: `${label} cannot do this for ${nameOf(agent)}: ${found.why} Jev picks again.`,
|
|
462
|
+
});
|
|
463
|
+
if (asked) store.meta(`swarm-asked:${thread.id}`, JSON.stringify(asked));
|
|
464
|
+
store.meta(`coordinator-resumed:${thread.id}`, "1");
|
|
465
|
+
poke(thread.id);
|
|
466
|
+
return false;
|
|
467
|
+
};
|
|
258
468
|
// The person's pins: specialty -> the agent that holds it when a step asks for it.
|
|
259
469
|
const pinsNow = () =>
|
|
260
470
|
Object.fromEntries(
|
|
@@ -566,10 +776,11 @@ export function createCoordinator({
|
|
|
566
776
|
const reachable = connected();
|
|
567
777
|
const names = pool.filter(
|
|
568
778
|
(agent) =>
|
|
569
|
-
agent !== "harness" &&
|
|
570
779
|
!asked.named.includes(agent) &&
|
|
571
780
|
(!TAGGED.has(agent) || inThread.includes(agent)) &&
|
|
572
|
-
(reachable || CODING.has(agent))
|
|
781
|
+
(reachable || CODING.has(agent)) &&
|
|
782
|
+
// One already handed this message has it (the A1 run's opening round, November 1).
|
|
783
|
+
!delivered(thread, agent, { seq: asked.seq })
|
|
573
784
|
);
|
|
574
785
|
const words = store
|
|
575
786
|
.roomPosts(thread.id, Math.max(0, asked.seq - 1), 1)
|
|
@@ -578,20 +789,21 @@ export function createCoordinator({
|
|
|
578
789
|
const joining = names.filter((agent) => !thread.goal.team.includes(agent));
|
|
579
790
|
if (joining.length)
|
|
580
791
|
store.setGoalTeam(thread.id, [...thread.goal.team, ...joining]);
|
|
792
|
+
for (const agent of names) markDelivered(thread, agent, { seq: asked.seq });
|
|
581
793
|
const list = names.map(nameOf).join(", ");
|
|
582
794
|
store.roomPost({
|
|
583
795
|
goalId: thread.id,
|
|
584
796
|
author: thread.goal.facilitator,
|
|
585
797
|
kind: "note",
|
|
586
798
|
text: why
|
|
587
|
-
? `
|
|
799
|
+
? `Jev could not work out who does what (${why}), so your message went to every agent here: ${list}.`
|
|
588
800
|
: `Your message went to every agent here: ${list}.`,
|
|
589
801
|
});
|
|
590
802
|
wakeAll(
|
|
591
803
|
thread.id,
|
|
592
804
|
names,
|
|
593
805
|
words,
|
|
594
|
-
`${asked.swarm ? "the person wrote to the whole swarm and " : ""}every agent here heard the person's message as they wrote it${why ? ", since
|
|
806
|
+
`${asked.swarm ? "the person wrote to the whole swarm and " : ""}every agent here heard the person's message as they wrote it${why ? ", since Jev could not work out who does what" : asked.swarm ? "" : ", since Jev found no one part in it"}. Do the part of it that is yours; if none of it is, say so in one line and stop`
|
|
595
807
|
);
|
|
596
808
|
notifyBoard(store.getTask(thread.id));
|
|
597
809
|
return names;
|
|
@@ -625,6 +837,7 @@ export function createCoordinator({
|
|
|
625
837
|
action: "hand_on",
|
|
626
838
|
agent: decider,
|
|
627
839
|
mode: "work",
|
|
840
|
+
decide: true,
|
|
628
841
|
text: `No need to ask the person this: ${String(decision.text).slice(0, 2_000)} Decide it with your best default, say in the thread which you chose and why, and carry on.`,
|
|
629
842
|
};
|
|
630
843
|
};
|
|
@@ -649,6 +862,8 @@ export function createCoordinator({
|
|
|
649
862
|
if (store.meta(`goal-kept:${thread.id}`) === String(personSaid(thread)))
|
|
650
863
|
return false;
|
|
651
864
|
goals.set(thread.id, decision.goal, { by: coordinator, seq: newest });
|
|
865
|
+
// Either round may word the goal for this post first (the goal round and the thread's own); the other keeps it.
|
|
866
|
+
store.meta(`goal-kept:${thread.id}`, String(personSaid(thread)));
|
|
652
867
|
return false;
|
|
653
868
|
}
|
|
654
869
|
if (!decision.met && !decision.goalState) return false;
|
|
@@ -1012,7 +1227,8 @@ export function createCoordinator({
|
|
|
1012
1227
|
).filter(
|
|
1013
1228
|
(part) =>
|
|
1014
1229
|
candidates.some((candidate) => candidate.id === part?.agent) &&
|
|
1015
|
-
part.text
|
|
1230
|
+
(part.text || asked) &&
|
|
1231
|
+
!allDone(thread, asked)
|
|
1016
1232
|
);
|
|
1017
1233
|
if (!parts.length) {
|
|
1018
1234
|
if (unheard) tellEveryone(thread, asked, null, { decided: true });
|
|
@@ -1028,65 +1244,109 @@ export function createCoordinator({
|
|
|
1028
1244
|
notifyBoard(store.getTask(thread.id));
|
|
1029
1245
|
return;
|
|
1030
1246
|
}
|
|
1031
|
-
const joining = parts
|
|
1032
|
-
.map((part) => part.agent)
|
|
1033
|
-
.filter((agent) => !thread.goal.team.includes(agent));
|
|
1034
|
-
if (joining.length)
|
|
1035
|
-
store.setGoalTeam(thread.id, [...thread.goal.team, ...joining]);
|
|
1036
1247
|
const worded = parts.map((part) => {
|
|
1037
|
-
const
|
|
1248
|
+
const mode = modeIn(
|
|
1249
|
+
thread,
|
|
1250
|
+
part.mode,
|
|
1251
|
+
parts.filter((other) => other !== part)
|
|
1252
|
+
);
|
|
1038
1253
|
return {
|
|
1039
1254
|
...part,
|
|
1040
|
-
|
|
1041
|
-
|
|
1255
|
+
mode,
|
|
1256
|
+
review: part.mode === "review" && REVIEWERS.has(part.agent),
|
|
1257
|
+
text: String(part.text ?? "").slice(0, 2_000),
|
|
1042
1258
|
};
|
|
1043
1259
|
});
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
.map(
|
|
1052
|
-
(part) =>
|
|
1053
|
-
`@${part.agent} ${part.review ? "(review, no changes) " : ""}${part.text}`
|
|
1054
|
-
)
|
|
1055
|
-
.join("\n\n"),
|
|
1056
|
-
});
|
|
1057
|
-
// The team moves first, so each brief says the step its agent now acts in.
|
|
1058
|
-
const moved = moveTeam(
|
|
1059
|
-
thread,
|
|
1060
|
-
decision,
|
|
1061
|
-
[...worded.map((part) => part.agent), ...(asked?.named ?? [])],
|
|
1062
|
-
coordinator
|
|
1260
|
+
const message = personMessage(thread, asked);
|
|
1261
|
+
if (answeredMeanwhile(thread, decision, asked)) {
|
|
1262
|
+
notifyBoard(store.getTask(thread.id));
|
|
1263
|
+
return;
|
|
1264
|
+
}
|
|
1265
|
+
const fresh = worded.filter(
|
|
1266
|
+
(part) => !delivered(thread, part.agent, message)
|
|
1063
1267
|
);
|
|
1064
|
-
if (!
|
|
1268
|
+
if (!fresh.length) {
|
|
1065
1269
|
notifyBoard(store.getTask(thread.id));
|
|
1066
1270
|
return;
|
|
1067
1271
|
}
|
|
1068
|
-
for (const part of
|
|
1069
|
-
|
|
1272
|
+
for (const part of fresh) markDelivered(thread, part.agent, message);
|
|
1273
|
+
// Each part is checked on the computer it goes to before anyone starts; one "no" sends the whole message back to
|
|
1274
|
+
// Jev, so no agent starts on half an assembly.
|
|
1275
|
+
return Promise.all(
|
|
1276
|
+
fresh.map((part) =>
|
|
1277
|
+
checkedOn(
|
|
1278
|
+
thread,
|
|
1279
|
+
part.agent,
|
|
1280
|
+
part.computer ?? null,
|
|
1281
|
+
message?.text ?? part.text,
|
|
1282
|
+
asked
|
|
1283
|
+
)
|
|
1284
|
+
)
|
|
1285
|
+
).then((checks) => {
|
|
1286
|
+
if (!checks.every(Boolean)) {
|
|
1287
|
+
for (const part of fresh)
|
|
1288
|
+
unmarkDelivered(thread, part.agent, message);
|
|
1289
|
+
return;
|
|
1290
|
+
}
|
|
1291
|
+
const joining = parts
|
|
1292
|
+
.map((part) => part.agent)
|
|
1293
|
+
.filter((agent) => !thread.goal.team.includes(agent));
|
|
1294
|
+
if (joining.length)
|
|
1295
|
+
store.setGoalTeam(thread.id, [...thread.goal.team, ...joining]);
|
|
1296
|
+
// Named as the post's addressees so the thread shows who it is to; each is woken below, not by the post.
|
|
1297
|
+
postAsCoordinator({
|
|
1298
|
+
goalId: thread.id,
|
|
1299
|
+
author: coordinator,
|
|
1300
|
+
kind: "post",
|
|
1301
|
+
mentions: fresh.map((part) => part.agent),
|
|
1302
|
+
text: fresh
|
|
1303
|
+
.map(
|
|
1304
|
+
(part) =>
|
|
1305
|
+
`@${part.agent} ${modeTag(part.mode)}${message ? `your message #${message.seq}.${part.text ? ` Your part: ${part.text}` : ""}` : part.text}`
|
|
1306
|
+
)
|
|
1307
|
+
.join("\n\n"),
|
|
1308
|
+
});
|
|
1309
|
+
// The team moves first, so each brief says the step its agent now acts in.
|
|
1310
|
+
const moved = moveTeam(
|
|
1070
1311
|
thread,
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
? part.text
|
|
1074
|
-
: `${coordinator} asked you: ${part.text.slice(0, 300)}`,
|
|
1075
|
-
{
|
|
1076
|
-
review: part.review,
|
|
1077
|
-
words: part.text,
|
|
1078
|
-
computer: part.computer ?? null,
|
|
1079
|
-
},
|
|
1312
|
+
decision,
|
|
1313
|
+
[...fresh.map((part) => part.agent), ...(asked?.named ?? [])],
|
|
1080
1314
|
coordinator
|
|
1081
1315
|
);
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
)
|
|
1088
|
-
|
|
1089
|
-
|
|
1316
|
+
if (!moved) {
|
|
1317
|
+
notifyBoard(store.getTask(thread.id));
|
|
1318
|
+
return;
|
|
1319
|
+
}
|
|
1320
|
+
// Each agent gets the person's words whole, with its part beside them (owner, November 1: "the swarm should know
|
|
1321
|
+
// about the full words from the user ... lossy notes are unacceptable").
|
|
1322
|
+
for (const part of fresh) {
|
|
1323
|
+
const words = message
|
|
1324
|
+
? [
|
|
1325
|
+
wholeWords(message),
|
|
1326
|
+
routingLine({ mode: part.mode }),
|
|
1327
|
+
part.text ? `Your part, from the dispatcher: ${part.text}` : "",
|
|
1328
|
+
]
|
|
1329
|
+
.filter(Boolean)
|
|
1330
|
+
.join("\n\n")
|
|
1331
|
+
: part.text;
|
|
1332
|
+
handOnOrHold(
|
|
1333
|
+
thread,
|
|
1334
|
+
part.agent,
|
|
1335
|
+
withheld || message
|
|
1336
|
+
? words
|
|
1337
|
+
: `${nameOf(coordinator)} asked you: ${part.text.slice(0, 300)}`,
|
|
1338
|
+
{ review: part.review, words, computer: part.computer ?? null },
|
|
1339
|
+
coordinator
|
|
1340
|
+
);
|
|
1341
|
+
}
|
|
1342
|
+
if (withheld)
|
|
1343
|
+
saidWithheld(
|
|
1344
|
+
thread,
|
|
1345
|
+
withheld,
|
|
1346
|
+
fresh.map((part) => part.agent)
|
|
1347
|
+
);
|
|
1348
|
+
notifyBoard(store.getTask(thread.id));
|
|
1349
|
+
});
|
|
1090
1350
|
}
|
|
1091
1351
|
if (decision.action === "ask_person" && decision.text) {
|
|
1092
1352
|
const asked = postAsCoordinator({
|
|
@@ -1105,8 +1365,9 @@ export function createCoordinator({
|
|
|
1105
1365
|
if (
|
|
1106
1366
|
decision.action === "hand_on" &&
|
|
1107
1367
|
candidates.some((candidate) => candidate.id === decision.agent) &&
|
|
1108
|
-
decision.text
|
|
1368
|
+
(decision.text || personMessage(thread, asked))
|
|
1109
1369
|
) {
|
|
1370
|
+
const mode = modeIn(thread, decision.mode);
|
|
1110
1371
|
const review =
|
|
1111
1372
|
decision.mode === "review" && REVIEWERS.has(decision.agent);
|
|
1112
1373
|
const agent = review
|
|
@@ -1116,19 +1377,73 @@ export function createCoordinator({
|
|
|
1116
1377
|
// not handed to it again: Bankr was handed the same purchase twice, and a round begun on a new thread's title
|
|
1117
1378
|
// posted "@claude-code (review, no changes)" after the person's own ask had started Claude Code, whose turn did
|
|
1118
1379
|
// the review instead (live, October 31). The person's new message is new work, and still reaches it.
|
|
1119
|
-
if (
|
|
1380
|
+
if (
|
|
1381
|
+
(!asked && holdsWork(thread.id, agent)) ||
|
|
1382
|
+
allDone(thread, asked) ||
|
|
1383
|
+
answeredMeanwhile(thread, decision, asked) ||
|
|
1384
|
+
delivered(thread, agent, personMessage(thread, asked))
|
|
1385
|
+
) {
|
|
1120
1386
|
notifyBoard(store.getTask(thread.id));
|
|
1121
1387
|
return;
|
|
1122
1388
|
}
|
|
1389
|
+
// Answering the person's message, the agent gets their words whole with the routing line, and the thread one
|
|
1390
|
+
// routing line; between agents, the dispatcher's brief. A review runs with its read-only switch.
|
|
1391
|
+
const message = personMessage(thread, asked);
|
|
1392
|
+
const brief = String(decision.text ?? "").slice(0, 4_000);
|
|
1393
|
+
const text = message
|
|
1394
|
+
? `${wholeWords(message)}\n\n${routingLine({ ...decision, mode })}`
|
|
1395
|
+
: brief;
|
|
1396
|
+
// Delivered, then checked on the computer it goes to before anything starts (capability check after delivery);
|
|
1397
|
+
// a "no" goes back to Jev and nothing is posted or woken.
|
|
1398
|
+
markDelivered(thread, agent, message);
|
|
1399
|
+
return checkedOn(
|
|
1400
|
+
thread,
|
|
1401
|
+
agent,
|
|
1402
|
+
decision.computer ?? null,
|
|
1403
|
+
message?.text ?? brief,
|
|
1404
|
+
asked
|
|
1405
|
+
).then((can) => {
|
|
1406
|
+
if (!can) {
|
|
1407
|
+
unmarkDelivered(thread, agent, message);
|
|
1408
|
+
return;
|
|
1409
|
+
}
|
|
1410
|
+
handOnNow({
|
|
1411
|
+
thread,
|
|
1412
|
+
decision,
|
|
1413
|
+
agent,
|
|
1414
|
+
mode,
|
|
1415
|
+
review,
|
|
1416
|
+
message,
|
|
1417
|
+
text,
|
|
1418
|
+
coordinator,
|
|
1419
|
+
withheld,
|
|
1420
|
+
});
|
|
1421
|
+
});
|
|
1422
|
+
} else if (withheld) saidWithheld(thread, withheld, []);
|
|
1423
|
+
notifyBoard(store.getTask(thread.id));
|
|
1424
|
+
};
|
|
1425
|
+
|
|
1426
|
+
const handOnNow = ({
|
|
1427
|
+
thread,
|
|
1428
|
+
decision,
|
|
1429
|
+
agent,
|
|
1430
|
+
mode,
|
|
1431
|
+
review,
|
|
1432
|
+
message,
|
|
1433
|
+
text,
|
|
1434
|
+
coordinator,
|
|
1435
|
+
withheld,
|
|
1436
|
+
}) => {
|
|
1437
|
+
{
|
|
1123
1438
|
if (!thread.goal.team.includes(agent))
|
|
1124
1439
|
store.setGoalTeam(thread.id, [...thread.goal.team, agent]);
|
|
1125
|
-
const text = String(decision.text).slice(0, 4_000);
|
|
1126
|
-
// The brief is posted for everyone to read and the agent is woken here, so a review runs with its read-only switch.
|
|
1127
1440
|
postAsCoordinator({
|
|
1128
1441
|
goalId: thread.id,
|
|
1129
1442
|
author: coordinator,
|
|
1130
1443
|
kind: "post",
|
|
1131
|
-
text:
|
|
1444
|
+
text: message
|
|
1445
|
+
? `@${agent} ${modeTag(mode)}your message #${message.seq}.`
|
|
1446
|
+
: `@${agent} ${modeTag(mode)}${text}`,
|
|
1132
1447
|
});
|
|
1133
1448
|
if (!moveTeam(thread, decision, [agent], coordinator)) {
|
|
1134
1449
|
notifyBoard(store.getTask(thread.id));
|
|
@@ -1137,12 +1452,16 @@ export function createCoordinator({
|
|
|
1137
1452
|
handOnOrHold(
|
|
1138
1453
|
thread,
|
|
1139
1454
|
agent,
|
|
1140
|
-
withheld
|
|
1455
|
+
withheld
|
|
1456
|
+
? text
|
|
1457
|
+
: message
|
|
1458
|
+
? text
|
|
1459
|
+
: `${nameOf(coordinator)} asked you: ${text.slice(0, 300)}`,
|
|
1141
1460
|
{ review, words: text, computer: decision.computer ?? null },
|
|
1142
1461
|
coordinator
|
|
1143
1462
|
);
|
|
1144
1463
|
if (withheld) saidWithheld(thread, withheld, [agent]);
|
|
1145
|
-
}
|
|
1464
|
+
}
|
|
1146
1465
|
notifyBoard(store.getTask(thread.id));
|
|
1147
1466
|
};
|
|
1148
1467
|
|
|
@@ -1186,18 +1505,28 @@ export function createCoordinator({
|
|
|
1186
1505
|
try {
|
|
1187
1506
|
const reply = await askHarness(
|
|
1188
1507
|
"coordinate",
|
|
1189
|
-
{ ...gathered, goalOnly: true },
|
|
1508
|
+
worded({ ...gathered, goalOnly: true }),
|
|
1190
1509
|
null
|
|
1191
1510
|
);
|
|
1192
1511
|
if (!reply.ok)
|
|
1193
|
-
throw new Error(reply.error || "
|
|
1512
|
+
throw new Error(reply.error || "Jev did not keep the goal");
|
|
1194
1513
|
decision = reply.result ?? reply;
|
|
1514
|
+
// The goal's words are the dispatcher's (dispatcher.mjs), whoever wrote them before.
|
|
1515
|
+
if (dispatcher && (decision.goal || decision.goalDue)) {
|
|
1516
|
+
const kept = await dispatcher.words(decision, gathered, null);
|
|
1517
|
+
decision = kept.decision;
|
|
1518
|
+
if (kept.failed.length)
|
|
1519
|
+
noteOnce(
|
|
1520
|
+
thread,
|
|
1521
|
+
`The dispatcher could not write ${kept.failed.join("; ")}.`
|
|
1522
|
+
);
|
|
1523
|
+
}
|
|
1195
1524
|
} catch (failure) {
|
|
1196
1525
|
error = failure.message;
|
|
1197
1526
|
}
|
|
1198
1527
|
store.recordRound({
|
|
1199
1528
|
goalId: thread.id,
|
|
1200
|
-
coordinator:
|
|
1529
|
+
coordinator: JEV,
|
|
1201
1530
|
action: decision ? "keep_goal" : null,
|
|
1202
1531
|
agent: null,
|
|
1203
1532
|
loop: null,
|
|
@@ -1205,13 +1534,20 @@ export function createCoordinator({
|
|
|
1205
1534
|
progress: gathered.progress,
|
|
1206
1535
|
estimatedMicroUsd: decision?.estimatedMicroUsd ?? null,
|
|
1207
1536
|
elapsedMs: Date.now() - startedAt,
|
|
1208
|
-
error: error &&
|
|
1537
|
+
error: error && `${deciderName(JEV)}: ${error}`,
|
|
1209
1538
|
});
|
|
1210
1539
|
if (!decision?.goal) return;
|
|
1211
1540
|
const now = store.getTask(thread.id);
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1541
|
+
// Read only words Harness's server wrote: the dispatcher's own here are this computer's.
|
|
1542
|
+
const fromServer =
|
|
1543
|
+
!dispatcher || dispatcher.setting().provider === "surplus";
|
|
1544
|
+
const screened =
|
|
1545
|
+
serverWords && fromServer
|
|
1546
|
+
? await serverWords.screen(
|
|
1547
|
+
{ goal: decision.goal },
|
|
1548
|
+
readingFor(thread.id)
|
|
1549
|
+
)
|
|
1550
|
+
: { reason: null };
|
|
1215
1551
|
if (screened.reason) {
|
|
1216
1552
|
saidWithheld(now, screened, []);
|
|
1217
1553
|
return;
|
|
@@ -1221,10 +1557,16 @@ export function createCoordinator({
|
|
|
1221
1557
|
};
|
|
1222
1558
|
|
|
1223
1559
|
// One coordinator's decision for the round's facts: Harness's server, or a coding agent here with its tools off.
|
|
1560
|
+
// The relay's dispatcher words every round (dispatcher.mjs), so a server that takes it (swarm_dispatcher) writes
|
|
1561
|
+
// nothing and returns Jev's decision only; an older server's words are replaced here.
|
|
1562
|
+
const worded = (gathered) =>
|
|
1563
|
+
dispatcher && serverHas("swarm_dispatcher")
|
|
1564
|
+
? { ...gathered, dispatcher: { provider: "relay" } }
|
|
1565
|
+
: gathered;
|
|
1224
1566
|
const decideWith = async (coordinator, gathered) => {
|
|
1225
|
-
if (coordinator !==
|
|
1567
|
+
if (coordinator !== JEV) return localDecision(coordinator, gathered);
|
|
1226
1568
|
// No deadline of its own: the round ends when Harness answers or the connection drops.
|
|
1227
|
-
const reply = await askHarness("coordinate", gathered, null);
|
|
1569
|
+
const reply = await askHarness("coordinate", worded(gathered), null);
|
|
1228
1570
|
if (!reply.ok)
|
|
1229
1571
|
throw new Error(reply.error || "Harness did not coordinate this round");
|
|
1230
1572
|
return reply.result ?? reply;
|
|
@@ -1281,15 +1623,17 @@ export function createCoordinator({
|
|
|
1281
1623
|
store.meta(`coordinator-post:${post.id}`)
|
|
1282
1624
|
);
|
|
1283
1625
|
if (!begun) {
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1626
|
+
Promise.resolve(
|
|
1627
|
+
apply(
|
|
1628
|
+
thread,
|
|
1629
|
+
intent.decision,
|
|
1630
|
+
intent.coordinator,
|
|
1631
|
+
intent.candidates,
|
|
1632
|
+
intent.asked,
|
|
1633
|
+
intent.rules,
|
|
1634
|
+
intent.withheld
|
|
1635
|
+
)
|
|
1636
|
+
).catch((error) => log(`coordinator ${goalId}: ${error.message}`));
|
|
1293
1637
|
continue;
|
|
1294
1638
|
}
|
|
1295
1639
|
for (const agent of wokenBy(intent.decision)) {
|
|
@@ -1376,7 +1720,7 @@ export function createCoordinator({
|
|
|
1376
1720
|
// dropped mid-round, not for a computer that is offline.
|
|
1377
1721
|
if (!local && !connected()) return;
|
|
1378
1722
|
// Who decides, in order: Harness (not on the privacy setting), then the coding agents here as backups.
|
|
1379
|
-
const chain = [...(local ? [] : [
|
|
1723
|
+
const chain = [...(local ? [] : [JEV]), ...backups()];
|
|
1380
1724
|
if (!chain.length) {
|
|
1381
1725
|
if (asked) settleAsked(goalId);
|
|
1382
1726
|
if (asked) tellEveryone(thread, asked, "no agent here can coordinate");
|
|
@@ -1413,7 +1757,7 @@ export function createCoordinator({
|
|
|
1413
1757
|
store.meta(`inventory-wait:${goalId}`, waitingFor);
|
|
1414
1758
|
store.roomPost({
|
|
1415
1759
|
goalId,
|
|
1416
|
-
author:
|
|
1760
|
+
author: DISPATCHER,
|
|
1417
1761
|
kind: "note",
|
|
1418
1762
|
text: `Waiting for repository inventory from ${waitingFor}. Work starts automatically when it arrives.`,
|
|
1419
1763
|
});
|
|
@@ -1438,7 +1782,7 @@ export function createCoordinator({
|
|
|
1438
1782
|
store.meta(`inventory-unavailable:${goalId}`, unavailable);
|
|
1439
1783
|
store.roomPost({
|
|
1440
1784
|
goalId,
|
|
1441
|
-
author:
|
|
1785
|
+
author: DISPATCHER,
|
|
1442
1786
|
kind: "note",
|
|
1443
1787
|
text: `Repository inventory did not arrive from ${unavailable}. Continuing on eligible computers.`,
|
|
1444
1788
|
});
|
|
@@ -1475,15 +1819,15 @@ export function createCoordinator({
|
|
|
1475
1819
|
for (const coordinator of chain) {
|
|
1476
1820
|
try {
|
|
1477
1821
|
// A backup decides a plain round: an assembly is Harness's, and the person's message goes to everyone instead.
|
|
1478
|
-
if (coordinator !==
|
|
1822
|
+
if (coordinator !== JEV && assembling) break;
|
|
1479
1823
|
decision = await decideWith(coordinator, gathered);
|
|
1480
|
-
if (coordinator !==
|
|
1824
|
+
if (coordinator !== JEV)
|
|
1481
1825
|
store.meta(`coordinator-backup-failed:${coordinator}`, "");
|
|
1482
1826
|
decidedBy = coordinator;
|
|
1483
1827
|
break;
|
|
1484
1828
|
} catch (failure) {
|
|
1485
1829
|
failures.push({ coordinator, error: failure.message });
|
|
1486
|
-
if (coordinator !==
|
|
1830
|
+
if (coordinator !== JEV)
|
|
1487
1831
|
store.meta(`coordinator-backup-failed:${coordinator}`, "1");
|
|
1488
1832
|
}
|
|
1489
1833
|
}
|
|
@@ -1514,7 +1858,7 @@ export function createCoordinator({
|
|
|
1514
1858
|
if (!decision) decidedBy = null;
|
|
1515
1859
|
}
|
|
1516
1860
|
const error =
|
|
1517
|
-
failures.find((entry) => entry.coordinator ===
|
|
1861
|
+
failures.find((entry) => entry.coordinator === JEV)?.error ??
|
|
1518
1862
|
failures[0]?.error ??
|
|
1519
1863
|
null;
|
|
1520
1864
|
const next = {
|
|
@@ -1542,7 +1886,7 @@ export function createCoordinator({
|
|
|
1542
1886
|
// What failed before the round was decided: Harness's error even when a backup decided.
|
|
1543
1887
|
error: failures.length
|
|
1544
1888
|
? failures
|
|
1545
|
-
.map((entry) => `${
|
|
1889
|
+
.map((entry) => `${deciderName(entry.coordinator)}: ${entry.error}`)
|
|
1546
1890
|
.join("; ")
|
|
1547
1891
|
: null,
|
|
1548
1892
|
});
|
|
@@ -1553,24 +1897,41 @@ export function createCoordinator({
|
|
|
1553
1897
|
return;
|
|
1554
1898
|
const others = failures
|
|
1555
1899
|
.slice(1)
|
|
1556
|
-
.map((entry) =>
|
|
1900
|
+
.map((entry) => deciderName(entry.coordinator))
|
|
1557
1901
|
.join(" and ");
|
|
1558
1902
|
noteOnce(
|
|
1559
1903
|
thread,
|
|
1560
|
-
`${
|
|
1904
|
+
`${jevCould(error)}${others ? `, and ${others} could not stand in` : ""}.`
|
|
1561
1905
|
);
|
|
1562
1906
|
notifyBoard(store.getTask(goalId));
|
|
1563
1907
|
return;
|
|
1564
1908
|
}
|
|
1565
|
-
if (decidedBy !==
|
|
1909
|
+
if (decidedBy !== JEV && !local)
|
|
1566
1910
|
noteOnce(
|
|
1567
1911
|
thread,
|
|
1568
|
-
`${
|
|
1912
|
+
`${jevCould(error)}; ${nameOf(decidedBy)} coordinated it.`
|
|
1569
1913
|
);
|
|
1570
|
-
//
|
|
1571
|
-
//
|
|
1914
|
+
// The dispatcher writes what the decision needs in words (dispatcher.mjs), replacing whatever a coordinator wrote,
|
|
1915
|
+
// so every word in the thread is from what signs it; a job it could not do is said in the thread.
|
|
1916
|
+
if (dispatcher) {
|
|
1917
|
+
const answering = personMessage(thread, asked);
|
|
1918
|
+
const worded = await dispatcher.words(decision, gathered, answering);
|
|
1919
|
+
decision = {
|
|
1920
|
+
...worded.decision,
|
|
1921
|
+
...(answering ? { answers: answering.seq } : {}),
|
|
1922
|
+
};
|
|
1923
|
+
if (worded.failed.length)
|
|
1924
|
+
noteOnce(
|
|
1925
|
+
thread,
|
|
1926
|
+
`The dispatcher could not write ${worded.failed.join("; ")}.`
|
|
1927
|
+
);
|
|
1928
|
+
}
|
|
1929
|
+
// Words from Harness's server keep the person's go only once this computer read them (serverWords.mjs): a round's
|
|
1930
|
+
// words are the server's only when the person put the dispatcher on a Surplus model, or there is no dispatcher.
|
|
1931
|
+
const serverWrote =
|
|
1932
|
+
!dispatcher || dispatcher.setting().provider === "surplus";
|
|
1572
1933
|
let withheld = null;
|
|
1573
|
-
if (decidedBy ===
|
|
1934
|
+
if (decidedBy === JEV && serverWords && serverWrote) {
|
|
1574
1935
|
const { reason, asks } = await serverWords.screen(
|
|
1575
1936
|
decision,
|
|
1576
1937
|
readingFor(goalId)
|
|
@@ -1587,11 +1948,12 @@ export function createCoordinator({
|
|
|
1587
1948
|
coordinator: thread.goal.facilitator,
|
|
1588
1949
|
candidates: gathered.candidates,
|
|
1589
1950
|
asked,
|
|
1590
|
-
rules: decidedBy ===
|
|
1951
|
+
rules: decidedBy === JEV ? keepsGoals() : true,
|
|
1591
1952
|
withheld,
|
|
1592
1953
|
};
|
|
1593
1954
|
keepIntent(goalId, intent);
|
|
1594
|
-
|
|
1955
|
+
// Kept until the decision is carried out, its check on the computer the work goes to included.
|
|
1956
|
+
await apply(
|
|
1595
1957
|
store.getTask(goalId),
|
|
1596
1958
|
decision,
|
|
1597
1959
|
intent.coordinator,
|
|
@@ -1603,12 +1965,13 @@ export function createCoordinator({
|
|
|
1603
1965
|
keepIntent(goalId, null);
|
|
1604
1966
|
};
|
|
1605
1967
|
|
|
1606
|
-
// Why
|
|
1607
|
-
const
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1968
|
+
// Why Jev did not decide, as one clause: its own words when it said why, else the failure behind it.
|
|
1969
|
+
const jevCould = (error) => {
|
|
1970
|
+
// Jev decides; a server from before November 1 said "Harness" for it.
|
|
1971
|
+
const why = String(error || "it did not answer")
|
|
1972
|
+
.replace(/\.+$/, "")
|
|
1973
|
+
.replace(/^Harness (could|cannot|decided)/, "Jev $1");
|
|
1974
|
+
return /^Jev /.test(why) ? why : `Jev could not decide this round (${why})`;
|
|
1612
1975
|
};
|
|
1613
1976
|
|
|
1614
1977
|
// The coordinator's note, unless the thread's newest post already says the same: a repeat after new work is said
|