@halonicjs/testing 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (384) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +1 -0
  3. package/README.md +40 -2
  4. package/dist/adapters/http-kit/src/address-class.d.ts +34 -0
  5. package/dist/adapters/http-kit/src/address-class.js +109 -0
  6. package/dist/adapters/http-kit/src/index.d.ts +2 -0
  7. package/dist/adapters/http-kit/src/index.js +2 -0
  8. package/dist/adapters/http-kit/src/ip-address.d.ts +23 -0
  9. package/dist/adapters/http-kit/src/ip-address.js +89 -0
  10. package/dist/adapters/integration-kit/src/declaration.d.ts +14 -0
  11. package/dist/adapters/integration-kit/src/declaration.js +77 -0
  12. package/dist/adapters/integration-kit/src/host.d.ts +28 -0
  13. package/dist/adapters/integration-kit/src/host.js +30 -0
  14. package/dist/adapters/integration-kit/src/index.d.ts +14 -0
  15. package/dist/adapters/integration-kit/src/index.js +21 -0
  16. package/dist/adapters/integration-kit/src/leak-attempt.d.ts +14 -0
  17. package/dist/adapters/integration-kit/src/leak-attempt.js +16 -0
  18. package/dist/adapters/integration-kit/src/limited-http.d.ts +49 -0
  19. package/dist/adapters/integration-kit/src/limited-http.js +182 -0
  20. package/dist/adapters/integration-kit/src/load-problem.d.ts +20 -0
  21. package/dist/adapters/integration-kit/src/load-problem.js +1 -0
  22. package/dist/adapters/integration-kit/src/loader.d.ts +104 -0
  23. package/dist/adapters/integration-kit/src/loader.js +219 -0
  24. package/dist/adapters/integration-kit/src/local-address.d.ts +15 -0
  25. package/dist/adapters/integration-kit/src/local-address.js +25 -0
  26. package/dist/adapters/integration-kit/src/own-request.d.ts +33 -0
  27. package/dist/adapters/integration-kit/src/own-request.js +36 -0
  28. package/dist/adapters/integration-kit/src/plugin-load.d.ts +14 -0
  29. package/dist/adapters/integration-kit/src/plugin-load.js +58 -0
  30. package/dist/adapters/integration-kit/src/policy.d.ts +55 -0
  31. package/dist/adapters/integration-kit/src/policy.js +37 -0
  32. package/dist/adapters/integration-kit/src/request-body.d.ts +38 -0
  33. package/dist/adapters/integration-kit/src/request-body.js +68 -0
  34. package/dist/adapters/integration-kit/src/request-log.d.ts +25 -0
  35. package/dist/adapters/integration-kit/src/request-log.js +17 -0
  36. package/dist/adapters/integration-kit/src/response-body.d.ts +23 -0
  37. package/dist/adapters/integration-kit/src/response-body.js +117 -0
  38. package/dist/adapters/integration-kit/src/scoped-tokens.d.ts +14 -0
  39. package/dist/adapters/integration-kit/src/scoped-tokens.js +27 -0
  40. package/dist/adapters/integration-kit/src/secret-filter.d.ts +84 -0
  41. package/dist/adapters/integration-kit/src/secret-filter.js +205 -0
  42. package/dist/adapters/integration-kit/src/secret-in-request.d.ts +59 -0
  43. package/dist/adapters/integration-kit/src/secret-in-request.js +133 -0
  44. package/dist/adapters/integration-kit/src/secret-placement.d.ts +36 -0
  45. package/dist/adapters/integration-kit/src/secret-placement.js +190 -0
  46. package/dist/adapters/integration-kit/src/wait.d.ts +16 -0
  47. package/dist/adapters/integration-kit/src/wait.js +35 -0
  48. package/dist/core/events/src/add-usage.d.ts +10 -0
  49. package/dist/core/events/src/add-usage.js +27 -0
  50. package/dist/core/events/src/agent-resume.d.ts +24 -0
  51. package/dist/core/events/src/agent-resume.js +1 -0
  52. package/dist/core/events/src/home-path.d.ts +13 -0
  53. package/dist/core/events/src/home-path.js +26 -0
  54. package/dist/core/events/src/index.d.ts +13 -0
  55. package/dist/core/events/src/index.js +7 -0
  56. package/dist/core/events/src/run-basics.d.ts +205 -0
  57. package/dist/core/events/src/run-basics.js +1 -0
  58. package/dist/core/events/src/run-event.d.ts +434 -0
  59. package/dist/core/events/src/run-event.js +1 -0
  60. package/dist/core/events/src/run-summary.d.ts +108 -0
  61. package/dist/core/events/src/run-summary.js +1 -0
  62. package/dist/core/events/src/sandbox-blocked.d.ts +42 -0
  63. package/dist/core/events/src/sandbox-blocked.js +26 -0
  64. package/dist/core/events/src/sandbox-opened-read.d.ts +17 -0
  65. package/dist/core/events/src/sandbox-opened-read.js +63 -0
  66. package/dist/core/events/src/sandbox-opened.d.ts +94 -0
  67. package/dist/core/events/src/sandbox-opened.js +52 -0
  68. package/dist/core/events/src/summarize.d.ts +14 -0
  69. package/dist/core/events/src/summarize.js +188 -0
  70. package/dist/core/events/src/timeline-entry.d.ts +21 -0
  71. package/dist/core/events/src/timeline-entry.js +105 -0
  72. package/dist/core/events/src/upgrade.d.ts +23 -0
  73. package/dist/core/events/src/upgrade.js +49 -0
  74. package/dist/core/format/src/compact.d.ts +30 -0
  75. package/dist/core/format/src/compact.js +72 -0
  76. package/dist/core/format/src/index.d.ts +37 -0
  77. package/dist/core/format/src/index.js +23 -0
  78. package/dist/core/format/src/integration/index.d.ts +6 -0
  79. package/dist/core/format/src/integration/index.js +9 -0
  80. package/dist/core/format/src/json-schema.d.ts +26 -0
  81. package/dist/core/format/src/json-schema.js +48 -0
  82. package/dist/core/format/src/kind.d.ts +65 -0
  83. package/dist/core/format/src/kind.js +1 -0
  84. package/dist/core/format/src/kinds/agent/kind.d.ts +4 -0
  85. package/dist/core/format/src/kinds/agent/kind.js +10 -0
  86. package/dist/core/format/src/kinds/agent/sandbox-fields.d.ts +89 -0
  87. package/dist/core/format/src/kinds/agent/sandbox-fields.js +197 -0
  88. package/dist/core/format/src/kinds/agent/schema.d.ts +147 -0
  89. package/dist/core/format/src/kinds/agent/schema.js +107 -0
  90. package/dist/core/format/src/kinds/agent/working-folder-start.d.ts +74 -0
  91. package/dist/core/format/src/kinds/agent/working-folder-start.js +312 -0
  92. package/dist/core/format/src/kinds/collection/kind.d.ts +8 -0
  93. package/dist/core/format/src/kinds/collection/kind.js +14 -0
  94. package/dist/core/format/src/kinds/collection/schema.d.ts +89 -0
  95. package/dist/core/format/src/kinds/collection/schema.js +90 -0
  96. package/dist/core/format/src/kinds/connector/is-local.d.ts +10 -0
  97. package/dist/core/format/src/kinds/connector/is-local.js +43 -0
  98. package/dist/core/format/src/kinds/connector/kind.d.ts +4 -0
  99. package/dist/core/format/src/kinds/connector/kind.js +119 -0
  100. package/dist/core/format/src/kinds/connector/schema.d.ts +50 -0
  101. package/dist/core/format/src/kinds/connector/schema.js +92 -0
  102. package/dist/core/format/src/kinds/deployments/kind.d.ts +4 -0
  103. package/dist/core/format/src/kinds/deployments/kind.js +25 -0
  104. package/dist/core/format/src/kinds/deployments/schema.d.ts +37 -0
  105. package/dist/core/format/src/kinds/deployments/schema.js +42 -0
  106. package/dist/core/format/src/kinds/hub/kind.d.ts +4 -0
  107. package/dist/core/format/src/kinds/hub/kind.js +10 -0
  108. package/dist/core/format/src/kinds/hub/schema.d.ts +54 -0
  109. package/dist/core/format/src/kinds/hub/schema.js +34 -0
  110. package/dist/core/format/src/kinds/integration/kind.d.ts +16 -0
  111. package/dist/core/format/src/kinds/integration/kind.js +138 -0
  112. package/dist/core/format/src/kinds/integration/parse-sheet.d.ts +19 -0
  113. package/dist/core/format/src/kinds/integration/parse-sheet.js +24 -0
  114. package/dist/core/format/src/kinds/integration/policy.d.ts +67 -0
  115. package/dist/core/format/src/kinds/integration/policy.js +268 -0
  116. package/dist/core/format/src/kinds/integration/schema.d.ts +233 -0
  117. package/dist/core/format/src/kinds/integration/schema.js +233 -0
  118. package/dist/core/format/src/kinds/knowledge/kind.d.ts +4 -0
  119. package/dist/core/format/src/kinds/knowledge/kind.js +13 -0
  120. package/dist/core/format/src/kinds/knowledge/schema.d.ts +18 -0
  121. package/dist/core/format/src/kinds/knowledge/schema.js +25 -0
  122. package/dist/core/format/src/kinds/models/kind.d.ts +4 -0
  123. package/dist/core/format/src/kinds/models/kind.js +10 -0
  124. package/dist/core/format/src/kinds/models/schema.d.ts +92 -0
  125. package/dist/core/format/src/kinds/models/schema.js +38 -0
  126. package/dist/core/format/src/kinds/plugin/backend.d.ts +22 -0
  127. package/dist/core/format/src/kinds/plugin/backend.js +31 -0
  128. package/dist/core/format/src/kinds/plugin/checks.d.ts +13 -0
  129. package/dist/core/format/src/kinds/plugin/checks.js +131 -0
  130. package/dist/core/format/src/kinds/plugin/kind.d.ts +8 -0
  131. package/dist/core/format/src/kinds/plugin/kind.js +16 -0
  132. package/dist/core/format/src/kinds/plugin/problems.d.ts +24 -0
  133. package/dist/core/format/src/kinds/plugin/problems.js +65 -0
  134. package/dist/core/format/src/kinds/plugin/schema.d.ts +542 -0
  135. package/dist/core/format/src/kinds/plugin/schema.js +261 -0
  136. package/dist/core/format/src/kinds/plugin/setting-values.d.ts +17 -0
  137. package/dist/core/format/src/kinds/plugin/setting-values.js +38 -0
  138. package/dist/core/format/src/kinds/plugin/ui-checks.d.ts +8 -0
  139. package/dist/core/format/src/kinds/plugin/ui-checks.js +94 -0
  140. package/dist/core/format/src/kinds/provider/kind.d.ts +4 -0
  141. package/dist/core/format/src/kinds/provider/kind.js +24 -0
  142. package/dist/core/format/src/kinds/provider/schema.d.ts +17 -0
  143. package/dist/core/format/src/kinds/provider/schema.js +22 -0
  144. package/dist/core/format/src/kinds/routine/kind.d.ts +8 -0
  145. package/dist/core/format/src/kinds/routine/kind.js +25 -0
  146. package/dist/core/format/src/kinds/routine/schema.d.ts +84 -0
  147. package/dist/core/format/src/kinds/routine/schema.js +93 -0
  148. package/dist/core/format/src/kinds/runtime/kind.d.ts +4 -0
  149. package/dist/core/format/src/kinds/runtime/kind.js +13 -0
  150. package/dist/core/format/src/kinds/runtime/schema.d.ts +10 -0
  151. package/dist/core/format/src/kinds/runtime/schema.js +12 -0
  152. package/dist/core/format/src/kinds/skill/kind.d.ts +4 -0
  153. package/dist/core/format/src/kinds/skill/kind.js +10 -0
  154. package/dist/core/format/src/kinds/skill/schema.d.ts +17 -0
  155. package/dist/core/format/src/kinds/skill/schema.js +17 -0
  156. package/dist/core/format/src/kinds/skill/scripts-folder.d.ts +27 -0
  157. package/dist/core/format/src/kinds/skill/scripts-folder.js +37 -0
  158. package/dist/core/format/src/kinds/workflow/kind.d.ts +8 -0
  159. package/dist/core/format/src/kinds/workflow/kind.js +14 -0
  160. package/dist/core/format/src/kinds/workflow/schema.d.ts +162 -0
  161. package/dist/core/format/src/kinds/workflow/schema.js +106 -0
  162. package/dist/core/format/src/kinds/workflow-test/kind.d.ts +4 -0
  163. package/dist/core/format/src/kinds/workflow-test/kind.js +14 -0
  164. package/dist/core/format/src/kinds/workflow-test/schema.d.ts +67 -0
  165. package/dist/core/format/src/kinds/workflow-test/schema.js +59 -0
  166. package/dist/core/format/src/kinds/workspace/kind.d.ts +4 -0
  167. package/dist/core/format/src/kinds/workspace/kind.js +10 -0
  168. package/dist/core/format/src/kinds/workspace/schema.d.ts +72 -0
  169. package/dist/core/format/src/kinds/workspace/schema.js +66 -0
  170. package/dist/core/format/src/parse-file.d.ts +69 -0
  171. package/dist/core/format/src/parse-file.js +105 -0
  172. package/dist/core/format/src/recording/format.d.ts +81 -0
  173. package/dist/core/format/src/recording/format.js +102 -0
  174. package/dist/core/format/src/recording/index.d.ts +1 -0
  175. package/dist/core/format/src/recording/index.js +3 -0
  176. package/dist/core/format/src/registry.d.ts +64 -0
  177. package/dist/core/format/src/registry.js +61 -0
  178. package/dist/core/format/src/reserved.d.ts +20 -0
  179. package/dist/core/format/src/reserved.js +30 -0
  180. package/dist/core/format/src/shared/fields.d.ts +37 -0
  181. package/dist/core/format/src/shared/fields.js +54 -0
  182. package/dist/core/format/src/shared/guard.d.ts +32 -0
  183. package/dist/core/format/src/shared/guard.js +16 -0
  184. package/dist/core/format/src/shared/key-in-value.d.ts +28 -0
  185. package/dist/core/format/src/shared/key-in-value.js +82 -0
  186. package/dist/core/format/src/shared/legacy-keys.d.ts +8 -0
  187. package/dist/core/format/src/shared/legacy-keys.js +17 -0
  188. package/dist/core/format/src/shared/program-start.d.ts +60 -0
  189. package/dist/core/format/src/shared/program-start.js +99 -0
  190. package/dist/core/format/src/shared/relative-path.d.ts +29 -0
  191. package/dist/core/format/src/shared/relative-path.js +50 -0
  192. package/dist/core/format/src/shared/secret-name.d.ts +24 -0
  193. package/dist/core/format/src/shared/secret-name.js +107 -0
  194. package/dist/core/format/src/source.d.ts +16 -0
  195. package/dist/core/format/src/source.js +73 -0
  196. package/dist/core/ports/src/agent-placement-store.d.ts +74 -0
  197. package/dist/core/ports/src/agent-placement-store.js +27 -0
  198. package/dist/core/ports/src/blob-store.d.ts +33 -0
  199. package/dist/core/ports/src/blob-store.js +2 -0
  200. package/dist/core/ports/src/cant-try-error.d.ts +35 -0
  201. package/dist/core/ports/src/cant-try-error.js +44 -0
  202. package/dist/core/ports/src/chat.d.ts +127 -0
  203. package/dist/core/ports/src/chat.js +1 -0
  204. package/dist/core/ports/src/clock.d.ts +7 -0
  205. package/dist/core/ports/src/clock.js +2 -0
  206. package/dist/core/ports/src/connection-settings-store.d.ts +57 -0
  207. package/dist/core/ports/src/connection-settings-store.js +2 -0
  208. package/dist/core/ports/src/connector-client.d.ts +259 -0
  209. package/dist/core/ports/src/connector-client.js +2 -0
  210. package/dist/core/ports/src/coordination.d.ts +84 -0
  211. package/dist/core/ports/src/coordination.js +2 -0
  212. package/dist/core/ports/src/definition-store.d.ts +208 -0
  213. package/dist/core/ports/src/definition-store.js +122 -0
  214. package/dist/core/ports/src/digest.d.ts +14 -0
  215. package/dist/core/ports/src/digest.js +2 -0
  216. package/dist/core/ports/src/folder-reader.d.ts +89 -0
  217. package/dist/core/ports/src/folder-reader.js +2 -0
  218. package/dist/core/ports/src/harness-bridge-server.d.ts +189 -0
  219. package/dist/core/ports/src/harness-bridge-server.js +37 -0
  220. package/dist/core/ports/src/harness.d.ts +250 -0
  221. package/dist/core/ports/src/harness.js +45 -0
  222. package/dist/core/ports/src/http-client.d.ts +27 -0
  223. package/dist/core/ports/src/http-client.js +2 -0
  224. package/dist/core/ports/src/id-generator.d.ts +14 -0
  225. package/dist/core/ports/src/id-generator.js +2 -0
  226. package/dist/core/ports/src/index.d.ts +37 -0
  227. package/dist/core/ports/src/index.js +36 -0
  228. package/dist/core/ports/src/integration.d.ts +178 -0
  229. package/dist/core/ports/src/integration.js +13 -0
  230. package/dist/core/ports/src/knowledge-provider.d.ts +65 -0
  231. package/dist/core/ports/src/knowledge-provider.js +2 -0
  232. package/dist/core/ports/src/llm-cache.d.ts +13 -0
  233. package/dist/core/ports/src/llm-cache.js +2 -0
  234. package/dist/core/ports/src/llm-provider.d.ts +184 -0
  235. package/dist/core/ports/src/llm-provider.js +136 -0
  236. package/dist/core/ports/src/model-price.d.ts +34 -0
  237. package/dist/core/ports/src/model-price.js +25 -0
  238. package/dist/core/ports/src/password-hasher.d.ts +47 -0
  239. package/dist/core/ports/src/password-hasher.js +2 -0
  240. package/dist/core/ports/src/plugin-folder-writer.d.ts +104 -0
  241. package/dist/core/ports/src/plugin-folder-writer.js +95 -0
  242. package/dist/core/ports/src/port-versions.d.ts +44 -0
  243. package/dist/core/ports/src/port-versions.js +74 -0
  244. package/dist/core/ports/src/program-probe.d.ts +46 -0
  245. package/dist/core/ports/src/program-probe.js +2 -0
  246. package/dist/core/ports/src/record-store.d.ts +62 -0
  247. package/dist/core/ports/src/record-store.js +38 -0
  248. package/dist/core/ports/src/resource-probe.d.ts +59 -0
  249. package/dist/core/ports/src/resource-probe.js +2 -0
  250. package/dist/core/ports/src/run-executor.d.ts +302 -0
  251. package/dist/core/ports/src/run-executor.js +2 -0
  252. package/dist/core/ports/src/run-failure-error.d.ts +49 -0
  253. package/dist/core/ports/src/run-failure-error.js +47 -0
  254. package/dist/core/ports/src/run-store.d.ts +194 -0
  255. package/dist/core/ports/src/run-store.js +131 -0
  256. package/dist/core/ports/src/sandbox.d.ts +247 -0
  257. package/dist/core/ports/src/sandbox.js +34 -0
  258. package/dist/core/ports/src/scheduler.d.ts +85 -0
  259. package/dist/core/ports/src/scheduler.js +2 -0
  260. package/dist/core/ports/src/secrets.d.ts +128 -0
  261. package/dist/core/ports/src/secrets.js +144 -0
  262. package/dist/core/ports/src/token-store.d.ts +19 -0
  263. package/dist/core/ports/src/token-store.js +2 -0
  264. package/dist/core/ports/src/tool-approval-store.d.ts +211 -0
  265. package/dist/core/ports/src/tool-approval-store.js +57 -0
  266. package/dist/core/ports/src/trust-store.d.ts +72 -0
  267. package/dist/core/ports/src/trust-store.js +2 -0
  268. package/dist/core/ports/src/unfenced-run-consent-store.d.ts +43 -0
  269. package/dist/core/ports/src/unfenced-run-consent-store.js +2 -0
  270. package/dist/core/ports/src/vcs.d.ts +394 -0
  271. package/dist/core/ports/src/vcs.js +48 -0
  272. package/dist/core/schema-kit/src/builders.d.ts +50 -0
  273. package/dist/core/schema-kit/src/builders.js +72 -0
  274. package/dist/core/schema-kit/src/depth.d.ts +15 -0
  275. package/dist/core/schema-kit/src/depth.js +37 -0
  276. package/dist/core/schema-kit/src/index.d.ts +6 -0
  277. package/dist/core/schema-kit/src/index.js +6 -0
  278. package/dist/core/schema-kit/src/issue.d.ts +22 -0
  279. package/dist/core/schema-kit/src/issue.js +23 -0
  280. package/dist/core/schema-kit/src/json-schema.d.ts +23 -0
  281. package/dist/core/schema-kit/src/json-schema.js +22 -0
  282. package/dist/core/schema-kit/src/parse.d.ts +17 -0
  283. package/dist/core/schema-kit/src/parse.js +25 -0
  284. package/dist/core/schema-kit/src/schema.d.ts +12 -0
  285. package/dist/core/schema-kit/src/schema.js +1 -0
  286. package/dist/core/std/src/ascii-host.d.ts +18 -0
  287. package/dist/core/std/src/ascii-host.js +110 -0
  288. package/dist/core/std/src/assert.d.ts +39 -0
  289. package/dist/core/std/src/assert.js +59 -0
  290. package/dist/core/std/src/base64url.d.ts +23 -0
  291. package/dist/core/std/src/base64url.js +65 -0
  292. package/dist/core/std/src/canonical-json.d.ts +18 -0
  293. package/dist/core/std/src/canonical-json.js +56 -0
  294. package/dist/core/std/src/clock.d.ts +27 -0
  295. package/dist/core/std/src/clock.js +33 -0
  296. package/dist/core/std/src/constant-time.d.ts +16 -0
  297. package/dist/core/std/src/constant-time.js +26 -0
  298. package/dist/core/std/src/content-digest.d.ts +24 -0
  299. package/dist/core/std/src/content-digest.js +28 -0
  300. package/dist/core/std/src/deep-clone.d.ts +15 -0
  301. package/dist/core/std/src/deep-clone.js +59 -0
  302. package/dist/core/std/src/deep-equal.d.ts +23 -0
  303. package/dist/core/std/src/deep-equal.js +64 -0
  304. package/dist/core/std/src/emitter.d.ts +42 -0
  305. package/dist/core/std/src/emitter.js +74 -0
  306. package/dist/core/std/src/error-kind.d.ts +88 -0
  307. package/dist/core/std/src/error-kind.js +98 -0
  308. package/dist/core/std/src/hex.d.ts +10 -0
  309. package/dist/core/std/src/hex.js +16 -0
  310. package/dist/core/std/src/ids.d.ts +45 -0
  311. package/dist/core/std/src/ids.js +49 -0
  312. package/dist/core/std/src/index.d.ts +25 -0
  313. package/dist/core/std/src/index.js +26 -0
  314. package/dist/core/std/src/keyed-queue.d.ts +18 -0
  315. package/dist/core/std/src/keyed-queue.js +32 -0
  316. package/dist/core/std/src/line-diff.d.ts +83 -0
  317. package/dist/core/std/src/line-diff.js +179 -0
  318. package/dist/core/std/src/line-merge.d.ts +63 -0
  319. package/dist/core/std/src/line-merge.js +138 -0
  320. package/dist/core/std/src/plain-data.d.ts +32 -0
  321. package/dist/core/std/src/plain-data.js +57 -0
  322. package/dist/core/std/src/posix-path.d.ts +61 -0
  323. package/dist/core/std/src/posix-path.js +121 -0
  324. package/dist/core/std/src/result.d.ts +55 -0
  325. package/dist/core/std/src/result.js +52 -0
  326. package/dist/core/std/src/secret-scrubber.d.ts +54 -0
  327. package/dist/core/std/src/secret-scrubber.js +124 -0
  328. package/dist/core/std/src/secret-shape.d.ts +20 -0
  329. package/dist/core/std/src/secret-shape.js +53 -0
  330. package/dist/core/std/src/stop-signal.d.ts +44 -0
  331. package/dist/core/std/src/stop-signal.js +77 -0
  332. package/dist/core/std/src/text.d.ts +28 -0
  333. package/dist/core/std/src/text.js +54 -0
  334. package/dist/core/std/src/utf8.d.ts +23 -0
  335. package/dist/core/std/src/utf8.js +110 -0
  336. package/dist/core/std/src/version.d.ts +48 -0
  337. package/dist/core/std/src/version.js +103 -0
  338. package/dist/core/yaml/src/depth.d.ts +14 -0
  339. package/dist/core/yaml/src/depth.js +140 -0
  340. package/dist/core/yaml/src/edit-data.d.ts +47 -0
  341. package/dist/core/yaml/src/edit-data.js +286 -0
  342. package/dist/core/yaml/src/edit-text.d.ts +92 -0
  343. package/dist/core/yaml/src/edit-text.js +267 -0
  344. package/dist/core/yaml/src/edit.d.ts +47 -0
  345. package/dist/core/yaml/src/edit.js +198 -0
  346. package/dist/core/yaml/src/index.d.ts +5 -0
  347. package/dist/core/yaml/src/index.js +4 -0
  348. package/dist/core/yaml/src/problem.d.ts +20 -0
  349. package/dist/core/yaml/src/problem.js +1 -0
  350. package/dist/core/yaml/src/read.d.ts +47 -0
  351. package/dist/core/yaml/src/read.js +130 -0
  352. package/dist/core/yaml/src/splice-node.d.ts +47 -0
  353. package/dist/core/yaml/src/splice-node.js +333 -0
  354. package/dist/core/yaml/src/splice.d.ts +13 -0
  355. package/dist/core/yaml/src/splice.js +174 -0
  356. package/dist/core/yaml/src/unsupported.d.ts +26 -0
  357. package/dist/core/yaml/src/unsupported.js +70 -0
  358. package/dist/core/yaml/src/write.d.ts +35 -0
  359. package/dist/core/yaml/src/write.js +44 -0
  360. package/dist/testing/integration/src/canaries.d.ts +14 -0
  361. package/dist/testing/integration/src/canaries.js +17 -0
  362. package/dist/testing/integration/src/checks.d.ts +37 -0
  363. package/dist/testing/integration/src/checks.js +195 -0
  364. package/dist/testing/integration/src/describe.d.ts +35 -0
  365. package/dist/testing/integration/src/describe.js +74 -0
  366. package/dist/testing/integration/src/failure.d.ts +6 -0
  367. package/dist/testing/integration/src/failure.js +8 -0
  368. package/dist/testing/integration/src/fake-wait.d.ts +18 -0
  369. package/dist/testing/integration/src/fake-wait.js +21 -0
  370. package/dist/testing/integration/src/index.d.ts +10 -0
  371. package/dist/testing/integration/src/index.js +11 -0
  372. package/dist/testing/integration/src/load.d.ts +14 -0
  373. package/dist/testing/integration/src/load.js +45 -0
  374. package/dist/testing/integration/src/plugin-folder.d.ts +23 -0
  375. package/dist/testing/integration/src/plugin-folder.js +59 -0
  376. package/dist/testing/integration/src/plugin.d.ts +32 -0
  377. package/dist/testing/integration/src/plugin.js +57 -0
  378. package/dist/testing/integration/src/recording.d.ts +84 -0
  379. package/dist/testing/integration/src/recording.js +164 -0
  380. package/dist/testing/integration/src/run.d.ts +60 -0
  381. package/dist/testing/integration/src/run.js +81 -0
  382. package/dist/testing/integration/src/source-scan.d.ts +16 -0
  383. package/dist/testing/integration/src/source-scan.js +40 -0
  384. package/package.json +35 -4
