tryharness 0.7.73 → 0.7.76

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 (49) hide show
  1. package/assets/pi-extension.ts +7 -1
  2. package/cli.mjs +67 -4
  3. package/lib/actorRoster.mjs +20 -9
  4. package/lib/adoption.mjs +5 -3
  5. package/lib/audit.mjs +7 -2
  6. package/lib/boardFiles.mjs +4 -2
  7. package/lib/boardMirror.mjs +2 -0
  8. package/lib/boardProtocol.json +4 -0
  9. package/lib/bridge.mjs +3 -0
  10. package/lib/capabilityCheck.mjs +39 -3
  11. package/lib/coordinator.mjs +480 -117
  12. package/lib/daemon.mjs +74 -21
  13. package/lib/dispatcher.mjs +568 -0
  14. package/lib/goalCommands.mjs +21 -6
  15. package/lib/handoffs.mjs +8 -7
  16. package/lib/handover.mjs +2 -2
  17. package/lib/inference.mjs +53 -3
  18. package/lib/jobAnswers.mjs +7 -6
  19. package/lib/lessons.mjs +6 -1
  20. package/lib/library.mjs +83 -7
  21. package/lib/lineup.mjs +17 -9
  22. package/lib/localAgentAsk.mjs +68 -29
  23. package/lib/localStack.mjs +19 -3
  24. package/lib/localmodels.mjs +59 -25
  25. package/lib/machineRoutes.mjs +1 -0
  26. package/lib/manager.mjs +97 -52
  27. package/lib/mcp-stdio.mjs +14 -7
  28. package/lib/members.json +5 -1
  29. package/lib/members.mjs +21 -1
  30. package/lib/moves.mjs +15 -2
  31. package/lib/nudge.mjs +5 -0
  32. package/lib/plans.mjs +2 -1
  33. package/lib/projects.mjs +16 -9
  34. package/lib/runAuthority.mjs +2 -1
  35. package/lib/runBrief.mjs +2 -2
  36. package/lib/runWorker.mjs +6 -6
  37. package/lib/snippets.mjs +5 -5
  38. package/lib/store.mjs +79 -10
  39. package/lib/swarm.mjs +56 -12
  40. package/lib/taskCommands.mjs +8 -8
  41. package/lib/taskRooms.mjs +6 -8
  42. package/lib/team.mjs +5 -3
  43. package/lib/threadActions.mjs +6 -30
  44. package/lib/threadAuthority.mjs +16 -3
  45. package/lib/threadRuns.mjs +26 -16
  46. package/lib/verdicts.mjs +2 -2
  47. package/npm-shrinkwrap.json +14 -14
  48. package/package.json +4 -4
  49. package/release.json +50 -49
