@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,7 @@
1
+ import type { MemoryBudget } from './memory-budget.ts';
2
+ export declare const IGPU_LIE_THRESHOLD = 0.9;
3
+ export declare function parseNvidiaSmiOutput(stdout: string): MemoryBudget | null;
4
+ export declare function parseRocmSmiOutput(stdout: string): MemoryBudget | null;
5
+ export declare function parseWindowsRegistryOutput(stdout: string, systemRamBytes: number): MemoryBudget | null;
6
+ export declare function sharedRamBudget(ramBytes: number): MemoryBudget;
7
+ export declare function mobileBudget(ramBytes: number, isPixel: boolean): MemoryBudget;
@@ -0,0 +1,41 @@
1
+ const GIB = 1024 * 1024 * 1024;
2
+ const SHARED_RAM_RESERVE_BYTES = 3 * GIB;
3
+ const SHARED_RAM_FRACTION = 0.8;
4
+ const MOBILE_FRACTION = 0.6;
5
+ const MOBILE_PIXEL_FRACTION = 0.4;
6
+ export const IGPU_LIE_THRESHOLD = 0.9;
7
+ export function parseNvidiaSmiOutput(stdout) {
8
+ const firstLine = stdout.split('\n')[0] ?? '';
9
+ const mib = Number.parseInt(firstLine, 10);
10
+ if (Number.isNaN(mib) || mib <= 0)
11
+ return null;
12
+ const bytes = mib * 1024 * 1024;
13
+ return { totalBytes: bytes, availableBytes: bytes, source: 'vram', gpuClass: 'discrete' };
14
+ }
15
+ export function parseRocmSmiOutput(stdout) {
16
+ const match = /Total.*?:\s*(\d+)/i.exec(stdout);
17
+ if (!match)
18
+ return null;
19
+ const bytes = Number.parseInt(match[1] ?? '', 10);
20
+ if (Number.isNaN(bytes) || bytes <= 0)
21
+ return null;
22
+ return { totalBytes: bytes, availableBytes: bytes, source: 'vram' };
23
+ }
24
+ export function parseWindowsRegistryOutput(stdout, systemRamBytes) {
25
+ const firstLine = stdout.split('\n')[0] ?? '';
26
+ const bytes = Number.parseInt(firstLine, 10);
27
+ if (Number.isNaN(bytes) || bytes <= 0)
28
+ return null;
29
+ if (bytes > systemRamBytes * IGPU_LIE_THRESHOLD) {
30
+ return { ...sharedRamBudget(systemRamBytes), source: 'integrated' };
31
+ }
32
+ return { totalBytes: bytes, availableBytes: bytes, source: 'vram' };
33
+ }
34
+ export function sharedRamBudget(ramBytes) {
35
+ const available = Math.min(ramBytes * SHARED_RAM_FRACTION, ramBytes - SHARED_RAM_RESERVE_BYTES);
36
+ return { totalBytes: ramBytes, availableBytes: Math.max(available, 0), source: 'shared' };
37
+ }
38
+ export function mobileBudget(ramBytes, isPixel) {
39
+ const fraction = isPixel ? MOBILE_PIXEL_FRACTION : MOBILE_FRACTION;
40
+ return { totalBytes: ramBytes, availableBytes: ramBytes * fraction, source: 'mobile' };
41
+ }
@@ -0,0 +1 @@
1
+ export { Headers } from 'bare-fetch';
@@ -0,0 +1 @@
1
+ export { Headers } from 'bare-fetch';
@@ -0,0 +1,4 @@
1
+ export declare const Headers: {
2
+ new (init?: HeadersInit): Headers;
3
+ prototype: Headers;
4
+ };
@@ -0,0 +1 @@
1
+ export const Headers = globalThis.Headers;
@@ -0,0 +1 @@
1
+ export declare function bufferBurst(tokens: AsyncIterable<string>, ms: number): AsyncGenerator<string>;
@@ -0,0 +1,20 @@
1
+ export async function* bufferBurst(tokens, ms) {
2
+ const deadline = Date.now() + ms;
3
+ let burst = '';
4
+ for await (const token of tokens) {
5
+ if (burst === null) {
6
+ yield token;
7
+ continue;
8
+ }
9
+ if (Date.now() >= deadline) {
10
+ if (burst)
11
+ yield burst;
12
+ burst = null;
13
+ yield token;
14
+ continue;
15
+ }
16
+ burst += token;
17
+ }
18
+ if (burst)
19
+ yield burst;
20
+ }
@@ -0,0 +1,7 @@
1
+ export declare const STOP_MARKERS: readonly string[];
2
+ export declare const RUNAWAY_STOP_SEQUENCES: readonly string[];
3
+ export declare function endsTurn(token: string): boolean;
4
+ export declare function controlTokenIndex(text: string): number;
5
+ export declare function truncateAtControlToken(text: string): string;
6
+ export declare function stripControlTokens(text: string): string;
7
+ export declare function stopAtControlToken(tokens: AsyncIterable<string>, onStop?: (token: string) => void): AsyncGenerator<string>;
@@ -0,0 +1,32 @@
1
+ import { firstMarker, markers, strip, truncateAt } from 'asenion/guards';
2
+ import { scanner } from 'asenion/scan';
3
+ export const STOP_MARKERS = [...markers.controlTokens, ...markers.scaffold];
4
+ const [SCAFFOLD_OPENING] = markers.scaffold;
5
+ export const RUNAWAY_STOP_SEQUENCES = [SCAFFOLD_OPENING];
6
+ export function endsTurn(token) {
7
+ return markers.turnEnd.includes(token);
8
+ }
9
+ export function controlTokenIndex(text) {
10
+ return firstMarker(text, STOP_MARKERS)?.index ?? -1;
11
+ }
12
+ export function truncateAtControlToken(text) {
13
+ return truncateAt(text, STOP_MARKERS);
14
+ }
15
+ export function stripControlTokens(text) {
16
+ return strip(truncateAt(text, markers.scaffold), markers.controlTokens);
17
+ }
18
+ export async function* stopAtControlToken(tokens, onStop) {
19
+ const safe = scanner({ stop: STOP_MARKERS });
20
+ for await (const token of tokens) {
21
+ const shown = safe.push(token);
22
+ if (shown)
23
+ yield shown;
24
+ if (safe.stopped !== null) {
25
+ onStop?.(safe.stopped);
26
+ return;
27
+ }
28
+ }
29
+ const rest = safe.flush();
30
+ if (rest)
31
+ yield rest;
32
+ }
@@ -0,0 +1,6 @@
1
+ export type JoinGuard = {
2
+ readonly push: (text: string) => string;
3
+ readonly cut: () => void;
4
+ readonly flush: () => string;
5
+ };
6
+ export declare function createJoinGuard(markers: readonly string[]): JoinGuard;
@@ -0,0 +1,46 @@
1
+ import { holdback } from 'asenion/scan';
2
+ export function createJoinGuard(markers) {
3
+ let held = '';
4
+ let join = -1;
5
+ return {
6
+ push(text) {
7
+ let buffer = held + text;
8
+ if (join !== -1) {
9
+ const mended = mend(buffer, join, markers);
10
+ buffer = mended.text;
11
+ join = mended.at;
12
+ }
13
+ const keep = holdback(buffer, markers);
14
+ const shown = buffer.slice(0, buffer.length - keep);
15
+ held = buffer.slice(buffer.length - keep);
16
+ join = join === -1 || join < shown.length ? -1 : join - shown.length;
17
+ return shown;
18
+ },
19
+ cut() {
20
+ join = held.length;
21
+ },
22
+ flush() {
23
+ const rest = held;
24
+ held = '';
25
+ join = -1;
26
+ return rest;
27
+ }
28
+ };
29
+ }
30
+ function mend(text, at, markers) {
31
+ for (;;) {
32
+ const found = spanning(text, at, markers);
33
+ if (found === null)
34
+ return { text, at };
35
+ text = text.slice(0, found.index) + text.slice(found.index + found.marker.length);
36
+ at = found.index;
37
+ }
38
+ }
39
+ function spanning(text, at, markers) {
40
+ for (const marker of markers) {
41
+ const index = text.indexOf(marker, Math.max(0, at - marker.length + 1));
42
+ if (index !== -1 && index < at)
43
+ return { index, marker };
44
+ }
45
+ return null;
46
+ }
@@ -0,0 +1,5 @@
1
+ export type MarkupStreamFilter = {
2
+ readonly push: (token: string) => string;
3
+ readonly flush: () => string;
4
+ };
5
+ export declare function createMarkupStreamFilter(): MarkupStreamFilter;
@@ -0,0 +1,75 @@
1
+ import { firstMarker } from 'asenion/guards';
2
+ import { holdback } from 'asenion/scan';
3
+ import { createJoinGuard } from "./join-guard.js";
4
+ const MARKUP_OPENERS = ['<tool_call>', '<function=', '<tool_response>'];
5
+ const MARKUP_CLOSERS = {
6
+ '<tool_call>': '</tool_call>',
7
+ '<function=': '</function>',
8
+ '<tool_response>': '</tool_response>'
9
+ };
10
+ const MARKUP_MARKERS = [...MARKUP_OPENERS, ...Object.values(MARKUP_CLOSERS)];
11
+ export function createMarkupStreamFilter() {
12
+ const state = {
13
+ buffer: '',
14
+ closer: null,
15
+ stripNewline: false,
16
+ guard: createJoinGuard(MARKUP_MARKERS)
17
+ };
18
+ return {
19
+ push(token) {
20
+ state.buffer += token;
21
+ let out = '';
22
+ for (;;) {
23
+ const step = state.closer ? consumeSuppressed(state) : emitUntilOpener(state);
24
+ out += step.out;
25
+ if (step.done)
26
+ return out;
27
+ }
28
+ },
29
+ flush() {
30
+ dropResumeNewline(state);
31
+ const rest = state.guard.push(state.closer ? '' : state.buffer) + state.guard.flush();
32
+ state.buffer = '';
33
+ state.closer = null;
34
+ state.stripNewline = false;
35
+ return rest;
36
+ }
37
+ };
38
+ }
39
+ function consumeSuppressed(state) {
40
+ const closer = state.closer ?? '';
41
+ const end = state.buffer.indexOf(closer);
42
+ if (end === -1) {
43
+ state.buffer = state.buffer.slice(state.buffer.length - holdback(state.buffer, [closer]));
44
+ return { out: '', done: true };
45
+ }
46
+ state.buffer = state.buffer.slice(end + closer.length);
47
+ state.stripNewline = true;
48
+ state.closer = null;
49
+ return { out: '', done: false };
50
+ }
51
+ function dropResumeNewline(state) {
52
+ if (!state.stripNewline || state.buffer.length === 0)
53
+ return;
54
+ state.stripNewline = false;
55
+ if (state.buffer[0] === '\n')
56
+ state.buffer = state.buffer.slice(1);
57
+ }
58
+ function emitUntilOpener(state) {
59
+ dropResumeNewline(state);
60
+ const marker = firstMarker(state.buffer, MARKUP_MARKERS);
61
+ if (marker) {
62
+ const out = state.guard.push(state.buffer.slice(0, marker.index));
63
+ state.guard.cut();
64
+ state.buffer = state.buffer.slice(marker.index + marker.marker.length);
65
+ const closer = MARKUP_CLOSERS[marker.marker];
66
+ if (closer === undefined)
67
+ state.stripNewline = true;
68
+ state.closer = closer ?? null;
69
+ return { out, done: false };
70
+ }
71
+ const hold = holdback(state.buffer, MARKUP_MARKERS);
72
+ const out = state.guard.push(state.buffer.slice(0, state.buffer.length - hold));
73
+ state.buffer = state.buffer.slice(state.buffer.length - hold);
74
+ return { out, done: true };
75
+ }
@@ -0,0 +1,5 @@
1
+ import type { AbortSignal as BareAbortSignal } from 'bare-abort-controller';
2
+ export declare class AbortedError extends Error {
3
+ constructor();
4
+ }
5
+ export declare function raceAbort<T>(promise: Promise<T>, signal?: BareAbortSignal): Promise<T>;
@@ -0,0 +1,18 @@
1
+ export class AbortedError extends Error {
2
+ constructor() {
3
+ super('aborted');
4
+ this.name = 'AbortedError';
5
+ Error.captureStackTrace?.(this, AbortedError);
6
+ }
7
+ }
8
+ export function raceAbort(promise, signal) {
9
+ if (!signal)
10
+ return promise;
11
+ if (signal.aborted)
12
+ return Promise.reject(new AbortedError());
13
+ return new Promise((resolve, reject) => {
14
+ const onAbort = () => reject(new AbortedError());
15
+ signal.addEventListener('abort', onAbort, { once: true });
16
+ promise.then(resolve, reject).finally(() => signal.removeEventListener('abort', onAbort));
17
+ });
18
+ }
@@ -0,0 +1,5 @@
1
+ export interface RetryMemo<T> {
2
+ (): Promise<T>;
3
+ peek(): Promise<T> | null;
4
+ }
5
+ export declare function retryMemo<T>(load: () => Promise<T>): RetryMemo<T>;
@@ -0,0 +1,12 @@
1
+ export function retryMemo(load) {
2
+ let memo = null;
3
+ return Object.assign(() => {
4
+ memo ??= Promise.resolve()
5
+ .then(load)
6
+ .catch((err) => {
7
+ memo = null;
8
+ throw err;
9
+ });
10
+ return memo;
11
+ }, { peek: () => memo });
12
+ }
@@ -0,0 +1,33 @@
1
+ import type { ToolExecutionOutcome } from '../tool-call-display.ts';
2
+ export type RunOutcome = 'answered' | 'mute' | 'exhausted' | 'search-capped' | 'time-capped';
3
+ export declare const DEGENERATE_ANSWER_FALLBACK = "I couldn't complete that step and don't have a useful result to share.";
4
+ export declare const ROUND_CAP_ANSWER = "I ran out of steps before I could finish that. Ask me to continue and I'll pick up where I left off.";
5
+ export declare const SEARCH_CAPPED_ANSWER = "I searched the web but couldn't find the answer in the results I got.";
6
+ export declare const WRITE_RESULT_LEAD = "Here's what came back:";
7
+ export declare const TIME_CAPPED_ANSWER = "I hit this run's time budget before I could finish that. Ask me to continue and I'll pick up where I left off.";
8
+ export interface RunOutcomeFacts {
9
+ readonly latestFailure: string | null;
10
+ readonly confirmedWrites: ReadonlyArray<string>;
11
+ }
12
+ export interface RunOutcomeTracker {
13
+ readonly confirmedWrites: string[];
14
+ beginRound(): void;
15
+ record(result: unknown, outcome: ToolExecutionOutcome): void;
16
+ finishRound(): void;
17
+ confirmWrite(result: unknown): void;
18
+ facts(): RunOutcomeFacts;
19
+ }
20
+ export declare function createRunOutcomeTracker(): RunOutcomeTracker;
21
+ export declare function normalizeToolExecutionOutcome(result: unknown, outcome: ToolExecutionOutcome): ToolExecutionOutcome;
22
+ export declare function failureFromToolExecution(result: unknown, outcome: ToolExecutionOutcome): string | null;
23
+ export declare function degenerateAnswer(outcome: Exclude<RunOutcome, 'answered'>, history: ReadonlyArray<{
24
+ role: string;
25
+ content: string;
26
+ }>, facts?: RunOutcomeFacts): string;
27
+ export declare function lastFailedToolAnswer(history: ReadonlyArray<{
28
+ role: string;
29
+ content: string;
30
+ }>): string | null;
31
+ export declare function writeResult(output: unknown): string | null;
32
+ export declare function unnamedWrites(answer: string, landed: ReadonlyArray<string>): ReadonlyArray<string>;
33
+ export declare function writeReport(landed: ReadonlyArray<string>): string | null;
@@ -0,0 +1,204 @@
1
+ import { TOOL_CONTINUATION_NUDGE } from "../capabilities/tool-turns.js";
2
+ export const DEGENERATE_ANSWER_FALLBACK = "I couldn't complete that step and don't have a useful result to share.";
3
+ export const ROUND_CAP_ANSWER = "I ran out of steps before I could finish that. Ask me to continue and I'll pick up where I left off.";
4
+ export const SEARCH_CAPPED_ANSWER = "I searched the web but couldn't find the answer in the results I got.";
5
+ export const WRITE_RESULT_LEAD = "Here's what came back:";
6
+ export const TIME_CAPPED_ANSWER = "I hit this run's time budget before I could finish that. Ask me to continue and I'll pick up where I left off.";
7
+ const MAX_FAILURE_CHARS = 300;
8
+ const MAX_SUCCESS_CHARS = 800;
9
+ const MAX_WRITES_LISTED = 4;
10
+ const MAX_CAPPED_SOURCES = 3;
11
+ const TOOL_RESULT_HEADER_RE = /^\[Tool: [^(\]]+ \([^)]+\)\]\n/;
12
+ const WEB_SEARCH_TURN_RE = /^\[Tool: web_search /;
13
+ const RESULT_ENTRY_RE = /\[\d+\] ([^\n]+)\nSource: (\S+)/g;
14
+ const WRITE_ID_RE = /[0-9a-f]{8}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{12}/gi;
15
+ export function createRunOutcomeTracker() {
16
+ const confirmedWrites = [];
17
+ let roundFailure = null;
18
+ let latestFailure = null;
19
+ let hasRoundResult = false;
20
+ return {
21
+ confirmedWrites,
22
+ beginRound() {
23
+ roundFailure = null;
24
+ hasRoundResult = false;
25
+ },
26
+ record(result, outcome) {
27
+ hasRoundResult = true;
28
+ const failure = failureFromToolExecution(result, outcome);
29
+ if (failure)
30
+ roundFailure = failure;
31
+ },
32
+ finishRound() {
33
+ if (!hasRoundResult)
34
+ return;
35
+ latestFailure = roundFailure;
36
+ },
37
+ confirmWrite(result) {
38
+ const write = writeResult(result);
39
+ if (write)
40
+ confirmedWrites.push(write);
41
+ },
42
+ facts() {
43
+ return { latestFailure, confirmedWrites };
44
+ }
45
+ };
46
+ }
47
+ export function normalizeToolExecutionOutcome(result, outcome) {
48
+ if (outcome.kind !== 'success')
49
+ return outcome;
50
+ const failure = resultFailure(result);
51
+ return failure ? { kind: 'error', message: failure } : outcome;
52
+ }
53
+ export function failureFromToolExecution(result, outcome) {
54
+ if (outcome.kind === 'denied' || outcome.kind === 'blocked' || outcome.kind === 'guidance') {
55
+ return null;
56
+ }
57
+ if (outcome.kind === 'error') {
58
+ return bound(outcome.message ?? resultFailure(result) ?? 'The request failed.', MAX_FAILURE_CHARS);
59
+ }
60
+ return resultFailure(result);
61
+ }
62
+ export function degenerateAnswer(outcome, history, facts) {
63
+ const rest = (facts ? facts.latestFailure : lastFailedToolAnswer(history)) ?? cappedAnswer(outcome, history);
64
+ const written = writeReport(facts?.confirmedWrites ?? []);
65
+ if (written)
66
+ return rest ? `${written}\n\n${rest}` : written;
67
+ return rest ?? DEGENERATE_ANSWER_FALLBACK;
68
+ }
69
+ function cappedAnswer(outcome, history) {
70
+ if (outcome === 'search-capped')
71
+ return searchCappedAnswer(history);
72
+ if (outcome === 'time-capped')
73
+ return TIME_CAPPED_ANSWER;
74
+ return outcome === 'exhausted' ? ROUND_CAP_ANSWER : null;
75
+ }
76
+ function searchCappedAnswer(history) {
77
+ const seen = new Set();
78
+ const lines = [];
79
+ for (const turn of history) {
80
+ if (lines.length === MAX_CAPPED_SOURCES)
81
+ break;
82
+ if (turn.role !== 'tool' || !WEB_SEARCH_TURN_RE.test(turn.content))
83
+ continue;
84
+ const payload = parsed(turn.content.replace(TOOL_RESULT_HEADER_RE, ''));
85
+ const content = typeof payload?.content === 'string' ? payload.content : '';
86
+ for (const [, title, url] of content.matchAll(RESULT_ENTRY_RE)) {
87
+ if (title === undefined || url === undefined)
88
+ continue;
89
+ if (seen.has(url))
90
+ continue;
91
+ seen.add(url);
92
+ lines.push(`- ${title.trim()}: ${url}`);
93
+ if (lines.length === MAX_CAPPED_SOURCES)
94
+ break;
95
+ }
96
+ }
97
+ if (!lines.length)
98
+ return SEARCH_CAPPED_ANSWER;
99
+ return `${SEARCH_CAPPED_ANSWER} These pages looked most relevant:\n${lines.join('\n')}`;
100
+ }
101
+ export function lastFailedToolAnswer(history) {
102
+ for (let i = history.length - 1; i >= 0; i--) {
103
+ const turn = history[i];
104
+ if (turn?.role === 'user' && turn.content === TOOL_CONTINUATION_NUDGE)
105
+ continue;
106
+ if (turn?.role !== 'tool')
107
+ return null;
108
+ const failure = failureText(turn.content.replace(TOOL_RESULT_HEADER_RE, ''));
109
+ if (failure)
110
+ return failure;
111
+ }
112
+ return null;
113
+ }
114
+ export function writeResult(output) {
115
+ const result = asRecord(output);
116
+ if (!result || typeof result.status !== 'number')
117
+ return null;
118
+ if (result.status >= 400 || nonEmpty(result.error))
119
+ return null;
120
+ return nonEmpty(result.body);
121
+ }
122
+ export function unnamedWrites(answer, landed) {
123
+ const said = withoutDashes(answer);
124
+ return landed.filter((write) => {
125
+ const ids = writeIds(write);
126
+ return ids.length > 0 && !ids.some((id) => said.includes(id));
127
+ });
128
+ }
129
+ function writeIds(write) {
130
+ return [...write.matchAll(WRITE_ID_RE)].map(([id]) => withoutDashes(id));
131
+ }
132
+ function withoutDashes(text) {
133
+ return text.toLowerCase().replace(/-/g, '');
134
+ }
135
+ export function writeReport(landed) {
136
+ if (!landed.length)
137
+ return null;
138
+ const listed = landed.slice(0, MAX_WRITES_LISTED);
139
+ const share = Math.floor(MAX_SUCCESS_CHARS / listed.length);
140
+ const lines = listed.map((write) => bound(write, share));
141
+ const dropped = landed.length - listed.length;
142
+ if (dropped)
143
+ lines.push(`(+${dropped} more)`);
144
+ return `${WRITE_RESULT_LEAD}\n${lines.join('\n')}`;
145
+ }
146
+ function failureText(payload) {
147
+ const result = parsed(payload);
148
+ return resultFailure(result);
149
+ }
150
+ function resultFailure(value) {
151
+ const result = typeof value === 'string' ? parsed(value) : asRecord(value);
152
+ if (!result)
153
+ return null;
154
+ if (result.denied === true || result.guidance === true)
155
+ return null;
156
+ const status = typeof result.status === 'number' ? result.status : null;
157
+ const httpSuffix = status !== null && status >= 400 ? ` (HTTP ${status.toString()})` : '';
158
+ const error = nonEmpty(result.error);
159
+ if (error)
160
+ return `${bound(error, MAX_FAILURE_CHARS)}${httpSuffix}`;
161
+ if (status !== null && status >= 400)
162
+ return httpFailure(status, result.body);
163
+ if (typeof result.exitCode === 'number' && result.exitCode !== 0) {
164
+ const output = nonEmpty(result.stderr) ?? nonEmpty(result.stdout);
165
+ return output ? bound(output, MAX_FAILURE_CHARS) : null;
166
+ }
167
+ return null;
168
+ }
169
+ function httpFailure(status, body) {
170
+ const message = apiMessage(body);
171
+ return message
172
+ ? `${bound(message, MAX_FAILURE_CHARS)} (HTTP ${status})`
173
+ : `The request failed with HTTP ${status}.`;
174
+ }
175
+ function apiMessage(body) {
176
+ const value = typeof body === 'string' ? parsed(body) : asRecord(body);
177
+ if (!value)
178
+ return null;
179
+ const error = value.error;
180
+ const fromError = typeof error === 'string' ? nonEmpty(error) : nonEmpty(asRecord(error)?.['message']);
181
+ return fromError ?? nonEmpty(value.message);
182
+ }
183
+ function parsed(payload) {
184
+ try {
185
+ return asRecord(JSON.parse(payload));
186
+ }
187
+ catch {
188
+ return null;
189
+ }
190
+ }
191
+ function asRecord(value) {
192
+ return value && typeof value === 'object' && !Array.isArray(value)
193
+ ? value
194
+ : null;
195
+ }
196
+ function nonEmpty(value) {
197
+ if (typeof value !== 'string')
198
+ return null;
199
+ const text = value.trim();
200
+ return text || null;
201
+ }
202
+ function bound(text, max) {
203
+ return text.length > max ? `${text.slice(0, max).trimEnd()}…` : text;
204
+ }
@@ -0,0 +1,5 @@
1
+ export declare const HOMEBREW_BIN_DIRS: readonly string[];
2
+ export declare function withHomebrewPath(path: string | undefined, platformName: string): string | undefined;
3
+ export declare const EXEC_ENV_ALLOWLIST: readonly ["PATH", "HOME", "TMPDIR", "TMP", "TEMP", "LANG", "LC_ALL", "LC_CTYPE", "TZ", "USER", "LOGNAME", "HTTP_PROXY", "http_proxy", "HTTPS_PROXY", "https_proxy", "ALL_PROXY", "all_proxy", "NO_PROXY", "no_proxy", "SSL_CERT_FILE", "SSL_CERT_DIR", "CURL_CA_BUNDLE", "REQUESTS_CA_BUNDLE", "NODE_EXTRA_CA_CERTS"];
4
+ export declare function execEnv(env: Readonly<Record<string, string | undefined>>, platformName: string): Record<string, string>;
5
+ export declare function spawnEnv(env: Readonly<Record<string, string | undefined>>, platformName: string, overrides?: Readonly<Record<string, string>>): Record<string, string>;
@@ -0,0 +1,57 @@
1
+ export const HOMEBREW_BIN_DIRS = ['/opt/homebrew/bin', '/usr/local/bin'];
2
+ export function withHomebrewPath(path, platformName) {
3
+ if (platformName !== 'darwin')
4
+ return path;
5
+ const dirs = (path ?? '').split(':').filter(Boolean);
6
+ const seen = new Set(dirs);
7
+ const missing = HOMEBREW_BIN_DIRS.filter((dir) => !seen.has(dir));
8
+ if (missing.length === 0)
9
+ return path;
10
+ return [...dirs, ...missing].join(':');
11
+ }
12
+ export const EXEC_ENV_ALLOWLIST = [
13
+ 'PATH',
14
+ 'HOME',
15
+ 'TMPDIR',
16
+ 'TMP',
17
+ 'TEMP',
18
+ 'LANG',
19
+ 'LC_ALL',
20
+ 'LC_CTYPE',
21
+ 'TZ',
22
+ 'USER',
23
+ 'LOGNAME',
24
+ 'HTTP_PROXY',
25
+ 'http_proxy',
26
+ 'HTTPS_PROXY',
27
+ 'https_proxy',
28
+ 'ALL_PROXY',
29
+ 'all_proxy',
30
+ 'NO_PROXY',
31
+ 'no_proxy',
32
+ 'SSL_CERT_FILE',
33
+ 'SSL_CERT_DIR',
34
+ 'CURL_CA_BUNDLE',
35
+ 'REQUESTS_CA_BUNDLE',
36
+ 'NODE_EXTRA_CA_CERTS'
37
+ ];
38
+ const PLATFORM_EXEC_ENV_ALLOWLIST = {
39
+ win32: ['SystemRoot', 'COMSPEC', 'PATHEXT', 'USERPROFILE'],
40
+ linux: ['DISPLAY', 'WAYLAND_DISPLAY', 'XDG_RUNTIME_DIR']
41
+ };
42
+ export function execEnv(env, platformName) {
43
+ const out = {};
44
+ const keys = [...EXEC_ENV_ALLOWLIST, ...(PLATFORM_EXEC_ENV_ALLOWLIST[platformName] ?? [])];
45
+ for (const key of keys) {
46
+ const value = env[key];
47
+ if (value !== undefined)
48
+ out[key] = value;
49
+ }
50
+ const path = withHomebrewPath(out.PATH ?? env.Path, platformName);
51
+ if (path !== undefined)
52
+ out.PATH = path;
53
+ return out;
54
+ }
55
+ export function spawnEnv(env, platformName, overrides) {
56
+ return { ...execEnv(env, platformName), ...overrides };
57
+ }
@@ -0,0 +1,15 @@
1
+ export type TextType = 'content' | 'thinking';
2
+ export interface TextCoalescerOptions {
3
+ cap?: number;
4
+ holdMs?: number;
5
+ }
6
+ export declare class TextCoalescer {
7
+ private readonly _write;
8
+ private readonly _cap;
9
+ private readonly _holdMs;
10
+ private _buffered;
11
+ private _hold;
12
+ constructor(write: (type: TextType, text: string) => Promise<void>, { cap, holdMs }?: TextCoalescerOptions);
13
+ add(type: TextType, text: string): Promise<void>;
14
+ flush(): Promise<void>;
15
+ }
@@ -0,0 +1,34 @@
1
+ export class TextCoalescer {
2
+ _write;
3
+ _cap;
4
+ _holdMs;
5
+ _buffered = null;
6
+ _hold = null;
7
+ constructor(write, { cap = 8192, holdMs = 60 } = {}) {
8
+ this._write = write;
9
+ this._cap = cap;
10
+ this._holdMs = holdMs;
11
+ }
12
+ async add(type, text) {
13
+ if (this._buffered && this._buffered.type !== type)
14
+ await this.flush();
15
+ if (!this._buffered) {
16
+ this._buffered = { type, text: '' };
17
+ this._hold = setTimeout(() => void this.flush(), this._holdMs);
18
+ }
19
+ this._buffered.text += text;
20
+ if (this._buffered.text.length >= this._cap)
21
+ await this.flush();
22
+ }
23
+ flush() {
24
+ if (this._hold) {
25
+ clearTimeout(this._hold);
26
+ this._hold = null;
27
+ }
28
+ if (!this._buffered)
29
+ return Promise.resolve();
30
+ const { type, text } = this._buffered;
31
+ this._buffered = null;
32
+ return this._write(type, text);
33
+ }
34
+ }