@qvac/harness 1.0.0-rc.2 → 1.0.0-rc.20

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 (582) hide show
  1. package/.nvmrc +1 -0
  2. package/CHANGELOG.md +3050 -1485
  3. package/README.md +110 -46
  4. package/dist-lib/index.d.ts +60 -15
  5. package/dist-lib/index.js +228 -35
  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 +11 -2
  10. package/dist-lib/lib/agent/resolve.js +29 -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 +2 -0
  14. package/dist-lib/lib/agent/tools.js +2 -1
  15. package/dist-lib/lib/capabilities/agent-ports.d.ts +1 -1
  16. package/dist-lib/lib/capabilities/agent-ports.js +11 -4
  17. package/dist-lib/lib/capabilities/completion-engine/actors/batching.js +1 -0
  18. package/dist-lib/lib/capabilities/completion-engine/actors/direct-search.js +2 -0
  19. package/dist-lib/lib/capabilities/completion-engine/actors/executing.d.ts +2 -1
  20. package/dist-lib/lib/capabilities/completion-engine/actors/executing.js +129 -12
  21. package/dist-lib/lib/capabilities/completion-engine/actors/execution-plan.js +10 -4
  22. package/dist-lib/lib/capabilities/completion-engine/actors/inspect-prepare.js +3 -2
  23. package/dist-lib/lib/capabilities/completion-engine/actors/inspecting.d.ts +1 -1
  24. package/dist-lib/lib/capabilities/completion-engine/actors/inspecting.js +54 -10
  25. package/dist-lib/lib/capabilities/completion-engine/actors/loading-skill.d.ts +1 -1
  26. package/dist-lib/lib/capabilities/completion-engine/actors/loading-skill.js +10 -1
  27. package/dist-lib/lib/capabilities/completion-engine/actors/preparing.js +137 -50
  28. package/dist-lib/lib/capabilities/completion-engine/actors/rejecting.js +10 -4
  29. package/dist-lib/lib/capabilities/completion-engine/actors/resolving.js +69 -17
  30. package/dist-lib/lib/capabilities/completion-engine/actors/retrieving.d.ts +2 -1
  31. package/dist-lib/lib/capabilities/completion-engine/actors/retrieving.js +33 -16
  32. package/dist-lib/lib/capabilities/completion-engine/actors/run-prepare.js +36 -22
  33. package/dist-lib/lib/capabilities/completion-engine/actors/skill-step.js +50 -12
  34. package/dist-lib/lib/capabilities/completion-engine/actors/stream.d.ts +10 -4
  35. package/dist-lib/lib/capabilities/completion-engine/actors/stream.js +80 -3
  36. package/dist-lib/lib/capabilities/completion-engine/actors/streaming.d.ts +5 -1
  37. package/dist-lib/lib/capabilities/completion-engine/actors/streaming.js +95 -35
  38. package/dist-lib/lib/capabilities/completion-engine/actors/wrap-up.d.ts +2 -1
  39. package/dist-lib/lib/capabilities/completion-engine/actors/wrap-up.js +55 -16
  40. package/dist-lib/lib/capabilities/completion-engine/driver.js +58 -15
  41. package/dist-lib/lib/capabilities/completion-engine/durable.d.ts +3 -1
  42. package/dist-lib/lib/capabilities/completion-engine/durable.js +12 -2
  43. package/dist-lib/lib/capabilities/completion-engine/engine.d.ts +4 -1
  44. package/dist-lib/lib/capabilities/completion-engine/engine.js +14 -1
  45. package/dist-lib/lib/capabilities/completion-engine/index.d.ts +5 -1
  46. package/dist-lib/lib/capabilities/completion-engine/index.js +5 -2
  47. package/dist-lib/lib/capabilities/completion-engine/loop.d.ts +25 -3
  48. package/dist-lib/lib/capabilities/completion-engine/loop.js +13 -2
  49. package/dist-lib/lib/capabilities/completion-engine/metrics.d.ts +9 -2
  50. package/dist-lib/lib/capabilities/completion-engine/metrics.js +28 -7
  51. package/dist-lib/lib/capabilities/completion-engine/model-round.d.ts +63 -0
  52. package/dist-lib/lib/capabilities/completion-engine/model-round.js +99 -0
  53. package/dist-lib/lib/capabilities/completion-engine/operations.js +30 -10
  54. package/dist-lib/lib/capabilities/completion-engine/ports.js +6 -9
  55. package/dist-lib/lib/capabilities/completion-engine/prepare-step.d.ts +4 -1
  56. package/dist-lib/lib/capabilities/completion-engine/round.d.ts +38 -6
  57. package/dist-lib/lib/capabilities/completion-engine/round.js +393 -116
  58. package/dist-lib/lib/capabilities/completion-engine/session.d.ts +12 -4
  59. package/dist-lib/lib/capabilities/completion-engine/session.js +31 -2
  60. package/dist-lib/lib/capabilities/completion-engine/tool-caller.js +3 -2
  61. package/dist-lib/lib/capabilities/completion-engine/tool-execution.d.ts +5 -4
  62. package/dist-lib/lib/capabilities/completion-engine/tool-execution.js +32 -12
  63. package/dist-lib/lib/capabilities/completion-engine/tool-sets.d.ts +24 -0
  64. package/dist-lib/lib/capabilities/completion-engine/tool-sets.js +15 -0
  65. package/dist-lib/lib/capabilities/completion-engine/turns.d.ts +17 -9
  66. package/dist-lib/lib/capabilities/completion-engine/turns.js +96 -87
  67. package/dist-lib/lib/capabilities/detect-language.d.ts +2 -1
  68. package/dist-lib/lib/capabilities/detect-language.js +14 -2
  69. package/dist-lib/lib/capabilities/download.d.ts +10 -8
  70. package/dist-lib/lib/capabilities/download.js +1 -1
  71. package/dist-lib/lib/capabilities/enhance.d.ts +1 -1
  72. package/dist-lib/lib/capabilities/enhance.js +23 -11
  73. package/dist-lib/lib/capabilities/kv-cache.d.ts +1 -1
  74. package/dist-lib/lib/capabilities/preview-model-source.d.ts +7 -0
  75. package/dist-lib/lib/capabilities/preview-model-source.js +83 -23
  76. package/dist-lib/lib/capabilities/prompt-prefix.d.ts +3 -1
  77. package/dist-lib/lib/capabilities/prompt-prefix.js +8 -0
  78. package/dist-lib/lib/capabilities/sdk-tool.d.ts +13 -4
  79. package/dist-lib/lib/capabilities/sdk-tool.js +59 -7
  80. package/dist-lib/lib/capabilities/skill-entry.d.ts +13 -1
  81. package/dist-lib/lib/capabilities/skill-entry.js +33 -2
  82. package/dist-lib/lib/capabilities/tool-failed-note.d.ts +1 -0
  83. package/dist-lib/lib/capabilities/tool-failed-note.js +1 -0
  84. package/dist-lib/lib/capabilities/tool-plan.d.ts +5 -1
  85. package/dist-lib/lib/capabilities/tool-plan.js +20 -5
  86. package/dist-lib/lib/capabilities/tool-prompt-log.d.ts +1 -1
  87. package/dist-lib/lib/capabilities/tool-prompt-log.js +3 -3
  88. package/dist-lib/lib/capabilities/tool-turns.d.ts +20 -9
  89. package/dist-lib/lib/capabilities/tool-turns.js +77 -49
  90. package/dist-lib/lib/capabilities/usage-breakdown.d.ts +1 -0
  91. package/dist-lib/lib/capabilities/usage-breakdown.js +4 -1
  92. package/dist-lib/lib/client/index.d.ts +19 -0
  93. package/dist-lib/lib/client/index.js +263 -0
  94. package/dist-lib/lib/connect.d.ts +19 -10
  95. package/dist-lib/lib/connect.js +239 -32
  96. package/dist-lib/lib/context-window.d.ts +2 -0
  97. package/dist-lib/lib/context-window.js +9 -3
  98. package/dist-lib/lib/contract/agent.d.ts +13 -3
  99. package/dist-lib/lib/contract/completion.d.ts +77 -31
  100. package/dist-lib/lib/contract/drive.d.ts +4 -0
  101. package/dist-lib/lib/contract/drive.js +1 -0
  102. package/dist-lib/lib/contract/egress-proxy.d.ts +13 -0
  103. package/dist-lib/lib/contract/egress-proxy.js +1 -0
  104. package/dist-lib/lib/contract/exec.d.ts +4 -3
  105. package/dist-lib/lib/contract/hooks.d.ts +4 -1
  106. package/dist-lib/lib/contract/index.d.ts +4 -0
  107. package/dist-lib/lib/contract/knowledge.d.ts +10 -0
  108. package/dist-lib/lib/contract/managed-skills.d.ts +1 -0
  109. package/dist-lib/lib/contract/managed-skills.js +1 -0
  110. package/dist-lib/lib/contract/media.d.ts +58 -0
  111. package/dist-lib/lib/contract/media.js +1 -0
  112. package/dist-lib/lib/contract/models.d.ts +12 -6
  113. package/dist-lib/lib/contract/ocr.d.ts +13 -0
  114. package/dist-lib/lib/contract/ocr.js +1 -0
  115. package/dist-lib/lib/contract/policy.d.ts +75 -0
  116. package/dist-lib/lib/contract/policy.js +1 -0
  117. package/dist-lib/lib/contract/run.d.ts +28 -3
  118. package/dist-lib/lib/contract/sandbox.d.ts +3 -1
  119. package/dist-lib/lib/contract/speech.d.ts +1 -1
  120. package/dist-lib/lib/contract/translation.d.ts +20 -0
  121. package/dist-lib/lib/contract/translation.js +1 -0
  122. package/dist-lib/lib/contract-types.d.ts +46 -16
  123. package/dist-lib/lib/embeddings/index.d.ts +7 -1
  124. package/dist-lib/lib/embeddings/index.js +26 -5
  125. package/dist-lib/lib/errors.d.ts +278 -0
  126. package/dist-lib/lib/errors.js +212 -0
  127. package/dist-lib/lib/fold/index.d.ts +26 -1
  128. package/dist-lib/lib/fold/index.js +76 -9
  129. package/dist-lib/lib/guarded-fetch.js +11 -7
  130. package/dist-lib/lib/guards.d.ts +2 -0
  131. package/dist-lib/lib/guards.js +7 -0
  132. package/dist-lib/lib/hardware/capability-probe.js +10 -7
  133. package/dist-lib/lib/hardware/cpu-placement.d.ts +8 -0
  134. package/dist-lib/lib/hardware/cpu-placement.js +48 -0
  135. package/dist-lib/lib/hardware/gpu-probe-addon.js +26 -11
  136. package/dist-lib/lib/hardware/gpu-probe.js +10 -1
  137. package/dist-lib/lib/hardware/gpu-stats.native.cjs +17 -1
  138. package/dist-lib/lib/helpers/completion-params.d.ts +7 -2
  139. package/dist-lib/lib/helpers/completion-params.js +26 -2
  140. package/dist-lib/lib/helpers/control-tokens.d.ts +3 -0
  141. package/dist-lib/lib/helpers/control-tokens.js +25 -0
  142. package/dist-lib/lib/helpers/engine-error.d.ts +2 -1
  143. package/dist-lib/lib/helpers/engine-error.js +12 -12
  144. package/dist-lib/lib/helpers/goal-check.d.ts +44 -0
  145. package/dist-lib/lib/helpers/goal-check.js +407 -0
  146. package/dist-lib/lib/helpers/head-tail.js +1 -1
  147. package/dist-lib/lib/helpers/html-helpers.js +9 -6
  148. package/dist-lib/lib/helpers/load-stall.d.ts +1 -1
  149. package/dist-lib/lib/helpers/load-stall.js +2 -2
  150. package/dist-lib/lib/helpers/markup-stream-filter.d.ts +4 -1
  151. package/dist-lib/lib/helpers/markup-stream-filter.js +20 -6
  152. package/dist-lib/lib/helpers/repeated-reply.js +24 -16
  153. package/dist-lib/lib/helpers/require-peers.d.ts +3 -0
  154. package/dist-lib/lib/helpers/require-peers.js +23 -0
  155. package/dist-lib/lib/helpers/run-outcome.d.ts +2 -0
  156. package/dist-lib/lib/helpers/run-outcome.js +6 -2
  157. package/dist-lib/lib/helpers/spawn-path.d.ts +1 -0
  158. package/dist-lib/lib/helpers/spawn-path.js +2 -1
  159. package/dist-lib/lib/helpers/thinking.d.ts +3 -2
  160. package/dist-lib/lib/helpers/thinking.js +19 -0
  161. package/dist-lib/lib/hooks/built-in/arg-repair.js +6 -2
  162. package/dist-lib/lib/hooks/built-in/policy-rules.d.ts +8 -0
  163. package/dist-lib/lib/hooks/built-in/policy-rules.js +192 -0
  164. package/dist-lib/lib/hooks/built-in/sandbox.js +23 -5
  165. package/dist-lib/lib/hooks/index.d.ts +4 -1
  166. package/dist-lib/lib/hooks/index.js +9 -4
  167. package/dist-lib/lib/hooks/run.js +3 -3
  168. package/dist-lib/lib/lifecycle/index.js +15 -14
  169. package/dist-lib/lib/lifecycle/machine.js +2 -2
  170. package/dist-lib/lib/log.d.ts +26 -5
  171. package/dist-lib/lib/log.js +86 -23
  172. package/dist-lib/lib/machine/completion/actions/completion.d.ts +11 -6
  173. package/dist-lib/lib/machine/completion/actions/completion.js +251 -35
  174. package/dist-lib/lib/machine/completion/actions/prepare.js +1 -1
  175. package/dist-lib/lib/machine/completion/actions/tools.js +122 -6
  176. package/dist-lib/lib/machine/completion/context.js +11 -1
  177. package/dist-lib/lib/machine/completion/guards/retry.d.ts +3 -1
  178. package/dist-lib/lib/machine/completion/guards/retry.js +9 -2
  179. package/dist-lib/lib/machine/completion/implementations.d.ts +16 -7
  180. package/dist-lib/lib/machine/completion/implementations.js +59 -15
  181. package/dist-lib/lib/machine/completion/machine.d.ts +36 -7
  182. package/dist-lib/lib/machine/completion/machine.js +58 -9
  183. package/dist-lib/lib/machine/completion/rules.d.ts +23 -2
  184. package/dist-lib/lib/machine/completion/rules.js +91 -6
  185. package/dist-lib/lib/machine/completion/types.d.ts +77 -1
  186. package/dist-lib/lib/machine/index.d.ts +48 -9
  187. package/dist-lib/lib/machine/index.js +11 -1
  188. package/dist-lib/lib/media-host.d.ts +12 -0
  189. package/dist-lib/lib/media-host.js +52 -0
  190. package/dist-lib/lib/media-port.d.ts +20 -0
  191. package/dist-lib/lib/media-port.js +77 -0
  192. package/dist-lib/lib/media-wire.d.ts +8 -0
  193. package/dist-lib/lib/media-wire.js +111 -0
  194. package/dist-lib/lib/models/context-choice.d.ts +15 -0
  195. package/dist-lib/lib/models/context-choice.js +62 -0
  196. package/dist-lib/lib/models/context.d.ts +1 -1
  197. package/dist-lib/lib/models/custom-model-cache.d.ts +1 -0
  198. package/dist-lib/lib/models/custom-model-cache.js +3 -0
  199. package/dist-lib/lib/models/download-gate.d.ts +20 -0
  200. package/dist-lib/lib/models/download-gate.js +73 -0
  201. package/dist-lib/lib/models/gguf-header.d.ts +11 -0
  202. package/dist-lib/lib/models/gguf-header.js +203 -15
  203. package/dist-lib/lib/models/gpu-selection.d.ts +6 -1
  204. package/dist-lib/lib/models/gpu-selection.js +29 -5
  205. package/dist-lib/lib/models/kv-cache.d.ts +2 -0
  206. package/dist-lib/lib/models/kv-cache.js +8 -0
  207. package/dist-lib/lib/models/llm-presets.d.ts +6 -1
  208. package/dist-lib/lib/models/llm-presets.js +33 -6
  209. package/dist-lib/lib/models/load-requests.d.ts +9 -0
  210. package/dist-lib/lib/models/load-requests.js +42 -0
  211. package/dist-lib/lib/models/memory-cap.d.ts +13 -0
  212. package/dist-lib/lib/models/memory-cap.js +21 -0
  213. package/dist-lib/lib/models/model-catalog-constants.d.ts +2 -2
  214. package/dist-lib/lib/models/model-catalog-constants.js +3 -4
  215. package/dist-lib/lib/models/model-catalog.d.ts +7 -3
  216. package/dist-lib/lib/models/model-catalog.js +44 -11
  217. package/dist-lib/lib/models/model-delete.d.ts +1 -1
  218. package/dist-lib/lib/models/model-fit.d.ts +2 -2
  219. package/dist-lib/lib/models/model-fit.js +5 -6
  220. package/dist-lib/lib/models/model-handle.d.ts +9 -2
  221. package/dist-lib/lib/models/model-handle.js +14 -3
  222. package/dist-lib/lib/models/model-list.d.ts +9 -2
  223. package/dist-lib/lib/models/model-list.js +23 -0
  224. package/dist-lib/lib/models/model-pool.d.ts +42 -7
  225. package/dist-lib/lib/models/model-pool.js +139 -49
  226. package/dist-lib/lib/models/model-source.d.ts +3 -2
  227. package/dist-lib/lib/models/model-source.js +23 -5
  228. package/dist-lib/lib/models/opencl-cache.js +2 -2
  229. package/dist-lib/lib/models/sdk-faults.d.ts +1 -0
  230. package/dist-lib/lib/models/sdk-faults.js +9 -0
  231. package/dist-lib/lib/models/tool-dialect.d.ts +1 -1
  232. package/dist-lib/lib/models/tts-model-default.d.ts +2 -1
  233. package/dist-lib/lib/models/tts-model-default.js +8 -6
  234. package/dist-lib/lib/no-redirect-fetch-bare.js +2 -1
  235. package/dist-lib/lib/no-redirect-fetch-impl.d.ts +2 -1
  236. package/dist-lib/lib/no-redirect-fetch-impl.js +46 -8
  237. package/dist-lib/lib/office/engine/pptx/picture-area.d.ts +23 -0
  238. package/dist-lib/lib/office/engine/pptx/picture-area.js +84 -0
  239. package/dist-lib/lib/office/engine/pptx/presentation.d.ts +2 -0
  240. package/dist-lib/lib/office/engine/pptx/presentation.js +64 -21
  241. package/dist-lib/lib/office/engine/pptx/types.d.ts +1 -0
  242. package/dist-lib/lib/office/engine/xlsx/sheet.js +10 -4
  243. package/dist-lib/lib/office/engine/xlsx/workbook.d.ts +1 -0
  244. package/dist-lib/lib/office/engine/xlsx/workbook.js +34 -3
  245. package/dist-lib/lib/office/extract.js +4 -3
  246. package/dist-lib/lib/office/index.js +2 -1
  247. package/dist-lib/lib/plugins/registry.d.ts +15 -0
  248. package/dist-lib/lib/plugins/registry.js +91 -22
  249. package/dist-lib/lib/plugins/require-bare.d.ts +1 -0
  250. package/dist-lib/lib/plugins/require-bare.js +13 -0
  251. package/dist-lib/lib/policy/index.d.ts +11 -0
  252. package/dist-lib/lib/policy/index.js +235 -0
  253. package/dist-lib/lib/prompt.d.ts +9 -4
  254. package/dist-lib/lib/prompt.js +95 -32
  255. package/dist-lib/lib/residency/completion-runtime.d.ts +15 -5
  256. package/dist-lib/lib/residency/completion-runtime.js +47 -36
  257. package/dist-lib/lib/residency/index.d.ts +56 -4
  258. package/dist-lib/lib/residency/index.js +442 -40
  259. package/dist-lib/lib/resolution-detector.js +3 -3
  260. package/dist-lib/lib/round-host.d.ts +12 -0
  261. package/dist-lib/lib/round-host.js +57 -0
  262. package/dist-lib/lib/round-port.d.ts +24 -0
  263. package/dist-lib/lib/round-port.js +81 -0
  264. package/dist-lib/lib/rpc-session.js +2 -1
  265. package/dist-lib/lib/run-log/request-codec.js +2 -2
  266. package/dist-lib/lib/sdk-loader.d.ts +1 -1
  267. package/dist-lib/lib/sdk-loader.js +47 -17
  268. package/dist-lib/lib/sdk-storage.d.ts +1 -0
  269. package/dist-lib/lib/sdk-storage.js +18 -2
  270. package/dist-lib/lib/serve.js +242 -50
  271. package/dist-lib/lib/sidecar/index.d.ts +39 -0
  272. package/dist-lib/lib/sidecar/index.js +205 -0
  273. package/dist-lib/lib/sidecar/user-plugins.d.ts +9 -0
  274. package/dist-lib/lib/sidecar/user-plugins.js +119 -0
  275. package/dist-lib/lib/skills-host/index.d.ts +3 -1
  276. package/dist-lib/lib/skills-host/index.js +27 -14
  277. package/dist-lib/lib/spawn.d.ts +6 -4
  278. package/dist-lib/lib/spawn.js +22 -20
  279. package/dist-lib/lib/spill.d.ts +1 -0
  280. package/dist-lib/lib/spill.js +12 -8
  281. package/dist-lib/lib/tools/ask-user.d.ts +2 -0
  282. package/dist-lib/lib/tools/ask-user.js +137 -0
  283. package/dist-lib/lib/tools/attachments/delivered.d.ts +5 -0
  284. package/dist-lib/lib/tools/attachments/delivered.js +16 -0
  285. package/dist-lib/lib/tools/attachments/fetched-file.d.ts +32 -0
  286. package/dist-lib/lib/tools/attachments/fetched-file.js +134 -0
  287. package/dist-lib/lib/tools/attachments/staging.d.ts +1 -0
  288. package/dist-lib/lib/tools/attachments/staging.js +19 -8
  289. package/dist-lib/lib/tools/exec/runner.d.ts +4 -0
  290. package/dist-lib/lib/tools/exec/runner.js +20 -2
  291. package/dist-lib/lib/tools/exec/scope.d.ts +0 -1
  292. package/dist-lib/lib/tools/exec/scope.js +23 -114
  293. package/dist-lib/lib/tools/exec/shell-guidance.js +4 -4
  294. package/dist-lib/lib/tools/exec/shell-line.d.ts +26 -0
  295. package/dist-lib/lib/tools/exec/shell-line.js +334 -0
  296. package/dist-lib/lib/tools/exec.d.ts +4 -1
  297. package/dist-lib/lib/tools/exec.js +89 -27
  298. package/dist-lib/lib/tools/files/edit-file.d.ts +6 -0
  299. package/dist-lib/lib/tools/files/edit-file.js +266 -0
  300. package/dist-lib/lib/tools/files/glob.d.ts +3 -0
  301. package/dist-lib/lib/tools/files/glob.js +65 -0
  302. package/dist-lib/lib/tools/files/grep.d.ts +6 -0
  303. package/dist-lib/lib/tools/files/grep.js +212 -0
  304. package/dist-lib/lib/tools/files/index.d.ts +3 -0
  305. package/dist-lib/lib/tools/files/index.js +25 -0
  306. package/dist-lib/lib/tools/files/list-dir.d.ts +6 -0
  307. package/dist-lib/lib/tools/files/list-dir.js +136 -0
  308. package/dist-lib/lib/tools/files/make-dir.d.ts +3 -0
  309. package/dist-lib/lib/tools/files/make-dir.js +48 -0
  310. package/dist-lib/lib/tools/files/read-file.d.ts +3 -0
  311. package/dist-lib/lib/tools/files/read-file.js +224 -0
  312. package/dist-lib/lib/tools/files/transfer.d.ts +4 -0
  313. package/dist-lib/lib/tools/files/transfer.js +83 -0
  314. package/dist-lib/lib/tools/files/trash-file.d.ts +4 -0
  315. package/dist-lib/lib/tools/files/trash-file.js +62 -0
  316. package/dist-lib/lib/tools/files/write-file.d.ts +3 -0
  317. package/dist-lib/lib/tools/files/write-file.js +56 -0
  318. package/dist-lib/lib/tools/fs/document-text.d.ts +8 -0
  319. package/dist-lib/lib/tools/fs/document-text.js +22 -0
  320. package/dist-lib/lib/tools/fs/drive.d.ts +10 -14
  321. package/dist-lib/lib/tools/fs/drive.js +9 -1
  322. package/dist-lib/lib/tools/fs/edit-match.d.ts +33 -0
  323. package/dist-lib/lib/tools/fs/edit-match.js +445 -0
  324. package/dist-lib/lib/tools/fs/ignore.d.ts +13 -0
  325. package/dist-lib/lib/tools/fs/ignore.js +104 -0
  326. package/dist-lib/lib/tools/fs/local.js +28 -5
  327. package/dist-lib/lib/tools/fs/remote-protocol.d.ts +45 -3
  328. package/dist-lib/lib/tools/fs/remote-protocol.js +1 -1
  329. package/dist-lib/lib/tools/fs/remote.d.ts +3 -11
  330. package/dist-lib/lib/tools/fs/remote.js +24 -14
  331. package/dist-lib/lib/tools/fs/scope.d.ts +5 -1
  332. package/dist-lib/lib/tools/fs/scope.js +5 -2
  333. package/dist-lib/lib/tools/fs/search.d.ts +41 -0
  334. package/dist-lib/lib/tools/fs/search.js +383 -0
  335. package/dist-lib/lib/tools/{file-glob.d.ts → fs/targets.d.ts} +1 -5
  336. package/dist-lib/lib/tools/fs/targets.js +32 -0
  337. package/dist-lib/lib/tools/fs/tool-path.d.ts +27 -0
  338. package/dist-lib/lib/tools/fs/tool-path.js +70 -0
  339. package/dist-lib/lib/tools/fs/walk.d.ts +16 -3
  340. package/dist-lib/lib/tools/fs/walk.js +119 -24
  341. package/dist-lib/lib/tools/http-request/request.d.ts +4 -2
  342. package/dist-lib/lib/tools/http-request/request.js +2 -1
  343. package/dist-lib/lib/tools/http-request/truncate-response.d.ts +16 -1
  344. package/dist-lib/lib/tools/http-request/truncate-response.js +56 -11
  345. package/dist-lib/lib/tools/http-request.d.ts +1 -0
  346. package/dist-lib/lib/tools/http-request.js +101 -16
  347. package/dist-lib/lib/tools/index.d.ts +4 -1
  348. package/dist-lib/lib/tools/index.js +8 -12
  349. package/dist-lib/lib/tools/office/ops.d.ts +1 -0
  350. package/dist-lib/lib/tools/office/ops.js +5 -1
  351. package/dist-lib/lib/tools/office.d.ts +2 -1
  352. package/dist-lib/lib/tools/office.js +273 -56
  353. package/dist-lib/lib/tools/operations/builders.d.ts +4 -3
  354. package/dist-lib/lib/tools/operations/builders.js +41 -3
  355. package/dist-lib/lib/tools/operations/calendar-range.d.ts +16 -0
  356. package/dist-lib/lib/tools/operations/calendar-range.js +40 -0
  357. package/dist-lib/lib/tools/operations/compile.js +8 -6
  358. package/dist-lib/lib/tools/operations/manifest.d.ts +4 -0
  359. package/dist-lib/lib/tools/pdf/build.d.ts +15 -1
  360. package/dist-lib/lib/tools/pdf/build.js +77 -16
  361. package/dist-lib/lib/tools/pdf/pages.d.ts +12 -0
  362. package/dist-lib/lib/tools/pdf/pages.js +31 -0
  363. package/dist-lib/lib/tools/pdf/recognize.d.ts +13 -0
  364. package/dist-lib/lib/tools/pdf/recognize.js +59 -0
  365. package/dist-lib/lib/tools/pdf.js +56 -12
  366. package/dist-lib/lib/tools/skill.js +10 -7
  367. package/dist-lib/lib/tools/skills/bundled-dir.d.ts +5 -1
  368. package/dist-lib/lib/tools/skills/bundled-dir.js +27 -24
  369. package/dist-lib/lib/tools/skills/catalog.d.ts +3 -1
  370. package/dist-lib/lib/tools/skills/catalog.js +7 -3
  371. package/dist-lib/lib/tools/skills/cli-argv.js +25 -5
  372. package/dist-lib/lib/tools/skills/cli-schema-check.d.ts +1 -0
  373. package/dist-lib/lib/tools/skills/cli-schema-check.js +3 -0
  374. package/dist-lib/lib/tools/skills/cli-schema-load.js +10 -0
  375. package/dist-lib/lib/tools/skills/cli-schema-types.d.ts +2 -0
  376. package/dist-lib/lib/tools/skills/cli-schema.js +6 -3
  377. package/dist-lib/lib/tools/skills/credential-check.d.ts +1 -0
  378. package/dist-lib/lib/tools/skills/credential-check.js +3 -0
  379. package/dist-lib/lib/tools/skills/credential-health.js +3 -3
  380. package/dist-lib/lib/tools/skills/frontmatter-parser.d.ts +3 -0
  381. package/dist-lib/lib/tools/skills/frontmatter-parser.js +5 -0
  382. package/dist-lib/lib/tools/skills/manifest-parse.d.ts +1 -0
  383. package/dist-lib/lib/tools/skills/manifest-parse.js +39 -3
  384. package/dist-lib/lib/tools/skills/manifest.d.ts +1 -0
  385. package/dist-lib/lib/tools/skills/mention-name.d.ts +6 -0
  386. package/dist-lib/lib/tools/skills/mention-name.js +6 -0
  387. package/dist-lib/lib/tools/skills/mention.d.ts +2 -2
  388. package/dist-lib/lib/tools/skills/mention.js +11 -4
  389. package/dist-lib/lib/tools/skills/overlay-crud.d.ts +3 -3
  390. package/dist-lib/lib/tools/skills/overlay-crud.js +7 -6
  391. package/dist-lib/lib/tools/skills/overlay-watch.d.ts +2 -2
  392. package/dist-lib/lib/tools/skills/overlay-watch.js +4 -3
  393. package/dist-lib/lib/tools/skills/scope-key.d.ts +1 -0
  394. package/dist-lib/lib/tools/skills/scope-key.js +4 -0
  395. package/dist-lib/lib/tools/skills/skill-state-constants.d.ts +1 -0
  396. package/dist-lib/lib/tools/skills/skill-state-constants.js +4 -0
  397. package/dist-lib/lib/tools/url-guard.d.ts +6 -1
  398. package/dist-lib/lib/tools/url-guard.js +8 -2
  399. package/dist-lib/lib/tools/web-fetch.js +50 -133
  400. package/dist-lib/lib/wire.d.ts +13 -0
  401. package/dist-lib/lib/wire.js +78 -6
  402. package/dist-lib/plugins/coding/index.d.ts +1 -1
  403. package/dist-lib/plugins/coding/index.js +2 -4
  404. package/dist-lib/plugins/coding/read-only.d.ts +1 -0
  405. package/dist-lib/plugins/coding/read-only.js +264 -0
  406. package/dist-lib/plugins/coding/session.d.ts +6 -4
  407. package/dist-lib/plugins/coding/session.js +45 -16
  408. package/dist-lib/plugins/coding-guards/index.d.ts +25 -0
  409. package/dist-lib/plugins/coding-guards/index.js +126 -0
  410. package/dist-lib/plugins/command-hooks/index.js +5 -3
  411. package/dist-lib/plugins/egress-proxy/index.d.ts +53 -0
  412. package/dist-lib/plugins/egress-proxy/index.js +184 -0
  413. package/dist-lib/plugins/image/edit-image.d.ts +3 -22
  414. package/dist-lib/plugins/image/edit-image.js +23 -46
  415. package/dist-lib/plugins/image/fit.d.ts +31 -0
  416. package/dist-lib/plugins/image/fit.js +28 -0
  417. package/dist-lib/plugins/image/generate-image.d.ts +27 -6
  418. package/dist-lib/plugins/image/generate-image.js +201 -74
  419. package/dist-lib/plugins/image/index.d.ts +2 -1
  420. package/dist-lib/plugins/image/index.js +29 -12
  421. package/dist-lib/plugins/knowledge/index.d.ts +3 -0
  422. package/dist-lib/plugins/knowledge/index.js +5 -0
  423. package/dist-lib/plugins/knowledge/manifest.d.ts +53 -0
  424. package/dist-lib/plugins/knowledge/manifest.js +86 -0
  425. package/dist-lib/plugins/knowledge/search-tool.js +8 -8
  426. package/dist-lib/plugins/knowledge/store.d.ts +45 -8
  427. package/dist-lib/plugins/knowledge/store.js +428 -166
  428. package/dist-lib/plugins/language-hint/index.d.ts +15 -0
  429. package/dist-lib/plugins/language-hint/index.js +54 -0
  430. package/dist-lib/plugins/lsp/tool.js +2 -2
  431. package/dist-lib/plugins/mcp/call.js +15 -4
  432. package/dist-lib/plugins/mcp/index.js +6 -3
  433. package/dist-lib/plugins/mcp/protocol.d.ts +10 -2
  434. package/dist-lib/plugins/mcp/protocol.js +13 -12
  435. package/dist-lib/plugins/mcp/server.js +1 -1
  436. package/dist-lib/plugins/mcp/tool-listing.d.ts +6 -0
  437. package/dist-lib/plugins/mcp/tool-listing.js +97 -0
  438. package/dist-lib/plugins/music/generate-music.d.ts +24 -5
  439. package/dist-lib/plugins/music/generate-music.js +170 -64
  440. package/dist-lib/plugins/music/index.d.ts +2 -1
  441. package/dist-lib/plugins/music/index.js +23 -11
  442. package/dist-lib/plugins/obsidian/command.js +2 -2
  443. package/dist-lib/plugins/obsidian/index.js +14 -4
  444. package/dist-lib/plugins/obsidian/note-name.js +2 -1
  445. package/dist-lib/plugins/obsidian/readiness.js +2 -2
  446. package/dist-lib/plugins/obsidian/safe-path.js +5 -4
  447. package/dist-lib/plugins/obsidian/vault-create.js +3 -2
  448. package/dist-lib/plugins/obsidian/vault-fs.js +2 -2
  449. package/dist-lib/plugins/obsidian/vault-paths.js +3 -2
  450. package/dist-lib/plugins/obsidian/vault-read.js +20 -18
  451. package/dist-lib/plugins/obsidian/vault-write.js +13 -12
  452. package/dist-lib/plugins/ocr/bmp.d.ts +2 -0
  453. package/dist-lib/plugins/ocr/bmp.js +27 -0
  454. package/dist-lib/plugins/ocr/index.d.ts +12 -0
  455. package/dist-lib/plugins/ocr/index.js +20 -0
  456. package/dist-lib/plugins/ocr/ocr-runtime.d.ts +23 -0
  457. package/dist-lib/plugins/ocr/ocr-runtime.js +82 -0
  458. package/dist-lib/plugins/ocr/reading-order.d.ts +5 -0
  459. package/dist-lib/plugins/ocr/reading-order.js +218 -0
  460. package/dist-lib/plugins/python/bare-floor.d.ts +1 -0
  461. package/dist-lib/plugins/python/bare-floor.js +2 -0
  462. package/dist-lib/plugins/python/guarded-fetch.d.ts +2 -1
  463. package/dist-lib/plugins/python/guarded-fetch.js +5 -1
  464. package/dist-lib/plugins/python/index.d.ts +4 -1
  465. package/dist-lib/plugins/python/index.js +6 -1
  466. package/dist-lib/plugins/python/interrupt-timer.js +2 -2
  467. package/dist-lib/plugins/python/language.js +11 -10
  468. package/dist-lib/plugins/python/loader.d.ts +1 -0
  469. package/dist-lib/plugins/python/loader.js +76 -3
  470. package/dist-lib/plugins/python/memfs.js +2 -2
  471. package/dist-lib/plugins/python/pyodide.d.ts +1 -0
  472. package/dist-lib/plugins/python/pyodide.js +9 -8
  473. package/dist-lib/plugins/python/python-adapter.d.ts +6 -1
  474. package/dist-lib/plugins/python/python-adapter.js +37 -2
  475. package/dist-lib/plugins/python/run-session.d.ts +1 -0
  476. package/dist-lib/plugins/python/run-session.js +19 -8
  477. package/dist-lib/plugins/python/wheels.js +8 -6
  478. package/dist-lib/plugins/python/worker/active.js +2 -2
  479. package/dist-lib/plugins/python/worker/client.js +10 -9
  480. package/dist-lib/plugins/python/worker/entry.js +2 -8
  481. package/dist-lib/plugins/python/worker/preload.d.ts +1 -0
  482. package/dist-lib/plugins/python/worker/preload.js +2 -0
  483. package/dist-lib/plugins/python/worker/protocol.d.ts +2 -0
  484. package/dist-lib/plugins/python/worker/serve.js +23 -4
  485. package/dist-lib/plugins/python/worker/spawn.d.ts +2 -1
  486. package/dist-lib/plugins/python/worker/spawn.js +3 -2
  487. package/dist-lib/plugins/quickjs/index.js +4 -0
  488. package/dist-lib/plugins/quickjs/runtime.js +8 -3
  489. package/dist-lib/plugins/run-report/chain.d.ts +2 -0
  490. package/dist-lib/plugins/run-report/chain.js +73 -0
  491. package/dist-lib/plugins/run-report/flow-view.js +2 -1
  492. package/dist-lib/plugins/run-report/flow.d.ts +1 -1
  493. package/dist-lib/plugins/run-report/flow.js +66 -14
  494. package/dist-lib/plugins/run-report/index.d.ts +23 -2
  495. package/dist-lib/plugins/run-report/index.js +32 -13
  496. package/dist-lib/plugins/run-report/layout.js +1 -1
  497. package/dist-lib/plugins/run-report/model.d.ts +10 -1
  498. package/dist-lib/plugins/run-report/model.js +12 -6
  499. package/dist-lib/plugins/run-report/page.d.ts +9 -0
  500. package/dist-lib/plugins/run-report/page.js +55 -15
  501. package/dist-lib/plugins/run-report/script.js +317 -43
  502. package/dist-lib/plugins/run-report/story.d.ts +2 -1
  503. package/dist-lib/plugins/run-report/story.js +7 -4
  504. package/dist-lib/plugins/run-report/style.d.ts +1 -1
  505. package/dist-lib/plugins/run-report/style.js +126 -0
  506. package/dist-lib/plugins/run-report/why.js +1 -1
  507. package/dist-lib/plugins/sandbox-linux/index.d.ts +62 -0
  508. package/dist-lib/plugins/sandbox-linux/index.js +354 -0
  509. package/dist-lib/plugins/sandbox-linux/seccomp.d.ts +2 -0
  510. package/dist-lib/plugins/sandbox-linux/seccomp.js +74 -0
  511. package/dist-lib/plugins/sandbox-macos/index.d.ts +25 -11
  512. package/dist-lib/plugins/sandbox-macos/index.js +244 -49
  513. package/dist-lib/plugins/sandbox-vm/index.d.ts +2 -1
  514. package/dist-lib/plugins/sandbox-vm/index.js +5 -2
  515. package/dist-lib/plugins/sandbox-vm/vm-shell.d.ts +7 -3
  516. package/dist-lib/plugins/sandbox-vm/vm-shell.js +54 -20
  517. package/dist-lib/plugins/sandbox-windows/helper/qvac-sandbox.c +554 -0
  518. package/dist-lib/plugins/sandbox-windows/index.d.ts +53 -0
  519. package/dist-lib/plugins/sandbox-windows/index.js +205 -0
  520. package/dist-lib/plugins/sandbox-windows/prebuilds/win32-arm64/qvac-sandbox.exe +0 -0
  521. package/dist-lib/plugins/sandbox-windows/prebuilds/win32-x64/qvac-sandbox.exe +0 -0
  522. package/dist-lib/plugins/speech/audio-resample.d.ts +1 -1
  523. package/dist-lib/plugins/speech/audio-resample.js +8 -8
  524. package/dist-lib/plugins/speech/audio-transcode-bare.d.ts +1 -1
  525. package/dist-lib/plugins/speech/audio-transcode-bare.js +23 -26
  526. package/dist-lib/plugins/speech/audio-transcode-node.d.ts +1 -1
  527. package/dist-lib/plugins/speech/audio-transcode-node.js +1 -3
  528. package/dist-lib/plugins/speech/index.d.ts +1 -0
  529. package/dist-lib/plugins/speech/index.js +8 -1
  530. package/dist-lib/plugins/speech/speech-engine.d.ts +1 -1
  531. package/dist-lib/plugins/speech/speech-engine.js +10 -5
  532. package/dist-lib/plugins/speech/speech-runtime.js +37 -37
  533. package/dist-lib/plugins/speech/speech-text.d.ts +1 -0
  534. package/dist-lib/plugins/speech/speech-text.js +9 -4
  535. package/dist-lib/plugins/speech/voice.d.ts +5 -1
  536. package/dist-lib/plugins/speech/voice.js +107 -33
  537. package/dist-lib/plugins/translation/index.d.ts +2 -1
  538. package/dist-lib/plugins/translation/index.js +21 -10
  539. package/dist-lib/plugins/translation/translate.d.ts +9 -5
  540. package/dist-lib/plugins/translation/translate.js +69 -64
  541. package/dist-lib/plugins/walkie-talkie/index.d.ts +4 -2
  542. package/dist-lib/plugins/walkie-talkie/index.js +19 -6
  543. package/dist-lib/plugins/walkie-talkie/wire.d.ts +5 -0
  544. package/dist-lib/plugins/walkie-talkie/wire.js +6 -5
  545. package/dist-lib/plugins/weather/geocode.js +2 -1
  546. package/dist-lib/plugins/weather/lookup.js +6 -4
  547. package/dist-lib/plugins/web-search/engines/bing.js +2 -1
  548. package/dist-lib/plugins/web-search/engines/google.js +2 -1
  549. package/dist-lib/plugins/web-search/fetch-html.d.ts +5 -5
  550. package/dist-lib/plugins/web-search/fetch-html.js +12 -15
  551. package/dist-lib/plugins/web-search/tool.js +1 -0
  552. package/dist-lib/schema/generate.js +8 -1
  553. package/dist-lib/schema/harness.js +91 -12
  554. package/dist-lib/spec/bind.js +12 -0
  555. package/dist-lib/spec/calls.js +4 -0
  556. package/dist-lib/spec/hrpc/hrpc.json +55 -3
  557. package/dist-lib/spec/hrpc/index.js +58 -10
  558. package/dist-lib/spec/hrpc/messages.js +461 -209
  559. package/dist-lib/spec/hyperschema/index.js +461 -209
  560. package/dist-lib/spec/hyperschema/schema.json +285 -85
  561. package/dist-lib/spec/hyperschema/types.d.ts +41 -5
  562. package/package.json +264 -64
  563. package/patches/pyodide@314.0.2.patch +37 -8
  564. package/scripts/addon-externals.cjs +16 -5
  565. package/worker/harness-sidecar.mjs +23 -154
  566. package/dist-lib/lib/tools/create-documents.d.ts +0 -3
  567. package/dist-lib/lib/tools/create-documents.js +0 -95
  568. package/dist-lib/lib/tools/edit-documents.d.ts +0 -3
  569. package/dist-lib/lib/tools/edit-documents.js +0 -132
  570. package/dist-lib/lib/tools/exec/shell-argv.d.ts +0 -2
  571. package/dist-lib/lib/tools/exec/shell-argv.js +0 -61
  572. package/dist-lib/lib/tools/file-glob.js +0 -118
  573. package/dist-lib/lib/tools/grep.d.ts +0 -5
  574. package/dist-lib/lib/tools/grep.js +0 -184
  575. package/dist-lib/lib/tools/read-files.d.ts +0 -5
  576. package/dist-lib/lib/tools/read-files.js +0 -160
  577. package/dist-lib/plugins/coding/write-file.d.ts +0 -3
  578. package/dist-lib/plugins/coding/write-file.js +0 -52
  579. package/patches/@qvac%2Finference@0.21.0.patch +0 -67
  580. package/patches/bare-stow@0.1.5.patch +0 -68
  581. package/patches/hypercore-blob-server@1.15.0.patch +0 -15
  582. package/patches/localwatch@1.4.3.patch +0 -13
