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
@@ -1,13 +1,21 @@
1
1
  // This computer asking the person's own Harness window for what only it holds (phones.mjs ask): this computer's own
2
2
  // windows first, then those linked to each of the person's other computers (ownMachines.mjs). With no Harness window
3
3
  // open, the browser that listens for this computer (browserWake.mjs, the extension's native host) is woken: the
4
- // extension brings up its hidden Harness page, which answers like a tab (owner, October 22: the swarm reads what the
5
- // person has seen from the hidden page). It is asked again as it comes up, until WAKE_DEADLINE_MS.
4
+ // extension brings up its hidden Harness page, which answers like a tab (the swarm reads what the person has seen from
5
+ // the hidden page). It is asked again as it comes up, until WAKE_DEADLINE_MS.
6
6
 
7
- // How long to keep asking a woken hidden page: the owner's value (October 22: "lets go 1 min on the wait"). Measured
8
- // only against a local app on loopback (e2e hidden-page-seen, run 20261022-161745-75cbcea9-f21f: closed page to
9
- // answer 1.04 to 1.08 s, 5 samples on an M5 Pro), never against tryharness.ai.
7
+ // How long to keep asking a woken hidden page: one minute, a chosen value. Measured only against a local app on
8
+ // loopback (an end-to-end test: closed page to answer 1.04 to 1.08 s, 5 samples on an M5 Pro), never against
9
+ // tryharness.ai.
10
10
  export const WAKE_DEADLINE_MS = 60_000;
11
+ // What home may ask the windows linked to a worker (ownMachines.mjs): the person's screen history, as its agents' tools
12
+ // ask it (boardTools.mjs search_screen, seen.mjs). A worker refuses any other tool home names (security audit
13
+ // 2026-10-25, M6).
14
+ export const WINDOW_TOOLS = new Set([
15
+ "search_screen_text",
16
+ "search_screen_semantic",
17
+ "screen_seen_since",
18
+ ]);
11
19
  const ASK_EVERY_MS = 1_000;
12
20
 
