tryharness 0.7.53 → 0.7.57

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. package/README.md +23 -19
  2. package/assets/dsh-plugin.mjs +72 -0
  3. package/assets/opencode-plugin.js +4 -3
  4. package/cli.mjs +484 -90
  5. package/lib/activity.mjs +10 -10
  6. package/lib/adapters.mjs +173 -222
  7. package/lib/agentBinaries.mjs +71 -0
  8. package/lib/agentRuntimeConfig.mjs +1 -1
  9. package/lib/agentRuntimes.mjs +34 -18
  10. package/lib/agentSignIn.mjs +456 -0
  11. package/lib/answers.mjs +5 -5
  12. package/lib/archetypes.d.ts +64 -0
  13. package/lib/archetypes.js +989 -0
  14. package/lib/asks.mjs +4 -4
  15. package/lib/audit.mjs +666 -0
  16. package/lib/backupSetup.mjs +143 -0
  17. package/lib/boardAccess.mjs +24 -11
  18. package/lib/boardBackup.mjs +283 -0
  19. package/lib/boardFileCommands.mjs +6 -6
  20. package/lib/boardFiles.mjs +13 -12
  21. package/lib/boardMirror.mjs +124 -25
  22. package/lib/boardProtocol.json +88 -2
  23. package/lib/boardWaits.mjs +101 -0
  24. package/lib/book.mjs +659 -0
  25. package/lib/bridge.mjs +6 -6
  26. package/lib/cards.mjs +138 -28
  27. package/lib/cloudAgents.mjs +216 -0
  28. package/lib/cloudAi.mjs +1312 -0
  29. package/lib/cloudAssistants.mjs +242 -0
  30. package/lib/cloudBoot.mjs +119 -0
  31. package/lib/cloudSave.mjs +197 -0
  32. package/lib/cloudSsh.mjs +178 -0
  33. package/lib/commands.mjs +7 -2
  34. package/lib/context.mjs +19 -5
  35. package/lib/contractGate.mjs +399 -0
  36. package/lib/control-client.mjs +9 -1
  37. package/lib/controlSocket.mjs +86 -0
  38. package/lib/coordinator.mjs +252 -144
  39. package/lib/daemon.mjs +1351 -2767
  40. package/lib/desk.mjs +240 -0
  41. package/lib/desktop.mjs +178 -74
  42. package/lib/directLink.mjs +16 -5
  43. package/lib/environment.mjs +2 -1
  44. package/lib/environments.mjs +247 -9
  45. package/lib/firewall.mjs +9 -9
  46. package/lib/folders.mjs +20 -16
  47. package/lib/frames.mjs +2 -3
  48. package/lib/gitHost.mjs +174 -0
  49. package/lib/goalCommands.mjs +25 -7
  50. package/lib/goals.mjs +7 -7
  51. package/lib/guestRequests.mjs +94 -0
  52. package/lib/handoffs.mjs +8 -7
  53. package/lib/handover.mjs +4 -4
  54. package/lib/harnessModel.mjs +6 -6
  55. package/lib/harnessOffers.mjs +266 -0
  56. package/lib/hookDialects.mjs +298 -0
  57. package/lib/inference.mjs +26 -8
  58. package/lib/jobAnswers.mjs +190 -0
  59. package/lib/landed.mjs +887 -0
  60. package/lib/lane.mjs +42 -11
  61. package/lib/lessons.mjs +16 -16
  62. package/lib/library.mjs +3 -3
  63. package/lib/lineup.mjs +3 -0
  64. package/lib/linkRelay.mjs +574 -0
  65. package/lib/live.mjs +284 -13
  66. package/lib/localAgentAsk.mjs +74 -0
  67. package/lib/localStack.mjs +536 -0
  68. package/lib/localmodels.mjs +6 -4
  69. package/lib/loopBackstop.mjs +4 -4
  70. package/lib/machineIdentity.mjs +9 -1
  71. package/lib/machineRoutes.mjs +181 -2
  72. package/lib/machineRuns.mjs +76 -1
  73. package/lib/machineSeal.mjs +39 -12
  74. package/lib/mcp-stdio.mjs +163 -27
  75. package/lib/mcpRelay.mjs +1 -1
  76. package/lib/members.json +29 -2
  77. package/lib/members.mjs +1 -1
  78. package/lib/models.mjs +85 -31
  79. package/lib/museSession.mjs +21 -13
  80. package/lib/nativeHost.mjs +36 -8
  81. package/lib/neovim.mjs +126 -0
  82. package/lib/network.mjs +50 -5
  83. package/lib/notify.mjs +7 -5
  84. package/lib/nudge.mjs +50 -19
  85. package/lib/ocr.mjs +9 -9
  86. package/lib/onboard.mjs +26 -20
  87. package/lib/oneLine.mjs +7 -7
  88. package/lib/ownMachines.mjs +1223 -140
  89. package/lib/pairing.mjs +60 -16
  90. package/lib/paths.mjs +19 -1
  91. package/lib/peerProcess.mjs +124 -0
  92. package/lib/personModel.mjs +89 -0
  93. package/lib/personNotices.mjs +151 -0
  94. package/lib/phones.mjs +538 -31
  95. package/lib/placeCommands.mjs +4 -4
  96. package/lib/places.mjs +400 -12
  97. package/lib/profile.mjs +67 -14
  98. package/lib/projectGit.mjs +158 -14
  99. package/lib/projectPieces.mjs +902 -0
  100. package/lib/projectSettings.mjs +7 -4
  101. package/lib/projects.mjs +384 -62
  102. package/lib/provenance.mjs +5 -1
  103. package/lib/proxyLinks.mjs +267 -0
  104. package/lib/reactions.mjs +7 -5
  105. package/lib/readiness.mjs +145 -23
  106. package/lib/record.mjs +128 -0
  107. package/lib/redact.mjs +4 -4
  108. package/lib/relayLimits.mjs +62 -0
  109. package/lib/release.mjs +170 -0
  110. package/lib/releaseKeys.json +6 -0
  111. package/lib/repoLinks.mjs +4 -4
  112. package/lib/roomChannels.mjs +24 -0
  113. package/lib/roomPage.mjs +1 -1
  114. package/lib/runAuthority.mjs +101 -0
  115. package/lib/runBrief.mjs +19 -8
  116. package/lib/runWorker.mjs +31 -7
  117. package/lib/runner.mjs +223 -29
  118. package/lib/runtime-install.mjs +143 -9
  119. package/lib/schedules.mjs +2 -2
  120. package/lib/screens.mjs +1 -1
  121. package/lib/sealed.mjs +11 -2
  122. package/lib/sealedThreads.mjs +671 -0
  123. package/lib/secretPatterns.json +1 -1
  124. package/lib/secrets.mjs +4 -4
  125. package/lib/seen.mjs +6 -6
  126. package/lib/serverWords.mjs +175 -0
  127. package/lib/service.mjs +22 -12
  128. package/lib/sessionControl.mjs +378 -90
  129. package/lib/specialties.json +74 -0
  130. package/lib/specialties.mjs +477 -0
  131. package/lib/specialtyKeys.d.ts +3 -0
  132. package/lib/specialtyKeys.js +57 -0
  133. package/lib/specialtyNotice.mjs +147 -0
  134. package/lib/specialtySnapshot.mjs +138 -0
  135. package/lib/speech.mjs +5 -5
  136. package/lib/store.mjs +420 -36
  137. package/lib/stuck.mjs +1 -1
  138. package/lib/swarm.mjs +304 -37
  139. package/lib/swarmDevices.mjs +319 -0
  140. package/lib/swarmMemory.mjs +27 -25
  141. package/lib/t3.mjs +24 -15
  142. package/lib/taskCommands.mjs +80 -20
  143. package/lib/taskRooms.mjs +125 -0
  144. package/lib/taskRuns.mjs +45 -3
  145. package/lib/team.json +255 -148
  146. package/lib/team.mjs +554 -190
  147. package/lib/threadActions.mjs +315 -0
  148. package/lib/threadAuthority.mjs +101 -0
  149. package/lib/threadBriefs.mjs +178 -0
  150. package/lib/threadLine.mjs +116 -0
  151. package/lib/threadRuns.mjs +209 -50
  152. package/lib/threadView.mjs +20 -7
  153. package/lib/usageTotals.mjs +2 -3
  154. package/lib/vault.mjs +101 -10
  155. package/lib/vaultCloud.mjs +2 -2
  156. package/lib/vaultCommands.mjs +15 -6
  157. package/lib/vaultTools.js +2 -2
  158. package/lib/verdicts.mjs +328 -0
  159. package/lib/wakes.mjs +1 -1
  160. package/lib/watches.mjs +2 -2
  161. package/lib/windowAsks.mjs +13 -5
  162. package/lib/worktrees.mjs +157 -25
  163. package/npm-shrinkwrap.json +1093 -0
  164. package/package.json +12 -11
  165. package/release.json +220 -0
  166. package/lib/modelTiers.json +0 -1183
  167. package/lib/modelTiers.mjs +0 -133
