tryharness 0.7.53 → 0.7.57

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 (167) hide show
  1. package/README.md +23 -19
  2. package/assets/dsh-plugin.mjs +72 -0
  3. package/assets/opencode-plugin.js +4 -3
  4. package/cli.mjs +484 -90
  5. package/lib/activity.mjs +10 -10
  6. package/lib/adapters.mjs +173 -222
  7. package/lib/agentBinaries.mjs +71 -0
  8. package/lib/agentRuntimeConfig.mjs +1 -1
  9. package/lib/agentRuntimes.mjs +34 -18
  10. package/lib/agentSignIn.mjs +456 -0
  11. package/lib/answers.mjs +5 -5
  12. package/lib/archetypes.d.ts +64 -0
  13. package/lib/archetypes.js +989 -0
  14. package/lib/asks.mjs +4 -4
  15. package/lib/audit.mjs +666 -0
  16. package/lib/backupSetup.mjs +143 -0
  17. package/lib/boardAccess.mjs +24 -11
  18. package/lib/boardBackup.mjs +283 -0
  19. package/lib/boardFileCommands.mjs +6 -6
  20. package/lib/boardFiles.mjs +13 -12
  21. package/lib/boardMirror.mjs +124 -25
  22. package/lib/boardProtocol.json +88 -2
  23. package/lib/boardWaits.mjs +101 -0
  24. package/lib/book.mjs +659 -0
  25. package/lib/bridge.mjs +6 -6
  26. package/lib/cards.mjs +138 -28
  27. package/lib/cloudAgents.mjs +216 -0
  28. package/lib/cloudAi.mjs +1312 -0
  29. package/lib/cloudAssistants.mjs +242 -0
  30. package/lib/cloudBoot.mjs +119 -0
  31. package/lib/cloudSave.mjs +197 -0
  32. package/lib/cloudSsh.mjs +178 -0
  33. package/lib/commands.mjs +7 -2
  34. package/lib/context.mjs +19 -5
  35. package/lib/contractGate.mjs +399 -0
  36. package/lib/control-client.mjs +9 -1
  37. package/lib/controlSocket.mjs +86 -0
  38. package/lib/coordinator.mjs +252 -144
  39. package/lib/daemon.mjs +1351 -2767
  40. package/lib/desk.mjs +240 -0
  41. package/lib/desktop.mjs +178 -74
  42. package/lib/directLink.mjs +16 -5
  43. package/lib/environment.mjs +2 -1
  44. package/lib/environments.mjs +247 -9
  45. package/lib/firewall.mjs +9 -9
  46. package/lib/folders.mjs +20 -16
  47. package/lib/frames.mjs +2 -3
  48. package/lib/gitHost.mjs +174 -0
  49. package/lib/goalCommands.mjs +25 -7
  50. package/lib/goals.mjs +7 -7
  51. package/lib/guestRequests.mjs +94 -0
  52. package/lib/handoffs.mjs +8 -7
  53. package/lib/handover.mjs +4 -4
  54. package/lib/harnessModel.mjs +6 -6
  55. package/lib/harnessOffers.mjs +266 -0
  56. package/lib/hookDialects.mjs +298 -0
  57. package/lib/inference.mjs +26 -8
  58. package/lib/jobAnswers.mjs +190 -0
  59. package/lib/landed.mjs +887 -0
  60. package/lib/lane.mjs +42 -11
  61. package/lib/lessons.mjs +16 -16
  62. package/lib/library.mjs +3 -3
  63. package/lib/lineup.mjs +3 -0
  64. package/lib/linkRelay.mjs +574 -0
  65. package/lib/live.mjs +284 -13
  66. package/lib/localAgentAsk.mjs +74 -0
  67. package/lib/localStack.mjs +536 -0
  68. package/lib/localmodels.mjs +6 -4
  69. package/lib/loopBackstop.mjs +4 -4
  70. package/lib/machineIdentity.mjs +9 -1
  71. package/lib/machineRoutes.mjs +181 -2
  72. package/lib/machineRuns.mjs +76 -1
  73. package/lib/machineSeal.mjs +39 -12
  74. package/lib/mcp-stdio.mjs +163 -27
  75. package/lib/mcpRelay.mjs +1 -1
  76. package/lib/members.json +29 -2
  77. package/lib/members.mjs +1 -1
  78. package/lib/models.mjs +85 -31
  79. package/lib/museSession.mjs +21 -13
  80. package/lib/nativeHost.mjs +36 -8
  81. package/lib/neovim.mjs +126 -0
  82. package/lib/network.mjs +50 -5
  83. package/lib/notify.mjs +7 -5
  84. package/lib/nudge.mjs +50 -19
  85. package/lib/ocr.mjs +9 -9
  86. package/lib/onboard.mjs +26 -20
  87. package/lib/oneLine.mjs +7 -7
  88. package/lib/ownMachines.mjs +1223 -140
  89. package/lib/pairing.mjs +60 -16
  90. package/lib/paths.mjs +19 -1
  91. package/lib/peerProcess.mjs +124 -0
  92. package/lib/personModel.mjs +89 -0
  93. package/lib/personNotices.mjs +151 -0
  94. package/lib/phones.mjs +538 -31
  95. package/lib/placeCommands.mjs +4 -4
  96. package/lib/places.mjs +400 -12
  97. package/lib/profile.mjs +67 -14
  98. package/lib/projectGit.mjs +158 -14
  99. package/lib/projectPieces.mjs +902 -0
  100. package/lib/projectSettings.mjs +7 -4
  101. package/lib/projects.mjs +384 -62
  102. package/lib/provenance.mjs +5 -1
  103. package/lib/proxyLinks.mjs +267 -0
  104. package/lib/reactions.mjs +7 -5
  105. package/lib/readiness.mjs +145 -23
  106. package/lib/record.mjs +128 -0
  107. package/lib/redact.mjs +4 -4
  108. package/lib/relayLimits.mjs +62 -0
  109. package/lib/release.mjs +170 -0
  110. package/lib/releaseKeys.json +6 -0
  111. package/lib/repoLinks.mjs +4 -4
  112. package/lib/roomChannels.mjs +24 -0
  113. package/lib/roomPage.mjs +1 -1
  114. package/lib/runAuthority.mjs +101 -0
  115. package/lib/runBrief.mjs +19 -8
  116. package/lib/runWorker.mjs +31 -7
  117. package/lib/runner.mjs +223 -29
  118. package/lib/runtime-install.mjs +143 -9
  119. package/lib/schedules.mjs +2 -2
  120. package/lib/screens.mjs +1 -1
  121. package/lib/sealed.mjs +11 -2
  122. package/lib/sealedThreads.mjs +671 -0
  123. package/lib/secretPatterns.json +1 -1
  124. package/lib/secrets.mjs +4 -4
  125. package/lib/seen.mjs +6 -6
  126. package/lib/serverWords.mjs +175 -0
  127. package/lib/service.mjs +22 -12
  128. package/lib/sessionControl.mjs +378 -90
  129. package/lib/specialties.json +74 -0
  130. package/lib/specialties.mjs +477 -0
  131. package/lib/specialtyKeys.d.ts +3 -0
  132. package/lib/specialtyKeys.js +57 -0
  133. package/lib/specialtyNotice.mjs +147 -0
  134. package/lib/specialtySnapshot.mjs +138 -0
  135. package/lib/speech.mjs +5 -5
  136. package/lib/store.mjs +420 -36
  137. package/lib/stuck.mjs +1 -1
  138. package/lib/swarm.mjs +304 -37
  139. package/lib/swarmDevices.mjs +319 -0
  140. package/lib/swarmMemory.mjs +27 -25
  141. package/lib/t3.mjs +24 -15
  142. package/lib/taskCommands.mjs +80 -20
  143. package/lib/taskRooms.mjs +125 -0
  144. package/lib/taskRuns.mjs +45 -3
  145. package/lib/team.json +255 -148
  146. package/lib/team.mjs +554 -190
  147. package/lib/threadActions.mjs +315 -0
  148. package/lib/threadAuthority.mjs +101 -0
  149. package/lib/threadBriefs.mjs +178 -0
  150. package/lib/threadLine.mjs +116 -0
  151. package/lib/threadRuns.mjs +209 -50
  152. package/lib/threadView.mjs +20 -7
  153. package/lib/usageTotals.mjs +2 -3
  154. package/lib/vault.mjs +101 -10
  155. package/lib/vaultCloud.mjs +2 -2
  156. package/lib/vaultCommands.mjs +15 -6
  157. package/lib/vaultTools.js +2 -2
  158. package/lib/verdicts.mjs +328 -0
  159. package/lib/wakes.mjs +1 -1
  160. package/lib/watches.mjs +2 -2
  161. package/lib/windowAsks.mjs +13 -5
  162. package/lib/worktrees.mjs +157 -25
  163. package/npm-shrinkwrap.json +1093 -0
  164. package/package.json +12 -11
  165. package/release.json +220 -0
  166. package/lib/modelTiers.json +0 -1183
  167. package/lib/modelTiers.mjs +0 -133
