@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,63 @@
1
+ import { deniedPathGroupCodes, } from "./sandbox-opened.js";
2
+ const strengths = ["os", "vm", "remote"];
3
+ const groupCodes = deniedPathGroupCodes;
4
+ /** A list of strings, or `null` when the value is anything else. */
5
+ function stringsOf(value) {
6
+ if (!Array.isArray(value))
7
+ return null;
8
+ if (!value.every((item) => typeof item === "string"))
9
+ return null;
10
+ return [...value];
11
+ }
12
+ /** A list of group codes, or `null` when the value holds anything else. */
13
+ function groupCodesOf(value) {
14
+ const codes = stringsOf(value);
15
+ if (codes === null)
16
+ return null;
17
+ if (!codes.every((code) => groupCodes.includes(code)))
18
+ return null;
19
+ return codes;
20
+ }
21
+ /**
22
+ * Reads the `sandbox` of a stored `sandbox.opened` event (requirement
23
+ * `events.sandbox-opened`). It never throws: a value that is damaged, from
24
+ * another version or missing a field gives `null`, so a screen says it
25
+ * couldn't read what the step could do instead of showing part of it. It
26
+ * copies only the view's fields, so an extra field in a damaged log never
27
+ * reaches a screen either.
28
+ *
29
+ * @param value - the event's `sandbox`, as parsed from the log
30
+ * @returns the view, or `null` when it can't be read
31
+ *
32
+ * @example
33
+ * readSandboxOpened({ strength: "os", workingFolder: "~/work", ... }); // => { strength: "os", ... }
34
+ * readSandboxOpened("damaged"); // => null
35
+ */
36
+ export function readSandboxOpened(value) {
37
+ if (typeof value !== "object" || value === null)
38
+ return null;
39
+ const fields = value;
40
+ const { strength, workingFolder, timeLimitMs } = fields;
41
+ const readOnlyPaths = stringsOf(fields.readOnlyPaths);
42
+ const deniedGroups = groupCodesOf(fields.deniedGroups);
43
+ const deniedPaths = stringsOf(fields.deniedPaths);
44
+ const allowedSites = stringsOf(fields.allowedSites);
45
+ if (!strengths.includes(strength) || typeof workingFolder !== "string")
46
+ return null;
47
+ if (typeof timeLimitMs !== "number" || !Number.isFinite(timeLimitMs) || timeLimitMs < 0) {
48
+ return null;
49
+ }
50
+ if (readOnlyPaths === null || deniedGroups === null)
51
+ return null;
52
+ if (deniedPaths === null || allowedSites === null)
53
+ return null;
54
+ return {
55
+ strength: strength,
56
+ workingFolder,
57
+ readOnlyPaths,
58
+ deniedGroups,
59
+ deniedPaths,
60
+ allowedSites,
61
+ timeLimitMs,
62
+ };
63
+ }
@@ -0,0 +1,94 @@
1
+ /**
2
+ * How strong a sandbox's fence is, as the `Sandbox` port's `capabilities()`
3
+ * gives it: `os` (the operating system confines the program), `vm` (a
4
+ * micro-VM) or `remote` (another machine).
5
+ */
6
+ export type SandboxStrength = "os" | "vm" | "remote";
7
+ /**
8
+ * The codes of the groups of paths a sandbox denies: the person's SSH keys,
9
+ * their cloud sign-ins, browser data, password stores, Halonic's own data and
10
+ * other agents' settings (such as `~/.claude`). One list, so the profile
11
+ * builder, the run log and the screens name the same groups. Screens word
12
+ * each code through the message catalogue.
13
+ */
14
+ export declare const deniedPathGroupCodes: readonly ["ssh-keys", "cloud-sign-ins", "browser-data", "password-stores", "halonic-data", "agent-settings"];
15
+ /** A group of denied paths: one of {@link deniedPathGroupCodes}. */
16
+ export type DeniedPathGroupCode = (typeof deniedPathGroupCodes)[number];
17
+ /**
18
+ * What a sandboxed step can do, as a `sandbox.opened` event records it. It is
19
+ * a display copy of the step's sandbox profile, made by
20
+ * {@link sandboxOpenedView}, so a finished run still shows it. It never holds
21
+ * the profile's environment variables or any field not named here.
22
+ */
23
+ export interface SandboxOpenedView {
24
+ /** How strong the fence is. */
25
+ strength: SandboxStrength;
26
+ /**
27
+ * The step's working folder. Paths in the person's home folder start with
28
+ * `~`. Its own temp folder and settings folder are writable too, but the
29
+ * screens never show their paths, so the view leaves them out.
30
+ */
31
+ workingFolder: string;
32
+ /** Paths the step may read but not change. */
33
+ readOnlyPaths: string[];
34
+ /** The codes of the groups of denied paths, in the order the groups were given. */
35
+ deniedGroups: DeniedPathGroupCode[];
36
+ /** The denied paths that are in no group: the ones the person added. */
37
+ deniedPaths: string[];
38
+ /** The sites the step may reach, besides the Halonic bridge when the profile has one. */
39
+ allowedSites: string[];
40
+ /** How long the step may last, in milliseconds. */
41
+ timeLimitMs: number;
42
+ }
43
+ /**
44
+ * The parts of a sandbox profile that {@link sandboxOpenedView} reads. The
45
+ * `Sandbox` port's `SandboxProfile` fits it; its other fields, such as `env`,
46
+ * are never read.
47
+ */
48
+ export interface ShownSandboxProfile {
49
+ workingFolder: string;
50
+ readOnlyPaths: readonly string[];
51
+ deniedPaths: readonly string[];
52
+ network: {
53
+ allowedSites: readonly string[];
54
+ };
55
+ timeLimitMs: number;
56
+ }
57
+ /** A named group of denied paths, such as the person's SSH keys. */
58
+ export interface DeniedPathGroup {
59
+ /** Which group it is. Screens show it through the message catalogue. */
60
+ code: DeniedPathGroupCode;
61
+ /** The paths of the group, absolute, as they are in the profile. */
62
+ paths: readonly string[];
63
+ }
64
+ /** What {@link sandboxOpenedView} needs besides the profile. */
65
+ export interface SandboxOpenedOptions {
66
+ /** The sandbox's strength, from its `capabilities()`. */
67
+ strength: SandboxStrength;
68
+ /** The person's home folder, or `null` when it is unknown. Paths in it are shortened to `~`. */
69
+ home: string | null;
70
+ /** The groups the profile's denied paths were built from. */
71
+ deniedGroups: readonly DeniedPathGroup[];
72
+ }
73
+ /**
74
+ * Makes the display copy of a sandbox profile that a `sandbox.opened` event
75
+ * carries (requirement `events.sandbox-opened`). It copies a fixed list of
76
+ * fields and nothing else, so the profile's `env`, its temp and settings
77
+ * folders and any field added later never reach the run log. A group is named when it has paths and all of them
78
+ * are denied, so a group with no paths never claims something was blocked;
79
+ * the denied paths outside the named groups are listed one by one. Paths in
80
+ * the person's home folder start with `~`.
81
+ *
82
+ * @param profile - the step's sandbox profile
83
+ * @param options - the sandbox's strength, the home folder and the groups of denied paths
84
+ * @returns the view for the event
85
+ *
86
+ * @example
87
+ * sandboxOpenedView(profile, {
88
+ * strength: "os",
89
+ * home: "<home>",
90
+ * deniedGroups: [{ code: "ssh-keys", paths: ["<home>/.ssh"] }],
91
+ * });
92
+ * // => { strength: "os", workingFolder: "~/work", deniedGroups: ["ssh-keys"], ... }
93
+ */
94
+ export declare function sandboxOpenedView(profile: ShownSandboxProfile, options: SandboxOpenedOptions): SandboxOpenedView;
@@ -0,0 +1,52 @@
1
+ import { shortenHome } from "./home-path.js";
2
+ /**
3
+ * The codes of the groups of paths a sandbox denies: the person's SSH keys,
4
+ * their cloud sign-ins, browser data, password stores, Halonic's own data and
5
+ * other agents' settings (such as `~/.claude`). One list, so the profile
6
+ * builder, the run log and the screens name the same groups. Screens word
7
+ * each code through the message catalogue.
8
+ */
9
+ export const deniedPathGroupCodes = [
10
+ "ssh-keys",
11
+ "cloud-sign-ins",
12
+ "browser-data",
13
+ "password-stores",
14
+ "halonic-data",
15
+ "agent-settings",
16
+ ];
17
+ /**
18
+ * Makes the display copy of a sandbox profile that a `sandbox.opened` event
19
+ * carries (requirement `events.sandbox-opened`). It copies a fixed list of
20
+ * fields and nothing else, so the profile's `env`, its temp and settings
21
+ * folders and any field added later never reach the run log. A group is named when it has paths and all of them
22
+ * are denied, so a group with no paths never claims something was blocked;
23
+ * the denied paths outside the named groups are listed one by one. Paths in
24
+ * the person's home folder start with `~`.
25
+ *
26
+ * @param profile - the step's sandbox profile
27
+ * @param options - the sandbox's strength, the home folder and the groups of denied paths
28
+ * @returns the view for the event
29
+ *
30
+ * @example
31
+ * sandboxOpenedView(profile, {
32
+ * strength: "os",
33
+ * home: "<home>",
34
+ * deniedGroups: [{ code: "ssh-keys", paths: ["<home>/.ssh"] }],
35
+ * });
36
+ * // => { strength: "os", workingFolder: "~/work", deniedGroups: ["ssh-keys"], ... }
37
+ */
38
+ export function sandboxOpenedView(profile, options) {
39
+ const shorten = (path) => shortenHome(path, options.home);
40
+ const denied = new Set(profile.deniedPaths);
41
+ const named = options.deniedGroups.filter((group) => group.paths.length > 0 && group.paths.every((path) => denied.has(path)));
42
+ const inNamedGroup = new Set(named.flatMap((group) => group.paths));
43
+ return {
44
+ strength: options.strength,
45
+ workingFolder: shorten(profile.workingFolder),
46
+ readOnlyPaths: profile.readOnlyPaths.map(shorten),
47
+ deniedGroups: named.map((group) => group.code),
48
+ deniedPaths: [...denied].filter((path) => !inNamedGroup.has(path)).map(shorten),
49
+ allowedSites: [...profile.network.allowedSites],
50
+ timeLimitMs: profile.timeLimitMs,
51
+ };
52
+ }
@@ -0,0 +1,14 @@
1
+ import type { RunEvent } from "./run-event.js";
2
+ import type { RunSummary } from "./run-summary.js";
3
+ /**
4
+ * Fold a run's event stream into its summary. Pure; every run store uses it,
5
+ * so all of them report a run the same way.
6
+ *
7
+ * @param events - the run's events, oldest first
8
+ * @returns the summary, or `null` when the stream doesn't start with `run.started`
9
+ *
10
+ * @example
11
+ * const summary = summarize(await runStore.events(runId));
12
+ * if (summary?.status === "waiting") showButtons(summary.accepts);
13
+ */
14
+ export declare function summarize(events: readonly RunEvent[]): RunSummary | null;
@@ -0,0 +1,188 @@
1
+ import { addUsage } from "./add-usage.js";
2
+ import { upgradeEvent } from "./upgrade.js";
3
+ /**
4
+ * Fold a run's event stream into its summary. Pure; every run store uses it,
5
+ * so all of them report a run the same way.
6
+ *
7
+ * @param events - the run's events, oldest first
8
+ * @returns the summary, or `null` when the stream doesn't start with `run.started`
9
+ *
10
+ * @example
11
+ * const summary = summarize(await runStore.events(runId));
12
+ * if (summary?.status === "waiting") showButtons(summary.accepts);
13
+ */
14
+ export function summarize(events) {
15
+ const firstEvent = events[0];
16
+ if (firstEvent === undefined)
17
+ return null;
18
+ const first = upgradeEvent(firstEvent);
19
+ if (first.type !== "run.started")
20
+ return null;
21
+ const summary = {
22
+ id: first.runId,
23
+ hubId: first.hubId,
24
+ workflowId: first.workflowId,
25
+ kind: first.kind,
26
+ status: "running",
27
+ state: null,
28
+ startedAt: first.at,
29
+ endedAt: null,
30
+ usage: { inputTokens: 0, outputTokens: 0 },
31
+ cost: 0,
32
+ unpricedCalls: 0,
33
+ subscriptionCalls: 0,
34
+ statesVisited: [],
35
+ context: {},
36
+ error: null,
37
+ reason: null,
38
+ definitionsVersion: first.definitionsVersion,
39
+ trigger: first.trigger ?? null,
40
+ parentRunId: first.parent?.runId ?? null,
41
+ waitingOn: null,
42
+ accepts: [],
43
+ answerLabels: {},
44
+ nextTimer: null,
45
+ waitingFor: null,
46
+ lastWaitingAt: null,
47
+ approvals: [],
48
+ signals: [],
49
+ cantTry: [...(first.cantTry ?? [])],
50
+ lastSeq: first.seq,
51
+ updatedAt: first.at,
52
+ };
53
+ for (const event of events) {
54
+ applyEvent(summary, event);
55
+ summary.lastSeq = event.seq;
56
+ summary.updatedAt = event.at;
57
+ }
58
+ return summary;
59
+ }
60
+ /** Update the summary in place with one event. Events that change nothing are skipped. */
61
+ function applyEvent(summary, event) {
62
+ switch (event.type) {
63
+ case "state.entered":
64
+ summary.state = event.state;
65
+ summary.statesVisited.push(event.state);
66
+ if (summary.status === "waiting")
67
+ summary.status = "running";
68
+ return;
69
+ case "llm.response":
70
+ addModelCall(summary, event);
71
+ return;
72
+ case "context.updated":
73
+ summary.context[event.key] = event.value;
74
+ return;
75
+ case "run.waiting":
76
+ summary.status = "waiting";
77
+ summary.waitingOn = event.child ?? null;
78
+ summary.accepts = event.events;
79
+ summary.answerLabels = { ...event.labels };
80
+ summary.nextTimer = earliestTimer(event.timers);
81
+ summary.waitingFor =
82
+ event.title === undefined && event.body === undefined
83
+ ? null
84
+ : { title: event.title ?? "", body: event.body ?? "" };
85
+ summary.lastWaitingAt = event.at;
86
+ return;
87
+ case "signal.sent":
88
+ summary.signals.push({
89
+ id: `${event.runId}:${event.seq}`,
90
+ name: event.name,
91
+ data: event.data,
92
+ at: event.at,
93
+ });
94
+ return;
95
+ case "approval.requested":
96
+ summary.approvals.push(pendingApproval(event));
97
+ return;
98
+ case "approval.resolved":
99
+ removeApproval(summary.approvals, event.callId);
100
+ return;
101
+ case "agent.finished":
102
+ if (event.cantTry !== undefined)
103
+ summary.cantTry.push(event.cantTry);
104
+ return;
105
+ case "event.received":
106
+ case "workflow.finished":
107
+ case "timer.fired":
108
+ summary.status = "running";
109
+ summary.waitingOn = null;
110
+ summary.accepts = [];
111
+ summary.answerLabels = {};
112
+ summary.nextTimer = null;
113
+ summary.waitingFor = null;
114
+ return;
115
+ case "run.completed":
116
+ summary.status = "completed";
117
+ summary.endedAt = event.at;
118
+ summary.context = event.context;
119
+ summary.approvals = [];
120
+ return;
121
+ case "run.failed":
122
+ // A run cancelled or stopped by its budget while it waited ends its
123
+ // approvals without an `approval.resolved`: nobody decided them.
124
+ summary.status = "failed";
125
+ summary.endedAt = event.at;
126
+ summary.error = event.error;
127
+ summary.reason = event.reason ?? null;
128
+ summary.approvals = [];
129
+ return;
130
+ case "run.cant-try":
131
+ summary.status = "cant-try";
132
+ summary.endedAt = event.at;
133
+ summary.cantTry = event.cantTry;
134
+ summary.approvals = [];
135
+ return;
136
+ default:
137
+ return;
138
+ }
139
+ }
140
+ /** The tool call an `approval.requested` asks about, as the summary lists it. */
141
+ function pendingApproval(event) {
142
+ return {
143
+ agent: event.agent,
144
+ ...(event.subagent === undefined ? {} : { subagent: event.subagent }),
145
+ tool: event.tool,
146
+ args: event.args,
147
+ callId: event.callId,
148
+ at: event.at,
149
+ state: event.state,
150
+ branch: event.branch ?? null,
151
+ item: event.item ?? null,
152
+ };
153
+ }
154
+ /**
155
+ * Remove the waiting approval with this call id. The engine makes call ids
156
+ * unique in a run; older logs asked for one approval at a time, so the first
157
+ * match is the one being resolved.
158
+ */
159
+ function removeApproval(approvals, callId) {
160
+ const index = approvals.findIndex((approval) => approval.callId === callId);
161
+ if (index !== -1)
162
+ approvals.splice(index, 1);
163
+ }
164
+ /**
165
+ * Add one model call's tokens, and its cost when it has a price. A call the
166
+ * person's subscription paid for is counted on its own, never priced.
167
+ */
168
+ function addModelCall(summary, call) {
169
+ summary.usage = addUsage(summary.usage, call.usage);
170
+ if (call.paidBy === "subscription")
171
+ summary.subscriptionCalls++;
172
+ else if (call.cost === undefined)
173
+ summary.unpricedCalls++;
174
+ else
175
+ summary.cost += call.cost;
176
+ }
177
+ /**
178
+ * The earliest due time of a wait state's timers, or `null` when it has none.
179
+ * ISO times in the same format sort as text, which is how the old code compared them.
180
+ */
181
+ function earliestTimer(timers) {
182
+ let earliest = null;
183
+ for (const timer of timers ?? []) {
184
+ if (earliest === null || timer.at < earliest)
185
+ earliest = timer.at;
186
+ }
187
+ return earliest;
188
+ }
@@ -0,0 +1,21 @@
1
+ import type { RunEvent } from "./run-event.js";
2
+ /**
3
+ * The timeline entry of each event of a run log: the `seq` of the event that
4
+ * opened the entry. An event that has `entry` keeps it. For a log written
5
+ * before the field existed, an event that finishes or updates an entry (such
6
+ * as `agent.finished`) gets the `seq` of the latest still-open event that
7
+ * opened it, with the same branch, item and matching fields; every other
8
+ * event opens an entry of its own. The engine writes `entry` by the same
9
+ * rules, so an old log and a new log of the same run give the same entries.
10
+ *
11
+ * @param events - one run's log, in `seq` order
12
+ * @returns the entry of each event, in the same order as `events`
13
+ *
14
+ * @example
15
+ * entryOf([
16
+ * { seq: 1, type: "agent.started", state: "s", agent: "a", ... },
17
+ * { seq: 2, type: "agent.finished", state: "s", agent: "a", ... },
18
+ * ]);
19
+ * // => [1, 1]
20
+ */
21
+ export declare function entryOf(events: readonly RunEvent[]): number[];
@@ -0,0 +1,105 @@
1
+ /**
2
+ * The timeline entry of each event of a run log: the `seq` of the event that
3
+ * opened the entry. An event that has `entry` keeps it. For a log written
4
+ * before the field existed, an event that finishes or updates an entry (such
5
+ * as `agent.finished`) gets the `seq` of the latest still-open event that
6
+ * opened it, with the same branch, item and matching fields; every other
7
+ * event opens an entry of its own. The engine writes `entry` by the same
8
+ * rules, so an old log and a new log of the same run give the same entries.
9
+ *
10
+ * @param events - one run's log, in `seq` order
11
+ * @returns the entry of each event, in the same order as `events`
12
+ *
13
+ * @example
14
+ * entryOf([
15
+ * { seq: 1, type: "agent.started", state: "s", agent: "a", ... },
16
+ * { seq: 2, type: "agent.finished", state: "s", agent: "a", ... },
17
+ * ]);
18
+ * // => [1, 1]
19
+ */
20
+ export function entryOf(events) {
21
+ // The entries still open, by opener key; the latest is last.
22
+ const open = new Map();
23
+ return events.map((event) => {
24
+ const fields = openerFields(event);
25
+ if (fields !== null) {
26
+ const entry = event.entry ?? event.seq;
27
+ const key = entryKey(event, event.type, fields);
28
+ open.set(key, [...(open.get(key) ?? []), entry]);
29
+ return entry;
30
+ }
31
+ const update = updateOf(event);
32
+ if (update === null)
33
+ return event.entry ?? event.seq;
34
+ const openEntries = open.get(entryKey(event, update.opener, update.fields)) ?? [];
35
+ const entry = event.entry ?? openEntries.at(-1) ?? event.seq;
36
+ const index = openEntries.lastIndexOf(entry);
37
+ if (update.closes && index !== -1)
38
+ openEntries.splice(index, 1);
39
+ return entry;
40
+ });
41
+ }
42
+ /** The key of an entry: its opener's type, branch, item and matched fields. */
43
+ function entryKey(event, opener, fields) {
44
+ // JSON keeps `undefined` apart from every string, as `null` in an array.
45
+ return JSON.stringify([opener, event.branch, event.item, ...fields]);
46
+ }
47
+ /**
48
+ * The fields an opening event is matched on, or `null` when the event doesn't
49
+ * open an entry that later events update.
50
+ */
51
+ function openerFields(event) {
52
+ switch (event.type) {
53
+ case "run.started":
54
+ case "run.waiting":
55
+ return [];
56
+ case "state.entered":
57
+ return [event.state];
58
+ case "agent.started":
59
+ return [event.state, event.agent, event.parent];
60
+ case "llm.request":
61
+ return [event.agent];
62
+ case "tool.called":
63
+ return [event.agent, event.tool];
64
+ case "approval.requested":
65
+ return [event.callId];
66
+ case "workflow.started":
67
+ return [event.childRunId];
68
+ default:
69
+ return null;
70
+ }
71
+ }
72
+ /** Which entry an event updates, or `null` when it doesn't update one. */
73
+ function updateOf(event) {
74
+ switch (event.type) {
75
+ case "run.completed":
76
+ case "run.failed":
77
+ case "run.cant-try":
78
+ return { opener: "run.started", fields: [], closes: true };
79
+ case "transition":
80
+ return { opener: "state.entered", fields: [event.from], closes: true };
81
+ case "agent.finished":
82
+ return {
83
+ opener: "agent.started",
84
+ fields: [event.state, event.agent, event.parent],
85
+ closes: true,
86
+ };
87
+ case "llm.response":
88
+ return { opener: "llm.request", fields: [event.agent], closes: true };
89
+ // The call goes on with the fallback model, so its response still follows.
90
+ case "llm.fallback":
91
+ return { opener: "llm.request", fields: [event.agent], closes: false };
92
+ case "tool.result":
93
+ return { opener: "tool.called", fields: [event.agent, event.tool], closes: true };
94
+ case "approval.resolved":
95
+ return { opener: "approval.requested", fields: [event.callId], closes: true };
96
+ case "workflow.finished":
97
+ return { opener: "workflow.started", fields: [event.childRunId], closes: true };
98
+ // Only while the run waits; otherwise no entry is open and it stands alone.
99
+ case "timer.fired":
100
+ case "event.received":
101
+ return { opener: "run.waiting", fields: [], closes: true };
102
+ default:
103
+ return null;
104
+ }
105
+ }
@@ -0,0 +1,23 @@
1
+ import type { RunEvent } from "./run-event.js";
2
+ /**
3
+ * Read a stored event, upgrading older shapes. Run logs written before
4
+ * workflows were renamed have `flowId` on `run.started`, and logs written
5
+ * before hubs were renamed have `projectId`. Both become today's names.
6
+ * Every other event is returned as it is.
7
+ *
8
+ * @param raw - one event as read from a run log
9
+ * @returns the event in today's shape
10
+ *
11
+ * @example
12
+ * upgradeEvent({ type: "run.started", projectId: "p", flowId: "greet", ... });
13
+ * // => { type: "run.started", hubId: "p", workflowId: "greet", ... }
14
+ */
15
+ export declare function upgradeEvent(raw: unknown): RunEvent;
16
+ /**
17
+ * Parse one line of a JSON-lines run log.
18
+ *
19
+ * @param line - one line of the log, without the line break
20
+ * @returns the event, upgraded by {@link upgradeEvent}
21
+ * @throws SyntaxError when the line isn't valid JSON or isn't a JSON object
22
+ */
23
+ export declare function parseEventLine(line: string): RunEvent;
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Read a stored event, upgrading older shapes. Run logs written before
3
+ * workflows were renamed have `flowId` on `run.started`, and logs written
4
+ * before hubs were renamed have `projectId`. Both become today's names.
5
+ * Every other event is returned as it is.
6
+ *
7
+ * @param raw - one event as read from a run log
8
+ * @returns the event in today's shape
9
+ *
10
+ * @example
11
+ * upgradeEvent({ type: "run.started", projectId: "p", flowId: "greet", ... });
12
+ * // => { type: "run.started", hubId: "p", workflowId: "greet", ... }
13
+ */
14
+ export function upgradeEvent(raw) {
15
+ // Stored logs are trusted to be run events; only the old names are fixed up.
16
+ const event = raw;
17
+ if (event.type !== "run.started")
18
+ return event;
19
+ const fields = raw;
20
+ const withWorkflow = renameOldField(fields, "flowId", "workflowId");
21
+ return renameOldField(withWorkflow, "projectId", "hubId");
22
+ }
23
+ /**
24
+ * Parse one line of a JSON-lines run log.
25
+ *
26
+ * @param line - one line of the log, without the line break
27
+ * @returns the event, upgraded by {@link upgradeEvent}
28
+ * @throws SyntaxError when the line isn't valid JSON or isn't a JSON object
29
+ */
30
+ export function parseEventLine(line) {
31
+ const parsed = JSON.parse(line);
32
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
33
+ throw new SyntaxError("A run log line must be a JSON object");
34
+ }
35
+ return upgradeEvent(parsed);
36
+ }
37
+ /**
38
+ * Move a string field to its new name. Only when the new name isn't set yet,
39
+ * so an event that already has both keeps both.
40
+ */
41
+ function renameOldField(fields, oldName, newName) {
42
+ if (fields[newName] !== undefined)
43
+ return fields;
44
+ const oldValue = fields[oldName];
45
+ if (typeof oldValue !== "string")
46
+ return fields;
47
+ const { [oldName]: _removed, ...rest } = fields;
48
+ return { ...rest, [newName]: oldValue };
49
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Removes the values a saved file doesn't need, so files stay small: in every
3
+ * object, a key whose value is `undefined`, an empty array or an empty object
4
+ * is left out. Each value is compacted before it is checked, so
5
+ * `{ a: { b: [] } }` loses `a` too.
6
+ *
7
+ * It behaves like the old app's `compact` (requirement `format.compact`):
8
+ * - `null`, `""`, `0` and `false` are kept.
9
+ * - Array items are compacted but never removed, not even `undefined` or `{}`,
10
+ * because removing one would shift the position of every item after it.
11
+ * - The value passed in is never removed: `compact({})` is `{}`.
12
+ * - A key named `__proto__` (`JSON.parse` can make one) is kept as an ordinary
13
+ * key; it never changes the result's prototype.
14
+ *
15
+ * Unlike the old app, it refuses any object that is neither a plain object nor
16
+ * an array, such as a `Date`, a `Map` or a class instance. The old app turned
17
+ * those into `{}` and left them out, quietly losing them; a parsed file never
18
+ * contains one, so meeting one means the caller passed the wrong value.
19
+ *
20
+ * The input is not changed; the result is a new value that shares no objects
21
+ * or arrays with it.
22
+ *
23
+ * @param value - the value about to be written, usually a parsed file
24
+ * @returns the value without empty keys
25
+ * @throws TypeError for an object that isn't a plain object or an array, naming where it is
26
+ *
27
+ * @example
28
+ * compact({ name: "triage", tags: [], layout: {} }); // { name: "triage" }
29
+ */
30
+ export declare function compact(value: unknown): unknown;