tryharness 0.7.82 → 0.7.86

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 (216) hide show
  1. package/README.md +21 -19
  2. package/assets/dsh-plugin.mjs +75 -4
  3. package/assets/herdr-mod/harness/main.js +367 -0
  4. package/assets/herdr-mod/harness/mod.json +6 -0
  5. package/assets/opencode-plugin.js +87 -22
  6. package/assets/pi-extension.ts +81 -2
  7. package/cli.mjs +544 -208
  8. package/lib/adapters.mjs +62 -27
  9. package/lib/agentBinaries.mjs +6 -8
  10. package/lib/agentClaims.mjs +168 -0
  11. package/lib/agentReadTools.json +415 -0
  12. package/lib/agentSignIn.mjs +17 -18
  13. package/lib/agentWiring.mjs +114 -0
  14. package/lib/archetypes.js +10 -11
  15. package/lib/attention.mjs +100 -0
  16. package/lib/audit.mjs +1 -1
  17. package/lib/backupSetup.mjs +6 -28
  18. package/lib/bankrApprovals.mjs +86 -0
  19. package/lib/boardAccess.mjs +40 -66
  20. package/lib/boardBackup.mjs +86 -85
  21. package/lib/boardCommands.mjs +28 -0
  22. package/lib/boardFileCommands.mjs +29 -36
  23. package/lib/boardFiles.mjs +83 -15
  24. package/lib/boardMirror.mjs +78 -11
  25. package/lib/boardProtocol.json +193 -123
  26. package/lib/boardThreads.mjs +19 -37
  27. package/lib/boardTools.mjs +22 -15
  28. package/lib/boardWatches.mjs +43 -15
  29. package/lib/bridge.mjs +7 -3
  30. package/lib/browserAgentTools.mjs +59 -0
  31. package/lib/browserWake.mjs +0 -6
  32. package/lib/cards.mjs +57 -2
  33. package/lib/circling.mjs +189 -0
  34. package/lib/cleanup.mjs +234 -0
  35. package/lib/cloudBoot.mjs +21 -4
  36. package/lib/cloudSave.mjs +46 -5
  37. package/lib/compaction.mjs +8 -1
  38. package/lib/completion.mjs +358 -0
  39. package/lib/computerDevices.mjs +853 -0
  40. package/lib/connectionStatus.mjs +34 -0
  41. package/lib/connectors.mjs +139 -1
  42. package/lib/coordinator.mjs +108 -14
  43. package/lib/coreModels.mjs +36 -12
  44. package/lib/daemon.mjs +2435 -333
  45. package/lib/daemonLock.mjs +103 -0
  46. package/lib/deviceDoor.mjs +308 -0
  47. package/lib/deviceIdentity.mjs +114 -0
  48. package/lib/deviceList.mjs +172 -0
  49. package/lib/deviceSeal.mjs +74 -0
  50. package/lib/dispatcher.mjs +497 -26
  51. package/lib/dispatches.mjs +3 -3
  52. package/lib/environment.mjs +2 -1
  53. package/lib/environments.mjs +67 -41
  54. package/lib/events.mjs +318 -0
  55. package/lib/facts.mjs +170 -0
  56. package/lib/fileSource.mjs +540 -0
  57. package/lib/files.mjs +47 -2
  58. package/lib/gitHost.mjs +39 -1
  59. package/lib/goalCommands.mjs +12 -80
  60. package/lib/handover.mjs +21 -16
  61. package/lib/harnessOffers.mjs +140 -15
  62. package/lib/herdr.mjs +100 -15
  63. package/lib/herdrAppCall.mjs +19 -0
  64. package/lib/herdrCore.mjs +59 -0
  65. package/lib/herdrRuns.mjs +1126 -0
  66. package/lib/hookDialects.mjs +235 -50
  67. package/lib/identityLink.mjs +81 -0
  68. package/lib/inference.mjs +31 -2
  69. package/lib/jamAccess.mjs +82 -0
  70. package/lib/{projectBoard.mjs → jamBoard.mjs} +5 -4
  71. package/lib/{projectGit.mjs → jamGit.mjs} +53 -15
  72. package/lib/jamKey.mjs +274 -0
  73. package/lib/{projectPieces.mjs → jamPieces.mjs} +35 -29
  74. package/lib/{projectSettings.mjs → jamSettings.mjs} +12 -22
  75. package/lib/jamStore.mjs +973 -0
  76. package/lib/jamUpgrade.mjs +112 -0
  77. package/lib/jams.mjs +3079 -0
  78. package/lib/kanban.mjs +13 -7
  79. package/lib/landed.mjs +5 -1
  80. package/lib/library.mjs +41 -22
  81. package/lib/limits.mjs +91 -0
  82. package/lib/lineDiff.mjs +97 -0
  83. package/lib/lineup.mjs +18 -13
  84. package/lib/link.mjs +584 -0
  85. package/lib/localStack.mjs +75 -16
  86. package/lib/localmodels.mjs +58 -78
  87. package/lib/loopBackstop.mjs +2 -1
  88. package/lib/machine.mjs +544 -0
  89. package/lib/machineLink.mjs +446 -0
  90. package/lib/machineRoutes.mjs +68 -19
  91. package/lib/machineRuns.mjs +85 -4
  92. package/lib/machineSeal.mjs +6 -31
  93. package/lib/manager.mjs +134 -12
  94. package/lib/mcp-stdio.mjs +492 -215
  95. package/lib/mcpRelay.mjs +34 -35
  96. package/lib/members.json +2 -2
  97. package/lib/modelRoute.mjs +162 -0
  98. package/lib/nativeHost.mjs +81 -90
  99. package/lib/nativeSenses.mjs +258 -0
  100. package/lib/nerves.mjs +523 -0
  101. package/lib/network.mjs +117 -278
  102. package/lib/networkPlaces.mjs +578 -0
  103. package/lib/nextStep.mjs +95 -0
  104. package/lib/notify.mjs +2 -2
  105. package/lib/nudge.mjs +116 -10
  106. package/lib/onboard.mjs +6 -6
  107. package/lib/originals.mjs +216 -0
  108. package/lib/outsideEvents.mjs +383 -0
  109. package/lib/outsideRuns.mjs +230 -0
  110. package/lib/ownMachines.mjs +674 -256
  111. package/lib/pain.mjs +215 -0
  112. package/lib/pairing.mjs +91 -11
  113. package/lib/paths.mjs +42 -3
  114. package/lib/peerProcess.mjs +21 -7
  115. package/lib/peopleLink.mjs +268 -0
  116. package/lib/personNotices.mjs +3 -2
  117. package/lib/phones.mjs +252 -542
  118. package/lib/placeCards.mjs +282 -0
  119. package/lib/placeChecks.mjs +95 -0
  120. package/lib/placeCommands.mjs +8 -17
  121. package/lib/placeRequests.mjs +152 -0
  122. package/lib/placeStore.mjs +295 -0
  123. package/lib/placeTool.d.ts +12 -0
  124. package/lib/placeTool.js +40 -0
  125. package/lib/places.mjs +63 -14
  126. package/lib/plans.mjs +53 -8
  127. package/lib/presence.mjs +270 -0
  128. package/lib/privateNetwork.d.ts +2 -0
  129. package/lib/privateNetwork.js +93 -0
  130. package/lib/proposals.mjs +300 -0
  131. package/lib/publicFetch.d.ts +32 -0
  132. package/lib/publicFetch.js +248 -0
  133. package/lib/reach.mjs +128 -0
  134. package/lib/rebuildable.mjs +72 -0
  135. package/lib/recall.mjs +216 -0
  136. package/lib/record.mjs +13 -0
  137. package/lib/reflexes.mjs +392 -0
  138. package/lib/relayLimits.mjs +31 -2
  139. package/lib/releaseNotice.mjs +198 -0
  140. package/lib/removeHarness.mjs +15 -4
  141. package/lib/repoLinks.mjs +204 -35
  142. package/lib/runAuthority.mjs +102 -39
  143. package/lib/runBrief.mjs +93 -40
  144. package/lib/runRequests.mjs +52 -14
  145. package/lib/runUsage.mjs +31 -0
  146. package/lib/runWorker.mjs +74 -25
  147. package/lib/runner.mjs +289 -45
  148. package/lib/runtime-install.mjs +37 -8
  149. package/lib/schedules.mjs +171 -47
  150. package/lib/screenWatches.mjs +221 -0
  151. package/lib/sealed.mjs +12 -30
  152. package/lib/sealedThreads.mjs +198 -392
  153. package/lib/secretStore.mjs +178 -0
  154. package/lib/secrets.mjs +11 -0
  155. package/lib/seen.mjs +3 -9
  156. package/lib/selfUpdate.mjs +51 -15
  157. package/lib/senseCall.mjs +1514 -0
  158. package/lib/senseHook.mjs +114 -0
  159. package/lib/senseTools.mjs +1298 -0
  160. package/lib/sessionBriefs.mjs +87 -0
  161. package/lib/sessionControl.mjs +63 -13
  162. package/lib/sessionFiles.mjs +85 -0
  163. package/lib/setupChoices.mjs +12 -3
  164. package/lib/setupMode.mjs +70 -25
  165. package/lib/sharedKeys.mjs +166 -0
  166. package/lib/sleep.mjs +396 -0
  167. package/lib/sources.mjs +306 -0
  168. package/lib/speech.mjs +166 -411
  169. package/lib/spoken.mjs +210 -0
  170. package/lib/steerHook.mjs +3 -1
  171. package/lib/steerQueue.mjs +40 -11
  172. package/lib/store.mjs +323 -130
  173. package/lib/stuck.mjs +85 -7
  174. package/lib/swarm.mjs +157 -49
  175. package/lib/swarmDevices.mjs +25 -85
  176. package/lib/swarmMemory.mjs +93 -9
  177. package/lib/t3.mjs +73 -3
  178. package/lib/taskCommands.mjs +51 -60
  179. package/lib/taskRooms.mjs +30 -4
  180. package/lib/taskRules.json +29 -0
  181. package/lib/taskRules.mjs +21 -0
  182. package/lib/taskRuns.mjs +74 -11
  183. package/lib/team.mjs +2 -1
  184. package/lib/threadActions.mjs +37 -9
  185. package/lib/threadAuthority.mjs +4 -4
  186. package/lib/threadBriefs.mjs +173 -43
  187. package/lib/threadNotes.mjs +320 -0
  188. package/lib/threadRecord.mjs +491 -0
  189. package/lib/threadRuns.mjs +216 -108
  190. package/lib/threadView.mjs +27 -30
  191. package/lib/threadWatches.mjs +1962 -0
  192. package/lib/timeSense.mjs +839 -0
  193. package/lib/tripwires.mjs +454 -0
  194. package/lib/ui.mjs +1 -1
  195. package/lib/vault.mjs +560 -45
  196. package/lib/vaultCommands.mjs +5 -3
  197. package/lib/vaultPeers.mjs +165 -0
  198. package/lib/vaultTools.d.ts +4 -1
  199. package/lib/vaultTools.js +22 -1
  200. package/lib/verdicts.mjs +12 -26
  201. package/lib/versions.mjs +117 -0
  202. package/lib/waitTool.mjs +278 -0
  203. package/lib/wakePicture.mjs +268 -0
  204. package/lib/wakeQueue.mjs +108 -0
  205. package/lib/watchResponses.mjs +533 -0
  206. package/lib/watches.mjs +290 -145
  207. package/lib/windowAsks.mjs +80 -17
  208. package/lib/worktrees.mjs +159 -9
  209. package/npm-shrinkwrap.json +138 -631
  210. package/package.json +7 -6
  211. package/release.json +212 -130
  212. package/lib/callSessions.mjs +0 -51
  213. package/lib/directLink.mjs +0 -349
  214. package/lib/peopleBoard.mjs +0 -131
  215. package/lib/projects.mjs +0 -2917
  216. package/lib/roomChannels.mjs +0 -667
