tryharness 0.7.54 → 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 (156) hide show
  1. package/README.md +15 -16
  2. package/cli.mjs +377 -62
  3. package/lib/activity.mjs +10 -10
  4. package/lib/adapters.mjs +16 -0
  5. package/lib/agentBinaries.mjs +71 -0
  6. package/lib/agentRuntimeConfig.mjs +1 -1
  7. package/lib/agentRuntimes.mjs +9 -3
  8. package/lib/agentSignIn.mjs +271 -41
  9. package/lib/answers.mjs +5 -5
  10. package/lib/archetypes.d.ts +64 -0
  11. package/lib/archetypes.js +989 -0
  12. package/lib/asks.mjs +4 -4
  13. package/lib/audit.mjs +36 -13
  14. package/lib/backupSetup.mjs +4 -2
  15. package/lib/boardAccess.mjs +17 -11
  16. package/lib/boardBackup.mjs +6 -6
  17. package/lib/boardFileCommands.mjs +6 -6
  18. package/lib/boardFiles.mjs +13 -12
  19. package/lib/boardMirror.mjs +82 -47
  20. package/lib/boardProtocol.json +30 -1
  21. package/lib/boardWaits.mjs +2 -3
  22. package/lib/book.mjs +6 -6
  23. package/lib/bridge.mjs +5 -5
  24. package/lib/cards.mjs +2 -2
  25. package/lib/cloudAgents.mjs +216 -0
  26. package/lib/cloudAi.mjs +1312 -0
  27. package/lib/cloudAssistants.mjs +242 -0
  28. package/lib/cloudBoot.mjs +81 -86
  29. package/lib/cloudSave.mjs +197 -0
  30. package/lib/cloudSsh.mjs +178 -0
  31. package/lib/context.mjs +3 -3
  32. package/lib/contractGate.mjs +34 -12
  33. package/lib/control-client.mjs +9 -1
  34. package/lib/controlSocket.mjs +86 -0
  35. package/lib/coordinator.mjs +103 -101
  36. package/lib/daemon.mjs +1128 -2865
  37. package/lib/desk.mjs +7 -6
  38. package/lib/desktop.mjs +72 -68
  39. package/lib/directLink.mjs +16 -5
  40. package/lib/environment.mjs +2 -1
  41. package/lib/environments.mjs +14 -6
  42. package/lib/firewall.mjs +9 -9
  43. package/lib/folders.mjs +18 -14
  44. package/lib/frames.mjs +2 -3
  45. package/lib/gitHost.mjs +3 -3
  46. package/lib/goalCommands.mjs +25 -7
  47. package/lib/goals.mjs +7 -7
  48. package/lib/guestRequests.mjs +94 -0
  49. package/lib/handoffs.mjs +8 -7
  50. package/lib/handover.mjs +4 -4
  51. package/lib/harnessModel.mjs +6 -6
  52. package/lib/harnessOffers.mjs +266 -0
  53. package/lib/inference.mjs +26 -8
  54. package/lib/jobAnswers.mjs +190 -0
  55. package/lib/landed.mjs +1 -1
  56. package/lib/lane.mjs +42 -11
  57. package/lib/lessons.mjs +16 -16
  58. package/lib/library.mjs +3 -3
  59. package/lib/lineup.mjs +3 -0
  60. package/lib/linkRelay.mjs +574 -0
  61. package/lib/localAgentAsk.mjs +74 -0
  62. package/lib/localStack.mjs +536 -0
  63. package/lib/localmodels.mjs +6 -4
  64. package/lib/loopBackstop.mjs +4 -4
  65. package/lib/machineIdentity.mjs +9 -1
  66. package/lib/machineRoutes.mjs +181 -2
  67. package/lib/machineRuns.mjs +76 -1
  68. package/lib/machineSeal.mjs +39 -12
  69. package/lib/mcp-stdio.mjs +96 -26
  70. package/lib/mcpRelay.mjs +1 -1
  71. package/lib/members.json +13 -0
  72. package/lib/members.mjs +1 -1
  73. package/lib/models.mjs +77 -23
  74. package/lib/museSession.mjs +6 -1
  75. package/lib/nativeHost.mjs +35 -7
  76. package/lib/network.mjs +50 -5
  77. package/lib/notify.mjs +7 -5
  78. package/lib/nudge.mjs +3 -3
  79. package/lib/ocr.mjs +9 -9
  80. package/lib/onboard.mjs +26 -20
  81. package/lib/oneLine.mjs +7 -7
  82. package/lib/ownMachines.mjs +928 -149
  83. package/lib/pairing.mjs +33 -6
  84. package/lib/paths.mjs +15 -1
  85. package/lib/peerProcess.mjs +124 -0
  86. package/lib/personModel.mjs +3 -3
  87. package/lib/personNotices.mjs +151 -0
  88. package/lib/phones.mjs +490 -38
  89. package/lib/placeCommands.mjs +4 -4
  90. package/lib/places.mjs +70 -2
  91. package/lib/profile.mjs +67 -14
  92. package/lib/projectGit.mjs +158 -14
  93. package/lib/projectPieces.mjs +902 -0
  94. package/lib/projectSettings.mjs +7 -4
  95. package/lib/projects.mjs +384 -62
  96. package/lib/provenance.mjs +5 -1
  97. package/lib/proxyLinks.mjs +267 -0
  98. package/lib/reactions.mjs +7 -5
  99. package/lib/readiness.mjs +12 -7
  100. package/lib/record.mjs +19 -6
  101. package/lib/redact.mjs +4 -4
  102. package/lib/relayLimits.mjs +62 -0
  103. package/lib/release.mjs +170 -0
  104. package/lib/releaseKeys.json +6 -0
  105. package/lib/repoLinks.mjs +4 -4
  106. package/lib/roomChannels.mjs +24 -0
  107. package/lib/roomPage.mjs +1 -1
  108. package/lib/runAuthority.mjs +101 -0
  109. package/lib/runBrief.mjs +19 -8
  110. package/lib/runWorker.mjs +14 -5
  111. package/lib/runner.mjs +215 -25
  112. package/lib/runtime-install.mjs +143 -9
  113. package/lib/schedules.mjs +2 -2
  114. package/lib/screens.mjs +1 -1
  115. package/lib/sealed.mjs +11 -2
  116. package/lib/sealedThreads.mjs +671 -0
  117. package/lib/secretPatterns.json +1 -1
  118. package/lib/secrets.mjs +4 -4
  119. package/lib/seen.mjs +6 -6
  120. package/lib/serverWords.mjs +175 -0
  121. package/lib/service.mjs +22 -12
  122. package/lib/sessionControl.mjs +6 -6
  123. package/lib/specialties.mjs +6 -6
  124. package/lib/specialtyKeys.js +4 -5
  125. package/lib/specialtyNotice.mjs +7 -7
  126. package/lib/specialtySnapshot.mjs +5 -5
  127. package/lib/speech.mjs +5 -5
  128. package/lib/store.mjs +140 -39
  129. package/lib/stuck.mjs +1 -1
  130. package/lib/swarm.mjs +167 -16
  131. package/lib/swarmDevices.mjs +319 -0
  132. package/lib/swarmMemory.mjs +27 -25
  133. package/lib/t3.mjs +13 -13
  134. package/lib/taskCommands.mjs +44 -11
  135. package/lib/taskRooms.mjs +125 -0
  136. package/lib/taskRuns.mjs +36 -1
  137. package/lib/team.mjs +41 -18
  138. package/lib/threadActions.mjs +315 -0
  139. package/lib/threadAuthority.mjs +101 -0
  140. package/lib/threadBriefs.mjs +178 -0
  141. package/lib/threadLine.mjs +2 -2
  142. package/lib/threadRuns.mjs +138 -43
  143. package/lib/threadView.mjs +5 -5
  144. package/lib/usageTotals.mjs +2 -3
  145. package/lib/vault.mjs +101 -10
  146. package/lib/vaultCloud.mjs +2 -2
  147. package/lib/vaultCommands.mjs +15 -6
  148. package/lib/vaultTools.js +2 -2
  149. package/lib/verdicts.mjs +328 -0
  150. package/lib/wakes.mjs +1 -1
  151. package/lib/watches.mjs +2 -2
  152. package/lib/windowAsks.mjs +13 -5
  153. package/lib/worktrees.mjs +112 -18
  154. package/npm-shrinkwrap.json +1093 -0
  155. package/package.json +11 -10
  156. package/release.json +220 -0