package/lib/stuck.mjs CHANGED
@@ -8,7 +8,7 @@ import { isSetupCheck } from "./handoffs.mjs";
8
8
  // Harness's notes never do. The daemon runs the sweep on board changes and on a timer, and says each finding where it
9
9
  // belongs (daemon.mjs): in the thread and to its coordinator, or to whoever posted loose work.
10
10
  //
11
- // The thresholds, from the owner's board on October 20 (a read-only copy; 60 threads, 373 tasks and wakes):
11
+ // The thresholds, from one real board (a read-only copy; 60 threads, 373 tasks and wakes):
12
12
  // - Pickup (claimMs, droppedMs): 367 pickups, from posting (or the person's Start) to claim: p50 0, p90 3.4, p95 11.2,
13
13
  // p99 224 min. The tail is the stuck kind this sweep is for: Grok Bot's 242 and 251 min and 13.9 days, Harness
14
14
  // waiting for a window up to 9.2 h. Every pickup of work Harness starts itself (277, queueing for a busy folder
package/lib/swarm.mjs CHANGED
@@ -6,14 +6,24 @@ import { readRunSteps } from "./runner.mjs";
6
6
  import { createSubagents } from "./subagents.mjs";
7
7
  import { MACHINE_RUNNERS, member, nameOf, resolveMember } from "./members.mjs";