package/lib/daemon.mjs CHANGED
@@ -64,11 +64,12 @@ import {
64
64
  import { createStuck, STUCK_THRESHOLDS } from "./stuck.mjs";
65
65
  import { createLoopBackstop } from "./loopBackstop.mjs";
66
66
  import {
67
+ DISPATCHER,
67
68
  ASKED_BY_TASK,
68
69
  CLOUD_HOMED,
69
70
  TARGETS,
70
- aboutOf,
71
71
  member,
72
+ aboutOf,
72
73
  nameOf,
73
74
  } from "./members.mjs";
74
75
  import { fingerprint } from "./sealed.mjs";
@@ -169,6 +170,7 @@ import { createThreadActions, inRoom, mentionsIn } from "./threadActions.mjs";
169
170
  import { createThreadAuthority } from "./threadAuthority.mjs";
170
171
  import { createDispatches } from "./dispatches.mjs";
171
172
  import { createCapabilityCheck } from "./capabilityCheck.mjs";
173
+ import { createDispatcher } from "./dispatcher.mjs";
172
174
  import { createThreadBriefs } from "./threadBriefs.mjs";
173
175
 
174
176
  // claude-mem 13.35.0, scratch worker with 3,000 observations, on the same machine: the whole lookup (git calls,
@@ -1026,7 +1028,20 @@ export async function startDaemon() {
1026
1028
  const handoffs = createHandoffs({
1027
1029
  store,
1028
1030
  wakeAgain: (agent, taskId) => actions.wakeAgain(agent, taskId),
1029
- moveTo: (task, to) => actions.moveHandoff(task, to),
1031
+ giveBack: (task) => {
1032
+ const thread = store.getTask(task.parent_id);
1033
+ if (thread?.kind !== "goal" || thread.status !== "open") return false;
1034
+ // Taken back first, so a wake that lands later cannot start the same work twice.
1035
+ store.removeTask(task.id);
1036
+ notifyBoard(store.getTask(task.id));
1037
+ // Jev passes over the agent in this thread for a while (coordinator.mjs failedHereLately) and places it again.
1038
+ store.meta(
1039
+ `job-failed:${thread.id}:${task.target_agent}`,
1040
+ new Date().toISOString()
1041
+ );
1042
+ coordinator.resumed(thread.id);
1043
+ return true;
1044
+ },
1030
1045
  say: (threadId, text) => {
1031
1046
  const thread = store.getTask(threadId);
1032
1047
  if (thread) actions.say(thread, text);
@@ -1275,23 +1290,42 @@ export async function startDaemon() {
1275
1290
  ? threadRuns.wake(goalId, agent, reason, {
1276
1291
  review,
1277
1292
  routeMachine,
1278
- go: threadAuthority.personsGo("harness", agent),
1293
+ // The person's words whole go into the agent's brief, not only the line that says why it was woken.
1294
+ words,
1295
+ asker: DISPATCHER,
1296
+ go: threadAuthority.personsGo(DISPATCHER, agent),
1279
1297
  })
1280
- : actions.ask(goalId, agent, reason, "harness", words);
1281
- // The swarm's manager (manager.mjs): the person's asks, kept to their words.
1298
+ : actions.ask(goalId, agent, reason, DISPATCHER, words);
1299
+ // The dispatcher slot (dispatcher.mjs): what words the swarm's threads and checks results against the person's words,
1300
+ // as the person picked; the relay's LFM3-Omni by default, downloaded in the background from the start.
1301
+ // One dispatcher per swarm, on whichever computer is home (owner, November 1): the pick is kept on the board, which
1302
+ // follows home, and only the computer holding the board downloads the local model. A pick made before it was kept
1303
+ // there (this computer's config) moves onto the board once.
1304
+ const configPick = readJson(paths.config, {}).dispatcher ?? null;
1305
+ if (configPick && holdsBoard() && !store.boardSetting("dispatcher")) {
1306
+ store.setBoardSetting("dispatcher", configPick);
1307
+ const config = readJson(paths.config, {});
1308
+ delete config.dispatcher;
1309
+ writeJsonAtomic(paths.config, config);
1310
+ }
1311
+ const dispatcher = createDispatcher({
1312
+ root: path.join(paths.home, "local"),
1313
+ read: () => store.boardSetting("dispatcher"),
1314
+ write: (value) => store.setBoardSetting("dispatcher", value),
1315
+ inference: local.inference,
1316
+ wanted: () =>
1317
+ holdsBoard() && readJson(paths.config, {}).localModels === "download",
1318
+ installedAgents: () => installedAgents,
1319
+ askHarness,
1320
+ log,
1321
+ });
1322
+ dispatcher.warm();
1323
+ // The swarm's manager (manager.mjs): the person's asks, kept to their words, judged by the dispatcher.
1282
1324
  const manager = createManager({
1283
1325
  store,
1284
- askHarness,
1285
- usesServer: () =>
1286
- coordinatorMode() !== "local" &&
1287
- state.connected &&
1288
- bridge.has("swarm_manager"),
1289
- localJudge: () =>
1290
- coordinatorMode() === "local"
1291
- ? (coordinatorPick() ??
1292
- LOCAL_DECIDERS.find((agent) => installedAgents.includes(agent)) ??
1293
- null)
1294
- : null,
1326
+ dispatcher,
1327
+ goals,
1328
+ settled: (threadId) => coordinator.resumed(threadId),
1295
1329
  handOn: handOnAgent,
1296
1330
  post: (entry) => {
1297
1331
  const posted = store.roomPost(entry);
@@ -1341,6 +1375,7 @@ export async function startDaemon() {
1341
1375
  store,
1342
1376
  askHarness,
1343
1377
  isTaskRoom: (thread) => Boolean(store.meta(`task-room:${thread.id}`)),
1378
+ swarmAgents: () => available(),
1344
1379
  readsLessons: () => harnessReads("swarm_lessons"),
1345
1380
  isCoordinatorPost,
1346
1381
  embed: (texts, kind) => local.embed(texts, kind),
@@ -1652,7 +1687,7 @@ export async function startDaemon() {
1652
1687
  store.addContribution({
1653
1688
  taskId: threadId,
1654
1689
  kind: "file",
1655
- author: "harness",
1690
+ author: DISPATCHER,
1656
1691
  text: `harness attached ${fileLine(file)}`,
1657
1692
  source: `file:${file.id}`,
1658
1693
  });
@@ -1661,7 +1696,7 @@ export async function startDaemon() {
1661
1696
  },
1662
1697
  },
1663
1698
  wake: (goalId, post, names) =>
1664
- actions.wakeFor(goalId, post, "harness", names),
1699
+ actions.wakeFor(goalId, post, DISPATCHER, names),
1665
1700
  notify: (text) => {
1666
1701
  localEvent("snippet", text);
1667
1702
  notices.notify(text);
@@ -1781,6 +1816,7 @@ export async function startDaemon() {
1781
1816
  log,
1782
1817
  });
1783
1818
  const coordinator = createCoordinator({
1819
+ dispatcher,
1784
1820
  moves,
1785
1821
  holdsBoard,
1786
1822
  store,
@@ -1832,6 +1868,8 @@ export async function startDaemon() {
1832
1868
  // October 26 over security audit S4: waiting on every round's Start costs the swarm acting on its own).
1833
1869
  handOn: handOnAgent,
1834
1870
  openAsks: (goalId) => manager.open(goalId),
1871
+ doneAsks: (goalId) =>
1872
+ manager.asks(goalId).filter((ask) => ask.status === "done"),
1835
1873
  harnessQueued: (goalId) => asks.waitingFor(goalId, "harness"),
1836
1874
  failedAsks: (goalId) => asks.failed(goalId),
1837
1875
  pauseGoal: actions.pause,
@@ -1957,6 +1995,8 @@ export async function startDaemon() {
1957
1995
  resumed: (id) => coordinator.resumed(id),
1958
1996
  assembles: () => coordinator.assembles(),
1959
1997
  },
1998
+ // The dispatcher slot the person fills (dispatcher.mjs): its setting, read and changed from the CLI.
1999
+ dispatcher,
1960
2000
  roster: () =>
1961
2001
  available().map((id) => ({ id, about: aboutOf(id), setup: setupOf(id) })),
1962
2002
  worktrees,
@@ -2261,11 +2301,20 @@ export async function startDaemon() {
2261
2301
  files: boardFiles,
2262
2302
  }),
2263
2303
  });
2304
+ // A file attached from the person's own folders is not shared with the cloud agents unless the agent says so: the
2305
+ // person keeps their files to their computers, and only the computer holding the file knows where it came from.
2306
+ const ownFilesStayHome = (request) =>
2307
+ request.command === "board.file.add" &&
2308
+ request.path != null &&
2309
+ request.cloud === undefined
2310
+ ? { ...request, cloud: !local.inOwnFolder(String(request.path)) }
2311
+ : request;
2264
2312
  // The person's swarm's board, as a call made on this computer reaches it: here on home, and on a worker at home,
2265
2313
  // sealed (ownMachines.mjs), except what a worker answers itself (its tools, live sessions, watches, prompts).
2266
2314
  // On a worker, a read home cannot answer comes from this computer's copy, saying how old it is, and a write that
2267
2315
  // reached home brings the copy up to date.
2268
- const swarmBoard = (request) => {
2316
+ const swarmBoard = (asked) => {
2317
+ const request = ownFilesStayHome(asked);
2269
2318
  // Work in this computer's own T3 Code is answered here: home has no such thread.
2270
2319
  if (!ownMachines?.forwards(request) || environments.mine(request.id)) {
2271
2320
  const result = boardCommand(request);
@@ -2616,7 +2665,11 @@ export async function startDaemon() {
2616
2665
  ask: (type, input) => bridge.ask(type, input),
2617
2666
  boardCommand: (request) => boardCommand(request),
2618
2667
  filesRoot: paths.files,
2619
- changed: saveStatus,
2668
+ // A computer that became home fetches the dispatcher's model then (the others never do).
2669
+ changed: () => {
2670
+ saveStatus();
2671
+ dispatcher.warm();
2672
+ },
2620
2673
  folders: (options) => machineFolders(options),
2621
2674
  repositoryOf: (folder) => repositoryName(folder),
2622
2675
  inventoryChanged: () => {
@@ -2762,7 +2815,7 @@ export async function startDaemon() {
2762
2815
  knownFolders: () => folders.known().map((place) => place.path),
2763
2816
  agents: () => [
2764
2817
  ...installedAgents.filter((agent) => RUNNERS.has(agent)),
2765
- "harness",
2818
+ ...(actors.available().includes("harness") ? ["harness"] : []),
2766
2819
  ],
2767
2820
  worktreeRoot: path.join(paths.home, "projects"),
2768
2821
  maxPosts: DEFAULT_MAX_POSTS,