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
@@ -1,8 +1,9 @@
1
+ import fs from "node:fs";
1
2
  import { createHash } from "node:crypto";
2
3
  import { detectAgents } from "./commands.mjs";
3
4
  import { member, nameOf } from "./members.mjs";
4
5
  import { t3Access, t3Tool } from "./t3.mjs";
5
- import { t3Link } from "./places.mjs";
6
+ import { t3Checkouts, t3Committers, t3Link } from "./places.mjs";
6
7
 
7
8
  const DRIVER_AGENT = {
8
9
  codex: "codex",
@@ -35,14 +36,57 @@ const failure = (error) => ({
35
36
  error: error.message,
36
37
  });
37
38
 
38
- /** Existing work owned by another execution environment, projected into the same swarm view. */
39
- export function createEnvironments({ store, log, notify = () => {} }) {
39
+ // How often T3 Code is read again while a surface on this computer waits for the board (the buddy's old poll, which
40
+ // read it this often).
41
+ const WATCHED_REFRESH_MS = 3_000;
42
+ // Where the person left each recent thread (threadLine.mjs) is read for this many of the newest, from the last two
43
+ // weeks, and only again when a thread has new items.
44
+ const LINE_THREADS = 40;
45
+ const LINE_DAYS_MS = 14 * 24 * 60 * 60 * 1000;
46
+ // The person's last message is looked for among the thread's newest items, at most this many back: a long run of an
47
+ // agent's steps comes between two of their messages.
48
+ const EXCHANGE_ITEMS = 400;
49
+
50
+ /**
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 (reading T3 Code took about 160 ms of every list on every
53
+ * surface); `notify` hears when what it says changed.
54
+ */
55
+ export function createEnvironments({
56
+ store,
57
+ log,
58
+ notify = () => {},
59
+ watched = () => false,
60
+ threadLine = null,
61
+ guestRequests = null,
62
+ }) {
40
63
  let providers = [];
41
64
  let threads = new Map();
65
+ // Each thread's own checkout and branch, from T3's record (its list leaves them out): what can land (landed.mjs).
66
+ let checkouts = new Map();
67
+ // The threads that ran a command making a commit, read again at most once a minute and never in a list's way.
68
+ let committers = new Set();
69
+ let committersAt = 0;
70
+ const COMMITTERS_FRESH_MS = 60_000;
42
71
  let projects = new Map();
43
72
  let refreshing = null;
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).
75
+ const reads = new Map();
76
+ // Threads the person removed from Harness's list, each until it does something new: id → its last activity then.
77
+ const HIDDEN_KEY = "outside-hidden";
78
+ const hiddenNow = () => {
79
+ try {
80
+ return JSON.parse(store.meta(HIDDEN_KEY) || "{}");
81
+ } catch {
82
+ return {};
83
+ }
84
+ };
44
85
  let lastError = null;
45
86
  let grant = null;
87
+ // The grant the rows held were read under, and what they said, so a refresh that changes nothing tells no one.
88
+ let loadedGrant = null;
89
+ let said = "";
46
90
  const controls = new Map();
47
91
  const keyOf = (id) =>
48
92
  `outside-t3-${createHash("sha256").update(`${t3Access()?.environmentId}:${id}`).digest("hex")}`;
@@ -56,6 +100,7 @@ export function createEnvironments({ store, log, notify = () => {} }) {
56
100
  const clear = () => {
57
101
  providers = [];
58
102
  threads = new Map();
103
+ checkouts = new Map();
59
104
  projects = new Map();
60
105
  };
61
106
  const authorized = () => {
@@ -113,11 +158,29 @@ export function createEnvironments({ store, log, notify = () => {} }) {
113
158
  }
114
159
  return selected;
115
160
  };
161
+ /**
162
+ * A thread's own checkout and branch, as T3 said it or as T3 keeps it; null for a thread working in its project, or
163
+ * one whose checkout T3 has since removed (nothing there to show).
164
+ */
165
+ const checkoutOf = (entry) => {
166
+ const own =
167
+ entry.worktreePath && entry.branch
168
+ ? { path: entry.worktreePath, branch: entry.branch }
169
+ : (checkouts.get(entry.threadId) ?? null);
170
+ return own && fs.existsSync(own.path) ? own : null;
171
+ };
172
+
116
173
  const summary = (entry) => {
117
174
  const family = [...treeOf(entry).values()];
118
175
  const active = family.filter((child) => ACTIVE.has(child.status));
119
- const state = active.length ? "working" : stateOf(entry.status);
120
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);
121
184
  return {
122
185
  id: keyOf(entry.threadId),
123
186
  title: entry.title || "Untitled work",
@@ -134,8 +197,10 @@ export function createEnvironments({ store, log, notify = () => {} }) {
134
197
  title: entry.title || "Untitled work",
135
198
  state,
136
199
  line: `${nameOf(agent)} · T3 Code`,
137
- needsYou: [],
200
+ needsYou: guests,
138
201
  done: false,
202
+ // Where the person left it: their last move and what it was about.
203
+ you: threadLine?.of(keyOf(entry.threadId)) ?? null,
139
204
  },
140
205
  folder: projects.get(entry.projectId)?.workspaceRoot ?? null,
141
206
  working: [
@@ -150,6 +215,9 @@ export function createEnvironments({ store, log, notify = () => {} }) {
150
215
  posts: family.reduce((sum, child) => sum + (child.itemCount ?? 0), 0),
151
216
  spend: { runs: 0, cost_usd: null },
152
217
  changes: null,
218
+ // A thread T3 works on in a checkout of its own can land (landed.mjs); one working in the project itself can't
219
+ // be told apart from the person's own work.
220
+ landed: Boolean(checkoutOf(entry) || committers.has(entry.threadId)),
153
221
  createdAt: entry.createdAt,
154
222
  updatedAt:
155
223
  family
@@ -162,6 +230,7 @@ export function createEnvironments({ store, log, notify = () => {} }) {
162
230
  child.settled,
163
231
  child.updatedAt,
164
232
  child.itemCount,
233
+ child.latestRunId ?? null,
165
234
  ]),
166
235
  openItems: [],
167
236
  coordination: null,
@@ -207,6 +276,12 @@ export function createEnvironments({ store, log, notify = () => {} }) {
207
276
  includeSubagents: true,
208
277
  },
209
278
  "threads"
279
+ ).then((listed) =>
280
+ // T3 lists a project's threads without naming the project on each; its folder is the thread's.
281
+ listed.map((entry) => ({
282
+ ...entry,
283
+ projectId: entry.projectId ?? project.id,
284
+ }))
210
285
  )
211
286
  )
212
287
  )
@@ -217,28 +292,152 @@ export function createEnvironments({ store, log, notify = () => {} }) {
217
292
  threads = new Map(
218
293
  listedThreads.map((entry) => [keyOf(entry.threadId), entry])
219
294
  );
295
+ checkouts = t3Checkouts();
296
+ void guestRequests?.refresh();
297
+
298
+ if (Date.now() - committersAt > COMMITTERS_FRESH_MS) {
299
+ committersAt = Date.now();
300
+ void t3Committers().then((found) => {
301
+ committers = found;
302
+ });
303
+ }
220
304
  lastError = null;
221
- notify();
305
+ catchUpLines();
222
306
  } catch (error) {
223
307
  clear();
224
308
  lastError = error.message;
225
309
  log(`outside environments: ${error.message}`);
226
310
  } finally {
311
+ loadedGrant = startedGrant;
227
312
  refreshing = null;
313
+ const now = JSON.stringify([providers, [...projects], [...threads]]);
314
+ if (now !== said) {
315
+ said = now;
316
+ notify();
317
+ }
228
318
  }
229
319
  })();
