@qvac/harness 0.3.3 → 0.5.0

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 (301) hide show
  1. package/CHANGELOG.md +700 -126
  2. package/README.md +156 -0
  3. package/dist/harness.bundle +71 -103
  4. package/dist/prebuilds-manifest.json +0 -8
  5. package/dist-lib/index.d.ts +42 -40
  6. package/dist-lib/index.js +307 -117
  7. package/dist-lib/lib/audio-transcode-bare.d.ts +2 -2
  8. package/dist-lib/lib/audio-transcode-bare.js +28 -18
  9. package/dist-lib/lib/audio-transcode-node.d.ts +2 -2
  10. package/dist-lib/lib/capabilities/audio-resample.d.ts +7 -6
  11. package/dist-lib/lib/capabilities/audio-resample.js +30 -18
  12. package/dist-lib/lib/capabilities/completion.d.ts +20 -19
  13. package/dist-lib/lib/capabilities/completion.js +194 -135
  14. package/dist-lib/lib/capabilities/download.d.ts +6 -6
  15. package/dist-lib/lib/capabilities/download.js +15 -8
  16. package/dist-lib/lib/capabilities/embed.js +2 -1
  17. package/dist-lib/lib/capabilities/enhance.d.ts +6 -1
  18. package/dist-lib/lib/capabilities/enhance.js +7 -4
  19. package/dist-lib/lib/capabilities/invoke.js +7 -4
  20. package/dist-lib/lib/capabilities/kv-cache.js +2 -1
  21. package/dist-lib/lib/capabilities/preview-model-source.d.ts +69 -0
  22. package/dist-lib/lib/capabilities/preview-model-source.js +439 -0
  23. package/dist-lib/lib/capabilities/speech-text.js +5 -4
  24. package/dist-lib/lib/capabilities/tool-selection.js +10 -9
  25. package/dist-lib/lib/capabilities/tool-turns.js +30 -16
  26. package/dist-lib/lib/capabilities/usage-breakdown.js +2 -1
  27. package/dist-lib/lib/capabilities/voice.d.ts +5 -1
  28. package/dist-lib/lib/capabilities/voice.js +22 -12
  29. package/dist-lib/lib/connect.d.ts +15 -37
  30. package/dist-lib/lib/connect.js +161 -112
  31. package/dist-lib/lib/context-window.js +25 -21
  32. package/dist-lib/lib/contract-types.d.ts +26 -20
  33. package/dist-lib/lib/diagram-repair.d.ts +4 -4
  34. package/dist-lib/lib/diagram-repair.js +6 -3
  35. package/dist-lib/lib/docx/index.d.ts +3 -2
  36. package/dist-lib/lib/{error-fields.d.ts → guards.d.ts} +1 -0
  37. package/dist-lib/lib/{error-fields.js → guards.js} +3 -0
  38. package/dist-lib/lib/hardware/capability-probe.js +20 -10
  39. package/dist-lib/lib/hardware/gpu-classify.js +6 -3
  40. package/dist-lib/lib/hardware/gpu-probe-addon.js +8 -4
  41. package/dist-lib/lib/hardware/gpu-probe.js +4 -2
  42. package/dist-lib/lib/hardware/gpu-stats.native.cjs +8 -9
  43. package/dist-lib/lib/hardware/parsers.js +8 -4
  44. package/dist-lib/lib/helpers/buffer-burst.js +4 -2
  45. package/dist-lib/lib/helpers/control-tokens.js +4 -2
  46. package/dist-lib/lib/helpers/join-guard.d.ts +2 -2
  47. package/dist-lib/lib/helpers/join-guard.js +4 -2
  48. package/dist-lib/lib/helpers/load-stall.js +4 -2
  49. package/dist-lib/lib/helpers/markup-stream-filter.d.ts +2 -2
  50. package/dist-lib/lib/helpers/markup-stream-filter.js +6 -3
  51. package/dist-lib/lib/helpers/race-abort.js +2 -1
  52. package/dist-lib/lib/helpers/race-timeout.d.ts +5 -0
  53. package/dist-lib/lib/helpers/race-timeout.js +14 -0
  54. package/dist-lib/lib/helpers/run-outcome.d.ts +6 -8
  55. package/dist-lib/lib/helpers/run-outcome.js +36 -20
  56. package/dist-lib/lib/helpers/spawn-path.js +6 -3
  57. package/dist-lib/lib/helpers/text-coalescer.js +6 -3
  58. package/dist-lib/lib/helpers/thinking.js +38 -45
  59. package/dist-lib/lib/helpers/tool-call-markup.d.ts +9 -7
  60. package/dist-lib/lib/helpers/tool-call-markup.js +36 -20
  61. package/dist-lib/lib/helpers/tool-intent.d.ts +3 -2
  62. package/dist-lib/lib/helpers/tool-intent.js +4 -2
  63. package/dist-lib/lib/helpers/tool-label.js +18 -9
  64. package/dist-lib/lib/hooks/built-in/arg-repair.js +23 -13
  65. package/dist-lib/lib/hooks/built-in/egress.js +2 -1
  66. package/dist-lib/lib/hooks/built-in/skill-catalog.js +2 -1
  67. package/dist-lib/lib/hooks/pipeline.d.ts +5 -4
  68. package/dist-lib/lib/hooks/pipeline.js +6 -3
  69. package/dist-lib/lib/hooks/run.js +12 -8
  70. package/dist-lib/lib/model-download-progress.js +10 -8
  71. package/dist-lib/lib/models/context.d.ts +1 -1
  72. package/dist-lib/lib/models/context.js +5 -1
  73. package/dist-lib/lib/models/custom-model-cache.d.ts +13 -0
  74. package/dist-lib/lib/models/custom-model-cache.js +70 -0
  75. package/dist-lib/lib/models/gguf-header.d.ts +31 -0
  76. package/dist-lib/lib/models/gguf-header.js +230 -0
  77. package/dist-lib/lib/models/idle-unload.d.ts +14 -0
  78. package/dist-lib/lib/models/idle-unload.js +51 -0
  79. package/dist-lib/lib/models/kv-cache.d.ts +3 -2
  80. package/dist-lib/lib/models/kv-cache.js +4 -3
  81. package/dist-lib/lib/models/llm-presets.d.ts +2 -2
  82. package/dist-lib/lib/models/llm-presets.js +4 -2
  83. package/dist-lib/lib/models/model-catalog-constants.js +3 -2
  84. package/dist-lib/lib/models/model-catalog.d.ts +19 -21
  85. package/dist-lib/lib/models/model-catalog.js +66 -33
  86. package/dist-lib/lib/models/model-delete.d.ts +4 -1
  87. package/dist-lib/lib/models/model-delete.js +30 -15
  88. package/dist-lib/lib/models/model-handle.js +2 -1
  89. package/dist-lib/lib/models/model-list.d.ts +14 -3
  90. package/dist-lib/lib/models/model-list.js +33 -6
  91. package/dist-lib/lib/models/model-pool.d.ts +44 -10
  92. package/dist-lib/lib/models/model-pool.js +47 -42
  93. package/dist-lib/lib/models/model-source.js +11 -6
  94. package/dist-lib/lib/models/music-catalog.d.ts +2 -2
  95. package/dist-lib/lib/models/nmt-catalog.d.ts +4 -3
  96. package/dist-lib/lib/models/nmt-catalog.js +10 -5
  97. package/dist-lib/lib/models/opencl-cache.d.ts +6 -1
  98. package/dist-lib/lib/models/opencl-cache.js +5 -3
  99. package/dist-lib/lib/models/sdk-faults.d.ts +11 -8
  100. package/dist-lib/lib/models/sdk-faults.js +9 -6
  101. package/dist-lib/lib/models/shards.d.ts +11 -0
  102. package/dist-lib/lib/models/shards.js +15 -0
  103. package/dist-lib/lib/models/tool-dialect.js +10 -5
  104. package/dist-lib/lib/no-redirect-fetch-bare.d.ts +3 -3
  105. package/dist-lib/lib/no-redirect-fetch-bare.js +1 -1
  106. package/dist-lib/lib/no-redirect-fetch-impl.js +6 -3
  107. package/dist-lib/lib/no-redirect-fetch-node.d.ts +1 -1
  108. package/dist-lib/lib/no-redirect-fetch-node.js +9 -9
  109. package/dist-lib/lib/office/index.d.ts +3 -2
  110. package/dist-lib/lib/office/python.d.ts +3 -2
  111. package/dist-lib/lib/office/python.js +2 -1
  112. package/dist-lib/lib/prompt.d.ts +5 -4
  113. package/dist-lib/lib/prompt.js +8 -4
  114. package/dist-lib/lib/queue.js +10 -5
  115. package/dist-lib/lib/resolution-detector.js +21 -11
  116. package/dist-lib/lib/rpc-session.js +2 -1
  117. package/dist-lib/lib/sdk-loader.js +2 -1
  118. package/dist-lib/lib/sdk-storage.js +4 -2
  119. package/dist-lib/lib/serve.js +128 -68
  120. package/dist-lib/lib/spawn.js +7 -4
  121. package/dist-lib/lib/tmp-path.d.ts +7 -6
  122. package/dist-lib/lib/tool-call-display.d.ts +2 -2
  123. package/dist-lib/lib/tools/create-documents.js +18 -10
  124. package/dist-lib/lib/tools/edit-documents.js +23 -13
  125. package/dist-lib/lib/tools/edit-image.d.ts +2 -2
  126. package/dist-lib/lib/tools/edit-image.js +60 -36
  127. package/dist-lib/lib/tools/exec/adapters/adapter.d.ts +10 -10
  128. package/dist-lib/lib/tools/exec/adapters/python/attachments.d.ts +17 -11
  129. package/dist-lib/lib/tools/exec/adapters/python/attachments.js +53 -40
  130. package/dist-lib/lib/tools/exec/adapters/python/create-effect.d.ts +2 -2
  131. package/dist-lib/lib/tools/exec/adapters/python/create-effect.js +60 -32
  132. package/dist-lib/lib/tools/exec/adapters/python/guarded-fetch.d.ts +33 -22
  133. package/dist-lib/lib/tools/exec/adapters/python/guarded-fetch.js +58 -29
  134. package/dist-lib/lib/tools/exec/adapters/python/interrupt-timer.d.ts +2 -2
  135. package/dist-lib/lib/tools/exec/adapters/python/loader.js +23 -12
  136. package/dist-lib/lib/tools/exec/adapters/python/memfs.d.ts +13 -11
  137. package/dist-lib/lib/tools/exec/adapters/python/memfs.js +10 -5
  138. package/dist-lib/lib/tools/exec/adapters/python/net-shim.js +3 -1
  139. package/dist-lib/lib/tools/exec/adapters/python/output-policy.d.ts +6 -4
  140. package/dist-lib/lib/tools/exec/adapters/python/output-policy.js +20 -10
  141. package/dist-lib/lib/tools/exec/adapters/python/pyodide.d.ts +2 -2
  142. package/dist-lib/lib/tools/exec/adapters/python/pyodide.js +14 -7
  143. package/dist-lib/lib/tools/exec/adapters/python/python-adapter.d.ts +41 -34
  144. package/dist-lib/lib/tools/exec/adapters/python/python-adapter.js +316 -166
  145. package/dist-lib/lib/tools/exec/adapters/python/run-session.d.ts +9 -8
  146. package/dist-lib/lib/tools/exec/adapters/python/run-session.js +56 -28
  147. package/dist-lib/lib/tools/exec/adapters/python/wheels.d.ts +8 -10
  148. package/dist-lib/lib/tools/exec/adapters/python/wheels.js +22 -11
  149. package/dist-lib/lib/tools/exec/adapters/python/worker/client.d.ts +3 -2
  150. package/dist-lib/lib/tools/exec/adapters/python/worker/client.js +41 -26
  151. package/dist-lib/lib/tools/exec/adapters/python/worker/entry.js +27 -18
  152. package/dist-lib/lib/tools/exec/adapters/python/worker/protocol.d.ts +2 -2
  153. package/dist-lib/lib/tools/exec/adapters/python/worker/protocol.js +14 -13
  154. package/dist-lib/lib/tools/exec/adapters/python/worker/spawn-node.d.ts +4 -4
  155. package/dist-lib/lib/tools/exec/adapters/python/worker/spawn-node.js +10 -5
  156. package/dist-lib/lib/tools/exec/adapters/shell/shell-adapter.d.ts +4 -4
  157. package/dist-lib/lib/tools/exec/adapters/shell/shell-adapter.js +2 -1
  158. package/dist-lib/lib/tools/exec/obsidian/cli-process.d.ts +6 -1
  159. package/dist-lib/lib/tools/exec/obsidian/cli-process.js +8 -5
  160. package/dist-lib/lib/tools/exec/obsidian/cli.d.ts +6 -6
  161. package/dist-lib/lib/tools/exec/obsidian/cli.js +4 -4
  162. package/dist-lib/lib/tools/exec/obsidian/command.d.ts +3 -2
  163. package/dist-lib/lib/tools/exec/obsidian/command.js +6 -3
  164. package/dist-lib/lib/tools/exec/obsidian/output.js +2 -1
  165. package/dist-lib/lib/tools/exec/obsidian/route.d.ts +4 -6
  166. package/dist-lib/lib/tools/exec/obsidian/route.js +17 -11
  167. package/dist-lib/lib/tools/exec/obsidian/safe-path.js +2 -1
  168. package/dist-lib/lib/tools/exec/obsidian/vault-create.js +15 -7
  169. package/dist-lib/lib/tools/exec/obsidian/vault-paths.d.ts +2 -2
  170. package/dist-lib/lib/tools/exec/obsidian/vault-paths.js +20 -10
  171. package/dist-lib/lib/tools/exec/obsidian/vault-read.js +20 -13
  172. package/dist-lib/lib/tools/exec/obsidian/vault-write.js +24 -12
  173. package/dist-lib/lib/tools/exec/runner.d.ts +14 -14
  174. package/dist-lib/lib/tools/exec/runner.js +5 -3
  175. package/dist-lib/lib/tools/exec/scope.js +52 -28
  176. package/dist-lib/lib/tools/exec/shell-argv.js +31 -18
  177. package/dist-lib/lib/tools/exec/shell-guidance.d.ts +6 -1
  178. package/dist-lib/lib/tools/exec/shell-guidance.js +35 -20
  179. package/dist-lib/lib/tools/exec/video-tools.js +2 -2
  180. package/dist-lib/lib/tools/exec.d.ts +6 -8
  181. package/dist-lib/lib/tools/exec.js +113 -54
  182. package/dist-lib/lib/tools/file-glob.d.ts +4 -5
  183. package/dist-lib/lib/tools/file-glob.js +16 -11
  184. package/dist-lib/lib/tools/fs/glob.js +13 -18
  185. package/dist-lib/lib/tools/fs/remote-protocol.d.ts +10 -10
  186. package/dist-lib/lib/tools/fs/remote.d.ts +3 -2
  187. package/dist-lib/lib/tools/fs/remote.js +13 -7
  188. package/dist-lib/lib/tools/fs/scope.d.ts +8 -3
  189. package/dist-lib/lib/tools/fs/scope.js +20 -12
  190. package/dist-lib/lib/tools/fs/walk.js +6 -3
  191. package/dist-lib/lib/tools/fs/write.d.ts +3 -2
  192. package/dist-lib/lib/tools/generate-image.d.ts +11 -9
  193. package/dist-lib/lib/tools/generate-image.js +73 -37
  194. package/dist-lib/lib/tools/generate-music.d.ts +22 -11
  195. package/dist-lib/lib/tools/generate-music.js +79 -48
  196. package/dist-lib/lib/tools/grep.js +66 -41
  197. package/dist-lib/lib/tools/http-request/encode-fields.js +18 -9
  198. package/dist-lib/lib/tools/http-request/{utils.js → request.js} +20 -11
  199. package/dist-lib/lib/tools/http-request/truncate-response.js +57 -46
  200. package/dist-lib/lib/tools/http-request.d.ts +1 -1
  201. package/dist-lib/lib/tools/http-request.js +33 -18
  202. package/dist-lib/lib/tools/mcp/protocol.d.ts +53 -0
  203. package/dist-lib/lib/tools/mcp/{utils.js → protocol.js} +45 -23
  204. package/dist-lib/lib/tools/mcp-call.d.ts +1 -1
  205. package/dist-lib/lib/tools/mcp-call.js +37 -16
  206. package/dist-lib/lib/tools/operations/builders.js +10 -6
  207. package/dist-lib/lib/tools/operations/compile.js +20 -10
  208. package/dist-lib/lib/tools/operations/decoders.js +12 -6
  209. package/dist-lib/lib/tools/operations/gmail-message.js +3 -2
  210. package/dist-lib/lib/tools/outbound-guard.d.ts +4 -3
  211. package/dist-lib/lib/tools/outbound-guard.js +14 -8
  212. package/dist-lib/lib/tools/private-ip.js +8 -7
  213. package/dist-lib/lib/tools/rag-search.js +14 -7
  214. package/dist-lib/lib/tools/read-files.js +23 -20
  215. package/dist-lib/lib/tools/skill.js +19 -10
  216. package/dist-lib/lib/tools/skills/auth-resolver.d.ts +11 -18
  217. package/dist-lib/lib/tools/skills/auth-resolver.js +30 -18
  218. package/dist-lib/lib/tools/skills/bin-check.d.ts +3 -2
  219. package/dist-lib/lib/tools/skills/bin-check.js +10 -3
  220. package/dist-lib/lib/tools/skills/bundled-dir.js +20 -10
  221. package/dist-lib/lib/tools/skills/bundled-hash.d.ts +3 -2
  222. package/dist-lib/lib/tools/skills/bundled-hash.js +6 -1
  223. package/dist-lib/lib/tools/skills/catalog.d.ts +3 -2
  224. package/dist-lib/lib/tools/skills/catalog.js +33 -28
  225. package/dist-lib/lib/tools/skills/cli-argv.d.ts +3 -2
  226. package/dist-lib/lib/tools/skills/cli-argv.js +55 -52
  227. package/dist-lib/lib/tools/skills/cli-schema-check.js +21 -10
  228. package/dist-lib/lib/tools/skills/cli-schema-load.js +28 -20
  229. package/dist-lib/lib/tools/skills/cli-schema-types.d.ts +6 -6
  230. package/dist-lib/lib/tools/skills/cli-schema.js +2 -1
  231. package/dist-lib/lib/tools/skills/credential-check.d.ts +6 -3
  232. package/dist-lib/lib/tools/skills/credential-check.js +24 -12
  233. package/dist-lib/lib/tools/skills/credential-grants.js +1 -6
  234. package/dist-lib/lib/tools/skills/credential-health.d.ts +5 -1
  235. package/dist-lib/lib/tools/skills/credential-health.js +5 -3
  236. package/dist-lib/lib/tools/skills/frontmatter-parser.js +10 -5
  237. package/dist-lib/lib/tools/skills/manifest-parse.js +84 -64
  238. package/dist-lib/lib/tools/skills/mention.js +7 -6
  239. package/dist-lib/lib/tools/skills/obsidian-readiness.d.ts +2 -2
  240. package/dist-lib/lib/tools/skills/obsidian-readiness.js +11 -3
  241. package/dist-lib/lib/tools/skills/overlay-crud.d.ts +6 -4
  242. package/dist-lib/lib/tools/skills/overlay-crud.js +12 -6
  243. package/dist-lib/lib/tools/skills/overlay-dir.js +4 -2
  244. package/dist-lib/lib/tools/skills/overlay-watch.d.ts +3 -2
  245. package/dist-lib/lib/tools/skills/overlay-watch.js +8 -4
  246. package/dist-lib/lib/tools/skills/setup-routes.js +1 -3
  247. package/dist-lib/lib/tools/skills/skill-settings.js +4 -1
  248. package/dist-lib/lib/tools/skills/skill-state.d.ts +6 -11
  249. package/dist-lib/lib/tools/skills/skill-state.js +48 -29
  250. package/dist-lib/lib/tools/skills/tool-grants.js +6 -3
  251. package/dist-lib/lib/tools/toolsets.js +2 -1
  252. package/dist-lib/lib/tools/translate.d.ts +4 -5
  253. package/dist-lib/lib/tools/translate.js +31 -14
  254. package/dist-lib/lib/tools/url-guard.js +2 -1
  255. package/dist-lib/lib/tools/weather-lookup/place.js +8 -4
  256. package/dist-lib/lib/tools/weather-lookup/report.d.ts +7 -1
  257. package/dist-lib/lib/tools/weather-lookup/report.js +46 -9
  258. package/dist-lib/lib/tools/weather-lookup.js +18 -12
  259. package/dist-lib/lib/tools/web-fetch.js +47 -24
  260. package/dist-lib/lib/tools/web-search.js +8 -3
  261. package/dist-lib/lib/validating-lookup.d.ts +4 -4
  262. package/dist-lib/lib/wav-encode.d.ts +1 -1
  263. package/dist-lib/lib/wav-encode.js +11 -10
  264. package/dist-lib/lib/web-fetch/embedded-state.js +24 -12
  265. package/dist-lib/lib/web-fetch/extract.js +4 -2
  266. package/dist-lib/lib/web-fetch/images.js +8 -4
  267. package/dist-lib/lib/web-fetch/video.d.ts +2 -2
  268. package/dist-lib/lib/web-fetch/video.js +8 -4
  269. package/dist-lib/lib/web-search/engine-registry.d.ts +2 -2
  270. package/dist-lib/lib/web-search/engines/aol.js +1 -1
  271. package/dist-lib/lib/web-search/engines/bing.js +1 -1
  272. package/dist-lib/lib/web-search/engines/brave.js +4 -1
  273. package/dist-lib/lib/web-search/engines/duckduckgo.js +3 -2
  274. package/dist-lib/lib/web-search/engines/google.js +7 -3
  275. package/dist-lib/lib/web-search/engines/wikipedia.js +5 -4
  276. package/dist-lib/lib/web-search/engines/yahoo.js +1 -1
  277. package/dist-lib/lib/web-search/fetch-html.d.ts +5 -4
  278. package/dist-lib/lib/web-search/fetch-html.js +13 -7
  279. package/dist-lib/lib/web-search/orchestrator.d.ts +9 -5
  280. package/dist-lib/lib/web-search/orchestrator.js +3 -3
  281. package/dist-lib/lib/wire.d.ts +3 -2
  282. package/dist-lib/lib/wire.js +23 -15
  283. package/dist-lib/schema/baseline.js +10 -5
  284. package/dist-lib/schema/build.js +2 -1
  285. package/dist-lib/schema/harness.d.ts +15 -2
  286. package/dist-lib/schema/harness.js +55 -2
  287. package/dist-lib/schema/release-tags.d.ts +3 -2
  288. package/dist-lib/schema/release-tags.js +6 -3
  289. package/dist-lib/spec/bind.js +6 -0
  290. package/dist-lib/spec/calls.js +2 -0
  291. package/dist-lib/spec/hrpc/hrpc.json +26 -0
  292. package/dist-lib/spec/hrpc/index.js +27 -3
  293. package/dist-lib/spec/hrpc/messages.js +207 -8
  294. package/dist-lib/spec/hyperschema/index.js +207 -8
  295. package/dist-lib/spec/hyperschema/schema.json +165 -1
  296. package/dist-lib/spec/hyperschema/types.d.ts +42 -1
  297. package/package.json +13 -14
  298. package/worker/harness-sidecar.mjs +16 -22
  299. package/worker/stow-entry.mjs +7 -4
  300. package/dist-lib/lib/tools/mcp/utils.d.ts +0 -47
  301. /package/dist-lib/lib/tools/http-request/{utils.d.ts → request.d.ts} +0 -0
