tryharness 0.7.82 → 0.7.86

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 (216) hide show
  1. package/README.md +21 -19
  2. package/assets/dsh-plugin.mjs +75 -4
  3. package/assets/herdr-mod/harness/main.js +367 -0
  4. package/assets/herdr-mod/harness/mod.json +6 -0
  5. package/assets/opencode-plugin.js +87 -22
  6. package/assets/pi-extension.ts +81 -2
  7. package/cli.mjs +544 -208
  8. package/lib/adapters.mjs +62 -27
  9. package/lib/agentBinaries.mjs +6 -8
  10. package/lib/agentClaims.mjs +168 -0
  11. package/lib/agentReadTools.json +415 -0
  12. package/lib/agentSignIn.mjs +17 -18
  13. package/lib/agentWiring.mjs +114 -0
  14. package/lib/archetypes.js +10 -11
  15. package/lib/attention.mjs +100 -0
  16. package/lib/audit.mjs +1 -1
  17. package/lib/backupSetup.mjs +6 -28
  18. package/lib/bankrApprovals.mjs +86 -0
  19. package/lib/boardAccess.mjs +40 -66
  20. package/lib/boardBackup.mjs +86 -85
  21. package/lib/boardCommands.mjs +28 -0
  22. package/lib/boardFileCommands.mjs +29 -36
  23. package/lib/boardFiles.mjs +83 -15
  24. package/lib/boardMirror.mjs +78 -11
  25. package/lib/boardProtocol.json +193 -123
  26. package/lib/boardThreads.mjs +19 -37
  27. package/lib/boardTools.mjs +22 -15
  28. package/lib/boardWatches.mjs +43 -15
  29. package/lib/bridge.mjs +7 -3
  30. package/lib/browserAgentTools.mjs +59 -0
  31. package/lib/browserWake.mjs +0 -6
  32. package/lib/cards.mjs +57 -2
  33. package/lib/circling.mjs +189 -0
  34. package/lib/cleanup.mjs +234 -0
  35. package/lib/cloudBoot.mjs +21 -4
  36. package/lib/cloudSave.mjs +46 -5
  37. package/lib/compaction.mjs +8 -1
  38. package/lib/completion.mjs +358 -0
  39. package/lib/computerDevices.mjs +853 -0
  40. package/lib/connectionStatus.mjs +34 -0
  41. package/lib/connectors.mjs +139 -1
  42. package/lib/coordinator.mjs +108 -14
  43. package/lib/coreModels.mjs +36 -12
  44. package/lib/daemon.mjs +2435 -333
  45. package/lib/daemonLock.mjs +103 -0
  46. package/lib/deviceDoor.mjs +308 -0
  47. package/lib/deviceIdentity.mjs +114 -0
  48. package/lib/deviceList.mjs +172 -0
  49. package/lib/deviceSeal.mjs +74 -0
  50. package/lib/dispatcher.mjs +497 -26
  51. package/lib/dispatches.mjs +3 -3
  52. package/lib/environment.mjs +2 -1
  53. package/lib/environments.mjs +67 -41
  54. package/lib/events.mjs +318 -0
  55. package/lib/facts.mjs +170 -0
  56. package/lib/fileSource.mjs +540 -0
  57. package/lib/files.mjs +47 -2
  58. package/lib/gitHost.mjs +39 -1
  59. package/lib/goalCommands.mjs +12 -80
  60. package/lib/handover.mjs +21 -16
  61. package/lib/harnessOffers.mjs +140 -15
  62. package/lib/herdr.mjs +100 -15
  63. package/lib/herdrAppCall.mjs +19 -0
  64. package/lib/herdrCore.mjs +59 -0
  65. package/lib/herdrRuns.mjs +1126 -0
  66. package/lib/hookDialects.mjs +235 -50
  67. package/lib/identityLink.mjs +81 -0
  68. package/lib/inference.mjs +31 -2
  69. package/lib/jamAccess.mjs +82 -0
  70. package/lib/{projectBoard.mjs → jamBoard.mjs} +5 -4
  71. package/lib/{projectGit.mjs → jamGit.mjs} +53 -15
  72. package/lib/jamKey.mjs +274 -0
  73. package/lib/{projectPieces.mjs → jamPieces.mjs} +35 -29
  74. package/lib/{projectSettings.mjs → jamSettings.mjs} +12 -22
  75. package/lib/jamStore.mjs +973 -0
  76. package/lib/jamUpgrade.mjs +112 -0
  77. package/lib/jams.mjs +3079 -0
  78. package/lib/kanban.mjs +13 -7
  79. package/lib/landed.mjs +5 -1
  80. package/lib/library.mjs +41 -22
  81. package/lib/limits.mjs +91 -0
  82. package/lib/lineDiff.mjs +97 -0
  83. package/lib/lineup.mjs +18 -13
  84. package/lib/link.mjs +584 -0
  85. package/lib/localStack.mjs +75 -16
  86. package/lib/localmodels.mjs +58 -78
  87. package/lib/loopBackstop.mjs +2 -1
  88. package/lib/machine.mjs +544 -0
  89. package/lib/machineLink.mjs +446 -0
  90. package/lib/machineRoutes.mjs +68 -19
  91. package/lib/machineRuns.mjs +85 -4
  92. package/lib/machineSeal.mjs +6 -31
  93. package/lib/manager.mjs +134 -12
  94. package/lib/mcp-stdio.mjs +492 -215
  95. package/lib/mcpRelay.mjs +34 -35
  96. package/lib/members.json +2 -2
  97. package/lib/modelRoute.mjs +162 -0
  98. package/lib/nativeHost.mjs +81 -90
  99. package/lib/nativeSenses.mjs +258 -0
  100. package/lib/nerves.mjs +523 -0
  101. package/lib/network.mjs +117 -278
  102. package/lib/networkPlaces.mjs +578 -0
  103. package/lib/nextStep.mjs +95 -0
  104. package/lib/notify.mjs +2 -2
  105. package/lib/nudge.mjs +116 -10
  106. package/lib/onboard.mjs +6 -6
  107. package/lib/originals.mjs +216 -0
  108. package/lib/outsideEvents.mjs +383 -0
  109. package/lib/outsideRuns.mjs +230 -0
  110. package/lib/ownMachines.mjs +674 -256
  111. package/lib/pain.mjs +215 -0
  112. package/lib/pairing.mjs +91 -11
  113. package/lib/paths.mjs +42 -3
  114. package/lib/peerProcess.mjs +21 -7
  115. package/lib/peopleLink.mjs +268 -0
  116. package/lib/personNotices.mjs +3 -2
  117. package/lib/phones.mjs +252 -542
  118. package/lib/placeCards.mjs +282 -0
  119. package/lib/placeChecks.mjs +95 -0
  120. package/lib/placeCommands.mjs +8 -17
  121. package/lib/placeRequests.mjs +152 -0
  122. package/lib/placeStore.mjs +295 -0
  123. package/lib/placeTool.d.ts +12 -0
  124. package/lib/placeTool.js +40 -0
  125. package/lib/places.mjs +63 -14
  126. package/lib/plans.mjs +53 -8
  127. package/lib/presence.mjs +270 -0
  128. package/lib/privateNetwork.d.ts +2 -0
  129. package/lib/privateNetwork.js +93 -0
  130. package/lib/proposals.mjs +300 -0
  131. package/lib/publicFetch.d.ts +32 -0
  132. package/lib/publicFetch.js +248 -0
  133. package/lib/reach.mjs +128 -0
  134. package/lib/rebuildable.mjs +72 -0
  135. package/lib/recall.mjs +216 -0
  136. package/lib/record.mjs +13 -0
  137. package/lib/reflexes.mjs +392 -0
  138. package/lib/relayLimits.mjs +31 -2
  139. package/lib/releaseNotice.mjs +198 -0
  140. package/lib/removeHarness.mjs +15 -4
  141. package/lib/repoLinks.mjs +204 -35
  142. package/lib/runAuthority.mjs +102 -39
  143. package/lib/runBrief.mjs +93 -40
  144. package/lib/runRequests.mjs +52 -14
  145. package/lib/runUsage.mjs +31 -0
  146. package/lib/runWorker.mjs +74 -25
  147. package/lib/runner.mjs +289 -45
  148. package/lib/runtime-install.mjs +37 -8
  149. package/lib/schedules.mjs +171 -47
  150. package/lib/screenWatches.mjs +221 -0
  151. package/lib/sealed.mjs +12 -30
  152. package/lib/sealedThreads.mjs +198 -392
  153. package/lib/secretStore.mjs +178 -0
  154. package/lib/secrets.mjs +11 -0
  155. package/lib/seen.mjs +3 -9
  156. package/lib/selfUpdate.mjs +51 -15
  157. package/lib/senseCall.mjs +1514 -0
  158. package/lib/senseHook.mjs +114 -0
  159. package/lib/senseTools.mjs +1298 -0
  160. package/lib/sessionBriefs.mjs +87 -0
  161. package/lib/sessionControl.mjs +63 -13
  162. package/lib/sessionFiles.mjs +85 -0
  163. package/lib/setupChoices.mjs +12 -3
  164. package/lib/setupMode.mjs +70 -25
  165. package/lib/sharedKeys.mjs +166 -0
  166. package/lib/sleep.mjs +396 -0
  167. package/lib/sources.mjs +306 -0
  168. package/lib/speech.mjs +166 -411
  169. package/lib/spoken.mjs +210 -0
  170. package/lib/steerHook.mjs +3 -1
  171. package/lib/steerQueue.mjs +40 -11
  172. package/lib/store.mjs +323 -130
  173. package/lib/stuck.mjs +85 -7
  174. package/lib/swarm.mjs +157 -49
  175. package/lib/swarmDevices.mjs +25 -85
  176. package/lib/swarmMemory.mjs +93 -9
  177. package/lib/t3.mjs +73 -3
  178. package/lib/taskCommands.mjs +51 -60
  179. package/lib/taskRooms.mjs +30 -4
  180. package/lib/taskRules.json +29 -0
  181. package/lib/taskRules.mjs +21 -0
  182. package/lib/taskRuns.mjs +74 -11
  183. package/lib/team.mjs +2 -1
  184. package/lib/threadActions.mjs +37 -9
  185. package/lib/threadAuthority.mjs +4 -4
  186. package/lib/threadBriefs.mjs +173 -43
  187. package/lib/threadNotes.mjs +320 -0
  188. package/lib/threadRecord.mjs +491 -0
  189. package/lib/threadRuns.mjs +216 -108
  190. package/lib/threadView.mjs +27 -30
  191. package/lib/threadWatches.mjs +1962 -0
  192. package/lib/timeSense.mjs +839 -0
  193. package/lib/tripwires.mjs +454 -0
  194. package/lib/ui.mjs +1 -1
  195. package/lib/vault.mjs +560 -45
  196. package/lib/vaultCommands.mjs +5 -3
  197. package/lib/vaultPeers.mjs +165 -0
  198. package/lib/vaultTools.d.ts +4 -1
  199. package/lib/vaultTools.js +22 -1
  200. package/lib/verdicts.mjs +12 -26
  201. package/lib/versions.mjs +117 -0
  202. package/lib/waitTool.mjs +278 -0
  203. package/lib/wakePicture.mjs +268 -0
  204. package/lib/wakeQueue.mjs +108 -0
  205. package/lib/watchResponses.mjs +533 -0
  206. package/lib/watches.mjs +290 -145
  207. package/lib/windowAsks.mjs +80 -17
  208. package/lib/worktrees.mjs +159 -9
  209. package/npm-shrinkwrap.json +138 -631
  210. package/package.json +7 -6
  211. package/release.json +212 -130
  212. package/lib/callSessions.mjs +0 -51
  213. package/lib/directLink.mjs +0 -349
  214. package/lib/peopleBoard.mjs +0 -131
  215. package/lib/projects.mjs +0 -2917
  216. package/lib/roomChannels.mjs +0 -667
