@halonicjs/testing 0.0.0 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (384) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +1 -0
  3. package/README.md +41 -1
  4. package/dist/adapters/http-kit/src/address-class.d.ts +34 -0
  5. package/dist/adapters/http-kit/src/address-class.js +109 -0
  6. package/dist/adapters/http-kit/src/index.d.ts +2 -0
  7. package/dist/adapters/http-kit/src/index.js +2 -0
  8. package/dist/adapters/http-kit/src/ip-address.d.ts +23 -0
  9. package/dist/adapters/http-kit/src/ip-address.js +89 -0
  10. package/dist/adapters/integration-kit/src/declaration.d.ts +14 -0
  11. package/dist/adapters/integration-kit/src/declaration.js +77 -0
  12. package/dist/adapters/integration-kit/src/host.d.ts +28 -0
  13. package/dist/adapters/integration-kit/src/host.js +30 -0
  14. package/dist/adapters/integration-kit/src/index.d.ts +14 -0
  15. package/dist/adapters/integration-kit/src/index.js +21 -0
  16. package/dist/adapters/integration-kit/src/leak-attempt.d.ts +14 -0
  17. package/dist/adapters/integration-kit/src/leak-attempt.js +16 -0
  18. package/dist/adapters/integration-kit/src/limited-http.d.ts +49 -0
  19. package/dist/adapters/integration-kit/src/limited-http.js +182 -0
  20. package/dist/adapters/integration-kit/src/load-problem.d.ts +20 -0
  21. package/dist/adapters/integration-kit/src/load-problem.js +1 -0
  22. package/dist/adapters/integration-kit/src/loader.d.ts +104 -0
  23. package/dist/adapters/integration-kit/src/loader.js +219 -0
  24. package/dist/adapters/integration-kit/src/local-address.d.ts +15 -0
  25. package/dist/adapters/integration-kit/src/local-address.js +25 -0
  26. package/dist/adapters/integration-kit/src/own-request.d.ts +33 -0
  27. package/dist/adapters/integration-kit/src/own-request.js +36 -0
  28. package/dist/adapters/integration-kit/src/plugin-load.d.ts +14 -0
  29. package/dist/adapters/integration-kit/src/plugin-load.js +58 -0
  30. package/dist/adapters/integration-kit/src/policy.d.ts +55 -0
  31. package/dist/adapters/integration-kit/src/policy.js +37 -0
  32. package/dist/adapters/integration-kit/src/request-body.d.ts +38 -0
  33. package/dist/adapters/integration-kit/src/request-body.js +68 -0
  34. package/dist/adapters/integration-kit/src/request-log.d.ts +25 -0
  35. package/dist/adapters/integration-kit/src/request-log.js +17 -0
  36. package/dist/adapters/integration-kit/src/response-body.d.ts +23 -0
  37. package/dist/adapters/integration-kit/src/response-body.js +117 -0
  38. package/dist/adapters/integration-kit/src/scoped-tokens.d.ts +14 -0
  39. package/dist/adapters/integration-kit/src/scoped-tokens.js +27 -0
  40. package/dist/adapters/integration-kit/src/secret-filter.d.ts +84 -0
  41. package/dist/adapters/integration-kit/src/secret-filter.js +205 -0
  42. package/dist/adapters/integration-kit/src/secret-in-request.d.ts +59 -0
  43. package/dist/adapters/integration-kit/src/secret-in-request.js +133 -0
  44. package/dist/adapters/integration-kit/src/secret-placement.d.ts +36 -0
  45. package/dist/adapters/integration-kit/src/secret-placement.js +190 -0
  46. package/dist/adapters/integration-kit/src/wait.d.ts +16 -0
  47. package/dist/adapters/integration-kit/src/wait.js +35 -0
  48. package/dist/core/events/src/add-usage.d.ts +10 -0
  49. package/dist/core/events/src/add-usage.js +27 -0
  50. package/dist/core/events/src/agent-resume.d.ts +24 -0
  51. package/dist/core/events/src/agent-resume.js +1 -0
  52. package/dist/core/events/src/home-path.d.ts +13 -0
  53. package/dist/core/events/src/home-path.js +26 -0
  54. package/dist/core/events/src/index.d.ts +13 -0
  55. package/dist/core/events/src/index.js +7 -0
  56. package/dist/core/events/src/run-basics.d.ts +205 -0
  57. package/dist/core/events/src/run-basics.js +1 -0
  58. package/dist/core/events/src/run-event.d.ts +434 -0
  59. package/dist/core/events/src/run-event.js +1 -0
  60. package/dist/core/events/src/run-summary.d.ts +108 -0
  61. package/dist/core/events/src/run-summary.js +1 -0
  62. package/dist/core/events/src/sandbox-blocked.d.ts +42 -0
  63. package/dist/core/events/src/sandbox-blocked.js +26 -0
  64. package/dist/core/events/src/sandbox-opened-read.d.ts +17 -0
  65. package/dist/core/events/src/sandbox-opened-read.js +63 -0
  66. package/dist/core/events/src/sandbox-opened.d.ts +94 -0
  67. package/dist/core/events/src/sandbox-opened.js +52 -0
  68. package/dist/core/events/src/summarize.d.ts +14 -0
  69. package/dist/core/events/src/summarize.js +188 -0
  70. package/dist/core/events/src/timeline-entry.d.ts +21 -0
  71. package/dist/core/events/src/timeline-entry.js +105 -0
  72. package/dist/core/events/src/upgrade.d.ts +23 -0
  73. package/dist/core/events/src/upgrade.js +49 -0
  74. package/dist/core/format/src/compact.d.ts +30 -0
  75. package/dist/core/format/src/compact.js +72 -0
  76. package/dist/core/format/src/index.d.ts +37 -0
  77. package/dist/core/format/src/index.js +23 -0
  78. package/dist/core/format/src/integration/index.d.ts +6 -0
  79. package/dist/core/format/src/integration/index.js +9 -0
  80. package/dist/core/format/src/json-schema.d.ts +26 -0
  81. package/dist/core/format/src/json-schema.js +48 -0
  82. package/dist/core/format/src/kind.d.ts +65 -0
  83. package/dist/core/format/src/kind.js +1 -0
  84. package/dist/core/format/src/kinds/agent/kind.d.ts +4 -0
  85. package/dist/core/format/src/kinds/agent/kind.js +10 -0
  86. package/dist/core/format/src/kinds/agent/sandbox-fields.d.ts +89 -0
  87. package/dist/core/format/src/kinds/agent/sandbox-fields.js +197 -0
  88. package/dist/core/format/src/kinds/agent/schema.d.ts +147 -0
  89. package/dist/core/format/src/kinds/agent/schema.js +107 -0
  90. package/dist/core/format/src/kinds/agent/working-folder-start.d.ts +74 -0
  91. package/dist/core/format/src/kinds/agent/working-folder-start.js +312 -0
  92. package/dist/core/format/src/kinds/collection/kind.d.ts +8 -0
  93. package/dist/core/format/src/kinds/collection/kind.js +14 -0
  94. package/dist/core/format/src/kinds/collection/schema.d.ts +89 -0
  95. package/dist/core/format/src/kinds/collection/schema.js +90 -0
  96. package/dist/core/format/src/kinds/connector/is-local.d.ts +10 -0
  97. package/dist/core/format/src/kinds/connector/is-local.js +43 -0
  98. package/dist/core/format/src/kinds/connector/kind.d.ts +4 -0
  99. package/dist/core/format/src/kinds/connector/kind.js +119 -0
  100. package/dist/core/format/src/kinds/connector/schema.d.ts +50 -0
  101. package/dist/core/format/src/kinds/connector/schema.js +92 -0
  102. package/dist/core/format/src/kinds/deployments/kind.d.ts +4 -0
  103. package/dist/core/format/src/kinds/deployments/kind.js +25 -0
  104. package/dist/core/format/src/kinds/deployments/schema.d.ts +37 -0
  105. package/dist/core/format/src/kinds/deployments/schema.js +42 -0
  106. package/dist/core/format/src/kinds/hub/kind.d.ts +4 -0
  107. package/dist/core/format/src/kinds/hub/kind.js +10 -0
  108. package/dist/core/format/src/kinds/hub/schema.d.ts +54 -0
  109. package/dist/core/format/src/kinds/hub/schema.js +34 -0
  110. package/dist/core/format/src/kinds/integration/kind.d.ts +16 -0
  111. package/dist/core/format/src/kinds/integration/kind.js +138 -0
  112. package/dist/core/format/src/kinds/integration/parse-sheet.d.ts +19 -0
  113. package/dist/core/format/src/kinds/integration/parse-sheet.js +24 -0
  114. package/dist/core/format/src/kinds/integration/policy.d.ts +67 -0
  115. package/dist/core/format/src/kinds/integration/policy.js +268 -0
  116. package/dist/core/format/src/kinds/integration/schema.d.ts +233 -0
  117. package/dist/core/format/src/kinds/integration/schema.js +233 -0
  118. package/dist/core/format/src/kinds/knowledge/kind.d.ts +4 -0
  119. package/dist/core/format/src/kinds/knowledge/kind.js +13 -0
  120. package/dist/core/format/src/kinds/knowledge/schema.d.ts +18 -0
  121. package/dist/core/format/src/kinds/knowledge/schema.js +25 -0
  122. package/dist/core/format/src/kinds/models/kind.d.ts +4 -0
  123. package/dist/core/format/src/kinds/models/kind.js +10 -0
  124. package/dist/core/format/src/kinds/models/schema.d.ts +92 -0
  125. package/dist/core/format/src/kinds/models/schema.js +38 -0
  126. package/dist/core/format/src/kinds/plugin/backend.d.ts +22 -0
  127. package/dist/core/format/src/kinds/plugin/backend.js +31 -0
  128. package/dist/core/format/src/kinds/plugin/checks.d.ts +13 -0
  129. package/dist/core/format/src/kinds/plugin/checks.js +131 -0
  130. package/dist/core/format/src/kinds/plugin/kind.d.ts +8 -0
  131. package/dist/core/format/src/kinds/plugin/kind.js +16 -0
  132. package/dist/core/format/src/kinds/plugin/problems.d.ts +24 -0
  133. package/dist/core/format/src/kinds/plugin/problems.js +65 -0
  134. package/dist/core/format/src/kinds/plugin/schema.d.ts +542 -0
  135. package/dist/core/format/src/kinds/plugin/schema.js +261 -0
  136. package/dist/core/format/src/kinds/plugin/setting-values.d.ts +17 -0
  137. package/dist/core/format/src/kinds/plugin/setting-values.js +38 -0
  138. package/dist/core/format/src/kinds/plugin/ui-checks.d.ts +8 -0
  139. package/dist/core/format/src/kinds/plugin/ui-checks.js +94 -0
  140. package/dist/core/format/src/kinds/provider/kind.d.ts +4 -0
  141. package/dist/core/format/src/kinds/provider/kind.js +24 -0
  142. package/dist/core/format/src/kinds/provider/schema.d.ts +17 -0
  143. package/dist/core/format/src/kinds/provider/schema.js +22 -0
  144. package/dist/core/format/src/kinds/routine/kind.d.ts +8 -0
  145. package/dist/core/format/src/kinds/routine/kind.js +25 -0
  146. package/dist/core/format/src/kinds/routine/schema.d.ts +84 -0
  147. package/dist/core/format/src/kinds/routine/schema.js +93 -0
  148. package/dist/core/format/src/kinds/runtime/kind.d.ts +4 -0
  149. package/dist/core/format/src/kinds/runtime/kind.js +13 -0
  150. package/dist/core/format/src/kinds/runtime/schema.d.ts +10 -0
  151. package/dist/core/format/src/kinds/runtime/schema.js +12 -0
  152. package/dist/core/format/src/kinds/skill/kind.d.ts +4 -0
  153. package/dist/core/format/src/kinds/skill/kind.js +10 -0
  154. package/dist/core/format/src/kinds/skill/schema.d.ts +17 -0
  155. package/dist/core/format/src/kinds/skill/schema.js +17 -0
  156. package/dist/core/format/src/kinds/skill/scripts-folder.d.ts +27 -0
  157. package/dist/core/format/src/kinds/skill/scripts-folder.js +37 -0
  158. package/dist/core/format/src/kinds/workflow/kind.d.ts +8 -0
  159. package/dist/core/format/src/kinds/workflow/kind.js +14 -0
  160. package/dist/core/format/src/kinds/workflow/schema.d.ts +162 -0
  161. package/dist/core/format/src/kinds/workflow/schema.js +106 -0
  162. package/dist/core/format/src/kinds/workflow-test/kind.d.ts +4 -0
  163. package/dist/core/format/src/kinds/workflow-test/kind.js +14 -0
  164. package/dist/core/format/src/kinds/workflow-test/schema.d.ts +67 -0
  165. package/dist/core/format/src/kinds/workflow-test/schema.js +59 -0
  166. package/dist/core/format/src/kinds/workspace/kind.d.ts +4 -0
  167. package/dist/core/format/src/kinds/workspace/kind.js +10 -0
  168. package/dist/core/format/src/kinds/workspace/schema.d.ts +72 -0
  169. package/dist/core/format/src/kinds/workspace/schema.js +66 -0
  170. package/dist/core/format/src/parse-file.d.ts +69 -0
  171. package/dist/core/format/src/parse-file.js +105 -0
  172. package/dist/core/format/src/recording/format.d.ts +81 -0
  173. package/dist/core/format/src/recording/format.js +102 -0
  174. package/dist/core/format/src/recording/index.d.ts +1 -0
  175. package/dist/core/format/src/recording/index.js +3 -0
  176. package/dist/core/format/src/registry.d.ts +64 -0
  177. package/dist/core/format/src/registry.js +61 -0
  178. package/dist/core/format/src/reserved.d.ts +20 -0
  179. package/dist/core/format/src/reserved.js +30 -0
  180. package/dist/core/format/src/shared/fields.d.ts +37 -0
  181. package/dist/core/format/src/shared/fields.js +54 -0
  182. package/dist/core/format/src/shared/guard.d.ts +32 -0
  183. package/dist/core/format/src/shared/guard.js +16 -0
  184. package/dist/core/format/src/shared/key-in-value.d.ts +28 -0
  185. package/dist/core/format/src/shared/key-in-value.js +82 -0
  186. package/dist/core/format/src/shared/legacy-keys.d.ts +8 -0
  187. package/dist/core/format/src/shared/legacy-keys.js +17 -0
  188. package/dist/core/format/src/shared/program-start.d.ts +60 -0
  189. package/dist/core/format/src/shared/program-start.js +99 -0
  190. package/dist/core/format/src/shared/relative-path.d.ts +29 -0
  191. package/dist/core/format/src/shared/relative-path.js +50 -0
  192. package/dist/core/format/src/shared/secret-name.d.ts +24 -0
  193. package/dist/core/format/src/shared/secret-name.js +107 -0
  194. package/dist/core/format/src/source.d.ts +16 -0
  195. package/dist/core/format/src/source.js +73 -0
  196. package/dist/core/ports/src/agent-placement-store.d.ts +74 -0
  197. package/dist/core/ports/src/agent-placement-store.js +27 -0
  198. package/dist/core/ports/src/blob-store.d.ts +33 -0
  199. package/dist/core/ports/src/blob-store.js +2 -0
  200. package/dist/core/ports/src/cant-try-error.d.ts +35 -0
  201. package/dist/core/ports/src/cant-try-error.js +44 -0
  202. package/dist/core/ports/src/chat.d.ts +127 -0
  203. package/dist/core/ports/src/chat.js +1 -0
  204. package/dist/core/ports/src/clock.d.ts +7 -0
  205. package/dist/core/ports/src/clock.js +2 -0
  206. package/dist/core/ports/src/connection-settings-store.d.ts +57 -0
  207. package/dist/core/ports/src/connection-settings-store.js +2 -0
  208. package/dist/core/ports/src/connector-client.d.ts +259 -0
  209. package/dist/core/ports/src/connector-client.js +2 -0
  210. package/dist/core/ports/src/coordination.d.ts +84 -0
  211. package/dist/core/ports/src/coordination.js +2 -0
  212. package/dist/core/ports/src/definition-store.d.ts +208 -0
  213. package/dist/core/ports/src/definition-store.js +122 -0
  214. package/dist/core/ports/src/digest.d.ts +14 -0
  215. package/dist/core/ports/src/digest.js +2 -0
  216. package/dist/core/ports/src/folder-reader.d.ts +89 -0
  217. package/dist/core/ports/src/folder-reader.js +2 -0
  218. package/dist/core/ports/src/harness-bridge-server.d.ts +189 -0
  219. package/dist/core/ports/src/harness-bridge-server.js +37 -0
  220. package/dist/core/ports/src/harness.d.ts +250 -0
  221. package/dist/core/ports/src/harness.js +45 -0
  222. package/dist/core/ports/src/http-client.d.ts +27 -0
  223. package/dist/core/ports/src/http-client.js +2 -0
  224. package/dist/core/ports/src/id-generator.d.ts +14 -0
  225. package/dist/core/ports/src/id-generator.js +2 -0
  226. package/dist/core/ports/src/index.d.ts +37 -0
  227. package/dist/core/ports/src/index.js +36 -0
  228. package/dist/core/ports/src/integration.d.ts +178 -0
  229. package/dist/core/ports/src/integration.js +13 -0
  230. package/dist/core/ports/src/knowledge-provider.d.ts +65 -0
  231. package/dist/core/ports/src/knowledge-provider.js +2 -0
  232. package/dist/core/ports/src/llm-cache.d.ts +13 -0
  233. package/dist/core/ports/src/llm-cache.js +2 -0
  234. package/dist/core/ports/src/llm-provider.d.ts +184 -0
  235. package/dist/core/ports/src/llm-provider.js +136 -0
  236. package/dist/core/ports/src/model-price.d.ts +34 -0
  237. package/dist/core/ports/src/model-price.js +25 -0
  238. package/dist/core/ports/src/password-hasher.d.ts +47 -0
  239. package/dist/core/ports/src/password-hasher.js +2 -0
  240. package/dist/core/ports/src/plugin-folder-writer.d.ts +104 -0
  241. package/dist/core/ports/src/plugin-folder-writer.js +95 -0
  242. package/dist/core/ports/src/port-versions.d.ts +44 -0
  243. package/dist/core/ports/src/port-versions.js +74 -0
  244. package/dist/core/ports/src/program-probe.d.ts +46 -0
  245. package/dist/core/ports/src/program-probe.js +2 -0
  246. package/dist/core/ports/src/record-store.d.ts +62 -0
  247. package/dist/core/ports/src/record-store.js +38 -0
  248. package/dist/core/ports/src/resource-probe.d.ts +59 -0
  249. package/dist/core/ports/src/resource-probe.js +2 -0
  250. package/dist/core/ports/src/run-executor.d.ts +302 -0
  251. package/dist/core/ports/src/run-executor.js +2 -0
  252. package/dist/core/ports/src/run-failure-error.d.ts +49 -0
  253. package/dist/core/ports/src/run-failure-error.js +47 -0
  254. package/dist/core/ports/src/run-store.d.ts +194 -0
  255. package/dist/core/ports/src/run-store.js +131 -0
  256. package/dist/core/ports/src/sandbox.d.ts +247 -0
  257. package/dist/core/ports/src/sandbox.js +34 -0
  258. package/dist/core/ports/src/scheduler.d.ts +85 -0
  259. package/dist/core/ports/src/scheduler.js +2 -0
  260. package/dist/core/ports/src/secrets.d.ts +128 -0
  261. package/dist/core/ports/src/secrets.js +144 -0
  262. package/dist/core/ports/src/token-store.d.ts +19 -0
  263. package/dist/core/ports/src/token-store.js +2 -0
  264. package/dist/core/ports/src/tool-approval-store.d.ts +211 -0
  265. package/dist/core/ports/src/tool-approval-store.js +57 -0
  266. package/dist/core/ports/src/trust-store.d.ts +72 -0
  267. package/dist/core/ports/src/trust-store.js +2 -0
  268. package/dist/core/ports/src/unfenced-run-consent-store.d.ts +43 -0
  269. package/dist/core/ports/src/unfenced-run-consent-store.js +2 -0
  270. package/dist/core/ports/src/vcs.d.ts +394 -0
  271. package/dist/core/ports/src/vcs.js +48 -0
  272. package/dist/core/schema-kit/src/builders.d.ts +50 -0
  273. package/dist/core/schema-kit/src/builders.js +72 -0
  274. package/dist/core/schema-kit/src/depth.d.ts +15 -0
  275. package/dist/core/schema-kit/src/depth.js +37 -0
  276. package/dist/core/schema-kit/src/index.d.ts +6 -0
  277. package/dist/core/schema-kit/src/index.js +6 -0
  278. package/dist/core/schema-kit/src/issue.d.ts +22 -0
  279. package/dist/core/schema-kit/src/issue.js +23 -0
  280. package/dist/core/schema-kit/src/json-schema.d.ts +23 -0
  281. package/dist/core/schema-kit/src/json-schema.js +22 -0
  282. package/dist/core/schema-kit/src/parse.d.ts +17 -0
  283. package/dist/core/schema-kit/src/parse.js +25 -0
  284. package/dist/core/schema-kit/src/schema.d.ts +12 -0
  285. package/dist/core/schema-kit/src/schema.js +1 -0
  286. package/dist/core/std/src/ascii-host.d.ts +18 -0
  287. package/dist/core/std/src/ascii-host.js +110 -0
  288. package/dist/core/std/src/assert.d.ts +39 -0
  289. package/dist/core/std/src/assert.js +59 -0
  290. package/dist/core/std/src/base64url.d.ts +23 -0
  291. package/dist/core/std/src/base64url.js +65 -0
  292. package/dist/core/std/src/canonical-json.d.ts +18 -0
  293. package/dist/core/std/src/canonical-json.js +56 -0
  294. package/dist/core/std/src/clock.d.ts +27 -0
  295. package/dist/core/std/src/clock.js +33 -0
  296. package/dist/core/std/src/constant-time.d.ts +16 -0
  297. package/dist/core/std/src/constant-time.js +26 -0
  298. package/dist/core/std/src/content-digest.d.ts +24 -0
  299. package/dist/core/std/src/content-digest.js +28 -0
  300. package/dist/core/std/src/deep-clone.d.ts +15 -0
  301. package/dist/core/std/src/deep-clone.js +59 -0
  302. package/dist/core/std/src/deep-equal.d.ts +23 -0
  303. package/dist/core/std/src/deep-equal.js +64 -0
  304. package/dist/core/std/src/emitter.d.ts +42 -0
  305. package/dist/core/std/src/emitter.js +74 -0
  306. package/dist/core/std/src/error-kind.d.ts +88 -0
  307. package/dist/core/std/src/error-kind.js +98 -0
  308. package/dist/core/std/src/hex.d.ts +10 -0
  309. package/dist/core/std/src/hex.js +16 -0
  310. package/dist/core/std/src/ids.d.ts +45 -0
  311. package/dist/core/std/src/ids.js +49 -0
  312. package/dist/core/std/src/index.d.ts +25 -0
  313. package/dist/core/std/src/index.js +26 -0
  314. package/dist/core/std/src/keyed-queue.d.ts +18 -0
  315. package/dist/core/std/src/keyed-queue.js +32 -0
  316. package/dist/core/std/src/line-diff.d.ts +83 -0
  317. package/dist/core/std/src/line-diff.js +179 -0
  318. package/dist/core/std/src/line-merge.d.ts +63 -0
  319. package/dist/core/std/src/line-merge.js +138 -0
  320. package/dist/core/std/src/plain-data.d.ts +32 -0
  321. package/dist/core/std/src/plain-data.js +57 -0
  322. package/dist/core/std/src/posix-path.d.ts +61 -0
  323. package/dist/core/std/src/posix-path.js +121 -0
  324. package/dist/core/std/src/result.d.ts +55 -0
  325. package/dist/core/std/src/result.js +52 -0
  326. package/dist/core/std/src/secret-scrubber.d.ts +54 -0
  327. package/dist/core/std/src/secret-scrubber.js +124 -0
  328. package/dist/core/std/src/secret-shape.d.ts +20 -0
  329. package/dist/core/std/src/secret-shape.js +53 -0
  330. package/dist/core/std/src/stop-signal.d.ts +44 -0
  331. package/dist/core/std/src/stop-signal.js +77 -0
  332. package/dist/core/std/src/text.d.ts +28 -0
  333. package/dist/core/std/src/text.js +54 -0
  334. package/dist/core/std/src/utf8.d.ts +23 -0
  335. package/dist/core/std/src/utf8.js +110 -0
  336. package/dist/core/std/src/version.d.ts +48 -0
  337. package/dist/core/std/src/version.js +103 -0
  338. package/dist/core/yaml/src/depth.d.ts +14 -0
  339. package/dist/core/yaml/src/depth.js +140 -0
  340. package/dist/core/yaml/src/edit-data.d.ts +47 -0
  341. package/dist/core/yaml/src/edit-data.js +286 -0
  342. package/dist/core/yaml/src/edit-text.d.ts +92 -0
  343. package/dist/core/yaml/src/edit-text.js +267 -0
  344. package/dist/core/yaml/src/edit.d.ts +47 -0
  345. package/dist/core/yaml/src/edit.js +198 -0
  346. package/dist/core/yaml/src/index.d.ts +5 -0
  347. package/dist/core/yaml/src/index.js +4 -0
  348. package/dist/core/yaml/src/problem.d.ts +20 -0
  349. package/dist/core/yaml/src/problem.js +1 -0
  350. package/dist/core/yaml/src/read.d.ts +47 -0
  351. package/dist/core/yaml/src/read.js +130 -0
  352. package/dist/core/yaml/src/splice-node.d.ts +47 -0
  353. package/dist/core/yaml/src/splice-node.js +333 -0
  354. package/dist/core/yaml/src/splice.d.ts +13 -0
  355. package/dist/core/yaml/src/splice.js +174 -0
  356. package/dist/core/yaml/src/unsupported.d.ts +26 -0
  357. package/dist/core/yaml/src/unsupported.js +70 -0
  358. package/dist/core/yaml/src/write.d.ts +35 -0
  359. package/dist/core/yaml/src/write.js +44 -0
  360. package/dist/testing/integration/src/canaries.d.ts +14 -0
  361. package/dist/testing/integration/src/canaries.js +17 -0
  362. package/dist/testing/integration/src/checks.d.ts +37 -0
  363. package/dist/testing/integration/src/checks.js +195 -0
  364. package/dist/testing/integration/src/describe.d.ts +35 -0
  365. package/dist/testing/integration/src/describe.js +74 -0
  366. package/dist/testing/integration/src/failure.d.ts +6 -0
  367. package/dist/testing/integration/src/failure.js +8 -0
  368. package/dist/testing/integration/src/fake-wait.d.ts +18 -0
  369. package/dist/testing/integration/src/fake-wait.js +21 -0
  370. package/dist/testing/integration/src/index.d.ts +10 -0
  371. package/dist/testing/integration/src/index.js +11 -0
  372. package/dist/testing/integration/src/load.d.ts +14 -0
  373. package/dist/testing/integration/src/load.js +45 -0
  374. package/dist/testing/integration/src/plugin-folder.d.ts +23 -0
  375. package/dist/testing/integration/src/plugin-folder.js +59 -0
  376. package/dist/testing/integration/src/plugin.d.ts +32 -0
  377. package/dist/testing/integration/src/plugin.js +57 -0
  378. package/dist/testing/integration/src/recording.d.ts +84 -0
  379. package/dist/testing/integration/src/recording.js +164 -0
  380. package/dist/testing/integration/src/run.d.ts +60 -0
  381. package/dist/testing/integration/src/run.js +81 -0
  382. package/dist/testing/integration/src/source-scan.d.ts +16 -0
  383. package/dist/testing/integration/src/source-scan.js +40 -0
  384. package/package.json +34 -3
