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
@@ -0,0 +1,319 @@
1
+ // The person's devices across all their computers: one list, kept by home, that only the person changes.
2
+ //
3
+ // Each computer pairs its own devices (phones.mjs: a browser or phone holds a key for that computer alone). This module
4
+ // makes them one swarm: every computer reports its devices and the browsers asking to link to it, home keeps the whole
5
+ // list, and a decision the person makes on any of their computers (allow, turn down, disconnect) reaches the computer the
6
+ // device is paired with. Decisions travel only on the sealed line between the person's own computers (ownMachines.mjs),
7
+ // so Harness's server, which carries that line, can neither add a device nor take one away (security audit,
8
+ // October 26: "devices registered to the swarm").
9
+ //
10
+ // A device is let in by the person's own action: a link or QR code made on one of their computers, or an ask they
11
+ // allowed on one of their computers or devices. One paired through an offer Harness made (a cloud computer's seeded
12
+ // link, cloudBoot.mjs) waits until they allow it, unless it is the first device of a cloud computer that is on its own:
13
+ // that one is the browser where the person pressed Add, and the box is Harness's to run anyway.
14
+
15
+ export const DEVICES_COMMAND = "machine.devices";
16
+
17
+ // On home: what the other computers reported, by computer. On every computer: the person's decisions it has not yet
18
+ // seen carried out, by device or ask id.
19
+ const REPORTED = "swarm-devices";
20
+ const DECISIONS = "swarm-device-decisions";
21
+ const waitingKey = (id) => `device-waiting:${id}`;
22
+ const DECISION_WORDS = new Set(["allow", "refuse", "remove"]);
23
+ // A report is a computer's own devices and asks; more than this is not a person's.
24
+ const MAX_REPORTED = 200;
25
+ const ID = /^[A-Za-z0-9_-]{8,64}$/;
26
+
27
+ export function createSwarmDevices({
28
+ store,
29
+ // The person's computers (ownMachines.mjs), or null on a computer that is not in a swarm.
30
+ computers = () => null,
31
+ // This computer's own browsers asking to link (phones.mjs linkAsk): their list, and the person's answer to one.
32
+ asks = () => [],
33
+ answerAsk = () => ({ ok: false, error: "that browser is no longer asking" }),
34
+ notify = () => {},
35
+ log = () => {},
36
+ }) {
37
+ const own = () => computers();
38
+ const self = () => own()?.self?.() ?? "this";
39
+ const isHome = () => own()?.isHome?.() ?? true;
40
+ const labelOf = (id) =>
41
+ id === self() ? null : (own()?.labelOf?.(id) ?? null);
42
+
43
+ const readJson = (key, fallback) => {
44
+ try {
45
+ return JSON.parse(store.meta(key) || "null") ?? fallback;
46
+ } catch {
47
+ return fallback;
48
+ }
49
+ };
50
+ const decisions = () => readJson(DECISIONS, {});
51
+ const keepDecisions = (all) => store.meta(DECISIONS, JSON.stringify(all));
52
+ const reported = () => readJson(REPORTED, {});
53
+
54
+ const waiting = (id) => Boolean(store.meta(waitingKey(id)));
55
+ // This computer's devices and asks, as the swarm's list holds them.
56
+ const mine = () => [
57
+ ...store.phones().map((device) => ({
58
+ id: device.id,
59
+ kind: device.kind || "phone",
60
+ label: device.label,
61
+ at: device.paired_at,
62
+ state: device.revoked_at
63
+ ? "removed"
64
+ : waiting(device.id)
65
+ ? "waiting"
66
+ : "listed",
67
+ })),
68
+ ...asks().map((ask) => ({
69
+ id: ask.id,
70
+ kind: "ask",
71
+ label: ask.label,
72
+ at: ask.askedAt,
73
+ state: "waiting",
74
+ })),
75
+ ];
76
+ // A decision the person made shows at once in the list, before the computer it is for has carried it out.
77
+ const decided = (entry) => {
78
+ const decision = decisions()[entry.id]?.decision;
79
+ if (!decision || entry.state === "removed") return entry;
80
+ if (decision === "remove") return { ...entry, state: "removed" };
81
+ if (entry.state !== "waiting") return entry;
82
+ return {
83
+ ...entry,
84
+ state:
85
+ decision === "allow"
86
+ ? entry.kind === "ask"
87
+ ? "allowed"
88
+ : "listed"
89
+ : "refused",
90
+ };
91
+ };
92
+
93
+ /** The swarm's whole list, on home; on a worker, its own devices and what home last told it of the others. */
94
+ const list = () => {
95
+ const here = mine().map((entry) => ({ ...entry, computer: self() }));
96
+ const elsewhere = Object.entries(reported())
97
+ .filter(([computer]) => computer !== self())
98
+ .flatMap(([computer, entries]) =>
99
+ (Array.isArray(entries) ? entries : []).map((entry) => ({
100
+ ...entry,
101
+ computer,
102
+ }))
103
+ );
104
+ return [...here, ...elsewhere]
105
+ .map(decided)
106
+ .map((entry) => ({ ...entry, computerLabel: labelOf(entry.computer) }));
107
+ };
108
+
109
+ // ---- carrying out the person's decisions on this computer ----
110
+
111
+ const applyHere = (id, decision) => {
112
+ const device = store.getPhone(id);
113
+ if (device) {
114
+ if (decision === "remove") store.revokePhone(id);
115
+ else if (decision === "allow") store.meta(waitingKey(id), "");
116
+ // A device turned down is disconnected: it never worked here.
117
+ else store.revokePhone(id);
118
+ return { ok: true };
119
+ }
120
+ if (asks().some((ask) => ask.id === id))
121
+ return answerAsk(id, decision === "allow");
122
+ return null;
123
+ };
124
+ // The decisions home holds for this computer's own devices and asks, carried out; each is dropped once done.
125
+ const carryOut = (forHere) => {
126
+ let changed = false;
127
+ for (const [id, entry] of Object.entries(forHere ?? {})) {
128
+ if (!ID.test(id) || !DECISION_WORDS.has(entry?.decision)) continue;
129
+ const done = applyHere(id, entry.decision);
130
+ if (done) changed = true;
131
+ }
132
+ return changed;
133
+ };
134
+
135
+ // ---- a worker and home ----
136
+
137
+ // On a worker: its devices and asks to home, which answers with the person's decisions for them. One report at a time;
138
+ // anything that changes while one is out is sent in the next, right after.
139
+ let reporting = null;
140
+ let again = false;
141
+ const report = () => {
142
+ const machines = own();
143
+ if (!machines || isHome() || !machines.joined?.()) return null;
144
+ if (reporting) {
145
+ again = true;
146
+ return reporting;
147
+ }
148
+ again = false;
149
+ reporting = machines
150
+ .callHome({ command: DEVICES_COMMAND, op: "report", devices: mine() })
151
+ .then((answer) => {
152
+ if (answer?.ok !== true) return answer;
153
+ store.meta(REPORTED, JSON.stringify(othersFrom(answer.devices)));
154
+ if (carryOut(answer.decisions)) again = true;
155
+ return answer;
156
+ })
157
+ .catch((error) => log(`devices: report failed: ${error.message}`))
158
+ .finally(() => {
159
+ reporting = null;
160
+ if (again) void report();
161
+ });
162
+ return reporting;
163
+ };
164
+ // Home's list as a worker keeps it: every other computer's entries, by computer.
165
+ const othersFrom = (entries) => {
166
+ const byComputer = {};
167
+ for (const entry of Array.isArray(entries) ? entries : []) {
168
+ if (!entry?.computer || entry.computer === self()) continue;
169
+ (byComputer[entry.computer] ??= []).push(clean(entry));
170
+ }
171
+ return byComputer;
172
+ };
173
+ const clean = (entry) => ({
174
+ id: String(entry.id),
175
+ kind: ["phone", "browser", "ask"].includes(entry.kind)
176
+ ? entry.kind
177
+ : "phone",
178
+ label: String(entry.label ?? "").slice(0, 40),
179
+ at: typeof entry.at === "string" ? entry.at.slice(0, 40) : null,
180
+ state: ["listed", "waiting", "removed", "allowed", "refused"].includes(
181
+ entry.state
182
+ )
183
+ ? entry.state
184
+ : "waiting",
185
+ });
186
+
187
+ // On home: the decisions for one computer's devices and asks, and those already carried out dropped.
188
+ const decisionsFor = (computer, entries) => {
189
+ const all = decisions();
190
+ const ids = new Set(entries.map((entry) => entry.id));
191
+ const forIt = {};
192
+ for (const [id, entry] of Object.entries(all)) {
193
+ if (entry.computer !== computer) continue;
194
+ const now = entries.find((item) => item.id === id);
195
+ const done =
196
+ !ids.has(id) ||
197
+ now?.state === "removed" ||
198
+ (entry.decision === "allow" && now?.state === "listed");
199
+ if (done) delete all[id];
200
+ else forIt[id] = entry;
201
+ }
202
+ keepDecisions(all);
203
+ return forIt;
204
+ };
205
+ const tellNew = (computer, before, entries) => {
206
+ const known = new Set(before.map((entry) => entry.id));
207
+ for (const entry of entries)
208
+ if (entry.state === "waiting" && !known.has(entry.id))
209
+ notify(
210
+ entry.kind === "ask"
211
+ ? `A browser (${entry.label}) asks to link to ${labelOf(computer) ?? "another of your computers"}. Allow it on any of your computers or devices: npx tryharness phone allow`
212
+ : `${entry.label} was linked to ${labelOf(computer) ?? "another of your computers"} by Harness, not from one of your computers, so it waits for you. Allow it on any of your computers or devices (npx tryharness phone allow), or leave it and it never works.`,
213
+ `devices:${entry.id}`
214
+ );
215
+ };
216
+
217
+ /**
218
+ * On home: a sealed call from another of the person's computers (ownMachines.mjs answerOpened). `drives`: the person
219
+ * works from that computer; a hosted one (agents only) reports its devices but decides nothing for the person.
220
+ */
221
+ const answer = (from, call, { drives = true } = {}) => {
222
+ if (!isHome()) return { ok: false, error: "this computer is not home" };
223
+ if (call?.op === "report") {
224
+ const entries = (Array.isArray(call.devices) ? call.devices : [])
225
+ .slice(0, MAX_REPORTED)
226
+ .filter((entry) => ID.test(String(entry?.id)))
227
+ .map(clean);
228
+ const all = reported();
229
+ tellNew(from, all[from] ?? [], entries);
230
+ all[from] = entries;
231
+ store.meta(REPORTED, JSON.stringify(all));
232
+ return {
233
+ ok: true,
234
+ devices: list(),
235
+ decisions: decisionsFor(from, entries),
236
+ };
237
+ }
238
+ if (call?.op === "decide")
239
+ return drives
240
+ ? decide(String(call.id ?? ""), String(call.decision ?? ""))
241
+ : {
242
+ ok: false,
243
+ code: "not_allowed",
244
+ error:
245
+ "a computer that only runs agents does not decide on the person's devices",
246
+ };
247
+ return { ok: false, error: "unknown devices call" };
248
+ };
249
+
250
+ /**
251
+ * The person's decision on a device or ask, from any of their computers: carried out here when it is this computer's,
252
+ * else kept by home for the computer it is for, which hears at once when it can and otherwise on its next report.
253
+ */
254
+ const decide = async (id, decision) => {
255
+ if (!ID.test(id) || !DECISION_WORDS.has(decision))
256
+ return { ok: false, error: "no device or browser with that id" };
257
+ const here = applyHere(id, decision);
258
+ if (here) {
259
+ void report();
260
+ return here;
261
+ }
262
+ const machines = own();
263
+ if (machines && !isHome()) {
264
+ if (!machines.joined?.())
265
+ return { ok: false, error: "no device or browser with that id" };
266
+ const answer = await machines.callHome({
267
+ command: DEVICES_COMMAND,
268
+ op: "decide",
269
+ id,
270
+ decision,
271
+ });
272
+ void report();
273
+ return answer ?? { ok: false, error: "home is out of reach" };
274
+ }
275
+ const entry = list().find((item) => item.id === id);
276
+ if (!entry || entry.computer === self())
277
+ return { ok: false, error: "no device or browser with that id" };
278
+ const all = decisions();
279
+ all[id] = { decision, computer: entry.computer, at: Date.now() };
280
+ keepDecisions(all);
281
+ void machines?.noticeTo?.(entry.computer, { devices: true });
282
+ log(`devices: ${decision} ${id} on ${entry.computer}`);
283
+ return { ok: true, computer: labelOf(entry.computer) };
284
+ };
285
+
286
+ // A device of the person's that works here: paired, not disconnected and not waiting for them.
287
+ const anotherListed = (id) =>
288
+ store
289
+ .phones()
290
+ .some(
291
+ (device) =>
292
+ device.id !== id && !device.revoked_at && !waiting(device.id)
293
+ );
294
+
295
+ /**
296
+ * A device just paired on this computer. One the person's own action let in (a link or code made here) is listed. One
297
+ * paired through an offer Harness made waits for the person, who allows it with one press on any of their computers
298
+ * or devices, when this computer works for a home of theirs or already has a device of theirs. The first device of a
299
+ * cloud computer on its own is listed: it is the browser where they pressed Add, with nothing else of theirs to press
300
+ * on.
301
+ */
302
+ const paired = (device, { seeded = false } = {}) => {
303
+ if (seeded && (own()?.joined?.() || anotherListed(device.id)))
304
+ store.meta(waitingKey(device.id), new Date().toISOString());
305
+ void report();
306
+ return waiting(device.id) ? "waiting" : "listed";
307
+ };
308
+
309
+ return {
310
+ list,
311
+ paired,
312
+ waiting,
313
+ decide,
314
+ report,
315
+ answer,
316
+ // Home's notice that decisions wait for this computer.
317
+ heard: () => void report(),
318
+ };
319
+ }
@@ -4,28 +4,28 @@ import { oneLine } from "./oneLine.mjs";
4
4
  import { nameOf } from "./members.mjs";