@@ -1,6 +1,15 @@
1
1
  import fs from 'fs';
2
2
  import path from 'path';
3
+ import { HarnessError } from '../../lib/errors.js';
3
4
  import { dailyCandidates, ensureWithinRoot, FRONTMATTER_RE, getArg, listFolders, listMarkdownFiles, parseFrontmatter, readFileText, resolveNotePath, todayStamp } from './vault-paths.js';
5
+ function statOrNull(p) {
6
+ try {
7
+ return fs.statSync(p);
8
+ }
9
+ catch {
10
+ return null;
11
+ }
12
+ }
4
13
  export function handleVault(vaultPath) {
5
14
  return JSON.stringify({ name: path.basename(vaultPath), path: vaultPath });
6
15
  }
@@ -16,8 +25,13 @@ export function handleVaults(vaultPath) {
16
25
  }
17
26
  export function handleRead(vaultPath, args) {
18
27
  const notePath = resolveNotePath(vaultPath, args);
19
- if (!notePath || !fs.existsSync(notePath)) {
20
- throw new Error(`Note not found. Args: ${args.join(', ')}`);
28
+ const stat = notePath ? statOrNull(notePath) : null;
29
+ if (!notePath || !stat) {
30
+ throw new HarnessError('OBSIDIAN_NOTE_NOT_FOUND', [args]);
31
+ }
32
+ if (stat.isDirectory()) {
33
+ const folder = path.relative(path.resolve(vaultPath), notePath).split(path.sep).join('/');
34
+ throw new HarnessError('OBSIDIAN_PATH_IS_FOLDER', [folder]);
21
35
  }
22
36
  return readFileText(notePath);
23
37
  }
@@ -43,7 +57,7 @@ function parseLimit(args) {
43
57
  export function handleSearch(vaultPath, args) {
44
58
  const query = getArg(args, 'query');
45
59
  if (!query) {
46
- throw new Error('Missing required argument: query=');
60
+ throw new HarnessError('OBSIDIAN_MISSING_ARGUMENT', ['query=']);
47
61
  }
48
62
  const limit = parseLimit(args);
49
63
  const lowerQuery = query.toLowerCase();
@@ -68,11 +82,7 @@ export function handleSearch(vaultPath, args) {
68
82
  return matches.join('\n') + truncated;
69
83
  }
70
84
  export function handleProperties(vaultPath, args) {
71
- const notePath = resolveNotePath(vaultPath, args);
72
- if (!notePath || !fs.existsSync(notePath)) {
73
- throw new Error(`Note not found. Args: ${args.join(', ')}`);
74
- }
75
- return JSON.stringify(parseFrontmatter(readFileText(notePath)), null, 2);
85
+ return JSON.stringify(parseFrontmatter(handleRead(vaultPath, args)), null, 2);
76
86
  }
77
87
  function countTags(tagCounts, content) {
78
88
  for (const match of content.matchAll(/#([a-zA-Z0-9_/-]+)/g)) {
@@ -97,20 +107,12 @@ export function handleTags(vaultPath) {
97
107
  return sorted.map(([tag, count]) => `#${tag} (${count})`).join('\n') || '(no tags)';
98
108
  }
99
109
  export function handleWordcount(vaultPath, args) {
100
- const notePath = resolveNotePath(vaultPath, args);
101
- if (!notePath || !fs.existsSync(notePath)) {
102
- throw new Error(`Note not found. Args: ${args.join(', ')}`);
103
- }
104
- const body = readFileText(notePath).replace(FRONTMATTER_RE, '').trim();
110
+ const body = handleRead(vaultPath, args).replace(FRONTMATTER_RE, '').trim();
105
111
  const words = body.split(/\s+/).filter(Boolean).length;
106
112
  return `${words} words`;
107
113
  }
108
114
  export function handleOutline(vaultPath, args) {
109
- const notePath = resolveNotePath(vaultPath, args);
110
- if (!notePath || !fs.existsSync(notePath)) {
111
- throw new Error(`Note not found. Args: ${args.join(', ')}`);
112
- }
113
- const headings = readFileText(notePath)
115
+ const headings = handleRead(vaultPath, args)
114
116
  .split('\n')
115
117
  .filter((line) => /^#{1,6}\s/.test(line));
116
118
  return headings.join('\n') || '(no headings)';
@@ -1,15 +1,16 @@
1
1
  import fs from 'fs';
2
2
  import path from 'path';
3
+ import { HarnessError } from '../../lib/errors.js';
3
4
  import { markdownFileName } from './note-name.js';
4
5
  import { appendToFile, dailyCandidates, ensureWithinRoot, FRONTMATTER_RE, getArg, getContentArg, moveFile, readFileSnapshot, resolveNotePath, todayStamp, updateFileText, writeIfUnchanged } from './vault-paths.js';
5
6
  export function handleAppend(vaultPath, args) {
6
7
  const notePath = resolveNotePath(vaultPath, args);
7
8
  if (!notePath || !fs.existsSync(notePath)) {
8
- throw new Error(`Note not found. Args: ${args.join(', ')}`);
9
+ throw new HarnessError('OBSIDIAN_NOTE_NOT_FOUND', [args]);
9
10
  }
10
11
  const content = getContentArg(args);
11
12
  if (!content) {
12
- throw new Error('Missing required argument: content=');
13
+ throw new HarnessError('OBSIDIAN_MISSING_ARGUMENT', ['content=']);
13
14
  }
14
15
  appendToFile(notePath, content);
15
16
  return `Appended to: ${path.relative(vaultPath, notePath)}`;
@@ -17,11 +18,11 @@ export function handleAppend(vaultPath, args) {
17
18
  export function handlePrepend(vaultPath, args) {
18
19
  const notePath = resolveNotePath(vaultPath, args);
19
20
  if (!notePath || !fs.existsSync(notePath)) {
20
- throw new Error(`Note not found. Args: ${args.join(', ')}`);
21
+ throw new HarnessError('OBSIDIAN_NOTE_NOT_FOUND', [args]);
21
22
  }
22
23
  const content = getContentArg(args);
23
24
  if (!content) {
24
- throw new Error('Missing required argument: content=');
25
+ throw new HarnessError('OBSIDIAN_MISSING_ARGUMENT', ['content=']);
25
26
  }
26
27
  updateFileText(notePath, (existing) => content + existing);
27
28
  return `Prepended to: ${path.relative(vaultPath, notePath)}`;
@@ -40,7 +41,7 @@ function uniqueTrashPath(base) {
40
41
  export function handleDelete(vaultPath, args) {
41
42
  const notePath = resolveNotePath(vaultPath, args);
42
43
  if (!notePath || !fs.existsSync(notePath)) {
43
- throw new Error(`Note not found. Args: ${args.join(', ')}`);
44
+ throw new HarnessError('OBSIDIAN_NOTE_NOT_FOUND', [args]);
44
45
  }
45
46
  const root = path.resolve(vaultPath);
46
47
  const trashPath = uniqueTrashPath(ensureWithinRoot(vaultPath, path.join('.trash', path.relative(root, notePath))));
@@ -51,11 +52,11 @@ export function handleDelete(vaultPath, args) {
51
52
  export function handleMove(vaultPath, args) {
52
53
  const notePath = resolveNotePath(vaultPath, args);
53
54
  if (!notePath || !fs.existsSync(notePath)) {
54
- throw new Error(`Note not found. Args: ${args.join(', ')}`);
55
+ throw new HarnessError('OBSIDIAN_NOTE_NOT_FOUND', [args]);
55
56
  }
56
57
  const to = getArg(args, 'to');
57
58
  if (!to) {
58
- throw new Error('Missing required argument: to=');
59
+ throw new HarnessError('OBSIDIAN_MISSING_ARGUMENT', ['to=']);
59
60
  }
60
61
  const destDir = ensureWithinRoot(vaultPath, to);
61
62
  if (!fs.existsSync(destDir)) {
@@ -68,11 +69,11 @@ export function handleMove(vaultPath, args) {
68
69
  export function handleRename(vaultPath, args) {
69
70
  const notePath = resolveNotePath(vaultPath, args);
70
71
  if (!notePath || !fs.existsSync(notePath)) {
71
- throw new Error(`Note not found. Args: ${args.join(', ')}`);
72
+ throw new HarnessError('OBSIDIAN_NOTE_NOT_FOUND', [args]);
72
73
  }
73
74
  const newName = getArg(args, 'name');
74
75
  if (!newName) {
75
- throw new Error('Missing required argument: name=');
76
+ throw new HarnessError('OBSIDIAN_MISSING_ARGUMENT', ['name=']);
76
77
  }
77
78
  const fileName = markdownFileName(newName);
78
79
  const relativeDir = path.relative(path.resolve(vaultPath), path.dirname(notePath));
@@ -96,11 +97,11 @@ function mergeIntoFrontmatter(fmBlock, newProps) {
96
97
  export function handlePropertySet(vaultPath, args) {
97
98
  const notePath = resolveNotePath(vaultPath, args);
98
99
  if (!notePath || !fs.existsSync(notePath)) {
99
- throw new Error(`Note not found. Args: ${args.join(', ')}`);
100
+ throw new HarnessError('OBSIDIAN_NOTE_NOT_FOUND', [args]);
100
101
  }
101
102
  const propArgs = args.filter((a) => !a.startsWith('file=') && !a.startsWith('path=') && a.includes('='));
102
103
  if (propArgs.length === 0) {
103
- throw new Error('No property key=value pairs provided.');
104
+ throw new HarnessError('OBSIDIAN_NO_PROPERTIES');
104
105
  }
105
106
  const newProps = propArgs.map((a) => {
106
107
  const eqIdx = a.indexOf('=');
@@ -120,7 +121,7 @@ export function handlePropertySet(vaultPath, args) {
120
121
  export function handleDailyAppend(vaultPath, args) {
121
122
  const content = getContentArg(args);
122
123
  if (!content) {
123
- throw new Error('Missing required argument: content=');
124
+ throw new HarnessError('OBSIDIAN_MISSING_ARGUMENT', ['content=']);
124
125
  }
125
126
  const dateStr = todayStamp();
126
127
  let target = null;
@@ -0,0 +1,2 @@
1
+ import type { OcrImage } from '../../lib/contract/ocr.ts';
2
+ export declare function bmp({ width, height, data }: OcrImage): Uint8Array;
@@ -0,0 +1,27 @@
1
+ import b4a from 'b4a';
2
+ const HEADER_BYTES = 54;
3
+ export function bmp({ width, height, data }) {
4
+ const row = (width * 3 + 3) & ~3;
5
+ const bytes = b4a.alloc(HEADER_BYTES + row * height);
6
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
7
+ bytes[0] = 0x42;
8
+ bytes[1] = 0x4d;
9
+ view.setUint32(2, bytes.byteLength, true);
10
+ view.setUint32(10, HEADER_BYTES, true);
11
+ view.setUint32(14, 40, true);
12
+ view.setInt32(18, width, true);
13
+ view.setInt32(22, height, true);
14
+ view.setUint16(26, 1, true);
15
+ view.setUint16(28, 24, true);
16
+ view.setUint32(34, row * height, true);
17
+ for (let y = 0; y < height; y++) {
18
+ const from = (height - 1 - y) * width * 4;
19
+ const to = HEADER_BYTES + y * row;
20
+ for (let x = 0; x < width; x++) {
21
+ bytes[to + x * 3] = data[from + x * 4 + 2] ?? 0;
22
+ bytes[to + x * 3 + 1] = data[from + x * 4 + 1] ?? 0;
23
+ bytes[to + x * 3 + 2] = data[from + x * 4] ?? 0;
24
+ }
25
+ }
26
+ return bytes;
27
+ }
@@ -0,0 +1,12 @@
1
+ import type { HarnessPlugin, PluginContext, PluginSetup } from '../../lib/plugins/index.ts';
2
+ export declare class Ocr implements HarnessPlugin {
3
+ readonly name = "ocr";
4
+ readonly api = 1;
5
+ readonly provides: string[];
6
+ readonly needs: string[];
7
+ readonly addons: {
8
+ 'ocr-ggml': () => Promise<(callback: (priority: number, message: string) => void) => void>;
9
+ };
10
+ constructor();
11
+ setup(ctx: PluginContext): PluginSetup;
12
+ }
@@ -0,0 +1,20 @@
1
+ import { PluginRegistry } from '../../lib/plugins/index.js';
2
+ import { OcrRuntime } from './ocr-runtime.js';
3
+ export class Ocr {
4
+ name = 'ocr';
5
+ api = PluginRegistry.API_VERSION;
6
+ provides = ['ocr'];
7
+ needs = ['models'];
8
+ addons = {
9
+ 'ocr-ggml': async () => (await import('@qvac/ocr-ggml/addonLogging')).default.setLogger
10
+ };
11
+ constructor() {
12
+ PluginRegistry.requirePeers('ocr', {
13
+ '@qvac/ocr-ggml': () => import.meta.resolve('@qvac/ocr-ggml/addonLogging')
14
+ });
15
+ }
16
+ setup(ctx) {
17
+ const runtime = new OcrRuntime(ctx.service('models'));
18
+ return { services: { ocr: runtime }, unloadIdle: () => runtime.unloadIdle() };
19
+ }
20
+ }
@@ -0,0 +1,23 @@
1
+ import type { AbortSignal as BareAbortSignal } from 'bare-abort-controller';
2
+ import type { ModelHost } from '../../lib/contract/models.ts';
3
+ import type { OcrImage, OcrService } from '../../lib/contract/ocr.ts';
4
+ import { type OcrBlock } from './reading-order.ts';
5
+ export interface OcrSdk {
6
+ ocr(params: {
7
+ modelId: string;
8
+ image: Uint8Array;
9
+ }): {
10
+ blocks: Promise<OcrBlock[]>;
11
+ };
12
+ }
13
+ export declare class OcrRuntime implements OcrService {
14
+ private readonly _models;
15
+ private readonly _loadSdk;
16
+ private readonly _pool;
17
+ private _tail;
18
+ constructor(models: ModelHost);
19
+ read(image: OcrImage, signal?: BareAbortSignal): Promise<string>;
20
+ unloadIdle(): Promise<void>;
21
+ private _open;
22
+ private _serial;
23
+ }
@@ -0,0 +1,82 @@
1
+ import { OCR_DOCTR, OCR_DOCTR_1 } from '@qvac/inference/models';
2
+ import { errorMessage } from '../../lib/guards.js';
3
+ import { raceAbort } from '../../lib/helpers/race-abort.js';
4
+ import { retryMemo } from '../../lib/helpers/retry-memo.js';
5
+ import { HarnessLog } from '../../lib/log.js';
6
+ import { bmp } from './bmp.js';
7
+ import { readingOrder } from './reading-order.js';
8
+ const OCR_MODEL_LABEL = 'OCR model';
9
+ function ocrSdk(models) {
10
+ return retryMemo(async () => {
11
+ const sdk = await models.sdk();
12
+ if (typeof globalThis.Bare !== 'undefined') {
13
+ const [{ ocrPlugin }, { registerPlugin }] = await Promise.all([
14
+ import('@qvac/inference/ggml-ocr/plugin'),
15
+ import('@qvac/inference/plugin-registry')
16
+ ]);
17
+ try {
18
+ registerPlugin(ocrPlugin);
19
+ }
20
+ catch (err) {
21
+ HarnessLog.warn('plugin registration skipped', { plugin: 'ocr', err: errorMessage(err) });
22
+ }
23
+ }
24
+ return sdk;
25
+ });
26
+ }
27
+ export class OcrRuntime {
28
+ _models;
29
+ _loadSdk;
30
+ _pool;
31
+ _tail = Promise.resolve();
32
+ constructor(models) {
33
+ this._models = models;
34
+ this._loadSdk = ocrSdk(models);
35
+ this._pool = models.registerPool({
36
+ addon: 'ocr',
37
+ modelType: 'ggml-ocr',
38
+ modelConfig: { pipelineType: 'doctr', detectorModelSrc: OCR_DOCTR_1 },
39
+ label: OCR_MODEL_LABEL,
40
+ sdk: this._loadSdk
41
+ });
42
+ }
43
+ async read(image, signal) {
44
+ const { held, releaseWork } = this._open();
45
+ let job = null;
46
+ try {
47
+ const { modelId } = await raceAbort(held.load(), signal);
48
+ const sdk = await this._loadSdk();
49
+ job = this._serial(async () => readingOrder(await sdk.ocr({ modelId, image: bmp(image) }).blocks));
50
+ return await raceAbort(job, signal);
51
+ }
52
+ finally {
53
+ void Promise.allSettled([job ?? held.peek()]).then(() => {
54
+ try {
55
+ held.release();
56
+ }
57
+ finally {
58
+ releaseWork();
59
+ }
60
+ });
61
+ }
62
+ }
63
+ unloadIdle() {
64
+ return this._pool.evictIdle(() => true);
65
+ }
66
+ _open() {
67
+ const releaseWork = this._models.enterWork();
68
+ try {
69
+ return { held: this._pool.open(OCR_DOCTR.src), releaseWork };
70
+ }
71
+ catch (error) {
72
+ releaseWork();
73
+ throw error;
74
+ }
75
+ }
76
+ _serial(job) {
77
+ const run = this._tail.then(job);
78
+ this._tail = run.catch(noop);
79
+ return run;
80
+ }
81
+ }
82
+ function noop() { }
@@ -0,0 +1,5 @@
1
+ export interface OcrBlock {
2
+ readonly text: string;
3
+ readonly bbox?: readonly [number, number, number, number] | undefined;
4
+ }
5
+ export declare function readingOrder(blocks: readonly OcrBlock[]): string;
@@ -0,0 +1,218 @@
1
+ const COLUMNS = { start: 'left', end: 'right' };
2
+ const ROWS = { start: 'top', end: 'bottom' };
3
+ const COLUMN_GAP = 1.5;
4
+ const BLOCK_GAP = 1;
5
+ const COLUMN_WORDS = 4;
6
+ const MARGIN_LINES = 0.6;
7
+ const MARGIN_MIN_LINES = 10;
8
+ const SPANNED_LINES = 0.2;
9
+ const MARGIN_SLACK = 0.25;
10
+ const SPANS = 0.5;
11
+ const HEADING_INSET = 0.25;
12
+ export function readingOrder(blocks) {
13
+ const words = blocks.flatMap(({ text, bbox }) => bbox ? [{ text, left: bbox[0], top: bbox[1], right: bbox[2], bottom: bbox[3] }] : []);
14
+ if (words.length < blocks.length) {
15
+ return blocks.map((block) => block.text).join('\n');
16
+ }
17
+ const level = deskewed(words);
18
+ return regionLines(level, medianHeight(level)).join('\n');
19
+ }
20
+ function deskewed(words) {
21
+ const gutter = medianHeight(words) * COLUMN_GAP;
22
+ const slants = chainLines(words).flatMap(({ words: line }) => segments(line, gutter).flatMap((run) => (run.length >= 3 ? [slope(run)] : [])));
23
+ const tilt = slants.sort((a, b) => a - b)[Math.floor(slants.length / 2)] ?? 0;
24
+ if (tilt === 0 || slants.length < MARGIN_MIN_LINES) {
25
+ return [...words];
26
+ }
27
+ return words.map((word) => {
28
+ const across = tilt * middle(word);
29
+ const down = tilt * centre(word);
30
+ const { text, left, top, right, bottom } = word;
31
+ return {
32
+ text,
33
+ left: left + across,
34
+ right: right + across,
35
+ top: top - down,
36
+ bottom: bottom - down
37
+ };
38
+ });
39
+ }
40
+ function slope(run) {
41
+ const first = run[0];
42
+ const last = run.at(-1);
43
+ if (!first || !last || centre(last) === centre(first)) {
44
+ return 0;
45
+ }
46
+ return (middle(last) - middle(first)) / (centre(last) - centre(first));
47
+ }
48
+ function segments(line, gutter) {
49
+ const runs = [];
50
+ let reach = -Infinity;
51
+ for (const word of line) {
52
+ if (word.left - reach >= gutter) {
53
+ runs.push([]);
54
+ }
55
+ runs.at(-1)?.push(word);
56
+ reach = Math.max(reach, word.right);
57
+ }
58
+ return runs;
59
+ }
60
+ function regionLines(words, lineHeight) {
61
+ const columns = dense(split(words, COLUMNS, lineHeight * COLUMN_GAP)) ?? dense(marginColumns(words, lineHeight));
62
+ if (columns) {
63
+ return columns.flatMap((column) => regionLines(column, lineHeight));
64
+ }
65
+ const blocks = split(words, ROWS, lineHeight * BLOCK_GAP) ?? spannedBands(words, lineHeight);
66
+ if (blocks) {
67
+ return blocks.flatMap((block) => regionLines(block, lineHeight));
68
+ }
69
+ return chainLines(words).map((line) => line.words.map((word) => word.text).join(' '));
70
+ }
71
+ function split(words, { start, end }, gap) {
72
+ const parts = [];
73
+ let reach = -Infinity;
74
+ for (const word of [...words].sort((a, b) => a[start] - b[start])) {
75
+ if (word[start] - reach >= gap) {
76
+ parts.push([]);
77
+ }
78
+ parts.at(-1)?.push(word);
79
+ reach = Math.max(reach, word[end]);
80
+ }
81
+ return parts.length > 1 ? parts : null;
82
+ }
83
+ function dense(columns) {
84
+ const text = columns?.every((column) => column.length / chainLines(column).length >= COLUMN_WORDS);
85
+ return text ? columns : null;
86
+ }
87
+ function marginColumns(words, lineHeight) {
88
+ const region = regionOf(words, lineHeight);
89
+ const { edges } = region;
90
+ if (edges.length === 0 || chainLines(words).some((line) => spanning(line, region))) {
91
+ return null;
92
+ }
93
+ const slack = lineHeight * MARGIN_SLACK;
94
+ const columns = edges.map(() => []);
95
+ columns.push([]);
96
+ for (const word of words) {
97
+ columns[edges.filter((edge) => word.left >= edge - slack).length]?.push(word);
98
+ }
99
+ return columns;
100
+ }
101
+ function spannedBands(words, lineHeight) {
102
+ const region = regionOf(words, lineHeight);
103
+ const { edges } = region;
104
+ const bands = [];
105
+ let across = true;
106
+ for (const line of chainLines(words)) {
107
+ const parts = spanning(line, region);
108
+ if (parts || across) {
109
+ bands.push([]);
110
+ }
111
+ bands.at(-1)?.push(...line.words);
112
+ across = parts;
113
+ }
114
+ return edges.length > 0 && bands.length > 1 ? bands : null;
115
+ }
116
+ function columnEdges(words, lineHeight) {
117
+ const lines = chainLines(words);
118
+ if (lines.length < MARGIN_MIN_LINES) {
119
+ return [];
120
+ }
121
+ const edges = sharedEdges(words, lineHeight * MARGIN_SLACK, lines.length * MARGIN_LINES);
122
+ return edges.filter((edge) => {
123
+ const before = words.filter((word) => word.right <= edge);
124
+ const across = lines.filter((line) => line.words.some((word) => spans(word, [edge], lineHeight)));
125
+ return dense([before]) !== null && across.length <= lines.length * SPANNED_LINES;
126
+ });
127
+ }
128
+ function regionOf(words, lineHeight) {
129
+ const firsts = chainLines(words)
130
+ .map((line) => line.first.left)
131
+ .sort((a, b) => a - b);
132
+ const start = firsts[Math.floor(firsts.length / 2)] ?? 0;
133
+ const end = Math.max(...words.map((word) => word.right));
134
+ return { edges: columnEdges(words, lineHeight), start, end, lineHeight };
135
+ }
136
+ function spanning(line, region) {
137
+ const { edges, lineHeight } = region;
138
+ return line.words.some((word) => spans(word, edges, lineHeight)) || heading(line, region);
139
+ }
140
+ function heading({ words }, { edges, start, end, lineHeight }) {
141
+ const ordered = [...words].sort((a, b) => a.left - b.left);
142
+ const first = ordered[0];
143
+ const last = ordered.at(-1);
144
+ const inset = ((end - start) / (edges.length + 1)) * HEADING_INSET;
145
+ if (!first || !last || first.left < start + inset || last.right > end - inset) {
146
+ return false;
147
+ }
148
+ const slack = lineHeight * MARGIN_SLACK;
149
+ return ordered.slice(1).some((word, at) => {
150
+ const before = ordered[at];
151
+ return (before !== undefined &&
152
+ word.left - before.right < lineHeight * COLUMN_GAP &&
153
+ edges.some((edge) => before.left < edge - slack && word.left >= edge - slack));
154
+ });
155
+ }
156
+ function spans({ left, right }, edges, lineHeight) {
157
+ const reach = lineHeight * SPANS;
158
+ return edges.some((edge) => left < edge - reach && right > edge + reach);
159
+ }
160
+ function sharedEdges(words, slack, least) {
161
+ const lefts = words.map((word) => word.left).sort((a, b) => a - b);
162
+ const windows = [];
163
+ let to = 0;
164
+ for (const [from, edge] of lefts.entries()) {
165
+ while (to < lefts.length && (lefts[to] ?? 0) <= edge + slack) {
166
+ to++;
167
+ }
168
+ if (to - from >= least) {
169
+ windows.push({ edge, count: to - from });
170
+ }
171
+ }
172
+ const edges = [];
173
+ for (const { edge } of windows.sort((a, b) => b.count - a.count)) {
174
+ if (edges.every((kept) => Math.abs(kept - edge) > slack)) {
175
+ edges.push(edge);
176
+ }
177
+ }
178
+ return edges.sort((a, b) => a - b);
179
+ }
180
+ function chainLines(words) {
181
+ const lines = [];
182
+ for (const word of [...words].sort((a, b) => a.left - b.left)) {
183
+ const line = levelWith(lines, word);
184
+ if (line) {
185
+ line.words.push(word);
186
+ line.last = word;
187
+ }
188
+ else {
189
+ lines.push({ first: word, last: word, words: [word] });
190
+ }
191
+ }
192
+ return lines.sort((a, b) => middle(a.first) - middle(b.first));
193
+ }
194
+ function levelWith(lines, word) {
195
+ let closest;
196
+ let offset = Infinity;
197
+ for (const line of lines) {
198
+ const apart = Math.abs(middle(line.last) - middle(word));
199
+ if (apart < height(line.last) / 2 && apart < offset) {
200
+ closest = line;
201
+ offset = apart;
202
+ }
203
+ }
204
+ return closest;
205
+ }
206
+ function middle(word) {
207
+ return (word.top + word.bottom) / 2;
208
+ }
209
+ function centre(word) {
210
+ return (word.left + word.right) / 2;
211
+ }
212
+ function height(word) {
213
+ return word.bottom - word.top;
214
+ }
215
+ function medianHeight(words) {
216
+ const heights = words.map(height).sort((a, b) => a - b);
217
+ return heights[Math.floor(heights.length / 2)] ?? 0;
218
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import { PluginRegistry } from '../../lib/plugins/index.js';
2
+ PluginRegistry.requireBare('python', '1.35.0');
@@ -1,8 +1,9 @@
1
1
  import { type GuardedFetch, type GuardedFetchOptions } from '../../lib/guarded-fetch.ts';
2
2
  declare const GUARDED: unique symbol;
3
3
  export interface ConnectPolicy {
4
- readonly named: readonly string[];
4
+ readonly named?: readonly string[] | undefined;
5
5
  readonly ask: (host: string) => Promise<boolean>;
6
+ readonly allowed?: readonly string[] | undefined;
6
7
  }
7
8
  export declare function setConnectPolicy(next: ConnectPolicy | null): void;
8
9
  export declare function isGuardedFetch(fetch: unknown): boolean;
@@ -1,4 +1,5 @@
1
1
  import { createGuardedFetch as createCoreFetch } from '../../lib/guarded-fetch.js';
2
+ import { Policy } from '../../lib/policy/index.js';
2
3
  import { hostIsNamed } from './named-hosts.js';
3
4
  const GUARDED = Symbol.for('qvac.harness.guardedFetch');
4
5
  let policy = null;
@@ -8,7 +9,10 @@ export function setConnectPolicy(next) {
8
9
  granted.clear();
9
10
  }
10
11
  async function mayConnect(host) {
11
- if (!policy || granted.has(host) || hostIsNamed(host, policy.named)) {
12
+ if (policy?.allowed && !Policy.allowsHost(policy.allowed, host)) {
13
+ return false;
14
+ }
15
+ if (!policy?.named || granted.has(host) || hostIsNamed(host, policy.named)) {
12
16
  return true;
13
17
  }
14
18
  const allowed = await policy.ask(host);
@@ -1,11 +1,14 @@
1
+ import './bare-floor.ts';
1
2
  import type { HarnessPlugin, PluginSetup } from '../../lib/plugins/index.ts';
2
3
  import { type PythonLanguageOptions } from './language.ts';
4
+ import type { PythonRunResult } from './pyodide.ts';
3
5
  import { closePythonWorker } from './worker/active.ts';
4
6
  import { preloadPythonAddons } from './worker/client.ts';
5
7
  export type { PythonLanguageOptions };
6
- export { runPython, type LoadPyodideFn, type PythonRunResult } from './pyodide.ts';
8
+ export type { LoadPyodideFn, PythonRunResult } from './pyodide.ts';
7
9
  export { planVendoredInstall, vendoredManifest, wheelsDir } from './wheels.ts';
8
10
  export { closePythonWorker };
11
+ export declare function runPython(...args: Parameters<typeof import('./pyodide.ts').runPython>): Promise<PythonRunResult>;
9
12
  export declare class Python implements HarnessPlugin {
10
13
  readonly name = "python";
11
14
  readonly api = 1;
@@ -1,10 +1,15 @@
1
+ import './bare-floor.js';
1
2
  import { PluginRegistry } from '../../lib/plugins/index.js';
2
3
  import { createPythonLanguage } from './language.js';
4
+ import { pyodideModule } from './python-adapter.js';
3
5
  import { closePythonWorker } from './worker/active.js';
4
6
  import { preloadPythonAddons } from './worker/client.js';
5
- export { runPython } from './pyodide.js';
7
+ PluginRegistry.requirePeers('python', { pyodide: () => import.meta.resolve('pyodide') });
6
8
  export { planVendoredInstall, vendoredManifest, wheelsDir } from './wheels.js';
7
9
  export { closePythonWorker };
10
+ export async function runPython(...args) {
11
+ return (await pyodideModule()).runPython(...args);
12
+ }
8
13
  export class Python {
9
14
  name = 'python';
10
15
  api = PluginRegistry.API_VERSION;
@@ -1,7 +1,7 @@
1
1
  import { fileURLToPath } from 'url';
2
2
  import { Worker } from 'worker_threads';
3
3
  import { errorMessage } from '../../lib/guards.js';
4
- import { hlog } from '../../lib/log.js';
4
+ import { HarnessLog } from '../../lib/log.js';
5
5
  import { DISARMED, FIRED } from './deadline-state.js';
6
6
  export function startInterruptTimer(ms) {
7
7
  const state = new Int32Array(new SharedArrayBuffer(4));
@@ -9,7 +9,7 @@ export function startInterruptTimer(ms) {
9
9
  const workerData = { state: state.buffer, interrupt: interrupt.buffer, ms };
10
10
  const entry = fileURLToPath(import.meta.resolve('#pyodide-interrupt-deadline'));
11
11
  new Worker(entry, { workerData })
12
- .on('error', (error) => hlog('python: interrupt deadline failed', { err: errorMessage(error) }))
12
+ .on('error', (error) => HarnessLog.warn('python: interrupt deadline failed', { err: errorMessage(error) }))
13
13
  .unref();
14
14
  return {
15
15
  interrupt,