tryharness 0.7.45 → 0.7.53

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 (99) hide show
  1. package/README.md +232 -12
  2. package/cli.mjs +406 -184
  3. package/lib/actorRoster.mjs +28 -5
  4. package/lib/adapters.mjs +9 -1
  5. package/lib/agentRuntimeConfig.mjs +36 -0
  6. package/lib/agentRuntimes.mjs +560 -0
  7. package/lib/atlas.mjs +7 -2
  8. package/lib/boardCommands.mjs +5 -10
  9. package/lib/boardFileCommands.mjs +2 -1
  10. package/lib/boardMirror.mjs +459 -0
  11. package/lib/boardProtocol.json +206 -6
  12. package/lib/boardTools.mjs +2 -6
  13. package/lib/bridge.mjs +25 -3
  14. package/lib/browserWake.mjs +60 -0
  15. package/lib/cards.mjs +35 -2
  16. package/lib/commands.mjs +20 -5
  17. package/lib/connectionTools.d.ts +13 -0
  18. package/lib/connectionTools.js +45 -0
  19. package/lib/connectorAuth.mjs +309 -0
  20. package/lib/connectorCatalog.json +41 -0
  21. package/lib/connectorCommands.mjs +121 -0
  22. package/lib/connectorGoogle.mjs +513 -0
  23. package/lib/connectors.mjs +805 -0
  24. package/lib/coordinator.mjs +8 -1
  25. package/lib/coreModels.mjs +78 -0
  26. package/lib/daemon.mjs +643 -45
  27. package/lib/desktop.mjs +7 -2
  28. package/lib/digest.mjs +32 -0
  29. package/lib/directLink.mjs +283 -0
  30. package/lib/environments.mjs +595 -0
  31. package/lib/folders.mjs +2 -2
  32. package/lib/goalCommands.mjs +58 -14
  33. package/lib/inference.mjs +263 -152
  34. package/lib/lessons.mjs +6 -0
  35. package/lib/lineup.mjs +324 -0
  36. package/lib/localmodels.mjs +10 -0
  37. package/lib/machineIdentity.mjs +3 -0
  38. package/lib/machineRoutes.mjs +40 -2
  39. package/lib/machineRuns.mjs +30 -3
  40. package/lib/machineSeal.mjs +69 -10
  41. package/lib/mcp-stdio.mjs +121 -118
  42. package/lib/mcpRelay.mjs +119 -0
  43. package/lib/members.json +12 -0
  44. package/lib/members.mjs +33 -0
  45. package/lib/modelMemory.mjs +100 -0
  46. package/lib/modelTiers.json +1183 -0
  47. package/lib/modelTiers.mjs +133 -0
  48. package/lib/models.mjs +41 -8
  49. package/lib/museSession.mjs +119 -0
  50. package/lib/nativeHost.mjs +203 -0
  51. package/lib/network.mjs +7 -2
  52. package/lib/nudge.mjs +10 -2
  53. package/lib/onboard.mjs +430 -1
  54. package/lib/oneclawLocal.mjs +150 -0
  55. package/lib/ownMachines.mjs +521 -36
  56. package/lib/pairing.mjs +165 -0
  57. package/lib/paths.mjs +4 -0
  58. package/lib/phones.mjs +61 -0
  59. package/lib/placeCommands.mjs +27 -0
  60. package/lib/places.mjs +10 -2
  61. package/lib/plans.mjs +151 -27
  62. package/lib/profile.mjs +152 -0
  63. package/lib/projects.mjs +624 -137
  64. package/lib/readiness.mjs +283 -0
  65. package/lib/repoLinks.mjs +354 -0
  66. package/lib/roomChannels.mjs +641 -0
  67. package/lib/runBrief.mjs +32 -2
  68. package/lib/runRequests.mjs +157 -0
  69. package/lib/runWorker.mjs +20 -7
  70. package/lib/runner.mjs +67 -8
  71. package/lib/secretPatterns.json +55 -0
  72. package/lib/secrets.mjs +10 -27
  73. package/lib/seen.mjs +102 -0
  74. package/lib/service.mjs +11 -6
  75. package/lib/sessionControl.mjs +10 -8
  76. package/lib/sessionIndex.mjs +5 -3
  77. package/lib/store.mjs +546 -29
  78. package/lib/subagents.mjs +8 -4
  79. package/lib/swarm.mjs +367 -37
  80. package/lib/swarmMemory.mjs +947 -0
  81. package/lib/t3.mjs +43 -13
  82. package/lib/taskCommands.mjs +56 -5
  83. package/lib/taskRuns.mjs +61 -11
  84. package/lib/team.json +17 -15
  85. package/lib/team.mjs +68 -18
  86. package/lib/threadRuns.mjs +3 -1
  87. package/lib/threadView.mjs +51 -14
  88. package/lib/tokenizer.mjs +405 -0
  89. package/lib/ui.mjs +16 -2
  90. package/lib/usageTotals.mjs +148 -0
  91. package/lib/vault.mjs +1144 -0
  92. package/lib/vaultCloud.mjs +117 -0
  93. package/lib/vaultCommands.mjs +201 -0
  94. package/lib/vaultTools.d.ts +12 -0
  95. package/lib/vaultTools.js +42 -0
  96. package/lib/windowAsks.mjs +42 -0
  97. package/lib/workFocus.mjs +59 -0
  98. package/lib/workLinks.mjs +90 -0
  99. package/package.json +9 -4
