tryharness 0.7.83 → 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 (215) 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 +191 -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 +52 -0
  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 +2426 -338
  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 +1 -1
  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/originals.mjs +216 -0
  107. package/lib/outsideEvents.mjs +383 -0
  108. package/lib/outsideRuns.mjs +230 -0
  109. package/lib/ownMachines.mjs +674 -256
  110. package/lib/pain.mjs +215 -0
  111. package/lib/pairing.mjs +91 -11
  112. package/lib/paths.mjs +42 -3
  113. package/lib/peerProcess.mjs +21 -7
  114. package/lib/peopleLink.mjs +268 -0
  115. package/lib/personNotices.mjs +3 -2
  116. package/lib/phones.mjs +252 -542
  117. package/lib/placeCards.mjs +282 -0
  118. package/lib/placeChecks.mjs +95 -0
  119. package/lib/placeCommands.mjs +8 -17
  120. package/lib/placeRequests.mjs +152 -0
  121. package/lib/placeStore.mjs +295 -0
  122. package/lib/placeTool.d.ts +12 -0
  123. package/lib/placeTool.js +40 -0
  124. package/lib/places.mjs +63 -14
  125. package/lib/plans.mjs +53 -8
  126. package/lib/presence.mjs +270 -0
  127. package/lib/privateNetwork.d.ts +2 -0
  128. package/lib/privateNetwork.js +93 -0
  129. package/lib/proposals.mjs +300 -0
  130. package/lib/publicFetch.d.ts +32 -0
  131. package/lib/publicFetch.js +248 -0
  132. package/lib/reach.mjs +128 -0
  133. package/lib/rebuildable.mjs +72 -0
  134. package/lib/recall.mjs +216 -0
  135. package/lib/record.mjs +13 -0
  136. package/lib/reflexes.mjs +392 -0
  137. package/lib/relayLimits.mjs +31 -2
  138. package/lib/releaseNotice.mjs +198 -0
  139. package/lib/removeHarness.mjs +15 -4
  140. package/lib/repoLinks.mjs +204 -35
  141. package/lib/runAuthority.mjs +102 -39
  142. package/lib/runBrief.mjs +93 -40
  143. package/lib/runRequests.mjs +52 -14
  144. package/lib/runUsage.mjs +31 -0
  145. package/lib/runWorker.mjs +74 -25
  146. package/lib/runner.mjs +289 -45
  147. package/lib/runtime-install.mjs +37 -8
  148. package/lib/schedules.mjs +171 -47
  149. package/lib/screenWatches.mjs +221 -0
  150. package/lib/sealed.mjs +12 -30
  151. package/lib/sealedThreads.mjs +198 -392
  152. package/lib/secretStore.mjs +178 -0
  153. package/lib/secrets.mjs +11 -0
  154. package/lib/seen.mjs +3 -9
  155. package/lib/selfUpdate.mjs +51 -15
  156. package/lib/senseCall.mjs +1514 -0
  157. package/lib/senseHook.mjs +114 -0
  158. package/lib/senseTools.mjs +1298 -0
  159. package/lib/sessionBriefs.mjs +87 -0
  160. package/lib/sessionControl.mjs +63 -13
  161. package/lib/sessionFiles.mjs +85 -0
  162. package/lib/setupChoices.mjs +12 -3
  163. package/lib/setupMode.mjs +70 -25
  164. package/lib/sharedKeys.mjs +166 -0
  165. package/lib/sleep.mjs +396 -0
  166. package/lib/sources.mjs +306 -0
  167. package/lib/speech.mjs +166 -411
  168. package/lib/spoken.mjs +210 -0
  169. package/lib/steerHook.mjs +3 -1
  170. package/lib/steerQueue.mjs +40 -11
  171. package/lib/store.mjs +323 -130
  172. package/lib/stuck.mjs +85 -7
  173. package/lib/swarm.mjs +157 -49
  174. package/lib/swarmDevices.mjs +25 -85
  175. package/lib/swarmMemory.mjs +93 -9
  176. package/lib/t3.mjs +73 -3
  177. package/lib/taskCommands.mjs +51 -60
  178. package/lib/taskRooms.mjs +30 -4
  179. package/lib/taskRules.json +29 -0
  180. package/lib/taskRules.mjs +21 -0
  181. package/lib/taskRuns.mjs +74 -11
  182. package/lib/team.mjs +2 -1
  183. package/lib/threadActions.mjs +37 -9
  184. package/lib/threadAuthority.mjs +4 -4
  185. package/lib/threadBriefs.mjs +173 -43
  186. package/lib/threadNotes.mjs +320 -0
  187. package/lib/threadRecord.mjs +491 -0
  188. package/lib/threadRuns.mjs +216 -108
  189. package/lib/threadView.mjs +27 -30
  190. package/lib/threadWatches.mjs +1962 -0
  191. package/lib/timeSense.mjs +839 -0
  192. package/lib/tripwires.mjs +454 -0
  193. package/lib/ui.mjs +1 -1
  194. package/lib/vault.mjs +560 -45
  195. package/lib/vaultCommands.mjs +5 -3
  196. package/lib/vaultPeers.mjs +165 -0
  197. package/lib/vaultTools.d.ts +4 -1
  198. package/lib/vaultTools.js +22 -1
  199. package/lib/verdicts.mjs +12 -26
  200. package/lib/versions.mjs +117 -0
  201. package/lib/waitTool.mjs +278 -0
  202. package/lib/wakePicture.mjs +268 -0
  203. package/lib/wakeQueue.mjs +108 -0
  204. package/lib/watchResponses.mjs +533 -0
  205. package/lib/watches.mjs +290 -145
  206. package/lib/windowAsks.mjs +80 -17
  207. package/lib/worktrees.mjs +159 -9
  208. package/npm-shrinkwrap.json +138 -631
  209. package/package.json +7 -6
  210. package/release.json +211 -129
  211. package/lib/callSessions.mjs +0 -51
  212. package/lib/directLink.mjs +0 -349
  213. package/lib/peopleBoard.mjs +0 -131
  214. package/lib/projects.mjs +0 -2917
  215. package/lib/roomChannels.mjs +0 -667