230
320
  return refreshing;
231
321
  };
322
+ // The thread's newest items, as far back as the person's last message: it and the agent's message it answers.
323
+ async function lastExchange(entry) {
324
+ const items = [];
325
+ let after = Math.max(0, (entry.itemCount ?? 0) - EXCHANGE_ITEMS) || null;
326
+ for (let page = 0; page < EXCHANGE_ITEMS / 100; page++) {
327
+ const read = await t3Tool("t3_thread_read", {
328
+ threadId: entry.threadId,
329
+ view: "messages",
330
+ limit: 100,
331
+ // An agent's `Deciding:` line ends its message: room for all of it.
332
+ maxCharsPerItem: 20_000,
333
+ runLimit: 1,
334
+ ...(after === null ? {} : { afterPosition: after }),
335
+ });
336
+ items.push(...(read.items ?? []));
337
+ if (!read.hasMore || read.nextPosition === after) break;
338
+ after = read.nextPosition;
339
+ }
340
+ const said = items.filter((item) =>
341
+ ["user_message", "assistant_message"].includes(item.type)
342
+ );
343
+ // T3's notices to an agent (a subagent finished) are filed as the user's: only the person's own words count.
344
+ const at = said.findLastIndex(
345
+ (item) => item.type === "user_message" && item.createdBy !== "agent"
346
+ );
347
+ if (at < 0) return null;
348
+ const mine = said[at];
349
+ return {
350
+ mine: {
351
+ id: mine.itemId,
352
+ text: mine.text ?? "",
353
+ at: mine.updatedAt ?? entry.updatedAt,
354
+ },
355
+ answered:
356
+ said.slice(0, at).findLast((item) => item.type === "assistant_message")
357
+ ?.text ?? null,
358
+ };
359
+ }
360
+ // Each recent thread's line, behind the list: a thread read again only when it has new items. Lists are drawn again
361
+ // once any line changed.
362
+ const lineChecked = new Map();
363
+ let lining = null;
364
+ function catchUpLines() {
365
+ if (!threadLine || lining) return;
366
+ lining = (async () => {
367
+ const recent = [...threads.values()]
368
+ .filter(
369
+ (entry) =>
370
+ entry.relationshipToParent !== "subagent" &&
371
+ Date.now() - Date.parse(entry.updatedAt) < LINE_DAYS_MS
372
+ )
373
+ .sort((a, b) => String(b.updatedAt).localeCompare(a.updatedAt))
374
+ .slice(0, LINE_THREADS);
375
+ let changed = false;
376
+ for (const entry of recent) {
377
+ const version = `${entry.itemCount}:${entry.updatedAt}`;
378
+ if (lineChecked.get(entry.threadId) === version) continue;
379
+ lineChecked.set(entry.threadId, version);
380
+ try {
381
+ const exchange = await lastExchange(entry);
382
+ if (!exchange) continue;
383
+ if (
384
+ await threadLine.update(keyOf(entry.threadId), {
385
+ title: entry.title || "Untitled work",
386
+ ...exchange,
387
+ })
388
+ )
389
+ changed = true;
390
+ } catch (error) {
391
+ lineChecked.delete(entry.threadId);
392
+ log(`thread line: ${error.message}`);
393
+ }
394
+ }
395
+ if (changed) notify();
396
+ })().finally(() => {
397
+ lining = null;
398
+ });
399
+ }
400
+ /**
401
+ * Before a list: null when the rows held can be shown now (T3 Code is read again behind them), or the first read under
402
+ * this grant to wait for.
403
+ */
404
+ const ready = () => {
405
+ if (!authorized()) return null;
406
+ const reading = refresh();
407
+ return loadedGrant === grant ? null : reading;
408
+ };
409
+ const keepFresh = setInterval(() => {
410
+ if (watched()) void refresh();
411
+ }, WATCHED_REFRESH_MS);
412
+ keepFresh.unref?.();
232
413
  const roots = () => {
233
414
  if (!authorized()) return [];
234
415
  const known = new Set([...threads.values()].map((entry) => entry.threadId));
416
+ const hidden = hiddenNow();
235
417
  return [...threads.values()]
236
418
  .filter(
237
419
  (entry) =>
238
420
  entry.relationshipToParent !== "subagent" ||
239
421
  !known.has(entry.parentThreadId)
240
422
  )
241
- .map(summary);
423
+ .map(summary)
424
+ .filter(
425
+ (thread) => hidden[thread.id] !== JSON.stringify(thread.activityVersion)
426
+ );
427
+ };
428
+ /** Removed from Harness's list (T3 keeps it): until it does something new, when it shows again. */
429
+ const hide = (id) => {
430
+ const entry = threads.get(id);
431
+ if (!authorized() || !entry)
432
+ return { ok: false, error: "This source thread is no longer available." };
433
+ const kept = Object.fromEntries(
434
+ Object.entries(hiddenNow()).filter(([key]) => threads.has(key))
435
+ );
436
+ kept[id] = JSON.stringify(summary(entry).activityVersion);
437
+ store.meta(HIDDEN_KEY, JSON.stringify(kept));
438
+ said = "";
439
+ notify();
440
+ return { ok: true };
242
441
  };