package/lib/subagents.mjs CHANGED
@@ -93,7 +93,11 @@ const quote = (value) => `'${String(value).replace(/'/g, "''")}'`;
93
93
  * The subagents of one run: `{ id, parent, type, task, startedAt, endedAt, live, depth, steps }`, oldest first.
94
94
  * `parent` is the subagent that spawned it, or null for the run's own session. `now` is for tests.
95
95
  */
96
- export function createSubagents({ now = () => Date.now() } = {}) {
96
+ export function createSubagents({
97
+ now = () => Date.now(),
98
+ // Every value in the person's vault out of a subagent's steps (vault.mjs).
99
+ scrub = (value) => value,
100
+ } = {}) {
97
101
  // Finished subagents by file (or OpenCode session), and Claude Code's folder for each session.
98
102
  const done = new Map();
99
103
  const claudeFolders = new Map();
@@ -161,7 +165,7 @@ export function createSubagents({ now = () => Date.now() } = {}) {
161
165
  endedAt: open ? null : iso(mtime),
162
166
  live: open,
163
167
  depth: Number(meta.spawnDepth) || 1,
164
- steps: lastSteps(sessionFeed("claude-code", file, 40)),
168
+ steps: scrub(lastSteps(sessionFeed("claude-code", file, 40))),
165
169
  });
166
170
  });
167
171
  }
@@ -252,7 +256,7 @@ export function createSubagents({ now = () => Date.now() } = {}) {
252
256
  endedAt: open ? null : iso(mtime),
253
257
  live: open,
254
258
  depth: meta.depth,
255
- steps: lastSteps(sessionFeed("codex", file, 40)),
259
+ steps: scrub(lastSteps(sessionFeed("codex", file, 40))),
256
260
  });
257
261
  });
258
262
  }
@@ -299,7 +303,7 @@ export function createSubagents({ now = () => Date.now() } = {}) {
299
303
  endedAt: open ? null : iso(Number(row.time_updated)),
300
304
  live: open,
301
305
  depth: Number(row.depth) || 1,
302
- steps: lastSteps(steps),
306
+ steps: scrub(lastSteps(steps)),
303
307
  });
304
308
  });
305
309
  }
package/lib/swarm.mjs CHANGED
@@ -4,9 +4,19 @@ import path from "node:path";
4
4
  import { spawnSync } from "node:child_process";
5
5
  import { readRunSteps } from "./runner.mjs";
6
6
  import { createSubagents } from "./subagents.mjs";