@@ -0,0 +1,138 @@
1
+ import { diffLines, sameLines, splitLines } from "./line-diff.js";
2
+ /**
3
+ * Merges two texts that each started from `base`, line by line, as git's
4
+ * merge does. A change only one side made is taken. The same change on both
5
+ * sides is taken once. Where both sides changed the same lines differently,
6
+ * or changed lines that touch (one ends where the other starts, or both add
7
+ * lines at the same place), the result has a conflict for the caller to
8
+ * settle, with `mergedText` or by asking the person.
9
+ *
10
+ * With `touchingConflicts: false`, changes that only touch are both taken,
11
+ * because there is just one way to put them together. Only changes that
12
+ * overlap, or lines both sides add at the same place (where their order is
13
+ * unclear), are a conflict. The assistant's baseline uses this, so typing on
14
+ * the line after one of the assistant's changes keeps that change to review.
15
+ *
16
+ * @param base - the text both sides started from
17
+ * @param ours - our side
18
+ * @param theirs - their side
19
+ * @param options - whether changes that touch are a conflict (`true`, as git, when left out)
20
+ * @returns the merged text as regions in order, with resolved lines next to each other joined
21
+ *
22
+ * @example
23
+ * mergeLines("a\nb\nc\n", "A\nb\nc\n", "a\nb\nC\n");
24
+ * // [{ kind: "resolved", lines: ["A\n", "b\n", "C\n"] }]
25
+ */
26
+ export function mergeLines(base, ours, theirs, options = {}) {
27
+ const baseLines = splitLines(base);
28
+ const groups = groupChanges(diffLines(base, ours), diffLines(base, theirs), options.touchingConflicts ?? true);
29
+ const regions = [];
30
+ let next = 0;
31
+ for (const group of groups) {
32
+ addResolved(regions, baseLines.slice(next, group.start));
33
+ const baseSlice = baseLines.slice(group.start, group.end);
34
+ const oursSlice = applyWithin(baseSlice, group.start, group.ours);
35
+ const theirsSlice = applyWithin(baseSlice, group.start, group.theirs);
36
+ if (group.theirs.length === 0 || sameLines(oursSlice, theirsSlice)) {
37
+ addResolved(regions, oursSlice);
38
+ }
39
+ else if (group.ours.length === 0) {
40
+ addResolved(regions, theirsSlice);
41
+ }
42
+ else {
43
+ regions.push({ kind: "conflict", base: baseSlice, ours: oursSlice, theirs: theirsSlice });
44
+ }
45
+ next = group.end;
46
+ }
47
+ addResolved(regions, baseLines.slice(next));
48
+ return regions;
49
+ }
50
+ /**
51
+ * The text of a merge, settling each conflict by taking one side whole.
52
+ *
53
+ * @param regions - what `mergeLines` gave back
54
+ * @param onConflict - which side wins a conflict
55
+ * @returns the merged text
56
+ *
57
+ * @example
58
+ * // A person's edit inside a change the assistant made: the person's text wins.
59
+ * mergedText(mergeLines(before, baseline, after), "theirs");
60
+ */
61
+ export function mergedText(regions, onConflict) {
62
+ return regions
63
+ .flatMap((region) => {
64
+ if (region.kind === "resolved")
65
+ return region.lines;
66
+ return onConflict === "ours" ? region.ours : region.theirs;
67
+ })
68
+ .join("");
69
+ }
70
+ /**
71
+ * Whether a merge has a conflict.
72
+ *
73
+ * @param regions - what `mergeLines` gave back
74
+ */
75
+ export function hasConflicts(regions) {
76
+ return regions.some((region) => region.kind === "conflict");
77
+ }
78
+ /**
79
+ * Puts the changes of both sides in order and groups the ones that overlap,
80
+ * or touch when `touchingConflicts` is set, so each group is settled on its
81
+ * own. Changes from one side never touch each other (`diffLines` leaves a
82
+ * kept line between them), so a group only grows past one change when the
83
+ * other side bridges it.
84
+ *
85
+ * Changes at the same line come insertions first, so lines added just before
86
+ * lines the other side changed stay before them when the two aren't grouped.
87
+ */
88
+ function groupChanges(ours, theirs, touchingConflicts) {
89
+ const tagged = [
90
+ ...ours.map((change) => ({ change, side: "ours" })),
91
+ ...theirs.map((change) => ({ change, side: "theirs" })),
92
+ ].sort((first, second) => first.change.beforeStart - second.change.beforeStart ||
93
+ first.change.beforeEnd - second.change.beforeEnd);
94
+ const groups = [];
95
+ let current;
96
+ for (const { change, side } of tagged) {
97
+ if (current === undefined || !joinsGroup(current, change, touchingConflicts)) {
98
+ current = { start: change.beforeStart, end: change.beforeEnd, ours: [], theirs: [] };
99
+ groups.push(current);
100
+ }
101
+ current.end = Math.max(current.end, change.beforeEnd);
102
+ current[side].push(change);
103
+ }
104
+ return groups;
105
+ }
106
+ /** Whether a change is settled together with the group before it in order. */
107
+ function joinsGroup(group, change, touchingConflicts) {
108
+ if (touchingConflicts)
109
+ return change.beforeStart <= group.end;
110
+ if (change.beforeStart < group.end)
111
+ return true;
112
+ // Lines both sides add at the same place: which go first is unclear.
113
+ const groupIsInsertion = group.start === group.end;
114
+ const changeIsInsertion = change.beforeStart === change.beforeEnd;
115
+ return groupIsInsertion && changeIsInsertion && change.beforeStart === group.start;
116
+ }
117
+ /** One side's lines for a group: the base slice (starting at base line `start`) with that side's changes in it. */
118
+ function applyWithin(baseSlice, start, changes) {
119
+ const out = [];
120
+ let next = 0;
121
+ for (const change of changes) {
122
+ out.push(...baseSlice.slice(next, change.beforeStart - start), ...change.added);
123
+ next = change.beforeEnd - start;
124
+ }
125
+ out.push(...baseSlice.slice(next));
126
+ return out;
127
+ }
128
+ /** Adds settled lines, joined to the region before when that one is settled too. */
129
+ function addResolved(regions, lines) {
130
+ if (lines.length === 0)
131
+ return;
132
+ const last = regions.at(-1);
133
+ if (last?.kind === "resolved") {
134
+ regions[regions.length - 1] = { kind: "resolved", lines: [...last.lines, ...lines] };
135
+ return;
136
+ }
137
+ regions.push({ kind: "resolved", lines });
138
+ }
@@ -0,0 +1,32 @@
1
+ /**
2
+ * True for objects made by `{}`, `Object.create(null)` or `JSON.parse`: the
3
+ * plain records that deep equality and deep clone walk into.
4
+ */
5
+ export declare function isPlainObject(value: unknown): value is Record<string, unknown>;
6
+ /**
7
+ * Says in words what kind of object a value is, for an error message about
8
+ * data that isn't plain: "a Map", "an Int8Array", "an instance of an unnamed
9
+ * class", or "an object with a custom prototype" when no class made it, as
10
+ * with `Object.create({})`.
11
+ *
12
+ * @param value - the object to describe
13
+ * @returns the kind, with "a" or "an" in front
14
+ *
15
+ * @example
16
+ * describeObject(new Map()); // "a Map"
17
+ */
18
+ export declare function describeObject(value: object): string;
19
+ /**
20
+ * Adds an object key to a path such as `value.steps[0]`, for an error message
21
+ * that says where a value is. A key that is a simple identifier follows a dot;
22
+ * any other key is quoted in brackets, so the key `"a.b"` reads differently
23
+ * from `a` then `b`, and the key `"0"` from an array index.
24
+ *
25
+ * @param path - the path so far
26
+ * @param key - the key to add
27
+ * @returns the longer path
28
+ *
29
+ * @example
30
+ * keyPath("value.steps", "a.b"); // 'value.steps["a.b"]'
31
+ */
32
+ export declare function keyPath(path: string, key: string): string;
@@ -0,0 +1,57 @@
1
+ /**
2
+ * True for objects made by `{}`, `Object.create(null)` or `JSON.parse`: the
3
+ * plain records that deep equality and deep clone walk into.
4
+ */
5
+ export function isPlainObject(value) {
6
+ if (typeof value !== "object" || value === null) {
7
+ return false;
8
+ }
9
+ const prototype = Object.getPrototypeOf(value);
10
+ return prototype === Object.prototype || prototype === null;
11
+ }
12
+ /**
13
+ * Says in words what kind of object a value is, for an error message about
14
+ * data that isn't plain: "a Map", "an Int8Array", "an instance of an unnamed
15
+ * class", or "an object with a custom prototype" when no class made it, as
16
+ * with `Object.create({})`.
17
+ *
18
+ * @param value - the object to describe
19
+ * @returns the kind, with "a" or "an" in front
20
+ *
21
+ * @example
22
+ * describeObject(new Map()); // "a Map"
23
+ */
24
+ export function describeObject(value) {
25
+ const prototype = Object.getPrototypeOf(value);
26
+ if (prototype === null || prototype === Object.prototype) {
27
+ return "a plain object";
28
+ }
29
+ // The prototype's own constructor, read without running a getter: an
30
+ // inherited one would name Object for an object made by Object.create({}).
31
+ const maker = Object.getOwnPropertyDescriptor(prototype, "constructor")?.value;
32
+ if (typeof maker !== "function") {
33
+ return "an object with a custom prototype";
34
+ }
35
+ const name = maker.name;
36
+ if (name === "") {
37
+ return "an instance of an unnamed class";
38
+ }
39
+ // No "u": built-in names that start with it, such as Uint8Array and URL, take "a".
40
+ return `${/^[aeio]/i.test(name) ? "an" : "a"} ${name}`;
41
+ }
42
+ /**
43
+ * Adds an object key to a path such as `value.steps[0]`, for an error message
44
+ * that says where a value is. A key that is a simple identifier follows a dot;
45
+ * any other key is quoted in brackets, so the key `"a.b"` reads differently
46
+ * from `a` then `b`, and the key `"0"` from an array index.
47
+ *
48
+ * @param path - the path so far
49
+ * @param key - the key to add
50
+ * @returns the longer path
51
+ *
52
+ * @example
53
+ * keyPath("value.steps", "a.b"); // 'value.steps["a.b"]'
54
+ */
55
+ export function keyPath(path, key) {
56
+ return /^[A-Za-z_$][\w$]*$/.test(key) ? `${path}.${key}` : `${path}[${JSON.stringify(key)}]`;
57
+ }
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Cleans up a path: joins repeated slashes, drops `.` segments and resolves
3
+ * `..` against the segment before it. A leading `/` and a trailing `/` are
4
+ * kept. An empty path becomes `.`.
5
+ *
6
+ * It doesn't check that a path stays inside a folder: `normalize("../a")`
7
+ * is `"../a"`. Callers that accept paths from people must refuse a leading
8
+ * `..` themselves.
9
+ *
10
+ * @param path - the path to clean
11
+ * @returns the clean path
12
+ *
13
+ * @example
14
+ * posixPath.normalize("hubs//support/./agents/../skills/"); // "hubs/support/skills/"
15
+ */
16
+ declare function normalize(path: string): string;
17
+ /**
18
+ * Joins path segments with `/` and normalizes the result. Empty segments are
19
+ * skipped; with none left the result is `.`.
20
+ *
21
+ * @param segments - the parts of the path
22
+ * @returns the joined, clean path
23
+ *
24
+ * @example
25
+ * posixPath.join("hubs", "support/", "agents", "triage.agent.yaml"); // "hubs/support/agents/triage.agent.yaml"
26
+ */
27
+ declare function join(...segments: readonly string[]): string;
28
+ /**
29
+ * The folder part of a path: everything before the last segment. Trailing
30
+ * slashes don't count as a segment. Meant for clean paths (see `normalize`);
31
+ * for those it gives the same result as `node:path.posix`.
32
+ *
33
+ * @param path - the path
34
+ * @returns the folder, `.` for a bare name and `/` at the root
35
+ *
36
+ * @example
37
+ * posixPath.dirname("hubs/support/agents/triage.agent.yaml"); // "hubs/support/agents"
38
+ */
39
+ declare function dirname(path: string): string;
40
+ /**
41
+ * The last segment of a path. Trailing slashes don't count as a segment.
42
+ * Gives the same result as `node:path.posix.basename` without a suffix.
43
+ *
44
+ * @param path - the path
45
+ * @returns the last segment, empty for `""` and `/`
46
+ *
47
+ * @example
48
+ * posixPath.basename("hubs/support/agents/triage.agent.yaml"); // "triage.agent.yaml"
49
+ */
50
+ declare function basename(path: string): string;
51
+ /**
52
+ * Helpers for forward-slash paths that behave like `node:path.posix`:
53
+ * `normalize`, `join`, `dirname` and `basename`.
54
+ */
55
+ export declare const posixPath: {
56
+ readonly normalize: typeof normalize;
57
+ readonly join: typeof join;
58
+ readonly dirname: typeof dirname;
59
+ readonly basename: typeof basename;
60
+ };
61
+ export {};
@@ -0,0 +1,121 @@
1
+ // Forward-slash paths, the way workspace files are named on every platform.
2
+ // The functions behave like node:path.posix, which the core can't import.
3
+ /**
4
+ * Cleans up a path: joins repeated slashes, drops `.` segments and resolves
5
+ * `..` against the segment before it. A leading `/` and a trailing `/` are
6
+ * kept. An empty path becomes `.`.
7
+ *
8
+ * It doesn't check that a path stays inside a folder: `normalize("../a")`
9
+ * is `"../a"`. Callers that accept paths from people must refuse a leading
10
+ * `..` themselves.
11
+ *
12
+ * @param path - the path to clean
13
+ * @returns the clean path
14
+ *
15
+ * @example
16
+ * posixPath.normalize("hubs//support/./agents/../skills/"); // "hubs/support/skills/"
17
+ */
18
+ function normalize(path) {
19
+ if (path === "") {
20
+ return ".";
21
+ }
22
+ const absolute = path.startsWith("/");
23
+ const trailingSlash = path.endsWith("/");
24
+ const segments = resolveSegments(path, absolute);
25
+ if (segments.length === 0) {
26
+ return emptyResult(absolute, trailingSlash);
27
+ }
28
+ const normalized = segments.join("/") + (trailingSlash ? "/" : "");
29
+ return absolute ? `/${normalized}` : normalized;
30
+ }
31
+ function resolveSegments(path, absolute) {
32
+ const segments = [];
33
+ for (const segment of path.split("/")) {
34
+ if (segment === "" || segment === ".") {
35
+ continue;
36
+ }
37
+ const previous = segments.at(-1);
38
+ if (segment === ".." && previous !== undefined && previous !== "..") {
39
+ segments.pop();
40
+ }
41
+ else if (segment === ".." && absolute) {
42
+ // Nothing is above the root.
43
+ }
44
+ else {
45
+ segments.push(segment);
46
+ }
47
+ }
48
+ return segments;
49
+ }
50
+ function emptyResult(absolute, trailingSlash) {
51
+ if (absolute) {
52
+ return "/";
53
+ }
54
+ return trailingSlash ? "./" : ".";
55
+ }
56
+ /**
57
+ * Joins path segments with `/` and normalizes the result. Empty segments are
58
+ * skipped; with none left the result is `.`.
59
+ *
60
+ * @param segments - the parts of the path
61
+ * @returns the joined, clean path
62
+ *
63
+ * @example
64
+ * posixPath.join("hubs", "support/", "agents", "triage.agent.yaml"); // "hubs/support/agents/triage.agent.yaml"
65
+ */
66
+ function join(...segments) {
67
+ const parts = segments.filter((segment) => segment !== "");
68
+ if (parts.length === 0) {
69
+ return ".";
70
+ }
71
+ return normalize(parts.join("/"));
72
+ }
73
+ /**
74
+ * The folder part of a path: everything before the last segment. Trailing
75
+ * slashes don't count as a segment. Meant for clean paths (see `normalize`);
76
+ * for those it gives the same result as `node:path.posix`.
77
+ *
78
+ * @param path - the path
79
+ * @returns the folder, `.` for a bare name and `/` at the root
80
+ *
81
+ * @example
82
+ * posixPath.dirname("hubs/support/agents/triage.agent.yaml"); // "hubs/support/agents"
83
+ */
84
+ function dirname(path) {
85
+ const trimmed = trimTrailingSlashes(path);
86
+ if (trimmed === "") {
87
+ return path.startsWith("/") ? "/" : ".";
88
+ }
89
+ const lastSlash = trimmed.lastIndexOf("/");
90
+ if (lastSlash === -1) {
91
+ return ".";
92
+ }
93
+ const folder = trimTrailingSlashes(trimmed.slice(0, lastSlash));
94
+ return folder === "" ? "/" : folder;
95
+ }
96
+ /**
97
+ * The last segment of a path. Trailing slashes don't count as a segment.
98
+ * Gives the same result as `node:path.posix.basename` without a suffix.
99
+ *
100
+ * @param path - the path
101
+ * @returns the last segment, empty for `""` and `/`
102
+ *
103
+ * @example
104
+ * posixPath.basename("hubs/support/agents/triage.agent.yaml"); // "triage.agent.yaml"
105
+ */
106
+ function basename(path) {
107
+ const trimmed = trimTrailingSlashes(path);
108
+ return trimmed.slice(trimmed.lastIndexOf("/") + 1);
109
+ }
110
+ function trimTrailingSlashes(path) {
111
+ let end = path.length;
112
+ while (end > 0 && path[end - 1] === "/") {
113
+ end--;
114
+ }
115
+ return path.slice(0, end);
116
+ }
117
+ /**
118
+ * Helpers for forward-slash paths that behave like `node:path.posix`:
119
+ * `normalize`, `join`, `dirname` and `basename`.
120
+ */
121
+ export const posixPath = { normalize, join, dirname, basename };
@@ -0,0 +1,55 @@
1
+ /** A successful outcome that carries a value. */
2
+ export interface Ok<T> {
3
+ readonly ok: true;
4
+ readonly value: T;
5
+ }
6
+ /** A failed outcome that carries an error. */
7
+ export interface Err<E> {
8
+ readonly ok: false;
9
+ readonly error: E;
10
+ }
11
+ /**
12
+ * The outcome of an operation that can fail in an expected way. Check `ok`
13
+ * before reading `value` or `error`; TypeScript narrows the type for you.
14
+ *
15
+ * @example
16
+ * const parsed = parsePort("8080");
17
+ * if (!parsed.ok) return parsed;
18
+ * listen(parsed.value);
19
+ */
20
+ export type Result<T, E = Error> = Ok<T> | Err<E>;
21
+ /**
22
+ * Wraps a value as a successful result.
23
+ *
24
+ * @param value - the value to carry
25
+ * @returns `{ ok: true, value }`
26
+ */
27
+ export declare function ok<T>(value: T): Ok<T>;
28
+ /**
29
+ * Wraps an error as a failed result.
30
+ *
31
+ * @param error - the error to carry
32
+ * @returns `{ ok: false, error }`
33
+ */
34
+ export declare function err<E>(error: E): Err<E>;
35
+ /**
36
+ * Changes the value of a successful result and passes a failed one through
37
+ * unchanged.
38
+ *
39
+ * @param result - the result to transform
40
+ * @param transform - called with the value when `result` is successful
41
+ * @returns a new result with the transformed value, or the original failure
42
+ *
43
+ * @example
44
+ * mapResult(ok(2), (n) => n * 10); // ok(20)
45
+ */
46
+ export declare function mapResult<T, U, E>(result: Result<T, E>, transform: (value: T) => U): Result<U, E>;
47
+ /**
48
+ * Returns the value of a successful result, or throws for a failed one.
49
+ * Use it where a failure is a bug, such as in tests and fixtures.
50
+ *
51
+ * @param result - the result to unwrap
52
+ * @returns the value
53
+ * @throws the carried error when it is an `Error`, otherwise an `Error` that describes it
54
+ */
55
+ export declare function unwrap<T, E>(result: Result<T, E>): T;
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Wraps a value as a successful result.
3
+ *
4
+ * @param value - the value to carry
5
+ * @returns `{ ok: true, value }`
6
+ */
7
+ export function ok(value) {
8
+ return { ok: true, value };
9
+ }
10
+ /**
11
+ * Wraps an error as a failed result.
12
+ *
13
+ * @param error - the error to carry
14
+ * @returns `{ ok: false, error }`
15
+ */
16
+ export function err(error) {
17
+ return { ok: false, error };
18
+ }
19
+ /**
20
+ * Changes the value of a successful result and passes a failed one through
21
+ * unchanged.
22
+ *
23
+ * @param result - the result to transform
24
+ * @param transform - called with the value when `result` is successful
25
+ * @returns a new result with the transformed value, or the original failure
26
+ *
27
+ * @example
28
+ * mapResult(ok(2), (n) => n * 10); // ok(20)
29
+ */
30
+ export function mapResult(result, transform) {
31
+ if (!result.ok) {
32
+ return result;
33
+ }
34
+ return ok(transform(result.value));
35
+ }
36
+ /**
37
+ * Returns the value of a successful result, or throws for a failed one.
38
+ * Use it where a failure is a bug, such as in tests and fixtures.
39
+ *
40
+ * @param result - the result to unwrap
41
+ * @returns the value
42
+ * @throws the carried error when it is an `Error`, otherwise an `Error` that describes it
43
+ */
44
+ export function unwrap(result) {
45
+ if (result.ok) {
46
+ return result.value;
47
+ }
48
+ if (result.error instanceof Error) {
49
+ throw result.error;
50
+ }
51
+ throw new Error(`Expected a successful result, but it failed with: ${String(result.error)}`);
52
+ }
@@ -0,0 +1,54 @@
1
+ /** What a secret value is replaced with wherever a scrubber finds it. */
2
+ export declare const secretRemoved = "[secret removed]";
3
+ /**
4
+ * The forms one secret commonly takes in text: as it is, URL-encoded (with
5
+ * upper- and lowercase escapes), form-encoded, and JSON-escaped (with `/`
6
+ * as it is and as `\/`). Base64, reversed, split or otherwise transformed
7
+ * copies are not here: those can't be found by matching text.
8
+ *
9
+ * Not covered either: JSON that escapes non-ASCII as `\uXXXX` (Python's
10
+ * default `json.dumps`), form-encoding with lowercase escapes, and
11
+ * URL-encoding that mixes upper- and lowercase escapes (`%2f%2F`).
12
+ *
13
+ * The forms come in the order shown, which stays the same. They can
14
+ * repeat, for example when the value has nothing to encode. An empty value
15
+ * has no forms, because an empty match is everywhere.
16
+ *
17
+ * @example
18
+ * secretTextForms("a b"); // ["a b", "a%20b", "a%20b", "a+b", "a b", "a b"]
19
+ */
20
+ export declare function secretTextForms(value: string): string[];
21
+ /**
22
+ * Replaces every secret it has been told about with `[secret removed]`, in
23
+ * each form {@link secretTextForms} lists. It finds every copy of every form
24
+ * in the text as given, so copies that touch or overlap become one
25
+ * `[secret removed]` and no part of either secret is left, and a short
26
+ * secret is never found inside a marker the scrubber wrote itself.
27
+ *
28
+ * Every non-empty secret is matched, however short: a one-letter secret
29
+ * mangles the text, but leaking it would be worse. Scrub a whole text
30
+ * before splitting it into lines, so a secret that holds a line break is
31
+ * still found.
32
+ *
33
+ * @example
34
+ * const scrubber = new SecretScrubber();
35
+ * scrubber.remember(apiKey);
36
+ * scrubber.scrub(`GET /v1?key=${apiKey} failed`); // "GET /v1?key=[secret removed] failed"
37
+ */
38
+ export declare class SecretScrubber {
39
+ #private;
40
+ /** Adds a secret to scrub from now on. An empty value is ignored. */
41
+ remember(value: string): void;
42
+ /** The text with every form of every remembered secret replaced. */
43
+ scrub(text: string): string;
44
+ /**
45
+ * A copy of JSON-shaped data with {@link scrub} applied to every string in
46
+ * it, object keys included, at any depth. Numbers, booleans, `null` and
47
+ * anything that isn't a string, an array or a plain object are kept as
48
+ * they are. The value given is not changed.
49
+ *
50
+ * @example
51
+ * scrubber.scrubValue({ headers: [`Bearer ${token}`] }); // { headers: ["Bearer [secret removed]"] }
52
+ */
53
+ scrubValue(value: unknown): unknown;
54
+ }