@qvac/harness 1.0.0-rc.6 → 1.0.0-rc.8

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 (93) hide show
  1. package/CHANGELOG.md +175 -10
  2. package/README.md +19 -7
  3. package/dist-lib/index.d.ts +3 -3
  4. package/dist-lib/index.js +1 -1
  5. package/dist-lib/lib/capabilities/completion-engine/actors/stream.js +2 -0
  6. package/dist-lib/lib/capabilities/completion-engine/actors/streaming.js +31 -3
  7. package/dist-lib/lib/capabilities/completion-engine/driver.js +3 -0
  8. package/dist-lib/lib/capabilities/completion-engine/index.d.ts +1 -0
  9. package/dist-lib/lib/capabilities/completion-engine/index.js +1 -0
  10. package/dist-lib/lib/capabilities/completion-engine/model-round.d.ts +1 -0
  11. package/dist-lib/lib/capabilities/completion-engine/round.js +5 -2
  12. package/dist-lib/lib/capabilities/completion-engine/tool-sets.d.ts +24 -0
  13. package/dist-lib/lib/capabilities/completion-engine/tool-sets.js +15 -0
  14. package/dist-lib/lib/capabilities/detect-language.d.ts +2 -1
  15. package/dist-lib/lib/capabilities/detect-language.js +14 -2
  16. package/dist-lib/lib/connect.d.ts +2 -0
  17. package/dist-lib/lib/connect.js +73 -7
  18. package/dist-lib/lib/contract/drive.d.ts +2 -2
  19. package/dist-lib/lib/contract-types.d.ts +5 -1
  20. package/dist-lib/lib/helpers/require-peers.d.ts +3 -0
  21. package/dist-lib/lib/helpers/require-peers.js +23 -0
  22. package/dist-lib/lib/models/llm-presets.d.ts +1 -0
  23. package/dist-lib/lib/models/model-catalog.js +1 -1
  24. package/dist-lib/lib/models/opencl-cache.js +2 -2
  25. package/dist-lib/lib/plugins/registry.d.ts +2 -0
  26. package/dist-lib/lib/plugins/registry.js +4 -0
  27. package/dist-lib/lib/round-host.d.ts +12 -0
  28. package/dist-lib/lib/round-host.js +57 -0
  29. package/dist-lib/lib/round-port.d.ts +24 -0
  30. package/dist-lib/lib/round-port.js +81 -0
  31. package/dist-lib/lib/sdk-loader.d.ts +1 -1
  32. package/dist-lib/lib/sdk-loader.js +30 -6
  33. package/dist-lib/lib/sdk-storage.d.ts +1 -0
  34. package/dist-lib/lib/sdk-storage.js +18 -2
  35. package/dist-lib/lib/serve.js +61 -1
  36. package/dist-lib/lib/sidecar/index.d.ts +10 -0
  37. package/dist-lib/lib/sidecar/index.js +35 -3
  38. package/dist-lib/lib/sidecar/user-plugins.d.ts +1 -0
  39. package/dist-lib/lib/sidecar/user-plugins.js +1 -1
  40. package/dist-lib/lib/tools/files/grep.js +113 -15
  41. package/dist-lib/lib/tools/fs/drive.d.ts +1 -16
  42. package/dist-lib/lib/tools/fs/edit-match.js +75 -7
  43. package/dist-lib/lib/tools/fs/remote-protocol.d.ts +23 -1
  44. package/dist-lib/lib/tools/fs/remote-protocol.js +1 -1
  45. package/dist-lib/lib/tools/fs/remote.d.ts +1 -8
  46. package/dist-lib/lib/tools/fs/remote.js +1 -1
  47. package/dist-lib/lib/tools/fs/search.d.ts +1 -1
  48. package/dist-lib/lib/tools/fs/search.js +2 -1
  49. package/dist-lib/lib/tools/index.d.ts +2 -1
  50. package/dist-lib/lib/tools/index.js +2 -2
  51. package/dist-lib/lib/tools/skills/frontmatter-parser.d.ts +1 -0
  52. package/dist-lib/lib/tools/skills/frontmatter-parser.js +1 -0
  53. package/dist-lib/lib/tools/skills/skill-state-constants.d.ts +1 -0
  54. package/dist-lib/lib/tools/skills/skill-state-constants.js +4 -0
  55. package/dist-lib/lib/wire.d.ts +13 -0
  56. package/dist-lib/lib/wire.js +44 -1
  57. package/dist-lib/plugins/coding/read-only.d.ts +1 -0
  58. package/dist-lib/plugins/coding/read-only.js +264 -0
  59. package/dist-lib/plugins/coding/session.d.ts +3 -1
  60. package/dist-lib/plugins/coding/session.js +19 -2
  61. package/dist-lib/plugins/egress-proxy/index.d.ts +2 -2
  62. package/dist-lib/plugins/egress-proxy/index.js +5 -3
  63. package/dist-lib/plugins/image/index.js +7 -2
  64. package/dist-lib/plugins/language-hint/index.js +4 -1
  65. package/dist-lib/plugins/music/index.js +6 -2
  66. package/dist-lib/plugins/python/index.js +1 -0
  67. package/dist-lib/plugins/python/loader.d.ts +1 -0
  68. package/dist-lib/plugins/python/loader.js +8 -0
  69. package/dist-lib/plugins/quickjs/index.js +4 -0
  70. package/dist-lib/plugins/quickjs/runtime.js +8 -3
  71. package/dist-lib/plugins/run-report/index.js +6 -2
  72. package/dist-lib/plugins/run-report/layout.js +1 -1
  73. package/dist-lib/plugins/sandbox-vm/index.js +3 -0
  74. package/dist-lib/plugins/sandbox-windows/prebuilds/win32-arm64/qvac-sandbox.exe +0 -0
  75. package/dist-lib/plugins/sandbox-windows/prebuilds/win32-x64/qvac-sandbox.exe +0 -0
  76. package/dist-lib/plugins/speech/audio-resample.js +2 -1
  77. package/dist-lib/plugins/speech/index.d.ts +1 -0
  78. package/dist-lib/plugins/speech/index.js +8 -1
  79. package/dist-lib/plugins/speech/speech-runtime.js +3 -3
  80. package/dist-lib/plugins/translation/index.d.ts +1 -1
  81. package/dist-lib/plugins/translation/index.js +7 -3
  82. package/dist-lib/plugins/translation/translate.d.ts +2 -2
  83. package/dist-lib/plugins/translation/translate.js +7 -8
  84. package/dist-lib/plugins/walkie-talkie/index.d.ts +2 -2
  85. package/dist-lib/plugins/walkie-talkie/index.js +13 -5
  86. package/dist-lib/plugins/walkie-talkie/wire.d.ts +5 -0
  87. package/dist-lib/plugins/walkie-talkie/wire.js +6 -5
  88. package/dist-lib/schema/harness.js +13 -4
  89. package/dist-lib/spec/hrpc/messages.js +205 -151
  90. package/dist-lib/spec/hyperschema/index.js +205 -151
  91. package/dist-lib/spec/hyperschema/schema.json +125 -89
  92. package/dist-lib/spec/hyperschema/types.d.ts +4 -4
  93. package/package.json +129 -24