7
- import { nameOf, resolveMember } from "./members.mjs";
8
- import { setNote, swarmBlock, swarmCards, swarmDigest } from "./cards.mjs";
7
+ import { MACHINE_RUNNERS, member, nameOf, resolveMember } from "./members.mjs";
8
+ import {
9
+ setNote,
10
+ setTier,
11
+ swarmBlock,
12
+ swarmCards,
13
+ swarmDigest,
14
+ youLine,
15
+ } from "./cards.mjs";
16
+ import { TIERS } from "./modelTiers.mjs";
9
17
  import { askOfRun } from "./threadView.mjs";
18
+ import { createWorkFocus } from "./workFocus.mjs";
19
+ import { createWorkLinks } from "./workLinks.mjs";
10
20
  import {
11
21
  DEFAULT_ROUTING,
12
22
  PICKABLE,
@@ -29,6 +39,12 @@ export const PROCESS_NAMES = {
29
39
  codex: "codex",
30
40
  pi: "pi",
31
41
  opencode: "opencode",
42
+ ...Object.fromEntries(
43
+ MACHINE_RUNNERS.filter((id) => member(id)?.runtime).map((id) => [
44
+ id,
45
+ member(id).runtime.command,
46
+ ])
47
+ ),
32
48
  };
33
49
  const SAY_LIMIT = 4_000;
34
50
  // `@swarm` in the person's message: written to their whole swarm, not to one agent.
@@ -83,6 +99,8 @@ export function agentProcessCwds(exclude = new Set()) {
83
99
 
84
100
  export function createSwarm({
85
101
  store,
102
+ // What this computer hands the person's Harness page through the extension (browserWake.mjs).
103
+ browserWake = null,
86
104
  roomAgents,
87
105
  mentionsIn,
88
106
  wakeFor,
@@ -96,8 +114,12 @@ export function createSwarm({
96
114
  coordinator,
97
115
  worktrees,
98
116
  roster,
117
+ // The coding agents here waiting to join the swarm, with their last check (readiness.mjs), for the person's browser.
118
+ joining = () => [],
99
119
  // Which of the person's computers each coding agent is on (actorRoster.mjs), when there are several.
100
120
  withMachines = (card) => card,
121
+ // Where an agent calling from a computer is (ownMachines.mjs whereIs), for what it is told of itself; null when unknown.
122
+ whereIs = () => null,
101
123
  authorizeRun,
102
124
  pickable,
103
125
  listModels,
@@ -112,6 +134,8 @@ export function createSwarm({
112
134
  // The person's post read for their reaction and for lessons (reactions.mjs, lessons.mjs), and what was learned.
113
135
  heardPerson = () => {},
114
136
  lessons = null,
137
+ // The swarm's long-running memory (swarmMemory.mjs): what swarm_memory recalls, and what the person forgets.
138
+ memory = null,
115
139
  // The subagents each run's own session spawned (subagents.mjs), for the thread's canvas.
116
140
  subagents = createSubagents(),
117
141
  // Work wired to wait for other work in the thread (plans.mjs).
@@ -122,7 +146,26 @@ export function createSwarm({
122
146
  projectOf = () => null,
123
147
  // The person's words name an agent of the other side of a shared project: theirs to answer, not this swarm's to sort.
124
148
  addressesPartner = () => false,
149
+ environments = null,
150
+ notifyFocus = () => {},
125
151
  }) {
152
+ const focus = createWorkFocus({ store });
153
+ const readWork = async (id, hostedCaller = false) => {
154
+ if (environments?.owns(id)) return environments.read(id);
155
+ const local = store.getTask(String(id || ""));
156
+ return local?.kind === "goal"
157
+ ? read(local, hostedCaller)
158
+ : { ok: false, error: "Work thread not found." };
159
+ };
160
+ const related = createWorkLinks({ store, readWork });
161
+ const linkedRevision = (id) => {
162
+ if (environments?.owns(id)) {
163
+ const source = environments.roots().find((entry) => entry.id === id);
164
+ return source ? focus.decorate(source).focus.revision : null;
165
+ }
166
+ const local = store.getTask(id);
167
+ return local?.kind === "goal" ? summary(local, false).focus.revision : null;
168
+ };
126
169
  // What the person let a thread spend of their Harness credits, in dollars, or null for no limit of its own.
127
170
  const ceilingOf = (threadId) => {
128
171
  const limit = Number(store.meta(`spend-ceiling:${threadId}`));
@@ -216,15 +259,18 @@ export function createSwarm({
216
259
  : null;
217
260
  };
218
261
 
219
- const summary = (thread) => {
262
+ const summary = (thread, includeRelated = true) => {
220
263
  const posts = store.roomPosts(thread.id, 0, 500);
221
264
  const runs = store.threadRuns(thread.id);
222
265
  const last = posts.at(-1);
223
266
  const live = runs.find((run) => run.status === "running");
224
267
  const step = live ? readRunSteps(runLog(live.id), 1)[0] : null;
225
268
  const view = threadView?.row(thread, posts) ?? null;
226
- return {
269
+ return focus.decorate({
227
270
  id: thread.id,
271
+ relatedVersion: includeRelated
272
+ ? related.version(thread.id, linkedRevision)
273
+ : null,
228
274
  title: view?.title ?? thread.objective,
229
275
  objective: thread.objective,
230
276
  // The same title, state, line and needs-you items on every surface (threadView.mjs).
@@ -303,7 +349,7 @@ export function createSwarm({
303
349
  changes: worktrees.summary(thread.id),
304
350
  // A project shared with another person's swarm (projects.mjs): which, and with whom.
305
351
  project: projectOf(thread.id),
306
- };
352
+ });
307
353
  };
308
354
 
309
355
  // The person's terminal sessions not yet in a thread, newest first, each saying whether it is still open there.
@@ -421,7 +467,7 @@ export function createSwarm({
421
467
  const posts = store.roomPosts(thread.id, 0, 500);
422
468
  return {
423
469
  ok: true,
424
- thread: summary(thread),
470
+ thread: summary(thread, !hostedCaller),
425
471
  posts,
426
472
  // The thread in order as the person reads it: messages, steps gathered into groups, files (threadView.mjs).
427
473
  timeline: threadView?.timeline(thread, posts) ?? [],
@@ -444,6 +490,8 @@ export function createSwarm({
444
490
 
445
491
  // `to`: the one agent the person wrote to (the desktop's agent list), so their words go as written, with no @name.
446
492
  const post = (thread, text, to = null) => {
493
+ if (projectOf(thread.id)?.status === "left")
494
+ return { ok: false, error: "Your participation in this room has ended." };
447
495
  const picked = picksIn(store, text, roomAgents);
448
496
  if (picked.error) return { ok: false, error: picked.error };
449
497
  // A new name in the person's message joins the thread.
@@ -482,7 +530,7 @@ export function createSwarm({
482
530
  return posted;
483
531
  };
484
532
 
485
- return function swarmCommand(request, agent) {
533
+ return function swarmCommand(request, agent, machine = null) {
486
534
  const command = String(request.command);
487
535
  if (command === "board.swarm.list") {
488
536
  if (agent !== "user" && agent !== "harness")
@@ -490,14 +538,181 @@ export function createSwarm({
490
538
  ok: false,
491
539
  error: "only the person and Harness read the swarm",
492
540
  };
493
- return {
541
+ const listed = () => ({
494
542
  ok: true,
495
- threads: store
496
- .goals({ all: request.all === true })
497
- .filter((thread) => !SETUP_CHECK.test(thread.objective))
498
- .map(summary),
543
+ threads: [
544
+ ...store
545
+ .goals({ all: request.all === true })
546
+ .filter((thread) => !SETUP_CHECK.test(thread.objective))
547
+ .map((thread) => summary(thread, !request.hostedCaller)),
548
+ ...(!request.hostedCaller
549
+ ? (environments?.roots() ?? []).map(focus.decorate)
550
+ : []),
551
+ ],
499
552
  sessions: request.sessions === false ? [] : sessions(),
500
553
  agents: roster(),
554
+ joining: request.hostedCaller ? [] : joining(),
555
+ });
556
+ return environments && !request.hostedCaller
557
+ ? { pending: environments.refresh().then(listed) }
558
+ : listed();
559
+ }
560
+ if (
561
+ [
562
+ "board.swarm.follow",
563
+ "board.swarm.seen",
564
+ "board.swarm.context",
565
+ "board.swarm.links",
566
+ "board.swarm.link",
567
+ ].includes(command)
568
+ ) {
569
+ if (
570
+ agent !== "user" ||
571
+ (request.hostedCaller &&
572
+ (environments?.owns(request.id) ||
573
+ environments?.owns(request.destination)))
574
+ )
575
+ return {
576
+ ok: false,
577
+ error: "Only the person manages their followed work and context.",
578
+ };
579
+ const perform = async () => {
580
+ if (["board.swarm.link", "board.swarm.links"].includes(command)) {
581
+ if (request.hostedCaller || environments?.owns(request.id))
582
+ return {
583
+ ok: false,
584
+ error:
585
+ "Manage related work on your computer or a browser linked to it.",
586
+ };
587
+ const target = store.getTask(String(request.id || ""));
588
+ if (target?.kind !== "goal")
589
+ return {
590
+ ok: false,
591
+ error: "Choose a Harness objective for this work.",
592
+ };
593
+ if (command === "board.swarm.links") return related.read(target.id);
594
+ const result = await related.update(request);
595
+ if (result.ok) notifyFocus(target.id);
596
+ return result;
597
+ }
598
+ const source = await readWork(
599
+ request.id,
600
+ request.hostedCaller === true
601
+ );
602
+ if (!source.ok) return source;
603
+ if (command !== "board.swarm.context") {
604
+ const result = focus.update(source.thread, request);
605
+ if (result.ok) notifyFocus(source.thread.id);
606
+ return result;
607
+ }
608
+ const selected = source.posts.find(
609
+ (entry) => entry.id === request.postId
610
+ );
611
+ if (
612
+ !selected ||
613
+ selected.author === "user" ||
614
+ !["result", "post"].includes(selected.kind)
615
+ )
616
+ return {
617
+ ok: false,
618
+ error: "Choose an agent's result from this work.",
619
+ };
620
+ if (request.destination === request.id)
621
+ return {
622
+ ok: false,
623
+ error: "Choose another work thread for this result.",
624
+ };
625
+ const target = await readWork(
626
+ request.destination,
627
+ request.hostedCaller === true
628
+ );
629
+ if (!target.ok) return target;
630
+ if (target.thread.project?.status === "left")
631
+ return {
632
+ ok: false,
633
+ error: "Your participation in this room has ended.",
634
+ };
635
+ if (target.thread.source && !target.thread.source.controls.send)
636
+ return {
637
+ ok: false,
638
+ error:
639
+ "The destination is read-only. Choose a thread you can message.",
640
+ };
641
+ const url = selected.source?.url ?? source.thread.source?.url ?? null;
642
+ const origin = source.thread.source?.environmentName ?? "Harness";
643
+ const attribution = `${nameOf(selected.author)} · ${origin} · ${source.thread.title}`;
644
+ const text = `Context from ${attribution}\n${url ?? `Harness thread: ${source.thread.id}`}\nRecorded ${selected.created_at}\n\n${selected.text}`;
645
+ if (text.length > 20_000)
646
+ return {
647
+ ok: false,
648
+ error:
649
+ "This result is too long for one message. Select a shorter result in its original session.",
650
+ };
651
+ return {
652
+ ok: true,
653
+ draft: {
654
+ text,
655
+ source: {
656
+ threadId: source.thread.id,
657
+ postId: selected.id,
658
+ author: selected.author,
659
+ url,
660
+ at: selected.created_at,
661
+ truncated: selected.source?.truncated === true,
662
+ },
663
+ },
664
+ destination: {
665
+ id: target.thread.id,
666
+ title: target.thread.title,
667
+ agents: target.thread.agents,
668
+ environment: target.thread.source?.environmentName ?? "Harness",
669
+ partner: target.thread.project?.partner ?? null,
670
+ },
671
+ };
672
+ };
673
+ return {
674
+ pending: perform().catch((error) => ({
675
+ ok: false,
676
+ error: error.message,
677
+ })),
678
+ };
679
+ }
680
+ if (environments?.owns(request.id)) {
681
+ if (request.hostedCaller || !["user", "harness"].includes(agent))
682
+ return {
683
+ ok: false,
684
+ error: "Outside sessions are private to the person.",
685
+ };
686
+ const pending = (operation) => ({
687
+ pending: operation.catch((error) => ({
688
+ ok: false,
689
+ error: error.message,
690
+ })),
691
+ });
692
+ if (command === "board.swarm.read")
693
+ return pending(
694
+ environments
695
+ .read(request.id)
696
+ .then((result) =>
697
+ result.ok
698
+ ? { ...result, thread: focus.decorate(result.thread) }
699
+ : result
700
+ )
701
+ );
702
+ if (command === "board.swarm.post" || command === "board.swarm.stop")
703
+ return pending(
704
+ environments.control(
705
+ {
706
+ ...request,
707
+ action: command === "board.swarm.stop" ? "stop" : "send",
708
+ },
709
+ agent
710
+ )
711
+ );
712
+ return {
713
+ ok: false,
714
+ error:
715
+ "This work belongs to its source environment. Open its original session for this action.",
501
716
  };
502
717
  }
503
718
  // The swarm's shared memory, for any of the person's agents: what any agent wrote in any thread, and the coding
@@ -507,26 +722,35 @@ export function createSwarm({
507
722
  .trim()
508
723
  .slice(0, 500);
509
724
  if (!query) return { ok: false, error: "search needs a query" };
510
- const mine = request.teamOnly
511
- ? store
512
- .goals({ all: true })
513
- .filter((thread) => thread.goal.team.includes(agent))
514
- .map((thread) => thread.id)
515
- : null;
725
+ const hosted = Boolean(request.teamOnly) || request.hostedCaller === true;
726
+ const sessions = hosted ? [] : store.search({ query, limit: 5 });
727
+ if (!memory)
728
+ return { ok: true, threads: [], sessions, lessons: [], weak: true };
516
729
  return {
517
- ok: true,
518
- threads: store.searchThreads(query, { goalIds: mine, k: 8 }),
519
- sessions: request.teamOnly ? [] : store.search({ query, limit: 5 }),
520
- // What the person told the swarm (lessons.mjs), to a caller on this computer.
521
- lessons:
522
- request.teamOnly || request.hostedCaller === true
523
- ? []
524
- : store.lessonsMatching(query, 5).map((lesson) => ({
525
- about: lesson.about,
526
- agent: lesson.agent,
527
- text: lesson.text,
528
- quote: lesson.evidence.at(-1)?.quote ?? null,
529
- })),
730
+ pending: memory
731
+ .recall(query, {
732
+ agent,
733
+ teamOnly: Boolean(request.teamOnly),
734
+ hosted,
735
+ everyFolder: true,
736
+ })
737
+ .then((found) => ({
738
+ ok: true,
739
+ // Posts, job results and receipts with their thread, author and time; a receipt is checked by code.
740
+ threads: found.posts,
741
+ sessions,
742
+ // What the person told the swarm, and what the dream keeps, to a caller on this computer.
743
+ lessons: found.lessons,
744
+ observations: found.observations,
745
+ // What the person saw (seen.mjs), when the person searches.
746
+ ...(found.seen?.length ? { seen: found.seen } : {}),
747
+ weak: found.weak,
748
+ ...(found.weak
749
+ ? {
750
+ note: "Nothing closely matches: these are only the nearest. Say it was not found rather than relying on them.",
751
+ }
752
+ : {}),
753
+ })),
530
754
  };
531
755
  }
532
756
  // Who can be asked: every other agent's card (cards.mjs), and the same cards as the block an agent is told when its
@@ -540,10 +764,14 @@ export function createSwarm({
540
764
  { lessons: local }
541
765
  ).map(withMachines);
542
766
  const told = local ? (lessons?.told() ?? []) : [];
767
+ // Who is asking, and on which computer, ahead of everyone else.
768
+ const you = local ? youLine(agent, whereIs(machine)) : "";
543
769
  return {
544
770
  ok: true,
545
771
  agents,
546
- text: swarmBlock(agents, Date.now(), told),
772
+ text: [you, swarmBlock(agents, Date.now(), told)]
773
+ .filter(Boolean)
774
+ .join("\n\n"),
547
775
  digest: swarmDigest(agents, told),
548
776
  };
549
777
  }
@@ -588,7 +816,7 @@ export function createSwarm({
588
816
  });
589
817
  // Harness's catalog is read the first time it is shown, once the server can send it.
590
818
  return request.refresh === true && agent === "user"
591
- ? { pending: listModels().then(listing) }
819
+ ? { pending: listModels({ protocols: true }).then(listing) }
592
820
  : !named && !harnessModel.listed() && agent === "user"
593
821
  ? { pending: harnessModel.refresh().then(listing) }
594
822
  : listing();
@@ -643,6 +871,7 @@ export function createSwarm({
643
871
  kind: "post",
644
872
  text,
645
873
  mentions: addressed(store.getTask(thread.id), text),
874
+ machine,
646
875
  });
647
876
  wakeFor(thread.id, first, agent);
648
877
  notifyBoard(store.getTask(thread.id));
@@ -718,6 +947,26 @@ export function createSwarm({
718
947
  note: setNote(store, named.id, request.text),
719
948
  };
720
949
  }
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") {
953
+ 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
+ return {
958
+ ok: false,
959
+ error: named.candidates.length
960
+ ? `"${request.target}" could be ${named.candidates.join(" or ")}; name one`
961
+ : `no agent called "${request.target}"`,
962
+ };
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 };
969
+ }
721
970
  // The person's choice of model and effort for one agent: a model it lists, "auto", or "default" for its own settings.
722
971
  if (command === "board.swarm.model") {
723
972
  const named = resolveMember(request.target);
@@ -889,7 +1138,12 @@ export function createSwarm({
889
1138
  ok: true,
890
1139
  lessons: (
891
1140
  lessons?.list({
892
- status: request.replaced === true ? "replaced" : "active",
1141
+ status:
1142
+ request.retired === true
1143
+ ? "retired"
1144
+ : request.replaced === true
1145
+ ? "replaced"
1146
+ : "active",
893
1147
  }) ?? []
894
1148
  ).map((lesson) => {
895
1149
  const last = lesson.evidence.at(-1);
@@ -916,9 +1170,17 @@ export function createSwarm({
916
1170
  };
917
1171
  if (command === "board.swarm.lessons.remove") {
918
1172
  const removed = lessons?.remove(request.id);
919
- return removed
920
- ? { ok: true, lesson: removed }
921
- : { ok: false, error: "no lesson starts with that id" };
1173
+ if (!removed)
1174
+ return { ok: false, error: "no lesson starts with that id" };
1175
+ // 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.
1177
+ memory?.forget({
1178
+ ids: removed.evidence.map((entry) => entry.postId).filter(Boolean),
1179
+ mode: "release",
1180
+ by: `lesson:${removed.id}`,
1181
+ reason: "the person took the lesson out",
1182
+ });
1183
+ return { ok: true, lesson: removed };
922
1184
  }
923
1185
  if (command === "board.swarm.lessons.undo")
924
1186
  return {
@@ -947,6 +1209,43 @@ export function createSwarm({
947
1209
  }
948
1210
  ),
949
1211
  };
1212
+ // The swarm's memory (swarmMemory.mjs), the person's: what the dream keeps, what was forgotten or replaced and the
1213
+ // last dream; forgetting posts, lessons or observations by id, Undo, and a dream now.
1214
+ if (command === "board.swarm.memory")
1215
+ return {
1216
+ ok: true,
1217
+ observations: memory?.observations() ?? [],
1218
+ seen: memory?.seen() ?? [],
1219
+ forgotten: store.memoryMarks(),
1220
+ dream: memory?.lastDream() ?? null,
1221
+ };
1222
+ if (command === "board.swarm.forget") {
1223
+ const mode = request.mode === "purge" ? "purge" : "release";
1224
+ const forgotten =
1225
+ memory?.forget({
1226
+ ids: Array.isArray(request.ids) ? request.ids.map(String) : [],
1227
+ mode,
1228
+ by: "user",
1229
+ reason: request.reason ? String(request.reason).slice(0, 200) : null,
1230
+ }) ?? [];
1231
+ return forgotten.length
1232
+ ? { ok: true, forgotten }
1233
+ : { ok: false, error: "nothing with those ids to forget" };
1234
+ }
1235
+ if (command === "board.swarm.unforget") {
1236
+ const back = memory?.unforget(String(request.id || ""));
1237
+ return back
1238
+ ? { ok: true, back }
1239
+ : {
1240
+ ok: false,
1241
+ error:
1242
+ "nothing to bring back with that id (deleted words are gone for good)",
1243
+ };
1244
+ }
1245
+ if (command === "board.swarm.dream")
1246
+ return memory
1247
+ ? { pending: memory.dream() }
1248
+ : { ok: false, error: "this daemon keeps no memory" };
950
1249
  // Check-ins (schedules.mjs), the person's: only the person gets this far, and the lead sets its own in its rounds
951
1250
  // (coordinator.mjs). Every thread's, or ending one by its own id.
952
1251
  if (command === "board.swarm.checkins" && !request.id)
@@ -1049,6 +1348,32 @@ export function createSwarm({
1049
1348
  ? { ok: true, thread: summary(store.getTask(thread.id)) }
1050
1349
  : done;
1051
1350
  }
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.
1353
+ if (command === "board.swarm.use_browser") {
1354
+ if (agent !== "user")
1355
+ return { ok: false, error: "only you let Harness use your browser" };
1356
+ const run = store
1357
+ .threadRuns(thread.id)
1358
+ .find((candidate) => candidate.id === String(request.runId || ""));
1359
+ if (
1360
+ !run ||
1361
+ run.target_agent !== "harness" ||
1362
+ run.status !== "open" ||
1363
+ !store.meta(`harness-window:${run.id}`)
1364
+ )
1365
+ return { ok: false, error: "that is not waiting for your browser" };
1366
+ if (!browserWake?.listening())
1367
+ return {
1368
+ ok: false,
1369
+ error:
1370
+ "your browser is not connected to this computer; open Harness on your computer instead",
1371
+ };
1372
+ store.meta(`harness-browser-allowed:${run.id}`, new Date().toISOString());
1373
+ browserWake.send({ kind: "board-task", task: run.id });
1374
+ notifyBoard(store.getTask(thread.id));
1375
+ return { ok: true, thread: summary(store.getTask(thread.id)) };
1376
+ }
1052
1377
  // The person's Start for one run in the thread that waits for it.
1053
1378
  if (command === "board.swarm.start_run") {
1054
1379
  const run = store
@@ -1189,6 +1514,11 @@ export function createSwarm({
1189
1514
  return { ok: true, thread: summary(store.getTask(thread.id)) };
1190
1515
  }
1191
1516
  if (command === "board.swarm.resume") {
1517
+ if (projectOf(thread.id)?.status === "left")
1518
+ return {
1519
+ ok: false,
1520
+ error: "Your participation in this room has ended.",
1521
+ };
1192
1522
  if (thread.status !== "paused")
1193
1523
  return { ok: false, error: `the thread is ${thread.status}` };
1194
1524
  store.setGoalState(thread.id, { status: "open" });