package/lib/models.mjs CHANGED
@@ -3,6 +3,7 @@ import os from "node:os";
3
3
  import path from "node:path";
4
4
  import { spawn } from "node:child_process";
5
5
  import { agentEnvironment } from "./agentnode.mjs";
6
+ import { agentBinary } from "./agentBinaries.mjs";
6
7
  import { MACHINE_RUNNERS, member, nameOf } from "./members.mjs";
7
8
  import { trackHelper } from "./runner.mjs";
8
9
  import { listProtocolModels } from "./agentRuntimes.mjs";
@@ -12,15 +13,17 @@ import { listProtocolModels } from "./agentRuntimes.mjs";
12
13
  // models the others list here). A run uses, first: a model named for it (`@codex:gpt-6-luna/high` in a post, or
13
14
  // post_task's model); then the person's choice for the agent, which may be Auto (Harness's Jev picks from the list
14
15
  // against the person's routing words); else nothing, and the agent runs on its own settings. Every pick is checked
15
- // against the agent's list before a run starts.
16
+ // against the agent's list before a run starts. An agent on Harness's AI on a cloud computer lists Harness's models
17
+ // instead (cloudAi.mjs catalogOf: what the person's pass or credits pay for, each with its limits), where Auto is
18
+ // Harness's own, picking the model for each request, and is the agent's default.
16
19
 
17
20
  const CLAUDE_EFFORTS = ["low", "medium", "high", "xhigh", "max"]; // claude --help
18
21
  const PI_THINKING = ["off", "minimal", "low", "medium", "high", "xhigh", "max"]; // pi --help
19
22
  const CLAUDE_NAMES = ["fable", "opus", "sonnet", "haiku"];
20
23
  /**
21
- * The routing words Auto goes by until the person writes their own. The first wording (owner, October 13), "The cheapest
22
- * model that can do this work well; more effort only for hard work.", sent demanding work to cheap models (eval
23
- * model-routing v1, 20261014-010225-80250750-357a).
24
+ * The routing words Auto goes by until the person writes their own. An earlier wording, "The cheapest model that can do
25
+ * this work well; more effort only for hard work.", sent demanding work to cheap models on a fixed set of routing
26
+ * cases.
24
27
  */
25
28
  export const DEFAULT_ROUTING =
26
29
  "Match the model to the work: for easy work, the cheapest model that does it well; for demanding work, the most capable one. Pass over a model that keeps failing here. More effort only for hard work.";
