tryharness 0.7.45 → 0.7.54

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 (125) hide show
  1. package/README.md +239 -14
  2. package/assets/dsh-plugin.mjs +72 -0
  3. package/assets/opencode-plugin.js +4 -3
  4. package/cli.mjs +497 -196
  5. package/lib/actorRoster.mjs +28 -5
  6. package/lib/adapters.mjs +165 -222
  7. package/lib/agentRuntimeConfig.mjs +36 -0
  8. package/lib/agentRuntimes.mjs +570 -0
  9. package/lib/agentSignIn.mjs +226 -0
  10. package/lib/atlas.mjs +7 -2
  11. package/lib/audit.mjs +643 -0
  12. package/lib/backupSetup.mjs +141 -0
  13. package/lib/boardAccess.mjs +8 -1
  14. package/lib/boardBackup.mjs +283 -0
  15. package/lib/boardCommands.mjs +5 -10
  16. package/lib/boardFileCommands.mjs +2 -1
  17. package/lib/boardMirror.mjs +523 -0
  18. package/lib/boardProtocol.json +263 -6
  19. package/lib/boardTools.mjs +2 -6
  20. package/lib/boardWaits.mjs +102 -0
  21. package/lib/book.mjs +659 -0
  22. package/lib/bridge.mjs +26 -4
  23. package/lib/browserWake.mjs +60 -0
  24. package/lib/cards.mjs +159 -16
  25. package/lib/cloudBoot.mjs +124 -0
  26. package/lib/commands.mjs +25 -5
  27. package/lib/connectionTools.d.ts +13 -0
  28. package/lib/connectionTools.js +45 -0
  29. package/lib/connectorAuth.mjs +309 -0
  30. package/lib/connectorCatalog.json +41 -0
  31. package/lib/connectorCommands.mjs +121 -0
  32. package/lib/connectorGoogle.mjs +513 -0
  33. package/lib/connectors.mjs +805 -0
  34. package/lib/context.mjs +18 -4
  35. package/lib/contractGate.mjs +377 -0
  36. package/lib/coordinator.mjs +152 -39
  37. package/lib/coreModels.mjs +78 -0
  38. package/lib/daemon.mjs +973 -54
  39. package/lib/desk.mjs +239 -0
  40. package/lib/desktop.mjs +113 -8
  41. package/lib/digest.mjs +32 -0
  42. package/lib/directLink.mjs +283 -0
  43. package/lib/environments.mjs +825 -0
  44. package/lib/folders.mjs +4 -4
  45. package/lib/gitHost.mjs +174 -0
  46. package/lib/goalCommands.mjs +58 -14
  47. package/lib/hookDialects.mjs +298 -0
  48. package/lib/inference.mjs +263 -152
  49. package/lib/landed.mjs +887 -0
  50. package/lib/lessons.mjs +6 -0
  51. package/lib/lineup.mjs +324 -0
  52. package/lib/live.mjs +284 -13
  53. package/lib/localmodels.mjs +10 -0
  54. package/lib/machineIdentity.mjs +3 -0
  55. package/lib/machineRoutes.mjs +40 -2
  56. package/lib/machineRuns.mjs +30 -3
  57. package/lib/machineSeal.mjs +69 -10
  58. package/lib/mcp-stdio.mjs +189 -120
  59. package/lib/mcpRelay.mjs +119 -0
  60. package/lib/members.json +26 -0
  61. package/lib/members.mjs +33 -0
  62. package/lib/modelMemory.mjs +100 -0
  63. package/lib/models.mjs +48 -15
  64. package/lib/museSession.mjs +122 -0
  65. package/lib/nativeHost.mjs +203 -0
  66. package/lib/neovim.mjs +126 -0
  67. package/lib/network.mjs +7 -2
  68. package/lib/nudge.mjs +57 -18
  69. package/lib/onboard.mjs +430 -1
  70. package/lib/oneclawLocal.mjs +150 -0
  71. package/lib/ownMachines.mjs +828 -39
  72. package/lib/pairing.mjs +182 -0
  73. package/lib/paths.mjs +8 -0
  74. package/lib/personModel.mjs +89 -0
  75. package/lib/phones.mjs +119 -3
  76. package/lib/placeCommands.mjs +27 -0
  77. package/lib/places.mjs +337 -9
  78. package/lib/plans.mjs +151 -27
  79. package/lib/profile.mjs +152 -0
  80. package/lib/projects.mjs +624 -137
  81. package/lib/readiness.mjs +400 -0
  82. package/lib/record.mjs +115 -0
  83. package/lib/repoLinks.mjs +354 -0
  84. package/lib/roomChannels.mjs +641 -0
  85. package/lib/runBrief.mjs +32 -2
  86. package/lib/runRequests.mjs +157 -0
  87. package/lib/runWorker.mjs +37 -9
  88. package/lib/runner.mjs +74 -11
  89. package/lib/secretPatterns.json +55 -0
  90. package/lib/secrets.mjs +10 -27
  91. package/lib/seen.mjs +102 -0
  92. package/lib/service.mjs +11 -6
  93. package/lib/sessionControl.mjs +386 -96
  94. package/lib/sessionIndex.mjs +5 -3
  95. package/lib/specialties.json +74 -0
  96. package/lib/specialties.mjs +477 -0
  97. package/lib/specialtyKeys.d.ts +3 -0
  98. package/lib/specialtyKeys.js +58 -0
  99. package/lib/specialtyNotice.mjs +147 -0
  100. package/lib/specialtySnapshot.mjs +138 -0
  101. package/lib/store.mjs +829 -29
  102. package/lib/subagents.mjs +8 -4
  103. package/lib/swarm.mjs +483 -37
  104. package/lib/swarmMemory.mjs +947 -0
  105. package/lib/t3.mjs +56 -17
  106. package/lib/taskCommands.mjs +91 -13
  107. package/lib/taskRuns.mjs +68 -11
  108. package/lib/team.json +253 -144
  109. package/lib/team.mjs +538 -147
  110. package/lib/threadLine.mjs +116 -0
  111. package/lib/threadRuns.mjs +78 -12
  112. package/lib/threadView.mjs +66 -16
  113. package/lib/tokenizer.mjs +405 -0
  114. package/lib/ui.mjs +16 -2
  115. package/lib/usageTotals.mjs +148 -0
  116. package/lib/vault.mjs +1144 -0
  117. package/lib/vaultCloud.mjs +117 -0
  118. package/lib/vaultCommands.mjs +201 -0
  119. package/lib/vaultTools.d.ts +12 -0
  120. package/lib/vaultTools.js +42 -0
  121. package/lib/windowAsks.mjs +42 -0
  122. package/lib/workFocus.mjs +59 -0
  123. package/lib/workLinks.mjs +90 -0
  124. package/lib/worktrees.mjs +51 -13
  125. package/package.json +10 -5
