@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,74 @@
1
+ import { basename } from "node:path";
2
+ import { describe, expect, it } from "vitest";
3
+ import { checkAbort, checkCase, checkConnectIsQuiet, checkDeclaration, checkHostWait, checkPolicy, checkProviderErrors, checkSources, } from "./checks.js";
4
+ import { checkPluginManifest, pluginBackendSubject, } from "./plugin.js";
5
+ /**
6
+ * Registers the conformance suite for one integration with Vitest. Every
7
+ * integration package calls it once from a test file.
8
+ *
9
+ * @example
10
+ * describeIntegrationConformance({
11
+ * integration: weather,
12
+ * sheet: JSON.parse(readFileSync("integration.json", "utf8")), // the sheet the build writes
13
+ * recordings: [forecastGhent],
14
+ * cases: [{ tool: "forecast", scenario: "forecast-ghent", args: { city: "Ghent" } }],
15
+ * sources: { "src/index.ts": readFileSync("src/index.ts", "utf8") },
16
+ * });
17
+ */
18
+ export function describeIntegrationConformance(subject) {
19
+ describe(`integration conformance: ${subject.integration.name}`, () => {
20
+ integrationChecks(() => subject, subject.cases, subject.sources !== undefined);
21
+ });
22
+ }
23
+ /**
24
+ * Registers the conformance suite for one plugin folder with Vitest: its
25
+ * manifest, then every integration check on its backend, if it has one.
26
+ * Every plugin calls it once from a test file.
27
+ *
28
+ * @example
29
+ * describePluginConformance({
30
+ * folder: fileURLToPath(new URL("..", import.meta.url)),
31
+ * backend: weather, // what backend/index.js exports
32
+ * recordings: [forecastGhent],
33
+ * cases: [{ tool: "forecast", scenario: "forecast-ghent", args: { place: "Ghent" } }],
34
+ * });
35
+ */
36
+ export function describePluginConformance(subject) {
37
+ describe(`plugin conformance: ${basename(subject.folder)}`, () => {
38
+ it("has one valid manifest for this SDK, and its files and backend code match it", () => passes(() => checkPluginManifest(subject)));
39
+ if (subject.backend !== undefined) {
40
+ describe("backend", () => {
41
+ integrationChecks(() => pluginBackendSubject(subject), subject.cases ?? [], true);
42
+ });
43
+ }
44
+ });
45
+ }
46
+ /**
47
+ * The integration checks, for an integration or a plugin's backend. The
48
+ * subject is read when each test runs, so a broken plugin folder fails its
49
+ * tests instead of the whole file.
50
+ */
51
+ function integrationChecks(subjectOf, cases, withSources) {
52
+ it("is what its sheet declares: name, version, tools and their risk", () => passes(() => checkDeclaration(subjectOf())));
53
+ it("declares exact https hosts and ties every secret to them", () => passes(() => checkPolicy(subjectOf())));
54
+ it("sends nothing when it connects, and closes twice safely", () => passes(() => checkConnectIsQuiet(subjectOf())));
55
+ it("waits through a host that caps the pause and stops on abort", () => passes(() => checkHostWait(subjectOf())));
56
+ if (withSources) {
57
+ it("uses nothing that reaches past its host", () => passes(() => checkSources(subjectOf())));
58
+ }
59
+ for (const [index, toolCase] of cases.entries()) {
60
+ const name = `${toolCase.tool} (case ${index + 1})`;
61
+ it(`${name} answers from its recording without leaking a secret`, () => passes(() => checkCase(subjectOf(), toolCase)));
62
+ it(`${name} stops when its signal is aborted`, () => passes(() => checkAbort(subjectOf(), toolCase)));
63
+ it(`${name} doesn't pass a provider's error body through`, () => passes(() => checkProviderErrors(subjectOf(), toolCase)));
64
+ }
65
+ }
66
+ /**
67
+ * Runs one check as an assertion, so the test counts it (a test without an
68
+ * assertion fails) and a failed check still shows its own message.
69
+ */
70
+ export async function passes(check) {
71
+ await expect((async () => {
72
+ await check();
73
+ })()).resolves.toBeUndefined();
74
+ }
@@ -0,0 +1,6 @@
1
+ /** A conformance check failed. The message says what to fix. */
2
+ export declare class ConformanceFailure extends Error {
3
+ readonly name = "ConformanceFailure";
4
+ }
5
+ /** Fails the current check with a message that says what to fix. */
6
+ export declare function fail(message: string): never;
@@ -0,0 +1,8 @@
1
+ /** A conformance check failed. The message says what to fix. */
2
+ export class ConformanceFailure extends Error {
3
+ name = "ConformanceFailure";
4
+ }
5
+ /** Fails the current check with a message that says what to fix. */
6
+ export function fail(message) {
7
+ throw new ConformanceFailure(message);
8
+ }
@@ -0,0 +1,18 @@
1
+ import type { IntegrationHost } from "../../../core/ports/src/index.js";
2
+ /** A `wait` for tests, and the pauses it was asked for. */
3
+ export interface FakeWait {
4
+ readonly wait: IntegrationHost["wait"];
5
+ /** Each pause, clamped as the real host clamps it, in call order. */
6
+ readonly waits: readonly number[];
7
+ }
8
+ /**
9
+ * A `wait` that resolves at once and records the clamped pause, so a test
10
+ * can say "waited 2 000 ms" without waiting. Like the real host, it rejects
11
+ * with `signal.reason` when `signal` is already aborted.
12
+ *
13
+ * @example
14
+ * const fake = fakeWait();
15
+ * await fake.wait(Infinity);
16
+ * fake.waits; // [30000]
17
+ */
18
+ export declare function fakeWait(): FakeWait;
@@ -0,0 +1,21 @@
1
+ import { clampWaitMs } from "../../../adapters/integration-kit/src/index.js";
2
+ /**
3
+ * A `wait` that resolves at once and records the clamped pause, so a test
4
+ * can say "waited 2 000 ms" without waiting. Like the real host, it rejects
5
+ * with `signal.reason` when `signal` is already aborted.
6
+ *
7
+ * @example
8
+ * const fake = fakeWait();
9
+ * await fake.wait(Infinity);
10
+ * fake.waits; // [30000]
11
+ */
12
+ export function fakeWait() {
13
+ const waits = [];
14
+ return {
15
+ waits,
16
+ wait: async (ms, signal) => {
17
+ signal?.throwIfAborted();
18
+ waits.push(clampWaitMs(ms));
19
+ },
20
+ };
21
+ }
@@ -0,0 +1,10 @@
1
+ export { canaryFor, canaryMark, canarySecrets } from "./canaries.js";
2
+ export { checkAbort, checkCase, checkConnectIsQuiet, checkDeclaration, checkHostWait, checkPolicy, checkProviderErrors, checkSources, } from "./checks.js";
3
+ export { describeIntegrationConformance, describePluginConformance } from "./describe.js";
4
+ export { ConformanceFailure } from "./failure.js";
5
+ export { type FakeWait, fakeWait } from "./fake-wait.js";
6
+ export { checkPluginManifest, type PluginConformanceSubject, pluginBackendSubject, } from "./plugin.js";
7
+ export { type ManifestFile, type PluginFolder, readPluginFolder } from "./plugin-folder.js";
8
+ export { NoRecordingError, type RecordedBody, type RecordedExchange, type RecordingFile, type ReplayedRequest, recordingFormat, replayTransport, } from "./recording.js";
9
+ export { type CaseRun, type ConformanceSubject, runCase, scenarioOf, type ToolCase, tripNetworkGlobals, } from "./run.js";
10
+ export { type SourceFinding, scanIntegrationSource } from "./source-scan.js";
@@ -0,0 +1,11 @@
1
+ // The public API of @halonicjs/testing-integration. Internal code imports by relative path.
2
+ export { canaryFor, canaryMark, canarySecrets } from "./canaries.js";
3
+ export { checkAbort, checkCase, checkConnectIsQuiet, checkDeclaration, checkHostWait, checkPolicy, checkProviderErrors, checkSources, } from "./checks.js";
4
+ export { describeIntegrationConformance, describePluginConformance } from "./describe.js";
5
+ export { ConformanceFailure } from "./failure.js";
6
+ export { fakeWait } from "./fake-wait.js";
7
+ export { checkPluginManifest, pluginBackendSubject, } from "./plugin.js";
8
+ export { readPluginFolder } from "./plugin-folder.js";
9
+ export { NoRecordingError, recordingFormat, replayTransport, } from "./recording.js";
10
+ export { runCase, scenarioOf, tripNetworkGlobals, } from "./run.js";
11
+ export { scanIntegrationSource } from "./source-scan.js";
@@ -0,0 +1,14 @@
1
+ import { type LoadedIntegration } from "../../../adapters/integration-kit/src/index.js";
2
+ import { type IntegrationPolicy, type IntegrationSheet } from "../../../core/format/src/integration/index.js";
3
+ import type { HttpClient, TokenStore } from "../../../core/ports/src/index.js";
4
+ import type { ConformanceSubject } from "./run.js";
5
+ /**
6
+ * Loads the subject the way Halonic does, through the kit's loader, with a
7
+ * canary for every secret in its sheet and every need available. Fails the
8
+ * check with each problem the loader found.
9
+ */
10
+ export declare function loadSubject(subject: ConformanceSubject, transport: HttpClient, tokens?: TokenStore): LoadedIntegration;
11
+ /** The subject's sheet, checked. Fails the check when it doesn't pass. */
12
+ export declare function sheetOf(subject: ConformanceSubject): IntegrationSheet;
13
+ /** What the kit enforces for the subject, with its settings. Fails the check when a host doesn't resolve. */
14
+ export declare function policyOf(subject: ConformanceSubject): IntegrationPolicy;
@@ -0,0 +1,47 @@
1
+ import { loadIntegration, } from "../../../adapters/integration-kit/src/index.js";
2
+ import { integrationPolicy, parseIntegrationSheet, } from "../../../core/format/src/integration/index.js";
3
+ import { canarySecrets } from "./canaries.js";
4
+ import { fail } from "./failure.js";
5
+ /**
6
+ * Loads the subject the way Halonic does, through the kit's loader, with a
7
+ * canary for every secret in its sheet and every need available. Fails the
8
+ * check with each problem the loader found.
9
+ */
10
+ export function loadSubject(subject, transport, tokens = emptyTokens) {
11
+ const sheet = sheetOf(subject);
12
+ const loaded = loadIntegration({
13
+ source: { origin: "built-in", sheet: subject.sheet, integration: subject.integration },
14
+ choices: {
15
+ settings: subject.settings ?? {},
16
+ // The canary store answers by name, so each secret is picked as itself.
17
+ secretNames: Object.fromEntries(Object.keys(sheet.secrets).map((name) => [name, name])),
18
+ },
19
+ // A replay answers from the recording and never connects anywhere, so
20
+ // there is no address to check.
21
+ transport: transport,
22
+ secrets: canarySecrets,
23
+ tokens,
24
+ capabilities: sheet.needs,
25
+ });
26
+ return loaded.ok ? loaded.value : fail(problemsText(loaded.error));
27
+ }
28
+ /** The subject's sheet, checked. Fails the check when it doesn't pass. */
29
+ export function sheetOf(subject) {
30
+ const parsed = parseIntegrationSheet(subject.sheet);
31
+ return parsed.ok ? parsed.value : fail(`the sheet is invalid:\n${problemsText(parsed.error)}`);
32
+ }
33
+ /** What the kit enforces for the subject, with its settings. Fails the check when a host doesn't resolve. */
34
+ export function policyOf(subject) {
35
+ const resolved = integrationPolicy(sheetOf(subject), subject.settings ?? {});
36
+ return resolved.ok ? resolved.value.policy : fail(problemsText(resolved.error));
37
+ }
38
+ function problemsText(problems) {
39
+ return problems
40
+ .map(({ code, path, message }) => `${message} (${code} at ${path.join(".") || "the sheet"})`)
41
+ .join("\n");
42
+ }
43
+ const emptyTokens = {
44
+ get: async () => null,
45
+ set: async () => { },
46
+ remove: async () => { },
47
+ };
@@ -0,0 +1,23 @@
1
+ import { type Plugin } from "../../../core/format/src/index.js";
2
+ /** The manifest files a plugin folder may have, at most one of them. */
3
+ export type ManifestFile = "plugin.yaml" | "integration.yaml";
4
+ /** A plugin folder whose manifest passed its schema and its own checks. */
5
+ export interface PluginFolder {
6
+ readonly plugin: Plugin;
7
+ readonly manifest: ManifestFile;
8
+ }
9
+ /**
10
+ * The folder's manifest, parsed and checked as `halonic validate` does.
11
+ * Fails the check when the folder has no manifest, has both, or its
12
+ * manifest has a problem, naming each with its line.
13
+ *
14
+ * @example
15
+ * readPluginFolder("plugins/weather").plugin.ui?.commands?.[0]?.tool; // "forecast"
16
+ */
17
+ export declare function readPluginFolder(folder: string): PluginFolder;
18
+ /**
19
+ * The code files in the folder of the backend's `entry` and below it, by
20
+ * their path in the plugin folder, for the source scan. Skips
21
+ * `node_modules`, which the built entry doesn't load from.
22
+ */
23
+ export declare function backendSources(folder: string, entry: string): Record<string, string>;
@@ -0,0 +1,59 @@
1
+ // Reads a plugin folder the way Halonic does (ADR 2026-11-09-plugins,
2
+ // sections 1 and 1.5): one `plugin.yaml`, or an `integration.yaml` read as a
3
+ // plugin with only a backend, never both. The suite runs in Node, so it reads
4
+ // the folder itself; the plugin's own code never gets a file system.
5
+ import { existsSync, readdirSync, readFileSync } from "node:fs";
6
+ import { dirname, join, relative, sep } from "node:path";
7
+ import { parseFile, pluginFromIntegrationSheet, } from "../../../core/format/src/index.js";
8
+ import { fail } from "./failure.js";
9
+ const manifestFiles = ["plugin.yaml", "integration.yaml"];
10
+ /** The file endings of code the source scan reads. */
11
+ const codeFile = /\.(?:[cm]?js|[cm]?ts)$/;
12
+ /**
13
+ * The folder's manifest, parsed and checked as `halonic validate` does.
14
+ * Fails the check when the folder has no manifest, has both, or its
15
+ * manifest has a problem, naming each with its line.
16
+ *
17
+ * @example
18
+ * readPluginFolder("plugins/weather").plugin.ui?.commands?.[0]?.tool; // "forecast"
19
+ */
20
+ export function readPluginFolder(folder) {
21
+ const found = manifestFiles.filter((name) => existsSync(join(folder, name)));
22
+ const [manifest] = found;
23
+ if (manifest === undefined)
24
+ fail(`${folder} has no plugin.yaml`);
25
+ if (found.length > 1)
26
+ fail("the folder has both plugin.yaml and integration.yaml; keep only plugin.yaml");
27
+ const text = readFileSync(join(folder, manifest), "utf8");
28
+ if (manifest === "plugin.yaml") {
29
+ const parsed = parseFile("plugin", text);
30
+ if (!parsed.ok)
31
+ fail(problemsText(manifest, parsed.error));
32
+ return { plugin: parsed.value.value, manifest };
33
+ }
34
+ const parsed = parseFile("integration", text);
35
+ if (!parsed.ok)
36
+ fail(problemsText(manifest, parsed.error));
37
+ return { plugin: pluginFromIntegrationSheet(parsed.value.value), manifest };
38
+ }
39
+ /**
40
+ * The code files in the folder of the backend's `entry` and below it, by
41
+ * their path in the plugin folder, for the source scan. Skips
42
+ * `node_modules`, which the built entry doesn't load from.
43
+ */
44
+ export function backendSources(folder, entry) {
45
+ const sources = {};
46
+ const root = join(folder, dirname(entry));
47
+ const files = existsSync(root) ? readdirSync(root, { recursive: true, encoding: "utf8" }) : [];
48
+ for (const file of files) {
49
+ if (!codeFile.test(file) || file.split(sep).includes("node_modules"))
50
+ continue;
51
+ const path = join(root, file);
52
+ sources[relative(folder, path).split(sep).join("/")] = readFileSync(path, "utf8");
53
+ }
54
+ return sources;
55
+ }
56
+ function problemsText(manifest, problems) {
57
+ const lines = problems.map(({ line, col, message, path }) => `${manifest}:${line}:${col}: ${message}${path.length > 0 ? ` (at ${path.join(".")})` : ""}`);
58
+ return `${manifest} is invalid:\n${lines.join("\n")}`;
59
+ }
@@ -0,0 +1,32 @@
1
+ import type { Integration } from "../../../core/ports/src/index.js";
2
+ import type { RecordingFile } from "./recording.js";
3
+ import type { ConformanceSubject, ToolCase } from "./run.js";
4
+ /** What the suite checks for one plugin: its folder and, if it has a backend, the backend's code. */
5
+ export interface PluginConformanceSubject {
6
+ /** The plugin folder, with its `plugin.yaml` (or an `integration.yaml`). */
7
+ readonly folder: string;
8
+ /**
9
+ * The backend's code, the `Integration` its `entry` exports. Required when
10
+ * the manifest has a backend, and refused when it has none.
11
+ */
12
+ readonly backend?: Integration;
13
+ /** The backend's recording files (`halonic.recording/1`), one per scenario. */
14
+ readonly recordings?: readonly RecordingFile[];
15
+ /** The backend tool calls to make, each answered from a recording. */
16
+ readonly cases?: readonly ToolCase[];
17
+ /** Setting values, such as the URL a `{ fromSetting }` host reads. */
18
+ readonly settings?: Readonly<Record<string, unknown>>;
19
+ }
20
+ /**
21
+ * The manifest passes its schema and its own checks, it is built for this
22
+ * Halonic's SDK, every file it names is in the folder, and the backend's
23
+ * code matches its backend: name, version, and each tool's text,
24
+ * arguments, `risk` and `untrusted`.
25
+ */
26
+ export declare function checkPluginManifest(subject: PluginConformanceSubject): void;
27
+ /**
28
+ * The plugin's backend as an integration subject: the backend's code, the
29
+ * sheet `backendSheet` builds from the manifest, the subject's recordings
30
+ * and cases, and every code file beside the backend's `entry` to scan.
31
+ */
32
+ export declare function pluginBackendSubject(subject: PluginConformanceSubject): ConformanceSubject;
@@ -0,0 +1,57 @@
1
+ // The plugin conformance suite's own checks (ADR 2026-11-09-plugins): the
2
+ // manifest, the SDK and the files it names. A plugin's backend is an
3
+ // integration, so the suite then runs every integration check on it.
4
+ import { existsSync } from "node:fs";
5
+ import { join } from "node:path";
6
+ import { pluginLoadProblems } from "../../../adapters/integration-kit/src/index.js";
7
+ import { backendSheet } from "../../../core/format/src/index.js";
8
+ import { fail } from "./failure.js";
9
+ import { backendSources, readPluginFolder } from "./plugin-folder.js";
10
+ /**
11
+ * The manifest passes its schema and its own checks, it is built for this
12
+ * Halonic's SDK, every file it names is in the folder, and the backend's
13
+ * code matches its backend: name, version, and each tool's text,
14
+ * arguments, `risk` and `untrusted`.
15
+ */
16
+ export function checkPluginManifest(subject) {
17
+ const { plugin } = readPluginFolder(subject.folder);
18
+ checkBackendCodeGiven(plugin, subject.backend);
19
+ const problems = pluginLoadProblems(plugin, subject.backend);
20
+ if (problems.length > 0) {
21
+ fail(problems.map(({ message, path }) => `${message} (at ${path.join(".")})`).join("\n"));
22
+ }
23
+ for (const path of namedFiles(plugin)) {
24
+ if (!existsSync(join(subject.folder, path)))
25
+ fail(`${path} is named in the manifest but isn't in the plugin folder`);
26
+ }
27
+ }
28
+ /**
29
+ * The plugin's backend as an integration subject: the backend's code, the
30
+ * sheet `backendSheet` builds from the manifest, the subject's recordings
31
+ * and cases, and every code file beside the backend's `entry` to scan.
32
+ */
33
+ export function pluginBackendSubject(subject) {
34
+ const { plugin } = readPluginFolder(subject.folder);
35
+ checkBackendCodeGiven(plugin, subject.backend);
36
+ const sheet = backendSheet(plugin);
37
+ if (sheet === undefined || plugin.backend === undefined || subject.backend === undefined)
38
+ fail("the manifest has no backend to check");
39
+ return {
40
+ integration: subject.backend,
41
+ sheet,
42
+ recordings: subject.recordings ?? [],
43
+ cases: subject.cases ?? [],
44
+ ...(subject.settings === undefined ? {} : { settings: subject.settings }),
45
+ sources: backendSources(subject.folder, plugin.backend.entry),
46
+ };
47
+ }
48
+ /** Code for a backend the manifest doesn't declare is a load problem, reported by `pluginLoadProblems`. */
49
+ function checkBackendCodeGiven(plugin, backend) {
50
+ if (plugin.backend !== undefined && backend === undefined)
51
+ fail("the manifest declares a backend; pass the code its entry exports as `backend`");
52
+ }
53
+ /** The files in the plugin folder the manifest points at: the backend's entry and each local tool's script. */
54
+ function namedFiles(plugin) {
55
+ const scripts = (plugin.localTools ?? []).flatMap((localTool) => localTool.start.script === undefined ? [] : [localTool.start.script.path]);
56
+ return plugin.backend === undefined ? scripts : [plugin.backend.entry, ...scripts];
57
+ }
@@ -0,0 +1,84 @@
1
+ import type { HttpClient } from "../../../core/ports/src/index.js";
2
+ /**
3
+ * A recording file in the `halonic.recording/1` format that `pnpm record`
4
+ * writes in the integrations repo (HAL-149): one scenario, its HTTP
5
+ * exchanges in call order, scrubbed before it was saved. These types follow
6
+ * that format exactly; `checkDeclaration` checks every file against its
7
+ * schema in `@halonicjs/format/recording`.
8
+ */
9
+ export interface RecordingFile {
10
+ readonly format: typeof recordingFormat;
11
+ readonly integration: string;
12
+ readonly scenario: string;
13
+ readonly exchanges: readonly RecordedExchange[];
14
+ readonly scrubReport: readonly {
15
+ rule: string;
16
+ path: string;
17
+ count: number;
18
+ }[];
19
+ }
20
+ /** The `format` value of a recording file. */
21
+ export declare const recordingFormat = "halonic.recording/1";
22
+ /** One request and the response it got, as the recorder saved them. */
23
+ export interface RecordedExchange {
24
+ readonly transport: "http";
25
+ readonly request: {
26
+ readonly method: string;
27
+ readonly url: string;
28
+ readonly headers: Readonly<Record<string, string>>;
29
+ readonly body: RecordedBody;
30
+ };
31
+ readonly response: {
32
+ readonly status: number;
33
+ readonly headers: Readonly<Record<string, string>>;
34
+ readonly body: RecordedBody;
35
+ };
36
+ }
37
+ /** A body, saved parsed. `sse` is a streamed answer, one entry per event. */
38
+ export type RecordedBody = {
39
+ readonly kind: "empty";
40
+ } | {
41
+ readonly kind: "json";
42
+ readonly value: unknown;
43
+ } | {
44
+ readonly kind: "form";
45
+ readonly value: readonly (readonly [string, string])[];
46
+ } | {
47
+ readonly kind: "text";
48
+ readonly contentType: string;
49
+ readonly value: string;
50
+ } | {
51
+ readonly kind: "sse";
52
+ readonly value: readonly {
53
+ event: string;
54
+ data: unknown;
55
+ }[];
56
+ };
57
+ /** A request as the replay transport saw it, with what the kit placed in it. */
58
+ export interface ReplayedRequest {
59
+ readonly method: string;
60
+ readonly url: string;
61
+ readonly headers: Readonly<Record<string, string>>;
62
+ readonly body: string | null;
63
+ }
64
+ /** The integration sent a request that the recording doesn't have at that point. Replays fail closed. */
65
+ export declare class NoRecordingError extends Error {
66
+ readonly name = "NoRecordingError";
67
+ }
68
+ /**
69
+ * A transport that answers only from one recording, in order, and keeps
70
+ * every request it saw. Each request must match the next exchange on method
71
+ * and URL, and on body and key headers where the recording kept them; a
72
+ * scrubbed placeholder matches any value. Anything else throws, so a test
73
+ * can't reach the network by accident.
74
+ *
75
+ * @example
76
+ * const replay = replayTransport(recording);
77
+ * await replay.transport.fetch("https://api.example.com/v1"); // the first exchange's response
78
+ * replay.unused(); // 0 once every exchange was asked for
79
+ */
80
+ export declare function replayTransport(recording: RecordingFile | undefined): {
81
+ transport: HttpClient;
82
+ seen: ReplayedRequest[];
83
+ unused: () => number;
84
+ };
@@ -0,0 +1,164 @@
1
+ /** The `format` value of a recording file. */
2
+ export const recordingFormat = "halonic.recording/1";
3
+ /** What the scrubber put where a key or the user's own content was. Matches any value on replay. */
4
+ const placeholders = new Set(["<scrubbed:secret>", "<scrubbed:content>"]);
5
+ /** The integration sent a request that the recording doesn't have at that point. Replays fail closed. */
6
+ export class NoRecordingError extends Error {
7
+ name = "NoRecordingError";
8
+ }
9
+ /**
10
+ * A transport that answers only from one recording, in order, and keeps
11
+ * every request it saw. Each request must match the next exchange on method
12
+ * and URL, and on body and key headers where the recording kept them; a
13
+ * scrubbed placeholder matches any value. Anything else throws, so a test
14
+ * can't reach the network by accident.
15
+ *
16
+ * @example
17
+ * const replay = replayTransport(recording);
18
+ * await replay.transport.fetch("https://api.example.com/v1"); // the first exchange's response
19
+ * replay.unused(); // 0 once every exchange was asked for
20
+ */
21
+ export function replayTransport(recording) {
22
+ if (recording !== undefined && recording.format !== recordingFormat) {
23
+ throw new TypeError(`recording format "${String(recording.format)}" is not ${recordingFormat}`);
24
+ }
25
+ const exchanges = recording?.exchanges ?? [];
26
+ const seen = [];
27
+ const transport = {
28
+ async fetch(url, init = {}) {
29
+ init.signal?.throwIfAborted();
30
+ const method = (init.method ?? "GET").toUpperCase();
31
+ const headers = Object.fromEntries(new Headers(init.headers));
32
+ const body = init.body == null ? null : await new Response(init.body).text();
33
+ seen.push({ method, url, headers, body });
34
+ const position = seen.length - 1;
35
+ const next = exchanges[position];
36
+ const where = new URL(url);
37
+ const mismatch = next === undefined
38
+ ? "the recording has no more exchanges"
39
+ : differs(next.request, { method, url: where, headers, body });
40
+ if (mismatch !== undefined) {
41
+ throw new NoRecordingError(`no recording for ${method} ${where.host}${where.pathname} as request ${position + 1}: ${mismatch}`);
42
+ }
43
+ return replayResponse(next.response);
44
+ },
45
+ };
46
+ return { transport, seen, unused: () => Math.max(0, exchanges.length - seen.length) };
47
+ }
48
+ /** Why the request doesn't match the recorded one, naming no values; undefined when it does. */
49
+ function differs(recorded, sent) {
50
+ if (recorded.method !== sent.method)
51
+ return `the recording expects ${recorded.method}`;
52
+ const expected = new URL(recorded.url);
53
+ if (expected.origin !== sent.url.origin)
54
+ return `the recording expects ${expected.host}`;
55
+ if (!sameParts(pathParts(expected), pathParts(sent.url)))
56
+ return "the path differs";
57
+ if (!sameParts([...expected.searchParams], [...sent.url.searchParams]))
58
+ return "the query differs";
59
+ for (const [name, value] of Object.entries(recorded.headers)) {
60
+ if (!hasPlaceholder(value))
61
+ continue;
62
+ const actual = sent.headers[name];
63
+ if (actual === undefined || !matchText(value, actual))
64
+ return `the ${name} header is missing`;
65
+ }
66
+ if (!matchBody(recorded.body, sent.body))
67
+ return "the body differs";
68
+ return undefined;
69
+ }
70
+ function pathParts(url) {
71
+ return url.pathname.split("/").map((part) => decodeURIComponent(part));
72
+ }
73
+ /** Same length, and each recorded part matches the sent one. Pairs compare name and value. */
74
+ function sameParts(recorded, sent) {
75
+ return recorded.length === sent.length && recorded.every((part, i) => matchValue(part, sent[i]));
76
+ }
77
+ function matchBody(recorded, sent) {
78
+ switch (recorded.kind) {
79
+ case "empty":
80
+ return sent === null || sent === "";
81
+ case "json":
82
+ try {
83
+ return sent !== null && matchValue(recorded.value, JSON.parse(sent));
84
+ }
85
+ catch {
86
+ return false;
87
+ }
88
+ case "form":
89
+ return sameParts(recorded.value, [...new URLSearchParams(sent ?? "")]);
90
+ case "text":
91
+ return matchText(recorded.value, sent ?? "");
92
+ case "sse":
93
+ return false;
94
+ }
95
+ }
96
+ /**
97
+ * Structural match. A placeholder string matches any string. User content
98
+ * that was a number or a boolean was saved as `0` or `false`, so those match
99
+ * any number or boolean.
100
+ */
101
+ function matchValue(recorded, sent) {
102
+ if (typeof recorded === "string")
103
+ return typeof sent === "string" && matchText(recorded, sent);
104
+ if (recorded === 0)
105
+ return typeof sent === "number";
106
+ if (recorded === false)
107
+ return typeof sent === "boolean";
108
+ if (Array.isArray(recorded))
109
+ return Array.isArray(sent) && sameParts(recorded, sent);
110
+ if (recorded !== null && typeof recorded === "object") {
111
+ if (sent === null || typeof sent !== "object" || Array.isArray(sent))
112
+ return false;
113
+ const keys = Object.keys(recorded);
114
+ const sentKeys = Object.keys(sent);
115
+ return (keys.length === sentKeys.length &&
116
+ keys.every((key) => Object.hasOwn(sent, key) &&
117
+ matchValue(recorded[key], sent[key])));
118
+ }
119
+ return recorded === sent;
120
+ }
121
+ /** Equal, or equal once each placeholder in the recorded text stands for any text. */
122
+ function matchText(recorded, sent) {
123
+ if (!hasPlaceholder(recorded))
124
+ return recorded === sent;
125
+ const pattern = recorded
126
+ .split(/(<scrubbed:(?:secret|content)>)/)
127
+ .map((piece) => placeholders.has(piece) ? "[\\s\\S]*" : piece.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"))
128
+ .join("");
129
+ return new RegExp(`^${pattern}$`).test(sent);
130
+ }
131
+ function hasPlaceholder(text) {
132
+ return text.includes("<scrubbed:secret>") || text.includes("<scrubbed:content>");
133
+ }
134
+ function replayResponse(recorded) {
135
+ const headers = new Headers(recorded.headers);
136
+ const nullBody = recorded.status === 204 || recorded.status === 205 || recorded.status === 304;
137
+ const { body, contentType } = responseBody(recorded.body);
138
+ if (contentType !== undefined && !headers.has("content-type"))
139
+ headers.set("content-type", contentType);
140
+ return new Response(nullBody ? null : body, { status: recorded.status, headers });
141
+ }
142
+ function responseBody(body) {
143
+ switch (body.kind) {
144
+ case "empty":
145
+ return { body: null };
146
+ case "json":
147
+ return { body: JSON.stringify(body.value), contentType: "application/json" };
148
+ case "form":
149
+ return {
150
+ body: new URLSearchParams(body.value.map(([name, value]) => [name, value])).toString(),
151
+ contentType: "application/x-www-form-urlencoded",
152
+ };
153
+ case "text":
154
+ return { body: body.value, contentType: body.contentType };
155
+ case "sse":
156
+ return { body: body.value.map(eventText).join(""), contentType: "text/event-stream" };
157
+ }
158
+ }
159
+ /** One server-sent event as text: `data` that was parsed JSON is written back as JSON. */
160
+ function eventText({ event, data }) {
161
+ const text = typeof data === "string" ? data : JSON.stringify(data);
162
+ const lines = text.split("\n").map((line) => `data: ${line}\n`);
163
+ return `${event === "message" ? "" : `event: ${event}\n`}${lines.join("")}\n`;
164
+ }