@qvac/harness 0.0.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 (483) hide show
  1. package/LICENSE.md +198 -0
  2. package/NOTICE.md +13 -0
  3. package/README.md +68 -0
  4. package/SECURITY.md +6 -0
  5. package/dist/harness.bundle +48339 -0
  6. package/dist/harness.cjs +18 -0
  7. package/dist/harness.d.ts +8 -0
  8. package/dist/prebuilds-manifest.json +379 -0
  9. package/dist-lib/index.d.ts +240 -0
  10. package/dist-lib/index.js +1063 -0
  11. package/dist-lib/lib/audio-transcode-bare.d.ts +2 -0
  12. package/dist-lib/lib/audio-transcode-bare.js +145 -0
  13. package/dist-lib/lib/audio-transcode-node.d.ts +2 -0
  14. package/dist-lib/lib/audio-transcode-node.js +6 -0
  15. package/dist-lib/lib/capabilities/audio-resample.d.ts +14 -0
  16. package/dist-lib/lib/capabilities/audio-resample.js +72 -0
  17. package/dist-lib/lib/capabilities/completion.d.ts +288 -0
  18. package/dist-lib/lib/capabilities/completion.js +1077 -0
  19. package/dist-lib/lib/capabilities/download.d.ts +46 -0
  20. package/dist-lib/lib/capabilities/download.js +124 -0
  21. package/dist-lib/lib/capabilities/embed.d.ts +20 -0
  22. package/dist-lib/lib/capabilities/embed.js +13 -0
  23. package/dist-lib/lib/capabilities/kv-cache.d.ts +13 -0
  24. package/dist-lib/lib/capabilities/kv-cache.js +21 -0
  25. package/dist-lib/lib/capabilities/prompt-prefix.d.ts +6 -0
  26. package/dist-lib/lib/capabilities/prompt-prefix.js +10 -0
  27. package/dist-lib/lib/capabilities/speech-lexicon.d.ts +5 -0
  28. package/dist-lib/lib/capabilities/speech-lexicon.js +32 -0
  29. package/dist-lib/lib/capabilities/speech-text.d.ts +6 -0
  30. package/dist-lib/lib/capabilities/speech-text.js +79 -0
  31. package/dist-lib/lib/capabilities/tool-names.d.ts +3 -0
  32. package/dist-lib/lib/capabilities/tool-names.js +3 -0
  33. package/dist-lib/lib/capabilities/tool-selection.d.ts +43 -0
  34. package/dist-lib/lib/capabilities/tool-selection.js +60 -0
  35. package/dist-lib/lib/capabilities/tool-turns.d.ts +9 -0
  36. package/dist-lib/lib/capabilities/tool-turns.js +101 -0
  37. package/dist-lib/lib/capabilities/usage-breakdown.d.ts +27 -0
  38. package/dist-lib/lib/capabilities/usage-breakdown.js +44 -0
  39. package/dist-lib/lib/capabilities/vision-history.d.ts +3 -0
  40. package/dist-lib/lib/capabilities/vision-history.js +21 -0
  41. package/dist-lib/lib/capabilities/voice.d.ts +78 -0
  42. package/dist-lib/lib/capabilities/voice.js +189 -0
  43. package/dist-lib/lib/connect.d.ts +76 -0
  44. package/dist-lib/lib/connect.js +789 -0
  45. package/dist-lib/lib/context-window.d.ts +7 -0
  46. package/dist-lib/lib/context-window.js +90 -0
  47. package/dist-lib/lib/contract-types.d.ts +210 -0
  48. package/dist-lib/lib/contract-types.js +1 -0
  49. package/dist-lib/lib/diagram-repair.d.ts +21 -0
  50. package/dist-lib/lib/diagram-repair.js +58 -0
  51. package/dist-lib/lib/dns-lookup.d.ts +1 -0
  52. package/dist-lib/lib/dns-lookup.js +13 -0
  53. package/dist-lib/lib/error-fields.d.ts +2 -0
  54. package/dist-lib/lib/error-fields.js +8 -0
  55. package/dist-lib/lib/fetch-node.d.ts +1 -0
  56. package/dist-lib/lib/fetch-node.js +1 -0
  57. package/dist-lib/lib/hardware/capability-probe.d.ts +9 -0
  58. package/dist-lib/lib/hardware/capability-probe.js +99 -0
  59. package/dist-lib/lib/hardware/gpu-classify.d.ts +2 -0
  60. package/dist-lib/lib/hardware/gpu-classify.js +32 -0
  61. package/dist-lib/lib/hardware/gpu-probe-addon.d.ts +2 -0
  62. package/dist-lib/lib/hardware/gpu-probe-addon.js +42 -0
  63. package/dist-lib/lib/hardware/gpu-stats.bare.d.ts +1 -0
  64. package/dist-lib/lib/hardware/gpu-stats.bare.js +24 -0
  65. package/dist-lib/lib/hardware/gpu-stats.stub.d.ts +1 -0
  66. package/dist-lib/lib/hardware/gpu-stats.stub.js +3 -0
  67. package/dist-lib/lib/hardware/memory-budget.d.ts +8 -0
  68. package/dist-lib/lib/hardware/memory-budget.js +1 -0
  69. package/dist-lib/lib/hardware/parsers.d.ts +7 -0
  70. package/dist-lib/lib/hardware/parsers.js +41 -0
  71. package/dist-lib/lib/headers-bare.d.ts +1 -0
  72. package/dist-lib/lib/headers-bare.js +1 -0
  73. package/dist-lib/lib/headers-node.d.ts +4 -0
  74. package/dist-lib/lib/headers-node.js +1 -0
  75. package/dist-lib/lib/helpers/buffer-burst.d.ts +1 -0
  76. package/dist-lib/lib/helpers/buffer-burst.js +20 -0
  77. package/dist-lib/lib/helpers/control-tokens.d.ts +7 -0
  78. package/dist-lib/lib/helpers/control-tokens.js +32 -0
  79. package/dist-lib/lib/helpers/join-guard.d.ts +6 -0
  80. package/dist-lib/lib/helpers/join-guard.js +46 -0
  81. package/dist-lib/lib/helpers/markup-stream-filter.d.ts +5 -0
  82. package/dist-lib/lib/helpers/markup-stream-filter.js +75 -0
  83. package/dist-lib/lib/helpers/race-abort.d.ts +5 -0
  84. package/dist-lib/lib/helpers/race-abort.js +18 -0
  85. package/dist-lib/lib/helpers/retry-memo.d.ts +5 -0
  86. package/dist-lib/lib/helpers/retry-memo.js +12 -0
  87. package/dist-lib/lib/helpers/run-outcome.d.ts +33 -0
  88. package/dist-lib/lib/helpers/run-outcome.js +204 -0
  89. package/dist-lib/lib/helpers/spawn-path.d.ts +5 -0
  90. package/dist-lib/lib/helpers/spawn-path.js +57 -0
  91. package/dist-lib/lib/helpers/text-coalescer.d.ts +15 -0
  92. package/dist-lib/lib/helpers/text-coalescer.js +34 -0
  93. package/dist-lib/lib/helpers/thinking.d.ts +8 -0
  94. package/dist-lib/lib/helpers/thinking.js +95 -0
  95. package/dist-lib/lib/helpers/tool-call-markup.d.ts +20 -0
  96. package/dist-lib/lib/helpers/tool-call-markup.js +201 -0
  97. package/dist-lib/lib/helpers/tool-intent.d.ts +7 -0
  98. package/dist-lib/lib/helpers/tool-intent.js +21 -0
  99. package/dist-lib/lib/helpers/tool-label.d.ts +8 -0
  100. package/dist-lib/lib/helpers/tool-label.js +131 -0
  101. package/dist-lib/lib/hooks/built-in/arg-repair.d.ts +5 -0
  102. package/dist-lib/lib/hooks/built-in/arg-repair.js +88 -0
  103. package/dist-lib/lib/hooks/built-in/egress.d.ts +5 -0
  104. package/dist-lib/lib/hooks/built-in/egress.js +29 -0
  105. package/dist-lib/lib/hooks/built-in/index.d.ts +3 -0
  106. package/dist-lib/lib/hooks/built-in/index.js +3 -0
  107. package/dist-lib/lib/hooks/built-in/skill-catalog.d.ts +10 -0
  108. package/dist-lib/lib/hooks/built-in/skill-catalog.js +17 -0
  109. package/dist-lib/lib/hooks/pipeline.d.ts +20 -0
  110. package/dist-lib/lib/hooks/pipeline.js +49 -0
  111. package/dist-lib/lib/hooks/registry.d.ts +2 -0
  112. package/dist-lib/lib/hooks/registry.js +6 -0
  113. package/dist-lib/lib/hooks/run.d.ts +5 -0
  114. package/dist-lib/lib/hooks/run.js +83 -0
  115. package/dist-lib/lib/hooks/types.d.ts +57 -0
  116. package/dist-lib/lib/hooks/types.js +1 -0
  117. package/dist-lib/lib/log.d.ts +5 -0
  118. package/dist-lib/lib/log.js +37 -0
  119. package/dist-lib/lib/model-download-progress.d.ts +22 -0
  120. package/dist-lib/lib/model-download-progress.js +95 -0
  121. package/dist-lib/lib/models/context.d.ts +5 -0
  122. package/dist-lib/lib/models/context.js +12 -0
  123. package/dist-lib/lib/models/embed-config.d.ts +14 -0
  124. package/dist-lib/lib/models/embed-config.js +31 -0
  125. package/dist-lib/lib/models/gpu-selection.d.ts +3 -0
  126. package/dist-lib/lib/models/gpu-selection.js +26 -0
  127. package/dist-lib/lib/models/kv-cache.d.ts +4 -0
  128. package/dist-lib/lib/models/kv-cache.js +6 -0
  129. package/dist-lib/lib/models/llm-presets.d.ts +10 -0
  130. package/dist-lib/lib/models/llm-presets.js +58 -0
  131. package/dist-lib/lib/models/model-catalog-constants.d.ts +29 -0
  132. package/dist-lib/lib/models/model-catalog-constants.js +103 -0
  133. package/dist-lib/lib/models/model-catalog.d.ts +125 -0
  134. package/dist-lib/lib/models/model-catalog.js +371 -0
  135. package/dist-lib/lib/models/model-delete.d.ts +18 -0
  136. package/dist-lib/lib/models/model-delete.js +47 -0
  137. package/dist-lib/lib/models/model-handle.d.ts +18 -0
  138. package/dist-lib/lib/models/model-handle.js +33 -0
  139. package/dist-lib/lib/models/model-list.d.ts +42 -0
  140. package/dist-lib/lib/models/model-list.js +123 -0
  141. package/dist-lib/lib/models/model-pool.d.ts +116 -0
  142. package/dist-lib/lib/models/model-pool.js +356 -0
  143. package/dist-lib/lib/models/model-source.d.ts +6 -0
  144. package/dist-lib/lib/models/model-source.js +21 -0
  145. package/dist-lib/lib/models/music-catalog.d.ts +12 -0
  146. package/dist-lib/lib/models/music-catalog.js +26 -0
  147. package/dist-lib/lib/models/opencl-cache.d.ts +5 -0
  148. package/dist-lib/lib/models/opencl-cache.js +50 -0
  149. package/dist-lib/lib/models/sdk-faults.d.ts +21 -0
  150. package/dist-lib/lib/models/sdk-faults.js +66 -0
  151. package/dist-lib/lib/models/tool-dialect.d.ts +2 -0
  152. package/dist-lib/lib/models/tool-dialect.js +19 -0
  153. package/dist-lib/lib/models/tts-model-default.d.ts +3 -0
  154. package/dist-lib/lib/models/tts-model-default.js +13 -0
  155. package/dist-lib/lib/no-redirect-fetch-bare.d.ts +15 -0
  156. package/dist-lib/lib/no-redirect-fetch-bare.js +59 -0
  157. package/dist-lib/lib/no-redirect-fetch-impl.d.ts +39 -0
  158. package/dist-lib/lib/no-redirect-fetch-impl.js +80 -0
  159. package/dist-lib/lib/no-redirect-fetch-node.d.ts +4 -0
  160. package/dist-lib/lib/no-redirect-fetch-node.js +52 -0
  161. package/dist-lib/lib/prompt.d.ts +22 -0
  162. package/dist-lib/lib/prompt.js +77 -0
  163. package/dist-lib/lib/queue.d.ts +9 -0
  164. package/dist-lib/lib/queue.js +48 -0
  165. package/dist-lib/lib/resolution-detector.d.ts +5 -0
  166. package/dist-lib/lib/resolution-detector.js +100 -0
  167. package/dist-lib/lib/rpc-session.d.ts +8 -0
  168. package/dist-lib/lib/rpc-session.js +20 -0
  169. package/dist-lib/lib/sdk-config-loader.node.d.ts +1 -0
  170. package/dist-lib/lib/sdk-config-loader.node.js +1 -0
  171. package/dist-lib/lib/sdk-loader.d.ts +30 -0
  172. package/dist-lib/lib/sdk-loader.js +53 -0
  173. package/dist-lib/lib/sdk-storage.d.ts +8 -0
  174. package/dist-lib/lib/sdk-storage.js +24 -0
  175. package/dist-lib/lib/serve.d.ts +3 -0
  176. package/dist-lib/lib/serve.js +612 -0
  177. package/dist-lib/lib/spawn.d.ts +62 -0
  178. package/dist-lib/lib/spawn.js +71 -0
  179. package/dist-lib/lib/staging.d.ts +4 -0
  180. package/dist-lib/lib/staging.js +28 -0
  181. package/dist-lib/lib/storage.d.ts +18 -0
  182. package/dist-lib/lib/storage.js +26 -0
  183. package/dist-lib/lib/tmp-path.d.ts +7 -0
  184. package/dist-lib/lib/tmp-path.js +17 -0
  185. package/dist-lib/lib/tool-call-display.d.ts +21 -0
  186. package/dist-lib/lib/tool-call-display.js +1 -0
  187. package/dist-lib/lib/tools/catalog.d.ts +13 -0
  188. package/dist-lib/lib/tools/catalog.js +13 -0
  189. package/dist-lib/lib/tools/create-documents.d.ts +3 -0
  190. package/dist-lib/lib/tools/create-documents.js +87 -0
  191. package/dist-lib/lib/tools/edit-documents.d.ts +3 -0
  192. package/dist-lib/lib/tools/edit-documents.js +122 -0
  193. package/dist-lib/lib/tools/edit-image.d.ts +25 -0
  194. package/dist-lib/lib/tools/edit-image.js +271 -0
  195. package/dist-lib/lib/tools/exec/adapters/adapter.d.ts +27 -0
  196. package/dist-lib/lib/tools/exec/adapters/adapter.js +1 -0
  197. package/dist-lib/lib/tools/exec/adapters/python/attachments.d.ts +26 -0
  198. package/dist-lib/lib/tools/exec/adapters/python/attachments.js +160 -0
  199. package/dist-lib/lib/tools/exec/adapters/python/create-effect.d.ts +7 -0
  200. package/dist-lib/lib/tools/exec/adapters/python/create-effect.js +290 -0
  201. package/dist-lib/lib/tools/exec/adapters/python/loader.d.ts +11 -0
  202. package/dist-lib/lib/tools/exec/adapters/python/loader.js +94 -0
  203. package/dist-lib/lib/tools/exec/adapters/python/memfs.d.ts +47 -0
  204. package/dist-lib/lib/tools/exec/adapters/python/memfs.js +85 -0
  205. package/dist-lib/lib/tools/exec/adapters/python/output-policy.d.ts +13 -0
  206. package/dist-lib/lib/tools/exec/adapters/python/output-policy.js +129 -0
  207. package/dist-lib/lib/tools/exec/adapters/python/pyodide.d.ts +19 -0
  208. package/dist-lib/lib/tools/exec/adapters/python/pyodide.js +107 -0
  209. package/dist-lib/lib/tools/exec/adapters/python/python-adapter.d.ts +75 -0
  210. package/dist-lib/lib/tools/exec/adapters/python/python-adapter.js +1094 -0
  211. package/dist-lib/lib/tools/exec/adapters/python/run-session.d.ts +75 -0
  212. package/dist-lib/lib/tools/exec/adapters/python/run-session.js +273 -0
  213. package/dist-lib/lib/tools/exec/adapters/python/wheels.d.ts +38 -0
  214. package/dist-lib/lib/tools/exec/adapters/python/wheels.js +102 -0
  215. package/dist-lib/lib/tools/exec/adapters/python/worker/client.d.ts +7 -0
  216. package/dist-lib/lib/tools/exec/adapters/python/worker/client.js +188 -0
  217. package/dist-lib/lib/tools/exec/adapters/python/worker/entry.d.ts +1 -0
  218. package/dist-lib/lib/tools/exec/adapters/python/worker/entry.js +105 -0
  219. package/dist-lib/lib/tools/exec/adapters/python/worker/protocol.d.ts +38 -0
  220. package/dist-lib/lib/tools/exec/adapters/python/worker/protocol.js +41 -0
  221. package/dist-lib/lib/tools/exec/adapters/python/worker/spawn-bare.d.ts +2 -0
  222. package/dist-lib/lib/tools/exec/adapters/python/worker/spawn-bare.js +30 -0
  223. package/dist-lib/lib/tools/exec/adapters/python/worker/spawn-node.d.ts +13 -0
  224. package/dist-lib/lib/tools/exec/adapters/python/worker/spawn-node.js +45 -0
  225. package/dist-lib/lib/tools/exec/adapters/shell/shell-adapter.d.ts +12 -0
  226. package/dist-lib/lib/tools/exec/adapters/shell/shell-adapter.js +20 -0
  227. package/dist-lib/lib/tools/exec/obsidian/cli-process.d.ts +8 -0
  228. package/dist-lib/lib/tools/exec/obsidian/cli-process.js +74 -0
  229. package/dist-lib/lib/tools/exec/obsidian/cli.d.ts +18 -0
  230. package/dist-lib/lib/tools/exec/obsidian/cli.js +153 -0
  231. package/dist-lib/lib/tools/exec/obsidian/command.d.ts +5 -0
  232. package/dist-lib/lib/tools/exec/obsidian/command.js +18 -0
  233. package/dist-lib/lib/tools/exec/obsidian/guidance.d.ts +5 -0
  234. package/dist-lib/lib/tools/exec/obsidian/guidance.js +18 -0
  235. package/dist-lib/lib/tools/exec/obsidian/note-name.d.ts +1 -0
  236. package/dist-lib/lib/tools/exec/obsidian/note-name.js +6 -0
  237. package/dist-lib/lib/tools/exec/obsidian/output.d.ts +1 -0
  238. package/dist-lib/lib/tools/exec/obsidian/output.js +31 -0
  239. package/dist-lib/lib/tools/exec/obsidian/route.d.ts +19 -0
  240. package/dist-lib/lib/tools/exec/obsidian/route.js +85 -0
  241. package/dist-lib/lib/tools/exec/obsidian/safe-path.d.ts +3 -0
  242. package/dist-lib/lib/tools/exec/obsidian/safe-path.js +56 -0
  243. package/dist-lib/lib/tools/exec/obsidian/vault-create.d.ts +1 -0
  244. package/dist-lib/lib/tools/exec/obsidian/vault-create.js +40 -0
  245. package/dist-lib/lib/tools/exec/obsidian/vault-fs.d.ts +3 -0
  246. package/dist-lib/lib/tools/exec/obsidian/vault-fs.js +57 -0
  247. package/dist-lib/lib/tools/exec/obsidian/vault-paths.d.ts +20 -0
  248. package/dist-lib/lib/tools/exec/obsidian/vault-paths.js +171 -0
  249. package/dist-lib/lib/tools/exec/obsidian/vault-read.d.ts +11 -0
  250. package/dist-lib/lib/tools/exec/obsidian/vault-read.js +119 -0
  251. package/dist-lib/lib/tools/exec/obsidian/vault-write.d.ts +7 -0
  252. package/dist-lib/lib/tools/exec/obsidian/vault-write.js +134 -0
  253. package/dist-lib/lib/tools/exec/runner.d.ts +62 -0
  254. package/dist-lib/lib/tools/exec/runner.js +87 -0
  255. package/dist-lib/lib/tools/exec/scope.d.ts +3 -0
  256. package/dist-lib/lib/tools/exec/scope.js +97 -0
  257. package/dist-lib/lib/tools/exec/shell-argv.d.ts +2 -0
  258. package/dist-lib/lib/tools/exec/shell-argv.js +48 -0
  259. package/dist-lib/lib/tools/exec.d.ts +29 -0
  260. package/dist-lib/lib/tools/exec.js +459 -0
  261. package/dist-lib/lib/tools/file-glob.d.ts +15 -0
  262. package/dist-lib/lib/tools/file-glob.js +112 -0
  263. package/dist-lib/lib/tools/fs/drive.d.ts +26 -0
  264. package/dist-lib/lib/tools/fs/drive.js +1 -0
  265. package/dist-lib/lib/tools/fs/glob.d.ts +1 -0
  266. package/dist-lib/lib/tools/fs/glob.js +34 -0
  267. package/dist-lib/lib/tools/fs/local.d.ts +2 -0
  268. package/dist-lib/lib/tools/fs/local.js +29 -0
  269. package/dist-lib/lib/tools/fs/read.d.ts +2 -0
  270. package/dist-lib/lib/tools/fs/read.js +17 -0
  271. package/dist-lib/lib/tools/fs/remote-protocol.d.ts +40 -0
  272. package/dist-lib/lib/tools/fs/remote-protocol.js +1 -0
  273. package/dist-lib/lib/tools/fs/remote.d.ts +17 -0
  274. package/dist-lib/lib/tools/fs/remote.js +131 -0
  275. package/dist-lib/lib/tools/fs/scope.d.ts +37 -0
  276. package/dist-lib/lib/tools/fs/scope.js +130 -0
  277. package/dist-lib/lib/tools/fs/walk.d.ts +15 -0
  278. package/dist-lib/lib/tools/fs/walk.js +38 -0
  279. package/dist-lib/lib/tools/fs/write.d.ts +4 -0
  280. package/dist-lib/lib/tools/fs/write.js +5 -0
  281. package/dist-lib/lib/tools/generate-image.d.ts +111 -0
  282. package/dist-lib/lib/tools/generate-image.js +369 -0
  283. package/dist-lib/lib/tools/generate-music.d.ts +124 -0
  284. package/dist-lib/lib/tools/generate-music.js +522 -0
  285. package/dist-lib/lib/tools/grep.d.ts +5 -0
  286. package/dist-lib/lib/tools/grep.js +158 -0
  287. package/dist-lib/lib/tools/http-methods.d.ts +1 -0
  288. package/dist-lib/lib/tools/http-methods.js +1 -0
  289. package/dist-lib/lib/tools/http-request/encode-fields.d.ts +2 -0
  290. package/dist-lib/lib/tools/http-request/encode-fields.js +69 -0
  291. package/dist-lib/lib/tools/http-request/truncate-response.d.ts +1 -0
  292. package/dist-lib/lib/tools/http-request/truncate-response.js +83 -0
  293. package/dist-lib/lib/tools/http-request/utils.d.ts +27 -0
  294. package/dist-lib/lib/tools/http-request/utils.js +84 -0
  295. package/dist-lib/lib/tools/http-request.d.ts +20 -0
  296. package/dist-lib/lib/tools/http-request.js +177 -0
  297. package/dist-lib/lib/tools/mcp/utils.d.ts +47 -0
  298. package/dist-lib/lib/tools/mcp/utils.js +172 -0
  299. package/dist-lib/lib/tools/mcp-call.d.ts +14 -0
  300. package/dist-lib/lib/tools/mcp-call.js +155 -0
  301. package/dist-lib/lib/tools/model-args.d.ts +1 -0
  302. package/dist-lib/lib/tools/model-args.js +4 -0
  303. package/dist-lib/lib/tools/operations/builders.d.ts +17 -0
  304. package/dist-lib/lib/tools/operations/builders.js +179 -0
  305. package/dist-lib/lib/tools/operations/compile.d.ts +7 -0
  306. package/dist-lib/lib/tools/operations/compile.js +92 -0
  307. package/dist-lib/lib/tools/operations/gmail-message.d.ts +15 -0
  308. package/dist-lib/lib/tools/operations/gmail-message.js +62 -0
  309. package/dist-lib/lib/tools/operations/manifest.d.ts +60 -0
  310. package/dist-lib/lib/tools/operations/manifest.js +50 -0
  311. package/dist-lib/lib/tools/outbound-guard.d.ts +10 -0
  312. package/dist-lib/lib/tools/outbound-guard.js +127 -0
  313. package/dist-lib/lib/tools/private-ip.d.ts +4 -0
  314. package/dist-lib/lib/tools/private-ip.js +126 -0
  315. package/dist-lib/lib/tools/rag-search.d.ts +2 -0
  316. package/dist-lib/lib/tools/rag-search.js +98 -0
  317. package/dist-lib/lib/tools/read-files.d.ts +5 -0
  318. package/dist-lib/lib/tools/read-files.js +153 -0
  319. package/dist-lib/lib/tools/skill.d.ts +10 -0
  320. package/dist-lib/lib/tools/skill.js +123 -0
  321. package/dist-lib/lib/tools/skills/auth-resolver.d.ts +43 -0
  322. package/dist-lib/lib/tools/skills/auth-resolver.js +121 -0
  323. package/dist-lib/lib/tools/skills/bin-check.d.ts +9 -0
  324. package/dist-lib/lib/tools/skills/bin-check.js +56 -0
  325. package/dist-lib/lib/tools/skills/bundled-dir.d.ts +2 -0
  326. package/dist-lib/lib/tools/skills/bundled-dir.js +117 -0
  327. package/dist-lib/lib/tools/skills/bundled-hash.d.ts +4 -0
  328. package/dist-lib/lib/tools/skills/bundled-hash.js +12 -0
  329. package/dist-lib/lib/tools/skills/catalog.d.ts +60 -0
  330. package/dist-lib/lib/tools/skills/catalog.js +203 -0
  331. package/dist-lib/lib/tools/skills/cli-argv.d.ts +9 -0
  332. package/dist-lib/lib/tools/skills/cli-argv.js +147 -0
  333. package/dist-lib/lib/tools/skills/cli-schema-check.d.ts +3 -0
  334. package/dist-lib/lib/tools/skills/cli-schema-check.js +62 -0
  335. package/dist-lib/lib/tools/skills/cli-schema-load.d.ts +4 -0
  336. package/dist-lib/lib/tools/skills/cli-schema-load.js +90 -0
  337. package/dist-lib/lib/tools/skills/cli-schema-types.d.ts +30 -0
  338. package/dist-lib/lib/tools/skills/cli-schema-types.js +1 -0
  339. package/dist-lib/lib/tools/skills/cli-schema.d.ts +7 -0
  340. package/dist-lib/lib/tools/skills/cli-schema.js +35 -0
  341. package/dist-lib/lib/tools/skills/credential-check.d.ts +20 -0
  342. package/dist-lib/lib/tools/skills/credential-check.js +94 -0
  343. package/dist-lib/lib/tools/skills/credential-grants.d.ts +9 -0
  344. package/dist-lib/lib/tools/skills/credential-grants.js +25 -0
  345. package/dist-lib/lib/tools/skills/credential-health.d.ts +8 -0
  346. package/dist-lib/lib/tools/skills/credential-health.js +51 -0
  347. package/dist-lib/lib/tools/skills/credential-slots.d.ts +7 -0
  348. package/dist-lib/lib/tools/skills/credential-slots.js +8 -0
  349. package/dist-lib/lib/tools/skills/frontmatter-parser.d.ts +23 -0
  350. package/dist-lib/lib/tools/skills/frontmatter-parser.js +68 -0
  351. package/dist-lib/lib/tools/skills/index.d.ts +5 -0
  352. package/dist-lib/lib/tools/skills/index.js +5 -0
  353. package/dist-lib/lib/tools/skills/manifest-parse.d.ts +12 -0
  354. package/dist-lib/lib/tools/skills/manifest-parse.js +199 -0
  355. package/dist-lib/lib/tools/skills/manifest.d.ts +47 -0
  356. package/dist-lib/lib/tools/skills/manifest.js +1 -0
  357. package/dist-lib/lib/tools/skills/mention-name.d.ts +1 -0
  358. package/dist-lib/lib/tools/skills/mention-name.js +4 -0
  359. package/dist-lib/lib/tools/skills/mention.d.ts +6 -0
  360. package/dist-lib/lib/tools/skills/mention.js +42 -0
  361. package/dist-lib/lib/tools/skills/obsidian-readiness.d.ts +16 -0
  362. package/dist-lib/lib/tools/skills/obsidian-readiness.js +95 -0
  363. package/dist-lib/lib/tools/skills/overlay-crud.d.ts +18 -0
  364. package/dist-lib/lib/tools/skills/overlay-crud.js +98 -0
  365. package/dist-lib/lib/tools/skills/overlay-dir.d.ts +2 -0
  366. package/dist-lib/lib/tools/skills/overlay-dir.js +22 -0
  367. package/dist-lib/lib/tools/skills/overlay-watch.d.ts +13 -0
  368. package/dist-lib/lib/tools/skills/overlay-watch.js +44 -0
  369. package/dist-lib/lib/tools/skills/scope-key.d.ts +7 -0
  370. package/dist-lib/lib/tools/skills/scope-key.js +7 -0
  371. package/dist-lib/lib/tools/skills/setup-routes.d.ts +4 -0
  372. package/dist-lib/lib/tools/skills/setup-routes.js +14 -0
  373. package/dist-lib/lib/tools/skills/skill-settings.d.ts +16 -0
  374. package/dist-lib/lib/tools/skills/skill-settings.js +33 -0
  375. package/dist-lib/lib/tools/skills/skill-state-constants.d.ts +12 -0
  376. package/dist-lib/lib/tools/skills/skill-state-constants.js +14 -0
  377. package/dist-lib/lib/tools/skills/skill-state.d.ts +40 -0
  378. package/dist-lib/lib/tools/skills/skill-state.js +117 -0
  379. package/dist-lib/lib/tools/skills/tool-grants.d.ts +5 -0
  380. package/dist-lib/lib/tools/skills/tool-grants.js +14 -0
  381. package/dist-lib/lib/tools/toolsets.d.ts +8 -0
  382. package/dist-lib/lib/tools/toolsets.js +20 -0
  383. package/dist-lib/lib/tools/url-guard.d.ts +8 -0
  384. package/dist-lib/lib/tools/url-guard.js +40 -0
  385. package/dist-lib/lib/tools/web-fetch.d.ts +8 -0
  386. package/dist-lib/lib/tools/web-fetch.js +302 -0
  387. package/dist-lib/lib/tools/web-search.d.ts +6 -0
  388. package/dist-lib/lib/tools/web-search.js +55 -0
  389. package/dist-lib/lib/transport.d.ts +12 -0
  390. package/dist-lib/lib/transport.js +59 -0
  391. package/dist-lib/lib/user-agent.d.ts +1 -0
  392. package/dist-lib/lib/user-agent.js +1 -0
  393. package/dist-lib/lib/validating-lookup.d.ts +17 -0
  394. package/dist-lib/lib/validating-lookup.js +25 -0
  395. package/dist-lib/lib/wav-encode.d.ts +5 -0
  396. package/dist-lib/lib/wav-encode.js +24 -0
  397. package/dist-lib/lib/web-fetch/embedded-state.d.ts +1 -0
  398. package/dist-lib/lib/web-fetch/embedded-state.js +131 -0
  399. package/dist-lib/lib/web-fetch/extract.d.ts +6 -0
  400. package/dist-lib/lib/web-fetch/extract.js +65 -0
  401. package/dist-lib/lib/web-fetch/images.d.ts +3 -0
  402. package/dist-lib/lib/web-fetch/images.js +43 -0
  403. package/dist-lib/lib/web-fetch/video.d.ts +5 -0
  404. package/dist-lib/lib/web-fetch/video.js +42 -0
  405. package/dist-lib/lib/web-search/engine-registry.d.ts +7 -0
  406. package/dist-lib/lib/web-search/engine-registry.js +17 -0
  407. package/dist-lib/lib/web-search/engines/aol.d.ts +3 -0
  408. package/dist-lib/lib/web-search/engines/aol.js +81 -0
  409. package/dist-lib/lib/web-search/engines/bing.d.ts +3 -0
  410. package/dist-lib/lib/web-search/engines/bing.js +111 -0
  411. package/dist-lib/lib/web-search/engines/brave.d.ts +3 -0
  412. package/dist-lib/lib/web-search/engines/brave.js +59 -0
  413. package/dist-lib/lib/web-search/engines/duckduckgo.d.ts +3 -0
  414. package/dist-lib/lib/web-search/engines/duckduckgo.js +112 -0
  415. package/dist-lib/lib/web-search/engines/google.d.ts +3 -0
  416. package/dist-lib/lib/web-search/engines/google.js +92 -0
  417. package/dist-lib/lib/web-search/engines/wikipedia.d.ts +3 -0
  418. package/dist-lib/lib/web-search/engines/wikipedia.js +37 -0
  419. package/dist-lib/lib/web-search/engines/yahoo.d.ts +3 -0
  420. package/dist-lib/lib/web-search/engines/yahoo.js +81 -0
  421. package/dist-lib/lib/web-search/fetch-html.d.ts +25 -0
  422. package/dist-lib/lib/web-search/fetch-html.js +97 -0
  423. package/dist-lib/lib/web-search/format-results.d.ts +3 -0
  424. package/dist-lib/lib/web-search/format-results.js +14 -0
  425. package/dist-lib/lib/web-search/html-helpers.d.ts +3 -0
  426. package/dist-lib/lib/web-search/html-helpers.js +24 -0
  427. package/dist-lib/lib/web-search/merge-results.d.ts +2 -0
  428. package/dist-lib/lib/web-search/merge-results.js +53 -0
  429. package/dist-lib/lib/web-search/orchestrator.d.ts +14 -0
  430. package/dist-lib/lib/web-search/orchestrator.js +50 -0
  431. package/dist-lib/lib/web-search/types.d.ts +34 -0
  432. package/dist-lib/lib/web-search/types.js +1 -0
  433. package/dist-lib/lib/web-search/url-helpers.d.ts +1 -0
  434. package/dist-lib/lib/web-search/url-helpers.js +11 -0
  435. package/dist-lib/lib/web-search/url-normalize.d.ts +1 -0
  436. package/dist-lib/lib/web-search/url-normalize.js +25 -0
  437. package/dist-lib/lib/web-search/user-agents.d.ts +3 -0
  438. package/dist-lib/lib/web-search/user-agents.js +3 -0
  439. package/dist-lib/lib/wire.d.ts +50 -0
  440. package/dist-lib/lib/wire.js +145 -0
  441. package/dist-lib/schema/baseline.d.ts +8 -0
  442. package/dist-lib/schema/baseline.js +35 -0
  443. package/dist-lib/schema/build.d.ts +1 -0
  444. package/dist-lib/schema/build.js +39 -0
  445. package/dist-lib/schema/generate.d.ts +20 -0
  446. package/dist-lib/schema/generate.js +149 -0
  447. package/dist-lib/schema/harness.d.ts +2 -0
  448. package/dist-lib/schema/harness.js +745 -0
  449. package/dist-lib/schema/release-tags.d.ts +5 -0
  450. package/dist-lib/schema/release-tags.js +58 -0
  451. package/dist-lib/spec/bind.d.ts +2 -0
  452. package/dist-lib/spec/bind.js +124 -0
  453. package/dist-lib/spec/calls.d.ts +3 -0
  454. package/dist-lib/spec/calls.js +41 -0
  455. package/dist-lib/spec/hrpc/hrpc.json +356 -0
  456. package/dist-lib/spec/hrpc/index.d.ts +3 -0
  457. package/dist-lib/spec/hrpc/index.js +463 -0
  458. package/dist-lib/spec/hrpc/messages.d.ts +4 -0
  459. package/dist-lib/spec/hrpc/messages.js +3102 -0
  460. package/dist-lib/spec/hyperschema/index.js +3102 -0
  461. package/dist-lib/spec/hyperschema/schema.json +2290 -0
  462. package/dist-lib/spec/hyperschema/types.d.ts +554 -0
  463. package/dist-lib/spec/index.d.ts +8 -0
  464. package/dist-lib/spec/index.js +1 -0
  465. package/package.json +418 -1
  466. package/wheels/cffi-2.0.0-cp314-cp314-pyemscripten_2026_0_wasm32.whl +0 -0
  467. package/wheels/cryptography-47.0.0-cp314-abi3-pyemscripten_2026_0_wasm32.whl +0 -0
  468. package/wheels/defusedxml-0.7.1-py2.py3-none-any.whl +0 -0
  469. package/wheels/et_xmlfile-2.0.0-py3-none-any.whl +0 -0
  470. package/wheels/fonttools-4.62.1-py3-none-any.whl +0 -0
  471. package/wheels/fpdf2-2.8.8-py3-none-any.whl +0 -0
  472. package/wheels/lxml-6.0.2-cp314-cp314-pyemscripten_2026_0_wasm32.whl +0 -0
  473. package/wheels/manifest.json +155 -0
  474. package/wheels/micropip-0.11.1-py3-none-any.whl +0 -0
  475. package/wheels/openpyxl-3.1.5-py2.py3-none-any.whl +0 -0
  476. package/wheels/pillow-12.2.0-cp314-cp314-pyemscripten_2026_0_wasm32.whl +0 -0
  477. package/wheels/pycparser-3.0-py3-none-any.whl +0 -0
  478. package/wheels/pypdf-6.15.0-py3-none-any.whl +0 -0
  479. package/wheels/python_docx-1.2.0-py3-none-any.whl +0 -0
  480. package/wheels/python_pptx-1.0.2-py3-none-any.whl +0 -0
  481. package/wheels/six-1.17.0-py2.py3-none-any.whl +0 -0
  482. package/wheels/typing_extensions-4.15.0-py3-none-any.whl +0 -0
  483. package/wheels/xlsxwriter-3.2.9-py3-none-any.whl +0 -0
