@halonicjs/testing 0.0.0 → 0.1.1

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 (438) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +5 -0
  3. package/README.md +41 -1
  4. package/dist/adapters/http-kit/src/address-checking.d.ts +19 -0
  5. package/dist/adapters/http-kit/src/address-checking.js +1 -0
  6. package/dist/adapters/http-kit/src/address-class.d.ts +34 -0
  7. package/dist/adapters/http-kit/src/address-class.js +109 -0
  8. package/dist/adapters/http-kit/src/index.d.ts +3 -0
  9. package/dist/adapters/http-kit/src/index.js +2 -0
  10. package/dist/adapters/http-kit/src/ip-address.d.ts +23 -0
  11. package/dist/adapters/http-kit/src/ip-address.js +89 -0
  12. package/dist/adapters/integration-kit/src/auth-placement.d.ts +40 -0
  13. package/dist/adapters/integration-kit/src/auth-placement.js +102 -0
  14. package/dist/adapters/integration-kit/src/current-secret-forms.d.ts +28 -0
  15. package/dist/adapters/integration-kit/src/current-secret-forms.js +60 -0
  16. package/dist/adapters/integration-kit/src/declaration.d.ts +15 -0
  17. package/dist/adapters/integration-kit/src/declaration.js +78 -0
  18. package/dist/adapters/integration-kit/src/host.d.ts +34 -0
  19. package/dist/adapters/integration-kit/src/host.js +31 -0
  20. package/dist/adapters/integration-kit/src/index.d.ts +16 -0
  21. package/dist/adapters/integration-kit/src/index.js +22 -0
  22. package/dist/adapters/integration-kit/src/leak-attempt.d.ts +16 -0
  23. package/dist/adapters/integration-kit/src/leak-attempt.js +19 -0
  24. package/dist/adapters/integration-kit/src/limited-http.d.ts +55 -0
  25. package/dist/adapters/integration-kit/src/limited-http.js +225 -0
  26. package/dist/adapters/integration-kit/src/load-problem.d.ts +20 -0
  27. package/dist/adapters/integration-kit/src/load-problem.js +1 -0
  28. package/dist/adapters/integration-kit/src/loader.d.ts +131 -0
  29. package/dist/adapters/integration-kit/src/loader.js +251 -0
  30. package/dist/adapters/integration-kit/src/local-address.d.ts +15 -0
  31. package/dist/adapters/integration-kit/src/local-address.js +25 -0
  32. package/dist/adapters/integration-kit/src/own-request.d.ts +33 -0
  33. package/dist/adapters/integration-kit/src/own-request.js +36 -0
  34. package/dist/adapters/integration-kit/src/plugin-load.d.ts +14 -0
  35. package/dist/adapters/integration-kit/src/plugin-load.js +58 -0
  36. package/dist/adapters/integration-kit/src/policy.d.ts +83 -0
  37. package/dist/adapters/integration-kit/src/policy.js +37 -0
  38. package/dist/adapters/integration-kit/src/request-body.d.ts +38 -0
  39. package/dist/adapters/integration-kit/src/request-body.js +68 -0
  40. package/dist/adapters/integration-kit/src/request-log.d.ts +25 -0
  41. package/dist/adapters/integration-kit/src/request-log.js +17 -0
  42. package/dist/adapters/integration-kit/src/response-body.d.ts +27 -0
  43. package/dist/adapters/integration-kit/src/response-body.js +117 -0
  44. package/dist/adapters/integration-kit/src/scoped-tokens.d.ts +14 -0
  45. package/dist/adapters/integration-kit/src/scoped-tokens.js +27 -0
  46. package/dist/adapters/integration-kit/src/secret-filter.d.ts +84 -0
  47. package/dist/adapters/integration-kit/src/secret-filter.js +220 -0
  48. package/dist/adapters/integration-kit/src/secret-in-request.d.ts +62 -0
  49. package/dist/adapters/integration-kit/src/secret-in-request.js +139 -0
  50. package/dist/adapters/integration-kit/src/secret-placement.d.ts +46 -0
  51. package/dist/adapters/integration-kit/src/secret-placement.js +160 -0
  52. package/dist/adapters/integration-kit/src/sign-in-placement.d.ts +29 -0
  53. package/dist/adapters/integration-kit/src/sign-in-placement.js +92 -0
  54. package/dist/adapters/integration-kit/src/wait.d.ts +16 -0
  55. package/dist/adapters/integration-kit/src/wait.js +35 -0
  56. package/dist/core/events/src/add-usage.d.ts +10 -0
  57. package/dist/core/events/src/add-usage.js +27 -0
  58. package/dist/core/events/src/agent-resume.d.ts +24 -0
  59. package/dist/core/events/src/agent-resume.js +1 -0
  60. package/dist/core/events/src/blocked-sites.d.ts +57 -0
  61. package/dist/core/events/src/blocked-sites.js +89 -0
  62. package/dist/core/events/src/home-path.d.ts +13 -0
  63. package/dist/core/events/src/home-path.js +26 -0
  64. package/dist/core/events/src/index.d.ts +17 -0
  65. package/dist/core/events/src/index.js +10 -0
  66. package/dist/core/events/src/run-basics.d.ts +228 -0
  67. package/dist/core/events/src/run-basics.js +1 -0
  68. package/dist/core/events/src/run-event.d.ts +478 -0
  69. package/dist/core/events/src/run-event.js +1 -0
  70. package/dist/core/events/src/run-reads.d.ts +25 -0
  71. package/dist/core/events/src/run-reads.js +44 -0
  72. package/dist/core/events/src/run-sends.d.ts +47 -0
  73. package/dist/core/events/src/run-sends.js +68 -0
  74. package/dist/core/events/src/run-summary.d.ts +108 -0
  75. package/dist/core/events/src/run-summary.js +1 -0
  76. package/dist/core/events/src/sandbox-blocked.d.ts +42 -0
  77. package/dist/core/events/src/sandbox-blocked.js +26 -0
  78. package/dist/core/events/src/sandbox-opened-read.d.ts +17 -0
  79. package/dist/core/events/src/sandbox-opened-read.js +63 -0
  80. package/dist/core/events/src/sandbox-opened.d.ts +94 -0
  81. package/dist/core/events/src/sandbox-opened.js +52 -0
  82. package/dist/core/events/src/summarize.d.ts +14 -0
  83. package/dist/core/events/src/summarize.js +192 -0
  84. package/dist/core/events/src/timeline-entry.d.ts +21 -0
  85. package/dist/core/events/src/timeline-entry.js +106 -0
  86. package/dist/core/events/src/upgrade.d.ts +23 -0
  87. package/dist/core/events/src/upgrade.js +49 -0
  88. package/dist/core/format/src/compact.d.ts +30 -0
  89. package/dist/core/format/src/compact.js +72 -0
  90. package/dist/core/format/src/index.d.ts +39 -0
  91. package/dist/core/format/src/index.js +25 -0
  92. package/dist/core/format/src/integration/index.d.ts +7 -0
  93. package/dist/core/format/src/integration/index.js +10 -0
  94. package/dist/core/format/src/json-schema.d.ts +26 -0
  95. package/dist/core/format/src/json-schema.js +48 -0
  96. package/dist/core/format/src/kind.d.ts +65 -0
  97. package/dist/core/format/src/kind.js +1 -0
  98. package/dist/core/format/src/kinds/agent/kind.d.ts +4 -0
  99. package/dist/core/format/src/kinds/agent/kind.js +10 -0
  100. package/dist/core/format/src/kinds/agent/sandbox-fields.d.ts +99 -0
  101. package/dist/core/format/src/kinds/agent/sandbox-fields.js +216 -0
  102. package/dist/core/format/src/kinds/agent/schema.d.ts +147 -0
  103. package/dist/core/format/src/kinds/agent/schema.js +107 -0
  104. package/dist/core/format/src/kinds/agent/working-folder-start.d.ts +74 -0
  105. package/dist/core/format/src/kinds/agent/working-folder-start.js +312 -0
  106. package/dist/core/format/src/kinds/collection/kind.d.ts +8 -0
  107. package/dist/core/format/src/kinds/collection/kind.js +14 -0
  108. package/dist/core/format/src/kinds/collection/schema.d.ts +89 -0
  109. package/dist/core/format/src/kinds/collection/schema.js +90 -0
  110. package/dist/core/format/src/kinds/connector/is-local.d.ts +10 -0
  111. package/dist/core/format/src/kinds/connector/is-local.js +43 -0
  112. package/dist/core/format/src/kinds/connector/kind.d.ts +4 -0
  113. package/dist/core/format/src/kinds/connector/kind.js +218 -0
  114. package/dist/core/format/src/kinds/connector/schema.d.ts +74 -0
  115. package/dist/core/format/src/kinds/connector/schema.js +143 -0
  116. package/dist/core/format/src/kinds/deployments/kind.d.ts +4 -0
  117. package/dist/core/format/src/kinds/deployments/kind.js +49 -0
  118. package/dist/core/format/src/kinds/deployments/schema.d.ts +77 -0
  119. package/dist/core/format/src/kinds/deployments/schema.js +94 -0
  120. package/dist/core/format/src/kinds/hub/kind.d.ts +4 -0
  121. package/dist/core/format/src/kinds/hub/kind.js +10 -0
  122. package/dist/core/format/src/kinds/hub/schema.d.ts +54 -0
  123. package/dist/core/format/src/kinds/hub/schema.js +34 -0
  124. package/dist/core/format/src/kinds/integration/approved-sign-ins.d.ts +62 -0
  125. package/dist/core/format/src/kinds/integration/approved-sign-ins.js +125 -0
  126. package/dist/core/format/src/kinds/integration/host-key.d.ts +7 -0
  127. package/dist/core/format/src/kinds/integration/host-key.js +8 -0
  128. package/dist/core/format/src/kinds/integration/kind.d.ts +18 -0
  129. package/dist/core/format/src/kinds/integration/kind.js +175 -0
  130. package/dist/core/format/src/kinds/integration/parse-sheet.d.ts +19 -0
  131. package/dist/core/format/src/kinds/integration/parse-sheet.js +24 -0
  132. package/dist/core/format/src/kinds/integration/policy.d.ts +112 -0
  133. package/dist/core/format/src/kinds/integration/policy.js +327 -0
  134. package/dist/core/format/src/kinds/integration/schema.d.ts +410 -0
  135. package/dist/core/format/src/kinds/integration/schema.js +359 -0
  136. package/dist/core/format/src/kinds/integration/sign-in-checks.d.ts +13 -0
  137. package/dist/core/format/src/kinds/integration/sign-in-checks.js +120 -0
  138. package/dist/core/format/src/kinds/integration/sign-in-urls.d.ts +19 -0
  139. package/dist/core/format/src/kinds/integration/sign-in-urls.js +47 -0
  140. package/dist/core/format/src/kinds/knowledge/kind.d.ts +4 -0
  141. package/dist/core/format/src/kinds/knowledge/kind.js +13 -0
  142. package/dist/core/format/src/kinds/knowledge/schema.d.ts +18 -0
  143. package/dist/core/format/src/kinds/knowledge/schema.js +25 -0
  144. package/dist/core/format/src/kinds/models/kind.d.ts +4 -0
  145. package/dist/core/format/src/kinds/models/kind.js +10 -0
  146. package/dist/core/format/src/kinds/models/schema.d.ts +92 -0
  147. package/dist/core/format/src/kinds/models/schema.js +38 -0
  148. package/dist/core/format/src/kinds/plugin/backend.d.ts +22 -0
  149. package/dist/core/format/src/kinds/plugin/backend.js +31 -0
  150. package/dist/core/format/src/kinds/plugin/checks.d.ts +13 -0
  151. package/dist/core/format/src/kinds/plugin/checks.js +137 -0
  152. package/dist/core/format/src/kinds/plugin/kind.d.ts +8 -0
  153. package/dist/core/format/src/kinds/plugin/kind.js +16 -0
  154. package/dist/core/format/src/kinds/plugin/problems.d.ts +24 -0
  155. package/dist/core/format/src/kinds/plugin/problems.js +65 -0
  156. package/dist/core/format/src/kinds/plugin/schema.d.ts +672 -0
  157. package/dist/core/format/src/kinds/plugin/schema.js +261 -0
  158. package/dist/core/format/src/kinds/plugin/setting-values.d.ts +17 -0
  159. package/dist/core/format/src/kinds/plugin/setting-values.js +38 -0
  160. package/dist/core/format/src/kinds/plugin/ui-checks.d.ts +8 -0
  161. package/dist/core/format/src/kinds/plugin/ui-checks.js +85 -0
  162. package/dist/core/format/src/kinds/provider/kind.d.ts +4 -0
  163. package/dist/core/format/src/kinds/provider/kind.js +24 -0
  164. package/dist/core/format/src/kinds/provider/schema.d.ts +17 -0
  165. package/dist/core/format/src/kinds/provider/schema.js +22 -0
  166. package/dist/core/format/src/kinds/routine/kind.d.ts +8 -0
  167. package/dist/core/format/src/kinds/routine/kind.js +62 -0
  168. package/dist/core/format/src/kinds/routine/schema.d.ts +94 -0
  169. package/dist/core/format/src/kinds/routine/schema.js +115 -0
  170. package/dist/core/format/src/kinds/routine/webhook-headers.d.ts +9 -0
  171. package/dist/core/format/src/kinds/routine/webhook-headers.js +26 -0
  172. package/dist/core/format/src/kinds/runtime/kind.d.ts +4 -0
  173. package/dist/core/format/src/kinds/runtime/kind.js +13 -0
  174. package/dist/core/format/src/kinds/runtime/schema.d.ts +10 -0
  175. package/dist/core/format/src/kinds/runtime/schema.js +12 -0
  176. package/dist/core/format/src/kinds/skill/kind.d.ts +4 -0
  177. package/dist/core/format/src/kinds/skill/kind.js +10 -0
  178. package/dist/core/format/src/kinds/skill/schema.d.ts +17 -0
  179. package/dist/core/format/src/kinds/skill/schema.js +17 -0
  180. package/dist/core/format/src/kinds/skill/scripts-folder.d.ts +27 -0
  181. package/dist/core/format/src/kinds/skill/scripts-folder.js +37 -0
  182. package/dist/core/format/src/kinds/workflow/kind.d.ts +8 -0
  183. package/dist/core/format/src/kinds/workflow/kind.js +14 -0
  184. package/dist/core/format/src/kinds/workflow/schema.d.ts +162 -0
  185. package/dist/core/format/src/kinds/workflow/schema.js +106 -0
  186. package/dist/core/format/src/kinds/workflow-test/kind.d.ts +4 -0
  187. package/dist/core/format/src/kinds/workflow-test/kind.js +14 -0
  188. package/dist/core/format/src/kinds/workflow-test/schema.d.ts +67 -0
  189. package/dist/core/format/src/kinds/workflow-test/schema.js +59 -0
  190. package/dist/core/format/src/kinds/workspace/kind.d.ts +4 -0
  191. package/dist/core/format/src/kinds/workspace/kind.js +10 -0
  192. package/dist/core/format/src/kinds/workspace/schema.d.ts +72 -0
  193. package/dist/core/format/src/kinds/workspace/schema.js +66 -0
  194. package/dist/core/format/src/parse-file.d.ts +69 -0
  195. package/dist/core/format/src/parse-file.js +105 -0
  196. package/dist/core/format/src/recording/format.d.ts +81 -0
  197. package/dist/core/format/src/recording/format.js +102 -0
  198. package/dist/core/format/src/recording/index.d.ts +1 -0
  199. package/dist/core/format/src/recording/index.js +3 -0
  200. package/dist/core/format/src/registry.d.ts +64 -0
  201. package/dist/core/format/src/registry.js +61 -0
  202. package/dist/core/format/src/reserved.d.ts +20 -0
  203. package/dist/core/format/src/reserved.js +30 -0
  204. package/dist/core/format/src/shared/fields.d.ts +34 -0
  205. package/dist/core/format/src/shared/fields.js +74 -0
  206. package/dist/core/format/src/shared/guard.d.ts +32 -0
  207. package/dist/core/format/src/shared/guard.js +16 -0
  208. package/dist/core/format/src/shared/key-in-value.d.ts +28 -0
  209. package/dist/core/format/src/shared/key-in-value.js +82 -0
  210. package/dist/core/format/src/shared/legacy-keys.d.ts +8 -0
  211. package/dist/core/format/src/shared/legacy-keys.js +17 -0
  212. package/dist/core/format/src/shared/program-start.d.ts +60 -0
  213. package/dist/core/format/src/shared/program-start.js +99 -0
  214. package/dist/core/format/src/shared/relative-path.d.ts +29 -0
  215. package/dist/core/format/src/shared/relative-path.js +50 -0
  216. package/dist/core/format/src/shared/secret-name.d.ts +24 -0
  217. package/dist/core/format/src/shared/secret-name.js +107 -0
  218. package/dist/core/format/src/source.d.ts +16 -0
  219. package/dist/core/format/src/source.js +73 -0
  220. package/dist/core/ports/src/agent-placement-store.d.ts +74 -0
  221. package/dist/core/ports/src/agent-placement-store.js +27 -0
  222. package/dist/core/ports/src/agent-runs-not-available.d.ts +21 -0
  223. package/dist/core/ports/src/agent-runs-not-available.js +25 -0
  224. package/dist/core/ports/src/blob-store.d.ts +45 -0
  225. package/dist/core/ports/src/blob-store.js +24 -0
  226. package/dist/core/ports/src/cant-try-error.d.ts +35 -0
  227. package/dist/core/ports/src/cant-try-error.js +44 -0
  228. package/dist/core/ports/src/chat.d.ts +127 -0
  229. package/dist/core/ports/src/chat.js +1 -0
  230. package/dist/core/ports/src/clock.d.ts +7 -0
  231. package/dist/core/ports/src/clock.js +2 -0
  232. package/dist/core/ports/src/connection-settings-store.d.ts +57 -0
  233. package/dist/core/ports/src/connection-settings-store.js +2 -0
  234. package/dist/core/ports/src/connector-client.d.ts +303 -0
  235. package/dist/core/ports/src/connector-client.js +19 -0
  236. package/dist/core/ports/src/coordination.d.ts +84 -0
  237. package/dist/core/ports/src/coordination.js +2 -0
  238. package/dist/core/ports/src/definition-store.d.ts +229 -0
  239. package/dist/core/ports/src/definition-store.js +122 -0
  240. package/dist/core/ports/src/digest.d.ts +14 -0
  241. package/dist/core/ports/src/digest.js +2 -0
  242. package/dist/core/ports/src/folder-reader.d.ts +89 -0
  243. package/dist/core/ports/src/folder-reader.js +2 -0
  244. package/dist/core/ports/src/harness-bridge-server.d.ts +198 -0
  245. package/dist/core/ports/src/harness-bridge-server.js +37 -0
  246. package/dist/core/ports/src/harness-sign-in-command.d.ts +27 -0
  247. package/dist/core/ports/src/harness-sign-in-command.js +31 -0
  248. package/dist/core/ports/src/harness.d.ts +283 -0
  249. package/dist/core/ports/src/harness.js +45 -0
  250. package/dist/core/ports/src/host-settings-store.d.ts +116 -0
  251. package/dist/core/ports/src/host-settings-store.js +106 -0
  252. package/dist/core/ports/src/http-client.d.ts +27 -0
  253. package/dist/core/ports/src/http-client.js +2 -0
  254. package/dist/core/ports/src/id-generator.d.ts +14 -0
  255. package/dist/core/ports/src/id-generator.js +2 -0
  256. package/dist/core/ports/src/index.d.ts +45 -0
  257. package/dist/core/ports/src/index.js +44 -0
  258. package/dist/core/ports/src/instruction-trust-store.d.ts +81 -0
  259. package/dist/core/ports/src/instruction-trust-store.js +43 -0
  260. package/dist/core/ports/src/integration.d.ts +242 -0
  261. package/dist/core/ports/src/integration.js +31 -0
  262. package/dist/core/ports/src/knowledge-provider.d.ts +65 -0
  263. package/dist/core/ports/src/knowledge-provider.js +2 -0
  264. package/dist/core/ports/src/llm-cache.d.ts +13 -0
  265. package/dist/core/ports/src/llm-cache.js +2 -0
  266. package/dist/core/ports/src/llm-provider.d.ts +186 -0
  267. package/dist/core/ports/src/llm-provider.js +139 -0
  268. package/dist/core/ports/src/model-price.d.ts +34 -0
  269. package/dist/core/ports/src/model-price.js +25 -0
  270. package/dist/core/ports/src/password-hasher.d.ts +63 -0
  271. package/dist/core/ports/src/password-hasher.js +2 -0
  272. package/dist/core/ports/src/plugin-folder-writer.d.ts +104 -0
  273. package/dist/core/ports/src/plugin-folder-writer.js +95 -0
  274. package/dist/core/ports/src/port-versions.d.ts +47 -0
  275. package/dist/core/ports/src/port-versions.js +80 -0
  276. package/dist/core/ports/src/program-probe.d.ts +69 -0
  277. package/dist/core/ports/src/program-probe.js +2 -0
  278. package/dist/core/ports/src/provider-default-base-url.d.ts +10 -0
  279. package/dist/core/ports/src/provider-default-base-url.js +18 -0
  280. package/dist/core/ports/src/record-store.d.ts +79 -0
  281. package/dist/core/ports/src/record-store.js +108 -0
  282. package/dist/core/ports/src/resource-probe.d.ts +59 -0
  283. package/dist/core/ports/src/resource-probe.js +2 -0
  284. package/dist/core/ports/src/run-executor.d.ts +303 -0
  285. package/dist/core/ports/src/run-executor.js +2 -0
  286. package/dist/core/ports/src/run-failure-error.d.ts +49 -0
  287. package/dist/core/ports/src/run-failure-error.js +47 -0
  288. package/dist/core/ports/src/run-store.d.ts +194 -0
  289. package/dist/core/ports/src/run-store.js +131 -0
  290. package/dist/core/ports/src/run-target-not-found.d.ts +34 -0
  291. package/dist/core/ports/src/run-target-not-found.js +41 -0
  292. package/dist/core/ports/src/sandbox-setting-store.d.ts +68 -0
  293. package/dist/core/ports/src/sandbox-setting-store.js +33 -0
  294. package/dist/core/ports/src/sandbox.d.ts +364 -0
  295. package/dist/core/ports/src/sandbox.js +70 -0
  296. package/dist/core/ports/src/scheduler.d.ts +85 -0
  297. package/dist/core/ports/src/scheduler.js +2 -0
  298. package/dist/core/ports/src/secrets.d.ts +201 -0
  299. package/dist/core/ports/src/secrets.js +200 -0
  300. package/dist/core/ports/src/token-store.d.ts +19 -0
  301. package/dist/core/ports/src/token-store.js +2 -0
  302. package/dist/core/ports/src/tool-approval-store.d.ts +253 -0
  303. package/dist/core/ports/src/tool-approval-store.js +116 -0
  304. package/dist/core/ports/src/trust-store.d.ts +72 -0
  305. package/dist/core/ports/src/trust-store.js +2 -0
  306. package/dist/core/ports/src/unfenced-run-consent-store.d.ts +43 -0
  307. package/dist/core/ports/src/unfenced-run-consent-store.js +2 -0
  308. package/dist/core/ports/src/vcs-status.d.ts +8 -0
  309. package/dist/core/ports/src/vcs-status.js +90 -0
  310. package/dist/core/ports/src/vcs.d.ts +394 -0
  311. package/dist/core/ports/src/vcs.js +48 -0
  312. package/dist/core/schema-kit/src/builders.d.ts +50 -0
  313. package/dist/core/schema-kit/src/builders.js +72 -0
  314. package/dist/core/schema-kit/src/depth.d.ts +15 -0
  315. package/dist/core/schema-kit/src/depth.js +37 -0
  316. package/dist/core/schema-kit/src/index.d.ts +6 -0
  317. package/dist/core/schema-kit/src/index.js +6 -0
  318. package/dist/core/schema-kit/src/issue.d.ts +22 -0
  319. package/dist/core/schema-kit/src/issue.js +23 -0
  320. package/dist/core/schema-kit/src/json-schema.d.ts +23 -0
  321. package/dist/core/schema-kit/src/json-schema.js +22 -0
  322. package/dist/core/schema-kit/src/parse.d.ts +17 -0
  323. package/dist/core/schema-kit/src/parse.js +25 -0
  324. package/dist/core/schema-kit/src/schema.d.ts +12 -0
  325. package/dist/core/schema-kit/src/schema.js +1 -0
  326. package/dist/core/std/src/amount.d.ts +13 -0
  327. package/dist/core/std/src/amount.js +22 -0
  328. package/dist/core/std/src/ascii-host.d.ts +18 -0
  329. package/dist/core/std/src/ascii-host.js +110 -0
  330. package/dist/core/std/src/assert.d.ts +39 -0
  331. package/dist/core/std/src/assert.js +59 -0
  332. package/dist/core/std/src/base64url.d.ts +23 -0
  333. package/dist/core/std/src/base64url.js +65 -0
  334. package/dist/core/std/src/canonical-json.d.ts +18 -0
  335. package/dist/core/std/src/canonical-json.js +56 -0
  336. package/dist/core/std/src/clock.d.ts +27 -0
  337. package/dist/core/std/src/clock.js +33 -0
  338. package/dist/core/std/src/constant-time.d.ts +16 -0
  339. package/dist/core/std/src/constant-time.js +26 -0
  340. package/dist/core/std/src/content-digest.d.ts +24 -0
  341. package/dist/core/std/src/content-digest.js +28 -0
  342. package/dist/core/std/src/deep-clone.d.ts +15 -0
  343. package/dist/core/std/src/deep-clone.js +59 -0
  344. package/dist/core/std/src/deep-equal.d.ts +23 -0
  345. package/dist/core/std/src/deep-equal.js +64 -0
  346. package/dist/core/std/src/emitter.d.ts +42 -0
  347. package/dist/core/std/src/emitter.js +74 -0
  348. package/dist/core/std/src/error-kind.d.ts +88 -0
  349. package/dist/core/std/src/error-kind.js +98 -0
  350. package/dist/core/std/src/hex.d.ts +10 -0
  351. package/dist/core/std/src/hex.js +16 -0
  352. package/dist/core/std/src/hidden-characters.d.ts +19 -0
  353. package/dist/core/std/src/hidden-characters.js +54 -0
  354. package/dist/core/std/src/ids.d.ts +45 -0
  355. package/dist/core/std/src/ids.js +49 -0
  356. package/dist/core/std/src/index.d.ts +30 -0
  357. package/dist/core/std/src/index.js +31 -0
  358. package/dist/core/std/src/keyed-queue.d.ts +18 -0
  359. package/dist/core/std/src/keyed-queue.js +32 -0
  360. package/dist/core/std/src/line-diff.d.ts +83 -0
  361. package/dist/core/std/src/line-diff.js +179 -0
  362. package/dist/core/std/src/line-merge.d.ts +63 -0
  363. package/dist/core/std/src/line-merge.js +138 -0
  364. package/dist/core/std/src/plain-data.d.ts +32 -0
  365. package/dist/core/std/src/plain-data.js +57 -0
  366. package/dist/core/std/src/posix-path.d.ts +61 -0
  367. package/dist/core/std/src/posix-path.js +121 -0
  368. package/dist/core/std/src/public-suffixes.generated.d.ts +9 -0
  369. package/dist/core/std/src/public-suffixes.generated.js +10429 -0
  370. package/dist/core/std/src/registrable-domain.d.ts +10 -0
  371. package/dist/core/std/src/registrable-domain.js +62 -0
  372. package/dist/core/std/src/result.d.ts +55 -0
  373. package/dist/core/std/src/result.js +52 -0
  374. package/dist/core/std/src/secret-scrubber.d.ts +54 -0
  375. package/dist/core/std/src/secret-scrubber.js +124 -0
  376. package/dist/core/std/src/secret-shape.d.ts +20 -0
  377. package/dist/core/std/src/secret-shape.js +53 -0
  378. package/dist/core/std/src/secret-variable-name.d.ts +12 -0
  379. package/dist/core/std/src/secret-variable-name.js +34 -0
  380. package/dist/core/std/src/site-name.d.ts +35 -0
  381. package/dist/core/std/src/site-name.js +111 -0
  382. package/dist/core/std/src/stop-signal.d.ts +44 -0
  383. package/dist/core/std/src/stop-signal.js +77 -0
  384. package/dist/core/std/src/text.d.ts +28 -0
  385. package/dist/core/std/src/text.js +54 -0
  386. package/dist/core/std/src/url-host.d.ts +35 -0
  387. package/dist/core/std/src/url-host.js +170 -0
  388. package/dist/core/std/src/utf8.d.ts +23 -0
  389. package/dist/core/std/src/utf8.js +110 -0
  390. package/dist/core/std/src/version.d.ts +48 -0
  391. package/dist/core/std/src/version.js +103 -0
  392. package/dist/core/yaml/src/depth.d.ts +14 -0
  393. package/dist/core/yaml/src/depth.js +140 -0
  394. package/dist/core/yaml/src/edit-data.d.ts +47 -0
  395. package/dist/core/yaml/src/edit-data.js +286 -0
  396. package/dist/core/yaml/src/edit-text.d.ts +92 -0
  397. package/dist/core/yaml/src/edit-text.js +267 -0
  398. package/dist/core/yaml/src/edit.d.ts +47 -0
  399. package/dist/core/yaml/src/edit.js +198 -0
  400. package/dist/core/yaml/src/index.d.ts +5 -0
  401. package/dist/core/yaml/src/index.js +4 -0
  402. package/dist/core/yaml/src/problem.d.ts +20 -0
  403. package/dist/core/yaml/src/problem.js +1 -0
  404. package/dist/core/yaml/src/read.d.ts +47 -0
  405. package/dist/core/yaml/src/read.js +130 -0
  406. package/dist/core/yaml/src/splice-node.d.ts +47 -0
  407. package/dist/core/yaml/src/splice-node.js +333 -0
  408. package/dist/core/yaml/src/splice.d.ts +13 -0
  409. package/dist/core/yaml/src/splice.js +174 -0
  410. package/dist/core/yaml/src/unsupported.d.ts +26 -0
  411. package/dist/core/yaml/src/unsupported.js +70 -0
  412. package/dist/core/yaml/src/write.d.ts +35 -0
  413. package/dist/core/yaml/src/write.js +44 -0
  414. package/dist/testing/integration/src/canaries.d.ts +14 -0
  415. package/dist/testing/integration/src/canaries.js +17 -0
  416. package/dist/testing/integration/src/checks.d.ts +37 -0
  417. package/dist/testing/integration/src/checks.js +195 -0
  418. package/dist/testing/integration/src/describe.d.ts +35 -0
  419. package/dist/testing/integration/src/describe.js +74 -0
  420. package/dist/testing/integration/src/failure.d.ts +6 -0
  421. package/dist/testing/integration/src/failure.js +8 -0
  422. package/dist/testing/integration/src/fake-wait.d.ts +18 -0
  423. package/dist/testing/integration/src/fake-wait.js +21 -0
  424. package/dist/testing/integration/src/index.d.ts +10 -0
  425. package/dist/testing/integration/src/index.js +11 -0
  426. package/dist/testing/integration/src/load.d.ts +14 -0
  427. package/dist/testing/integration/src/load.js +47 -0
  428. package/dist/testing/integration/src/plugin-folder.d.ts +23 -0
  429. package/dist/testing/integration/src/plugin-folder.js +59 -0
  430. package/dist/testing/integration/src/plugin.d.ts +32 -0
  431. package/dist/testing/integration/src/plugin.js +57 -0
  432. package/dist/testing/integration/src/recording.d.ts +84 -0
  433. package/dist/testing/integration/src/recording.js +164 -0
  434. package/dist/testing/integration/src/run.d.ts +60 -0
  435. package/dist/testing/integration/src/run.js +81 -0
  436. package/dist/testing/integration/src/source-scan.d.ts +16 -0
  437. package/dist/testing/integration/src/source-scan.js +40 -0
  438. package/package.json +34 -3
