@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
@@ -0,0 +1,137 @@
1
+ import { isRecord } from '../guards.js';
2
+ const FIELD_TYPES = [
3
+ 'single',
4
+ 'multiple',
5
+ 'date',
6
+ 'text',
7
+ 'note',
8
+ 'number'
9
+ ];
10
+ const CHOICE_TYPES = ['single', 'multiple'];
11
+ function fieldType(value) {
12
+ return FIELD_TYPES.find((type) => type === value) ?? null;
13
+ }
14
+ function fieldError(field, seen) {
15
+ if (!isRecord(field) || typeof field.id !== 'string' || !field.id) {
16
+ return 'every field needs an id';
17
+ }
18
+ if (seen.has(field.id)) {
19
+ return `field id ${field.id} is used twice`;
20
+ }
21
+ seen.add(field.id);
22
+ if (typeof field.label !== 'string' || !field.label) {
23
+ return `field ${field.id} needs a label`;
24
+ }
25
+ const type = fieldType(field.type);
26
+ if (!type) {
27
+ return `field ${field.id} has type ${String(field.type)}; use one of ${FIELD_TYPES.join(', ')}`;
28
+ }
29
+ const options = field.options;
30
+ if (CHOICE_TYPES.includes(type) &&
31
+ !(Array.isArray(options) && options.length > 0 && options.every((o) => typeof o === 'string'))) {
32
+ return `field ${field.id} is a ${type} choice and needs options`;
33
+ }
34
+ return null;
35
+ }
36
+ function formError(args) {
37
+ if (typeof args.question !== 'string' || !args.question) {
38
+ return 'question is required';
39
+ }
40
+ if (!Array.isArray(args.fields) || args.fields.length === 0) {
41
+ return 'fields needs at least one field';
42
+ }
43
+ const seen = new Set();
44
+ for (const field of args.fields) {
45
+ const error = fieldError(field, seen);
46
+ if (error) {
47
+ return error;
48
+ }
49
+ }
50
+ return null;
51
+ }
52
+ function formFields(fields) {
53
+ const out = [];
54
+ for (const field of Array.isArray(fields) ? fields : []) {
55
+ const type = isRecord(field) ? fieldType(field.type) : null;
56
+ if (!isRecord(field) || !type) {
57
+ continue;
58
+ }
59
+ out.push({
60
+ id: String(field.id),
61
+ label: String(field.label),
62
+ type,
63
+ options: CHOICE_TYPES.includes(type) && Array.isArray(field.options)
64
+ ? field.options.map(String)
65
+ : undefined,
66
+ required: field.required === true
67
+ });
68
+ }
69
+ return out;
70
+ }
71
+ function answerOf(answer) {
72
+ try {
73
+ const values = JSON.parse(answer);
74
+ if (isRecord(values) && !Array.isArray(values)) {
75
+ return { answers: values };
76
+ }
77
+ }
78
+ catch { }
79
+ return { reply: answer };
80
+ }
81
+ const PARAMETERS = {
82
+ type: 'object',
83
+ properties: {
84
+ question: { type: 'string', description: 'One line on what you need and why' },
85
+ fields: {
86
+ type: 'array',
87
+ items: {
88
+ type: 'object',
89
+ properties: {
90
+ id: { type: 'string', description: 'Key of this answer in the result' },
91
+ label: { type: 'string', description: 'The question the user reads' },
92
+ type: {
93
+ type: 'string',
94
+ enum: [...FIELD_TYPES],
95
+ description: 'single: pick one option; multiple: pick any options; date; text: a short answer; ' +
96
+ 'note: a longer optional comment; number'
97
+ },
98
+ options: {
99
+ type: 'array',
100
+ items: { type: 'string' },
101
+ description: 'The choices, for single and multiple'
102
+ },
103
+ required: { type: 'boolean' }
104
+ },
105
+ required: ['id', 'label', 'type']
106
+ }
107
+ }
108
+ },
109
+ required: ['question', 'fields']
110
+ };
111
+ export function createAskUserTool() {
112
+ return {
113
+ name: 'ask_user',
114
+ toolset: null,
115
+ description: 'Ask the user for details you need before you act, as a short form in the chat. ' +
116
+ 'The run waits for the answers. Ask only what you cannot guess well, all in one form. ' +
117
+ 'The result is the answers by field id, a reply in the user’s own words, or skipped: ' +
118
+ 'then go on with your best guess and say what you assumed.',
119
+ parameters: PARAMETERS,
120
+ effect: () => 'read',
121
+ autoApprove: true,
122
+ validate: formError,
123
+ async execute(args, ctx) {
124
+ if (!ctx?.askUser) {
125
+ return { error: 'This chat cannot show a form; ask in your reply instead.' };
126
+ }
127
+ const answer = await ctx.askUser({
128
+ question: String(args.question),
129
+ form: formFields(args.fields)
130
+ });
131
+ if (answer === null) {
132
+ return { skipped: true, note: 'The user skipped the form; go on with your best guess.' };
133
+ }
134
+ return answerOf(answer);
135
+ }
136
+ };
137
+ }
@@ -0,0 +1,5 @@
1
+ import type { DeliveredFile, RunBudget } from '../../contract/run.ts';
2
+ export declare function sha256(bytes: Uint8Array): string;
3
+ export declare function deliveredFile(budget: RunBudget | undefined, name: string): DeliveredFile | undefined;
4
+ export declare function recordDelivered(budget: RunBudget | undefined, file: DeliveredFile): void;
5
+ export declare function attachmentOf({ attachmentId, fileName, byteLength }: DeliveredFile): Pick<DeliveredFile, 'attachmentId' | 'fileName' | 'byteLength'>;
@@ -0,0 +1,16 @@
1
+ import { createHash } from 'crypto';
2
+ export function sha256(bytes) {
3
+ return createHash('sha256').update(bytes).digest('hex');
4
+ }
5
+ export function deliveredFile(budget, name) {
6
+ const key = name.toLowerCase();
7
+ return budget?.delivered?.find((file) => file.name === key);
8
+ }
9
+ export function recordDelivered(budget, file) {
10
+ if (budget) {
11
+ budget.delivered = [...(budget.delivered ?? []), file];
12
+ }
13
+ }
14
+ export function attachmentOf({ attachmentId, fileName, byteLength }) {
15
+ return { attachmentId, fileName, byteLength };
16
+ }
@@ -0,0 +1,32 @@
1
+ import type { AttachFn, AttachmentRecord } from '../../contract/index.ts';
2
+ export declare const MAX_FILE_BYTES = 100000000;
3
+ export declare function isFileMime(mimeType: string): boolean;
4
+ export declare function bareMime(contentType: string | null | undefined): string;
5
+ export declare function fetchedFileName(url: URL, mimeType: string): string;
6
+ export declare function dispositionFileName(header: string | null | undefined): string | null;
7
+ export interface AttachFetchedFileOptions {
8
+ readonly url: URL;
9
+ readonly mimeType: string;
10
+ readonly attach: AttachFn | undefined;
11
+ readonly maxBytes: number;
12
+ readonly fileName?: string | null | undefined;
13
+ }
14
+ export interface AttachedFile {
15
+ readonly attachmentId: string;
16
+ readonly fileName: string;
17
+ readonly mimeType: string;
18
+ readonly byteLength: number;
19
+ readonly content: string;
20
+ }
21
+ export interface FileRefused {
22
+ readonly error: string;
23
+ }
24
+ export declare function attachFetchedFile(bytes: Uint8Array | undefined, { url, mimeType, attach, maxBytes, fileName }: AttachFetchedFileOptions): Promise<AttachedFile | FileRefused>;
25
+ export interface AttachTextFileOptions {
26
+ readonly url: URL;
27
+ readonly mimeType: string;
28
+ readonly attach: AttachFn | undefined;
29
+ readonly maxBytes: number;
30
+ readonly fileName?: string | null | undefined;
31
+ }
32
+ export declare function attachTextFile(bytes: Uint8Array | undefined, { url, mimeType, attach, maxBytes, fileName }: AttachTextFileOptions): Promise<AttachmentRecord | null>;
@@ -0,0 +1,134 @@
1
+ import b4a from 'b4a';
2
+ import { checkFileName } from './output-policy.js';
3
+ export const MAX_FILE_BYTES = 100_000_000;
4
+ const BINARY_MIME_PREFIXES = ['image/', 'audio/', 'video/', 'font/', 'model/'];
5
+ const TEXT_EXTENSIONS = {
6
+ 'text/plain': 'txt',
7
+ 'text/markdown': 'md'
8
+ };
9
+ const MIME_EXTENSIONS = {
10
+ 'application/pdf': 'pdf',
11
+ 'application/msword': 'doc',
12
+ 'application/vnd.openxmlformats-officedocument.wordprocessingml.document': 'docx',
13
+ 'application/vnd.ms-excel': 'xls',
14
+ 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': 'xlsx',
15
+ 'application/vnd.ms-powerpoint': 'ppt',
16
+ 'application/vnd.openxmlformats-officedocument.presentationml.presentation': 'pptx',
17
+ 'application/vnd.oasis.opendocument.text': 'odt',
18
+ 'application/vnd.oasis.opendocument.spreadsheet': 'ods',
19
+ 'application/epub+zip': 'epub',
20
+ 'application/zip': 'zip',
21
+ 'application/gzip': 'gz',
22
+ 'image/svg+xml': 'svg',
23
+ 'image/jpeg': 'jpg',
24
+ 'audio/mpeg': 'mp3',
25
+ 'video/quicktime': 'mov',
26
+ 'application/octet-stream': 'bin'
27
+ };
28
+ export function isFileMime(mimeType) {
29
+ if (mimeType in MIME_EXTENSIONS)
30
+ return true;
31
+ return BINARY_MIME_PREFIXES.some((prefix) => mimeType.startsWith(prefix));
32
+ }
33
+ export function bareMime(contentType) {
34
+ return contentType?.split(';')[0]?.trim().toLowerCase() ?? '';
35
+ }
36
+ export function fetchedFileName(url, mimeType) {
37
+ const last = url.pathname.split('/').filter(Boolean).pop() ?? '';
38
+ let decoded = last;
39
+ try {
40
+ decoded = decodeURIComponent(last);
41
+ }
42
+ catch { }
43
+ const base = decoded.split(/[/\\]/).filter(Boolean).pop() ?? '';
44
+ return base ? withExtension(base, mimeType) : `${url.hostname}.${extensionFor(mimeType)}`;
45
+ }
46
+ export function dispositionFileName(header) {
47
+ if (!header)
48
+ return null;
49
+ const extended = /filename\*\s*=\s*(?:UTF-8|utf-8)''([^;]+)/.exec(header)?.[1];
50
+ if (extended) {
51
+ try {
52
+ return decodeURIComponent(extended.trim());
53
+ }
54
+ catch { }
55
+ }
56
+ return (/filename\s*=\s*"([^"]*)"/.exec(header)?.[1] ??
57
+ /filename\s*=\s*([^;\s]+)/.exec(header)?.[1] ??
58
+ null);
59
+ }
60
+ export async function attachFetchedFile(bytes, { url, mimeType, attach, maxBytes, fileName }) {
61
+ if (!attach || !bytes || bytes.byteLength === 0) {
62
+ return { error: 'This URL serves a file, not a readable page, and it could not be attached.' };
63
+ }
64
+ if (bytes.byteLength >= maxBytes) {
65
+ return { error: `This file is larger than ${maxBytes / 1_000_000}MB and was not attached.` };
66
+ }
67
+ const mime = isPdf(bytes) ? 'application/pdf' : mimeType || 'application/octet-stream';
68
+ const named = fileName && checkFileName(fileName) === null ? withExtension(fileName, mime) : null;
69
+ const record = await attach({
70
+ fileName: named ?? fetchedFileName(url, mime),
71
+ mimeType: mime,
72
+ bytes,
73
+ raw: !mime.startsWith('image/')
74
+ });
75
+ return {
76
+ attachmentId: record.id,
77
+ fileName: record.fileName,
78
+ mimeType: mime,
79
+ byteLength: record.byteLength,
80
+ content: `Attached the file "${record.fileName}" (${Math.round(record.byteLength / 1024)}KB, ${mime}) from ${url.toString()} — ` +
81
+ 'the user can open or save it. Its contents were NOT read, so do not describe what is inside ' +
82
+ 'yet. To read it, use the skill for its type (pdf for a PDF), or stage it with exec as ' +
83
+ `inputs [{ "attachmentId": "${record.id}", "path": "${record.fileName}" }] — never ask the ` +
84
+ 'user to attach a file this call already attached.'
85
+ };
86
+ }
87
+ function isPdf(bytes) {
88
+ return b4a.toString(bytes.subarray(0, 5), 'latin1') === '%PDF-';
89
+ }
90
+ export async function attachTextFile(bytes, { url, mimeType, attach, maxBytes, fileName }) {
91
+ if (!attach || !bytes || bytes.byteLength === 0 || bytes.byteLength >= maxBytes) {
92
+ return null;
93
+ }
94
+ const mime = mimeType || 'text/plain';
95
+ const named = fileName && checkFileName(fileName) === null ? withExtension(fileName, mime) : null;
96
+ try {
97
+ return await attach({
98
+ fileName: named ?? fetchedFileName(url, mime),
99
+ mimeType: mime,
100
+ bytes,
101
+ raw: true
102
+ });
103
+ }
104
+ catch {
105
+ return null;
106
+ }
107
+ }
108
+ function withExtension(base, mimeType) {
109
+ const extension = /\.([\w-]{1,8})$/.exec(base)?.[1]?.toLowerCase() ?? '';
110
+ if (extension && acceptableExtensions(mimeType).has(extension)) {
111
+ return base;
112
+ }
113
+ const trustsName = mimeType === 'application/octet-stream' || !isFileMime(mimeType);
114
+ if (trustsName && /^[a-z][\w-]*$/.test(extension)) {
115
+ return base;
116
+ }
117
+ return `${base}.${extensionFor(mimeType)}`;
118
+ }
119
+ function acceptableExtensions(mimeType) {
120
+ const accepted = new Set([extensionFor(mimeType)]);
121
+ const subtype = mimeType.split('/')[1] ?? '';
122
+ if (/^[a-z0-9]{1,8}$/.test(subtype)) {
123
+ accepted.add(subtype);
124
+ }
125
+ return accepted;
126
+ }
127
+ function extensionFor(mimeType) {
128
+ const known = MIME_EXTENSIONS[mimeType] ?? TEXT_EXTENSIONS[mimeType];
129
+ if (known) {
130
+ return known;
131
+ }
132
+ const subtype = mimeType.split('/')[1] ?? '';
133
+ return /^[a-z0-9]{1,5}$/.test(subtype) ? subtype : 'bin';
134
+ }
@@ -19,6 +19,7 @@ export interface StageInputsOptions {
19
19
  export interface StagedInputs {
20
20
  files: readonly StagedInput[];
21
21
  }
22
+ export declare function uploadsAvailable(fetchAttachment: FetchAttachmentFn, { turnImages, signal }?: StageInputsOptions): Promise<number | null>;
22
23
  export declare function stageInputs(fetchAttachment: FetchAttachmentFn, inputs: readonly ExecInput[], opts?: StageInputsOptions): Promise<StagedInputs | ExecError>;
23
24
  export interface AttachOutputsOptions {
24
25
  readonly declared: readonly string[];
@@ -1,19 +1,19 @@
1
1
  import fs from 'fs';
2
2
  import path from 'path';
3
+ import { HarnessError } from '../../errors.js';
3
4
  import { errorMessage } from '../../guards.js';
4
- import { hlog } from '../../log.js';
5
+ import { HarnessLog } from '../../log.js';
5
6
  import { checkOutputBytes, MAX_INPUT_TOTAL_BYTES, RUN_OUTPUT_BUDGET_BYTES } from './output-policy.js';
6
7
  const STAGE_TIMEOUT_MS = 60_000;
7
- const STAGE_TIMEOUT_MESSAGE = `staging attachments timed out after ${STAGE_TIMEOUT_MS}ms`;
8
8
  const OVER_BUDGET_ERROR = 'inputs exceed maximum total size';
9
9
  const NO_UPLOAD_ERROR = 'no uploaded image in this chat — attach an image or pass an attachmentId';
10
10
  const DOCUMENT_INPUT = /\.(pdf|docx?|xlsx?|xlsm|pptx?|csv|tsv|txt|md|markdown|rtf|odt|ods|odp|epub|jsonl?|xhtml|html?|xml|ya?ml|log|zip)$/i;
11
11
  const NO_DOCUMENT_ERROR = 'an id-less input stages an uploaded image, and this path names a document — pass its ' +
12
12
  'attachmentId, which the [Attached file "…"] line on the user\'s message carries';
13
- function bounded(work, ms, message) {
13
+ function bounded(work, ms) {
14
14
  let timer;
15
15
  const bound = new Promise((_, reject) => {
16
- timer = setTimeout(() => reject(new Error(message)), ms);
16
+ timer = setTimeout(() => reject(new HarnessError('ATTACHMENT_STAGING_TIMED_OUT', [STAGE_TIMEOUT_MS])), ms);
17
17
  });
18
18
  return Promise.race([work, bound]).finally(() => {
19
19
  if (timer) {
@@ -54,19 +54,30 @@ async function probeUpload(fetchAttachment, input, { index, turnImages, signal,
54
54
  if (DOCUMENT_INPUT.test(input.path)) {
55
55
  return { error: NO_DOCUMENT_ERROR };
56
56
  }
57
- const bytes = await bounded(uploadedBytes(fetchAttachment, index, { turnImages, signal }), deadline - Date.now(), STAGE_TIMEOUT_MESSAGE);
57
+ const bytes = await bounded(uploadedBytes(fetchAttachment, index, { turnImages, signal }), deadline - Date.now());
58
58
  if ('error' in bytes) {
59
59
  return bytes;
60
60
  }
61
61
  return { size: bytes.byteLength, bytes };
62
62
  }
63
63
  async function probeAttachment(fetchAttachment, id, { signal, deadline }) {
64
- const head = await bounded(fetchAttachment({ attachmentId: id, meta: true, signal }), deadline - Date.now(), STAGE_TIMEOUT_MESSAGE);
64
+ const head = await bounded(fetchAttachment({ attachmentId: id, meta: true, signal }), deadline - Date.now());
65
65
  if (!head) {
66
66
  return { error: `attachment ${id} not found in this chat` };
67
67
  }
68
68
  return { size: byteLengthOf(head), bytes: hasBytes(head) ? head.bytes : null };
69
69
  }
70
+ export async function uploadsAvailable(fetchAttachment, { turnImages = [], signal } = {}) {
71
+ if (turnImages.length) {
72
+ return turnImages.length;
73
+ }
74
+ try {
75
+ return (await bounded(fetchAttachment({ meta: true, signal }), STAGE_TIMEOUT_MS)) ? 1 : 0;
76
+ }
77
+ catch {
78
+ return null;
79
+ }
80
+ }
70
81
  export async function stageInputs(fetchAttachment, inputs, opts = {}) {
71
82
  const { turnImages = [], signal } = opts;
72
83
  const files = inputs.map(() => null);
@@ -90,7 +101,7 @@ export async function stageInputs(fetchAttachment, inputs, opts = {}) {
90
101
  }
91
102
  total += probe.size;
92
103
  if (total > MAX_INPUT_TOTAL_BYTES) {
93
- hlog('input attachments over budget; skipping blob download', {
104
+ HarnessLog.warn('input attachments over budget; skipping blob download', {
94
105
  total,
95
106
  cap: MAX_INPUT_TOTAL_BYTES,
96
107
  count: inputs.length
@@ -111,7 +122,7 @@ export async function stageInputs(fetchAttachment, inputs, opts = {}) {
111
122
  for (const { index, input } of pending) {
112
123
  const id = input.attachmentId;
113
124
  try {
114
- const fetched = await bounded(fetchAttachment({ attachmentId: id, signal }), deadline - Date.now(), STAGE_TIMEOUT_MESSAGE);
125
+ const fetched = await bounded(fetchAttachment({ attachmentId: id, signal }), deadline - Date.now());
115
126
  if (!fetched || !hasBytes(fetched)) {
116
127
  return { error: `attachment ${id} not found in this chat` };
117
128
  }
@@ -14,6 +14,8 @@ export interface RunCommandOptions {
14
14
  readonly platform?: string;
15
15
  }
16
16
  export declare const DEFAULT_TIMEOUT_MS = 120000;
17
+ export declare const STOP_GRACE_MS = 2000;
18
+ export declare const TIMED_OUT_EXIT_CODE = 124;
17
19
  export declare const MAX_OUTPUT_CHARS = 8192;
18
20
  export declare const MAX_OUTPUT_CHARS_LIMIT = 65536;
19
21
  interface CapturedOutput {
@@ -27,6 +29,8 @@ export declare function capOutput(text: string, limit: number): string;
27
29
  export declare function appendOutput(output: CapturedOutput, chunk: Buffer | string): void;
28
30
  export declare function formatOutput(output: CapturedOutput, locator?: string | null): string;
29
31
  export declare function createCapturedOutput(limit: number, sink?: SpillSink): CapturedOutput;
32
+ export declare function timeoutNote(timeoutMs: number, printed: boolean): string;
33
+ export declare function withNote(stderr: string, note: string): string;
30
34
  export interface StartCommandOptions {
31
35
  readonly cwd?: string;
32
36
  readonly spawn: SpawnFn;
@@ -3,7 +3,8 @@ import process from 'process';
3
3
  import { headTail, joinHeadTail } from '../../helpers/head-tail.js';
4
4
  import { AbortedError } from '../../helpers/race-abort.js';
5
5
  export const DEFAULT_TIMEOUT_MS = 120_000;
6
- const STOP_GRACE_MS = 2_000;
6
+ export const STOP_GRACE_MS = 2_000;
7
+ export const TIMED_OUT_EXIT_CODE = 124;
7
8
  export const MAX_OUTPUT_CHARS = 8_192;
8
9
  export const MAX_OUTPUT_CHARS_LIMIT = 65_536;
9
10
  export function capOutput(text, limit) {
@@ -26,6 +27,23 @@ export function formatOutput(output, locator) {
26
27
  export function createCapturedOutput(limit, sink) {
27
28
  return { limit, sink, head: '', tail: '', total: 0 };
28
29
  }
30
+ export function timeoutNote(timeoutMs, printed) {
31
+ const stopped = `command timed out after ${timeoutMs}ms and was stopped`;
32
+ return printed
33
+ ? `${stopped}; the output shown is what it printed before then`
34
+ : `${stopped}; no output reached exec in that time. A filter it pipes into (head, grep, sort) loses what it held when the command is stopped: send the output to a file, then head or tail the file. Otherwise it may loop over too much work or wait for input: try it on a small input that prints its progress`;
35
+ }
36
+ export function withNote(stderr, note) {
37
+ return stderr === '' || stderr.endsWith('\n') ? `${stderr}${note}` : `${stderr}\n${note}`;
38
+ }
39
+ function timedOut(timeoutMs, { stdout, stderr, files: [out, err] }) {
40
+ const note = timeoutNote(timeoutMs, stdout.total + stderr.total > 0);
41
+ return {
42
+ stdout: formatOutput(stdout, out),
43
+ stderr: withNote(formatOutput(stderr, err), note),
44
+ exitCode: TIMED_OUT_EXIT_CODE
45
+ };
46
+ }
29
47
  function terminateProcessTree(child, killProcess, signal = 'SIGTERM') {
30
48
  if (child.pid !== undefined && killProcess) {
31
49
  try {
@@ -108,7 +126,7 @@ export function runCommand(command, options) {
108
126
  };
109
127
  options.signal?.addEventListener('abort', onAbort, { once: true });
110
128
  const timer = setTimeout(() => {
111
- finish(() => reject(new Error(`Command timed out after ${timeoutMs}ms`)));
129
+ finish((files) => resolve(timedOut(timeoutMs, { stdout, stderr, files })));
112
130
  terminateProcessTree(child, options.killProcess);
113
131
  }, timeoutMs);
114
132
  child.stdout?.on('data', (chunk) => appendOutput(stdout, chunk));
@@ -1,5 +1,4 @@
1
1
  export declare function bareBin(token: string): string | null;
2
- export declare function firstCommandToken(command: string): string;
3
2
  export declare function escapeLiteralDollars(command: string): string;
4
3
  export declare const SHELL_EXPANSION_ERROR: string;
5
4
  export declare function sanitizeCommand(command: string): string | null;
@@ -1,61 +1,9 @@
1
+ import { ShellLine } from './shell-line.js';
1
2
  export function bareBin(token) {
2
3
  if (!token || /[/\\~$]/.test(token))
3
4
  return null;
4
5
  return token.replace(/\.exe$/i, '').toLowerCase();
5
6
  }
6
- export function firstCommandToken(command) {
7
- const chars = [...command];
8
- let i = 0;
9
- while (i < chars.length && (chars[i] === ' ' || chars[i] === '\t')) {
10
- i++;
11
- }
12
- let token = '';
13
- while (i < chars.length) {
14
- const c = chars[i];
15
- if (c === '"' || c === "'") {
16
- const quote = c;
17
- i++;
18
- while (i < chars.length && chars[i] !== quote) {
19
- token += chars[i];
20
- i++;
21
- }
22
- i++;
23
- continue;
24
- }
25
- if (c === ' ' || c === '\t' || c === '\n') {
26
- break;
27
- }
28
- if (c === ';' || c === '&' || c === '|' || c === '>' || c === '<' || c === '`') {
29
- break;
30
- }
31
- token += c;
32
- i++;
33
- }
34
- return token;
35
- }
36
- function isPad(c) {
37
- return c === ' ' || c === '\t' || c === '\n';
38
- }
39
- function skipDoubleQuoted(chars, open) {
40
- let i = open + 1;
41
- while (i < chars.length && chars[i] !== '"') {
42
- if (chars[i] === '\\') {
43
- if (chars[i + 1] === '\n') {
44
- return 'command must not use line continuations';
45
- }
46
- i += 2;
47
- continue;
48
- }
49
- if (chars[i] === '`') {
50
- return 'command must not use backtick substitution';
51
- }
52
- if (chars[i] === '$') {
53
- return SHELL_EXPANSION_ERROR;
54
- }
55
- i++;
56
- }
57
- return i + 1;
58
- }
59
7
  const EXPANDS = /[A-Za-z_{(?#@*!$-]/;
60
8
  export function escapeLiteralDollars(command) {
61
9
  const chars = [...command];
@@ -87,66 +35,27 @@ export function escapeLiteralDollars(command) {
87
35
  }
88
36
  export const SHELL_EXPANSION_ERROR = 'command must not use shell expansion: $ outside single quotes is expanded by the shell. ' +
89
37
  "Put text containing $ (prices, amounts) in single quotes, e.g. content='Total: $1,348'";
38
+ const REFUSED = {
39
+ chain: 'command must not chain with ;',
40
+ ampersand: 'command must not use & or &&',
41
+ pipe: 'command must not use pipes',
42
+ 'redirect-output': 'command must not redirect output',
43
+ 'redirect-input': 'command must not redirect input',
44
+ newline: 'command must not span multiple lines',
45
+ expansion: SHELL_EXPANSION_ERROR,
46
+ backtick: 'command must not use backtick substitution',
47
+ continuation: 'command must not use line continuations',
48
+ 'process-substitution': 'command must not use process substitution',
49
+ subshell: 'command must not use ( ) subshells: run the program directly',
50
+ group: 'command must not use { } groups: run the program directly',
51
+ negation: 'command must not negate with !: run the program directly',
52
+ keyword: 'command must not use shell keywords (if, for, while, case): run one program per call',
53
+ function: 'command must not define shell functions: run the program directly',
54
+ eval: 'command must not run eval, ., source, trap or a builtin given $ or `: run the program directly',
55
+ comment: 'command must not carry a # comment: drop it, or quote a literal #',
56
+ unterminated: 'command must close every quote it opens'
57
+ };
90
58
  export function sanitizeCommand(command) {
91
- const chars = [...command];
92
- let i = 0;
93
- while (i < chars.length) {
94
- const c = chars[i];
95
- if (c === '\n') {
96
- i++;
97
- while (i < chars.length && isPad(chars[i])) {
98
- i++;
99
- }
100
- if (i < chars.length) {
101
- return 'command must not span multiple lines';
102
- }
103
- return null;
104
- }
105
- if (c === "'") {
106
- i++;
107
- while (i < chars.length && chars[i] !== "'") {
108
- i++;
109
- }
110
- i++;
111
- continue;
112
- }
113
- if (c === '"') {
114
- const end = skipDoubleQuoted(chars, i);
115
- if (typeof end === 'string') {
116
- return end;
117
- }
118
- i = end;
119
- continue;
120
- }
121
- if (c === '\\') {
122
- if (chars[i + 1] === '\n') {
123
- return 'command must not use line continuations';
124
- }
125
- i += 2;
126
- continue;
127
- }
128
- if (c === '`') {
129
- return 'command must not use backtick substitution';
130
- }
131
- if (c === '$') {
132
- return SHELL_EXPANSION_ERROR;
133
- }
134
- if (c === ';') {
135
- return 'command must not chain with ;';
136
- }
137
- if (c === '&') {
138
- return 'command must not use & or &&';
139
- }
140
- if (c === '|') {
141
- return 'command must not use pipes';
142
- }
143
- if (c === '>') {
144
- return 'command must not redirect output';
145
- }
146
- if (c === '<') {
147
- return 'command must not redirect input';
148
- }
149
- i++;
150
- }
151
- return null;
59
+ const first = ShellLine.parse(command).constructs[0];
60
+ return first ? REFUSED[first.kind] : null;
152
61
  }
@@ -1,6 +1,6 @@
1
1
  import { pipInstallTargets, unwrapPythonSource, withoutProgramDir } from './python-source.js';
2
- import { bareBin, firstCommandToken } from './scope.js';
3
- import { shellArgv } from './shell-argv.js';
2
+ import { bareBin } from './scope.js';
3
+ import { ShellLine } from './shell-line.js';
4
4
  import { isTranscoder, TRANSCODE_ERROR, VIDEO_TOOLS_ERROR, videoTool } from './video-tools.js';
5
5
  const INTERPRETER = /^(python[\d.]*|py)$/;
6
6
  const PIP = /^pip[\d.]*$/;
@@ -11,7 +11,7 @@ export const LANGUAGE_UNAVAILABLE_ERROR = 'That language is not available here,
11
11
  export const PIP_UNAVAILABLE_ERROR = 'pip is not available here, and no exec call installs Python packages. Use a shell command, ' +
12
12
  'or tell the user it cannot be done.';
13
13
  export function commandBin(command) {
14
- return bareBin(firstCommandToken(command).replace(/^.*[/\\]/, '')) ?? '';
14
+ return (bareBin((ShellLine.parse(command).commands[0]?.argv[0] ?? '').replace(/^.*[/\\]/, '')) ?? '');
15
15
  }
16
16
  export function dashModule(command) {
17
17
  return /^\s*(?:python[\d.]*|py)\s+-m\s+([\w.-]+)/.exec(withoutProgramDir(command))?.[1] ?? null;
@@ -99,7 +99,7 @@ export function savesDownload(command) {
99
99
  if (bin !== 'curl' && bin !== 'wget') {
100
100
  return false;
101
101
  }
102
- return writesFile(shellArgv(command), bin === 'curl');
102
+ return writesFile(ShellLine.parse(command).commands[0]?.argv ?? [], bin === 'curl');
103
103
  }
104
104
  export function shellOnlyError(command) {
105
105
  if (runsPip(command)) {