package/lib/spoken.mjs ADDED
@@ -0,0 +1,210 @@
1
+ import { spawn } from "node:child_process";
2
+ import fs from "node:fs";
3
+ import os from "node:os";
4
+ import path from "node:path";
5
+ import {
6
+ llamaServer,
7
+ modelById,
8
+ modelFile,
9
+ modelsPresent,
10
+ } from "./localmodels.mjs";
11
+
12
+ // The swarm's voice: a line for what just happened in a thread, spoken by LFM3-Omni's speech mode (llama-tts, about a second to
13
+ // generate a line after loading the model) and played one at a time. The owner rejected the Mac's own voice (November 6: "im am
14
+ // certain i hate the default mac voice"), so with Omni not here yet it stays silent rather than falling back to it. A
15
+ // wrong sentence said out loud is believed, so the board and the agents' own words say what happened: `started` names agents
16
+ // that did start, and an answer is read as its agent wrote it, shortened. Only what the person is needed for is worded by the
17
+ // dispatcher's model, which drew the point out of a thread on real questions but misstated real long answers it summarized
18
+ // (November 6), and even that falls back to the agent's own question.
19
+ const LONGEST_LINE = 300;
20
+ // A post this short reads aloud as it is.
21
+ const READS_AS_IS = 240;
22
+ const OPENING = 160;
23
+ const TRANSCRIPT_POSTS = 8;
24
+ const VOICES = new Set(["female", "male"]);
25
+
26
+ /** Written words as they sound: no code, links, list marks or post numbers. Mechanical, so nothing is lost to a model. */
27
+ export function speakable(text) {
28
+ return (
29
+ String(text ?? "")
30
+ .replace(/^Deciding:.*$/gm, " ")
31
+ .replace(/```[\s\S]*?```/g, " ")
32
+ .replace(/`([^`]*)`/g, "$1")
33
+ .replace(/!?\[([^\]]*)\]\([^)]*\)/g, "$1")
34
+ .replace(/https?:\/\/\S+/g, "a link")
35
+ .replace(/^\s{0,3}(?:#{1,6}\s+|[-*+]\s+|\d+\.\s+|>\s*)/gm, "")
36
+ .replace(/[*_~]{1,3}([^*_~\n]+)[*_~]{1,3}/g, "$1")
37
+ .replace(/(^|\s)[@#](?=[\w-])/g, "$1")
38
+ // What only reads right on a screen: MIN_STAKE, rewards.ts, 0.4.
39
+ .replace(/(\w)_(?=\w)/g, "$1 ")
40
+ .replace(
41
+ /\b([\w-]+)\.(ts|tsx|js|mjs|json|py|md|rs|sh|css|html)\b/g,
42
+ "$1 dot $2"
43
+ )
44
+ .replace(/(\d)\.(?=\d)/g, "$1 point ")
45
+ .replace(/\s+/g, " ")
46
+ .trim()
47
+ );
48
+ }
49
+
50
+ /** The start of a long post, and its closing question when it ends by asking one. */
51
+ function shortened(words) {
52
+ const sentences = words.split(/(?<=[.!?])\s+/);
53
+ let opening = "";
54
+ for (const sentence of sentences) {
55
+ if (opening && opening.length + sentence.length > OPENING) break;
56
+ opening = `${opening} ${sentence}`.trim();
57
+ }
58
+ const closing = sentences.at(-1);
59
+ const asks =
60
+ closing.endsWith("?") &&
61
+ !opening.endsWith(closing) &&
62
+ closing.length <= LONGEST_LINE - OPENING - 2;
63
+ return asks
64
+ ? `${opening.slice(0, OPENING)} ${closing}`
65
+ : `${opening.slice(0, LONGEST_LINE - 30)} The rest is in the thread.`;
66
+ }
67
+
68
+ const asOneLine = (text) => speakable(text).slice(0, LONGEST_LINE).trim();
69
+
70
+ export function createSpoken({
71
+ dispatcher,
72
+ postsOf,
73
+ titleOf,
74
+ nameOf,
75
+ root,
76
+ platform = process.platform,
77
+ run = spawn,
78
+ log = () => {},
79
+ }) {
80
+ const transcript = (threadId) =>
81
+ postsOf(threadId)
82
+ .slice(-TRANSCRIPT_POSTS)
83
+ .map((post) => ({
84
+ author: nameOf(post.author),
85
+ kind: post.kind,
86
+ text: post.text,
87
+ }));
88
+
89
+ const lineFor = async (request) => {
90
+ if (request.kind === "plain") return request.text;
91
+ if (request.kind === "started") {
92
+ const names = (request.agents ?? []).map(nameOf);
93
+ if (!names.length) return "";
94
+ const who = `${names.join(" and ")} ${names.length > 1 ? "have" : "has"}`;
95
+ return `${who} it: ${titleOf(request.thread)}.`;
96
+ }
97
+ if (request.kind === "needs_you") {
98
+ if (!request.thread) return request.text;
99
+ return dispatcher
100
+ .speak("say_thread", {
101
+ kind: "needs_you",
102
+ transcript: transcript(request.thread),
103
+ })
104
+ .catch((error) => {
105
+ log(`voice: the agent's own words (${error.message})`);
106
+ return request.text;
107
+ });
108
+ }
109
+ if (request.kind === "reply") {
110
+ const posts = postsOf(request.thread);
111
+ const post = posts.find((each) => each.seq === request.seq);
112
+ const words = speakable(post?.text);
113
+ return words.length <= READS_AS_IS ? words : shortened(words);
114
+ }
115
+ return "";
116
+ };
117
+
118
+ const omni = () => {
119
+ const entry = modelById("dispatcher");
120
+ const server = llamaServer(root);
121
+ if (!server || !modelsPresent(root, ["dispatcher"])) return null;
122
+ return {
123
+ program: path.join(path.dirname(server), "llama-tts"),
124
+ model: modelFile(root, entry, 0),
125
+ projector: modelFile(root, entry, 1),
126
+ };
127
+ };
128
+
129
+ let current = null;
130
+ let waiting = [];
131
+ let working = false;
132
+ // Counts each stop, so a line generated meanwhile is not played afterwards.
133
+ let stops = 0;
134
+ const step = (program, args) =>
135
+ new Promise((resolve) => {
136
+ let child;
137
+ try {
138
+ child = run(program, args, { stdio: "ignore" });
139
+ } catch {
140
+ return resolve(false);
141
+ }
142
+ current = child;
143
+ child.on("error", (error) => {
144
+ log(`voice: ${path.basename(program)} did not run (${error.message})`);
145
+ resolve(false);
146
+ });
147
+ child.on("close", (code) => resolve(code === 0));
148
+ });
149
+ const sayLine = async ({ line, voice, parts }) => {
150
+ const stop = stops;
151
+ const folder = fs.mkdtempSync(path.join(os.tmpdir(), "harness-voice-"));
152
+ const file = path.join(folder, "line.wav");
153
+ try {
154
+ const made = await step(parts.program, [
155
+ "-m",
156
+ parts.model,
157
+ "-mm",
158
+ parts.projector,
159
+ "--tts-lang",
160
+ "en",
161
+ "--tts-voice",
162
+ voice,
163
+ "-p",
164
+ line,
165
+ "-o",
166
+ file,
167
+ ]);
168
+ if (stop !== stops) return;
169
+ if (!made) log("voice: Omni could not speak that line");
170
+ else await step("afplay", [file]);
171
+ } finally {
172
+ fs.rmSync(folder, { recursive: true, force: true });
173
+ }
174
+ };
175
+ const next = async () => {
176
+ if (working) return;
177
+ working = true;
178
+ while (waiting.length) await sayLine(waiting.shift());
179
+ current = null;
180
+ working = false;
181
+ };
182
+
183
+ return {
184
+ /** Words the line and queues it; answers with what will be said, without waiting for it to be said. */
185
+ async say(request) {
186
+ if (platform !== "darwin")
187
+ return { ok: false, error: "The swarm speaks on a Mac for now." };
188
+ const parts = omni();
189
+ if (!parts)
190
+ return {
191
+ ok: false,
192
+ error: "The swarm speaks once its local models are here.",
193
+ };
194
+ const said = asOneLine(await lineFor(request));
195
+ if (said) {
196
+ const voice = VOICES.has(request.voice) ? request.voice : "female";
197
+ waiting.push({ line: said, voice, parts });
198
+ void next();
199
+ }
200
+ return { ok: true, said };
201
+ },
202
+ /** Stops at once, with nothing left to come: the person started talking, or turned the voice off. */
203
+ quiet() {
204
+ waiting = [];
205
+ stops += 1;
206
+ current?.kill();
207
+ return { ok: true };
208
+ },
209
+ };
210
+ }
package/lib/steerHook.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  import path from "node:path";
2
+ import { ranAsProgram } from "./paths.mjs";
2
3
  import {
3
4
  REDIRECT_HOLD,
4
5
  endSteers,
@@ -108,7 +109,8 @@ async function tellAsk(input) {
108
109
  ).catch(() => null);
109
110
  }