5
5
  import { fromBlob, toBlob, topK } from "./vectors.mjs";
6
6
 
7
- // The swarm's long-running memory, after Hindsight (vectorize-io/hindsight, MIT; owner, October 22: "take the dream
8
- // architecture from the memory repo with 52k stars and implement it for long running memories of the swarm"). The
9
- // raw facts are what the board already keeps: every post, job result and receipt, by who wrote it, where and when.
7
+ // The swarm's long-running memory, after Hindsight (vectorize-io/hindsight, MIT): its dream architecture, applied to
8
+ // a swarm's memory over long-running work. The raw facts are what the board already keeps: every post, job result and
9
+ // receipt, by who wrote it, where and when.
10
10
  //
11
11
  // - recall: what an agent finds when it looks back. Hindsight's parallel searches fused by rank: by meaning (the
12
12
  // search model's vectors) and by words, over threads and jobs alike, each item with its thread, author and time.
13
13
  // Held posts and what the person forgot or replaced never come back; a hosted asker sees only its own threads and
14
14
  // none of the person's lessons or observations; a receipt (written by code from a run's own session) comes before
15
15
  // what the agent said about the same thread. With nothing close, it says so (`weak`) instead of passing near misses
16
- // off as answers (eval memory-public: a never-said question's nearest posts score like a real one's).
16
+ // off as answers (measured: a never-said question's nearest posts score like a real one's).
17
17
  // - forBrief: what a woken agent is told without asking: the observations that hold for its work, then what other