@@ -0,0 +1,21 @@
1
+ import { audioGenModelByName, curatedModelAsset, customModelSrc } from "./model-catalog.js";
2
+ export async function resolveModelSrc(sdk, model, addon = 'llm') {
3
+ if (/^(\/|~|\.|file:|https?:|registry:|pear:|hyper:)/.test(model))
4
+ return model;
5
+ const custom = customModelSrc(model);
6
+ if (custom)
7
+ return custom;
8
+ if (addon === 'audiogen') {
9
+ const audio = audioGenModelByName(model);
10
+ if (!audio)
11
+ throw new Error(`audiogen model not found: ${model}`);
12
+ return audio.src;
13
+ }
14
+ const asset = curatedModelAsset(model, addon);
15
+ if (asset)
16
+ return asset;
17
+ const [entry] = await sdk.modelRegistrySearch({ filter: model, addon });
18
+ if (!entry)
19
+ throw new Error(`model not found in registry: ${model} (addon=${addon})`);
20
+ return { ...entry, src: `registry://${entry.registrySource}/${entry.registryPath}` };
21
+ }
@@ -0,0 +1,12 @@
1
+ export declare const MUSIC_MODEL_CHOICES: readonly ["turbo", "turbo-hq", "sft"];
2
+ export type MusicModelChoice = (typeof MUSIC_MODEL_CHOICES)[number];
3
+ export declare const GENERATE_MUSIC_TOOL = "generate_music";
4
+ export declare const DEFAULT_MUSIC_MODEL_CHOICE: MusicModelChoice;
5
+ export type MusicChoiceEntry = {
6
+ readonly choice: MusicModelChoice;
7
+ readonly label: string;
8
+ readonly sizeBytesApprox: number;
9
+ readonly requiresGpu: boolean;
10
+ readonly notes: string;
11
+ };
12
+ export declare const MUSIC_CHOICE_CATALOG: ReadonlyArray<MusicChoiceEntry>;
@@ -0,0 +1,26 @@
1
+ export const MUSIC_MODEL_CHOICES = ['turbo', 'turbo-hq', 'sft'];
2
+ export const GENERATE_MUSIC_TOOL = 'generate_music';
3
+ export const DEFAULT_MUSIC_MODEL_CHOICE = 'turbo';
4
+ export const MUSIC_CHOICE_CATALOG = [
5
+ {
6
+ choice: 'turbo',
7
+ label: 'ACE-Step 1.5 Turbo (Q4)',
8
+ sizeBytesApprox: 3_300_000_000,
9
+ requiresGpu: false,
10
+ notes: 'Fastest, fits phone memory. Good default.'
11
+ },
12
+ {
13
+ choice: 'turbo-hq',
14
+ label: 'ACE-Step 1.5 Turbo (Q8)',
15
+ sizeBytesApprox: 4_400_000_000,
16
+ requiresGpu: true,
17
+ notes: 'Higher-precision Turbo. Wants a desktop GPU.'
18
+ },
19
+ {
20
+ choice: 'sft',
21
+ label: 'ACE-Step 1.5 SFT (Q8)',
22
+ sizeBytesApprox: 4_400_000_000,
23
+ requiresGpu: true,
24
+ notes: 'Fine-tuned quality. Wants a desktop GPU.'
25
+ }
26
+ ];
@@ -0,0 +1,5 @@
1
+ export declare const OPENCL_CACHE_MAX_AGE_MS: number;
2
+ export declare function openclEngineKey(sdkVersion?: string): string;
3
+ export declare function openclCacheRoot(env?: Record<string, string | undefined>, hostPlatform?: string): string | undefined;
4
+ export declare function openclCacheDir(env?: Record<string, string | undefined>, hostPlatform?: string, sdkVersion?: string): string | undefined;
5
+ export declare function prepareOpenclCache(env?: Record<string, string | undefined>, hostPlatform?: string, sdkVersion?: string, now?: number): void;
@@ -0,0 +1,50 @@
1
+ import fs from 'fs';
2
+ import { platform } from 'os';
3
+ import path from 'path';
4
+ import process from 'process';
5
+ import sdkPkg from '@qvac/sdk/package' with { type: 'json' };
6
+ const OPENCL_CACHE_DIR_ENV = 'QVAC_OPENCL_CACHE_DIR';
7
+ export const OPENCL_CACHE_MAX_AGE_MS = 60 * 60 * 1000;
8
+ const noop = () => { };
9
+ export function openclEngineKey(sdkVersion = sdkPkg.version) {
10
+ return `sdk-${sdkVersion}`.replace(/[^A-Za-z0-9._-]/g, '_');
11
+ }
12
+ export function openclCacheRoot(env = process.env, hostPlatform = platform()) {
13
+ if (hostPlatform !== 'android')
14
+ return undefined;
15
+ const dir = env[OPENCL_CACHE_DIR_ENV];
16
+ if (!dir?.startsWith('/'))
17
+ return undefined;
18
+ return dir.split('/').includes('..') ? undefined : dir;
19
+ }
20
+ export function openclCacheDir(env = process.env, hostPlatform = platform(), sdkVersion) {
21
+ const root = openclCacheRoot(env, hostPlatform);
22
+ return root === undefined ? undefined : path.join(root, openclEngineKey(sdkVersion));
23
+ }
24
+ export function prepareOpenclCache(env = process.env, hostPlatform = platform(), sdkVersion, now = Date.now()) {
25
+ const root = openclCacheRoot(env, hostPlatform);
26
+ if (root === undefined)
27
+ return;
28
+ const key = openclEngineKey(sdkVersion);
29
+ try {
30
+ fs.mkdirSync(path.join(root, key), { recursive: true });
31
+ }
32
+ catch {
33
+ return;
34
+ }
35
+ fs.promises.readdir(root).then((names) => {
36
+ for (const name of names) {
37
+ if (name === key)
38
+ continue;
39
+ const entry = path.join(root, name);
40
+ fs.promises
41
+ .stat(entry)
42
+ .then((stat) => {
43
+ if (now - stat.mtimeMs > OPENCL_CACHE_MAX_AGE_MS) {
44
+ return fs.promises.rm(entry, { recursive: true, force: true }).catch(noop);
45
+ }
46
+ })
47
+ .catch(noop);
48
+ }
49
+ }, noop);
50
+ }
@@ -0,0 +1,21 @@
1
+ import type { EmbedDevice } from './embed-config.ts';
2
+ export declare function isSdkGpuDeviceLostError(err: unknown): boolean;
3
+ export declare function isSdkModelWedgedError(err: unknown): boolean;
4
+ export declare function isContextOverflowError(err: unknown): boolean;
5
+ export type GpuFaultDecision = 'reload' | 'fallback';
6
+ export declare function createGpuFaultEscalation(): {
7
+ recordFault(onGpu: boolean): GpuFaultDecision;
8
+ reset(): void;
9
+ };
10
+ export type GpuFaultState = ReturnType<typeof createGpuFaultState>;
11
+ export declare function createGpuFaultState({ device, gpuLayers }?: {
12
+ device?: EmbedDevice;
13
+ gpuLayers?: number;
14
+ }): {
15
+ readonly device: EmbedDevice;
16
+ readonly generation: number;
17
+ gpuLayers(): number;
18
+ key(model: string): string;
19
+ recordFault(bornAt: number): void;
20
+ reset(): void;
21
+ };
@@ -0,0 +1,66 @@
1
+ export function isSdkGpuDeviceLostError(err) {
2
+ if (typeof err !== 'object' || err === null)
3
+ return false;
4
+ const message = err.message;
5
+ if (typeof message !== 'string')
6
+ return false;
7
+ return /ErrorDeviceLost/i.test(message) || /VK_ERROR_DEVICE_LOST/i.test(message);
8
+ }
9
+ export function isSdkModelWedgedError(err) {
10
+ if (typeof err !== 'object' || err === null)
11
+ return false;
12
+ const message = err.message;
13
+ if (typeof message !== 'string')
14
+ return false;
15
+ return /failed to (decode next token|eval chunk)/i.test(message);
16
+ }
17
+ export function isContextOverflowError(err) {
18
+ if (typeof err !== 'object' || err === null)
19
+ return false;
20
+ return err.name === 'CONTEXT_OVERFLOW';
21
+ }
22
+ export function createGpuFaultEscalation() {
23
+ let count = 0;
24
+ return {
25
+ recordFault(onGpu) {
26
+ count += 1;
27
+ return onGpu && count >= 2 ? 'fallback' : 'reload';
28
+ },
29
+ reset() {
30
+ count = 0;
31
+ }
32
+ };
33
+ }
34
+ const GPU_LAYERS_FULL = 99;
35
+ const GPU_LAYERS_NONE = 0;
36
+ export function createGpuFaultState({ device, gpuLayers } = {}) {
37
+ const escalation = createGpuFaultEscalation();
38
+ let current = device ?? 'gpu';
39
+ let generation = 0;
40
+ let lastFaulted = -1;
41
+ return {
42
+ get device() {
43
+ return current;
44
+ },
45
+ get generation() {
46
+ return generation;
47
+ },
48
+ gpuLayers() {
49
+ return gpuLayers ?? (current === 'gpu' ? GPU_LAYERS_FULL : GPU_LAYERS_NONE);
50
+ },
51
+ key(model) {
52
+ return [model, current, generation].join('\0');
53
+ },
54
+ recordFault(bornAt) {
55
+ if (bornAt <= lastFaulted)
56
+ return;
57
+ lastFaulted = bornAt;
58
+ generation += 1;
59
+ if (escalation.recordFault(current === 'gpu') === 'fallback')
60
+ current = 'cpu';
61
+ },
62
+ reset() {
63
+ escalation.reset();
64
+ }
65
+ };
66
+ }
@@ -0,0 +1,2 @@
1
+ import type { ToolDialect } from '@qvac/sdk';
2
+ export declare function detectToolDialect(src: string, name?: string): ToolDialect | undefined;
@@ -0,0 +1,19 @@
1
+ export function detectToolDialect(src, name) {
2
+ const basename = src
3
+ .toLowerCase()
4
+ .split(/[/\\?#]/)
5
+ .filter(Boolean)
6
+ .pop() ?? '';
7
+ const tag = `${(name ?? '').toLowerCase()}|${basename}`;
8
+ if (/qwen3[._-]?[56](?![a-z0-9])/.test(tag))
9
+ return 'qwen35';
10
+ if (/gemma[-_]?4(?=[^a-z0-9]|$)/.test(tag))
11
+ return 'gemma4';
12
+ if (/gpt[_-]?oss/.test(tag))
13
+ return 'harmony';
14
+ if (/deepseek[-_. ]?v(?:4|3[._-]?2)(?![0-9])/.test(tag))
15
+ return 'dsml';
16
+ if (/lfm[_-]?\d/.test(tag))
17
+ return 'pythonic';
18
+ return undefined;
19
+ }
@@ -0,0 +1,3 @@
1
+ export type TtsCapabilityProfile = 'tiny' | 'low' | 'mid' | 'high' | 'xhigh';
2
+ export declare const TTS_MODEL_NAMES: ReadonlyArray<string>;
3
+ export declare function defaultTtsModelName(profile: TtsCapabilityProfile): string;
@@ -0,0 +1,13 @@
1
+ const TTS_MODEL_BY_PROFILE = {
2
+ tiny: 'Supertonic3-Q4_0',
3
+ low: 'Supertonic3-Q4_0',
4
+ mid: 'Supertonic3-Q8_0',
5
+ high: 'Supertonic3-Q8_0',
6
+ xhigh: 'Supertonic3-Q8_0'
7
+ };
8
+ export const TTS_MODEL_NAMES = [
9
+ ...new Set(Object.values(TTS_MODEL_BY_PROFILE))
10
+ ];
11
+ export function defaultTtsModelName(profile) {
12
+ return TTS_MODEL_BY_PROFILE[profile];
13
+ }
@@ -0,0 +1,15 @@
1
+ import { type BareLookupAll } from './validating-lookup.ts';
2
+ import { type NoRedirectFetchInit, type NoRedirectFetchResponse } from './no-redirect-fetch-impl.ts';
3
+ export type { NoRedirectFetchResponse };
4
+ export type ConnectionAgent = {
5
+ createConnection(opts: {
6
+ readonly host?: string;
7
+ }): unknown;
8
+ };
9
+ export type AgentCtor<A extends ConnectionAgent> = new (opts: object) => A;
10
+ export declare class BlockedHostError extends Error {
11
+ readonly code = "EBLOCKEDHOST";
12
+ constructor(host: string);
13
+ }
14
+ export declare function makeValidatingAgent<A extends ConnectionAgent>(Agent: AgentCtor<A>, lookup: BareLookupAll): A;
15
+ export default function noRedirectFetch(url: URL, init?: NoRedirectFetchInit): Promise<NoRedirectFetchResponse>;
@@ -0,0 +1,59 @@
1
+ import http, { Agent as HttpAgent } from 'bare-http1';
2
+ import https, { Agent as HttpsAgent } from 'bare-https';
3
+ import * as bareDns from 'bare-dns';
4
+ import { isPrivateOrBlocked } from "./tools/private-ip.js";
5
+ import { makeValidatingLookup } from "./validating-lookup.js";
6
+ import { runNoRedirectFetch } from "./no-redirect-fetch-impl.js";
7
+ export class BlockedHostError extends Error {
8
+ code = 'EBLOCKEDHOST';
9
+ constructor(host) {
10
+ super(`Connection to "${host}" is blocked (private/loopback/metadata).`);
11
+ this.name = 'BlockedHostError';
12
+ }
13
+ }
14
+ function isLiteralIp(host) {
15
+ if (host.includes(':')) {
16
+ return true;
17
+ }
18
+ return /^\d{1,3}(\.\d{1,3}){3}$/.test(host);
19
+ }
20
+ export function makeValidatingAgent(Agent, lookup) {
21
+ const agent = new Agent({ keepAlive: 1000, timeout: 5000, lookup });
22
+ const original = agent.createConnection.bind(agent);
23
+ agent.createConnection = (opts) => {
24
+ const host = opts.host;
25
+ if (typeof host === 'string' && isLiteralIp(host) && isPrivateOrBlocked(host)) {
26
+ throw new BlockedHostError(host);
27
+ }
28
+ return original(opts);
29
+ };
30
+ return agent;
31
+ }
32
+ const rawAllLookup = (hostname, opts, cb) => {
33
+ bareDns.lookup(hostname, opts, cb);
34
+ };
35
+ const validatingLookup = makeValidatingLookup(rawAllLookup);
36
+ const httpAgent = makeValidatingAgent(HttpAgent, validatingLookup);
37
+ const httpsAgent = makeValidatingAgent(HttpsAgent, validatingLookup);
38
+ export default function noRedirectFetch(url, init = {}) {
39
+ const request = (target, opts, onresponse) => {
40
+ const common = { method: readMethod(opts.method), headers: opts.headers };
41
+ const forward = (res) => onresponse(res);
42
+ return target.protocol === 'https:'
43
+ ? https.request(target.href, { ...common, agent: httpsAgent }, forward)
44
+ : http.request(target.href, { ...common, agent: httpAgent }, forward);
45
+ };
46
+ return runNoRedirectFetch(request, url, init);
47
+ }
48
+ function readMethod(method) {
49
+ if (method === 'GET' ||
50
+ method === 'POST' ||
51
+ method === 'PUT' ||
52
+ method === 'DELETE' ||
53
+ method === 'PATCH' ||
54
+ method === 'HEAD' ||
55
+ method === 'OPTIONS') {
56
+ return method;
57
+ }
58
+ throw new Error(`unsupported HTTP method: ${method}`);
59
+ }
@@ -0,0 +1,39 @@
1
+ export interface FetchRequestLike {
2
+ on(event: 'error', listener: (err: Error) => void): void;
3
+ write(chunk: string): void;
4
+ end(): void;
5
+ destroy(err?: Error): void;
6
+ }
7
+ export interface FetchResponseLike {
8
+ statusCode: number;
9
+ headers: Record<string, string | string[] | number | undefined>;
10
+ on(event: 'data', listener: (chunk: Uint8Array) => void): void;
11
+ on(event: 'error', listener: (err: Error) => void): void;
12
+ on(event: 'end', listener: () => void): void;
13
+ }
14
+ export type BareRequestFn<Response extends FetchResponseLike = FetchResponseLike, Request extends FetchRequestLike = FetchRequestLike> = (url: URL, opts: {
15
+ method: string;
16
+ headers: Record<string, string>;
17
+ validatedAddresses?: readonly string[] | undefined;
18
+ }, onresponse: (res: Response) => void) => Request;
19
+ export interface NoRedirectFetchInit {
20
+ method?: string;
21
+ headers?: Record<string, string>;
22
+ body?: string;
23
+ signal?: {
24
+ readonly aborted: boolean;
25
+ addEventListener(type: 'abort', listener: () => void): void;
26
+ };
27
+ validatedAddresses?: readonly string[] | undefined;
28
+ maxBytes?: number;
29
+ truncate?: boolean;
30
+ }
31
+ export interface NoRedirectFetchResponse {
32
+ status: number;
33
+ headers: {
34
+ get(name: string): string | null;
35
+ };
36
+ text(): string;
37
+ bytes(): Uint8Array;
38
+ }
39
+ export declare function runNoRedirectFetch<Response extends FetchResponseLike, Request extends FetchRequestLike>(request: BareRequestFn<Response, Request>, url: URL, init?: NoRedirectFetchInit): Promise<NoRedirectFetchResponse>;
@@ -0,0 +1,80 @@
1
+ import b4a from 'b4a';
2
+ import { DEFAULT_USER_AGENT } from "./user-agent.js";
3
+ const UA_SNIFFING_HOSTS = new Set(['wttr.in']);
4
+ export function runNoRedirectFetch(request, url, init = {}) {
5
+ return new Promise((resolve, reject) => {
6
+ const headers = { ...init.headers };
7
+ if (init.body !== undefined &&
8
+ !Object.keys(headers).some((h) => h.toLowerCase() === 'content-length')) {
9
+ headers['content-length'] = String(b4a.byteLength(init.body));
10
+ }
11
+ if (!Object.keys(headers).some((h) => h.toLowerCase() === 'user-agent')) {
12
+ headers['user-agent'] = UA_SNIFFING_HOSTS.has(url.hostname.toLowerCase())
13
+ ? ''
14
+ : DEFAULT_USER_AGENT;
15
+ }
16
+ const method = init.method ?? 'GET';
17
+ const req = request(url, { method, headers, validatedAddresses: init.validatedAddresses }, (res) => {
18
+ const chunks = [];
19
+ let received = 0;
20
+ let settled = false;
21
+ const respond = () => {
22
+ if (settled)
23
+ return;
24
+ settled = true;
25
+ const body = b4a.concat(chunks);
26
+ const responseHeaders = {};
27
+ for (const [name, value] of Object.entries(res.headers)) {
28
+ responseHeaders[name.toLowerCase()] = String(value);
29
+ }
30
+ resolve({
31
+ status: res.statusCode,
32
+ headers: { get: (name) => responseHeaders[name.toLowerCase()] ?? null },
33
+ text: () => b4a.toString(body, 'utf8'),
34
+ bytes: () => body
35
+ });
36
+ };
37
+ const fail = (err) => {
38
+ if (settled)
39
+ return;
40
+ settled = true;
41
+ reject(err);
42
+ };
43
+ res.on('data', (chunk) => {
44
+ received += chunk.byteLength;
45
+ if (init.maxBytes !== undefined && received > init.maxBytes) {
46
+ if (init.truncate) {
47
+ const allowed = chunk.byteLength - (received - init.maxBytes);
48
+ if (allowed > 0)
49
+ chunks.push(chunk.subarray(0, allowed));
50
+ respond();
51
+ req.destroy();
52
+ return;
53
+ }
54
+ const err = new Error(`response exceeded ${init.maxBytes} bytes`);
55
+ req.destroy(err);
56
+ fail(err);
57
+ return;
58
+ }
59
+ chunks.push(chunk);
60
+ });
61
+ res.on('error', fail);
62
+ res.on('end', respond);
63
+ });
64
+ req.on('error', reject);
65
+ if (init.signal) {
66
+ const abort = () => {
67
+ const err = new Error('This operation was aborted');
68
+ err.name = 'AbortError';
69
+ req.destroy(err);
70
+ reject(err);
71
+ };
72
+ if (init.signal.aborted)
73
+ return abort();
74
+ init.signal.addEventListener('abort', abort);
75
+ }
76
+ if (init.body !== undefined)
77
+ req.write(init.body);
78
+ req.end();
79
+ });
80
+ }
@@ -0,0 +1,4 @@
1
+ import * as http from 'node:http';
2
+ import { type NoRedirectFetchInit, type NoRedirectFetchResponse } from './no-redirect-fetch-impl.ts';
3
+ export default function noRedirectFetch(url: URL, init?: NoRedirectFetchInit): Promise<NoRedirectFetchResponse>;
4
+ export declare function createLookup(validatedAddresses: readonly string[] | undefined): NonNullable<http.RequestOptions['lookup']>;
@@ -0,0 +1,52 @@
1
+ import * as dns from 'node:dns';
2
+ import * as http from 'node:http';
3
+ import * as https from 'node:https';
4
+ import { isPrivateOrBlocked } from "./tools/private-ip.js";
5
+ import { runNoRedirectFetch } from "./no-redirect-fetch-impl.js";
6
+ export default function noRedirectFetch(url, init = {}) {
7
+ const request = (target, options, onresponse) => {
8
+ const common = {
9
+ method: options.method,
10
+ headers: options.headers,
11
+ lookup: createLookup(options.validatedAddresses)
12
+ };
13
+ const forward = (res) => onresponse(res);
14
+ return (target.protocol === 'https:' ? https : http).request(target.href, common, forward);
15
+ };
16
+ return runNoRedirectFetch(request, url, init);
17
+ }
18
+ export function createLookup(validatedAddresses) {
19
+ return (hostname, options, callback) => {
20
+ const wantsAll = typeof options === 'object' && options !== null && options.all === true;
21
+ const cb = callback;
22
+ const fail = () => {
23
+ cb(new Error(`Requests to "${hostname}" resolve to a blocked address.`), '', 0);
24
+ };
25
+ const respond = (records) => {
26
+ if (records.length === 0 || records.some((record) => isPrivateOrBlocked(record.address))) {
27
+ fail();
28
+ return;
29
+ }
30
+ if (wantsAll) {
31
+ cb(null, records);
32
+ return;
33
+ }
34
+ const [first] = records;
35
+ cb(null, first.address, first.family);
36
+ };
37
+ if (validatedAddresses !== undefined) {
38
+ respond(validatedAddresses.map((address) => ({
39
+ address,
40
+ family: address.includes(':') ? 6 : 4
41
+ })));
42
+ return;
43
+ }
44
+ dns.lookup(hostname, { all: true }, (err, records) => {
45
+ if (err) {
46
+ cb(err, '', 0);
47
+ return;
48
+ }
49
+ respond(records);
50
+ });
51
+ };
52
+ }
@@ -0,0 +1,22 @@
1
+ export declare const RAG_CITATION_LINE = "After your answer, add one final line naming the files you used, written exactly as [Sources: file-a.pdf, file-b.md] - or [Sources: none] if the excerpts did not answer the question. This line is required, it is the only place square brackets belong, and it is removed before the user sees it.";
2
+ export declare function currentTimeAnnotation(now?: Date): string;
3
+ export declare function annotateLastUserTime<T extends {
4
+ role: string;
5
+ content: string;
6
+ }>(turns: ReadonlyArray<T>, now?: Date): T[];
7
+ export interface SystemPromptInput {
8
+ bio?: string | null | undefined;
9
+ toolNames?: ReadonlyArray<string>;
10
+ skillsSection?: string | null;
11
+ }
12
+ export interface SystemPromptParts {
13
+ text: string;
14
+ bioChars: number;
15
+ skillsChars: number;
16
+ }
17
+ export declare function systemPromptParts({ bio, toolNames, skillsSection }: SystemPromptInput): SystemPromptParts;
18
+ export declare function buildSystemPrompt(input: SystemPromptInput): string;
19
+ export declare function skillsPromptSection(activeSkills: ReadonlyArray<{
20
+ name: string;
21
+ description: string;
22
+ }>): string | null;
@@ -0,0 +1,77 @@
1
+ const BASE_GUIDELINES = [
2
+ 'When the request is ambiguous, ask for clarification rather than guessing.'
3
+ ];
4
+ const TOOL_GUIDELINES = [
5
+ 'Request one action at a time; inspect the result before deciding the next step.',
6
+ 'If a tool fails, analyze the error and try a corrective action before asking the user for help.',
7
+ 'If a tool reports missing auth, setup, or approval, take the next tool step to complete it. Do not ask the user in chat whether to request approval; the policy/UI layer handles that.',
8
+ 'If the user asks you to use a tool, emit a tool call. Never claim external information was fetched or a side effect completed unless a tool result from this turn proves it.',
9
+ 'After tool execution, summarize the result for the user in plain language.',
10
+ 'Every gated tool takes an `intent`: one short sentence, addressed to the user, saying plainly what that call does for them — the outcome in their words, never the code. It is the only thing the approval prompt shows them, so never leave it out and never paste the command into it.'
11
+ ];
12
+ const EXEC_FILE_GUIDELINE = 'You CAN create and deliver files: run code with `exec` and declare the file names in `outputs` — each produced file is attached to the chat for the user to open or save. Never claim you cannot produce a file, and never instruct the user to run code or use another app to make one.';
13
+ const EXEC_ATTACHED_IMAGE_GUIDELINE = 'An image the user attached is a file you can use, not just something to look at: when they want it inside a file you build, stage that attachment as an `exec` input and embed it. Never generate a replacement for an image the user attached, and if you truly cannot use it, say so rather than delivering the file without it.';
14
+ const SKILL_GUIDELINES = [
15
+ 'Tools are typed callable functions; skills are markdown guidance for when and how to use them.',
16
+ 'Before your first action on a request, check the skills list. If a skill covers the capability you are about to use, call the `skill` tool to load its full instructions FIRST — before any other tool call, and before asking the user a follow-up; the instructions usually answer it.',
17
+ 'Never use a capability whose skill you have not loaded this conversation, and never claim a capability is unavailable without checking the skills list.',
18
+ 'Loaded instructions may point to more files in the skill (e.g. references/edit.md). Call the `skill` tool again with `name` and `file` to load one BEFORE doing the work it covers — never guess what a referenced file contains.'
19
+ ];
20
+ const CITATION_GUIDELINE = 'Search results arrive prefixed with source labels (`[1]`, `[Source 2: file, ...]`, `Source: <url>`). Do NOT echo those labels or refer to sources by number — they are shown to the user separately. Name a source (its file name or site) in natural prose when you rely on it. If the user explicitly asks for numbered references, produce them normally.';
21
+ export const RAG_CITATION_LINE = 'After your answer, add one final line naming the files you used, written exactly as [Sources: file-a.pdf, file-b.md] - or [Sources: none] if the excerpts did not answer the question. This line is required, it is the only place square brackets belong, and it is removed before the user sees it.';
22
+ const METADATA_SECTION = `## Message Metadata
23
+
24
+ User messages may include metadata such as [Current local time: ...]. This is contextual information provided by the system, not part of the user's query. Use it only when relevant and never repeat it unless the user asks about the current date or time.`;
25
+ export function currentTimeAnnotation(now = new Date()) {
26
+ const p = (n) => String(n).padStart(2, '0');
27
+ const stamp = `${now.getFullYear()}-${p(now.getMonth() + 1)}-${p(now.getDate())} ${p(now.getHours())}:${p(now.getMinutes())}:${p(now.getSeconds())}`;
28
+ const offset = -now.getTimezoneOffset();
29
+ const sign = offset < 0 ? '-' : '+';
30
+ const abs = Math.abs(offset);
31
+ return `[Current local time: ${stamp} (UTC${sign}${p(Math.floor(abs / 60))}:${p(abs % 60)})]`;
32
+ }
33
+ export function annotateLastUserTime(turns, now) {
34
+ const result = [...turns];
35
+ for (let i = result.length - 1; i >= 0; i--) {
36
+ const turn = result[i];
37
+ if (!turn || turn.role !== 'user')
38
+ continue;
39
+ result[i] = { ...turn, content: `${currentTimeAnnotation(now)}\n\n${turn.content}` };
40
+ break;
41
+ }
42
+ return result;
43
+ }
44
+ function buildGuidelines(active) {
45
+ const lines = [...BASE_GUIDELINES];
46
+ if (active.size > 0)
47
+ lines.push(...TOOL_GUIDELINES);
48
+ if (active.has('exec'))
49
+ lines.push(EXEC_FILE_GUIDELINE, EXEC_ATTACHED_IMAGE_GUIDELINE);
50
+ if (active.has('skill'))
51
+ lines.push(...SKILL_GUIDELINES);
52
+ if (active.has('web_search') || active.has('web_fetch')) {
53
+ lines.push(CITATION_GUIDELINE);
54
+ }
55
+ return `**Guidelines:**\n${lines.map((line) => `- ${line}`).join('\n')}`;
56
+ }
57
+ export function systemPromptParts({ bio, toolNames = [], skillsSection }) {
58
+ const active = new Set(toolNames);
59
+ const header = active.size
60
+ ? 'You are a helpful AI assistant with access to tools.'
61
+ : 'You are a helpful AI assistant.';
62
+ const preamble = `${header}\n\n${METADATA_SECTION}`;
63
+ const skills = active.has('skill') ? skillsSection : null;
64
+ const text = [preamble, bio, skills, buildGuidelines(active)]
65
+ .filter((part) => Boolean(part))
66
+ .join('\n\n');
67
+ return { text, bioChars: (bio ?? '').length, skillsChars: (skills ?? '').length };
68
+ }
69
+ export function buildSystemPrompt(input) {
70
+ return systemPromptParts(input).text;
71
+ }
72
+ export function skillsPromptSection(activeSkills) {
73
+ if (!activeSkills.length)
74
+ return null;
75
+ const lines = activeSkills.map((skill) => `- ${skill.name}: ${skill.description}`).join('\n');
76
+ return `Skills available this turn. You MUST call the \`skill\` tool with its name BEFORE using the capability it describes — load the skill first, then act.\n${lines}`;
77
+ }
@@ -0,0 +1,9 @@
1
+ export interface PushQueue<T> extends AsyncIterable<T> {
2
+ push(item: T): Promise<void>;
3
+ end(): void;
4
+ readonly size: number;
5
+ }
6
+ export interface PushQueueOptions {
7
+ highWaterMark?: number;
8
+ }
9
+ export declare function pushQueue<T>({ highWaterMark }?: PushQueueOptions): PushQueue<T>;