@@ -44,6 +44,10 @@ export const MIRRORED = {
44
44
  board_memory_marks: ["contribution_id"],
45
45
  board_observations: ["id"],
46
46
  team_notes: ["id"],
47
+ // The person's places and what was done there (networkPlaces.mjs), kept on home: carried like the board, so a
48
+ // computer made home has them and the board's backup restores them. Each place's key stays in home's vault.
49
+ places: ["id"],
50
+ place_acts: ["id"],
47
51
  board_files: ["id"],
48
52
  // The onchain desk's book (book.mjs): personal, so it is carried only where the board is, sealed in its backup.
49
53
  ...BOOK_MIRRORED,
@@ -56,9 +60,18 @@ export const MIRRORED = {
56
60
  board_specialty_benchmarks: ["agent", "model", "effort", "specialty"],
57
61
  // The person's choices for the whole swarm (the dispatcher slot), so they follow home when it moves.
58
62
  board_settings: ["key"],
63
+ // What every computer reads the same (facts.mjs). The log of what happened (events.mjs) stays on its own computer.
64
+ board_facts: ["key", "machine"],
65
+ // Watches that belong to threads (threadWatches.mjs): each computer reads the ones that name it.
66
+ board_watches: ["id"],
67
+ // Each agent's next step in each thread (nextStep.mjs), for its next turn on whichever computer.
68
+ board_next_steps: ["goal_id", "agent"],
59
69
  };
70
+ // Rows numbered in order within their thread, which readers page through by that number (store.mjs roomPosts).
71
+ const SEQUENCED = { board_contributions: "task_id", board_messages: "task_id" };
60
72
  // The person's grants, made on whichever computer was home: never taken from a board a computer kept on its own.
61
- const AUTHORITY_TABLES = new Set(["board_standing", "board_offices"]);
73
+ // What the swarm may do at a place is the person's grant too (places.allowed).
74
+ const AUTHORITY_TABLES = new Set(["board_standing", "board_offices", "places"]);
62
75
  // What says a task may run and on whose word, and who holds it: home's own, never another computer's.
63
76
  const TASK_AUTHORITY = ["run_authorized_at", "run_authorized_by", "trust"];
64
77
  const TASK_HOLD = [
@@ -82,6 +95,8 @@ const keyJson = (prefix, columns) =>
82
95
 
83
96
  /** The change log and its triggers, made once on every computer, and every row already there counted as changed. */
84
97
  function install(db) {
98
+ // One transaction: each statement on its own synced a journal to disk, and the triggers are made on every start.
99
+ db.exec("begin");
85
100
  db.exec(`create table if not exists board_changes (
86
101
  seq integer primary key autoincrement,
87
102
  tbl text not null,
@@ -130,6 +145,7 @@ function install(db) {
130
145
  create trigger ${table}_mirror_delete after delete on ${table} begin ${changed("old", 1)} ${forget("old")} end;
131
146
  `);
132
147
  }
148
+ db.exec("commit");
133
149
  if (!db.get("select value from board_meta where key = ?", [FEED])) {
134
150
  db.exec("begin immediate");
135
151
  try {
@@ -289,6 +305,9 @@ export function createBoardMirror({
289
305
  standIn = false,
290
306
  // A worker that applies a row's changed columns (one older than them takes whole rows).
291
307
  diffs = false,
308
+ // A computer's own changes going to another to be merged: each whole row also names the columns this computer
309
+ // changed in it after `from` (merge keeps the other computer's own changes to the rest).
310
+ withChanged = standIn,
292
311
  } = {}) => {
293
312
  const standing = standInRecord();
294
313
  if (standIn && !standing)
@@ -332,7 +351,14 @@ export function createBoardMirror({
332
351
  Object.fromEntries(moved.map((name) => [name, row[name]]))
333
352
  ),
334
353
  }
335
- : { seq: change.seq, tbl: change.tbl, row: onWire(row) };
354
+ : {
355
+ seq: change.seq,
356
+ tbl: change.tbl,
357
+ row: onWire(row),
358
+ ...(withChanged && from > 0
359
+ ? { changed: changedSince(change.tbl, change.pk, from) }
360
+ : {}),
361
+ };
336
362
  const size = Buffer.byteLength(JSON.stringify(item));
337
363
  if (changes.length && bytes + size > PAGE_BYTES) break;
338
364
  changes.push(item);
@@ -389,6 +415,8 @@ export function createBoardMirror({
389
415
  missed = true;
390
416
  break;
391
417
  }
418
+ // Part of the listing like any row, or the sweep below takes it out (a listing past one page lost rows this way).
419
+ starting?.get(change.tbl)?.add(JSON.stringify(change.key));
392
420
  continue;
393
421
  }
394
422
  writeRow(change.tbl, change.row);
@@ -480,16 +508,24 @@ export function createBoardMirror({
480
508
  if (!bring) removeRow(change.tbl, change.gone);
481
509
  continue;
482
510
  }
511
+ const key = columns.map((column) => change.row[column]);
483
512
  const here = db.get(
484
513
  `select * from ${change.tbl} where ${whereKey(columns)}`,
485
- columns.map((column) => change.row[column])
514
+ key
486
515
  );
487
- if (here && (bring || !newer(change.row, here))) continue;
516
+ if (here && bring) continue;
517
+ if (here && !hasClock(change.row, here)) {
518
+ mergeUnclocked(change, here, key);
519
+ continue;
520
+ }
521
+ if (here && !newer(change.row, here)) continue;
488
522
  writeRow(
489
523
  change.tbl,
490
524
  change.tbl === "board_tasks"
491
525
  ? withoutAuthority(change.row, here, { bring })
492
- : change.row
526
+ : here
527
+ ? change.row
528
+ : afterTheLast(change.tbl, change.row)
493
529
  );
494
530
  }
495
531
  db.exec("commit");
@@ -512,17 +548,48 @@ export function createBoardMirror({
512
548
  }
513
549
  return task;
514
550
  };
515
- // A row with no version or time of change (a thread's state, a goal's sessions, a reaction) is taken from the
516
- // computer that sent it: only rows it changed while standing in come in a merge (these edits were once dropped).
551
+ // Whether two copies of a row say which is newer: a version every write bumps, or a time of change.
552
+ const hasClock = (incoming, here) =>
553
+ ("version" in incoming && "version" in here) ||
554
+ ("updated_at" in incoming && "updated_at" in here);
517
555
  const newer = (incoming, here) => {
518
556
  if ("version" in incoming && "version" in here) {
519
557
  if (Number(incoming.version) !== Number(here.version))
520
558
  return Number(incoming.version) > Number(here.version);
521
559
  return String(incoming.updated_at) > String(here.updated_at);
522
560
  }
523
- if ("updated_at" in incoming && "updated_at" in here)
524
- return String(incoming.updated_at) > String(here.updated_at);
525
- return true;
561
+ return String(incoming.updated_at) > String(here.updated_at);
562
+ };
563
+ // A row with no version or time of change (a thread's state, a goal's sessions, a post), on both computers: nothing
564
+ // says which copy is newer, so each column comes from the computer that changed it. The sender names the columns it
565
+ // changed after it began standing in (since, withChanged); only those are taken, and this board's own changes to the
566
+ // others stay. A post keeps the place it has here, so no reader's place in the thread moves past it. A sender that
567
+ // names none (one from before this, or a row it made itself) is taken whole, as before, but in its place here.
568
+ const mergeUnclocked = (change, here, key) => {
569
+ const placed = SEQUENCED[change.tbl] ? { seq: here.seq } : {};
570
+ if (!Array.isArray(change.changed)) {
571
+ writeRow(change.tbl, { ...change.row, ...placed });
572
+ return;
573
+ }
574
+ const cols = Object.fromEntries(
575
+ change.changed
576
+ .filter((name) => !(name in placed))
577
+ .map((name) => [name, change.row[name]])
578
+ );
579
+ writeColumns(change.tbl, key, cols);
580
+ };
581
+ // A post or message another computer numbered while it stood in, after the last one here in its thread: both
582
+ // computers numbered from the same last post, and a reader that has read past a number would never see one given it.
583
+ const afterTheLast = (table, row) => {
584
+ const parent = SEQUENCED[table];
585
+ if (!parent) return row;
586
+ const last = Number(
587
+ db.get(
588
+ `select coalesce(max(seq), 0) as seq from ${table} where ${parent} = ?`,
589
+ [row[parent]]
590
+ )?.seq ?? 0
591
+ );
592
+ return Number(row.seq) > last ? row : { ...row, seq: last + 1 };
526
593
  };
527
594
 
528
595
  /** This computer works on a board of its own: once confirmed, it brings that board to home. */
@@ -534,7 +601,7 @@ export function createBoardMirror({
534
601
  // home took them all; the refusal when home said it takes none (answerMergeCall), so this computer stops asking.
535
602
  const pushAll = async (after, options) => {
536
603
  for (;;) {
537
- const page = since({ after, feed: feed() });
604
+ const page = since({ after, feed: feed(), withChanged: true });
538
605
  const answer = await pushPage(page, options);
539
606
  if (answer?.ok !== true) return answer ?? { ok: false };
540
607
  after = page.to;