package/lib/stuck.mjs CHANGED
@@ -6,7 +6,9 @@ import { isSetupCheck } from "./handoffs.mjs";
6
6
  // is kept per task and kind (board meta `stuck-findings`), reported once, and let go when the condition goes away, so a
7
7
  // restart neither repeats one nor forgets it. Only the agents' own posts and status changes count as the work moving;
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
- // belongs (daemon.mjs): in the thread and to its coordinator, or to whoever posted loose work.
9
+ // belongs (daemon.mjs): in the thread and to its coordinator, or to whoever posted loose work. Each finding is on the log
10
+ // too, once when found and once when cleared (docs/senses-plan.md S3.6), so an agent woken in the thread reads it in
11
+ // its picture (wakePicture.mjs); the log's line names no task, since a task's words are someone's.
10
12
  //
11
13
  // The thresholds, from one real board (a read-only copy; 60 threads, 373 tasks and wakes):
12
14
  // - Pickup (claimMs, droppedMs): 367 pickups, from posting (or the person's Start) to claim: p50 0, p90 3.4, p95 11.2,
@@ -37,7 +39,11 @@ const latest = (times) =>
37
39
  times.filter(Boolean).reduce((a, b) => (a > b ? a : b), null);
38
40
 
39
41
  /** What a finding says, in the thread or to whoever posted the work. */
