@halonicjs/testing 0.0.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (438) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +5 -0
  3. package/README.md +41 -1
  4. package/dist/adapters/http-kit/src/address-checking.d.ts +19 -0
  5. package/dist/adapters/http-kit/src/address-checking.js +1 -0
  6. package/dist/adapters/http-kit/src/address-class.d.ts +34 -0
  7. package/dist/adapters/http-kit/src/address-class.js +109 -0
  8. package/dist/adapters/http-kit/src/index.d.ts +3 -0
  9. package/dist/adapters/http-kit/src/index.js +2 -0
  10. package/dist/adapters/http-kit/src/ip-address.d.ts +23 -0
  11. package/dist/adapters/http-kit/src/ip-address.js +89 -0
  12. package/dist/adapters/integration-kit/src/auth-placement.d.ts +40 -0
  13. package/dist/adapters/integration-kit/src/auth-placement.js +102 -0
  14. package/dist/adapters/integration-kit/src/current-secret-forms.d.ts +28 -0
  15. package/dist/adapters/integration-kit/src/current-secret-forms.js +60 -0
  16. package/dist/adapters/integration-kit/src/declaration.d.ts +15 -0
  17. package/dist/adapters/integration-kit/src/declaration.js +78 -0
  18. package/dist/adapters/integration-kit/src/host.d.ts +34 -0
  19. package/dist/adapters/integration-kit/src/host.js +31 -0
  20. package/dist/adapters/integration-kit/src/index.d.ts +16 -0
  21. package/dist/adapters/integration-kit/src/index.js +22 -0
  22. package/dist/adapters/integration-kit/src/leak-attempt.d.ts +16 -0
  23. package/dist/adapters/integration-kit/src/leak-attempt.js +19 -0
  24. package/dist/adapters/integration-kit/src/limited-http.d.ts +55 -0
  25. package/dist/adapters/integration-kit/src/limited-http.js +225 -0
  26. package/dist/adapters/integration-kit/src/load-problem.d.ts +20 -0
  27. package/dist/adapters/integration-kit/src/load-problem.js +1 -0
  28. package/dist/adapters/integration-kit/src/loader.d.ts +131 -0
  29. package/dist/adapters/integration-kit/src/loader.js +251 -0
  30. package/dist/adapters/integration-kit/src/local-address.d.ts +15 -0
  31. package/dist/adapters/integration-kit/src/local-address.js +25 -0
  32. package/dist/adapters/integration-kit/src/own-request.d.ts +33 -0
  33. package/dist/adapters/integration-kit/src/own-request.js +36 -0
  34. package/dist/adapters/integration-kit/src/plugin-load.d.ts +14 -0
  35. package/dist/adapters/integration-kit/src/plugin-load.js +58 -0
  36. package/dist/adapters/integration-kit/src/policy.d.ts +83 -0
  37. package/dist/adapters/integration-kit/src/policy.js +37 -0
  38. package/dist/adapters/integration-kit/src/request-body.d.ts +38 -0
  39. package/dist/adapters/integration-kit/src/request-body.js +68 -0
  40. package/dist/adapters/integration-kit/src/request-log.d.ts +25 -0
  41. package/dist/adapters/integration-kit/src/request-log.js +17 -0
  42. package/dist/adapters/integration-kit/src/response-body.d.ts +27 -0
  43. package/dist/adapters/integration-kit/src/response-body.js +117 -0
  44. package/dist/adapters/integration-kit/src/scoped-tokens.d.ts +14 -0
  45. package/dist/adapters/integration-kit/src/scoped-tokens.js +27 -0
  46. package/dist/adapters/integration-kit/src/secret-filter.d.ts +84 -0
  47. package/dist/adapters/integration-kit/src/secret-filter.js +220 -0
  48. package/dist/adapters/integration-kit/src/secret-in-request.d.ts +62 -0
  49. package/dist/adapters/integration-kit/src/secret-in-request.js +139 -0
  50. package/dist/adapters/integration-kit/src/secret-placement.d.ts +46 -0
  51. package/dist/adapters/integration-kit/src/secret-placement.js +160 -0
  52. package/dist/adapters/integration-kit/src/sign-in-placement.d.ts +29 -0
  53. package/dist/adapters/integration-kit/src/sign-in-placement.js +92 -0
  54. package/dist/adapters/integration-kit/src/wait.d.ts +16 -0
  55. package/dist/adapters/integration-kit/src/wait.js +35 -0
  56. package/dist/core/events/src/add-usage.d.ts +10 -0
  57. package/dist/core/events/src/add-usage.js +27 -0
  58. package/dist/core/events/src/agent-resume.d.ts +24 -0
  59. package/dist/core/events/src/agent-resume.js +1 -0
  60. package/dist/core/events/src/blocked-sites.d.ts +57 -0
  61. package/dist/core/events/src/blocked-sites.js +89 -0
  62. package/dist/core/events/src/home-path.d.ts +13 -0
  63. package/dist/core/events/src/home-path.js +26 -0
  64. package/dist/core/events/src/index.d.ts +17 -0
  65. package/dist/core/events/src/index.js +10 -0
  66. package/dist/core/events/src/run-basics.d.ts +228 -0
  67. package/dist/core/events/src/run-basics.js +1 -0
  68. package/dist/core/events/src/run-event.d.ts +478 -0
  69. package/dist/core/events/src/run-event.js +1 -0
  70. package/dist/core/events/src/run-reads.d.ts +25 -0
  71. package/dist/core/events/src/run-reads.js +44 -0
  72. package/dist/core/events/src/run-sends.d.ts +47 -0
  73. package/dist/core/events/src/run-sends.js +68 -0
  74. package/dist/core/events/src/run-summary.d.ts +108 -0
  75. package/dist/core/events/src/run-summary.js +1 -0
  76. package/dist/core/events/src/sandbox-blocked.d.ts +42 -0
  77. package/dist/core/events/src/sandbox-blocked.js +26 -0
  78. package/dist/core/events/src/sandbox-opened-read.d.ts +17 -0
  79. package/dist/core/events/src/sandbox-opened-read.js +63 -0
  80. package/dist/core/events/src/sandbox-opened.d.ts +94 -0
  81. package/dist/core/events/src/sandbox-opened.js +52 -0
  82. package/dist/core/events/src/summarize.d.ts +14 -0
  83. package/dist/core/events/src/summarize.js +192 -0
  84. package/dist/core/events/src/timeline-entry.d.ts +21 -0
  85. package/dist/core/events/src/timeline-entry.js +106 -0
  86. package/dist/core/events/src/upgrade.d.ts +23 -0
  87. package/dist/core/events/src/upgrade.js +49 -0
  88. package/dist/core/format/src/compact.d.ts +30 -0
  89. package/dist/core/format/src/compact.js +72 -0
  90. package/dist/core/format/src/index.d.ts +39 -0
  91. package/dist/core/format/src/index.js +25 -0
  92. package/dist/core/format/src/integration/index.d.ts +7 -0
  93. package/dist/core/format/src/integration/index.js +10 -0
  94. package/dist/core/format/src/json-schema.d.ts +26 -0
  95. package/dist/core/format/src/json-schema.js +48 -0
  96. package/dist/core/format/src/kind.d.ts +65 -0
  97. package/dist/core/format/src/kind.js +1 -0
  98. package/dist/core/format/src/kinds/agent/kind.d.ts +4 -0
  99. package/dist/core/format/src/kinds/agent/kind.js +10 -0
  100. package/dist/core/format/src/kinds/agent/sandbox-fields.d.ts +99 -0
  101. package/dist/core/format/src/kinds/agent/sandbox-fields.js +216 -0
  102. package/dist/core/format/src/kinds/agent/schema.d.ts +147 -0
  103. package/dist/core/format/src/kinds/agent/schema.js +107 -0
  104. package/dist/core/format/src/kinds/agent/working-folder-start.d.ts +74 -0
  105. package/dist/core/format/src/kinds/agent/working-folder-start.js +312 -0
  106. package/dist/core/format/src/kinds/collection/kind.d.ts +8 -0
  107. package/dist/core/format/src/kinds/collection/kind.js +14 -0
  108. package/dist/core/format/src/kinds/collection/schema.d.ts +89 -0
  109. package/dist/core/format/src/kinds/collection/schema.js +90 -0
  110. package/dist/core/format/src/kinds/connector/is-local.d.ts +10 -0
  111. package/dist/core/format/src/kinds/connector/is-local.js +43 -0
  112. package/dist/core/format/src/kinds/connector/kind.d.ts +4 -0
  113. package/dist/core/format/src/kinds/connector/kind.js +218 -0
  114. package/dist/core/format/src/kinds/connector/schema.d.ts +74 -0
  115. package/dist/core/format/src/kinds/connector/schema.js +143 -0
  116. package/dist/core/format/src/kinds/deployments/kind.d.ts +4 -0
  117. package/dist/core/format/src/kinds/deployments/kind.js +49 -0
  118. package/dist/core/format/src/kinds/deployments/schema.d.ts +77 -0
  119. package/dist/core/format/src/kinds/deployments/schema.js +94 -0
  120. package/dist/core/format/src/kinds/hub/kind.d.ts +4 -0
  121. package/dist/core/format/src/kinds/hub/kind.js +10 -0
  122. package/dist/core/format/src/kinds/hub/schema.d.ts +54 -0
  123. package/dist/core/format/src/kinds/hub/schema.js +34 -0
  124. package/dist/core/format/src/kinds/integration/approved-sign-ins.d.ts +62 -0
  125. package/dist/core/format/src/kinds/integration/approved-sign-ins.js +125 -0
  126. package/dist/core/format/src/kinds/integration/host-key.d.ts +7 -0
  127. package/dist/core/format/src/kinds/integration/host-key.js +8 -0
  128. package/dist/core/format/src/kinds/integration/kind.d.ts +18 -0
  129. package/dist/core/format/src/kinds/integration/kind.js +175 -0
  130. package/dist/core/format/src/kinds/integration/parse-sheet.d.ts +19 -0
  131. package/dist/core/format/src/kinds/integration/parse-sheet.js +24 -0
  132. package/dist/core/format/src/kinds/integration/policy.d.ts +112 -0
  133. package/dist/core/format/src/kinds/integration/policy.js +327 -0
  134. package/dist/core/format/src/kinds/integration/schema.d.ts +410 -0
  135. package/dist/core/format/src/kinds/integration/schema.js +359 -0
  136. package/dist/core/format/src/kinds/integration/sign-in-checks.d.ts +13 -0
  137. package/dist/core/format/src/kinds/integration/sign-in-checks.js +120 -0
  138. package/dist/core/format/src/kinds/integration/sign-in-urls.d.ts +19 -0
  139. package/dist/core/format/src/kinds/integration/sign-in-urls.js +47 -0
  140. package/dist/core/format/src/kinds/knowledge/kind.d.ts +4 -0
  141. package/dist/core/format/src/kinds/knowledge/kind.js +13 -0
  142. package/dist/core/format/src/kinds/knowledge/schema.d.ts +18 -0
  143. package/dist/core/format/src/kinds/knowledge/schema.js +25 -0
  144. package/dist/core/format/src/kinds/models/kind.d.ts +4 -0
  145. package/dist/core/format/src/kinds/models/kind.js +10 -0
  146. package/dist/core/format/src/kinds/models/schema.d.ts +92 -0
  147. package/dist/core/format/src/kinds/models/schema.js +38 -0
  148. package/dist/core/format/src/kinds/plugin/backend.d.ts +22 -0
  149. package/dist/core/format/src/kinds/plugin/backend.js +31 -0
  150. package/dist/core/format/src/kinds/plugin/checks.d.ts +13 -0
  151. package/dist/core/format/src/kinds/plugin/checks.js +137 -0
  152. package/dist/core/format/src/kinds/plugin/kind.d.ts +8 -0
  153. package/dist/core/format/src/kinds/plugin/kind.js +16 -0
  154. package/dist/core/format/src/kinds/plugin/problems.d.ts +24 -0
  155. package/dist/core/format/src/kinds/plugin/problems.js +65 -0
  156. package/dist/core/format/src/kinds/plugin/schema.d.ts +672 -0
  157. package/dist/core/format/src/kinds/plugin/schema.js +261 -0
  158. package/dist/core/format/src/kinds/plugin/setting-values.d.ts +17 -0
  159. package/dist/core/format/src/kinds/plugin/setting-values.js +38 -0
  160. package/dist/core/format/src/kinds/plugin/ui-checks.d.ts +8 -0
  161. package/dist/core/format/src/kinds/plugin/ui-checks.js +85 -0
  162. package/dist/core/format/src/kinds/provider/kind.d.ts +4 -0
  163. package/dist/core/format/src/kinds/provider/kind.js +24 -0
  164. package/dist/core/format/src/kinds/provider/schema.d.ts +17 -0
  165. package/dist/core/format/src/kinds/provider/schema.js +22 -0
  166. package/dist/core/format/src/kinds/routine/kind.d.ts +8 -0
  167. package/dist/core/format/src/kinds/routine/kind.js +62 -0
  168. package/dist/core/format/src/kinds/routine/schema.d.ts +94 -0
  169. package/dist/core/format/src/kinds/routine/schema.js +115 -0
  170. package/dist/core/format/src/kinds/routine/webhook-headers.d.ts +9 -0
  171. package/dist/core/format/src/kinds/routine/webhook-headers.js +26 -0
  172. package/dist/core/format/src/kinds/runtime/kind.d.ts +4 -0
  173. package/dist/core/format/src/kinds/runtime/kind.js +13 -0
  174. package/dist/core/format/src/kinds/runtime/schema.d.ts +10 -0
  175. package/dist/core/format/src/kinds/runtime/schema.js +12 -0
  176. package/dist/core/format/src/kinds/skill/kind.d.ts +4 -0
  177. package/dist/core/format/src/kinds/skill/kind.js +10 -0
  178. package/dist/core/format/src/kinds/skill/schema.d.ts +17 -0
  179. package/dist/core/format/src/kinds/skill/schema.js +17 -0
  180. package/dist/core/format/src/kinds/skill/scripts-folder.d.ts +27 -0
  181. package/dist/core/format/src/kinds/skill/scripts-folder.js +37 -0
  182. package/dist/core/format/src/kinds/workflow/kind.d.ts +8 -0
  183. package/dist/core/format/src/kinds/workflow/kind.js +14 -0
  184. package/dist/core/format/src/kinds/workflow/schema.d.ts +162 -0
  185. package/dist/core/format/src/kinds/workflow/schema.js +106 -0
  186. package/dist/core/format/src/kinds/workflow-test/kind.d.ts +4 -0
  187. package/dist/core/format/src/kinds/workflow-test/kind.js +14 -0
  188. package/dist/core/format/src/kinds/workflow-test/schema.d.ts +67 -0
  189. package/dist/core/format/src/kinds/workflow-test/schema.js +59 -0
  190. package/dist/core/format/src/kinds/workspace/kind.d.ts +4 -0
  191. package/dist/core/format/src/kinds/workspace/kind.js +10 -0
  192. package/dist/core/format/src/kinds/workspace/schema.d.ts +72 -0
  193. package/dist/core/format/src/kinds/workspace/schema.js +66 -0
  194. package/dist/core/format/src/parse-file.d.ts +69 -0
  195. package/dist/core/format/src/parse-file.js +105 -0
  196. package/dist/core/format/src/recording/format.d.ts +81 -0
  197. package/dist/core/format/src/recording/format.js +102 -0
  198. package/dist/core/format/src/recording/index.d.ts +1 -0
  199. package/dist/core/format/src/recording/index.js +3 -0
  200. package/dist/core/format/src/registry.d.ts +64 -0
  201. package/dist/core/format/src/registry.js +61 -0
  202. package/dist/core/format/src/reserved.d.ts +20 -0
  203. package/dist/core/format/src/reserved.js +30 -0
  204. package/dist/core/format/src/shared/fields.d.ts +34 -0
  205. package/dist/core/format/src/shared/fields.js +74 -0
  206. package/dist/core/format/src/shared/guard.d.ts +32 -0
  207. package/dist/core/format/src/shared/guard.js +16 -0
  208. package/dist/core/format/src/shared/key-in-value.d.ts +28 -0
  209. package/dist/core/format/src/shared/key-in-value.js +82 -0
  210. package/dist/core/format/src/shared/legacy-keys.d.ts +8 -0
  211. package/dist/core/format/src/shared/legacy-keys.js +17 -0
  212. package/dist/core/format/src/shared/program-start.d.ts +60 -0
  213. package/dist/core/format/src/shared/program-start.js +99 -0
  214. package/dist/core/format/src/shared/relative-path.d.ts +29 -0
  215. package/dist/core/format/src/shared/relative-path.js +50 -0
  216. package/dist/core/format/src/shared/secret-name.d.ts +24 -0
  217. package/dist/core/format/src/shared/secret-name.js +107 -0
  218. package/dist/core/format/src/source.d.ts +16 -0
  219. package/dist/core/format/src/source.js +73 -0
  220. package/dist/core/ports/src/agent-placement-store.d.ts +74 -0
  221. package/dist/core/ports/src/agent-placement-store.js +27 -0
  222. package/dist/core/ports/src/agent-runs-not-available.d.ts +21 -0
  223. package/dist/core/ports/src/agent-runs-not-available.js +25 -0
  224. package/dist/core/ports/src/blob-store.d.ts +45 -0
  225. package/dist/core/ports/src/blob-store.js +24 -0
  226. package/dist/core/ports/src/cant-try-error.d.ts +35 -0
  227. package/dist/core/ports/src/cant-try-error.js +44 -0
  228. package/dist/core/ports/src/chat.d.ts +127 -0
  229. package/dist/core/ports/src/chat.js +1 -0
  230. package/dist/core/ports/src/clock.d.ts +7 -0
  231. package/dist/core/ports/src/clock.js +2 -0
  232. package/dist/core/ports/src/connection-settings-store.d.ts +57 -0
  233. package/dist/core/ports/src/connection-settings-store.js +2 -0
  234. package/dist/core/ports/src/connector-client.d.ts +303 -0
  235. package/dist/core/ports/src/connector-client.js +19 -0
  236. package/dist/core/ports/src/coordination.d.ts +84 -0
  237. package/dist/core/ports/src/coordination.js +2 -0
  238. package/dist/core/ports/src/definition-store.d.ts +229 -0
  239. package/dist/core/ports/src/definition-store.js +122 -0
  240. package/dist/core/ports/src/digest.d.ts +14 -0
  241. package/dist/core/ports/src/digest.js +2 -0
  242. package/dist/core/ports/src/folder-reader.d.ts +89 -0
  243. package/dist/core/ports/src/folder-reader.js +2 -0
  244. package/dist/core/ports/src/harness-bridge-server.d.ts +198 -0
  245. package/dist/core/ports/src/harness-bridge-server.js +37 -0
  246. package/dist/core/ports/src/harness-sign-in-command.d.ts +27 -0
  247. package/dist/core/ports/src/harness-sign-in-command.js +31 -0
  248. package/dist/core/ports/src/harness.d.ts +283 -0
  249. package/dist/core/ports/src/harness.js +45 -0
  250. package/dist/core/ports/src/host-settings-store.d.ts +116 -0
  251. package/dist/core/ports/src/host-settings-store.js +106 -0
  252. package/dist/core/ports/src/http-client.d.ts +27 -0
  253. package/dist/core/ports/src/http-client.js +2 -0
  254. package/dist/core/ports/src/id-generator.d.ts +14 -0
  255. package/dist/core/ports/src/id-generator.js +2 -0
  256. package/dist/core/ports/src/index.d.ts +45 -0
  257. package/dist/core/ports/src/index.js +44 -0
  258. package/dist/core/ports/src/instruction-trust-store.d.ts +81 -0
  259. package/dist/core/ports/src/instruction-trust-store.js +43 -0
  260. package/dist/core/ports/src/integration.d.ts +242 -0
  261. package/dist/core/ports/src/integration.js +31 -0
  262. package/dist/core/ports/src/knowledge-provider.d.ts +65 -0
  263. package/dist/core/ports/src/knowledge-provider.js +2 -0
  264. package/dist/core/ports/src/llm-cache.d.ts +13 -0
  265. package/dist/core/ports/src/llm-cache.js +2 -0
  266. package/dist/core/ports/src/llm-provider.d.ts +186 -0
  267. package/dist/core/ports/src/llm-provider.js +139 -0
  268. package/dist/core/ports/src/model-price.d.ts +34 -0
  269. package/dist/core/ports/src/model-price.js +25 -0
  270. package/dist/core/ports/src/password-hasher.d.ts +63 -0
  271. package/dist/core/ports/src/password-hasher.js +2 -0
  272. package/dist/core/ports/src/plugin-folder-writer.d.ts +104 -0
  273. package/dist/core/ports/src/plugin-folder-writer.js +95 -0
  274. package/dist/core/ports/src/port-versions.d.ts +47 -0
  275. package/dist/core/ports/src/port-versions.js +80 -0
  276. package/dist/core/ports/src/program-probe.d.ts +69 -0
  277. package/dist/core/ports/src/program-probe.js +2 -0
  278. package/dist/core/ports/src/provider-default-base-url.d.ts +10 -0
  279. package/dist/core/ports/src/provider-default-base-url.js +18 -0
  280. package/dist/core/ports/src/record-store.d.ts +79 -0
  281. package/dist/core/ports/src/record-store.js +108 -0
  282. package/dist/core/ports/src/resource-probe.d.ts +59 -0
  283. package/dist/core/ports/src/resource-probe.js +2 -0
  284. package/dist/core/ports/src/run-executor.d.ts +303 -0
  285. package/dist/core/ports/src/run-executor.js +2 -0
  286. package/dist/core/ports/src/run-failure-error.d.ts +49 -0
  287. package/dist/core/ports/src/run-failure-error.js +47 -0
  288. package/dist/core/ports/src/run-store.d.ts +194 -0
  289. package/dist/core/ports/src/run-store.js +131 -0
  290. package/dist/core/ports/src/run-target-not-found.d.ts +34 -0
  291. package/dist/core/ports/src/run-target-not-found.js +41 -0
  292. package/dist/core/ports/src/sandbox-setting-store.d.ts +68 -0
  293. package/dist/core/ports/src/sandbox-setting-store.js +33 -0
  294. package/dist/core/ports/src/sandbox.d.ts +364 -0
  295. package/dist/core/ports/src/sandbox.js +70 -0
  296. package/dist/core/ports/src/scheduler.d.ts +85 -0
  297. package/dist/core/ports/src/scheduler.js +2 -0
  298. package/dist/core/ports/src/secrets.d.ts +201 -0
  299. package/dist/core/ports/src/secrets.js +200 -0
  300. package/dist/core/ports/src/token-store.d.ts +19 -0
  301. package/dist/core/ports/src/token-store.js +2 -0
  302. package/dist/core/ports/src/tool-approval-store.d.ts +253 -0
  303. package/dist/core/ports/src/tool-approval-store.js +116 -0
  304. package/dist/core/ports/src/trust-store.d.ts +72 -0
  305. package/dist/core/ports/src/trust-store.js +2 -0
  306. package/dist/core/ports/src/unfenced-run-consent-store.d.ts +43 -0
  307. package/dist/core/ports/src/unfenced-run-consent-store.js +2 -0
  308. package/dist/core/ports/src/vcs-status.d.ts +8 -0
  309. package/dist/core/ports/src/vcs-status.js +90 -0
  310. package/dist/core/ports/src/vcs.d.ts +394 -0
  311. package/dist/core/ports/src/vcs.js +48 -0
  312. package/dist/core/schema-kit/src/builders.d.ts +50 -0
  313. package/dist/core/schema-kit/src/builders.js +72 -0
  314. package/dist/core/schema-kit/src/depth.d.ts +15 -0
  315. package/dist/core/schema-kit/src/depth.js +37 -0
  316. package/dist/core/schema-kit/src/index.d.ts +6 -0
  317. package/dist/core/schema-kit/src/index.js +6 -0
  318. package/dist/core/schema-kit/src/issue.d.ts +22 -0
  319. package/dist/core/schema-kit/src/issue.js +23 -0
  320. package/dist/core/schema-kit/src/json-schema.d.ts +23 -0
  321. package/dist/core/schema-kit/src/json-schema.js +22 -0
  322. package/dist/core/schema-kit/src/parse.d.ts +17 -0
  323. package/dist/core/schema-kit/src/parse.js +25 -0
  324. package/dist/core/schema-kit/src/schema.d.ts +12 -0
  325. package/dist/core/schema-kit/src/schema.js +1 -0
  326. package/dist/core/std/src/amount.d.ts +13 -0
  327. package/dist/core/std/src/amount.js +22 -0
  328. package/dist/core/std/src/ascii-host.d.ts +18 -0
  329. package/dist/core/std/src/ascii-host.js +110 -0
  330. package/dist/core/std/src/assert.d.ts +39 -0
  331. package/dist/core/std/src/assert.js +59 -0
  332. package/dist/core/std/src/base64url.d.ts +23 -0
  333. package/dist/core/std/src/base64url.js +65 -0
  334. package/dist/core/std/src/canonical-json.d.ts +18 -0
  335. package/dist/core/std/src/canonical-json.js +56 -0
  336. package/dist/core/std/src/clock.d.ts +27 -0
  337. package/dist/core/std/src/clock.js +33 -0
  338. package/dist/core/std/src/constant-time.d.ts +16 -0
  339. package/dist/core/std/src/constant-time.js +26 -0
  340. package/dist/core/std/src/content-digest.d.ts +24 -0
  341. package/dist/core/std/src/content-digest.js +28 -0
  342. package/dist/core/std/src/deep-clone.d.ts +15 -0
  343. package/dist/core/std/src/deep-clone.js +59 -0
  344. package/dist/core/std/src/deep-equal.d.ts +23 -0
  345. package/dist/core/std/src/deep-equal.js +64 -0
  346. package/dist/core/std/src/emitter.d.ts +42 -0
  347. package/dist/core/std/src/emitter.js +74 -0
  348. package/dist/core/std/src/error-kind.d.ts +88 -0
  349. package/dist/core/std/src/error-kind.js +98 -0
  350. package/dist/core/std/src/hex.d.ts +10 -0
  351. package/dist/core/std/src/hex.js +16 -0
  352. package/dist/core/std/src/hidden-characters.d.ts +19 -0
  353. package/dist/core/std/src/hidden-characters.js +54 -0
  354. package/dist/core/std/src/ids.d.ts +45 -0
  355. package/dist/core/std/src/ids.js +49 -0
  356. package/dist/core/std/src/index.d.ts +30 -0
  357. package/dist/core/std/src/index.js +31 -0
  358. package/dist/core/std/src/keyed-queue.d.ts +18 -0
  359. package/dist/core/std/src/keyed-queue.js +32 -0
  360. package/dist/core/std/src/line-diff.d.ts +83 -0
  361. package/dist/core/std/src/line-diff.js +179 -0
  362. package/dist/core/std/src/line-merge.d.ts +63 -0
  363. package/dist/core/std/src/line-merge.js +138 -0
  364. package/dist/core/std/src/plain-data.d.ts +32 -0
  365. package/dist/core/std/src/plain-data.js +57 -0
  366. package/dist/core/std/src/posix-path.d.ts +61 -0
  367. package/dist/core/std/src/posix-path.js +121 -0
  368. package/dist/core/std/src/public-suffixes.generated.d.ts +9 -0
  369. package/dist/core/std/src/public-suffixes.generated.js +10429 -0
  370. package/dist/core/std/src/registrable-domain.d.ts +10 -0
  371. package/dist/core/std/src/registrable-domain.js +62 -0
  372. package/dist/core/std/src/result.d.ts +55 -0
  373. package/dist/core/std/src/result.js +52 -0
  374. package/dist/core/std/src/secret-scrubber.d.ts +54 -0
  375. package/dist/core/std/src/secret-scrubber.js +124 -0
  376. package/dist/core/std/src/secret-shape.d.ts +20 -0
  377. package/dist/core/std/src/secret-shape.js +53 -0
  378. package/dist/core/std/src/secret-variable-name.d.ts +12 -0
  379. package/dist/core/std/src/secret-variable-name.js +34 -0
  380. package/dist/core/std/src/site-name.d.ts +35 -0
  381. package/dist/core/std/src/site-name.js +111 -0
  382. package/dist/core/std/src/stop-signal.d.ts +44 -0
  383. package/dist/core/std/src/stop-signal.js +77 -0
  384. package/dist/core/std/src/text.d.ts +28 -0
  385. package/dist/core/std/src/text.js +54 -0
  386. package/dist/core/std/src/url-host.d.ts +35 -0
  387. package/dist/core/std/src/url-host.js +170 -0
  388. package/dist/core/std/src/utf8.d.ts +23 -0
  389. package/dist/core/std/src/utf8.js +110 -0
  390. package/dist/core/std/src/version.d.ts +48 -0
  391. package/dist/core/std/src/version.js +103 -0
  392. package/dist/core/yaml/src/depth.d.ts +14 -0
  393. package/dist/core/yaml/src/depth.js +140 -0
  394. package/dist/core/yaml/src/edit-data.d.ts +47 -0
  395. package/dist/core/yaml/src/edit-data.js +286 -0
  396. package/dist/core/yaml/src/edit-text.d.ts +92 -0
  397. package/dist/core/yaml/src/edit-text.js +267 -0
  398. package/dist/core/yaml/src/edit.d.ts +47 -0
  399. package/dist/core/yaml/src/edit.js +198 -0
  400. package/dist/core/yaml/src/index.d.ts +5 -0
  401. package/dist/core/yaml/src/index.js +4 -0
  402. package/dist/core/yaml/src/problem.d.ts +20 -0
  403. package/dist/core/yaml/src/problem.js +1 -0
  404. package/dist/core/yaml/src/read.d.ts +47 -0
  405. package/dist/core/yaml/src/read.js +130 -0
  406. package/dist/core/yaml/src/splice-node.d.ts +47 -0
  407. package/dist/core/yaml/src/splice-node.js +333 -0
  408. package/dist/core/yaml/src/splice.d.ts +13 -0
  409. package/dist/core/yaml/src/splice.js +174 -0
  410. package/dist/core/yaml/src/unsupported.d.ts +26 -0
  411. package/dist/core/yaml/src/unsupported.js +70 -0
  412. package/dist/core/yaml/src/write.d.ts +35 -0
  413. package/dist/core/yaml/src/write.js +44 -0
  414. package/dist/testing/integration/src/canaries.d.ts +14 -0
  415. package/dist/testing/integration/src/canaries.js +17 -0
  416. package/dist/testing/integration/src/checks.d.ts +37 -0
  417. package/dist/testing/integration/src/checks.js +195 -0
  418. package/dist/testing/integration/src/describe.d.ts +35 -0
  419. package/dist/testing/integration/src/describe.js +74 -0
  420. package/dist/testing/integration/src/failure.d.ts +6 -0
  421. package/dist/testing/integration/src/failure.js +8 -0
  422. package/dist/testing/integration/src/fake-wait.d.ts +18 -0
  423. package/dist/testing/integration/src/fake-wait.js +21 -0
  424. package/dist/testing/integration/src/index.d.ts +10 -0
  425. package/dist/testing/integration/src/index.js +11 -0
  426. package/dist/testing/integration/src/load.d.ts +14 -0
  427. package/dist/testing/integration/src/load.js +47 -0
  428. package/dist/testing/integration/src/plugin-folder.d.ts +23 -0
  429. package/dist/testing/integration/src/plugin-folder.js +59 -0
  430. package/dist/testing/integration/src/plugin.d.ts +32 -0
  431. package/dist/testing/integration/src/plugin.js +57 -0
  432. package/dist/testing/integration/src/recording.d.ts +84 -0
  433. package/dist/testing/integration/src/recording.js +164 -0
  434. package/dist/testing/integration/src/run.d.ts +60 -0
  435. package/dist/testing/integration/src/run.js +81 -0
  436. package/dist/testing/integration/src/source-scan.d.ts +16 -0
  437. package/dist/testing/integration/src/source-scan.js +40 -0
  438. package/package.json +34 -3
