@halonicjs/testing 0.0.0 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (384) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +1 -0
  3. package/README.md +41 -1
  4. package/dist/adapters/http-kit/src/address-class.d.ts +34 -0
  5. package/dist/adapters/http-kit/src/address-class.js +109 -0
  6. package/dist/adapters/http-kit/src/index.d.ts +2 -0
  7. package/dist/adapters/http-kit/src/index.js +2 -0
  8. package/dist/adapters/http-kit/src/ip-address.d.ts +23 -0
  9. package/dist/adapters/http-kit/src/ip-address.js +89 -0
  10. package/dist/adapters/integration-kit/src/declaration.d.ts +14 -0
  11. package/dist/adapters/integration-kit/src/declaration.js +77 -0
  12. package/dist/adapters/integration-kit/src/host.d.ts +28 -0
  13. package/dist/adapters/integration-kit/src/host.js +30 -0
  14. package/dist/adapters/integration-kit/src/index.d.ts +14 -0
  15. package/dist/adapters/integration-kit/src/index.js +21 -0
  16. package/dist/adapters/integration-kit/src/leak-attempt.d.ts +14 -0
  17. package/dist/adapters/integration-kit/src/leak-attempt.js +16 -0
  18. package/dist/adapters/integration-kit/src/limited-http.d.ts +49 -0
  19. package/dist/adapters/integration-kit/src/limited-http.js +182 -0
  20. package/dist/adapters/integration-kit/src/load-problem.d.ts +20 -0
  21. package/dist/adapters/integration-kit/src/load-problem.js +1 -0
  22. package/dist/adapters/integration-kit/src/loader.d.ts +104 -0
  23. package/dist/adapters/integration-kit/src/loader.js +219 -0
  24. package/dist/adapters/integration-kit/src/local-address.d.ts +15 -0
  25. package/dist/adapters/integration-kit/src/local-address.js +25 -0
  26. package/dist/adapters/integration-kit/src/own-request.d.ts +33 -0
  27. package/dist/adapters/integration-kit/src/own-request.js +36 -0
  28. package/dist/adapters/integration-kit/src/plugin-load.d.ts +14 -0
  29. package/dist/adapters/integration-kit/src/plugin-load.js +58 -0
  30. package/dist/adapters/integration-kit/src/policy.d.ts +55 -0
  31. package/dist/adapters/integration-kit/src/policy.js +37 -0
  32. package/dist/adapters/integration-kit/src/request-body.d.ts +38 -0
  33. package/dist/adapters/integration-kit/src/request-body.js +68 -0
  34. package/dist/adapters/integration-kit/src/request-log.d.ts +25 -0
  35. package/dist/adapters/integration-kit/src/request-log.js +17 -0
  36. package/dist/adapters/integration-kit/src/response-body.d.ts +23 -0
  37. package/dist/adapters/integration-kit/src/response-body.js +117 -0
  38. package/dist/adapters/integration-kit/src/scoped-tokens.d.ts +14 -0
  39. package/dist/adapters/integration-kit/src/scoped-tokens.js +27 -0
  40. package/dist/adapters/integration-kit/src/secret-filter.d.ts +84 -0
  41. package/dist/adapters/integration-kit/src/secret-filter.js +205 -0
  42. package/dist/adapters/integration-kit/src/secret-in-request.d.ts +59 -0
  43. package/dist/adapters/integration-kit/src/secret-in-request.js +133 -0
  44. package/dist/adapters/integration-kit/src/secret-placement.d.ts +36 -0
  45. package/dist/adapters/integration-kit/src/secret-placement.js +190 -0
  46. package/dist/adapters/integration-kit/src/wait.d.ts +16 -0
  47. package/dist/adapters/integration-kit/src/wait.js +35 -0
  48. package/dist/core/events/src/add-usage.d.ts +10 -0
  49. package/dist/core/events/src/add-usage.js +27 -0
  50. package/dist/core/events/src/agent-resume.d.ts +24 -0
  51. package/dist/core/events/src/agent-resume.js +1 -0
  52. package/dist/core/events/src/home-path.d.ts +13 -0
  53. package/dist/core/events/src/home-path.js +26 -0
  54. package/dist/core/events/src/index.d.ts +13 -0
  55. package/dist/core/events/src/index.js +7 -0
  56. package/dist/core/events/src/run-basics.d.ts +205 -0
  57. package/dist/core/events/src/run-basics.js +1 -0
  58. package/dist/core/events/src/run-event.d.ts +434 -0
  59. package/dist/core/events/src/run-event.js +1 -0
  60. package/dist/core/events/src/run-summary.d.ts +108 -0
  61. package/dist/core/events/src/run-summary.js +1 -0
  62. package/dist/core/events/src/sandbox-blocked.d.ts +42 -0
  63. package/dist/core/events/src/sandbox-blocked.js +26 -0
  64. package/dist/core/events/src/sandbox-opened-read.d.ts +17 -0
  65. package/dist/core/events/src/sandbox-opened-read.js +63 -0
  66. package/dist/core/events/src/sandbox-opened.d.ts +94 -0
  67. package/dist/core/events/src/sandbox-opened.js +52 -0
  68. package/dist/core/events/src/summarize.d.ts +14 -0
  69. package/dist/core/events/src/summarize.js +188 -0
  70. package/dist/core/events/src/timeline-entry.d.ts +21 -0
  71. package/dist/core/events/src/timeline-entry.js +105 -0
  72. package/dist/core/events/src/upgrade.d.ts +23 -0
  73. package/dist/core/events/src/upgrade.js +49 -0
  74. package/dist/core/format/src/compact.d.ts +30 -0
  75. package/dist/core/format/src/compact.js +72 -0
  76. package/dist/core/format/src/index.d.ts +37 -0
  77. package/dist/core/format/src/index.js +23 -0
  78. package/dist/core/format/src/integration/index.d.ts +6 -0
  79. package/dist/core/format/src/integration/index.js +9 -0
  80. package/dist/core/format/src/json-schema.d.ts +26 -0
  81. package/dist/core/format/src/json-schema.js +48 -0
  82. package/dist/core/format/src/kind.d.ts +65 -0
  83. package/dist/core/format/src/kind.js +1 -0
  84. package/dist/core/format/src/kinds/agent/kind.d.ts +4 -0
  85. package/dist/core/format/src/kinds/agent/kind.js +10 -0
  86. package/dist/core/format/src/kinds/agent/sandbox-fields.d.ts +89 -0
  87. package/dist/core/format/src/kinds/agent/sandbox-fields.js +197 -0
  88. package/dist/core/format/src/kinds/agent/schema.d.ts +147 -0
  89. package/dist/core/format/src/kinds/agent/schema.js +107 -0
  90. package/dist/core/format/src/kinds/agent/working-folder-start.d.ts +74 -0
  91. package/dist/core/format/src/kinds/agent/working-folder-start.js +312 -0
  92. package/dist/core/format/src/kinds/collection/kind.d.ts +8 -0
  93. package/dist/core/format/src/kinds/collection/kind.js +14 -0
  94. package/dist/core/format/src/kinds/collection/schema.d.ts +89 -0
  95. package/dist/core/format/src/kinds/collection/schema.js +90 -0
  96. package/dist/core/format/src/kinds/connector/is-local.d.ts +10 -0
  97. package/dist/core/format/src/kinds/connector/is-local.js +43 -0
  98. package/dist/core/format/src/kinds/connector/kind.d.ts +4 -0
  99. package/dist/core/format/src/kinds/connector/kind.js +119 -0
  100. package/dist/core/format/src/kinds/connector/schema.d.ts +50 -0
  101. package/dist/core/format/src/kinds/connector/schema.js +92 -0
  102. package/dist/core/format/src/kinds/deployments/kind.d.ts +4 -0
  103. package/dist/core/format/src/kinds/deployments/kind.js +25 -0
  104. package/dist/core/format/src/kinds/deployments/schema.d.ts +37 -0
  105. package/dist/core/format/src/kinds/deployments/schema.js +42 -0
  106. package/dist/core/format/src/kinds/hub/kind.d.ts +4 -0
  107. package/dist/core/format/src/kinds/hub/kind.js +10 -0
  108. package/dist/core/format/src/kinds/hub/schema.d.ts +54 -0
  109. package/dist/core/format/src/kinds/hub/schema.js +34 -0
  110. package/dist/core/format/src/kinds/integration/kind.d.ts +16 -0
  111. package/dist/core/format/src/kinds/integration/kind.js +138 -0
  112. package/dist/core/format/src/kinds/integration/parse-sheet.d.ts +19 -0
  113. package/dist/core/format/src/kinds/integration/parse-sheet.js +24 -0
  114. package/dist/core/format/src/kinds/integration/policy.d.ts +67 -0
  115. package/dist/core/format/src/kinds/integration/policy.js +268 -0
  116. package/dist/core/format/src/kinds/integration/schema.d.ts +233 -0
  117. package/dist/core/format/src/kinds/integration/schema.js +233 -0
  118. package/dist/core/format/src/kinds/knowledge/kind.d.ts +4 -0
  119. package/dist/core/format/src/kinds/knowledge/kind.js +13 -0
  120. package/dist/core/format/src/kinds/knowledge/schema.d.ts +18 -0
  121. package/dist/core/format/src/kinds/knowledge/schema.js +25 -0
  122. package/dist/core/format/src/kinds/models/kind.d.ts +4 -0
  123. package/dist/core/format/src/kinds/models/kind.js +10 -0
  124. package/dist/core/format/src/kinds/models/schema.d.ts +92 -0
  125. package/dist/core/format/src/kinds/models/schema.js +38 -0
  126. package/dist/core/format/src/kinds/plugin/backend.d.ts +22 -0
  127. package/dist/core/format/src/kinds/plugin/backend.js +31 -0
  128. package/dist/core/format/src/kinds/plugin/checks.d.ts +13 -0
  129. package/dist/core/format/src/kinds/plugin/checks.js +131 -0
  130. package/dist/core/format/src/kinds/plugin/kind.d.ts +8 -0
  131. package/dist/core/format/src/kinds/plugin/kind.js +16 -0
  132. package/dist/core/format/src/kinds/plugin/problems.d.ts +24 -0
  133. package/dist/core/format/src/kinds/plugin/problems.js +65 -0
  134. package/dist/core/format/src/kinds/plugin/schema.d.ts +542 -0
  135. package/dist/core/format/src/kinds/plugin/schema.js +261 -0
  136. package/dist/core/format/src/kinds/plugin/setting-values.d.ts +17 -0
  137. package/dist/core/format/src/kinds/plugin/setting-values.js +38 -0
  138. package/dist/core/format/src/kinds/plugin/ui-checks.d.ts +8 -0
  139. package/dist/core/format/src/kinds/plugin/ui-checks.js +94 -0
  140. package/dist/core/format/src/kinds/provider/kind.d.ts +4 -0
  141. package/dist/core/format/src/kinds/provider/kind.js +24 -0
  142. package/dist/core/format/src/kinds/provider/schema.d.ts +17 -0
  143. package/dist/core/format/src/kinds/provider/schema.js +22 -0
  144. package/dist/core/format/src/kinds/routine/kind.d.ts +8 -0
  145. package/dist/core/format/src/kinds/routine/kind.js +25 -0
  146. package/dist/core/format/src/kinds/routine/schema.d.ts +84 -0
  147. package/dist/core/format/src/kinds/routine/schema.js +93 -0
  148. package/dist/core/format/src/kinds/runtime/kind.d.ts +4 -0
  149. package/dist/core/format/src/kinds/runtime/kind.js +13 -0
  150. package/dist/core/format/src/kinds/runtime/schema.d.ts +10 -0
  151. package/dist/core/format/src/kinds/runtime/schema.js +12 -0
  152. package/dist/core/format/src/kinds/skill/kind.d.ts +4 -0
  153. package/dist/core/format/src/kinds/skill/kind.js +10 -0
  154. package/dist/core/format/src/kinds/skill/schema.d.ts +17 -0
  155. package/dist/core/format/src/kinds/skill/schema.js +17 -0
  156. package/dist/core/format/src/kinds/skill/scripts-folder.d.ts +27 -0
  157. package/dist/core/format/src/kinds/skill/scripts-folder.js +37 -0
  158. package/dist/core/format/src/kinds/workflow/kind.d.ts +8 -0
  159. package/dist/core/format/src/kinds/workflow/kind.js +14 -0
  160. package/dist/core/format/src/kinds/workflow/schema.d.ts +162 -0
  161. package/dist/core/format/src/kinds/workflow/schema.js +106 -0
  162. package/dist/core/format/src/kinds/workflow-test/kind.d.ts +4 -0
  163. package/dist/core/format/src/kinds/workflow-test/kind.js +14 -0
  164. package/dist/core/format/src/kinds/workflow-test/schema.d.ts +67 -0
  165. package/dist/core/format/src/kinds/workflow-test/schema.js +59 -0
  166. package/dist/core/format/src/kinds/workspace/kind.d.ts +4 -0
  167. package/dist/core/format/src/kinds/workspace/kind.js +10 -0
  168. package/dist/core/format/src/kinds/workspace/schema.d.ts +72 -0
  169. package/dist/core/format/src/kinds/workspace/schema.js +66 -0
  170. package/dist/core/format/src/parse-file.d.ts +69 -0
  171. package/dist/core/format/src/parse-file.js +105 -0
  172. package/dist/core/format/src/recording/format.d.ts +81 -0
  173. package/dist/core/format/src/recording/format.js +102 -0
  174. package/dist/core/format/src/recording/index.d.ts +1 -0
  175. package/dist/core/format/src/recording/index.js +3 -0
  176. package/dist/core/format/src/registry.d.ts +64 -0
  177. package/dist/core/format/src/registry.js +61 -0
  178. package/dist/core/format/src/reserved.d.ts +20 -0
  179. package/dist/core/format/src/reserved.js +30 -0
  180. package/dist/core/format/src/shared/fields.d.ts +37 -0
  181. package/dist/core/format/src/shared/fields.js +54 -0
  182. package/dist/core/format/src/shared/guard.d.ts +32 -0
  183. package/dist/core/format/src/shared/guard.js +16 -0
  184. package/dist/core/format/src/shared/key-in-value.d.ts +28 -0
  185. package/dist/core/format/src/shared/key-in-value.js +82 -0
  186. package/dist/core/format/src/shared/legacy-keys.d.ts +8 -0
  187. package/dist/core/format/src/shared/legacy-keys.js +17 -0
  188. package/dist/core/format/src/shared/program-start.d.ts +60 -0
  189. package/dist/core/format/src/shared/program-start.js +99 -0
  190. package/dist/core/format/src/shared/relative-path.d.ts +29 -0
  191. package/dist/core/format/src/shared/relative-path.js +50 -0
  192. package/dist/core/format/src/shared/secret-name.d.ts +24 -0
  193. package/dist/core/format/src/shared/secret-name.js +107 -0
  194. package/dist/core/format/src/source.d.ts +16 -0
  195. package/dist/core/format/src/source.js +73 -0
  196. package/dist/core/ports/src/agent-placement-store.d.ts +74 -0
  197. package/dist/core/ports/src/agent-placement-store.js +27 -0
  198. package/dist/core/ports/src/blob-store.d.ts +33 -0
  199. package/dist/core/ports/src/blob-store.js +2 -0
  200. package/dist/core/ports/src/cant-try-error.d.ts +35 -0
  201. package/dist/core/ports/src/cant-try-error.js +44 -0
  202. package/dist/core/ports/src/chat.d.ts +127 -0
  203. package/dist/core/ports/src/chat.js +1 -0
  204. package/dist/core/ports/src/clock.d.ts +7 -0
  205. package/dist/core/ports/src/clock.js +2 -0
  206. package/dist/core/ports/src/connection-settings-store.d.ts +57 -0
  207. package/dist/core/ports/src/connection-settings-store.js +2 -0
  208. package/dist/core/ports/src/connector-client.d.ts +259 -0
  209. package/dist/core/ports/src/connector-client.js +2 -0
  210. package/dist/core/ports/src/coordination.d.ts +84 -0
  211. package/dist/core/ports/src/coordination.js +2 -0
  212. package/dist/core/ports/src/definition-store.d.ts +208 -0
  213. package/dist/core/ports/src/definition-store.js +122 -0
  214. package/dist/core/ports/src/digest.d.ts +14 -0
  215. package/dist/core/ports/src/digest.js +2 -0
  216. package/dist/core/ports/src/folder-reader.d.ts +89 -0
  217. package/dist/core/ports/src/folder-reader.js +2 -0
  218. package/dist/core/ports/src/harness-bridge-server.d.ts +189 -0
  219. package/dist/core/ports/src/harness-bridge-server.js +37 -0
  220. package/dist/core/ports/src/harness.d.ts +250 -0
  221. package/dist/core/ports/src/harness.js +45 -0
  222. package/dist/core/ports/src/http-client.d.ts +27 -0
  223. package/dist/core/ports/src/http-client.js +2 -0
  224. package/dist/core/ports/src/id-generator.d.ts +14 -0
  225. package/dist/core/ports/src/id-generator.js +2 -0
  226. package/dist/core/ports/src/index.d.ts +37 -0
  227. package/dist/core/ports/src/index.js +36 -0
  228. package/dist/core/ports/src/integration.d.ts +178 -0
  229. package/dist/core/ports/src/integration.js +13 -0
  230. package/dist/core/ports/src/knowledge-provider.d.ts +65 -0
  231. package/dist/core/ports/src/knowledge-provider.js +2 -0
  232. package/dist/core/ports/src/llm-cache.d.ts +13 -0
  233. package/dist/core/ports/src/llm-cache.js +2 -0
  234. package/dist/core/ports/src/llm-provider.d.ts +184 -0
  235. package/dist/core/ports/src/llm-provider.js +136 -0
  236. package/dist/core/ports/src/model-price.d.ts +34 -0
  237. package/dist/core/ports/src/model-price.js +25 -0
  238. package/dist/core/ports/src/password-hasher.d.ts +47 -0
  239. package/dist/core/ports/src/password-hasher.js +2 -0
  240. package/dist/core/ports/src/plugin-folder-writer.d.ts +104 -0
  241. package/dist/core/ports/src/plugin-folder-writer.js +95 -0
  242. package/dist/core/ports/src/port-versions.d.ts +44 -0
  243. package/dist/core/ports/src/port-versions.js +74 -0
  244. package/dist/core/ports/src/program-probe.d.ts +46 -0
  245. package/dist/core/ports/src/program-probe.js +2 -0
  246. package/dist/core/ports/src/record-store.d.ts +62 -0
  247. package/dist/core/ports/src/record-store.js +38 -0
  248. package/dist/core/ports/src/resource-probe.d.ts +59 -0
  249. package/dist/core/ports/src/resource-probe.js +2 -0
  250. package/dist/core/ports/src/run-executor.d.ts +302 -0
  251. package/dist/core/ports/src/run-executor.js +2 -0
  252. package/dist/core/ports/src/run-failure-error.d.ts +49 -0
  253. package/dist/core/ports/src/run-failure-error.js +47 -0
  254. package/dist/core/ports/src/run-store.d.ts +194 -0
  255. package/dist/core/ports/src/run-store.js +131 -0
  256. package/dist/core/ports/src/sandbox.d.ts +247 -0
  257. package/dist/core/ports/src/sandbox.js +34 -0
  258. package/dist/core/ports/src/scheduler.d.ts +85 -0
  259. package/dist/core/ports/src/scheduler.js +2 -0
  260. package/dist/core/ports/src/secrets.d.ts +128 -0
  261. package/dist/core/ports/src/secrets.js +144 -0
  262. package/dist/core/ports/src/token-store.d.ts +19 -0
  263. package/dist/core/ports/src/token-store.js +2 -0
  264. package/dist/core/ports/src/tool-approval-store.d.ts +211 -0
  265. package/dist/core/ports/src/tool-approval-store.js +57 -0
  266. package/dist/core/ports/src/trust-store.d.ts +72 -0
  267. package/dist/core/ports/src/trust-store.js +2 -0
  268. package/dist/core/ports/src/unfenced-run-consent-store.d.ts +43 -0
  269. package/dist/core/ports/src/unfenced-run-consent-store.js +2 -0
  270. package/dist/core/ports/src/vcs.d.ts +394 -0
  271. package/dist/core/ports/src/vcs.js +48 -0
  272. package/dist/core/schema-kit/src/builders.d.ts +50 -0
  273. package/dist/core/schema-kit/src/builders.js +72 -0
  274. package/dist/core/schema-kit/src/depth.d.ts +15 -0
  275. package/dist/core/schema-kit/src/depth.js +37 -0
  276. package/dist/core/schema-kit/src/index.d.ts +6 -0
  277. package/dist/core/schema-kit/src/index.js +6 -0
  278. package/dist/core/schema-kit/src/issue.d.ts +22 -0
  279. package/dist/core/schema-kit/src/issue.js +23 -0
  280. package/dist/core/schema-kit/src/json-schema.d.ts +23 -0
  281. package/dist/core/schema-kit/src/json-schema.js +22 -0
  282. package/dist/core/schema-kit/src/parse.d.ts +17 -0
  283. package/dist/core/schema-kit/src/parse.js +25 -0
  284. package/dist/core/schema-kit/src/schema.d.ts +12 -0
  285. package/dist/core/schema-kit/src/schema.js +1 -0
  286. package/dist/core/std/src/ascii-host.d.ts +18 -0
  287. package/dist/core/std/src/ascii-host.js +110 -0
  288. package/dist/core/std/src/assert.d.ts +39 -0
  289. package/dist/core/std/src/assert.js +59 -0
  290. package/dist/core/std/src/base64url.d.ts +23 -0
  291. package/dist/core/std/src/base64url.js +65 -0
  292. package/dist/core/std/src/canonical-json.d.ts +18 -0
  293. package/dist/core/std/src/canonical-json.js +56 -0
  294. package/dist/core/std/src/clock.d.ts +27 -0
  295. package/dist/core/std/src/clock.js +33 -0
  296. package/dist/core/std/src/constant-time.d.ts +16 -0
  297. package/dist/core/std/src/constant-time.js +26 -0
  298. package/dist/core/std/src/content-digest.d.ts +24 -0
  299. package/dist/core/std/src/content-digest.js +28 -0
  300. package/dist/core/std/src/deep-clone.d.ts +15 -0
  301. package/dist/core/std/src/deep-clone.js +59 -0
  302. package/dist/core/std/src/deep-equal.d.ts +23 -0
  303. package/dist/core/std/src/deep-equal.js +64 -0
  304. package/dist/core/std/src/emitter.d.ts +42 -0
  305. package/dist/core/std/src/emitter.js +74 -0
  306. package/dist/core/std/src/error-kind.d.ts +88 -0
  307. package/dist/core/std/src/error-kind.js +98 -0
  308. package/dist/core/std/src/hex.d.ts +10 -0
  309. package/dist/core/std/src/hex.js +16 -0
  310. package/dist/core/std/src/ids.d.ts +45 -0
  311. package/dist/core/std/src/ids.js +49 -0
  312. package/dist/core/std/src/index.d.ts +25 -0
  313. package/dist/core/std/src/index.js +26 -0
  314. package/dist/core/std/src/keyed-queue.d.ts +18 -0
  315. package/dist/core/std/src/keyed-queue.js +32 -0
  316. package/dist/core/std/src/line-diff.d.ts +83 -0
  317. package/dist/core/std/src/line-diff.js +179 -0
  318. package/dist/core/std/src/line-merge.d.ts +63 -0
  319. package/dist/core/std/src/line-merge.js +138 -0
  320. package/dist/core/std/src/plain-data.d.ts +32 -0
  321. package/dist/core/std/src/plain-data.js +57 -0
  322. package/dist/core/std/src/posix-path.d.ts +61 -0
  323. package/dist/core/std/src/posix-path.js +121 -0
  324. package/dist/core/std/src/result.d.ts +55 -0
  325. package/dist/core/std/src/result.js +52 -0
  326. package/dist/core/std/src/secret-scrubber.d.ts +54 -0
  327. package/dist/core/std/src/secret-scrubber.js +124 -0
  328. package/dist/core/std/src/secret-shape.d.ts +20 -0
  329. package/dist/core/std/src/secret-shape.js +53 -0
  330. package/dist/core/std/src/stop-signal.d.ts +44 -0
  331. package/dist/core/std/src/stop-signal.js +77 -0
  332. package/dist/core/std/src/text.d.ts +28 -0
  333. package/dist/core/std/src/text.js +54 -0
  334. package/dist/core/std/src/utf8.d.ts +23 -0
  335. package/dist/core/std/src/utf8.js +110 -0
  336. package/dist/core/std/src/version.d.ts +48 -0
  337. package/dist/core/std/src/version.js +103 -0
  338. package/dist/core/yaml/src/depth.d.ts +14 -0
  339. package/dist/core/yaml/src/depth.js +140 -0
  340. package/dist/core/yaml/src/edit-data.d.ts +47 -0
  341. package/dist/core/yaml/src/edit-data.js +286 -0
  342. package/dist/core/yaml/src/edit-text.d.ts +92 -0
  343. package/dist/core/yaml/src/edit-text.js +267 -0
  344. package/dist/core/yaml/src/edit.d.ts +47 -0
  345. package/dist/core/yaml/src/edit.js +198 -0
  346. package/dist/core/yaml/src/index.d.ts +5 -0
  347. package/dist/core/yaml/src/index.js +4 -0
  348. package/dist/core/yaml/src/problem.d.ts +20 -0
  349. package/dist/core/yaml/src/problem.js +1 -0
  350. package/dist/core/yaml/src/read.d.ts +47 -0
  351. package/dist/core/yaml/src/read.js +130 -0
  352. package/dist/core/yaml/src/splice-node.d.ts +47 -0
  353. package/dist/core/yaml/src/splice-node.js +333 -0
  354. package/dist/core/yaml/src/splice.d.ts +13 -0
  355. package/dist/core/yaml/src/splice.js +174 -0
  356. package/dist/core/yaml/src/unsupported.d.ts +26 -0
  357. package/dist/core/yaml/src/unsupported.js +70 -0
  358. package/dist/core/yaml/src/write.d.ts +35 -0
  359. package/dist/core/yaml/src/write.js +44 -0
  360. package/dist/testing/integration/src/canaries.d.ts +14 -0
  361. package/dist/testing/integration/src/canaries.js +17 -0
  362. package/dist/testing/integration/src/checks.d.ts +37 -0
  363. package/dist/testing/integration/src/checks.js +195 -0
  364. package/dist/testing/integration/src/describe.d.ts +35 -0
  365. package/dist/testing/integration/src/describe.js +74 -0
  366. package/dist/testing/integration/src/failure.d.ts +6 -0
  367. package/dist/testing/integration/src/failure.js +8 -0
  368. package/dist/testing/integration/src/fake-wait.d.ts +18 -0
  369. package/dist/testing/integration/src/fake-wait.js +21 -0
  370. package/dist/testing/integration/src/index.d.ts +10 -0
  371. package/dist/testing/integration/src/index.js +11 -0
  372. package/dist/testing/integration/src/load.d.ts +14 -0
  373. package/dist/testing/integration/src/load.js +45 -0
  374. package/dist/testing/integration/src/plugin-folder.d.ts +23 -0
  375. package/dist/testing/integration/src/plugin-folder.js +59 -0
  376. package/dist/testing/integration/src/plugin.d.ts +32 -0
  377. package/dist/testing/integration/src/plugin.js +57 -0
  378. package/dist/testing/integration/src/recording.d.ts +84 -0
  379. package/dist/testing/integration/src/recording.js +164 -0
  380. package/dist/testing/integration/src/run.d.ts +60 -0
  381. package/dist/testing/integration/src/run.js +81 -0
  382. package/dist/testing/integration/src/source-scan.d.ts +16 -0
  383. package/dist/testing/integration/src/source-scan.js +40 -0
  384. package/package.json +34 -3