8
8
  import {
9
+ agentSpecialties,
9
10
  setNote,
10
- setTier,
11
11
  swarmBlock,
12
12
  swarmCards,
13
13
  swarmDigest,
14
14
  youLine,
15
15
  } from "./cards.mjs";
16
- import { TIERS } from "./modelTiers.mjs";
16
+ import {
17
+ SPECIALTIES,
18
+ addSpecialty,
19
+ appoint,
20
+ headingOf,
21
+ offices,
22
+ pins,
23
+ removeSpecialty,
24
+ setPin,
25
+ setPrimary,
26
+ } from "./specialties.mjs";
17
27
  import { askOfRun } from "./threadView.mjs";
18
28
  import { createWorkFocus } from "./workFocus.mjs";
19
29
  import { createWorkLinks } from "./workLinks.mjs";
@@ -39,10 +49,11 @@ export const PROCESS_NAMES = {
39
49
  codex: "codex",
40
50
  pi: "pi",
41
51
  opencode: "opencode",
52
+ // The command the person runs when it is not the protocol server Harness runs (Antigravity's `agy`).
42
53
  ...Object.fromEntries(
43
54
  MACHINE_RUNNERS.filter((id) => member(id)?.runtime).map((id) => [
44
55
  id,
45
- member(id).runtime.command,
56
+ member(id).cli ?? member(id).runtime.command,
46
57
  ])
47
58
  ),
48
59
  };
@@ -53,6 +64,30 @@ const UUID = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i;
53
64
  // A setup check's own room, from before checks stopped opening one (onboard.mjs): never a thread for the person.
54
65
  const SETUP_CHECK = /^Setup check from Harness: reply ready$/;
55
66
 
67
+ // A specialty as a command names it: its id, or its name as cards show it ("code review").
68
+ const specialtyIdOf = (text) => {
69
+ const wanted = String(text ?? "")
70
+ .trim()
71
+ .toLowerCase();
72
+ return (
73
+ SPECIALTIES.find(
74
+ (specialty) =>
75
+ specialty.id === wanted || specialty.name.toLowerCase() === wanted
76
+ )?.id ?? null
77
+ );
78
+ };
79
+ // Every specialty under its archetype's heading, in the list's order, for the Swarm map to offer.
80
+ const specialtyHeadings = () => {
81
+ const headings = new Map();
82
+ for (const specialty of SPECIALTIES) {
83
+ const heading = headingOf(specialty.id);
84
+ const entry = headings.get(heading.id) ?? { ...heading, specialties: [] };
85
+ entry.specialties.push({ id: specialty.id, name: specialty.name });
86
+ headings.set(heading.id, entry);
87
+ }
88
+ return [...headings.values()];
89
+ };
90
+
56
91
  // The id an agent resumes a session by: the index keys sessions by their file name.