@@ -103,7 +106,8 @@ const LISTS = {
103
106
  },
104
107
  };
105
108
 
106
- function capture(command, args) {
109
+ // `program` is the agent's confirmed program (agentBinaries.mjs); `command` its name, for the Node it needs.
110
+ function capture(command, args, program) {
107
111
  return new Promise((resolve, reject) => {
108
112
  const environment = agentEnvironment(command);
109
113
  if (environment.error) {
@@ -112,7 +116,7 @@ function capture(command, args) {
112
116
  }
113
117
  let child;
114
118
  try {
115
- child = spawn(command, args, { cwd: os.tmpdir(), env: environment.env });
119
+ child = spawn(program, args, { cwd: os.tmpdir(), env: environment.env });
116
120
  } catch (error) {
117
121
  reject(error);
118
122
  return;
@@ -149,7 +153,10 @@ export const listingOf = (store, agent) => {
149
153
  return null;
150
154
  }
151
155
  };
152
- /** An agent's models as it last listed them: [{ id, about?, efforts, defaultEffort?, context?, price? }]. */
156
+ /**
157
+ * An agent's models as it last listed them: [{ id, about?, efforts, defaultEffort?, context?, price? }], and on
158
+ * Harness's AI also name, maxOutput and image, with Auto marked auto.
159
+ */
153
160
  export const catalogOf = (store, agent) =>
154
161
  listingOf(store, agent)?.models ?? [];
155
162
 
@@ -161,16 +168,32 @@ export async function refreshCatalogs(
161
168
  store,
162
169
  agents,
163
170
  log = () => {},
164
- { protocols = false } = {}
171
+ { protocols = false, managed = () => null } = {}
165
172
  ) {
173
+ // An agent on Harness's AI lists Harness's models, as the computer last read them; its own command is not asked.
174
+ const onHarness = agents.filter((agent) => {
175
+ const listing = managed(agent);
176
+ if (!listing) return false;
177
+ store.meta(
178
+ catalogKey(agent),
179
+ JSON.stringify({ at: new Date().toISOString(), ...listing })
180
+ );
181
+ return true;
182
+ });
166
183
  await Promise.all(
167
184
  agents
185
+ .filter((name) => !onHarness.includes(name))
168
186
  .filter((name) => LISTS[name] || (protocols && member(name)?.runtime))
169
187
  .map(async (agent) => {
170
188
  try {
171
189
  const offered = LISTS[agent]
172
190
  ? LISTS[agent].parse(
173
- await capture(LISTS[agent].command, LISTS[agent].args)
191
+ await capture(
192
+ LISTS[agent].command,
193
+ LISTS[agent].args,
194
+ agentBinary(agent, LISTS[agent].command) ??
195
+ LISTS[agent].command
196
+ )
174
197
  )
175
198
  : await listProtocolModels(agent, trackHelper);
176
199
  const models = offered.filter((entry) => entry.id);
@@ -180,17 +203,21 @@ export async function refreshCatalogs(
180
203
  );
181
204
  } catch (error) {
182
205
  log(`model list for ${agent}: ${error.message}`);
206
+ // Its last own list stands; Harness's list or a proxy link's does not, once the agent is off it.
207
+ const last = listingOf(store, agent);
183
208
  store.meta(
184
209
  catalogKey(agent),
185
210
  JSON.stringify({
186
- ...(listingOf(store, agent) ?? { models: [] }),
211
+ ...(last && !last.harness && !last.link && !last.standin
212
+ ? last
213
+ : { models: [] }),
187
214
  error: error.message.slice(0, 300),
188
215
  })
189
216
  );
190
217
  }
191
218
  })
192
219
  );
193
- if (agents.includes("claude-code")) {
220
+ if (agents.includes("claude-code") && !onHarness.includes("claude-code")) {
194
221
  const anthropic = [
195
222
  ...new Set(
196
223
  ["pi", "opencode"]
@@ -236,14 +263,26 @@ function findModel(store, agent, written) {
236
263
  };
237
264
  }
238
265
 
239
- /** A model and effort for an agent, checked against its list: { ok, pick } with pick { model, effort } or { auto: true }. */
266
+ /**
267
+ * A model and effort for an agent, checked against its list: { ok, pick } with pick { model, effort } or { auto: true }.
268
+ * On Harness's AI, Auto is Harness's own entry in the list, which picks the model for each request.
269
+ */
240
270
  export function resolvePick(store, agent, model, effort = null) {
241
271
  if (
242
272
  String(model || "")
243
273
  .trim()
244
274
  .toLowerCase() === "auto"
245
- )
246
- return { ok: true, pick: { auto: true } };
275
+ ) {
276
+ const harnessAuto = listingOf(store, agent)?.harness
277
+ ? catalogOf(store, agent).find((entry) => entry.auto)
278
+ : null;
279
+ return {
280
+ ok: true,
281
+ pick: harnessAuto
282
+ ? { model: harnessAuto.id, effort: null }
283
+ : { auto: true },
284
+ };
285
+ }
247
286
  const found = findModel(store, agent, model);
248
287
  if (found.error) return { ok: false, error: found.error };
249
288
  const level = effort ? String(effort).trim().toLowerCase() : null;
@@ -317,6 +356,12 @@ export function setChoice(store, agent, model, effort = null) {
317
356
  }
318
357
  const resolved = resolvePick(store, agent, model, effort);
319
358
  if (!resolved.ok) return resolved;
359
+ // On Harness's AI, Auto is the agent's own default: choosing it is choosing nothing else.
360
+ const autoEntry = catalogOf(store, agent).find((entry) => entry.auto);
361
+ if (autoEntry && resolved.pick.model === autoEntry.id) {
362
+ store.meta(choiceKey(agent), "");
363
+ return { ok: true, choice: null };
364
+ }
320
365
  store.meta(choiceKey(agent), JSON.stringify(resolved.pick));
321
366
  return { ok: true, choice: resolved.pick };
322
367
  }
@@ -484,7 +529,7 @@ function recordByModel(store, agent) {
484
529
  };
485
530
  }
486
531
 
487
- /** What Auto sends Harness for one run (src/server/swarm/route.ts): the work, the person's words, every listed model with its record here. */
532
+ /** What Auto sends Harness for one run: the work, the person's words, every listed model with its record here. */
488
533
  export const routeInput = ({
489
534
  agent,
490
535
  work,
@@ -526,14 +571,23 @@ export function createModelRouter({
526
571
  if (!pick) return null;
527
572
  const by = named ? (named.by === "user" ? "you" : named.by) : pick.by;
528
573
  // A model picked without an effort runs at the default its list gives it, the one the buddy shows, named on the run
529
- // so the agent's own settings (Codex's model_reasoning_effort) do not put a different one in its place.
530
- const withDefaultEffort = (picked) => ({
531
- ...picked,
532
- effort:
533
- picked.effort ??
534
- findModel(store, agent, picked.model).entry?.defaultEffort ??
535
- null,
536
- });
574
+ // so the agent's own settings (Codex's model_reasoning_effort) do not put a different one in its place. A model
575
+ // whose list says its window and longest answer (Harness's AI) carries them, for an agent told them per run.
576
+ const withDefaultEffort = (picked) => {
577
+ const entry = findModel(store, agent, picked.model).entry;
578
+ return {
579
+ ...picked,
580
+ effort: picked.effort ?? entry?.defaultEffort ?? null,
581
+ ...(entry?.context && entry?.maxOutput
582
+ ? {
583
+ limits: {
584
+ contextTokens: entry.context,
585
+ maxOutputTokens: entry.maxOutput,
586
+ },
587
+ }
588
+ : {}),
589
+ };
590
+ };
537
591
  if (!pick.auto) {
538
592
  // The list may have changed since the pick: a model the agent no longer lists runs on its own settings, said so.
539
593
  const checked = resolvePick(store, agent, pick.model, pick.effort);
@@ -76,7 +76,12 @@ export async function openMuseSession({
76
76
  "--agent",
77
77
  task.agent,
78
78
  ],
79
- env: { HARNESS_RUN_ID: task.runId },
79
+ env: {
80
+ HARNESS_RUN_ID: task.runId,
81
+ ...(task.capability
82
+ ? { HARNESS_RUN_TOKEN: task.capability }
83
+ : {}),
84
+ },
80
85
  },
81
86
  },
82
87
  };
@@ -5,8 +5,8 @@ import { paths } from "./paths.mjs";
5
5
 
6
6
  // The Harness extension finds the daemon on its own computer through Chrome's native messaging: Chrome starts this
7
7
  // host for the extension, one message in and one answer out, so the Harness window links to the computer it runs on
8
- // with no `tryharness link`. The host says which computer this is (its public key and name) and, asked, makes a link
9
- // offer for this browser exactly as `tryharness link` does; the page pairs with it through Harness, sealed.
8
+ // with no `tryharness link`. The host says which computer this is (its public key and name) and, asked, gets a link
9
+ // offer for this browser once the person allows it on this computer; the page pairs with it through Harness, sealed.
10
10
  //
11
11
  // Only the extension named in the manifest's allowed_origins can start the host (Chrome enforces it). Its ID is fixed
12
12
  // by the public key in packages/browser-extension/manifest.json, the Chrome Web Store item's.
@@ -110,7 +110,7 @@ const shellQuote = (value) => `'${String(value).replaceAll("'", `'\\''`)}'`;
110
110
  /**
111
111
  * The host itself, run by Chrome: reads length-prefixed JSON messages on `input` and answers each on `output`.
112
112
  * `daemon(request)` is the daemon's control socket. Answers: `this-computer` with {publicKey, hostname, label, role},
113
- * `computer-offer` with a pairing link's fragment for this browser.
113
+ * `computer-offer` with a pairing link's fragment for this browser once the person allows it on this computer.
114
114
  */
115
115
  export async function serveNativeHost({
116
116
  input,
@@ -159,11 +159,39 @@ export async function serveNativeHost({
159
159
  }
160
160
  : { ok: false, error: found?.error || "the daemon did not say" };
161
161
  }
162
+ // The page asking is served by Harness, so its word alone makes no offer: the daemon asks the person on this
163
+ // computer, and the host waits for their answer (as long as the ask lasts, the offer's ten minutes).
162
164
  if (message?.type === "computer-offer") {
163
- const made = await daemon({ command: "phone.offer", kind: "browser" });
164
- if (!made?.ok || typeof made.url !== "string")
165
- return { ok: false, error: made?.error || "no offer was made" };
166
- return { ok: true, fragment: new URL(made.url).hash };
165
+ let asked = null;
166
+ do
167
+ asked = await daemon(
168
+ {
169
+ command: "phone.link.ask",
170
+ id: asked?.id ?? null,
171
+ label: String(message.label ?? "").slice(0, 60),
172
+ waitMs: 25_000,
173
+ },
174
+ 30_000
175
+ );
176
+ while (asked?.ok && asked.state === "waiting" && !closed);
177
+ if (asked?.ok && asked.state === "allowed" && asked.url)
178
+ return { ok: true, fragment: new URL(asked.url).hash };
179
+ return {
180
+ ok: false,
181
+ code: asked?.state ?? "failed",
182
+ error:
183
+ asked?.state === "refused" || asked?.state === "expired"
184
+ ? "the person did not allow this browser on this computer"
185
+ : asked?.error || "no offer was made",
186
+ };
187
+ }
188
+ // The extension itself asking to hold this browser's link (its deskKey.js), never a page's ask passed on: the
189
+ // background sends this on its own, and the key it pairs stays in the extension.
190
+ if (message?.type === "extension-link") {
191
+ const made = await daemon({ command: "phone.link.extension" });
192
+ return made?.ok && made.fragment
193
+ ? { ok: true, fragment: made.fragment }
194
+ : { ok: false, error: made?.error || "no offer was made" };
167
195
  }
168
196
  return { ok: false, error: "unknown message" };
169
197
  } catch (error) {
package/lib/network.mjs CHANGED
@@ -22,6 +22,8 @@ export function createNetwork({
22
22
  myKey,
23
23
  // A relay thread that carries a shared project (projects.mjs): Swarms lists the project, not the thread under it.
24
24
  isChannel = () => false,
25
+ // The person blocked a handle: whatever is open with them on this computer ends (security audit P9).
26
+ blocked = () => {},
25
27
  }) {
26
28
  // Harness answers for the server's half; a refusal comes back as a plain error the person can read.
27
29
  const harness = async (input) => {
@@ -35,7 +37,21 @@ export function createNetwork({
35
37
  // One row per request or thread, grouped by what it needs: the person (a request to answer, a held reply,
36
38
  // a message from a person), nothing (open), the other side (a request not answered yet), or nobody (ended).
37
39
  const conversations = async () => {
38
- const server = await harness({ op: "threads" }).catch(() => null);
40
+ const [server, card] = await Promise.all([
41
+ harness({ op: "threads" }).catch(() => null),
42
+ harness({ op: "card" }).catch(() => null),
43
+ ]);
44
+ // A block made where this computer did not hear it (the dashboard while it was off) ends what is open here too.
45
+ for (const handle of Array.isArray(card?.blocks) ? card.blocks : [])
46
+ if (
47
+ store
48
+ .relayThreads()
49
+ .some(
50
+ (row) =>
51
+ !row.closed_at && handleOf(row.with_agent) === handleOf(handle)
52
+ )
53
+ )
54
+ blocked(handleOf(handle));
39
55
  const local = new Map(
40
56
  store.relayThreads().map((row) => [row.task_id, row])
41
57
  );
@@ -54,6 +70,7 @@ export function createNetwork({
54
70
  const opened = await openRelayRequest({
55
71
  sealed: thread.sealed,
56
72
  from: `${peer.handle}/${peer.agent}`,
73
+ id: thread.role === "target" ? thread.id : null,
57
74
  }).catch(() => null);
58
75
  if (opened) {
59
76
  about = opened.about;
@@ -221,14 +238,28 @@ export function createNetwork({
221
238
  return answered(conversations());
222
239
  // The server's half of Swarms (card, search, contacts, blocks): what the dashboard asks Harness directly.
223
240
  case "board.relay.network": {
224
- const { command: _command, agent: _agent, ...input } = request;
241
+ // Only the operation's own fields go to Harness, which refuses any other (a browser's call adds fromWindow and
242
+ // sealedBy, phones.mjs).
243
+ const {
244
+ command: _command,
245
+ agent: _agent,
246
+ fromWindow: _fromWindow,
247
+ hostedCaller: _hosted,
248
+ provenance: _provenance,
249
+ sealedBy: _sealedBy,
250
+ ...input
251
+ } = request;
225
252
  if (input.op === "decide" || input.op === "threads")
226
253
  return {
227
254
  ok: false,
228
255
  error: "use board.relay.decide and board.relay.list",
229
256
  };
230
257
  return answered(
231
- harness(input).then((answer) => ({ ok: true, ...answer }))
258
+ harness(input).then((answer) => {
259
+ if (input.op === "block" && input.on === true)
260
+ blocked(handleOf(input.handle));
261
+ return { ok: true, ...answer };
262
+ })
232
263
  );
233
264
  }
234
265
  case "board.relay.decide":
@@ -239,7 +270,11 @@ export function createNetwork({
239
270
  op: "decide",
240
271
  id,
241
272
  decision: String(request.decision),
242
- }).then((answer) => ({ ok: true, ...answer }))
273
+ }).then((answer) => {
274
+ if (request.decision === "block" && answer.thread?.asker?.handle)
275
+ blocked(handleOf(answer.thread.asker.handle));
276
+ return { ok: true, ...answer };
277
+ })
243
278
  );
244
279
  // A request from this computer: to one of their listed agents from one of the person's, or to the person themselves.
245
280
  case "board.relay.request": {
@@ -256,6 +291,7 @@ export function createNetwork({
256
291
  about: request.about,
257
292
  brief: request.brief,
258
293
  refs: request.refs,
294
+ readable: request.readable === true,
259
295
  }).then((made) => ({ ok: true, ...made }))
260
296
  );
261
297
  }
@@ -310,5 +346,14 @@ export function createNetwork({
310
346
  return answer.card?.handle ?? null;
311
347
  };
312
348
 
313
- return { command, opened, invites, sentProjects, decide, myHandle };
349
+ return {
350
+ command,
351
+ opened,
352
+ invites,
353
+ sentProjects,
354
+ decide,
355
+ myHandle,
356
+ // Harness says the person blocked a handle from another of their screens.
357
+ blockedElsewhere: (handle) => blocked(handleOf(handle)),
358
+ };
314
359
  }
package/lib/notify.mjs CHANGED
@@ -9,7 +9,7 @@ import { nameOf } from "./members.mjs";
9
9
 
10
10
  const TITLE = "Harness";
11
11
 
12
- function command(platform, title, body, env) {
12
+ export function command(platform, title, body, env) {
13
13
  if (env.HARNESS_NOTIFY_COMMAND)
14
14
  return { command: env.HARNESS_NOTIFY_COMMAND, args: [title, body] };
15
15
  if (platform === "darwin") {
@@ -25,17 +25,18 @@ function command(platform, title, body, env) {
25
25
  }
26
26
  if (platform === "linux")
27
27
  return { command: "notify-send", args: [title, body] };
28
- if (platform === "win32") {
29
- const quote = (value) => String(value).replaceAll("'", "''");
28
+ // The words go in through the environment, never into the script: PowerShell also ends a quoted string at the
29
+ // typographic quotes an agent's words can carry, so no escaping of them inside a script is safe.
30
+ if (platform === "win32")
30
31
  return {
31
32
  command: "powershell",
32
33
  args: [
33
34
  "-NoProfile",
34
35
  "-Command",
35
- `[void][System.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms'); $n = New-Object System.Windows.Forms.NotifyIcon; $n.Icon = [System.Drawing.SystemIcons]::Information; $n.Visible = $true; $n.ShowBalloonTip(8000, '${quote(title)}', '${quote(body)}', 'Info'); Start-Sleep -Seconds 9; $n.Dispose()`,
36
+ "[void][System.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms'); $n = New-Object System.Windows.Forms.NotifyIcon; $n.Icon = [System.Drawing.SystemIcons]::Information; $n.Visible = $true; $n.ShowBalloonTip(8000, $env:HARNESS_NOTICE_TITLE, $env:HARNESS_NOTICE_BODY, 'Info'); Start-Sleep -Seconds 9; $n.Dispose()",
36
37
  ],
38
+ env: { HARNESS_NOTICE_TITLE: title, HARNESS_NOTICE_BODY: body },
37
39
  };
38
- }
39
40
  return null;
40
41
  }
41
42
 
@@ -49,6 +50,7 @@ export function notifyDesktop(
49
50
  const child = spawn(call.command, call.args, {
50
51
  stdio: "ignore",
51
52
  detached: true,
53
+ ...(call.env ? { env: { ...env, ...call.env } } : {}),
52
54
  });
53
55
  child.on("error", () => {});
54
56
  child.unref();
package/lib/nudge.mjs CHANGED
@@ -16,9 +16,9 @@ import { hookDialect, hookInput } from "./hookDialects.mjs";
16
16
  // import this file from the runtime and call the same functions. Nothing waiting, or no daemon, prints nothing.
17
17
 
18
18
  // What a session start may carry. Claude Code 2.1.304 cuts an MCP server's instructions at 4,096 characters and ends
19
- // them "… [truncated]" (its CLAUDE_CODE_MAX_MCP_DESCRIPTION_LENGTH default); a session on the owner's machine on October
20
- // 20 got its handshake cut that way, the last agent cards lost. No client cut a shorter one, so the hook's text keeps to
21
- // the same budget, and the handshake to what is left of it after the server's own instructions (mcp-stdio.mjs).
19
+ // them "… [truncated]" (its CLAUDE_CODE_MAX_MCP_DESCRIPTION_LENGTH default); a real session got its handshake cut that
20
+ // way, the last agent cards lost. No client cut a shorter one, so the hook's text keeps to the same budget, and the
21
+ // handshake to what is left of it after the server's own instructions (mcp-stdio.mjs).
22
22
  export const HANDSHAKE_LIMIT = 4_096;
23
23
  // Each list names this many before saying how many more list_tasks has.
24
24
  const LISTED = 5;
package/lib/ocr.mjs CHANGED
@@ -197,12 +197,12 @@ function regions(map, width, height) {
197
197
  return boxes;
198
198
  }
199
199
 
200
- // The detector's memory grows with its input (about 1 KB a pixel: 1.6 GB for a 2048x1280 screenshot, measured
201
- // October 14), and ONNX Runtime keeps memory for every input shape it has run. So the detector reads full-width bands
202
- // WINDOW rows tall, always the same shape (rows past the image and columns up to a multiple of 512 repeat its edge), and
203
- // the probability map is stitched from rows at least MARGIN from a band's edge. Lines are never cut: regions are found
204
- // on the whole map. On the image-redaction eval's screens this found what one pass did, and the OCR models' memory
205
- // levelled off at 544 MB instead of growing past 2 GB (160-row bands; 256 rows: 766 MB and about 10% faster).
200
+ // The detector's memory grows with its input (measured at about 1 KB a pixel: 1.6 GB for a 2048x1280 screenshot), and
201
+ // ONNX Runtime keeps memory for every input shape it has run. So the detector reads full-width bands WINDOW rows tall,
202
+ // always the same shape (rows past the image and columns up to a multiple of 512 repeat its edge), and the probability
203
+ // map is stitched from rows at least MARGIN from a band's edge. Lines are never cut: regions are found on the whole
204
+ // map. On a fixed set of test screenshots this found what one pass did, and the OCR models' memory levelled off at
205
+ // 544 MB instead of growing past 2 GB (160-row bands; 256 rows: 766 MB and about 10% faster).
206
206
  const BAND = 160,
207
207
  MARGIN = 32,
208
208
  WINDOW = BAND + 2 * MARGIN;
@@ -262,9 +262,9 @@ async function detect(image, { ort, graph }) {
262
262
  .filter(([x0, y0, x1, y1]) => x1 - x0 >= 4 && y1 - y0 >= 4);
263
263
  }
264
264
 
265
- // ONNX Runtime keeps memory for every input shape it has run (400 crop widths: 108 MB grew to 513 MB, October 14), so
266
- // crops are padded on the right to a few widths, with 0 after normalization as PaddleOCR's own batches pad. Over this
267
- // eval's screens that changed 16 of 845 lines, by spacing or a dash, none of a planted value.
265
+ // ONNX Runtime keeps memory for every input shape it has run (400 crop widths: 108 MB grew to 513 MB), so crops are
266
+ // padded on the right to a few widths, with 0 after normalization as PaddleOCR's own batches pad. Over the same test
267
+ // screenshots, that changed 16 of 845 lines, by spacing or a dash, none of a planted value.
268
268
  const bucket = (width) =>
269
269
  width <= 512 ? Math.ceil(width / 32) * 32 : Math.ceil(width / 64) * 64;
270
270
 
package/lib/onboard.mjs CHANGED
@@ -8,6 +8,7 @@ import {
8
8
  } from "./wakes.mjs";
9
9
  import { columns, createUi, wrap } from "./ui.mjs";
10
10
  import { CHECKABLE, SIGN_IN } from "./readiness.mjs";
11
+ import { relayCommand } from "./runtime-install.mjs";
11
12
 
12
13
  // "Your swarm" in setup: every agent class with how Harness reaches it, the recommended way already chosen, and a real
13
14
  // test at the end that passes only when the agent claims and reports a task. Also reachable on its own as
@@ -20,10 +21,10 @@ const LABEL = {
20
21
  "grok-bot": "Grok Bot",
21
22
  };
22
23
  const later = (agent) =>
23
- `Later: ${pc.cyan(`npx tryharness agents setup ${agent}`)}`;
24
+ `Later: ${pc.cyan(`${relayCommand()} agents setup ${agent}`)}`;
24
25
 
25
- // The Harness mark (src/main/home/landing/walkthrough/BrandMark.tsx) in box characters: dim corners, the bright one in
26
- // Harness teal, the wordmark beside it. Plain when the output is not a terminal or NO_COLOR is set.
26
+ // The Harness mark, as the app's walkthrough draws it, in box characters: dim corners, the bright one in Harness teal,
27
+ // the wordmark beside it. Plain when the output is not a terminal or NO_COLOR is set.
27
28
  export function banner(version, { color = pc.isColorSupported } = {}) {
28
29
  const c = pc.createColors(color),
29
30
  teal = (text) => (color ? `\x1b[38;5;36m${text}\x1b[39m` : text);
@@ -120,7 +121,7 @@ export async function testAgent({
120
121
  }
121
122
  }
122
123
  spin.stop(
123
- `No answer after ${Math.round(waitMs / 60_000)} minutes. Check that ${name} is running, then: npx tryharness agents test ${agent}`,
124
+ `No answer after ${Math.round(waitMs / 60_000)} minutes. Check that ${name} is running, then: ${relayCommand()} agents test ${agent}`,
124
125
  2
125
126
  );
126
127
  return false;
@@ -292,7 +293,7 @@ async function setupGrok({ ui, daemonRequest, clipboard }) {
292
293
  });
293
294
  if (!saved.ok) {
294
295
  ui.warn(
295
- `${saved.error}. Try again: npx tryharness agents setup grok-bot`
296
+ `${saved.error}. Try again: ${relayCommand()} agents setup grok-bot`
296
297
  );
297
298
  return false;
298
299
  }
@@ -363,7 +364,7 @@ async function setupGrok({ ui, daemonRequest, clipboard }) {
363
364
  ? { ok, line: "Grok registered its address" }
364
365
  : {
365
366
  ok,
366
- line: "Grok has not registered yet. When it has: npx tryharness agents test grok-bot",
367
+ line: `Grok has not registered yet. When it has: ${relayCommand()} agents test grok-bot`,
367
368
  }
368
369
  );
369
370
  const answer = await ui.waitOrType({
@@ -444,8 +445,12 @@ export async function setupSwarm({
444
445
  );
445
446
  }
446
447
 
447
- const ADD_LATER = `Add another agent any time: ${pc.cyan("npx tryharness agents add")}, or Settings, then Your swarm, in the Harness app.`;
448
- const JOINS_LATER = `Install or sign in another agent any time: it joins your swarm by itself once it answers. ${pc.dim(`Or: npx tryharness agents add`)}`;
448
+ // A function, not a constant: the installed command only exists once setup has installed the runtime.
449
+ const ADD_LATER = () =>
450
+ `Add another agent any time: ${pc.cyan(`${relayCommand()} agents add`)}, or Settings, then Your swarm, in the Harness app.`;
451
+ // A function, not a constant: the installed command only exists once setup has installed the runtime.
452
+ const JOINS_LATER = () =>
453
+ `Install or sign in another agent any time: it joins your swarm by itself once it answers. ${pc.dim(`Or: ${relayCommand()} agents add`)}`;
449
454
 
450
455
  const COMMAND = {
451
456
  "claude-code": "claude",
@@ -609,10 +614,11 @@ export async function setupChosen({
609
614
  );
610
615
  for (const entry of local)
611
616
  await setupLocal({ entry, runtimeRoot, ui, daemonRequest, ask: false });
612
- ui.info(JOINS_LATER);
617
+ ui.info(JOINS_LATER());
613
618
  }
614
619
 
615
- const T3_LATER = `Later: ${pc.cyan("npx tryharness t3")}`;
620
+ // A function, not a constant: the installed command only exists once setup has installed the runtime.
621
+ const T3_LATER = () => `Later: ${pc.cyan(`${relayCommand()} t3`)}`;
616
622
  const t3Line = (access) =>
617
623
  access?.state === "send"
618
624
  ? {
@@ -651,7 +657,7 @@ export async function setupT3({ ui = createUi(), daemonRequest, open }) {
651
657
  if (first.t3?.state === "expired")
652
658
  ui.info("Harness's approval in T3 Code ran out.");
653
659
  if (!ui.interactive) {
654
- ui.info(T3_LATER);
660
+ ui.info(T3_LATER());
655
661
  return;
656
662
  }
657
663
  const approve = await ui.select({
@@ -666,7 +672,7 @@ export async function setupT3({ ui = createUi(), daemonRequest, open }) {
666
672
  ],
667
673
  });
668
674
  if (approve !== "approve") {
669
- ui.info(`Skipped. ${T3_LATER}`);
675
+ ui.info(`Skipped. ${T3_LATER()}`);
670
676
  return;
671
677
  }
672
678
  for (;;) {
@@ -675,7 +681,7 @@ export async function setupT3({ ui = createUi(), daemonRequest, open }) {
675
681
  if (!started.ok) {
676
682
  ui.warn(started.error || "Harness could not start the approval.");
677
683
  if (started.code !== "not_running") {
678
- ui.info(T3_LATER);
684
+ ui.info(T3_LATER());
679
685
  return;
680
686
  }
681
687
  const next = await ui.select({
@@ -686,7 +692,7 @@ export async function setupT3({ ui = createUi(), daemonRequest, open }) {
686
692
  ],
687
693
  });
688
694
  if (next !== "check") {
689
- ui.info(`Skipped. ${T3_LATER}`);
695
+ ui.info(`Skipped. ${T3_LATER()}`);
690
696
  return;
691
697
  }
692
698
  continue;
@@ -718,7 +724,7 @@ export async function setupT3({ ui = createUi(), daemonRequest, open }) {
718
724
  if (answer.cancelled) {
719
725
  settled = true;
720
726
  ui.info(
721
- `Stopped waiting. Approving it on that page still counts. ${T3_LATER}`
727
+ `Stopped waiting. Approving it on that page still counts. ${T3_LATER()}`
722
728
  );
723
729
  return;
724
730
  }
@@ -754,7 +760,7 @@ export async function showLineup({ daemonRequest, ui = createUi() }) {
754
760
  const lineup = await daemonRequest({ command: "swarm.lineup" });
755
761
  if (!lineup?.ok) {
756
762
  ui.warn(
757
- lineup?.error || "Harness is not running here. Run: npx tryharness"
763
+ lineup?.error || `Harness is not running here. Run: ${relayCommand()}`
758
764
  );
759
765
  return;
760
766
  }
@@ -765,7 +771,7 @@ export async function showLineup({ daemonRequest, ui = createUi() }) {
765
771
  ui.step(
766
772
  `Your swarm ${pc.dim("· ✓ in it, + can be added")}\n${rows.join("\n")}`
767
773
  );
768
- ui.info(ADD_LATER);
774
+ ui.info(ADD_LATER());
769
775
  }
770
776
 
771
777
  /**
@@ -781,7 +787,7 @@ export async function addAgents({
781
787
  const lineup = await daemonRequest({ command: "swarm.lineup" });
782
788
  if (!lineup?.ok) {
783
789
  ui.warn(
784
- lineup?.error || "Harness is not running here. Run: npx tryharness"
790
+ lineup?.error || `Harness is not running here. Run: ${relayCommand()}`
785
791
  );
786
792
  return false;
787
793
  }
@@ -806,7 +812,7 @@ export async function addAgents({
806
812
  }
807
813
  if (!ui.interactive) {
808
814
  ui.info(
809
- `Can be added: ${open.map((entry) => entry.id).join(", ")}. Run: npx tryharness agents add <agent>`
815
+ `Can be added: ${open.map((entry) => entry.id).join(", ")}. Run: ${relayCommand()} agents add <agent>`
810
816
  );
811
817
  return true;
812
818
  }
@@ -856,7 +862,7 @@ export async function removeAgent({ daemonRequest, agent, ui = createUi() }) {
856
862
  return false;
857
863
  }
858
864
  ui.success(
859
- `${removed.name} is out of your swarm. Add it back any time: npx tryharness agents add ${agent}`
865
+ `${removed.name} is out of your swarm. Add it back any time: ${relayCommand()} agents add ${agent}`
860
866
  );
861
867
  return true;
862
868
  }