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
@@ -0,0 +1,116 @@
1
+ import { askLocal } from "./personModel.mjs";
2
+
3
+ // The line that puts the person back into a thread at a glance, answering "what was the last thing I said here",
4
+ // which a title is too lossy to: their last move, in their own words, and what it was about.
5
+ // "go ahead and deploy" → "deploy DeepSeek support".
6
+ //
7
+ // Most of what a person last says in a thread answers the agent ("yes", "commit this"), and agents end by asking them
8
+ // to decide something. So agents name it in a last line, `Deciding: deploy DeepSeek support` (mcp-stdio.mjs's
9
+ // instructions), and a short reply right after one is about that. A longer message is a new ask or a steer: the
10
+ // person's own local model names its work, when they have one (personModel.mjs). With neither, the thread's title says
11
+ // what it is about. Worked out once per message and kept, never while the person waits.
12
+
13
+ /** A reply this short answers what the agent asked rather than saying something new. */
14
+ const SHORT_WORDS = 8;
15
+ /** What is kept of a move or what it was about. */
16
+ const MOVE_CHARS = 60;
17
+ const ABOUT_CHARS = 80;
18
+
19
+ const NAME_WORK = `You label a message a person sent to an AI agent, so that weeks later they recognize the thread at a glance.
20
+ Reply with JSON only: {"move": "...", "object": "..."}.
21
+ - move: 1 to 3 words for what the person asked for, in their own word when they used one (look into, fix, build, write, remake, deep dive). A question: "asked".
22
+ - object: 2 to 6 words naming the work: the feature, bug, decision or document. Never mechanics: no file counts, "the change", "this", "it".
23
+ Lowercase except names. No sentences. Think briefly.`;
24
+
25
+ const tidy = (text) =>
26
+ String(text ?? "")
27
+ .replace(/\s+/g, " ")
28
+ .trim();
29
+ const words = (text) => tidy(text).split(" ").filter(Boolean);
30
+ const cut = (text, limit) => {
31
+ const clean = tidy(text);
32
+ if (clean.length <= limit) return clean;
33
+ const end = clean.lastIndexOf(" ", limit - 1);
34
+ return `${clean.slice(0, end > limit / 2 ? end : limit - 1)}…`;
35
+ };
36
+
37
+ /** What an agent's message asks the person to decide: its last `Deciding:` line, or null. */
38
+ export function decidingOf(text) {
39
+ const lines = String(text ?? "").split("\n");
40
+ for (let i = lines.length - 1; i >= 0; i--) {
41
+ const said = /^\s*[*_]*deciding:[*_]*\s*(.+?)\s*$/i.exec(lines[i]);
42
+ if (!said) continue;
43
+ const named = said[1].replace(/^[`*_"]+|[`*_".]+$/g, "").trim();
44
+ return named ? cut(named, ABOUT_CHARS) : null;
45
+ }
46
+ return null;
47
+ }
48
+
49
+ /**
50
+ * `store` keeps each thread's line by the message it was made from. `nameWork(message)`, when given, names a longer
51
+ * message's work ({ move, object } or null); by default the person's local model does.
52
+ */
53
+ export function createThreadLine({
54
+ store,
55
+ log = () => {},
56
+ nameWork = (message) => askLocal(NAME_WORK, message),
57
+ }) {
58
+ const kept = (key) => {
59
+ try {
60
+ return JSON.parse(store.meta(`thread-line:${key}`) || "null");
61
+ } catch {
62
+ return null;
63
+ }
64
+ };
65
+ // One label at a time: the local model runs on the person's computer.
66
+ let queue = Promise.resolve();
67
+
68
+ async function lineOf({ title, mine, answered }) {
69
+ const at = mine.at ?? null;
70
+ if (words(mine.text).length <= SHORT_WORDS) {
71
+ const asked = decidingOf(answered);
72
+ return {
73
+ move: cut(mine.text, MOVE_CHARS),
74
+ about: asked ?? cut(title, ABOUT_CHARS),
75
+ by: asked ? "agent" : "title",
76
+ at,
77
+ };
78
+ }
79
+ const named = await nameWork(cut(mine.text, 1500)).catch(() => null);
80
+ if (named?.move && named?.object)
81
+ return {
82
+ move: cut(named.move, MOVE_CHARS),
83
+ about: cut(named.object, ABOUT_CHARS),
84
+ by: "model",
85
+ at,
86
+ };
87
+ return {
88
+ move: `${words(mine.text).slice(0, 4).join(" ")}…`,
89
+ about: cut(title, ABOUT_CHARS),
90
+ by: "title",
91
+ at,
92
+ };
93
+ }
94
+
95
+ return {
96
+ /** The thread's line, as last worked out, or null. */
97
+ of: (key) => kept(key)?.line ?? null,
98
+ /**
99
+ * Works out the thread's line from the person's last message (`mine`: id, text, at) and the agent's message before
100
+ * it (`answered`, its text), unless it was already made from that message. Resolves to whether it changed.
101
+ */
102
+ update(key, { title, mine, answered = null }) {
103
+ const next = queue.then(async () => {
104
+ if (kept(key)?.message === mine.id) return false;
105
+ const line = await lineOf({ title, mine, answered });
106
+ store.meta(
107
+ `thread-line:${key}`,
108
+ JSON.stringify({ message: mine.id, line })
109
+ );
110
+ return true;
111
+ });
112
+ queue = next.catch((error) => log(`thread line: ${error.message}`));
113
+ return next.catch(() => false);
114
+ },
115
+ };
116
+ }
@@ -4,8 +4,10 @@ import { randomUUID } from "node:crypto";
4
4
  import { MEMBERS, nameOf } from "./members.mjs";
5
5
  import { oneLine } from "./oneLine.mjs";
6
6
  import { setRunPick } from "./models.mjs";
7
- import { t3Access, startT3SignIn, steerT3Run } from "./t3.mjs";
7
+ import { t3Access, steerT3Run } from "./t3.mjs";
8
8
  import { t3Model, t3Open, t3Project, t3Provider } from "./places.mjs";
9
+ import { within } from "./folders.mjs";
10
+ import { namedFiles } from "./worktrees.mjs";
9
11
 
10
12
  // The agents with a read-only switch (runner.mjs): only they talk out a clash in a shared project without waiting.
11
13
  const REVIEWERS = new Set(
@@ -31,6 +33,12 @@ export function createThreadRuns({
31
33
  placeElsewhere = () => null,
32
34
  // Projects shared with another person's swarm (projects.mjs): their check before work, and each agent's own branch.
33
35
  projects = () => null,
36
+ // The step of the thread's route an agent was last given (team.mjs), or null.
37
+ stepHeld = () => null,
38
+ verdicts = null,
39
+ // Stops a run in progress where it runs: on this computer, or on the one that took it (a sealed notice from home).
40
+ // Whether it was stopping.
41
+ stopRun = () => false,
34
42
  }) {
35
43
  const { RUNNERS } = authority;
36
44
  const inT3 = (thread, agent, review) => {
@@ -68,18 +76,32 @@ export function createThreadRuns({
68
76
  ? { in: "t3", why: null }
69
77
  : { in: "here", why: gap };
70
78
  };
71
- // A task's own run (its room's first job) goes where its room's turns go: into T3 Code when the person uses the agent
72
- // there. Not when it would run restricted (work another agent asked for on a goal's authority): only this computer
73
- // holds a run to that.
79
+ // Whether a task works in its thread's folder: the thread's repository, or Harness's copy of it where the agent that
80
+ // handed the work on was running.
81
+ const inThreadFolder = (task, room) => {
82
+ const folder = path.resolve(task.run_workspace);
83
+ const copy = worktrees.get(room.id)?.path;
84
+ return (
85
+ within(folder, room.goal.workspace) ||
86
+ Boolean(copy && within(folder, copy))
87
+ );
88
+ };
89
+ // A task's run goes where its room's turns go: into T3 Code when the person uses the agent there. That is the room's
90
+ // first job, and work an agent handed on into a thread in that thread's folder, a turn of the agent there like any
91
+ // other: it opens where the person uses that agent most. Not when it would run restricted (work another agent asked
92
+ // for on a goal's authority): only this computer holds a run to that. Nor in a shared project, whose agents work on
93
+ // their own branches here.
74
94
  const taskInT3 = (task, agent) => {
75
95
  const room = task.parent_id ? store.getTask(task.parent_id) : null;
76
96
  if (
77
97
  task.kind !== "task" ||
78
98
  room?.kind !== "goal" ||
79
- store.meta(`task-room:${room.id}`) !== task.id ||
80
- !task.run_workspace
99
+ !task.run_workspace ||
100
+ projects()?.isProjectRoom(room.id)
81
101
  )
82
102
  return false;
103
+ const ownJob = store.meta(`task-room:${room.id}`) === task.id;
104
+ if (!ownJob && !inThreadFolder(task, room)) return false;
83
105
  const restricted =
84
106
  task.trust !== "user" &&
85
107
  task.run_authorized_by === "goal" &&
@@ -117,7 +139,7 @@ export function createThreadRuns({
117
139
  };
118
140
  };
119
141
  // A turn that ran outside T3 Code because T3 did not answer: the thread hears it, and the agent's next turn in T3 is
120
- // told what its T3 thread did not see, so the thread goes back to T3 with nothing lost (owner, October 15).
142
+ // told what its T3 thread did not see, so the thread goes back to T3 with nothing lost.
121
143
  const ranOutsideT3 = new Set();
122
144
  const t3Missed = (runId, why) => {
123
145
  ranOutsideT3.add(runId);
@@ -170,52 +192,108 @@ export function createThreadRuns({
170
192
  store.meta("pending-wake:" + key, "");
171
193
  },
172
194
  };
173
- const discard = (goalId) => {
174
- for (const agent of RUNNERS) pendingWakes.delete(goalId + ":" + agent);
195
+ // Another person's agent or the person themselves, by their address ("igor/codex"); the person's own agents are named
196
+ // without one. A turn such an ask brings runs on this person's own agent settings only (runWorker.mjs).
197
+ const fromAnotherPerson = (asker) => String(asker ?? "").includes("/");
198
+ // `only`: one agent's waiting turns, as when its piece of a shared project is released.
199
+ const discard = (goalId, only = null) => {
200
+ for (const agent of only ? [only] : RUNNERS)
201
+ pendingWakes.delete(goalId + ":" + agent);
175
202
  };
176
203
  // go: the person's go for this turn (personsGo), their own post naming this agent or one of their agents here asking;
177
- // any other wake is work another agent asked for and runs restricted or waits (docs/member-runs.md).
204
+ // any other wake is work another agent asked for and runs restricted or waits.
178
205
  // asker: who asked for this turn, the person or an agent, named on the card that waits for the person.
179
206
  // pick: the model and effort the post named for this turn (models.mjs).
180
- // The person's words to an agent already at work in the thread reach its turn when T3 Code carries it: T3 steers them
181
- // in at the agent's next step, and the wake kept for them is dropped. A run started on this computer has no way in,
182
- // so the agent reads them when its turn ends (the pending wake). Either way the thread says which happened.
207
+ // The person's words to an agent already at work in the thread are a steer (owner, October 25), from any surface: a
208
+ // thread post in PiP or on the phone, `tryharness steer` here or over SSH on a cloud computer. A turn T3 Code carries
209
+ // takes them live: T3 steers them in at the agent's next step, and the wake kept for them is dropped. Any other run,
210
+ // here or on another of the person's computers, has no way in while it runs, so with the person's go it is stopped
211
+ // where it is and the wake kept for the words goes on from there, in the same session. Without their go it reads
212
+ // them when its turn ends. The thread says which happened; the note is also what the steer's caller is told.
213
+ const steers = new Map();
183
214
  const steerRunning = (goalId, agent, words, pending) => {
215
+ // The agent's turn that does the work, before a read-only review of its own beside it.
184
216
  const running = store
185
217
  .threadRuns(goalId)
186
- .find((run) => run.target_agent === agent && run.status === "running");
218
+ .filter((run) => run.target_agent === agent && run.status === "running")
219
+ .sort(
220
+ (a, b) =>
221
+ Number(store.meta(`review:${a.id}`) === "1") -
222
+ Number(store.meta(`review:${b.id}`) === "1")
223
+ )[0];
187
224
  if (!running) return;
188
225
  const who = nameOf(agent);
189
226
  const note = (text) => {
190
227
  store.roomPost({ goalId, author: "harness", kind: "note", text });
191
228
  notifyBoard(store.getTask(goalId));
229
+ return text;
192
230
  };
193
- if (store.meta(`t3-run:${running.id}`) !== "1") {
194
- note(
195
- `${who} reads your message when its current turn ends: a run started on this computer cannot take messages mid-turn.`
196
- );
197
- return;
198
- }
231
+ const told =
232
+ store.meta(`t3-run:${running.id}`) === "1"
233
+ ? steerT3(goalId, agent, words, pending, running).then(note)
234
+ : Promise.resolve(note(stopToSteer(running, pending, who)));
235
+ // Kept only until the call that sent the words reads it, which it does as it sends them (board.swarm.steer).
236
+ const key = `${goalId}:${agent}`;
237
+ steers.set(key, told);
238
+ void told.then(() => {
239
+ if (steers.get(key) === told) steers.delete(key);
240
+ });
241
+ };
242
+ const steerT3 = async (goalId, agent, words, pending, running) => {
243
+ const who = nameOf(agent);
199
244
  const thread = store.getTask(goalId);
200
- void steerT3Run(
245
+ const delivery = await steerT3Run(
201
246
  running.id,
202
247
  `The person just wrote in the thread "${oneLine(thread.objective)}" while you work:\n\n${words}\n\nTake it into account in what you are doing now.`
203
- ).then((delivery) => {
204
- if (!delivery) {
205
- note(`${who} reads your message when its current turn ends.`);
206
- return;
207
- }
208
- if (pendingWakes.get(`${goalId}:${agent}`)?.id === pending.id)
209
- pendingWakes.delete(`${goalId}:${agent}`);
210
- note(
211
- delivery === "restarted"
212
- ? `${who} restarted its turn to take your message.`
213
- : `${who} has your message and reads it at its next step.`
214
- );
215
- });
248
+ );
249
+ if (!delivery)
250
+ return `${who} reads your message when its current turn ends.`;
251
+ if (pendingWakes.get(`${goalId}:${agent}`)?.id === pending.id)
252
+ pendingWakes.delete(`${goalId}:${agent}`);
253
+ return delivery === "restarted"
254
+ ? `${who} restarted its turn to take your message.`
255
+ : `${who} has your message and reads it at its next step.`;
256
+ };
257
+ // Marked before it is stopped: its end comes back as a failure, which the thread is not told (settleWake), and the
258
+ // turn after goes on in its session wherever it ran (resumeAfterSteer).
259
+ const stopToSteer = (running, pending, who) => {
260
+ if (!pending.go)
261
+ return `${who} reads your message when its current turn ends.`;
262
+ store.meta(`steered:${running.id}`, pending.id);
263
+ if (stopRun(running))
264
+ return `${who} stopped where it was to take your message, and goes on from there with it.`;
265
+ store.meta(`steered:${running.id}`, "");
266
+ return `${who} reads your message when its current turn ends.`;
267
+ };
268
+ /** What the steer just made of the person's words to `agent` in the thread, for whoever sent them; once. */
269
+ const steered = (goalId, agent) => {
270
+ const told = steers.get(`${goalId}:${agent}`) ?? null;
271
+ steers.delete(`${goalId}:${agent}`);
272
+ return told;
273
+ };
274
+ /**
275
+ * On home: the session a thread's turn on another computer goes on in, when the turn before it there was stopped by
276
+ * the person's steer; null otherwise (a worker's turns start afresh from the thread's brief).
277
+ */
278
+ const resumeAfterSteer = (wake, machine) => {
279
+ const before = store
280
+ .threadRuns(wake.parent_id)
281
+ .filter(
282
+ (run) =>
283
+ run.id !== wake.id &&
284
+ run.target_agent === wake.target_agent &&
285
+ run.created_at <= wake.created_at
286
+ )
287
+ .sort((a, b) => b.created_at.localeCompare(a.created_at))[0];
288
+ return before &&
289
+ before.claimed_machine === machine &&
290
+ before.session_id &&
291
+ store.meta(`steered:${before.id}`)
292
+ ? before.session_id
293
+ : null;
216
294
  };
217
295
  // The person's go reaches a turn another agent's ask left waiting for their Start, so it starts now rather than
218
- // after a turn that would never come (October 17: Grok Bot's mention held Claude Code in the person's own folder, and
296
+ // after a turn that would never come (Grok Bot's mention once held Claude Code in the person's own folder, and
219
297
  // their @claude-code queued behind it). The pending call stays, so the turn's brief carries the person's words.
220
298
  const startHeldWake = (goalId, agent) => {
221
299
  const wake = store.getTask(store.openWake(goalId, agent));
@@ -272,6 +350,8 @@ export function createThreadRuns({
272
350
  return;
273
351
  }
274
352
  if (store.openWake(goalId, agent)) {
353
+ if (fromAnotherPerson(asker))
354
+ store.meta(`other-person-run:${store.openWake(goalId, agent)}`, "1");
275
355
  const prior = pendingWakes.get(`${goalId}:${agent}`);
276
356
  // Words the guard flagged keep the next turn waiting for the person, whatever go an earlier call carried; the
277
357
  // person's own call is their go.
@@ -306,12 +386,16 @@ export function createThreadRuns({
306
386
  return (
307
387
  shared.gate(
308
388
  { task, agent, reason, asker, go, mode: null, words },
309
- (mode, override = null) =>
389
+ // `hold`: the run waits for the person's Start whatever its mode (another person asked for it). A review
390
+ // carries only the go its ask had: a review another person's words started never runs on this person's go.
391
+ (mode, override = null, hold = false) =>
310
392
  wakeAgent(goalId, agent, override ?? reason, {
311
393
  review: review || (mode === "review" && REVIEWERS.has(agent)),
312
- go: mode === "review" ? REVIEWERS.has(agent) : go,
394
+ go: mode === "review" ? REVIEWERS.has(agent) && go : go,
313
395
  wait:
314
- mode === "wait" || (mode === "review" && !REVIEWERS.has(agent)),
396
+ hold ||
397
+ mode === "wait" ||
398
+ (mode === "review" && !REVIEWERS.has(agent)),
315
399
  asker,
316
400
  pick,
317
401
  words,
@@ -372,6 +456,8 @@ export function createThreadRuns({
372
456
  targetMachine: elsewhere?.machine ?? null,
373
457
  });
374
458
  if (t3) store.meta(`t3-run:${wake.id}`, "1");
459
+ if (fromAnotherPerson(asker))
460
+ store.meta(`other-person-run:${wake.id}`, "1");
375
461
  store.meta(
376
462
  `wake-reason:${wake.id}`,
377
463
  JSON.stringify({ reason, review, asker })
@@ -402,8 +488,8 @@ export function createThreadRuns({
402
488
  return wake.id;
403
489
  };
404
490
  // A wake's brief as of its start, not of when it was queued: a turn that waited for the folder reads the thread as it
405
- // is now, with a call that came while it waited (October 17: Codex, queued at 07:29, started at 07:39 on a brief
406
- // without Claude Code's 07:38 handoff, and settleWake dropped the handoff's own wake as already read).
491
+ // is now, with a call that came while it waited (once Codex, queued at 07:29, started at 07:39 on a brief without
492
+ // Claude Code's 07:38 handoff, and settleWake dropped the handoff's own wake as already read).
407
493
  const wakeBrief = (wake) => {
408
494
  const thread = store.getTask(wake.parent_id);
409
495
  let woken = null;
@@ -438,7 +524,7 @@ export function createThreadRuns({
438
524
  const key = `overlap:${[goalId, other.id].sort().join(":")}:${shared.join(",")}`;
439
525
  if (!shared.length || store.meta(key)) continue;
440
526
  store.meta(key, "1");
441
- const named = `${shared.slice(0, 5).join(", ")}${shared.length > 5 ? ` and ${shared.length - 5} more` : ""}`;
527
+ const named = namedFiles(shared);
442
528
  for (const [here, there] of [
443
529
  [goalId, other],
444
530
  [other.id, store.getTask(goalId)],
@@ -453,16 +539,83 @@ export function createThreadRuns({
453
539
  }
454
540
  }
455
541
  };
456
- // The turn's changes are committed in its thread's copy as soon as it ends, before another run can start there.
457
- // A shared project's agent commits on its own branch (projects.mjs); it is undefined for any other thread.
458
- const commitWake = (task) => {
542
+ // A run that may change its thread's copy: every turn woken there, and work handed on as a task into that copy. A
543
+ // review runs read-only (runner.mjs) beside whoever writes there, so what it would commit is never its own.
544
+ const inThreadCopy = (task) => {
545
+ const thread = task.parent_id ? store.getTask(task.parent_id) : null;
546
+ if (thread?.kind !== "goal" || !task.run_workspace) return false;
547
+ if (store.meta(`review:${task.id}`) === "1") return false;
548
+ if (task.kind === "wake") return true;
549
+ const copy = worktrees.get(thread.id)?.path;
550
+ return Boolean(copy && within(path.resolve(task.run_workspace), copy));
551
+ };
552
+ const startTurn = (task) => {
553
+ verdicts?.started(task);
554
+ if (inThreadCopy(task)) worktrees.startTurn(task.parent_id, task.id);
555
+ };
556
+ // For code, made means committed on the thread's branch: a run's changes in its thread's copy are committed as soon
557
+ // as it ends, whatever kind of run it was, before another run can start there. A shared project's agent commits on
558
+ // its own branch (projects.mjs, undefined for any other thread).
559
+ const commitRun = (task) => {
560
+ if (store.meta(`review:${task.id}`) === "1") return null;
459
561
  const onBranch = projects()?.committed(task);
460
- if (onBranch !== undefined) return onBranch;
461
- return worktrees.commitTurn(
562
+ if (onBranch !== undefined) {
563
+ verdicts?.returned(task);
564
+ return onBranch;
565
+ }
566
+ if (!inThreadCopy(task)) {
567
+ verdicts?.returned(task);
568
+ return null;
569
+ }
570
+ // A run that replaced its copy's .git chose what git would run there: nothing more is committed in that copy.
571
+ const changed = worktrees.changedGit(task.parent_id);
572
+ if (changed) {
573
+ store.roomPost({
574
+ goalId: task.parent_id,
575
+ author: "harness",
576
+ kind: "note",
577
+ text: `${nameOf(task.target_agent)}'s turn is not committed: ${changed}, so Harness runs no git in that copy. Discard the thread's changes and start it again.`,
578
+ });
579
+ notifyBoard(store.getTask(task.parent_id));
580
+ verdicts?.returned(task);
581
+ return null;
582
+ }
583
+ const sha = worktrees.commitTurn(
462
584
  task.parent_id,
463
585
  task.id,
464
586
  `${task.target_agent}: ${task.objective.replace(/^Room: /, "")}`
465
587
  );
588
+ noteUncommitted(task);
589
+ verdicts?.returned(task);
590
+ return sha;
591
+ };
592
+ // What git would not commit (a hook refused it, say) stays in the copy. After a make run it is a fact: the thread's,
593
+ // for the next check's brief (team.mjs) until the branch is clean again, and the run's, for the audit (audit.mjs),
594
+ // with a note naming the agent and the files. A check or a frame does not make the change.
595
+ const noteUncommitted = (task) => {
596
+ const goalId = task.parent_id;
597
+ const files = worktrees.uncommitted(goalId);
598
+ if (!files.length) {
599
+ if (store.meta(`uncommitted:${goalId}`))
600
+ store.meta(`uncommitted:${goalId}`, "");
601
+ return;
602
+ }
603
+ const agent = task.target_agent;
604
+ const step = store.getTask(task.id)?.step ?? stepHeld(goalId, agent);
605
+ const makes = !step || step === "make";
606
+ if (!makes) return;
607
+ store.meta(
608
+ `uncommitted:${goalId}`,
609
+ JSON.stringify({ agent, files, run: task.id })
610
+ );
611
+ store.meta(`uncommitted:${task.id}`, JSON.stringify({ files }));
612
+ store.roomPost({
613
+ goalId,
614
+ author: "harness",
615
+ kind: "note",
616
+ text: `${nameOf(agent)}'s change is not committed on this thread's branch, so it is not made yet: ${namedFiles(files)} ${files.length === 1 ? "is" : "are"} still uncommitted in the thread's copy.`,
617
+ });
618
+ notifyBoard(store.getTask(goalId));
466
619
  };
467
620
  const settleWake = (task, kind, text, startedAt) => {
468
621
  const goalId = task.parent_id;
@@ -471,9 +624,12 @@ export function createThreadRuns({
471
624
  } catch (error) {
472
625
  log(`overlap check for ${goalId}: ${error.message}`);
473
626
  }
474
- // A run the person stopped says nothing more: the thread already says it was stopped.
627
+ // A run the person stopped says nothing more: the thread already says it was stopped, or that it stopped for their
628
+ // steer and goes on with it.
475
629
  const stopped =
476
- kind === "failed" && store.getTask(goalId)?.status !== "open";
630
+ kind === "failed" &&
631
+ (store.getTask(goalId)?.status !== "open" ||
632
+ Boolean(store.meta(`steered:${task.id}`)));
477
633
  if (
478
634
  !stopped &&
479
635
  !store.postsBy(goalId, task.target_agent, startedAt) &&
@@ -490,7 +646,7 @@ export function createThreadRuns({
490
646
  const key = `${goalId}:${task.target_agent}`;
491
647
  const pending = pendingWakes.get(key);
492
648
  // A call that came before this run started was in the thread the run read: waking it again repeats its work
493
- // (October 15, Codex woken a second time for an animatic it had just made). Only a later call wakes it again.
649
+ // (Codex was once woken a second time for an animatic it had just made). Only a later call wakes it again.
494
650
  if (pending && startedAt && pending.at <= startedAt) {
495
651
  pendingWakes.delete(key);
496
652
  } else if (pending) {
@@ -540,11 +696,14 @@ export function createThreadRuns({
540
696
  };
541
697
  return {
542
698
  wake: wakeAgent,
699
+ steered,
543
700
  discard,
544
701
  recover,
545
702
  where: runsIn,
546
703
  worker: {
547
- commitWake,
704
+ resumeAfterSteer,
705
+ startTurn,
706
+ commitRun,
548
707
  settleWake,
549
708
  wakeBrief,
550
709
  ranOutsideT3,
@@ -36,7 +36,7 @@ export function shorten(text, limit) {
36
36
 
37
37
  const capitalized = (text) => text.charAt(0).toUpperCase() + text.slice(1);
38
38
 
39
- // Who said something, as the person reads it: another person's agent in a shared project is "igor's Codex".
39
+ // Who said something, as the person reads it: another person's agent in a shared project is "maya's Codex".
40
40
  const whoIs = (name) => {
41
41
  const [handle, agent] = String(name).split("/");
42
42
  if (!agent) return nameOf(name);
@@ -90,6 +90,11 @@ export function createThreadView({
90
90
  computerOf = () => null,
91
91
  // Whether the person's browser is listening for this computer (browserWake.mjs), so Harness can use it now.
92
92
  browserListening = () => false,
93
+ // Where the person left the thread: their last move and what it was about (threadLine.mjs).
94
+ whereLeft = () => null,
95
+ // What waits on the person about an agent rather than a thread (kind "agent", specialtyNotice.mjs): an agent not
96
+ // living up to a specialty. Each opens the agent in the Swarm map.
97
+ agentNeeds = () => [],
93
98
  }) {
94
99
  // Words from an agent on the person's computers say which one: the buddy reads it "Codex (linux)".
95
100
  const writtenOn = (post) => {
@@ -188,7 +193,7 @@ export function createThreadView({
188
193
  });
189
194
  const goal = goals?.record(thread.id);
190
195
  // A review waits only in an open thread that is still moving: one the lead closed, or one left for two days, the
191
- // person has already moved past (October 20: nine stale reviews from the week before).
196
+ // person has already moved past (nine stale reviews from the week before once waited).
192
197
  const moving =
193
198
  thread.status === "open" &&
194
199
  now() - Date.parse(posts.at(-1)?.created_at ?? thread.updated_at) <
@@ -218,9 +223,9 @@ export function createThreadView({
218
223
  text: reason.replace(/^The room is paused:\s*/, "") || "Paused.",
219
224
  at: thread.updated_at,
220
225
  });
221
- // What Harness's server left for the browser waits on the person opening their Harness window (October 18: one
222
- // such part waited 9 hours with nothing saying so), or on their Allow when their browser listens for this computer
223
- // (October 22: "right away, even if away"). Once allowed it waits on no one, unless the browser has not taken it.
226
+ // What Harness's server left for the browser waits on the person opening their Harness window (one such part once
227
+ // waited 9 hours with nothing saying so), or on their Allow when their browser listens for this computer. Once
228
+ // allowed it waits on no one, unless the browser has not taken it.
224
229
  for (const run of runs) {
225
230
  if (
226
231
  run.target_agent !== "harness" ||
@@ -325,6 +330,7 @@ export function createThreadView({
325
330
  if (item.kind === "review") return "Ready for your review";
326
331
  if (item.kind === "held") return item.text;
327
332
  if (item.kind === "window") return "Harness needs your browser to finish";
333
+ if (item.kind === "agent") return item.text;
328
334
  return `${who} needs you to decide: ${shorten(item.text, 120)}`;
329
335
  }
330
336
 
@@ -350,6 +356,7 @@ export function createThreadView({
350
356
  late: state === "working" && Boolean(lateHandoff(runs)),
351
357
  needsYou: items,
352
358
  done: doneOf(thread, state, posts),
359
+ you: whereLeft(thread.id),
353
360
  };
354
361
  }
355
362
 
@@ -485,8 +492,14 @@ export function createThreadView({
485
492
  const items = needsYouOf(thread, posts, store.threadRuns(thread.id));
486
493
  const title = titleOf(thread, posts);
487
494
  return items.map((item) => ({ ...item, threadId: thread.id, title }));
488
- });
495
+ })
496
+ .concat(swarmNeeds().map((item) => ({ ...item, threadId: null })));
497
+ }
498
+
499
+ /** What waits on the person outside any thread, newest last: the same items on every surface. */
500
+ function swarmNeeds() {
501
+ return agentNeeds();
489
502
  }
490
503
 
491
- return { row, timeline, file, waiting, itemLine };
504
+ return { row, timeline, file, waiting, itemLine, swarmNeeds };
492
505
  }
@@ -3,9 +3,8 @@ import { MEMBERS } from "./members.mjs";
3
3
 
4
4
  // Once a day, the home computer sends Harness the board's finished days as anonymous totals:
5
5
  // counts under fixed names, split by agent type. No text, task ids, folders or computer details
6
- // leave, and the server adds each report into the day's sums without the account
7
- // (src/server/bridge/usageTotals.ts). `npx tryharness usage-totals off` stops it; days while it
8
- // is off are never sent.
6
+ // leave, and the server adds each report into the day's sums without the account.
7
+ // `npx tryharness usage-totals off` stops it; days while it is off are never sent.
9
8
  //
10
9
  // board_meta "usage-totals" keeps the last day handled and the report waiting to be sent, whose
11
10
  // random id is reused on a resend so the server can refuse a repeat.