@@ -0,0 +1,85 @@
1
+ /** Version of the {@link Scheduler} port. A breaking change bumps it and comes with an ADR. */
2
+ export declare const schedulerVersion = 1;
3
+ /** A timer: a run's wait, timeout or retry, due at an ISO time. */
4
+ export interface ScheduledTimer {
5
+ /** What the timer belongs to, usually a run id. At most 256 UTF-8 bytes. */
6
+ key: string;
7
+ /** Unique within its key. At most 256 UTF-8 bytes. */
8
+ timerId: string;
9
+ /**
10
+ * ISO time the timer was set for, not the time it was delivered. The
11
+ * listener compares it with its own state to drop late or repeated
12
+ * deliveries.
13
+ */
14
+ at: string;
15
+ }
16
+ /**
17
+ * What a scheduler calls. Adapters take it when they are created (see
18
+ * {@link SchedulerFactory}), because on some runtimes the platform wakes the
19
+ * code, not the code itself.
20
+ *
21
+ * **Timers can arrive late or twice**. The listener
22
+ * ignores a timer it has already handled or cancelled.
23
+ *
24
+ * **A timer that comes due is delivered even while `onTimer` is still
25
+ * running for another timer.** The engine relies on this: a harness call's
26
+ * start limit is a timer that has to arrive while the call's own timer is
27
+ * still being handled. A scheduler doesn't wait for one call to end before
28
+ * it delivers the next timer.
29
+ *
30
+ * If `onTimer` rejects, the scheduler delivers the timer again later, waiting
31
+ * longer each time: at least 1 second after the first failure, doubling, and
32
+ * at most 15 minutes between tries. It never drops the timer, so a listener
33
+ * that can't handle a timer resolves anyway (for example by failing the run)
34
+ * rather than rejecting for ever.
35
+ */
36
+ export interface SchedulerListener {
37
+ /**
38
+ * A timer is due. It is removed after this resolves, unless `schedule` set
39
+ * the same key and id again while this ran (a retry, say): a timer set
40
+ * during the call always stays as it was set, whether this resolves or
41
+ * rejects. The retry wait after a rejection never replaces a time set
42
+ * during the call.
43
+ */
44
+ onTimer(timer: ScheduledTimer): Promise<void>;
45
+ /**
46
+ * The routine tick, about once a minute, with the ISO time of the tick.
47
+ * Ticks can be missed (a deploy, a laptop asleep), so the receiver works
48
+ * out what is due from its last tick, with a catch-up policy. A tick that
49
+ * rejects is not retried: the next tick catches up.
50
+ */
51
+ onTick(at: string): Promise<void>;
52
+ }
53
+ /**
54
+ * Timers per key, kept outside memory so they survive restarts. The core
55
+ * has no timers of its own: it asks the scheduler.
56
+ */
57
+ export interface Scheduler {
58
+ /**
59
+ * Sets a timer, or moves it when the same key and id is already set. A time in the past is due at once.
60
+ *
61
+ * @throws RangeError when the key or timer id is longer than 256 UTF-8 bytes
62
+ */
63
+ schedule(key: string, timerId: string, at: string): Promise<void>;
64
+ /** Removes a timer. Removing one that isn't set is not an error. */
65
+ cancel(key: string, timerId: string): Promise<void>;
66
+ /** The timers set for a key, earliest first. */
67
+ pending(key: string): Promise<ScheduledTimer[]>;
68
+ }
69
+ /**
70
+ * Creates a scheduler that calls `listener`. Every adapter has one, so a
71
+ * contract suite builds them all the same way.
72
+ *
73
+ * The listener usually calls the run executor, which uses this scheduler, so
74
+ * one of them has to be bound late: pass a listener that forwards to an
75
+ * executor set after both are created.
76
+ *
77
+ * @example
78
+ * let executor: RunExecutor | undefined;
79
+ * const scheduler = createScheduler({
80
+ * onTimer: (timer) => engineStep(executor, timer),
81
+ * onTick: (at) => routineTick(executor, at),
82
+ * });
83
+ * executor = createLocalExecutor({ scheduler });
84
+ */
85
+ export type SchedulerFactory = (listener: SchedulerListener) => Scheduler;
@@ -0,0 +1,2 @@
1
+ /** Version of the {@link Scheduler} port. A breaking change bumps it and comes with an ADR. */
2
+ export const schedulerVersion = 1;
@@ -0,0 +1,128 @@
1
+ /** Version of the {@link Secrets} port. A breaking change bumps it and comes with an ADR. */
2
+ export declare const secretsVersion = 1;
3
+ /**
4
+ * The secrets someone configured: provider keys, the sign-in password hash,
5
+ * the token key. Read-only at run time (OS keychain, a mode-0600 file,
6
+ * environment variables, Workers secrets). What the server writes itself goes
7
+ * in the {@link TokenStore} instead.
8
+ *
9
+ * **Names** match `^[A-Za-z][A-Za-z0-9_-]*$` and are at most 128 characters,
10
+ * so the same name works as an environment variable, a Workers secret and a
11
+ * keychain entry. `secretKey` and `isSecretName` below hold the rule, so
12
+ * every adapter checks names the same way.
13
+ *
14
+ * **Two names that differ only in upper and lower case, or in `-` versus
15
+ * `_`, are the same secret on every adapter.** The old environment adapter
16
+ * upper-cased names and mapped `-` to `_` (`serve-password` is
17
+ * `HALONIC_SECRET_SERVE_PASSWORD`), so a keychain or file store must match
18
+ * names the same way. A prefix is up to the adapter.
19
+ */
20
+ export interface Secrets {
21
+ /**
22
+ * The secret's value, or `null` when it isn't configured.
23
+ *
24
+ * @throws RangeError when the name breaks the rule above
25
+ */
26
+ get(name: string): Promise<string | null>;
27
+ }
28
+ /** The longest a `Secrets` or `TokenStore` name may be. */
29
+ export declare const maxSecretNameLength = 128;
30
+ /**
31
+ * Whether a name follows the name rule of the `Secrets` port: a letter,
32
+ * then letters, digits, `-` or `_`, at most 128 characters. Workspace checks
33
+ * use it to report a bad name in a file before anything asks a store for it.
34
+ *
35
+ * @example
36
+ * isSecretName("openai-key"); // true
37
+ * isSecretName("openai key"); // false
38
+ */
39
+ export declare function isSecretName(name: string): boolean;
40
+ /**
41
+ * The form two names are compared in: upper case, with `-` as `_`. Names
42
+ * with the same key are the same secret on every adapter, as the
43
+ * `Secrets` port requires. An adapter may store a different case of
44
+ * it, but must match by it.
45
+ *
46
+ * @throws RangeError when the name breaks the rule; the message repeats the
47
+ * name only when {@link describeSecretName} allows it
48
+ *
49
+ * @example
50
+ * secretKey("serve-password"); // "SERVE_PASSWORD"
51
+ */
52
+ export declare function secretKey(name: string): string;
53
+ /**
54
+ * Whether a message may repeat a secret name: only when it is at most 128
55
+ * printable ASCII characters. Anything else is more likely a value passed as
56
+ * a name by mistake, so it must never reach a log or an error report.
57
+ *
58
+ * @example
59
+ * isQuotableSecretName("openai key"); // true
60
+ * isQuotableSecretName("x".repeat(300)); // false
61
+ */
62
+ export declare function isQuotableSecretName(name: string): boolean;
63
+ /**
64
+ * How a message may refer to a secret name: quoted when
65
+ * {@link isQuotableSecretName} allows it, otherwise by its length only.
66
+ *
67
+ * @example
68
+ * describeSecretName("openai key"); // 'Secret name "openai key"'
69
+ * describeSecretName("x".repeat(300)); // "A secret name of 300 characters"
70
+ */
71
+ export declare function describeSecretName(name: string): string;
72
+ /**
73
+ * Halonic's own secrets: the key of the encrypted token store and the hash of
74
+ * the sign-in password. Only Halonic reads them; no workspace may pick them.
75
+ */
76
+ export declare const halonicSecretNames: readonly string[];
77
+ /**
78
+ * The prefix of a token's name in a store that also holds secrets, such as
79
+ * the desktop keychain. A secret name with this prefix is a token, so no
80
+ * workspace may pick it.
81
+ */
82
+ export declare const tokenNamePrefix = "halonic_token_";
83
+ /**
84
+ * Whether a secret name belongs to Halonic: one of {@link halonicSecretNames}
85
+ * or a token name under {@link tokenNamePrefix}. Names are compared in their
86
+ * `secretKey` form, so `Token_Key` is `token-key`.
87
+ *
88
+ * @throws RangeError when the name breaks the rule of the `Secrets` port
89
+ *
90
+ * @example
91
+ * isHalonicSecretName("Serve_Password"); // true
92
+ * isHalonicSecretName("openai-key"); // false
93
+ */
94
+ export declare function isHalonicSecretName(name: string): boolean;
95
+ /**
96
+ * The prefix of every secret a plugin declares: the app keeps a plugin's
97
+ * secret under `plugin__<id>__<secret>`. A secret name with this prefix
98
+ * belongs to a plugin, so no workspace may pick it.
99
+ */
100
+ export declare const pluginSecretNamePrefix = "plugin__";
101
+ /**
102
+ * Whether a secret name belongs to a plugin: it starts with
103
+ * {@link pluginSecretNamePrefix}. Names are compared in their `secretKey`
104
+ * form, so `Plugin-_weather` counts too.
105
+ *
106
+ * @throws RangeError when the name breaks the rule of the `Secrets` port
107
+ *
108
+ * @example
109
+ * isPluginSecretName("plugin__weather__acme-key"); // true
110
+ * isPluginSecretName("plugin-key"); // false
111
+ */
112
+ export declare function isPluginSecretName(name: string): boolean;
113
+ /**
114
+ * The secrets as a workspace may read them: by any name it picks, except the
115
+ * ones that belong to Halonic ({@link isHalonicSecretName}) or to a plugin
116
+ * ({@link isPluginSecretName}). Pass this, never the raw store, wherever a
117
+ * workspace's choice of name reaches `Secrets`.
118
+ *
119
+ * @throws RangeError from `get`, for a name of Halonic's own or a plugin's;
120
+ * the message never repeats the name
121
+ *
122
+ * @example
123
+ * const picks = workspaceSecrets(secrets);
124
+ * await picks.get("openai-key"); // the configured key, or null
125
+ * await picks.get("token-key"); // throws a RangeError
126
+ * await picks.get("plugin__weather__acme-key"); // throws a RangeError
127
+ */
128
+ export declare function workspaceSecrets(secrets: Secrets): Secrets;
@@ -0,0 +1,144 @@
1
+ /** Version of the {@link Secrets} port. A breaking change bumps it and comes with an ADR. */
2
+ export const secretsVersion = 1;
3
+ /** The longest a `Secrets` or `TokenStore` name may be. */
4
+ export const maxSecretNameLength = 128;
5
+ const secretNamePattern = /^[A-Za-z][A-Za-z0-9_-]*$/;
6
+ const printableAscii = /^[\x20-\x7E]*$/;
7
+ /**
8
+ * Whether a name follows the name rule of the `Secrets` port: a letter,
9
+ * then letters, digits, `-` or `_`, at most 128 characters. Workspace checks
10
+ * use it to report a bad name in a file before anything asks a store for it.
11
+ *
12
+ * @example
13
+ * isSecretName("openai-key"); // true
14
+ * isSecretName("openai key"); // false
15
+ */
16
+ export function isSecretName(name) {
17
+ return name.length <= maxSecretNameLength && secretNamePattern.test(name);
18
+ }
19
+ /**
20
+ * The form two names are compared in: upper case, with `-` as `_`. Names
21
+ * with the same key are the same secret on every adapter, as the
22
+ * `Secrets` port requires. An adapter may store a different case of
23
+ * it, but must match by it.
24
+ *
25
+ * @throws RangeError when the name breaks the rule; the message repeats the
26
+ * name only when {@link describeSecretName} allows it
27
+ *
28
+ * @example
29
+ * secretKey("serve-password"); // "SERVE_PASSWORD"
30
+ */
31
+ export function secretKey(name) {
32
+ if (!isSecretName(name)) {
33
+ throw new RangeError(`${describeSecretName(name)} must be a letter, then letters, digits, "-" or "_", at most ${maxSecretNameLength} characters.`);
34
+ }
35
+ return name.toUpperCase().replaceAll("-", "_");
36
+ }
37
+ /**
38
+ * Whether a message may repeat a secret name: only when it is at most 128
39
+ * printable ASCII characters. Anything else is more likely a value passed as
40
+ * a name by mistake, so it must never reach a log or an error report.
41
+ *
42
+ * @example
43
+ * isQuotableSecretName("openai key"); // true
44
+ * isQuotableSecretName("x".repeat(300)); // false
45
+ */
46
+ export function isQuotableSecretName(name) {
47
+ return name.length <= maxSecretNameLength && printableAscii.test(name);
48
+ }
49
+ /**
50
+ * How a message may refer to a secret name: quoted when
51
+ * {@link isQuotableSecretName} allows it, otherwise by its length only.
52
+ *
53
+ * @example
54
+ * describeSecretName("openai key"); // 'Secret name "openai key"'
55
+ * describeSecretName("x".repeat(300)); // "A secret name of 300 characters"
56
+ */
57
+ export function describeSecretName(name) {
58
+ if (isQuotableSecretName(name)) {
59
+ return `Secret name ${JSON.stringify(name)}`;
60
+ }
61
+ return `A secret name of ${name.length} characters`;
62
+ }
63
+ // A workspace names the secrets its providers and models use. Those names
64
+ // share one namespace with Halonic's own secrets, and on desktop with the
65
+ // tokens too (one keychain backs both stores). So every name a workspace
66
+ // picks goes through `workspaceSecrets`, which refuses the ones that belong
67
+ // to Halonic or to a plugin, whatever their case or `-`/`_` spelling.
68
+ /**
69
+ * Halonic's own secrets: the key of the encrypted token store and the hash of
70
+ * the sign-in password. Only Halonic reads them; no workspace may pick them.
71
+ */
72
+ export const halonicSecretNames = ["token-key", "serve-password"];
73
+ /**
74
+ * The prefix of a token's name in a store that also holds secrets, such as
75
+ * the desktop keychain. A secret name with this prefix is a token, so no
76
+ * workspace may pick it.
77
+ */
78
+ export const tokenNamePrefix = "halonic_token_";
79
+ const halonicSecretKeys = new Set(halonicSecretNames.map(secretKey));
80
+ const tokenKeyPrefix = secretKey(tokenNamePrefix);
81
+ /**
82
+ * Whether a secret name belongs to Halonic: one of {@link halonicSecretNames}
83
+ * or a token name under {@link tokenNamePrefix}. Names are compared in their
84
+ * `secretKey` form, so `Token_Key` is `token-key`.
85
+ *
86
+ * @throws RangeError when the name breaks the rule of the `Secrets` port
87
+ *
88
+ * @example
89
+ * isHalonicSecretName("Serve_Password"); // true
90
+ * isHalonicSecretName("openai-key"); // false
91
+ */
92
+ export function isHalonicSecretName(name) {
93
+ const key = secretKey(name);
94
+ return halonicSecretKeys.has(key) || key.startsWith(tokenKeyPrefix);
95
+ }
96
+ /**
97
+ * The prefix of every secret a plugin declares: the app keeps a plugin's
98
+ * secret under `plugin__<id>__<secret>`. A secret name with this prefix
99
+ * belongs to a plugin, so no workspace may pick it.
100
+ */
101
+ export const pluginSecretNamePrefix = "plugin__";
102
+ const pluginKeyPrefix = secretKey(pluginSecretNamePrefix);
103
+ /**
104
+ * Whether a secret name belongs to a plugin: it starts with
105
+ * {@link pluginSecretNamePrefix}. Names are compared in their `secretKey`
106
+ * form, so `Plugin-_weather` counts too.
107
+ *
108
+ * @throws RangeError when the name breaks the rule of the `Secrets` port
109
+ *
110
+ * @example
111
+ * isPluginSecretName("plugin__weather__acme-key"); // true
112
+ * isPluginSecretName("plugin-key"); // false
113
+ */
114
+ export function isPluginSecretName(name) {
115
+ return secretKey(name).startsWith(pluginKeyPrefix);
116
+ }
117
+ /**
118
+ * The secrets as a workspace may read them: by any name it picks, except the
119
+ * ones that belong to Halonic ({@link isHalonicSecretName}) or to a plugin
120
+ * ({@link isPluginSecretName}). Pass this, never the raw store, wherever a
121
+ * workspace's choice of name reaches `Secrets`.
122
+ *
123
+ * @throws RangeError from `get`, for a name of Halonic's own or a plugin's;
124
+ * the message never repeats the name
125
+ *
126
+ * @example
127
+ * const picks = workspaceSecrets(secrets);
128
+ * await picks.get("openai-key"); // the configured key, or null
129
+ * await picks.get("token-key"); // throws a RangeError
130
+ * await picks.get("plugin__weather__acme-key"); // throws a RangeError
131
+ */
132
+ export function workspaceSecrets(secrets) {
133
+ return {
134
+ get: async (name) => {
135
+ if (isHalonicSecretName(name)) {
136
+ throw new RangeError("A workspace can't pick a secret that belongs to Halonic.");
137
+ }
138
+ if (isPluginSecretName(name)) {
139
+ throw new RangeError("A workspace can't pick a secret that belongs to a plugin.");
140
+ }
141
+ return await secrets.get(name);
142
+ },
143
+ };
144
+ }
@@ -0,0 +1,19 @@
1
+ /** Version of the {@link TokenStore} port. A breaking change bumps it and comes with an ADR. */
2
+ export declare const tokenStoreVersion = 1;
3
+ /**
4
+ * Secrets the server writes itself, such as Google refresh tokens after a
5
+ * sign-in. Adapters keep them encrypted at rest. Configured secrets are read
6
+ * through {@link Secrets} and never written here.
7
+ *
8
+ * Names follow the same rule as {@link Secrets} names, including that names
9
+ * differing only in case or in `-` versus `_` are the same token. Every
10
+ * method throws a `RangeError` for a name that breaks the rule.
11
+ */
12
+ export interface TokenStore {
13
+ /** The token's value, or `null` when there is none. */
14
+ get(name: string): Promise<string | null>;
15
+ /** Creates or replaces a token. */
16
+ set(name: string, value: string): Promise<void>;
17
+ /** Deletes a token. Deleting one that isn't there is not an error. */
18
+ remove(name: string): Promise<void>;
19
+ }
@@ -0,0 +1,2 @@
1
+ /** Version of the {@link TokenStore} port. A breaking change bumps it and comes with an ADR. */
2
+ export const tokenStoreVersion = 1;
@@ -0,0 +1,211 @@
1
+ import type { ConnectorPin } from "./connector-client.js";
2
+ /** Version of the {@link ToolApprovalStore} port. A breaking change bumps it and comes with an ADR. */
3
+ export declare const toolApprovalStoreVersion = 1;
4
+ /**
5
+ * The address of the server a listed tool came from, as far as it can be
6
+ * told apart without secrets. An approval holds only for the address it was
7
+ * given at, so pointing the same source id at another server asks the
8
+ * person again, even when the tools read the same.
9
+ *
10
+ * Every part is kept as the workspace writes it: a `${NAME}` reference stays
11
+ * `${NAME}` and is never resolved, so rotating a secret asks nothing and no
12
+ * secret value reaches the profile.
13
+ *
14
+ * - `http`: the connector's URL as the trust content writes it, without
15
+ * its fragment. A URL with user info has no address, as it can't be
16
+ * trusted. The query string stays, because it is part of the server's
17
+ * identity. The headers count too, but only as their {@link WrittenDigest},
18
+ * because a person may have typed a token straight into one.
19
+ * - `stdio`: the command and its arguments, the pin when the command is a
20
+ * package runner, else `null`, and the environment as its
21
+ * {@link WrittenDigest}, for the same reason. So a wrapper pointed at
22
+ * another server through its environment asks again.
23
+ * - `integration`: the integration's id, its version and the settings the
24
+ * workspace gives it, such as the `url` of an MCP server. A new version
25
+ * asks again, because its reviewed code may talk to the server
26
+ * differently, and so do new settings. The settings are kept as plain
27
+ * text, unlike headers and the environment, because they never hold a
28
+ * secret value: a secret setting is kept in Secrets, and the settings
29
+ * hold only its `${NAME}` reference.
30
+ */
31
+ export type ToolServer = {
32
+ kind: "http";
33
+ url: string;
34
+ headers: WrittenDigest | null;
35
+ } | {
36
+ kind: "stdio";
37
+ command: string;
38
+ args: string[];
39
+ pin: ConnectorPin | null;
40
+ env: WrittenDigest | null;
41
+ } | {
42
+ kind: "integration";
43
+ id: string;
44
+ version: string;
45
+ settings: Record<string, unknown>;
46
+ };
47
+ /**
48
+ * `sha256:` and the lowercase hex SHA-256 of a connector's headers or
49
+ * environment, names and values as the workspace writes them, as canonical
50
+ * JSON. `null` in a {@link ToolServer} when the workspace writes none. Only
51
+ * the digest reaches the profile, never the text: changing a value typed in
52
+ * directly asks again, rotating the secret behind a `${NAME}` reference
53
+ * doesn't.
54
+ */
55
+ export type WrittenDigest = `sha256:${string}`;
56
+ /** A listed tool's fingerprint: `htl1:` and the lowercase hex SHA-256 of the tool as canonical JSON. */
57
+ export type ListedToolFingerprint = `htl1:${string}`;
58
+ /** Which listed tool an approval is for. */
59
+ export interface ToolApprovalKey {
60
+ /** The workspace's resolved real path, as in a `TrustRecord`. */
61
+ location: string;
62
+ /** The integration's or connector's id in the workspace. */
63
+ source: string;
64
+ /** The tool's name as the server listed it, without the source's id in front. */
65
+ name: string;
66
+ }
67
+ /**
68
+ * A listed tool as the model would see it: what `readToolListing` gives back
69
+ * after its checks, with every untrusted text written as its plain text.
70
+ * This is what a fingerprint covers and what the approval screen shows.
71
+ */
72
+ export interface ListedToolText {
73
+ /** The final name the model sees, with the source's id in front, such as "notes__lookup". */
74
+ name: string;
75
+ description: string;
76
+ /** The rebuilt parameters, with every kept `description` and `title` as plain text. */
77
+ parameters: Record<string, unknown>;
78
+ }
79
+ /**
80
+ * What Halonic keeps when a person approves one listed tool (requirement
81
+ * `ports.listed-tool-approval`).
82
+ *
83
+ * @example
84
+ * const approval: ToolApproval = {
85
+ * location: "/workspaces/acme",
86
+ * source: "notes",
87
+ * name: "lookup",
88
+ * server: { kind: "http", url: "https://notes.example.com/mcp", headers: null },
89
+ * fingerprint: "htl1:9f86d081884c7d65…",
90
+ * tool: {
91
+ * name: "notes__lookup",
92
+ * description: "Finds a note by its title.",
93
+ * parameters: { type: "object", properties: { title: { type: "string" } } },
94
+ * },
95
+ * approvedAt: "2026-11-09T10:00:00.000Z",
96
+ * };
97
+ */
98
+ export interface ToolApproval extends ToolApprovalKey {
99
+ /** The address the tool was approved at. */
100
+ server: ToolServer;
101
+ /** The fingerprint of the tool as the person was shown it, such as "htl1:9f86d0…". */
102
+ fingerprint: ListedToolFingerprint;
103
+ /** The tool the fingerprint was computed from, so Studio can show what changed. */
104
+ tool: ListedToolText;
105
+ /** When the person approved it, as ISO text. */
106
+ approvedAt: string;
107
+ }
108
+ /** One version of a listed tool that waited for approval. */
109
+ export interface WaitingVersion {
110
+ fingerprint: ListedToolFingerprint;
111
+ /** When the host first saw this version waiting, as ISO text. */
112
+ firstSeenAt: string;
113
+ }
114
+ /**
115
+ * The listed tools a person approved, in the user's profile next to the
116
+ * trust records: the profile folder for the CLI and `serve`, the app data
117
+ * folder for the desktop app, memory for tests and the browser demo.
118
+ * **Never inside a workspace**, so a workspace can't arrive with its tools
119
+ * already approved.
120
+ *
121
+ * The port only stores. `listedToolFingerprint` and `approveListedTools` in
122
+ * `core/app` compute the fingerprint and decide which tools are offered.
123
+ * Only a person writes approvals: no tool the model can call reaches this
124
+ * store. An approval stays when its tool is no longer listed, so the tool
125
+ * is on again if it comes back unchanged. Disconnecting a source revokes
126
+ * all of its approvals.
127
+ *
128
+ * An approval that exists but can't be read makes `get` and `list` throw an
129
+ * {@link UnreadableToolApprovalError}, never return `null` or skip it: the
130
+ * host then offers none of that source's listed tools and tells the user
131
+ * which approval it is. `revoke` still deletes it.
132
+ */
133
+ export interface ToolApprovalStore {
134
+ /** The approval for one listed tool, or `null` when there is none. */
135
+ get(key: ToolApprovalKey): Promise<ToolApproval | null>;
136
+ /**
137
+ * Saves an approval, replacing any approval with the same key, and
138
+ * forgets the tool's waiting versions.
139
+ */
140
+ approve(approval: ToolApproval): Promise<void>;
141
+ /**
142
+ * Deletes the approval for one listed tool, even one that can't be read,
143
+ * and forgets its waiting versions. Revoking one that isn't there is not
144
+ * an error.
145
+ */
146
+ revoke(key: ToolApprovalKey): Promise<void>;
147
+ /**
148
+ * Every approval for one source in one workspace, sorted by listed name
149
+ * in UTF-16 code-unit order.
150
+ *
151
+ * @throws UnreadableToolApprovalError when any of them can't be read
152
+ */
153
+ list(location: string, source: string): Promise<ToolApproval[]>;
154
+ /**
155
+ * Notes that a version of a listed tool is waiting, and returns the
156
+ * versions noted for that tool, oldest first. Noting a fingerprint that
157
+ * is already there keeps its first `firstSeenAt`. The store keeps at most
158
+ * the newest {@link maxWaitingVersions}, so a server that changes a tool
159
+ * on every call can't fill the profile. The host uses them to stop asking
160
+ * about a tool its server keeps changing.
161
+ */
162
+ noteWaiting(key: ToolApprovalKey, version: WaitingVersion): Promise<WaitingVersion[]>;
163
+ }
164
+ /**
165
+ * What a {@link ToolApprovalStore} throws for an approval that exists but
166
+ * can't be read: a damaged file, or one a newer Halonic wrote. It names the
167
+ * approval's source and tool as fields, so Studio and the CLI can say which
168
+ * approval it is in their own words. The message is for the log, not for a
169
+ * person to read.
170
+ *
171
+ * Check for it with {@link isUnreadableToolApprovalError}, not `instanceof`:
172
+ * an adapter may be built against its own copy of this package.
173
+ *
174
+ * @example
175
+ * throw new UnreadableToolApprovalError(
176
+ * { location: "/workspaces/acme", source: "notes" },
177
+ * "lookup",
178
+ * "The approval for tool \"lookup\" can't be read.",
179
+ * { cause },
180
+ * );
181
+ */
182
+ export declare class UnreadableToolApprovalError extends Error {
183
+ readonly name = "UnreadableToolApprovalError";
184
+ readonly location: string;
185
+ readonly source: string;
186
+ /** The tool's name as the server listed it, or `null` when the store can't tell which tool the approval is for. */
187
+ readonly toolName: string | null;
188
+ /**
189
+ * @param where - the workspace and source the approval belongs to
190
+ * @param toolName - the tool it is for, or `null` when that can't be read either
191
+ * @param message - for the log
192
+ * @param options - `cause` keeps the error this one wraps
193
+ */
194
+ constructor(where: {
195
+ location: string;
196
+ source: string;
197
+ }, toolName: string | null, message: string, options?: {
198
+ cause?: unknown;
199
+ });
200
+ }
201
+ /**
202
+ * Whether `value` is an {@link UnreadableToolApprovalError}: an `Error`
203
+ * named "UnreadableToolApprovalError" with its fields. It works across
204
+ * copies of this package, where `instanceof` doesn't.
205
+ *
206
+ * @example
207
+ * const toolName = isUnreadableToolApprovalError(error) ? error.toolName : null;
208
+ */
209
+ export declare function isUnreadableToolApprovalError(value: unknown): value is UnreadableToolApprovalError;
210
+ /** How many waiting versions of one listed tool a {@link ToolApprovalStore} keeps. */
211
+ export declare const maxWaitingVersions = 8;
@@ -0,0 +1,57 @@
1
+ /** Version of the {@link ToolApprovalStore} port. A breaking change bumps it and comes with an ADR. */
2
+ export const toolApprovalStoreVersion = 1;
3
+ /**
4
+ * What a {@link ToolApprovalStore} throws for an approval that exists but
5
+ * can't be read: a damaged file, or one a newer Halonic wrote. It names the
6
+ * approval's source and tool as fields, so Studio and the CLI can say which
7
+ * approval it is in their own words. The message is for the log, not for a
8
+ * person to read.
9
+ *
10
+ * Check for it with {@link isUnreadableToolApprovalError}, not `instanceof`:
11
+ * an adapter may be built against its own copy of this package.
12
+ *
13
+ * @example
14
+ * throw new UnreadableToolApprovalError(
15
+ * { location: "/workspaces/acme", source: "notes" },
16
+ * "lookup",
17
+ * "The approval for tool \"lookup\" can't be read.",
18
+ * { cause },
19
+ * );
20
+ */
21
+ export class UnreadableToolApprovalError extends Error {
22
+ name = "UnreadableToolApprovalError";
23
+ location;
24
+ source;
25
+ /** The tool's name as the server listed it, or `null` when the store can't tell which tool the approval is for. */
26
+ toolName;
27
+ /**
28
+ * @param where - the workspace and source the approval belongs to
29
+ * @param toolName - the tool it is for, or `null` when that can't be read either
30
+ * @param message - for the log
31
+ * @param options - `cause` keeps the error this one wraps
32
+ */
33
+ constructor(where, toolName, message, options) {
34
+ super(message, options);
35
+ this.location = where.location;
36
+ this.source = where.source;
37
+ this.toolName = toolName;
38
+ }
39
+ }
40
+ /**
41
+ * Whether `value` is an {@link UnreadableToolApprovalError}: an `Error`
42
+ * named "UnreadableToolApprovalError" with its fields. It works across
43
+ * copies of this package, where `instanceof` doesn't.
44
+ *
45
+ * @example
46
+ * const toolName = isUnreadableToolApprovalError(error) ? error.toolName : null;
47
+ */
48
+ export function isUnreadableToolApprovalError(value) {
49
+ if (!(value instanceof Error) || value.name !== "UnreadableToolApprovalError")
50
+ return false;
51
+ const fields = value;
52
+ return (typeof fields.location === "string" &&
53
+ typeof fields.source === "string" &&
54
+ (typeof fields.toolName === "string" || fields.toolName === null));
55
+ }
56
+ /** How many waiting versions of one listed tool a {@link ToolApprovalStore} keeps. */
57
+ export const maxWaitingVersions = 8;