tryharness 0.7.54 → 0.7.57

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. package/README.md +15 -16
  2. package/cli.mjs +377 -62
  3. package/lib/activity.mjs +10 -10
  4. package/lib/adapters.mjs +16 -0
  5. package/lib/agentBinaries.mjs +71 -0
  6. package/lib/agentRuntimeConfig.mjs +1 -1
  7. package/lib/agentRuntimes.mjs +9 -3
  8. package/lib/agentSignIn.mjs +271 -41
  9. package/lib/answers.mjs +5 -5
  10. package/lib/archetypes.d.ts +64 -0
  11. package/lib/archetypes.js +989 -0
  12. package/lib/asks.mjs +4 -4
  13. package/lib/audit.mjs +36 -13
  14. package/lib/backupSetup.mjs +4 -2
  15. package/lib/boardAccess.mjs +17 -11
  16. package/lib/boardBackup.mjs +6 -6
  17. package/lib/boardFileCommands.mjs +6 -6
  18. package/lib/boardFiles.mjs +13 -12
  19. package/lib/boardMirror.mjs +82 -47
  20. package/lib/boardProtocol.json +30 -1
  21. package/lib/boardWaits.mjs +2 -3
  22. package/lib/book.mjs +6 -6
  23. package/lib/bridge.mjs +5 -5
  24. package/lib/cards.mjs +2 -2
  25. package/lib/cloudAgents.mjs +216 -0
  26. package/lib/cloudAi.mjs +1312 -0
  27. package/lib/cloudAssistants.mjs +242 -0
  28. package/lib/cloudBoot.mjs +81 -86
  29. package/lib/cloudSave.mjs +197 -0
  30. package/lib/cloudSsh.mjs +178 -0
  31. package/lib/context.mjs +3 -3
  32. package/lib/contractGate.mjs +34 -12
  33. package/lib/control-client.mjs +9 -1
  34. package/lib/controlSocket.mjs +86 -0
  35. package/lib/coordinator.mjs +103 -101
  36. package/lib/daemon.mjs +1128 -2865
  37. package/lib/desk.mjs +7 -6
  38. package/lib/desktop.mjs +72 -68
  39. package/lib/directLink.mjs +16 -5
  40. package/lib/environment.mjs +2 -1
  41. package/lib/environments.mjs +14 -6
  42. package/lib/firewall.mjs +9 -9
  43. package/lib/folders.mjs +18 -14
  44. package/lib/frames.mjs +2 -3
  45. package/lib/gitHost.mjs +3 -3
  46. package/lib/goalCommands.mjs +25 -7
  47. package/lib/goals.mjs +7 -7
  48. package/lib/guestRequests.mjs +94 -0
  49. package/lib/handoffs.mjs +8 -7
  50. package/lib/handover.mjs +4 -4
  51. package/lib/harnessModel.mjs +6 -6
  52. package/lib/harnessOffers.mjs +266 -0
  53. package/lib/inference.mjs +26 -8
  54. package/lib/jobAnswers.mjs +190 -0
  55. package/lib/landed.mjs +1 -1
  56. package/lib/lane.mjs +42 -11
  57. package/lib/lessons.mjs +16 -16
  58. package/lib/library.mjs +3 -3
  59. package/lib/lineup.mjs +3 -0
  60. package/lib/linkRelay.mjs +574 -0
  61. package/lib/localAgentAsk.mjs +74 -0
  62. package/lib/localStack.mjs +536 -0
  63. package/lib/localmodels.mjs +6 -4
  64. package/lib/loopBackstop.mjs +4 -4
  65. package/lib/machineIdentity.mjs +9 -1
  66. package/lib/machineRoutes.mjs +181 -2
  67. package/lib/machineRuns.mjs +76 -1
  68. package/lib/machineSeal.mjs +39 -12
  69. package/lib/mcp-stdio.mjs +96 -26
  70. package/lib/mcpRelay.mjs +1 -1
  71. package/lib/members.json +13 -0
  72. package/lib/members.mjs +1 -1
  73. package/lib/models.mjs +77 -23
  74. package/lib/museSession.mjs +6 -1
  75. package/lib/nativeHost.mjs +35 -7
  76. package/lib/network.mjs +50 -5
  77. package/lib/notify.mjs +7 -5
  78. package/lib/nudge.mjs +3 -3
  79. package/lib/ocr.mjs +9 -9
  80. package/lib/onboard.mjs +26 -20
  81. package/lib/oneLine.mjs +7 -7
  82. package/lib/ownMachines.mjs +928 -149
  83. package/lib/pairing.mjs +33 -6
  84. package/lib/paths.mjs +15 -1
  85. package/lib/peerProcess.mjs +124 -0
  86. package/lib/personModel.mjs +3 -3
  87. package/lib/personNotices.mjs +151 -0
  88. package/lib/phones.mjs +490 -38
  89. package/lib/placeCommands.mjs +4 -4
  90. package/lib/places.mjs +70 -2
  91. package/lib/profile.mjs +67 -14
  92. package/lib/projectGit.mjs +158 -14
  93. package/lib/projectPieces.mjs +902 -0
  94. package/lib/projectSettings.mjs +7 -4
  95. package/lib/projects.mjs +384 -62
  96. package/lib/provenance.mjs +5 -1
  97. package/lib/proxyLinks.mjs +267 -0
  98. package/lib/reactions.mjs +7 -5
  99. package/lib/readiness.mjs +12 -7
  100. package/lib/record.mjs +19 -6
  101. package/lib/redact.mjs +4 -4
  102. package/lib/relayLimits.mjs +62 -0
  103. package/lib/release.mjs +170 -0
  104. package/lib/releaseKeys.json +6 -0
  105. package/lib/repoLinks.mjs +4 -4
  106. package/lib/roomChannels.mjs +24 -0
  107. package/lib/roomPage.mjs +1 -1
  108. package/lib/runAuthority.mjs +101 -0
  109. package/lib/runBrief.mjs +19 -8
  110. package/lib/runWorker.mjs +14 -5
  111. package/lib/runner.mjs +215 -25
  112. package/lib/runtime-install.mjs +143 -9
  113. package/lib/schedules.mjs +2 -2
  114. package/lib/screens.mjs +1 -1
  115. package/lib/sealed.mjs +11 -2
  116. package/lib/sealedThreads.mjs +671 -0
  117. package/lib/secretPatterns.json +1 -1
  118. package/lib/secrets.mjs +4 -4
  119. package/lib/seen.mjs +6 -6
  120. package/lib/serverWords.mjs +175 -0
  121. package/lib/service.mjs +22 -12
  122. package/lib/sessionControl.mjs +6 -6
  123. package/lib/specialties.mjs +6 -6
  124. package/lib/specialtyKeys.js +4 -5
  125. package/lib/specialtyNotice.mjs +7 -7
  126. package/lib/specialtySnapshot.mjs +5 -5
  127. package/lib/speech.mjs +5 -5
  128. package/lib/store.mjs +140 -39
  129. package/lib/stuck.mjs +1 -1
  130. package/lib/swarm.mjs +167 -16
  131. package/lib/swarmDevices.mjs +319 -0
  132. package/lib/swarmMemory.mjs +27 -25
  133. package/lib/t3.mjs +13 -13
  134. package/lib/taskCommands.mjs +44 -11
  135. package/lib/taskRooms.mjs +125 -0
  136. package/lib/taskRuns.mjs +36 -1
  137. package/lib/team.mjs +41 -18
  138. package/lib/threadActions.mjs +315 -0
  139. package/lib/threadAuthority.mjs +101 -0
  140. package/lib/threadBriefs.mjs +178 -0
  141. package/lib/threadLine.mjs +2 -2
  142. package/lib/threadRuns.mjs +138 -43
  143. package/lib/threadView.mjs +5 -5
  144. package/lib/usageTotals.mjs +2 -3
  145. package/lib/vault.mjs +101 -10
  146. package/lib/vaultCloud.mjs +2 -2
  147. package/lib/vaultCommands.mjs +15 -6
  148. package/lib/vaultTools.js +2 -2
  149. package/lib/verdicts.mjs +328 -0
  150. package/lib/wakes.mjs +1 -1
  151. package/lib/watches.mjs +2 -2
  152. package/lib/windowAsks.mjs +13 -5
  153. package/lib/worktrees.mjs +112 -18
  154. package/npm-shrinkwrap.json +1093 -0
  155. package/package.json +11 -10
  156. package/release.json +220 -0
