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

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 (85) hide show
  1. package/CHANGELOG.md +157 -10
  2. package/README.md +19 -7
  3. package/dist-lib/index.d.ts +2 -2
  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-types.d.ts +4 -0
  19. package/dist-lib/lib/helpers/require-peers.d.ts +3 -0
  20. package/dist-lib/lib/helpers/require-peers.js +23 -0
  21. package/dist-lib/lib/models/llm-presets.d.ts +1 -0
  22. package/dist-lib/lib/models/model-catalog.js +1 -1
  23. package/dist-lib/lib/models/opencl-cache.js +2 -2
  24. package/dist-lib/lib/plugins/registry.d.ts +2 -0
  25. package/dist-lib/lib/plugins/registry.js +4 -0
  26. package/dist-lib/lib/round-host.d.ts +12 -0
  27. package/dist-lib/lib/round-host.js +57 -0
  28. package/dist-lib/lib/round-port.d.ts +24 -0
  29. package/dist-lib/lib/round-port.js +81 -0
  30. package/dist-lib/lib/sdk-loader.d.ts +1 -1
  31. package/dist-lib/lib/sdk-loader.js +30 -6
  32. package/dist-lib/lib/sdk-storage.d.ts +1 -0
  33. package/dist-lib/lib/sdk-storage.js +18 -2
  34. package/dist-lib/lib/serve.js +61 -1
  35. package/dist-lib/lib/sidecar/index.d.ts +10 -0
  36. package/dist-lib/lib/sidecar/index.js +35 -3
  37. package/dist-lib/lib/sidecar/user-plugins.d.ts +1 -0
  38. package/dist-lib/lib/sidecar/user-plugins.js +1 -1
  39. package/dist-lib/lib/tools/files/grep.js +113 -15
  40. package/dist-lib/lib/tools/fs/edit-match.js +75 -7
  41. package/dist-lib/lib/tools/fs/search.d.ts +1 -1
  42. package/dist-lib/lib/tools/fs/search.js +2 -1
  43. package/dist-lib/lib/tools/index.d.ts +2 -1
  44. package/dist-lib/lib/tools/index.js +2 -2
  45. package/dist-lib/lib/tools/skills/skill-state-constants.d.ts +1 -0
  46. package/dist-lib/lib/tools/skills/skill-state-constants.js +4 -0
  47. package/dist-lib/lib/wire.d.ts +13 -0
  48. package/dist-lib/lib/wire.js +44 -1
  49. package/dist-lib/plugins/coding/read-only.d.ts +1 -0
  50. package/dist-lib/plugins/coding/read-only.js +264 -0
  51. package/dist-lib/plugins/coding/session.d.ts +3 -1
  52. package/dist-lib/plugins/coding/session.js +19 -2
  53. package/dist-lib/plugins/egress-proxy/index.d.ts +2 -2
  54. package/dist-lib/plugins/egress-proxy/index.js +5 -3
  55. package/dist-lib/plugins/image/index.js +7 -2
  56. package/dist-lib/plugins/language-hint/index.js +4 -1
  57. package/dist-lib/plugins/music/index.js +6 -2
  58. package/dist-lib/plugins/python/index.js +1 -0
  59. package/dist-lib/plugins/python/loader.d.ts +1 -0
  60. package/dist-lib/plugins/python/loader.js +8 -0
  61. package/dist-lib/plugins/quickjs/index.js +4 -0
  62. package/dist-lib/plugins/quickjs/runtime.js +8 -3
  63. package/dist-lib/plugins/run-report/index.js +6 -2
  64. package/dist-lib/plugins/run-report/layout.js +1 -1
  65. package/dist-lib/plugins/sandbox-vm/index.js +3 -0
  66. package/dist-lib/plugins/sandbox-windows/prebuilds/win32-arm64/qvac-sandbox.exe +0 -0
  67. package/dist-lib/plugins/sandbox-windows/prebuilds/win32-x64/qvac-sandbox.exe +0 -0
  68. package/dist-lib/plugins/speech/audio-resample.js +2 -1
  69. package/dist-lib/plugins/speech/index.d.ts +1 -0
  70. package/dist-lib/plugins/speech/index.js +8 -1
  71. package/dist-lib/plugins/speech/speech-runtime.js +3 -3
  72. package/dist-lib/plugins/translation/index.d.ts +1 -1
  73. package/dist-lib/plugins/translation/index.js +7 -3
  74. package/dist-lib/plugins/translation/translate.d.ts +2 -2
  75. package/dist-lib/plugins/translation/translate.js +7 -8
  76. package/dist-lib/plugins/walkie-talkie/index.d.ts +2 -2
  77. package/dist-lib/plugins/walkie-talkie/index.js +13 -5
  78. package/dist-lib/plugins/walkie-talkie/wire.d.ts +5 -0
  79. package/dist-lib/plugins/walkie-talkie/wire.js +6 -5
  80. package/dist-lib/schema/harness.js +13 -4
  81. package/dist-lib/spec/hrpc/messages.js +205 -151
  82. package/dist-lib/spec/hyperschema/index.js +205 -151
  83. package/dist-lib/spec/hyperschema/schema.json +125 -89
  84. package/dist-lib/spec/hyperschema/types.d.ts +4 -4
  85. package/package.json +149 -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,107 @@ 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
