@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,70 @@
1
+ /**
2
+ * Version of the {@link Sandbox} port. A breaking change bumps it and comes with an ADR.
3
+ *
4
+ * 2: {@link SandboxSession.fence} proves the fence before anything runs
5
+ * (docs/adr/2026-11-09-sandbox-fence-proof.md).
6
+ * 3: `SandboxCheck.reason` says why the sandbox can't start, as a listed code
7
+ * (docs/adr/2026-11-09-sandbox-check-reason-codes.md).
8
+ * 4: {@link SandboxNetwork.bridge} may be `null`: a session with no network
9
+ * but its listed sites (docs/adr/2026-11-10-sandbox-optional-bridge.md).
10
+ * 5: strength `none` and the fence proof `off`, for the launcher that starts
11
+ * programs without a fence (docs/adr/2026-11-11-sandbox-without-fence.md).
12
+ * 6: reason codes for setup, WSL, company policy and sign-in, and `windows`
13
+ * narrowed to a backend with no Windows mode
14
+ * (docs/adr/2026-11-11-pluggable-sandbox-layer.md).
15
+ * 7: {@link SandboxNetwork.bridge} says its kind: a loopback port, or a name
16
+ * the sandbox's proxy serves on a Unix socket
17
+ * (docs/adr/2026-11-11-sandbox-bridge-on-a-socket.md).
18
+ */
19
+ export const sandboxVersion = 7;
20
+ /**
21
+ * Every reason a sandbox can't start on this machine. The list is closed: an
22
+ * adapter returns only these, and a new reason is a port change. Studio and
23
+ * the CLI turn each one into the words a person reads and the fix; the
24
+ * adapter never words it.
25
+ *
26
+ * - `windows`: this backend has no Windows mode, so it can't run on Windows at all.
27
+ * - `container`: Halonic itself runs inside a container (such as Docker), which won't nest the fence.
28
+ * - `not-supported`: this edition or build of the operating system can't run the backend, such as Windows older than 10 2004.
29
+ * - `blocked-by-policy`: a company policy blocks the backend, such as a WSL group policy or Docker's admin settings.
30
+ * - `virtualisation-off`: hardware virtualisation is off, or a VM has no nested virtualisation.
31
+ * - `wsl-missing`: WSL isn't installed, which needs an administrator.
32
+ * - `restart-needed`: WSL is installed, but Windows must restart first.
33
+ * - `distro-missing`: WSL works, but Halonic's own distro isn't imported (no administrator needed).
34
+ * - `setup-conflict`: the machine-wide setup belongs to another program, or is set up another way.
35
+ * - `setup-needed`: the one-time administrator setup isn't done, or was done by another release of the backend.
36
+ * - `user-namespaces-restricted`: the system doesn't let programs create user namespaces, as Ubuntu 24.04 does by default.
37
+ * - `bubblewrap-missing`: bubblewrap (`bwrap`) is not installed.
38
+ * - `linux-tools-missing`: `socat` or ripgrep (`rg`), which srt starts next to bubblewrap, is not installed.
39
+ * - `ripgrep-missing`: ripgrep (`rg`), which srt starts next to Seatbelt on macOS, is not installed.
40
+ * - `sign-in-needed`: the backend needs an account sign-in.
41
+ * - `other`: none of the above; `SandboxCheck.missing` says what.
42
+ *
43
+ * The order is the order of the fixes: what Halonic can't fix comes before
44
+ * what an administrator can, and that before what the person can do in one
45
+ * step.
46
+ */
47
+ export const sandboxUnavailableReasons = [
48
+ "windows",
49
+ "container",
50
+ "not-supported",
51
+ "blocked-by-policy",
52
+ "virtualisation-off",
53
+ "wsl-missing",
54
+ "restart-needed",
55
+ "distro-missing",
56
+ "setup-conflict",
57
+ "setup-needed",
58
+ "user-namespaces-restricted",
59
+ "bubblewrap-missing",
60
+ "linux-tools-missing",
61
+ "ripgrep-missing",
62
+ "sign-in-needed",
63
+ "other",
64
+ ];
65
+ /**
66
+ * Every package manager a {@link SandboxFix} can name: `apt` (Debian,
67
+ * Ubuntu), `dnf` (Fedora), `pacman` (Arch), `zypper` (openSUSE) and `brew`
68
+ * (Homebrew on macOS). The list is closed, and a new one is a port change.
69
+ */
70
+ export const sandboxPackageManagers = ["apt", "dnf", "pacman", "zypper", "brew"];
@@ -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,201 @@
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
+ * Any error `get` throws, for this or any other reason, never holds the
27
+ * secret's value in its message or its cause, so a caller may show the
28
+ * message.
29
+ */
30
+ get(name: string): Promise<string | null>;
31
+ }
32
+ /**
33
+ * The secrets a person sets and removes with `halonic secret`: {@link Secrets}
34
+ * that can also be written. A host that only reads secrets (a Worker, the
35
+ * environment) implements `Secrets` alone; only a store the person owns, such
36
+ * as a file in the profile, implements this. It follows the version of
37
+ * {@link Secrets}, which it extends without changing.
38
+ *
39
+ * The same name rule and the same matching apply: every method runs
40
+ * {@link secretKey} on a name before it touches storage, so a bad name is a
41
+ * `RangeError` that changes nothing, and `Open-AI` and `open_ai` are one secret.
42
+ * **A value never appears in an error, a log or a listing.**
43
+ */
44
+ export interface SecretStore extends Secrets {
45
+ /**
46
+ * Saves a value, replacing the one stored under the same name. The name is
47
+ * kept as it was written last, so a listing shows what the person typed.
48
+ *
49
+ * @throws RangeError when the name breaks the rule, or the value is empty or
50
+ * longer than {@link maxSecretValueLength}; the message never repeats the value
51
+ */
52
+ set(name: string, value: string): Promise<void>;
53
+ /**
54
+ * Removes a secret. Removing one that isn't stored succeeds and changes nothing.
55
+ *
56
+ * @throws RangeError when the name breaks the rule
57
+ */
58
+ remove(name: string): Promise<void>;
59
+ /** The names of the stored secrets, sorted by their `secretKey` form, and never a value. */
60
+ names(): Promise<readonly string[]>;
61
+ }
62
+ /** The longest value a {@link SecretStore} saves, in UTF-16 code units. Bounds what one secret may cost a store. */
63
+ export declare const maxSecretValueLength: number;
64
+ /**
65
+ * Checks a value before a {@link SecretStore} saves it, so every store refuses
66
+ * the same ones: an empty value (`EnvSecrets` treats it as unset, so it would
67
+ * look like no secret) and one over {@link maxSecretValueLength}.
68
+ *
69
+ * @throws RangeError; the message never repeats the value, only its length
70
+ *
71
+ * @example
72
+ * checkSecretValue("sk-live-1234"); // fine
73
+ * checkSecretValue(""); // throws a RangeError
74
+ */
75
+ export declare function checkSecretValue(value: string): void;
76
+ /** The longest a `Secrets` or `TokenStore` name may be. */
77
+ export declare const maxSecretNameLength = 128;
78
+ /**
79
+ * Whether a name follows the name rule of the `Secrets` port: a letter,
80
+ * then letters, digits, `-` or `_`, at most 128 characters. Workspace checks
81
+ * use it to report a bad name in a file before anything asks a store for it.
82
+ *
83
+ * @example
84
+ * isSecretName("openai-key"); // true
85
+ * isSecretName("openai key"); // false
86
+ */
87
+ export declare function isSecretName(name: string): boolean;
88
+ /**
89
+ * The form two names are compared in: upper case, with `-` as `_`. Names
90
+ * with the same key are the same secret on every adapter, as the
91
+ * `Secrets` port requires. An adapter may store a different case of
92
+ * it, but must match by it.
93
+ *
94
+ * @throws RangeError when the name breaks the rule; the message repeats the
95
+ * name only when {@link describeSecretName} allows it
96
+ *
97
+ * @example
98
+ * secretKey("serve-password"); // "SERVE_PASSWORD"
99
+ */
100
+ export declare function secretKey(name: string): string;
101
+ /**
102
+ * Whether a message may repeat a secret name: only when it is at most 128
103
+ * printable ASCII characters. Anything else is more likely a value passed as
104
+ * a name by mistake, so it must never reach a log or an error report.
105
+ *
106
+ * @example
107
+ * isQuotableSecretName("openai key"); // true
108
+ * isQuotableSecretName("x".repeat(300)); // false
109
+ */
110
+ export declare function isQuotableSecretName(name: string): boolean;
111
+ /**
112
+ * How a message may refer to a secret name: quoted when
113
+ * {@link isQuotableSecretName} allows it, otherwise by its length only.
114
+ *
115
+ * @example
116
+ * describeSecretName("openai key"); // 'Secret name "openai key"'
117
+ * describeSecretName("x".repeat(300)); // "A secret name of 300 characters"
118
+ */
119
+ export declare function describeSecretName(name: string): string;
120
+ /**
121
+ * Halonic's own secrets: the key of the encrypted token store and the hash of
122
+ * the sign-in password. Only Halonic reads them; no workspace may pick them.
123
+ */
124
+ export declare const halonicSecretNames: readonly string[];
125
+ /**
126
+ * The prefix of a token's name in a store that also holds secrets, such as
127
+ * the desktop keychain. A secret name with this prefix is a token, so no
128
+ * workspace may pick it.
129
+ */
130
+ export declare const tokenNamePrefix = "halonic_token_";
131
+ /**
132
+ * Whether a secret name belongs to Halonic: one of {@link halonicSecretNames}
133
+ * or a token name under {@link tokenNamePrefix}. Names are compared in their
134
+ * `secretKey` form, so `Token_Key` is `token-key`.
135
+ *
136
+ * @throws RangeError when the name breaks the rule of the `Secrets` port
137
+ *
138
+ * @example
139
+ * isHalonicSecretName("Serve_Password"); // true
140
+ * isHalonicSecretName("openai-key"); // false
141
+ */
142
+ export declare function isHalonicSecretName(name: string): boolean;
143
+ /**
144
+ * The prefix of every secret a plugin declares: the app keeps a plugin's
145
+ * secret under `plugin__<id>__<secret>`. A secret name with this prefix
146
+ * belongs to a plugin, so no workspace may pick it.
147
+ */
148
+ export declare const pluginSecretNamePrefix = "plugin__";
149
+ /**
150
+ * Comes between the plugin's id and the secret's name in a plugin's secret
151
+ * name, and ends {@link pluginSecretNamePrefix}'s share of it. `Secrets`
152
+ * takes `-` and `_` as the same character, so a single one can't tell
153
+ * `a-b` + `c` from `a` + `b-c`. Ids and secret names never hold two `-` in a
154
+ * row, so a doubled `_` can't come from either of them.
155
+ */
156
+ export declare const pluginSecretSeparator = "__";
157
+ /**
158
+ * Whether a secret name belongs to a plugin: it starts with
159
+ * {@link pluginSecretNamePrefix}. Names are compared in their `secretKey`
160
+ * form, so `Plugin-_weather` counts too.
161
+ *
162
+ * @throws RangeError when the name breaks the rule of the `Secrets` port
163
+ *
164
+ * @example
165
+ * isPluginSecretName("plugin__weather__acme-key"); // true
166
+ * isPluginSecretName("plugin-key"); // false
167
+ */
168
+ export declare function isPluginSecretName(name: string): boolean;
169
+ /**
170
+ * The secrets as a workspace may read them: by any name it picks, except the
171
+ * ones that belong to Halonic ({@link isHalonicSecretName}) or to a plugin
172
+ * ({@link isPluginSecretName}). Pass this, never the raw store, wherever a
173
+ * workspace's choice of name reaches `Secrets`.
174
+ *
175
+ * @throws RangeError from `get`, for a name of Halonic's own or a plugin's;
176
+ * the message never repeats the name
177
+ *
178
+ * @example
179
+ * const picks = workspaceSecrets(secrets);
180
+ * await picks.get("openai-key"); // the configured key, or null
181
+ * await picks.get("token-key"); // throws a RangeError
182
+ * await picks.get("plugin__weather__acme-key"); // throws a RangeError
183
+ */
184
+ export declare function workspaceSecrets(secrets: Secrets): Secrets;
185
+ /**
186
+ * The secrets as one plugin's backend may read them: only the names stored
187
+ * for that plugin, `plugin__<id>__<secret>` in `secretKey` form, and nothing
188
+ * else, so a plugin can't read a workspace's secret, Halonic's own or
189
+ * another plugin's. The app picks each name from the plugin's own manifest;
190
+ * this is the second check, at the place that reads.
191
+ *
192
+ * @throws RangeError from `get`, for a name that isn't one of the plugin's;
193
+ * the message never repeats the name
194
+ *
195
+ * @example
196
+ * const own = pluginSecrets(secrets, "weather");
197
+ * await own.get("plugin__weather__acme-key"); // the stored key, or null
198
+ * await own.get("openai-key"); // throws a RangeError
199
+ * await own.get("plugin__rain__acme-key"); // throws a RangeError
200
+ */
201
+ export declare function pluginSecrets(secrets: Secrets, pluginId: string): Secrets;
@@ -0,0 +1,200 @@
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 value a {@link SecretStore} saves, in UTF-16 code units. Bounds what one secret may cost a store. */
4
+ export const maxSecretValueLength = 64 * 1024;
5
+ /**
6
+ * Checks a value before a {@link SecretStore} saves it, so every store refuses
7
+ * the same ones: an empty value (`EnvSecrets` treats it as unset, so it would
8
+ * look like no secret) and one over {@link maxSecretValueLength}.
9
+ *
10
+ * @throws RangeError; the message never repeats the value, only its length
11
+ *
12
+ * @example
13
+ * checkSecretValue("sk-live-1234"); // fine
14
+ * checkSecretValue(""); // throws a RangeError
15
+ */
16
+ export function checkSecretValue(value) {
17
+ if (value === "") {
18
+ throw new RangeError("A secret's value can't be empty. Remove the secret instead.");
19
+ }
20
+ if (value.length > maxSecretValueLength) {
21
+ throw new RangeError(`A secret's value can be at most ${maxSecretValueLength} characters; this one has ${value.length}.`);
22
+ }
23
+ }
24
+ /** The longest a `Secrets` or `TokenStore` name may be. */
25
+ export const maxSecretNameLength = 128;
26
+ const secretNamePattern = /^[A-Za-z][A-Za-z0-9_-]*$/;
27
+ const printableAscii = /^[\x20-\x7E]*$/;
28
+ /**
29
+ * Whether a name follows the name rule of the `Secrets` port: a letter,
30
+ * then letters, digits, `-` or `_`, at most 128 characters. Workspace checks
31
+ * use it to report a bad name in a file before anything asks a store for it.
32
+ *
33
+ * @example
34
+ * isSecretName("openai-key"); // true
35
+ * isSecretName("openai key"); // false
36
+ */
37
+ export function isSecretName(name) {
38
+ return name.length <= maxSecretNameLength && secretNamePattern.test(name);
39
+ }
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 function secretKey(name) {
53
+ if (!isSecretName(name)) {
54
+ throw new RangeError(`${describeSecretName(name)} must be a letter, then letters, digits, "-" or "_", at most ${maxSecretNameLength} characters.`);
55
+ }
56
+ return name.toUpperCase().replaceAll("-", "_");
57
+ }
58
+ /**
59
+ * Whether a message may repeat a secret name: only when it is at most 128
60
+ * printable ASCII characters. Anything else is more likely a value passed as
61
+ * a name by mistake, so it must never reach a log or an error report.
62
+ *
63
+ * @example
64
+ * isQuotableSecretName("openai key"); // true
65
+ * isQuotableSecretName("x".repeat(300)); // false
66
+ */
67
+ export function isQuotableSecretName(name) {
68
+ return name.length <= maxSecretNameLength && printableAscii.test(name);
69
+ }
70
+ /**
71
+ * How a message may refer to a secret name: quoted when
72
+ * {@link isQuotableSecretName} allows it, otherwise by its length only.
73
+ *
74
+ * @example
75
+ * describeSecretName("openai key"); // 'Secret name "openai key"'
76
+ * describeSecretName("x".repeat(300)); // "A secret name of 300 characters"
77
+ */
78
+ export function describeSecretName(name) {
79
+ if (isQuotableSecretName(name)) {
80
+ return `Secret name ${JSON.stringify(name)}`;
81
+ }
82
+ return `A secret name of ${name.length} characters`;
83
+ }
84
+ // A workspace names the secrets its providers and models use. Those names
85
+ // share one namespace with Halonic's own secrets, and on desktop with the
86
+ // tokens too (one keychain backs both stores). So every name a workspace
87
+ // picks goes through `workspaceSecrets`, which refuses the ones that belong
88
+ // to Halonic or to a plugin, whatever their case or `-`/`_` spelling.
89
+ /**
90
+ * Halonic's own secrets: the key of the encrypted token store and the hash of
91
+ * the sign-in password. Only Halonic reads them; no workspace may pick them.
92
+ */
93
+ export const halonicSecretNames = ["token-key", "serve-password"];
94
+ /**
95
+ * The prefix of a token's name in a store that also holds secrets, such as
96
+ * the desktop keychain. A secret name with this prefix is a token, so no
97
+ * workspace may pick it.
98
+ */
99
+ export const tokenNamePrefix = "halonic_token_";
100
+ const halonicSecretKeys = new Set(halonicSecretNames.map(secretKey));
101
+ const tokenKeyPrefix = secretKey(tokenNamePrefix);
102
+ /**
103
+ * Whether a secret name belongs to Halonic: one of {@link halonicSecretNames}
104
+ * or a token name under {@link tokenNamePrefix}. Names are compared in their
105
+ * `secretKey` form, so `Token_Key` is `token-key`.
106
+ *
107
+ * @throws RangeError when the name breaks the rule of the `Secrets` port
108
+ *
109
+ * @example
110
+ * isHalonicSecretName("Serve_Password"); // true
111
+ * isHalonicSecretName("openai-key"); // false
112
+ */
113
+ export function isHalonicSecretName(name) {
114
+ const key = secretKey(name);
115
+ return halonicSecretKeys.has(key) || key.startsWith(tokenKeyPrefix);
116
+ }
117
+ /**
118
+ * The prefix of every secret a plugin declares: the app keeps a plugin's
119
+ * secret under `plugin__<id>__<secret>`. A secret name with this prefix
120
+ * belongs to a plugin, so no workspace may pick it.
121
+ */
122
+ export const pluginSecretNamePrefix = "plugin__";
123
+ /**
124
+ * Comes between the plugin's id and the secret's name in a plugin's secret
125
+ * name, and ends {@link pluginSecretNamePrefix}'s share of it. `Secrets`
126
+ * takes `-` and `_` as the same character, so a single one can't tell
127
+ * `a-b` + `c` from `a` + `b-c`. Ids and secret names never hold two `-` in a
128
+ * row, so a doubled `_` can't come from either of them.
129
+ */
130
+ export const pluginSecretSeparator = "__";
131
+ const pluginKeyPrefix = secretKey(pluginSecretNamePrefix);
132
+ /**
133
+ * Whether a secret name belongs to a plugin: it starts with
134
+ * {@link pluginSecretNamePrefix}. Names are compared in their `secretKey`
135
+ * form, so `Plugin-_weather` counts too.
136
+ *
137
+ * @throws RangeError when the name breaks the rule of the `Secrets` port
138
+ *
139
+ * @example
140
+ * isPluginSecretName("plugin__weather__acme-key"); // true
141
+ * isPluginSecretName("plugin-key"); // false
142
+ */
143
+ export function isPluginSecretName(name) {
144
+ return secretKey(name).startsWith(pluginKeyPrefix);
145
+ }
146
+ /**
147
+ * The secrets as a workspace may read them: by any name it picks, except the
148
+ * ones that belong to Halonic ({@link isHalonicSecretName}) or to a plugin
149
+ * ({@link isPluginSecretName}). Pass this, never the raw store, wherever a
150
+ * workspace's choice of name reaches `Secrets`.
151
+ *
152
+ * @throws RangeError from `get`, for a name of Halonic's own or a plugin's;
153
+ * the message never repeats the name
154
+ *
155
+ * @example
156
+ * const picks = workspaceSecrets(secrets);
157
+ * await picks.get("openai-key"); // the configured key, or null
158
+ * await picks.get("token-key"); // throws a RangeError
159
+ * await picks.get("plugin__weather__acme-key"); // throws a RangeError
160
+ */
161
+ export function workspaceSecrets(secrets) {
162
+ return {
163
+ get: async (name) => {
164
+ if (isHalonicSecretName(name)) {
165
+ throw new RangeError("A workspace can't pick a secret that belongs to Halonic.");
166
+ }
167
+ if (isPluginSecretName(name)) {
168
+ throw new RangeError("A workspace can't pick a secret that belongs to a plugin.");
169
+ }
170
+ return await secrets.get(name);
171
+ },
172
+ };
173
+ }
174
+ /**
175
+ * The secrets as one plugin's backend may read them: only the names stored
176
+ * for that plugin, `plugin__<id>__<secret>` in `secretKey` form, and nothing
177
+ * else, so a plugin can't read a workspace's secret, Halonic's own or
178
+ * another plugin's. The app picks each name from the plugin's own manifest;
179
+ * this is the second check, at the place that reads.
180
+ *
181
+ * @throws RangeError from `get`, for a name that isn't one of the plugin's;
182
+ * the message never repeats the name
183
+ *
184
+ * @example
185
+ * const own = pluginSecrets(secrets, "weather");
186
+ * await own.get("plugin__weather__acme-key"); // the stored key, or null
187
+ * await own.get("openai-key"); // throws a RangeError
188
+ * await own.get("plugin__rain__acme-key"); // throws a RangeError
189
+ */
190
+ export function pluginSecrets(secrets, pluginId) {
191
+ const own = secretKey(`${pluginSecretNamePrefix}${pluginId}${pluginSecretSeparator}`);
192
+ return {
193
+ get: async (name) => {
194
+ if (!secretKey(name).startsWith(own)) {
195
+ throw new RangeError("A plugin can read only the secrets stored for it.");
196
+ }
197
+ return await secrets.get(name);
198
+ },
199
+ };
200
+ }
@@ -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;