tryharness 0.7.71 → 0.7.73

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/README.md +13 -8
  2. package/assets/opencode-plugin.js +70 -3
  3. package/cli.mjs +27 -12
  4. package/lib/asks.mjs +4 -0
  5. package/lib/boardCommands.mjs +9 -1
  6. package/lib/boardProtocol.json +23 -19
  7. package/lib/bridge.mjs +2 -0
  8. package/lib/capabilityCheck.mjs +86 -0
  9. package/lib/computerAddress.mjs +6 -14
  10. package/lib/coordinator.mjs +259 -30
  11. package/lib/daemon.mjs +164 -133
  12. package/lib/dispatchContract.json +1 -31
  13. package/lib/dispatchTools.js +8 -39
  14. package/lib/dispatches.mjs +27 -285
  15. package/lib/goalCommands.mjs +21 -38
  16. package/lib/herdr.mjs +159 -0
  17. package/lib/hookDialects.mjs +36 -2
  18. package/lib/jobAnswers.mjs +3 -0
  19. package/lib/kanban.mjs +256 -0
  20. package/lib/live.mjs +25 -3
  21. package/lib/localAgentAsk.mjs +20 -29
  22. package/lib/machineRoutes.mjs +1 -5
  23. package/lib/machineRuns.mjs +42 -22
  24. package/lib/manager.mjs +254 -0
  25. package/lib/mcp-stdio.mjs +58 -39
  26. package/lib/moves.mjs +365 -0
  27. package/lib/nudge.mjs +13 -3
  28. package/lib/ownMachines.mjs +122 -12
  29. package/lib/places.mjs +29 -2
  30. package/lib/plans.mjs +7 -1
  31. package/lib/projectSettings.mjs +11 -1
  32. package/lib/projects.mjs +20 -4
  33. package/lib/runAuthority.mjs +104 -35
  34. package/lib/runBrief.mjs +14 -1
  35. package/lib/runWorker.mjs +48 -24
  36. package/lib/runner.mjs +184 -75
  37. package/lib/selfUpdate.mjs +41 -0
  38. package/lib/serverWords.mjs +11 -11
  39. package/lib/sessionControl.mjs +68 -3
  40. package/lib/steerHook.mjs +124 -0
  41. package/lib/steerQueue.mjs +176 -0
  42. package/lib/store.mjs +34 -34
  43. package/lib/subagentSteering.mjs +363 -0
  44. package/lib/subagents.mjs +138 -29
  45. package/lib/swarm.mjs +16 -3
  46. package/lib/taskCommands.mjs +36 -71
  47. package/lib/threadActions.mjs +13 -3
  48. package/lib/threadAuthority.mjs +21 -14
  49. package/lib/threadBriefs.mjs +9 -3
  50. package/lib/threadRuns.mjs +35 -8
  51. package/npm-shrinkwrap.json +14 -14
  52. package/package.json +4 -4
  53. package/release.json +54 -49
  54. package/lib/comfyExecution.mjs +0 -545
  55. package/lib/promptDecider.mjs +0 -471
  56. package/lib/promptFlow.mjs +0 -562
  57. package/lib/promptScopes.mjs +0 -670