57
92
  export function nativeSessionId(agent, sessionId) {
58
93
  const bare = String(sessionId).replace(/\.jsonl$/, "");
@@ -98,6 +133,7 @@ export function agentProcessCwds(exclude = new Set()) {
98
133
  }
99
134
 
100
135
  export function createSwarm({
136
+ landed = null,
101
137
  store,
102
138
  // What this computer hands the person's Harness page through the extension (browserWake.mjs).
103
139
  browserWake = null,
@@ -124,6 +160,8 @@ export function createSwarm({
124
160
  pickable,
125
161
  listModels,
126
162
  harnessModel,
163
+ // The person chose a model for an agent here (an agent on Harness's AI also takes it as its default).
164
+ modelChosen = () => {},
127
165
  folders,
128
166
  runsIn,
129
167
  threadFiles = () => ({ files: [], rendering: [] }),
@@ -148,6 +186,8 @@ export function createSwarm({
148
186
  addressesPartner = () => false,
149
187
  environments = null,
150
188
  notifyFocus = () => {},
189
+ // What the person's words just did to a run they steered (threadRuns.mjs steered): a promise of the thread's note.
190
+ steered = () => null,
151
191
  }) {
152
192
  const focus = createWorkFocus({ store });
153
193
  const readWork = async (id, hostedCaller = false) => {
@@ -197,8 +237,8 @@ export function createSwarm({
197
237
 
198
238
  // Who a message is for: the agents it names, else whoever coordinates, which brings in every agent with a part in it.
199
239
  // Where the coordinator cannot assemble (the privacy setting, a Harness without it) the thread's only agent takes it.
200
- // `@swarm` is for the whole swarm: whoever coordinates brings in the rest, and the agents it names hear it from the post
201
- // itself (October 16: a message naming an orchestrator and a role for each agent reached none of them).
240
+ // `@swarm` is for the whole swarm: whoever coordinates brings in the rest, and the agents it names hear it from the
241
+ // post itself (a message naming an orchestrator and a role for each agent once reached none of them).
202
242
  const addressed = (thread, text) => {
203
243
  if (SWARM.test(text))
204
244
  return [
@@ -241,7 +281,7 @@ export function createSwarm({
241
281
  agent: asking.claimed_by || asking.target_agent,
242
282
  text: asking.result || "",
243
283
  };
244
- // Work another agent asked for that only the person's Start lets run (docs/member-runs.md).
284
+ // Work another agent asked for that only the person's Start lets run.
245
285
  const held = runs.find(awaitingStart);
246
286
  if (held)
247
287
  return {
@@ -329,6 +369,9 @@ export function createSwarm({
329
369
  .map((post) => ({ seq: post.seq, text: post.text })),
330
370
  coordination: {
331
371
  mode: coordinator.mode(),
372
+ // The coding agent here the person picked, and the ones they can pick.
373
+ pick: coordinator.pick(),
374
+ choices: coordinator.choices(),
332
375
  rounds: coordinator.state(thread.id).rounds,
333
376
  // Who decided this thread's rounds: Harness, a backup here after Harness could not, this computer, no one.
334
377
  decided: store.roundHealth(thread.id, 3650).reduce(
@@ -347,6 +390,8 @@ export function createSwarm({
347
390
  checkIns: schedules?.list({ threadId: thread.id }) ?? [],
348
391
  ceilingUsd: ceilingOf(thread.id),
349
392
  changes: worktrees.summary(thread.id),
393
+ // Whether it made anything that can land: its Landed view shows then (landed.mjs).
394
+ landed: landed?.produced(thread, posts) ?? false,
350
395
  // A project shared with another person's swarm (projects.mjs): which, and with whom.
351
396
  project: projectOf(thread.id),
352
397
  });
@@ -530,6 +575,125 @@ export function createSwarm({
530
575
  return posted;
531
576
  };
532
577
 
578
+ /**
579
+ * The person's steer: words for an agent while it works, named by its thread or its run (tryharness steer, also over
580
+ * SSH on a cloud computer). They go into the thread as the person's message to that agent, as from PiP or the
581
+ * phone, which is what steers its run (threadRuns.mjs). The answer says what became of them.
582
+ */
583
+ const steer = (request) => {
584
+ const text = String(request.text || "")
585
+ .trim()
586
+ .slice(0, 20_000);
587
+ if (!text) return { ok: false, error: "a steer needs words" };
588
+ const named = store.getTask(String(request.id || ""));
589
+ const run = named && named.kind !== "goal" ? named : null;
590
+ const thread = run?.parent_id ? store.getTask(run.parent_id) : named;
591
+ if (thread?.kind !== "goal")
592
+ return { ok: false, error: "no thread or run has that id" };
593
+ if (run && run.status !== "running")
594
+ return {
595
+ ok: false,
596
+ error: `That run of ${nameOf(run.target_agent)}'s is not going any more. Write in its thread instead.`,
597
+ };
598
+ const working = store
599
+ .threadRuns(thread.id)
600
+ .filter((each) => each.status === "running")
601
+ .map((each) => each.target_agent)
602
+ .filter((agent) => roomAgents.includes(agent));
603
+ const asked = recipient(request);
604
+ if (asked === false)
605
+ return {
606
+ ok: false,
607
+ error: `${request.to} can't be written to in a thread`,
608
+ };
609
+ const to =
610
+ run?.target_agent ??
611
+ asked ??
612
+ (new Set(working).size === 1 ? working[0] : null);
613
+ if (!to)
614
+ return {
615
+ ok: false,
616
+ error: working.length
617
+ ? `More than one agent is working in this thread. Name one: ${[...new Set(working)].join(", ")}.`
618
+ : "Nothing is working in this thread now. Write in it instead.",
619
+ };
620
+ const posted = post(thread, text, to);
621
+ if (!posted?.ok) return posted;
622
+ const told = steered(thread.id, to);
623
+ const answer = (note) => {
624
+ const now = summary(store.getTask(thread.id));
625
+ return {
626
+ ok: true,
627
+ steered: true,
628
+ agent: to,
629
+ note,
630
+ // What a chat outside the thread says of it, beside a link to the thread.
631
+ line: `Sent to ${nameOf(to)}, which is working in "${now.title}".`,
632
+ thread: now,
633
+ };
634
+ };
635
+ return told
636
+ ? { pending: told.then(answer) }
637
+ : answer(
638
+ `${nameOf(to)} is not working now, so your message starts its next turn.`
639
+ );
640
+ };
641
+
642
+ /**
643
+ * The person's words in a chat that is not a thread (the PiP chat, the extension, the buddy's box, the phone's New
644
+ * message), naming one agent that is working (owner, October 26: steering "from any chat interface"): they go into
645
+ * the thread it works in as the person's steer, as written. Working in several threads, the answer asks which
646
+ * (`choose`); none, null, and the chat goes on as it would have. Words for the whole swarm, or naming several agents,
647
+ * are never a steer.
648
+ */
649
+ const steerFromChat = (request) => {
650
+ const text = String(request.text || "");
651
+ if (/(^|\s)@swarm\b/.test(text)) return null;
652
+ const asked = recipient(request);
653
+ // Harness counts as a name like any agent: "@claude-code … for @harness" is for both, and is no steer.
654
+ const named = asked ? [asked] : mentionsIn(text, roomAgents);
655
+ if (named.length !== 1 || named[0] === "harness") return null;
656
+ const [agent] = named;
657
+ const threads = store
658
+ .goals({ all: false })
659
+ .filter(
660
+ (thread) =>
661
+ thread.status === "open" &&
662
+ store
663
+ .threadRuns(thread.id)
664
+ .some(
665
+ (run) => run.target_agent === agent && run.status === "running"
666
+ )
667
+ );
668
+ if (!threads.length) return null;
669
+ if (threads.length > 1)
670
+ return {
671
+ ok: true,
672
+ steered: false,
673
+ choose: {
674
+ agent,
675
+ question: `${nameOf(agent)} is working in ${threads.length} threads. Which one is this for?`,
676
+ threads: threads.map((thread) => ({
677
+ id: thread.id,
678
+ title: summary(thread).title,
679
+ })),
680
+ },
681
+ };
682
+ return steer({ ...request, id: threads[0].id, to: agent });
683
+ };
684
+
685
+ // One of the person's agents as a command names it, or why not.
686
+ const namedAgent = (target) => {
687
+ const named = resolveMember(target);
688
+ if (named.ok) return named;
689
+ return {
690
+ ok: false,
691
+ error: named.candidates?.length
692
+ ? `"${target}" could be ${named.candidates.join(" or ")}; name one`
693
+ : `no agent called "${target}"`,
694
+ };
695
+ };
696
+
533
697
  return function swarmCommand(request, agent, machine = null) {
534
698
  const command = String(request.command);
535
699
  if (command === "board.swarm.list") {
@@ -552,10 +716,12 @@ export function createSwarm({
552
716
  sessions: request.sessions === false ? [] : sessions(),
553
717
  agents: roster(),
554
718
  joining: request.hostedCaller ? [] : joining(),
719
+ // What waits on the person about an agent, outside any thread (threadView.mjs swarmNeeds).
720
+ needsYou: request.hostedCaller ? [] : (threadView?.swarmNeeds() ?? []),
555
721
  });
556
- return environments && !request.hostedCaller
557
- ? { pending: environments.refresh().then(listed) }
558
- : listed();
722
+ // The work in T3 Code beside the board as T3 Code last said it; only the first read waits for it.
723
+ const loading = request.hostedCaller ? null : environments?.ready();
724
+ return loading ? { pending: loading.then(listed) } : listed();
559
725
  }
560
726
  if (
561
727
  [
@@ -806,9 +972,12 @@ export function createSwarm({
806
972
  id,
807
973
  name: nameOf(id),
808
974
  choice: choiceOf(store, id),
809
- ownModel: agentModelSettings(id).model,
975
+ // On Harness's AI its own settings are Harness's, so its default is Auto, in the list.
976
+ ownModel: listed?.harness ? null : agentModelSettings(id).model,
810
977
  listedAt: listed?.at ?? null,
811
978
  ...(listed?.error ? { error: listed.error } : {}),
979
+ // What pays for its models on Harness's AI, and the words for a pick that runs on Auto or the free model.
980
+ ...(listed?.harness ? { harness: listed.harness } : {}),
812
981
  models: listed?.models ?? [],
813
982
  };
814
983
  }),
@@ -853,7 +1022,9 @@ export function createSwarm({
853
1022
  const thread = store.createGoal({
854
1023
  objective,
855
1024
  originAgent: agent,
856
- provenance: provenanceFor(agent),
1025
+ provenance: provenanceFor(agent, null, null, {
1026
+ viaServer: request.hostedCaller === true,
1027
+ }),
857
1028
  team: [...team, agent, "harness"],
858
1029
  facilitator: "harness",
859
1030
  workspace: folder ? path.resolve(folder) : null,
@@ -947,25 +1118,89 @@ export function createSwarm({
947
1118
  note: setNote(store, named.id, request.text),
948
1119
  };
949
1120
  }
950
- // The person's own tier for one agent, which wins over its model's benchmark tier for the roles with a floor
951
- // (team.json); "auto" goes back to the benchmark's.
952
- if (command === "board.swarm.tier") {
1121
+ // What one agent is good at on the model it runs on now (specialties.mjs), for the Swarm map: each specialty with
1122
+ // its source and evidence, primary first, the specialties the person pinned it for, and every specialty there is,
1123
+ // under its heading. The person's, like everything from here on: agents read the cards through list_agents.
1124
+ if (command === "board.swarm.specialties") {
1125
+ const named = namedAgent(request.target);
1126
+ if (!named.ok) return named;
1127
+ const { model, effort, specialties } = agentSpecialties(store, named.id);
1128
+ return {
1129
+ ok: true,
1130
+ agent: named.id,
1131
+ model,
1132
+ effort,
1133
+ specialties,
1134
+ pinned: pins(store).filter((pin) => pin.agent === named.id),
1135
+ headings: specialtyHeadings(),
1136
+ };
1137
+ }
1138
+ // The person adds or removes one of an agent's specialties, or makes it the primary. A removal is final for the
1139
+ // agent and the model it runs on now: no benchmark or record brings it back.
1140
+ if (command === "board.swarm.specialty") {
953
1141
  if (agent !== "user")
954
- return { ok: false, error: "only the person sets an agent's tier" };
955
- const named = resolveMember(request.target);
956
- if (!named.ok)
957
1142
  return {
958
1143
  ok: false,
959
- error: named.candidates.length
960
- ? `"${request.target}" could be ${named.candidates.join(" or ")}; name one`
961
- : `no agent called "${request.target}"`,
1144
+ error: "only the person changes an agent's specialties",
1145
+ };
1146
+ const named = namedAgent(request.target);
1147
+ if (!named.ok) return named;
1148
+ const specialty = specialtyIdOf(request.specialty);
1149
+ if (!specialty)
1150
+ return {
1151
+ ok: false,
1152
+ error: `"${request.specialty}" is not a specialty Harness knows`,
1153
+ };
1154
+ const action = String(request.action || "");
1155
+ const change = {
1156
+ add: addSpecialty,
1157
+ remove: removeSpecialty,
1158
+ primary: setPrimary,
1159
+ }[action];
1160
+ if (!change)
1161
+ return { ok: false, error: "the action is add, remove or primary" };
1162
+ const { model } = agentSpecialties(store, named.id);
1163
+ const changed = change(store, named.id, specialty, model);
1164
+ if (!changed.ok) return changed;
1165
+ return {
1166
+ ok: true,
1167
+ agent: named.id,
1168
+ specialties: agentSpecialties(store, named.id).specialties,
1169
+ };
1170
+ }
1171
+ // The person pins an agent for a specialty: it holds that specialty whenever a step asks for it. No agent takes the
1172
+ // pin off.
1173
+ if (command === "board.swarm.pin") {
1174
+ if (agent !== "user")
1175
+ return { ok: false, error: "only the person pins an agent" };
1176
+ const specialty = specialtyIdOf(request.specialty);
1177
+ if (!specialty)
1178
+ return {
1179
+ ok: false,
1180
+ error: `"${request.specialty}" is not a specialty Harness knows`,
962
1181
  };
963
- const tier = String(request.tier || "").toLowerCase();
964
- if (![...TIERS, "auto"].includes(tier))
965
- return { ok: false, error: "a tier is top, middle, bottom or auto" };
966
- setTier(store, named.id, tier === "auto" ? null : tier);
967
- const card = swarmCards(store, [{ id: named.id }])[0];
968
- return { ok: true, agent: named.id, tier: card?.tier ?? null };
1182
+ if (request.target === null || request.target === undefined)
1183
+ return setPin(store, specialty, null);
1184
+ const named = namedAgent(request.target);
1185
+ if (!named.ok) return named;
1186
+ return setPin(store, specialty, named.id);
1187
+ }
1188
+ // The swarm's offices and who holds each, for the home computer's panel.
1189
+ if (command === "board.swarm.offices")
1190
+ return { ok: true, offices: offices(store) };
1191
+ // The person appoints an agent to an office, or no agent for its default; the rules refuse some, saying why.
1192
+ if (command === "board.swarm.office") {
1193
+ if (agent !== "user")
1194
+ return { ok: false, error: "only the person appoints an office" };
1195
+ const office = String(request.office || "")
1196
+ .trim()
1197
+ .toLowerCase()
1198
+ .replace(/\s+/g, "-");
1199
+ if (request.target === null || request.target === undefined)
1200
+ return appoint(store, office, null);
1201
+ const named = namedAgent(request.target);
1202
+ if (!named.ok) return named;
1203
+ return appoint(store, office, named.id);
969
1204
  }
970
1205
  // The person's choice of model and effort for one agent: a model it lists, "auto", or "default" for its own settings.
971
1206
  if (command === "board.swarm.model") {
@@ -979,12 +1214,16 @@ export function createSwarm({
979
1214
  ? { ok: true, agent: "harness", choice: set.choice }
980
1215
  : set;
981
1216
  }
982
- if (!named.ok || !PICKABLE.has(named.id))
1217
+ if (
1218
+ !named.ok ||
1219
+ !(PICKABLE.has(named.id) || pickable().includes(named.id))
1220
+ )
983
1221
  return {
984
1222
  ok: false,
985
1223
  error: `the relay sets the model of ${[...PICKABLE].join(", ")}, not "${request.target}"`,
986
1224
  };
987
1225
  const set = setChoice(store, named.id, request.model, request.effort);
1226
+ if (set.ok) modelChosen(named.id);
988
1227
  return set.ok ? { ok: true, agent: named.id, choice: set.choice } : set;
989
1228
  }
990
1229
  // The person's words on how Auto picks models for swarm work; no text goes back to the default words.
@@ -1011,10 +1250,28 @@ export function createSwarm({
1011
1250
  request.days
1012
1251
  ),
1013
1252
  };
1253
+ // Who coordinates the threads: Harness (the default), or one of the coding agents here the person picks.
1014
1254
  if (command === "board.swarm.coordinator") {
1015
- if (request.mode === "harness" || request.mode === "local")
1016
- coordinator.setMode(request.mode);
1017
- return { ok: true, mode: coordinator.mode() };
1255
+ const choices = coordinator.choices();
1256
+ if (request.mode !== undefined) {
1257
+ const wanted = String(request.mode);
1258
+ if (
1259
+ wanted !== "harness" &&
1260
+ wanted !== "local" &&
1261
+ !choices.includes(wanted)
1262
+ )
1263
+ return {
1264
+ ok: false,
1265
+ error: `${wanted} cannot coordinate here: pick harness${choices.map((id) => `, ${id}`).join("")} or local`,
1266
+ };
1267
+ coordinator.setMode(wanted);
1268
+ }
1269
+ return {
1270
+ ok: true,
1271
+ mode: coordinator.mode(),
1272
+ pick: coordinator.pick(),
1273
+ choices,
1274
+ };
1018
1275
  }
1019
1276
  if (command === "board.swarm.stop_all") {
1020
1277
  const stopped = store
@@ -1031,7 +1288,11 @@ export function createSwarm({
1031
1288
  .trim()
1032
1289
  .slice(0, 20_000);
1033
1290
  if (!text) return { ok: false, error: "a thread starts with a message" };
1034
- // What it may spend of the person's Harness credits, set once as it starts (owner, October 15).
1291
+ // From a chat outside any thread (the buddy's box, the phone's New message): words for one agent already at work
1292
+ // steer it there rather than start it again somewhere new.
1293
+ const steering = request.steer === true ? steerFromChat(request) : null;
1294
+ if (steering) return steering;
1295
+ // What it may spend of the person's Harness credits, set once as it starts.
1035
1296
  const ceiling = ceilingFrom(request.ceilingUsd);
1036
1297
  if (ceiling === undefined)
1037
1298
  return { ok: false, error: "a limit is a number of dollars, or off" };
@@ -1173,7 +1434,7 @@ export function createSwarm({
1173
1434
  if (!removed)
1174
1435
  return { ok: false, error: "no lesson starts with that id" };
1175
1436
  // The words it came from stop coming back through search and briefs too, so the swarm does not learn it again
1176
- // from them (eval memory-swarm); they stay in their thread.
1437
+ // from them; they stay in their thread.
1177
1438
  memory?.forget({
1178
1439
  ids: removed.evidence.map((entry) => entry.postId).filter(Boolean),
1179
1440
  mode: "release",
@@ -1261,6 +1522,12 @@ export function createSwarm({
1261
1522
  if (removed.ok) notifyBoard(store.getTask(removed.schedule.threadId));
1262
1523
  return removed;
1263
1524
  }
1525
+ // With no thread or run named, the words come from a chat outside any thread: a steer only if they name one agent
1526
+ // that is working, else nothing is done and the chat goes on as before.
1527
+ if (command === "board.swarm.steer")
1528
+ return request.id
1529
+ ? steer(request)
1530
+ : (steerFromChat(request) ?? { ok: true, steered: false });
1264
1531
  const thread = store.getTask(String(request.id || ""));
1265
1532
  if (!thread || thread.kind !== "goal")
1266
1533
  return { ok: false, error: "thread not found" };
@@ -1348,8 +1615,8 @@ export function createSwarm({
1348
1615
  ? { ok: true, thread: summary(store.getTask(thread.id)) }
1349
1616
  : done;
1350
1617
  }
1351
- // The person lets Harness finish in their browser now what it left for the browser (owner, October 22: "right
1352
- // away, even if away"): their extension's hidden Harness page takes it, claiming it only once this is recorded.
1618
+ // The person lets Harness finish in their browser now what it left for the browser, right away, even while they are
1619
+ // away: their extension's hidden Harness page takes it, claiming it only once this is recorded.
1353
1620
  if (command === "board.swarm.use_browser") {
1354
1621
  if (agent !== "user")
1355
1622
  return { ok: false, error: "only you let Harness use your browser" };
@@ -1408,9 +1675,9 @@ export function createSwarm({
1408
1675
  stopThreadRuns(thread.id);
1409
1676
  return { ok: true, thread: summary(store.getTask(thread.id)) };
1410
1677
  }
1411
- // A post held for the person (it looked like a secret, or like orders to the agents): they read it, then send it into
1412
- // the thread as its author wrote it or throw it away (owner, October 19: "yes" to Send and Discard). Its words
1413
- // reach only the person's own sealed surfaces (boardProtocol.json).
1678
+ // A post held for the person (it looked like a secret, or like orders to the agents): they read it, then send it
1679
+ // into the thread as its author wrote it or throw it away (Send and Discard). Its words reach only the person's own
1680
+ // sealed surfaces (boardProtocol.json).
1414
1681
  if (command === "board.swarm.held") {
1415
1682
  const held = store.heldPost(thread.id, String(request.post || ""));
1416
1683
  if (!held || store.meta(`held-replaced:${held.id}`))