243
442
  const catalog = () => ({
244
443
  ok: true,
@@ -292,6 +491,8 @@ export function createEnvironments({ store, log, notify = () => {} }) {
292
491
  const root = threads.get(id);
293
492
  if (!root)
294
493
  return { ok: false, error: "This source thread is no longer available." };
494
+ const version = JSON.stringify([grant, summary(root).activityVersion]);
495
+ if (reads.get(id)?.version === version) return reads.get(id).result;
295
496
  const selected = treeOf(root);
296
497
  const runs = [];
297
498
  const posts = [];
@@ -425,7 +626,7 @@ export function createEnvironments({ store, log, notify = () => {} }) {
425
626
  code: "not_connected",
426
627
  error: "T3 Code access changed while reading this work.",
427
628
  };
428
- return {
629
+ const result = {
429
630
  ok: true,
430
631
  thread: { ...summary(root), source: runs[0].source },
431
632
  runs,
@@ -440,6 +641,8 @@ export function createEnvironments({ store, log, notify = () => {} }) {
440
641
  kept: [],
441
642
  rendering: [],
442
643
  };
644
+ reads.set(id, { version, result });
645
+ return result;
443
646
  }
444
647
  async function control(request, agent) {
445
648
  if (agent !== "user" || request.hostedCaller)
@@ -591,5 +794,40 @@ export function createEnvironments({ store, log, notify = () => {} }) {
591
794
  return pending(control(request, agent));
592
795
  return { ok: false, error: "Unknown environment command." };
593
796
  };
594
- return { command, refresh, roots, owns, read, control, catalog };
797
+ /** A T3 Code thread's own checkout and branch, for what it put into the world (landed.mjs); null without one. */
798
+ const work = (id) => {
799
+ const entry = threads.get(id);
800
+ if (!authorized() || !entry) return null;
801
+ const own = checkoutOf(entry);
802
+ const project = projects.get(entry.projectId)?.workspaceRoot ?? null;
803
+ // Working in the project itself, it landed work only through the commits it made (landed.mjs reads those).
804
+ if (!own && !(committers.has(entry.threadId) && project)) return null;
805
+ return {
806
+ id,
807
+ threadId: entry.threadId,
808
+ title: entry.title || "Untitled work",
809
+ agent: providerAgent(entry.providerInstanceId),
810
+ branch: own?.branch ?? null,
811
+ path: own?.path ?? project,
812
+ inPlace: !own,
813
+ createdAt: entry.createdAt,
814
+ updatedAt: entry.updatedAt,
815
+ };
816
+ };
817
+ /** Every T3 Code thread working in a checkout of its own, or that made commits in its project. */
818
+ const worked = () => [...threads.keys()].map(work).filter(Boolean);
819
+
820
+ return {
821
+ command,
822
+ refresh,
823
+ ready,
824
+ roots,
825
+ owns,
826
+ read,
827
+ hide,
828
+ control,
829
+ catalog,
830
+ work,
831
+ worked,
832
+ };
595
833
  }
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.
@@ -32,13 +32,13 @@ export const isDir = (dir) =>
32
32
  path.isAbsolute(dir) &&
33
33
  fs.statSync(dir, { throwIfNoEntry: false })?.isDirectory() === true;
34
34
 
35
- const within = (dir, root) => {
35
+ export const within = (dir, root) => {
36
36
  const rel = root ? path.relative(root, dir) : "..";
37
37
  return rel === "" || (!rel.startsWith("..") && !path.isAbsolute(rel));
38
38
  };
39
39
 
40
40
  /** A folder Harness may offer or pick by itself: not the home folder or above it, not hidden, not Harness's own, not gone. */
41
- function offerable(dir) {
41
+ export function offerable(dir) {
42
42
  const real = realDir(dir);
43
43
  if (!real || !isDir(real) || within(real, realDir(paths.home))) return false;
44
44
  const home = realDir(os.homedir()) ?? os.homedir();
@@ -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
  ? {