@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,14 @@
1
+ /** Version of the {@link Digest} port. A breaking change bumps it and comes with an ADR. */
2
+ export declare const digestVersion = 1;
3
+ /**
4
+ * Hashes bytes. The core has no hash code of its own: an adapter asks the
5
+ * platform's WebCrypto, which Node, Workers and browsers all have.
6
+ *
7
+ * @example
8
+ * const hash = await digest.sha256(encodeUtf8("abc"));
9
+ * // hash.length === 32
10
+ */
11
+ export interface Digest {
12
+ /** The 32-byte SHA-256 of the bytes. The input is not changed. */
13
+ sha256(data: Uint8Array): Promise<Uint8Array>;
14
+ }
@@ -0,0 +1,2 @@
1
+ /** Version of the {@link Digest} port. A breaking change bumps it and comes with an ADR. */
2
+ export const digestVersion = 1;
@@ -0,0 +1,89 @@
1
+ /** Version of the {@link FolderReader} port. A breaking change bumps it and comes with an ADR. */
2
+ export declare const folderReaderVersion = 1;
3
+ /**
4
+ * One entry under a {@link FolderReader}'s folder. `path` is relative to the
5
+ * folder and "/" separated on every system. A `link` is a symbolic link, a
6
+ * Windows junction or any other reparse point; `other` is anything that is
7
+ * neither a file, a folder nor a link, such as a pipe, a socket or a device.
8
+ * Only a file has a size: its length in bytes.
9
+ *
10
+ * @example
11
+ * const entry: FolderEntry = { path: "acme-notes/plugin.yaml", kind: "file", size: 412 };
12
+ */
13
+ export type FolderEntry = {
14
+ readonly path: string;
15
+ readonly kind: "file";
16
+ readonly size: number;
17
+ } | {
18
+ readonly path: string;
19
+ readonly kind: "folder" | "link" | "other";
20
+ };
21
+ /** Options for {@link FolderReader.entries}. */
22
+ export interface FolderEntriesOptions {
23
+ /**
24
+ * Stop listing once more than this many entries were found, so a huge
25
+ * folder can't stall the caller. The result then holds `limit + 1`
26
+ * entries, which tells the caller the folder went past it.
27
+ */
28
+ readonly limit?: number;
29
+ /**
30
+ * `false` lists only the entries directly under the folder, without going
31
+ * into the folders among them, so a caller can find what a folder holds
32
+ * without listing everything inside. `true` by default.
33
+ */
34
+ readonly recursive?: boolean;
35
+ }
36
+ /**
37
+ * Read access to every byte of a folder, with nothing left out (requirement
38
+ * `ports.folder-reader`). The plugin service reads a plugin folder through
39
+ * it, because a plugin's trust fingerprint has to cover each file exactly as
40
+ * the plugin's own code would find it.
41
+ *
42
+ * **Unlike `DefinitionSource`, it hides nothing.** `.git`, `.env` and
43
+ * other names a workspace keeps private are listed and read like any other.
44
+ * Links and special files are listed, with their kind, but never followed
45
+ * and never read: a caller decides what to do about them. Bytes come back
46
+ * as they are, so two files that differ only in bytes that aren't valid
47
+ * UTF-8 never read the same.
48
+ *
49
+ * **Every method refuses an unsafe path** with a `RangeError` before it
50
+ * touches storage, by the rule of `checkWorkspacePath`: one that is
51
+ * absolute, has a `.`, `..` or empty segment, or holds a backslash or NUL.
52
+ * A path whose entry or any folder above it is a link is refused the same
53
+ * way, so nothing is ever read through a link.
54
+ *
55
+ * It only reads. Whoever hashes what it read hashes the bytes `read` gave,
56
+ * never a second read, so what is trusted is what was hashed.
57
+ *
58
+ * @example
59
+ * for (const entry of await reader.entries("acme-notes")) {
60
+ * const bytes = entry.kind === "file" ? await reader.read(entry.path) : null;
61
+ * if (bytes !== null) hashes.set(entry.path, await digest.sha256(bytes));
62
+ * }
63
+ */
64
+ export interface FolderReader {
65
+ /** Human-readable location of the folder, such as "~/.halonic/plugins" or "memory:plugins". */
66
+ readonly location: string;
67
+ /**
68
+ * Every entry under `dir`, recursively unless `options.recursive` is
69
+ * `false`, links and special files included but never followed. Paths are relative to the reader's folder, not to
70
+ * `dir`, and sorted by plain code-unit order (not by locale), so the
71
+ * same folder lists the same on every system. Omit `dir` for the whole
72
+ * folder; `""` is an empty path and is refused like any other unsafe
73
+ * path. A `dir` that doesn't exist or is a file gives `[]`.
74
+ */
75
+ entries(dir?: string, options?: FolderEntriesOptions): Promise<FolderEntry[]>;
76
+ /**
77
+ * The file's bytes, a fresh copy on every call, or `null` when there is
78
+ * no file at `path` (nothing, or a folder). Rejects with a `RangeError`
79
+ * for a link or a special file, which it never opens.
80
+ */
81
+ read(path: string): Promise<Uint8Array | null>;
82
+ /**
83
+ * The resolved real location of an entry, such as its absolute path with
84
+ * every link above the folder resolved, for a trust record's location.
85
+ * Omit `path` for the folder itself. `null` when there is no entry at
86
+ * `path`. Async, because a file system adapter has to ask the system.
87
+ */
88
+ locationOf(path?: string): Promise<string | null>;
89
+ }
@@ -0,0 +1,2 @@
1
+ /** Version of the {@link FolderReader} port. A breaking change bumps it and comes with an ADR. */
2
+ export const folderReaderVersion = 1;
@@ -0,0 +1,189 @@
1
+ import type { ToolOutcome, Usage } from "../../events/src/index.js";
2
+ import type { ToolDefinition } from "./chat.js";
3
+ import type { HarnessBridge, HarnessEvent } from "./harness.js";
4
+ import { type ModelPrice } from "./model-price.js";
5
+ /** Version of the {@link HarnessBridgeServer} port. A breaking change bumps it and comes with an ADR. */
6
+ export declare const harnessBridgeServerVersion = 1;
7
+ /** A model provider the bridge passes requests to, each at one fixed host the adapter knows. */
8
+ export type BridgeProvider = "anthropic" | "openai";
9
+ /** How the agent reaches one provider through the bridge. */
10
+ export type BridgeProviderAccess =
11
+ /**
12
+ * With a key Halonic keeps: the bridge puts the value of the secret with
13
+ * this name, from the `Secrets` port, in place of the program's key, and
14
+ * records the cost from the model's price. A model without a price is
15
+ * recorded without a cost, so the run shows it as unpriced.
16
+ */
17
+ {
18
+ kind: "key";
19
+ secret: string;
20
+ }
21
+ /**
22
+ * With the person's own subscription: the bridge passes the program's own
23
+ * sign-in to the provider unchanged and never reads, logs or stores it.
24
+ * The subscription pays and Halonic spends nothing, so the bridge records
25
+ * the call with its tokens, `cost: 0` and `paidBy: "subscription"`. The
26
+ * run counts it in `subscriptionCalls`, never as unpriced (which would hide
27
+ * a keyed model that really lacks a price) and never towards a budget.
28
+ */
29
+ | {
30
+ kind: "sign-in";
31
+ };
32
+ /** What the bridge records itself: the model calls and Halonic tool calls that go through it. */
33
+ export type BridgeEvent = Extract<HarnessEvent, {
34
+ type: "llm.request" | "llm.response" | "tool.called" | "tool.result";
35
+ }>;
36
+ /** Writes the bridge's events to the run's log. The engine adds `runId`, `seq`, `at` and the `state`. */
37
+ export interface BridgeRecorder {
38
+ record(event: BridgeEvent): Promise<void>;
39
+ }
40
+ /**
41
+ * What to do with a tool call before it runs, by the same rules as the
42
+ * built-in loop: the agent's `allow` and `approve` lists, the connection's
43
+ * "allow sending" setting and the workspace's trust. `ask`: run it only once
44
+ * a person says yes. `refused`: don't run it; `reason` goes back to the
45
+ * program as the call's result.
46
+ */
47
+ export type BridgeToolCheck = {
48
+ kind: "run";
49
+ } | {
50
+ kind: "ask";
51
+ } | {
52
+ kind: "refused";
53
+ reason: string;
54
+ };
55
+ /** How a tool call ended: its text result, and whether the tool answered or failed. */
56
+ export interface BridgeToolResult {
57
+ result: string;
58
+ outcome: ToolOutcome;
59
+ }
60
+ /**
61
+ * Halonic's tools for one agent of one run, which the bridge serves over MCP.
62
+ * The engine builds them, so integrations and their secrets stay in Halonic.
63
+ */
64
+ export interface BridgeTools {
65
+ /** The tools the agent is offered, in order. */
66
+ list(): Promise<ToolDefinition[]>;
67
+ /** Checks one call before it runs. A name {@link list} didn't offer is `refused`. */
68
+ check(name: string, args: Record<string, unknown>): Promise<BridgeToolCheck>;
69
+ /**
70
+ * Runs one call that {@link check} allowed, or a person approved. A tool
71
+ * that fails doesn't throw: it ends with `outcome: "error"` and the reason
72
+ * as its result.
73
+ */
74
+ call(name: string, args: Record<string, unknown>, options: {
75
+ signal: AbortSignal;
76
+ }): Promise<BridgeToolResult>;
77
+ }
78
+ /** One call a person has to approve. `tool` is a Halonic tool, or one of the program's own, such as "Bash". */
79
+ export interface BridgeApprovalRequest {
80
+ /** Unique in the run; the bridge makes it up. */
81
+ callId: string;
82
+ tool: string;
83
+ args: unknown;
84
+ }
85
+ /** A person's answer to a {@link BridgeApprovalRequest}. */
86
+ export interface BridgeApprovalDecision {
87
+ approved: boolean;
88
+ comment?: string;
89
+ }
90
+ /**
91
+ * Asks a person for an OK. The engine writes `approval.requested`, waits for
92
+ * the answer and writes `approval.resolved`, as it does for the built-in
93
+ * loop.
94
+ */
95
+ export interface BridgeApprovals {
96
+ /**
97
+ * Resolves with the person's decision.
98
+ *
99
+ * @throws when `signal` aborts first, because the run was cancelled or the program went away
100
+ */
101
+ request(request: BridgeApprovalRequest, options: {
102
+ signal: AbortSignal;
103
+ }): Promise<BridgeApprovalDecision>;
104
+ }
105
+ /** What the engine gives the bridge of one run. */
106
+ export interface HarnessBridgeOptions {
107
+ runId: string;
108
+ /** The agent the bridge's events name. */
109
+ agentId: string;
110
+ /** The providers this agent may reach and how it signs in. A provider not named here is refused. */
111
+ providers: Partial<Record<BridgeProvider, BridgeProviderAccess>>;
112
+ /**
113
+ * A model's price, or `null` when `models.yaml` gives none. Only asked for
114
+ * a provider reached with a key: a keyed call without a price is recorded
115
+ * without a cost (unpriced), and a sign-in call always costs 0. See
116
+ * {@link bridgeCallCharge}.
117
+ */
118
+ price(provider: BridgeProvider, model: string): ModelPrice | null;
119
+ recorder: BridgeRecorder;
120
+ tools: BridgeTools;
121
+ approvals: BridgeApprovals;
122
+ /** Aborting it closes the bridge, as {@link OpenHarnessBridge.close} does. */
123
+ signal?: AbortSignal;
124
+ }
125
+ /**
126
+ * The `cost` the bridge records on a model call's `llm.response`, in the
127
+ * workspace's budget currency (requirement `ports.harness-bridge-server`).
128
+ * A sign-in call costs 0, because the person's subscription pays. A keyed call
129
+ * costs its tokens at the model's price ({@link priceOf}), or is `undefined` (unpriced) when the
130
+ * model has no price.
131
+ *
132
+ * @deprecated Use {@link bridgeCallCharge}, which also marks a sign-in call
133
+ * `paidBy: "subscription"`. Recording this cost alone writes a sign-in call
134
+ * as a free call, so the run never counts it in `subscriptionCalls`.
135
+ */
136
+ export declare function bridgeCallCost(access: BridgeProviderAccess, price: ModelPrice | null, usage: Usage): number | undefined;
137
+ /** What the bridge puts on a model call's `llm.response` about its price: see {@link bridgeCallCharge}. */
138
+ export type BridgeCallCharge = Pick<Extract<BridgeEvent, {
139
+ type: "llm.response";
140
+ }>, "cost" | "paidBy">;
141
+ /**
142
+ * The `cost` and `paidBy` the bridge records on a model call's
143
+ * `llm.response` (requirement `ports.harness-bridge-server`). A sign-in call
144
+ * gets `cost: 0` and `paidBy: "subscription"`, so the run counts it in
145
+ * `subscriptionCalls`. A keyed call gets the cost from {@link bridgeCallCost},
146
+ * or nothing when its model has no price.
147
+ *
148
+ * @example
149
+ * recorder.record({ type: "llm.response", ...call, ...bridgeCallCharge(access, price, usage) });
150
+ */
151
+ export declare function bridgeCallCharge(access: BridgeProviderAccess, price: ModelPrice | null, usage: Usage): BridgeCallCharge;
152
+ /** A bridge that is serving one run. */
153
+ export interface OpenHarnessBridge extends HarnessBridge {
154
+ /**
155
+ * Stops serving: refuses new requests, ends those in flight and their
156
+ * calls to the provider, and resolves when they have ended and recorded
157
+ * what they had to, or after the bridge's close time limit for a request
158
+ * that doesn't end. Nothing is recorded for the run once it resolves.
159
+ * Safe to call twice.
160
+ */
161
+ close(): Promise<void>;
162
+ }
163
+ /**
164
+ * Opens the Halonic bridge for one run: a server on loopback that passes the
165
+ * program's model requests to the provider and serves Halonic's tools and
166
+ * approvals over MCP (requirement `ports.harness-bridge-server`). The engine
167
+ * opens it before the sandbox and closes it when the run ends. It is a port
168
+ * because core can't import the adapter that serves it.
169
+ *
170
+ * Only a request with the run's token in the `harnessBridgeTokenHeader`
171
+ * header is served. The token, a provider key and a person's sign-in never
172
+ * appear in an event, a log line or an error.
173
+ *
174
+ * @example
175
+ * const bridge = await server.open({ runId, agentId, providers, price, recorder, tools, approvals, signal });
176
+ * try {
177
+ * await runHarness(bridge);
178
+ * } finally {
179
+ * await bridge.close();
180
+ * }
181
+ */
182
+ export interface HarnessBridgeServer {
183
+ /**
184
+ * Starts serving one run on a free loopback port.
185
+ *
186
+ * @throws when it can't listen on loopback
187
+ */
188
+ open(options: HarnessBridgeOptions): Promise<OpenHarnessBridge>;
189
+ }
@@ -0,0 +1,37 @@
1
+ import { priceOf } from "./model-price.js";
2
+ /** Version of the {@link HarnessBridgeServer} port. A breaking change bumps it and comes with an ADR. */
3
+ export const harnessBridgeServerVersion = 1;
4
+ /**
5
+ * The `cost` the bridge records on a model call's `llm.response`, in the
6
+ * workspace's budget currency (requirement `ports.harness-bridge-server`).
7
+ * A sign-in call costs 0, because the person's subscription pays. A keyed call
8
+ * costs its tokens at the model's price ({@link priceOf}), or is `undefined` (unpriced) when the
9
+ * model has no price.
10
+ *
11
+ * @deprecated Use {@link bridgeCallCharge}, which also marks a sign-in call
12
+ * `paidBy: "subscription"`. Recording this cost alone writes a sign-in call
13
+ * as a free call, so the run never counts it in `subscriptionCalls`.
14
+ */
15
+ export function bridgeCallCost(access, price, usage) {
16
+ if (access.kind === "sign-in")
17
+ return 0;
18
+ if (price === null)
19
+ return undefined;
20
+ return priceOf(price, usage);
21
+ }
22
+ /**
23
+ * The `cost` and `paidBy` the bridge records on a model call's
24
+ * `llm.response` (requirement `ports.harness-bridge-server`). A sign-in call
25
+ * gets `cost: 0` and `paidBy: "subscription"`, so the run counts it in
26
+ * `subscriptionCalls`. A keyed call gets the cost from {@link bridgeCallCost},
27
+ * or nothing when its model has no price.
28
+ *
29
+ * @example
30
+ * recorder.record({ type: "llm.response", ...call, ...bridgeCallCharge(access, price, usage) });
31
+ */
32
+ export function bridgeCallCharge(access, price, usage) {
33
+ if (access.kind === "sign-in")
34
+ return { cost: 0, paidBy: "subscription" };
35
+ const cost = bridgeCallCost(access, price, usage);
36
+ return cost === undefined ? {} : { cost };
37
+ }
@@ -0,0 +1,250 @@
1
+ import type { AgentResume, RunEventBody, RunEventType } from "../../events/src/index.js";
2
+ import type { SandboxProfile, SandboxSession } from "./sandbox.js";
3
+ /** Version of the {@link Harness} port. A breaking change bumps it and comes with an ADR. */
4
+ export declare const harnessVersion = 2;
5
+ /**
6
+ * Whether a harness can run on this machine, as `detect()` finds it. Studio
7
+ * turns it into the sentence next to the harness choice, so each case
8
+ * carries what that sentence needs.
9
+ *
10
+ * @example
11
+ * const found = await codex.detect();
12
+ * if (found.status === "missing") show(`${codex.name} isn't installed`);
13
+ * if (found.status === "unsupported") {
14
+ * const oldest = found.supported.replace(/^>=/, "");
15
+ * show(`${codex.name} ${found.version} isn't supported. Halonic needs ${oldest} or newer.`);
16
+ * }
17
+ * if (found.status === "signed-out") show(`Found ${codex.name} ${found.version} · not signed in`);
18
+ */
19
+ export type HarnessDetection =
20
+ /** Installed in a version Halonic supports, and signed in, or its sign-in can't be checked. */
21
+ {
22
+ status: "ready";
23
+ version: string;
24
+ }
25
+ /**
26
+ * Installed in a version Halonic supports, but the program says no one is
27
+ * signed in on this computer. It can still run when Halonic holds a key
28
+ * for the agent's model provider, so this isn't an error on its own.
29
+ */
30
+ | {
31
+ status: "signed-out";
32
+ version: string;
33
+ }
34
+ /** The program isn't installed, or isn't where Halonic looks for it. */
35
+ | {
36
+ status: "missing";
37
+ }
38
+ /**
39
+ * Installed, but in a version Halonic doesn't support. `supported` names the
40
+ * oldest version it does, always written as ">=X.Y.Z" (such as ">=1.0.0"),
41
+ * so screens can drop the ">=" and say "needs 1.0.0 or newer".
42
+ */
43
+ | {
44
+ status: "unsupported";
45
+ version: string;
46
+ supported: string;
47
+ }
48
+ /** Found, but asking it for its version failed; `error` says how, in words a person can act on. */
49
+ | {
50
+ status: "failed";
51
+ error: string;
52
+ };
53
+ /** What a harness run is asked to do: one agent of one run, with the agent's own settings. */
54
+ export interface HarnessTask {
55
+ /** The run this agent belongs to. Every event the harness reports is written to its log. */
56
+ runId: string;
57
+ hubId: string;
58
+ /** The agent's id; the harness sets it as `agent` on the events it reports for this agent. */
59
+ agentId: string;
60
+ /** The agent's instructions from its file; empty when it has none. */
61
+ instructions: string;
62
+ /** What the agent is asked to do in this run: the task step's prompt, or the chat message. */
63
+ prompt: string;
64
+ /** The model the agent's file names; the harness's own default when absent. */
65
+ model?: string;
66
+ }
67
+ /**
68
+ * The request header that carries the run's bridge token. The token has a
69
+ * header of its own because `Authorization` isn't free: with a subscription,
70
+ * it carries the person's own sign-in, which the bridge passes on unread.
71
+ * Never put the token in the URL, because paths end up in logs.
72
+ */
73
+ export declare const harnessBridgeTokenHeader = "x-halonic-run-token";
74
+ /**
75
+ * The Halonic bridge of one run: a loopback address in Halonic that serves
76
+ * the model gateway and Halonic's tools over MCP. The harness points its
77
+ * program at `url` and has it send `token` in the
78
+ * {@link harnessBridgeTokenHeader} header on every request.
79
+ *
80
+ * The token is a credential for this run only. A harness never writes it into
81
+ * an event, a log line or an error message.
82
+ */
83
+ export interface HarnessBridge {
84
+ /** The bridge's address on loopback, such as "http://127.0.0.1:41817". */
85
+ url: string;
86
+ /** The run's random token. */
87
+ token: string;
88
+ }
89
+ /** The body of the run log event with this `type`. */
90
+ type RunEventOf<Type extends RunEventType> = Extract<RunEventBody, {
91
+ type: Type;
92
+ }>;
93
+ /**
94
+ * What a harness reports, as run log events without the fields the engine
95
+ * adds. A harness run is still a Halonic run: Runs, the receipt, budgets and
96
+ * the inbox read these events as they read the built-in agent loop's, so a
97
+ * harness has no event types of its own.
98
+ *
99
+ * The engine adds the run fields (`runId`, `seq`, `at`) and the workflow
100
+ * `state` the agent runs in, then writes the event to the run's log.
101
+ *
102
+ * - `agent.started` and `agent.finished` with a `parent` report a subagent.
103
+ * The engine writes the task's own `agent.started` before it calls
104
+ * `start`; the stream ends with the task's own `agent.finished`, without a
105
+ * `parent`, whose `output` is the agent's result.
106
+ * - `llm.request`, `llm.response` and `llm.fallback` report model calls, with
107
+ * their token use and cost.
108
+ * - `knowledge.searched`, `tool.called` and `tool.result` report tool use.
109
+ * - `approval.requested` asks a person for an OK; the harness waits until
110
+ * `send` brings the answer. The built-in loop sets `resume`, so the run can
111
+ * continue after a restart; a program can't be resumed, so a program
112
+ * harness leaves it out.
113
+ *
114
+ * `approval.resolved` isn't here: the engine writes it when a person answers,
115
+ * and passes the answer on with `send`.
116
+ *
117
+ * Each model call and tool call is recorded once. A call that goes through
118
+ * the Halonic bridge is recorded by the bridge, so a harness reports only the
119
+ * calls its program makes elsewhere. The built-in loop calls the model port
120
+ * and Halonic's tools directly, so it reports all of its own.
121
+ */
122
+ export type HarnessEvent = Omit<RunEventOf<"agent.started">, "state"> | RunEventOf<"llm.request"> | RunEventOf<"llm.response"> | RunEventOf<"llm.fallback"> | RunEventOf<"knowledge.searched"> | RunEventOf<"tool.called"> | RunEventOf<"tool.result"> | (Omit<RunEventOf<"approval.requested">, "state" | "resume"> & {
123
+ resume?: AgentResume;
124
+ }) | Omit<RunEventOf<"agent.finished">, "state">;
125
+ /** What `send` passes to a running harness. */
126
+ export type HarnessInput =
127
+ /** A person's answer to a question the agent asked, or the next message of a chat. */
128
+ {
129
+ type: "answer";
130
+ text: string;
131
+ }
132
+ /** A person's decision on the `approval.requested` event with this `callId`. */
133
+ | {
134
+ type: "approval";
135
+ callId: string;
136
+ approved: boolean;
137
+ comment?: string;
138
+ };
139
+ /**
140
+ * One harness run: its events, read with `for await`, and the way to answer
141
+ * it or stop it.
142
+ *
143
+ * The stream ends with the task agent's `agent.finished` and yields nothing
144
+ * after it. A run that fails or is cancelled ends the stream with an error
145
+ * instead. An error never contains the bridge token.
146
+ */
147
+ export interface HarnessRun extends AsyncIterable<HarnessEvent> {
148
+ /**
149
+ * Passes a person's answer or approval decision to the run.
150
+ *
151
+ * @throws when the run has ended, or no `approval.requested` with that `callId` is waiting
152
+ */
153
+ send(input: HarnessInput): Promise<void>;
154
+ /** Stops the run. Resolves once every program it started has stopped; does nothing on a run that has ended. */
155
+ cancel(): Promise<void>;
156
+ }
157
+ /**
158
+ * What drives an agent: Halonic's own agent loop, Claude Code or Codex. An
159
+ * agent's file picks one by `id`.
160
+ *
161
+ * Every harness runs behind Halonic's `Sandbox` port and reaches Halonic
162
+ * only through the bridge, so integrations, secrets and approvals stay in
163
+ * Halonic. The built-in loop starts no program for the agent: it calls the
164
+ * model port and Halonic's tools directly, ignores `bridge`, and uses
165
+ * `session` only to start the stdio connectors a workspace names. On a
166
+ * target that can't start programs, such as a cloud worker, the session's
167
+ * `start` throws, so the same loop runs there without stdio connectors.
168
+ *
169
+ * @example
170
+ * if ((await harness.detect()).status !== "ready") return;
171
+ * const extra = harness.environment?.(bridge, profile) ?? {};
172
+ * const session = await sandbox.open({ ...profile, env: addHarnessEnvironment(profile.env, extra) });
173
+ * const run = harness.start(task, session, bridge);
174
+ * for await (const event of run) {
175
+ * if (event.type === "approval.requested") await run.send(await askPerson(event));
176
+ * else record(event);
177
+ * }
178
+ */
179
+ export interface Harness {
180
+ /** The value of `harness` in an agent's file, such as "claude-code". */
181
+ readonly id: string;
182
+ /** The name a person reads, such as "Claude Code". */
183
+ readonly name: string;
184
+ /**
185
+ * Finds the harness's program on this machine, checks its version and,
186
+ * where the program can tell, whether someone is signed in to it. Never
187
+ * throws: a problem is a {@link HarnessDetection}.
188
+ */
189
+ detect(): Promise<HarnessDetection>;
190
+ /**
191
+ * The environment variables the harness's program needs, such as the
192
+ * bridge's address, the token header and the program's own settings and
193
+ * temp folders (requirement `ports.harness-environment`). The engine calls
194
+ * it before it opens the sandbox and adds the result to the profile's `env`
195
+ * with {@link addHarnessEnvironment}, so `session.profile` stays exactly
196
+ * what the program gets.
197
+ *
198
+ * Optional: the built-in loop starts no program, so it has none.
199
+ */
200
+ environment?(bridge: HarnessBridge, folders: Pick<SandboxProfile, "workingFolder" | "tempFolder" | "settingsFolder">): Record<string, string>;
201
+ /**
202
+ * Starts the agent on `task` inside the sandbox `session`, pointed at the
203
+ * run's `bridge`. Returns at once; a program that can't start ends the
204
+ * stream with an error.
205
+ */
206
+ start(task: HarnessTask, session: SandboxSession, bridge: HarnessBridge): HarnessRun;
207
+ /**
208
+ * How a person signs in to the harness's program for one agent, with the
209
+ * program's own sign-in (requirement `ports.harness-sign-in`). Studio runs
210
+ * it in a terminal the person can see, and `halonic doctor` shows it.
211
+ *
212
+ * Optional: the built-in loop has no sign-in of its own.
213
+ */
214
+ readonly signIn?: HarnessSignIn;
215
+ }
216
+ /**
217
+ * The program's own sign-in, pointed at one agent's settings folder. Each
218
+ * agent signs in on its own, so a run reaches only its own sign-in; the
219
+ * person's own is never copied there.
220
+ *
221
+ * @example
222
+ * // Claude Code: CLAUDE_CONFIG_DIR=<agent's folder> claude auth login
223
+ * const { program, args, folderVariable } = harness.signIn;
224
+ * start(program, args, { [folderVariable]: profile.settingsFolder });
225
+ */
226
+ export interface HarnessSignIn {
227
+ /** The program, by the name Halonic finds it under, such as "claude". */
228
+ readonly program: string;
229
+ /** What it is asked to sign in, such as `["auth", "login"]`. */
230
+ readonly args: readonly string[];
231
+ /**
232
+ * The environment variable that points the program at the agent's
233
+ * settings folder, such as "CLAUDE_CONFIG_DIR": the same one
234
+ * `environment()` sets for a run.
235
+ */
236
+ readonly folderVariable: string;
237
+ }
238
+ /**
239
+ * The profile's environment with a harness's variables added (requirement
240
+ * `ports.harness-environment`). A harness may only add: a name the engine
241
+ * already set is an error, so a harness can't quietly replace `PATH` or
242
+ * `HOME`. Names are compared without regard to case, because Windows treats
243
+ * `Path` and `PATH` as one variable. For the same reason a harness may not set
244
+ * two names that differ only in case: which one wins would depend on the
245
+ * platform.
246
+ *
247
+ * @throws Error naming the variables in question, never their values, which may hold the run token
248
+ */
249
+ export declare function addHarnessEnvironment(engine: Readonly<Record<string, string>>, harness: Readonly<Record<string, string>>): Record<string, string>;
250
+ export {};
@@ -0,0 +1,45 @@
1
+ /** Version of the {@link Harness} port. A breaking change bumps it and comes with an ADR. */
2
+ export const harnessVersion = 2;
3
+ /**
4
+ * The request header that carries the run's bridge token. The token has a
5
+ * header of its own because `Authorization` isn't free: with a subscription,
6
+ * it carries the person's own sign-in, which the bridge passes on unread.
7
+ * Never put the token in the URL, because paths end up in logs.
8
+ */
9
+ export const harnessBridgeTokenHeader = "x-halonic-run-token";
10
+ /**
11
+ * The profile's environment with a harness's variables added (requirement
12
+ * `ports.harness-environment`). A harness may only add: a name the engine
13
+ * already set is an error, so a harness can't quietly replace `PATH` or
14
+ * `HOME`. Names are compared without regard to case, because Windows treats
15
+ * `Path` and `PATH` as one variable. For the same reason a harness may not set
16
+ * two names that differ only in case: which one wins would depend on the
17
+ * platform.
18
+ *
19
+ * @throws Error naming the variables in question, never their values, which may hold the run token
20
+ */
21
+ export function addHarnessEnvironment(engine, harness) {
22
+ const twice = namesSetTwice(Object.keys(harness));
23
+ if (twice.length > 0) {
24
+ throw new Error(`The harness sets environment variables that differ only in case: ${twice.join(", ")}`);
25
+ }
26
+ const engineNames = new Set(Object.keys(engine).map((name) => name.toUpperCase()));
27
+ const clashes = Object.keys(harness).filter((name) => engineNames.has(name.toUpperCase()));
28
+ if (clashes.length > 0) {
29
+ throw new Error(`The harness sets environment variables Halonic already sets: ${clashes.join(", ")}`);
30
+ }
31
+ return { ...engine, ...harness };
32
+ }
33
+ /** The names that share their spelling, apart from case, with an earlier name. */
34
+ function namesSetTwice(names) {
35
+ const seen = new Set();
36
+ const twice = [];
37
+ for (const name of names) {
38
+ const key = name.toUpperCase();
39
+ if (seen.has(key))
40
+ twice.push(name);
41
+ else
42
+ seen.add(key);
43
+ }
44
+ return twice;
45
+ }
@@ -0,0 +1,27 @@
1
+ /** Version of the {@link HttpClient} port. A breaking change bumps it and comes with an ADR. */
2
+ export declare const httpClientVersion = 1;
3
+ /**
4
+ * Outbound HTTP for adapters and the host: model APIs, HTTP connectors,
5
+ * Google, webhooks. Replaces the old `FetchLike`. The same signature as the
6
+ * Web `fetch`, so most adapters wrap it directly. Some refuse addresses:
7
+ * the container target refuses loopback, link-local and private addresses
8
+ * unless a connector is explicitly allowed.
9
+ *
10
+ * An adapter that refuses addresses checks every redirect hop, and the
11
+ * address a host name resolves to when it connects, not only the first URL.
12
+ * Otherwise a redirect or a DNS answer that changes between check and
13
+ * connect (DNS rebinding) gets around it.
14
+ *
15
+ * Every adapter passes `init.redirect` and `init.signal` through to the
16
+ * request. Callers rely on both: `redirect: "error"` keeps a bearer token
17
+ * from following a redirect to another address, and `signal` is how they
18
+ * put a time limit on a request.
19
+ */
20
+ export interface HttpClient {
21
+ /**
22
+ * Sends one request. An HTTP error status still resolves; check `ok`.
23
+ *
24
+ * @throws when the network fails, the request is aborted or the address is refused
25
+ */
26
+ fetch(url: string, init?: RequestInit): Promise<Response>;
27
+ }
@@ -0,0 +1,2 @@
1
+ /** Version of the {@link HttpClient} port. A breaking change bumps it and comes with an ADR. */
2
+ export const httpClientVersion = 1;