@qvac/harness 0.1.0 → 0.1.1

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 (460) hide show
  1. package/dist/harness.bundle +8 -59
  2. package/dist/prebuilds-manifest.json +0 -8
  3. package/dist-lib/index.d.ts +240 -0
  4. package/dist-lib/index.js +1063 -0
  5. package/dist-lib/lib/audio-transcode-bare.d.ts +2 -0
  6. package/dist-lib/lib/audio-transcode-bare.js +145 -0
  7. package/dist-lib/lib/audio-transcode-node.d.ts +2 -0
  8. package/dist-lib/lib/audio-transcode-node.js +6 -0
  9. package/dist-lib/lib/capabilities/audio-resample.d.ts +14 -0
  10. package/dist-lib/lib/capabilities/audio-resample.js +72 -0
  11. package/dist-lib/lib/capabilities/completion.d.ts +288 -0
  12. package/dist-lib/lib/capabilities/completion.js +1077 -0
  13. package/dist-lib/lib/capabilities/download.d.ts +46 -0
  14. package/dist-lib/lib/capabilities/download.js +124 -0
  15. package/dist-lib/lib/capabilities/embed.d.ts +20 -0
  16. package/dist-lib/lib/capabilities/embed.js +13 -0
  17. package/dist-lib/lib/capabilities/kv-cache.d.ts +13 -0
  18. package/dist-lib/lib/capabilities/kv-cache.js +21 -0
  19. package/dist-lib/lib/capabilities/prompt-prefix.d.ts +6 -0
  20. package/dist-lib/lib/capabilities/prompt-prefix.js +10 -0
  21. package/dist-lib/lib/capabilities/speech-lexicon.d.ts +5 -0
  22. package/dist-lib/lib/capabilities/speech-lexicon.js +32 -0
  23. package/dist-lib/lib/capabilities/speech-text.d.ts +6 -0
  24. package/dist-lib/lib/capabilities/speech-text.js +79 -0
  25. package/dist-lib/lib/capabilities/tool-names.d.ts +3 -0
  26. package/dist-lib/lib/capabilities/tool-names.js +3 -0
  27. package/dist-lib/lib/capabilities/tool-selection.d.ts +43 -0
  28. package/dist-lib/lib/capabilities/tool-selection.js +60 -0
  29. package/dist-lib/lib/capabilities/tool-turns.d.ts +9 -0
  30. package/dist-lib/lib/capabilities/tool-turns.js +101 -0
  31. package/dist-lib/lib/capabilities/usage-breakdown.d.ts +27 -0
  32. package/dist-lib/lib/capabilities/usage-breakdown.js +44 -0
  33. package/dist-lib/lib/capabilities/vision-history.d.ts +3 -0
  34. package/dist-lib/lib/capabilities/vision-history.js +21 -0
  35. package/dist-lib/lib/capabilities/voice.d.ts +78 -0
  36. package/dist-lib/lib/capabilities/voice.js +189 -0
  37. package/dist-lib/lib/connect.d.ts +76 -0
  38. package/dist-lib/lib/connect.js +789 -0
  39. package/dist-lib/lib/context-window.d.ts +7 -0
  40. package/dist-lib/lib/context-window.js +90 -0
  41. package/dist-lib/lib/contract-types.d.ts +210 -0
  42. package/dist-lib/lib/contract-types.js +1 -0
  43. package/dist-lib/lib/diagram-repair.d.ts +21 -0
  44. package/dist-lib/lib/diagram-repair.js +58 -0
  45. package/dist-lib/lib/dns-lookup.d.ts +1 -0
  46. package/dist-lib/lib/dns-lookup.js +13 -0
  47. package/dist-lib/lib/error-fields.d.ts +2 -0
  48. package/dist-lib/lib/error-fields.js +8 -0
  49. package/dist-lib/lib/fetch-node.d.ts +1 -0
  50. package/dist-lib/lib/fetch-node.js +1 -0
  51. package/dist-lib/lib/hardware/capability-probe.d.ts +9 -0
  52. package/dist-lib/lib/hardware/capability-probe.js +99 -0
  53. package/dist-lib/lib/hardware/gpu-classify.d.ts +2 -0
  54. package/dist-lib/lib/hardware/gpu-classify.js +32 -0
  55. package/dist-lib/lib/hardware/gpu-probe-addon.d.ts +2 -0
  56. package/dist-lib/lib/hardware/gpu-probe-addon.js +42 -0
  57. package/dist-lib/lib/hardware/gpu-stats.bare.d.ts +1 -0
  58. package/dist-lib/lib/hardware/gpu-stats.bare.js +24 -0
  59. package/dist-lib/lib/hardware/gpu-stats.stub.d.ts +1 -0
  60. package/dist-lib/lib/hardware/gpu-stats.stub.js +3 -0
  61. package/dist-lib/lib/hardware/memory-budget.d.ts +8 -0
  62. package/dist-lib/lib/hardware/memory-budget.js +1 -0
  63. package/dist-lib/lib/hardware/parsers.d.ts +7 -0
  64. package/dist-lib/lib/hardware/parsers.js +41 -0
  65. package/dist-lib/lib/headers-bare.d.ts +1 -0
  66. package/dist-lib/lib/headers-bare.js +1 -0
  67. package/dist-lib/lib/headers-node.d.ts +4 -0
  68. package/dist-lib/lib/headers-node.js +1 -0
  69. package/dist-lib/lib/helpers/buffer-burst.d.ts +1 -0
  70. package/dist-lib/lib/helpers/buffer-burst.js +20 -0
  71. package/dist-lib/lib/helpers/control-tokens.d.ts +7 -0
  72. package/dist-lib/lib/helpers/control-tokens.js +32 -0
  73. package/dist-lib/lib/helpers/join-guard.d.ts +6 -0
  74. package/dist-lib/lib/helpers/join-guard.js +46 -0
  75. package/dist-lib/lib/helpers/markup-stream-filter.d.ts +5 -0
  76. package/dist-lib/lib/helpers/markup-stream-filter.js +75 -0
  77. package/dist-lib/lib/helpers/race-abort.d.ts +5 -0
  78. package/dist-lib/lib/helpers/race-abort.js +18 -0
  79. package/dist-lib/lib/helpers/retry-memo.d.ts +5 -0
  80. package/dist-lib/lib/helpers/retry-memo.js +12 -0
  81. package/dist-lib/lib/helpers/run-outcome.d.ts +33 -0
  82. package/dist-lib/lib/helpers/run-outcome.js +204 -0
  83. package/dist-lib/lib/helpers/spawn-path.d.ts +5 -0
  84. package/dist-lib/lib/helpers/spawn-path.js +57 -0
  85. package/dist-lib/lib/helpers/text-coalescer.d.ts +15 -0
  86. package/dist-lib/lib/helpers/text-coalescer.js +34 -0
  87. package/dist-lib/lib/helpers/thinking.d.ts +8 -0
  88. package/dist-lib/lib/helpers/thinking.js +95 -0
  89. package/dist-lib/lib/helpers/tool-call-markup.d.ts +20 -0
  90. package/dist-lib/lib/helpers/tool-call-markup.js +201 -0
  91. package/dist-lib/lib/helpers/tool-intent.d.ts +7 -0
  92. package/dist-lib/lib/helpers/tool-intent.js +21 -0
  93. package/dist-lib/lib/helpers/tool-label.d.ts +8 -0
  94. package/dist-lib/lib/helpers/tool-label.js +131 -0
  95. package/dist-lib/lib/hooks/built-in/arg-repair.d.ts +5 -0
  96. package/dist-lib/lib/hooks/built-in/arg-repair.js +88 -0
  97. package/dist-lib/lib/hooks/built-in/egress.d.ts +5 -0
  98. package/dist-lib/lib/hooks/built-in/egress.js +29 -0
  99. package/dist-lib/lib/hooks/built-in/index.d.ts +3 -0
  100. package/dist-lib/lib/hooks/built-in/index.js +3 -0
  101. package/dist-lib/lib/hooks/built-in/skill-catalog.d.ts +10 -0
  102. package/dist-lib/lib/hooks/built-in/skill-catalog.js +17 -0
  103. package/dist-lib/lib/hooks/pipeline.d.ts +20 -0
  104. package/dist-lib/lib/hooks/pipeline.js +49 -0
  105. package/dist-lib/lib/hooks/registry.d.ts +2 -0
  106. package/dist-lib/lib/hooks/registry.js +6 -0
  107. package/dist-lib/lib/hooks/run.d.ts +5 -0
  108. package/dist-lib/lib/hooks/run.js +83 -0
  109. package/dist-lib/lib/hooks/types.d.ts +57 -0
  110. package/dist-lib/lib/hooks/types.js +1 -0
  111. package/dist-lib/lib/log.d.ts +5 -0
  112. package/dist-lib/lib/log.js +37 -0
  113. package/dist-lib/lib/model-download-progress.d.ts +22 -0
  114. package/dist-lib/lib/model-download-progress.js +95 -0
  115. package/dist-lib/lib/models/context.d.ts +5 -0
  116. package/dist-lib/lib/models/context.js +12 -0
  117. package/dist-lib/lib/models/embed-config.d.ts +14 -0
  118. package/dist-lib/lib/models/embed-config.js +31 -0
  119. package/dist-lib/lib/models/gpu-selection.d.ts +3 -0
  120. package/dist-lib/lib/models/gpu-selection.js +26 -0
  121. package/dist-lib/lib/models/kv-cache.d.ts +4 -0
  122. package/dist-lib/lib/models/kv-cache.js +6 -0
  123. package/dist-lib/lib/models/llm-presets.d.ts +10 -0
  124. package/dist-lib/lib/models/llm-presets.js +58 -0
  125. package/dist-lib/lib/models/model-catalog-constants.d.ts +29 -0
  126. package/dist-lib/lib/models/model-catalog-constants.js +103 -0
  127. package/dist-lib/lib/models/model-catalog.d.ts +125 -0
  128. package/dist-lib/lib/models/model-catalog.js +371 -0
  129. package/dist-lib/lib/models/model-delete.d.ts +18 -0
  130. package/dist-lib/lib/models/model-delete.js +47 -0
  131. package/dist-lib/lib/models/model-handle.d.ts +18 -0
  132. package/dist-lib/lib/models/model-handle.js +33 -0
  133. package/dist-lib/lib/models/model-list.d.ts +42 -0
  134. package/dist-lib/lib/models/model-list.js +123 -0
  135. package/dist-lib/lib/models/model-pool.d.ts +116 -0
  136. package/dist-lib/lib/models/model-pool.js +356 -0
  137. package/dist-lib/lib/models/model-source.d.ts +6 -0
  138. package/dist-lib/lib/models/model-source.js +21 -0
  139. package/dist-lib/lib/models/music-catalog.d.ts +12 -0
  140. package/dist-lib/lib/models/music-catalog.js +26 -0
  141. package/dist-lib/lib/models/opencl-cache.d.ts +5 -0
  142. package/dist-lib/lib/models/opencl-cache.js +50 -0
  143. package/dist-lib/lib/models/sdk-faults.d.ts +21 -0
  144. package/dist-lib/lib/models/sdk-faults.js +66 -0
  145. package/dist-lib/lib/models/tool-dialect.d.ts +2 -0
  146. package/dist-lib/lib/models/tool-dialect.js +19 -0
  147. package/dist-lib/lib/models/tts-model-default.d.ts +3 -0
  148. package/dist-lib/lib/models/tts-model-default.js +13 -0
  149. package/dist-lib/lib/no-redirect-fetch-bare.d.ts +15 -0
  150. package/dist-lib/lib/no-redirect-fetch-bare.js +59 -0
  151. package/dist-lib/lib/no-redirect-fetch-impl.d.ts +39 -0
  152. package/dist-lib/lib/no-redirect-fetch-impl.js +80 -0
  153. package/dist-lib/lib/no-redirect-fetch-node.d.ts +4 -0
  154. package/dist-lib/lib/no-redirect-fetch-node.js +52 -0
  155. package/dist-lib/lib/prompt.d.ts +22 -0
  156. package/dist-lib/lib/prompt.js +77 -0
  157. package/dist-lib/lib/queue.d.ts +9 -0
  158. package/dist-lib/lib/queue.js +48 -0
  159. package/dist-lib/lib/resolution-detector.d.ts +5 -0
  160. package/dist-lib/lib/resolution-detector.js +100 -0
  161. package/dist-lib/lib/rpc-session.d.ts +8 -0
  162. package/dist-lib/lib/rpc-session.js +20 -0
  163. package/dist-lib/lib/sdk-config-loader.node.d.ts +1 -0
  164. package/dist-lib/lib/sdk-config-loader.node.js +1 -0
  165. package/dist-lib/lib/sdk-loader.d.ts +30 -0
  166. package/dist-lib/lib/sdk-loader.js +53 -0
  167. package/dist-lib/lib/sdk-storage.d.ts +8 -0
  168. package/dist-lib/lib/sdk-storage.js +24 -0
  169. package/dist-lib/lib/serve.d.ts +3 -0
  170. package/dist-lib/lib/serve.js +612 -0
  171. package/dist-lib/lib/spawn.d.ts +62 -0
  172. package/dist-lib/lib/spawn.js +71 -0
  173. package/dist-lib/lib/staging.d.ts +4 -0
  174. package/dist-lib/lib/staging.js +28 -0
  175. package/dist-lib/lib/storage.d.ts +18 -0
  176. package/dist-lib/lib/storage.js +26 -0
  177. package/dist-lib/lib/tmp-path.d.ts +7 -0
  178. package/dist-lib/lib/tmp-path.js +17 -0
  179. package/dist-lib/lib/tool-call-display.d.ts +21 -0
  180. package/dist-lib/lib/tool-call-display.js +1 -0
  181. package/dist-lib/lib/tools/catalog.d.ts +13 -0
  182. package/dist-lib/lib/tools/catalog.js +13 -0
  183. package/dist-lib/lib/tools/create-documents.d.ts +3 -0
  184. package/dist-lib/lib/tools/create-documents.js +87 -0
  185. package/dist-lib/lib/tools/edit-documents.d.ts +3 -0
  186. package/dist-lib/lib/tools/edit-documents.js +122 -0
  187. package/dist-lib/lib/tools/edit-image.d.ts +25 -0
  188. package/dist-lib/lib/tools/edit-image.js +271 -0
  189. package/dist-lib/lib/tools/exec/adapters/adapter.d.ts +27 -0
  190. package/dist-lib/lib/tools/exec/adapters/adapter.js +1 -0
  191. package/dist-lib/lib/tools/exec/adapters/python/attachments.d.ts +26 -0
  192. package/dist-lib/lib/tools/exec/adapters/python/attachments.js +160 -0
  193. package/dist-lib/lib/tools/exec/adapters/python/create-effect.d.ts +7 -0
  194. package/dist-lib/lib/tools/exec/adapters/python/create-effect.js +290 -0
  195. package/dist-lib/lib/tools/exec/adapters/python/loader.d.ts +11 -0
  196. package/dist-lib/lib/tools/exec/adapters/python/loader.js +94 -0
  197. package/dist-lib/lib/tools/exec/adapters/python/memfs.d.ts +47 -0
  198. package/dist-lib/lib/tools/exec/adapters/python/memfs.js +85 -0
  199. package/dist-lib/lib/tools/exec/adapters/python/output-policy.d.ts +13 -0
  200. package/dist-lib/lib/tools/exec/adapters/python/output-policy.js +129 -0
  201. package/dist-lib/lib/tools/exec/adapters/python/pyodide.d.ts +19 -0
  202. package/dist-lib/lib/tools/exec/adapters/python/pyodide.js +107 -0
  203. package/dist-lib/lib/tools/exec/adapters/python/python-adapter.d.ts +75 -0
  204. package/dist-lib/lib/tools/exec/adapters/python/python-adapter.js +1094 -0
  205. package/dist-lib/lib/tools/exec/adapters/python/run-session.d.ts +75 -0
  206. package/dist-lib/lib/tools/exec/adapters/python/run-session.js +273 -0
  207. package/dist-lib/lib/tools/exec/adapters/python/wheels.d.ts +38 -0
  208. package/dist-lib/lib/tools/exec/adapters/python/wheels.js +102 -0
  209. package/dist-lib/lib/tools/exec/adapters/python/worker/client.d.ts +7 -0
  210. package/dist-lib/lib/tools/exec/adapters/python/worker/client.js +188 -0
  211. package/dist-lib/lib/tools/exec/adapters/python/worker/entry.d.ts +1 -0
  212. package/dist-lib/lib/tools/exec/adapters/python/worker/entry.js +105 -0
  213. package/dist-lib/lib/tools/exec/adapters/python/worker/protocol.d.ts +38 -0
  214. package/dist-lib/lib/tools/exec/adapters/python/worker/protocol.js +41 -0
  215. package/dist-lib/lib/tools/exec/adapters/python/worker/spawn-bare.d.ts +2 -0
  216. package/dist-lib/lib/tools/exec/adapters/python/worker/spawn-bare.js +30 -0
  217. package/dist-lib/lib/tools/exec/adapters/python/worker/spawn-node.d.ts +13 -0
  218. package/dist-lib/lib/tools/exec/adapters/python/worker/spawn-node.js +45 -0
  219. package/dist-lib/lib/tools/exec/adapters/shell/shell-adapter.d.ts +12 -0
  220. package/dist-lib/lib/tools/exec/adapters/shell/shell-adapter.js +20 -0
  221. package/dist-lib/lib/tools/exec/obsidian/cli-process.d.ts +8 -0
  222. package/dist-lib/lib/tools/exec/obsidian/cli-process.js +74 -0
  223. package/dist-lib/lib/tools/exec/obsidian/cli.d.ts +18 -0
  224. package/dist-lib/lib/tools/exec/obsidian/cli.js +153 -0
  225. package/dist-lib/lib/tools/exec/obsidian/command.d.ts +5 -0
  226. package/dist-lib/lib/tools/exec/obsidian/command.js +18 -0
  227. package/dist-lib/lib/tools/exec/obsidian/guidance.d.ts +5 -0
  228. package/dist-lib/lib/tools/exec/obsidian/guidance.js +18 -0
  229. package/dist-lib/lib/tools/exec/obsidian/note-name.d.ts +1 -0
  230. package/dist-lib/lib/tools/exec/obsidian/note-name.js +6 -0
  231. package/dist-lib/lib/tools/exec/obsidian/output.d.ts +1 -0
  232. package/dist-lib/lib/tools/exec/obsidian/output.js +31 -0
  233. package/dist-lib/lib/tools/exec/obsidian/route.d.ts +19 -0
  234. package/dist-lib/lib/tools/exec/obsidian/route.js +85 -0
  235. package/dist-lib/lib/tools/exec/obsidian/safe-path.d.ts +3 -0
  236. package/dist-lib/lib/tools/exec/obsidian/safe-path.js +56 -0
  237. package/dist-lib/lib/tools/exec/obsidian/vault-create.d.ts +1 -0
  238. package/dist-lib/lib/tools/exec/obsidian/vault-create.js +40 -0
  239. package/dist-lib/lib/tools/exec/obsidian/vault-fs.d.ts +3 -0
  240. package/dist-lib/lib/tools/exec/obsidian/vault-fs.js +57 -0
  241. package/dist-lib/lib/tools/exec/obsidian/vault-paths.d.ts +20 -0
  242. package/dist-lib/lib/tools/exec/obsidian/vault-paths.js +171 -0
  243. package/dist-lib/lib/tools/exec/obsidian/vault-read.d.ts +11 -0
  244. package/dist-lib/lib/tools/exec/obsidian/vault-read.js +119 -0
  245. package/dist-lib/lib/tools/exec/obsidian/vault-write.d.ts +7 -0
  246. package/dist-lib/lib/tools/exec/obsidian/vault-write.js +134 -0
  247. package/dist-lib/lib/tools/exec/runner.d.ts +62 -0
  248. package/dist-lib/lib/tools/exec/runner.js +87 -0
  249. package/dist-lib/lib/tools/exec/scope.d.ts +3 -0
  250. package/dist-lib/lib/tools/exec/scope.js +97 -0
  251. package/dist-lib/lib/tools/exec/shell-argv.d.ts +2 -0
  252. package/dist-lib/lib/tools/exec/shell-argv.js +48 -0
  253. package/dist-lib/lib/tools/exec.d.ts +29 -0
  254. package/dist-lib/lib/tools/exec.js +459 -0
  255. package/dist-lib/lib/tools/file-glob.d.ts +15 -0
  256. package/dist-lib/lib/tools/file-glob.js +112 -0
  257. package/dist-lib/lib/tools/fs/drive.d.ts +26 -0
  258. package/dist-lib/lib/tools/fs/drive.js +1 -0
  259. package/dist-lib/lib/tools/fs/glob.d.ts +1 -0
  260. package/dist-lib/lib/tools/fs/glob.js +34 -0
  261. package/dist-lib/lib/tools/fs/local.d.ts +2 -0
  262. package/dist-lib/lib/tools/fs/local.js +29 -0
  263. package/dist-lib/lib/tools/fs/read.d.ts +2 -0
  264. package/dist-lib/lib/tools/fs/read.js +17 -0
  265. package/dist-lib/lib/tools/fs/remote-protocol.d.ts +40 -0
  266. package/dist-lib/lib/tools/fs/remote-protocol.js +1 -0
  267. package/dist-lib/lib/tools/fs/remote.d.ts +17 -0
  268. package/dist-lib/lib/tools/fs/remote.js +131 -0
  269. package/dist-lib/lib/tools/fs/scope.d.ts +37 -0
  270. package/dist-lib/lib/tools/fs/scope.js +130 -0
  271. package/dist-lib/lib/tools/fs/walk.d.ts +15 -0
  272. package/dist-lib/lib/tools/fs/walk.js +38 -0
  273. package/dist-lib/lib/tools/fs/write.d.ts +4 -0
  274. package/dist-lib/lib/tools/fs/write.js +5 -0
  275. package/dist-lib/lib/tools/generate-image.d.ts +111 -0
  276. package/dist-lib/lib/tools/generate-image.js +369 -0
  277. package/dist-lib/lib/tools/generate-music.d.ts +124 -0
  278. package/dist-lib/lib/tools/generate-music.js +522 -0
  279. package/dist-lib/lib/tools/grep.d.ts +5 -0
  280. package/dist-lib/lib/tools/grep.js +158 -0
  281. package/dist-lib/lib/tools/http-methods.d.ts +1 -0
  282. package/dist-lib/lib/tools/http-methods.js +1 -0
  283. package/dist-lib/lib/tools/http-request/encode-fields.d.ts +2 -0
  284. package/dist-lib/lib/tools/http-request/encode-fields.js +69 -0
  285. package/dist-lib/lib/tools/http-request/truncate-response.d.ts +1 -0
  286. package/dist-lib/lib/tools/http-request/truncate-response.js +83 -0
  287. package/dist-lib/lib/tools/http-request/utils.d.ts +27 -0
  288. package/dist-lib/lib/tools/http-request/utils.js +84 -0
  289. package/dist-lib/lib/tools/http-request.d.ts +20 -0
  290. package/dist-lib/lib/tools/http-request.js +177 -0
  291. package/dist-lib/lib/tools/mcp/utils.d.ts +47 -0
  292. package/dist-lib/lib/tools/mcp/utils.js +172 -0
  293. package/dist-lib/lib/tools/mcp-call.d.ts +14 -0
  294. package/dist-lib/lib/tools/mcp-call.js +155 -0
  295. package/dist-lib/lib/tools/model-args.d.ts +1 -0
  296. package/dist-lib/lib/tools/model-args.js +4 -0
  297. package/dist-lib/lib/tools/operations/builders.d.ts +17 -0
  298. package/dist-lib/lib/tools/operations/builders.js +179 -0
  299. package/dist-lib/lib/tools/operations/compile.d.ts +7 -0
  300. package/dist-lib/lib/tools/operations/compile.js +92 -0
  301. package/dist-lib/lib/tools/operations/gmail-message.d.ts +15 -0
  302. package/dist-lib/lib/tools/operations/gmail-message.js +62 -0
  303. package/dist-lib/lib/tools/operations/manifest.d.ts +60 -0
  304. package/dist-lib/lib/tools/operations/manifest.js +50 -0
  305. package/dist-lib/lib/tools/outbound-guard.d.ts +10 -0
  306. package/dist-lib/lib/tools/outbound-guard.js +127 -0
  307. package/dist-lib/lib/tools/private-ip.d.ts +4 -0
  308. package/dist-lib/lib/tools/private-ip.js +126 -0
  309. package/dist-lib/lib/tools/rag-search.d.ts +2 -0
  310. package/dist-lib/lib/tools/rag-search.js +98 -0
  311. package/dist-lib/lib/tools/read-files.d.ts +5 -0
  312. package/dist-lib/lib/tools/read-files.js +153 -0
  313. package/dist-lib/lib/tools/skill.d.ts +10 -0
  314. package/dist-lib/lib/tools/skill.js +123 -0
  315. package/dist-lib/lib/tools/skills/auth-resolver.d.ts +43 -0
  316. package/dist-lib/lib/tools/skills/auth-resolver.js +121 -0
  317. package/dist-lib/lib/tools/skills/bin-check.d.ts +9 -0
  318. package/dist-lib/lib/tools/skills/bin-check.js +56 -0
  319. package/dist-lib/lib/tools/skills/bundled-dir.d.ts +2 -0
  320. package/dist-lib/lib/tools/skills/bundled-dir.js +117 -0
  321. package/dist-lib/lib/tools/skills/bundled-hash.d.ts +4 -0
  322. package/dist-lib/lib/tools/skills/bundled-hash.js +12 -0
  323. package/dist-lib/lib/tools/skills/catalog.d.ts +60 -0
  324. package/dist-lib/lib/tools/skills/catalog.js +203 -0
  325. package/dist-lib/lib/tools/skills/cli-argv.d.ts +9 -0
  326. package/dist-lib/lib/tools/skills/cli-argv.js +147 -0
  327. package/dist-lib/lib/tools/skills/cli-schema-check.d.ts +3 -0
  328. package/dist-lib/lib/tools/skills/cli-schema-check.js +62 -0
  329. package/dist-lib/lib/tools/skills/cli-schema-load.d.ts +4 -0
  330. package/dist-lib/lib/tools/skills/cli-schema-load.js +90 -0
  331. package/dist-lib/lib/tools/skills/cli-schema-types.d.ts +30 -0
  332. package/dist-lib/lib/tools/skills/cli-schema-types.js +1 -0
  333. package/dist-lib/lib/tools/skills/cli-schema.d.ts +7 -0
  334. package/dist-lib/lib/tools/skills/cli-schema.js +35 -0
  335. package/dist-lib/lib/tools/skills/credential-check.d.ts +20 -0
  336. package/dist-lib/lib/tools/skills/credential-check.js +94 -0
  337. package/dist-lib/lib/tools/skills/credential-grants.d.ts +9 -0
  338. package/dist-lib/lib/tools/skills/credential-grants.js +25 -0
  339. package/dist-lib/lib/tools/skills/credential-health.d.ts +8 -0
  340. package/dist-lib/lib/tools/skills/credential-health.js +51 -0
  341. package/dist-lib/lib/tools/skills/credential-slots.d.ts +7 -0
  342. package/dist-lib/lib/tools/skills/credential-slots.js +8 -0
  343. package/dist-lib/lib/tools/skills/frontmatter-parser.d.ts +23 -0
  344. package/dist-lib/lib/tools/skills/frontmatter-parser.js +68 -0
  345. package/dist-lib/lib/tools/skills/index.d.ts +5 -0
  346. package/dist-lib/lib/tools/skills/index.js +5 -0
  347. package/dist-lib/lib/tools/skills/manifest-parse.d.ts +12 -0
  348. package/dist-lib/lib/tools/skills/manifest-parse.js +199 -0
  349. package/dist-lib/lib/tools/skills/manifest.d.ts +47 -0
  350. package/dist-lib/lib/tools/skills/manifest.js +1 -0
  351. package/dist-lib/lib/tools/skills/mention-name.d.ts +1 -0
  352. package/dist-lib/lib/tools/skills/mention-name.js +4 -0
  353. package/dist-lib/lib/tools/skills/mention.d.ts +6 -0
  354. package/dist-lib/lib/tools/skills/mention.js +42 -0
  355. package/dist-lib/lib/tools/skills/obsidian-readiness.d.ts +16 -0
  356. package/dist-lib/lib/tools/skills/obsidian-readiness.js +95 -0
  357. package/dist-lib/lib/tools/skills/overlay-crud.d.ts +18 -0
  358. package/dist-lib/lib/tools/skills/overlay-crud.js +98 -0
  359. package/dist-lib/lib/tools/skills/overlay-dir.d.ts +2 -0
  360. package/dist-lib/lib/tools/skills/overlay-dir.js +22 -0
  361. package/dist-lib/lib/tools/skills/overlay-watch.d.ts +13 -0
  362. package/dist-lib/lib/tools/skills/overlay-watch.js +44 -0
  363. package/dist-lib/lib/tools/skills/scope-key.d.ts +7 -0
  364. package/dist-lib/lib/tools/skills/scope-key.js +7 -0
  365. package/dist-lib/lib/tools/skills/setup-routes.d.ts +4 -0
  366. package/dist-lib/lib/tools/skills/setup-routes.js +14 -0
  367. package/dist-lib/lib/tools/skills/skill-settings.d.ts +16 -0
  368. package/dist-lib/lib/tools/skills/skill-settings.js +33 -0
  369. package/dist-lib/lib/tools/skills/skill-state-constants.d.ts +12 -0
  370. package/dist-lib/lib/tools/skills/skill-state-constants.js +14 -0
  371. package/dist-lib/lib/tools/skills/skill-state.d.ts +40 -0
  372. package/dist-lib/lib/tools/skills/skill-state.js +117 -0
  373. package/dist-lib/lib/tools/skills/tool-grants.d.ts +5 -0
  374. package/dist-lib/lib/tools/skills/tool-grants.js +14 -0
  375. package/dist-lib/lib/tools/toolsets.d.ts +8 -0
  376. package/dist-lib/lib/tools/toolsets.js +20 -0
  377. package/dist-lib/lib/tools/url-guard.d.ts +8 -0
  378. package/dist-lib/lib/tools/url-guard.js +40 -0
  379. package/dist-lib/lib/tools/web-fetch.d.ts +8 -0
  380. package/dist-lib/lib/tools/web-fetch.js +302 -0
  381. package/dist-lib/lib/tools/web-search.d.ts +6 -0
  382. package/dist-lib/lib/tools/web-search.js +55 -0
  383. package/dist-lib/lib/transport.d.ts +12 -0
  384. package/dist-lib/lib/transport.js +59 -0
  385. package/dist-lib/lib/user-agent.d.ts +1 -0
  386. package/dist-lib/lib/user-agent.js +1 -0
  387. package/dist-lib/lib/validating-lookup.d.ts +17 -0
  388. package/dist-lib/lib/validating-lookup.js +25 -0
  389. package/dist-lib/lib/wav-encode.d.ts +5 -0
  390. package/dist-lib/lib/wav-encode.js +24 -0
  391. package/dist-lib/lib/web-fetch/embedded-state.d.ts +1 -0
  392. package/dist-lib/lib/web-fetch/embedded-state.js +131 -0
  393. package/dist-lib/lib/web-fetch/extract.d.ts +6 -0
  394. package/dist-lib/lib/web-fetch/extract.js +65 -0
  395. package/dist-lib/lib/web-fetch/images.d.ts +3 -0
  396. package/dist-lib/lib/web-fetch/images.js +43 -0
  397. package/dist-lib/lib/web-fetch/video.d.ts +5 -0
  398. package/dist-lib/lib/web-fetch/video.js +42 -0
  399. package/dist-lib/lib/web-search/engine-registry.d.ts +7 -0
  400. package/dist-lib/lib/web-search/engine-registry.js +17 -0
  401. package/dist-lib/lib/web-search/engines/aol.d.ts +3 -0
  402. package/dist-lib/lib/web-search/engines/aol.js +81 -0
  403. package/dist-lib/lib/web-search/engines/bing.d.ts +3 -0
  404. package/dist-lib/lib/web-search/engines/bing.js +111 -0
  405. package/dist-lib/lib/web-search/engines/brave.d.ts +3 -0
  406. package/dist-lib/lib/web-search/engines/brave.js +59 -0
  407. package/dist-lib/lib/web-search/engines/duckduckgo.d.ts +3 -0
  408. package/dist-lib/lib/web-search/engines/duckduckgo.js +112 -0
  409. package/dist-lib/lib/web-search/engines/google.d.ts +3 -0
  410. package/dist-lib/lib/web-search/engines/google.js +92 -0
  411. package/dist-lib/lib/web-search/engines/wikipedia.d.ts +3 -0
  412. package/dist-lib/lib/web-search/engines/wikipedia.js +37 -0
  413. package/dist-lib/lib/web-search/engines/yahoo.d.ts +3 -0
  414. package/dist-lib/lib/web-search/engines/yahoo.js +81 -0
  415. package/dist-lib/lib/web-search/fetch-html.d.ts +25 -0
  416. package/dist-lib/lib/web-search/fetch-html.js +97 -0
  417. package/dist-lib/lib/web-search/format-results.d.ts +3 -0
  418. package/dist-lib/lib/web-search/format-results.js +14 -0
  419. package/dist-lib/lib/web-search/html-helpers.d.ts +3 -0
  420. package/dist-lib/lib/web-search/html-helpers.js +24 -0
  421. package/dist-lib/lib/web-search/merge-results.d.ts +2 -0
  422. package/dist-lib/lib/web-search/merge-results.js +53 -0
  423. package/dist-lib/lib/web-search/orchestrator.d.ts +14 -0
  424. package/dist-lib/lib/web-search/orchestrator.js +50 -0
  425. package/dist-lib/lib/web-search/types.d.ts +34 -0
  426. package/dist-lib/lib/web-search/types.js +1 -0
  427. package/dist-lib/lib/web-search/url-helpers.d.ts +1 -0
  428. package/dist-lib/lib/web-search/url-helpers.js +11 -0
  429. package/dist-lib/lib/web-search/url-normalize.d.ts +1 -0
  430. package/dist-lib/lib/web-search/url-normalize.js +25 -0
  431. package/dist-lib/lib/web-search/user-agents.d.ts +3 -0
  432. package/dist-lib/lib/web-search/user-agents.js +3 -0
  433. package/dist-lib/lib/wire.d.ts +50 -0
  434. package/dist-lib/lib/wire.js +145 -0
  435. package/dist-lib/schema/baseline.d.ts +8 -0
  436. package/dist-lib/schema/baseline.js +35 -0
  437. package/dist-lib/schema/build.d.ts +1 -0
  438. package/dist-lib/schema/build.js +39 -0
  439. package/dist-lib/schema/generate.d.ts +20 -0
  440. package/dist-lib/schema/generate.js +149 -0
  441. package/dist-lib/schema/harness.d.ts +2 -0
  442. package/dist-lib/schema/harness.js +745 -0
  443. package/dist-lib/schema/release-tags.d.ts +5 -0
  444. package/dist-lib/schema/release-tags.js +58 -0
  445. package/dist-lib/spec/bind.d.ts +2 -0
  446. package/dist-lib/spec/bind.js +124 -0
  447. package/dist-lib/spec/calls.d.ts +3 -0
  448. package/dist-lib/spec/calls.js +41 -0
  449. package/dist-lib/spec/hrpc/hrpc.json +356 -0
  450. package/dist-lib/spec/hrpc/index.d.ts +3 -0
  451. package/dist-lib/spec/hrpc/index.js +463 -0
  452. package/dist-lib/spec/hrpc/messages.d.ts +4 -0
  453. package/dist-lib/spec/hrpc/messages.js +3102 -0
  454. package/dist-lib/spec/hyperschema/index.js +3102 -0
  455. package/dist-lib/spec/hyperschema/schema.json +2290 -0
  456. package/dist-lib/spec/hyperschema/types.d.ts +554 -0
  457. package/dist-lib/spec/index.d.ts +8 -0
  458. package/dist-lib/spec/index.js +1 -0
  459. package/package.json +239 -64
  460. package/.gitattributes +0 -1