@@ -0,0 +1,229 @@
1
+ /** Version of the {@link DefinitionStore} and {@link DefinitionSource} ports. A breaking change bumps it and comes with an ADR. */
2
+ export declare const definitionStoreVersion = 2;
3
+ /**
4
+ * Read access to the workspace files (agents, workflows, hubs …), wherever
5
+ * they live: a folder, git, memory or a deployed snapshot. Paths are
6
+ * relative and "/" separated.
7
+ *
8
+ * **Every method refuses an unsafe path** with a `RangeError` before it
9
+ * touches storage: one that is absolute, has a `.`, `..` or empty segment, or
10
+ * contains a backslash or NUL. The port says so, not each adapter, because
11
+ * in the old repo only the Node adapter checked. Refusing `.` keeps `a/./b`
12
+ * from meaning `a/b` in a folder but another key in a key-value store.
13
+ *
14
+ * **Every method also refuses a private entry** with a `RangeError`, and
15
+ * `list()` leaves such entries out instead of throwing. A private entry is
16
+ * a path with a segment that, after the clean-up below, is `.git`,
17
+ * `.studio`, `.env` or `.envrc`, or starts with `.env.` (such as
18
+ * `.env.local`). The clean-up matches segments the way Windows and macOS
19
+ * would open them: it removes the code points HFS+ ignores (as git's
20
+ * `is_hfs_dotgit` does, so `.g\u200Cit` is `.git`), ignores case and
21
+ * removes trailing dots and spaces. Two more kinds of segment are private
22
+ * whatever their name: one that holds a `:`, because NTFS opens
23
+ * `.env::$DATA` as `.env`, and one that holds `~` followed by a digit,
24
+ * because that is how 8.3 short names look (`GIT~1`, `ENV~1.LOC`,
25
+ * `GI3F2A~1`), as git refuses for its own paths.
26
+ *
27
+ * **Any symbolic link** counts as private too, wherever it points, inside
28
+ * the root or not, and so do Windows junctions and other reparse points. A
29
+ * link in any segment counts, not only the last: a store that has links
30
+ * refuses to read, write or remove through one and doesn't list it or
31
+ * anything under it. This keeps the served Studio and agents away from git
32
+ * internals, Halonic's own data and secrets files.
33
+ *
34
+ * A cloud deployment hands out only this read side, so a stolen session can't
35
+ * change what runs.
36
+ */
37
+ export interface DefinitionSource {
38
+ /** Human-readable location, such as "~/workspaces/acme" or "memory:demo". */
39
+ readonly location: string;
40
+ /**
41
+ * Lists the file paths under a directory, recursively and sorted. The
42
+ * paths are relative to the store root, not to `dir`, as in the old
43
+ * adapter. Omit `dir` for the whole store; `""` is an empty path and is
44
+ * refused like any other unsafe path. A directory that doesn't exist
45
+ * gives `[]`. A folder under the root that the account may not read
46
+ * throws an `UnreadableWorkspaceFolderError` naming it, rather than being
47
+ * left out.
48
+ */
49
+ list(dir?: string): Promise<string[]>;
50
+ /** The file's text, or `null` when there is no such file. */
51
+ read(path: string): Promise<string | null>;
52
+ /**
53
+ * Identifier of the current version of the definitions (git commit, content
54
+ * hash). Runs record it so they can be explained and replayed later.
55
+ */
56
+ version(): Promise<string>;
57
+ }
58
+ /**
59
+ * What a caller expects a file to hold before it writes: the digest of the
60
+ * text it last read, or `"absent"` for a file that should not exist yet. The
61
+ * digest is `sha256:` and the 64 lowercase hex characters of the SHA-256 of
62
+ * the text's UTF-8 bytes: a fixed format, not one each store picks, so a
63
+ * caller can work it out from text it got elsewhere (a proposal's snapshot)
64
+ * and a watcher can recognise its own write. `contentDigest` and
65
+ * `matchesExpected` in `@halonicjs/std` work it out and compare it, so every
66
+ * store does both the same way.
67
+ */
68
+ export type ExpectedContent = `sha256:${string}` | "absent";
69
+ /** Options for {@link DefinitionStore.write}. */
70
+ export interface WriteOptions {
71
+ /**
72
+ * Write only if the file still holds this (save model 1.7). Leave it out
73
+ * to replace the file whatever it holds, as setting up a new workspace or
74
+ * checking out a version does. The Studio's saves always pass it.
75
+ */
76
+ readonly expected?: ExpectedContent;
77
+ }
78
+ /**
79
+ * What {@link DefinitionStore.write} did. `changed-on-disk` means the file
80
+ * no longer held what the caller expected, so nothing was written; `current`
81
+ * is its text now, or `null` when it is gone, so the Studio can show
82
+ * Compare without reading it again.
83
+ */
84
+ export type WriteResult = {
85
+ readonly status: "written";
86
+ } | {
87
+ readonly status: "changed-on-disk";
88
+ readonly current: string | null;
89
+ };
90
+ /** Options for {@link DefinitionStore.remove}. */
91
+ export interface RemoveOptions {
92
+ /** Remove only if the file still holds this. Leave it out to remove the file whatever it holds. */
93
+ readonly expected?: ExpectedContent;
94
+ }
95
+ /**
96
+ * What {@link DefinitionStore.remove} did. `changed-on-disk` means the file
97
+ * no longer held what the caller expected, so nothing was removed; `current`
98
+ * is its text now, or `null` when it is gone.
99
+ */
100
+ export type RemoveResult = {
101
+ readonly status: "removed";
102
+ } | {
103
+ readonly status: "changed-on-disk";
104
+ readonly current: string | null;
105
+ };
106
+ /**
107
+ * One workspace file that changed outside Halonic. `removed` means it is gone
108
+ * at the end of the batch; a file removed and created again, as many editors
109
+ * save, is `changed`. A folder that went away gives one `removed` per file
110
+ * that was in it.
111
+ */
112
+ export interface WorkspaceFileChange {
113
+ readonly path: string;
114
+ readonly kind: "changed" | "removed";
115
+ }
116
+ /** Who hears about changes from outside Halonic while a watch is open. */
117
+ export interface DefinitionWatchListener {
118
+ /**
119
+ * One batch of changes, each path at most once, sorted by path. Many
120
+ * changes close together (a checkout touching 50 files) come as one batch.
121
+ */
122
+ changed(changes: readonly WorkspaceFileChange[]): void;
123
+ /** The watch broke (the folder went away, say) and reports nothing more. */
124
+ failed(error: Error): void;
125
+ }
126
+ /** An open watch; see {@link DefinitionStore.watch}. */
127
+ export interface DefinitionWatch {
128
+ /** Stops the watch. No batch is reported after it resolves. */
129
+ close(): Promise<void>;
130
+ }
131
+ /** A {@link DefinitionSource} that can also change the files: the Studio's editors and `halonic serve` use it. */
132
+ export interface DefinitionStore extends DefinitionSource {
133
+ /**
134
+ * Creates or replaces a file, creating folders as needed. With
135
+ * `expected`, it first checks the file still holds what the caller last
136
+ * read and, if not, writes nothing and returns `changed-on-disk`.
137
+ */
138
+ write(path: string, content: string, options?: WriteOptions): Promise<WriteResult>;
139
+ /**
140
+ * Deletes a file. Deleting a file that isn't there is not an error. With
141
+ * `expected`, it first checks the file still holds what the caller last
142
+ * read and, if not, removes nothing and returns `changed-on-disk`, so an
143
+ * edit made since is not deleted.
144
+ */
145
+ remove(path: string, options?: RemoveOptions): Promise<RemoveResult>;
146
+ /**
147
+ * Reports the files that change from outside Halonic (save model 6):
148
+ * another editor, a sync tool, `git pull`. A change is one whose text
149
+ * differs from what the store last saw, so the store's own writes and
150
+ * removes, and a file saved again with the same text, are not reported.
151
+ * Private entries are left out, as in `list()`. A store nothing else can
152
+ * change, such as one in memory, reports nothing.
153
+ */
154
+ watch(listener: DefinitionWatchListener): Promise<DefinitionWatch>;
155
+ }
156
+ /**
157
+ * What a {@link DefinitionSource}'s `list()` throws when the account may not
158
+ * read a folder under the store's root (requirement
159
+ * `ports.unreadable-workspace-folder`). Leaving the folder out instead would
160
+ * hide the agents in it without a word, which is worse than an error.
161
+ *
162
+ * `path` is the folder's workspace path, so a caller can name it without
163
+ * knowing where the store keeps its files. The message is for the log; keep
164
+ * the store's own error in `cause`.
165
+ *
166
+ * Check for it with {@link isUnreadableWorkspaceFolderError}, not
167
+ * `instanceof`: an adapter may be built against its own copy of this package.
168
+ *
169
+ * @example
170
+ * throw new UnreadableWorkspaceFolderError("hubs/support", "The folder can't be read.", { cause });
171
+ */
172
+ export declare class UnreadableWorkspaceFolderError extends Error {
173
+ readonly name = "UnreadableWorkspaceFolderError";
174
+ /** The folder's workspace path: relative and "/" separated, as the port's paths are. */
175
+ readonly path: string;
176
+ /**
177
+ * @param path - the folder's workspace path
178
+ * @param message - for the log
179
+ * @param options - `cause` keeps the error this one wraps
180
+ */
181
+ constructor(path: string, message: string, options?: {
182
+ cause?: unknown;
183
+ });
184
+ }
185
+ /**
186
+ * Whether `value` is an {@link UnreadableWorkspaceFolderError}: an `Error`
187
+ * named "UnreadableWorkspaceFolderError" with a `path`. It works across
188
+ * copies of this package, where `instanceof` doesn't.
189
+ *
190
+ * @example
191
+ * const folder = isUnreadableWorkspaceFolderError(error) ? error.path : null;
192
+ */
193
+ export declare function isUnreadableWorkspaceFolderError(value: unknown): value is UnreadableWorkspaceFolderError;
194
+ /**
195
+ * Refuses a workspace path the `DefinitionSource` port calls unsafe: one that
196
+ * is absolute, has a `.`, `..` or empty segment, or contains a backslash or
197
+ * NUL. Checked before the store is touched, so `a/./b` can never mean `a/b`.
198
+ *
199
+ * @throws RangeError naming the path and what is wrong with it
200
+ */
201
+ export declare function checkWorkspacePath(path: string): void;
202
+ /**
203
+ * Refuses an unsafe path, as {@link checkWorkspacePath} does, and also a
204
+ * private one (see {@link isPrivateWorkspacePath}). Every method that takes a path
205
+ * calls this.
206
+ *
207
+ * @throws RangeError naming the path and what is wrong with it
208
+ */
209
+ export declare function checkPublicWorkspacePath(path: string): void;
210
+ /**
211
+ * Whether a safe path has a private segment, as the port defines it: after
212
+ * removing the code points HFS+ ignores, ignoring case and removing trailing
213
+ * dots and spaces, `.git`, `.studio`, `.env`, `.envrc` or `.env.` and more;
214
+ * or, whatever its name, a segment with a `:` (an NTFS stream) or a `~`
215
+ * followed by a digit (an 8.3 short name).
216
+ */
217
+ export declare function isPrivateWorkspacePath(path: string): boolean;
218
+ /**
219
+ * A path segment the way Windows and macOS would open it, as the private
220
+ * rule above compares names: without the code points HFS+ ignores, with
221
+ * case folded as any file system might fold it, and without trailing dots
222
+ * and spaces. Another folder a store or decorator keeps to itself compares
223
+ * names the same way, so `.Halonic./x` can't get round a check for
224
+ * `.halonic/x`.
225
+ *
226
+ * @example
227
+ * segmentAsOpened(".G\u200CIT. "); // ".git"
228
+ */
229
+ export declare function segmentAsOpened(segment: string): string;
@@ -0,0 +1,122 @@
1
+ /** Version of the {@link DefinitionStore} and {@link DefinitionSource} ports. A breaking change bumps it and comes with an ADR. */
2
+ export const definitionStoreVersion = 2;
3
+ /**
4
+ * What a {@link DefinitionSource}'s `list()` throws when the account may not
5
+ * read a folder under the store's root (requirement
6
+ * `ports.unreadable-workspace-folder`). Leaving the folder out instead would
7
+ * hide the agents in it without a word, which is worse than an error.
8
+ *
9
+ * `path` is the folder's workspace path, so a caller can name it without
10
+ * knowing where the store keeps its files. The message is for the log; keep
11
+ * the store's own error in `cause`.
12
+ *
13
+ * Check for it with {@link isUnreadableWorkspaceFolderError}, not
14
+ * `instanceof`: an adapter may be built against its own copy of this package.
15
+ *
16
+ * @example
17
+ * throw new UnreadableWorkspaceFolderError("hubs/support", "The folder can't be read.", { cause });
18
+ */
19
+ export class UnreadableWorkspaceFolderError extends Error {
20
+ name = "UnreadableWorkspaceFolderError";
21
+ /** The folder's workspace path: relative and "/" separated, as the port's paths are. */
22
+ path;
23
+ /**
24
+ * @param path - the folder's workspace path
25
+ * @param message - for the log
26
+ * @param options - `cause` keeps the error this one wraps
27
+ */
28
+ constructor(path, message, options) {
29
+ super(message, options);
30
+ this.path = path;
31
+ }
32
+ }
33
+ /**
34
+ * Whether `value` is an {@link UnreadableWorkspaceFolderError}: an `Error`
35
+ * named "UnreadableWorkspaceFolderError" with a `path`. It works across
36
+ * copies of this package, where `instanceof` doesn't.
37
+ *
38
+ * @example
39
+ * const folder = isUnreadableWorkspaceFolderError(error) ? error.path : null;
40
+ */
41
+ export function isUnreadableWorkspaceFolderError(value) {
42
+ if (!(value instanceof Error) || value.name !== "UnreadableWorkspaceFolderError")
43
+ return false;
44
+ return typeof value.path === "string";
45
+ }
46
+ // The path rules above, as code, so every adapter refuses exactly the same paths.
47
+ /**
48
+ * Refuses a workspace path the `DefinitionSource` port calls unsafe: one that
49
+ * is absolute, has a `.`, `..` or empty segment, or contains a backslash or
50
+ * NUL. Checked before the store is touched, so `a/./b` can never mean `a/b`.
51
+ *
52
+ * @throws RangeError naming the path and what is wrong with it
53
+ */
54
+ export function checkWorkspacePath(path) {
55
+ if (path.includes("\\") || path.includes("\u0000")) {
56
+ throw new RangeError(`Unsafe workspace path ${JSON.stringify(path)}: no backslash or NUL.`);
57
+ }
58
+ if (path.startsWith("/")) {
59
+ throw new RangeError(`Unsafe workspace path ${JSON.stringify(path)}: it must be relative.`);
60
+ }
61
+ for (const segment of path.split("/")) {
62
+ if (segment === "" || segment === "." || segment === "..") {
63
+ throw new RangeError(`Unsafe workspace path ${JSON.stringify(path)}: no empty, "." or ".." segment.`);
64
+ }
65
+ }
66
+ }
67
+ /**
68
+ * Refuses an unsafe path, as {@link checkWorkspacePath} does, and also a
69
+ * private one (see {@link isPrivateWorkspacePath}). Every method that takes a path
70
+ * calls this.
71
+ *
72
+ * @throws RangeError naming the path and what is wrong with it
73
+ */
74
+ export function checkPublicWorkspacePath(path) {
75
+ checkWorkspacePath(path);
76
+ if (isPrivateWorkspacePath(path)) {
77
+ throw new RangeError(`Private workspace path ${JSON.stringify(path)}: the store doesn't serve it.`);
78
+ }
79
+ }
80
+ /** Code points HFS+ ignores in a name, as in git's `next_hfs_char`. */
81
+ const hfsIgnored = /[\u200C-\u200F\u202A-\u202E\u206A-\u206F\uFEFF]/gu;
82
+ /**
83
+ * Whether a safe path has a private segment, as the port defines it: after
84
+ * removing the code points HFS+ ignores, ignoring case and removing trailing
85
+ * dots and spaces, `.git`, `.studio`, `.env`, `.envrc` or `.env.` and more;
86
+ * or, whatever its name, a segment with a `:` (an NTFS stream) or a `~`
87
+ * followed by a digit (an 8.3 short name).
88
+ */
89
+ export function isPrivateWorkspacePath(path) {
90
+ return path.split("/").some(isPrivateSegment);
91
+ }
92
+ /**
93
+ * A path segment the way Windows and macOS would open it, as the private
94
+ * rule above compares names: without the code points HFS+ ignores, with
95
+ * case folded as any file system might fold it, and without trailing dots
96
+ * and spaces. Another folder a store or decorator keeps to itself compares
97
+ * names the same way, so `.Halonic./x` can't get round a check for
98
+ * `.halonic/x`.
99
+ *
100
+ * @example
101
+ * segmentAsOpened(".G\u200CIT. "); // ".git"
102
+ */
103
+ export function segmentAsOpened(segment) {
104
+ return (segment
105
+ .replace(hfsIgnored, "")
106
+ // Upper case first, so letters that fold to ASCII on some file system match
107
+ // too: a long s to `s`, an `st` ligature to `st`, a dotless i to `i`.
108
+ .toUpperCase()
109
+ .toLowerCase()
110
+ .replace(/[. ]+$/u, ""));
111
+ }
112
+ function isPrivateSegment(segment) {
113
+ if (segment.includes(":") || /~\d/u.test(segment)) {
114
+ return true;
115
+ }
116
+ const name = segmentAsOpened(segment);
117
+ return (name === ".git" ||
118
+ name === ".studio" ||
119
+ name === ".env" ||
120
+ name === ".envrc" ||
121
+ name.startsWith(".env."));
122
+ }
@@ -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,198 @@
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
+ /**
39
+ * @throws KindedError `limit_reached` for an `llm.request` once the run's
40
+ * budget is reached: the bridge then sends the model call nowhere and
41
+ * answers the program with 429 and the error's message
42
+ */
43
+ record(event: BridgeEvent): Promise<void>;
44
+ }
45
+ /**
46
+ * What to do with a tool call before it runs, by the same rules as the
47
+ * built-in loop: the agent's `allow` and `approve` lists, the connection's
48
+ * "allow sending" setting and the workspace's trust. `ask`: run it only once
49
+ * a person says yes. `refused`: don't run it; `reason` goes back to the
50
+ * program as the call's result.
51
+ */
52
+ export type BridgeToolCheck = {
53
+ kind: "run";
54
+ } | {
55
+ kind: "ask";
56
+ } | {
57
+ kind: "refused";
58
+ reason: string;
59
+ };
60
+ /** How a tool call ended: its text result, and whether the tool answered or failed. */
61
+ export interface BridgeToolResult {
62
+ result: string;
63
+ outcome: ToolOutcome;
64
+ }
65
+ /**
66
+ * Halonic's tools for one agent of one run, which the bridge serves over MCP.
67
+ * The engine builds them, so integrations and their secrets stay in Halonic.
68
+ */
69
+ export interface BridgeTools {
70
+ /** The tools the agent is offered, in order. */
71
+ list(): Promise<ToolDefinition[]>;
72
+ /** Checks one call before it runs. A name {@link list} didn't offer is `refused`. */
73
+ check(name: string, args: Record<string, unknown>): Promise<BridgeToolCheck>;
74
+ /**
75
+ * Runs one call that {@link check} allowed, or a person approved. A tool
76
+ * that fails doesn't throw: it ends with `outcome: "error"` and the reason
77
+ * as its result.
78
+ */
79
+ call(name: string, args: Record<string, unknown>, options: {
80
+ signal: AbortSignal;
81
+ }): Promise<BridgeToolResult>;
82
+ }
83
+ /** One call a person has to approve. `tool` is a Halonic tool, or one of the program's own, such as "Bash". */
84
+ export interface BridgeApprovalRequest {
85
+ /** Unique in the run; the bridge makes it up. */
86
+ callId: string;
87
+ tool: string;
88
+ args: unknown;
89
+ }
90
+ /** A person's answer to a {@link BridgeApprovalRequest}. */
91
+ export interface BridgeApprovalDecision {
92
+ approved: boolean;
93
+ comment?: string;
94
+ }
95
+ /**
96
+ * Asks a person for an OK. The engine writes `approval.requested`, waits for
97
+ * the answer and writes `approval.resolved`, as it does for the built-in
98
+ * loop.
99
+ */
100
+ export interface BridgeApprovals {
101
+ /**
102
+ * Resolves with the person's decision.
103
+ *
104
+ * @throws when `signal` aborts first, because the run was cancelled or the program went away
105
+ */
106
+ request(request: BridgeApprovalRequest, options: {
107
+ signal: AbortSignal;
108
+ }): Promise<BridgeApprovalDecision>;
109
+ }
110
+ /** What the engine gives the bridge of one run. */
111
+ export interface HarnessBridgeOptions {
112
+ runId: string;
113
+ /** The agent the bridge's events name. */
114
+ agentId: string;
115
+ /** The providers this agent may reach and how it signs in. A provider not named here is refused. */
116
+ providers: Partial<Record<BridgeProvider, BridgeProviderAccess>>;
117
+ /**
118
+ * A model's price, or `null` when `models.yaml` gives none. Only asked for
119
+ * a provider reached with a key: a keyed call without a price is recorded
120
+ * without a cost (unpriced), and a sign-in call always costs 0. See
121
+ * {@link bridgeCallCharge}.
122
+ */
123
+ price(provider: BridgeProvider, model: string): ModelPrice | null;
124
+ recorder: BridgeRecorder;
125
+ tools: BridgeTools;
126
+ approvals: BridgeApprovals;
127
+ /** Aborting it closes the bridge, as {@link OpenHarnessBridge.close} does. */
128
+ signal?: AbortSignal;
129
+ }
130
+ /**
131
+ * The `cost` the bridge records on a model call's `llm.response`, in the
132
+ * workspace's budget currency (requirement `ports.harness-bridge-server`).
133
+ * A sign-in call costs 0, because the person's subscription pays. A keyed call
134
+ * costs its tokens at the model's price ({@link priceOf}), or is `undefined` (unpriced) when the
135
+ * model has no price.
136
+ *
137
+ * @deprecated Use {@link bridgeCallCharge}, which also marks a sign-in call
138
+ * `paidBy: "subscription"`. Recording this cost alone writes a sign-in call
139
+ * as a free call, so the run never counts it in `subscriptionCalls`.
140
+ */
141
+ export declare function bridgeCallCost(access: BridgeProviderAccess, price: ModelPrice | null, usage: Usage): number | undefined;
142
+ /** What the bridge puts on a model call's `llm.response` about its price: see {@link bridgeCallCharge}. */
143
+ export type BridgeCallCharge = Pick<Extract<BridgeEvent, {
144
+ type: "llm.response";
145
+ }>, "cost" | "paidBy">;
146
+ /**
147
+ * The `cost` and `paidBy` the bridge records on a model call's
148
+ * `llm.response` (requirement `ports.harness-bridge-server`). A sign-in call
149
+ * gets `cost: 0` and `paidBy: "subscription"`, so the run counts it in
150
+ * `subscriptionCalls`. A keyed call gets the cost from {@link bridgeCallCost},
151
+ * or nothing when its model has no price.
152
+ *
153
+ * @example
154
+ * recorder.record({ type: "llm.response", ...call, ...bridgeCallCharge(access, price, usage) });
155
+ */
156
+ export declare function bridgeCallCharge(access: BridgeProviderAccess, price: ModelPrice | null, usage: Usage): BridgeCallCharge;
157
+ /** A bridge that is serving one run. */
158
+ export interface OpenHarnessBridge extends HarnessBridge {
159
+ /**
160
+ * Stops serving: refuses new requests, ends those in flight and their
161
+ * calls to the provider, and resolves when they have ended and recorded
162
+ * what they had to, or after the bridge's close time limit for a request
163
+ * that doesn't end. Nothing is recorded for the run once it resolves.
164
+ * Safe to call twice.
165
+ */
166
+ close(): Promise<void>;
167
+ }
168
+ /**
169
+ * Opens the Halonic bridge for one run: a server on loopback, or on a Unix
170
+ * socket only this user can open, that passes the
171
+ * program's model requests to the provider and serves Halonic's tools and
172
+ * approvals over MCP (requirement `ports.harness-bridge-server`). The engine
173
+ * opens it before the sandbox and closes it when the run ends. It is a port
174
+ * because core can't import the adapter that serves it.
175
+ *
176
+ * Only a request with the run's token in the `harnessBridgeTokenHeader`
177
+ * header is served. The token, a provider key and a person's sign-in never
178
+ * appear in an event, a log line or an error.
179
+ *
180
+ * @example
181
+ * const bridge = await server.open({ runId, agentId, providers, price, recorder, tools, approvals, signal });
182
+ * try {
183
+ * await runHarness(bridge);
184
+ * } finally {
185
+ * await bridge.close();
186
+ * }
187
+ */
188
+ export interface HarnessBridgeServer {
189
+ /**
190
+ * Starts serving one run on a free loopback port, or on a new Unix socket
191
+ * of its own when the adapter is set up for sockets. A socket bridge gives
192
+ * its path as {@link HarnessBridge.socketPath}. One that can't create its
193
+ * socket fails: it never falls back to a loopback port.
194
+ *
195
+ * @throws when it can't listen
196
+ */
197
+ open(options: HarnessBridgeOptions): Promise<OpenHarnessBridge>;
198
+ }