40
- function lineFor({ kind, task, agent, since }, at) {
42
+ // A run waiting on a command Harness knows: what that command usually takes (timeSense.mjs).
43
+ const usualWords = (usualMs) =>
44
+ usualMs ? `; its command usually takes ${minutes(usualMs)} min` : "";
45
+
46
+ function lineFor({ kind, task, agent, since, usualMs }, at) {
41
47
  const who = nameOf(agent);
42
48
  const waited = minutes(at - Date.parse(since));
43
49
  const turn = task.kind === "wake";
@@ -47,7 +53,7 @@ function lineFor({ kind, task, agent, since }, at) {
47
53
  ? `${who} hasn't started its turn here after ${waited} min.`
48
54
  : `${who} hasn't picked up ${quoted} after ${waited} min.`;
49
55
  if (kind === "no_step")
50
- return `${who}'s turn${turn ? " here" : ` on ${quoted}`} has shown no new step for ${waited} min.`;
56
+ return `${who}'s turn${turn ? " here" : ` on ${quoted}`} has shown no new step for ${waited} min${usualWords(usualMs)}.`;
51
57
  if (kind === "lease")
52
58
  return `${who} took ${quoted} and stopped checking in ${waited} min ago.`;
53
59
  if (kind === "unanswered")
@@ -55,14 +61,46 @@ function lineFor({ kind, task, agent, since }, at) {
55
61
  return `${who}'s turn ended ${waited} min ago while it still holds ${quoted}.`;
56
62
  }
57
63
 
64
+ /** What the log says of a finding: who and how long, never the task's words. */
65
+ function logLineFor({ kind, task, agent, since, usualMs }, at) {
66
+ const who = nameOf(agent);
67
+ const waited = minutes(at - Date.parse(since));
68
+ const turn = task.kind === "wake";
69
+ if (kind === "unclaimed")
70
+ return turn
71
+ ? `${who} hasn't started its turn here after ${waited} min`
72
+ : `${who} hasn't picked up a task after ${waited} min`;
73
+ if (kind === "no_step")
74
+ return `${who}'s turn${turn ? " here" : ""} has shown no new step for ${waited} min${usualWords(usualMs)}`;
75
+ if (kind === "lease")
76
+ return `${who} took a task and stopped checking in ${waited} min ago`;
77
+ if (kind === "unanswered")
78
+ return `a question has waited ${waited} min for ${agent === "user" ? "the person's answer" : `${who}'s answer`}`;
79
+ return `${who}'s turn ended ${waited} min ago while it still holds a task`;
80
+ }
81
+
82
+ /** What the log says as a finding clears. */
83
+ const CLEARED = {
84
+ unclaimed: (who, turn) =>
85
+ turn ? `${who} started its turn here` : `${who} picked up the task`,
86
+ no_step: (who, turn) => `${who}'s turn${turn ? " here" : ""} moved again`,
87
+ lease: (who) => `${who}'s task is no longer past its lease`,
88
+ unanswered: () => "the question no longer waits",
89
+ dropped: (who) => `${who} no longer holds the task`,
90
+ };
91
+
58
92
  /**
59
93
  * `lastStepAt(taskId)`: when a run last took a step (its run record), or null. `report(finding)` says a new finding:
60
- * { key, kind, agent, since, task, thread (null outside one), text }.
94
+ * { key, kind, agent, since, task, thread (null outside one), text }. `events`: the log.
61
95
  */
62
96
  export function createStuck({
63
97
  store,
64
98
  lastStepAt,
65
99
  report,
100
+ events = null,
101
+ // `usualOf(task)`: when a run is waiting on a command Harness knows, how long to wait for it (`ms`, sooner than the
102
+ // flat threshold only) and what it usually takes (`usualMs`); null otherwise.
103
+ usualOf = () => null,
66
104
  log = () => {},
67
105
  thresholds = STUCK_THRESHOLDS,
68
106
  now = Date.now,
@@ -124,8 +162,20 @@ export function createStuck({
124
162
  }
125
163
  if (task.status === "running") {
126
164
  const last = lastStepAt(task.id) ?? task.claimed_at ?? task.updated_at;
127
- return waited(last, thresholds.stepMs, at)
128
- ? { kind: "no_step", agent: task.claimed_by, since: last }
165
+ // The usual only tightens: 30 minutes stays for everything Harness has no usual for (owner, November 14).
166
+ const usual = usualOf(task);
167
+ const limit = usual
168
+ ? Math.min(thresholds.stepMs, usual.ms)
169
+ : thresholds.stepMs;
170
+ return waited(last, limit, at)
171
+ ? {
172
+ kind: "no_step",
173
+ agent: task.claimed_by,
174
+ since: last,
175
+ ...(usual && usual.ms < thresholds.stepMs
176
+ ? { usualMs: usual.usualMs }
177
+ : {}),
178
+ }
129
179
  : null;
130
180
  }
131
181
  if (task.status === "needs_input") {
@@ -180,9 +230,37 @@ export function createStuck({
180
230
  // Kept before it is said, so the board change a report makes finds it already reported.
181
231
  if (fresh.length || cleared.length)
182
232
  store.meta(FINDINGS_KEY, JSON.stringify(found));
183
- for (const key of cleared) log(`stuck: cleared ${key}`);
233
+ for (const key of cleared) {
234
+ log(`stuck: cleared ${key}`);
235
+ const was = before[key];
236
+ const turn = store.getTask(was.taskId)?.kind === "wake";
237
+ events?.append({
238
+ source: "stuck",
239
+ kind: "cleared",
240
+ subject: `task:${was.taskId}`,
241
+ text: (CLEARED[was.kind] ?? CLEARED.dropped)(nameOf(was.agent), turn),
242
+ data: {
243
+ what: was.kind,
244
+ agent: was.agent,
245
+ task: was.taskId,
246
+ thread: was.thread,
247
+ },
248
+ });
249
+ }
184
250
  for (const finding of fresh) {
185
251
  log(`stuck: ${finding.key}`);
252
+ events?.append({
253
+ source: "stuck",
254
+ kind: "found",
255
+ subject: `task:${finding.task.id}`,
256
+ text: logLineFor(finding, at),
257
+ data: {
258
+ what: finding.kind,
259
+ agent: finding.agent,
260
+ task: finding.task.id,
261
+ thread: finding.thread,
262
+ },
263
+ });
186
264
  report(finding);
187
265
  }
188
266
  return { reported: fresh.map((f) => f.key), cleared };
package/lib/swarm.mjs CHANGED
@@ -2,8 +2,10 @@ import { randomUUID } from "node:crypto";
2
2
  import fs from "node:fs";
3
3
  import os from "node:os";
4
4
  import path from "node:path";
5
+ import { fromCloud } from "./machineRoutes.mjs";
5
6
  import { kept } from "./kept.mjs";
6
7
  import { readRunSteps } from "./runner.mjs";
8
+ import { maskSecrets } from "./secrets.mjs";
7
9
  import { createSubagents } from "./subagents.mjs";
8
10
  import {
9
11
  DISPATCHER,
@@ -162,11 +164,21 @@ export function agentProcessCwds(exclude = new Set()) {
162
164
  return cwds;
163
165
  }
164
166
 
167
+ // A conversation going with a person's message (`board.swarm.start`), as the file it becomes on the thread.
168
+ const conversationFile = (given) => {
169
+ if (!given || typeof given.data !== "string" || !given.data) return null;
170
+ const words = Buffer.from(given.data, "base64").toString("utf8");
171
+ return {
172
+ name: String(given.name || "conversation.md"),
173
+ data: Buffer.from(maskSecrets(words)).toString("base64"),
174
+ };
175
+ };
176
+
165
177
  export function createSwarm({
166
178
  landed = null,
167
179
  store,
168
- // What this computer hands the person's Harness page through the extension (browserWake.mjs).
169
- browserWake = null,
180
+ // The board's file commands (boardFileCommands.mjs).
181
+ fileCommand,
170
182
  roomAgents,
171
183
  mentionsIn,
172
184
  wakeFor,
@@ -213,6 +225,8 @@ export function createSwarm({
213
225
  lessons = null,
214
226
  // The swarm's long-running memory (swarmMemory.mjs): what swarm_memory recalls, and what the person forgets.
215
227
  memory = null,
228
+ // What sleep proposes (proposals.mjs, S8.4): the person's to start or dismiss.
229
+ proposals = null,
216
230
  // The subagents each run's own session spawned (subagents.mjs), for the thread's canvas.
217
231
  subagents = createSubagents(),
218
232
  // Work wired to wait for other work in the thread (plans.mjs).
@@ -221,10 +235,13 @@ export function createSwarm({
221
235
  boardOf = () => [],
222
236
  // The thread as the person reads it on every surface (threadView.mjs).
223
237
  threadView = null,
224
- // The project a thread is the room of, shared with another person's swarm (projects.mjs).
225
- projectOf = () => null,
226
- // The person's words name an agent of the other side of a shared project: theirs to answer, not this swarm's to sort.
227
- addressesPartner = () => false,
238
+ // The thread's record (threadRecord.mjs): what Harness did and noticed there, a few lines, for its ··· to open.
239
+ recordOf = () => [],
240
+ // The project a thread is the room of, shared with another person's swarm (jams.mjs).
241
+ // The jam a thread is the room of (jams.mjs roomInfo), or null.
242
+ jamOf = () => null,
243
+ // The person's words name only other people in a jam or their agents: theirs to answer, not this swarm's to sort.
244
+ addressesAnotherPerson = () => false,
228
245
  environments = null,
229
246
  // Work from another tool taken over as a Harness thread (adoption.mjs).
230
247
  adoption = null,
@@ -386,6 +403,8 @@ export function createSwarm({
386
403
  // The task this room was opened for, when it is a task's own room.
387
404
  root: store.meta(`task-room:${thread.id}`) || null,
388
405
  folder: thread.goal.workspace,
406
+ // The Herdr space its agents' turns run in (herdrRuns.mjs), for a Herdr panel to go to.
407
+ herdrSpace: store.meta(`herdr-space:${thread.id}`) || null,
389
408
  // The folder on another of the person's computers it works in instead, with that computer.
390
409
  folderOn: folderOnOf(thread.id),
391
410
  working: [
@@ -418,6 +437,23 @@ export function createSwarm({
418
437
  }
419
438
  : null,
420
439
  waiting: waitingOn(thread, posts, runs),
440
+ // The person's newest words here: the swarm's voice confirms each once (desktop harness/swarmVoice.ts).
441
+ personAt:
442
+ posts.findLast((post) => post.author === "user")?.created_at ?? null,
443
+ // What an agent last said to the person, which the board's own notes and answer may follow within a second: the swarm's
444
+ // voice reads it in a conversation by voice. A post calling on another agent is not for the person.
445
+ answer: (() => {
446
+ const said = posts.findLast(
447
+ (post) =>
448
+ post.kind === "post" &&
449
+ post.author !== "user" &&
450
+ post.author !== thread.goal.facilitator &&
451
+ !(Array.isArray(post.mentions) ? post.mentions : []).some(
452
+ (agent) => agent !== post.author && agent !== "user"
453
+ )
454
+ );
455
+ return said ? { seq: said.seq, at: said.created_at } : null;
456
+ })(),
421
457
  last: last
422
458
  ? {
423
459
  author: last.author,
@@ -460,8 +496,8 @@ export function createSwarm({
460
496
  changes: worktrees.summary(thread.id),
461
497
  // Whether it made anything that can land: its Landed view shows then (landed.mjs).
462
498
  landed: landed?.produced(thread, posts) ?? false,
463
- // A project shared with another person's swarm (projects.mjs): which, and with whom.
464
- project: projectOf(thread.id),
499
+ // The jam this thread is the room of (jams.mjs): which, and who else is in it.
500
+ jam: jamOf(thread.id),
465
501
  });
466
502
  };
467
503
 
@@ -598,7 +634,12 @@ export function createSwarm({
598
634
  };
599
635
 
600
636
  const read = (thread, hostedCaller = false) => {
601
- const runs = store.threadRuns(thread.id).map((run) => ({
637
+ // A run is an agent's: a task no agent was named for and none has taken yet is a card on the thread's board until
638
+ // one takes it (every reader draws a run under its agent's name).
639
+ const owned = store
640
+ .threadRuns(thread.id)
641
+ .filter((run) => run.claimed_by || run.target_agent);
642
+ const runs = owned.map((run) => ({
602
643
  id: run.id,
603
644
  agent: run.claimed_by || run.target_agent,
604
645
  ...askOf(run),
@@ -643,6 +684,8 @@ export function createSwarm({
643
684
  runs,
644
685
  plans: hostedCaller ? [] : plansOf(thread.id),
645
686
  board: boardOf(thread.id),
687
+ // It names files and commands on this computer: never for a hosted caller.
688
+ record: hostedCaller ? [] : recordOf(thread.id),
646
689
  // Posts held for the person (who wrote one, when, never its words), and the post that replaced each one an agent
647
690
  // posted again.
648
691
  held: store.heldPosts(thread.id).map((post) => ({
@@ -658,7 +701,7 @@ export function createSwarm({
658
701
 
659
702
  // `to`: the one agent the person wrote to (the desktop's agent list), so their words go as written, with no @name.
660
703
  const post = (thread, text, to = null) => {
661
- if (projectOf(thread.id)?.status === "left")
704
+ if (jamOf(thread.id) && jamOf(thread.id).status !== "open")
662
705
  return { ok: false, error: "Your participation in this room has ended." };
663
706
  const picked = picksIn(store, text, roomAgents);
664
707
  if (picked.error) return { ok: false, error: picked.error };
@@ -671,6 +714,8 @@ export function createSwarm({
671
714
  if (thread.status !== "open") {
672
715
  store.setGoalState(thread.id, { status: "open" });
673
716
  goals?.reopen(thread.id);
717
+ // A one-time check-in held while the thread was paused runs now.
718
+ schedules?.tick();
674
719
  store.roomPost({
675
720
  goalId: thread.id,
676
721
  author: "user",
@@ -692,7 +737,7 @@ export function createSwarm({
692
737
  !to &&
693
738
  posted?.ok &&
694
739
  !posted.paused &&
695
- !addressesPartner(thread.id, text)
740
+ !addressesAnotherPerson(thread.id, text)
696
741
  )
697
742
  heardBy(current, posted.post, text);
698
743
  return posted;
@@ -955,7 +1000,7 @@ export function createSwarm({
955
1000
  request.hostedCaller === true
956
1001
  );
957
1002
  if (!target.ok) return target;
958
- if (target.thread.project?.status === "left")
1003
+ if (target.thread.jam && target.thread.jam.status !== "open")
959
1004
  return {
960
1005
  ok: false,
961
1006
  error: "Your participation in this room has ended.",
@@ -994,7 +1039,7 @@ export function createSwarm({
994
1039
  title: target.thread.title,
995
1040
  agents: target.thread.agents,
996
1041
  environment: target.thread.source?.environmentName ?? "Harness",
997
- partner: target.thread.project?.partner ?? null,
1042
+ people: target.thread.jam?.people ?? null,
998
1043
  },
999
1044
  };
1000
1045
  };
@@ -1076,7 +1121,11 @@ export function createSwarm({
1076
1121
  .slice(0, 500);
1077
1122
  if (!query) return { ok: false, error: "search needs a query" };
1078
1123
  const thread = request.thread ? String(request.thread) : null;
1079
- const hosted = Boolean(request.teamOnly) || request.hostedCaller === true;
1124
+ // An agent on a cloud computer Harness runs for the person asks as a hosted agent does through Harness's server:
1125
+ // only the threads it is in, never this computer's sessions, whatever its call says.
1126
+ const teamOnly =
1127
+ request.teamOnly === true || fromCloud(store, request) === true;
1128
+ const hosted = teamOnly || request.hostedCaller === true;
1080
1129
  const sessions =
1081
1130
  hosted || thread ? [] : store.search({ query, limit: 5 });
1082
1131
  if (!memory)
@@ -1085,7 +1134,7 @@ export function createSwarm({
1085
1134
  pending: memory
1086
1135
  .recall(query, {
1087
1136
  agent,
1088
- teamOnly: Boolean(request.teamOnly),
1137
+ teamOnly,
1089
1138
  thread,
1090
1139
  hosted,
1091
1140
  everyFolder: true,
@@ -1212,10 +1261,18 @@ export function createSwarm({
1212
1261
  .find(Boolean)
1213
1262
  .replace(/@([a-z][a-z0-9-]*)(:\S+)?\s*/g, "")
1214
1263
  .slice(0, 120) || text.slice(0, 120);
1264
+ // Words another agent wrote reach a thread Harness starts as that agent's (what Harness sent from above it can
1265
+ // only tighten the label), as they reach a task Harness posts (taskCommands.mjs).
1266
+ const claimed =
1267
+ request.provenance &&
1268
+ typeof request.provenance === "object" &&
1269
+ request.provenance.trust === "agent"
1270
+ ? request.provenance
1271
+ : null;
1215
1272
  const thread = store.createGoal({
1216
1273
  objective,
1217
1274
  originAgent: agent,
1218
- provenance: provenanceFor(agent, null, null, {
1275
+ provenance: provenanceFor(agent, claimed, null, {
1219
1276
  viaServer: request.hostedCaller === true,
1220
1277
  }),
1221
1278
  // The dispatcher facilitates (owner, November 1: "facilitator is dispatcher"); Harness joins like any agent, when
@@ -1616,6 +1673,20 @@ export function createSwarm({
1616
1673
  team.add(agentName);
1617
1674
  folder ??= isDir(session.cwd) ? session.cwd : null;
1618
1675
  }
1676
+ // The conversation the words were written in: its secrets masked here, and kept off the agents on Harness's side.
1677
+ const carried = conversationFile(request.conversation);
1678
+ // Words sending every coding agent to another computer: this computer's folders mean nothing to it, and the pick
1679
+ // held the agent back 16 s (owner, November 5). That computer works in its own scratch folder.
1680
+ const allElsewhere =
1681
+ !folder &&
1682
+ !folderOn &&
1683
+ team.size > 0 &&
1684
+ [...team]
1685
+ .filter((name) => PROCESS_NAMES[name])
1686
+ .every((name) => {
1687
+ const named = address.forAgent(name)?.id ?? null;
1688
+ return Boolean(named) && named !== here();
1689
+ });
1619
1690
  // Where the work happens: the folder the person chose, else one picked from what they wrote, else where its agent
1620
1691
  // last worked (folders.mjs); never the home folder or a hidden one.
1621
1692
  const begin = (where) => {
@@ -1650,9 +1721,21 @@ export function createSwarm({
1650
1721
  goalId: thread.id,
1651
1722
  author: "user",
1652
1723
  kind: "post",
1653
- text,
1724
+ text: carried ? `${text}\n\n(Attached ${carried.name}.)` : text,
1654
1725
  mentions: addressed(store.getTask(thread.id), text),
1655
1726
  });
1727
+ // On the thread before any agent hears of it, so what it names is there when the agent looks.
1728
+ if (carried)
1729
+ fileCommand(
1730
+ {
1731
+ command: "board.file.add",
1732
+ name: carried.name,
1733
+ mime: "text/markdown",
1734
+ data: carried.data,
1735
+ cloud: false,
1736
+ },
1737
+ { agent: "user", id: thread.id, machine: here() }
1738
+ );
1656
1739
  return { id: thread.id, first };
1657
1740
  };
1658
1741
  const hear = ({ id, first }) => {
@@ -1665,7 +1748,7 @@ export function createSwarm({
1665
1748
  notifyBoard(store.getTask(id));
1666
1749
  return { ok: true, thread: summary(store.getTask(id)) };
1667
1750
  };
1668
- if (folder || noFolder || !needsFolder([...team])) {
1751
+ if (folder || noFolder || !needsFolder([...team]) || allElsewhere) {
1669
1752
  const thread = begin(folder);
1670
1753
  hear(thread);
1671
1754
  return started(thread);
@@ -1773,14 +1856,65 @@ export function createSwarm({
1773
1856
  };
1774
1857
  // The swarm's memory (swarmMemory.mjs), the person's: what the dream keeps, what was forgotten or replaced and the
1775
1858
  // last dream; forgetting posts, lessons or observations by id, Undo, and a dream now.
1776
- if (command === "board.swarm.memory")
1859
+ if (command === "board.swarm.memory") {
1860
+ const dream = memory?.lastDream() ?? null;
1777
1861
  return {
1778
1862
  ok: true,
1779
- observations: memory?.observations() ?? [],
1863
+ // Each belief with where it came from as the person reads it: the thread's title and who wrote its post.
1864
+ observations: (memory?.observations() ?? []).map((observation) => ({
1865
+ ...observation,
1866
+ threadTitle: observation.thread
1867
+ ? (store.getTask(observation.thread)?.objective ?? null)
1868
+ : null,
1869
+ from: observation.sources.length
1870
+ ? (store.getContribution(observation.sources.at(-1))?.author ??
1871
+ null)
1872
+ : null,
1873
+ })),
1780
1874
  seen: memory?.seen() ?? [],
1781
1875
  forgotten: store.memoryMarks(),
1782
- dream: memory?.lastDream() ?? null,
1876
+ dream: dream
1877
+ ? {
1878
+ ...dream,
1879
+ undone: Boolean(store.meta(`dream-undone:${dream.at}`)),
1880
+ }
1881
+ : null,
1783
1882
  };
1883
+ }
1884
+ // What sleep proposes, replayed on the record; each runs only once the person starts it (S8.4).
1885
+ if (command === "board.swarm.proposals")
1886
+ return { ok: true, proposals: proposals?.list() ?? [] };
1887
+ if (
1888
+ command === "board.swarm.proposals.start" ||
1889
+ command === "board.swarm.proposals.dismiss"
1890
+ ) {
1891
+ const done = command.endsWith(".start")
1892
+ ? proposals?.start(String(request.id || ""))
1893
+ : proposals?.dismiss(String(request.id || ""));
1894
+ return done
1895
+ ? { ok: true, proposal: done }
1896
+ : {
1897
+ ok: false,
1898
+ error: "there is no such proposal, or it can no longer run",
1899
+ };
1900
+ }
1901
+ // The person undoes everything one dream wrote, or puts a belief in their own words (S8.3).
1902
+ if (command === "board.swarm.memory.undo") {
1903
+ const undone = memory?.undoDream(request.dream) ?? null;
1904
+ return undone
1905
+ ? { ok: true, ...undone }
1906
+ : { ok: false, error: "that dream wrote nothing to undo" };
1907
+ }
1908
+ if (command === "board.swarm.memory.correct") {
1909
+ const corrected = memory?.correct(request.id, request.text) ?? null;
1910
+ return corrected
1911
+ ? { ok: true, observation: corrected }
1912
+ : {
1913
+ ok: false,
1914
+ error:
1915
+ "no belief in the work has that id, or the new words are empty",
1916
+ };
1917
+ }
1784
1918
  if (command === "board.swarm.forget") {
1785
1919
  const mode = request.mode === "purge" ? "purge" : "release";
1786
1920
  const forgotten =
@@ -1903,7 +2037,7 @@ export function createSwarm({
1903
2037
  kind: "note",
1904
2038
  text:
1905
2039
  command === "board.swarm.merge"
1906
- ? `Merged into ${done.into}.`
2040
+ ? `Merged into ${done.into}.${done.left ? ` ${done.left.files} file${done.left.files === 1 ? "" : "s"} never committed stay in ${done.left.path} (${done.left.named.join(", ")}${done.left.files > done.left.named.length ? ", ..." : ""}): Harness leaves them for you.` : ""}`
1907
2041
  : "Discarded this thread's changes.",
1908
2042
  });
1909
2043
  else if (done.conflict)
@@ -1918,32 +2052,6 @@ export function createSwarm({
1918
2052
  ? { ok: true, thread: summary(store.getTask(thread.id)) }
1919
2053
  : done;
1920
2054
  }
1921
- // The person lets Harness finish in their browser now what it left for the browser, right away, even while they are
1922
- // away: their extension's hidden Harness page takes it, claiming it only once this is recorded.
1923
- if (command === "board.swarm.use_browser") {
1924
- if (agent !== "user")
1925
- return { ok: false, error: "only you let Harness use your browser" };
1926
- const run = store
1927
- .threadRuns(thread.id)
1928
- .find((candidate) => candidate.id === String(request.runId || ""));
1929
- if (
1930
- !run ||
1931
- run.target_agent !== "harness" ||
1932
- run.status !== "open" ||
1933
- !store.meta(`harness-window:${run.id}`)
1934
- )
1935
- return { ok: false, error: "that is not waiting for your browser" };
1936
- if (!browserWake?.listening())
1937
- return {
1938
- ok: false,
1939
- error:
1940
- "your browser is not connected to this computer; open Harness on your computer instead",
1941
- };
1942
- store.meta(`harness-browser-allowed:${run.id}`, new Date().toISOString());
1943
- browserWake.send({ kind: "board-task", task: run.id });
1944
- notifyBoard(store.getTask(thread.id));
1945
- return { ok: true, thread: summary(store.getTask(thread.id)) };
1946
- }
1947
2055
  // The person's Start for one run in the thread that waits for it.
1948
2056
  if (command === "board.swarm.start_run") {
1949
2057
  const run = store
@@ -2084,7 +2192,7 @@ export function createSwarm({
2084
2192
  return { ok: true, thread: summary(store.getTask(thread.id)) };
2085
2193
  }
2086
2194
  if (command === "board.swarm.resume") {
2087
- if (projectOf(thread.id)?.status === "left")
2195
+ if (jamOf(thread.id) && jamOf(thread.id).status !== "open")
2088
2196
  return {
2089
2197
  ok: false,
2090
2198
  error: "Your participation in this room has ended.",