package/CHANGELOG.md CHANGED
@@ -21,28 +21,58 @@ breaking change is listed under Changed and Removed.
21
21
 
22
22
  ### Added
23
23
 
24
- - `CompletionContext.modelRound`, in process only, sends each `generating` and
24
+ - `Tools.product` takes `files: false` to leave the file tools out, for a host
25
+ with no folder to share, such as a phone entry that composes its tools with
26
+ the mcp, web-search and weather plugins. `isDeviceSharedCredentialKey` from
27
+ `@qvac/harness/skill-state` names the first-party plugins' device-shared
28
+ credential keys for a client that has no skill readiness to read them from.
29
+ - `CompletionContext.modelRound` sends each `generating` and
25
30
  `wrapping` model round to another device. It gets the request the local
26
31
  round would send and streams `content` and `thinking` back through `emit`;
27
32
  tools, the stop hook and `answering` stay on the run owner.
28
33
  A run started with it pauses for it on resume. A paused or cancelled round,
29
34
  local or remote, now ends at once even when the model sends nothing. See the
30
35
  [decision record](docs/decisions/2026-10-19-a-remote-host-serves-the-model-round.md).
31
- A sidecar from `spawnHarness` or `connectHarness` refuses `modelRound` and
32
- `roundCut` with `CAPABILITY_UNSUPPORTED` instead of running locally.
33
- (#493, #542)
36
+ (#493)
34
37
  - `ModelRoundIo.retake()` restarts a remote round when another host takes it:
35
38
  the run emits `round-reset` for the round and the returned emitter carries
36
39
  the new taker's chunks, while the earlier taker's late chunks are dropped.
37
40
  The port resolves with the new taker's result. (#497)
38
41
  - `harness.serveModelRound(request, io)` serves a model round on the model
39
- host, in process: it leases `request.modelId` and runs the same round a local
42
+ host: it leases `request.modelId` and runs the same round a local
40
43
  run does, with the context ladder and the forced-call fallback, and is
41
44
  refused with `HARNESS_SUSPENDED` while suspended. Core sends it the
42
45
  `ModelRoundRequest` whole. A remote round now answers an unclosed think from
43
46
  the host's replay, and its request carries `unforced`. See the
44
47
  [decision record](docs/decisions/2026-10-19-a-remote-host-serves-the-model-round.md).
45
48
  (#541)
49
+ - A remote round crosses the wire on both sides. A `RemoteHarness` from
50
+ `spawnHarness`, `connectHarness` or `harnessChild` (the mobile worker) takes
51
+ `modelRound` and `roundCut` on the run owner, and serves
52
+ `serveModelRound(request, io)` on the model host, so neither device embeds a
53
+ second `Harness` beside its sidecar or worker. They ride the `completion`
54
+ stream as `model-round-*` and `round-cut` frames, and an abort crosses it as
55
+ the run's does. The `CAPABILITY_UNSUPPORTED` refusal from #542 is gone.
56
+ See the
57
+ [decision record](docs/decisions/2026-10-19-a-remote-host-serves-the-model-round.md).
58
+ (#542, #616)
59
+
60
+ ```js
61
+ const owner = spawnHarness(options)
62
+ owner.completion({ ...run, modelRound: (request, io) => host.serveModelRound(request, io) })
63
+ ```
64
+
65
+ - `ToolSets` names a round's tool set by hash, so a shared chat carries each
66
+ set's schemas once. A remote round's request now carries `toolSet`, the
67
+ `ToolSets.hash` of its `tools`, on every round that has tools. The run
68
+ owner writes the schemas only when its `ToolSets` cannot `resolve` the
69
+ hash, and a model host replays the chat into a `ToolSets` and resolves
70
+ each request's `toolSet` (#495).
71
+
72
+ ```js
73
+ const tools = toolSets.resolve(request.toolSet)
74
+ ```
75
+
46
76
  - A turn's context is data the host can replay. A run reports what it added to
47
77
  each user turn (its time, the knowledge it retrieved, a `promptSubmit` hook's
48
78
  context) once, as a `context` event. A host stores it and sends it back as
@@ -306,7 +336,7 @@ breaking change is listed under Changed and Removed.
306
336
  only. A goal's `ms` wins, and a resume keeps the budget the run started
307
337
  with. See the
308
338
  [decision record](docs/decisions/2026-10-13-run-time-budget.md). (#442)
309
- - `CompletionContext.roundCut`, in process only, hands the host a `cut(note)`
339
+ - `CompletionContext.roundCut` hands the host a `cut(note)`
310
340
  that stops the tool round streaming now and keeps the run. The round's whole
311
341
  calls run, a call it may have truncated is answered with
312
342
  `wording.toolRoundCut`, and the note is the next user turn, acked by an
@@ -374,8 +404,116 @@ breaking change is listed under Changed and Removed.
374
404
  import type { DriveOpFn, GrantedDrive, ManagedSkill } from '@qvac/harness'
375
405
  ```
376
406
 
407
+ - `grep` takes `output` (`content`, the default; `files`, the matching paths;
408
+ `count`, per file), and `limit` and `offset` to page past a cut-off answer.
409
+ A plain-text pattern can name alternatives as `a|b`, and a miss on a pattern
410
+ that looks like a regular expression says to set `regex: true`. (#628)
411
+ - `edit_file` answers a miss with the file's closest lines, numbered as
412
+ `read_file` shows them, so the next try can copy them; when the new text is
413
+ already in the file it says the edit looks done. Old text copied with
414
+ `read_file`'s line numbers matches without them. (#628)
415
+ - The coding plugin runs a shell line that only reads, such as `rg`, `grep`,
416
+ `sed -n` or `cat` with files inside the shared folder, without asking. Each
417
+ reader allows only flags known to shape output, and a run whose shell may
418
+ have moved (an earlier line other than a reader, or a `cwd`) asks again.
419
+ (#628)
420
+ - `generationParams.reasoning_rounds: 'plan'` thinks only where a plan is made
421
+ or remade: after the user speaks and after a round whose call failed. (#628)
422
+ - A host that runs the sidecar names a module in `QVAC_HARNESS_HOST_MODULE`,
423
+ an absolute path, whose `configureHarness(harness, log)` the sidecar calls
424
+ after the user plugins load; a module that fails stops the sidecar.
425
+ `QVAC_SDK_OPTIONS` names a JSON file of SDK options the sidecar adds to the
426
+ SDK config it writes. The `drive`, `remote`, `remote-protocol` and five skill
427
+ leaves under `@qvac/harness/lib/tools/` are exported for such a host. See the
428
+ [decision record](docs/decisions/2026-10-25-a-host-shapes-the-harness-through-a-named-module.md).
429
+ (#629)
430
+
377
431
  ### Changed
378
432
 
433
+ - A host reaches the drive protocol it serves, the skill catalog and the
434
+ user-plugin import map through named entries: `@qvac/harness/drive`
435
+ (`DriveRequest`, `DriveResponse`, `DriveEntry`, `GrantedDrive`, `DriveOpFn`,
436
+ `MAX_DRIVE_BYTES`), `@qvac/harness/skill-catalog` (`loadSkillCatalog`,
437
+ `availableSkills`) and `@qvac/harness/user-plugins` (`sharedImports`), and
438
+ `@qvac/harness/skill-manifest` adds `readSkillSetup`. `test/entry-weight.ts`
439
+ holds every named entry to a ceiling on the files importing it loads, so a
440
+ host that imports a constant never parses the engine. (#636)
441
+
442
+ - Every host that runs python, on Bare or Node, recopies
443
+ `patches/pyodide@314.0.2.patch` into its `patchedDependencies`. Guest Python
444
+ sees: `ctypes` calls to `emscripten_run_script*` do nothing and return 0, a
445
+ side module with `EM_JS` or `EM_ASM` is refused with `OSError`, `pyodide_js`
446
+ holds only the allowlisted members, and `loadPackage` takes lockfile names
447
+ only. A worker that boots an unpatched pyodide logs one line per process.
448
+ (#567, #586)
449
+ - **Breaking:** a plugin's dependencies are optional peer dependencies of
450
+ `@qvac/harness`, so installing the harness no longer installs any plugin's
451
+ native addons or libraries. A host installs the peers of the plugins it
452
+ imports; importing a plugin without them throws one error that names the
453
+ plugin and the packages. The shipped sidecar entry composes speech, image,
454
+ music, translation and python, so a host that spawns it installs their
455
+ peers; a host that wants fewer writes its own entry. See
456
+ [Plugin dependencies](docs/hosting.md#plugin-dependencies). (#626)
457
+
458
+ | Plugin | Peers |
459
+ | --------------- | ---------------------------------------------------------------------- |
460
+ | `speech` | `@qvac/asr-ggml`, `@qvac/tts-ggml`, `bare-ffmpeg` |
461
+ | `image` | `@qvac/diffusion-cpp`, `bare-image-resample`, `bare-media` |
462
+ | `music` | `@qvac/audiogen-ggml` |
463
+ | `translation` | `@qvac/translation-nmtcpp` |
464
+ | `python` | `pyodide` |
465
+ | `quickjs` | `@jitl/quickjs-singlefile-mjs-release-sync`, `quickjs-emscripten-core` |
466
+ | `egress-proxy` | `bare-net` |
467
+ | `run-report` | `elkjs` |
468
+ | `walkie-talkie` | `hyperswarm`, `hypercore-crypto` |
469
+ | `sandbox-vm` | `barevisor` |
470
+
471
+ ```sh
472
+ # before: the harness installed every plugin's dependencies
473
+ npm i @qvac/harness
474
+ # after: a host spawning the shipped sidecar entry
475
+ npm i @qvac/harness @qvac/asr-ggml @qvac/tts-ggml bare-ffmpeg @qvac/diffusion-cpp \
476
+ bare-image-resample bare-media @qvac/audiogen-ggml @qvac/translation-nmtcpp pyodide
477
+ ```
478
+
479
+ - **Breaking:** `@qvac/sdk` and the model addons are optional peer
480
+ dependencies of `@qvac/harness`, so installing the harness installs no model
481
+ engine. Each belongs to the capability that loads it: on Bare, completion
482
+ needs `@qvac/llm-llamacpp` and `@qvac/langdetect-text`, embeddings and the
483
+ `knowledge` plugin need `@qvac/embed-llamacpp`; on Node every capability
484
+ needs `@qvac/sdk`, which brings its own addons. A missing one throws where
485
+ the capability loads, naming the capability and the packages; the harness
486
+ entry imports without any of them. Speech and music add `@qvac/decoder-audio`
487
+ to their peers, and translation and `language-hint` add
488
+ `@qvac/langdetect-text`. The core and the plugins import the engine's
489
+ plugins and model catalog from `@qvac/inference`, a dependency, not through
490
+ `@qvac/sdk`. See [Model dependencies](docs/hosting.md#model-dependencies).
491
+ (#630)
492
+
493
+ ```sh
494
+ # a desktop host on Node
495
+ npm i @qvac/harness @qvac/sdk @qvac/llm-llamacpp @qvac/embed-llamacpp @qvac/langdetect-text
496
+ # a phone app running completion on a Bare thread
497
+ npm i @qvac/harness @qvac/llm-llamacpp @qvac/langdetect-text
498
+ ```
499
+
500
+ - **Breaking:** `harness.detectLanguage` returns a promise, since it loads the
501
+ detector on first use. (#630)
502
+
503
+ ```js
504
+ // before
505
+ const [best] = harness.detectLanguage({ text })
506
+ // after
507
+ const [best] = await harness.detectLanguage({ text })
508
+ ```
509
+
510
+ - `bare-worker` is pinned to 4.5.0 and `bare-module` is a dependency at
511
+ `~7.1.0`, so a host's install resolves a `bare-module` that runs on Bare
512
+ 1.34: `bare-worker` 4.5.3 asks for `bare-module` 7.4, and npm gives it 7.5,
513
+ which needs Bare 1.35. (#630)
514
+ - The `sandbox-vm` plugin (`VmShell`, `./plugins/sandbox-vm`) is back, with
515
+ `barevisor` an optional peer instead of a dependency every host installed.
516
+ (#626)
379
517
  - Every skill-gated tool (`docx`, `pptx`, `xlsx`, `pdf`, `generate_image`, …),
380
518
  `http_request` and every MCP server's tools are deferred behind
381
519
  `tool_search`. The sent tool set is fixed per chat, so a skill load no longer
@@ -383,6 +521,18 @@ breaking change is listed under Changed and Removed.
383
521
  direct call to a deferred tool loads it and runs in the same round instead of
384
522
  being refused. An MCP server sets `defer: false` to send its schemas whole.
385
523
  `skill-eval` gains `--defer`. (#566)
524
+ - **Breaking:** `engines.node` is `^22.21.0 || >=24.9.0`. A Node host outside
525
+ that range crashed with `SIGSEGV` in `spawnHarness`; npm now warns at install.
526
+ See [On Node](docs/hosting.md#on-node). (#553)
527
+ - **Breaking** for guest Python that imports from `js`: the `js` module holds
528
+ only the names in `JS_GLOBALS`, and the python worker seals the `Function`,
529
+ `AsyncFunction` and generator constructors after boot. `pyodide_js` holds
530
+ only what pyodide's Python and micropip import, with no `FS` or
531
+ `mountNodeFS`, and the pyodide patch turns the `emscripten_run_script*` and
532
+ `EM_JS`/`EM_ASM` routes into no-ops or refusals. `pyodide.code.run_js` raises
533
+ in the guest. See
534
+ [the decision record](docs/decisions/2026-10-20-guest-python-sees-only-allowlisted-js-globals.md).
535
+ (#554, #567)
386
536
  - **Breaking** for a TypeScript host that reads it: `inference-sent` no longer
387
537
  carries `messages`. `@qvac/inference` 0.22 does not report the slice it
388
538
  pushed, so the field was always empty; a prompt inspector reads the payload
@@ -457,8 +607,9 @@ breaking change is listed under Changed and Removed.
457
607
  - A host that runs python on Node recopies `patches/pyodide@314.0.2.patch`
458
608
  into its `patchedDependencies`. Pyodide now loads `child-process-stub.cjs`
459
609
  by path, so guest `os.system` cannot spawn a process on Node either. A Bare
460
- host needs nothing: the old patch already gave it the stub. On Node, guest
461
- Python still reaches the host realm through `js` (#554, open). (#535)
610
+ host needs nothing: the old patch already gave it the stub. #554 later closed
611
+ the `js` route to the host realm, and #567 changed the patch again for every
612
+ host. (#535)
462
613
  - A call whose result is the same as its last result in the run is not
463
614
  progress: its result carries `wording.toolUnchanged`, and 3 such calls send
464
615
  the run to the wrap-up with the `exhausted` outcome. A round whose sent
@@ -818,6 +969,15 @@ breaking change is listed under Changed and Removed.
818
969
 
819
970
  ### Removed
820
971
 
972
+ - The eight file exports 1.0.0-rc.7 added for hosts:
973
+ `./lib/tools/fs/drive.ts`, `remote.ts` and `remote-protocol.ts`, and
974
+ `./lib/tools/skills/skill-state.ts`, `credential-slots.ts`,
975
+ `manifest-parse.ts`, `overlay-crud.ts` and `scope-key.ts`. Import
976
+ `@qvac/harness/drive`, `@qvac/harness/skill-state` (`SKILL_STATE`,
977
+ `isDeviceSharedCredentialKey`), `@qvac/harness/skill-manifest`
978
+ (`credentialSlots`, `readSkillSetup`), and the `ManagedSkill` and
979
+ `SkillFileContent` types from `@qvac/harness`. (#636)
980
+
821
981
  - **Breaking:** `harnessLogEnabled` from `./lib/log.ts`: use
822
982
  `HarnessLog.enabled(level)` or `HarnessLog.level()`. (#471, #506, #532)
823
983
  - **Breaking:** `./lib/log.ts` exports the `HarnessLog` class in place of the
@@ -849,8 +1009,8 @@ breaking change is listed under Changed and Removed.
849
1009
  (with `skillsDir` for `skill`), `McpPlugin` and `WebSearchPlugin`.
850
1010
  `credentialSlots` comes from `@qvac/harness/skill-manifest`,
851
1011
  `ensureBundledSkillsDir` is `Tools.bundledSkillsDir()`, and
852
- `isDeviceSharedCredentialKey` has no replacement (plugins declare
853
- `SkillReadiness.deviceSharedKeys`). Only `./lib/tools/exec.ts`,
1012
+ `isDeviceSharedCredentialKey` comes from `@qvac/harness/skill-state` (a
1013
+ plugin declares its own in `SkillReadiness.deviceSharedKeys`). Only `./lib/tools/exec.ts`,
854
1014
  `./lib/tools/toolsets.ts`, `./lib/tools/skills/index.ts`, `mention.ts` and
855
1015
  `mention-name.ts` keep their keys. (#273, #283)
856
1016
  - **Breaking:** `./plugins` no longer exports the contract types: import
@@ -881,6 +1041,11 @@ breaking change is listed under Changed and Removed.
881
1041
 
882
1042
  ### Fixed
883
1043
 
1044
+ - A message keeps the wire layout 0.8.13 shipped: `sentAt` is its fourth
1045
+ field again, ahead of `toolCalls`, `toolCallId`, `name`, `id` and `context`.
1046
+ Up to rc.6 a 1.0 harness could not decode a message from a 0.8.13 host that
1047
+ carried a send time. A host built against an earlier 1.0 rc must be rebuilt
1048
+ with this one, since those fields moved. (#623)
884
1049
  - The wrap-up round a run ends on keeps the tool block in the prompt and
885
1050
  forbids a call with `tool_choice: "none"`, instead of dropping the block.
886
1051
  Under `@qvac/sdk` 0.22 the dropped block rewrote the chat's one cache file,
package/README.md CHANGED
@@ -26,7 +26,7 @@
26
26
  </p>
27
27
 
28
28
  ```sh
29
- npm i @qvac/harness
29
+ npm i @qvac/harness @qvac/sdk
30
30
  ```
31
31
 
32
32
  ```ts
@@ -192,14 +192,18 @@ const delegate = Agent.delegateTool(harness, base, { targets })
192
192
 
193
193
  `plan: true` gives an agent `update_plan`, a checklist it sees after every round. A `goal` keeps the
194
194
  run going until every step is done or a budget runs out. A goal's `checks` are commands the result
195
- is judged by: the goal is met only once a call's `command` ran each of them and it exited 0, and
196
- until then each goal turn names the check and the output of its failed run. A goal sent with no
197
- checks, on a run with a tool that takes a `command`, asks the model to name its own before the
198
- first turn, so it is never met on the model's word alone. `planMode` refuses writes until the user approves the plan.
195
+ is judged by, and until they pass each goal turn names the check and the output of its failed run.
196
+ On a run with a tool that takes a `command`, the model must also name its own checks under a
197
+ `Checks:` line, and the goal is met only once every check, the host's and the model's, ran in a
198
+ call's `command` and exited 0, so host checks alone never meet it. `checksProve: true` says the host
199
+ checks prove the task: the goal is met on them alone and the model is not asked for its own. It has
200
+ no effect without checks. With no tool that takes a `command` and no host checks, the goal ends when the plan is done; host
201
+ checks need a tool that takes a `command`, or the goal runs to its budget.
202
+ `planMode` refuses writes until the user approves the plan.
199
203
 
200
204
  ```ts
201
205
  const agent = { id: 'lead', bio: 'You are the lead engineer.', plan: true }
202
- const goal = { objective: 'All tests pass', rounds: 30, checks: ['npm test'] }
206
+ const goal = { objective: 'All tests pass', rounds: 30, checks: ['npm test'], checksProve: true }
203
207
  harness.completion({ model, agent, messages, goal })
204
208
  ```
205
209
 
@@ -286,7 +290,15 @@ itself.
286
290
  | [`Weather`](plugins/weather/README.md) | Weather lookup |
287
291
  | [`ObsidianRoute`](plugins/obsidian/README.md) | `obsidian …` commands against a vault |
288
292
 
289
- Each plugin is imported from `@qvac/harness/plugins/<folder>`. Writing your own takes one object:
293
+ Each plugin is imported from `@qvac/harness/plugins/<folder>`. Its own dependencies are optional
294
+ peers of `@qvac/harness`: a host installs the ones for the plugins it imports
295
+ (`npm i @qvac/asr-ggml @qvac/tts-ggml bare-ffmpeg` for `Speech`), and importing a plugin without
296
+ them throws an error naming them. The shipped sidecar entry composes speech, image, music,
297
+ translation and python, so a host that spawns it installs all of their peers; a host that wants
298
+ fewer writes its own entry with only those plugins. See
299
+ [Plugin dependencies](docs/hosting.md#plugin-dependencies) for each plugin's peers.
300
+
301
+ Writing your own takes one object:
290
302
 
291
303
  ```ts
292
304
  import { Harness, PLUGIN_API_VERSION, type HarnessPlugin } from '@qvac/harness'
@@ -26,11 +26,11 @@ import { type HarnessSkillsOptions } from './lib/skills-host/index.ts';
26
26
  import type { CredentialStoreFn, CredentialStoreValue } from './lib/tools/skills/auth-resolver.ts';
27
27
  import type { CopyBaseResult, DeleteOverlayResult, ManagedSkill, SkillFileContent } from './lib/tools/skills/overlay-crud.ts';
28
28
  import { HarnessLog } from './lib/log.ts';
29
- import { type DriveOpFn, type GrantedDrive } from './lib/tools/fs/remote.ts';
29
+ import type { DriveOpFn, GrantedDrive } from './lib/tools/fs/remote-protocol.ts';
30
30
  import type { ResolvedSkillCatalogEntry } from './lib/tools/skills/catalog.ts';
31
31
  import type { SkillSettingEntry } from './lib/tools/skills/skill-settings.ts';
32
32
  export type * from './lib/contract/index.ts';
33
- export { CompletionEngine, type CompletionArgs, type CompletionEngineOptions, type CompletionRun, type ModelRoundEvent, type ModelRoundIo, type ModelRoundPort, type ModelRoundRequest, type ModelRoundResult } from './lib/capabilities/completion-engine/index.ts';
33
+ export { CompletionEngine, type CompletionArgs, type CompletionEngineOptions, type CompletionRun, type ModelRoundEvent, type ModelRoundIo, type ModelRoundPort, type ModelRoundRequest, type ModelRoundResult, ToolSets } from './lib/capabilities/completion-engine/index.ts';
34
34
  export declare const CONTEXT_OVERFLOW_MESSAGE: string;
35
35
  export { imageSettingsFrom } from './lib/helpers/image-settings.ts';
36
36
  export { skillInContext, unreadySkillState, type CompletionSkillEntry } from './lib/capabilities/skill-entry.ts';
@@ -293,7 +293,7 @@ export declare class Harness extends ReadyResource {
293
293
  knowledgeStatus(): Promise<KnowledgeStatus>;
294
294
  transcribe(context: TranscribeContext): Promise<string>;
295
295
  private _transcribe;
296
- detectLanguage(context: DetectLanguageContext): DetectedLanguage[];
296
+ detectLanguage(context: DetectLanguageContext): Promise<DetectedLanguage[]>;
297
297
  speak(context: SpeakContext): Promise<SpeakResult>;
298
298
  private _speak;
299
299
  speakStream(context: SpeakStreamContext): AsyncIterable<SpeakResult>;
package/dist-lib/index.js CHANGED
@@ -40,7 +40,7 @@ import { bareRuntime } from './lib/tools/exec/bare-runtime.js';
40
40
  import { runCommand } from './lib/tools/exec/runner.js';
41
41
  import { createLocalRoots } from './lib/tools/fs/local.js';
42
42
  import { createRemoteRoots } from './lib/tools/fs/remote.js';
43
- export { CompletionEngine } from './lib/capabilities/completion-engine/index.js';
43
+ export { CompletionEngine, ToolSets } from './lib/capabilities/completion-engine/index.js';
44
44
  export const CONTEXT_OVERFLOW_MESSAGE = HarnessError.CONTEXT_OVERFLOW_MESSAGE;
45
45
  export { imageSettingsFrom } from './lib/helpers/image-settings.js';
46
46
  export { skillInContext, unreadySkillState } from './lib/capabilities/skill-entry.js';
@@ -1,6 +1,7 @@
1
1
  import { reportUnnamedWrites } from '../loop.js';
2
2
  import { recordWholeRound, runRecoveredRound } from '../round.js';
3
3
  import { ModelRound } from '../model-round.js';
4
+ import { ToolSets } from '../tool-sets.js';
4
5
  import { AbortedError } from '../../../helpers/race-abort.js';
5
6
  import { HarnessLog } from '../../../log.js';
6
7
  const BOUNDARY_UNFLAGGED = "length stop without contextBoundary: the host's @qvac/inference patch lacks the contextBoundary hunk";
@@ -59,6 +60,7 @@ async function remoteRound({ port, kind, args, runId, emit }) {
59
60
  modelId: params.modelId,
60
61
  history: params.history,
61
62
  tools: params.tools,
63
+ toolSet: params.tools && ToolSets.hash(params.tools),
62
64
  generationParams: params.generationParams,
63
65
  responseFormat: params.responseFormat,
64
66
  toolDialect: params.toolDialect,
@@ -7,6 +7,7 @@ import { clipRawCall, recoverMarkupToolCalls, recoverPrintedSkillLoad, recoverSk
7
7
  import { unquoteArg } from '../../../helpers/model-args.js';
8
8
  import { Agent } from '../../../agent/index.js';
9
9
  import { loadedTools } from '../../sdk-tool.js';
10
+ import { FILE_DELIVERED_NUDGE, GOAL_CONTINUATION_NUDGE, TOOL_CONTINUATION_NUDGE } from '../../tool-turns.js';
10
11
  import { HarnessLog } from '../../../log.js';
11
12
  import { toolDialectFor } from '../../../models/model-catalog.js';
12
13
  import { loadedSkills } from '../session.js';
@@ -152,18 +153,45 @@ export function roundFold(args, session, context) {
152
153
  };
153
154
  }
154
155
  function roundGenerationParams(context, session, responseFormat) {
156
+ const params = planned(context, session.generationParams);
155
157
  const owesCall = context.narrated || (context.malformed && context.lastRound?.stopReason !== 'length');
156
158
  if (!owesCall ||
157
159
  !session.sdkTools?.length ||
158
160
  responseFormat ||
159
161
  loadedTools(context.history).size > 0) {
160
- return { generationParams: session.generationParams };
162
+ return { generationParams: params };
161
163
  }
162
164
  return {
163
- generationParams: { ...session.generationParams, reasoning_budget: 0, tool_choice: 'required' },
164
- unforced: { generationParams: session.generationParams }
165
+ generationParams: { ...params, reasoning_budget: 0, tool_choice: 'required' },
166
+ unforced: { generationParams: params }
165
167
  };
166
168
  }
169
+ function planned(context, params) {
170
+ if (params?.reasoning_rounds !== 'plan') {
171
+ return params;
172
+ }
173
+ return plans(context.history) ? params : { ...params, reasoning_budget: 0 };
174
+ }
175
+ const NUDGES = new Set([TOOL_CONTINUATION_NUDGE, FILE_DELIVERED_NUDGE, GOAL_CONTINUATION_NUDGE]);
176
+ const FAILED_RESULT = /"error"\s*:|"exitCode"\s*:\s*[1-9]/;
177
+ function plans(history) {
178
+ for (const entry of [...history].reverse()) {
179
+ if (!('role' in entry)) {
180
+ return true;
181
+ }
182
+ if (entry.role === 'assistant') {
183
+ return false;
184
+ }
185
+ const text = typeof entry.content === 'string' ? entry.content : null;
186
+ if (entry.role === 'user' && (text === null || !NUDGES.has(text))) {
187
+ return true;
188
+ }
189
+ if (entry.role === 'tool' && text !== null && FAILED_RESULT.test(text)) {
190
+ return true;
191
+ }
192
+ }
193
+ return true;
194
+ }
167
195
  function recoverToolCalls({ recovered, session, round }) {
168
196
  const markup = stripToolResponseBlocks(truncateAtControlToken(recovered.final.raw.fullText) || recovered.unproven || '');
169
197
  let calls = recovered.final.toolCalls?.length
@@ -307,6 +307,9 @@ function isGenerationParams(value) {
307
307
  return (isRecord(value) &&
308
308
  (value.reasoning_budget === undefined ||
309
309
  (Number.isInteger(value.reasoning_budget) && Number(value.reasoning_budget) >= -1)) &&
310
+ (value.reasoning_rounds === undefined ||
311
+ value.reasoning_rounds === 'every' ||
312
+ value.reasoning_rounds === 'plan') &&
310
313
  [
311
314
  'temp',
312
315
  'top_p',
@@ -31,3 +31,4 @@ export declare class CompletionEngine {
31
31
  export type { CompletionArgs } from './loop.ts';
32
32
  export type { CompletionRun, CompletionRuntime } from './driver.ts';
33
33
  export type { ModelRoundEvent, ModelRoundIo, ModelRoundPort, ModelRoundRequest, ModelRoundResult, ModelRoundServeOptions } from './model-round.ts';
34
+ export { ToolSets } from './tool-sets.ts';
@@ -44,3 +44,4 @@ export class CompletionEngine {
44
44
  return new CompletionEngine(sdk, opts).run(args);
45
45
  }
46
46
  }
47
+ export { ToolSets } from './tool-sets.js';
@@ -10,6 +10,7 @@ export interface ModelRoundRequest {
10
10
  modelId: string;
11
11
  history: Message[];
12
12
  tools?: SdkTool[] | undefined;
13
+ toolSet?: string | undefined;
13
14
  generationParams?: Partial<LlmGenerationParams> | undefined;
14
15
  responseFormat?: ResponseFormat | undefined;
15
16
  toolDialect?: ToolDialect | undefined;
@@ -698,8 +698,11 @@ function inferenceParams({ args, modelId, history, cacheable }) {
698
698
  });
699
699
  }
700
700
  function generationParams(args) {
701
- const host = args.generationParams ? detachJson(args.generationParams) : undefined;
702
- return args.tools?.length ? { parallel_tool_calls: true, ...host } : host;
701
+ const { reasoning_rounds: _rounds, ...host } = args.generationParams
702
+ ? detachJson(args.generationParams)
703
+ : {};
704
+ const sent = args.generationParams ? host : undefined;
705
+ return args.tools?.length ? { parallel_tool_calls: true, ...sent } : sent;
703
706
  }
704
707
  function inferenceCall({ args, candidate, modelId, params, cacheKey }) {
705
708
  return {
@@ -0,0 +1,24 @@
1
+ import type { Tool as SdkTool } from '@qvac/sdk';
2
+ export declare class ToolSets {
3
+ sets: Map<string, {
4
+ type: "function";
5
+ name: string;
6
+ description: string;
7
+ deferLoading?: boolean | undefined;
8
+ group?: string | undefined;
9
+ parameters: {
10
+ [x: string]: unknown;
11
+ type: "object";
12
+ properties: Record<string, {
13
+ [x: string]: unknown;
14
+ type?: "array" | "boolean" | "integer" | "null" | "number" | "object" | "string" | ("array" | "boolean" | "integer" | "null" | "number" | "object" | "string")[] | undefined;
15
+ description?: string | undefined;
16
+ enum?: (string | number | boolean | null)[] | undefined;
17
+ }>;
18
+ required?: string[] | undefined;
19
+ };
20
+ }[]>;
21
+ add(tools: SdkTool[]): string;
22
+ resolve(hash: string): SdkTool[] | undefined;
23
+ static hash(tools: readonly SdkTool[]): string;
24
+ }
@@ -0,0 +1,15 @@
1
+ import crypto from 'crypto';
2
+ export class ToolSets {
3
+ sets = new Map();
4
+ add(tools) {
5
+ const hash = ToolSets.hash(tools);
6
+ this.sets.set(hash, tools);
7
+ return hash;
8
+ }
9
+ resolve(hash) {
10
+ return this.sets.get(hash);
11
+ }
12
+ static hash(tools) {
13
+ return crypto.createHash('sha256').update(JSON.stringify(tools)).digest('hex');
14
+ }
15
+ }
@@ -8,4 +8,5 @@ export interface DetectLanguageContext {
8
8
  topK?: number;
9
9
  }
10
10
  export declare const UNDETERMINED = "und";
11
- export declare function detectLanguage({ text, topK }: DetectLanguageContext): DetectedLanguage[];
11
+ export declare function detectLanguage({ text, topK }: DetectLanguageContext): Promise<DetectedLanguage[]>;
12
+ export declare function languageName(code: string): Promise<string | null>;
@@ -1,6 +1,14 @@
1
- import { detectMultiple, detectOne } from '@qvac/langdetect-text';
1
+ import { requirePeers } from '../helpers/require-peers.js';
2
+ import { retryMemo } from '../helpers/retry-memo.js';
2
3
  export const UNDETERMINED = 'und';
3
- export function detectLanguage({ text, topK }) {
4
+ const langdetect = retryMemo(() => {
5
+ requirePeers('@qvac/harness language detection', {
6
+ '@qvac/langdetect-text': () => import.meta.resolve('@qvac/langdetect-text')
7
+ });
8
+ return import('@qvac/langdetect-text');
9
+ });
10
+ export async function detectLanguage({ text, topK }) {
11
+ const { detectMultiple, detectOne } = await langdetect();
4
12
  if (!topK || topK === 1) {
5
13
  const { code, language } = detectOne(text);
6
14
  return [{ code, language }];
@@ -11,3 +19,7 @@ export function detectLanguage({ text, topK }) {
11
19
  probability
12
20
  }));
13
21
  }
22
+ export async function languageName(code) {
23
+ const { getLangName } = await langdetect();
24
+ return getLangName(code);
25
+ }
@@ -5,6 +5,7 @@ import type { CustomModelEntry } from './models/model-catalog.ts';
5
5
  import { type ModelSourcePreview, type PreviewModelSourceContext } from './capabilities/preview-model-source.ts';
6
6
  import type { CapabilityInfo, CompletionContext, CredentialEntry, DetectedLanguage, DetectLanguageContext, DownloadContext, EmbedContext, HarnessContract, HarnessDiagnostics, HarnessEvent, HarnessInfo, HostContext, InfraModel, InvokeContext, ListModelsOptions, ModelInfo, ResolvedSkillCatalogEntry, SkillsOptions, SkillWriteResult, SpeakContext, SpeakResult, SpeakStreamContext, ToolCatalogEntry, TranscribeContext, LoadModelContext, LoadModelResult, MemoryUsage, UnloadModelContext, UnloadModelResult, WarmModelContext, DownloadsAllowedOptions } from './contract-types.ts';
7
7
  import type { KnowledgeArtifact, KnowledgeHit, KnowledgeQuery, KnowledgeRemoved, KnowledgeStatus, KnowledgeUpsertResult } from './contract/knowledge.ts';
8
+ import type { ModelRoundIo, ModelRoundRequest, ModelRoundResult } from './capabilities/completion-engine/index.ts';
8
9
  import { type EmbedDevice } from './models/embed-config.ts';
9
10
  import type { DeleteModelSummary } from './models/model-delete.ts';
10
11
  import type { CopyBaseResult, DeleteOverlayResult, ManagedSkill, SkillFileContent } from './tools/skills/overlay-crud.ts';
@@ -32,6 +33,7 @@ export declare class RemoteHarness extends EventEmitter implements HarnessContra
32
33
  private _open;
33
34
  completion(context: HostContext<CompletionContext | import('./contract-types.ts').ResumeCompletionContext>): AsyncIterable<HarnessEvent>;
34
35
  private _hop;
36
+ serveModelRound(request: ModelRoundRequest, io: HostContext<ModelRoundIo>): Promise<ModelRoundResult>;
35
37
  invoke(context: HostContext<InvokeContext>): AsyncIterable<HarnessEvent>;
36
38
  private _run;
37
39
  download(context: HostContext<DownloadContext>): AsyncIterable<HarnessEvent>;