@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
@@ -12,6 +12,7 @@ import * as fit from './fit.js';
12
12
  import * as template from './template.js';
13
13
  import * as slides from './slides.js';
14
14
  import * as notes from './notes.js';
15
+ import { fitted, framed, pictureArea } from './picture-area.js';
15
16
  import { pick, describe, layoutName, layoutType, BODY_TYPES } from './read.js';
16
17
  import { SHAPE_ORDER, shapesOf, placeholderFrom, pictureElement, textBoxElement, tableElement, chartFrameElement, setBackground, nextShapeId } from './shapes.js';
17
18
  const { a: A, p: P, r: R, p14: P14 } = xml.ns;
@@ -154,16 +155,19 @@ function checkSlideText(doc, at, opts) {
154
155
  }
155
156
  }
156
157
  }
157
- function fitted(info, current) {
158
- const scale = Math.min(current.width / info.width, current.height / info.height);
159
- const width = Math.round(info.width * scale);
160
- const height = Math.round(info.height * scale);
161
- return {
162
- x: current.x + Math.round((current.width - width) / 2),
163
- y: current.y + Math.round((current.height - height) / 2),
164
- width,
165
- height
166
- };
158
+ function roleOf(shape) {
159
+ const { el, kind, placeholder } = shape;
160
+ if (kind === 'picture') {
161
+ return 'picture';
162
+ }
163
+ if (el.localName !== 'sp' || !placeholder || !BODY_TYPES.has(placeholder)) {
164
+ return 'other';
165
+ }
166
+ const txBody = xml.child(el, P, 'txBody');
167
+ if (txBody && text.readParagraphs(txBody).some((p) => p.text.trim())) {
168
+ return placeholder === 'subTitle' ? 'other' : 'body';
169
+ }
170
+ return placeholder === 'obj' ? 'slot' : 'blank';
167
171
  }
168
172
  function tableBody(tc) {
169
173
  const existing = xml.child(tc, A, 'txBody');
@@ -366,6 +370,9 @@ export class Presentation {
366
370
  const layoutDoc = this.package.xml(layout);
367
371
  const doc = slideFromLayout(layoutDoc);
368
372
  checkSlideText(doc, at, opts);
373
+ if (opts.image !== undefined) {
374
+ probe(opts.image);
375
+ }
369
376
  this.insertSlide({ doc, layout, at, ids: all.map((e) => e.id), before: all[at]?.el ?? null });
370
377
  if (opts.title !== undefined) {
371
378
  this.setText({ slide: at, shape: 'title' }, opts.title);
@@ -373,14 +380,25 @@ export class Presentation {
373
380
  if (opts.body !== undefined) {
374
381
  this.setText({ slide: at, shape: 'body' }, opts.body);
375
382
  }
376
- return { index: at, layout: layoutName(layoutDoc), shapes: shapesOf(doc).map(describe) };
383
+ if (opts.image !== undefined) {
384
+ this.addPicture(at, opts.image);
385
+ }
386
+ const shapes = shapesOf(this.package.xml(slides.slideAt(this.deck, at).part));
387
+ return { index: at, layout: layoutName(layoutDoc), shapes: shapes.map(describe) };
377
388
  }
378
389
  addPicture(slide, bytes, opts = {}) {
379
390
  const entry = slides.slideAt(this.deck, slide);
380
- const box = this.pictureBox(probe(bytes), opts);
391
+ const area = this.pictureArea(entry.part, opts);
392
+ const box = this.pictureBox(probe(bytes), opts, area.box);
381
393
  const { rId } = media.addImage(this.package, bytes, { source: entry.part, dir: '../media' });
382
394
  const doc = this.package.xml(entry.part);
383
395
  const id = nextShapeId(doc);
396
+ for (const shape of area.cleared) {
397
+ xml.remove(shape.el);
398
+ }
399
+ if (area.beside) {
400
+ this.narrow(entry.part, area.beside);
401
+ }
384
402
  this.spTree(entry.part).appendChild(pictureElement(doc, { id, rId, box, name: opts.name, description: opts.description }));
385
403
  this.package.touch(entry.part);
386
404
  return { id, ...box };
@@ -722,14 +740,34 @@ export class Presentation {
722
740
  }
723
741
  return box;
724
742
  }
725
- pictureBox(info, opts) {
743
+ narrow(part, { shape, box }) {
744
+ writeXfrm(shape.el, box);
745
+ const txBody = xml.child(shape.el, P, 'txBody');
746
+ const estimate = txBody ? this.estimate(part, shape.el, txBody) : null;
747
+ if (txBody && estimate?.overflow) {
748
+ applyAutofit(txBody, estimate);
749
+ }
750
+ }
751
+ pictureArea(part, opts) {
752
+ if (opts.x !== undefined || opts.y !== undefined) {
753
+ return { box: framed(this.slideSize), cleared: [], beside: null };
754
+ }
755
+ const shapes = shapesOf(this.package.xml(part)).flatMap((shape) => {
756
+ if (shape.group !== null || SKIPPED_PLACEHOLDERS.has(shape.placeholder ?? '')) {
757
+ return [];
758
+ }
759
+ const box = inherit.box({ pkg: this.package, slide: part, el: shape.el });
760
+ return box ? [{ el: shape.el, box, role: roleOf(shape) }] : [];
761
+ });
762
+ return pictureArea(this.slideSize, shapes);
763
+ }
764
+ pictureBox(info, opts, area) {
726
765
  checkPlacement(opts);
727
- const slide = this.slideSize;
728
766
  const ratio = info.height / info.width;
729
767
  let { width, height } = opts;
730
768
  if (width === undefined && height === undefined) {
731
769
  const natural = { width: info.width * EMU_PER_PIXEL, height: info.height * EMU_PER_PIXEL };
732
- const scale = Math.min(1, (slide.width * 0.8) / natural.width, (slide.height * 0.8) / natural.height);
770
+ const scale = Math.min(1, area.width / natural.width, area.height / natural.height);
733
771
  width = Math.round(natural.width * scale);
734
772
  height = Math.round(natural.height * scale);
735
773
  }
@@ -742,8 +780,8 @@ export class Presentation {
742
780
  if (!width || !height) {
743
781
  throw new DocsError('INVALID_BOX', 'the picture would have no visible size');
744
782
  }
745
- const x = opts.x ?? Math.max(0, Math.round((slide.width - width) / 2));
746
- const y = opts.y ?? Math.max(0, Math.round((slide.height - height) / 2));
783
+ const x = opts.x ?? Math.max(0, area.x + Math.round((area.width - width) / 2));
784
+ const y = opts.y ?? Math.max(0, area.y + Math.round((area.height - height) / 2));
747
785
  return { x, y, width, height };
748
786
  }
749
787
  }
@@ -61,6 +61,7 @@ export interface AddSlideOptions {
61
61
  at?: number;
62
62
  title?: TextInput;
63
63
  body?: TextInput;
64
+ image?: Uint8Array;
64
65
  }
65
66
  export interface AddedSlide {
66
67
  index: number;
@@ -156,6 +156,7 @@ export declare class Workbook {
156
156
  private ownCharts;
157
157
  private rangeValues;
158
158
  private besideData;
159
+ private rowsBelowDrawings;
159
160
  private drawingOf;
160
161
  private ensureDrawing;
161
162
  }
@@ -2,6 +2,7 @@ import { Package } from '../opc/package.js';
2
2
  import * as xml from '../xml.js';
3
3
  import * as media from '../opc/media.js';
4
4
  import { probe } from '../image.js';
5
+ import { points } from '../units.js';
5
6
  import * as refs from './refs.js';
6
7
  import * as formula from './formula.js';
7
8
  import { Sheet, SHEET_ORDER } from './sheet.js';
@@ -170,6 +171,12 @@ function pictureAnchor(doc, anchor, spec) {
170
171
  root.appendChild(d('clientData'));
171
172
  return root;
172
173
  }
174
+ function markerCell(marker) {
175
+ return {
176
+ row: Number(xml.text(xml.child(marker, XDR, 'row'))),
177
+ col: Number(xml.text(xml.child(marker, XDR, 'col')))
178
+ };
179
+ }
173
180
  function nextDrawingId(doc) {
174
181
  return (Math.max(0, ...xml.descendants(doc, XDR, 'cNvPr').map((el) => Number(el.getAttribute('id')) || 0)) + 1);
175
182
  }
@@ -421,7 +428,7 @@ export class Workbook {
421
428
  const target = this.sheet(sheet);
422
429
  const info = probe(bytes);
423
430
  const o = isRecord(opts) ? opts : {};
424
- const at = refs.parse(o.cell === undefined ? 'A1' : o.cell);
431
+ const at = o.cell === undefined ? this.besideData(target) : refs.parse(o.cell);
425
432
  const size = imageSize(o, info);
426
433
  const drawing = this.ensureDrawing(target);
427
434
  const { rId } = media.addImage(this.package, bytes, { source: drawing, dir: '../media' });
@@ -791,7 +798,8 @@ export class Workbook {
791
798
  const from = xml.child(anchor, XDR, 'from');
792
799
  const info = chart.readChart(this.package.xml(rel.part));
793
800
  if (from) {
794
- info.cell = refs.cell(Number(xml.text(xml.child(from, XDR, 'row'))), Number(xml.text(xml.child(from, XDR, 'col'))));
801
+ const { row, col } = markerCell(from);
802
+ info.cell = refs.cell(row, col);
795
803
  }
796
804
  out.push(info);
797
805
  }
@@ -823,7 +831,30 @@ export class Workbook {
823
831
  }
824
832
  besideData(sheet) {
825
833
  const used = sheet.usedRange();
826
- return used ? { row: used.top, col: used.right + 2 } : { row: 0, col: 0 };
834
+ const col = used ? used.right + 2 : 0;
835
+ return { row: Math.max(used ? used.top : 0, ...this.rowsBelowDrawings(sheet, col)), col };
836
+ }
837
+ rowsBelowDrawings(sheet, col) {
838
+ const drawing = this.drawingOf(sheet);
839
+ if (!drawing) {
840
+ return [];
841
+ }
842
+ const format = xml.child(sheet.root, X, 'sheetFormatPr');
843
+ const rowHeight = points(Number(format?.getAttribute('defaultRowHeight') ?? 15));
844
+ return xml.children(this.package.root(drawing), XDR).flatMap((anchor) => {
845
+ const from = xml.child(anchor, XDR, 'from');
846
+ if (!from || markerCell(from).col !== col) {
847
+ return [];
848
+ }
849
+ const to = xml.child(anchor, XDR, 'to');
850
+ if (to) {
851
+ return [markerCell(to).row + 2];
852
+ }
853
+ const ext = xml.child(anchor, XDR, 'ext');
854
+ return ext
855
+ ? [markerCell(from).row + Math.ceil(Number(ext.getAttribute('cy')) / rowHeight) + 1]
856
+ : [];
857
+ });
827
858
  }
828
859
  drawingOf(sheet) {
829
860
  const ref = xml.child(sheet.root, X, 'drawing');
@@ -1,17 +1,18 @@
1
+ import { HarnessError } from '../errors.js';
1
2
  import { errorMessage } from '../guards.js';
2
3
  const MAX_OFFICE_BYTES = 20 * 1024 * 1024;
3
4
  export function extractWith(bytes, { fileName, signal, extract }) {
4
5
  if (bytes.byteLength > MAX_OFFICE_BYTES) {
5
- throw new Error(`document is too large to extract: ${bytes.byteLength} bytes, limit ${MAX_OFFICE_BYTES}`);
6
+ throw new HarnessError('OFFICE_TOO_LARGE', [bytes.byteLength, MAX_OFFICE_BYTES]);
6
7
  }
7
8
  if (signal?.aborted) {
8
- throw new Error(`${fileName}: extraction aborted`);
9
+ throw new HarnessError('OFFICE_EXTRACTION_ABORTED', [fileName]);
9
10
  }
10
11
  try {
11
12
  return extract(bytes);
12
13
  }
13
14
  catch (err) {
14
- throw new Error(`${fileName}: ${errorMessage(err)}`);
15
+ throw new HarnessError('OFFICE_EXTRACTION_FAILED', [fileName, errorMessage(err)]);
15
16
  }
16
17
  }
17
18
  export function cellText(value) {
@@ -1,4 +1,5 @@
1
1
  import path from 'path';
2
+ import { HarnessError } from '../errors.js';
2
3
  import { extractDocxText } from '../docx/index.js';
3
4
  import { pptx, xlsx } from './engine/index.js';
4
5
  import { cellText, extractWith } from './extract.js';
@@ -89,5 +90,5 @@ export async function extractOfficeText(bytes, fileName, options = {}) {
89
90
  if (extract) {
90
91
  return extractWith(bytes, { fileName, signal: options.signal, extract });
91
92
  }
92
- throw new Error(`Unsupported Office document: ${fileName}`);
93
+ throw new HarnessError('OFFICE_UNSUPPORTED_DOCUMENT', [fileName]);
93
94
  }
@@ -1,6 +1,7 @@
1
1
  import type { AddonLoaders, ToolDefinition, ToolExecuteContext, ToolFetch } from '../contract/index.ts';
2
2
  import type { KnowledgeService } from '../contract/knowledge.ts';
3
3
  import type { SandboxService } from '../contract/sandbox.ts';
4
+ import type { EgressProxyService } from '../contract/egress-proxy.ts';
4
5
  import type { EmbedHost, ModelHost } from '../contract/models.ts';
5
6
  import type { SpeechService } from '../contract/speech.ts';
6
7
  import type { HarnessHook, SkillReadiness } from '../contract/index.ts';
@@ -14,6 +15,7 @@ declare module './context.ts' {
14
15
  embed: EmbedHost;
15
16
  knowledge: KnowledgeService;
16
17
  sandbox: SandboxService;
18
+ 'egress-proxy': EgressProxyService;
17
19
  }
18
20
  }
19
21
  export interface PluginContext {
@@ -44,6 +46,7 @@ export interface HarnessPlugin {
44
46
  api: number;
45
47
  provides?: readonly string[];
46
48
  needs?: readonly string[];
49
+ wants?: readonly string[];
47
50
  addons?: AddonLoaders;
48
51
  read?: readonly string[];
49
52
  validate?(): string | null;
@@ -1,3 +1,5 @@
1
+ import { HarnessError } from '../errors.js';
2
+ import { Policy } from '../policy/index.js';
1
3
  import { canonicalDenyRoots, defaultRealpath } from '../tools/fs/scope.js';
2
4
  import { TOOLSETS } from '../tools/toolsets.js';
3
5
  import { loadAddons } from './addons.js';
@@ -55,7 +57,8 @@ function startOrder(plugins, providers, core) {
55
57
  const placed = new Set();
56
58
  const pending = [...plugins];
57
59
  while (pending.length > 0) {
58
- const index = pending.findIndex((plugin) => (plugin.needs ?? []).every((service) => core.has(service) || placed.has(providers.get(service) ?? '')));
60
+ const index = pending.findIndex((plugin) => (plugin.needs ?? []).every((service) => core.has(service) || placed.has(providers.get(service) ?? '')) &&
61
+ (plugin.wants ?? []).every((service) => !providers.has(service) || placed.has(providers.get(service) ?? '')));
59
62
  if (index === -1) {
60
63
  fail(pending[0].name, 'is part of a dependency cycle');
61
64
  }
@@ -76,7 +79,11 @@ function contextFor(plugin, ctx, { onDispose, fetch, deniedRoots }) {
76
79
  }
77
80
  function servicesFor(plugin, ctx) {
78
81
  const view = {};
79
- for (const name of [...(plugin.needs ?? []), ...(plugin.provides ?? [])]) {
82
+ for (const name of [
83
+ ...(plugin.needs ?? []),
84
+ ...(plugin.wants ?? []),
85
+ ...(plugin.provides ?? [])
86
+ ]) {
80
87
  view[name] = { enumerable: true, get: () => Reflect.get(ctx, name) };
81
88
  }
82
89
  return Object.create(null, view);
@@ -100,10 +107,10 @@ function ruledTool(tool, plugin, policy) {
100
107
  effect: granted ? tool.effect : () => 'write'
101
108
  };
102
109
  }
103
- const offline = () => Promise.reject(new TypeError('fetch refused: sandbox mode allows no network'));
104
- const unfetched = () => Promise.reject(new TypeError('fetch refused: the host gave the plugins no fetch'));
110
+ const offline = () => Promise.reject(new HarnessError('FETCH_REFUSED', ['the run has the network off']));
111
+ const unfetched = () => Promise.reject(new HarnessError('FETCH_REFUSED', ['the host gave the plugins no fetch']));
105
112
  const anywhere = () => Promise.resolve(true);
106
- function declaredHosts(targets) {
113
+ function declaredHosts(targets, allowed) {
107
114
  const hostnames = new Set();
108
115
  for (const target of typeof targets === 'string' ? [targets] : (targets ?? [])) {
109
116
  try {
@@ -112,7 +119,7 @@ function declaredHosts(targets) {
112
119
  catch {
113
120
  }
114
121
  }
115
- return (host) => Promise.resolve(hostnames.has(host));
122
+ return (host) => Promise.resolve(hostnames.has(host) && (!allowed || Policy.allowsHost(allowed, host)));
116
123
  }
117
124
  function withFetch(tool, fetchFor) {
118
125
  const { egress, execute } = tool;
@@ -123,7 +130,9 @@ function withFetch(tool, fetchFor) {
123
130
  ...tool,
124
131
  execute: (args, ctx = {}) => execute(args, {
125
132
  ...ctx,
126
- fetch: ctx.sandboxMode ? offline : fetchFor(ctx.signal, declaredHosts(egress(args)))
133
+ fetch: ctx.policy?.network.mode === 'off'
134
+ ? offline
135
+ : fetchFor(ctx.signal, declaredHosts(egress(args), Policy.hostsOf(ctx.policy)))
127
136
  })
128
137
  };
129
138
  }
@@ -0,0 +1,10 @@
1
+ import type { AccessPolicy, CompiledPolicy, PolicyGrants, PolicyProvider, RunRoots } from '../contract/policy.ts';
2
+ export declare class Policy {
3
+ static narrow(...layers: readonly (AccessPolicy | null | undefined)[]): AccessPolicy;
4
+ static compile(policy: AccessPolicy | null | undefined, grants?: PolicyGrants): CompiledPolicy;
5
+ static enforceable(policy: CompiledPolicy, { enforces }: PolicyProvider): string | null;
6
+ static refusal(policy: CompiledPolicy, providers: readonly PolicyProvider[]): string | null;
7
+ static forRun(layers: readonly (AccessPolicy | null | undefined)[], { fsRoots, fsWriteRoots, deny }: RunRoots, providers: readonly PolicyProvider[]): CompiledPolicy | undefined;
8
+ static hostsOf(policy: CompiledPolicy | undefined): readonly string[] | undefined;
9
+ static allowsHost(hosts: readonly string[], host: string): boolean;
10
+ }
@@ -0,0 +1,229 @@
1
+ import path from 'path';
2
+ const PRESETS = {
3
+ 'read-only': { files: { write: [] }, network: { mode: 'off' } },
4
+ 'workspace-write': { network: { mode: 'off' } },
5
+ full: {}
6
+ };
7
+ const ORDER = ['off', 'hosts', 'on'];
8
+ const DECISIONS = ['allow', 'ask', 'deny'];
9
+ const RULE_KEYS = ['decision', 'tool', 'command', 'paths', 'hosts'];
10
+ const UNBOUNDED = bounds({});
11
+ export class Policy {
12
+ static narrow(...layers) {
13
+ return policyOf(layers.reduce((acc, layer) => (layer ? intersect(acc, bounds(layer)) : acc), UNBOUNDED));
14
+ }
15
+ static compile(policy, grants = {}) {
16
+ const own = bounds(policy ?? {});
17
+ const outside = (grant, roots) => roots !== null && !roots.some((root) => inside(grant, root));
18
+ const read = (grants.read ?? []).find((grant) => outside(grant, own.read));
19
+ if (read !== undefined) {
20
+ throw new Error(`a granted folder is outside the policy's files.read: ${read}`);
21
+ }
22
+ const write = (grants.write ?? []).find((grant) => outside(grant, own.write));
23
+ if (write !== undefined) {
24
+ throw new Error(`a granted write folder is outside the policy's files.write: ${write}`);
25
+ }
26
+ return {
27
+ files: {
28
+ read: own.read ?? 'all',
29
+ write: unique(grants.write ?? []),
30
+ deny: unique([...own.deny, ...(grants.deny ?? [])])
31
+ },
32
+ network: networkOf(own),
33
+ sockets: own.sockets ?? 'all',
34
+ exec: { allow: own.allow ?? 'all', deny: own.execDeny },
35
+ env: own.env ?? 'all',
36
+ rules: own.rules
37
+ };
38
+ }
39
+ static enforceable(policy, { enforces }) {
40
+ if ((policy.exec.allow !== 'all' || policy.exec.deny.length > 0) && !enforces?.exec) {
41
+ return 'cannot enforce exec.allow or exec.deny';
42
+ }
43
+ if (policy.env !== 'all' && !enforces?.env) {
44
+ return 'cannot enforce an env allowlist';
45
+ }
46
+ if (enforces?.files === 'workspace-only' && policy.files.read !== 'all') {
47
+ return 'confines writes only, so it cannot enforce a files.read list';
48
+ }
49
+ if (policy.network.mode === 'hosts' && !enforces) {
50
+ return 'runs lines on the host, so it cannot enforce network.mode hosts';
51
+ }
52
+ if (enforces?.network === 'on-off' && policy.network.mode === 'hosts') {
53
+ return 'cannot enforce network.mode hosts without the egress-proxy plugin';
54
+ }
55
+ const { localhost, bind } = policy.network;
56
+ const partial = !localhost || !bind || policy.sockets !== 'all';
57
+ const bounded = enforces?.network === 'on-off' || enforces?.network === 'hosts';
58
+ if (bounded && policy.network.mode === 'on' && partial) {
59
+ return 'turns the network on or off, so it cannot enforce localhost, bind or sockets under network.mode on';
60
+ }
61
+ return null;
62
+ }
63
+ static refusal(policy, providers) {
64
+ if (!ORDER.includes(policy.network.mode)) {
65
+ return `network.mode ${policy.network.mode} is refused: it is not off, hosts or on`;
66
+ }
67
+ for (const provider of providers) {
68
+ const refused = Policy.enforceable(policy, provider);
69
+ if (refused) {
70
+ return `${provider.name} ${refused}`;
71
+ }
72
+ }
73
+ const malformed = policy.rules.findIndex((rule) => !wellFormed(rule));
74
+ return malformed === -1
75
+ ? null
76
+ : `policy rule ${malformed} is malformed: it needs a decision (allow, ask or deny), a non-empty tool, command, paths or hosts, and no other key`;
77
+ }
78
+ static forRun(layers, { fsRoots = [], fsWriteRoots = [], deny = [] }, providers) {
79
+ if (!layers.some(Boolean)) {
80
+ return undefined;
81
+ }
82
+ const access = Policy.compile(Policy.narrow(...layers), {
83
+ read: local(fsRoots),
84
+ write: local(fsWriteRoots),
85
+ deny
86
+ });
87
+ const refused = Policy.refusal(access, providers);
88
+ if (refused) {
89
+ throw new Error(`the run's policy is refused: ${refused}`);
90
+ }
91
+ return access;
92
+ }
93
+ static hostsOf(policy) {
94
+ return policy?.network.mode === 'hosts' ? policy.network.hosts : undefined;
95
+ }
96
+ static allowsHost(hosts, host) {
97
+ const name = hostName(host);
98
+ return hosts.some((entry) => covers(hostName(entry), name));
99
+ }
100
+ }
101
+ function wellFormed(rule) {
102
+ if (typeof rule !== 'object' || rule === null || !DECISIONS.includes(rule.decision)) {
103
+ return false;
104
+ }
105
+ if (Object.keys(rule).some((key) => !RULE_KEYS.includes(key))) {
106
+ return false;
107
+ }
108
+ const { tool, command, paths, hosts } = rule;
109
+ const lists = [command, paths, hosts];
110
+ if (tool === undefined && lists.every((list) => list === undefined)) {
111
+ return false;
112
+ }
113
+ return ((tool === undefined || (typeof tool === 'string' && tool !== '')) &&
114
+ lists.every((list) => list === undefined || strings(list)));
115
+ }
116
+ function strings(list) {
117
+ return (Array.isArray(list) &&
118
+ list.length > 0 &&
119
+ list.every((each) => typeof each === 'string' && each !== ''));
120
+ }
121
+ function local(roots) {
122
+ return roots.flatMap((root) => (root.kind === 'local' ? [root.root] : []));
123
+ }
124
+ function bounds(layer) {
125
+ const preset = layer.preset ? PRESETS[layer.preset] : {};
126
+ const read = layer.files?.read ?? preset.files?.read ?? 'all';
127
+ const write = layer.files?.write ?? preset.files?.write;
128
+ const network = layer.network ?? preset.network ?? { mode: 'on' };
129
+ const mode = ORDER.includes(network.mode) ? network.mode : 'off';
130
+ const open = mode === 'on';
131
+ return {
132
+ read: read === 'all' ? null : unique(read.map(normal)),
133
+ write: write ? unique(write.map(normal)) : null,
134
+ deny: unique((layer.files?.deny ?? preset.files?.deny ?? []).map(normal)),
135
+ mode,
136
+ hosts: open ? null : unique((network.hosts ?? []).map(hostName)),
137
+ localhost: network.localhost ?? open,
138
+ bind: network.bind ?? open,
139
+ sockets: socketsOf(layer.sockets, open),
140
+ allow: layer.exec?.allow ? unique(layer.exec.allow) : null,
141
+ execDeny: unique(layer.exec?.deny ?? []),
142
+ env: layer.env ? unique(layer.env) : null,
143
+ rules: layer.rules ?? []
144
+ };
145
+ }
146
+ function socketsOf(sockets, open) {
147
+ if (sockets) {
148
+ return unique(sockets.map(normal));
149
+ }
150
+ return open ? null : [];
151
+ }
152
+ function intersect(a, b) {
153
+ return {
154
+ read: within(a.read, b.read),
155
+ write: within(a.write, b.write),
156
+ deny: unique([...a.deny, ...b.deny]),
157
+ mode: ORDER[Math.min(ORDER.indexOf(a.mode), ORDER.indexOf(b.mode))],
158
+ hosts: coveredHosts(a.hosts, b.hosts),
159
+ localhost: a.localhost && b.localhost,
160
+ bind: a.bind && b.bind,
161
+ sockets: within(a.sockets, b.sockets),
162
+ allow: common(a.allow, b.allow),
163
+ execDeny: unique([...a.execDeny, ...b.execDeny]),
164
+ env: common(a.env, b.env),
165
+ rules: [...a.rules, ...b.rules]
166
+ };
167
+ }
168
+ function policyOf(own) {
169
+ return {
170
+ files: { read: own.read ?? 'all', write: own.write ?? undefined, deny: own.deny },
171
+ network: networkOf(own),
172
+ sockets: own.sockets ?? undefined,
173
+ exec: { allow: own.allow ?? undefined, deny: own.execDeny },
174
+ env: own.env ?? undefined,
175
+ rules: own.rules
176
+ };
177
+ }
178
+ function networkOf(own) {
179
+ return {
180
+ mode: own.mode,
181
+ hosts: own.mode === 'hosts' ? (own.hosts ?? []) : [],
182
+ localhost: own.localhost,
183
+ bind: own.bind
184
+ };
185
+ }
186
+ function within(a, b) {
187
+ if (a === null || b === null) {
188
+ return a ?? b;
189
+ }
190
+ return unique([
191
+ ...a.filter((each) => b.some((root) => inside(each, root))),
192
+ ...b.filter((each) => a.some((root) => inside(each, root)))
193
+ ]).sort();
194
+ }
195
+ function coveredHosts(a, b) {
196
+ if (a === null || b === null) {
197
+ return a ?? b;
198
+ }
199
+ return unique([
200
+ ...a.filter((each) => b.some((entry) => covers(entry, each))),
201
+ ...b.filter((each) => a.some((entry) => covers(entry, each)))
202
+ ]).sort();
203
+ }
204
+ function covers(entry, host) {
205
+ return host === entry || (entry.startsWith('*.') && host.endsWith(entry.slice(1)));
206
+ }
207
+ function hostName(host) {
208
+ return host
209
+ .toLowerCase()
210
+ .replace(/^\[(.*)\]$/, '$1')
211
+ .replace(/\.$/, '');
212
+ }
213
+ function common(a, b) {
214
+ if (a === null || b === null) {
215
+ return a ?? b;
216
+ }
217
+ return a.filter((each) => b.includes(each));
218
+ }
219
+ function inside(child, root) {
220
+ const relative = path.relative(normal(root), normal(child));
221
+ return (relative === '' ||
222
+ (relative !== '..' && !relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative)));
223
+ }
224
+ function normal(root) {
225
+ return path.resolve(root);
226
+ }
227
+ function unique(items) {
228
+ return [...new Set(items)];
229
+ }
@@ -6,6 +6,7 @@ export declare function annotateLastUserTime<T extends {
6
6
  role: string;
7
7
  content: string;
8
8
  }>(turns: ReadonlyArray<T>, now?: Date): T[];
9
+ export declare function toolGuidelines(name: string): string[];
9
10
  export interface SystemPromptInput {
10
11
  bio?: string | null | undefined;
11
12
  toolNames?: ReadonlyArray<string>;
@@ -51,13 +51,19 @@ export function annotateLastUserTime(turns, now) {
51
51
  }
52
52
  return result;
53
53
  }
54
+ export function toolGuidelines(name) {
55
+ if (name === 'exec') {
56
+ return [EXEC_FILE_GUIDELINE, EXEC_ATTACHED_IMAGE_GUIDELINE];
57
+ }
58
+ return name === 'web_search' || name === 'web_fetch' ? [CITATION_GUIDELINE] : [];
59
+ }
54
60
  function buildGuidelines(active) {
55
61
  const lines = [...BASE_GUIDELINES];
56
62
  if (active.size > 0) {
57
63
  lines.push(...TOOL_GUIDELINES);
58
64
  }
59
65
  if (active.has('exec')) {
60
- lines.push(EXEC_FILE_GUIDELINE, EXEC_ATTACHED_IMAGE_GUIDELINE);
66
+ lines.push(...toolGuidelines('exec'));
61
67
  }
62
68
  if (active.has('skill')) {
63
69
  lines.push(...SKILL_GUIDELINES);
@@ -10,6 +10,7 @@ export type CompletionRuntimeRequest = CompletionContext & {
10
10
  interface RuntimeLease {
11
11
  modelId: string;
12
12
  ctxSize?: number | undefined;
13
+ slots?: number | undefined;
13
14
  release(): void;
14
15
  }
15
16
  interface RuntimeAcquireOptions {
@@ -1,7 +1,8 @@
1
+ import { HarnessError } from '../errors.js';
1
2
  import { createLocalRoots } from '../tools/fs/local.js';
2
3
  import { createRemoteRoots } from '../tools/fs/remote.js';
3
4
  import { isResident, modelKey, resolveCtxSize } from '../models/model-pool.js';
4
- import { hlog } from '../log.js';
5
+ import { HarnessLog } from '../log.js';
5
6
  export async function prepareCompletionRuntime(residency, request) {
6
7
  const model = request.model ?? '';
7
8
  const agent = request.agent;
@@ -14,7 +15,7 @@ export async function prepareCompletionRuntime(residency, request) {
14
15
  }
15
16
  const key = modelKey(model, loadOpts);
16
17
  const resident = isResident(residency.pool, key);
17
- hlog('completion start', { model, resident, projection: Boolean(projectionModel) });
18
+ HarnessLog.info('completion start', { model, resident, projection: Boolean(projectionModel) });
18
19
  const acquireRound = async (invocationSignal) => {
19
20
  const pool = residency.pool;
20
21
  const lease = await residency.acquireLease({
@@ -39,10 +40,16 @@ export async function prepareCompletionRuntime(residency, request) {
39
40
  try {
40
41
  const sdk = await residency.sdk.load();
41
42
  if (residency.gate.suspended || residency.gate.draining) {
42
- throw new Error('harness is suspended');
43
+ throw new HarnessError('HARNESS_SUSPENDED');
43
44
  }
44
45
  residency.gate.assertNotClosing();
45
- return { modelId: lease.modelId, ctxSize: lease.ctxSize, sdk, release: lease.release };
46
+ return {
47
+ modelId: lease.modelId,
48
+ ctxSize: lease.ctxSize,
49
+ slots: lease.slots,
50
+ sdk,
51
+ release: lease.release
52
+ };
46
53
  }
47
54
  catch (error) {
48
55
  lease.release();