package/lib/moves.mjs ADDED
@@ -0,0 +1,365 @@
1
+ import { nameOf } from "./members.mjs";
2
+
3
+ // The coordinator's moves beyond bringing agents in, asking the person and waiting (Codex's decision contract, posts 163
4
+ // and 168 of thread 344f1900; the server's half is src/server/swarm/moves.ts). This module offers what exists in a
5
+ // thread (what can be looked up, the agents' conversations, turns held for the person's go, results, work going now,
6
+ // whether the thread can close) and carries out the one Jev picks. Every move uses the person's own words or an
7
+ // agent's own result; none writes a brief, and each is checked again here against the thread as it is now.
8
+
9
+ const TRANSCRIPT_POSTS = 30;
10
+ // What a look-up brings back at most; the round it goes into is sent again with fewer posts if Jev cannot read it all.
11
+ const LOOKED_CHARS = 40_000;
12
+ const SAID = new Set(["post", "result", "question"]);
13
+
14
+ const line = (text, max) =>
15
+ String(text ?? "")
16
+ .replace(/\s+/g, " ")
17
+ .trim()
18
+ .slice(0, max);
19
+ const minutesSince = (at) =>
20
+ at ? Math.max(0, Math.round((Date.now() - Date.parse(at)) / 60_000)) : null;
21
+
22
+ export function createMoves({
23
+ store,
24
+ // Whether a run is going (claimed, running or authorized and waiting to start).
25
+ going,
26
+ // Agents on Harness's server at work in the thread, and the server task each holds there.
27
+ hostedAtWork,
28
+ hostedTaskOf = () => null,
29
+ // The person's own words to agents, as if the person had named them (their go, their authority).
30
+ wakeAll,
31
+ // The person's Start for one held turn (board.run as the person).
32
+ start,
33
+ // Stop a run here or on the computer that took it; cancel a task on Harness's server (acknowledged or not).
34
+ stopRun,
35
+ cancelHosted,
36
+ finishGoal,
37
+ // The person's open asks (manager.mjs): the thread does not close while any is open.
38
+ openAsks = () => [],
39
+ post,
40
+ notifyBoard,
41
+ log = () => {},
42
+ }) {
43
+ const posts = (goalId) => store.roomPosts(goalId, 0, 500);
44
+ const isHeld = (run) => run.status === "open" && !run.run_authorized_at;
45
+ const working = (run) => going(run) && !isHeld(run);
46
+ // Agents' turns waiting for the person's Start, newest last.
47
+ const heldOf = (goalId) => store.threadRuns(goalId).filter(isHeld);
48
+ const runningOf = (goalId) => [
49
+ ...store
50
+ .threadRuns(goalId)
51
+ .filter(working)
52
+ .map((run) => ({
53
+ id: run.id,
54
+ agent: run.target_agent || "agent",
55
+ what: line(run.objective, 300),
56
+ run,
57
+ })),
58
+ ...hostedAtWork(goalId).map((agent) => ({
59
+ id: `hosted:${agent}`,
60
+ agent,
61
+ what: line(
62
+ posts(goalId).findLast(
63
+ (each) => each.kind === "job" && each.mentions.includes(agent)
64
+ )?.text,
65
+ 300
66
+ ),
67
+ })),
68
+ ];
69
+
70
+ /** What a round may do besides bringing agents in, for this thread now. `looked`: a look-up already done. */
71
+ const offered = (thread, { candidates, looked = null }) => {
72
+ const all = posts(thread.id);
73
+ const reachable = new Set(candidates.map((candidate) => candidate.id));
74
+ const atWork = new Set([
75
+ ...store
76
+ .threadRuns(thread.id)
77
+ .filter(working)
78
+ .map((run) => run.target_agent),
79
+ ...hostedAtWork(thread.id),
80
+ ]);
81
+ const conversations = [
82
+ ...new Set(
83
+ all
84
+ .filter(
85
+ (each) =>
86
+ SAID.has(each.kind) &&
87
+ reachable.has(each.author) &&
88
+ !store.meta(`coordinator-post:${each.id}`)
89
+ )
90
+ .map((each) => each.author)
91
+ ),
92
+ ]
93
+ .map((agent) => {
94
+ const last = all.findLast(
95
+ (each) =>
96
+ each.author === agent &&
97
+ SAID.has(each.kind) &&
98
+ !store.meta(`coordinator-post:${each.id}`)
99
+ );
100
+ return {
101
+ agent,
102
+ state: atWork.has(agent)
103
+ ? "at_work"
104
+ : last.kind === "question"
105
+ ? "asked_the_person"
106
+ : "answered",
107
+ last: line(last.text, 500),
108
+ };
109
+ })
110
+ .slice(-8);
111
+ const held = heldOf(thread.id)
112
+ .slice(-8)
113
+ .map((run) => ({
114
+ id: run.id,
115
+ agent: run.target_agent || "agent",
116
+ asker: run.origin_agent || "agent",
117
+ what: line(run.objective, 500),
118
+ }));
119
+ const results = [
120
+ ...all
121
+ .filter(
122
+ (each) =>
123
+ (each.kind === "result" || each.kind === "post") &&
124
+ each.author !== "user" &&
125
+ each.author !== thread.goal.facilitator &&
126
+ !store.meta(`coordinator-post:${each.id}`)
127
+ )
128
+ .slice(-5)
129
+ .map((each) => ({
130
+ id: `post:${each.seq}`,
131
+ author: each.author,
132
+ what: line(each.text, 500),
133
+ })),
134
+ ...resultFiles(thread)
135
+ .slice(-3)
136
+ .map((file) => ({
137
+ id: `file:${file.id}`,
138
+ author: file.author,
139
+ what: `the file ${line(file.name, 200)}`,
140
+ })),
141
+ ];
142
+ const running = runningOf(thread.id)
143
+ .slice(-8)
144
+ .map(({ id, agent, what }) => ({ id, agent, what }));
145
+ const lookUps = looked
146
+ ? []
147
+ : [
148
+ ...(all.length > TRANSCRIPT_POSTS ? ["earlier_posts"] : []),
149
+ "board",
150
+ ...(running.length ? ["work_status"] : []),
151
+ ];
152
+ return {
153
+ lookUps,
154
+ ...(looked ? { lookedUp: [looked] } : {}),
155
+ conversations,
156
+ held,
157
+ results,
158
+ running,
159
+ finishable: !running.length && !held.length,
160
+ };
161
+ };
162
+
163
+ // Files on the thread and on the work done in it.
164
+ const resultFiles = (thread) =>
165
+ [thread.id, ...store.threadRuns(thread.id).map((run) => run.id)]
166
+ .flatMap((taskId) => store.taskFiles(taskId))
167
+ .filter((file) => file && file.author !== "user")
168
+ .sort((a, b) => a.created_at.localeCompare(b.created_at));
169
+
170
+ /** The look-up Jev asked for, as text the next decision reads. */
171
+ const lookUp = (thread, kind, request, before = null) => {
172
+ if (kind === "earlier_posts") {
173
+ const all = posts(thread.id);
174
+ // Before the oldest post the round read: the transcript's window, or fewer when the round left some out to fit.
175
+ const earlier =
176
+ before === null
177
+ ? all.slice(0, -TRANSCRIPT_POSTS)
178
+ : all.filter((each) => each.seq < before);
179
+ const kept = [];
180
+ let room = LOOKED_CHARS;
181
+ for (const each of earlier.reverse()) {
182
+ // The person's words whole, as they wrote them; an agent's cut, its post whole in the thread.
183
+ const text =
184
+ each.author === "user" ? each.text : line(each.text, 1_500);
185
+ const said = `#${each.seq} ${nameOf(each.author)} (${each.kind}): ${text}`;
186
+ if (said.length > room && kept.length) break;
187
+ kept.unshift(said);
188
+ room -= said.length + 1;
189
+ }
190
+ return { kind, text: kept.join("\n") || "No earlier posts." };
191
+ }
192
+ if (kind === "work_status") {
193
+ const text = runningOf(thread.id)
194
+ .map(({ agent, what, run }) => {
195
+ const latest = posts(thread.id).findLast(
196
+ (each) => each.author === agent
197
+ );
198
+ const minutes = minutesSince(run?.claimed_at ?? run?.created_at);
199
+ return `${nameOf(agent)}: ${what}${minutes === null ? "" : `, ${run.status} for ${minutes} min`}${run?.claimed_machine ? ` on ${run.claimed_machine}` : ""}${latest ? `; latest post: ${line(latest.text, 600)}` : ""}`;
200
+ })
201
+ .join("\n");
202
+ return { kind, text: text || "Nothing is running." };
203
+ }
204
+ const threads = store
205
+ .searchThreads(request, { k: 12 })
206
+ .filter((hit) => hit.thread !== thread.id)
207
+ .map(
208
+ (hit) =>
209
+ `Thread "${line(hit.thread_title, 120)}", ${nameOf(hit.author)}: ${line(hit.text, 1_200)}`
210
+ );
211
+ const sessions = store
212
+ .search({
213
+ query: String(request).split(/\s+/).slice(0, 12).join(" "),
214
+ limit: 6,
215
+ })
216
+ .filter((hit) => hit.excerpt)
217
+ .map(
218
+ (hit) =>
219
+ `${nameOf(hit.agent)} session "${line(hit.title, 120)}": ${line(hit.excerpt, 1_200)}`
220
+ );
221
+ const text = [...threads, ...sessions].join("\n").slice(0, LOOKED_CHARS);
222
+ return { kind, text: text || "Nothing on the board matches." };
223
+ };
224
+
225
+ // The person's newest message in the thread: the words a move carries, and the go it may give.
226
+ const personMessage = (goalId) =>
227
+ posts(goalId).findLast(
228
+ (each) => each.author === "user" && each.kind === "post"
229
+ ) ?? null;
230
+
231
+ /** Carries out a move. True when it was one; the thread says what happened. */
232
+ const apply = (thread, decision, coordinator) => {
233
+ const say = (text) =>
234
+ post({ goalId: thread.id, author: coordinator, kind: "note", text });
235
+ const message = personMessage(thread.id);
236
+ switch (decision.action) {
237
+ case "continue": {
238
+ const agent = String(decision.agent ?? "");
239
+ if (!message || !thread.goal.team.includes(agent)) return true;
240
+ wakeAll(
241
+ thread.id,
242
+ [agent],
243
+ message.text,
244
+ "the person's message follows on from your conversation in this thread"
245
+ );
246
+ say(`Your message went on to ${nameOf(agent)}, as you wrote it.`);
247
+ break;
248
+ }
249
+ case "execute": {
250
+ const held = heldOf(thread.id).find((run) => run.id === decision.ref);
251
+ // The person's go is their own message, written after the turn began to wait.
252
+ if (!held || !message || message.created_at < held.created_at)
253
+ return true;
254
+ store.meta(`go-by-message:${held.id}`, String(message.seq));
255
+ const started = start(held.id);
256
+ say(
257
+ started?.ok
258
+ ? `${nameOf(held.target_agent)}'s turn started on your go (your message #${message.seq}).`
259
+ : `${nameOf(held.target_agent)}'s turn could not start: ${started?.error ?? "it is no longer waiting"}.`
260
+ );
261
+ break;
262
+ }
263
+ case "deliver": {
264
+ const shown = deliver(thread, String(decision.ref ?? ""), coordinator);
265
+ if (!shown) return true;
266
+ break;
267
+ }
268
+ case "cancel": {
269
+ const stopping = runningOf(thread.id).filter((work) =>
270
+ (decision.stop ?? []).includes(work.id)
271
+ );
272
+ for (const work of stopping) void stop(thread, work, say);
273
+ break;
274
+ }
275
+ case "finish": {
276
+ if (runningOf(thread.id).length || heldOf(thread.id).length)
277
+ return true;
278
+ const open = openAsks(thread.id);
279
+ if (open.length) {
280
+ say(`Still open: ${open.join("; ")}`);
281
+ break;
282
+ }
283
+ finishGoal(
284
+ thread.id,
285
+ coordinator,
286
+ message
287
+ ? `Closed on your word (your message #${message.seq}).`
288
+ : "Closed: what was asked is done."
289
+ );
290
+ break;
291
+ }
292
+ default:
293
+ return false;
294
+ }
295
+ notifyBoard(store.getTask(thread.id));
296
+ return true;
297
+ };
298
+
299
+ // A result shown again: the agent's own words or file, attributed, never reworded.
300
+ const deliver = (thread, ref, coordinator) => {
301
+ if (ref.startsWith("post:")) {
302
+ const seq = Number(ref.slice(5));
303
+ const original = posts(thread.id).find((each) => each.seq === seq);
304
+ if (!original) return false;
305
+ post({
306
+ goalId: thread.id,
307
+ author: coordinator,
308
+ kind: "post",
309
+ text: `${nameOf(original.author)}'s result (post #${seq}):\n\n${original.text}`,
310
+ });
311
+ return true;
312
+ }
313
+ const file = ref.startsWith("file:") ? store.file(ref.slice(5)) : null;
314
+ if (!file) return false;
315
+ if (file.task_id !== thread.id)
316
+ store.addFile({
317
+ taskId: thread.id,
318
+ name: file.name,
319
+ mime: file.mime,
320
+ bytes: file.bytes,
321
+ sha256: file.sha256,
322
+ author: file.author,
323
+ cloud: file.cloud,
324
+ });
325
+ post({
326
+ goalId: thread.id,
327
+ author: coordinator,
328
+ kind: "post",
329
+ text: `${nameOf(file.author)}'s file ${file.name}, in this thread's files.`,
330
+ });
331
+ return true;
332
+ };
333
+
334
+ // Stopped only once its executor says so; a request with no answer is said as asked, not as stopped.
335
+ const stop = async (thread, work, say) => {
336
+ if (work.run) {
337
+ const runs = store
338
+ .threadRuns(thread.id)
339
+ .filter((run) => run.target_agent === work.agent && working(run));
340
+ store.closeGoalChildren(thread.id, "Stopped on your word.", work.agent);
341
+ const acknowledged = runs.map((run) => stopRun(run)).every(Boolean);
342
+ say(
343
+ acknowledged
344
+ ? `${nameOf(work.agent)} stopped: ${work.what}`
345
+ : `${nameOf(work.agent)} was asked to stop: ${work.what}. Its computer has not said it stopped yet.`
346
+ );
347
+ return;
348
+ }
349
+ const taskId = hostedTaskOf(thread.id, work.agent);
350
+ const cancelled = taskId
351
+ ? await cancelHosted(taskId).catch((error) => {
352
+ log(`cancel ${taskId}: ${error.message}`);
353
+ return null;
354
+ })
355
+ : null;
356
+ say(
357
+ cancelled?.ok
358
+ ? `${nameOf(work.agent)} stopped: ${work.what}`
359
+ : `${nameOf(work.agent)} could not be stopped${cancelled?.error ? ` (${cancelled.error})` : ""}: ${work.what}`
360
+ );
361
+ notifyBoard(store.getTask(thread.id));
362
+ };
363
+
364
+ return { offered, lookUp, apply };
365
+ }
package/lib/nudge.mjs CHANGED
@@ -9,6 +9,7 @@ import { fitSections } from "./fit.mjs";
9
9
  import { oneLine } from "./oneLine.mjs";
