@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,152 +0,0 @@
1
- """BFCL v4 multi-turn with the harness as the model: BFCL's own entries, backends and checker.
2
-
3
- Each user turn is one harness run over the conversation so far. A call the run makes executes
4
- on gorilla's Python backends as BFCL's inference executes it, and the entry is scored by BFCL's
5
- multi_turn_checker as its eval runner calls it. Needs bfcl-eval from the pinned gorilla commit.
6
- """
7
-
8
- import copy
9
- import json
10
- from typing import Any, Awaitable, Callable
11
-
12
- from bfcl_eval.constants.default_prompts import (
13
- DEFAULT_USER_PROMPT_FOR_ADDITIONAL_FUNCTION_FC,
14
- MAXIMUM_STEP_LIMIT,
15
- )
16
- from bfcl_eval.constants.enums import ModelStyle
17
- from bfcl_eval.constants.type_mappings import GORILLA_TO_OPENAPI
18
- from bfcl_eval.eval_checker.multi_turn_eval.multi_turn_checker import multi_turn_checker
19
- from bfcl_eval.eval_checker.multi_turn_eval.multi_turn_utils import (
20
- execute_multi_turn_func_call,
21
- is_empty_execute_response,
22
- )
23
- from bfcl_eval.model_handler.utils import convert_to_function_call, convert_to_tool
24
- from bfcl_eval.utils import load_dataset_entry, load_ground_truth_entry
25
-
26
- from .client import Execute
27
- from .speed import add_speed, no_speed
28
-
29
- CATEGORIES = [
30
- "multi_turn_base",
31
- "multi_turn_miss_func",
32
- "multi_turn_miss_param",
33
- "multi_turn_long_context",
34
- ]
35
- # BFCL force-quits a turn on its step past the limit, so the run may take one round more
36
- MAX_TOOL_ROUNDS = MAXIMUM_STEP_LIMIT + 1
37
-
38
- Run = Callable[[list[dict[str, Any]], list[dict[str, Any]], Execute], Awaitable[dict[str, Any]]]
39
-
40
-
41
- def load(category: str, limit: int | None) -> list[tuple[dict, list]]:
42
- """Entries with their ground truth, spread evenly across the category as data.ts spreads them."""
43
- entries = load_dataset_entry(category)
44
- answers = {row["id"]: row["ground_truth"] for row in load_ground_truth_entry(category)}
45
- count = min(limit or len(entries), len(entries))
46
- step = max(1, len(entries) // count)
47
- picked = [entry for index, entry in enumerate(entries) if index % step == 0][:count]
48
- return [(entry, answers[entry["id"]]) for entry in picked]
49
-
50
-
51
- def specs(functions: list[dict]) -> list[dict]:
52
- """The docs as BFCL's function-calling handlers send them."""
53
- tools = convert_to_tool(functions, GORILLA_TO_OPENAPI, ModelStyle.OPENAI_COMPLETIONS)
54
- return [{key: tool["function"][key] for key in ("name", "description", "parameters")} for tool in tools]
55
-
56
-
57
- class Episode:
58
- """One entry. Its backends live in BFCL's own instances, keyed by run_name, so a run never sees another's state."""
59
-
60
- def __init__(self, entry: dict, answer: list, run_name: str):
61
- self.entry = entry
62
- self.answer = answer
63
- self.run_name = run_name
64
- self.category = entry["id"].rsplit("_", 1)[0]
65
- self.turns: list[list[list[dict]]] = []
66
- # the calls the backends ran, in order; a call the harness refused never reaches them
67
- self.ran: list[dict] = []
68
- self.replies: list[str] = []
69
- self.speed = no_speed()
70
-
71
- # async only because the bridge client awaits every tool
72
- async def execute(self, name: str, args: dict[str, Any]) -> Any:
73
- self.ran.append({name: args})
74
- results, _ = execute_multi_turn_func_call(
75
- convert_to_function_call([{name: args}]),
76
- self.entry["initial_config"],
77
- self.entry["involved_classes"],
78
- self.run_name,
79
- self.entry["id"],
80
- long_context="long_context" in self.category or "composite" in self.category,
81
- is_evaL_run=False,
82
- )
83
- return as_sent(results[0])
84
-
85
- async def play(self, run: Run) -> dict[str, Any]:
86
- functions = copy.deepcopy(self.entry["function"])
87
- holdout = self.entry.get("missed_function", {})
88
- history: list[dict[str, Any]] = []
89
- for index, messages in enumerate(self.entry["question"]):
90
- if str(index) in holdout:
91
- functions.extend(holdout[str(index)])
92
- messages = [{"role": "user", "content": DEFAULT_USER_PROMPT_FOR_ADDITIONAL_FUNCTION_FC}]
93
- history.extend(messages)
94
- ran = len(self.ran)
95
- done = await run(history, specs(functions), self.execute)
96
- history.extend(done["history"])
97
- steps = executed(done["history"], self.ran[ran:])
98
- self.turns.append(steps)
99
- self.replies.append(done["reply"])
100
- add_speed(self.speed, done.get("metrics"))
101
- # BFCL fails an entry whose inference raised, without scoring it
102
- if done["error"]:
103
- return failed("multi_turn:inference_error", done["error"])
104
- if len(steps) > MAXIMUM_STEP_LIMIT:
105
- break
106
- return self.score()
107
-
108
- def score(self) -> dict[str, Any]:
109
- """BFCL's eval runner's own steps; it is not imported, as it imports every provider's SDK."""
110
- if len(self.turns) != len(self.answer):
111
- return failed(
112
- "multi_turn:force_terminated",
113
- f"Model was force-terminated during inference phase. The length of the model result turns ({len(self.turns)}) does not match the length of the ground truth turns ({len(self.answer)}).",
114
- )
115
- decoded = [
116
- [calls for calls in map(convert_to_function_call, turn) if not is_empty_execute_response(calls)]
117
- for turn in self.turns
118
- ]
119
- result = multi_turn_checker(decoded, self.answer, self.entry, self.category, self.run_name)
120
- if result["valid"]:
121
- return {"valid": True, "error_type": None, "error": None}
122
- return failed(result["error_type"], result["error_message"])
123
-
124
-
125
- def as_sent(result: str) -> Any:
126
- """BFCL sends a backend's JSON as it is; the harness encodes a tool's result, so it gets the object."""
127
- try:
128
- parsed = json.loads(result)
129
- except ValueError:
130
- return result
131
- return parsed if isinstance(parsed, dict) else result
132
-
133
-
134
- def executed(history: list[dict[str, Any]], ran: list[dict]) -> list[list[dict]]:
135
- """The calls the backends ran, grouped by the round that made them, as BFCL's steps.
136
-
137
- A call the harness refused, such as one cut off at the output limit, never ran, so it is not scored.
138
- """
139
- pending = list(ran)
140
- steps = []
141
- for turn in history:
142
- step = []
143
- for call in turn.get("toolCalls") or []:
144
- if pending and {call["name"]: call["arguments"]} == pending[0]:
145
- step.append(pending.pop(0))
146
- if step:
147
- steps.append(step)
148
- return steps + ([pending] if pending else [])
149
-
150
-
151
- def failed(error_type: str, message: str) -> dict[str, Any]:
152
- return {"valid": False, "error_type": error_type, "error": message}
@@ -1,88 +0,0 @@
1
- """Drive @qvac/harness from Python: the harness runs the loop, the caller's environment runs the tools."""
2
-
3
- import asyncio
4
- import json
5
- import os
6
- from typing import Any, Awaitable, Callable
7
-
8
- FRAME = "\x1eqvac "
9
- # the native addon prints whole prompts on the same stdout, one line each
10
- LINE_LIMIT = 1 << 26
11
-
12
- Execute = Callable[[str, dict[str, Any]], Awaitable[Any]]
13
-
14
-
15
- class QvacBridge:
16
- def __init__(self, repo: str, model: str, bare: str | None = None):
17
- self.repo = repo
18
- self.model = model
19
- self.bare = bare or os.path.join(repo, "node_modules", ".bin", "bare")
20
- self._proc: asyncio.subprocess.Process | None = None
21
- self._runs = 0
22
-
23
- async def start(self) -> None:
24
- self._proc = await asyncio.create_subprocess_exec(
25
- self.bare,
26
- "bench/bridge/serve.ts",
27
- cwd=self.repo,
28
- stdin=asyncio.subprocess.PIPE,
29
- stdout=asyncio.subprocess.PIPE,
30
- stderr=asyncio.subprocess.DEVNULL,
31
- limit=LINE_LIMIT,
32
- )
33
- await self._expect("ready")
34
-
35
- async def run(
36
- self,
37
- messages: list[dict[str, Any]],
38
- tools: list[dict[str, Any]],
39
- execute: Execute,
40
- system: str | None = None,
41
- max_tool_rounds: int | None = None,
42
- cache_key: str | None = None,
43
- ) -> dict[str, Any]:
44
- run_id = f"run-{self._runs}"
45
- self._runs += 1
46
- run = {"type": "run", "id": run_id, "model": self.model, "system": system, "messages": messages, "tools": tools}
47
- # the harness reads a null limit as invalid, so an unset one is left out
48
- if max_tool_rounds is not None:
49
- run["maxToolRounds"] = max_tool_rounds
50
- if cache_key is not None:
51
- run["cacheKey"] = cache_key
52
- self._send(run)
53
- while True:
54
- frame = await self._frame()
55
- if frame["type"] == "call":
56
- result = await execute(frame["name"], frame["args"])
57
- self._send({"type": "result", "callId": frame["callId"], "result": result})
58
- elif frame["type"] == "done" and frame["id"] == run_id:
59
- return frame
60
-
61
- def forget(self, cache_key: str) -> None:
62
- """Drops a finished conversation's cached prefill."""
63
- self._send({"type": "forget", "cacheKey": cache_key})
64
-
65
- async def close(self) -> None:
66
- if self._proc is None:
67
- return
68
- self._proc.stdin.close()
69
- await self._proc.wait()
70
- self._proc = None
71
-
72
- def _send(self, frame: dict[str, Any]) -> None:
73
- self._proc.stdin.write((json.dumps(frame) + "\n").encode())
74
-
75
- async def _expect(self, kind: str) -> dict[str, Any]:
76
- frame = await self._frame()
77
- if frame["type"] != kind:
78
- raise RuntimeError(f"expected {kind}, got {frame}")
79
- return frame
80
-
81
- async def _frame(self) -> dict[str, Any]:
82
- while True:
83
- line = await self._proc.stdout.readline()
84
- if not line:
85
- raise RuntimeError("the harness bridge exited")
86
- text = line.decode(errors="replace")
87
- if text.startswith(FRAME):
88
- return json.loads(text[len(FRAME):])
@@ -1,85 +0,0 @@
1
- """A Harbor agent: the harness's loop with one bash tool that runs in the task container.
2
-
3
- QVAC_HARNESS_REPO=$PWD PYTHONPATH=bench/bridge/python uv tool run harbor run \\
4
- --dataset terminal-bench@2.0 -a qvac_bench.harbor_agent:QvacHarnessAgent \\
5
- -m Qwen3.5-9B-Q4_K_M -n 1 --ak max_tool_rounds=10
6
- """
7
-
8
- import json
9
- import os
10
- import time
11
-
12
- from harbor.agents.base import BaseAgent
13
- from harbor.environments.base import BaseEnvironment
14
- from harbor.models.agent.context import AgentContext
15
-
16
- from .client import QvacBridge
17
- from .tools import BASH
18
-
19
- # keep a tool result inside a small model's context
20
- OUTPUT_TAIL = 8000
21
- COMMAND_TIMEOUT_SEC = 180
22
- # what timeout(1) exits with
23
- TIMEOUT_RETURN_CODE = 124
24
-
25
- SYSTEM = (
26
- "You are working in a Linux terminal to complete a task. Use the bash tool to inspect "
27
- "the environment, make changes and verify them. When the task is complete, say so."
28
- )
29
-
30
-
31
- class QvacHarnessAgent(BaseAgent):
32
- def __init__(self, *args, max_tool_rounds: int | str | None = None, **kwargs):
33
- super().__init__(*args, **kwargs)
34
- self.max_tool_rounds = None if max_tool_rounds in (None, "") else int(max_tool_rounds)
35
-
36
- @staticmethod
37
- def name() -> str:
38
- return "qvac-harness"
39
-
40
- def version(self) -> str | None:
41
- return "bridge-1"
42
-
43
- async def setup(self, environment: BaseEnvironment) -> None:
44
- return None
45
-
46
- async def run(self, instruction: str, environment: BaseEnvironment, context: AgentContext) -> None:
47
- model = self.model_name or "Qwen3.5-9B-Q4_K_M"
48
- bridge = QvacBridge(os.environ["QVAC_HARNESS_REPO"], model)
49
- # the load average shows whether other work on the machine slowed the run
50
- log = open(os.path.join(self.logs_dir, "qvac.jsonl"), "a")
51
-
52
- def write(row: dict) -> None:
53
- log.write(json.dumps(row) + "\n")
54
- log.flush()
55
-
56
- async def execute(name: str, args: dict) -> dict:
57
- command = str(args.get("command", ""))
58
- started = time.monotonic()
59
- # DockerEnvironment.exec raises on timeout; the model gets it as a failed command
60
- try:
61
- result = await environment.exec(command, timeout_sec=COMMAND_TIMEOUT_SEC)
62
- stdout, stderr, return_code = result.stdout or "", result.stderr or "", result.return_code
63
- except RuntimeError as error:
64
- stdout, stderr, return_code = "", str(error), TIMEOUT_RETURN_CODE
65
- write({"type": "call", "command": command, "return_code": return_code, "seconds": time.monotonic() - started})
66
- return {"stdout": stdout[-OUTPUT_TAIL:], "stderr": stderr[-OUTPUT_TAIL:], "return_code": return_code}
67
-
68
- write({"type": "start", "model": model, "max_tool_rounds": self.max_tool_rounds, "load": os.getloadavg()})
69
- try:
70
- await bridge.start()
71
- done = await bridge.run(
72
- [{"role": "user", "content": instruction}],
73
- [BASH],
74
- execute,
75
- system=SYSTEM,
76
- max_tool_rounds=self.max_tool_rounds,
77
- )
78
- write(done)
79
- rounds = (done.get("metrics") or {}).get("rounds") or []
80
- context.n_input_tokens = sum(record.get("promptTokens") or 0 for record in rounds)
81
- context.n_output_tokens = sum(record.get("generatedTokens") or 0 for record in rounds)
82
- finally:
83
- write({"type": "end", "load": os.getloadavg()})
84
- log.close()
85
- await bridge.close()
@@ -1,107 +0,0 @@
1
- """A synchronous bridge session, for benchmarks whose agent API returns one message at a time."""
2
-
3
- import json
4
- import os
5
- import subprocess
6
- import time
7
- from typing import Any
8
-
9
- from .client import FRAME
10
-
11
- # the addon prints whole prompts on the same stdout; the harness's own log lines are short
12
- TRACE_LINE_LIMIT = 4000
13
-
14
-
15
- class QvacSession:
16
- def __init__(self, repo: str, model: str, bare: str | None = None, trace: str | None = None):
17
- self.model = model
18
- self._trace = open(trace, "a") if trace else None
19
- self._runs = 0
20
- # the run whose frames this session answers; a frame of any other run is stale
21
- self._active: str | None = None
22
- self._proc = subprocess.Popen(
23
- [bare or os.path.join(repo, "node_modules", ".bin", "bare"), "bench/bridge/serve.ts"],
24
- cwd=repo,
25
- stdin=subprocess.PIPE,
26
- stdout=subprocess.PIPE,
27
- stderr=subprocess.DEVNULL,
28
- env={**os.environ, "QVAC_HARNESS_LOG": "1"} if trace else None,
29
- text=True,
30
- bufsize=1,
31
- )
32
- self._expect("ready")
33
-
34
- def start(
35
- self,
36
- messages: list[dict[str, Any]],
37
- tools: list[dict[str, Any]],
38
- system: str | None,
39
- now: int | None = None,
40
- ) -> dict[str, Any]:
41
- """Starts a run and returns its first call, approve or done frame."""
42
- self.finish()
43
- self._runs += 1
44
- self._active = f"run-{self._runs}"
45
- self._send({
46
- "type": "run",
47
- "id": self._active,
48
- "model": self.model,
49
- "system": system,
50
- "messages": messages,
51
- "tools": tools,
52
- "now": now,
53
- })
54
- return self._next()
55
-
56
- def answer(self, call_id: str, result: Any) -> dict[str, Any]:
57
- """Returns a call's result and the active run's next call, approve or done frame."""
58
- self._send({"type": "result", "callId": call_id, "result": result})
59
- return self._next()
60
-
61
- def decide(self, call_id: str, approved: bool) -> dict[str, Any]:
62
- """Settles a write the run asked the user about and returns its next frame."""
63
- self._send({"type": "decision", "callId": call_id, "approved": approved})
64
- return self._next()
65
-
66
- def finish(self) -> None:
67
- """Ends a run the benchmark abandoned mid-turn, so its frames never reach the next task."""
68
- if self._active is None:
69
- return
70
- self._send({"type": "cancel", "id": self._active})
71
- while self._next()["type"] != "done":
72
- pass
73
-
74
- def close(self) -> None:
75
- self._proc.stdin.close()
76
- self._proc.wait()
77
- if self._trace:
78
- self._trace.close()
79
-
80
- def _send(self, frame: dict[str, Any]) -> None:
81
- self._proc.stdin.write(json.dumps(frame) + "\n")
82
- self._proc.stdin.flush()
83
-
84
- def _next(self) -> dict[str, Any]:
85
- while True:
86
- frame = self._frame()
87
- if frame.get("id") != self._active or frame["type"] not in ("call", "approve", "done"):
88
- continue
89
- if frame["type"] == "done":
90
- self._active = None
91
- return frame
92
-
93
- def _expect(self, kind: str) -> None:
94
- frame = self._frame()
95
- if frame["type"] != kind:
96
- raise RuntimeError(f"expected {kind}, got {frame}")
97
-
98
- def _frame(self) -> dict[str, Any]:
99
- while True:
100
- line = self._proc.stdout.readline()
101
- if not line:
102
- raise RuntimeError("the harness bridge exited")
103
- if line.startswith(FRAME):
104
- return json.loads(line[len(FRAME):])
105
- if self._trace and len(line) < TRACE_LINE_LIMIT:
106
- self._trace.write(f"{time.strftime('%H:%M:%S')} {line}")
107
- self._trace.flush()
@@ -1,30 +0,0 @@
1
- """A run's speed as sums, in the shape of bench/speed.ts, so runs add up."""
2
-
3
-
4
- def add_speed(speed: dict, metrics: dict | None) -> None:
5
- """Adds one run's metrics to a task's sums, in the shape of bench/speed.ts."""
6
- if not metrics:
7
- return
8
- speed["runs"] += 1
9
- for record in metrics.get("rounds", []):
10
- speed["rounds"] += 1
11
- prompt, prefill_rate = record.get("promptTokens"), record.get("promptTokensPerSecond")
12
- if prompt and prefill_rate:
13
- speed["promptTokens"] += prompt
14
- speed["prefillMs"] += prompt / prefill_rate * 1000
15
- generated, decode_rate = record.get("generatedTokens"), record.get("tokensPerSecond")
16
- if generated and decode_rate:
17
- speed["generatedTokens"] += generated
18
- speed["decodeMs"] += generated / decode_rate * 1000
19
- speed["modelMs"] += metrics.get("modelMs", 0)
20
- speed["toolMs"] += metrics.get("toolMs", 0)
21
- speed["wallMs"] += metrics["durationMs"]
22
- if metrics.get("timeToFirstToken") is not None:
23
- speed["ttftMs"].append(metrics["timeToFirstToken"])
24
-
25
-
26
- def no_speed() -> dict:
27
- return {
28
- "runs": 0, "rounds": 0, "promptTokens": 0, "prefillMs": 0, "generatedTokens": 0,
29
- "decodeMs": 0, "modelMs": 0, "toolMs": 0, "wallMs": 0, "ttftMs": [],
30
- }
@@ -1,106 +0,0 @@
1
- """A tau2-bench agent whose every turn is a harness run; tau2's orchestrator still runs the tools.
2
-
3
- A call frame becomes an assistant message carrying that one tool call, and the ToolMessage
4
- tau2 sends back answers it, so the same harness run continues until it replies to the user.
5
- A write first comes back as an approve frame: the agent quotes it to the user, and a reply that
6
- confirms it lets the same run make the call. Any other answer starts a new run, so the model
7
- reads the user's words as the conversation goes on.
8
- """
9
-
10
- import json
11
- import sys
12
- from typing import Any, Optional
13
-
14
- from tau2.agent.base_agent import HalfDuplexAgent
15
- from tau2.agent.llm_agent import AGENT_INSTRUCTION, SYSTEM_PROMPT
16
- from tau2.data_model.message import AssistantMessage, MultiToolMessage, ToolCall, ToolMessage, UserMessage
17
- from tau2.environment.toolkit import Tool
18
-
19
- from .airline import quote
20
- from .approval import confirms
21
- from .session import QvacSession
22
- from .speed import add_speed, no_speed
23
-
24
-
25
- # the airline domain's writes; every other tool reads, so it runs without asking
26
- WRITE_TOOLS = {
27
- "book_reservation",
28
- "cancel_reservation",
29
- "update_reservation_baggages",
30
- "update_reservation_flights",
31
- "update_reservation_passengers",
32
- "send_certificate",
33
- }
34
-
35
-
36
- class QvacTau2Agent(HalfDuplexAgent[dict]):
37
- def __init__(self, tools: list[Tool], domain_policy: str, session: QvacSession, now: int | None = None):
38
- super().__init__(tools=tools, domain_policy=domain_policy)
39
- self.session = session
40
- # the policy's own date, in epoch ms: the harness otherwise stamps today on every turn
41
- self.now = now
42
- self.system = SYSTEM_PROMPT.format(domain_policy=domain_policy, agent_instruction=AGENT_INSTRUCTION)
43
- self.specs = [
44
- {**spec, "write": spec["name"] in WRITE_TOOLS}
45
- for spec in (tool.openai_schema["function"] for tool in tools)
46
- ]
47
- # a turn the harness ended without a reply, and why: the SDK's errors count against the agent
48
- self.replies = 0
49
- self.failed_turns = 0
50
- self.errors: dict[str, int] = {}
51
- # τ² runs carry no cache key, so every round primes the cache cold
52
- self.speed = no_speed()
53
-
54
- def get_init_state(self, message_history: Optional[list] = None) -> dict:
55
- return {"history": [], "calls": {}}
56
-
57
- def generate_next_message(self, message: Any, state: dict) -> tuple[AssistantMessage, dict]:
58
- if isinstance(message, UserMessage):
59
- asked = state.pop("approval", None)
60
- state["history"].append({"role": "user", "content": message.content or ""})
61
- if asked and confirms(message.content):
62
- frame = self.session.decide(asked, True)
63
- else:
64
- frame = self.session.start(state["history"], self.specs, self.system, self.now)
65
- elif isinstance(message, ToolMessage):
66
- frame = self.answer(message, state)
67
- elif isinstance(message, MultiToolMessage):
68
- frame = None
69
- for tool_message in message.tool_messages:
70
- frame = self.answer(tool_message, state)
71
- else:
72
- raise TypeError(f"unexpected message {type(message).__name__}")
73
-
74
- if frame["type"] == "call":
75
- state["calls"][frame["callId"]] = frame["name"]
76
- replayed = {"id": frame["callId"], "name": frame["name"], "arguments": frame["args"]}
77
- state["history"].append({"role": "assistant", "content": "", "toolCalls": [replayed]})
78
- call = ToolCall(id=frame["callId"], name=frame["name"], arguments=frame["args"])
79
- return AssistantMessage(role="assistant", content=None, tool_calls=[call]), state
80
-
81
- if frame["type"] == "approve":
82
- state["approval"] = frame["callId"]
83
- ask = f"{quote(frame['name'], frame['args'])} Reply yes to confirm."
84
- state["history"].append({"role": "assistant", "content": ask})
85
- return AssistantMessage(role="assistant", content=ask), state
86
-
87
- self.replies += 1
88
- add_speed(self.speed, frame.get("metrics"))
89
- if not frame["reply"].strip() or frame["error"]:
90
- self.failed_turns += 1
91
- error = frame["error"] or "empty reply"
92
- self.errors[error] = self.errors.get(error, 0) + 1
93
- print(f"[qvac] failed turn: calls={frame['calls']} error={error!r}", file=sys.stderr, flush=True)
94
- reply = frame["reply"].strip() or "I'm sorry, could you say that again?"
95
- state["history"].append({"role": "assistant", "content": reply})
96
- return AssistantMessage(role="assistant", content=reply), state
97
-
98
- def answer(self, message: ToolMessage, state: dict) -> dict[str, Any]:
99
- # the run got the text as its result, so the replay carries it as a JSON string
100
- state["history"].append({
101
- "role": "tool",
102
- "toolCallId": message.id,
103
- "name": state["calls"][message.id],
104
- "content": json.dumps(message.content),
105
- })
106
- return self.session.answer(message.id, message.content)
@@ -1,11 +0,0 @@
1
- """Tool specs a benchmark hands the bridge; the benchmark's environment runs them."""
2
-
3
- BASH = {
4
- "name": "bash",
5
- "description": "Run one shell command in the task's Linux container and get its stdout, stderr and exit code.",
6
- "parameters": {
7
- "type": "object",
8
- "properties": {"command": {"type": "string", "description": "The command to run"}},
9
- "required": ["command"],
10
- },
11
- }
@@ -1,95 +0,0 @@
1
- """BFCL v4 multi-turn with the harness as the model, scored by BFCL's own checker.
2
-
3
- output/venvs/bfcl/bin/python bench/bridge/python/run_bfcl_multi_turn.py \\
4
- --models Qwen3.5-2B-Q4_K_M,Qwen3.5-9B-Q4_K_M --limit 10 --out output/bfcl-multi-turn/run
5
- """
6
-
7
- import argparse
8
- import asyncio
9
- import json
10
- import os
11
- import subprocess
12
- import sys
13
- import time
14
-
15
- sys.path.insert(0, os.path.dirname(__file__))
16
- from qvac_bench.bfcl_multi_turn import CATEGORIES, MAX_TOOL_ROUNDS, Episode, load # noqa: E402
17
- from qvac_bench.client import QvacBridge # noqa: E402
18
-
19
- REPO = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", ".."))
20
-
21
-
22
- async def run_model(model: str, cases: list, args: argparse.Namespace, stamp: str, commit: str) -> None:
23
- bridge = QvacBridge(REPO, model)
24
- await bridge.start()
25
- run_name = f"qvac_{model}_{stamp}"
26
- try:
27
- for entry, answer in cases:
28
- episode = Episode(entry, answer, run_name)
29
- key = f"bfcl-multi-turn-{stamp}-{model}-{entry['id']}"
30
-
31
- def run(messages, tools, execute, key=key):
32
- return bridge.run(messages, tools, execute, max_tool_rounds=args.max_tool_rounds, cache_key=key)
33
-
34
- started = time.time()
35
- verdict = await episode.play(run)
36
- bridge.forget(key)
37
- row = {
38
- "model": model,
39
- "category": episode.category,
40
- "id": entry["id"],
41
- "commit": commit,
42
- **verdict,
43
- "turns": len(answer),
44
- "played": len(episode.turns),
45
- "calls": [[call for step in turn for call in step] for turn in episode.turns],
46
- "replies": [reply[:300] for reply in episode.replies],
47
- "seconds": round(time.time() - started, 1),
48
- "speed": episode.speed,
49
- }
50
- with open(os.path.join(args.out, "runs.jsonl"), "a") as f:
51
- f.write(json.dumps(row) + "\n")
52
- outcome = "pass" if verdict["valid"] else verdict["error_type"]
53
- print(f"{model} {entry['id']}: {outcome} in {row['seconds']}s", flush=True)
54
- finally:
55
- await bridge.close()
56
-
57
-
58
- def summary(out: str) -> str:
59
- with open(os.path.join(out, "runs.jsonl")) as f:
60
- rows = [json.loads(line) for line in f if line.strip()]
61
- lines = []
62
- for model in dict.fromkeys(row["model"] for row in rows):
63
- for category in CATEGORIES:
64
- own = [row for row in rows if row["model"] == model and row["category"] == category]
65
- if own:
66
- passed = sum(row["valid"] for row in own)
67
- lines.append(f"{model} {category}: {passed}/{len(own)} ({round(passed / len(own) * 100)}%)")
68
- return "\n".join(lines)
69
-
70
-
71
- def main() -> None:
72
- parser = argparse.ArgumentParser()
73
- parser.add_argument("--categories", default=",".join(CATEGORIES))
74
- parser.add_argument("--models", default="Qwen3.5-9B-Q4_K_M")
75
- parser.add_argument("--limit", type=int, default=None, help="entries per category, spread evenly across it")
76
- parser.add_argument("--max-tool-rounds", type=int, default=MAX_TOOL_ROUNDS, help="per turn; default BFCL's step limit")
77
- parser.add_argument("--out", default=None)
78
- args = parser.parse_args()
79
-
80
- stamp = time.strftime("%Y%m%d-%H%M%S")
81
- args.out = args.out or os.path.join(REPO, "output", "bfcl-multi-turn", stamp)
82
- os.makedirs(args.out, exist_ok=True)
83
- # report.ts reads every row, so a second run into the same dir would count each entry twice
84
- if os.path.exists(os.path.join(args.out, "runs.jsonl")):
85
- sys.exit(f"{args.out} already holds a run; pick another --out")
86
- commit = subprocess.run(["git", "rev-parse", "--short", "HEAD"], cwd=REPO, capture_output=True, text=True).stdout.strip()
87
- cases = [case for category in args.categories.split(",") for case in load(category, args.limit)]
88
- print(f"{len(cases)} BFCL multi-turn entries -> {args.out}", flush=True)
89
- for model in args.models.split(","):
90
- asyncio.run(run_model(model, cases, args, stamp, commit))
91
- print(summary(args.out))
92
-
93
-
94
- if __name__ == "__main__":
95
- main()