package/lib/neovim.mjs ADDED
@@ -0,0 +1,126 @@
1
+ import fs from "node:fs";
2
+ import os from "node:os";
3
+ import path from "node:path";
4
+ import { spawnSync } from "node:child_process";
5
+ import { hostApp, processTable, tmuxPlace } from "./live.mjs";
6
+
7
+ // A session in a Neovim terminal (:terminal), opened inside that Neovim. Neovim gives everything it runs in a terminal
8
+ // its own server's address ($NVIM), and answers there: any nvim can send it an expression (nvim --server <address>
9
+ // --remote-expr), which is how the session's terminal buffer is brought up, or a session resumed in a new tab. Neovim
10
+ // itself runs in a terminal app, whose tab (or tmux, WezTerm or kitty pane) then comes forward like any other's.
11
+
12
+ /** An nvim to speak to a server with: one running now (the daemon's PATH may not have it), else a usual install. */
13
+ function nvimBinary(table) {
14
+ const running = [...table.values()]
15
+ .map((row) => row.comm)
16
+ .filter((comm) => path.isAbsolute(comm) && path.basename(comm) === "nvim");
17
+ const usual = [
18
+ ...(process.env.PATH || "").split(path.delimiter),
19
+ "/opt/homebrew/bin",
20
+ "/usr/local/bin",
21
+ "/usr/bin",
22
+ "/snap/bin",
23
+ path.join(os.homedir(), ".local", "bin"),
24
+ path.join(os.homedir(), "bin"),
25
+ ]
26
+ .filter(Boolean)
27
+ .map((dir) => path.join(dir, "nvim"));
28
+ return [...running, ...usual].find((file) => fs.existsSync(file)) ?? null;
29
+ }
30
+
31
+ /**
32
+ * Runs a Lua chunk in the Neovim at `server`, with `data` as its argument; its answer as text, or null when no Neovim
33
+ * answers there. The chunk and data travel as one JSON value, which Vim script reads as its own list.
34
+ */
35
+ function inNeovim(server, code, data, table) {
36
+ if (typeof server !== "string" || !server) return null;
37
+ // A socket that is gone means a Neovim that closed: no nvim started to find that out.
38
+ if (path.isAbsolute(server) && !fs.existsSync(server)) return null;
39
+ const nvim = nvimBinary(table);
40
+ if (!nvim) return null;
41
+ const expr = `luaeval('(loadstring or load)(_A[1])(_A[2])', ${JSON.stringify([code, data])})`;
42
+ const ran = spawnSync(nvim, ["--server", server, "--remote-expr", expr], {
43
+ encoding: "utf8",
44
+ timeout: 3_000,
45
+ stdio: ["ignore", "pipe", "pipe"],
46
+ });
47
+ return ran.status === 0 ? ran.stdout.trim() : null;
48
+ }
49
+
50
+ /**
51
+ * The terminal Neovim shows in, from its server's process: the first process up from it on a terminal device (Neovim's
52
+ * own interface, since 0.10 a process of its own), with the app around it, or tmux's client for a Neovim in tmux.
53
+ */
54
+ function terminalOf(serverPid, table) {
55
+ for (let pid = serverPid, steps = 0; pid > 1 && steps < 8; steps++) {
56
+ const row = table.get(pid);
57
+ if (!row) return null;
58
+ if (row.tty)
59
+ return {
60
+ pid,
61
+ tty: row.tty,
62
+ host:
63
+ hostApp(table, pid) ??
64
+ tmuxPlace(table, row.tty)?.client?.host ??
65
+ null,
66
+ };
67
+ pid = row.ppid;
68
+ }
69
+ return null;
70
+ }
71
+
72
+ // The terminal buffer whose job is the session's process or one it runs under (a shell started with :terminal), shown
73
+ // in its window, else in a new tab, ready to type in.
74
+ const SHOW = `
75
+ local pids = ...
76
+ for _, buf in ipairs(vim.api.nvim_list_bufs()) do
77
+ local job = vim.bo[buf].buftype == "terminal" and vim.b[buf].terminal_job_pid
78
+ if job and pids[tostring(job)] then
79
+ local win = vim.fn.win_findbuf(buf)[1]
80
+ if win then vim.fn.win_gotoid(win) else vim.cmd("tab sbuffer " .. buf) end
81
+ vim.cmd.startinsert()
82
+ return vim.fn.getpid()
83
+ end
84
+ end
85
+ return 0`;
86
+
87
+ // A new tab on the folder, with the command in a terminal there, run by the person's own shell.
88
+ const RESUME = `
89
+ local command, cwd = (...)[1], (...)[2]
90
+ vim.cmd.tabnew()
91
+ if cwd ~= "" then vim.cmd.tcd(vim.fn.fnameescape(cwd)) end
92
+ if vim.fn.has("nvim-0.11") == 1 then vim.fn.jobstart(command, { term = true }) else vim.fn.termopen(command) end
93
+ vim.cmd.startinsert()
94
+ return vim.fn.getpid()`;
95
+
96
+ const shownAt = (answer, table) => {
97
+ const pid = Number(answer);
98
+ return Number.isInteger(pid) && pid > 1 ? terminalOf(pid, table) : null;
99
+ };
100
+
101
+ /**
102
+ * Brings up the terminal buffer a running session is in, in the Neovim at `server`: the terminal Neovim runs in
103
+ * ({ pid, tty, host }, to come forward as any terminal does), or null when that Neovim does not answer or has no such
104
+ * buffer.
105
+ */
106
+ export function showInNeovim(server, sessionPid, table = processTable()) {
107
+ const pids = {};
108
+ for (let pid = sessionPid, steps = 0; pid > 1 && steps < 16; steps++) {
109
+ pids[String(pid)] = 1;
110
+ pid = table.get(pid)?.ppid ?? 0;
111
+ }
112
+ return shownAt(inNeovim(server, SHOW, pids, table), table);
113
+ }
114
+
115
+ /** Runs `command` (a session's resume) in a new terminal tab of the Neovim at `server`; as showInNeovim. */
116
+ export function resumeInNeovim(
117
+ server,
118
+ command,
119
+ folder,
120
+ table = processTable()
121
+ ) {
122
+ return shownAt(
123
+ inNeovim(server, RESUME, [command, folder ?? ""], table),
124
+ table
125
+ );
126
+ }
package/lib/network.mjs CHANGED
@@ -67,9 +67,14 @@ export function createNetwork({
67
67
  thread.role === "target" &&
68
68
  thread.status === "requested"
69
69
  )
70
- invited.push({ id: thread.id, project, fingerprint: keyPrint });
70
+ invited.push({
71
+ id: thread.id,
72
+ project,
73
+ sender: peer.handle,
74
+ fingerprint: keyPrint,
75
+ });
71
76
  if (thread.role === "asker")
72
- sent.push({ id: thread.id, status: thread.status });
77
+ sent.push({ id: thread.id, status: thread.status, project });
73
78
  continue;
74
79
  }
