@halonicjs/testing 0.0.0 → 0.1.0

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 (384) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +1 -0
  3. package/README.md +41 -1
  4. package/dist/adapters/http-kit/src/address-class.d.ts +34 -0
  5. package/dist/adapters/http-kit/src/address-class.js +109 -0
  6. package/dist/adapters/http-kit/src/index.d.ts +2 -0
  7. package/dist/adapters/http-kit/src/index.js +2 -0
  8. package/dist/adapters/http-kit/src/ip-address.d.ts +23 -0
  9. package/dist/adapters/http-kit/src/ip-address.js +89 -0
  10. package/dist/adapters/integration-kit/src/declaration.d.ts +14 -0
  11. package/dist/adapters/integration-kit/src/declaration.js +77 -0
  12. package/dist/adapters/integration-kit/src/host.d.ts +28 -0
  13. package/dist/adapters/integration-kit/src/host.js +30 -0
  14. package/dist/adapters/integration-kit/src/index.d.ts +14 -0
  15. package/dist/adapters/integration-kit/src/index.js +21 -0
  16. package/dist/adapters/integration-kit/src/leak-attempt.d.ts +14 -0
  17. package/dist/adapters/integration-kit/src/leak-attempt.js +16 -0
  18. package/dist/adapters/integration-kit/src/limited-http.d.ts +49 -0
  19. package/dist/adapters/integration-kit/src/limited-http.js +182 -0
  20. package/dist/adapters/integration-kit/src/load-problem.d.ts +20 -0
  21. package/dist/adapters/integration-kit/src/load-problem.js +1 -0
  22. package/dist/adapters/integration-kit/src/loader.d.ts +104 -0
  23. package/dist/adapters/integration-kit/src/loader.js +219 -0
  24. package/dist/adapters/integration-kit/src/local-address.d.ts +15 -0
  25. package/dist/adapters/integration-kit/src/local-address.js +25 -0
  26. package/dist/adapters/integration-kit/src/own-request.d.ts +33 -0
  27. package/dist/adapters/integration-kit/src/own-request.js +36 -0
  28. package/dist/adapters/integration-kit/src/plugin-load.d.ts +14 -0
  29. package/dist/adapters/integration-kit/src/plugin-load.js +58 -0
  30. package/dist/adapters/integration-kit/src/policy.d.ts +55 -0
  31. package/dist/adapters/integration-kit/src/policy.js +37 -0
  32. package/dist/adapters/integration-kit/src/request-body.d.ts +38 -0
  33. package/dist/adapters/integration-kit/src/request-body.js +68 -0
  34. package/dist/adapters/integration-kit/src/request-log.d.ts +25 -0
  35. package/dist/adapters/integration-kit/src/request-log.js +17 -0
  36. package/dist/adapters/integration-kit/src/response-body.d.ts +23 -0
  37. package/dist/adapters/integration-kit/src/response-body.js +117 -0
  38. package/dist/adapters/integration-kit/src/scoped-tokens.d.ts +14 -0
  39. package/dist/adapters/integration-kit/src/scoped-tokens.js +27 -0
  40. package/dist/adapters/integration-kit/src/secret-filter.d.ts +84 -0
  41. package/dist/adapters/integration-kit/src/secret-filter.js +205 -0
  42. package/dist/adapters/integration-kit/src/secret-in-request.d.ts +59 -0
  43. package/dist/adapters/integration-kit/src/secret-in-request.js +133 -0
  44. package/dist/adapters/integration-kit/src/secret-placement.d.ts +36 -0
  45. package/dist/adapters/integration-kit/src/secret-placement.js +190 -0
  46. package/dist/adapters/integration-kit/src/wait.d.ts +16 -0
  47. package/dist/adapters/integration-kit/src/wait.js +35 -0
  48. package/dist/core/events/src/add-usage.d.ts +10 -0
  49. package/dist/core/events/src/add-usage.js +27 -0
  50. package/dist/core/events/src/agent-resume.d.ts +24 -0
  51. package/dist/core/events/src/agent-resume.js +1 -0
  52. package/dist/core/events/src/home-path.d.ts +13 -0
  53. package/dist/core/events/src/home-path.js +26 -0
  54. package/dist/core/events/src/index.d.ts +13 -0
  55. package/dist/core/events/src/index.js +7 -0
  56. package/dist/core/events/src/run-basics.d.ts +205 -0
  57. package/dist/core/events/src/run-basics.js +1 -0
  58. package/dist/core/events/src/run-event.d.ts +434 -0
  59. package/dist/core/events/src/run-event.js +1 -0
  60. package/dist/core/events/src/run-summary.d.ts +108 -0
  61. package/dist/core/events/src/run-summary.js +1 -0
  62. package/dist/core/events/src/sandbox-blocked.d.ts +42 -0
  63. package/dist/core/events/src/sandbox-blocked.js +26 -0
  64. package/dist/core/events/src/sandbox-opened-read.d.ts +17 -0
  65. package/dist/core/events/src/sandbox-opened-read.js +63 -0
  66. package/dist/core/events/src/sandbox-opened.d.ts +94 -0
  67. package/dist/core/events/src/sandbox-opened.js +52 -0
  68. package/dist/core/events/src/summarize.d.ts +14 -0
  69. package/dist/core/events/src/summarize.js +188 -0
  70. package/dist/core/events/src/timeline-entry.d.ts +21 -0
  71. package/dist/core/events/src/timeline-entry.js +105 -0
  72. package/dist/core/events/src/upgrade.d.ts +23 -0
  73. package/dist/core/events/src/upgrade.js +49 -0
  74. package/dist/core/format/src/compact.d.ts +30 -0
  75. package/dist/core/format/src/compact.js +72 -0
  76. package/dist/core/format/src/index.d.ts +37 -0
  77. package/dist/core/format/src/index.js +23 -0
  78. package/dist/core/format/src/integration/index.d.ts +6 -0
  79. package/dist/core/format/src/integration/index.js +9 -0
  80. package/dist/core/format/src/json-schema.d.ts +26 -0
  81. package/dist/core/format/src/json-schema.js +48 -0
  82. package/dist/core/format/src/kind.d.ts +65 -0
  83. package/dist/core/format/src/kind.js +1 -0
  84. package/dist/core/format/src/kinds/agent/kind.d.ts +4 -0
  85. package/dist/core/format/src/kinds/agent/kind.js +10 -0
  86. package/dist/core/format/src/kinds/agent/sandbox-fields.d.ts +89 -0
  87. package/dist/core/format/src/kinds/agent/sandbox-fields.js +197 -0
  88. package/dist/core/format/src/kinds/agent/schema.d.ts +147 -0
  89. package/dist/core/format/src/kinds/agent/schema.js +107 -0
  90. package/dist/core/format/src/kinds/agent/working-folder-start.d.ts +74 -0
  91. package/dist/core/format/src/kinds/agent/working-folder-start.js +312 -0
  92. package/dist/core/format/src/kinds/collection/kind.d.ts +8 -0
  93. package/dist/core/format/src/kinds/collection/kind.js +14 -0
  94. package/dist/core/format/src/kinds/collection/schema.d.ts +89 -0
  95. package/dist/core/format/src/kinds/collection/schema.js +90 -0
  96. package/dist/core/format/src/kinds/connector/is-local.d.ts +10 -0
  97. package/dist/core/format/src/kinds/connector/is-local.js +43 -0
  98. package/dist/core/format/src/kinds/connector/kind.d.ts +4 -0
  99. package/dist/core/format/src/kinds/connector/kind.js +119 -0
  100. package/dist/core/format/src/kinds/connector/schema.d.ts +50 -0
  101. package/dist/core/format/src/kinds/connector/schema.js +92 -0
  102. package/dist/core/format/src/kinds/deployments/kind.d.ts +4 -0
  103. package/dist/core/format/src/kinds/deployments/kind.js +25 -0
  104. package/dist/core/format/src/kinds/deployments/schema.d.ts +37 -0
  105. package/dist/core/format/src/kinds/deployments/schema.js +42 -0
  106. package/dist/core/format/src/kinds/hub/kind.d.ts +4 -0
  107. package/dist/core/format/src/kinds/hub/kind.js +10 -0
  108. package/dist/core/format/src/kinds/hub/schema.d.ts +54 -0
  109. package/dist/core/format/src/kinds/hub/schema.js +34 -0
  110. package/dist/core/format/src/kinds/integration/kind.d.ts +16 -0
  111. package/dist/core/format/src/kinds/integration/kind.js +138 -0
  112. package/dist/core/format/src/kinds/integration/parse-sheet.d.ts +19 -0
  113. package/dist/core/format/src/kinds/integration/parse-sheet.js +24 -0
  114. package/dist/core/format/src/kinds/integration/policy.d.ts +67 -0
  115. package/dist/core/format/src/kinds/integration/policy.js +268 -0
  116. package/dist/core/format/src/kinds/integration/schema.d.ts +233 -0
  117. package/dist/core/format/src/kinds/integration/schema.js +233 -0
  118. package/dist/core/format/src/kinds/knowledge/kind.d.ts +4 -0
  119. package/dist/core/format/src/kinds/knowledge/kind.js +13 -0
  120. package/dist/core/format/src/kinds/knowledge/schema.d.ts +18 -0
  121. package/dist/core/format/src/kinds/knowledge/schema.js +25 -0
  122. package/dist/core/format/src/kinds/models/kind.d.ts +4 -0
  123. package/dist/core/format/src/kinds/models/kind.js +10 -0
  124. package/dist/core/format/src/kinds/models/schema.d.ts +92 -0
  125. package/dist/core/format/src/kinds/models/schema.js +38 -0
  126. package/dist/core/format/src/kinds/plugin/backend.d.ts +22 -0
  127. package/dist/core/format/src/kinds/plugin/backend.js +31 -0
  128. package/dist/core/format/src/kinds/plugin/checks.d.ts +13 -0
  129. package/dist/core/format/src/kinds/plugin/checks.js +131 -0
  130. package/dist/core/format/src/kinds/plugin/kind.d.ts +8 -0
  131. package/dist/core/format/src/kinds/plugin/kind.js +16 -0
  132. package/dist/core/format/src/kinds/plugin/problems.d.ts +24 -0
  133. package/dist/core/format/src/kinds/plugin/problems.js +65 -0
  134. package/dist/core/format/src/kinds/plugin/schema.d.ts +542 -0
  135. package/dist/core/format/src/kinds/plugin/schema.js +261 -0
  136. package/dist/core/format/src/kinds/plugin/setting-values.d.ts +17 -0
  137. package/dist/core/format/src/kinds/plugin/setting-values.js +38 -0
  138. package/dist/core/format/src/kinds/plugin/ui-checks.d.ts +8 -0
  139. package/dist/core/format/src/kinds/plugin/ui-checks.js +94 -0
  140. package/dist/core/format/src/kinds/provider/kind.d.ts +4 -0
  141. package/dist/core/format/src/kinds/provider/kind.js +24 -0
  142. package/dist/core/format/src/kinds/provider/schema.d.ts +17 -0
  143. package/dist/core/format/src/kinds/provider/schema.js +22 -0
  144. package/dist/core/format/src/kinds/routine/kind.d.ts +8 -0
  145. package/dist/core/format/src/kinds/routine/kind.js +25 -0
  146. package/dist/core/format/src/kinds/routine/schema.d.ts +84 -0
  147. package/dist/core/format/src/kinds/routine/schema.js +93 -0
  148. package/dist/core/format/src/kinds/runtime/kind.d.ts +4 -0
  149. package/dist/core/format/src/kinds/runtime/kind.js +13 -0
  150. package/dist/core/format/src/kinds/runtime/schema.d.ts +10 -0
  151. package/dist/core/format/src/kinds/runtime/schema.js +12 -0
  152. package/dist/core/format/src/kinds/skill/kind.d.ts +4 -0
  153. package/dist/core/format/src/kinds/skill/kind.js +10 -0
  154. package/dist/core/format/src/kinds/skill/schema.d.ts +17 -0
  155. package/dist/core/format/src/kinds/skill/schema.js +17 -0
  156. package/dist/core/format/src/kinds/skill/scripts-folder.d.ts +27 -0
  157. package/dist/core/format/src/kinds/skill/scripts-folder.js +37 -0
  158. package/dist/core/format/src/kinds/workflow/kind.d.ts +8 -0
  159. package/dist/core/format/src/kinds/workflow/kind.js +14 -0
  160. package/dist/core/format/src/kinds/workflow/schema.d.ts +162 -0
  161. package/dist/core/format/src/kinds/workflow/schema.js +106 -0
  162. package/dist/core/format/src/kinds/workflow-test/kind.d.ts +4 -0
  163. package/dist/core/format/src/kinds/workflow-test/kind.js +14 -0
  164. package/dist/core/format/src/kinds/workflow-test/schema.d.ts +67 -0
  165. package/dist/core/format/src/kinds/workflow-test/schema.js +59 -0
  166. package/dist/core/format/src/kinds/workspace/kind.d.ts +4 -0
  167. package/dist/core/format/src/kinds/workspace/kind.js +10 -0
  168. package/dist/core/format/src/kinds/workspace/schema.d.ts +72 -0
  169. package/dist/core/format/src/kinds/workspace/schema.js +66 -0
  170. package/dist/core/format/src/parse-file.d.ts +69 -0
  171. package/dist/core/format/src/parse-file.js +105 -0
  172. package/dist/core/format/src/recording/format.d.ts +81 -0
  173. package/dist/core/format/src/recording/format.js +102 -0
  174. package/dist/core/format/src/recording/index.d.ts +1 -0
  175. package/dist/core/format/src/recording/index.js +3 -0
  176. package/dist/core/format/src/registry.d.ts +64 -0
  177. package/dist/core/format/src/registry.js +61 -0
  178. package/dist/core/format/src/reserved.d.ts +20 -0
  179. package/dist/core/format/src/reserved.js +30 -0
  180. package/dist/core/format/src/shared/fields.d.ts +37 -0
  181. package/dist/core/format/src/shared/fields.js +54 -0
  182. package/dist/core/format/src/shared/guard.d.ts +32 -0
  183. package/dist/core/format/src/shared/guard.js +16 -0
  184. package/dist/core/format/src/shared/key-in-value.d.ts +28 -0
  185. package/dist/core/format/src/shared/key-in-value.js +82 -0
  186. package/dist/core/format/src/shared/legacy-keys.d.ts +8 -0
  187. package/dist/core/format/src/shared/legacy-keys.js +17 -0
  188. package/dist/core/format/src/shared/program-start.d.ts +60 -0
  189. package/dist/core/format/src/shared/program-start.js +99 -0
  190. package/dist/core/format/src/shared/relative-path.d.ts +29 -0
  191. package/dist/core/format/src/shared/relative-path.js +50 -0
  192. package/dist/core/format/src/shared/secret-name.d.ts +24 -0
  193. package/dist/core/format/src/shared/secret-name.js +107 -0
  194. package/dist/core/format/src/source.d.ts +16 -0
  195. package/dist/core/format/src/source.js +73 -0
  196. package/dist/core/ports/src/agent-placement-store.d.ts +74 -0
  197. package/dist/core/ports/src/agent-placement-store.js +27 -0
  198. package/dist/core/ports/src/blob-store.d.ts +33 -0
  199. package/dist/core/ports/src/blob-store.js +2 -0
  200. package/dist/core/ports/src/cant-try-error.d.ts +35 -0
  201. package/dist/core/ports/src/cant-try-error.js +44 -0
  202. package/dist/core/ports/src/chat.d.ts +127 -0
  203. package/dist/core/ports/src/chat.js +1 -0
  204. package/dist/core/ports/src/clock.d.ts +7 -0
  205. package/dist/core/ports/src/clock.js +2 -0
  206. package/dist/core/ports/src/connection-settings-store.d.ts +57 -0
  207. package/dist/core/ports/src/connection-settings-store.js +2 -0
  208. package/dist/core/ports/src/connector-client.d.ts +259 -0
  209. package/dist/core/ports/src/connector-client.js +2 -0
  210. package/dist/core/ports/src/coordination.d.ts +84 -0
  211. package/dist/core/ports/src/coordination.js +2 -0
  212. package/dist/core/ports/src/definition-store.d.ts +208 -0
  213. package/dist/core/ports/src/definition-store.js +122 -0
  214. package/dist/core/ports/src/digest.d.ts +14 -0
  215. package/dist/core/ports/src/digest.js +2 -0
  216. package/dist/core/ports/src/folder-reader.d.ts +89 -0
  217. package/dist/core/ports/src/folder-reader.js +2 -0
  218. package/dist/core/ports/src/harness-bridge-server.d.ts +189 -0
  219. package/dist/core/ports/src/harness-bridge-server.js +37 -0
  220. package/dist/core/ports/src/harness.d.ts +250 -0
  221. package/dist/core/ports/src/harness.js +45 -0
  222. package/dist/core/ports/src/http-client.d.ts +27 -0
  223. package/dist/core/ports/src/http-client.js +2 -0
  224. package/dist/core/ports/src/id-generator.d.ts +14 -0
  225. package/dist/core/ports/src/id-generator.js +2 -0
  226. package/dist/core/ports/src/index.d.ts +37 -0
  227. package/dist/core/ports/src/index.js +36 -0
  228. package/dist/core/ports/src/integration.d.ts +178 -0
  229. package/dist/core/ports/src/integration.js +13 -0
  230. package/dist/core/ports/src/knowledge-provider.d.ts +65 -0
  231. package/dist/core/ports/src/knowledge-provider.js +2 -0
  232. package/dist/core/ports/src/llm-cache.d.ts +13 -0
  233. package/dist/core/ports/src/llm-cache.js +2 -0
  234. package/dist/core/ports/src/llm-provider.d.ts +184 -0
  235. package/dist/core/ports/src/llm-provider.js +136 -0
  236. package/dist/core/ports/src/model-price.d.ts +34 -0
  237. package/dist/core/ports/src/model-price.js +25 -0
  238. package/dist/core/ports/src/password-hasher.d.ts +47 -0
  239. package/dist/core/ports/src/password-hasher.js +2 -0
  240. package/dist/core/ports/src/plugin-folder-writer.d.ts +104 -0
  241. package/dist/core/ports/src/plugin-folder-writer.js +95 -0
  242. package/dist/core/ports/src/port-versions.d.ts +44 -0
  243. package/dist/core/ports/src/port-versions.js +74 -0
  244. package/dist/core/ports/src/program-probe.d.ts +46 -0
  245. package/dist/core/ports/src/program-probe.js +2 -0
  246. package/dist/core/ports/src/record-store.d.ts +62 -0
  247. package/dist/core/ports/src/record-store.js +38 -0
  248. package/dist/core/ports/src/resource-probe.d.ts +59 -0
  249. package/dist/core/ports/src/resource-probe.js +2 -0
  250. package/dist/core/ports/src/run-executor.d.ts +302 -0
  251. package/dist/core/ports/src/run-executor.js +2 -0
  252. package/dist/core/ports/src/run-failure-error.d.ts +49 -0
  253. package/dist/core/ports/src/run-failure-error.js +47 -0
  254. package/dist/core/ports/src/run-store.d.ts +194 -0
  255. package/dist/core/ports/src/run-store.js +131 -0
  256. package/dist/core/ports/src/sandbox.d.ts +247 -0
  257. package/dist/core/ports/src/sandbox.js +34 -0
  258. package/dist/core/ports/src/scheduler.d.ts +85 -0
  259. package/dist/core/ports/src/scheduler.js +2 -0
  260. package/dist/core/ports/src/secrets.d.ts +128 -0
  261. package/dist/core/ports/src/secrets.js +144 -0
  262. package/dist/core/ports/src/token-store.d.ts +19 -0
  263. package/dist/core/ports/src/token-store.js +2 -0
  264. package/dist/core/ports/src/tool-approval-store.d.ts +211 -0
  265. package/dist/core/ports/src/tool-approval-store.js +57 -0
  266. package/dist/core/ports/src/trust-store.d.ts +72 -0
  267. package/dist/core/ports/src/trust-store.js +2 -0
  268. package/dist/core/ports/src/unfenced-run-consent-store.d.ts +43 -0
  269. package/dist/core/ports/src/unfenced-run-consent-store.js +2 -0
  270. package/dist/core/ports/src/vcs.d.ts +394 -0
  271. package/dist/core/ports/src/vcs.js +48 -0
  272. package/dist/core/schema-kit/src/builders.d.ts +50 -0
  273. package/dist/core/schema-kit/src/builders.js +72 -0
  274. package/dist/core/schema-kit/src/depth.d.ts +15 -0
  275. package/dist/core/schema-kit/src/depth.js +37 -0
  276. package/dist/core/schema-kit/src/index.d.ts +6 -0
  277. package/dist/core/schema-kit/src/index.js +6 -0
  278. package/dist/core/schema-kit/src/issue.d.ts +22 -0
  279. package/dist/core/schema-kit/src/issue.js +23 -0
  280. package/dist/core/schema-kit/src/json-schema.d.ts +23 -0
  281. package/dist/core/schema-kit/src/json-schema.js +22 -0
  282. package/dist/core/schema-kit/src/parse.d.ts +17 -0
  283. package/dist/core/schema-kit/src/parse.js +25 -0
  284. package/dist/core/schema-kit/src/schema.d.ts +12 -0
  285. package/dist/core/schema-kit/src/schema.js +1 -0
  286. package/dist/core/std/src/ascii-host.d.ts +18 -0
  287. package/dist/core/std/src/ascii-host.js +110 -0
  288. package/dist/core/std/src/assert.d.ts +39 -0
  289. package/dist/core/std/src/assert.js +59 -0
  290. package/dist/core/std/src/base64url.d.ts +23 -0
  291. package/dist/core/std/src/base64url.js +65 -0
  292. package/dist/core/std/src/canonical-json.d.ts +18 -0
  293. package/dist/core/std/src/canonical-json.js +56 -0
  294. package/dist/core/std/src/clock.d.ts +27 -0
  295. package/dist/core/std/src/clock.js +33 -0
  296. package/dist/core/std/src/constant-time.d.ts +16 -0
  297. package/dist/core/std/src/constant-time.js +26 -0
  298. package/dist/core/std/src/content-digest.d.ts +24 -0
  299. package/dist/core/std/src/content-digest.js +28 -0
  300. package/dist/core/std/src/deep-clone.d.ts +15 -0
  301. package/dist/core/std/src/deep-clone.js +59 -0
  302. package/dist/core/std/src/deep-equal.d.ts +23 -0
  303. package/dist/core/std/src/deep-equal.js +64 -0
  304. package/dist/core/std/src/emitter.d.ts +42 -0
  305. package/dist/core/std/src/emitter.js +74 -0
  306. package/dist/core/std/src/error-kind.d.ts +88 -0
  307. package/dist/core/std/src/error-kind.js +98 -0
  308. package/dist/core/std/src/hex.d.ts +10 -0
  309. package/dist/core/std/src/hex.js +16 -0
  310. package/dist/core/std/src/ids.d.ts +45 -0
  311. package/dist/core/std/src/ids.js +49 -0
  312. package/dist/core/std/src/index.d.ts +25 -0
  313. package/dist/core/std/src/index.js +26 -0
  314. package/dist/core/std/src/keyed-queue.d.ts +18 -0
  315. package/dist/core/std/src/keyed-queue.js +32 -0
  316. package/dist/core/std/src/line-diff.d.ts +83 -0
  317. package/dist/core/std/src/line-diff.js +179 -0
  318. package/dist/core/std/src/line-merge.d.ts +63 -0
  319. package/dist/core/std/src/line-merge.js +138 -0
  320. package/dist/core/std/src/plain-data.d.ts +32 -0
  321. package/dist/core/std/src/plain-data.js +57 -0
  322. package/dist/core/std/src/posix-path.d.ts +61 -0
  323. package/dist/core/std/src/posix-path.js +121 -0
  324. package/dist/core/std/src/result.d.ts +55 -0
  325. package/dist/core/std/src/result.js +52 -0
  326. package/dist/core/std/src/secret-scrubber.d.ts +54 -0
  327. package/dist/core/std/src/secret-scrubber.js +124 -0
  328. package/dist/core/std/src/secret-shape.d.ts +20 -0
  329. package/dist/core/std/src/secret-shape.js +53 -0
  330. package/dist/core/std/src/stop-signal.d.ts +44 -0
  331. package/dist/core/std/src/stop-signal.js +77 -0
  332. package/dist/core/std/src/text.d.ts +28 -0
  333. package/dist/core/std/src/text.js +54 -0
  334. package/dist/core/std/src/utf8.d.ts +23 -0
  335. package/dist/core/std/src/utf8.js +110 -0
  336. package/dist/core/std/src/version.d.ts +48 -0
  337. package/dist/core/std/src/version.js +103 -0
  338. package/dist/core/yaml/src/depth.d.ts +14 -0
  339. package/dist/core/yaml/src/depth.js +140 -0
  340. package/dist/core/yaml/src/edit-data.d.ts +47 -0
  341. package/dist/core/yaml/src/edit-data.js +286 -0
  342. package/dist/core/yaml/src/edit-text.d.ts +92 -0
  343. package/dist/core/yaml/src/edit-text.js +267 -0
  344. package/dist/core/yaml/src/edit.d.ts +47 -0
  345. package/dist/core/yaml/src/edit.js +198 -0
  346. package/dist/core/yaml/src/index.d.ts +5 -0
  347. package/dist/core/yaml/src/index.js +4 -0
  348. package/dist/core/yaml/src/problem.d.ts +20 -0
  349. package/dist/core/yaml/src/problem.js +1 -0
  350. package/dist/core/yaml/src/read.d.ts +47 -0
  351. package/dist/core/yaml/src/read.js +130 -0
  352. package/dist/core/yaml/src/splice-node.d.ts +47 -0
  353. package/dist/core/yaml/src/splice-node.js +333 -0
  354. package/dist/core/yaml/src/splice.d.ts +13 -0
  355. package/dist/core/yaml/src/splice.js +174 -0
  356. package/dist/core/yaml/src/unsupported.d.ts +26 -0
  357. package/dist/core/yaml/src/unsupported.js +70 -0
  358. package/dist/core/yaml/src/write.d.ts +35 -0
  359. package/dist/core/yaml/src/write.js +44 -0
  360. package/dist/testing/integration/src/canaries.d.ts +14 -0
  361. package/dist/testing/integration/src/canaries.js +17 -0
  362. package/dist/testing/integration/src/checks.d.ts +37 -0
  363. package/dist/testing/integration/src/checks.js +195 -0
  364. package/dist/testing/integration/src/describe.d.ts +35 -0
  365. package/dist/testing/integration/src/describe.js +74 -0
  366. package/dist/testing/integration/src/failure.d.ts +6 -0
  367. package/dist/testing/integration/src/failure.js +8 -0
  368. package/dist/testing/integration/src/fake-wait.d.ts +18 -0
  369. package/dist/testing/integration/src/fake-wait.js +21 -0
  370. package/dist/testing/integration/src/index.d.ts +10 -0
  371. package/dist/testing/integration/src/index.js +11 -0
  372. package/dist/testing/integration/src/load.d.ts +14 -0
  373. package/dist/testing/integration/src/load.js +45 -0
  374. package/dist/testing/integration/src/plugin-folder.d.ts +23 -0
  375. package/dist/testing/integration/src/plugin-folder.js +59 -0
  376. package/dist/testing/integration/src/plugin.d.ts +32 -0
  377. package/dist/testing/integration/src/plugin.js +57 -0
  378. package/dist/testing/integration/src/recording.d.ts +84 -0
  379. package/dist/testing/integration/src/recording.js +164 -0
  380. package/dist/testing/integration/src/run.d.ts +60 -0
  381. package/dist/testing/integration/src/run.js +81 -0
  382. package/dist/testing/integration/src/source-scan.d.ts +16 -0
  383. package/dist/testing/integration/src/source-scan.js +40 -0
  384. package/package.json +34 -3