@@ -0,0 +1,61 @@
1
+ import { agentKind } from "./kinds/agent/kind.js";
2
+ import { collectionKind } from "./kinds/collection/kind.js";
3
+ import { connectorKind } from "./kinds/connector/kind.js";
4
+ import { deploymentsKind } from "./kinds/deployments/kind.js";
5
+ import { hubKind } from "./kinds/hub/kind.js";
6
+ import { integrationKind } from "./kinds/integration/kind.js";
7
+ import { knowledgeKind } from "./kinds/knowledge/kind.js";
8
+ import { modelsKind } from "./kinds/models/kind.js";
9
+ import { pluginKind } from "./kinds/plugin/kind.js";
10
+ import { providerKind } from "./kinds/provider/kind.js";
11
+ import { routineKind } from "./kinds/routine/kind.js";
12
+ import { runtimeKind } from "./kinds/runtime/kind.js";
13
+ import { skillKind } from "./kinds/skill/kind.js";
14
+ import { workflowKind } from "./kinds/workflow/kind.js";
15
+ import { workflowTestKind } from "./kinds/workflow-test/kind.js";
16
+ import { workspaceKind } from "./kinds/workspace/kind.js";
17
+ /**
18
+ * Every file kind, by name. Adding a kind means adding its folder under
19
+ * `kinds/` and one line here; the loader and the tooling read this list
20
+ * instead of switching on kind names.
21
+ */
22
+ export const fileKinds = {
23
+ workspace: workspaceKind,
24
+ deployments: deploymentsKind,
25
+ models: modelsKind,
26
+ provider: providerKind,
27
+ runtime: runtimeKind,
28
+ knowledge: knowledgeKind,
29
+ collection: collectionKind,
30
+ connector: connectorKind,
31
+ skill: skillKind,
32
+ hub: hubKind,
33
+ agent: agentKind,
34
+ workflow: workflowKind,
35
+ workflowTest: workflowTestKind,
36
+ routine: routineKind,
37
+ integration: integrationKind,
38
+ plugin: pluginKind,
39
+ };
40
+ /**
41
+ * The names of every file kind, workspace-level kinds first and the
42
+ * integration sheet and the plugin manifest, which sit outside workspaces,
43
+ * last, in a fixed order.
44
+ *
45
+ * @example
46
+ * for (const name of kindNames()) console.log(name, fileKinds[name].about);
47
+ */
48
+ export function kindNames() {
49
+ return Object.keys(fileKinds);
50
+ }
51
+ /**
52
+ * Whether a text names a file kind, for input from outside such as a CLI
53
+ * argument.
54
+ *
55
+ * @example
56
+ * isKindName("agent"); // true
57
+ * isKindName("toString"); // false
58
+ */
59
+ export function isKindName(name) {
60
+ return Object.hasOwn(fileKinds, name);
61
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * The folder Halonic keeps for its own data inside a workspace and inside
3
+ * each hub: install records, staging and change sets. It holds no workspace
4
+ * files, so the loader skips it without a warning (format.reserved-folder).
5
+ */
6
+ export declare const RESERVED_FOLDER = ".halonic";
7
+ /**
8
+ * Whether a workspace-relative path (with `/` separators) sits in the
9
+ * reserved `.halonic/` folder of the workspace root or of a hub. Names
10
+ * compare the way Windows and macOS open them, as `segmentAsOpened` gives
11
+ * them: case folded, without trailing dots and spaces and without the code
12
+ * points HFS+ ignores. So `.Halonic./x` and `HUBS/billing/.HALONIC/x` are
13
+ * reserved too, since they open the same folder.
14
+ *
15
+ * @example
16
+ * isReservedPath("hubs/billing/.halonic/source.json"); // true
17
+ * isReservedPath(".Halonic./staging/abc/hub.yaml"); // true
18
+ * isReservedPath("hubs/billing/agents/clerk.agent.yaml"); // false
19
+ */
20
+ export declare function isReservedPath(path: string): boolean;
@@ -0,0 +1,30 @@
1
+ import { segmentAsOpened } from "../../ports/src/index.js";
2
+ /**
3
+ * The folder Halonic keeps for its own data inside a workspace and inside
4
+ * each hub: install records, staging and change sets. It holds no workspace
5
+ * files, so the loader skips it without a warning (format.reserved-folder).
6
+ */
7
+ export const RESERVED_FOLDER = ".halonic";
8
+ /**
9
+ * Whether a workspace-relative path (with `/` separators) sits in the
10
+ * reserved `.halonic/` folder of the workspace root or of a hub. Names
11
+ * compare the way Windows and macOS open them, as `segmentAsOpened` gives
12
+ * them: case folded, without trailing dots and spaces and without the code
13
+ * points HFS+ ignores. So `.Halonic./x` and `HUBS/billing/.HALONIC/x` are
14
+ * reserved too, since they open the same folder.
15
+ *
16
+ * @example
17
+ * isReservedPath("hubs/billing/.halonic/source.json"); // true
18
+ * isReservedPath(".Halonic./staging/abc/hub.yaml"); // true
19
+ * isReservedPath("hubs/billing/agents/clerk.agent.yaml"); // false
20
+ */
21
+ export function isReservedPath(path) {
22
+ const [first = "", hub = "", inHub = ""] = path.split("/");
23
+ if (opensAsReservedFolder(first)) {
24
+ return true;
25
+ }
26
+ return segmentAsOpened(first) === "hubs" && hub !== "" && opensAsReservedFolder(inHub);
27
+ }
28
+ function opensAsReservedFolder(segment) {
29
+ return segmentAsOpened(segment) === RESERVED_FOLDER;
30
+ }
@@ -0,0 +1,37 @@
1
+ /** The file format version every kind's `version` key holds. */
2
+ export declare const SCHEMA_VERSION: 1;
3
+ /** An item's id: lowercase letters, digits, `-` and `_`, starting with a letter or digit. */
4
+ export declare const id: import("zod").ZodString;
5
+ /**
6
+ * A deployment's id: an {@link id} of at most 64 characters that isn't a
7
+ * Windows device name, because it names the deployment's runs folder.
8
+ * The device names are refused through a pattern, not a refinement, so the
9
+ * JSON Schema carries the rule too.
10
+ */
11
+ export declare const deploymentId: import("zod").ZodString;
12
+ /**
13
+ * A workspace collection's id: lowercase letters, digits and `-`, starting
14
+ * with a letter or digit. Halonic's own collections (`_tokens`,
15
+ * `_google_setups`) start with `_`, so no workspace file can name them.
16
+ * The scheduler's and coordination's collections (`halonic.scheduler.timers`,
17
+ * `halonic.coordination`) are kept out by the `.` instead, so keep a `.` in
18
+ * their names.
19
+ */
20
+ export declare const collectionId: import("zod").ZodString;
21
+ /** The `version` key: `1`, and `1` when the file leaves it out. */
22
+ export declare const version: import("zod").ZodDefault<import("zod").ZodLiteral<1>>;
23
+ /** A whole number and a unit: minutes, hours or days ("30m", "4h", "2d"). */
24
+ export declare const DURATION_PATTERN: RegExp;
25
+ /** Tuning passed to a model (temperature, maxTokens, …). */
26
+ export declare const ModelParams: import("zod").ZodObject<{
27
+ temperature: import("zod").ZodOptional<import("zod").ZodNumber>;
28
+ topP: import("zod").ZodOptional<import("zod").ZodNumber>;
29
+ maxTokens: import("zod").ZodOptional<import("zod").ZodNumber>;
30
+ stop: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
31
+ reasoningEffort: import("zod").ZodOptional<import("zod").ZodEnum<{
32
+ high: "high";
33
+ low: "low";
34
+ medium: "medium";
35
+ }>>;
36
+ extra: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>;
37
+ }, import("zod/v4/core").$strict>;
@@ -0,0 +1,54 @@
1
+ // Field schemas that several file kinds share. Each keeps the exact rule and
2
+ // message of the old schema (784f78d: packages/core/schema/src/index.ts).
3
+ import { s } from "../../../schema-kit/src/index.js";
4
+ /** The file format version every kind's `version` key holds. */
5
+ export const SCHEMA_VERSION = 1;
6
+ /** An item's id: lowercase letters, digits, `-` and `_`, starting with a letter or digit. */
7
+ export const id = s
8
+ .string()
9
+ .min(1)
10
+ .regex(/^[a-z0-9][a-z0-9-_]*$/, "use lowercase letters, digits, '-' or '_'");
11
+ /**
12
+ * The most characters a deployment id may have. Each deployment's runs live
13
+ * in a folder named after it (`deployments/<id>/runs` in the profile), and
14
+ * 64 keeps that path well under Windows' 260-character limit.
15
+ */
16
+ const DEPLOYMENT_ID_MAX_LENGTH = 64;
17
+ /** Names Windows keeps for devices, as pattern alternatives; no file or folder can have them. */
18
+ const WINDOWS_DEVICE_NAMES = "con|prn|aux|nul|com[0-9]|lpt[0-9]";
19
+ /**
20
+ * A deployment's id: an {@link id} of at most 64 characters that isn't a
21
+ * Windows device name, because it names the deployment's runs folder.
22
+ * The device names are refused through a pattern, not a refinement, so the
23
+ * JSON Schema carries the rule too.
24
+ */
25
+ export const deploymentId = id
26
+ .max(DEPLOYMENT_ID_MAX_LENGTH, `use at most ${DEPLOYMENT_ID_MAX_LENGTH} characters, so the deployment's folder fits in a Windows path`)
27
+ .regex(new RegExp(`^(?!(?:${WINDOWS_DEVICE_NAMES})$)`), "use a name Windows doesn't keep for a device (con, prn, aux, nul, com0-com9, lpt0-lpt9)");
28
+ /**
29
+ * A workspace collection's id: lowercase letters, digits and `-`, starting
30
+ * with a letter or digit. Halonic's own collections (`_tokens`,
31
+ * `_google_setups`) start with `_`, so no workspace file can name them.
32
+ * The scheduler's and coordination's collections (`halonic.scheduler.timers`,
33
+ * `halonic.coordination`) are kept out by the `.` instead, so keep a `.` in
34
+ * their names.
35
+ */
36
+ export const collectionId = s
37
+ .string()
38
+ .regex(/^[a-z0-9][a-z0-9-]*$/, "use lowercase letters, digits or '-'");
39
+ /** The `version` key: `1`, and `1` when the file leaves it out. */
40
+ export const version = s.literal(SCHEMA_VERSION).default(SCHEMA_VERSION);
41
+ /** A whole number and a unit: minutes, hours or days ("30m", "4h", "2d"). */
42
+ export const DURATION_PATTERN = /^[1-9]\d*(m|h|d)$/;
43
+ /** Tuning passed to a model (temperature, maxTokens, …). */
44
+ export const ModelParams = s
45
+ .object({
46
+ temperature: s.number().min(0).max(2).optional(),
47
+ topP: s.number().min(0).max(1).optional(),
48
+ maxTokens: s.number().int().positive().optional(),
49
+ stop: s.array(s.string()).optional(),
50
+ reasoningEffort: s.enum(["low", "medium", "high"]).optional(),
51
+ /** Provider-specific extras, passed through untouched. */
52
+ extra: s.record(s.string(), s.unknown()).optional(),
53
+ })
54
+ .strict();
@@ -0,0 +1,32 @@
1
+ import { type Schema } from "../../../schema-kit/src/index.js";
2
+ /**
3
+ * A condition on a run's data, used by workflow transitions and signal
4
+ * routines. Values may be `{{path}}` templates.
5
+ */
6
+ export type Guard = {
7
+ equals: [unknown, unknown];
8
+ } | {
9
+ notEquals: [unknown, unknown];
10
+ } | {
11
+ contains: [unknown, unknown];
12
+ } | {
13
+ exists: string;
14
+ }
15
+ /** Numbers: both sides are read as numbers; a side that is no number makes the guard false. */
16
+ | {
17
+ gt: [unknown, unknown];
18
+ } | {
19
+ gte: [unknown, unknown];
20
+ } | {
21
+ lt: [unknown, unknown];
22
+ } | {
23
+ lte: [unknown, unknown];
24
+ } | {
25
+ not: Guard;
26
+ } | {
27
+ all: Guard[];
28
+ } | {
29
+ any: Guard[];
30
+ };
31
+ /** The schema of a `Guard`. It refers to itself for `not`, `all` and `any`. */
32
+ export declare const Guard: Schema<Guard>;
@@ -0,0 +1,16 @@
1
+ import { s } from "../../../schema-kit/src/index.js";
2
+ const pair = () => s.tuple([s.unknown(), s.unknown()]);
3
+ /** The schema of a `Guard`. It refers to itself for `not`, `all` and `any`. */
4
+ export const Guard = s.lazy(() => s.union([
5
+ s.object({ equals: pair() }).strict(),
6
+ s.object({ notEquals: pair() }).strict(),
7
+ s.object({ contains: pair() }).strict(),
8
+ s.object({ exists: s.string() }).strict(),
9
+ s.object({ gt: pair() }).strict(),
10
+ s.object({ gte: pair() }).strict(),
11
+ s.object({ lt: pair() }).strict(),
12
+ s.object({ lte: pair() }).strict(),
13
+ s.object({ not: Guard }).strict(),
14
+ s.object({ all: s.array(Guard) }).strict(),
15
+ s.object({ any: s.array(Guard) }).strict(),
16
+ ]));
@@ -0,0 +1,28 @@
1
+ import type { Path } from "../../../schema-kit/src/index.js";
2
+ import type { KindCheckProblem } from "../kind.js";
3
+ declare const words: {
4
+ readonly header: "This looks like an API key written into the file. Remove it, store the key as a secret, and write the secret's name in the connector's secret, which is sent as a bearer token.";
5
+ readonly env: "This looks like an API key written into the file. Remove it, store the key as a secret, and set this variable under secretEnv to the secret's name instead.";
6
+ readonly arg: "This looks like an API key written into the file. Remove it, store the key as a secret, and give it to the program through secretEnv instead of its arguments.";
7
+ readonly "provider-option": "This looks like an API key written into the file. Remove it, store the key as a secret, and write the secret's name in the provider's secret.";
8
+ readonly setting: "This looks like an API key written into the file. Remove it and store the key as a secret, so the file can be shared and committed safely.";
9
+ };
10
+ /** Which field the text sits in, which picks the advice in the message. */
11
+ export type KeyPlace = keyof typeof words;
12
+ /**
13
+ * Checks every text in a free field for a pasted key, down through nested
14
+ * maps and lists, and reports each one as the error `value-looks-like-key`
15
+ * at its own path. The message never repeats the value.
16
+ *
17
+ * @param value - the field's value from the file
18
+ * @param path - where the field sits in the file
19
+ * @param place - which advice the message gives
20
+ * @param name - the name the value sits under, when the field itself is one entry
21
+ * @returns one problem per text that holds a key
22
+ *
23
+ * @example
24
+ * checkKeysIn({ Authorization: `Bearer sk-${"Q7x2Lm9K".repeat(4)}` }, ["headers"], "header");
25
+ * // [{ code: "value-looks-like-key", path: ["headers", "Authorization"], … }]
26
+ */
27
+ export declare function checkKeysIn(value: unknown, path: Path, place: KeyPlace, name?: string): KindCheckProblem[];
28
+ export {};
@@ -0,0 +1,82 @@
1
+ import { findSecretShape } from "../../../std/src/index.js";
2
+ import { looksLikeKey } from "./secret-name.js";
3
+ /*
4
+ * A file holds only a secret's name, never the secret (save model 8.1). The
5
+ * fields checked here take any text: a connector's HTTP headers, a local
6
+ * program's `env` and `args`, and the adapter settings in `options` and
7
+ * `config`. Two tests catch a key pasted into one:
8
+ *
9
+ * - The known key formats `findSecretShape` spots, anywhere in the text, so
10
+ * `Bearer sk-…` and `--api-key=sk-…` are caught too.
11
+ * - Under a name that says it holds a credential (`Authorization`,
12
+ * `GITHUB_TOKEN`, `apiKey`), the full `looksLikeKey` test, once a leading
13
+ * `Bearer`, `Basic` or `Token` is dropped. Only a value made of key
14
+ * characters counts: without the name, or with a `.`, `:` or space left
15
+ * in it, the long-random-part test would also find addresses and paths
16
+ * such as `/opt/python3.12-tools`. A value that starts like a path
17
+ * (`/`, `./`, `../`, `~/`) is a path, such as `CREDENTIALS_DIR:
18
+ * /srv/runner/work/app2/creds`; a base64 key may hold a `/`, but doesn't
19
+ * start with one.
20
+ */
21
+ const credentialName = /token|secret|passw(?:or)?d|api[-_]?key|access[-_]?key|private[-_]?key|credential|authorization|^auth$/i;
22
+ const authScheme = /^(?:bearer|basic|token)\s+/i;
23
+ const keyCharacters = /^[A-Za-z0-9+/=_-]+$/;
24
+ const pathStart = /^(?:\/|\.\.?\/|~\/)/;
25
+ /**
26
+ * Whether a value in a free text field holds a key.
27
+ * Only the answer leaves the check; when it is `true`, never repeat the value.
28
+ *
29
+ * @param value - the text from the file
30
+ * @param name - the header, variable or setting the text belongs to
31
+ */
32
+ function holdsKey(value, name) {
33
+ if (findSecretShape(value) !== undefined) {
34
+ return true;
35
+ }
36
+ if (name === undefined || !credentialName.test(name)) {
37
+ return false;
38
+ }
39
+ const credential = value.trim().replace(authScheme, "");
40
+ return !pathStart.test(credential) && keyCharacters.test(credential) && looksLikeKey(credential);
41
+ }
42
+ /*
43
+ * The words wait on the board (HAL-2264, P8), like those in
44
+ * `secret-name.ts`. Each says where the secret's name goes instead.
45
+ */
46
+ const opening = "This looks like an API key written into the file.";
47
+ const words = {
48
+ header: `${opening} Remove it, store the key as a secret, and write the secret's name in the connector's secret, which is sent as a bearer token.`,
49
+ env: `${opening} Remove it, store the key as a secret, and set this variable under secretEnv to the secret's name instead.`,
50
+ arg: `${opening} Remove it, store the key as a secret, and give it to the program through secretEnv instead of its arguments.`,
51
+ "provider-option": `${opening} Remove it, store the key as a secret, and write the secret's name in the provider's secret.`,
52
+ setting: `${opening} Remove it and store the key as a secret, so the file can be shared and committed safely.`,
53
+ };
54
+ /**
55
+ * Checks every text in a free field for a pasted key, down through nested
56
+ * maps and lists, and reports each one as the error `value-looks-like-key`
57
+ * at its own path. The message never repeats the value.
58
+ *
59
+ * @param value - the field's value from the file
60
+ * @param path - where the field sits in the file
61
+ * @param place - which advice the message gives
62
+ * @param name - the name the value sits under, when the field itself is one entry
63
+ * @returns one problem per text that holds a key
64
+ *
65
+ * @example
66
+ * checkKeysIn({ Authorization: `Bearer sk-${"Q7x2Lm9K".repeat(4)}` }, ["headers"], "header");
67
+ * // [{ code: "value-looks-like-key", path: ["headers", "Authorization"], … }]
68
+ */
69
+ export function checkKeysIn(value, path, place, name) {
70
+ if (typeof value === "string") {
71
+ return holdsKey(value, name)
72
+ ? [{ severity: "error", code: "value-looks-like-key", path, message: words[place] }]
73
+ : [];
74
+ }
75
+ if (Array.isArray(value)) {
76
+ return value.flatMap((item, index) => checkKeysIn(item, [...path, index], place, name));
77
+ }
78
+ if (typeof value === "object" && value !== null) {
79
+ return Object.entries(value).flatMap(([key, item]) => checkKeysIn(item, [...path, key], place, key));
80
+ }
81
+ return [];
82
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Returns a copy of `map` with the key `oldName` read as `newName`, so files
3
+ * from before a rename keep loading. When the file already has `newName`,
4
+ * the old key stays as it is and the schema reports it as unknown.
5
+ */
6
+ export declare function renameKey(map: Readonly<Record<string, unknown>>, oldName: string, newName: string): Record<string, unknown>;
7
+ /** Whether a value is a plain map (not a list, not null). */
8
+ export declare function isMap(value: unknown): value is Readonly<Record<string, unknown>>;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Returns a copy of `map` with the key `oldName` read as `newName`, so files
3
+ * from before a rename keep loading. When the file already has `newName`,
4
+ * the old key stays as it is and the schema reports it as unknown.
5
+ */
6
+ export function renameKey(map, oldName, newName) {
7
+ if (!Object.hasOwn(map, oldName) || Object.hasOwn(map, newName)) {
8
+ return { ...map };
9
+ }
10
+ // fromEntries defines keys as plain properties, so a "__proto__" key in a
11
+ // file stays data instead of changing the copy's prototype.
12
+ return Object.fromEntries(Object.entries(map).map(([key, value]) => [key === oldName ? newName : key, value]));
13
+ }
14
+ /** Whether a value is a plain map (not a list, not null). */
15
+ export function isMap(value) {
16
+ return typeof value === "object" && value !== null && !Array.isArray(value);
17
+ }
@@ -0,0 +1,60 @@
1
+ /**
2
+ * How Halonic reads a program start for the paths it names. Three guards
3
+ * refuse a start by what it names: a skill's `scripts/` folder
4
+ * (`format.skill-scripts-folder`), and an agent's working folder, both as
5
+ * written in a workspace (`workspace.working-folders`) and on the real file
6
+ * system (`format.working-folder-start`). They read a start the same way, so
7
+ * a path one of them finds, the others find too (HAL-4777). Reading too much
8
+ * as a path only makes a guard stricter.
9
+ */
10
+ /** What a start would run: the program, its arguments, the folder it starts in and its environment. */
11
+ export interface ProgramStart {
12
+ readonly cwd: string;
13
+ readonly program: string;
14
+ readonly args: readonly string[];
15
+ /** The variables the program gets. Their values are read for paths; their names aren't. */
16
+ readonly env?: Readonly<Record<string, string>>;
17
+ }
18
+ /** A path a start names. */
19
+ export interface NamedPath {
20
+ /** The path as written. A relative path is read from the start folder. */
21
+ readonly path: string;
22
+ /** The program, argument or `NAME=value` it comes from, for a message. */
23
+ readonly shown: string;
24
+ }
25
+ /**
26
+ * The paths a start names, besides the folder it starts in: the program,
27
+ * every path each argument names (see {@link pathsIn}), the folder path of a
28
+ * module that `python -m` runs (see {@link moduleIn}) and every path an `env`
29
+ * value names. The start folder isn't listed, as each guard reads it on its
30
+ * own terms.
31
+ *
32
+ * @example
33
+ * pathsNamedBy({ cwd: ".", program: "node", args: ["--config=tools/mail.json"] });
34
+ * // [{ path: "node", shown: "node" },
35
+ * // { path: "--config=tools/mail.json", shown: "--config=tools/mail.json" },
36
+ * // { path: "--config", shown: "--config=tools/mail.json" },
37
+ * // { path: "tools/mail.json", shown: "--config=tools/mail.json" }]
38
+ */
39
+ export declare function pathsNamedBy({ program, args, env }: ProgramStart): NamedPath[];
40
+ /**
41
+ * The paths an argument or `env` value may name: the whole text, each piece
42
+ * between `;` and spaces (a Windows `PATH` keeps its drive letters), each
43
+ * piece between `=`, `:`, `;`, `@` and spaces (as in
44
+ * `--config=tools/mail.json`, `--define=KEY=tools/x`, `PATH=tools/bin:/usr/bin`,
45
+ * `file:tools/x` or `@tools/args.txt`), the whole text after each `=`, `:`
46
+ * and `@` (so `--file=my link` still names `my link`), the whole text inside
47
+ * each pair of quotes (as in `--require "my tools/x.js"`), each piece without
48
+ * its quotes (HAL-4903), and each piece without its short flag, as in
49
+ * `-ctools/mail.json`.
50
+ */
51
+ export declare function pathsIn(text: string): string[];
52
+ /**
53
+ * The folder paths of a module that `python -m` runs, from the argument at
54
+ * `index`: `-m tools.mail`, `-mtools.mail` and, with `-m` among other short
55
+ * flags, `-Im tools.mail` or `-Imtools.mail` read `tools/mail`. Both readings
56
+ * are kept: in `-Wm -mtools.mail`, the argument is read as a module after
57
+ * `-Wm` and as `-m` with its module, so a guard never reads less than before
58
+ * (HAL-4903). Empty when that argument names no module.
59
+ */
60
+ export declare function moduleIn(args: readonly string[], index: number): string[];
@@ -0,0 +1,99 @@
1
+ /**
2
+ * How Halonic reads a program start for the paths it names. Three guards
3
+ * refuse a start by what it names: a skill's `scripts/` folder
4
+ * (`format.skill-scripts-folder`), and an agent's working folder, both as
5
+ * written in a workspace (`workspace.working-folders`) and on the real file
6
+ * system (`format.working-folder-start`). They read a start the same way, so
7
+ * a path one of them finds, the others find too (HAL-4777). Reading too much
8
+ * as a path only makes a guard stricter.
9
+ */
10
+ /**
11
+ * The paths a start names, besides the folder it starts in: the program,
12
+ * every path each argument names (see {@link pathsIn}), the folder path of a
13
+ * module that `python -m` runs (see {@link moduleIn}) and every path an `env`
14
+ * value names. The start folder isn't listed, as each guard reads it on its
15
+ * own terms.
16
+ *
17
+ * @example
18
+ * pathsNamedBy({ cwd: ".", program: "node", args: ["--config=tools/mail.json"] });
19
+ * // [{ path: "node", shown: "node" },
20
+ * // { path: "--config=tools/mail.json", shown: "--config=tools/mail.json" },
21
+ * // { path: "--config", shown: "--config=tools/mail.json" },
22
+ * // { path: "tools/mail.json", shown: "--config=tools/mail.json" }]
23
+ */
24
+ export function pathsNamedBy({ program, args, env = {} }) {
25
+ const named = (shown, paths) => paths.map((path) => ({ path, shown }));
26
+ return [
27
+ { path: program, shown: program },
28
+ ...args.flatMap((arg, index) => named(arg, [...pathsIn(arg), ...moduleIn(args, index)])),
29
+ ...Object.entries(env).flatMap(([name, value]) => named(`${name}=${value}`, pathsIn(value))),
30
+ ];
31
+ }
32
+ /**
33
+ * The paths an argument or `env` value may name: the whole text, each piece
34
+ * between `;` and spaces (a Windows `PATH` keeps its drive letters), each
35
+ * piece between `=`, `:`, `;`, `@` and spaces (as in
36
+ * `--config=tools/mail.json`, `--define=KEY=tools/x`, `PATH=tools/bin:/usr/bin`,
37
+ * `file:tools/x` or `@tools/args.txt`), the whole text after each `=`, `:`
38
+ * and `@` (so `--file=my link` still names `my link`), the whole text inside
39
+ * each pair of quotes (as in `--require "my tools/x.js"`), each piece without
40
+ * its quotes (HAL-4903), and each piece without its short flag, as in
41
+ * `-ctools/mail.json`.
42
+ */
43
+ export function pathsIn(text) {
44
+ const pieces = [
45
+ text,
46
+ ...text.split(/[;\s]+/),
47
+ ...text.split(/[=:;@\s]+/),
48
+ ...textsAfter(/[=:@]/g, text),
49
+ ...textsInQuotes(text),
50
+ ];
51
+ const withoutQuotes = pieces.flatMap((piece) => [piece, piece.replaceAll(/["']/g, "")]);
52
+ const withoutFlags = withoutQuotes.flatMap((piece) => /^-[^-]./.test(piece) ? [piece, piece.slice(2)] : [piece]);
53
+ return [...new Set(withoutFlags.filter((piece) => piece !== ""))];
54
+ }
55
+ /** The whole text after each match of `separator`: `a=b:c` gives `b:c` and `c` for `/[=:]/g`. */
56
+ function textsAfter(separator, text) {
57
+ return [...text.matchAll(separator)].map((match) => text.slice(match.index + 1));
58
+ }
59
+ /**
60
+ * The text inside each pair of `"` and each pair of `'`: `--require "my x.js"`
61
+ * gives `my x.js`. The two kinds are paired in separate passes, so a stray
62
+ * apostrophe, as in `it's --require "my x.js"`, can't hide a double-quoted
63
+ * path (HAL-4903). A quote escaped with `\` inside quotes isn't read as part
64
+ * of the path; that needs a path with quotes and spaces in its name.
65
+ */
66
+ function textsInQuotes(text) {
67
+ const inPairsOf = (quote) => [...text.matchAll(new RegExp(`${quote}([^${quote}]*)${quote}`, "g"))].map((match) => match[1] ?? "");
68
+ return [...inPairsOf('"'), ...inPairsOf("'")];
69
+ }
70
+ /**
71
+ * The folder paths of a module that `python -m` runs, from the argument at
72
+ * `index`: `-m tools.mail`, `-mtools.mail` and, with `-m` among other short
73
+ * flags, `-Im tools.mail` or `-Imtools.mail` read `tools/mail`. Both readings
74
+ * are kept: in `-Wm -mtools.mail`, the argument is read as a module after
75
+ * `-Wm` and as `-m` with its module, so a guard never reads less than before
76
+ * (HAL-4903). Empty when that argument names no module.
77
+ */
78
+ export function moduleIn(args, index) {
79
+ return moduleNames(args[index - 1], args[index] ?? "").map((name) => name.replaceAll(".", "/"));
80
+ }
81
+ /** The modules an argument names: after a `-m` before it, and after its own `-m`. */
82
+ function moduleNames(before, arg) {
83
+ const afterFlagBefore = before !== undefined && textAfterShortM(before) === "" ? arg : "";
84
+ const afterOwnFlag = textAfterShortM(arg) ?? "";
85
+ return [...new Set([afterFlagBefore, afterOwnFlag].filter((name) => name !== ""))];
86
+ }
87
+ /**
88
+ * The text after the first `m` in a group of short flags, as Python reads
89
+ * one: `-Imtools.mail` gives `tools.mail`, and `-Im` gives an empty text, as
90
+ * the module is the next argument. Undefined when the argument isn't a group
91
+ * of short flags or has no `m`. A flag that takes a value, as in `-Xdev`, may
92
+ * read a stray module; that only makes a guard stricter.
93
+ */
94
+ function textAfterShortM(arg) {
95
+ if (!/^-[^-]/.test(arg))
96
+ return undefined;
97
+ const at = arg.indexOf("m", 1);
98
+ return at === -1 ? undefined : arg.slice(at + 1);
99
+ }
@@ -0,0 +1,29 @@
1
+ /** The words a message uses for the folder a path must stay in, and for one part of it. */
2
+ export type PathPlace = {
3
+ /** The folder the path is relative to, such as `the workspace`. */
4
+ readonly root: string;
5
+ /** What one part of the path is, such as `folder name`. */
6
+ readonly part: string;
7
+ };
8
+ /**
9
+ * A name as a case-insensitive file system sees it: compatibility forms
10
+ * folded (`hubs` is `hubs`) and case folded (`ſ` and `S` are `s`).
11
+ *
12
+ * @example
13
+ * foldName(".GIT"); // ".git"
14
+ */
15
+ export declare function foldName(name: string): string;
16
+ /**
17
+ * Why a path can't be used inside `place`, or `null` when it can. It must be
18
+ * relative, with `/` between its parts, and stay inside the folder. Parts
19
+ * that Windows or macOS would read as another name are refused too: a
20
+ * trailing `.` or space, a `:` (a drive or an NTFS stream), an 8.3 short name
21
+ * such as `GIT~1`, control characters and invisible code points. The checks
22
+ * run on the path after {@link foldName}, so `agents./x` fails like
23
+ * `agents./x`. Symlinks are resolved later, when the program starts.
24
+ *
25
+ * @param path - the path as written in the file
26
+ * @param place - the words the message uses
27
+ * @returns a message, or `null`
28
+ */
29
+ export declare function relativePathProblem(path: string, place: PathPlace): string | null;
@@ -0,0 +1,50 @@
1
+ // The rules for a path that must stay inside one folder: an agent's working
2
+ // folder in the workspace, or a file in a plugin's folder. They decide what a
3
+ // program on the person's computer can touch, so one set of rules serves both.
4
+ /**
5
+ * A name as a case-insensitive file system sees it: compatibility forms
6
+ * folded (`hubs` is `hubs`) and case folded (`ſ` and `S` are `s`).
7
+ *
8
+ * @example
9
+ * foldName(".GIT"); // ".git"
10
+ */
11
+ export function foldName(name) {
12
+ return name.normalize("NFKC").toUpperCase().toLowerCase();
13
+ }
14
+ /**
15
+ * Why a path can't be used inside `place`, or `null` when it can. It must be
16
+ * relative, with `/` between its parts, and stay inside the folder. Parts
17
+ * that Windows or macOS would read as another name are refused too: a
18
+ * trailing `.` or space, a `:` (a drive or an NTFS stream), an 8.3 short name
19
+ * such as `GIT~1`, control characters and invisible code points. The checks
20
+ * run on the path after {@link foldName}, so `agents./x` fails like
21
+ * `agents./x`. Symlinks are resolved later, when the program starts.
22
+ *
23
+ * @param path - the path as written in the file
24
+ * @param place - the words the message uses
25
+ * @returns a message, or `null`
26
+ */
27
+ export function relativePathProblem(path, place) {
28
+ if (/[\p{Cc}\p{Default_Ignorable_Code_Point}]/u.test(path)) {
29
+ return `Don't use control characters or invisible characters in a ${place.part}`;
30
+ }
31
+ const folded = foldName(path);
32
+ if (folded.includes("\\"))
33
+ return "Use '/' between folders";
34
+ if (folded.startsWith("/") || /^[a-z]:/.test(folded)) {
35
+ return `Use a path relative to ${place.root}`;
36
+ }
37
+ if (folded.includes(":"))
38
+ return `Don't use ':' in a ${place.part}`;
39
+ const parts = folded.split("/");
40
+ if (parts.some((part) => part === "" || part === "." || part === "..")) {
41
+ return `Use a path inside ${place.root}, without '.', '..' or empty parts`;
42
+ }
43
+ if (parts.some((part) => /[. ]$/.test(part))) {
44
+ return `Don't end a ${place.part} with '.' or a space`;
45
+ }
46
+ if (parts.some((part) => /~\d/.test(part))) {
47
+ return "Don't use '~' followed by a digit: Windows reads it as a short name";
48
+ }
49
+ return null;
50
+ }