13
21
  export function createWindowAsks({
package/lib/worktrees.mjs CHANGED
@@ -14,9 +14,10 @@ const IDENTITY = [
14
14
  ];
15
15
  const PATCH_LIMIT = 200_000;
16
16
 
17
- function git(cwd, args) {
17
+ function git(cwd, args, env = process.env) {
18
18
  const result = spawnSync("git", [...IDENTITY, ...args], {
19
19
  cwd,
20
+ env,
20
21
  encoding: "utf8",
21
22
  maxBuffer: 16 * 1024 * 1024,
22
23
  });
@@ -27,6 +28,49 @@ function git(cwd, args) {
27
28
  };
28
29
  }
29
30
 
31
+ // A thread's copy is where an agent's run writes, a restricted one included, so nothing in it decides what git runs
32
+ // when the daemon commits there: the repository is the one the daemon recorded (GIT_DIR), never the copy's own .git
33
+ // file, and no hook or file monitor runs. A copy whose .git file no longer points where the daemon made it is not
34
+ // touched at all (changedGit).
35
+ const NO_HOOKS = [
36
+ "-c",
37
+ "core.hooksPath=/dev/null",
38
+ "-c",
39
+ "core.fsmonitor=false",
40
+ ];
41
+
42
+ // git writes every path it records resolved through symlinks (macOS's /var is /private/var), so a path the daemon
43
+ // holds is compared the same way.
44
+ const sameFile = (a, b) => {
45
+ const real = (file) => {
46
+ try {
47
+ return fs.realpathSync(file);
48
+ } catch {
49
+ return path.resolve(file);
50
+ }
51
+ };
52
+ return real(a) === real(b);
53
+ };
54
+
55
+ /** The worktree's own folder in its repository's .git, found from the repository the person's checkout uses. */
56
+ function adminDirOf(repo, where) {
57
+ const common = git(repo, [
58
+ "rev-parse",
59
+ "--path-format=absolute",
60
+ "--git-common-dir",
61
+ ]).out;
62
+ const admin = path.join(common, "worktrees");
63
+ const target = path.resolve(where, ".git");
64
+ for (const name of fs.existsSync(admin) ? fs.readdirSync(admin) : []) {
65
+ const pointer = path.join(admin, name, "gitdir");
66
+ try {
67
+ if (sameFile(fs.readFileSync(pointer, "utf8").trim(), target))
68
+ return path.join(admin, name);
69
+ } catch {}
70
+ }
71
+ return null;
72
+ }
73
+
30
74
  /** The repository a folder is in, and the folder's place inside it; null when it is not in one. */
31
75
  export function repositoryOf(folder) {
32
76
  if (!folder || !fs.existsSync(folder)) return null;
@@ -84,6 +128,33 @@ export function createWorktrees({ store, root }) {
84
128
  const save = (threadId, value) =>
85
129
  store.meta(key(threadId), value ? JSON.stringify(value) : "null");
86
130
 
131
+ // The copy's repository as the daemon made it; a record from before it was kept is found from the person's checkout.
132
+ const gitDirOf = (tree) => tree.gitDir ?? adminDirOf(tree.repo, tree.path);
133
+ /** Why the daemon will not run git in a thread's copy, or null: its .git no longer points where the daemon made it. */
134
+ const changedGit = (tree) => {
135
+ const gitDir = gitDirOf(tree);
136
+ if (!gitDir)
137
+ return "Harness cannot find the repository it made this copy in";
138
+ let pointer = "";
139
+ try {
140
+ pointer = fs.readFileSync(path.join(tree.path, ".git"), "utf8").trim();
141
+ } catch {}
142
+ const named = /^gitdir: (.+)$/.exec(pointer)?.[1];
143
+ return named && sameFile(path.resolve(tree.path, named), gitDir)
144
+ ? null
145
+ : "something in the thread's copy replaced its .git";
146
+ };
147
+ /** git in a thread's copy, on the repository the daemon recorded, with no hooks and no file monitor. */
148
+ const inTree = (tree, args) => {
149
+ if (changedGit(tree)) return { ok: false, out: "", err: changedGit(tree) };
150
+ const env = {
151
+ ...process.env,
152
+ GIT_DIR: gitDirOf(tree),
153
+ GIT_WORK_TREE: tree.path,
154
+ };
155
+ return git(tree.path, [...NO_HOOKS, ...args], env);
156
+ };
157
+
87
158
  /** Where a thread's coding runs work: its worktree when the folder is in a repository, else the folder itself. */
88
159
  const folderFor = (thread) => {
89
160
  const folder = thread.goal.workspace;
@@ -121,6 +192,7 @@ export function createWorktrees({ store, root }) {
121
192
  path: where,
122
193
  branch,
123
194
  base,
195
+ gitDir: adminDirOf(repo.root, where),
124
196
  });
125
197
  return path.join(where, repo.inside);
126
198
  };
@@ -134,7 +206,7 @@ export function createWorktrees({ store, root }) {
134
206
  const startTurn = (threadId, runId) => {
135
207
  const tree = openTree(threadId);
136
208
  if (!tree) return;
137
- store.meta(`turn-from:${runId}`, git(tree.path, ["rev-parse", "HEAD"]).out);
209
+ store.meta(`turn-from:${runId}`, inTree(tree, ["rev-parse", "HEAD"]).out);
138
210
  };
139
211
 
140
212
  /**
@@ -144,13 +216,19 @@ export function createWorktrees({ store, root }) {
144
216
  */
145
217
  const commitTurn = (threadId, runId, message) => {
146
218
  const tree = openTree(threadId);
147
- if (!tree) return null;
148
- git(tree.path, ["add", "-A"]);
149
- const staged = !git(tree.path, ["diff", "--cached", "--quiet"]).ok;
219
+ if (!tree || changedGit(tree)) return null;
220
+ inTree(tree, ["add", "-A"]);
221
+ const staged = !inTree(tree, ["diff", "--cached", "--quiet"]).ok;
150
222
  const committed =
151
223
  staged &&
152
- git(tree.path, ["commit", "-q", "-m", String(message).slice(0, 200)]).ok;
153
- const sha = git(tree.path, ["rev-parse", "HEAD"]).out;
224
+ inTree(tree, [
225
+ "commit",
226
+ "-q",
227
+ "--no-verify",
228
+ "-m",
229
+ String(message).slice(0, 200),
230
+ ]).ok;
231
+ const sha = inTree(tree, ["rev-parse", "HEAD"]).out;
154
232
  // A turn from before turns recorded their start counts only the commit made here.
155
233
  const from = store.meta(`turn-from:${runId}`);
156
234
  const moved = from ? sha !== from : committed;
@@ -163,15 +241,17 @@ export function createWorktrees({ store, root }) {
163
241
  const uncommitted = (threadId) => {
164
242
  const tree = openTree(threadId);
165
243
  if (!tree) return [];
166
- const lines = (args) =>
167
- git(tree.path, args).out.split("\n").filter(Boolean);
244
+ const lines = (args) => inTree(tree, args).out.split("\n").filter(Boolean);
168
245
  const changed = lines(["diff", "--name-only", "HEAD"]);
169
246
  const added = lines(["ls-files", "--others", "--exclude-standard"]);
170
247
  return [...new Set([...changed, ...added])];
171
248
  };
172
249
 
173
- const stat = (cwd, range) => {
174
- const out = git(cwd, ["diff", "--numstat", range]).out;
250
+ // `where`: a thread's copy (its record) or the person's checkout (a folder).
251
+ const run = (where, args) =>
252
+ typeof where === "string" ? git(where, args) : inTree(where, args);
253
+ const stat = (where, range) => {
254
+ const out = run(where, ["diff", "--numstat", range]).out;
175
255
  const files = out
176
256
  ? out.split("\n").map((line) => {
177
257
  const [added, removed, file] = line.split("\t");
@@ -190,7 +270,7 @@ export function createWorktrees({ store, root }) {
190
270
  const tree = get(threadId);
191
271
  if (!tree)
192
272
  return { ok: false, error: "this thread has no copy of a repository" };
193
- const cwd = fs.existsSync(tree.path) ? tree.path : tree.repo;
273
+ const cwd = fs.existsSync(tree.path) ? tree : tree.repo;
194
274
  let range;
195
275
  if (runId) {
196
276
  const sha = store.meta(`turn:${runId}`);
@@ -199,7 +279,7 @@ export function createWorktrees({ store, root }) {
199
279
  range = from ? `${from}..${sha}` : `${sha}~1..${sha}`;
200
280
  } else
201
281
  range = `${tree.base}..${tree.state === "open" ? "HEAD" : tree.branch}`;
202
- const patch = git(cwd, ["diff", range]).out;
282
+ const patch = run(cwd, ["diff", range]).out;
203
283
  return {
204
284
  ok: true,
205
285
  files: stat(cwd, range),
@@ -218,13 +298,17 @@ export function createWorktrees({ store, root }) {
218
298
  if (!tree || tree.state === "in_place" || tree.state === "t3") return null;
219
299
  const files =
220
300
  tree.state === "open" && fs.existsSync(tree.path)
221
- ? stat(tree.path, `${tree.base}..HEAD`).length
301
+ ? stat(tree, `${tree.base}..HEAD`).length
222
302
  : 0;
223
303
  return { state: tree.state, branch: tree.branch, repo: tree.repo, files };
224
304
  };
225
305
 
226
306
  const retire = (tree) => {
227
- git(tree.repo, ["worktree", "remove", "--force", tree.path]);
307
+ // A copy whose .git was replaced is not one git will remove; it is the daemon's own folder, so it goes as files.
308
+ const ours = path.relative(root, tree.path);
309
+ if (changedGit(tree) && ours && !ours.startsWith(".."))
310
+ fs.rmSync(tree.path, { recursive: true, force: true });
311
+ else git(tree.repo, ["worktree", "remove", "--force", tree.path]);
228
312
  git(tree.repo, ["worktree", "prune"]);
229
313
  };
230
314
 
@@ -233,7 +317,12 @@ export function createWorktrees({ store, root }) {
233
317
  const tree = get(threadId);
234
318
  if (!tree || tree.state !== "open")
235
319
  return { ok: false, error: "there is nothing of this thread's to merge" };
236
- if (!stat(tree.path, `${tree.base}..HEAD`).length)
320
+ if (changedGit(tree))
321
+ return {
322
+ ok: false,
323
+ error: `${changedGit(tree)}, so Harness does not merge it; discard it`,
324
+ };
325
+ if (!stat(tree, `${tree.base}..HEAD`).length)
237
326
  return { ok: false, error: "this thread has not changed anything" };
238
327
  const into = git(tree.repo, ["rev-parse", "--abbrev-ref", "HEAD"]).out;
239
328
  const merged = git(tree.repo, [
@@ -295,7 +384,7 @@ export function createWorktrees({ store, root }) {
295
384
  const moved = (threadId) => {
296
385
  const tree = get(threadId);
297
386
  if (tree?.state === "open" && fs.existsSync(tree.path)) {
298
- if (stat(tree.path, `${tree.base}..HEAD`).length)
387
+ if (stat(tree, `${tree.base}..HEAD`).length)
299
388
  return {
300
389
  ok: false,
301
390
  error: `this thread changed files on ${tree.branch}; merge or discard them first`,
@@ -357,7 +446,7 @@ export function createWorktrees({ store, root }) {
357
446
  const tree = get(threadId);
358
447
  if (!tree || tree.state !== "open" || !fs.existsSync(tree.path))
359
448
  return null;
360
- return git(tree.path, ["rev-parse", "HEAD"]).out || null;
449
+ return inTree(tree, ["rev-parse", "HEAD"]).out || null;
361
450
  };
362
451
 
363
452
  return {
@@ -366,6 +455,11 @@ export function createWorktrees({ store, root }) {
366
455
  folderFor,
367
456
  startTurn,
368
457
  commitTurn,
458
+ /** Why the daemon no longer runs git in the thread's copy, or null (a run replaced its .git). */
459
+ changedGit: (threadId) => {
460
+ const tree = openTree(threadId);
461
+ return tree ? changedGit(tree) : null;
462
+ },
369
463
  uncommitted,
370
464
  head,
371
465
  diff,