@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,253 @@
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`, the folder it starts in, normalised as the
21
+ * trust content writes it (`.` when the workspace writes none), the
22
+ * environment as its {@link WrittenDigest}, for the same reason, and the
23
+ * secret environment (variable name to secret name) as its
24
+ * {@link WrittenDigest}, and the names it takes from the app's environment
25
+ * (`inheritEnv`), sorted, only when it names one. So a wrapper pointed at
26
+ * another server through its environment, its folder, another secret or
27
+ * another variable of the person's asks again.
28
+ * - `integration`: the integration's id, its version and the settings the
29
+ * workspace gives it, such as the `url` of an MCP server. A new version
30
+ * asks again, because its reviewed code may talk to the server
31
+ * differently, and so do new settings. The settings are kept as plain
32
+ * text, unlike headers and the environment, because they never hold a
33
+ * secret value: a secret setting is kept in Secrets, and the settings
34
+ * hold only its `${NAME}` reference.
35
+ */
36
+ export type ToolServer = {
37
+ kind: "http";
38
+ url: string;
39
+ headers: WrittenDigest | null;
40
+ } | {
41
+ kind: "stdio";
42
+ command: string;
43
+ args: string[];
44
+ pin: ConnectorPin | null;
45
+ cwd: string;
46
+ env: WrittenDigest | null;
47
+ secretEnv: WrittenDigest | null;
48
+ inheritEnv?: string[];
49
+ } | {
50
+ kind: "integration";
51
+ id: string;
52
+ version: string;
53
+ settings: Record<string, unknown>;
54
+ };
55
+ /**
56
+ * `sha256:` and the lowercase hex SHA-256 of a connector's headers or
57
+ * environment, names and values as the workspace writes them, as canonical
58
+ * JSON. `null` in a {@link ToolServer} when the workspace writes none. Only
59
+ * the digest reaches the profile, never the text: changing a value typed in
60
+ * directly asks again, rotating the secret behind a `${NAME}` reference
61
+ * doesn't.
62
+ */
63
+ export type WrittenDigest = `sha256:${string}`;
64
+ /** A listed tool's fingerprint: `htl1:` and the lowercase hex SHA-256 of the tool as canonical JSON. */
65
+ export type ListedToolFingerprint = `htl1:${string}`;
66
+ /** Which listed tool an approval is for. */
67
+ export interface ToolApprovalKey {
68
+ /** The workspace's resolved real path, as in a `TrustRecord`. */
69
+ location: string;
70
+ /** The integration's or connector's id in the workspace. */
71
+ source: string;
72
+ /** The tool's name as the server listed it, without the source's id in front. */
73
+ name: string;
74
+ }
75
+ /**
76
+ * A listed tool as the model would see it: what `readToolListing` gives back
77
+ * after its checks, with every untrusted text written as its plain text.
78
+ * This is what a fingerprint covers and what the approval screen shows.
79
+ */
80
+ export interface ListedToolText {
81
+ /** The final name the model sees, with the source's id in front, such as "notes__lookup". */
82
+ name: string;
83
+ description: string;
84
+ /** The rebuilt parameters, with every kept `description` and `title` as plain text. */
85
+ parameters: Record<string, unknown>;
86
+ }
87
+ /**
88
+ * What Halonic keeps when a person approves one listed tool (requirement
89
+ * `ports.listed-tool-approval`).
90
+ *
91
+ * @example
92
+ * const approval: ToolApproval = {
93
+ * location: "/workspaces/acme",
94
+ * source: "notes",
95
+ * name: "lookup",
96
+ * server: { kind: "http", url: "https://notes.example.com/mcp", headers: null },
97
+ * fingerprint: "htl1:9f86d081884c7d65…",
98
+ * tool: {
99
+ * name: "notes__lookup",
100
+ * description: "Finds a note by its title.",
101
+ * parameters: { type: "object", properties: { title: { type: "string" } } },
102
+ * },
103
+ * approvedAt: "2026-11-09T10:00:00.000Z",
104
+ * };
105
+ */
106
+ export interface ToolApproval extends ToolApprovalKey {
107
+ /** The address the tool was approved at. */
108
+ server: ToolServer;
109
+ /** The fingerprint of the tool as the person was shown it, such as "htl1:9f86d0…". */
110
+ fingerprint: ListedToolFingerprint;
111
+ /** The tool the fingerprint was computed from, so Studio can show what changed. */
112
+ tool: ListedToolText;
113
+ /** When the person approved it, as ISO text. */
114
+ approvedAt: string;
115
+ }
116
+ /** The `fingerprint` of a stored {@link ToolApproval}: `htl1:` and 64 lowercase hex digits. */
117
+ export declare const listedToolFingerprintPattern: RegExp;
118
+ /** One version of a listed tool that waited for approval. */
119
+ export interface WaitingVersion {
120
+ fingerprint: ListedToolFingerprint;
121
+ /** When the host first saw this version waiting, as ISO text. */
122
+ firstSeenAt: string;
123
+ }
124
+ /**
125
+ * The listed tools a person approved, in the user's profile next to the
126
+ * trust records: the profile folder for the CLI and `serve`, the app data
127
+ * folder for the desktop app, memory for tests and the browser demo.
128
+ * **Never inside a workspace**, so a workspace can't arrive with its tools
129
+ * already approved.
130
+ *
131
+ * The port only stores. `listedToolFingerprint` and `approveListedTools` in
132
+ * `core/app` compute the fingerprint and decide which tools are offered.
133
+ * Only a person writes approvals: no tool the model can call reaches this
134
+ * store. An approval stays when its tool is no longer listed, so the tool
135
+ * is on again if it comes back unchanged. Disconnecting a source revokes
136
+ * all of its approvals.
137
+ *
138
+ * An approval that exists but can't be read makes `get` and `list` throw an
139
+ * {@link UnreadableToolApprovalError}, never return `null` or skip it: the
140
+ * host then offers none of that source's listed tools and tells the user
141
+ * which approval it is. `revoke` still deletes it.
142
+ */
143
+ export interface ToolApprovalStore {
144
+ /** The approval for one listed tool, or `null` when there is none. */
145
+ get(key: ToolApprovalKey): Promise<ToolApproval | null>;
146
+ /**
147
+ * Saves an approval, replacing any approval with the same key, and
148
+ * forgets the tool's waiting versions.
149
+ */
150
+ approve(approval: ToolApproval): Promise<void>;
151
+ /**
152
+ * Deletes the approval for one listed tool, even one that can't be read,
153
+ * and forgets its waiting versions. Revoking one that isn't there is not
154
+ * an error.
155
+ */
156
+ revoke(key: ToolApprovalKey): Promise<void>;
157
+ /**
158
+ * Every approval for one source in one workspace, sorted by listed name
159
+ * in UTF-16 code-unit order.
160
+ *
161
+ * @throws UnreadableToolApprovalError when any of them can't be read
162
+ */
163
+ list(location: string, source: string): Promise<ToolApproval[]>;
164
+ /**
165
+ * Notes that a version of a listed tool is waiting, and returns the
166
+ * versions noted for that tool, oldest first. The store follows
167
+ * {@link keptWaitingVersions}, so a server that changes a tool on every
168
+ * call, or lists new names on every call, can't fill the profile. The
169
+ * host uses the versions to stop asking about a tool its server keeps
170
+ * changing.
171
+ */
172
+ noteWaiting(key: ToolApprovalKey, version: WaitingVersion): Promise<WaitingVersion[]>;
173
+ }
174
+ /**
175
+ * What a {@link ToolApprovalStore} throws for an approval that exists but
176
+ * can't be read: a damaged file, or one a newer Halonic wrote. It names the
177
+ * approval's source and tool as fields, so Studio and the CLI can say which
178
+ * approval it is in their own words. The message is for the log, not for a
179
+ * person to read.
180
+ *
181
+ * Check for it with {@link isUnreadableToolApprovalError}, not `instanceof`:
182
+ * an adapter may be built against its own copy of this package.
183
+ *
184
+ * @example
185
+ * throw new UnreadableToolApprovalError(
186
+ * { location: "/workspaces/acme", source: "notes" },
187
+ * "lookup",
188
+ * "The approval for tool \"lookup\" can't be read.",
189
+ * { cause },
190
+ * );
191
+ */
192
+ export declare class UnreadableToolApprovalError extends Error {
193
+ readonly name = "UnreadableToolApprovalError";
194
+ readonly location: string;
195
+ readonly source: string;
196
+ /** The tool's name as the server listed it, or `null` when the store can't tell which tool the approval is for. */
197
+ readonly toolName: string | null;
198
+ /**
199
+ * @param where - the workspace and source the approval belongs to
200
+ * @param toolName - the tool it is for, or `null` when that can't be read either
201
+ * @param message - for the log
202
+ * @param options - `cause` keeps the error this one wraps
203
+ */
204
+ constructor(where: {
205
+ location: string;
206
+ source: string;
207
+ }, toolName: string | null, message: string, options?: {
208
+ cause?: unknown;
209
+ });
210
+ }
211
+ /**
212
+ * Whether `value` is an {@link UnreadableToolApprovalError}: an `Error`
213
+ * named "UnreadableToolApprovalError" with its fields. It works across
214
+ * copies of this package, where `instanceof` doesn't.
215
+ *
216
+ * @example
217
+ * const toolName = isUnreadableToolApprovalError(error) ? error.toolName : null;
218
+ */
219
+ export declare function isUnreadableToolApprovalError(value: unknown): value is UnreadableToolApprovalError;
220
+ /** How many waiting versions of one listed tool a {@link ToolApprovalStore} keeps. */
221
+ export declare const maxWaitingVersions = 8;
222
+ /**
223
+ * How many listed tools of one source a {@link ToolApprovalStore} keeps
224
+ * waiting versions for: twice the most tools one listing may return.
225
+ */
226
+ export declare const maxWaitingTools = 256;
227
+ /** How long a {@link ToolApprovalStore} keeps a waiting version after it was first seen: 24 hours. */
228
+ export declare const waitingVersionKeptMs: number;
229
+ /**
230
+ * The waiting versions of one source after noting `version` for the tool
231
+ * `name`, the one rule every {@link ToolApprovalStore} follows:
232
+ *
233
+ * - The time `version` was first seen counts as now. Every version first
234
+ * seen more than {@link waitingVersionKeptMs} before it is dropped, and so
235
+ * is a tool left with none.
236
+ * - A fingerprint that is still noted keeps its first `firstSeenAt`;
237
+ * otherwise `version` is added as the newest.
238
+ * - Each tool keeps its newest {@link maxWaitingVersions} versions.
239
+ * - The source keeps the {@link maxWaitingTools} tools whose newest version
240
+ * was first seen most recently, `name` always among them. Among tools
241
+ * whose newest versions were first seen at the same time, the one first
242
+ * in UTF-16 code-unit order is dropped first.
243
+ *
244
+ * Dropping only ever makes the host ask again, never offer a tool.
245
+ *
246
+ * @param waiting - the source's waiting versions by tool name, each oldest first; not changed
247
+ * @returns the source's waiting versions to store, and those of `name`, as `noteWaiting` returns them
248
+ * @throws RangeError when `version.firstSeenAt` isn't a date
249
+ */
250
+ export declare function keptWaitingVersions(waiting: ReadonlyMap<string, readonly WaitingVersion[]>, name: string, version: WaitingVersion): {
251
+ waiting: Map<string, WaitingVersion[]>;
252
+ versions: WaitingVersion[];
253
+ };
@@ -0,0 +1,116 @@
1
+ /** Version of the {@link ToolApprovalStore} port. A breaking change bumps it and comes with an ADR. */
2
+ export const toolApprovalStoreVersion = 1;
3
+ /** The `fingerprint` of a stored {@link ToolApproval}: `htl1:` and 64 lowercase hex digits. */
4
+ export const listedToolFingerprintPattern = /^htl1:[0-9a-f]{64}$/u;
5
+ /**
6
+ * What a {@link ToolApprovalStore} throws for an approval that exists but
7
+ * can't be read: a damaged file, or one a newer Halonic wrote. It names the
8
+ * approval's source and tool as fields, so Studio and the CLI can say which
9
+ * approval it is in their own words. The message is for the log, not for a
10
+ * person to read.
11
+ *
12
+ * Check for it with {@link isUnreadableToolApprovalError}, not `instanceof`:
13
+ * an adapter may be built against its own copy of this package.
14
+ *
15
+ * @example
16
+ * throw new UnreadableToolApprovalError(
17
+ * { location: "/workspaces/acme", source: "notes" },
18
+ * "lookup",
19
+ * "The approval for tool \"lookup\" can't be read.",
20
+ * { cause },
21
+ * );
22
+ */
23
+ export class UnreadableToolApprovalError extends Error {
24
+ name = "UnreadableToolApprovalError";
25
+ location;
26
+ source;
27
+ /** The tool's name as the server listed it, or `null` when the store can't tell which tool the approval is for. */
28
+ toolName;
29
+ /**
30
+ * @param where - the workspace and source the approval belongs to
31
+ * @param toolName - the tool it is for, or `null` when that can't be read either
32
+ * @param message - for the log
33
+ * @param options - `cause` keeps the error this one wraps
34
+ */
35
+ constructor(where, toolName, message, options) {
36
+ super(message, options);
37
+ this.location = where.location;
38
+ this.source = where.source;
39
+ this.toolName = toolName;
40
+ }
41
+ }
42
+ /**
43
+ * Whether `value` is an {@link UnreadableToolApprovalError}: an `Error`
44
+ * named "UnreadableToolApprovalError" with its fields. It works across
45
+ * copies of this package, where `instanceof` doesn't.
46
+ *
47
+ * @example
48
+ * const toolName = isUnreadableToolApprovalError(error) ? error.toolName : null;
49
+ */
50
+ export function isUnreadableToolApprovalError(value) {
51
+ if (!(value instanceof Error) || value.name !== "UnreadableToolApprovalError")
52
+ return false;
53
+ const fields = value;
54
+ return (typeof fields.location === "string" &&
55
+ typeof fields.source === "string" &&
56
+ (typeof fields.toolName === "string" || fields.toolName === null));
57
+ }
58
+ /** How many waiting versions of one listed tool a {@link ToolApprovalStore} keeps. */
59
+ export const maxWaitingVersions = 8;
60
+ /**
61
+ * How many listed tools of one source a {@link ToolApprovalStore} keeps
62
+ * waiting versions for: twice the most tools one listing may return.
63
+ */
64
+ export const maxWaitingTools = 256;
65
+ /** How long a {@link ToolApprovalStore} keeps a waiting version after it was first seen: 24 hours. */
66
+ export const waitingVersionKeptMs = 24 * 60 * 60 * 1000;
67
+ /**
68
+ * The waiting versions of one source after noting `version` for the tool
69
+ * `name`, the one rule every {@link ToolApprovalStore} follows:
70
+ *
71
+ * - The time `version` was first seen counts as now. Every version first
72
+ * seen more than {@link waitingVersionKeptMs} before it is dropped, and so
73
+ * is a tool left with none.
74
+ * - A fingerprint that is still noted keeps its first `firstSeenAt`;
75
+ * otherwise `version` is added as the newest.
76
+ * - Each tool keeps its newest {@link maxWaitingVersions} versions.
77
+ * - The source keeps the {@link maxWaitingTools} tools whose newest version
78
+ * was first seen most recently, `name` always among them. Among tools
79
+ * whose newest versions were first seen at the same time, the one first
80
+ * in UTF-16 code-unit order is dropped first.
81
+ *
82
+ * Dropping only ever makes the host ask again, never offer a tool.
83
+ *
84
+ * @param waiting - the source's waiting versions by tool name, each oldest first; not changed
85
+ * @returns the source's waiting versions to store, and those of `name`, as `noteWaiting` returns them
86
+ * @throws RangeError when `version.firstSeenAt` isn't a date
87
+ */
88
+ export function keptWaitingVersions(waiting, name, version) {
89
+ const now = Date.parse(version.firstSeenAt);
90
+ if (Number.isNaN(now)) {
91
+ throw new RangeError(`The waiting version's firstSeenAt isn't a date: ${version.firstSeenAt}`);
92
+ }
93
+ const recent = (noted) => now - Date.parse(noted.firstSeenAt) <= waitingVersionKeptMs;
94
+ const kept = new Map();
95
+ for (const [other, versions] of waiting) {
96
+ const left = versions.filter(recent).map((noted) => ({ ...noted }));
97
+ if (left.length > 0)
98
+ kept.set(other, left);
99
+ }
100
+ const versions = kept.get(name) ?? [];
101
+ if (!versions.some((noted) => noted.fingerprint === version.fingerprint)) {
102
+ versions.push({ fingerprint: version.fingerprint, firstSeenAt: version.firstSeenAt });
103
+ }
104
+ const toolVersions = versions.slice(-maxWaitingVersions);
105
+ kept.set(name, toolVersions);
106
+ if (kept.size > maxWaitingTools) {
107
+ const lastNoted = (versions) => Math.max(...versions.map((noted) => Date.parse(noted.firstSeenAt)));
108
+ const others = [...kept]
109
+ .filter(([other]) => other !== name)
110
+ .sort(([leftName, left], [rightName, right]) => lastNoted(left) - lastNoted(right) || (leftName < rightName ? -1 : 1));
111
+ for (const [other] of others.slice(0, kept.size - maxWaitingTools)) {
112
+ kept.delete(other);
113
+ }
114
+ }
115
+ return { waiting: kept, versions: toolVersions.map((noted) => ({ ...noted })) };
116
+ }
@@ -0,0 +1,72 @@
1
+ import type { ConnectorPin } from "./connector-client.js";
2
+ /** Version of the {@link TrustStore} port. A breaking change bumps it and comes with an ADR. */
3
+ export declare const trustStoreVersion = 1;
4
+ /** How a trust record came to be: the Studio prompt, `halonic trust`, a new workspace Halonic wrote, or the one-time migration. */
5
+ export type TrustOrigin = "prompt" | "cli" | "created" | "migration";
6
+ /**
7
+ * What Halonic keeps when a person trusts a source (a workspace, or a hub
8
+ * or skill folder outside it).
9
+ *
10
+ * @example
11
+ * const record: TrustRecord = {
12
+ * location: "/workspaces/acme",
13
+ * fingerprint: "hfp1:9f86d081884c7d65…",
14
+ * content: { programs: [{ connector: "mail", command: "npx", args: ["-y", "@acme/mail-mcp"] }] },
15
+ * grantedAt: "2026-11-08T10:00:00.000Z",
16
+ * appVersion: "0.1.0",
17
+ * pins: { mail: { registry: "npm", registryUrl: "https://registry.npmjs.org", package: "@acme/mail-mcp", version: "2.3.1" } },
18
+ * origin: "prompt",
19
+ * };
20
+ */
21
+ export interface TrustRecord {
22
+ /** The source's resolved real path. It is the record's key and isn't part of the fingerprint. */
23
+ location: string;
24
+ /** The fingerprint of what the prompt showed, such as "hfp1:9f86d0…". */
25
+ fingerprint: string;
26
+ /** The normalised content the fingerprint was computed from, as JSON, so "what changed" can be shown later. */
27
+ content: unknown;
28
+ /** When the person trusted it, as ISO text. */
29
+ grantedAt: string;
30
+ /** The version of Halonic that wrote the record. */
31
+ appVersion: string;
32
+ /** The pinned version of each package-runner connector (`npx`, `uvx` and so on), by connector id. */
33
+ pins: Record<string, ConnectorPin>;
34
+ origin: TrustOrigin;
35
+ }
36
+ /**
37
+ * The trust records in the user's profile: the profile folder for the CLI
38
+ * and `serve`, the app data folder for the desktop app, memory for tests
39
+ * and the browser demo. **Never inside a workspace**, so a workspace can't
40
+ * trust itself.
41
+ *
42
+ * The port only stores records. `TrustService` in `core/app` resolves the
43
+ * location, computes the fingerprint and decides whether a source is
44
+ * trusted. Locations are compared exactly as given: no case folding and
45
+ * no Unicode normalisation, so `café` written as one code point and as `e`
46
+ * plus a combining accent are two locations.
47
+ *
48
+ * A record that exists but can't be read makes `get` and `list` throw,
49
+ * never return `null` or skip it: the service then treats the source as
50
+ * untrusted and tells the user why, instead of asking again as if it were
51
+ * new. The error names the record's location, and `revoke` still deletes
52
+ * that record, so the user can recover with `halonic trust --remove`.
53
+ */
54
+ export interface TrustStore {
55
+ /** The record for a location, or `null` when there is none. */
56
+ get(location: string): Promise<TrustRecord | null>;
57
+ /** Saves a record, replacing any record for the same location. */
58
+ grant(record: TrustRecord): Promise<void>;
59
+ /**
60
+ * Deletes the record for a location, even one that can't be read.
61
+ * Revoking one that isn't there is not an error.
62
+ */
63
+ revoke(location: string): Promise<void>;
64
+ /**
65
+ * Every record, sorted by location in UTF-16 code-unit order (as `<`
66
+ * compares strings, not `localeCompare`), for `halonic trust --list` and
67
+ * the trusted-sources list.
68
+ *
69
+ * @throws when any record can't be read, naming its location
70
+ */
71
+ list(): Promise<TrustRecord[]>;
72
+ }
@@ -0,0 +1,2 @@
1
+ /** Version of the {@link TrustStore} port. A breaking change bumps it and comes with an ADR. */
2
+ export const trustStoreVersion = 1;
@@ -0,0 +1,43 @@
1
+ /** Version of the {@link UnfencedRunConsentStore} port. A breaking change bumps it and comes with an ADR. */
2
+ export declare const unfencedRunConsentStoreVersion = 1;
3
+ /**
4
+ * The user's yes to run plugin and integration code without the sandbox on
5
+ * this computer (requirement `ports.unfenced-run-consent-store`). One yes
6
+ * covers every plugin and integration, and holds only for the reason it was
7
+ * given for.
8
+ *
9
+ * @example
10
+ * const consent: UnfencedRunConsent = { reason: "windows", allowedAt: "2026-11-09T10:00:00.000Z" };
11
+ */
12
+ export interface UnfencedRunConsent {
13
+ /**
14
+ * Why the code couldn't run in the sandbox when the user said yes, as the
15
+ * fence status names it, such as `windows` or `container`.
16
+ */
17
+ reason: string;
18
+ /** When the user said yes, as ISO text. Studio shows it ("You allowed … on 9 Nov"). */
19
+ allowedAt: string;
20
+ }
21
+ /**
22
+ * The user's one saved yes, in their profile on this computer: the profile
23
+ * folder for the CLI and `serve`, the app data folder for the desktop app,
24
+ * memory for tests. **Never in a workspace, a sheet, a setting or a config
25
+ * file**, and there is no CLI flag for it, so neither a workspace nor an
26
+ * agent can give it (I5 design 4.3.1).
27
+ *
28
+ * The port only stores the yes. `UnfencedRuns` in `core/app` decides from it
29
+ * and the fence status whether code may start, and asks again when the
30
+ * reason changes. Only Studio saves a yes, when the user ticks the trust
31
+ * check's checkbox; no tool the model can call reaches this store.
32
+ *
33
+ * A yes that exists but can't be read makes `get` throw, never return
34
+ * `null`; the caller then treats it as no yes. `remove` still deletes it.
35
+ */
36
+ export interface UnfencedRunConsentStore {
37
+ /** The saved yes, or `null` when there is none. */
38
+ get(): Promise<UnfencedRunConsent | null>;
39
+ /** Saves the yes, replacing any saved one. */
40
+ save(consent: UnfencedRunConsent): Promise<void>;
41
+ /** Deletes the yes, even one that can't be read. Removing none is not an error. */
42
+ remove(): Promise<void>;
43
+ }
@@ -0,0 +1,2 @@
1
+ /** Version of the {@link UnfencedRunConsentStore} port. A breaking change bumps it and comes with an ADR. */
2
+ export const unfencedRunConsentStoreVersion = 1;
@@ -0,0 +1,8 @@
1
+ import type { VcsStatus } from "./vcs.js";
2
+ /**
3
+ * Reads the output of `git status --porcelain=v2 -z`, with or without `--branch`: the branch
4
+ * header lines, if any, then one record per changed path. A path changed both in the index and
5
+ * in the working tree gives two changes, one staged and one not. The result is for a repository;
6
+ * a folder that isn't one is for the caller to tell.
7
+ */
8
+ export declare function parseStatus(output: string): VcsStatus;
@@ -0,0 +1,90 @@
1
+ /** What one letter of a porcelain `XY` field means; `.` is no change. */
2
+ const letterStatus = {
3
+ M: "modified",
4
+ T: "modified",
5
+ A: "added",
6
+ C: "added",
7
+ D: "deleted",
8
+ R: "renamed",
9
+ };
10
+ /** The spaces before the path in an ordinary (`1`), renamed (`2`) and conflicted (`u`) record. */
11
+ const pathAfterSpaces = { "1": 8, "2": 9, u: 10 };
12
+ /**
13
+ * Reads the output of `git status --porcelain=v2 -z`, with or without `--branch`: the branch
14
+ * header lines, if any, then one record per changed path. A path changed both in the index and
15
+ * in the working tree gives two changes, one staged and one not. The result is for a repository;
16
+ * a folder that isn't one is for the caller to tell.
17
+ */
18
+ export function parseStatus(output) {
19
+ const status = {
20
+ isRepo: true,
21
+ branch: null,
22
+ upstream: null,
23
+ ahead: 0,
24
+ behind: 0,
25
+ changes: [],
26
+ };
27
+ const fields = output.split("\0");
28
+ for (let at = 0; at < fields.length; at++) {
29
+ const field = fields[at] ?? "";
30
+ if (field.startsWith("# "))
31
+ readHeader(field.slice(2), status);
32
+ else if (field.startsWith("1 "))
33
+ status.changes.push(...ordinary(field, pathAfterSpaces["1"]));
34
+ else if (field.startsWith("2 ")) {
35
+ // A rename's old path is the next field.
36
+ at += 1;
37
+ status.changes.push(...ordinary(field, pathAfterSpaces["2"], fields[at]));
38
+ }
39
+ else if (field.startsWith("u ")) {
40
+ status.changes.push({
41
+ path: pathAfter(field, pathAfterSpaces.u),
42
+ status: "conflicted",
43
+ staged: false,
44
+ });
45
+ }
46
+ else if (field.startsWith("? ")) {
47
+ status.changes.push({ path: field.slice(2), status: "untracked", staged: false });
48
+ }
49
+ }
50
+ return status;
51
+ }
52
+ function readHeader(header, status) {
53
+ const space = header.indexOf(" ");
54
+ const name = header.slice(0, space);
55
+ const value = header.slice(space + 1);
56
+ if (name === "branch.head")
57
+ status.branch = value === "(detached)" ? null : value;
58
+ if (name === "branch.upstream")
59
+ status.upstream = value;
60
+ if (name === "branch.ab") {
61
+ const match = /^\+(\d+) -(\d+)$/u.exec(value);
62
+ status.ahead = Number(match?.[1] ?? 0);
63
+ status.behind = Number(match?.[2] ?? 0);
64
+ }
65
+ }
66
+ /** The changes of an ordinary or renamed record: one for the index letter, one for the tree's. */
67
+ function ordinary(field, spaces, from) {
68
+ const path = pathAfter(field, spaces);
69
+ const changes = [];
70
+ for (const [letter, staged] of [
71
+ [field.charAt(2), true],
72
+ [field.charAt(3), false],
73
+ ]) {
74
+ const status = letterStatus[letter];
75
+ if (status === undefined)
76
+ continue;
77
+ const change = { path, status, staged };
78
+ if (status === "renamed" && from !== undefined)
79
+ change.from = from;
80
+ changes.push(change);
81
+ }
82
+ return changes;
83
+ }
84
+ /** The text after the first `spaces` spaces of a record: the path, which may hold spaces itself. */
85
+ function pathAfter(field, spaces) {
86
+ let at = 0;
87
+ for (let found = 0; found < spaces; found++)
88
+ at = field.indexOf(" ", at) + 1;
89
+ return field.slice(at);
90
+ }