@qvac/harness 1.0.0-rc.3 → 1.0.0-rc.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (460) hide show
  1. package/.nvmrc +1 -0
  2. package/CHANGELOG.md +2280 -1485
  3. package/README.md +44 -31
  4. package/dist-lib/index.d.ts +50 -6
  5. package/dist-lib/index.js +130 -28
  6. package/dist-lib/lib/agent/delegate.d.ts +3 -2
  7. package/dist-lib/lib/agent/delegate.js +6 -4
  8. package/dist-lib/lib/agent/follow.d.ts +5 -0
  9. package/dist-lib/lib/agent/follow.js +2 -0
  10. package/dist-lib/lib/agent/resolve.js +22 -17
  11. package/dist-lib/lib/agent/tool-selection.d.ts +4 -2
  12. package/dist-lib/lib/agent/tool-selection.js +5 -6
  13. package/dist-lib/lib/agent/tools.d.ts +1 -0
  14. package/dist-lib/lib/agent/tools.js +2 -1
  15. package/dist-lib/lib/capabilities/agent-ports.js +3 -3
  16. package/dist-lib/lib/capabilities/completion-engine/actors/batching.js +1 -0
  17. package/dist-lib/lib/capabilities/completion-engine/actors/direct-search.js +2 -0
  18. package/dist-lib/lib/capabilities/completion-engine/actors/executing.js +60 -9
  19. package/dist-lib/lib/capabilities/completion-engine/actors/execution-plan.js +4 -4
  20. package/dist-lib/lib/capabilities/completion-engine/actors/inspect-prepare.js +3 -2
  21. package/dist-lib/lib/capabilities/completion-engine/actors/inspecting.js +35 -6
  22. package/dist-lib/lib/capabilities/completion-engine/actors/loading-skill.d.ts +1 -1
  23. package/dist-lib/lib/capabilities/completion-engine/actors/loading-skill.js +2 -0
  24. package/dist-lib/lib/capabilities/completion-engine/actors/preparing.js +67 -27
  25. package/dist-lib/lib/capabilities/completion-engine/actors/rejecting.js +6 -1
  26. package/dist-lib/lib/capabilities/completion-engine/actors/resolving.js +61 -16
  27. package/dist-lib/lib/capabilities/completion-engine/actors/retrieving.js +2 -2
  28. package/dist-lib/lib/capabilities/completion-engine/actors/skill-step.js +23 -13
  29. package/dist-lib/lib/capabilities/completion-engine/actors/stream.d.ts +8 -3
  30. package/dist-lib/lib/capabilities/completion-engine/actors/stream.js +61 -3
  31. package/dist-lib/lib/capabilities/completion-engine/actors/streaming.d.ts +5 -1
  32. package/dist-lib/lib/capabilities/completion-engine/actors/streaming.js +47 -21
  33. package/dist-lib/lib/capabilities/completion-engine/actors/wrap-up.d.ts +1 -0
  34. package/dist-lib/lib/capabilities/completion-engine/actors/wrap-up.js +30 -5
  35. package/dist-lib/lib/capabilities/completion-engine/driver.js +27 -11
  36. package/dist-lib/lib/capabilities/completion-engine/durable.d.ts +1 -0
  37. package/dist-lib/lib/capabilities/completion-engine/durable.js +5 -1
  38. package/dist-lib/lib/capabilities/completion-engine/index.d.ts +2 -1
  39. package/dist-lib/lib/capabilities/completion-engine/index.js +2 -2
  40. package/dist-lib/lib/capabilities/completion-engine/loop.d.ts +15 -2
  41. package/dist-lib/lib/capabilities/completion-engine/loop.js +7 -0
  42. package/dist-lib/lib/capabilities/completion-engine/metrics.d.ts +9 -2
  43. package/dist-lib/lib/capabilities/completion-engine/metrics.js +28 -7
  44. package/dist-lib/lib/capabilities/completion-engine/model-round.d.ts +46 -0
  45. package/dist-lib/lib/capabilities/completion-engine/model-round.js +45 -0
  46. package/dist-lib/lib/capabilities/completion-engine/operations.js +1 -1
  47. package/dist-lib/lib/capabilities/completion-engine/ports.js +3 -7
  48. package/dist-lib/lib/capabilities/completion-engine/round.d.ts +23 -3
  49. package/dist-lib/lib/capabilities/completion-engine/round.js +323 -97
  50. package/dist-lib/lib/capabilities/completion-engine/session.d.ts +10 -3
  51. package/dist-lib/lib/capabilities/completion-engine/session.js +30 -2
  52. package/dist-lib/lib/capabilities/completion-engine/tool-caller.js +3 -2
  53. package/dist-lib/lib/capabilities/completion-engine/tool-execution.d.ts +4 -3
  54. package/dist-lib/lib/capabilities/completion-engine/tool-execution.js +15 -10
  55. package/dist-lib/lib/capabilities/completion-engine/turns.d.ts +11 -4
  56. package/dist-lib/lib/capabilities/completion-engine/turns.js +48 -65
  57. package/dist-lib/lib/capabilities/download.d.ts +9 -7
  58. package/dist-lib/lib/capabilities/download.js +1 -1
  59. package/dist-lib/lib/capabilities/enhance.d.ts +1 -1
  60. package/dist-lib/lib/capabilities/enhance.js +20 -8
  61. package/dist-lib/lib/capabilities/preview-model-source.d.ts +7 -0
  62. package/dist-lib/lib/capabilities/preview-model-source.js +83 -23
  63. package/dist-lib/lib/capabilities/sdk-tool.d.ts +1 -0
  64. package/dist-lib/lib/capabilities/sdk-tool.js +18 -1
  65. package/dist-lib/lib/capabilities/tool-plan.d.ts +1 -1
  66. package/dist-lib/lib/capabilities/tool-plan.js +5 -5
  67. package/dist-lib/lib/capabilities/tool-prompt-log.js +3 -3
  68. package/dist-lib/lib/capabilities/tool-turns.d.ts +7 -9
  69. package/dist-lib/lib/capabilities/tool-turns.js +25 -20
  70. package/dist-lib/lib/client/index.d.ts +19 -0
  71. package/dist-lib/lib/client/index.js +262 -0
  72. package/dist-lib/lib/connect.d.ts +13 -10
  73. package/dist-lib/lib/connect.js +62 -24
  74. package/dist-lib/lib/context-window.d.ts +1 -0
  75. package/dist-lib/lib/context-window.js +3 -3
  76. package/dist-lib/lib/contract/agent.d.ts +7 -3
  77. package/dist-lib/lib/contract/completion.d.ts +44 -29
  78. package/dist-lib/lib/contract/egress-proxy.d.ts +13 -0
  79. package/dist-lib/lib/contract/egress-proxy.js +1 -0
  80. package/dist-lib/lib/contract/exec.d.ts +3 -3
  81. package/dist-lib/lib/contract/hooks.d.ts +4 -1
  82. package/dist-lib/lib/contract/index.d.ts +1 -0
  83. package/dist-lib/lib/contract/models.d.ts +6 -4
  84. package/dist-lib/lib/contract/policy.d.ts +75 -0
  85. package/dist-lib/lib/contract/policy.js +1 -0
  86. package/dist-lib/lib/contract/run.d.ts +9 -3
  87. package/dist-lib/lib/contract/sandbox.d.ts +3 -1
  88. package/dist-lib/lib/contract/translation.d.ts +20 -0
  89. package/dist-lib/lib/contract/translation.js +1 -0
  90. package/dist-lib/lib/contract-types.d.ts +32 -14
  91. package/dist-lib/lib/embeddings/index.d.ts +7 -1
  92. package/dist-lib/lib/embeddings/index.js +26 -5
  93. package/dist-lib/lib/errors.d.ts +266 -0
  94. package/dist-lib/lib/errors.js +198 -0
  95. package/dist-lib/lib/fold/index.d.ts +25 -1
  96. package/dist-lib/lib/fold/index.js +75 -9
  97. package/dist-lib/lib/guarded-fetch.js +11 -7
  98. package/dist-lib/lib/hardware/gpu-probe.js +10 -1
  99. package/dist-lib/lib/helpers/completion-params.d.ts +6 -2
  100. package/dist-lib/lib/helpers/completion-params.js +10 -1
  101. package/dist-lib/lib/helpers/engine-error.d.ts +2 -1
  102. package/dist-lib/lib/helpers/engine-error.js +12 -12
  103. package/dist-lib/lib/helpers/goal-check.d.ts +4 -0
  104. package/dist-lib/lib/helpers/goal-check.js +81 -0
  105. package/dist-lib/lib/helpers/head-tail.js +1 -1
  106. package/dist-lib/lib/helpers/load-stall.d.ts +1 -1
  107. package/dist-lib/lib/helpers/load-stall.js +2 -2
  108. package/dist-lib/lib/helpers/markup-stream-filter.d.ts +4 -1
  109. package/dist-lib/lib/helpers/markup-stream-filter.js +20 -6
  110. package/dist-lib/lib/helpers/repeated-reply.js +24 -16
  111. package/dist-lib/lib/helpers/thinking.d.ts +3 -2
  112. package/dist-lib/lib/helpers/thinking.js +19 -0
  113. package/dist-lib/lib/hooks/built-in/arg-repair.js +6 -2
  114. package/dist-lib/lib/hooks/built-in/policy-rules.d.ts +8 -0
  115. package/dist-lib/lib/hooks/built-in/policy-rules.js +192 -0
  116. package/dist-lib/lib/hooks/built-in/sandbox.js +23 -5
  117. package/dist-lib/lib/hooks/index.d.ts +4 -1
  118. package/dist-lib/lib/hooks/index.js +9 -4
  119. package/dist-lib/lib/hooks/run.js +3 -3
  120. package/dist-lib/lib/lifecycle/index.js +15 -14
  121. package/dist-lib/lib/lifecycle/machine.js +2 -2
  122. package/dist-lib/lib/log.d.ts +26 -5
  123. package/dist-lib/lib/log.js +86 -23
  124. package/dist-lib/lib/machine/completion/actions/completion.d.ts +4 -2
  125. package/dist-lib/lib/machine/completion/actions/completion.js +75 -10
  126. package/dist-lib/lib/machine/completion/actions/prepare.js +1 -1
  127. package/dist-lib/lib/machine/completion/actions/tools.js +48 -5
  128. package/dist-lib/lib/machine/completion/context.js +4 -1
  129. package/dist-lib/lib/machine/completion/guards/retry.d.ts +1 -0
  130. package/dist-lib/lib/machine/completion/guards/retry.js +8 -2
  131. package/dist-lib/lib/machine/completion/implementations.d.ts +10 -4
  132. package/dist-lib/lib/machine/completion/implementations.js +27 -6
  133. package/dist-lib/lib/machine/completion/machine.d.ts +21 -3
  134. package/dist-lib/lib/machine/completion/machine.js +33 -4
  135. package/dist-lib/lib/machine/completion/rules.d.ts +17 -2
  136. package/dist-lib/lib/machine/completion/rules.js +49 -3
  137. package/dist-lib/lib/machine/completion/types.d.ts +36 -0
  138. package/dist-lib/lib/machine/index.d.ts +27 -4
  139. package/dist-lib/lib/machine/index.js +6 -1
  140. package/dist-lib/lib/models/context-choice.d.ts +15 -0
  141. package/dist-lib/lib/models/context-choice.js +55 -0
  142. package/dist-lib/lib/models/download-gate.d.ts +20 -0
  143. package/dist-lib/lib/models/download-gate.js +73 -0
  144. package/dist-lib/lib/models/gguf-header.d.ts +5 -0
  145. package/dist-lib/lib/models/gguf-header.js +165 -14
  146. package/dist-lib/lib/models/llm-presets.d.ts +5 -1
  147. package/dist-lib/lib/models/llm-presets.js +6 -5
  148. package/dist-lib/lib/models/memory-cap.d.ts +13 -0
  149. package/dist-lib/lib/models/memory-cap.js +21 -0
  150. package/dist-lib/lib/models/model-catalog.d.ts +2 -0
  151. package/dist-lib/lib/models/model-catalog.js +15 -0
  152. package/dist-lib/lib/models/model-fit.d.ts +1 -1
  153. package/dist-lib/lib/models/model-fit.js +5 -6
  154. package/dist-lib/lib/models/model-handle.d.ts +8 -2
  155. package/dist-lib/lib/models/model-handle.js +14 -3
  156. package/dist-lib/lib/models/model-list.d.ts +8 -1
  157. package/dist-lib/lib/models/model-list.js +23 -0
  158. package/dist-lib/lib/models/model-pool.d.ts +35 -5
  159. package/dist-lib/lib/models/model-pool.js +121 -43
  160. package/dist-lib/lib/models/model-source.d.ts +1 -0
  161. package/dist-lib/lib/models/model-source.js +23 -5
  162. package/dist-lib/lib/models/sdk-faults.d.ts +1 -0
  163. package/dist-lib/lib/models/sdk-faults.js +9 -0
  164. package/dist-lib/lib/no-redirect-fetch-bare.js +2 -1
  165. package/dist-lib/lib/no-redirect-fetch-impl.js +2 -1
  166. package/dist-lib/lib/office/engine/pptx/picture-area.d.ts +23 -0
  167. package/dist-lib/lib/office/engine/pptx/picture-area.js +84 -0
  168. package/dist-lib/lib/office/engine/pptx/presentation.d.ts +2 -0
  169. package/dist-lib/lib/office/engine/pptx/presentation.js +55 -17
  170. package/dist-lib/lib/office/engine/pptx/types.d.ts +1 -0
  171. package/dist-lib/lib/office/engine/xlsx/workbook.d.ts +1 -0
  172. package/dist-lib/lib/office/engine/xlsx/workbook.js +34 -3
  173. package/dist-lib/lib/office/extract.js +4 -3
  174. package/dist-lib/lib/office/index.js +2 -1
  175. package/dist-lib/lib/plugins/registry.d.ts +3 -0
  176. package/dist-lib/lib/plugins/registry.js +16 -7
  177. package/dist-lib/lib/policy/index.d.ts +10 -0
  178. package/dist-lib/lib/policy/index.js +229 -0
  179. package/dist-lib/lib/prompt.d.ts +1 -0
  180. package/dist-lib/lib/prompt.js +7 -1
  181. package/dist-lib/lib/residency/completion-runtime.d.ts +1 -0
  182. package/dist-lib/lib/residency/completion-runtime.js +11 -4
  183. package/dist-lib/lib/residency/index.d.ts +44 -4
  184. package/dist-lib/lib/residency/index.js +399 -35
  185. package/dist-lib/lib/resolution-detector.js +3 -3
  186. package/dist-lib/lib/rpc-session.js +2 -1
  187. package/dist-lib/lib/sdk-loader.js +17 -11
  188. package/dist-lib/lib/serve.js +76 -36
  189. package/dist-lib/lib/sidecar/index.d.ts +29 -0
  190. package/dist-lib/lib/sidecar/index.js +174 -0
  191. package/dist-lib/lib/sidecar/user-plugins.d.ts +8 -0
  192. package/dist-lib/lib/sidecar/user-plugins.js +117 -0
  193. package/dist-lib/lib/skills-host/index.d.ts +1 -0
  194. package/dist-lib/lib/skills-host/index.js +8 -4
  195. package/dist-lib/lib/spawn.d.ts +3 -4
  196. package/dist-lib/lib/spawn.js +17 -17
  197. package/dist-lib/lib/spill.d.ts +1 -0
  198. package/dist-lib/lib/spill.js +12 -8
  199. package/dist-lib/lib/tools/attachments/staging.js +8 -8
  200. package/dist-lib/lib/tools/exec/runner.js +2 -1
  201. package/dist-lib/lib/tools/exec/scope.d.ts +0 -1
  202. package/dist-lib/lib/tools/exec/scope.js +23 -114
  203. package/dist-lib/lib/tools/exec/shell-guidance.js +4 -4
  204. package/dist-lib/lib/tools/exec/shell-line.d.ts +26 -0
  205. package/dist-lib/lib/tools/exec/shell-line.js +334 -0
  206. package/dist-lib/lib/tools/exec.d.ts +4 -1
  207. package/dist-lib/lib/tools/exec.js +87 -26
  208. package/dist-lib/lib/tools/files/edit-file.d.ts +3 -0
  209. package/dist-lib/lib/tools/files/edit-file.js +74 -0
  210. package/dist-lib/lib/tools/files/glob.d.ts +3 -0
  211. package/dist-lib/lib/tools/files/glob.js +65 -0
  212. package/dist-lib/lib/tools/files/grep.d.ts +6 -0
  213. package/dist-lib/lib/tools/files/grep.js +114 -0
  214. package/dist-lib/lib/tools/files/index.d.ts +3 -0
  215. package/dist-lib/lib/tools/files/index.js +23 -0
  216. package/dist-lib/lib/tools/files/list-dir.d.ts +6 -0
  217. package/dist-lib/lib/tools/files/list-dir.js +136 -0
  218. package/dist-lib/lib/tools/files/make-dir.d.ts +3 -0
  219. package/dist-lib/lib/tools/files/make-dir.js +48 -0
  220. package/dist-lib/lib/tools/files/read-file.d.ts +3 -0
  221. package/dist-lib/lib/tools/files/read-file.js +105 -0
  222. package/dist-lib/lib/tools/files/transfer.d.ts +4 -0
  223. package/dist-lib/lib/tools/files/transfer.js +83 -0
  224. package/dist-lib/lib/tools/files/trash-file.d.ts +4 -0
  225. package/dist-lib/lib/tools/files/trash-file.js +62 -0
  226. package/dist-lib/lib/tools/files/write-file.d.ts +3 -0
  227. package/dist-lib/lib/tools/files/write-file.js +56 -0
  228. package/dist-lib/lib/tools/fs/document-text.d.ts +2 -0
  229. package/dist-lib/lib/tools/fs/document-text.js +38 -0
  230. package/dist-lib/lib/tools/fs/drive.d.ts +14 -3
  231. package/dist-lib/lib/tools/fs/drive.js +9 -1
  232. package/dist-lib/lib/tools/fs/edit-match.d.ts +11 -0
  233. package/dist-lib/lib/tools/fs/edit-match.js +85 -0
  234. package/dist-lib/lib/tools/fs/ignore.d.ts +13 -0
  235. package/dist-lib/lib/tools/fs/ignore.js +104 -0
  236. package/dist-lib/lib/tools/fs/local.js +28 -5
  237. package/dist-lib/lib/tools/fs/remote-protocol.d.ts +23 -3
  238. package/dist-lib/lib/tools/fs/remote.d.ts +3 -4
  239. package/dist-lib/lib/tools/fs/remote.js +23 -13
  240. package/dist-lib/lib/tools/fs/scope.d.ts +5 -1
  241. package/dist-lib/lib/tools/fs/scope.js +5 -2
  242. package/dist-lib/lib/tools/fs/search.d.ts +41 -0
  243. package/dist-lib/lib/tools/fs/search.js +382 -0
  244. package/dist-lib/lib/tools/{file-glob.d.ts → fs/targets.d.ts} +1 -5
  245. package/dist-lib/lib/tools/fs/targets.js +32 -0
  246. package/dist-lib/lib/tools/fs/tool-path.d.ts +27 -0
  247. package/dist-lib/lib/tools/fs/tool-path.js +70 -0
  248. package/dist-lib/lib/tools/fs/walk.d.ts +15 -3
  249. package/dist-lib/lib/tools/fs/walk.js +118 -24
  250. package/dist-lib/lib/tools/http-request.js +12 -2
  251. package/dist-lib/lib/tools/index.js +2 -10
  252. package/dist-lib/lib/tools/office/ops.js +1 -1
  253. package/dist-lib/lib/tools/office.js +77 -21
  254. package/dist-lib/lib/tools/pdf/build.d.ts +5 -1
  255. package/dist-lib/lib/tools/pdf/build.js +31 -6
  256. package/dist-lib/lib/tools/pdf.js +17 -2
  257. package/dist-lib/lib/tools/skill.js +10 -7
  258. package/dist-lib/lib/tools/skills/bundled-dir.js +4 -4
  259. package/dist-lib/lib/tools/skills/catalog.d.ts +2 -0
  260. package/dist-lib/lib/tools/skills/catalog.js +6 -2
  261. package/dist-lib/lib/tools/skills/cli-argv.js +25 -5
  262. package/dist-lib/lib/tools/skills/cli-schema-check.d.ts +1 -0
  263. package/dist-lib/lib/tools/skills/cli-schema-check.js +3 -0
  264. package/dist-lib/lib/tools/skills/cli-schema-load.js +10 -0
  265. package/dist-lib/lib/tools/skills/cli-schema-types.d.ts +2 -0
  266. package/dist-lib/lib/tools/skills/cli-schema.js +6 -3
  267. package/dist-lib/lib/tools/skills/credential-health.js +3 -3
  268. package/dist-lib/lib/tools/skills/frontmatter-parser.d.ts +2 -0
  269. package/dist-lib/lib/tools/skills/frontmatter-parser.js +4 -0
  270. package/dist-lib/lib/tools/skills/manifest-parse.d.ts +1 -0
  271. package/dist-lib/lib/tools/skills/manifest-parse.js +12 -0
  272. package/dist-lib/lib/tools/skills/mention-name.d.ts +6 -0
  273. package/dist-lib/lib/tools/skills/mention-name.js +6 -0
  274. package/dist-lib/lib/tools/skills/mention.d.ts +2 -2
  275. package/dist-lib/lib/tools/skills/mention.js +11 -4
  276. package/dist-lib/lib/tools/skills/overlay-crud.js +3 -2
  277. package/dist-lib/lib/tools/url-guard.d.ts +6 -1
  278. package/dist-lib/lib/tools/url-guard.js +8 -2
  279. package/dist-lib/lib/tools/web-fetch.js +10 -4
  280. package/dist-lib/lib/wire.js +3 -5
  281. package/dist-lib/plugins/coding/index.d.ts +1 -1
  282. package/dist-lib/plugins/coding/index.js +2 -4
  283. package/dist-lib/plugins/coding/session.d.ts +3 -3
  284. package/dist-lib/plugins/coding/session.js +26 -14
  285. package/dist-lib/plugins/command-hooks/index.js +5 -3
  286. package/dist-lib/plugins/egress-proxy/index.d.ts +53 -0
  287. package/dist-lib/plugins/egress-proxy/index.js +182 -0
  288. package/dist-lib/plugins/image/edit-image.js +4 -3
  289. package/dist-lib/plugins/image/generate-image.d.ts +4 -3
  290. package/dist-lib/plugins/image/generate-image.js +10 -9
  291. package/dist-lib/plugins/image/index.d.ts +1 -1
  292. package/dist-lib/plugins/image/index.js +13 -10
  293. package/dist-lib/plugins/language-hint/index.d.ts +15 -0
  294. package/dist-lib/plugins/language-hint/index.js +51 -0
  295. package/dist-lib/plugins/lsp/tool.js +2 -2
  296. package/dist-lib/plugins/mcp/index.js +6 -3
  297. package/dist-lib/plugins/music/generate-music.d.ts +4 -2
  298. package/dist-lib/plugins/music/generate-music.js +7 -4
  299. package/dist-lib/plugins/music/index.js +12 -9
  300. package/dist-lib/plugins/obsidian/command.js +2 -2
  301. package/dist-lib/plugins/obsidian/note-name.js +2 -1
  302. package/dist-lib/plugins/obsidian/safe-path.js +5 -4
  303. package/dist-lib/plugins/obsidian/vault-create.js +3 -2
  304. package/dist-lib/plugins/obsidian/vault-fs.js +2 -2
  305. package/dist-lib/plugins/obsidian/vault-paths.js +3 -2
  306. package/dist-lib/plugins/obsidian/vault-read.js +6 -5
  307. package/dist-lib/plugins/obsidian/vault-write.js +13 -12
  308. package/dist-lib/plugins/python/guarded-fetch.d.ts +2 -1
  309. package/dist-lib/plugins/python/guarded-fetch.js +5 -1
  310. package/dist-lib/plugins/python/interrupt-timer.js +2 -2
  311. package/dist-lib/plugins/python/loader.js +68 -3
  312. package/dist-lib/plugins/python/memfs.js +2 -2
  313. package/dist-lib/plugins/python/pyodide.d.ts +1 -0
  314. package/dist-lib/plugins/python/pyodide.js +9 -8
  315. package/dist-lib/plugins/python/python-adapter.js +3 -1
  316. package/dist-lib/plugins/python/run-session.d.ts +1 -0
  317. package/dist-lib/plugins/python/run-session.js +19 -8
  318. package/dist-lib/plugins/python/wheels.js +8 -6
  319. package/dist-lib/plugins/python/worker/active.js +2 -2
  320. package/dist-lib/plugins/python/worker/client.js +9 -8
  321. package/dist-lib/plugins/python/worker/protocol.d.ts +2 -0
  322. package/dist-lib/plugins/python/worker/serve.js +23 -4
  323. package/dist-lib/plugins/python/worker/spawn.d.ts +2 -1
  324. package/dist-lib/plugins/python/worker/spawn.js +2 -1
  325. package/dist-lib/plugins/run-report/chain.d.ts +2 -0
  326. package/dist-lib/plugins/run-report/chain.js +73 -0
  327. package/dist-lib/plugins/run-report/flow-view.js +2 -1
  328. package/dist-lib/plugins/run-report/flow.d.ts +1 -1
  329. package/dist-lib/plugins/run-report/flow.js +66 -14
  330. package/dist-lib/plugins/run-report/index.d.ts +23 -2
  331. package/dist-lib/plugins/run-report/index.js +27 -12
  332. package/dist-lib/plugins/run-report/model.d.ts +10 -1
  333. package/dist-lib/plugins/run-report/model.js +12 -6
  334. package/dist-lib/plugins/run-report/page.d.ts +9 -0
  335. package/dist-lib/plugins/run-report/page.js +55 -15
  336. package/dist-lib/plugins/run-report/script.js +317 -43
  337. package/dist-lib/plugins/run-report/story.d.ts +2 -1
  338. package/dist-lib/plugins/run-report/story.js +3 -3
  339. package/dist-lib/plugins/run-report/style.d.ts +1 -1
  340. package/dist-lib/plugins/run-report/style.js +126 -0
  341. package/dist-lib/plugins/run-report/why.js +1 -1
  342. package/dist-lib/plugins/sandbox-linux/index.d.ts +60 -0
  343. package/dist-lib/plugins/sandbox-linux/index.js +347 -0
  344. package/dist-lib/plugins/sandbox-linux/seccomp.d.ts +2 -0
  345. package/dist-lib/plugins/sandbox-linux/seccomp.js +74 -0
  346. package/dist-lib/plugins/sandbox-macos/index.d.ts +23 -11
  347. package/dist-lib/plugins/sandbox-macos/index.js +239 -49
  348. package/dist-lib/plugins/sandbox-vm/vm-shell.d.ts +4 -2
  349. package/dist-lib/plugins/sandbox-vm/vm-shell.js +9 -4
  350. package/dist-lib/plugins/sandbox-windows/helper/qvac-sandbox.c +554 -0
  351. package/dist-lib/plugins/sandbox-windows/index.d.ts +53 -0
  352. package/dist-lib/plugins/sandbox-windows/index.js +205 -0
  353. package/dist-lib/plugins/sandbox-windows/prebuilds/win32-arm64/qvac-sandbox.exe +0 -0
  354. package/dist-lib/plugins/sandbox-windows/prebuilds/win32-x64/qvac-sandbox.exe +0 -0
  355. package/dist-lib/plugins/speech/audio-resample.d.ts +1 -1
  356. package/dist-lib/plugins/speech/audio-resample.js +7 -8
  357. package/dist-lib/plugins/speech/audio-transcode-bare.d.ts +1 -1
  358. package/dist-lib/plugins/speech/audio-transcode-bare.js +23 -26
  359. package/dist-lib/plugins/speech/audio-transcode-node.d.ts +1 -1
  360. package/dist-lib/plugins/speech/audio-transcode-node.js +1 -3
  361. package/dist-lib/plugins/speech/speech-runtime.js +37 -37
  362. package/dist-lib/plugins/speech/voice.d.ts +5 -1
  363. package/dist-lib/plugins/speech/voice.js +100 -31
  364. package/dist-lib/plugins/translation/index.d.ts +1 -0
  365. package/dist-lib/plugins/translation/index.js +16 -9
  366. package/dist-lib/plugins/translation/translate.d.ts +7 -3
  367. package/dist-lib/plugins/translation/translate.js +64 -58
  368. package/dist-lib/plugins/weather/geocode.js +2 -1
  369. package/dist-lib/plugins/weather/lookup.js +5 -4
  370. package/dist-lib/plugins/web-search/engines/bing.js +2 -1
  371. package/dist-lib/plugins/web-search/engines/google.js +2 -1
  372. package/dist-lib/plugins/web-search/fetch-html.d.ts +5 -5
  373. package/dist-lib/plugins/web-search/fetch-html.js +12 -15
  374. package/dist-lib/plugins/web-search/tool.js +1 -0
  375. package/dist-lib/schema/harness.js +48 -7
  376. package/dist-lib/spec/bind.js +9 -0
  377. package/dist-lib/spec/calls.js +3 -0
  378. package/dist-lib/spec/hrpc/hrpc.json +42 -3
  379. package/dist-lib/spec/hrpc/index.js +44 -8
  380. package/dist-lib/spec/hrpc/messages.js +297 -202
  381. package/dist-lib/spec/hyperschema/index.js +297 -202
  382. package/dist-lib/spec/hyperschema/schema.json +155 -84
  383. package/dist-lib/spec/hyperschema/types.d.ts +23 -3
  384. package/package.json +98 -26
  385. package/patches/@qvac%2Finference@0.22.0.patch +59 -0
  386. package/patches/pyodide@314.0.2.patch +37 -8
  387. package/scripts/addon-externals.cjs +10 -5
  388. package/worker/harness-sidecar.mjs +18 -154
  389. package/bench/README.md +0 -94
  390. package/bench/bfcl/checker.ts +0 -313
  391. package/bench/bfcl/data.ts +0 -93
  392. package/bench/bfcl/observe.ts +0 -93
  393. package/bench/bfcl/run.ts +0 -213
  394. package/bench/bfcl/tools.ts +0 -72
  395. package/bench/bridge/bridge.ts +0 -392
  396. package/bench/bridge/openai.ts +0 -150
  397. package/bench/bridge/python/qvac_bench/__init__.py +0 -3
  398. package/bench/bridge/python/qvac_bench/airline.py +0 -42
  399. package/bench/bridge/python/qvac_bench/approval.py +0 -26
  400. package/bench/bridge/python/qvac_bench/bfcl_multi_turn.py +0 -152
  401. package/bench/bridge/python/qvac_bench/client.py +0 -88
  402. package/bench/bridge/python/qvac_bench/harbor_agent.py +0 -85
  403. package/bench/bridge/python/qvac_bench/session.py +0 -107
  404. package/bench/bridge/python/qvac_bench/speed.py +0 -30
  405. package/bench/bridge/python/qvac_bench/tau2_agent.py +0 -106
  406. package/bench/bridge/python/qvac_bench/tools.py +0 -11
  407. package/bench/bridge/python/run_bfcl_multi_turn.py +0 -95
  408. package/bench/bridge/python/run_tau2.py +0 -150
  409. package/bench/bridge/python/smoke.py +0 -47
  410. package/bench/bridge/python/test_airline.py +0 -28
  411. package/bench/bridge/python/test_approval.py +0 -57
  412. package/bench/bridge/python/test_bfcl_multi_turn.py +0 -185
  413. package/bench/bridge/python/test_harbor_agent.py +0 -107
  414. package/bench/bridge/serve.ts +0 -52
  415. package/bench/bridge/transcript.ts +0 -52
  416. package/bench/bun-tsconfig.json +0 -15
  417. package/bench/cpu-main.mjs +0 -216
  418. package/bench/cpu.ts +0 -457
  419. package/bench/evidence/2026-09-28-review15.md +0 -225
  420. package/bench/evidence/redact-bun1.3.14.json +0 -92
  421. package/bench/evidence/redact-node24.11.json +0 -92
  422. package/bench/graph-metrics.ts +0 -43
  423. package/bench/harness.ts +0 -73
  424. package/bench/issue129-matrix.mjs +0 -722
  425. package/bench/redact-adversarial.ts +0 -256
  426. package/bench/repeat-cpu.mjs +0 -281
  427. package/bench/report.ts +0 -1075
  428. package/bench/skill-eval/harness.ts +0 -30
  429. package/bench/skill-eval/laws.ts +0 -37
  430. package/bench/skill-eval/mermaid/client.ts +0 -132
  431. package/bench/skill-eval/mermaid/validate.mjs +0 -115
  432. package/bench/skill-eval/pack.ts +0 -61
  433. package/bench/skill-eval/packs/diagrams/cases.ts +0 -281
  434. package/bench/skill-eval/packs/diagrams/index.ts +0 -50
  435. package/bench/skill-eval/packs/diagrams/score.ts +0 -74
  436. package/bench/skill-eval/packs/index.ts +0 -5
  437. package/bench/skill-eval/packs/weather/cases.ts +0 -279
  438. package/bench/skill-eval/packs/weather/fixtures/wttr.json +0 -566
  439. package/bench/skill-eval/packs/weather/fixtures.ts +0 -84
  440. package/bench/skill-eval/packs/weather/index.ts +0 -55
  441. package/bench/skill-eval/packs/weather/score.ts +0 -92
  442. package/bench/skill-eval/report.ts +0 -194
  443. package/bench/skill-eval/run.ts +0 -316
  444. package/bench/speed.ts +0 -80
  445. package/dist-lib/lib/tools/create-documents.d.ts +0 -3
  446. package/dist-lib/lib/tools/create-documents.js +0 -95
  447. package/dist-lib/lib/tools/edit-documents.d.ts +0 -3
  448. package/dist-lib/lib/tools/edit-documents.js +0 -132
  449. package/dist-lib/lib/tools/exec/shell-argv.d.ts +0 -2
  450. package/dist-lib/lib/tools/exec/shell-argv.js +0 -61
  451. package/dist-lib/lib/tools/file-glob.js +0 -118
  452. package/dist-lib/lib/tools/grep.d.ts +0 -5
  453. package/dist-lib/lib/tools/grep.js +0 -184
  454. package/dist-lib/lib/tools/read-files.d.ts +0 -5
  455. package/dist-lib/lib/tools/read-files.js +0 -160
  456. package/dist-lib/plugins/coding/write-file.d.ts +0 -3
  457. package/dist-lib/plugins/coding/write-file.js +0 -52
  458. package/patches/@qvac%2Finference@0.21.0.patch +0 -67
  459. package/patches/bare-stow@0.1.5.patch +0 -68
  460. package/patches/hypercore-blob-server@1.15.0.patch +0 -15