@@ -0,0 +1,789 @@
1
+ import EventEmitter from 'events';
2
+ import fs from 'fs';
3
+ import { settleOnClose } from "./rpc-session.js";
4
+ import { harnessClient } from '../spec/calls.js';
5
+ import HRPC from '../spec/hrpc/index.js';
6
+ import { unsupportedKvCacheDeletion } from "./capabilities/kv-cache.js";
7
+ import { hlog } from "./log.js";
8
+ import { assertEmbedDevice } from "./models/embed-config.js";
9
+ import { errorCode, errorMessage } from "./error-fields.js";
10
+ import { pushQueue } from "./queue.js";
11
+ import { stageFile, sweepStaging } from "./staging.js";
12
+ import { readInstall, readSetup } from "./tools/skills/manifest-parse.js";
13
+ import { SKILL_STATE } from "./tools/skills/skill-state.js";
14
+ import { asToolset } from "./tools/toolsets.js";
15
+ import { fromDownloadWire, fromWire, unpackVectors } from "./wire.js";
16
+ export const HARNESS_DIED = 'HARNESS_DIED';
17
+ export function connectHarness(transport) {
18
+ return new RemoteHarness(transport);
19
+ }
20
+ export function readEmbeddingDeviceResponse(response) {
21
+ const device = typeof response === 'object' && response !== null ? Reflect.get(response, 'device') : undefined;
22
+ if (typeof device !== 'string')
23
+ throw new Error('invalid embedding device response');
24
+ assertEmbedDevice(device);
25
+ return device;
26
+ }
27
+ export class RemoteHarness extends EventEmitter {
28
+ _transport;
29
+ _session = null;
30
+ _opening = null;
31
+ _closed = false;
32
+ _customModels = [];
33
+ constructor(transport) {
34
+ super();
35
+ this._transport = transport;
36
+ }
37
+ _ensure() {
38
+ if (this._closed)
39
+ return Promise.reject(died('harness closed'));
40
+ if (this._session) {
41
+ return this._session.dead
42
+ ? Promise.reject(died('harness is dead'))
43
+ : Promise.resolve(this._session);
44
+ }
45
+ this._opening ??= this._open();
46
+ return this._opening;
47
+ }
48
+ async _open() {
49
+ sweepStaging();
50
+ let stream;
51
+ try {
52
+ stream = await this._transport();
53
+ }
54
+ catch (err) {
55
+ const details = errorDetails(err);
56
+ this.emit('status', { state: 'died', ...details });
57
+ throw died(`harness failed to open: ${details.error}`);
58
+ }
59
+ if (this._closed) {
60
+ stream.destroy();
61
+ throw died('harness closed');
62
+ }
63
+ const session = {
64
+ client: harnessClient(settleOnClose(new HRPC(stream))),
65
+ stream,
66
+ dead: false
67
+ };
68
+ let streamError = null;
69
+ stream.on('error', (err) => {
70
+ streamError = err;
71
+ });
72
+ stream.on('close', () => {
73
+ session.dead = true;
74
+ if (this._closed)
75
+ return;
76
+ this.emit('status', streamError ? { state: 'died', ...errorDetails(streamError) } : { state: 'died' });
77
+ });
78
+ this._session = session;
79
+ this.emit('status', { state: 'running' });
80
+ const models = session.client.modelEvents({});
81
+ models.on('data', (state) => this.emit('model', state));
82
+ models.on('error', noop);
83
+ if (this._customModels.length) {
84
+ try {
85
+ await session.client.setCustomModels({ models: this._customModels });
86
+ }
87
+ catch (err) {
88
+ hlog('custom model restore failed', { message: errorMessage(err) });
89
+ }
90
+ }
91
+ return session;
92
+ }
93
+ async *completion(context) {
94
+ const { client } = await this._ensure();
95
+ let duplex = null;
96
+ let emittedAborted = false;
97
+ const staged = [];
98
+ let closed = false;
99
+ let received = 0;
100
+ const reclaim = () => {
101
+ while (staged.length)
102
+ void fs.promises.unlink(staged.pop()).catch(noop);
103
+ };
104
+ const onAbort = () => duplex?.destroy();
105
+ try {
106
+ duplex = client.completion();
107
+ duplex.write({
108
+ type: 'start',
109
+ model: context.model,
110
+ agent: knobs(context.agent),
111
+ cacheKey: context.cacheKey,
112
+ thinkingDefault: context.thinkingDefault,
113
+ generationParams: context.generationParams,
114
+ responseFormat: context.responseFormat,
115
+ messages: context.messages.map(({ role, content, attachments }) => ({
116
+ role,
117
+ content,
118
+ attachments: attachments?.map(({ path: file }) => ({ path: file }))
119
+ })),
120
+ toolConfigs: context.toolConfigs,
121
+ grantedDirs: context.grantedDirs,
122
+ grantedDrives: context.grantedDrives,
123
+ grantedWriteDirs: context.grantedWriteDirs
124
+ });
125
+ if (context.signal?.aborted) {
126
+ duplex.destroy();
127
+ yield { type: 'aborted' };
128
+ return;
129
+ }
130
+ context.signal?.addEventListener?.('abort', onAbort, { once: true });
131
+ hlog('client wire open', { model: context.model });
132
+ for await (const event of frames(duplex)) {
133
+ received++;
134
+ if (event.type !== 'content' && event.type !== 'thinking') {
135
+ hlog('client frame', { type: event.type, n: received });
136
+ }
137
+ if (event.type === 'done')
138
+ break;
139
+ if (event.type === 'approval-ask') {
140
+ const callId = event.callId;
141
+ void Promise.resolve()
142
+ .then(() => context.approve?.({
143
+ name: event.name ?? '',
144
+ arguments: (event.arguments ?? {}),
145
+ resource: event.resource ?? null,
146
+ effect: event.effect === 'read' ? 'read' : 'write',
147
+ intent: event.intent || null,
148
+ display: event.display ?? null
149
+ }))
150
+ .then((approved) => {
151
+ if (!closed) {
152
+ duplex.write({ type: 'decision', callId, approved: approved === true });
153
+ }
154
+ }, () => {
155
+ if (!closed) {
156
+ duplex.write({ type: 'decision', callId, approved: false });
157
+ }
158
+ })
159
+ .catch((err) => hlog('approval reply failed', { callId, message: errorMessage(err) }));
160
+ continue;
161
+ }
162
+ if (event.type === 'attach-ask') {
163
+ const callId = event.callId;
164
+ void bridgeAttach(event, context.attach)
165
+ .then((frame) => {
166
+ if (!closed)
167
+ duplex.write({ ...frame, callId });
168
+ }, (err) => {
169
+ if (!closed) {
170
+ duplex.write({
171
+ type: 'attach-result',
172
+ callId,
173
+ message: errorMessage(err)
174
+ });
175
+ }
176
+ })
177
+ .catch((err) => hlog('attach reply failed', { callId, message: errorMessage(err) }));
178
+ continue;
179
+ }
180
+ if (event.type === 'fetch-ask') {
181
+ const callId = event.callId;
182
+ void bridgeFetch(event, context, staged)
183
+ .then((frame) => {
184
+ if (closed)
185
+ return reclaim();
186
+ duplex.write({ ...frame, callId });
187
+ }, (err) => {
188
+ if (closed)
189
+ return reclaim();
190
+ duplex.write({ type: 'fetch-result', callId, message: errorMessage(err) });
191
+ })
192
+ .catch((err) => hlog('fetch reply failed', { callId, message: errorMessage(err) }));
193
+ continue;
194
+ }
195
+ if (event.type === 'drive-ask') {
196
+ const callId = event.callId;
197
+ void bridgeDrive(event, context)
198
+ .then((frame) => {
199
+ if (!closed)
200
+ return duplex.write({ ...frame, callId });
201
+ const stagedPath = frame.payload?.path;
202
+ if (stagedPath)
203
+ void fs.promises.unlink(stagedPath).catch(noop);
204
+ }, (err) => {
205
+ if (!closed) {
206
+ duplex.write({
207
+ type: 'drive-result',
208
+ callId,
209
+ message: errorMessage(err)
210
+ });
211
+ }
212
+ })
213
+ .catch((err) => hlog('drive reply failed', { callId, message: errorMessage(err) }));
214
+ continue;
215
+ }
216
+ if (event.type === 'rag-ask') {
217
+ const callId = event.callId;
218
+ void bridgeRag(event, context)
219
+ .then((frame) => {
220
+ if (!closed)
221
+ duplex.write({ ...frame, callId });
222
+ }, (err) => {
223
+ if (!closed) {
224
+ duplex.write({
225
+ type: 'rag-result',
226
+ callId,
227
+ message: errorMessage(err)
228
+ });
229
+ }
230
+ })
231
+ .catch((err) => hlog('rag reply failed', { callId, message: errorMessage(err) }));
232
+ continue;
233
+ }
234
+ if (event.type === 'question-ask') {
235
+ const callId = event.callId;
236
+ const askUser = context.askUser;
237
+ if (!askUser) {
238
+ if (!closed) {
239
+ duplex.write({
240
+ type: 'question-result',
241
+ callId,
242
+ message: 'the host cannot ask questions'
243
+ });
244
+ }
245
+ continue;
246
+ }
247
+ void Promise.resolve()
248
+ .then(() => askUser({
249
+ question: event.question ?? '',
250
+ ...(Array.isArray(event.options)
251
+ ? { options: event.options.map(String) }
252
+ : {})
253
+ }))
254
+ .then((answer) => {
255
+ if (!closed) {
256
+ duplex.write({ type: 'question-result', callId, answer: answer ?? '' });
257
+ }
258
+ }, (err) => {
259
+ if (!closed) {
260
+ duplex.write({
261
+ type: 'question-result',
262
+ callId,
263
+ message: errorMessage(err)
264
+ });
265
+ }
266
+ })
267
+ .catch((err) => hlog('question reply failed', { callId, message: errorMessage(err) }));
268
+ continue;
269
+ }
270
+ if (event.type === 'progress') {
271
+ context.progress?.(event.cleared ? null : { percentage: event.percentage ?? 0 });
272
+ continue;
273
+ }
274
+ const wire = fromWire(event);
275
+ if (wire.type === 'aborted')
276
+ emittedAborted = true;
277
+ yield wire;
278
+ }
279
+ hlog('client wire ended', { received });
280
+ }
281
+ catch (err) {
282
+ if (context.signal?.aborted) {
283
+ if (!emittedAborted)
284
+ yield { type: 'aborted' };
285
+ return;
286
+ }
287
+ throw died(`harness died mid-run: ${err.message}`);
288
+ }
289
+ finally {
290
+ hlog('client completion end', { received, aborted: Boolean(context.signal?.aborted) });
291
+ context.signal?.removeEventListener?.('abort', onAbort);
292
+ duplex?.destroy();
293
+ closed = true;
294
+ reclaim();
295
+ }
296
+ if (context.signal?.aborted && !emittedAborted)
297
+ yield { type: 'aborted' };
298
+ }
299
+ async *download(context) {
300
+ const { client } = await this._ensure();
301
+ let stream = null;
302
+ let emittedAborted = false;
303
+ const onAbort = () => stream?.destroy();
304
+ try {
305
+ stream = client.download({
306
+ model: context.model,
307
+ addon: context.addon,
308
+ seed: context.seed
309
+ });
310
+ if (context.signal?.aborted) {
311
+ stream.destroy();
312
+ yield { type: 'aborted' };
313
+ return;
314
+ }
315
+ context.signal?.addEventListener?.('abort', onAbort, { once: true });
316
+ for await (const event of downloadFrames(stream)) {
317
+ const wire = fromDownloadWire(event);
318
+ if (wire.type === 'aborted')
319
+ emittedAborted = true;
320
+ yield wire;
321
+ }
322
+ }
323
+ catch (err) {
324
+ if (context.signal?.aborted) {
325
+ if (!emittedAborted)
326
+ yield { type: 'aborted' };
327
+ return;
328
+ }
329
+ throw died(`harness died mid-download: ${err.message}`);
330
+ }
331
+ finally {
332
+ context.signal?.removeEventListener?.('abort', onAbort);
333
+ stream?.destroy();
334
+ }
335
+ if (context.signal?.aborted && !emittedAborted)
336
+ yield { type: 'aborted' };
337
+ }
338
+ async embed(context) {
339
+ const { client } = await this._ensure();
340
+ const response = await abortable(client.embed({ model: context.model, texts: context.texts }), context.signal);
341
+ const rows = unpackVectors(response.dimensions, response.vectors);
342
+ if (rows.length !== context.texts.length) {
343
+ throw new Error(`embed returned ${rows.length} vectors for ${context.texts.length} texts`);
344
+ }
345
+ return rows;
346
+ }
347
+ async transcribe(context) {
348
+ const { client } = await this._ensure();
349
+ const response = await abortable(client.transcribe({ model: context.model, audio: context.audio }), context.signal);
350
+ return response.text;
351
+ }
352
+ async speak(context) {
353
+ const { client } = await this._ensure();
354
+ const response = await abortable(client.speak({ model: context.model, text: context.text }), context.signal);
355
+ return { audio: response.audio, sampleRate: response.sampleRate };
356
+ }
357
+ async *speakStream(context) {
358
+ const { client } = await this._ensure();
359
+ const duplex = client.speakStream();
360
+ const pump = (async () => {
361
+ try {
362
+ for await (const fragment of context.text)
363
+ duplex.write({ text: fragment });
364
+ duplex.end();
365
+ }
366
+ catch {
367
+ duplex.destroy();
368
+ }
369
+ })();
370
+ try {
371
+ for await (const frame of frames(duplex)) {
372
+ const chunk = frame;
373
+ yield { audio: chunk.audio, sampleRate: chunk.sampleRate };
374
+ }
375
+ }
376
+ finally {
377
+ await pump.catch(() => { });
378
+ }
379
+ }
380
+ async getEmbeddingDevice() {
381
+ const { client } = await this._ensure();
382
+ return readEmbeddingDeviceResponse(await client.getEmbeddingDevice({}));
383
+ }
384
+ async setEmbeddingDevice(device) {
385
+ const { client } = await this._ensure();
386
+ await client.setEmbeddingDevice({ device });
387
+ }
388
+ async setCredentials(entries) {
389
+ const { client } = await this._ensure();
390
+ await client.setCredentials({ entries });
391
+ }
392
+ async setSkillSettings(entries) {
393
+ const { client } = await this._ensure();
394
+ await client.setSkillSettings({ entries });
395
+ }
396
+ async listManagedSkills() {
397
+ const { client } = await this._ensure();
398
+ const response = await client.listManagedSkills({});
399
+ return (response.skills ?? []).map((s) => ({
400
+ name: s.name,
401
+ origin: s.origin === 'overlay' ? 'overlay' : 'base',
402
+ overridesBase: s.overridesBase === true
403
+ }));
404
+ }
405
+ async readSkillFile(name) {
406
+ const { client } = await this._ensure();
407
+ const response = await client.readSkillFile({ name });
408
+ return response?.found
409
+ ? {
410
+ content: response.content ?? '',
411
+ origin: response.origin === 'overlay' ? 'overlay' : 'base'
412
+ }
413
+ : null;
414
+ }
415
+ async writeSkillFile(name, content) {
416
+ const { client } = await this._ensure();
417
+ const response = await client.writeSkillFile({ name, content });
418
+ return { ok: response?.ok === true };
419
+ }
420
+ async copyBaseForEdit(name) {
421
+ const { client } = await this._ensure();
422
+ const response = await client.copySkillForEdit({ name });
423
+ return { copied: response?.copied === true };
424
+ }
425
+ async deleteOverlaySkill(name) {
426
+ const { client } = await this._ensure();
427
+ const response = await client.deleteOverlaySkill({ name });
428
+ return { removed: response?.removed === true };
429
+ }
430
+ async setCustomModels(entries) {
431
+ this._customModels = entries;
432
+ const { client } = await this._ensure();
433
+ await client.setCustomModels({ models: entries });
434
+ }
435
+ async skills(agentId, modelName, options) {
436
+ const { client } = await this._ensure();
437
+ const response = await client.skills({
438
+ agentId: agentId ?? undefined,
439
+ modelName: modelName ?? undefined,
440
+ refresh: options?.refresh === true,
441
+ skipCredentialProbe: options?.skipCredentialProbe === true
442
+ });
443
+ return (response.skills ?? []).map((skill) => {
444
+ const install = readInstall(skill.install);
445
+ const setup = readSetup(skill.setupV2 ?? skill.setup);
446
+ const binaries = skill.requirements?.binaries ?? [];
447
+ const binMinVersions = Object.fromEntries(binaries.flatMap((binary) => {
448
+ const minVersion = binary.minVersion;
449
+ return minVersion
450
+ ? [
451
+ [
452
+ binary.bin,
453
+ {
454
+ min: minVersion,
455
+ ...(binary.command ? { command: binary.command } : {})
456
+ }
457
+ ]
458
+ ]
459
+ : [];
460
+ }));
461
+ return {
462
+ name: skill.name,
463
+ description: skill.description,
464
+ tools: skill.tools ?? [],
465
+ credentials: skill.credentials ?? [],
466
+ allowList: skill.allowList ?? [],
467
+ platform: skill.platforms ?? [],
468
+ status: parseSkillState(skill.status),
469
+ ...(skill.requirements
470
+ ? {
471
+ requires: {
472
+ bins: binaries.map((binary) => binary.bin),
473
+ ...(skill.requirements?.credentials?.length
474
+ ? { credentials: skill.requirements.credentials }
475
+ : {}),
476
+ ...(Object.keys(binMinVersions).length > 0 ? { binMinVersions } : {})
477
+ }
478
+ }
479
+ : {}),
480
+ ...(install ? { install } : {}),
481
+ ...(setup ? { setup } : {}),
482
+ ...(skill.stub === true ? { stub: true } : {}),
483
+ ...(skill.minCapabilityProfile ? { minCapabilityProfile: skill.minCapabilityProfile } : {}),
484
+ ...(skill.emoji ? { emoji: skill.emoji } : {})
485
+ };
486
+ });
487
+ }
488
+ async tools() {
489
+ const { client } = await this._ensure();
490
+ const response = await client.tools({});
491
+ return (response.tools ?? []).map((tool) => ({
492
+ name: tool.name,
493
+ description: tool.description,
494
+ skillGated: tool.skillGated === true,
495
+ scopeRequired: tool.scopeRequired === true,
496
+ toolset: asToolset(tool.toolset),
497
+ rootsRequired: tool.rootsRequired === true,
498
+ writeRootsRequired: tool.writeRootsRequired === true,
499
+ promptChars: tool.promptChars ?? 0
500
+ }));
501
+ }
502
+ async warmModel(context) {
503
+ const { client } = await this._ensure();
504
+ await abortable(client.warmModel({
505
+ model: context.model,
506
+ ...(context.agent ? { agent: knobs(context.agent) } : {})
507
+ }), context.signal);
508
+ }
509
+ async list(options = {}) {
510
+ const { client } = await this._ensure();
511
+ const response = (await client.listModels({
512
+ type: options.type,
513
+ cachedOnly: options.cachedOnly,
514
+ fullRegistry: options.fullRegistry
515
+ }));
516
+ return (response.models ?? []).map(({ actualSize, ...row }) => ({
517
+ ...row,
518
+ ...(actualSize ? { actualSize } : {})
519
+ }));
520
+ }
521
+ async deleteModel(name) {
522
+ const { client } = await this._ensure();
523
+ const response = (await client.deleteModel({ name }));
524
+ return { name: response.name, removed: response.removed, freedBytes: response.freedBytes };
525
+ }
526
+ async clearKvCache() {
527
+ try {
528
+ const { client } = await this._ensure();
529
+ const info = await client.describe({});
530
+ if (info.supportsKvCacheDeletion !== true)
531
+ return unsupportedKvCacheDeletion();
532
+ const response = await client.clearKvCache({});
533
+ if (response.status === 'success')
534
+ return { status: 'success' };
535
+ if (response.status === 'failure') {
536
+ return { status: 'failure', error: response.error ?? 'Harness cache deletion failed' };
537
+ }
538
+ return unsupportedKvCacheDeletion(response.error ?? undefined);
539
+ }
540
+ catch (error) {
541
+ return {
542
+ status: 'failure',
543
+ error: error instanceof Error ? error.message : String(error)
544
+ };
545
+ }
546
+ }
547
+ async infraModels(profile) {
548
+ const { client } = await this._ensure();
549
+ const response = (await client.infraModels({ profile }));
550
+ return response.models ?? [];
551
+ }
552
+ async capability() {
553
+ const { client } = await this._ensure();
554
+ const response = await client.capability({});
555
+ const memoryBudget = response.memoryBudget;
556
+ return {
557
+ capabilityProfile: response.capabilityProfile,
558
+ recommendedModelName: response.recommendedModelName,
559
+ ...(memoryBudget
560
+ ? {
561
+ memoryBudget: {
562
+ totalBytes: memoryBudget.totalBytes,
563
+ availableBytes: memoryBudget.availableBytes,
564
+ source: memoryBudget.source,
565
+ ...(memoryBudget.gpuClass ? { gpuClass: memoryBudget.gpuClass } : {})
566
+ }
567
+ }
568
+ : {})
569
+ };
570
+ }
571
+ close() {
572
+ this._closed = true;
573
+ this._session?.stream.destroy();
574
+ }
575
+ async describe() {
576
+ const { client } = await this._ensure();
577
+ const describe = client.describe;
578
+ if (!describe)
579
+ return null;
580
+ const info = await describe.call(client, {});
581
+ return {
582
+ toolNames: info?.toolNames ?? [],
583
+ skills: info?.skills ?? [],
584
+ supportsImages: info?.supportsImages ?? false,
585
+ supportsKvCacheDeletion: info?.supportsKvCacheDeletion ?? false
586
+ };
587
+ }
588
+ async fetchDiagnostics() {
589
+ const session = this._session;
590
+ if (!session || session.dead)
591
+ return null;
592
+ const client = session.client;
593
+ const diagnostics = client.diagnostics;
594
+ if (!diagnostics)
595
+ return null;
596
+ const snapshot = await diagnostics.call(client, {});
597
+ const device = snapshot?.device;
598
+ return {
599
+ models: (snapshot?.models ?? []).map((row) => ({ model: row.model, refs: row.refs })),
600
+ suspended: snapshot?.suspended ?? false,
601
+ sdkLoaded: snapshot?.sdkLoaded ?? false,
602
+ toolNames: snapshot?.toolNames ?? [],
603
+ skills: snapshot?.skills ?? [],
604
+ ...(device ? { device } : {})
605
+ };
606
+ }
607
+ }
608
+ function parseSkillState(value) {
609
+ return value ? value : SKILL_STATE.failed;
610
+ }
611
+ function errorDetails(err) {
612
+ return { error: errorMessage(err), code: errorCode(err) };
613
+ }
614
+ function died(message) {
615
+ const err = new Error(message);
616
+ err.code = HARNESS_DIED;
617
+ return err;
618
+ }
619
+ const noop = () => { };
620
+ function abortable(promise, signal) {
621
+ if (!signal)
622
+ return promise;
623
+ return new Promise((resolve, reject) => {
624
+ if (signal.aborted) {
625
+ promise.then(noop, noop);
626
+ reject(new Error('embed aborted'));
627
+ return;
628
+ }
629
+ const onAbort = () => reject(new Error('embed aborted'));
630
+ signal.addEventListener?.('abort', onAbort, { once: true });
631
+ promise.then(resolve, reject).finally(() => signal.removeEventListener?.('abort', onAbort));
632
+ });
633
+ }
634
+ function knobs(agent) {
635
+ return {
636
+ id: agent.id,
637
+ name: agent.name,
638
+ bio: agent.bio,
639
+ reasoning: agent.reasoning ?? undefined,
640
+ enabledTools: agent.enabledTools ?? undefined,
641
+ enabledSkills: agent.enabledSkills ?? undefined,
642
+ toolsScope: agent.toolsScope ?? undefined,
643
+ skillsScope: agent.skillsScope ?? undefined,
644
+ ctxSize: agent.ctxSize ?? undefined,
645
+ kvCacheK: agent.kvCacheK ?? undefined,
646
+ kvCacheV: agent.kvCacheV ?? undefined,
647
+ imageModelChoice: agent.imageModelChoice ?? undefined,
648
+ imageSteps: agent.imageSteps ?? undefined,
649
+ imageWidth: agent.imageWidth ?? undefined,
650
+ imageHeight: agent.imageHeight ?? undefined,
651
+ approvalMode: agent.approvalMode ?? undefined,
652
+ disabledToolsets: agent.disabledToolsets ?? undefined
653
+ };
654
+ }
655
+ async function bridgeAttach(event, attach) {
656
+ try {
657
+ if (!attach)
658
+ return { type: 'attach-result', message: 'the host cannot persist attachments' };
659
+ const bytes = await fs.promises.readFile(event.path ?? '');
660
+ const record = await attach({
661
+ fileName: event.fileName ?? '',
662
+ mimeType: event.mimeType ?? '',
663
+ bytes,
664
+ raw: event.raw === true
665
+ });
666
+ return {
667
+ type: 'attach-result',
668
+ attachment: {
669
+ id: record.id,
670
+ fileName: record.fileName,
671
+ mimeType: record.mimeType,
672
+ byteLength: record.byteLength
673
+ }
674
+ };
675
+ }
676
+ catch (err) {
677
+ return { type: 'attach-result', message: err.message };
678
+ }
679
+ finally {
680
+ if (event.path)
681
+ void fs.promises.unlink(event.path).catch(noop);
682
+ }
683
+ }
684
+ async function bridgeFetch(event, context, staged) {
685
+ if (!context.fetchAttachment) {
686
+ return { type: 'fetch-result', message: 'the host cannot read attachments' };
687
+ }
688
+ try {
689
+ const metaOnly = event.meta === true;
690
+ const found = await context.fetchAttachment({
691
+ attachmentId: event.attachmentId ?? undefined,
692
+ ...(metaOnly ? { meta: true } : {}),
693
+ signal: context.signal
694
+ });
695
+ if (!found)
696
+ return { type: 'fetch-result' };
697
+ const size = 'bytes' in found && found.bytes !== null ? found.bytes.byteLength : found.byteLength;
698
+ if (metaOnly) {
699
+ return {
700
+ type: 'fetch-result',
701
+ meta: true,
702
+ fileName: found.fileName,
703
+ mimeType: found.mimeType,
704
+ attachmentId: found.id,
705
+ size
706
+ };
707
+ }
708
+ if (!('bytes' in found) || found.bytes === null) {
709
+ return { type: 'fetch-result', message: 'attachment has no bytes' };
710
+ }
711
+ const file = await stageFile('fetch', found.bytes);
712
+ staged.push(file);
713
+ return {
714
+ type: 'fetch-result',
715
+ path: file,
716
+ fileName: found.fileName,
717
+ mimeType: found.mimeType,
718
+ attachmentId: found.id,
719
+ size
720
+ };
721
+ }
722
+ catch (err) {
723
+ return { type: 'fetch-result', message: err.message };
724
+ }
725
+ }
726
+ async function bridgeDrive(event, context) {
727
+ if (!context.driveOp)
728
+ return { type: 'drive-result', message: 'the host cannot proxy drives' };
729
+ try {
730
+ const payload = await context.driveOp(event.payload);
731
+ return { type: 'drive-result', payload };
732
+ }
733
+ catch (err) {
734
+ return { type: 'drive-result', message: err instanceof Error ? err.message : String(err) };
735
+ }
736
+ }
737
+ async function bridgeRag(event, context) {
738
+ if (!context.ragSearch) {
739
+ return {
740
+ type: 'rag-result',
741
+ result: { enabled: false, indexEmpty: true, hasKnowledge: false, hits: [] }
742
+ };
743
+ }
744
+ try {
745
+ const result = await context.ragSearch({
746
+ query: event.query ?? '',
747
+ limit: event.limit ?? undefined
748
+ });
749
+ return { type: 'rag-result', result };
750
+ }
751
+ catch (err) {
752
+ return { type: 'rag-result', message: err instanceof Error ? err.message : String(err) };
753
+ }
754
+ }
755
+ async function* frames(stream) {
756
+ const queue = pushQueue();
757
+ let error = null;
758
+ stream.on('data', (frame) => queue.push(frame));
759
+ stream.on('end', () => {
760
+ hlog('client stream event', { event: 'end' });
761
+ queue.end();
762
+ });
763
+ stream.on('close', () => {
764
+ hlog('client stream event', { event: 'close' });
765
+ queue.end();
766
+ });
767
+ stream.on('error', (err) => {
768
+ hlog('client stream event', { event: 'error', err: err.message });
769
+ error = err;
770
+ queue.end();
771
+ });
772
+ yield* queue;
773
+ if (error)
774
+ throw error;
775
+ }
776
+ async function* downloadFrames(stream) {
777
+ const queue = pushQueue();
778
+ let error = null;
779
+ stream.on('data', (frame) => queue.push(frame));
780
+ stream.on('end', () => queue.end());
781
+ stream.on('close', () => queue.end());
782
+ stream.on('error', (err) => {
783
+ error = err;
784
+ queue.end();
785
+ });
786
+ yield* queue;
787
+ if (error)
788
+ throw error;
789
+ }