package/lib/desk.mjs CHANGED
@@ -7,6 +7,7 @@ import {
7
7
  treasurerOf,
8
8
  writeBook,
9
9
  } from "./book.mjs";
10
+ import { RUN_CALLER } from "./runAuthority.mjs";
10
11
  import {
11
12
  approveDeploy,
12
13
  buildAsk,
@@ -21,10 +22,9 @@ import {
21
22
  view,
22
23
  } from "./contractGate.mjs";
23
24
 
24
- // The onchain desk on this computer (docs/swarm-organization.md, "The onchain desk"): the book's commands for agents
25
- // and the person (board.desk.*), each Bankr ask in a thread under a strategy carrying that strategy's high-level
26
- // instructions instead of the book, Bankr's chain receipts filed into the book when its work comes back, and the
27
- // contract gate's deploy ask and the check of what was deployed.
25
+ // The onchain desk on this computer: the book's commands for agents and the person (board.desk.*), each Bankr ask in a
26
+ // thread under a strategy carrying that strategy's high-level instructions instead of the book, Bankr's chain receipts
27
+ // filed into the book when its work comes back, and the contract gate's deploy ask and the check of what was deployed.
28
28
 
29
29
  export function createDesk({
30
30
  store,
@@ -133,17 +133,18 @@ export function createDesk({
133
133
  buildTask: request.build_task,
134
134
  address: request.address,
135
135
  });
136
+ // A verdict is bound to the run that made it and the model Harness chose for that run (contractGate.mjs).
136
137
  if (action === "check")
137
138
  return fileCheck(store, agent, {
138
139
  contract: id,
139
- model: request.model,
140
+ run: request[RUN_CALLER],
140
141
  sha256: request.sha256,
141
142
  passed: request.passed,
142
143
  });
143
144
  if (action === "judge")
144
145
  return fileJudge(store, agent, {
145
146
  contract: id,
146
- model: request.model,
147
+ run: request[RUN_CALLER],
147
148
  sha256: request.sha256,
148
149
  accepted: request.accepted,
149
150
  });
package/lib/desktop.mjs CHANGED
@@ -1,4 +1,3 @@
1
- import { createHash } from "node:crypto";
2
1
  import fs from "node:fs";
3
2
  import os from "node:os";
4
3
  import path from "node:path";
@@ -9,13 +8,25 @@ import { ensureDir, readJson, writeJsonAtomic } from "./files.mjs";
9
8
  import { paths } from "./paths.mjs";
10
9
 
11
10
  // The desktop app ships as one npm package per platform (tryharness-desktop-<os>-<cpu>), an optional
12
- // dependency of tryharness, so `npx tryharness` brings the build for this machine and nothing else.
13
- // Setup installs the newest build there is: npx may run a tryharness it cached before a newer app was
14
- // published, so setup also asks npm, and never puts an older build over a newer one. It copies the app
15
- // to a place it keeps, opens it, and the app registers itself to start at login from there.
11
+ // dependency of tryharness pinned to one exact version, so `npx tryharness` brings the build for this machine and
12
+ // nothing else. Setup installs that build and no other: never npm's newest, which would let whoever can publish to
13
+ // npm choose the program that starts at login (the app is the daemon's launcher, service.mjs). On a Mac the app must
14
+ // also carry Harness's Developer ID signature, checked by codesign before it is copied. Setup copies the app to a
15
+ // place it keeps, opens it, and the app registers itself to start at login from there.
16
+
17
+ // The platforms Harness builds a desktop app for (the Linux AppImage since 0.7.57). Harness holds the npm names of the
18
+ // others with empty placeholders; a package for one of them is never installed, whatever it says it carries.
19
+ const BUILT = ["darwin", "linux"];
20
+ // The Apple team whose Developer ID signs every published Mac app (packages/desktop/scripts/build-helper.mjs and
21
+ // npm-package.mjs sign with "Developer ID Application: Sigala Fosam (CYNVUR3WT7)").
22
+ const TEAM = "CYNVUR3WT7";
23
+ // Apple's own requirement for a Developer ID application, narrowed to that team.
24
+ export const DEVELOPER_ID_REQUIREMENT =
25
+ "anchor apple generic and certificate 1[field.1.2.840.113635.100.6.2.6] exists and " +
26
+ `certificate leaf[field.1.2.840.113635.100.6.1.13] exists and certificate leaf[subject.OU] = "${TEAM}"`;
16
27
 
17
- const REGISTRY = "https://registry.npmjs.org";
18
28
  const marker = () => path.join(paths.home, "desktop.json");
29
+ // Where setups before the pinned-build rule unpacked npm's newest; uninstall still clears it.
19
30
  const downloads = () => path.join(paths.home, "desktop-download");
20
31
 
21
32
  /** Whether version `a` is newer than `b`: x.y.z, a prerelease (0.7.13-local.ab12) before its release. */
@@ -29,66 +40,33 @@ export function newerVersion(a, b) {
29
40
  return !x[4] && Boolean(y[4]);
30
41
  }
31
42
 
32
- /**
33
- * This machine's desktop package as npm has it now, downloaded when it is newer than `than` and unpacked under
34
- * Harness's home. The download must match the checksum npm publishes for it. Null when there is nothing newer,
35
- * nothing for this machine, or npm cannot be reached: setup goes on with what it has.
36
- */
37
- export async function latestDesktop({
38
- than,
39
- platform = process.platform,
40
- arch = process.arch,
41
- registry = REGISTRY,
42
- }) {
43
- try {
44
- const response = await fetch(
45
- `${registry}/${desktopPackageName(platform, arch)}/latest`
46
- );
47
- if (!response.ok) return null;
48
- const meta = await response.json();
49
- const tarball = String(meta.dist?.tarball ?? "");
50
- if (
51
- !meta.harnessDesktop ||
52
- !newerVersion(meta.version, than) ||
53
- !tarball.startsWith(`${registry}/`)
54
- )
55
- return null;
56
- const download = await fetch(tarball);
57
- if (!download.ok) return null;
58
- const bytes = Buffer.from(await download.arrayBuffer());
59
- const [algorithm, digest] = String(meta.dist.integrity ?? "").split(
60
- /-(.*)/s
61
- );
62
- if (
63
- algorithm !== "sha512" ||
64
- createHash("sha512").update(bytes).digest("base64") !== digest
65
- )
66
- return null;
67
- fs.rmSync(downloads(), { recursive: true, force: true });
68
- ensureDir(downloads());
69
- const file = path.join(downloads(), "package.tgz");
70
- fs.writeFileSync(file, bytes);
71
- if (!run("tar", ["-xzf", file, "-C", downloads()]).ok) return null;
72
- const app = path.join(downloads(), "package", String(meta.harnessDesktop));
73
- return fs.existsSync(app) ? { app, version: String(meta.version) } : null;
74
- } catch {
75
- return null;
76
- }
43
+ /** Whether a Mac app is signed, intact, by Harness's Developer ID: { ok, detail }. */
44
+ export function verifyMacApp(app, execute = run) {
45
+ const checked = execute("codesign", [
46
+ "--verify",
47
+ "--deep",
48
+ "--strict",
49
+ `-R=${DEVELOPER_ID_REQUIREMENT}`,
50
+ app,
51
+ ]);
52
+ const detail = (checked.stderr || checked.error || "").trim().split("\n")[0];
53
+ return { ok: checked.ok, detail };
77
54
  }
78
55
 
79
56
  /**
80
- * Setup's desktop app: the newest of the one npx brought, the one on npm and the one installed, never an older build
81
- * over a newer one (a local build stays). Where it is and whether it changed, or null when this machine has none.
82
- * HARNESS_DESKTOP_APP installs that app as it is.
57
+ * Setup's desktop app: the build tryharness pins for this machine, or the one installed when that is newer (a local
58
+ * build stays). Where it is and whether it changed, or null when Harness has no app for this machine. Throws, having
59
+ * installed nothing, when a Mac app is not signed by Harness's Developer ID. HARNESS_DESKTOP_APP installs that app as
60
+ * it is.
83
61
  */
84
62
  export async function setupDesktop({
85
63
  sourceRoot,
86
64
  env = process.env,
87
65
  platform = process.platform,
88
66
  arch = process.arch,
89
- registry = REGISTRY,
90
67
  execute = run,
91
68
  }) {
69
+ if (!BUILT.includes(platform)) return null;
92
70
  const bundled = desktopSource({ sourceRoot, env, platform, arch });
93
71
  const install = (source) =>
94
72
  installDesktop({
@@ -101,18 +79,18 @@ export async function setupDesktop({
101
79
  const installed = readJson(marker(), {});
102
80
  const have =
103
81
  installed.path && fs.existsSync(installed.path) ? installed : null;
104
- const than = newerVersion(have?.version, bundled?.version)
105
- ? have.version
106
- : (bundled?.version ?? have?.version);
107
- const latest = await latestDesktop({ than, platform, arch, registry });
108
- const source = latest ?? bundled;
109
- try {
110
- if (have && (!source || newerVersion(have.version, source.version)))
111
- return { target: have.path, updated: false };
112
- return source && install(source);
113
- } finally {
114
- if (latest) fs.rmSync(downloads(), { recursive: true, force: true });
115
- }
82
+ if (have && (!bundled || newerVersion(have.version, bundled.version)))
83
+ return { target: have.path, updated: false };
84
+ if (!bundled) return null;
85
+ // A Mac app must carry Harness's Developer ID. Linux has no such signature: the AppImage is trusted as the exact
86
+ // build tryharness pins, whose npm integrity is in tryharness's own signed release (npm-shrinkwrap.json).
87
+ const signed =
88
+ platform === "darwin" ? verifyMacApp(bundled.app, execute) : { ok: true };
89
+ if (!signed.ok)
90
+ throw new Error(
91
+ `the desktop app ${bundled.version} is not signed by Harness's Developer ID, so it was not installed (${signed.detail || "codesign refused it"})`
92
+ );
93
+ return install(bundled);
116
94
  }
117
95
 
118
96
  export function desktopPackageName(
@@ -195,6 +173,21 @@ function executables(target, platform) {
195
173
  return [target];
196
174
  }
197
175
 
176
+ function linuxAppImagePids(target) {
177
+ if (!fs.existsSync("/proc")) return [];
178
+ return fs.readdirSync("/proc").flatMap((pid) => {
179
+ if (!/^\d+$/.test(pid)) return [];
180
+ try {
181
+ if (fs.readFileSync(`/proc/${pid}/comm`, "utf8").trim() !== "Harness")
182
+ return [];
183
+ const env = fs.readFileSync(`/proc/${pid}/environ`, "utf8").split("\0");
184
+ return env.includes(`APPIMAGE=${target}`) ? [Number(pid)] : [];
185
+ } catch {
186
+ return [];
187
+ }
188
+ });
189
+ }
190
+
198
191
  export function quitDesktop({
199
192
  target,
200
193
  platform = process.platform,
@@ -204,6 +197,15 @@ export function quitDesktop({
204
197
  execute("taskkill", ["/F", "/IM", path.basename(target)]);
205
198
  return;
206
199
  }
200
+ // AppRun names the native process "Harness"; its command line no longer
201
+ // contains the AppImage path. Stop it as well as the FUSE launcher.
202
+ const nativePids = () =>
203
+ platform === "linux" ? linuxAppImagePids(target) : [];
204
+ for (const pid of nativePids()) {
205
+ try {
206
+ process.kill(pid, "SIGTERM");
207
+ } catch {}
208
+ }
207
209
  // The daemon's launcher keeps running through an update: its next start is the new one.
208
210
  const exes = executables(target, platform).filter(
209
211
  (exe) => path.basename(exe) !== "HarnessDaemon"
@@ -217,7 +219,9 @@ export function quitDesktop({
217
219
  // Opening it again before the old one has gone fails on macOS (LaunchServices error -600).
218
220
  for (
219
221
  let i = 0;
220
- i < 50 && processes.some((pattern) => execute("pgrep", ["-f", pattern]).ok);
222
+ i < 50 &&
223
+ (nativePids().length > 0 ||
224
+ processes.some((pattern) => execute("pgrep", ["-f", pattern]).ok));
221
225
  i++
222
226
  ) {
223
227
  Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 100);
@@ -3,9 +3,9 @@ import path from "node:path";
3
3
  import { ASK_TIMEOUT_MS } from "./bridge.mjs";
4
4
 
5
5
  // The person's own computers reach each other directly when they can: on the same network, or across the internet
6
- // through a hole punched in each router (HyperDHT, the Holepunch library), and through Harness otherwise. Owner,
7
- // October 20: "home wifi first, then ... then through a harness node"; spike October 21 (Mac on a phone hotspot to the
8
- // Linux computer at home): 11 of 11 connections hole-punched, about 0.6 s to connect, a reply in about 45 ms.
6
+ // through a hole punched in each router (HyperDHT, the Holepunch library), and through Harness otherwise, in that
7
+ // order. In a trial with a Mac on a phone hotspot and a Linux computer on home wifi, 11 of 11 connections hole-punched,
8
+ // about 0.6 s to connect, a reply in about 45 ms.
9
9
  //
10
10
  // - Each computer has its own HyperDHT key (direct-identity.json). Two computers swap these keys over the sealed
11
11
  // channel they already share (ownMachines.mjs), so each admits only the other computers the person confirmed:
@@ -118,7 +118,7 @@ export function createDirectLink({
118
118
  };
119
119
 
120
120
  // One link: newline-framed JSON, requests and answers matched by number. The peer is looked up when something
121
- // happens, never kept: a key swap updates it in place (review, October 21: a copied peer kept a dead link "linked").
121
+ // happens, never kept: a key swap updates it in place (a copied peer once kept a dead link "linked").
122
122
  const attach = (id, socket) => {
123
123
  const peer = peers.get(id);
124
124
  if (!peer) return socket.destroy();
@@ -212,6 +212,17 @@ export function createDirectLink({
212
212
  }
213
213
  };
214
214
 
215
+ /** That computer is no longer one of the person's (removed, or a home this one no longer follows): its key is refused. */
216
+ const disallow = (id) => {
217
+ const known = peers.get(id);
218
+ if (!known) return;
219
+ peers.delete(id);
220
+ if (known.socket) {
221
+ release(known, known.socket);
222
+ known.socket.destroy();
223
+ }
224
+ };
225
+
215
226
  /** Links with that computer if not linked already (the worker's side). */
216
227
  const dial = async (id) => {
217
228
  const peer = peers.get(id);
@@ -279,5 +290,5 @@ export function createDirectLink({
279
290
  await node?.destroy().catch(() => {});
280
291
  };
281
292
 
282
- return { key, allow, dial, request, status, stop };
293
+ return { key, allow, disallow, dial, request, status, stop };
283
294
  }
@@ -32,7 +32,8 @@ export function readPerson({
32
32
  exec = run,
33
33
  file = process.env.HARNESS_PRESENCE_FILE,
34
34
  } = {}) {
35
- // Tests stand in for the OS: a JSON file { app, idleSeconds }, read instead of it (tests/e2e/desktop-local.mts).
35
+ // Tests stand in for the OS: a JSON file { app, idleSeconds }, read instead of it (Harness's desktop end-to-end test
36
+ // writes it).
36
37
  if (file) {
37
38
  try {
38
39
  const read = JSON.parse(fs.readFileSync(file, "utf8"));
@@ -49,8 +49,8 @@ const EXCHANGE_ITEMS = 400;
49
49
 
50
50
  /**
51
51
  * Existing work owned by another execution environment, projected into the same swarm view. Reads are answered from
52
- * what T3 Code last said and read it again behind the answer (October 23: reading T3 Code took about 160 ms of every
53
- * list on every surface); `notify` hears when what it says changed.
52
+ * what T3 Code last said and read it again behind the answer (reading T3 Code took about 160 ms of every list on every
53
+ * surface); `notify` hears when what it says changed.
54
54
  */
55
55
  export function createEnvironments({
56
56
  store,
@@ -58,6 +58,7 @@ export function createEnvironments({
58
58
  notify = () => {},
59
59
  watched = () => false,
60
60
  threadLine = null,
61
+ guestRequests = null,
61
62
  }) {
62
63
  let providers = [];
63
64
  let threads = new Map();
@@ -69,8 +70,8 @@ export function createEnvironments({
69
70
  const COMMITTERS_FRESH_MS = 60_000;
70
71
  let projects = new Map();
71
72
  let refreshing = null;
72
- // Each thread's read as it was last made, kept until T3 says the thread or its subagents changed: one is a page of T3's
73
- // record per 100 items (October 24: 1 MB and 0.8 to 1.5 s each, asked every 2 s while it was on screen).
73
+ // Each thread's read as it was last made, kept until T3 says the thread or its subagents changed: one is a page of
74
+ // T3's record per 100 items (1 MB and 0.8 to 1.5 s each, asked every 2 s while it was on screen).
74
75
  const reads = new Map();
75
76
  // Threads the person removed from Harness's list, each until it does something new: id → its last activity then.
76
77
  const HIDDEN_KEY = "outside-hidden";
@@ -172,8 +173,14 @@ export function createEnvironments({
172
173
  const summary = (entry) => {
173
174
  const family = [...treeOf(entry).values()];
174
175
  const active = family.filter((child) => ACTIVE.has(child.status));
175
- const state = active.length ? "working" : stateOf(entry.status);
176
176
  const agent = providerAgent(entry.providerInstanceId);
177
+ // A guest's message waiting for the person's Send or Dismiss in T3 (guestRequests.mjs).
178
+ const guests = guestRequests?.needsOf(entry.threadId, agent) ?? [];
179
+ const state = guests.length
180
+ ? "needs_you"
181
+ : active.length
182
+ ? "working"
183
+ : stateOf(entry.status);
177
184
  return {
178
185
  id: keyOf(entry.threadId),
179
186
  title: entry.title || "Untitled work",
@@ -190,7 +197,7 @@ export function createEnvironments({
190
197
  title: entry.title || "Untitled work",
191
198
  state,
192
199
  line: `${nameOf(agent)} · T3 Code`,
193
- needsYou: [],
200
+ needsYou: guests,
194
201
  done: false,
195
202
  // Where the person left it: their last move and what it was about.
196
203
  you: threadLine?.of(keyOf(entry.threadId)) ?? null,
@@ -286,6 +293,7 @@ export function createEnvironments({
286
293
  listedThreads.map((entry) => [keyOf(entry.threadId), entry])
287
294
  );
288
295
  checkouts = t3Checkouts();
296
+ void guestRequests?.refresh();
289
297
 
290
298
  if (Date.now() - committersAt > COMMITTERS_FRESH_MS) {
291
299
  committersAt = Date.now();
package/lib/firewall.mjs CHANGED
@@ -5,18 +5,18 @@ import { personalSpans } from "./personal.mjs";
5
5
  // what an agent, page, tool or file hands another agent and flags or holds words that try to give orders. Outbound, a
6
6
  // credential model joins the room's patterns (secrets.mjs) and swaps any key or password in a brief bound for a hosted
7
7
  // agent for a placeholder, restored when the answer comes back to this computer. Neither model decides anything about
8
- // money or permissions: those stay code-enforced. Thresholds come from the handoff-firewall eval (measured on this
9
- // computer's own threads); a guard that cannot run leaves the text as it was, with the patterns still applied.
8
+ // money or permissions: those stay code-enforced. Thresholds were measured on a fixed set of real threads; a guard that
9
+ // cannot run leaves the text as it was, with the patterns still applied.
10
10
 
11
11
  const OVERLAP = 200;
12
12
  // A guard's score is its logit margin (injection minus benign), the scale its card calibrates on; the maximum over
13
- // windows stands for the whole text. Measured on this computer's own threads (handoff-firewall eval, October 14): small
14
- // windows find a sentence planted in a long page, large ones almost never hold a harmless post. A hold (the person must
15
- // release it) is Wolf Defender over 1,800-character windows at 2.5: no harmless post held, 90% of standalone attacks
16
- // held. A flag (a label every reader sees) is a hold or Horizon over 300-character windows at 6.0: 3.4% of real
17
- // harmless posts and pages flagged, 83% of planted and all standalone attacks caught (84% planted at 4.4% flagged with
18
- // the thresholds chosen on one half of the attacks and checked on the other). Without Horizon, Wolf Defender flags alone
19
- // over 400-character windows at 1.6 (3.9% flagged, 63% planted, 95% standalone).
13
+ // windows stands for the whole text. Measured on a fixed set of real threads: small windows find a sentence planted in
14
+ // a long page, large ones almost never hold a harmless post. A hold (the person must release it) is Wolf Defender over
15
+ // 1,800-character windows at 2.5: no harmless post held, 90% of standalone attacks held. A flag (a label every reader
16
+ // sees) is a hold or Horizon over 300-character windows at 6.0: 3.4% of real harmless posts and pages flagged, 83% of
17
+ // planted and all standalone attacks caught (84% planted at 4.4% flagged with the thresholds chosen on one half of the
18
+ // attacks and checked on the other). Without Horizon, Wolf Defender flags alone over 400-character windows at 1.6 (3.9%
19
+ // flagged, 63% planted, 95% standalone).
20
20
  const HOLD_WINDOW = 1_800;
21
21
  const FLAG_WINDOW = 300;
22
22
  const FALLBACK_WINDOW = 400;
package/lib/folders.mjs CHANGED
@@ -6,13 +6,13 @@ import { MACHINE_RUNNERS, nameOf } from "./members.mjs";
6
6
  import { paths } from "./paths.mjs";
7
7
  import { t3Projects } from "./places.mjs";
8
8
 
9
- // Where the person's threads work. The folder is the person's to choose, any folder on the computer: the composer offers
10
- // the folders they work in (T3 Code's projects, the folders their agents' sessions and threads ran in, each as its
11
- // repository) and browses from their home folder. With none chosen, Harness picks one from the message among those folders
12
- // (src/server/swarm/folder.ts), else the folder the agent last worked in. The home folder itself and hidden folders are never
13
- // offered or picked, nor Harness's and T3's own copies or a repository's subfolders (the repository stands for them): work
14
- // there is never what was meant (the owner's October 13 thread ran Codex over their whole home folder; on October 14 a
15
- // buddy message was picked into ~/harness/src).
9
+ // Where the person's threads work. The folder is the person's to choose, any folder on the computer: the composer
10
+ // offers the folders they work in (T3 Code's projects, the folders their agents' sessions and threads ran in, each as
11
+ // its repository) and browses from their home folder. With none chosen, Harness picks one from the message among those
12
+ // folders (Harness's server picks it), else the folder the agent last worked in. The home folder itself and hidden
13
+ // folders are never offered or picked, nor Harness's and T3's own copies or a repository's subfolders (the repository
14
+ // stands for them): work there is never what was meant (picking them once ran Codex over a whole home folder, and once
15
+ // put a buddy message into a repository's src folder).
16
16
 
17
17
  const CODING = new Set(MACHINE_RUNNERS);
18
18
  // Folders offered and sent to Jev: the most recently worked in. Browsing reaches any other.
@@ -101,7 +101,7 @@ export function repositoryName(dir) {
101
101
  /**
102
102
  * What Jev reads of a folder: its name, its repository, who worked there and when, and the titles of the sessions there
103
103
  * (each the start of its first message), newest first. What was worked on in a folder says where new work goes; READMEs
104
- * mostly say how to install a project, and together they passed Jev's limit (October 14).
104
+ * mostly say how to install a project, and together they once passed Jev's limit.
105
105
  */
106
106
  function facts(place) {
107
107
  // A remote's address without any credentials in it.
@@ -128,8 +128,12 @@ export function createFolders({
128
128
  lastChanged = () => null,
129
129
  rank = async (_message, places) => places,
130
130
  }) {
131
- /** The folders the person works in, most recently worked in first: { path, name, t3, agents, lastWorked, titles }. */
132
- const known = () => {
131
+ /**
132
+ * The folders the person works in, most recently worked in first: { path, name, t3, agents, lastWorked, titles }.
133
+ * `own`: only what this computer itself knows (its agents' sessions, T3's projects), not the threads on the board,
134
+ * which on a worker is home's copy and names folders home chose.
135
+ */
136
+ const known = ({ own = false } = {}) => {
133
137
  const byPath = new Map();
134
138
  const add = (dir, agent, at, title) => {
135
139
  const real = realDir(dir);
@@ -152,7 +156,7 @@ export function createFolders({
152
156
  };
153
157
  for (const row of store.sessionPlaces())
154
158
  add(row.cwd, row.agent, row.at, row.title);
155
- for (const thread of store.goals({ all: true }))
159
+ for (const thread of own ? [] : store.goals({ all: true }))
156
160
  if (thread.goal?.workspace)
157
161
  for (const agent of thread.goal.team)
158
162
  add(
@@ -246,8 +250,8 @@ export function createFolders({
246
250
  );
247
251
  const pending = (async () => {
248
252
  let reply = await ask(places);
249
- // Over Jev's limit: asked again about the most recently worked in half, halving until it fits. On the owner's
250
- // sessions that half held the folder 99.5% of the time; the search model's closest half, 95.6% (eval folder-shortlist).
253
+ // Over Jev's limit: asked again about the most recently worked in half, halving until it fits. On real
254
+ // sessions that half held the folder 99.5% of the time; the search model's closest half, 95.6%.
251
255
  if (reply?.ok && reply.tooLarge) {
252
256
  const ranked = await rank(message, places);
253
257
  for (
@@ -317,7 +321,7 @@ export function createFolders({
317
321
 
318
322
  // Offered to the composer without the session titles, which only Jev reads.
319
323
  return {
320
- known: () => known().map(({ titles, ...place }) => place),
324
+ known: (options) => known(options).map(({ titles, ...place }) => place),
321
325
  browse,
322
326
  suggest,
323
327
  };
package/lib/frames.mjs CHANGED
@@ -1,4 +1,3 @@
1
- import path from "node:path";
2
1
  import { createHash } from "node:crypto";
3
2
  import { repositoryOf } from "./worktrees.mjs";
4
3
  import { nameOf } from "./members.mjs";
@@ -15,7 +14,7 @@ import { oneLine } from "./oneLine.mjs";
15
14
  const LINE_SUFFIX = /:(\d{1,6})(?::\d+)?$/;
16
15
  const FILE_TOKEN = /(?:[\w@.-]+\/)+[\w@.-]+|[\w-]+\.[a-z][a-z0-9]{0,5}\b/gi;
17
16
  // Names that only code has: camelCase, PascalCase with two humps, snake_case. A plain word, even written as a call
18
- // ("address(es)"), is left alone: in the owner's sessions they resolved to unrelated files (task-frame eval).
17
+ // ("address(es)"), is left alone: in real sessions they resolved to unrelated files.
19
18
  const CODE_NAME = /\b([A-Za-z_$][\w$]{3,})\b/g;
20
19
  const codeShaped = (name) =>
21
20
  /[a-z][A-Z]/.test(name) ||
@@ -297,7 +296,7 @@ export function createFrames({
297
296
  : "";
298
297
  };
299
298
 
300
- /** The parts of the frame the coordinator's round reads, in the server's shape (src/server/swarm/coordinator.ts). */
299
+ /** The parts of the frame the coordinator's round reads, in the shape Harness's server reads. */
301
300
  const roundFacts = (frame) =>
302
301
  frame
303
302
  ? {
package/lib/gitHost.mjs CHANGED
@@ -70,9 +70,9 @@ export function comparePage(host, base, branch) {
70
70
 
71
71
  const FIELDS =
72
72
  "number,title,state,isDraft,url,headRefName,author,createdAt,mergedAt,updatedAt";
73
- // Measured October 23 on the person's Mac: `gh pr list --limit 100` took 301-918 ms (32 runs over three
74
- // repositories, the busiest cli/cli and vercel/next.js) and `gh pr view` 347-790 ms (10 runs). Ten seconds is about
75
- // ten times the slowest; past it the board says GitHub did not answer rather than waiting on it.
73
+ // Measured on a Mac: `gh pr list --limit 100` took 301-918 ms (32 runs over three repositories, the busiest cli/cli and
74
+ // vercel/next.js) and `gh pr view` 347-790 ms (10 runs). Ten seconds is about ten times the slowest; past it the board
75
+ // says GitHub did not answer rather than waiting on it.
76
76
  const GH_DEADLINE_MS = 10_000;
77
77
  const LIST_FRESH_MS = 60_000;
78
78
  const ONE_FRESH_MS = 5 * 60_000;
@@ -8,7 +8,8 @@ import { provenanceFor } from "./provenance.mjs";
8
8
  import { TAGGED_ONLY, nameOf } from "./members.mjs";
9
9
  import { picksIn } from "./models.mjs";
10
10
  import { roomPage } from "./roomPage.mjs";
11
- import { withComputer } from "./machineRoutes.mjs";
11
+ import { FROM_MACHINE, withComputer } from "./machineRoutes.mjs";
12
+ import { callerLimit } from "./runAuthority.mjs";
12
13
 
13
14
  export function createGoalCommands({
14
15
  DEFAULT_MAX_POSTS,
@@ -20,6 +21,8 @@ export function createGoalCommands({
20
21
  endGuestThreads,
21
22
  getFirewall,
22
23
  flagNote,
24
+ // A post's words as an agent reads them (serverWords.mjs agentText); the person reads every post as written.
25
+ agentText = (post) => post.text,
23
26
  heardPerson,
24
27
  inRoom,
25
28
  localEvent,
@@ -66,7 +69,7 @@ export function createGoalCommands({
66
69
  if (!objective) return { ok: false, error: "a goal needs an objective" };
67
70
  // With no team, the agents the person named that can work here; the coordinator brings in the rest as it hands
68
71
  // out work. Never every agent the relay knows: that put Bankr, Quotient and agents never installed into an
69
- // @swarm thread (October 18).
72
+ // @swarm thread.
70
73
  const reachable = available();
71
74
  const team =
72
75
  Array.isArray(request.team) && request.team.length
@@ -102,7 +105,9 @@ export function createGoalCommands({
102
105
  objective,
103
106
  brief: String(request.brief || "").slice(0, 200000),
104
107
  originAgent: agent,
105
- provenance: provenanceFor(agent),
108
+ provenance: provenanceFor(agent, null, null, {
109
+ viaServer: request.hostedCaller === true,
110
+ }),
106
111
  team: team.includes(facilitator) ? team : [...team, facilitator],
107
112
  facilitator,
108
113
  workspace: workspace && path.resolve(workspace),
@@ -117,7 +122,9 @@ export function createGoalCommands({
117
122
  text: request.brief ? `${objective}\n\n${request.brief}` : objective,
118
123
  mentions: [facilitator],
119
124
  });
120
- wakeFor(goal.id, post, agent);
125
+ wakeFor(goal.id, post, agent, undefined, {
126
+ window: request.fromWindow === true,
127
+ });
121
128
  notifyBoard(store.getTask(goal.id));
122
129
  return { ok: true, task: store.getTask(goal.id) };
123
130
  }
@@ -138,7 +145,10 @@ export function createGoalCommands({
138
145
  // A post as a reader gets it: which of the person's computers its agent wrote from, when they have several, and
139
146
  // the guard's flag.
140
147
  const readable = (post) => {
141
- const placed = withComputer(post, computerOf);
148
+ const placed = withComputer(
149
+ agent === "user" ? post : { ...post, text: agentText(post) },
150
+ computerOf
151
+ );
142
152
  return flagNote(post)
143
153
  ? {
144
154
  ...placed,
@@ -167,7 +177,7 @@ export function createGoalCommands({
167
177
  return { ok: false, error: `${agent} is not on this goal's team` };
168
178
  if (!teams) return { ok: false, error: "the daemon is still starting" };
169
179
  // A note goes to every agent of the swarm, so it is checked like a post: never a secret, never orders to the
170
- // swarm (it was kept unchecked until October 22, when notes became the swarm's shared memory).
180
+ // swarm (notes are the swarm's shared memory).
171
181
  const said = `${request.text ?? ""}\n${request.reason ?? ""}`;
172
182
  const flag = secretReason(said);
173
183
  if (flag)
@@ -347,7 +357,13 @@ export function createGoalCommands({
347
357
  return { ok: true, post, paused: true };
348
358
  }
349
359
  const told = wakeFor(goal.id, post, agent, wakes, {
350
- hosted: request.hostedCaller === true,
360
+ // An agent's words from another of the person's computers carry no go here, as through Harness (M1).
361
+ hosted:
362
+ request.hostedCaller === true ||
363
+ (request[FROM_MACHINE] !== undefined &&
364
+ !["user", "harness"].includes(agent)),
365
+ limited: callerLimit(request),
366
+ window: request.fromWindow === true,
351
367
  guard: verdict ?? {
352
368
  score: null,
353
369
  verdict: "clean",
@@ -457,6 +473,8 @@ export function createGoalCommands({
457
473
  about: `Goal: ${goal.objective}`.slice(0, 500),
458
474
  brief,
459
475
  refs: [],
476
+ // A guest whose computer has no key gets a readable invitation only when the person said so (--readable).
477
+ readable: request.readable === true,
460
478
  }).then((response) => {
461
479
  if (!response.ok)
462
480
  throw new Error(response.error || "the invitation was refused");
package/lib/goals.mjs CHANGED
@@ -1,9 +1,9 @@
1
- // A thread's goal (owner, October 15: "very little plumbing on evaluating whether that goal has been reached… no
2
- // mechanism to update the goal by whoever is leading the swarm"). The thread's title is only its first line; the goal is
3
- // the whole aim in the person's terms, the checks that show it is reached, and where it stands. The lead drafts it from
4
- // the person's words, writes a new version when the person changes what they want, and marks each check reached with
5
- // the posts that show it. Every version stays, with the post that caused it. A version can say what the work is for, never
6
- // what it may spend or do: those stay the person's own limits.
1
+ // A thread's goal, so that whether it has been reached can be judged and whoever leads the swarm can update it. The
2
+ // thread's title is only its first line; the goal is the whole aim in the person's terms, the checks that show it is
3
+ // reached, and where it stands. The lead drafts it from the person's words, writes a new version when the person
4
+ // changes what they want, and marks each check reached with the posts that show it. Every version stays, with the post
5
+ // that caused it. A version can say what the work is for, never what it may spend or do: those stay the person's own
6
+ // limits.
7
7
 
8
8
  const KEY = (threadId) => `goal-record:${threadId}`;
9
9
  const MAX_CRITERIA = 12;
@@ -150,7 +150,7 @@ export function createGoals({ store, notifyBoard = () => {} }) {
150
150
  });
151
151
  const allMet = criteria.every((criterion) => criterion.status !== "open");
152
152
  // Met, or ready for the person's review, only when every check is reached: a round that says so early leaves it
153
- // working (October 19: "Ready for your review" with one of three checks met).
153
+ // working (a round once said "Ready for your review" with one of three checks met).
154
154
  const state = STATES.includes(goalState)
155
155
  ? goalState !== "working" && !allMet
156
156
  ? "working"