@@ -1,316 +0,0 @@
1
- // skill eval: the real local model, a pack's fake tools, one SKILL.md variant at a time
2
- import fs from 'fs'
3
- import path from 'path'
4
- import process from 'process'
5
- import { fileURLToPath } from 'url'
6
- import { AbortController } from 'bare-abort-controller'
7
- import liveFetch from '#fetch'
8
- import { errorMessage } from '../../lib/guards.ts'
9
- import { QWEN_35_2B } from '../../lib/models/model-catalog-constants.ts'
10
- import type { Message, MetricsEvent } from '../../lib/contract/index.ts'
11
- import type { FetchFn } from '../../lib/tools/http-request.ts'
12
- import { ensureBundledSkillsDir } from '../../lib/tools/skills/bundled-dir.ts'
13
- import { loadSkillCatalog, type SkillCatalogEntry } from '../../lib/tools/skills/catalog.ts'
14
- import { resolveImplicitSkill } from '../../lib/tools/skills/mention.ts'
15
- import { resolveSkillsOverlayDir } from '../../lib/tools/skills/overlay-dir.ts'
16
- import { openEvalHarness } from './harness.ts'
17
- import type { AnyPack, EvalCase, ToolCall } from './pack.ts'
18
- import { PACKS } from './packs/index.ts'
19
- import { ROUTES, summaryMarkdown, toCsv, toJsonl, type Route, type RunRow } from './report.ts'
20
-
21
- const USAGE = `usage: bare bench/skill-eval/run.ts [options]
22
- --pack <name> which skill pack to run; one of ${Object.keys(PACKS).join(', ')} (default weather)
23
- --variant <name>=<SKILL.md> a skill body to test, repeatable; the bundled skill runs as "baseline"
24
- --no-baseline skip the bundled skill
25
- --model <name> default ${QWEN_35_2B}
26
- --repeats <n> default 3
27
- --route mention|prose|both default both; prose rows split into prose and self-load
28
- --cases <id,...> --category <name,...>
29
- --temp <n> override the preset sampler temperature
30
- --timeout <ms> per run, default 60000
31
- --ctx <n> context size, default 4096
32
- --reasoning <mode> disabled|enabled|inherit, default disabled; the app's agents inherit
33
- --skills-dir <path> measure this skills/ tree instead of the bundled one
34
- --record let the pack fetch what its fixtures lack, live, and keep it
35
- --out <dir> default output/skill-eval/<stamp>
36
- `
37
-
38
- const BASELINE = 'baseline'
39
- const REASONING_MODES = ['disabled', 'enabled', 'inherit'] as const
40
- const REPO_ROOT = fileURLToPath(new URL('../..', import.meta.url))
41
-
42
- const argv = process.argv.slice(2)
43
- if (argv.includes('--help')) {
44
- console.log(USAGE)
45
- process.exit(0)
46
- }
47
-
48
- const flag = (name: string): string | undefined => {
49
- const index = argv.indexOf(`--${name}`)
50
- return index >= 0 ? argv[index + 1] : undefined
51
- }
52
- const flags = (name: string): string[] =>
53
- argv.flatMap((arg, index) => (arg === `--${name}` ? [argv[index + 1]] : []))
54
- const list = (name: string): string[] | null => flag(name)?.split(',') ?? null
55
-
56
- const pack: AnyPack = PACKS[flag('pack') ?? 'weather']
57
- const model = flag('model') ?? QWEN_35_2B
58
- const repeats = Number(flag('repeats') ?? 3)
59
- const timeoutMs = Number(flag('timeout') ?? 60000)
60
- const ctxSize = Number(flag('ctx') ?? 4096)
61
- // the eval pinned reasoning off for years; an app agent inherits it on, so a product sweep says so
62
- const reasoningFlag = flag('reasoning') ?? 'disabled'
63
- // completion reads any unknown mode as inherit, so the fallback keeps what a typo always did
64
- const reasoning = REASONING_MODES.find((mode) => mode === reasoningFlag) ?? 'inherit'
65
- const temp = flag('temp') === undefined ? undefined : Number(flag('temp'))
66
- const routeFlag = flag('route') ?? 'both'
67
- const mentionRoute = routeFlag !== 'prose'
68
- const proseRoute = routeFlag !== 'mention'
69
- const record = argv.includes('--record')
70
- const stamp = new Date().toISOString().replace(/[:.]/g, '-')
71
- const outDir = flag('out') ?? path.join(REPO_ROOT, 'output', 'skill-eval', stamp)
72
-
73
- const wantedCases = list('cases')
74
- const wantedCategories = list('category')
75
- const cases = pack.cases.filter(
76
- (evalCase) =>
77
- (!wantedCases || wantedCases.includes(evalCase.id)) &&
78
- (!wantedCategories || wantedCategories.includes(evalCase.category))
79
- )
80
- const categories = [...new Set(pack.cases.map((evalCase) => evalCase.category))]
81
-
82
- // baseline is the bundled skill; every other variant is a SKILL.md written into the overlay
83
- const baseline: ReadonlyArray<[name: string, body: string | null]> = argv.includes('--no-baseline')
84
- ? []
85
- : [[BASELINE, null]]
86
- const variants: ReadonlyArray<[name: string, body: string | null]> = [
87
- ...baseline,
88
- ...flags('variant').map((spec): [string, string] => {
89
- const [name, file] = spec.split('=', 2)
90
- return [name, fs.readFileSync(file, 'utf8')]
91
- })
92
- ]
93
-
94
- // lunte-disable-next-line qvac/no-as-cast -- tsc sees node's fetch; bare runs bare-fetch
95
- const world = pack.world({ live: record ? (liveFetch as unknown as FetchFn) : undefined })
96
-
97
- process.env.QVAC_NO_SKILL_BIN_PROBE = '1'
98
- reportFatals()
99
- // a checkout of @qvac/skills is the tree you are editing; the bundled one is what ships today
100
- const skillsDir = flag('skills-dir') ?? (await ensureBundledSkillsDir())
101
- const harness = await openEvalHarness({
102
- root: path.join(REPO_ROOT, 'output', 'skill-eval', 'sdk-root'),
103
- skillsDir,
104
- tools: world.tools,
105
- ctxSize
106
- })
107
- console.log(
108
- `model ${model} · pack ${pack.skill} · skills ${harness.skillNames.join(', ')} · ${cases.length} cases × ${repeats} repeats × ${variants.length} variants`
109
- )
110
-
111
- const rows: RunRow[] = []
112
- for (const [variant, body] of variants) {
113
- if (body === null) {
114
- await harness.deleteOverlaySkill(pack.skill)
115
- } else {
116
- await harness.writeSkillFile(pack.skill, body)
117
- }
118
-
119
- // the route label asks the harness's own resolver, against the catalog entry the variant just became
120
- const catalog = await loadSkillCatalog(skillsDir, {
121
- platform: null,
122
- overlayDir: resolveSkillsOverlayDir()
123
- })
124
- const entry = catalog.find((skill) => skill.name === pack.skill)
125
-
126
- for (const mention of [true, false]) {
127
- if (mention ? !mentionRoute : !proseRoute) continue
128
- rows.push(...(await runRoute({ variant, mention, entry })))
129
- }
130
- }
131
-
132
- fs.mkdirSync(outDir, { recursive: true })
133
- fs.writeFileSync(path.join(outDir, 'runs.jsonl'), toJsonl(rows))
134
- fs.writeFileSync(path.join(outDir, 'summary.csv'), toCsv(rows))
135
- const summary = summaryMarkdown(rows, { focus: pack.focus, categories })
136
- fs.writeFileSync(path.join(outDir, 'summary.md'), summary)
137
- if (record) {
138
- world.save()
139
- }
140
-
141
- world.close?.()
142
-
143
- console.log(`\n${summary}\nwritten to ${outDir}`)
144
- await harness.close()
145
-
146
- interface RunSpec {
147
- readonly variant: string
148
- readonly mention: boolean
149
- readonly evalCase: EvalCase<unknown>
150
- readonly repeat: number
151
- readonly entry: SkillCatalogEntry | undefined
152
- }
153
-
154
- type RouteSpec = Pick<RunSpec, 'variant' | 'mention' | 'entry'>
155
-
156
- async function runRoute(route: RouteSpec): Promise<RunRow[]> {
157
- const routeRows: RunRow[] = []
158
- for (const evalCase of cases) {
159
- for (let repeat = 0; repeat < repeats; repeat++) {
160
- const row = await runOne({ ...route, evalCase, repeat })
161
- routeRows.push(row)
162
- const mark = markOf(row)
163
- const why = row.failures.length ? ` — ${row.failures.join('; ')}` : ''
164
- console.log(
165
- `${mark} ${route.variant}/${row.route} ${evalCase.id} #${repeat} ${row.wallMs}ms${why}`
166
- )
167
- }
168
- }
169
-
170
- return routeRows
171
- }
172
-
173
- async function runOne(spec: RunSpec): Promise<RunRow> {
174
- const { variant, mention, evalCase, repeat, entry } = spec
175
- const messages = mention ? mentioned(evalCase.messages) : [...evalCase.messages]
176
- const route = routeOf(messages, mention, entry)
177
- world.reset()
178
-
179
- const controller = new AbortController()
180
- const deadline = setTimeout(() => controller.abort(new Error('deadline')), timeoutMs)
181
- const started = Date.now()
182
- const calls: ToolCall[] = []
183
- const refused: string[] = []
184
- let reply = ''
185
- let thinkingChars = 0
186
- let skillLoaded = false
187
- let metrics: MetricsEvent | null = null
188
- let error: string | null = null
189
-
190
- try {
191
- const events = harness.completion({
192
- model,
193
- agent: { id: 'skill-eval', enabledSkills: [pack.skill], reasoning },
194
- messages,
195
- // a fresh key per run keeps every prefill cold, so token counts and ttft compare across variants
196
- cacheKey: `skill-eval-${variant}-${route}-${evalCase.id}-${repeat}`,
197
- generationParams: temp === undefined ? undefined : { reasoning_budget: 0, temp },
198
- signal: controller.signal
199
- })
200
- for await (const event of events) {
201
- // the answer is what follows the last tool result; content before it is narration
202
- if (event.type === 'tool-result') {
203
- reply = ''
204
- }
205
-
206
- if (event.type === 'content') {
207
- reply += event.text
208
- }
209
-
210
- if (event.type === 'thinking') {
211
- thinkingChars += event.text.length
212
- }
213
-
214
- if (event.type === 'tool-call' && event.name === 'skill') {
215
- skillLoaded = true
216
- }
217
-
218
- // a skill load is a call a pack may judge
219
- if (event.type === 'tool-call') {
220
- calls.push({ name: event.name, args: event.args })
221
- }
222
-
223
- // a call the harness would not run (no approver here) never reached the fake world
224
- if (
225
- event.type === 'tool-activity' &&
226
- event.decision !== 'auto' &&
227
- event.decision !== 'allowed'
228
- ) {
229
- refused.push(`${event.name} ${event.decision}`)
230
- }
231
-
232
- if (event.type === 'metrics') {
233
- metrics = event
234
- }
235
-
236
- if (event.type === 'error') {
237
- error = event.message
238
- }
239
-
240
- if (event.type === 'aborted') {
241
- error = `aborted after ${timeoutMs} ms`
242
- }
243
- }
244
- } catch (err) {
245
- error = errorMessage(err)
246
- } finally {
247
- clearTimeout(deadline)
248
- }
249
-
250
- const judgement = await world.judge(evalCase, { calls, reply })
251
- const failures = [
252
- ...refused.map((call) => `refused: ${call}`),
253
- ...judgement.failures,
254
- ...(error === null ? [] : [`error: ${error}`])
255
- ]
256
-
257
- return {
258
- variant,
259
- route,
260
- caseId: evalCase.id,
261
- category: evalCase.category,
262
- repeat,
263
- passed: failures.length === 0,
264
- gap: judgement.gap,
265
- renders: judgement.renders ?? null,
266
- outcome: judgement.outcome ?? null,
267
- failures,
268
- reply,
269
- calls: calls.map((call) => `${call.name} ${JSON.stringify(call.args)}`),
270
- skillLoaded,
271
- thinkingChars,
272
- contextTokens: metrics?.usage?.totalTokens ?? null,
273
- skillTokens: metrics?.usage?.activeSkills ?? null,
274
- ttftMs: metrics?.timeToFirstToken ?? null,
275
- generatedTokens: metrics?.totalTokens ?? null,
276
- wallMs: Date.now() - started,
277
- error
278
- }
279
- }
280
-
281
- // the mention route is the deterministic SKILL-4 path, written on the turn the harness reads
282
- function mentioned(messages: ReadonlyArray<Message>): Message[] {
283
- const copy = [...messages]
284
- const last = copy.length - 1
285
- copy[last] = { ...copy[last], content: `@${pack.skill} ${copy[last].content}` }
286
- return copy
287
- }
288
-
289
- // prose is whatever the harness would preload from the last user turn; the rest is self-load
290
- function routeOf(
291
- messages: ReadonlyArray<Message>,
292
- mention: boolean,
293
- entry: SkillCatalogEntry | undefined
294
- ): Route {
295
- if (mention) {
296
- return ROUTES[0]
297
- }
298
-
299
- const last = messages[messages.length - 1].content
300
-
301
- return entry && resolveImplicitSkill(last, [entry]) ? ROUTES[1] : ROUTES[2]
302
- }
303
-
304
- // the SDK takes over both handlers and exits silently; this leaves the stack behind first
305
- function reportFatals(): void {
306
- const report = (err: unknown) => {
307
- console.error('[skill-eval]', err instanceof Error ? err.stack : err)
308
- }
309
- Bare.on('unhandledRejection', report)
310
- Bare.on('uncaughtException', report)
311
- }
312
-
313
- function markOf(row: Pick<RunRow, 'passed' | 'gap'>): string {
314
- if (row.passed) return ' ok '
315
- return row.gap ? 'GAP ' : 'FAIL'
316
- }
package/bench/speed.ts DELETED
@@ -1,80 +0,0 @@
1
- import type { MetricsEvent } from '../lib/contract/index.ts'
2
-
3
- // Sums, not rates, so runs add up and a rate weighs its tokens; qvac_bench/speed.py mirrors it.
4
- export interface Speed {
5
- readonly runs: number
6
- readonly rounds: number
7
- readonly promptTokens: number
8
- readonly prefillMs: number
9
- readonly generatedTokens: number
10
- readonly decodeMs: number
11
- readonly modelMs: number
12
- readonly toolMs: number
13
- readonly wallMs: number
14
- // each run's first-round wait, for a median
15
- readonly ttftMs: number[]
16
- }
17
-
18
- export const NO_SPEED: Speed = {
19
- runs: 0,
20
- rounds: 0,
21
- promptTokens: 0,
22
- prefillMs: 0,
23
- generatedTokens: 0,
24
- decodeMs: 0,
25
- modelMs: 0,
26
- toolMs: 0,
27
- wallMs: 0,
28
- ttftMs: []
29
- }
30
-
31
- export function speedOf(metrics: MetricsEvent | null): Speed | null {
32
- if (!metrics) {
33
- return null
34
- }
35
-
36
- const rounds = metrics.rounds ?? []
37
- let promptTokens = 0
38
- let prefillMs = 0
39
- let generatedTokens = 0
40
- let decodeMs = 0
41
- for (const round of rounds) {
42
- if (round.promptTokens && round.promptTokensPerSecond) {
43
- promptTokens += round.promptTokens
44
- prefillMs += (round.promptTokens / round.promptTokensPerSecond) * 1000
45
- }
46
-
47
- if (round.generatedTokens && round.tokensPerSecond) {
48
- generatedTokens += round.generatedTokens
49
- decodeMs += (round.generatedTokens / round.tokensPerSecond) * 1000
50
- }
51
- }
52
-
53
- return {
54
- runs: 1,
55
- rounds: rounds.length,
56
- promptTokens,
57
- prefillMs,
58
- generatedTokens,
59
- decodeMs,
60
- modelMs: metrics.modelMs ?? 0,
61
- toolMs: metrics.toolMs ?? 0,
62
- wallMs: metrics.durationMs,
63
- ttftMs: metrics.timeToFirstToken === undefined ? [] : [metrics.timeToFirstToken]
64
- }
65
- }
66
-
67
- export function addSpeed(left: Speed, right: Speed): Speed {
68
- return {
69
- runs: left.runs + right.runs,
70
- rounds: left.rounds + right.rounds,
71
- promptTokens: left.promptTokens + right.promptTokens,
72
- prefillMs: left.prefillMs + right.prefillMs,
73
- generatedTokens: left.generatedTokens + right.generatedTokens,
74
- decodeMs: left.decodeMs + right.decodeMs,
75
- modelMs: left.modelMs + right.modelMs,
76
- toolMs: left.toolMs + right.toolMs,
77
- wallMs: left.wallMs + right.wallMs,
78
- ttftMs: [...left.ttftMs, ...right.ttftMs]
79
- }
80
- }
@@ -1,3 +0,0 @@
1
- import type { ToolDefinition } from '../contract/index.ts';
2
- import { type FsToolOptions } from './fs/scope.ts';
3
- export declare function createCreateDocumentsTool({ realpath, deniedRoots }?: FsToolOptions): ToolDefinition;
@@ -1,95 +0,0 @@
1
- import { canonicalDenyRoots, defaultRealpath, resolveKey } from './fs/scope.js';
2
- import { writeText } from './fs/write.js';
3
- import { errorMessage } from '../guards.js';
4
- function documentRequests(raw) {
5
- if (!Array.isArray(raw) || raw.length === 0)
6
- return null;
7
- const documents = [];
8
- for (const entry of raw) {
9
- if (!isDocumentRequest(entry))
10
- return null;
11
- documents.push({ path: entry.path, content: entry.content });
12
- }
13
- return documents;
14
- }
15
- function isDocumentRequest(value) {
16
- if (typeof value !== 'object' || value === null)
17
- return false;
18
- if (!('path' in value) || typeof value.path !== 'string' || !value.path.trim()) {
19
- return false;
20
- }
21
- return 'content' in value && typeof value.content === 'string';
22
- }
23
- export function createCreateDocumentsTool({ realpath = defaultRealpath, deniedRoots } = {}) {
24
- return {
25
- name: 'create_documents',
26
- toolset: 'files',
27
- description: 'Create new files inside the granted directories. Parent directories are ' +
28
- 'created as needed. Fails per file if the file already exists — use ' +
29
- 'edit_documents to change existing files.',
30
- parameters: {
31
- type: 'object',
32
- properties: {
33
- documents: {
34
- type: 'array',
35
- description: 'Files to create',
36
- items: {
37
- type: 'object',
38
- properties: {
39
- path: { type: 'string', description: 'File path' },
40
- content: { type: 'string', description: 'Full file content' }
41
- },
42
- required: ['path', 'content']
43
- }
44
- }
45
- },
46
- required: ['documents']
47
- },
48
- effect: () => 'read',
49
- writeRootsRequired: true,
50
- validate(rawArgs) {
51
- return documentRequests(rawArgs.documents)
52
- ? null
53
- : 'documents must be a non-empty array of { path, content }';
54
- },
55
- resource(args) {
56
- const documents = documentRequests(args.documents);
57
- if (!documents) {
58
- return null;
59
- }
60
- const bytes = documents.reduce((sum, doc) => sum + doc.content.length, 0);
61
- const first = documents[0];
62
- const suffix = documents.length > 1 ? ` (+${documents.length - 1} more)` : '';
63
- return { kind: 'file', label: `create ${first.path}${suffix}, ${bytes} chars` };
64
- },
65
- async execute(rawArgs, ctx) {
66
- const roots = ctx?.fsWriteRoots ?? [];
67
- const documents = documentRequests(rawArgs.documents);
68
- if (!documents) {
69
- return { error: 'documents must be a non-empty array of { path, content }' };
70
- }
71
- const created = [];
72
- const failed = [];
73
- const deny = await canonicalDenyRoots(deniedRoots, realpath);
74
- for (const doc of documents) {
75
- const resolved = await resolveKey(doc.path, roots, { realpath, deny });
76
- if ('error' in resolved) {
77
- failed.push({ path: doc.path, error: resolved.error });
78
- continue;
79
- }
80
- try {
81
- if ((await resolved.root.drive.entry(resolved.key)) !== null) {
82
- failed.push({ path: doc.path, error: 'file already exists' });
83
- continue;
84
- }
85
- await writeText(resolved.root.drive, resolved.key, doc.content);
86
- created.push(doc.path);
87
- }
88
- catch (err) {
89
- failed.push({ path: doc.path, error: errorMessage(err) });
90
- }
91
- }
92
- return { created, failed: failed.length ? failed : undefined };
93
- }
94
- };
95
- }
@@ -1,3 +0,0 @@
1
- import type { ToolDefinition } from '../contract/index.ts';
2
- import { type FsToolOptions } from './fs/scope.ts';
3
- export declare function createEditDocumentsTool({ realpath, deniedRoots }?: FsToolOptions): ToolDefinition;
@@ -1,132 +0,0 @@
1
- import b4a from 'b4a';
2
- import { canonicalDenyRoots, defaultRealpath, resolveKey } from './fs/scope.js';
3
- import { writeText } from './fs/write.js';
4
- import { errorMessage } from '../guards.js';
5
- function editRequests(raw) {
6
- if (!Array.isArray(raw) || raw.length === 0)
7
- return null;
8
- const edits = [];
9
- for (const entry of raw) {
10
- if (!isEditRequest(entry))
11
- return null;
12
- edits.push({ path: entry.path, search: entry.search, replace: entry.replace });
13
- }
14
- return edits;
15
- }
16
- function isEditRequest(value) {
17
- if (typeof value !== 'object' || value === null)
18
- return false;
19
- if (!('path' in value) || typeof value.path !== 'string' || !value.path.trim()) {
20
- return false;
21
- }
22
- if (!('search' in value) || typeof value.search !== 'string' || !value.search) {
23
- return false;
24
- }
25
- return 'replace' in value && typeof value.replace === 'string';
26
- }
27
- function applyEdits(content, edits) {
28
- let next = content;
29
- for (const edit of edits) {
30
- const first = next.indexOf(edit.search);
31
- if (first === -1) {
32
- return { error: 'search text not found' };
33
- }
34
- if (next.indexOf(edit.search, first + edit.search.length) !== -1) {
35
- return { error: 'search text is ambiguous (matches more than once)' };
36
- }
37
- next = next.slice(0, first) + edit.replace + next.slice(first + edit.search.length);
38
- }
39
- return next;
40
- }
41
- export function createEditDocumentsTool({ realpath = defaultRealpath, deniedRoots } = {}) {
42
- return {
43
- name: 'edit_documents',
44
- toolset: 'files',
45
- description: 'Edit existing files inside the granted directories via search/replace. ' +
46
- 'Each search string must match exactly once in its file; include enough ' +
47
- 'surrounding context to make it unique. Edits to one file apply together.',
48
- parameters: {
49
- type: 'object',
50
- properties: {
51
- edits: {
52
- type: 'array',
53
- description: 'Search/replace edits',
54
- items: {
55
- type: 'object',
56
- properties: {
57
- path: { type: 'string', description: 'File path' },
58
- search: { type: 'string', description: 'Exact text to find (must match once)' },
59
- replace: { type: 'string', description: 'Replacement text' }
60
- },
61
- required: ['path', 'search', 'replace']
62
- }
63
- }
64
- },
65
- required: ['edits']
66
- },
67
- effect: () => 'write',
68
- autoApprove: false,
69
- writeRootsRequired: true,
70
- validate(rawArgs) {
71
- return editRequests(rawArgs.edits)
72
- ? null
73
- : 'edits must be a non-empty array of { path, search, replace }';
74
- },
75
- resource(args) {
76
- const edits = editRequests(args.edits);
77
- if (!edits) {
78
- return null;
79
- }
80
- const paths = [...new Set(edits.map((edit) => edit.path))];
81
- const label = paths.slice(0, 3).join(', ');
82
- return {
83
- kind: 'file',
84
- label: `edit ${paths.length > 3 ? `${label} (+${paths.length - 3} more)` : label} (${edits.length} edit${edits.length > 1 ? 's' : ''})`
85
- };
86
- },
87
- async execute(rawArgs, ctx) {
88
- const roots = ctx?.fsWriteRoots ?? [];
89
- const edits = editRequests(rawArgs.edits);
90
- if (!edits) {
91
- return { error: 'edits must be a non-empty array of { path, search, replace }' };
92
- }
93
- const byPath = new Map();
94
- for (const edit of edits) {
95
- const list = byPath.get(edit.path) ?? [];
96
- list.push(edit);
97
- byPath.set(edit.path, list);
98
- }
99
- const edited = [];
100
- const failed = [];
101
- const deny = await canonicalDenyRoots(deniedRoots, realpath);
102
- for (const [file, fileEdits] of byPath) {
103
- const resolved = await resolveKey(file, roots, { realpath, deny });
104
- if ('error' in resolved) {
105
- failed.push({ path: file, error: resolved.error });
106
- continue;
107
- }
108
- try {
109
- const entry = await resolved.root.drive.entry(resolved.key);
110
- const blob = entry === null ? null : await resolved.root.drive.get(resolved.key);
111
- if (entry === null || blob === null) {
112
- failed.push({ path: file, error: `no such file: ${file}` });
113
- continue;
114
- }
115
- const next = applyEdits(b4a.toString(blob, 'utf8'), fileEdits);
116
- if (typeof next === 'object') {
117
- failed.push({ path: file, error: next.error });
118
- continue;
119
- }
120
- await writeText(resolved.root.drive, resolved.key, next, {
121
- executable: entry.value.executable
122
- });
123
- edited.push(file);
124
- }
125
- catch (err) {
126
- failed.push({ path: file, error: errorMessage(err) });
127
- }
128
- }
129
- return { edited, failed: failed.length ? failed : undefined };
130
- }
131
- };
132
- }
@@ -1,2 +0,0 @@
1
- export declare function shellEscapeArg(value: string): string;
2
- export declare function shellArgv(command: string): string[];