18
- // threads and earlier jobs found or failed at (eval memory-swarm: a finding was searchable but never reached the
19
- // next agent; a failed attempt's cause and a receipt reached no one).
18
+ // threads and earlier jobs found or failed at (without it, a finding was searchable but never reached the next agent;
19
+ // a failed attempt's cause and a receipt reached no one).
20
20
  // - heard: each post of the person's is read on Harness's server (swarm/memoryChange.ts) against their earlier posts
21
21
  // and what the memory holds: what it replaces is marked replaced, what it asks to forget is released (out of recall
22
22
  // and briefs, still in the thread) or purged (its words gone everywhere). ForgetEval's finding: the judgment belongs
23
- // at the moment of change (eval memory-public: the relay forgot nothing, 1 of 385).
23
+ // at the moment of change (before it, the relay forgot next to nothing: 1 of 385).
24
24
  // - dream: the background consolidation. New facts are read on Harness's server (swarm/dream.ts) against the
25
25
  // observations already kept: a belief borne out again gains the new words, a changed one keeps what it said before
26
26
  // in its history, and only what should still hold later is kept (Hindsight's mission: durable, specific facts, not
27
27
  // ephemeral state). With hindsight, lessons that were instructions for one job are retired and lessons that hold
28
- // for all work are widened beyond their folder (eval memory-lane: 5 of 11 lessons were one-job instructions).
28
+ // for all work are widened beyond their folder (measured on real threads, 5 of 11 lessons were one-job instructions).
29
29
  // Observations are what Hindsight calls them; its mental models, standing answers per scope, are assembled here by