@@ -37,7 +37,8 @@ function buildInit(options, signal) {
37
37
  }
38
38
  return init;
39
39
  }
40
- async function fetchWithTimeout(fetcher, url, options, callerSignal) {
40
+ async function fetchWithTimeout(fetcher, url, options) {
41
+ const callerSignal = options?.signal;
41
42
  if (callerSignal?.aborted) {
42
43
  throw new AbortError();
43
44
  }
@@ -57,10 +58,12 @@ async function fetchWithTimeout(fetcher, url, options, callerSignal) {
57
58
  return { ok: resp.ok, status: resp.status, text };
58
59
  }
59
60
  catch (err) {
60
- if (timedOut)
61
+ if (timedOut) {
61
62
  throw new TimeoutError(timeoutMs);
62
- if (callerSignal?.aborted)
63
+ }
64
+ if (callerSignal?.aborted) {
63
65
  throw new AbortError();
66
+ }
64
67
  throw err;
65
68
  }
66
69
  finally {
@@ -68,8 +71,8 @@ async function fetchWithTimeout(fetcher, url, options, callerSignal) {
68
71
  callerSignal?.removeEventListener('abort', onCallerAbort);
69
72
  }
70
73
  }
71
- export async function fetchHtml(fetcher, url, options, signal) {
72
- const { ok, status, text } = await fetchWithTimeout(fetcher, url, options, signal);
74
+ export async function fetchHtml(fetcher, url, options) {
75
+ const { ok, status, text } = await fetchWithTimeout(fetcher, url, options);
73
76
  if (!ok) {
74
77
  throw new Error(`HTTP ${status}`);
75
78
  }
@@ -83,8 +86,11 @@ export class JsonParseError extends Error {
83
86
  this.name = 'JsonParseError';
84
87
  }
85
88
  }
86
- export async function fetchJson(fetcher, url, options, signal) {
87
- const { ok, status, text } = await fetchWithTimeout(fetcher, url, { ...options, accept: options?.accept ?? 'application/json' }, signal);
89
+ export async function fetchJson(fetcher, url, options) {
90
+ const { ok, status, text } = await fetchWithTimeout(fetcher, url, {
91
+ ...options,
92
+ accept: options?.accept ?? 'application/json'
93
+ });
88
94
  if (!ok) {
89
95
  throw new Error(`HTTP ${status}`);
90
96
  }
@@ -1,14 +1,18 @@
1
1
  import type { AbortSignal as BareAbortSignal } from 'bare-abort-controller';
2
2
  import type { Fetcher, WebSearchResult } from './types.ts';
3
- export type EngineSummaryEntry = {
3
+ export interface EngineSummaryEntry {
4
4
  readonly engine: string;
5
5
  readonly status: 'ok' | 'timeout' | 'error';
6
6
  readonly resultCount: number;
7
7
  readonly durationMs: number;
8
- };
9
- export type SearchWebResult = {
8
+ }
9
+ export interface SearchWebResult {
10
10
  readonly results: ReadonlyArray<WebSearchResult>;
11
11
  readonly engineSummary: ReadonlyArray<EngineSummaryEntry>;
12
- };
12
+ }
13
13
  export declare function classifyEngineError(reason: unknown): 'timeout' | 'error';
14
- export declare function searchWeb(fetcher: Fetcher, query: string, maxResults?: number, signal?: BareAbortSignal): Promise<SearchWebResult>;
14
+ export interface SearchWebOptions {
15
+ readonly maxResults?: number;
16
+ readonly signal?: BareAbortSignal;
17
+ }
18
+ export declare function searchWeb(fetcher: Fetcher, query: string, { maxResults, signal }?: SearchWebOptions): Promise<SearchWebResult>;
@@ -4,7 +4,7 @@ import { mergeResults } from './merge-results.js';
4
4
  export function classifyEngineError(reason) {
5
5
  return reason instanceof TimeoutError ? 'timeout' : 'error';
6
6
  }
7
- function processSettledResult(engineName, result, outcomes, engineSummary) {
7
+ function processSettledResult(engineName, result, { outcomes, engineSummary }) {
8
8
  if (result.status === 'fulfilled') {
9
9
  outcomes.push(result.value);
10
10
  engineSummary.push({
@@ -23,7 +23,7 @@ function processSettledResult(engineName, result, outcomes, engineSummary) {
23
23
  });
24
24
  }
25
25
  }
26
- export async function searchWeb(fetcher, query, maxResults = DEFAULT_MAX_RESULTS, signal) {
26
+ export async function searchWeb(fetcher, query, { maxResults = DEFAULT_MAX_RESULTS, signal } = {}) {
27
27
  const settled = await Promise.allSettled(ENGINES.map(async ({ name, fn }) => {
28
28
  const start = Date.now();
29
29
  const results = await fn(query, fetcher, signal);
@@ -41,7 +41,7 @@ export async function searchWeb(fetcher, query, maxResults = DEFAULT_MAX_RESULTS
41
41
  if (!engine || !settledResult) {
42
42
  continue;
43
43
  }
44
- processSettledResult(engine.name, settledResult, outcomes, engineSummary);
44
+ processSettledResult(engine.name, settledResult, { outcomes, engineSummary });
45
45
  }
46
46
  if (outcomes.length === 0) {
47
47
  return { results: [], engineSummary };
@@ -44,8 +44,9 @@ export declare function toWire(event: HarnessEvent): WireEvent;
44
44
  export declare function fromWire(event: WireEvent): HarnessEvent;
45
45
  export declare function toDownloadWire(event: HarnessEvent): WireDownloadEvent;
46
46
  export declare function fromDownloadWire(event: WireDownloadEvent): HarnessEvent;
47
- export declare function packVectors(vectors: number[][]): {
47
+ export interface PackedVectors {
48
48
  dimensions: number;
49
49
  vectors: Buffer;
50
- };
50
+ }
51
+ export declare function packVectors(vectors: number[][]): PackedVectors;
51
52
  export declare function unpackVectors(dimensions: number, bytes: Buffer): number[][];
@@ -1,4 +1,14 @@
1
1
  import b4a from 'b4a';
2
+ import { isRecord } from './guards.js';
3
+ function stringField(value) {
4
+ return typeof value === 'string' ? value : undefined;
5
+ }
6
+ function objectField(value) {
7
+ return isRecord(value) ? value : {};
8
+ }
9
+ function isResource(value) {
10
+ return isRecord(value) && typeof value.kind === 'string' && typeof value.label === 'string';
11
+ }
2
12
  export function toWire(event) {
3
13
  switch (event.type) {
4
14
  case 'content':
@@ -7,26 +17,26 @@ export function toWire(event) {
7
17
  case 'tool-call':
8
18
  return {
9
19
  type: 'tool-call',
10
- name: event.name,
20
+ name: stringField(event.name),
11
21
  arguments: event.args,
12
- rawCall: event.rawCall ?? null,
13
- effect: event.effect ?? null,
22
+ rawCall: stringField(event.rawCall) ?? null,
23
+ effect: stringField(event.effect) ?? null,
14
24
  display: event.display
15
25
  };
16
26
  case 'tool-result':
17
27
  return {
18
28
  type: 'tool-result',
19
- name: event.name,
29
+ name: stringField(event.name),
20
30
  result: event.result
21
31
  };
22
32
  case 'tool-activity':
23
33
  return {
24
34
  type: 'tool-activity',
25
- name: event.name,
35
+ name: stringField(event.name),
26
36
  arguments: event.args,
27
- resource: event.resource ?? null,
28
- effect: event.effect,
29
- decision: event.decision
37
+ resource: isResource(event.resource) ? event.resource : null,
38
+ effect: stringField(event.effect),
39
+ decision: stringField(event.decision)
30
40
  };
31
41
  case 'metrics': {
32
42
  const { type, ...metrics } = event;
@@ -64,9 +74,7 @@ export function fromWire(event) {
64
74
  type: 'tool-call',
65
75
  name: event.name ?? '',
66
76
  args: event.arguments ?? {},
67
- ...(event.rawCall === null || event.rawCall === undefined
68
- ? {}
69
- : { rawCall: event.rawCall }),
77
+ rawCall: event.rawCall ?? undefined,
70
78
  effect: event.effect === 'read' ? 'read' : 'write',
71
79
  display: event.display ?? undefined
72
80
  };
@@ -86,11 +94,11 @@ export function fromWire(event) {
86
94
  decision: event.decision || 'blocked'
87
95
  };
88
96
  case 'metrics':
89
- return { type: 'metrics', ...event.metrics };
97
+ return { type: 'metrics', ...objectField(event.metrics) };
90
98
  case 'inference-call':
91
99
  return { type: 'inference-call', call: event.payload };
92
100
  case 'inference-sent': {
93
- const sent = (event.payload ?? {});
101
+ const sent = objectField(event.payload);
94
102
  return {
95
103
  type: 'inference-sent',
96
104
  messages: sent.messages,
@@ -118,7 +126,7 @@ export function toDownloadWire(event) {
118
126
  case 'complete':
119
127
  return {
120
128
  type: 'complete',
121
- assetId: event.assetId,
129
+ assetId: stringField(event.assetId),
122
130
  downloaded: typeof event.downloaded === 'boolean' ? event.downloaded : undefined
123
131
  };
124
132
  case 'error':
@@ -132,7 +140,7 @@ export function toDownloadWire(event) {
132
140
  export function fromDownloadWire(event) {
133
141
  switch (event.type) {
134
142
  case 'progress':
135
- return { type: 'progress', ...(event.progress ?? {}) };
143
+ return { type: 'progress', ...objectField(event.progress) };
136
144
  case 'complete':
137
145
  return { type: 'complete', assetId: event.assetId ?? '', downloaded: event.downloaded };
138
146
  case 'error':
@@ -7,28 +7,33 @@ export function rewindSpec(root, dirs, { carries, keep }) {
7
7
  if (process.env.SCHEMA_NO_BASELINE)
8
8
  return [];
9
9
  const baselines = previousReleaseTags(root, { carries });
10
- if (baselines.length === 0)
10
+ if (baselines.length === 0) {
11
11
  return [];
12
+ }
12
13
  const held = keep.map((file) => {
13
14
  const target = path.join(root, file);
14
15
  return { target, contents: fs.readFileSync(target) };
15
16
  });
16
- for (const dir of dirs)
17
+ for (const dir of dirs) {
17
18
  checkoutSpec(root, dir, baselines[0]);
18
- for (const { target, contents } of held)
19
+ }
20
+ for (const { target, contents } of held) {
19
21
  fs.writeFileSync(target, contents);
22
+ }
20
23
  return baselines;
21
24
  }
22
25
  function checkoutSpec(root, dir, tag) {
23
26
  console.log(`rewinding ${path.relative(root, dir)} to ${tag}`);
24
27
  const done = spawnSync('git', ['checkout', tag, '--', dir], { cwd: root });
25
- if (done.status !== 0)
28
+ if (done.status !== 0) {
26
29
  throw new Error(`checkout ${tag} failed: ${done.stderr ?? ''}`);
30
+ }
27
31
  }
28
32
  export function unstageSpec(root, dirs) {
29
33
  const done = spawnSync('git', ['reset', '--quiet', 'HEAD', '--', ...dirs], { cwd: root });
30
- if (done.status !== 0)
34
+ if (done.status !== 0) {
31
35
  throw new Error(`git reset -- spec failed: ${done.stderr ?? ''}`);
36
+ }
32
37
  }
33
38
  export function resetHrpcIds(hrpcDir) {
34
39
  fs.rmSync(path.join(hrpcDir, 'hrpc.json'), { force: true });
@@ -34,6 +34,7 @@ registerHarnessApi(builder.namespace('harness'));
34
34
  HRPCBuilder.toDisk(builder);
35
35
  writeBind(builder, path.join(SPEC_DIR, 'bind.js'));
36
36
  writeClient(builder, path.join(SPEC_DIR, 'calls.js'), 'harnessClient');
37
- if (baselines.length > 0)
37
+ if (baselines.length > 0) {
38
38
  unstageSpec(ROOT, BASELINE_DIRS);
39
+ }
39
40
  console.log('harness contract spec generated under spec/');
@@ -1,2 +1,15 @@
1
- export declare function registerHarnessTypes(ns: any): void;
2
- export declare function registerHarnessApi(api: any): void;
1
+ import type Hyperschema from 'hyperschema';
2
+ interface HrpcRoute {
3
+ name: string;
4
+ stream: boolean;
5
+ }
6
+ interface HrpcNamespace {
7
+ register(description: {
8
+ name: string;
9
+ request: HrpcRoute;
10
+ response: HrpcRoute;
11
+ }): void;
12
+ }
13
+ export declare function registerHarnessTypes(ns: Hyperschema.Namespace): void;
14
+ export declare function registerHarnessApi(api: HrpcNamespace): void;
15
+ export {};
@@ -338,7 +338,8 @@ export function registerHarnessTypes(ns) {
338
338
  { name: 'isLoaded', type: 'bool', required: true },
339
339
  { name: 'supportsImages', type: 'bool', required: true },
340
340
  { name: 'expectedSize', type: 'uint', required: true },
341
- { name: 'actualSize', type: 'uint' }
341
+ { name: 'actualSize', type: 'uint' },
342
+ { name: 'label', type: 'string' }
342
343
  ]
343
344
  });
344
345
  ns.register({
@@ -564,7 +565,11 @@ export function registerHarnessTypes(ns) {
564
565
  fields: [
565
566
  { name: 'name', type: 'string', required: true },
566
567
  { name: 'src', type: 'string', required: true },
567
- { name: 'projectionSrc', type: 'string' }
568
+ { name: 'projectionSrc', type: 'string' },
569
+ { name: 'taskType', type: 'string' },
570
+ { name: 'expectedSize', type: 'uint' },
571
+ { name: 'label', type: 'string' },
572
+ { name: 'contextLength', type: 'uint' }
568
573
  ]
569
574
  });
570
575
  ns.register({
@@ -678,6 +683,44 @@ export function registerHarnessTypes(ns) {
678
683
  { name: 'verify', type: '@harness/skill-oauth-verify' }
679
684
  ]
680
685
  });
686
+ ns.register({
687
+ name: 'preview-model-source-request',
688
+ fields: [
689
+ { name: 'src', type: 'string', required: true },
690
+ { name: 'mmprojSrc', type: 'string' }
691
+ ]
692
+ });
693
+ ns.register({
694
+ name: 'model-source-file',
695
+ fields: [
696
+ { name: 'src', type: 'string', required: true },
697
+ { name: 'label', type: 'string', required: true },
698
+ { name: 'sizeBytes', type: 'uint' }
699
+ ]
700
+ });
701
+ ns.register({
702
+ name: 'preview-model-source-response',
703
+ fields: [
704
+ { name: 'ok', type: 'bool', required: true },
705
+ { name: 'refusal', type: 'string' },
706
+ { name: 'reason', type: 'string' },
707
+ { name: 'src', type: 'string' },
708
+ { name: 'files', type: '@harness/model-source-file', array: true },
709
+ { name: 'sizeBytes', type: 'uint' },
710
+ { name: 'contextLength', type: 'uint' },
711
+ { name: 'architecture', type: 'string' },
712
+ { name: 'sizeLabel', type: 'string' },
713
+ { name: 'taskType', type: 'string' },
714
+ { name: 'license', type: 'string' },
715
+ { name: 'fit', type: 'string' },
716
+ { name: 'fitReasons', type: 'string', array: true },
717
+ { name: 'mmprojSrc', type: 'string' }
718
+ ]
719
+ });
720
+ ns.register({
721
+ name: 'set-model-idle-timeout-request',
722
+ fields: [{ name: 'ms', type: 'uint', required: true }]
723
+ });
681
724
  }
682
725
  export function registerHarnessApi(api) {
683
726
  api.register({
@@ -825,4 +868,14 @@ export function registerHarnessApi(api) {
825
868
  request: { name: '@harness/detect-language-request', stream: false },
826
869
  response: { name: '@harness/detect-language-response', stream: false }
827
870
  });
871
+ api.register({
872
+ name: 'preview-model-source',
873
+ request: { name: '@harness/preview-model-source-request', stream: false },
874
+ response: { name: '@harness/preview-model-source-response', stream: false }
875
+ });
876
+ api.register({
877
+ name: 'set-model-idle-timeout',
878
+ request: { name: '@harness/set-model-idle-timeout-request', stream: false },
879
+ response: { name: '@harness/ok-response', stream: false }
880
+ });
828
881
  }
@@ -1,6 +1,7 @@
1
1
  import { Version } from 'bare-semver';
2
2
  export declare function currentReleaseVersion(root: string): Version;
3
- export declare function previousReleaseTags(root: string, { count, carries }: {
3
+ export interface PreviousReleaseTagsOptions {
4
4
  count?: number;
5
5
  carries: string;
6
- }): string[];
6
+ }
7
+ export declare function previousReleaseTags(root: string, { count, carries }: PreviousReleaseTagsOptions): string[];
@@ -16,13 +16,15 @@ const TAG_PREFIX = 'v';
16
16
  export function previousReleaseTags(root, { count = 3, carries }) {
17
17
  const current = currentReleaseVersion(root);
18
18
  const listed = spawnSync('git', ['tag', '-l', `${TAG_PREFIX}*`], { cwd: root });
19
- if (listed.status !== 0)
19
+ if (listed.status !== 0) {
20
20
  throw new Error(`git tag -l failed: ${listed.stderr ?? ''}`);
21
+ }
21
22
  const newestPerLine = new Map();
22
23
  for (const line of (listed.stdout?.toString() ?? '').split('\n')) {
23
24
  const parsed = parseTag(line.trim());
24
- if (!parsed || Version.compare(parsed.version, current) > 0)
25
+ if (!parsed || Version.compare(parsed.version, current) > 0) {
25
26
  continue;
27
+ }
26
28
  const winner = newestPerLine.get(parsed.line);
27
29
  if (!winner || Version.compare(parsed.version, winner.version) > 0) {
28
30
  newestPerLine.set(parsed.line, parsed);
@@ -46,8 +48,9 @@ function parseTag(name) {
46
48
  return null;
47
49
  try {
48
50
  const version = Version.parse(name.slice(TAG_PREFIX.length));
49
- if (version.prerelease.length > 0)
51
+ if (version.prerelease.length > 0) {
50
52
  return null;
53
+ }
51
54
  return { tag: name, version, line: `${version.major}.${version.minor}` };
52
55
  }
53
56
  catch {
@@ -127,4 +127,10 @@ export function bindApi(rpc, api) {
127
127
  if (api.detectLanguage) {
128
128
  rpc.onDetectLanguage((req) => api.detectLanguage(req));
129
129
  }
130
+ if (api.previewModelSource) {
131
+ rpc.onPreviewModelSource((req) => api.previewModelSource(req));
132
+ }
133
+ if (api.setModelIdleTimeout) {
134
+ rpc.onSetModelIdleTimeout((req) => api.setModelIdleTimeout(req));
135
+ }
130
136
  }
@@ -39,5 +39,7 @@ export function harnessClient(rpc) {
39
39
  deleteOverlaySkill: (input) => rpc.deleteOverlaySkill(input),
40
40
  deleteKvCache: (input) => rpc.deleteKvCache(input),
41
41
  detectLanguage: (input) => rpc.detectLanguage(input),
42
+ previewModelSource: (input) => rpc.previewModelSource(input),
43
+ setModelIdleTimeout: (input) => rpc.setModelIdleTimeout(input),
42
44
  };
43
45
  }
@@ -377,6 +377,32 @@
377
377
  "stream": false
378
378
  },
379
379
  "version": 1
380
+ },
381
+ {
382
+ "id": 29,
383
+ "name": "@harness/preview-model-source",
384
+ "request": {
385
+ "name": "@harness/preview-model-source-request",
386
+ "stream": false
387
+ },
388
+ "response": {
389
+ "name": "@harness/preview-model-source-response",
390
+ "stream": false
391
+ },
392
+ "version": 1
393
+ },
394
+ {
395
+ "id": 30,
396
+ "name": "@harness/set-model-idle-timeout",
397
+ "request": {
398
+ "name": "@harness/set-model-idle-timeout-request",
399
+ "stream": false
400
+ },
401
+ "response": {
402
+ "name": "@harness/ok-response",
403
+ "stream": false
404
+ },
405
+ "version": 1
380
406
  }
381
407
  ]
382
408
  }
@@ -63,7 +63,11 @@ const methods = new Map([
63
63
  ['@harness/delete-kv-cache', 27],
64
64
  [27, '@harness/delete-kv-cache'],
65
65
  ['@harness/detect-language', 28],
66
- [28, '@harness/detect-language']
66
+ [28, '@harness/detect-language'],
67
+ ['@harness/preview-model-source', 29],
68
+ [29, '@harness/preview-model-source'],
69
+ ['@harness/set-model-idle-timeout', 30],
70
+ [30, '@harness/set-model-idle-timeout']
67
71
  ])
68
72
 
69
73
  class HRPC {
@@ -99,7 +103,9 @@ class HRPC {
99
103
  ['@harness/copy-skill-for-edit', getEncoding('@harness/skill-name-request')],
100
104
  ['@harness/delete-overlay-skill', getEncoding('@harness/skill-name-request')],
101
105
  ['@harness/delete-kv-cache', getEncoding('@harness/kv-cache-delete-request')],
102
- ['@harness/detect-language', getEncoding('@harness/detect-language-request')]
106
+ ['@harness/detect-language', getEncoding('@harness/detect-language-request')],
107
+ ['@harness/preview-model-source', getEncoding('@harness/preview-model-source-request')],
108
+ ['@harness/set-model-idle-timeout', getEncoding('@harness/set-model-idle-timeout-request')]
103
109
  ])
104
110
  this._responseEncodings = new Map([
105
111
  ['@harness/completion', getEncoding('@harness/completion-event')],
@@ -130,7 +136,9 @@ class HRPC {
130
136
  ['@harness/copy-skill-for-edit', getEncoding('@harness/copy-skill-response')],
131
137
  ['@harness/delete-overlay-skill', getEncoding('@harness/delete-skill-response')],
132
138
  ['@harness/delete-kv-cache', getEncoding('@harness/kv-cache-deletion-response')],
133
- ['@harness/detect-language', getEncoding('@harness/detect-language-response')]
139
+ ['@harness/detect-language', getEncoding('@harness/detect-language-response')],
140
+ ['@harness/preview-model-source', getEncoding('@harness/preview-model-source-response')],
141
+ ['@harness/set-model-idle-timeout', getEncoding('@harness/ok-response')]
134
142
  ])
135
143
  this._rpc = new RPC(stream, async (req) => {
136
144
  const command = methods.get(req.command)
@@ -344,6 +352,14 @@ class HRPC {
344
352
  return this._call('@harness/detect-language', args)
345
353
  }
346
354
 
355
+ async previewModelSource(args) {
356
+ return this._call('@harness/preview-model-source', args)
357
+ }
358
+
359
+ async setModelIdleTimeout(args) {
360
+ return this._call('@harness/set-model-idle-timeout', args)
361
+ }
362
+
347
363
  onCompletion(responseFn) {
348
364
  this._handlers['@harness/completion'] = responseFn
349
365
  }
@@ -460,6 +476,14 @@ class HRPC {
460
476
  this._handlers['@harness/detect-language'] = responseFn
461
477
  }
462
478
 
479
+ onPreviewModelSource(responseFn) {
480
+ this._handlers['@harness/preview-model-source'] = responseFn
481
+ }
482
+
483
+ onSetModelIdleTimeout(responseFn) {
484
+ this._handlers['@harness/set-model-idle-timeout'] = responseFn
485
+ }
486
+
463
487
  _requestIsStream(command) {
464
488
  return [
465
489
  '@harness/completion',