tryharness 0.7.77 → 0.7.81

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.
@@ -96,6 +96,7 @@
96
96
  "board.relay.decide": "relay",
97
97
  "board.relay.defaults": "relay",
98
98
  "board.relay.list": "relay",
99
+ "board.relay.board": "relay",
99
100
  "board.relay.network": "relay",
100
101
  "board.relay.peers": "relay",
101
102
  "board.relay.request": "relay",
@@ -362,6 +363,7 @@
362
363
  "board.template.save",
363
364
  "board.template.use",
364
365
  "board.relay.list",
366
+ "board.relay.board",
365
367
  "board.relay.network",
366
368
  "board.relay.decide",
367
369
  "board.relay.request",
@@ -446,6 +448,7 @@
446
448
  "board.standing.check",
447
449
  "board.standing.off",
448
450
  "board.relay.list",
451
+ "board.relay.board",
449
452
  "board.relay.network",
450
453
  "board.relay.decide",
451
454
  "board.relay.request",
@@ -678,6 +681,7 @@
678
681
  "board.file.get",
679
682
  "board.file.share",
680
683
  "board.relay.list",
684
+ "board.relay.board",
681
685
  "board.relay.network",
682
686
  "board.relay.decide",
683
687
  "board.relay.request",
@@ -108,6 +108,14 @@ export function createCapabilityCheck({
108
108
  return reply ? shaped(reply) : unknown("the computer did not answer");
109
109
  };
110
110
 
111
+ /** Whether that computer is away now: another of the person's computers, not connected, so it cannot be asked. */
112
+ const away = (id) =>
113
+ Boolean(id) &&
114
+ id !== machine().id &&
115
+ !(ownMachines()?.all() ?? []).some(
116
+ (computer) => computer.id === id && computer.connected
117
+ );
118
+
111
119
  /** A computer's name as the person knows it. */
112
120
  const labelOf = (id) =>
113
121
  !id || id === machine().id
@@ -118,5 +126,5 @@ export function createCapabilityCheck({
118
126
  /** This computer's id, for an answer kept beside it. */
119
127
  const here = () => machine().id;
120
128
 
121
- return { answer, check, choosing, on, labelOf, here };
129
+ return { answer, check, choosing, on, away, labelOf, here };
122
130
  }
@@ -184,6 +184,11 @@ export function createCoordinator({
184
184
  // The person's asks the manager has seen done in a thread.
185
185
  doneAsks = () => [],
186
186
  computerOf = (goalId) => store.meta(`thread-work-computer:${goalId}`) || null,
187
+ // The computers a post names for the agents it wakes (threadActions.mjs computerAddress): `#pop-os` or
188
+ // `@codex on pop-os`.
189
+ computerAddress = () => ({ ok: true, shared: null, forAgent: () => null }),
190
+ // Whether an agent's turn in the thread waits for the computer the person named to come back (threadRuns.mjs).
191
+ waitsForComputer = () => false,
187
192
  // A post from the other side of a shared project (projects.mjs): their own swarm sorts it, so it starts no round here.
188
193
  fromPartner = () => false,
189
194
  // This computer's reading of the words a round Harness's server decided (serverWords.mjs).
@@ -245,6 +250,34 @@ export function createCoordinator({
245
250
  );
246
251
  return answered ? null : newest;
247
252
  };
253
+ // The computer the person named for `agent` in `message`, by id, or null. It wins over the thread's checkout and
254
+ // over Jev's pick (A1 run, November 2: "#pop-os" and "#Sigalas-MBP-2" both ran where the thread had last worked, and
255
+ // Claude Code handed each on by hand).
256
+ const namedComputer = (message, agent) => {
257
+ if (message?.author !== "user") return null;
258
+ const address = computerAddress(message.text, "user");
259
+ return address.ok ? (address.forAgent(agent)?.id ?? null) : null;
260
+ };
261
+ // Whether Jev may offer an agent for the person's message: a coding agent only when it is on the computer the message
262
+ // names, online or not (work for one that is offline waits for it, threadRuns.mjs). When no coding agent is on it,
263
+ // every agent stays offered and the run says why it cannot go there.
264
+ const namedComputerFilter = (thread, asked) => {
265
+ const message = personMessage(thread, asked);
266
+ const isOn = (agent) => {
267
+ const named = namedComputer(message, agent);
268
+ return (
269
+ !named ||
270
+ (machinesOf(agent, thread.goal.workspace) ?? []).some(
271
+ (computer) => computer.id === named
272
+ )
273
+ );
274
+ };
275
+ const anyOn = roster().some(
276
+ (card) =>
277
+ CODING.has(card.id) && namedComputer(message, card.id) && isOn(card.id)
278
+ );
279
+ return (agent) => !anyOn || !CODING.has(agent) || isOn(agent);
280
+ };
248
281
  // An agent is handed each of the person's messages once, whichever round hands it on: a new thread's opening round
249
282
  // and its message-to-the-swarm round both handed Claude Code the A1 message (live, November 1).
250
283
  // A run of the agent that ended after the message was handed to it frees the message for another try (a retry
@@ -387,16 +420,18 @@ export function createCoordinator({
387
420
  : ((machinesOf(agent, thread.goal.workspace) ?? []).find(
388
421
  (computer) => computer.online
389
422
  )?.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) => {
423
+ // The computer the agent's work lands on, as the run is placed (threadRuns.mjs wake): the one the person named in
424
+ // the message, else the computer holding the thread's checkout, else the one this agent or the thread worked on
425
+ // before, else the route's computer for it, else the one Jev picked when it is online, else the agent's default. The
426
+ // check looks at the same computer.
427
+ const placedOn = (thread, agent, computer, named = null) => {
394
428
  const online = (id) =>
395
429
  Boolean(id) &&
396
430
  (machinesOf(agent, thread.goal.workspace) ?? []).some(
397
431
  (each) => each.id === id && each.online
398
432
  );
399
433
  return (
434
+ named ||
400
435
  computerOf(thread.id) ||
401
436
  store.meta(`thread-computer:${thread.id}:${agent}`) ||
402
437
  store.meta(`thread-computer:${thread.id}`) ||
@@ -412,9 +447,27 @@ export function createCoordinator({
412
447
  * computer said no and the thread says what it found; the message goes back to Jev when another computer is online,
413
448
  * and otherwise the thread waits on the person. A computer picked again after saying no pauses the thread.
414
449
  */
415
- const checkedOn = async (thread, agent, computer, work, asked) => {
450
+ const checkedOn = async (thread, agent, computer, work, asked, at) => {
416
451
  if (!checksTaken() || !MACHINE_RUNNERS.includes(agent)) return true;
417
- const target = placedOn(thread, agent, computer);
452
+ const target =
453
+ at !== undefined
454
+ ? at
455
+ : placedOn(
456
+ thread,
457
+ agent,
458
+ computer,
459
+ namedComputer(personMessage(thread, asked), agent)
460
+ );
461
+ // Away now: the turn waits for that computer (threadRuns.mjs), and the check is kept to run when it is back, before
462
+ // the turn starts (checkWaiting). Asked while away it answered "unknown", kept, and the turn then started on its
463
+ // return with nothing checked (A1 run, November 2).
464
+ if (capabilities.away?.(target)) {
465
+ store.meta(
466
+ laterKey(thread.id, agent),
467
+ JSON.stringify({ computer: target, work: String(work), asked })
468
+ );
469
+ return true;
470
+ }
418
471
  const id = target ?? capabilities.here();
419
472
  const label = capabilities.labelOf(target);
420
473
  const kept = keptAnswers(thread) ?? {
@@ -465,6 +518,38 @@ export function createCoordinator({
465
518
  poke(thread.id);
466
519
  return false;
467
520
  };
521
+ const laterKey = (goalId, agent) => `capability-later:${goalId}:${agent}`;
522
+ /**
523
+ * An agent's turn waited for its computer, which is back: the check kept for it runs there now. True: the turn starts.
524
+ * False: the computer said no, the thread says so, and the person's message goes back to Jev (or the thread pauses
525
+ * with no other computer to choose), as for a check made at once.
526
+ */
527
+ const checkWaiting = async (goalId, agent) => {
528
+ let later = null;
529
+ try {
530
+ later = JSON.parse(store.meta(laterKey(goalId, agent)) || "null");
531
+ } catch {
532
+ later = null;
533
+ }
534
+ const thread = store.getTask(goalId);
535
+ if (!later || !thread?.goal) return true;
536
+ store.meta(laterKey(goalId, agent), "");
537
+ const can = await checkedOn(
538
+ thread,
539
+ agent,
540
+ null,
541
+ later.work,
542
+ later.asked ?? null,
543
+ later.computer
544
+ );
545
+ if (!can)
546
+ unmarkDelivered(
547
+ thread,
548
+ agent,
549
+ personMessage(thread, later.asked ?? null)
550
+ );
551
+ return can;
552
+ };
468
553
  // The person's pins: specialty -> the agent that holds it when a step asks for it.
469
554
  const pinsNow = () =>
470
555
  Object.fromEntries(
@@ -516,6 +601,20 @@ export function createCoordinator({
516
601
  }
517
602
  };
518
603
  const settleAsked = (goalId) => store.meta(`swarm-asked:${goalId}`, "");
604
+ // Whether the person resumed the thread and neither they nor an agent has posted since: what the dispatcher posts
605
+ // (notes, the goal's wording) is not news.
606
+ const nothingSinceResume = (thread) => {
607
+ const resumedAt = Number(store.meta(`resumed-note:${thread.id}`) || 0);
608
+ if (!resumedAt) return false;
609
+ return !store
610
+ .roomPosts(thread.id, resumedAt, 500)
611
+ .some(
612
+ (post) =>
613
+ post.kind !== "note" &&
614
+ post.author !== thread.goal.facilitator &&
615
+ post.author !== DISPATCHER
616
+ );
617
+ };
519
618
 
520
619
  // What this machine knows that the round needs, whole: the transcript, who can run, and progress since last time.
521
620
  const facts = async (thread, state, asked = null) => {
@@ -586,10 +685,12 @@ export function createCoordinator({
586
685
  const specialtiesTaken =
587
686
  mode() === "local" || serverHas("team_specialties");
588
687
  const can = await canDo(thread, posts, asked);
688
+ const onNamedComputer = namedComputerFilter(thread, asked);
589
689
  // Who could hold a role on the thread's team: the candidates and the agents the person named.
590
690
  const eligible = roster()
591
691
  .filter(
592
692
  (candidate) =>
693
+ onNamedComputer(candidate.id) &&
593
694
  !failedHereLately(thread.id, candidate.id) &&
594
695
  (!CODING.has(candidate.id) ||
595
696
  placeable(candidate.id, thread.goal.workspace)) &&
@@ -1053,7 +1154,16 @@ export function createCoordinator({
1053
1154
  ]
1054
1155
  : [],
1055
1156
  });
1056
- if (placed && !placed.ok) {
1157
+ // The computer holding the checkout is away and this agent works there: no one there is online to hold the
1158
+ // step now, but the turn waits for that computer (threadRuns.mjs) instead of pausing the thread (A1 run,
1159
+ // November 2: work for a computer that was asleep paused the thread).
1160
+ const away =
1161
+ placed &&
1162
+ !placed.ok &&
1163
+ (machinesOf(agent, thread.goal.workspace) ?? []).some(
1164
+ (computer) => computer.id === placed.computer && !computer.online
1165
+ );
1166
+ if (placed && !placed.ok && !away) {
1057
1167
  const label =
1058
1168
  roster()
1059
1169
  .flatMap((card) => machinesOf(card.id, thread.goal.workspace) ?? [])
@@ -1067,7 +1177,7 @@ export function createCoordinator({
1067
1177
  return;
1068
1178
  }
1069
1179
  const replacement =
1070
- placed?.agents.length === 1 ? placed.agents[0] : agent;
1180
+ placed?.agents?.length === 1 ? placed.agents[0] : agent;
1071
1181
  if (replacement !== agent) {
1072
1182
  postAsCoordinator({
1073
1183
  goalId: thread.id,
@@ -1089,9 +1199,11 @@ export function createCoordinator({
1089
1199
  )
1090
1200
  ? options.computer
1091
1201
  : null;
1202
+ const { message, ...rest } = options;
1092
1203
  options = {
1093
- ...options,
1204
+ ...rest,
1094
1205
  routeMachine: team?.machineFor(thread.id, agent) ?? picked,
1206
+ on: namedComputer(message, agent),
1095
1207
  };
1096
1208
  const step = keepsTeams() ? team.pinnedStep(thread.id, agent) : null;
1097
1209
  if (!step || !store.busyElsewhere(agent, thread.id)) {
@@ -1211,6 +1323,28 @@ export function createCoordinator({
1211
1323
  notifyBoard(store.getTask(thread.id));
1212
1324
  return;
1213
1325
  }
1326
+ // Work waiting for the computer the person named starts there once it is back: no reason to pause either.
1327
+ if (decision.action === "pause" && waitsForComputer(thread.id)) {
1328
+ notifyBoard(store.getTask(thread.id));
1329
+ return;
1330
+ }
1331
+ // The person resumed and nothing came in since: pausing again for the same reason only sends the thread back to
1332
+ // them, and pressing Resume again did the same, six times in two minutes (A1 run, November 2). The thread stays
1333
+ // open and says once why; the person's next message is what moves it.
1334
+ if (decision.action === "pause" && nothingSinceResume(thread)) {
1335
+ const resumedAt = store.meta(`resumed-note:${thread.id}`);
1336
+ if (store.meta(`resume-unchanged:${thread.id}`) !== resumedAt) {
1337
+ store.meta(`resume-unchanged:${thread.id}`, resumedAt);
1338
+ postAsCoordinator({
1339
+ goalId: thread.id,
1340
+ author: coordinator,
1341
+ kind: "note",
1342
+ text: "Nothing new has come in since you resumed this, so Jev has no new way to go on. Write here what should change and the swarm takes it from there.",
1343
+ });
1344
+ }
1345
+ notifyBoard(store.getTask(thread.id));
1346
+ return;
1347
+ }
1214
1348
  if (decision.action === "pause") {
1215
1349
  pauseGoal(
1216
1350
  thread.id,
@@ -1335,7 +1469,12 @@ export function createCoordinator({
1335
1469
  withheld || message
1336
1470
  ? words
1337
1471
  : `${nameOf(coordinator)} asked you: ${part.text.slice(0, 300)}`,
1338
- { review: part.review, words, computer: part.computer ?? null },
1472
+ {
1473
+ review: part.review,
1474
+ words,
1475
+ computer: part.computer ?? null,
1476
+ message,
1477
+ },
1339
1478
  coordinator
1340
1479
  );
1341
1480
  }
@@ -1457,7 +1596,7 @@ export function createCoordinator({
1457
1596
  : message
1458
1597
  ? text
1459
1598
  : `${nameOf(coordinator)} asked you: ${text.slice(0, 300)}`,
1460
- { review, words: text, computer: decision.computer ?? null },
1599
+ { review, words: text, computer: decision.computer ?? null, message },
1461
1600
  coordinator
1462
1601
  );
1463
1602
  if (withheld) saidWithheld(thread, withheld, [agent]);
@@ -1649,7 +1788,11 @@ export function createCoordinator({
1649
1788
  thread,
1650
1789
  agent,
1651
1790
  `${intent.coordinator} asked you: ${String(words).slice(0, 300)}`,
1652
- { words, computer: intent.decision.computer ?? null },
1791
+ {
1792
+ words,
1793
+ computer: intent.decision.computer ?? null,
1794
+ message: personMessage(thread, intent.asked),
1795
+ },
1653
1796
  intent.coordinator
1654
1797
  );
1655
1798
  }
@@ -1676,8 +1819,6 @@ export function createCoordinator({
1676
1819
  store.threadRuns(goalId).some(going) ||
1677
1820
  hostedAtWork(goalId).length > 0 ||
1678
1821
  busyInT3(thread).length > 0;
1679
- // A thread started through Harness by an agent that runs elsewhere gets no rounds until the person sets a spend ceiling.
1680
- if (store.meta(`hosted-thread:${goalId}`)) return;
1681
1822
  const local = mode() === "local";
1682
1823
  const seenUpTo = () =>
1683
1824
  store.roomPosts(goalId, 0, 500).at(-1)?.seq ?? state.lastSeenSeq;
@@ -2029,6 +2170,7 @@ export function createCoordinator({
2029
2170
  poke,
2030
2171
  heard,
2031
2172
  resumed,
2173
+ checkWaiting,
2032
2174
  assembles,
2033
2175
  recover,
2034
2176
  hostedAtWork,
package/lib/daemon.mjs CHANGED
@@ -816,6 +816,8 @@ export async function startDaemon() {
816
816
  store,
817
817
  log,
818
818
  onChange: (threadId) => notifyBoard(store.getTask(threadId)),
819
+ // A shared project's room keeps its board in the project's record, the same on every computer in it.
820
+ shared: (threadId) => projects?.boardOf(threadId) ?? null,
819
821
  });
820
822
  const notifyBoard = (task) => {
821
823
  if (!task) return;
@@ -1165,6 +1167,13 @@ export async function startDaemon() {
1165
1167
  placeElsewhere: (agent, workspace) =>
1166
1168
  ownMachines?.placeElsewhere(agent, workspace) ?? null,
1167
1169
  threadFiles: (thread) => boardFiles.threadFiles(thread).files,
1170
+ // Jev passes over the agent in this thread for a while (coordinator.mjs failedHereLately) and picks again.
1171
+ unplaced: (goalId, agent) => {
1172
+ store.meta(`job-failed:${goalId}:${agent}`, new Date().toISOString());
1173
+ coordinator.resumed(goalId);
1174
+ },
1175
+ checkBeforeStart: (goalId, agent) =>
1176
+ coordinator.checkWaiting(goalId, agent),
1168
1177
  // Read when a turn starts: the person's computers are known once ownMachines is made, after this.
1169
1178
  computers: {
1170
1179
  self: () => ownMachines?.self() ?? null,
@@ -1284,12 +1293,14 @@ export async function startDaemon() {
1284
1293
  goalId,
1285
1294
  agent,
1286
1295
  reason,
1287
- { review, words, routeMachine } = {}
1296
+ { review, words, routeMachine, on = null } = {}
1288
1297
  ) =>
1289
1298
  RUNNERS.has(agent)
1290
1299
  ? threadRuns.wake(goalId, agent, reason, {
1291
1300
  review,
1292
1301
  routeMachine,
1302
+ // The computer the person named in the message this answers.
1303
+ on,
1293
1304
  // The person's words whole go into the agent's brief, not only the line that says why it was woken.
1294
1305
  words,
1295
1306
  asker: DISPATCHER,
@@ -1326,6 +1337,8 @@ export async function startDaemon() {
1326
1337
  dispatcher,
1327
1338
  goals,
1328
1339
  settled: (threadId) => coordinator.resumed(threadId),
1340
+ computerAddress: actions.computerAddress,
1341
+ agentsIn: (text) => mentionsIn(text, ROOM_AGENTS),
1329
1342
  handOn: handOnAgent,
1330
1343
  post: (entry) => {
1331
1344
  const posted = store.roomPost(entry);
@@ -1440,6 +1453,7 @@ export async function startDaemon() {
1440
1453
  void memory.heard(thread, post);
1441
1454
  };
1442
1455
  const goalCommand = createGoalCommands({
1456
+ boardView: (threadId) => kanban.view(threadId),
1443
1457
  heardRelayed: (thread, post) => void manager.heard(thread, post),
1444
1458
  computerOf,
1445
1459
  teams,
@@ -1859,6 +1873,8 @@ export async function startDaemon() {
1859
1873
  ),
1860
1874
  machinesOf: (agent, workspace) =>
1861
1875
  ownMachines?.computersFor(agent, workspace),
1876
+ computerAddress: actions.computerAddress,
1877
+ waitsForComputer: (goalId) => threadRuns.waitsForComputer(goalId),
1862
1878
  capabilities: capabilityCheck,
1863
1879
  computerOf: threadRuns.computerOf,
1864
1880
  placeable: (agent, workspace) =>
@@ -1980,6 +1996,7 @@ export async function startDaemon() {
1980
1996
  goalCommand,
1981
1997
  stopThreadRuns,
1982
1998
  steered: (goalId, agent) => threadRuns.steered(goalId, agent),
1999
+ computerOfRun: (run) => threadRuns.computerOfRun(run),
1983
2000
  runningPids,
1984
2001
  provenanceFor,
1985
2002
  runLog: (runId) => taskFiles(runId).log,
@@ -2001,6 +2018,17 @@ export async function startDaemon() {
2001
2018
  available().map((id) => ({ id, about: aboutOf(id), setup: setupOf(id) })),
2002
2019
  worktrees,
2003
2020
  folders,
2021
+ // The person's other computers, read when a composer or thread names one: ownMachines is made after this.
2022
+ computers: {
2023
+ self: () => ownMachines?.self() ?? machine.id,
2024
+ labelOf: (id) => ownMachines?.labelOf(id) ?? null,
2025
+ foldersOn: (id, question) =>
2026
+ ownMachines?.foldersOn(id, question) ?? {
2027
+ ok: false,
2028
+ error: "your other computers are not reachable",
2029
+ },
2030
+ checkoutOn: (id, folder) => ownMachines?.checkoutOn(id, folder) ?? null,
2031
+ },
2004
2032
  runsIn: threadRuns.where,
2005
2033
  authorizeRun: (id) =>
2006
2034
  boardCommand({ command: "board.run", agent: "user", id }),
@@ -2147,9 +2175,9 @@ export async function startDaemon() {
2147
2175
  store,
2148
2176
  validAgent,
2149
2177
  touchListener,
2150
- // A task posted for a card on its thread's board is linked to it once it exists (kanban.mjs).
2178
+ // A task posted into a thread is on its board once it exists: on the card it was posted for, or its own (kanban.mjs).
2151
2179
  answered: (request, answer) =>
2152
- request.command === "board.post" && request.card
2180
+ request.command === "board.post" && request.parentId && answer?.ok
2153
2181
  ? kanban.posted(request, answer)
2154
2182
  : answer,
2155
2183
  machineOf: (request) => request[FROM_MACHINE] ?? machine.id,
@@ -2669,10 +2697,13 @@ export async function startDaemon() {
2669
2697
  changed: () => {
2670
2698
  saveStatus();
2671
2699
  dispatcher.warm();
2700
+ // A turn waiting for one of these computers starts there once it is back (threadRuns.mjs).
2701
+ threadRuns.computersChanged();
2672
2702
  },
2673
2703
  folders: (options) => machineFolders(options),
2674
2704
  repositoryOf: (folder) => repositoryName(folder),
2675
2705
  inventoryChanged: () => {
2706
+ threadRuns.computersChanged();
2676
2707
  for (const goal of store.goals())
2677
2708
  if (store.meta(`inventory-wait:${goal.id}`)) coordinator.poke(goal.id);
2678
2709
  },
@@ -2698,6 +2729,15 @@ export async function startDaemon() {
2698
2729
  ownModels,
2699
2730
  ownLive,
2700
2731
  answerCapability: capabilityCheck.answer,
2732
+ // A composer on home whose message names this computer lists this computer's folders (swarm.mjs board.swarm.places).
2733
+ ownFolders: async (question) =>
2734
+ question.browse !== undefined
2735
+ ? folders.browse(question.browse)
2736
+ : {
2737
+ ok: true,
2738
+ places: folders.known({ own: true }),
2739
+ home: os.homedir(),
2740
+ },
2701
2741
  answerLink: proxyLinks
2702
2742
  ? (from, call) => proxyLinks.answer(from, call)
2703
2743
  : null,
@@ -38,7 +38,7 @@ const FAITHFUL =
38
38
 
39
39
  export const JOBS = {
40
40
  question: `You are the dispatcher for a person's agents. Write one message to the person saying what the thread needs from them, based on \`transcript\` and \`request\`; \`category\` says what it is about (spend: money above what the thread may spend; outward: something outward-facing or hard to undo; secret: something only they have; scope: what the goal is for). If several decisions are open, put them together in this one message, each with lettered options and the option the swarm will take if they have no preference. Say in a few words what was already checked. If \`category\` is secret, never ask for the secret itself in the thread: ask them to give it privately. ${FAITHFUL} Plain words, no greeting. Also give each decision as a choice the person can answer with one tap: \`question\` in a few words, two to four short \`options\`, and \`recommended\`, the index of the option the swarm will take with no preference (or null). Return JSON {"text": string, "choices": [{"question": string, "options": [string], "recommended": number | null}]}.`,
41
- goal: 'You are the dispatcher for a person\'s agents. From the person\'s own posts in `transcript` and `request`, and `goal` (the current version) when given, write the goal of the thread as it stands now. `statement`: the whole aim in one to three plain sentences in the person\'s terms, including what matters most to them (speed, quality, cost, the kind of result) where they said so. `criteria`: one to five checks that would show the goal is reached, each one sentence that a person or code can verify about the result the person wants (e.g. "The installed Python version is named in the thread"), never about the request itself or what the transcript contains. Keep a current criterion word for word when it still applies. `title`: what the work is, in two to six plain words the person would use, with no ending punctuation (e.g. "Find the installed Python version"). Return JSON {"title": string, "statement": string, "criteria": [string]}.',
41
+ goal: 'You are the dispatcher for a person\'s agents. From the person\'s own posts in `transcript` and `request`, write the goal of the thread as it stands now. The newest of the person\'s posts wins: when it asks about another computer, file, place or thing than the earlier ones, the goal is now about that, in its name. A word after # (#pop-os) is the name of one of the person\'s computers. `statement`: the whole aim in one to three plain sentences in the person\'s terms, including what matters most to them (speed, quality, cost, the kind of result) where they said so. `criteria`: one to five checks that would show the goal is reached, each one sentence that a person or code can verify about the result the person wants (e.g. "The installed Python version is named in the thread"), never about the request itself or what the transcript contains. A check names what the request is about (the computer, file or place), so a result about something else cannot meet it. `title`: what the work is, in two to six plain words the person would use, with no ending punctuation (e.g. "Find the installed Python version"). Return JSON {"title": string, "statement": string, "criteria": [string]}.',
42
42
  open_item:
43
43
  'You are the dispatcher for a person\'s agents. In one or two plain sentences, record the part of the request that could not be done: what it was, what was tried and why it did not work, based on `transcript` and `failed_jobs`. Return JSON {"text": string}.',
44
44
  pause:
@@ -50,6 +50,7 @@ export const JOBS = {
50
50
  // stand after an agent's report.
51
51
  judge_message: `You keep a person's swarm of agents to what the person asked. The JSON below has the person's newest message (\`post\`), the posts before it (\`transcript\`), and the person's open asks (\`asks\`). Say what the message is. Answer with one JSON object only: {"kind": "work" (it asks the agents to do something or produce a result not already in \`asks\`) | "question" (it asks the agents something and wants an answer) | "idea" (the person is exploring an idea or talking through the agents' reasoning, not asking for it to be done) | "answer" (it answers a question or approves a choice put to the person) | "chat" (anything else), "steers": the index in \`asks\` of the ask it changes, corrects or narrows, or null, "withdraws": true if it drops that ask, else false}.`,
52
52
  judge_report: `You keep a person's swarm of agents to what the person asked. The JSON below has an agent's report (\`post\`), the posts before it (\`transcript\`), and one item to judge it against (\`item\`): an ask of the person's (kind work or question, with the person's own words, newest word wins) or a check of the thread's goal (kind check). Answer with one JSON object only: {"state": "done" | "in_progress" | "ignored" | "contradicted" (ignored: reported finished without doing it or only part; contradicted: did something different, or claims something the thread does not show), "shown": true if something other than an agent saying so shows it done (a file, commit, command run with output, link, the result itself), else false, "taste": true if only the person's own judgment can settle it, else false}. For kind question, "done" means it was answered; for kind check, that the report shows the check reached.`,
53
+ judge_handoff: `An agent wrote \`post\` in a thread. Does the post itself contain the result of the work (the answer, findings, output, or what was changed), or only a request for another agent to do it? Answer with one JSON object only: {"has_result": true if the post contains the result, false if it only asks another agent to do the work}.`,
53
54
  };
54
55
 
55
56
  /** The JSON object in a model's answer: the whole answer, or the object inside prose or a code fence. */
@@ -72,8 +73,17 @@ export const objectIn = (text) => {
72
73
  return null;
73
74
  };
74
75
 
75
- const clean = (value, max) =>
76
- typeof value === "string" ? value.trim().slice(0, max) : "";
76
+ // Words over `max` end at their last whole sentence that fits, else their last whole word: a pause reason cut at 300
77
+ // characters once ended "cannot procee" (A1 run, November 2).
78
+ const clean = (value, max) => {
79
+ if (typeof value !== "string") return "";
80
+ const text = value.trim();
81
+ if (text.length <= max) return text;
82
+ const head = text.slice(0, max - 1);
83
+ const sentence = head.match(/^[\s\S]*[.!?](?=\s)/)?.[0];
84
+ if (sentence && sentence.length >= max / 2) return sentence;
85
+ return `${head.replace(/\s+\S*$/, "")}…`;
86
+ };
77
87
 
78
88
  /** A setting as the person gave it, or the reason it cannot be one. */
79
89
  export function dispatcherSetting(value) {
@@ -362,7 +372,17 @@ export function createDispatcher({
362
372
  const goal = await attempt(
363
373
  "the goal",
364
374
  async () => {
365
- const output = await job(JOBS.goal, base, (each) => {
375
+ // Only the person's own words: shown the current goal, the base LFM3-Omni copied it word for word after the
376
+ // person named another computer (A1 run, November 2: "#pop-os" and "#Sigalas-MBP-2" kept "this Mac"), and an
377
+ // agent's post about one computer was read as the person's aim (dispatcher-slot 2c).
378
+ const said = {
379
+ thread: base.thread,
380
+ request: base.request,
381
+ transcript: base.transcript.filter(
382
+ (post) => post.author === "user"
383
+ ),
384
+ };
385
+ const output = await job(JOBS.goal, said, (each) => {
366
386
  const criteria = Array.isArray(each.criteria) ? each.criteria : [];
367
387
  return (
368
388
  Boolean(clean(each.statement, 4_000)) &&
@@ -8,7 +8,7 @@ import { provenanceFor } from "./provenance.mjs";
8
8
  import { DISPATCHER, TAGGED_ONLY, nameOf } from "./members.mjs";
9
9
  import { picksIn } from "./models.mjs";
10
10
  import { roomPage } from "./roomPage.mjs";
11
- import { FROM_MACHINE, withComputer } from "./machineRoutes.mjs";
11
+ import { fromCloud, withComputer } from "./machineRoutes.mjs";
12
12
  import { callerLimit, HOSTED_CALLER } from "./runAuthority.mjs";
13
13
 
14
14
  export function createGoalCommands({
@@ -23,6 +23,8 @@ export function createGoalCommands({
23
23
  flagNote,
24
24
  // A post's words as an agent reads them (serverWords.mjs agentText); the person reads every post as written.
25
25
  agentText = (post) => post.text,
26
+ // The thread's board as an agent reads it (kanban.mjs view): where the thread's work is managed.
27
+ boardView = () => null,
26
28
  heardPerson,
27
29
  heardRelayed = () => {},
28
30
  inRoom,
@@ -181,7 +183,13 @@ export function createGoalCommands({
181
183
  files,
182
184
  };
183
185
  const page = roomPage(store, goal.id, request);
184
- return { ...view, ...page, posts: page.posts.map(readable), files };
186
+ return {
187
+ ...view,
188
+ board: boardView(goal.id),
189
+ ...page,
190
+ posts: page.posts.map(readable),
191
+ files,
192
+ };
185
193
  }
186
194
  if (request.command === "board.room.learn") {
187
195
  if (!inRoom(goal, agent) || agent === "user")
@@ -301,10 +309,27 @@ export function createGoalCommands({
301
309
  const answered = named.filter((name) =>
302
310
  store.meta(waitingKey(name, agent))
303
311
  );
312
+ // An asker that passed its own work on with its ask (the manager found its report holds no result) has nothing
313
+ // to go on with: the answer is the result, read in the thread, and starts no turn (A1 run, November 2: Codex's
314
+ // answer woke Claude Code, which did the same look again). One that asked mid-work hears it as before.
315
+ const passedOn = (asker) => {
316
+ const askedAt = Number(
317
+ /^#(\d+)$/.exec(store.meta(waitingKey(asker, agent)))?.[1]
318
+ );
319
+ const handedAt = Number(
320
+ store.meta(`handed-off:${goal.id}:${asker}`) || 0
321
+ );
322
+ return askedAt > 0 && handedAt >= askedAt;
323
+ };
304
324
  const wakes =
305
325
  agent === "user" || agent === "harness"
306
326
  ? mentions
307
- : [...new Set([...asked, ...answered])];
327
+ : [
328
+ ...new Set([
329
+ ...asked,
330
+ ...answered.filter((name) => !passedOn(name)),
331
+ ]),
332
+ ];
308
333
  // A computer chosen for the agents it wakes that cannot be read refuses the post, which then wakes no one on
309
334
  // Home in its place (computerAddress.mjs).
310
335
  const target = request.targetMachine ?? null;
@@ -313,10 +338,9 @@ export function createGoalCommands({
313
338
  if (!address.ok) return { ok: false, error: address.error };
314
339
  }
315
340
  for (const name of answered) store.meta(waitingKey(name, agent), "");
316
- if (agent !== "user" && agent !== "harness")
317
- for (const name of asked) store.meta(waitingKey(agent, name), "1");
318
341
  const unwoken = mentions.filter(
319
- (name) => !wakes.includes(name) && name !== agent
342
+ (name) =>
343
+ !wakes.includes(name) && !answered.includes(name) && name !== agent
320
344
  );
321
345
  const joining = mentions.filter(
322
346
  (name) => !goal.goal.team.includes(name)
@@ -331,6 +355,10 @@ export function createGoalCommands({
331
355
  mentions,
332
356
  });
333
357
  replaceHeld(goal.id, agent, post);
358
+ // Each ask waits for its answer, kept with the post that asked.
359
+ if (agent !== "user" && agent !== "harness")
360
+ for (const name of asked)
361
+ store.meta(waitingKey(agent, name), `#${post.seq}`);
334
362
  if (agent === "user") heardPerson(goal, post);
335
363
  // The person's words an agent brings from its own session (post_to_room person_said): asks for the manager,
336
364
  // never the person's authority.
@@ -361,11 +389,12 @@ export function createGoalCommands({
361
389
  return { ok: true, post, paused: true };
362
390
  }
363
391
  const told = wakeFor(goal.id, post, agent, wakes, {
364
- // An agent's words from another of the person's computers carry no go here, as through Harness (M1).
365
- hosted:
366
- request.hostedCaller === true ||
367
- (request[FROM_MACHINE] !== undefined &&
368
- !["user", "harness"].includes(agent)),
392
+ hosted: request.hostedCaller === true,
393
+ // An agent's words from another computer the person drives carry their go as from this one, its run's limits
394
+ // sealed with them (owner, November 2, in place of audit M1); from a cloud computer Harness runs, the guard
395
+ // reads them as words through Harness's server.
396
+ cloud:
397
+ fromCloud(store, request) && !["user", "harness"].includes(agent),
369
398
  limited: callerLimit(request),
370
399
  window: request.fromWindow === true,
371
400
  target: request.targetMachine ?? null,