@@ -0,0 +1,303 @@
1
+ import type { CantTryStep, ModelSkipReason, RunEvent, RunKind, RunSummary, RunTrigger, RunVersion } from "../../events/src/index.js";
2
+ import type { ChatMessage, ChatParams, ChatResponse, ToolDefinition } from "./chat.js";
3
+ /** Version of the {@link RunExecutor} port. A breaking change bumps it and comes with an ADR. */
4
+ export declare const runExecutorVersion = 1;
5
+ /**
6
+ * Start a workflow run. Subflows are not started through this port: the
7
+ * engine starts them inside the executor, which also tells the parent when a
8
+ * child finishes.
9
+ */
10
+ export interface StartRunRequest {
11
+ hubId: string;
12
+ workflowId: string;
13
+ input: Record<string, unknown>;
14
+ kind?: RunKind;
15
+ trigger?: RunTrigger;
16
+ /**
17
+ * The harness every task agent of the run runs in, whatever its file
18
+ * names, such as `codex`; `halonic` runs them all in Halonic's own loop.
19
+ * Its child runs use it too. Each agent's own harness when absent. An id
20
+ * that isn't a harness is refused before anything is recorded. Whether
21
+ * the harness is installed is the caller's check (`detect()`).
22
+ */
23
+ harness?: string;
24
+ /**
25
+ * The steps of a Try it or Test run that can't be tried, as found when the
26
+ * caller loaded the run's item: each `step` names a state of the run's
27
+ * workflow, or is `null` when the whole item can't be tried. They go on
28
+ * `run.started`, and the run never runs them. None when absent.
29
+ */
30
+ cantTry?: readonly CantTryStep[];
31
+ /**
32
+ * Which version of the workspace the run reads, as the caller loaded it:
33
+ * the live version, with its commit and date, or the saved files. It goes
34
+ * on `run.started`, and the run's child runs record it too. Not recorded
35
+ * when absent. The local executor passes it to `definitionsOf`, so the
36
+ * host gives the run that version's files; it doesn't check them against it.
37
+ */
38
+ version?: RunVersion;
39
+ /**
40
+ * The id the run gets, for a start that may be repeated: a routine fire, a
41
+ * mail or a signal. When a run with this id already exists, `start` returns
42
+ * its summary and starts nothing, whatever the rest of the request says.
43
+ * A new id from the executor's `IdGenerator` when absent. At most 256
44
+ * UTF-8 bytes, because it becomes a `Scheduler` key; a longer one
45
+ * is refused with a `RangeError` before anything is recorded.
46
+ */
47
+ runId?: string;
48
+ }
49
+ /** Start a run of a single agent with a prompt. */
50
+ export interface StartAgentRequest {
51
+ hubId: string;
52
+ agentId: string;
53
+ prompt: string;
54
+ /**
55
+ * What started the run, as for a workflow run. A routine that runs one
56
+ * agent sets it, so the routine can find its own runs again (last run,
57
+ * overlap). The old local engine accepted it too.
58
+ */
59
+ trigger?: RunTrigger;
60
+ /**
61
+ * As {@link StartRunRequest.runId}: repeating a start with the same id
62
+ * starts nothing, and an id over 256 UTF-8 bytes is a `RangeError`.
63
+ */
64
+ runId?: string;
65
+ }
66
+ /** Options for {@link RunExecutor.send}. */
67
+ export interface SendOptions {
68
+ /**
69
+ * The tool call the event is meant for, such as the one a person approves,
70
+ * as the run's summary names it. When it is given and the run doesn't wait
71
+ * on that call, `send` is refused before anything is recorded: a person
72
+ * who answered an approval that has since moved on must not approve the
73
+ * next one by accident. Absent: no check.
74
+ */
75
+ readonly callId?: string;
76
+ }
77
+ /** An agent's model settings for a chat turn that aren't saved in a file yet. */
78
+ export interface ChatAgentSettings {
79
+ /** The provider adapter type, such as "openai". */
80
+ type: string;
81
+ /** The model name at that provider. */
82
+ model: string;
83
+ /** The provider's address, when it isn't the adapter's default. */
84
+ baseUrl?: string;
85
+ /**
86
+ * The **name** of the secret that holds the API key, never the key itself.
87
+ * This travels over the wire to a remote host, which looks the name up.
88
+ */
89
+ secret?: string;
90
+ /** Whether the model runs on this machine (such as Ollama), so it has no price. */
91
+ local: boolean;
92
+ }
93
+ /** One model turn for a chat outside any run (agent chat, the Build assistant, inbox conversations). */
94
+ export interface ChatTurnRequest {
95
+ hubId: string;
96
+ /** The model alias to use; the workspace default when absent. */
97
+ alias?: string;
98
+ messages: ChatMessage[];
99
+ tools: ToolDefinition[];
100
+ /** The agent whose settings and prompt apply, if any. */
101
+ agentId?: string;
102
+ params?: ChatParams;
103
+ /** Unsaved model settings from the agent editor; they win over the saved ones. */
104
+ agent?: ChatAgentSettings;
105
+ /**
106
+ * Aborted when the person stops the chat. An executor that honors it stops
107
+ * the model call and rejects; a remote one also stops waiting for the host.
108
+ * It is never sent over the wire. Optional, so an executor that ignores it
109
+ * still satisfies the port: the caller then drops an answer that comes
110
+ * after the abort.
111
+ */
112
+ signal?: AbortSignal;
113
+ }
114
+ /**
115
+ * Something a chat turn refused, as data a status view can read. It mirrors
116
+ * `ToolRefusal` from `core/app`, which this package can't import, and adds
117
+ * `call`. `listing`, `tool` and `keyword` are refusals of what a source
118
+ * listed; they never go to the model. `call` is a tool call that didn't run:
119
+ * the check refused it, it named a tool nobody offered, or the turn hit its
120
+ * round limit first.
121
+ */
122
+ export interface ChatTurnRefusal {
123
+ /** The id of the tool's source: a connector or integration, or "halonic" for Halonic's own tools. */
124
+ source: string;
125
+ /** The tool's name; left out when a whole listing is refused. */
126
+ name?: string;
127
+ refused: "listing" | "tool" | "keyword" | "call";
128
+ /** Why, as plain text. Text a server wrote is cut and escaped before it gets here. */
129
+ reason: string;
130
+ }
131
+ /**
132
+ * A model alias a chat turn skipped before calling it. It is what an
133
+ * `llm.skipped` run log event says, for a turn that has no run log.
134
+ */
135
+ export interface ChatTurnSkip {
136
+ /** The skipped alias, such as "smart". */
137
+ alias: string;
138
+ provider: string;
139
+ model: string;
140
+ reason: ModelSkipReason;
141
+ /** The alias tried instead; absent when none was left. */
142
+ next?: string;
143
+ }
144
+ /**
145
+ * The model's answer to a {@link ChatTurnRequest}, with the model that gave it.
146
+ * `content`, `toolCalls` and `finishReason` are those of the turn's last
147
+ * answer; `usage` adds up every model call in the turn.
148
+ */
149
+ export interface ChatTurnResponse extends ChatResponse {
150
+ model: string;
151
+ /**
152
+ * Every assistant and tool message the turn added, in order, so the
153
+ * caller can keep the conversation by appending them. It ends with the
154
+ * last answer, or, when the turn ends on the caller's tool calls, with the
155
+ * results of the calls the executor ran from that answer; the caller then
156
+ * adds one tool message for each call in `toolCalls`. Absent
157
+ * from an executor that doesn't report it; the caller then appends the
158
+ * answer itself.
159
+ */
160
+ turn?: ChatMessage[];
161
+ /** What the turn refused, in the order it happened. Absent or empty when it refused nothing. */
162
+ refusals?: ChatTurnRefusal[];
163
+ /** The model aliases skipped before any call, in order. Absent or empty when none was. */
164
+ skipped?: ChatTurnSkip[];
165
+ }
166
+ /** Receives a run's events from {@link RunExecutor.subscribe}. */
167
+ export interface RunEventListener {
168
+ /** One durable event, in order and without gaps. */
169
+ onEvent(event: RunEvent): void;
170
+ /**
171
+ * The stream ended, once and for good. Without an error: the run ended and
172
+ * every event was delivered. With an error: the stream broke (such as a
173
+ * dropped connection), and the caller subscribes again after the last
174
+ * `seq` it saw. Not called when the caller closes the subscription.
175
+ */
176
+ onClose(error?: Error): void;
177
+ }
178
+ /** An open subscription. Closing it twice is not an error. */
179
+ export interface RunSubscription {
180
+ close(): void;
181
+ }
182
+ /** Whether the engine behind a {@link RunExecutor} can be reached. */
183
+ export type EngineConnectionState = "connected" | "lost";
184
+ /**
185
+ * The engine connection of an executor that can lose it, such as the remote
186
+ * one in served mode or on a phone connected to a host. A broken run stream
187
+ * only tells its own subscriber; this tells everyone that the engine as a
188
+ * whole is gone, and when it is back.
189
+ */
190
+ export interface EngineConnection {
191
+ /** The state now. */
192
+ readonly state: EngineConnectionState;
193
+ /**
194
+ * Calls `listener` on each change of state: never twice in a row with the
195
+ * same state, and never before `onChange` returns. Returns a function that
196
+ * stops it; calling that twice is not an error.
197
+ *
198
+ * A listener may throw, as the shell re-throws its features' errors. The
199
+ * executor catches that inside its own loop, reports it and carries on,
200
+ * so one faulty feature can't break its reconnect handling.
201
+ */
202
+ onChange(listener: (state: EngineConnectionState) => void): () => void;
203
+ }
204
+ /**
205
+ * Where runs execute. Replaces the old `Runtime` and `RunHost` ports: the
206
+ * local implementation runs the engine in this process, the remote
207
+ * one forwards to a host such as `halonic serve` or a Worker. It is chosen
208
+ * once at start-up, so no caller asks "local or remote?".
209
+ *
210
+ * A run advances one step per call, from timers, so
211
+ * `start` and `send` return once the input is recorded. The summary they
212
+ * return may still be "running"; follow progress with `subscribe`.
213
+ */
214
+ export interface RunExecutor {
215
+ /** Identifies the implementation, such as "local" or "remote". */
216
+ readonly id: string;
217
+ /**
218
+ * Starts a workflow run, or returns the existing one for a repeated `runId`.
219
+ *
220
+ * @throws RunTargetNotFound when the hub or workflow doesn't exist
221
+ * @throws when the input is refused
222
+ */
223
+ start(request: StartRunRequest): Promise<RunSummary>;
224
+ /**
225
+ * Starts a run of one agent; its workflow id is "agent:<agentId>". A
226
+ * repeated `runId` returns the existing run.
227
+ *
228
+ * @throws RunTargetNotFound when the hub or agent doesn't exist
229
+ */
230
+ startAgent(request: StartAgentRequest): Promise<RunSummary>;
231
+ /**
232
+ * Delivers an event to a waiting run, such as "approve".
233
+ *
234
+ * @throws when the run doesn't exist, doesn't accept the event now, or
235
+ * doesn't wait on the call that `options.callId` names
236
+ */
237
+ send(runId: string, event: string, payload?: unknown, options?: SendOptions): Promise<RunSummary>;
238
+ /**
239
+ * Streams a run's durable events: first the stored ones after `afterSeq`,
240
+ * then new ones as they are appended, until the run ends or the stream
241
+ * breaks (see {@link RunEventListener.onClose}). A client that reconnects
242
+ * passes the last sequence number it saw.
243
+ *
244
+ * It returns at once and never throws for the run itself, because a
245
+ * remote executor only learns later whether the run exists: an unknown
246
+ * run gets `onClose(error)`. The listener is never called before
247
+ * `subscribe` returns, so the caller always holds the handle it may
248
+ * need to `close()`.
249
+ */
250
+ subscribe(runId: string, afterSeq: number, listener: RunEventListener): RunSubscription;
251
+ /**
252
+ * Cancels a run that hasn't ended, as Ctrl C or a Stop button asks: it
253
+ * ends with `run.failed` and `reason: "cancelled"`, and so does the child
254
+ * run it waits on. A run that waits ends too. What the run was doing
255
+ * stops where the executor can stop it; anything it still finishes is
256
+ * recorded nowhere. A run that has already ended is left as it is, so a
257
+ * cancel that comes just after the end is not an error.
258
+ *
259
+ * A remote executor forwards it to the host. Optional, so the port keeps
260
+ * version 1, as for `connection`: a caller without it can only stop
261
+ * following the run.
262
+ *
263
+ * @returns the run's summary after the cancel
264
+ * @throws when the run doesn't exist
265
+ */
266
+ cancel?(runId: string): Promise<RunSummary>;
267
+ /**
268
+ * One chat turn outside any run. Served mode forwards it to the host,
269
+ * which has the provider keys, like a run. `request.signal` may cancel it.
270
+ *
271
+ * A turn may take several model calls. The executor offers the model the
272
+ * caller's `request.tools`, Halonic's own tools and the tools the
273
+ * connected servers list, in that order; when two have the same name, the
274
+ * first is kept and the later one refused. It runs the calls to Halonic's
275
+ * and the servers' tools itself and asks the model again, until the model
276
+ * answers without such calls or the round limit is hit. The messages
277
+ * this adds come back in `turn`.
278
+ *
279
+ * The caller's tools run on the caller's side: when the model calls one,
280
+ * the turn ends with `finishReason: "tool_calls"` and only those calls in
281
+ * `toolCalls`. Calls to the executor's tools in the same answer have
282
+ * already run, and their results are in `turn`. At the round limit the
283
+ * turn ends with `finishReason: "length"` and no calls; the calls the
284
+ * model still asked for are dropped and refused. Anything refused along
285
+ * the way (a listing, a tool, a call) is in `refusals`; a refused call
286
+ * also goes back to the model as that call's result. A tool that throws
287
+ * gives the model an error result, not the caller an error. Nothing
288
+ * outside a run can wait for a person, so a call that needs approval is
289
+ * refused here. A model alias skipped before any call, such as one whose
290
+ * provider has no key, is in `skipped`.
291
+ *
292
+ * @throws when the model can't be reached or refuses the call, or when
293
+ * `request.signal` is aborted and the executor honors it
294
+ */
295
+ chatTurn(request: ChatTurnRequest): Promise<ChatTurnResponse>;
296
+ /**
297
+ * The connection to the engine, for an executor that can lose it. The
298
+ * remote executor sets it from its streams and retries. Absent means
299
+ * always connected: the local executor's engine runs in this process.
300
+ * Optional, so callers check for it and the port keeps version 1.
301
+ */
302
+ readonly connection?: EngineConnection;
303
+ }
@@ -0,0 +1,2 @@
1
+ /** Version of the {@link RunExecutor} port. A breaking change bumps it and comes with an ADR. */
2
+ export const runExecutorVersion = 1;
@@ -0,0 +1,49 @@
1
+ /** Every failure a {@link RunFailureError} can name, in {@link AdapterFailure} order. */
2
+ export declare const adapterFailures: readonly ["disk-full", "sandbox-start-failed", "harness-start-failed"];
3
+ /**
4
+ * The run failure reasons an adapter that isn't a model provider can tell the
5
+ * engine about by throwing a {@link RunFailureError}:
6
+ * - `disk-full`: the disk ran out of space while the run wrote to it.
7
+ * - `sandbox-start-failed`: the sandbox the run needs didn't start.
8
+ * - `harness-start-failed`: the coding agent harness didn't start.
9
+ *
10
+ * A provider says why a model call failed with a `ModelCallError` instead, so
11
+ * the model fallback can read it. The engine decides `budget`, `cancelled`,
12
+ * `interrupted` and `error` itself.
13
+ */
14
+ export type AdapterFailure = (typeof adapterFailures)[number];
15
+ /**
16
+ * An error an adapter that isn't a model provider throws when it knows why a
17
+ * run can't go on, so the engine puts that reason on `run.failed`
18
+ * (requirement `ports.run-failure-error`).
19
+ *
20
+ * The message must be safe to show and to log. Keep the adapter's own text in
21
+ * `cause`, not in the message.
22
+ *
23
+ * Check for it with {@link isRunFailureError}, not `instanceof`: an adapter
24
+ * may be built against its own copy of this package.
25
+ *
26
+ * @example
27
+ * throw new RunFailureError("sandbox-start-failed", "The sandbox didn't start.", { cause });
28
+ */
29
+ export declare class RunFailureError extends Error {
30
+ readonly name = "RunFailureError";
31
+ readonly failure: AdapterFailure;
32
+ /**
33
+ * @param failure - why the run can't go on
34
+ * @param message - safe to show and to log
35
+ * @param options - `cause` keeps the error this one wraps, for the log
36
+ */
37
+ constructor(failure: AdapterFailure, message: string, options?: {
38
+ cause?: unknown;
39
+ });
40
+ }
41
+ /**
42
+ * Whether `value` is a {@link RunFailureError}: an `Error` named
43
+ * "RunFailureError" with one of the known failures. It works across copies
44
+ * of this package, where `instanceof` doesn't.
45
+ *
46
+ * @example
47
+ * const failure = isRunFailureError(error) ? error.failure : "error";
48
+ */
49
+ export declare function isRunFailureError(value: unknown): value is RunFailureError;
@@ -0,0 +1,47 @@
1
+ /** Every failure a {@link RunFailureError} can name, in {@link AdapterFailure} order. */
2
+ export const adapterFailures = [
3
+ "disk-full",
4
+ "sandbox-start-failed",
5
+ "harness-start-failed",
6
+ ];
7
+ /**
8
+ * An error an adapter that isn't a model provider throws when it knows why a
9
+ * run can't go on, so the engine puts that reason on `run.failed`
10
+ * (requirement `ports.run-failure-error`).
11
+ *
12
+ * The message must be safe to show and to log. Keep the adapter's own text in
13
+ * `cause`, not in the message.
14
+ *
15
+ * Check for it with {@link isRunFailureError}, not `instanceof`: an adapter
16
+ * may be built against its own copy of this package.
17
+ *
18
+ * @example
19
+ * throw new RunFailureError("sandbox-start-failed", "The sandbox didn't start.", { cause });
20
+ */
21
+ export class RunFailureError extends Error {
22
+ name = "RunFailureError";
23
+ failure;
24
+ /**
25
+ * @param failure - why the run can't go on
26
+ * @param message - safe to show and to log
27
+ * @param options - `cause` keeps the error this one wraps, for the log
28
+ */
29
+ constructor(failure, message, options) {
30
+ super(message, options);
31
+ this.failure = failure;
32
+ }
33
+ }
34
+ /**
35
+ * Whether `value` is a {@link RunFailureError}: an `Error` named
36
+ * "RunFailureError" with one of the known failures. It works across copies
37
+ * of this package, where `instanceof` doesn't.
38
+ *
39
+ * @example
40
+ * const failure = isRunFailureError(error) ? error.failure : "error";
41
+ */
42
+ export function isRunFailureError(value) {
43
+ if (!(value instanceof Error) || value.name !== "RunFailureError")
44
+ return false;
45
+ const failure = value.failure;
46
+ return adapterFailures.some((known) => known === failure);
47
+ }
@@ -0,0 +1,194 @@
1
+ import { type RunEvent, type RunKind, type RunStatus, type RunSummary } from "../../events/src/index.js";
2
+ /** Version of the {@link RunStore} port. A breaking change bumps it and comes with an ADR. */
3
+ export declare const runStoreVersion = 1;
4
+ /** Which runs {@link RunStore.list} returns. Every field narrows the list; none means all runs. */
5
+ export interface RunFilter {
6
+ hubId?: string;
7
+ workflowId?: string;
8
+ kind?: RunKind;
9
+ /**
10
+ * One status or any of several, such as `["running", "waiting"]` for the
11
+ * watchdog. An empty list is no status filter, the same as leaving it out.
12
+ */
13
+ status?: RunStatus | readonly RunStatus[];
14
+ /**
15
+ * An ISO time: only runs that started at or after it. A store that keeps
16
+ * each run in its own log can then skip a log by its first line, so a
17
+ * month's runs cost a read of that month's logs, not of every log.
18
+ */
19
+ startedSince?: string;
20
+ }
21
+ /**
22
+ * What {@link RunStore.append} did. `lastSeq` is the sequence number of the
23
+ * run's last stored event afterwards, so a writer that lost the race knows
24
+ * where the log is now.
25
+ *
26
+ * A lost race is the error kind `conflict` from `@halonicjs/std`, so a surface
27
+ * that reports it responds the same way as to any other conflict. The ports
28
+ * may not import std (docs/adr/2026-11-09-api-types-stand-alone.md), so the
29
+ * run-store contract in `@halonicjs/testing-contracts` checks that the two
30
+ * stay the same.
31
+ */
32
+ export type AppendResult = {
33
+ ok: true;
34
+ lastSeq: number;
35
+ } | {
36
+ ok: false;
37
+ reason: "conflict";
38
+ lastSeq: number;
39
+ };
40
+ /** Options for {@link RunStore.append}. */
41
+ export interface AppendOptions {
42
+ /**
43
+ * The engine's state after these events, as plain JSON data, so the next
44
+ * step starts from it instead of replaying the whole log. It is a cache:
45
+ * an adapter may store the events and drop the snapshot, and `snapshot()`
46
+ * then gives an older one or `null`.
47
+ */
48
+ snapshot?: unknown;
49
+ }
50
+ /** The latest state snapshot of a run, and the sequence number of the last event it includes. */
51
+ export interface RunSnapshot {
52
+ seq: number;
53
+ state: unknown;
54
+ }
55
+ /**
56
+ * The append-only run event logs and the run list. The log is the truth and
57
+ * the list is a copy of it, worked out with `summarize`
58
+ * from `@halonicjs/events`.
59
+ */
60
+ export interface RunStore {
61
+ /**
62
+ * Appends events to a run's log, but only if its last stored event is
63
+ * `expectedSeq` (0 for a new run), so two writers can never both win.
64
+ * The events are stored together or not at all: an append that fails or
65
+ * gives a conflict stores none of them. Only a crash of the program in the
66
+ * middle of an append may leave the first events stored, in an adapter
67
+ * that writes to disk; its readme says so.
68
+ *
69
+ * @param runId - the run the events belong to; every event carries it too
70
+ * @param expectedSeq - the sequence number of the last event the writer saw
71
+ * @param events - at least one, numbered `expectedSeq + 1`, `expectedSeq + 2` …
72
+ * @returns `ok: false` with reason "conflict" when the log has moved on
73
+ * @throws RangeError when `events` is empty, misnumbered, or carries another
74
+ * run id, or `expectedSeq` isn't a whole number of 0 or more. These are the
75
+ * caller's bugs and are never reported as a conflict.
76
+ */
77
+ append(runId: string, expectedSeq: number, events: readonly RunEvent[], options?: AppendOptions): Promise<AppendResult>;
78
+ /** A run's events, oldest first; with `afterSeq`, only those after it. Empty for an unknown run. */
79
+ events(runId: string, afterSeq?: number): Promise<RunEvent[]>;
80
+ /** The run's latest snapshot, or `null` when it has none or the run is unknown. */
81
+ snapshot(runId: string): Promise<RunSnapshot | null>;
82
+ /** A run's summary, or `null` for an unknown run. Always up to date with the log. */
83
+ get(runId: string): Promise<RunSummary | null>;
84
+ /**
85
+ * The summaries of the runs that match the filter, newest start time first.
86
+ * The list may lag the log for a short time (on Cloudflare it is filled
87
+ * from an outbox); use {@link RunStore.get} when one run must be current.
88
+ */
89
+ list(filter?: RunFilter): Promise<RunSummary[]>;
90
+ }
91
+ /**
92
+ * What a file-system adapter writes into `<runId>.lock`, next to the run's
93
+ * log, while it appends to the run. The Node and Tauri adapters share this
94
+ * format and these rules, so a CLI and a desktop app writing to one
95
+ * workspace exclude each other, and one of them gets `conflict` instead of
96
+ * both winning.
97
+ *
98
+ * - **Taking the lock:** create `<runId>.lock` with an exclusive create that
99
+ * fails when the file is already there (`wx` in Node, `create_new` in
100
+ * Rust), and write this record into it as JSON.
101
+ * - **Appending:** with the lock held, read the log, return `conflict` when
102
+ * its last event isn't `expectedSeq`, otherwise write the events.
103
+ * - **Releasing:** remove the lock file, but only while it still holds the
104
+ * record this writer wrote.
105
+ * - **Waiting:** when the lock is held, try again a few milliseconds later.
106
+ * - **Stale locks:** a crashed writer leaves its lock behind. Another writer
107
+ * may remove it when the lock's `host` is this computer and no process
108
+ * `pid` runs here any more, or when `takenAt` is more than
109
+ * {@link runLockStaleAfterMs} ago. The age limit also covers a process id
110
+ * that was reused, and a lock taken on another computer of a shared
111
+ * folder. A lock file that can't be read as a record (a crash between
112
+ * creating and writing it) counts its age from the file's change time.
113
+ * - **Removing a stale lock:** only one writer removes a lock at a time,
114
+ * the one that creates `<runId>.lock.takeover` with an exclusive create.
115
+ * Holding it, the writer reads the lock again and removes it only while
116
+ * it still holds the same stale text, then removes the takeover file. A
117
+ * lock that isn't stale is never moved or removed. A writer that finds
118
+ * the takeover file there waits and tries again; one older than
119
+ * {@link runLockTakeoverStaleAfterMs} was left by a remover that crashed,
120
+ * and any writer may remove it.
121
+ * - **A link at the lock's path:** when the exclusive create finds the file
122
+ * there but reading it finds none, and the path is a symbolic link to a
123
+ * file that isn't there, fail with an error instead of trying again.
124
+ */
125
+ export interface RunLockRecord {
126
+ /** The format version, {@link runLockFormat}. */
127
+ version: number;
128
+ /** The process id of the writer holding the lock. */
129
+ pid: number;
130
+ /** The host name of the computer the writer runs on. */
131
+ host: string;
132
+ /** When the lock was taken, as an ISO 8601 time in UTC. */
133
+ takenAt: string;
134
+ }
135
+ /** The format version of {@link RunLockRecord} that adapters write today. */
136
+ export declare const runLockFormat = 1;
137
+ /**
138
+ * How old a run lock may get before any writer may remove it. An append holds
139
+ * the lock for milliseconds, so this is far longer than any append takes.
140
+ */
141
+ export declare const runLockStaleAfterMs = 10000;
142
+ /**
143
+ * How old a lock's takeover file may get before any writer may remove it.
144
+ * Removing a stale lock takes milliseconds, and up to 2 seconds a step on
145
+ * Windows while a file is busy, so a takeover file this old was left by a
146
+ * writer that crashed while removing a lock.
147
+ */
148
+ export declare const runLockTakeoverStaleAfterMs = 5000;
149
+ /**
150
+ * Refuses an append that is the caller's bug, as {@link RunStore.append}
151
+ * says: `expectedSeq` that isn't a whole number of 0 or more, no events,
152
+ * an event of another run, or events not numbered from `expectedSeq + 1`.
153
+ *
154
+ * @throws RangeError naming what is wrong
155
+ */
156
+ export declare function checkRunAppend(runId: string, expectedSeq: number, events: readonly RunEvent[]): void;
157
+ /** Whether a summary matches every field of a {@link RunFilter}. An empty status list is no status filter. */
158
+ export declare function matchesRunFilter(summary: RunSummary, filter: RunFilter): boolean;
159
+ /**
160
+ * Whether a run that started at `startedAt` is in a list filtered by
161
+ * `startedSince`. Both are ISO times; they are compared as times, so an
162
+ * offset or a missing fraction of a second doesn't change the answer.
163
+ */
164
+ export declare function startedAtOrAfter(startedAt: string, since: string): boolean;
165
+ /** Orders summaries as {@link RunStore.list} returns them: newest start time first, then by run id. */
166
+ export declare function compareRunSummaries(a: RunSummary, b: RunSummary): number;
167
+ /** Writes events as run log lines: one JSON event per line, each ending in a line break. */
168
+ export declare function formatLogLines(events: readonly RunEvent[]): string;
169
+ /**
170
+ * Reads a run log's whole lines back into events. Every line must hold the
171
+ * run's next event, numbered from 1. Pass only whole lines, each ending in
172
+ * a line break: a torn last line, from a crash, is the adapter's to leave
173
+ * out first.
174
+ *
175
+ * @param lines - the log's whole lines, or `""` for an empty log
176
+ * @param runId - the run the log belongs to
177
+ * @param file - the log's name, for the error message
178
+ * @returns the events, in order
179
+ * @throws Error naming the file and line when a line is broken
180
+ */
181
+ export declare function parseLogLines(lines: string, runId: string, file: string): RunEvent[];
182
+ /**
183
+ * Whether a run id can be a plain file name in the run folder: 1 to 128
184
+ * letters, digits, `_`, `-` or `.`, not starting with a dot, and not a name
185
+ * Windows keeps for a device.
186
+ */
187
+ export declare function isRunId(runId: string): boolean;
188
+ /**
189
+ * Refuses a run id that couldn't be a plain file name in the run folder:
190
+ * `..`, a separator, an absolute path, a name Windows keeps for a device.
191
+ *
192
+ * @throws RangeError naming the run id
193
+ */
194
+ export declare function checkRunId(runId: string): void;