@@ -0,0 +1,56 @@
1
+ import { describeObject, isPlainObject, keyPath } from "./plain-data.js";
2
+ /**
3
+ * Writes plain data as JSON in one canonical form, so equal data always
4
+ * gives the same text and can be hashed: object keys sorted by code unit,
5
+ * arrays kept in order, no spaces. As with `JSON.stringify`, an object key
6
+ * whose value is `undefined` is left out.
7
+ *
8
+ * It throws instead of writing something lossy: a number that isn't finite,
9
+ * `undefined` in an array, or a value JSON can't hold, such as a `Map`, a
10
+ * `Date`, a function or a bigint.
11
+ *
12
+ * @param value - plain data: objects, arrays, strings, finite numbers, booleans and `null`
13
+ * @returns the canonical JSON text
14
+ * @throws when the data isn't plain JSON data, saying where
15
+ *
16
+ * @example
17
+ * canonicalJson({ b: [2, 1], a: "x" }); // '{"a":"x","b":[2,1]}'
18
+ */
19
+ export function canonicalJson(value) {
20
+ return write(value, "value");
21
+ }
22
+ function write(value, path) {
23
+ if (value === null || typeof value === "boolean" || typeof value === "string") {
24
+ return JSON.stringify(value);
25
+ }
26
+ if (typeof value === "number") {
27
+ if (!Number.isFinite(value)) {
28
+ throw new TypeError(`Can't write ${path} as JSON: ${value} isn't a finite number.`);
29
+ }
30
+ return JSON.stringify(value);
31
+ }
32
+ if (Array.isArray(value)) {
33
+ const items = value.map((item, index) => {
34
+ if (item === undefined) {
35
+ throw new TypeError(`Can't write ${path}[${index}] as JSON: it is undefined.`);
36
+ }
37
+ return write(item, `${path}[${index}]`);
38
+ });
39
+ return `[${items.join(",")}]`;
40
+ }
41
+ if (isPlainObject(value)) {
42
+ const keys = Object.keys(value)
43
+ .filter((key) => value[key] !== undefined)
44
+ .sort(byCodeUnit);
45
+ const entries = keys.map((key) => `${JSON.stringify(key)}:${write(value[key], keyPath(path, key))}`);
46
+ return `{${entries.join(",")}}`;
47
+ }
48
+ const kind = typeof value === "object" ? describeObject(value) : `a ${typeof value}`;
49
+ throw new TypeError(`Can't write ${path} as JSON: it is ${kind}.`);
50
+ }
51
+ function byCodeUnit(left, right) {
52
+ if (left === right) {
53
+ return 0;
54
+ }
55
+ return left < right ? -1 : 1;
56
+ }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Tells the current time. Code that needs the time takes a `Clock`, so tests
3
+ * can pass a fixed one and get the same output on every run.
4
+ */
5
+ export interface Clock {
6
+ /** The current time. */
7
+ now(): Date;
8
+ }
9
+ /** The real clock: the time of the machine it runs on. */
10
+ export declare const systemClock: Clock;
11
+ /** The start of `fixedClock` when no start is given: 2026-01-01T00:00:00Z. */
12
+ export declare const fixedClockStart: number;
13
+ /**
14
+ * A clock for tests. The first call returns `start`, and every later call
15
+ * returns a time `stepMs` later than the call before.
16
+ *
17
+ * @param start - the first time, in milliseconds since 1970 (default 2026-01-01T00:00:00Z)
18
+ * @param stepMs - how far the clock moves on per call, zero or more (default 1000)
19
+ * @returns a new clock with its own position
20
+ * @throws AssertionError when `start` or `stepMs` isn't a valid number of milliseconds
21
+ *
22
+ * @example
23
+ * const clock = fixedClock();
24
+ * clock.now().toISOString(); // "2026-01-01T00:00:00.000Z"
25
+ * clock.now().toISOString(); // "2026-01-01T00:00:01.000Z"
26
+ */
27
+ export declare function fixedClock(start?: number, stepMs?: number): Clock;
@@ -0,0 +1,33 @@
1
+ import { assert } from "./assert.js";
2
+ /** The real clock: the time of the machine it runs on. */
3
+ export const systemClock = {
4
+ now: () => new Date(),
5
+ };
6
+ /** The start of `fixedClock` when no start is given: 2026-01-01T00:00:00Z. */
7
+ export const fixedClockStart = Date.UTC(2026, 0, 1);
8
+ /**
9
+ * A clock for tests. The first call returns `start`, and every later call
10
+ * returns a time `stepMs` later than the call before.
11
+ *
12
+ * @param start - the first time, in milliseconds since 1970 (default 2026-01-01T00:00:00Z)
13
+ * @param stepMs - how far the clock moves on per call, zero or more (default 1000)
14
+ * @returns a new clock with its own position
15
+ * @throws AssertionError when `start` or `stepMs` isn't a valid number of milliseconds
16
+ *
17
+ * @example
18
+ * const clock = fixedClock();
19
+ * clock.now().toISOString(); // "2026-01-01T00:00:00.000Z"
20
+ * clock.now().toISOString(); // "2026-01-01T00:00:01.000Z"
21
+ */
22
+ export function fixedClock(start = fixedClockStart, stepMs = 1000) {
23
+ assert(Number.isFinite(start), `fixedClock needs a finite start time, got ${start}.`);
24
+ assert(Number.isFinite(stepMs) && stepMs >= 0, `fixedClock needs a step of zero or more milliseconds, got ${stepMs}.`);
25
+ let current = start;
26
+ return {
27
+ now() {
28
+ const time = new Date(current);
29
+ current += stepMs;
30
+ return time;
31
+ },
32
+ };
33
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Compares two byte arrays in time that depends only on their length, never
3
+ * on where they first differ. Use it to check password hashes and tokens, so
4
+ * an attacker can't learn a secret from how long a comparison takes.
5
+ *
6
+ * Arrays of different lengths are unequal at once: lengths aren't secret
7
+ * here, because hashes and tokens have a fixed length.
8
+ *
9
+ * @param first - the first bytes
10
+ * @param second - the second bytes
11
+ * @returns true when both hold the same bytes
12
+ *
13
+ * @example
14
+ * constantTimeEqual(storedHash, await hasher.hash(password, salt)); // true or false
15
+ */
16
+ export declare function constantTimeEqual(first: Uint8Array, second: Uint8Array): boolean;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Compares two byte arrays in time that depends only on their length, never
3
+ * on where they first differ. Use it to check password hashes and tokens, so
4
+ * an attacker can't learn a secret from how long a comparison takes.
5
+ *
6
+ * Arrays of different lengths are unequal at once: lengths aren't secret
7
+ * here, because hashes and tokens have a fixed length.
8
+ *
9
+ * @param first - the first bytes
10
+ * @param second - the second bytes
11
+ * @returns true when both hold the same bytes
12
+ *
13
+ * @example
14
+ * constantTimeEqual(storedHash, await hasher.hash(password, salt)); // true or false
15
+ */
16
+ export function constantTimeEqual(first, second) {
17
+ if (first.length !== second.length) {
18
+ return false;
19
+ }
20
+ let difference = 0;
21
+ for (let index = 0; index < first.length; index++) {
22
+ // No early exit: every byte is compared, and differences pile up in one number.
23
+ difference |= (first[index] ?? 0) ^ (second[index] ?? 0);
24
+ }
25
+ return difference === 0;
26
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Anything that hashes bytes with SHA-256, such as the `Digest` port. The
3
+ * core has no hash code of its own, so the caller passes one in.
4
+ */
5
+ export interface Sha256 {
6
+ /** The 32-byte SHA-256 of the bytes. */
7
+ sha256(data: Uint8Array): Promise<Uint8Array>;
8
+ }
9
+ /**
10
+ * The digest of a workspace file's text, as `DefinitionStore.write` expects
11
+ * it: `sha256:` and the 64 lowercase hex characters of the SHA-256 of the
12
+ * text's UTF-8 bytes.
13
+ *
14
+ * @example
15
+ * await contentDigest("hello", digest);
16
+ * // "sha256:2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824"
17
+ */
18
+ export declare function contentDigest(content: string, digest: Sha256): Promise<`sha256:${string}`>;
19
+ /**
20
+ * Whether a file's text, or `null` when there is no file, is what a caller
21
+ * expects: the {@link contentDigest} of the text it last read, or `"absent"`
22
+ * for no file. Every store calls this before a write with `expected`.
23
+ */
24
+ export declare function matchesExpected(current: string | null, expected: string, digest: Sha256): Promise<boolean>;
@@ -0,0 +1,28 @@
1
+ // The digest the `DefinitionStore` port's write-if-unchanged check compares.
2
+ // It lives here, not in `@halonicjs/ports`, because the ports package uses no
3
+ // other package and the core has no `TextEncoder`.
4
+ import { bytesToHex } from "./hex.js";
5
+ import { encodeUtf8 } from "./utf8.js";
6
+ /**
7
+ * The digest of a workspace file's text, as `DefinitionStore.write` expects
8
+ * it: `sha256:` and the 64 lowercase hex characters of the SHA-256 of the
9
+ * text's UTF-8 bytes.
10
+ *
11
+ * @example
12
+ * await contentDigest("hello", digest);
13
+ * // "sha256:2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824"
14
+ */
15
+ export async function contentDigest(content, digest) {
16
+ return `sha256:${bytesToHex(await digest.sha256(encodeUtf8(content)))}`;
17
+ }
18
+ /**
19
+ * Whether a file's text, or `null` when there is no file, is what a caller
20
+ * expects: the {@link contentDigest} of the text it last read, or `"absent"`
21
+ * for no file. Every store calls this before a write with `expected`.
22
+ */
23
+ export async function matchesExpected(current, expected, digest) {
24
+ if (expected === "absent" || current === null) {
25
+ return expected === "absent" && current === null;
26
+ }
27
+ return (await contentDigest(current, digest)) === expected;
28
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Copies plain data all the way down: arrays, plain objects, dates and
3
+ * primitives. A value that appears twice, or contains itself, is copied once
4
+ * and shared the same way in the copy, as `structuredClone` does. The core
5
+ * has no `structuredClone`, so this replaces it for run events, records and
6
+ * workflow context.
7
+ *
8
+ * @param value - the data to copy
9
+ * @returns a copy that shares no objects with `value`
10
+ * @throws TypeError for anything that isn't plain data, such as a function, a `Map` or a class instance
11
+ *
12
+ * @example
13
+ * const copy = deepClone({ steps: [{ id: "a" }] });
14
+ */
15
+ export declare function deepClone<T>(value: T): T;
@@ -0,0 +1,59 @@
1
+ import { describeObject, isPlainObject, keyPath } from "./plain-data.js";
2
+ /**
3
+ * Copies plain data all the way down: arrays, plain objects, dates and
4
+ * primitives. A value that appears twice, or contains itself, is copied once
5
+ * and shared the same way in the copy, as `structuredClone` does. The core
6
+ * has no `structuredClone`, so this replaces it for run events, records and
7
+ * workflow context.
8
+ *
9
+ * @param value - the data to copy
10
+ * @returns a copy that shares no objects with `value`
11
+ * @throws TypeError for anything that isn't plain data, such as a function, a `Map` or a class instance
12
+ *
13
+ * @example
14
+ * const copy = deepClone({ steps: [{ id: "a" }] });
15
+ */
16
+ export function deepClone(value) {
17
+ return cloneValue(value, new Map(), "value");
18
+ }
19
+ function cloneValue(value, copies, path) {
20
+ if (typeof value === "function" || typeof value === "symbol") {
21
+ throw new TypeError(`deepClone can't copy the ${typeof value} at ${path}.`);
22
+ }
23
+ if (typeof value !== "object" || value === null) {
24
+ return value;
25
+ }
26
+ const existing = copies.get(value);
27
+ if (existing !== undefined) {
28
+ return existing;
29
+ }
30
+ if (value instanceof Date) {
31
+ const copy = new Date(value.getTime());
32
+ copies.set(value, copy);
33
+ return copy;
34
+ }
35
+ if (Array.isArray(value)) {
36
+ const copy = [];
37
+ copies.set(value, copy);
38
+ for (let index = 0; index < value.length; index++) {
39
+ copy.push(cloneValue(value[index], copies, `${path}[${index}]`));
40
+ }
41
+ return copy;
42
+ }
43
+ if (isPlainObject(value)) {
44
+ const copy = Object.getPrototypeOf(value) === null ? Object.create(null) : {};
45
+ copies.set(value, copy);
46
+ for (const key of Object.keys(value)) {
47
+ // defineProperty, not assignment: a "__proto__" key from JSON.parse
48
+ // stays a plain key instead of changing the copy's prototype.
49
+ Object.defineProperty(copy, key, {
50
+ value: cloneValue(value[key], copies, keyPath(path, key)),
51
+ enumerable: true,
52
+ writable: true,
53
+ configurable: true,
54
+ });
55
+ }
56
+ return copy;
57
+ }
58
+ throw new TypeError(`deepClone copies plain data only, but ${path} is ${describeObject(value)}.`);
59
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Compares two values by content: arrays item by item, plain objects key by
3
+ * key in any order, and dates by time. Numbers compare with `===`, except
4
+ * that `NaN` equals `NaN`. Any other object (a `Map`, a class instance)
5
+ * equals only itself.
6
+ *
7
+ * Unlike comparing `JSON.stringify` output, key order doesn't matter, and a
8
+ * key whose value is `undefined` is still a key: `{ a: undefined }` doesn't
9
+ * equal `{}`.
10
+ *
11
+ * Cyclic data isn't supported: comparing it throws a `RangeError`. JSON can't
12
+ * express cycles, and `@halonicjs/yaml` rejects aliases that refer to
13
+ * themselves. `deepClone` keeps cycles because it mirrors `structuredClone`,
14
+ * while comparing a cycle would need extra bookkeeping on every call.
15
+ *
16
+ * @param first - the first value
17
+ * @param second - the second value
18
+ * @returns true when both have the same content
19
+ *
20
+ * @example
21
+ * deepEqual({ a: [1, 2], b: "x" }, { b: "x", a: [1, 2] }); // true
22
+ */
23
+ export declare function deepEqual(first: unknown, second: unknown): boolean;
@@ -0,0 +1,64 @@
1
+ import { isPlainObject } from "./plain-data.js";
2
+ /**
3
+ * Compares two values by content: arrays item by item, plain objects key by
4
+ * key in any order, and dates by time. Numbers compare with `===`, except
5
+ * that `NaN` equals `NaN`. Any other object (a `Map`, a class instance)
6
+ * equals only itself.
7
+ *
8
+ * Unlike comparing `JSON.stringify` output, key order doesn't matter, and a
9
+ * key whose value is `undefined` is still a key: `{ a: undefined }` doesn't
10
+ * equal `{}`.
11
+ *
12
+ * Cyclic data isn't supported: comparing it throws a `RangeError`. JSON can't
13
+ * express cycles, and `@halonicjs/yaml` rejects aliases that refer to
14
+ * themselves. `deepClone` keeps cycles because it mirrors `structuredClone`,
15
+ * while comparing a cycle would need extra bookkeeping on every call.
16
+ *
17
+ * @param first - the first value
18
+ * @param second - the second value
19
+ * @returns true when both have the same content
20
+ *
21
+ * @example
22
+ * deepEqual({ a: [1, 2], b: "x" }, { b: "x", a: [1, 2] }); // true
23
+ */
24
+ export function deepEqual(first, second) {
25
+ if (first === second) {
26
+ return true;
27
+ }
28
+ if (typeof first === "number" && typeof second === "number") {
29
+ return Number.isNaN(first) && Number.isNaN(second);
30
+ }
31
+ if (Array.isArray(first) && Array.isArray(second)) {
32
+ return arraysEqual(first, second);
33
+ }
34
+ if (first instanceof Date && second instanceof Date) {
35
+ return Object.is(first.getTime(), second.getTime());
36
+ }
37
+ if (isPlainObject(first) && isPlainObject(second)) {
38
+ return objectsEqual(first, second);
39
+ }
40
+ return false;
41
+ }
42
+ function arraysEqual(first, second) {
43
+ if (first.length !== second.length) {
44
+ return false;
45
+ }
46
+ for (let index = 0; index < first.length; index++) {
47
+ if (!deepEqual(first[index], second[index])) {
48
+ return false;
49
+ }
50
+ }
51
+ return true;
52
+ }
53
+ function objectsEqual(first, second) {
54
+ const firstKeys = Object.keys(first);
55
+ if (firstKeys.length !== Object.keys(second).length) {
56
+ return false;
57
+ }
58
+ for (const key of firstKeys) {
59
+ if (!Object.hasOwn(second, key) || !deepEqual(first[key], second[key])) {
60
+ return false;
61
+ }
62
+ }
63
+ return true;
64
+ }
@@ -0,0 +1,42 @@
1
+ /** A function that receives one kind of event. */
2
+ export type Listener<Payload> = (payload: Payload) => void;
3
+ /**
4
+ * A small typed event emitter. `Events` maps each event name to the type of
5
+ * its payload, so `emit` and `on` check both.
6
+ *
7
+ * Listeners run in the order they were added. A listener added or removed
8
+ * while an event is being sent takes effect from the next event. If a
9
+ * listener throws, the others still run, and `emit` then throws the error
10
+ * (or an `AggregateError` with all of them).
11
+ *
12
+ * @example
13
+ * const changes = new Emitter<{ saved: { path: string }; closed: undefined }>();
14
+ * const stop = changes.on("saved", ({ path }) => console.log(path));
15
+ * changes.emit("saved", { path: "hubs/support/hub.yaml" });
16
+ * stop();
17
+ */
18
+ export declare class Emitter<Events extends Record<string, unknown>> {
19
+ private readonly listeners;
20
+ /**
21
+ * Adds a listener for one event.
22
+ *
23
+ * @param name - the event to listen to
24
+ * @param listener - called with each payload
25
+ * @returns a function that removes the listener again; calling it twice is harmless
26
+ */
27
+ on<Name extends keyof Events>(name: Name, listener: Listener<Events[Name]>): () => void;
28
+ /**
29
+ * Sends an event to every listener for it.
30
+ *
31
+ * @param name - the event
32
+ * @param payload - what the listeners receive
33
+ * @throws the error of the one listener that threw, or an `AggregateError` when several did
34
+ */
35
+ emit<Name extends keyof Events>(name: Name, payload: Events[Name]): void;
36
+ /**
37
+ * How many listeners an event has.
38
+ *
39
+ * @param name - the event
40
+ */
41
+ listenerCount(name: keyof Events): number;
42
+ }
@@ -0,0 +1,74 @@
1
+ /**
2
+ * A small typed event emitter. `Events` maps each event name to the type of
3
+ * its payload, so `emit` and `on` check both.
4
+ *
5
+ * Listeners run in the order they were added. A listener added or removed
6
+ * while an event is being sent takes effect from the next event. If a
7
+ * listener throws, the others still run, and `emit` then throws the error
8
+ * (or an `AggregateError` with all of them).
9
+ *
10
+ * @example
11
+ * const changes = new Emitter<{ saved: { path: string }; closed: undefined }>();
12
+ * const stop = changes.on("saved", ({ path }) => console.log(path));
13
+ * changes.emit("saved", { path: "hubs/support/hub.yaml" });
14
+ * stop();
15
+ */
16
+ export class Emitter {
17
+ listeners = new Map();
18
+ /**
19
+ * Adds a listener for one event.
20
+ *
21
+ * @param name - the event to listen to
22
+ * @param listener - called with each payload
23
+ * @returns a function that removes the listener again; calling it twice is harmless
24
+ */
25
+ on(name, listener) {
26
+ let forName = this.listeners.get(name);
27
+ if (forName === undefined) {
28
+ forName = new Set();
29
+ this.listeners.set(name, forName);
30
+ }
31
+ // Wrapped, so adding the same function twice gives two independent listeners.
32
+ const entry = (payload) => listener(payload);
33
+ forName.add(entry);
34
+ return () => {
35
+ forName.delete(entry);
36
+ };
37
+ }
38
+ /**
39
+ * Sends an event to every listener for it.
40
+ *
41
+ * @param name - the event
42
+ * @param payload - what the listeners receive
43
+ * @throws the error of the one listener that threw, or an `AggregateError` when several did
44
+ */
45
+ emit(name, payload) {
46
+ const forName = this.listeners.get(name);
47
+ if (forName === undefined) {
48
+ return;
49
+ }
50
+ const errors = [];
51
+ for (const listener of [...forName]) {
52
+ try {
53
+ listener(payload);
54
+ }
55
+ catch (error) {
56
+ errors.push(error);
57
+ }
58
+ }
59
+ if (errors.length === 1) {
60
+ throw errors[0];
61
+ }
62
+ if (errors.length > 1) {
63
+ throw new AggregateError(errors, `${errors.length} listeners for "${String(name)}" failed.`);
64
+ }
65
+ }
66
+ /**
67
+ * How many listeners an event has.
68
+ *
69
+ * @param name - the event
70
+ */
71
+ listenerCount(name) {
72
+ return this.listeners.get(name)?.size ?? 0;
73
+ }
74
+ }
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Every kind of error a surface (HTTP, CLI, Studio, MCP) can respond to, in a
3
+ * fixed order for exhaustive tests and docs. Each surface turns a kind into
4
+ * its response in one `switch` that ends in
5
+ * `assertNever(kind, "error kind")`, so a new kind fails the typecheck until
6
+ * every surface handles it.
7
+ *
8
+ * - `invalid_input`: the request or file is wrong; the caller fixes the input.
9
+ * - `not_found`: the thing asked for doesn't exist.
10
+ * - `conflict`: it exists, but its state doesn't allow this now: it already
11
+ * exists, someone else changed it first, or another step must come first.
12
+ * - `unauthenticated`: we don't know who is asking, or their sign-in expired.
13
+ * - `denied`: we know who is asking, but a rule says no.
14
+ * - `limit_reached`: a rate limit, quota or spend budget is used up.
15
+ * - `unavailable`: something we depend on is down or timed out; a retry may work.
16
+ * - `internal`: a bug on our side. Anything without a kind is `internal`.
17
+ */
18
+ export declare const errorKinds: readonly ["invalid_input", "not_found", "conflict", "unauthenticated", "denied", "limit_reached", "unavailable", "internal"];
19
+ /** One of {@link errorKinds}. */
20
+ export type ErrorKind = (typeof errorKinds)[number];
21
+ /**
22
+ * True when `value` is one of the error kinds. Use it to decode a kind that
23
+ * came over the wire, such as the `kind` in an HTTP error body.
24
+ *
25
+ * @example
26
+ * isErrorKind("not_found"); // true
27
+ * isErrorKind("not-found"); // false
28
+ */
29
+ export declare function isErrorKind(value: unknown): value is ErrorKind;
30
+ /** What a {@link KindedError} can carry besides its kind and message. */
31
+ export type KindedErrorOptions = {
32
+ /**
33
+ * The one next step that fixes it, as a sentence on its own line, such as
34
+ * "Start Ollama, then run again." Leave it out when there is no step to
35
+ * suggest: surfaces then show no fix and never make one up.
36
+ */
37
+ readonly fix?: string;
38
+ /** The error this one wraps, for the log. */
39
+ readonly cause?: unknown;
40
+ };
41
+ /**
42
+ * An error with a kind, for code that fails in a way a person should hear
43
+ * about. Errors that already have their own class don't have to extend this
44
+ * one: a `kind` property is enough for {@link errorKindOf}.
45
+ *
46
+ * The message must be safe to show and to log: no secrets, tokens, internal
47
+ * paths or internal codes. Surfaces show a generic message for `internal`
48
+ * instead of this one, so don't rely on the text of an `internal` error
49
+ * reaching the user; put what helps there in the log. The same rule holds
50
+ * for the optional `fix`, which is kept apart from the message so a surface
51
+ * can show it on its own line or in its own JSON field.
52
+ *
53
+ * @example
54
+ * throw new KindedError("not_found", `There is no routine named "${name}".`);
55
+ * throw new KindedError("unavailable", "Halonic couldn't reach Ollama.", {
56
+ * fix: "Start Ollama, then run again.",
57
+ * });
58
+ */
59
+ export declare class KindedError extends Error {
60
+ readonly name = "KindedError";
61
+ readonly kind: ErrorKind;
62
+ /** The one next step that fixes it; `undefined` when there is none to suggest. */
63
+ readonly fix: string | undefined;
64
+ /**
65
+ * @param kind - how a surface should respond
66
+ * @param message - safe to show and to log
67
+ * @param options - `fix` is the next step, safe to show and to log; `cause`
68
+ * keeps the error this one wraps, for the log
69
+ */
70
+ constructor(kind: ErrorKind, message: string, options?: KindedErrorOptions);
71
+ }
72
+ /**
73
+ * The kind of any thrown value, for the one function per surface that turns
74
+ * errors into responses. A value has a kind when it is an object with a
75
+ * valid `kind` string and a `message` string: a `KindedError`, an error class
76
+ * with a `kind` property, or the `{ kind, message }` shape an error takes over
77
+ * HTTP or IPC. Anything else is `internal`, including objects that only have
78
+ * a `kind`, such as events.
79
+ *
80
+ * It reads only the value itself, never its `cause`: code that wraps an error
81
+ * chooses the kind of the wrapper on purpose.
82
+ *
83
+ * @example
84
+ * errorKindOf(new KindedError("conflict", "The run changed.")); // "conflict"
85
+ * errorKindOf({ kind: "not_found", message: "No such hub." }); // "not_found"
86
+ * errorKindOf(new TypeError("x is undefined")); // "internal"
87
+ */
88
+ export declare function errorKindOf(error: unknown): ErrorKind;