30
30
  // code from the observations of a folder or agent at the moment a brief needs them, so they are never stale.
31
31
  //
@@ -38,8 +38,8 @@ const POOL = 60;
38
38
  const RRF_K = 60;
39
39
  const QUERY_CHARS = 500;
40
40
  // The nearest post's similarity below which nothing closely matches: what at least 95% of answerable questions reach,
41
- // on LongMemEval-S questions no other memory eval scores (eval memory-tune, run 20261022-114119-2375af42-75af, stopped at
42
- // 36 of 48: 35 of 36 answerable kept, 23 of 36 never-said caught).
41
+ // on LongMemEval-S questions no other memory eval scores (measured while tuning, stopped at 36 of 48: 35 of 36
42
+ // answerable kept, 23 of 36 never-said caught).
43
43
  export const WEAK_BELOW = 0.7;
44
44
  const POST_CHARS = 2_000;
45
45
  const RECALL_OBSERVATIONS = 4;
@@ -74,6 +74,8 @@ export function createSwarmMemory({
74
74
  inRoom = () => false,
75
75
  isCoordinatorPost = () => false,
76
76
  isFlagged = () => false,
77
+ // A post's words as an agent reads them (serverWords.mjs agentText): a round's words the guard did not clear are left out.
78
+ agentText = (row) => row.text,
77
79
  // What the person saw (seen.mjs): read at each dream, shown to the person's own searches only.
78
80
  seenMemory = null,
79
81
  log = () => {},
@@ -94,7 +96,7 @@ export function createSwarmMemory({
94
96
  task: row.task_id,
95
97
  kind: row.kind,
96
98
  author: row.author,
97
- text: String(row.text).slice(0, POST_CHARS),
99
+ text: String(agentText(row)).slice(0, POST_CHARS),
98
100
  created_at: row.created_at,
99
101
  // Written by code from a run's own session file (receipts.mjs), never by the agent.
100
102
  checked: row.kind === "receipt",
@@ -114,8 +116,8 @@ export function createSwarmMemory({
114
116
  (folder && path.resolve(item.folder) === path.resolve(folder));
115
117
 
116
118
  // The kept observations closest to a text that hold for this folder and agent: by meaning (at or above `floor` when
117
- // given), then by words unless `byWords` is off. Never topped up with ones that do not bear on the text: in eval
118
- // memory-dream the dream also kept agents' passing progress, which a brief should not carry for being well borne out.
119
+ // given), then by words unless `byWords` is off. Never topped up with ones that do not bear on the text: on real
120
+ // history the dream also kept agents' passing progress, which a brief should not carry for being well borne out.
119
121
  const closestObservations = async (
120
122
  text,
121
123
  { folder, agent, limit, floor = null, byWords = true, everyFolder = false }
@@ -153,7 +155,7 @@ export function createSwarmMemory({
153
155
 
154
156
  // Hindsight's graph strategy for what the dream kept, by the thread: the newest observations standing on the threads
155
157
  // found come along. A later post refers to them without their words ("the same song selection" for "the person liked
156
- // the candy track", eval memory-dream v5: kept, and shown at no limit up to 12 by meaning or words).
158
+ // the candy track": measured, kept, and shown at no limit up to 12 by meaning or words).
157
159
  const threadObservations = (threads, { folder, agent, everyFolder }) => {
158
160
  const followed = new Set(threads.slice(0, THREADS_FOLLOWED));
159
161
  const taken = new Map();
@@ -688,12 +690,12 @@ export function createSwarmMemory({
688
690
  * DREAM_FACTS new facts; the rest wait for the next night.
689
691
  */
690
692
  /**
691
- * An agent's note pushed to the swarm (swarm_memory remember, goalCommands.mjs checks it first): kept as an observation every
692
- * agent pulls through swarm_memory and briefs, on any computer (board_observations is mirrored), standing on the
693
- * agent's own words and unchecked until later work bears it out; the dream confirms, changes or replaces it like any
694
- * other. Its `agent` stays null: an observation about one agent reaches only that agent, and a push is for all of
695
- * them (owner, October 22: "memory for a swarm not for a particular agent ... push to and pull from"). A note that
696
- * replaces the agent's own earlier one takes its pushed observation's place.
693
+ * An agent's note pushed to the swarm (swarm_memory remember, goalCommands.mjs checks it first): kept as an
694
+ * observation every agent pulls through swarm_memory and briefs, on any computer (board_observations is mirrored),
695
+ * standing on the agent's own words and unchecked until later work bears it out; the dream confirms, changes or
696
+ * replaces it like any other. Its `agent` stays null: an observation about one agent reaches only that agent, and a
697
+ * push is for all of them: the memory is the swarm's, not one agent's, and every agent pushes to it and pulls from
698
+ * it. A note that replaces the agent's own earlier one takes its pushed observation's place.
697
699
  */
698
700
  const push = async (thread, agent, note) => {
699
701
  if (!note?.id) return null;
@@ -726,7 +728,7 @@ export function createSwarmMemory({
726
728
  // `before`: only what was written before a moment (an eval replaying a board in the order it was written).
727
729
  // The person's approvals, as the board recorded them (reactions.mjs), kept as decisions by code: each stands on their
728
730
  // words and the work approved. Approvals are what "the two videos I okayed" refers to, and the model-read dream kept
729
- // none of them in eval memory-dream ("I would post that!" read at 0.36). One decision per post of theirs.
731
+ // none of them on real history ("I would post that!" read at 0.36). One decision per post of theirs.
730
732
  const keepApprovals = async (before, report) => {
731
733
  const rows = store
732
734
  .approvalsAfter(meta("dream-approvals-cursor") || "", 200)
@@ -744,7 +746,7 @@ export function createSwarmMemory({
744
746
  const added = store.addObservation({
745
747
  kind: "decision",
746
748
  // What the person okayed is theirs, not one folder's: "the two videos I okayed" was asked from a thread in
747
- // another folder than the videos' (eval memory-dream v4).
749
+ // another folder than the videos'.
748
750
  folder: null,
749
751
  text: `The person approved${changes ? ", with changes," : ""} ${agents.join(" and ")}'s work in "${clip(first.thread_title, 120)}" on ${dateOf(first.said_at)}${work ? `: ${clip(work.work, 200)}` : ""}`,
750
752
  evidence: [
@@ -781,8 +783,8 @@ export function createSwarmMemory({
781
783
  meta(`dream-approved:${fact.id}`, new Date().toISOString());
782
784
  const held = store.observations({ limit: 5000 }).some(
783
785
  // An approval code already kept (keepApprovals), not the writer's reading of the same post: the writer read "I
784
- // would post that!" as "The person reviewed video 5 ... and provided critical feedback" (eval memory-dream
785
- // 20261022-182757-f4cd2185-5f23), and the approval was never kept.
786
+ // would post that!" as "The person reviewed video 5 ... and provided critical feedback", and the approval was
787
+ // never kept.
786
788
  (observation) =>
787
789
  observation.text.startsWith("The person approved") &&
788
790
  observation.evidence.some((entry) => entry.contributionId === fact.id)
@@ -806,7 +808,7 @@ export function createSwarmMemory({
806
808
  };
807
809
 
808
810
  // A night that fails is tried again later (daemon.mjs waits an hour after one): Jev now and then answers a choice
809
- // that is not its likeliest, which its validator refuses (eval memory-dream v4, one comparison in 113 nights).
811
+ // that is not its likeliest, which its validator refuses (one comparison in 113 nights).
810
812
  const failed = (report, why) => {
811
813
  log(`dream: ${why}`);
812
814
  meta("dream-failed", report.at);
package/lib/t3.mjs CHANGED
@@ -17,8 +17,8 @@ import { trackRun } from "./runner.mjs";
17
17
  // T3's desktop app binds the first free port from 3773 up (T3 apps/server/src/auth/utils.ts).
18
18
  const FIRST_PORT = 3773;
19
19
  const PORTS = 20;
20
- // Its descriptor answered in at most 1.7 ms over 40 tries while T3 ran four busy sessions (October 12); a closed port
21
- // refuses in under 0.4 ms. The limit only keeps a port held by something else from stalling the search.
20
+ // Its descriptor answered in at most 1.7 ms over 40 tries while T3 ran four busy sessions; a closed port refuses in
21
+ // under 0.4 ms. The limit only keeps a port held by something else from stalling the search.
22
22
  const PROBE_MS = 1_000;
23
23
  const PROTOCOL = "2025-06-18";
24
24
 
@@ -57,8 +57,8 @@ export async function findT3(home = t3Home(), hint = null) {
57
57
  }
58
58
  };
59
59
  // The address T3 last answered on is asked again when it was late: the daemon's own work blocked it for up to 11 s
60
- // during the context engine's pass (October 23, .harness-runs/measure/t3-probe) while T3 answered in under 50 ms,
61
- // so a late answer there said "not running" and the T3 threads list emptied.
60
+ // during the context engine's pass while T3 answered in under 50 ms, so a late answer there said "not running" and
61
+ // the T3 threads list emptied.
62
62
  if (hint) {
63
63
  const first = await answers(hint);
64
64
  const found = first === "late" ? await answers(hint) : first;
@@ -451,7 +451,7 @@ function stepOf(item) {
451
451
 
452
452
  // The option T3 gives each agent's effort under, by agent.
453
453
  const EFFORT_OPTIONS = new Set(["reasoningEffort", "effort"]);
454
- // An option's choices: `values` since T3 #22889 (October 21), `options: [{ id }]` before.
454
+ // An option's choices: `values` since T3 #22889, `options: [{ id }]` before.
455
455
  const choicesOf = (option) =>
456
456
  option.values ?? option.options?.map((level) => level.id) ?? [];
457
457
  const versionOf = (id) => (id.match(/\d+/g) ?? []).map(Number);
@@ -474,13 +474,13 @@ const matching = (provider, model) => {
474
474
 
475
475
  /**
476
476
  * The selection T3 Code runs an agent's turn with: the model and effort the buddy shows for it (the person's pick, else
477
- * the agent's own settings), as T3 names them. T3 names Claude's models in full (claude-opus-5-5) where Claude Code takes
478
- * a short name (opus), which is the newest of that family T3 offers. Null when nothing names a model. A model or effort
479
- * T3 does not offer fails the turn rather than letting T3 run it on another (October 17: Codex ran on gpt-6-astra
480
- * for days while the buddy showed gpt-6.1-sol).
477
+ * the agent's own settings), as T3 names them. T3 names Claude's models in full (claude-opus-5-5) where Claude Code
478
+ * takes a short name (opus), which is the newest of that family T3 offers. Null when nothing names a model. A model or
479
+ * effort T3 does not offer fails the turn rather than letting T3 run it on another (Codex once ran on gpt-6-astra for
480
+ * days while the buddy showed gpt-6.1-sol).
481
481
  *
482
- * Since T3 #22889 (October 21) T3 lists a short list of each agent's models and says how many it left out; a model not
483
- * on it is looked up with T3's search. An older T3 lists every model and leaves out none, so it is never searched.
482
+ * Since T3 #22889, T3 lists a short list of each agent's models and says how many it left out; a model not on it is
483
+ * looked up with T3's search. An older T3 lists every model and leaves out none, so it is never searched.
484
484
  */
485
485
  async function selectionFor({ instanceId, model, effort } = {}) {
486
486
  if (!model) return null;
@@ -697,8 +697,8 @@ export function runInT3(run, emit, observe) {
697
697
  if (stopped) await interrupt();
698
698
  void read();
699
699
  } catch (error) {
700
- // T3 Code did not answer before the turn began, though it was there a moment before (October 14 and 15: twice
701
- // a turn failed this way while T3 was running): where the caller can run the agent itself, it does.
700
+ // T3 Code did not answer before the turn began, though it was there a moment before (twice a turn failed this way
701
+ // while T3 was running): where the caller can run the agent itself, it does.
702
702
  if (error.code === "not_running" && !runId && run.fallback && !stopped) {
703
703
  letGo();
704
704
  run.fallback(error.message);
@@ -24,6 +24,7 @@ import { PICKABLE, resolvePick, setRunPick } from "./models.mjs";
24
24
  import { onMachine, placeTask } from "./machineRoutes.mjs";
25
25
  import { within } from "./folders.mjs";
26
26
  import { recordClaims } from "./audit.mjs";
27
+ import { limitedCaller, RUN_CALLER } from "./runAuthority.mjs";
27
28
 
28
29
  // An agent working in a thread may bring another agent in for part of the work there, as Harness does when it names
29
30
  // one; an agent that moves money or takes positions joins only when the person names it (members.mjs TAGGED_ONLY).
@@ -47,6 +48,8 @@ export function createTaskCommands({
47
48
  machines,
48
49
  ROOM_AGENTS,
49
50
  getActiveRuns,
51
+ commitRun = () => {},
52
+ startTurn = () => {},
50
53
  boardCommand,
51
54
  forwardToHarness,
52
55
  frames,
@@ -153,6 +156,11 @@ export function createTaskCommands({
153
156
  let outcome;
154
157
  // A call from one of the person's other computers, which home answers on its board (ownMachines.mjs).
155
158
  const fromElsewhere = Boolean(machine) && machine !== machines.self();
159
+ // An agent's words from another computer carry no go of the person's here, as a call through Harness carries none
160
+ // (security audit 2026-10-25, M1): the work it writes waits for the person's Start.
161
+ const noGo =
162
+ Boolean(request.hostedCaller) ||
163
+ (fromElsewhere && !["user", "harness"].includes(agent));
156
164
  if (
157
165
  request.command === "board.post" &&
158
166
  request.thread &&
@@ -232,9 +240,9 @@ export function createTaskCommands({
232
240
  if (!resolved.ok) return { ok: false, error: resolved.error };
233
241
  pick = resolved.pick;
234
242
  }
235
- // Work an agent hands on while it works in one thread is placed in that thread, not a new one (owner, October 19:
236
- // "new threads get spun up when the agents hand work off"). It is placed after it is posted, so whether it waits
237
- // for the person's Start is decided exactly as for work outside any thread: placing it grants nothing.
243
+ // Work an agent hands on while it works in one thread is placed in that thread, so a hand-off never spins up a
244
+ // new thread. It is placed after it is posted, so whether it waits for the person's Start is decided exactly as
245
+ // for work outside any thread: placing it grants nothing.
238
246
  const workingThread =
239
247
  !request.parentId && !request.thread && agent !== "user"
240
248
  ? soleThreadOf(agent, request.targetAgent, request.runWorkspace)
@@ -256,7 +264,10 @@ export function createTaskCommands({
256
264
  }
257
265
  : claimed;
258
266
  const provenance = provenanceFor(agent, upstream, null, {
259
- personSession: authority.personSession(agent, request.posterPid),
267
+ personSession:
268
+ !request[RUN_CALLER] &&
269
+ authority.personSession(agent, request.posterPid),
270
+ viaServer: request.hostedCaller === true,
260
271
  });
261
272
  const goalParent = parentTask?.kind === "goal" ? parentTask : null;
262
273
  if (goalParent) {
@@ -517,14 +528,23 @@ export function createTaskCommands({
517
528
  // A job in a goal's room runs on the goal's authority; anywhere else, standing permission decides. The goal covers
518
529
  // jobs from the person, Harness and the coding agents on this machine, with the person's go (personsGo) unless an
519
530
  // agent's words came from above the poster; a job from a member that runs elsewhere (Grok Bot, Muse, a connected
520
- // app) waits for the person's Start.
531
+ // app), or any job that came through Harness's server whatever name it carries, waits for the person's Start. A job
532
+ // a restricted run or a review posts carries no go: it runs restricted (a review's job as a review) or waits, as
533
+ // the run that posted it would. Harness's call as a linked window sealed it (phones.mjs fromWindow) is the served
534
+ // page's word, never a go.
521
535
  const onGoal =
522
536
  agent === "user" ||
523
- agent === "harness" ||
524
- (!request.hostedCaller && member(agent)?.runs === "machine");
537
+ (agent === "harness" &&
538
+ !request.hostedCaller &&
539
+ request.fromWindow !== true) ||
540
+ (!noGo && member(agent)?.runs === "machine");
525
541
  const agentWritten = task.trust !== "user";
542
+ const limited = limitedCaller(request);
543
+ if (limited && request[RUN_CALLER].review)
544
+ store.meta(`review:${task.id}`, "1");
526
545
  const go =
527
546
  onGoal &&
547
+ !limited &&
528
548
  (!agentWritten || (!claimed && !setToWait(String(task.target_agent))));
529
549
  const mayStart =
530
550
  goalParent &&
@@ -863,6 +883,7 @@ export function createTaskCommands({
863
883
  };
864
884
  // The person's own session that took it, so the task opens there (its MCP server is a child of that session).
865
885
  const claimed = outcome?.ok ? store.getTask(id) : null;
886
+ if (claimed && !fromElsewhere) startTurn(claimed);
866
887
  const reportedBy = (pid) =>
867
888
  Object.entries(placesOf(agent)).find(
868
889
  ([, place]) => place.pid === pid
@@ -894,6 +915,8 @@ export function createTaskCommands({
894
915
  expected,
895
916
  machine
896
917
  );
918
+ if (outcome?.ok && !fromElsewhere && request.status === "done")
919
+ commitRun(outcome.task);
897
920
  // What the report claims in its structured fields, which the auditor's code compares with the receipts.
898
921
  if (outcome?.ok && request.claims) {
899
922
  recordClaims(store, id, request.claims);
@@ -1004,12 +1027,19 @@ export function createTaskCommands({
1004
1027
  };
1005
1028
  const claimed = store.claimTask(id, agent, expected, null, machine);
1006
1029
  outcome = claimed.ok ? store.startRun(id, agent) : claimed;
1007
- // A thread's turn carries the thread as home's run worker would hand it over.
1008
- if (outcome.ok && outcome.task.kind === "wake")
1030
+ // A thread's turn carries the thread as home's run worker would hand it over, and goes on in the session of the
1031
+ // turn the person's steer stopped there (threadRuns.mjs).
1032
+ if (outcome.ok && outcome.task.kind === "wake") {
1033
+ const resumeSession = machines.resumeAfterSteer(outcome.task, machine);
1009
1034
  outcome = {
1010
1035
  ...outcome,
1011
- task: { ...outcome.task, brief: machines.briefOf(outcome.task) },
1036
+ task: {
1037
+ ...outcome.task,
1038
+ brief: machines.briefOf(outcome.task),
1039
+ ...(resumeSession ? { resumeSession } : {}),
1040
+ },
1012
1041
  };
1042
+ }
1013
1043
  } else if (request.command === "board.machine.session") {
1014
1044
  const task = store.getTask(id);
1015
1045
  if (!task || task.claimed_machine !== machine || task.holder !== agent)
@@ -1047,7 +1077,10 @@ export function createTaskCommands({
1047
1077
  {
1048
1078
  status: request.status === "done" ? "done" : "failed",
1049
1079
  result: String(request.result || "").slice(0, 200000),
1050
- failure: String(request.failure || "exit"),
1080
+ // Stopped there for the person's steer: the person ended it (threadRuns.mjs).
1081
+ failure: store.meta(`steered:${id}`)
1082
+ ? "person"
1083
+ : String(request.failure || "exit"),
1051
1084
  },
1052
1085
  null,
1053
1086
  machine