@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,10 @@
1
+ /**
2
+ * The registrable domain of `host`: its public suffix and one label before
3
+ * it. A host that is a public suffix itself, or has a single label, is its
4
+ * own domain. A suffix the list doesn't know is the last label, as the list
5
+ * says. Labels are compared as they are, so pass a lowercase ASCII host.
6
+ *
7
+ * @param host - a lowercase host name in ASCII form, without a trailing dot
8
+ * @returns the registrable domain, at the end of `host`
9
+ */
10
+ export declare function registrableDomain(host: string): string;
@@ -0,0 +1,62 @@
1
+ // Finds a host's registrable domain with our pinned copy of the public suffix
2
+ // list (P7 on HAL-1782): the part a person or company registered, such as
3
+ // `example.co.uk` in `api.example.co.uk`. The list's own algorithm is at
4
+ // https://github.com/publicsuffix/list/wiki/Format.
5
+ import { publicSuffixRules } from "./public-suffixes.generated.js";
6
+ // Split on first use, not when the package loads: most programs that use std
7
+ // never show a site. The rules never change while a program runs.
8
+ let rules;
9
+ /**
10
+ * The registrable domain of `host`: its public suffix and one label before
11
+ * it. A host that is a public suffix itself, or has a single label, is its
12
+ * own domain. A suffix the list doesn't know is the last label, as the list
13
+ * says. Labels are compared as they are, so pass a lowercase ASCII host.
14
+ *
15
+ * @param host - a lowercase host name in ASCII form, without a trailing dot
16
+ * @returns the registrable domain, at the end of `host`
17
+ */
18
+ export function registrableDomain(host) {
19
+ const labels = host.split(".");
20
+ const suffixLength = publicSuffixLength(labels);
21
+ if (labels.length <= suffixLength)
22
+ return host;
23
+ return labels.slice(-(suffixLength + 1)).join(".");
24
+ }
25
+ /** How many labels at the end of `labels` are the public suffix. */
26
+ function publicSuffixLength(labels) {
27
+ const { exact, wildcard, exception } = suffixRules();
28
+ // From the longest candidate to the shortest, so the first rule that
29
+ // matches is the longest. An exception rule wins over the wildcard it
30
+ // undoes: its suffix is the candidate without its first label.
31
+ for (let start = 0; start < labels.length; start += 1) {
32
+ const candidate = labels.slice(start).join(".");
33
+ if (exception.has(candidate))
34
+ return labels.length - start - 1;
35
+ if (exact.has(candidate))
36
+ return labels.length - start;
37
+ const parent = labels.slice(start + 1).join(".");
38
+ if (start + 1 < labels.length && wildcard.has(parent))
39
+ return labels.length - start;
40
+ }
41
+ return 1;
42
+ }
43
+ function suffixRules() {
44
+ rules ??= splitRules(publicSuffixRules);
45
+ return rules;
46
+ }
47
+ function splitRules(text) {
48
+ const exact = new Set();
49
+ const wildcard = new Set();
50
+ const exception = new Set();
51
+ for (const rule of text.split("\n")) {
52
+ if (rule === "")
53
+ continue;
54
+ if (rule.startsWith("!"))
55
+ exception.add(rule.slice(1));
56
+ else if (rule.startsWith("*."))
57
+ wildcard.add(rule.slice(2));
58
+ else
59
+ exact.add(rule);
60
+ }
61
+ return { exact, wildcard, exception };
62
+ }
@@ -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
+ }
@@ -0,0 +1,124 @@
1
+ import { isPlainObject } from "./plain-data.js";
2
+ /** What a secret value is replaced with wherever a scrubber finds it. */
3
+ export const secretRemoved = "[secret removed]";
4
+ /**
5
+ * The forms one secret commonly takes in text: as it is, URL-encoded (with
6
+ * upper- and lowercase escapes), form-encoded, and JSON-escaped (with `/`
7
+ * as it is and as `\/`). Base64, reversed, split or otherwise transformed
8
+ * copies are not here: those can't be found by matching text.
9
+ *
10
+ * Not covered either: JSON that escapes non-ASCII as `\uXXXX` (Python's
11
+ * default `json.dumps`), form-encoding with lowercase escapes, and
12
+ * URL-encoding that mixes upper- and lowercase escapes (`%2f%2F`).
13
+ *
14
+ * The forms come in the order shown, which stays the same. They can
15
+ * repeat, for example when the value has nothing to encode. An empty value
16
+ * has no forms, because an empty match is everywhere.
17
+ *
18
+ * @example
19
+ * secretTextForms("a b"); // ["a b", "a%20b", "a%20b", "a+b", "a b", "a b"]
20
+ */
21
+ export function secretTextForms(value) {
22
+ if (value === "")
23
+ return [];
24
+ // `encodeURIComponent` throws on a lone surrogate; the URL and form
25
+ // encoders of the web platform write it as U+FFFD, so do the same.
26
+ const urlEncoded = encodeURIComponent(value.toWellFormed());
27
+ const json = JSON.stringify(value).slice(1, -1);
28
+ return [
29
+ value,
30
+ urlEncoded,
31
+ urlEncoded.replace(/%[0-9A-F]{2}/g, (hex) => hex.toLowerCase()),
32
+ formEncoded(urlEncoded),
33
+ json,
34
+ json.replaceAll("/", "\\/"),
35
+ ];
36
+ }
37
+ /**
38
+ * The value as `application/x-www-form-urlencoded` writes it, as
39
+ * `URLSearchParams` does, built from its URL-encoded form: a space becomes
40
+ * `+`, and `!'()~`, which `encodeURIComponent` leaves alone, are escaped.
41
+ */
42
+ function formEncoded(urlEncoded) {
43
+ return urlEncoded
44
+ .replaceAll("%20", "+")
45
+ .replace(/[!'()~]/g, (character) => `%${character.charCodeAt(0).toString(16).toUpperCase()}`);
46
+ }
47
+ /**
48
+ * Replaces every secret it has been told about with `[secret removed]`, in
49
+ * each form {@link secretTextForms} lists. It finds every copy of every form
50
+ * in the text as given, so copies that touch or overlap become one
51
+ * `[secret removed]` and no part of either secret is left, and a short
52
+ * secret is never found inside a marker the scrubber wrote itself.
53
+ *
54
+ * Every non-empty secret is matched, however short: a one-letter secret
55
+ * mangles the text, but leaking it would be worse. Scrub a whole text
56
+ * before splitting it into lines, so a secret that holds a line break is
57
+ * still found.
58
+ *
59
+ * @example
60
+ * const scrubber = new SecretScrubber();
61
+ * scrubber.remember(apiKey);
62
+ * scrubber.scrub(`GET /v1?key=${apiKey} failed`); // "GET /v1?key=[secret removed] failed"
63
+ */
64
+ export class SecretScrubber {
65
+ #forms = new Set();
66
+ /** Adds a secret to scrub from now on. An empty value is ignored. */
67
+ remember(value) {
68
+ for (const form of secretTextForms(value))
69
+ this.#forms.add(form);
70
+ }
71
+ /** The text with every form of every remembered secret replaced. */
72
+ scrub(text) {
73
+ const hidden = this.#hiddenCharacters(text);
74
+ let scrubbed = "";
75
+ let at = 0;
76
+ while (at < text.length) {
77
+ if (!hidden[at]) {
78
+ scrubbed += text[at];
79
+ at += 1;
80
+ continue;
81
+ }
82
+ scrubbed += secretRemoved;
83
+ while (at < text.length && hidden[at])
84
+ at += 1;
85
+ }
86
+ return scrubbed;
87
+ }
88
+ /**
89
+ * A copy of JSON-shaped data with {@link scrub} applied to every string in
90
+ * it, object keys included, at any depth. Numbers, booleans, `null` and
91
+ * anything that isn't a string, an array or a plain object are kept as
92
+ * they are. The value given is not changed.
93
+ *
94
+ * @example
95
+ * scrubber.scrubValue({ headers: [`Bearer ${token}`] }); // { headers: ["Bearer [secret removed]"] }
96
+ */
97
+ scrubValue(value) {
98
+ if (typeof value === "string")
99
+ return this.scrub(value);
100
+ if (Array.isArray(value))
101
+ return value.map((item) => this.scrubValue(item));
102
+ if (!isPlainObject(value))
103
+ return value;
104
+ const scrubbed = {};
105
+ for (const [key, item] of Object.entries(value)) {
106
+ scrubbed[this.scrub(key)] = this.scrubValue(item);
107
+ }
108
+ return scrubbed;
109
+ }
110
+ /**
111
+ * One flag per UTF-16 code unit of the text, set where any copy of any
112
+ * form covers it. Copies of one form may overlap (`aa` in `aaa`), so the
113
+ * search moves on one code unit at a time, not past the whole copy.
114
+ */
115
+ #hiddenCharacters(text) {
116
+ const hidden = new Uint8Array(text.length);
117
+ for (const form of this.#forms) {
118
+ for (let at = text.indexOf(form); at !== -1; at = text.indexOf(form, at + 1)) {
119
+ hidden.fill(1, at, at + form.length);
120
+ }
121
+ }
122
+ return hidden;
123
+ }
124
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * The kinds of secret `findSecretShape` spots. Only the kind leaves the
3
+ * check, never the text that matched, so a caller can't log or keep the key
4
+ * by accident.
5
+ */
6
+ export type SecretShape = "ai-provider-key" | "google-client-secret" | "google-api-key" | "github-token" | "slack-token";
7
+ /**
8
+ * Finds text shaped like an API key or other secret, so Studio can hold a
9
+ * message before it is sent, saved or logged. The Assistant, Try it chats and
10
+ * the Inbox all ask this one check, so they spot the same formats. When the
11
+ * text holds more than one, the kind that comes first in the text wins.
12
+ *
13
+ * The answer is the kind only. When it finds something, never put the text
14
+ * in a log or an error report: the text holds the key.
15
+ *
16
+ * @example
17
+ * findSecretShape(`my key is sk-${"a".repeat(16)}`); // "ai-provider-key"
18
+ * findSecretShape("we use sk-learn for this"); // undefined
19
+ */
20
+ export declare function findSecretShape(text: string): SecretShape | undefined;
@@ -0,0 +1,53 @@
1
+ /*
2
+ * Each pattern is a prefix at the start of a run of key characters (letters,
3
+ * digits, `-` and `_`), so `task-…` or `xGOCSPX-…` never match, followed by
4
+ * at least 16 more key characters, so words such as `sk-learn` or a prefix
5
+ * named in a sentence don't count either.
6
+ *
7
+ * The run after the prefix must also hold a digit or a capital letter.
8
+ * Lowercase slugs such as `sk-learn-tutorial-for-beginners` are long enough
9
+ * to pass the 16-character floor, but real keys are random mixed-case text
10
+ * and almost never lack both. A digit alone would miss about 1 in 140 Google
11
+ * client secrets.
12
+ *
13
+ * `sk-` covers OpenAI and Anthropic keys (`sk-proj-…`, `sk-ant-…`). `GOCSPX-`
14
+ * is a Google OAuth client secret, which Studio sends to the Google setup's
15
+ * secret field instead of the providers page.
16
+ */
17
+ const notAfterKeyCharacter = "(?<![A-Za-z0-9_-])";
18
+ const keyBody = "(?=[a-z_-]*[A-Z0-9])[A-Za-z0-9_-]{16,}";
19
+ function keyPattern(prefix) {
20
+ return new RegExp(notAfterKeyCharacter + prefix + keyBody);
21
+ }
22
+ const patterns = [
23
+ ["ai-provider-key", keyPattern("sk-")],
24
+ ["google-client-secret", keyPattern("GOCSPX-")],
25
+ ["google-api-key", keyPattern("AIza")],
26
+ ["github-token", keyPattern("(?:ghp_|github_pat_)")],
27
+ ["slack-token", keyPattern("xoxb-")],
28
+ ];
29
+ /**
30
+ * Finds text shaped like an API key or other secret, so Studio can hold a
31
+ * message before it is sent, saved or logged. The Assistant, Try it chats and
32
+ * the Inbox all ask this one check, so they spot the same formats. When the
33
+ * text holds more than one, the kind that comes first in the text wins.
34
+ *
35
+ * The answer is the kind only. When it finds something, never put the text
36
+ * in a log or an error report: the text holds the key.
37
+ *
38
+ * @example
39
+ * findSecretShape(`my key is sk-${"a".repeat(16)}`); // "ai-provider-key"
40
+ * findSecretShape("we use sk-learn for this"); // undefined
41
+ */
42
+ export function findSecretShape(text) {
43
+ let found;
44
+ let foundAt = Number.POSITIVE_INFINITY;
45
+ for (const [shape, pattern] of patterns) {
46
+ const match = pattern.exec(text);
47
+ if (match !== null && match.index < foundAt) {
48
+ found = shape;
49
+ foundAt = match.index;
50
+ }
51
+ }
52
+ return found;
53
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Whether an environment variable's name says its value is a secret: one
3
+ * of its words, in any letter case, is a word such as `TOKEN`, `KEY` or
4
+ * `PASSWORD`. Words are split at each character that is not a letter or
5
+ * digit and before a capital letter that follows a small letter or digit.
6
+ *
7
+ * @example
8
+ * isSecretVariableName("ANTHROPIC_API_KEY"); // true
9
+ * isSecretVariableName("authToken"); // true
10
+ * isSecretVariableName("KEYMAP"); // false
11
+ */
12
+ export declare function isSecretVariableName(name: string): boolean;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Words in a variable's name that say its value is a secret, such as
3
+ * `API_KEY`, `NODE_AUTH_TOKEN` or `npm_config__authToken`. Only whole words
4
+ * count, so `KEYMAP` or `AUTHOR` don't.
5
+ */
6
+ const secretWords = new Set([
7
+ "APIKEY",
8
+ "AUTH",
9
+ "COOKIE",
10
+ "CREDENTIAL",
11
+ "CREDENTIALS",
12
+ "KEY",
13
+ "PASSPHRASE",
14
+ "PASSWD",
15
+ "PASSWORD",
16
+ "PRIVATE",
17
+ "SECRET",
18
+ "TOKEN",
19
+ ]);
20
+ /**
21
+ * Whether an environment variable's name says its value is a secret: one
22
+ * of its words, in any letter case, is a word such as `TOKEN`, `KEY` or
23
+ * `PASSWORD`. Words are split at each character that is not a letter or
24
+ * digit and before a capital letter that follows a small letter or digit.
25
+ *
26
+ * @example
27
+ * isSecretVariableName("ANTHROPIC_API_KEY"); // true
28
+ * isSecretVariableName("authToken"); // true
29
+ * isSecretVariableName("KEYMAP"); // false
30
+ */
31
+ export function isSecretVariableName(name) {
32
+ const words = name.split(/[^A-Za-z0-9]+|(?<=[a-z0-9])(?=[A-Z])/);
33
+ return words.some((word) => secretWords.has(word.toUpperCase()));
34
+ }
@@ -0,0 +1,35 @@
1
+ /** A site's name, split so a screen can show the registrable domain apart. */
2
+ export interface SiteName {
3
+ /** The labels before the domain, with their last dot, such as `registry.`; empty when there are none. */
4
+ readonly prefix: string;
5
+ /** The registrable domain, such as `npmjs.org`, or the whole address of an IP host. */
6
+ readonly domain: string;
7
+ /** Whether the name was shortened to fit {@link siteNameMaxLength}; the text then holds `…`. */
8
+ readonly cut: boolean;
9
+ }
10
+ /** The most characters `prefix` and `domain` hold together, `…` and escapes included. */
11
+ export declare const siteNameMaxLength = 64;
12
+ /**
13
+ * Writes a host name the way a screen shows a site (requirement
14
+ * `std.site-name`). It is lowercased and loses a trailing dot. Any character
15
+ * other than `a`–`z`, `0`–`9`, `.`, `-`, `:`, `[` and `]` is written as
16
+ * `\u{…}`, so a Cyrillic letter, a full-width dot or a bidi mark can't look
17
+ * like the real thing. Punycode (`xn--`) labels stay as they are, never
18
+ * decoded. `domain` is the registrable domain from our pinned copy of the
19
+ * public suffix list, private section included, looked up on the host's
20
+ * ASCII form so a suffix written in Unicode (`公司.cn`) is found; an IP
21
+ * address is all domain.
22
+ *
23
+ * A name longer than {@link siteNameMaxLength} keeps its domain whole and
24
+ * loses the middle of its prefix, or all of it when the domain alone fills
25
+ * the cap. A domain too long by itself loses its start.
26
+ * Either way `cut` is set and the text holds `…`.
27
+ *
28
+ * @param host - the host as the sandbox reported it, without a port
29
+ * @returns the plain-text parts to show; never a link
30
+ *
31
+ * @example
32
+ * siteName("registry.npmjs.org.evil.example");
33
+ * // => { prefix: "registry.npmjs.org.", domain: "evil.example", cut: false }
34
+ */
35
+ export declare function siteName(host: string): SiteName;
@@ -0,0 +1,111 @@
1
+ // A site's name as a screen shows it: plain text, capped in length, with the
2
+ // registrable domain apart so it can stand out. Julian's conditions for
3
+ // showing blocked and allowed sites (HAL-1673): a look-alike name must never
4
+ // pass for the real one, and a long name must never push the real domain out
5
+ // of sight.
6
+ import { asciiHost } from "./ascii-host.js";
7
+ import { registrableDomain } from "./registrable-domain.js";
8
+ /** The most characters `prefix` and `domain` hold together, `…` and escapes included. */
9
+ export const siteNameMaxLength = 64;
10
+ const ellipsis = "…";
11
+ /** The characters shown as they are; any other is escaped. */
12
+ const plainCharacter = /^[a-z0-9.\-:[\]]$/;
13
+ const ipv4 = /^\d{1,3}(?:\.\d{1,3}){3}$/;
14
+ /**
15
+ * Writes a host name the way a screen shows a site (requirement
16
+ * `std.site-name`). It is lowercased and loses a trailing dot. Any character
17
+ * other than `a`–`z`, `0`–`9`, `.`, `-`, `:`, `[` and `]` is written as
18
+ * `\u{…}`, so a Cyrillic letter, a full-width dot or a bidi mark can't look
19
+ * like the real thing. Punycode (`xn--`) labels stay as they are, never
20
+ * decoded. `domain` is the registrable domain from our pinned copy of the
21
+ * public suffix list, private section included, looked up on the host's
22
+ * ASCII form so a suffix written in Unicode (`公司.cn`) is found; an IP
23
+ * address is all domain.
24
+ *
25
+ * A name longer than {@link siteNameMaxLength} keeps its domain whole and
26
+ * loses the middle of its prefix, or all of it when the domain alone fills
27
+ * the cap. A domain too long by itself loses its start.
28
+ * Either way `cut` is set and the text holds `…`.
29
+ *
30
+ * @param host - the host as the sandbox reported it, without a port
31
+ * @returns the plain-text parts to show; never a link
32
+ *
33
+ * @example
34
+ * siteName("registry.npmjs.org.evil.example");
35
+ * // => { prefix: "registry.npmjs.org.", domain: "evil.example", cut: false }
36
+ */
37
+ export function siteName(host) {
38
+ const plainHost = host.endsWith(".") ? host.slice(0, -1) : host;
39
+ const tokens = shownCharacters(plainHost);
40
+ const text = tokens.join("");
41
+ const domainStart = isIpAddress(text) ? 0 : domainStartOf(tokens, plainHost);
42
+ const prefixTokens = tokens.slice(0, domainStart);
43
+ const domainTokens = tokens.slice(domainStart);
44
+ const domain = domainTokens.join("");
45
+ if (text.length <= siteNameMaxLength) {
46
+ return { prefix: prefixTokens.join(""), domain, cut: false };
47
+ }
48
+ if (domain.length === siteNameMaxLength)
49
+ return { prefix: "", domain, cut: true };
50
+ if (domain.length < siteNameMaxLength) {
51
+ return {
52
+ prefix: middleCut(prefixTokens, siteNameMaxLength - domain.length),
53
+ domain,
54
+ cut: true,
55
+ };
56
+ }
57
+ const kept = lastTokens(domainTokens, siteNameMaxLength - ellipsis.length);
58
+ return { prefix: "", domain: ellipsis + kept.join(""), cut: true };
59
+ }
60
+ /** The host's characters as shown: ASCII letters lowercased, others plain or escaped. */
61
+ function shownCharacters(host) {
62
+ return Array.from(host, (character) => {
63
+ const lower = /^[A-Z]$/.test(character) ? character.toLowerCase() : character;
64
+ if (plainCharacter.test(lower))
65
+ return lower;
66
+ const codePoint = lower.codePointAt(0) ?? 0;
67
+ return `\\u{${codePoint.toString(16)}}`;
68
+ });
69
+ }
70
+ function isIpAddress(text) {
71
+ return ipv4.test(text) || text.includes(":");
72
+ }
73
+ /**
74
+ * Where the registrable domain starts in the shown tokens. The list is read
75
+ * on the ASCII form, which has the same labels: only a plain `.` separates
76
+ * them in both, and an escaped character is never one.
77
+ */
78
+ function domainStartOf(tokens, host) {
79
+ const domainLabels = registrableDomain(asciiHost(host)).split(".").length;
80
+ let dots = 0;
81
+ for (let index = tokens.length - 1; index >= 0; index -= 1) {
82
+ if (tokens[index] !== ".")
83
+ continue;
84
+ dots += 1;
85
+ if (dots === domainLabels)
86
+ return index + 1;
87
+ }
88
+ return 0;
89
+ }
90
+ /** `tokens` in at most `budget` characters, with `…` in place of the middle. Never splits an escape. */
91
+ function middleCut(tokens, budget) {
92
+ const room = budget - ellipsis.length;
93
+ // The end gets the odd character, so a prefix keeps its last dot.
94
+ const tail = lastTokens(tokens, Math.ceil(room / 2));
95
+ const head = firstTokens(tokens, room - Math.ceil(room / 2));
96
+ return head.join("") + ellipsis + tail.join("");
97
+ }
98
+ function firstTokens(tokens, budget) {
99
+ const kept = [];
100
+ let characters = 0;
101
+ for (const token of tokens) {
102
+ if (characters + token.length > budget)
103
+ break;
104
+ kept.push(token);
105
+ characters += token.length;
106
+ }
107
+ return kept;
108
+ }
109
+ function lastTokens(tokens, budget) {
110
+ return firstTokens([...tokens].reverse(), budget).reverse();
111
+ }
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Tells work that it should stop, and why. It does what an `AbortSignal`
3
+ * does for code that can't create one: core packages see the Web types but
4
+ * not their values, so they have no `AbortController`.
5
+ */
6
+ export interface StopSignal {
7
+ /** Whether the work was told to stop. */
8
+ readonly stopped: boolean;
9
+ /** Why it was told to stop; `undefined` until then. */
10
+ readonly reason: Error | undefined;
11
+ /** @throws the reason, once the work was told to stop */
12
+ throwIfStopped(): void;
13
+ /**
14
+ * Calls `listener` once, when the work is told to stop, or soon after this
15
+ * returns when it already was. Returns a function that removes it; a
16
+ * listener removed during the stop, by an earlier listener, isn't called.
17
+ *
18
+ * A listener added after the stop runs outside any `stop` call, so if it
19
+ * throws, nothing catches the error: it becomes an unhandled rejection,
20
+ * which ends a Node process by default.
21
+ */
22
+ onStop(listener: () => void): () => void;
23
+ }
24
+ /**
25
+ * Gives out a {@link StopSignal} and tells it to stop.
26
+ *
27
+ * @example
28
+ * const source = new StopSource();
29
+ * void runHarness(source.signal);
30
+ * source.stop(new Error("The engine stopped."));
31
+ */
32
+ export declare class StopSource {
33
+ #private;
34
+ readonly signal: StopSignal;
35
+ constructor();
36
+ /**
37
+ * Tells the signal to stop with `reason`, and each listener once. A second
38
+ * call changes nothing.
39
+ *
40
+ * @throws the error of the one listener that threw, or an `AggregateError`
41
+ * when several did; the other listeners still run
42
+ */
43
+ stop(reason: Error): void;
44
+ }