75
80
  items.push(
package/lib/nudge.mjs CHANGED
@@ -8,6 +8,7 @@ import { placeEnv } from "./places.mjs";
8
8
  import { fitSections } from "./fit.mjs";
9
9
  import { oneLine } from "./oneLine.mjs";
10
10
  import { SWARM_HEADER } from "./cards.mjs";
11
+ import { hookDialect, hookInput } from "./hookDialects.mjs";
11
12
 
12
13
  // The session-start nudge: what an interactive agent is told when a session opens, so work
13
14
  // waiting on the board is not silent until someone asks. Claude Code runs this as a
@@ -89,8 +90,9 @@ const shorterLists = (render, count, from) =>
89
90
  );
90
91
 
91
92
  // The session start as sections (fit.mjs): the queue first and always; the goal rooms, newest first, down to a count
92
- // and list_tasks; the swarm's cards whole, then short, then list_agents; what the person told the swarm, then list_agents.
93
- // `swarm` is the daemon's block ({ text, cards, short, told }), or its text alone from an older daemon.
93
+ // and list_tasks; who this agent is and the computer it runs on, always; the swarm's cards whole, then short, then
94
+ // list_agents; what the person told the swarm, then list_agents. `swarm` is the daemon's block
95
+ // ({ text, cards, short, told, you }), or its text alone from an older daemon.
94
96
  function sessionSections(agent, tasks, unread, goals, swarm) {
95
97
  const queue = {
96
98
  waiting: (tasks || []).filter(
@@ -143,6 +145,13 @@ function sessionSections(agent, tasks, unread, goals, swarm) {
143
145
  },
144
146
  ]
145
147
  : [];
148
+ if (swarm?.you)
149
+ sections.push({
150
+ name: "you",
151
+ priority: "core",
152
+ source: "board",
153
+ text: swarm.you,
154
+ });
146
155
  if (typeof swarm === "string")
147
156
  return [
148
157
  ...sections,
@@ -319,11 +328,37 @@ export async function boardNudgeIfChanged(agent, homeDir = paths.home) {
319
328
  ).text;
320
329
  }
321
330
 
331
+ // Other agents read Claude Code's own config files: Devin CLI, Grok Build, Cursor, Cortex Code and Continue's cn run the
332
+ // hooks in ~/.claude/settings.json, and Devin, Cortex Code and Warp start the MCP servers in ~/.claude.json (their
333
+ // docs, October 23, 2026). The entries setup writes there would run inside them under Claude Code's name, so they carry
334
+ // --check-host and stand down unless Claude Code started them: Claude Code 2.1.309 sets CLAUDECODE=1 for every process
335
+ // it starts (hooks, MCP servers, shells). Grok Build likewise runs Cursor's hooks and starts the servers in Cursor's
336
+ // config: it marks every hook it runs (GROK_HOOK_EVENT), and a server it starts is its child. Harness's own runs name
337
+ // the agent they start and are not checked.
338
+ export const startedByAnother = (
339
+ agent,
340
+ env = process.env,
341
+ parent = () => processName(process.ppid)
342
+ ) => {
343
+ if (agent === "claude-code") return env.CLAUDECODE !== "1";
344
+ if (agent === "cursor")
345
+ return Boolean(env.GROK_HOOK_EVENT) || parent() === "grok";
346
+ return false;
347
+ };
348
+
322
349
  // The prompt hook also tells the daemon the person typed in this session: the agent process is the hook's parent, or
323
350
  // its grandparent when the hook runs through a shell.
324
351
  export const PS =
325
352
  ["/bin/ps", "/usr/bin/ps"].find((file) => fs.existsSync(file)) || "ps";
326
353
 
354
+ function processName(pid) {
355
+ return path.basename(
356
+ spawnSync(PS, ["-o", "comm=", "-p", String(pid)], {
357
+ encoding: "utf8",
358
+ }).stdout?.trim() ?? ""
359
+ );
360
+ }
361
+
327
362
  function agentPids() {
328
363
  const pids = [process.ppid];
329
364
  try {
@@ -417,8 +452,8 @@ export function messagesText(messages) {
417
452
  .join("\n\n");
418
453
  }
419
454
 
420
- // The JSON the agent hands every hook on stdin (session_id among it); null when there is none.
421
- async function hookInput() {
455
+ // The JSON the agent hands every hook on stdin, in its own words (hookDialects.mjs hookInput); null when there is none.
456
+ async function readHookInput() {
422
457
  if (process.stdin.isTTY) return null;
423
458
  let text = "";
424
459
  process.stdin.setEncoding("utf8");
@@ -435,7 +470,7 @@ async function hookInput() {
435
470
  ]);
436
471
  process.stdin.destroy();
437
472
  try {
438
- return JSON.parse(text);
473
+ return hookInput(JSON.parse(text));
439
474
  } catch {
440
475
  return null;
441
476
  }
@@ -444,34 +479,38 @@ async function hookInput() {
444
479
  if (import.meta.url === `file://${process.argv[1]}`) {
445
480
  const index = process.argv.indexOf("--agent");
446
481
  const agent = index >= 0 ? process.argv[index + 1] : "claude-code";
447
- const input = await hookInput();
482
+ if (process.argv.includes("--check-host") && startedByAnother(agent))
483
+ process.exit(0);
484
+ const dialect = hookDialect(agent);
485
+ const input = await readHookInput();
448
486
  const sessionId = input?.session_id;
487
+ const prompted = process.argv.includes("--if-changed");
449
488
  if (process.argv.includes("--stop")) {
489
+ // A stop that is not a turn ending (Grok's as a session closes) cannot keep anything going: a message taken then
490
+ // would be lost.
491
+ if (input && !input.endsTurn) process.exit(0);
450
492
  // The Stop hook: a message waiting for this session keeps the agent going with it.
451
493
  const messages = await takeMessages(agent, sessionId);
452
494
  if (messages.length)
453
- process.stdout.write(
454
- JSON.stringify({ decision: "block", reason: messagesText(messages) }) +
455
- "\n"
456
- );
495
+ process.stdout.write(dialect.block(messagesText(messages)) + "\n");
457
496
  else await noteTurn(agent, input);
458
497
  } else {
459
- if (process.argv.includes("--if-changed")) await notePrompt(agent, input);
498
+ if (prompted) await notePrompt(agent, input);
460
499
  else await notePlace(agent, input);
461
- const messages = process.argv.includes("--if-changed")
462
- ? await takeMessages(agent, sessionId)
463
- : [];
500
+ // An agent that does not read what this hook prints: nothing is taken or marked as told.
501
+ const speak =
502
+ dialect.context[prompted ? "UserPromptSubmit" : "SessionStart"];
503
+ if (!speak) process.exit(0);
504
+ const messages = prompted ? await takeMessages(agent, sessionId) : [];
464
505
  const compacted =
465
506
  input?.source === "compact" ? await compactionNote(agent, sessionId) : "";
466
507
  const text = [
467
508
  compacted,
468
509
  messages.length ? messagesText(messages) : "",
469
- process.argv.includes("--if-changed")
470
- ? await boardNudgeIfChanged(agent)
471
- : await boardNudge(agent),
510
+ prompted ? await boardNudgeIfChanged(agent) : await boardNudge(agent),
472
511
  ]
473
512
  .filter(Boolean)
474
513
  .join("\n\n");
475
- if (text) process.stdout.write(text + "\n");
514
+ if (text) process.stdout.write(speak(text) + "\n");
476
515
  }
477
516
  }