110
111
 
111
- if (import.meta.url === `file://${process.argv[1]}`) {
112
+ // Started by an agent's hook, by the linked name an update leaves as it was (paths.mjs ranAsProgram).
113
+ if (ranAsProgram(import.meta.url)) {
112
114
  if (process.argv.includes("--ask")) {
113
115
  try {
114
116
  await tellAsk(await readInput());
@@ -3,7 +3,11 @@ import path from "node:path";
3
3
  import { harnessHome } from "./paths.mjs";
4
4
 
5
5
  // What the person tells a subagent from Harness, waiting for that subagent's next step. The daemon writes; the hook
6
- // inside each agent (steerHook.mjs for Claude Code, the OpenCode plugin) takes. A steer is one file under
6
+ // inside each agent (steerHook.mjs for Claude Code, the OpenCode plugin) takes. Harness's own readings for an agent at
7
+ // work (a watch or wait answering, the same command run again and again: docs/senses-plan.md S3.6) wait here too, as
8
+ // kind "sense": every agent's own hook after a tool call takes them (nudge.mjs --step), and the turn's end takes any
9
+ // left (nudge.mjs --stop). The person's own words keep their way in: a note reaches the model as its turn ends, where it
10
+ // reads them as the person's. A steer is one file under
7
11
  // steer/<session>/<agent>/, so taking one is a single rename no two processes both win, and the folder is empty
8
12
  // whenever nothing waits: the hook's shell guard checks only that, so a tool call with nothing waiting costs no Node
9
13
  // start. `agent` is Claude Code's agent_id for one of its subagents, and PARENT for the session's own model (OpenCode's
@@ -12,7 +16,9 @@ import { harnessHome } from "./paths.mjs";
12
16
 
13
17
  export const PARENT = "_";
14
18
  const ID = /^[A-Za-z0-9._:-]{1,128}$/;
15
- const KINDS = new Set(["note", "redirect", "stop", "parent"]);
19
+ const KINDS = new Set(["note", "redirect", "stop", "parent", "sense"]);
20
+ /** Harness's own readings for an agent at work, given after its next tool call (nudge.mjs --step). */
21
+ export const SENSE = "sense";
16
22
 
17
23
  export const steerRoot = (home = harnessHome) => path.join(home, "steer");
18
24
  const receiptsRoot = (home) => path.join(home, "steer-receipts");
@@ -89,7 +95,7 @@ export function takeSteers(
89
95
  agent,
90
96
  where = {},
91
97
  home = harnessHome,
92
- { keep = false } = {}
98
+ { keep = false, only = null } = {}
93
99
  ) {
94
100
  if (!ID.test(String(session)) || !ID.test(String(agent || PARENT))) return [];
95
101
  const folder = folderOf(home, session, agent);
@@ -98,6 +104,13 @@ export function takeSteers(
98
104
  const file = path.join(folder, name);
99
105
  const item = readItem(file);
100
106
  if (!item) continue;
107
+ // `only`: what a hook takes here, the kinds or a rule (a step's hook takes Harness's readings and leaves the
108
+ // person's words).
109
+ if (
110
+ only &&
111
+ !(typeof only === "function" ? only(item) : only.includes(item.kind))
112
+ )
113
+ continue;
101
114
  if (item.kind === "stop") {
102
115
  if (!item.landed) {
103
116
  receipt(home, item, where);
@@ -158,19 +171,35 @@ const FROM_PERSON =
158
171
  /** What a Claude Code subagent reads while a new brief for it waits: drop the current course, so the brief reaches it. */
159
172
  export const REDIRECT_HOLD = `${FROM_PERSON} They are giving you a new brief. Stop what you are doing and end your turn now, without calling more tools: the new brief reaches you as you finish, and you carry on with it.`;
160
173
 
174
+ // Harness's readings are data about the agent's work, never orders, and say where they come from.
175
+ const FROM_HARNESS =
176
+ "From Harness, about your work here: what it noticed while you worked (a reading, not an instruction).";
177
+
178
+ /** What an agent reads of Harness's readings (kind "sense"). */
179
+ export function senseText(items) {
180
+ return [FROM_HARNESS, ...items.map((item) => `- ${item.text}`)].join("\n");
181
+ }
182
+
161
183
  /** The words a subagent (or the agent that started it) reads for what it was told. */
162
184
  export function steerText(items) {
163
185
  const stop = items.find((item) => item.kind === "stop");
164
186
  if (stop)
165
187
  return `${FROM_PERSON} They stopped you. Make no more changes and call no more tools. Return now with what you have done so far and what is left undone.`;
188
+ const senses = items.filter((item) => item.kind === SENSE);
189
+ const theirs = items.filter((item) => item.kind !== SENSE);
166
190
  return [
167
- FROM_PERSON,
168
- ...items.map((item) =>
169
- item.kind === "redirect"
170
- ? `They replaced your brief. Your brief is now:\n\n${item.text}\n\nDrop any step that does not serve it.`
171
- : item.kind === "parent"
172
- ? item.text
173
- : `Their message to you:\n\n${item.text}`
174
- ),
191
+ ...(theirs.length
192
+ ? [
193
+ FROM_PERSON,
194
+ ...theirs.map((item) =>
195
+ item.kind === "redirect"
196
+ ? `They replaced your brief. Your brief is now:\n\n${item.text}\n\nDrop any step that does not serve it.`
197
+ : item.kind === "parent"
198
+ ? item.text
199
+ : `Their message to you:\n\n${item.text}`
200
+ ),
201
+ ]
202
+ : []),
203
+ ...(senses.length ? [senseText(senses)] : []),
175
204
  ].join("\n\n");
176
205
  }