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
@@ -4,12 +4,12 @@ import path from "node:path";
4
4
  import { execFile } from "node:child_process";
5
5
  import { ATLAS_VERSION } from "./atlas.mjs";
6
6
  import { createContextWorker } from "./contextWorker.mjs";
7
- import { createCoreModels } from "./coreModels.mjs";
8
- import { readJson, writeJsonAtomic } from "./files.mjs";
7
+ import { CORE, createCoreModels } from "./coreModels.mjs";
8
+ import { readJson, updateJson } from "./files.mjs";
9
9
  import { createFirewall } from "./firewall.mjs";
10
10
  import { createInference } from "./inference.mjs";
11
11
  import { listen } from "./listen.mjs";
12
- import { ensureModels, modelsPresent } from "./localmodels.mjs";
12
+ import { MODELS, ensureModels, modelsPresent } from "./localmodels.mjs";
13
13
  import { createOcr, imageKind } from "./ocr.mjs";
14
14
  import { createAppleSpeech, createSpeech } from "./speech.mjs";
15
15
  import { fromBlob, toBlob, topK } from "./vectors.mjs";
@@ -24,6 +24,7 @@ const SPEECH_NAMES_MS = 5 * 60_000;
24
24
  // Commands this module answers on the control socket.
25
25
  const COMMANDS = new Set([
26
26
  "local.status",
27
+ "local.models",
27
28
  "local.learn",
28
29
  "local.on",
29
30
  "local.off",
@@ -35,8 +36,8 @@ const COMMANDS = new Set([
35
36
  ]);
36
37
 
37
38
  /**
38
- * The relay's local models and everything that reads with them. Setup asks for the core set, which this daemon
39
- * downloads into `<home>/local` in the background (coreModels.mjs); until a model is present, what needs it says so or
39
+ * The relay's local models and everything that reads with them. Setup asks the person, and on their yes this daemon
40
+ * downloads the models into `<home>/local` (coreModels.mjs); until a model is present, what needs it says so or
40
41
  * goes as it did before.
41
42
  *
42
43
  * - The context space (search): the search model embeds it in the background, a batch at a time, so no request waits
@@ -63,14 +64,18 @@ export function createLocalStack({
63
64
  quiet,
64
65
  notify,
65
66
  localEvent,
67
+ holdsBoard = () => true,
66
68
  log,
67
69
  }) {
68
70
  const root = path.join(home, "local");
69
71
  const inference = createInference({ root, log });
70
72
  const ready = (ids) => modelsPresent(root, ids);
73
+ // The dispatcher's model runs where the board is; the image and audio part comes when folders first need it.
74
+ const offered = () => (holdsBoard() ? [...CORE, "dispatcher"] : CORE);
71
75
  const coreModels = createCoreModels({
72
76
  root,
73
77
  wanted: () => readJson(configPath, {}).localModels === "download",
78
+ ids: offered,
74
79
  log,
75
80
  });
76
81
  const ocr = createOcr({ inference });
@@ -410,13 +415,14 @@ export function createLocalStack({
410
415
  ok: false,
411
416
  error: "give the full path of a folder on this computer",
412
417
  };
413
- const config = readJson(configPath, {});
414
- const listed = (
415
- Array.isArray(config.localFolders) ? config.localFolders : []
416
- ).filter((entry) => entry !== folder);
417
- writeJsonAtomic(configPath, {
418
- ...config,
419
- localFolders: adding ? [...listed, folder] : listed,
418
+ updateJson(configPath, (config) => {
419
+ const listed = (
420
+ Array.isArray(config.localFolders) ? config.localFolders : []
421
+ ).filter((entry) => entry !== folder);
422
+ return {
423
+ ...config,
424
+ localFolders: adding ? [...listed, folder] : listed,
425
+ };
420
426
  });
421
427
  if (adding) {
422
428
  const read = () =>
@@ -481,6 +487,55 @@ export function createLocalStack({
481
487
  );
482
488
  };
483
489
 
490
+ // Every model the relay may run, for the person: its job, its size and whether it is here. `download` is the person's
491
+ // switch: off means nothing more comes down; what is here stays until they remove Harness.
492
+ // An upgraded computer has no Local models step: it says once what its answer is waiting for, in Settings.
493
+ const tellUpgradeAsks = (tell) => {
494
+ const config = readJson(configPath, {});
495
+ if (config.localModels !== "ask" || config.upgradeAsks !== true) return;
496
+ if (coreModels.status().ready) return;
497
+ const { total } = coreModels.status().progress ?? {};
498
+ const sized = total ? ` (${(total / 1e9).toFixed(1)} GB)` : "";
499
+ if (
500
+ tell(
501
+ `Harness's local models aren't on this computer yet. Download them${sized} in Settings, under Local models, if you want them.`
502
+ )
503
+ )
504
+ updateJson(configPath, (saved) => ({
505
+ ...saved,
506
+ upgradeAsks: false,
507
+ }));
508
+ };
509
+
510
+ const localModels = (request) => {
511
+ if (typeof request.download === "boolean") {
512
+ updateJson(configPath, (saved) => ({
513
+ ...saved,
514
+ localModels: request.download ? "download" : "off",
515
+ localModelsAnswered: true,
516
+ upgradeAsks: false,
517
+ }));
518
+ if (request.download) void coreModels.start({ again: true });
519
+ }
520
+ const models = MODELS.map((entry) => ({
521
+ id: entry.id,
522
+ name: entry.name,
523
+ purpose: entry.purpose,
524
+ tier: entry.tier,
525
+ offered: offered().includes(entry.id),
526
+ here: ready([entry.id]),
527
+ bytes: entry.files.reduce((sum, file) => sum + (file.size ?? 0), 0),
528
+ }));
529
+ const choice = readJson(configPath, {}).localModels;
530
+ return {
531
+ ok: true,
532
+ asking: choice === "ask",
533
+ download: choice !== "off" && choice !== "ask",
534
+ core: coreModels.status(),
535
+ models,
536
+ };
537
+ };
538
+
484
539
  /**
485
540
  * The local stack as the person sees it (tryharness local, the buddy): what is installed, where it runs, what is
486
541
  * indexed and the overnight learner's last result; `local.learn` starts the learner now instead of waiting for the
@@ -500,6 +555,8 @@ export function createLocalStack({
500
555
  }),
501
556
  (error) => ({ ok: false, error: error.message })
502
557
  );
558
+ case "local.models":
559
+ return localModels(request);
503
560
  case "local.learn":
504
561
  void contextEngine
505
562
  .learn({ force: true })
@@ -507,10 +564,10 @@ export function createLocalStack({
507
564
  return { ok: true, started: true };
508
565
  case "local.on":
509
566
  case "local.off":
510
- writeJsonAtomic(configPath, {
511
- ...readJson(configPath, {}),
567
+ updateJson(configPath, (saved) => ({
568
+ ...saved,
512
569
  libraryOff: request.command === "local.off",
513
- });
570
+ }));
514
571
  setImmediate(() => void contextEngine.refreshFiles().catch(() => {}));
515
572
  return { ok: true, folders: libraryFolders() };
516
573
  case "local.add":
@@ -549,11 +606,13 @@ export function createLocalStack({
549
606
  return {
550
607
  inference,
551
608
  ready,
609
+ tellUpgradeAsks,
552
610
  contextEngine,
553
611
  ocr,
554
612
  firewall,
555
613
  speech,
556
- scrubber: () => scrubber,
614
+ // The credential model may come down after the daemon starts: the scrub picks it up without a restart.
615
+ scrubber: () => (ready(["credentials"]) ? firewall : scrubber),
557
616
  embed,
558
617
  searchContext,
559
618
  libraryFolders,
@@ -273,95 +273,27 @@ export const MODELS = [
273
273
  },
274
274
  ],
275
275
  },
276
- // Talk in the buddy (speech.mjs), downloaded the first time the person holds it: the VAD always, the speech model only
277
- // where Apple's transcriber is not used.
278
- {
279
- id: "vad",
280
- name: "Silero VAD 6.2",
281
- purpose: "Hears whether anyone spoke while the talk key was held",
282
- tier: "extended",
283
- runtime: "onnx",
284
- licence: "mit",
285
- repo: "istupakov/silero-vad-onnx",
286
- revision: "b3e3ee3cce4c11ceb63b1a0b229d916069c1ddf6",
287
- files: [
288
- {
289
- path: "silero_vad_16k_op15.onnx",
290
- sha256:
291
- "7ed98ddbad84ccac4cd0aeb3099049280713df825c610a8ed34543318f1b2c49",
292
- size: 1289603,
293
- },
294
- ],
295
- },
296
- // Speech where Apple's own transcriber is not on the computer (Linux, Windows, Macs before macOS 26): NVIDIA's
297
- // Parakeet TDT 0.6B v3 (CC-BY-4.0; credited in the CLI's README), the 8-bit ONNX export by istupakov. Measured on a
298
- // fixed set of recordings against the Moonshine base it replaced: 2.8% of words wrong on real people reading against 4.9%. Two
299
- // threads: a 5 s recording in 130 ms here against 205 ms on one (four: 99 ms).
300
- {
301
- id: "speech",
302
- name: "Parakeet TDT 0.6B v3 (8-bit)",
303
- purpose: "Turns what the person says into text for the buddy's composer",
304
- tier: "extended",
305
- runtime: "onnx",
306
- licence: "cc-by-4.0",
307
- repo: "istupakov/parakeet-tdt-0.6b-v3-onnx",
308
- revision: "8f23f0c03c8761650bdb5b40aaf3e40d2c15f1ce",
309
- engine: "parakeet",
310
- threads: 2,
311
- files: [
312
- {
313
- path: "encoder-model.int8.onnx",
314
- sha256:
315
- "6139d2fa7e1b086097b277c7149725edbab89cc7c7ae64b23c741be4055aff09",
316
- size: 652183999,
317
- },
318
- {
319
- path: "decoder_joint-model.int8.onnx",
320
- sha256:
321
- "eea7483ee3d1a30375daedc8ed83e3960c91b098812127a0d99d1c8977667a70",
322
- size: 18202004,
323
- },
324
- {
325
- path: "nemo128.onnx",
326
- sha256:
327
- "a9fde1486ebfcc08f328d75ad4610c67835fea58c73ba57e3209a6f6cf019e9f",
328
- size: 139764,
329
- },
330
- {
331
- path: "vocab.txt",
332
- sha256:
333
- "d58544679ea4bc6ac563d1f545eb7d474bd6cfa467f0a6e2c1dc1c7d37e3c35d",
334
- size: 93939,
335
- },
336
- {
337
- path: "config.json",
338
- sha256:
339
- "666903c76b9798caf2c210afd4f6cd60b08a8dbf9800ec8d7a3bc0d2148ac466",
340
- size: 97,
341
- },
342
- ],
343
- },
344
276
  // The dispatcher slot's default model (owner, November 1: "LFM 3-omni not the 1.7b version", "the slot should use the
345
277
  // base model for now and ill work on a fine tune"). Words what needs words and checks results against the person's
346
278
  // words; it never decides who takes the work (Jev does). Measured at 759 MB phys_footprint with a 16K window on this
347
279
  // M-series Mac after a goal-writing job; needs llama.cpp b12032 or later (b11609 does not know the lfm3 architecture).
348
280
  {
349
281
  id: "dispatcher",
350
- name: "LFM3-Omni 2B (base)",
282
+ name: "LFM3-Omni 2B (Harness dispatcher)",
351
283
  purpose:
352
- "Dispatches the swarm's work: words what needs words and checks results against the person's words",
284
+ "Dispatches the swarm's work: sorts the person's messages, words what needs words, and hears speech where Apple's transcriber isn't on the computer",
353
285
  tier: "extended",
354
- memoryMb: 760,
286
+ memoryMb: 843,
355
287
  runtime: "llama",
356
288
  licence: "lfm1.0",
357
- repo: "LiquidAI/LFM3-Omni-2B-GGUF",
358
- revision: "3d29af2ad166f8299c2d820937e47dc0add20ffc",
289
+ repo: "Saltorious/lfm3-omni-2b-harness-dispatcher",
290
+ revision: "5a40f6f0e252e8596f2af278745470f890d1d973",
359
291
  files: [
360
292
  {
361
- path: "LFM3-Omni-2B-Q4_K_M.gguf",
293
+ path: "lfm3-omni-dispatcher-Q4_K_M.gguf",
362
294
  sha256:
363
- "9f8d30e9d4fd7a9349d586e077988229b3ca0a0e4ad730897563d1eccc9893e2",
364
- size: 1099630080,
295
+ "28544a4aa44ec8731d56a4dac63a6bc8de2501d17ab92536de16bc1cdc1d1d93",
296
+ size: 1099629344,
365
297
  },
366
298
  {
367
299
  path: "mmproj-LFM3-Omni-2B-Q4_K_M.gguf",
@@ -370,7 +302,9 @@ export const MODELS = [
370
302
  size: 291586720,
371
303
  },
372
304
  ],
373
- llama: { mmproj: 1, c: 16384 },
305
+ // The prompt cache held every recording it heard: 3.3 GB after 70 minutes of audio, against 843 MB without it, at the
306
+ // same accuracy and speed (eval long-listen, November 6).
307
+ llama: { mmproj: 1, c: 16384, "cache-ram": 0, "no-cache-prompt": true },
374
308
  },
375
309
  ];
376
310
 
@@ -446,7 +380,20 @@ const present = (file, size) => {
446
380
  }
447
381
  };
448
382
 
449
- async function download(url, target, expected, { fetchImpl, log }) {
383
+ // Search, redaction, speech and the setup step can each ask for the same file, and two writers would corrupt its partial.
384
+ const underway = new Map();
385
+ function download(url, target, expected, options) {
386
+ if (!underway.has(target))
387
+ underway.set(
388
+ target,
389
+ fetchFile(url, target, expected, options).finally(() =>
390
+ underway.delete(target)
391
+ )
392
+ );
393
+ return underway.get(target);
394
+ }
395
+
396
+ async function fetchFile(url, target, expected, { fetchImpl, log }) {
450
397
  const partial = `${target}.partial`;
451
398
  ensureDir(path.dirname(target));
452
399
  let have = 0;
@@ -519,6 +466,39 @@ export async function ensureModels({
519
466
  return done;
520
467
  }
521
468
 
469
+ const bytesOnDisk = (file, size) => {
470
+ if (present(file, size)) return size;
471
+ try {
472
+ return Math.min(fs.statSync(`${file}.partial`).size, size);
473
+ } catch {
474
+ return 0;
475
+ }
476
+ };
477
+
478
+ /** How far these models and the model server have come, read off the disk: { done, total } in bytes. */
479
+ export function downloadProgress(root, ids, list = MODELS) {
480
+ const files = ids.flatMap((id) => {
481
+ const entry = modelById(id, list);
482
+ return entry.files.map((file, index) => ({
483
+ path: modelFile(root, entry, index),
484
+ size: file.size,
485
+ }));
486
+ });
487
+ const server = llamaAsset();
488
+ const serverDone = !server
489
+ ? 0
490
+ : llamaServer(root)
491
+ ? server.size
492
+ : bytesOnDisk(path.join(root, server.name), server.size);
493
+ return {
494
+ done: files.reduce(
495
+ (sum, file) => sum + bytesOnDisk(file.path, file.size),
496
+ serverDone
497
+ ),
498
+ total: files.reduce((sum, file) => sum + file.size, server?.size ?? 0),
499
+ };
500
+ }
501
+
522
502
  export const modelsPresent = (root, ids, list = MODELS) =>
523
503
  ids.every((id) => {
524
504
  const entry = modelById(id, list);
@@ -10,7 +10,7 @@
10
10
  export const LOOP_TURNS = 8;
11
11
  export const LOOP_COOLDOWN_MS = 60 * 60_000;
12
12
 
13
- const ENDED = ["done", "failed", "unknown"];
13
+ const ENDED = TASK_ENDED;
14
14
  // Turns that never reached their agent: the person stopped them, or they could not start.
15
15
  const NEVER_RAN = ["person", "start"];
16
16
 
@@ -102,3 +102,4 @@ export function createLoopBackstop({
102
102
 
103
103
  return { check };
104
104
  }
105
+ import { TASK_ENDED } from "./taskRules.mjs";