@halonicjs/testing 0.0.0-stage → 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 +40 -2
  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 +35 -4
@@ -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;
@@ -0,0 +1,131 @@
1
+ import { parseEventLine, } from "../../events/src/index.js";
2
+ /** Version of the {@link RunStore} port. A breaking change bumps it and comes with an ADR. */
3
+ export const runStoreVersion = 1;
4
+ /** The format version of {@link RunLockRecord} that adapters write today. */
5
+ export const runLockFormat = 1;
6
+ /**
7
+ * How old a run lock may get before any writer may remove it. An append holds
8
+ * the lock for milliseconds, so this is far longer than any append takes.
9
+ */
10
+ export const runLockStaleAfterMs = 10_000;
11
+ /**
12
+ * How old a lock's takeover file may get before any writer may remove it.
13
+ * Removing a stale lock takes milliseconds, and up to 2 seconds a step on
14
+ * Windows while a file is busy, so a takeover file this old was left by a
15
+ * writer that crashed while removing a lock.
16
+ */
17
+ export const runLockTakeoverStaleAfterMs = 5_000;
18
+ // The rules above, as code, so every adapter checks appends and filters runs the same way.
19
+ /**
20
+ * Refuses an append that is the caller's bug, as {@link RunStore.append}
21
+ * says: `expectedSeq` that isn't a whole number of 0 or more, no events,
22
+ * an event of another run, or events not numbered from `expectedSeq + 1`.
23
+ *
24
+ * @throws RangeError naming what is wrong
25
+ */
26
+ export function checkRunAppend(runId, expectedSeq, events) {
27
+ if (!Number.isSafeInteger(expectedSeq) || expectedSeq < 0) {
28
+ throw new RangeError(`expectedSeq must be a whole number of 0 or more, not ${expectedSeq}.`);
29
+ }
30
+ if (events.length === 0) {
31
+ throw new RangeError("append needs at least one event.");
32
+ }
33
+ events.forEach((event, index) => {
34
+ if (event.runId !== runId) {
35
+ throw new RangeError(`Event ${event.seq} belongs to run ${event.runId}, not ${runId}.`);
36
+ }
37
+ if (event.seq !== expectedSeq + index + 1) {
38
+ throw new RangeError(`Event ${index} has seq ${event.seq}, not ${expectedSeq + index + 1}.`);
39
+ }
40
+ });
41
+ }
42
+ /** Whether a summary matches every field of a {@link RunFilter}. An empty status list is no status filter. */
43
+ export function matchesRunFilter(summary, filter) {
44
+ const statuses = filter.status === undefined ? [] : [filter.status].flat();
45
+ return ((filter.hubId === undefined || summary.hubId === filter.hubId) &&
46
+ (filter.workflowId === undefined || summary.workflowId === filter.workflowId) &&
47
+ (filter.kind === undefined || summary.kind === filter.kind) &&
48
+ (statuses.length === 0 || statuses.includes(summary.status)) &&
49
+ (filter.startedSince === undefined || startedAtOrAfter(summary.startedAt, filter.startedSince)));
50
+ }
51
+ /**
52
+ * Whether a run that started at `startedAt` is in a list filtered by
53
+ * `startedSince`. Both are ISO times; they are compared as times, so an
54
+ * offset or a missing fraction of a second doesn't change the answer.
55
+ */
56
+ export function startedAtOrAfter(startedAt, since) {
57
+ return Date.parse(startedAt) >= Date.parse(since);
58
+ }
59
+ /** Orders summaries as {@link RunStore.list} returns them: newest start time first, then by run id. */
60
+ export function compareRunSummaries(a, b) {
61
+ return b.startedAt.localeCompare(a.startedAt) || a.id.localeCompare(b.id);
62
+ }
63
+ // The run folder's file rules, which every adapter that keeps runs as files
64
+ // in a folder applies: the CLI's `FolderRunStore` in `fs-node` and the
65
+ // desktop app's store in `fs-tauri`, whose shell writes the same files. Bytes
66
+ // stay with the adapters: each finds the log's whole lines and decodes them
67
+ // its own way, then reads them here (HAL-2701).
68
+ /** Letters, digits, `_`, `-` and `.`, not starting with a dot, at most 128 characters: a safe file name everywhere. */
69
+ const runIdPattern = /^[A-Za-z0-9_-][A-Za-z0-9_.-]{0,127}$/u;
70
+ /** Names Windows opens as a device whatever the extension, such as `NUL.jsonl`. */
71
+ const windowsDeviceName = /^(con|prn|aux|nul|com\d|lpt\d)(\.|$)/iu;
72
+ /** Writes events as run log lines: one JSON event per line, each ending in a line break. */
73
+ export function formatLogLines(events) {
74
+ return events.map((event) => `${JSON.stringify(event)}\n`).join("");
75
+ }
76
+ /**
77
+ * Reads a run log's whole lines back into events. Every line must hold the
78
+ * run's next event, numbered from 1. Pass only whole lines, each ending in
79
+ * a line break: a torn last line, from a crash, is the adapter's to leave
80
+ * out first.
81
+ *
82
+ * @param lines - the log's whole lines, or `""` for an empty log
83
+ * @param runId - the run the log belongs to
84
+ * @param file - the log's name, for the error message
85
+ * @returns the events, in order
86
+ * @throws Error naming the file and line when a line is broken
87
+ */
88
+ export function parseLogLines(lines, runId, file) {
89
+ if (lines === "") {
90
+ return [];
91
+ }
92
+ if (!lines.endsWith("\n")) {
93
+ throw new RangeError(`Only whole lines of run log ${file} can be read.`);
94
+ }
95
+ return lines
96
+ .slice(0, -1)
97
+ .split("\n")
98
+ .map((line, index) => parseLine(line, index + 1, runId, file));
99
+ }
100
+ /**
101
+ * Whether a run id can be a plain file name in the run folder: 1 to 128
102
+ * letters, digits, `_`, `-` or `.`, not starting with a dot, and not a name
103
+ * Windows keeps for a device.
104
+ */
105
+ export function isRunId(runId) {
106
+ return runIdPattern.test(runId) && !windowsDeviceName.test(runId);
107
+ }
108
+ /**
109
+ * Refuses a run id that couldn't be a plain file name in the run folder:
110
+ * `..`, a separator, an absolute path, a name Windows keeps for a device.
111
+ *
112
+ * @throws RangeError naming the run id
113
+ */
114
+ export function checkRunId(runId) {
115
+ if (!isRunId(runId)) {
116
+ throw new RangeError(`Unsafe run id ${JSON.stringify(runId)}: use 1 to 128 letters, digits, "_", "-" or ".", not starting with ".".`);
117
+ }
118
+ }
119
+ function parseLine(line, seq, runId, file) {
120
+ let event;
121
+ try {
122
+ event = parseEventLine(line);
123
+ }
124
+ catch (error) {
125
+ throw new Error(`Broken run log ${file}, line ${seq}: ${error.message}`);
126
+ }
127
+ if (event.runId !== runId || event.seq !== seq) {
128
+ throw new Error(`Broken run log ${file}, line ${seq}: it holds event ${event.seq} of run ${event.runId}.`);
129
+ }
130
+ return event;
131
+ }
@@ -0,0 +1,247 @@
1
+ /**
2
+ * Version of the {@link Sandbox} port. A breaking change bumps it and comes with an ADR.
3
+ *
4
+ * 2: {@link SandboxSession.fence} proves the fence before anything runs
5
+ * (docs/adr/2026-11-09-sandbox-fence-proof.md).
6
+ * 3: `SandboxCheck.reason` says why the sandbox can't start, as a listed code
7
+ * (docs/adr/2026-11-09-sandbox-check-reason-codes.md).
8
+ * 4: {@link SandboxNetwork.bridge} may be `null`: a session with no network
9
+ * but its listed sites (docs/adr/2026-11-10-sandbox-optional-bridge.md).
10
+ * 5: strength `none` and the fence proof `off`, for the launcher that starts
11
+ * programs without a fence (docs/adr/2026-11-11-sandbox-without-fence.md).
12
+ */
13
+ export declare const sandboxVersion = 5;
14
+ /**
15
+ * How files reach the sandbox. `shared`: the program sees the same folders as
16
+ * Halonic, so nothing is copied (a sandbox on this computer). `copied`: the
17
+ * sandbox has its own file system, and the adapter syncs the working folder
18
+ * in before a run and out after it (a VM or Halonic Cloud).
19
+ */
20
+ export type SandboxFileAccess = "shared" | "copied";
21
+ /**
22
+ * How strong the fence is. `os`: the operating system confines the program
23
+ * (kernel escapes are not covered). `vm`: a micro-VM, with its own kernel.
24
+ * `remote`: another machine. `none`: no fence at all, only the launcher
25
+ * (`sandbox-host`), for runs the user confirmed without the sandbox.
26
+ */
27
+ export type SandboxStrength = "os" | "vm" | "remote" | "none";
28
+ /** What a sandbox adapter can do. */
29
+ export interface SandboxCapabilities {
30
+ /** How files reach the sandbox. */
31
+ files: SandboxFileAccess;
32
+ /** How strong the fence is. */
33
+ strength: SandboxStrength;
34
+ }
35
+ /**
36
+ * Every reason a sandbox can't start on this machine. The list is closed: an
37
+ * adapter returns only these, and a new reason is a port change. Studio and
38
+ * the CLI turn each one into the words a person reads and the fix; the
39
+ * adapter never words it.
40
+ *
41
+ * - `windows`: plain Windows, outside WSL2.
42
+ * - `container`: Halonic itself runs inside a container (such as Docker), which won't nest the fence.
43
+ * - `user-namespaces-restricted`: the system doesn't let programs create user namespaces, as Ubuntu 24.04 does by default.
44
+ * - `bubblewrap-missing`: bubblewrap (`bwrap`) is not installed.
45
+ * - `linux-tools-missing`: `socat` or ripgrep (`rg`), which srt starts next to bubblewrap, is not installed.
46
+ * - `other`: none of the above; `SandboxCheck.missing` says what.
47
+ */
48
+ export declare const sandboxUnavailableReasons: readonly ["windows", "container", "user-namespaces-restricted", "bubblewrap-missing", "linux-tools-missing", "other"];
49
+ /** Why a sandbox can't start on this machine: one of {@link sandboxUnavailableReasons}. */
50
+ export type SandboxUnavailableReason = (typeof sandboxUnavailableReasons)[number];
51
+ /**
52
+ * Whether a sandbox works on this machine. `ok` is true when
53
+ * {@link Sandbox.open} can be expected to work; then there is no reason and
54
+ * nothing missing. Otherwise:
55
+ *
56
+ * - `reason` says why it can't start (since version 3). When more than one
57
+ * reason applies, the first in {@link sandboxUnavailableReasons}, because
58
+ * its fix comes first.
59
+ * - `missing` says what is missing, one plain sentence each, such as
60
+ * "bubblewrap is not installed". For logs and support, not for people:
61
+ * Studio words the refusal from `reason`.
62
+ */
63
+ export type SandboxCheck = {
64
+ ok: true;
65
+ reason: null;
66
+ missing: [];
67
+ } | {
68
+ ok: false;
69
+ reason: SandboxUnavailableReason;
70
+ missing: string[];
71
+ };
72
+ /**
73
+ * What a program in the sandbox may reach. Halonic builds it from the
74
+ * person's profile and the trusted workspace, and the agent can't change it.
75
+ * Every path is absolute, in the host's notation.
76
+ *
77
+ * The profile is Halonic's own format, not that of a particular sandbox
78
+ * library, so an adapter for a VM or for Halonic Cloud reads the same one.
79
+ * It is a plain type and not a schema: Halonic builds it in process and never
80
+ * reads it from data, and a port may not import the schema package. An
81
+ * adapter that takes one from outside must check it itself.
82
+ */
83
+ export interface SandboxProfile {
84
+ /** The one folder the program writes to, and where it starts. */
85
+ workingFolder: string;
86
+ /** A private temp folder, writable. A fresh one per session; the adapter doesn't clean it up. */
87
+ tempFolder: string;
88
+ /**
89
+ * The agent's own settings folder inside Halonic's data (such as
90
+ * `CLAUDE_CONFIG_DIR`), writable, never the person's own. `null` when the
91
+ * program needs none.
92
+ */
93
+ settingsFolder: string | null;
94
+ /** Paths the program may read but not change, such as the workspace's definition files. */
95
+ readOnlyPaths: string[];
96
+ /** Paths the program may not read or write, such as SSH keys and Halonic's own data. Wins over every other list. */
97
+ deniedPaths: string[];
98
+ /**
99
+ * The only environment variables the program gets, by name and value. The
100
+ * host's own environment is never passed on.
101
+ */
102
+ env: Readonly<Record<string, string>>;
103
+ /** The network. Everything not named here is blocked. */
104
+ network: SandboxNetwork;
105
+ /** How long the whole run may last, in milliseconds, counted from {@link Sandbox.open}. */
106
+ timeLimitMs: number;
107
+ }
108
+ /** The network a {@link SandboxProfile} allows. */
109
+ export interface SandboxNetwork {
110
+ /**
111
+ * The Halonic bridge: the one loopback address the program can reach. An
112
+ * adapter rejects a host that is not a loopback address (`127.0.0.1`, `::1`
113
+ * or `localhost`) when {@link Sandbox.open} is called.
114
+ *
115
+ * `null` means no bridge: the program reaches no loopback address at all,
116
+ * only the allowed sites. The integration runner uses it, because it talks
117
+ * to Halonic over its standard input and output, not the network. The field
118
+ * is never optional, so leaving it out can't mean "the whole network".
119
+ */
120
+ bridge: {
121
+ host: string;
122
+ port: number;
123
+ } | null;
124
+ /**
125
+ * Further sites, by host name such as "registry.npmjs.org" or with a
126
+ * leading "*." for every subdomain. Empty by default.
127
+ */
128
+ allowedSites: string[];
129
+ }
130
+ /** What to start in a session. */
131
+ export interface SandboxCommand {
132
+ /** The program, by name or path. */
133
+ program: string;
134
+ /** Its arguments, passed as they are, never through a shell. */
135
+ args: string[];
136
+ /** Where it starts: the working folder or a folder inside it. Absent means the working folder. */
137
+ cwd?: string;
138
+ }
139
+ /** How a started program ended. */
140
+ export interface SandboxExit {
141
+ /**
142
+ * The exit code, or `null` when a signal ended it. A program the fence can't
143
+ * find or run ends with a non-zero code, not `null`.
144
+ */
145
+ code: number | null;
146
+ /** The signal that ended it, such as "SIGKILL", or `null`. */
147
+ signal: string | null;
148
+ /** Why: it finished by itself, it was stopped (`kill`, `close`, cancel), or the time limit ran out. */
149
+ reason: "exited" | "stopped" | "timeout";
150
+ }
151
+ /** A program a session started. */
152
+ export interface SandboxProcess {
153
+ /** Writes to the program's standard input. Close it to end the input. */
154
+ stdin: WritableStream<Uint8Array>;
155
+ /** The program's standard output, as bytes. */
156
+ stdout: ReadableStream<Uint8Array>;
157
+ /** The program's standard error, as bytes. */
158
+ stderr: ReadableStream<Uint8Array>;
159
+ /** Settles when the program and everything it started has ended. Never rejects. */
160
+ exited: Promise<SandboxExit>;
161
+ /** Stops the program and everything it started. Safe to call twice. */
162
+ kill(): Promise<void>;
163
+ }
164
+ /** An access the sandbox refused. It becomes the run's `sandbox.blocked` event. */
165
+ export type SandboxBlock = {
166
+ kind: "file";
167
+ path: string;
168
+ access: "read" | "write";
169
+ } | {
170
+ kind: "network";
171
+ host: string;
172
+ port: number | null;
173
+ };
174
+ /** Hears the session's blocked accesses. */
175
+ export type SandboxBlockListener = (block: SandboxBlock) => void;
176
+ /**
177
+ * Whether the fence is really around the session. Before a session starts any
178
+ * program, the adapter runs its own probes (a file the fence hides, and a
179
+ * loopback port the fence blocks) and reports what it found.
180
+ *
181
+ * `fenced`: the probes were refused, so programs run inside the fence.
182
+ * `not-fenced`: a probe got through, or could not run; `reason` says which, in
183
+ * one plain sentence, and {@link SandboxSession.start} throws.
184
+ * `off`: the adapter has no fence by design (strength `none`), so there is
185
+ * nothing to prove and programs start without one. Only the launcher reports
186
+ * it; a fenced adapter whose fence fails reports `not-fenced`, never `off`.
187
+ * `stopped`: the session is closed.
188
+ */
189
+ export type SandboxFence = {
190
+ state: "fenced";
191
+ } | {
192
+ state: "not-fenced";
193
+ reason: string;
194
+ } | {
195
+ state: "off";
196
+ } | {
197
+ state: "stopped";
198
+ };
199
+ /** One run's sandbox: the programs it started, the fence they are in and the time limit. */
200
+ export interface SandboxSession {
201
+ /** The profile the session was opened with. */
202
+ readonly profile: SandboxProfile;
203
+ /**
204
+ * The fence proof. It is settled before {@link Sandbox.open} returns, so no
205
+ * untrusted code has loaded when it is read, and it becomes `stopped` after
206
+ * {@link SandboxSession.close}.
207
+ */
208
+ readonly fence: SandboxFence;
209
+ /**
210
+ * Starts a program inside the fence.
211
+ *
212
+ * @throws when the session is closed, the fence proof is `not-fenced`, or the sandbox can't launch anything.
213
+ * A program that is missing inside the fence doesn't throw: it ends with a
214
+ * non-zero {@link SandboxExit.code}.
215
+ */
216
+ start(command: SandboxCommand): Promise<SandboxProcess>;
217
+ /** Reports each blocked access from now on. Returns a function that stops the reports. */
218
+ onBlocked(listener: SandboxBlockListener): () => void;
219
+ /**
220
+ * Stops every program the session started, and everything they started, and
221
+ * resolves when they have ended. The session does this by itself when the
222
+ * time limit runs out or the signal given to {@link Sandbox.open} aborts.
223
+ * Safe to call twice.
224
+ */
225
+ close(): Promise<void>;
226
+ }
227
+ /** Runs programs inside a fence: a sandbox on this computer today, a VM or Halonic Cloud later. */
228
+ export interface Sandbox {
229
+ /**
230
+ * Whether it works on this machine, and if not, why and what is missing.
231
+ * Never throws. When it isn't `ok`, Halonic doesn't run the step: it never
232
+ * falls back to running a program without the fence by itself. Only the
233
+ * user's saved yes for that reason sends a start to the launcher instead.
234
+ */
235
+ check(): Promise<SandboxCheck>;
236
+ /** How files reach it and how strong the fence is. */
237
+ capabilities(): SandboxCapabilities;
238
+ /**
239
+ * Opens a session for one run. Cancelling the run, by aborting `signal`,
240
+ * closes the session.
241
+ *
242
+ * @throws when the sandbox doesn't work here (see {@link Sandbox.check}) or the profile can't be applied, including a bridge that is not a loopback address
243
+ */
244
+ open(profile: SandboxProfile, options?: {
245
+ signal?: AbortSignal;
246
+ }): Promise<SandboxSession>;
247
+ }
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Version of the {@link Sandbox} port. A breaking change bumps it and comes with an ADR.
3
+ *
4
+ * 2: {@link SandboxSession.fence} proves the fence before anything runs
5
+ * (docs/adr/2026-11-09-sandbox-fence-proof.md).
6
+ * 3: `SandboxCheck.reason` says why the sandbox can't start, as a listed code
7
+ * (docs/adr/2026-11-09-sandbox-check-reason-codes.md).
8
+ * 4: {@link SandboxNetwork.bridge} may be `null`: a session with no network
9
+ * but its listed sites (docs/adr/2026-11-10-sandbox-optional-bridge.md).
10
+ * 5: strength `none` and the fence proof `off`, for the launcher that starts
11
+ * programs without a fence (docs/adr/2026-11-11-sandbox-without-fence.md).
12
+ */
13
+ export const sandboxVersion = 5;
14
+ /**
15
+ * Every reason a sandbox can't start on this machine. The list is closed: an
16
+ * adapter returns only these, and a new reason is a port change. Studio and
17
+ * the CLI turn each one into the words a person reads and the fix; the
18
+ * adapter never words it.
19
+ *
20
+ * - `windows`: plain Windows, outside WSL2.
21
+ * - `container`: Halonic itself runs inside a container (such as Docker), which won't nest the fence.
22
+ * - `user-namespaces-restricted`: the system doesn't let programs create user namespaces, as Ubuntu 24.04 does by default.
23
+ * - `bubblewrap-missing`: bubblewrap (`bwrap`) is not installed.
24
+ * - `linux-tools-missing`: `socat` or ripgrep (`rg`), which srt starts next to bubblewrap, is not installed.
25
+ * - `other`: none of the above; `SandboxCheck.missing` says what.
26
+ */
27
+ export const sandboxUnavailableReasons = [
28
+ "windows",
29
+ "container",
30
+ "user-namespaces-restricted",
31
+ "bubblewrap-missing",
32
+ "linux-tools-missing",
33
+ "other",
34
+ ];