10
10
  import { SWARM_HEADER } from "./cards.mjs";
11
11
  import { hookDialect, hookInput } from "./hookDialects.mjs";
12
+ import { PARENT, steerText, takeSteers } from "./steerQueue.mjs";
12
13
 
13
14
  // The session-start nudge: what an interactive agent is told when a session opens, so work
14
15
  // waiting on the board is not silent until someone asks. Claude Code runs this as a
@@ -489,10 +490,19 @@ if (import.meta.url === `file://${process.argv[1]}`) {
489
490
  // A stop that is not a turn ending (Grok's as a session closes) cannot keep anything going: a message taken then
490
491
  // would be lost.
491
492
  if (input && !input.endsTurn) process.exit(0);
492
- // The Stop hook: a message waiting for this session keeps the agent going with it.
493
+ // The Stop hook: a message waiting for this session keeps the agent going with it, and so does a word about one of
494
+ // its subagents the person steered that its own model has not seen yet (steerQueue.mjs).
493
495
  const messages = await takeMessages(agent, sessionId);
494
- if (messages.length)
495
- process.stdout.write(dialect.block(messagesText(messages)) + "\n");
496
+ const steers = sessionId
497
+ ? takeSteers(sessionId, PARENT, { event: "turn end" })
498
+ : [];
499
+ const text = [
500
+ messages.length ? messagesText(messages) : "",
501
+ steers.length ? steerText(steers) : "",
502
+ ]
503
+ .filter(Boolean)
504
+ .join("\n\n");
505
+ if (text) process.stdout.write(dialect.block(text) + "\n");
496
506
  else await noteTurn(agent, input);
497
507
  } else {
498
508
  if (prompted) await notePrompt(agent, input);
@@ -180,10 +180,18 @@ export function createOwnMachines({
180
180
  // A proxy link's model call from one of the person's cloud computers, on the computer holding the link
181
181
  // (proxyLinks.mjs answer); null where none is held.
182
182
  answerLink = null,
183
- // Bounded GPU operations, admitted only over the pinned Home's sealed ask.
184
- answerPrompt = null,
183
+ // Home asking whether this computer can do a piece of work (capabilityCheck.mjs), only over its sealed ask.
184
+ answerCapability = null,
185
185
  // A cloud computer's own SSH keys (cloudSsh.mjs allow): { key, by } in, null on a computer that takes none.
186
186
  ownSsh = null,
187
+ // This computer updating itself to a published release (daemon.mjs): `tryharness upgrade <spec>`, which takes only a
188
+ // release signed with Harness's release key, started on its own so it outlives the daemon it restarts.
189
+ ownUpdate = () => ({
190
+ ok: false,
191
+ error: "this computer cannot update itself",
192
+ }),
193
+ // The release this computer runs, which an update never goes back from.
194
+ runningVersion = "0.0.0",
187
195
  }) {
188
196
  // On home: each worker's folders and the repository each holds, as it said them.
189
197
  const infos = new Map();
@@ -2090,8 +2098,8 @@ export function createOwnMachines({
2090
2098
  // a question for the windows only from the few they answer for home (M6).
2091
2099
  // A cloud home's call through a proxy link this computer holds is answered for that home alone (proxyLinks.mjs).
2092
2100
  const answer =
2093
- call.prompt && answerPrompt
2094
- ? await answerPrompt(call.prompt, pinned.machine_id)
2101
+ typeof call.capability === "string" && answerCapability
2102
+ ? await answerCapability(call.capability)
2095
2103
  : call.inventory === true
2096
2104
  ? { ok: true, folders: folders({ fresh: true }) }
2097
2105
  : call.home === true
@@ -2104,12 +2112,14 @@ export function createOwnMachines({
2104
2112
  ? await ownLive(call.live)
2105
2113
  : call.ssh
2106
2114
  ? ownSshAllow(call.ssh)
2107
- : WINDOW_TOOLS.has(call.tool)
2108
- ? await askOwnWindows(call)
2109
- : {
2110
- ok: false,
2111
- error: `home cannot ask this computer's windows for ${call.tool}`,
2112
- };
2115
+ : call.update
2116
+ ? ownUpdateChecked(call.update)
2117
+ : WINDOW_TOOLS.has(call.tool)
2118
+ ? await askOwnWindows(call)
2119
+ : {
2120
+ ok: false,
2121
+ error: `home cannot ask this computer's windows for ${call.tool}`,
2122
+ };
2113
2123
  return {
2114
2124
  envelope: await sealAskAnswer(
2115
2125
  key,
@@ -2416,6 +2426,37 @@ export function createOwnMachines({
2416
2426
  };
2417
2427
  };
2418
2428
 
2429
+ /**
2430
+ * A subagent read or steer, done on the computer its session runs on (subagentSteering.mjs local): through home, which
2431
+ * asks the worker that has it, as a session read goes.
2432
+ */
2433
+ const askSubagents = async (target, call) => {
2434
+ const where = String(target || machine.id);
2435
+ if (where === machine.id) return ownLive({ subagent: call });
2436
+ if (isHome()) {
2437
+ if (
2438
+ !siblings.some((sibling) => sibling.id === where && confirmed(sibling))
2439
+ )
2440
+ return { ok: false, error: "that computer is not in your swarm" };
2441
+ return (
2442
+ (await askWorker(where, { live: { subagent: call } })) ?? {
2443
+ ok: false,
2444
+ error: `${labelOf(where) ?? "That computer"} did not answer`,
2445
+ }
2446
+ );
2447
+ }
2448
+ const pinned = pinnedHome();
2449
+ if (!pinned) return { ok: false, error: unreachableNote(null) };
2450
+ return (
2451
+ (await callOnce(pinned, {
2452
+ command: LIVE_COMMAND,
2453
+ agent: "user",
2454
+ subagent: call,
2455
+ machine: where,
2456
+ })) ?? offline()
2457
+ );
2458
+ };
2459
+
2419
2460
  /**
2420
2461
  * One session's latest messages and steps, read on the computer it runs on (`machine`, this one by default): through
2421
2462
  * home, which asks the worker that has it.
@@ -2511,6 +2552,7 @@ export function createOwnMachines({
2511
2552
  const answerLiveCall = async (call, from) => {
2512
2553
  if (call.agent !== "user")
2513
2554
  return { ok: false, error: "only the person reads their sessions" };
2555
+ if (call.subagent) return askSubagents(call.machine, call.subagent);
2514
2556
  if (call.open) return openSession({ ...call.open, machine: call.machine });
2515
2557
  if (call.read) return readSession({ ...call.read, machine: call.machine });
2516
2558
  return { ok: true, computers: await everyComputersLive(from) };
@@ -2554,6 +2596,68 @@ export function createOwnMachines({
2554
2596
  );
2555
2597
  };
2556
2598
 
2599
+ // ---- updating another of the person's computers (tryharness machines update) ----
2600
+
2601
+ /**
2602
+ * The person updating one of their computers to a published release, from home: "latest" or a version, never an
2603
+ * older one than it runs, and never any other npm spec (a git address or a file would run code no release key
2604
+ * signed). The computer fetches and checks it itself; home only asks, over the pair's sealed line.
2605
+ */
2606
+ const update = async ({ computer: named, version = "latest" } = {}) => {
2607
+ const spec = String(version || "latest");
2608
+ if (spec !== "latest" && !/^\d+\.\d+\.\d+$/.test(spec))
2609
+ return {
2610
+ ok: false,
2611
+ error: `${spec} is not a release: give a version like 0.7.72, or latest`,
2612
+ };
2613
+ const target =
2614
+ findMachine(all(), named)?.id ??
2615
+ store.ownMachines().find((pinned) => pinned.label === named)
2616
+ ?.machine_id ??
2617
+ String(named || machine.id);
2618
+ if (target === machine.id) return ownUpdateChecked({ version: spec });
2619
+ if (!isHome())
2620
+ return {
2621
+ ok: false,
2622
+ error: "Ask home to update your other computers: it holds their keys.",
2623
+ };
2624
+ const worker = siblings.find((sibling) => sibling.id === target);
2625
+ if (!worker || !confirmed(worker))
2626
+ return {
2627
+ ok: false,
2628
+ error: "that computer is not one of yours confirmed on home",
2629
+ };
2630
+ return (
2631
+ (await askWorker(target, { update: { version: spec } })) ?? {
2632
+ ok: false,
2633
+ error: `${worker.label} did not answer; it may be asleep or offline`,
2634
+ }
2635
+ );
2636
+ };
2637
+ // Numbers only: a local build (0.7.71-local.abc) counts as its release.
2638
+ const releaseOf = (version) =>
2639
+ String(version)
2640
+ .split("-")[0]
2641
+ .split(".")
2642
+ .map((part) => Number(part) || 0);
2643
+ const older = (spec, than) => {
2644
+ const [a, b] = [releaseOf(spec), releaseOf(than)];
2645
+ for (let i = 0; i < 3; i++) if (a[i] !== b[i]) return a[i] < b[i];
2646
+ return false;
2647
+ };
2648
+ /** On the computer updated: the same checks again, as home's word is not taken for them. */
2649
+ const ownUpdateChecked = ({ version } = {}) => {
2650
+ const spec = String(version || "latest");
2651
+ if (spec !== "latest" && !/^\d+\.\d+\.\d+$/.test(spec))
2652
+ return { ok: false, error: `${spec} is not a release` };
2653
+ if (spec !== "latest" && older(spec, runningVersion))
2654
+ return {
2655
+ ok: false,
2656
+ error: `${labelOf(machine.id) ?? "This computer"} runs ${runningVersion}; it never moves back to ${spec}.`,
2657
+ };
2658
+ return ownUpdate(spec);
2659
+ };
2660
+
2557
2661
  // ---- the person's SSH key into a cloud computer (cloudSsh.mjs) ----
2558
2662
 
2559
2663
  const ownSshAllow = (ssh) =>
@@ -2803,6 +2907,9 @@ export function createOwnMachines({
2803
2907
  inventoryOf(sibling.id).state === "ready"
2804
2908
  ? namesOf(infos.get(sibling.id).folders)
2805
2909
  : [],
2910
+ // Its last inventory request got no answer (a worker that never answers, or one too old to): asking it again
2911
+ // now would only wait out the transport.
2912
+ unanswered: Boolean(inventoryRequests.get(sibling.id)?.error),
2806
2913
  })),
2807
2914
  ];
2808
2915
 
@@ -2897,9 +3004,10 @@ export function createOwnMachines({
2897
3004
  answerAs,
2898
3005
  pushViews,
2899
3006
  askWorkerWindows,
2900
- promptTo: (workerId, call) =>
3007
+ // Whether a worker can do this work, by an agent there looking (capabilityCheck.mjs); null when it cannot be asked.
3008
+ capabilityOf: (workerId, work) =>
2901
3009
  isHome() && store.ownMachine(workerId)?.hosted !== true
2902
- ? askWorker(workerId, { prompt: call })
3010
+ ? askWorker(workerId, { capability: String(work) })
2903
3011
  : Promise.resolve(null),
2904
3012
  linkCall,
2905
3013
  tellWorkers,
@@ -2927,8 +3035,10 @@ export function createOwnMachines({
2927
3035
  models,
2928
3036
  sessions,
2929
3037
  readSession,
3038
+ askSubagents,
2930
3039
  openSession,
2931
3040
  setModel,
3041
+ update,
2932
3042
  allowSsh,
2933
3043
  status,
2934
3044
  all,
package/lib/places.mjs CHANGED
@@ -12,8 +12,8 @@ import { kept } from "./kept.mjs";
12
12
  // Harness piece inside the agent sends it when the session starts (the Claude Code and Codex hooks, nudge.mjs; the
13
13
  // opencode plugin; the pi extension), or the daemon reads it from the running process when nothing did. Terminals and
14
14
  // editors put their own ids into everything they start, the same on every OS (TERM_PROGRAM, TMUX_PANE, WEZTERM_PANE,
15
- // KITTY_WINDOW_ID, NVIM: Neovim's server, VSCODE_GIT_ASKPASS_NODE: the editor's own install); macOS adds the app
16
- // (__CFBundleIdentifier).
15
+ // KITTY_WINDOW_ID, NVIM: Neovim's server, HERDR_PANE_ID: herdr's pane, VSCODE_GIT_ASKPASS_NODE: the editor's own
16
+ // install); macOS adds the app (__CFBundleIdentifier).
17
17
  //
18
18
  // Any other agent (a custom harness) does the same with one line to the daemon's socket as a session starts:
19
19
  // {"command":"board.live.place","agent":"<its id>","sessionId":"<id>","folder":"<absolute path>","pids":[<its pid>],
@@ -34,6 +34,11 @@ export const PLACE_ENV = [
34
34
  "KITTY_WINDOW_ID",
35
35
  "KITTY_LISTEN_ON",
36
36
  "NVIM",
37
+ "HERDR_PANE_ID",
38
+ "HERDR_TAB_ID",
39
+ "HERDR_WORKSPACE_ID",
40
+ "HERDR_SOCKET_PATH",
41
+ "HERDR_BIN_PATH",
37
42
  "WT_SESSION",
38
43
  "VSCODE_GIT_ASKPASS_NODE",
39
44
  "CLAUDE_CODE_ENTRYPOINT",
@@ -1184,12 +1189,29 @@ export const isTerminalApp = (app) =>
1184
1189
  path.basename(app, ".app")
1185
1190
  );
1186
1191
 
1192
+ const HERDR_ID = /^[A-Za-z0-9._:-]{1,128}$/;
1193
+ const absolute = (file) =>
1194
+ typeof file === "string" && path.isAbsolute(file) ? file : null;
1195
+ /** A herdr pane's ids, from what herdr puts in everything a pane runs; null outside herdr. */
1196
+ function herdrIds(env) {
1197
+ if (!HERDR_ID.test(env.HERDR_PANE_ID || "")) return null;
1198
+ const id = (value) => (HERDR_ID.test(value || "") ? value : null);
1199
+ return {
1200
+ pane: env.HERDR_PANE_ID,
1201
+ tab: id(env.HERDR_TAB_ID),
1202
+ workspace: id(env.HERDR_WORKSPACE_ID),
1203
+ socket: absolute(env.HERDR_SOCKET_PATH),
1204
+ bin: absolute(env.HERDR_BIN_PATH),
1205
+ };
1206
+ }
1207
+
1187
1208
  /**
1188
1209
  * Where a session runs, from its environment and the app found up its process tree (`host`, live.mjs hostApp):
1189
1210
  * t3 T3 Code;
1190
1211
  * editor an editor built on VS Code: its terminal, or an agent's own panel there ("surface");
1191
1212
  * codex-app the Codex app;
1192
1213
  * nvim a Neovim terminal: its server (neovim.mjs), and the terminal app and pane Neovim itself runs in;
1214
+ * herdr a herdr pane: its pane, tab and workspace, and the socket and binary of the herdr it is in (herdr.mjs);
1193
1215
  * terminal a terminal app, with the ids that pick its pane on any OS (tmux, WezTerm, kitty) and its tty;
1194
1216
  * app any other app.
1195
1217
  * The environment comes first: the app a process sits under can be a different one (a terminal started from an editor).
@@ -1229,6 +1251,11 @@ export function placeFrom({
1229
1251
  folder,
1230
1252
  };
1231
1253
  };
1254
+ // A herdr pane, before anything its environment carries from where herdr's server started (a terminal's, an editor's or
1255
+ // T3 Code's): a session in it shows only in herdr. Neovim run in the pane, or an editor's own panel, is the place.
1256
+ const herdr = herdrIds(env);
1257
+ if (herdr && !env.NVIM && env.CLAUDE_CODE_ENTRYPOINT !== "claude-vscode")
1258
+ return { kind: "herdr", name: "herdr", ...herdr, folder };
1232
1259
  if (env.T3CODE_CLI_PATH || bundle === T3_BUNDLE)
1233
1260
  return { kind: "t3", name: "T3 Code", folder };
1234
1261
  const ids = {
package/lib/plans.mjs CHANGED
@@ -265,7 +265,13 @@ export function createPlans({
265
265
  targetAgent: node.agent,
266
266
  parentId: threadId,
267
267
  });
268
- if (posted?.ok && posted.task?.id) {
268
+ // While the guard reads its words, the post answers { pending, task }: the task is in, and only whether it may
269
+ // start waits (taskCommands.mjs). Read as no answer, a step was once marked "could not be posted".
270
+ if (posted?.pending)
271
+ void posted.pending.catch((error) =>
272
+ log(`plan ${node.id} start not decided: ${error.message}`)
273
+ );
274
+ if ((posted?.ok || posted?.pending) && posted.task?.id) {
269
275
  node.taskId = posted.task.id;
270
276
  node.state = "posted";
271
277
  } else {