@@ -0,0 +1,190 @@
1
+ import { askerOf } from "./answers.mjs";
2
+ import { TAGGED_ONLY, member, nameOf } from "./members.mjs";
3
+ import { notifyDesktop } from "./notify.mjs";
4
+ import { restrictedRun } from "./runWorker.mjs";
5
+ import { secretReason } from "./secrets.mjs";
6
+ import { conversationOf } from "./taskRooms.mjs";
7
+ import { mentionsIn } from "./threadActions.mjs";
8
+
9
+ // Failures that can change on their own: the person's stop, a run that never started, a run that ended early.
10
+ const TRANSIENT_FAILURES = ["person", "start", "exit"];
11
+ const ENDED = ["done", "failed", "needs_input"];
12
+ const OPEN_RUN = ["open", "claimed", "running", "needs_input"];
13
+
14
+ /**
15
+ * A job under a thread changed: its result or question lands in the thread and wakes whoever asked for it.
16
+ *
17
+ * `actions` wakes and asks in the thread (threadActions.mjs); `fromElsewhere(agent)` says whether an agent runs in its
18
+ * own cloud (threadAuthority.mjs), whose answers wake their asker only on the injection guard's reading
19
+ * (`readByGuard`). `files` lists what Harness made for a task (boardFiles.mjs).
20
+ */
21
+ export function createJobAnswers({
22
+ store,
23
+ roomAgents,
24
+ runsHere,
25
+ fromElsewhere,
26
+ readByGuard,
27
+ actions,
28
+ files,
29
+ notifyBoard,
30
+ }) {
31
+ // What the post says: an answer to an ask follows the ask in the thread, so it stands as said; a job's result names
32
+ // the job. What Harness made for the task is named under its answer, so every agent reading the thread can get it.
33
+ const textOf = (task, goal) => {
34
+ const answer =
35
+ task.status !== "failed" &&
36
+ String(task.result || "").trim() &&
37
+ task.objective.startsWith(`Asked in "${goal.objective}": `);
38
+ const made =
39
+ task.target_agent === "harness"
40
+ ? files
41
+ .harnessFilesOf(task.id)
42
+ .map((fileId) => store.file(fileId))
43
+ .filter(Boolean)
44
+ : [];
45
+ const said = answer
46
+ ? task.result
47
+ : `${task.status === "done" ? "Finished" : task.status === "failed" ? "Could not finish" : "Asks about"} job "${task.objective}": ${task.result || ""}`;
48
+ return `${said.slice(0, 18_000)}${made.length ? `\n\nFiles: ${made.map(files.fileLine).join("; ")}` : ""}`.slice(
49
+ 0,
50
+ 20_000
51
+ );
52
+ };
53
+
54
+ // Asks Harness's turn read while it worked (asks.mjs turnEnded): their askers hear the answer as the task's does.
55
+ const alsoAskedOf = (task) => {
56
+ try {
57
+ return JSON.parse(store.meta(`harness-also-asked:${task.id}`) || "[]");
58
+ } catch {
59
+ return [];
60
+ }
61
+ };
62
+
63
+ // A room where only the task's own agent worked closes with the task; one that grew into a conversation stays open.
64
+ const closesWithTask = (goal, task, mentions) =>
65
+ !mentions.length &&
66
+ task.status !== "needs_input" &&
67
+ goal.status === "open" &&
68
+ !store.roomPosts(goal.id, 0, 500).some((entry) => entry.kind === "post") &&
69
+ !store.threadRuns(goal.id).some((run) => OPEN_RUN.includes(run.status));
70
+
71
+ /** `previous` is the task's last seen status, holder and run fields. */
72
+ const changed = (task, previous) => {
73
+ const goal = task.parent_id ? store.getTask(task.parent_id) : null;
74
+ if (
75
+ !goal ||
76
+ goal.kind !== "goal" ||
77
+ task.kind !== "task" ||
78
+ previous?.status === task.status
79
+ )
80
+ return;
81
+ if (!ENDED.includes(task.status)) return;
82
+ const who = task.claimed_by || task.target_agent || "an agent";
83
+ // An answer that came through Harness's server (Bankr's, Quotient's, Harness's server answering for a closed
84
+ // window) wakes no one with the person's go (personsGo).
85
+ const hosted =
86
+ member(who)?.runs === "server" &&
87
+ (who !== "harness" || Boolean(store.meta(`harness-served:${task.id}`)));
88
+ // A job that failed on its own terms (the agent refused it or reported failure, not a run that never started or
89
+ // ended early) is kept, so the next rounds do not hand the same agent the same failing work (coordinator.mjs).
90
+ if (task.status === "failed" && !TRANSIENT_FAILURES.includes(task.failure))
91
+ store.meta(`job-failed:${goal.id}:${who}`, new Date().toISOString());
92
+ // A task's own job: the first in the thread the task opened. Its answer names only its asker (below).
93
+ const root = store.meta(`task-room:${goal.id}`) === task.id;
94
+ const text = textOf(task, goal);
95
+ // Harness's answer wakes the agents it names, as its other posts do: a next step it names for @claude is Claude's.
96
+ // Other agents' answers wake only the asker. An agent Harness names joins the thread, as one the coordinator hands
97
+ // work to does. One that moves money or takes positions is never woken by Harness naming it, even once it is in
98
+ // the thread: only the person's name for it or another agent's ask. (Harness explaining why Bankr failed, with
99
+ // "@bankr" in its words, would otherwise start more Bankr jobs.)
100
+ const named =
101
+ who === "harness" && !root
102
+ ? mentionsIn(task.result || "", roomAgents).filter(
103
+ (agent) => agent !== who && !TAGGED_ONLY.includes(agent)
104
+ )
105
+ : [];
106
+ const joining = named.filter((agent) => !goal.goal.team.includes(agent));
107
+ if (joining.length)
108
+ store.setGoalTeam(goal.id, [...goal.goal.team, ...joining]);
109
+ const team = [...goal.goal.team, ...joining];
110
+ // Its asker gets a turn (answers.mjs). In a task's own thread an agent woken on its own channel (OpenClaw, Hermes,
111
+ // Grok Bot, Muse) hears it there, and Harness hears work it posted from a conversation in that conversation; a
112
+ // coding agent here, or Harness otherwise, hears it in this thread.
113
+ const asker = askerOf(task);
114
+ const hearsHere =
115
+ !root ||
116
+ runsHere(asker) ||
117
+ (asker === "harness" && !conversationOf(task));
118
+ const mentions = [
119
+ ...new Set([
120
+ ...(hearsHere ? [asker] : []),
121
+ ...(root ? [] : [...alsoAskedOf(task), ...named]),
122
+ ]),
123
+ ].filter((agent) => agent && agent !== who && team.includes(agent));
124
+ // The asker's turn on its own task's answer, in the thread the task opened (threadAuthority.mjs threadMayRun).
125
+ const answering = root && mentions.includes(asker) ? asker : null;
126
+ // An answer that carries something like a key is held for the person, as any post is, and the room hears that it
127
+ // was.
128
+ const flag = secretReason(text);
129
+ if (flag) {
130
+ store.roomPost({
131
+ goalId: goal.id,
132
+ author: who,
133
+ kind: "held",
134
+ text,
135
+ machine: task.claimed_machine,
136
+ });
137
+ notifyDesktop(
138
+ `${nameOf(who)}'s answer in a thread was held: it looks like ${flag}.`
139
+ );
140
+ }
141
+ const post = store.roomPost({
142
+ goalId: goal.id,
143
+ author: who,
144
+ kind: flag
145
+ ? "note"
146
+ : task.status === "needs_input"
147
+ ? "question"
148
+ : "result",
149
+ text: flag
150
+ ? `${nameOf(who)}'s answer was held for you: it looks like ${flag}.`
151
+ : text,
152
+ mentions,
153
+ // The computer that did the job, so the thread says which Codex answered.
154
+ machine: task.claimed_machine,
155
+ });
156
+ if (root && closesWithTask(goal, task, mentions)) {
157
+ store.setGoalState(goal.id, {
158
+ status: task.status,
159
+ result: task.result || "",
160
+ });
161
+ } else if (goal.status === "open" && fromElsewhere(who) && !flag)
162
+ // An answer from the person's agents elsewhere wakes its asker on the guard's reading of it, as their posts do.
163
+ void readByGuard(text).then((guard) => {
164
+ if (guard?.verdict === "flag" || guard?.verdict === "hold")
165
+ store.meta(`flagged:${post.id}`, String(guard.score));
166
+ actions.wakeFor(goal.id, post, who, undefined, { guard, answering });
167
+ notifyBoard(store.getTask(goal.id));
168
+ });
169
+ // A restricted job's answer is that run's words: the asker it wakes gets no go from it.
170
+ else if (goal.status === "open")
171
+ actions.wakeFor(goal.id, post, who, undefined, {
172
+ answering,
173
+ hosted,
174
+ limited: restrictedRun(store, task) ? "restricted" : null,
175
+ });
176
+ // Harness is asked by name only in a post (wakeFor); in a task's own thread no round follows the answer, so its
177
+ // answer to work Harness posted is asked of Harness as one.
178
+ if (root && mentions.includes("harness") && goal.status === "open")
179
+ actions.ask(
180
+ goal.id,
181
+ "harness",
182
+ `${who} mentioned you: ${post.text.slice(0, 300)}`,
183
+ who,
184
+ post.text
185
+ );
186
+ notifyBoard(store.getTask(goal.id));
187
+ };
188
+
189
+ return { changed };
190
+ }