+ - Every host that runs python, on Bare or Node, recopies
434
+ `patches/pyodide@314.0.2.patch` into its `patchedDependencies`. Guest Python
435
+ sees: `ctypes` calls to `emscripten_run_script*` do nothing and return 0, a
436
+ side module with `EM_JS` or `EM_ASM` is refused with `OSError`, `pyodide_js`
437
+ holds only the allowlisted members, and `loadPackage` takes lockfile names
438
+ only. A worker that boots an unpatched pyodide logs one line per process.
439
+ (#567, #586)
440
+ - **Breaking:** a plugin's dependencies are optional peer dependencies of
441
+ `@qvac/harness`, so installing the harness no longer installs any plugin's
442
+ native addons or libraries. A host installs the peers of the plugins it
443
+ imports; importing a plugin without them throws one error that names the
444
+ plugin and the packages. The shipped sidecar entry composes speech, image,
445
+ music, translation and python, so a host that spawns it installs their
446
+ peers; a host that wants fewer writes its own entry. See
447
+ [Plugin dependencies](docs/hosting.md#plugin-dependencies). (#626)
448
+
449
+ | Plugin | Peers |
450
+ | --------------- | ---------------------------------------------------------------------- |
451
+ | `speech` | `@qvac/asr-ggml`, `@qvac/tts-ggml`, `bare-ffmpeg` |
452
+ | `image` | `@qvac/diffusion-cpp`, `bare-image-resample`, `bare-media` |
453
+ | `music` | `@qvac/audiogen-ggml` |
454
+ | `translation` | `@qvac/translation-nmtcpp` |
455
+ | `python` | `pyodide` |
456
+ | `quickjs` | `@jitl/quickjs-singlefile-mjs-release-sync`, `quickjs-emscripten-core` |
457
+ | `egress-proxy` | `bare-net` |
458
+ | `run-report` | `elkjs` |
459
+ | `walkie-talkie` | `hyperswarm`, `hypercore-crypto` |
460
+ | `sandbox-vm` | `barevisor` |
461
+
462
+ ```sh
463
+ # before: the harness installed every plugin's dependencies
464
+ npm i @qvac/harness
465
+ # after: a host spawning the shipped sidecar entry
466
+ npm i @qvac/harness @qvac/asr-ggml @qvac/tts-ggml bare-ffmpeg @qvac/diffusion-cpp \
467
+ bare-image-resample bare-media @qvac/audiogen-ggml @qvac/translation-nmtcpp pyodide
468
+ ```
469
+
470
+ - **Breaking:** `@qvac/sdk` and the model addons are optional peer
471
+ dependencies of `@qvac/harness`, so installing the harness installs no model
472
+ engine. Each belongs to the capability that loads it: on Bare, completion
473
+ needs `@qvac/llm-llamacpp` and `@qvac/langdetect-text`, embeddings and the
474
+ `knowledge` plugin need `@qvac/embed-llamacpp`; on Node every capability
475
+ needs `@qvac/sdk`, which brings its own addons. A missing one throws where
476
+ the capability loads, naming the capability and the packages; the harness
477
+ entry imports without any of them. Speech and music add `@qvac/decoder-audio`
478
+ to their peers, and translation and `language-hint` add
479
+ `@qvac/langdetect-text`. The core and the plugins import the engine's
480
+ plugins and model catalog from `@qvac/inference`, a dependency, not through
481
+ `@qvac/sdk`. See [Model dependencies](docs/hosting.md#model-dependencies).
482
+ (#630)
483
+
484
+ ```sh
485
+ # a desktop host on Node
486
+ npm i @qvac/harness @qvac/sdk @qvac/llm-llamacpp @qvac/embed-llamacpp @qvac/langdetect-text
487
+ # a phone app running completion on a Bare thread
488
+ npm i @qvac/harness @qvac/llm-llamacpp @qvac/langdetect-text
489
+ ```
490
+
491
+ - **Breaking:** `harness.detectLanguage` returns a promise, since it loads the
492
+ detector on first use. (#630)
493
+
494
+ ```js
495
+ // before
496
+ const [best] = harness.detectLanguage({ text })
497
+ // after
498
+ const [best] = await harness.detectLanguage({ text })
499
+ ```
500
+
501
+ - `bare-worker` is pinned to 4.5.0 and `bare-module` is a dependency at
502
+ `~7.1.0`, so a host's install resolves a `bare-module` that runs on Bare
503
+ 1.34: `bare-worker` 4.5.3 asks for `bare-module` 7.4, and npm gives it 7.5,
504
+ which needs Bare 1.35. (#630)
505
+ - The `sandbox-vm` plugin (`VmShell`, `./plugins/sandbox-vm`) is back, with
506
+ `barevisor` an optional peer instead of a dependency every host installed.
507
+ (#626)
379
508
  - Every skill-gated tool (`docx`, `pptx`, `xlsx`, `pdf`, `generate_image`, …),
380
509
  `http_request` and every MCP server's tools are deferred behind
381
510
  `tool_search`. The sent tool set is fixed per chat, so a skill load no longer
@@ -383,6 +512,18 @@ breaking change is listed under Changed and Removed.
383
512
  direct call to a deferred tool loads it and runs in the same round instead of
384
513
  being refused. An MCP server sets `defer: false` to send its schemas whole.
385
514
  `skill-eval` gains `--defer`. (#566)
515
+ - **Breaking:** `engines.node` is `^22.21.0 || >=24.9.0`. A Node host outside
516
+ that range crashed with `SIGSEGV` in `spawnHarness`; npm now warns at install.
517
+ See [On Node](docs/hosting.md#on-node). (#553)
518
+ - **Breaking** for guest Python that imports from `js`: the `js` module holds
519
+ only the names in `JS_GLOBALS`, and the python worker seals the `Function`,
520
+ `AsyncFunction` and generator constructors after boot. `pyodide_js` holds
521
+ only what pyodide's Python and micropip import, with no `FS` or
522
+ `mountNodeFS`, and the pyodide patch turns the `emscripten_run_script*` and
523
+ `EM_JS`/`EM_ASM` routes into no-ops or refusals. `pyodide.code.run_js` raises
524
+ in the guest. See
525
+ [the decision record](docs/decisions/2026-10-20-guest-python-sees-only-allowlisted-js-globals.md).
526
+ (#554, #567)
386
527
  - **Breaking** for a TypeScript host that reads it: `inference-sent` no longer
387
528
  carries `messages`. `@qvac/inference` 0.22 does not report the slice it
388
529
  pushed, so the field was always empty; a prompt inspector reads the payload
@@ -457,8 +598,9 @@ breaking change is listed under Changed and Removed.
457
598
  - A host that runs python on Node recopies `patches/pyodide@314.0.2.patch`
458
599
  into its `patchedDependencies`. Pyodide now loads `child-process-stub.cjs`
459
600
  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)
601
+ host needs nothing: the old patch already gave it the stub. #554 later closed
602
+ the `js` route to the host realm, and #567 changed the patch again for every
603
+ host. (#535)
462
604
  - A call whose result is the same as its last result in the run is not
463
605
  progress: its result carries `wording.toolUnchanged`, and 3 such calls send
464
606
  the run to the wrap-up with the `exhausted` outcome. A round whose sent
@@ -849,8 +991,8 @@ breaking change is listed under Changed and Removed.
849
991
  (with `skillsDir` for `skill`), `McpPlugin` and `WebSearchPlugin`.
850
992
  `credentialSlots` comes from `@qvac/harness/skill-manifest`,
851
993
  `ensureBundledSkillsDir` is `Tools.bundledSkillsDir()`, and
852
- `isDeviceSharedCredentialKey` has no replacement (plugins declare
853
- `SkillReadiness.deviceSharedKeys`). Only `./lib/tools/exec.ts`,
994
+ `isDeviceSharedCredentialKey` comes from `@qvac/harness/skill-state` (a
995
+ plugin declares its own in `SkillReadiness.deviceSharedKeys`). Only `./lib/tools/exec.ts`,
854
996
  `./lib/tools/toolsets.ts`, `./lib/tools/skills/index.ts`, `mention.ts` and
855
997
  `mention-name.ts` keep their keys. (#273, #283)
856
998
  - **Breaking:** `./plugins` no longer exports the contract types: import
@@ -881,6 +1023,11 @@ breaking change is listed under Changed and Removed.
881
1023
 
882
1024
  ### Fixed
883
1025
 
1026
+ - A message keeps the wire layout 0.8.13 shipped: `sentAt` is its fourth
1027
+ field again, ahead of `toolCalls`, `toolCallId`, `name`, `id` and `context`.
1028
+ Up to rc.6 a 1.0 harness could not decode a message from a 0.8.13 host that
1029
+ carried a send time. A host built against an earlier 1.0 rc must be rebuilt
1030
+ with this one, since those fields moved. (#623)
884
1031
  - The wrap-up round a run ends on keeps the tool block in the prompt and
885
1032
  forbids a call with `tool_choice: "none"`, instead of dropping the block.
886
1033
  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'
@@ -30,7 +30,7 @@ import { type DriveOpFn, type GrantedDrive } from './lib/tools/fs/remote.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>;