@plune-ai/cairn 0.9.0 → 0.11.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 (337) hide show
  1. package/README.md +84 -8
  2. package/dist/agent/check-docs.d.ts +25 -0
  3. package/dist/agent/check-docs.d.ts.map +1 -0
  4. package/dist/agent/check-docs.js +57 -0
  5. package/dist/agent/check-docs.js.map +1 -0
  6. package/dist/agent/collect-docs.d.ts +94 -0
  7. package/dist/agent/collect-docs.d.ts.map +1 -0
  8. package/dist/agent/collect-docs.js +326 -0
  9. package/dist/agent/collect-docs.js.map +1 -0
  10. package/dist/agent/graph.d.ts +39 -2
  11. package/dist/agent/graph.d.ts.map +1 -1
  12. package/dist/agent/graph.js +113 -4
  13. package/dist/agent/graph.js.map +1 -1
  14. package/dist/agent/index.d.ts +14 -0
  15. package/dist/agent/index.d.ts.map +1 -1
  16. package/dist/agent/index.js +114 -10
  17. package/dist/agent/index.js.map +1 -1
  18. package/dist/agent/overlays.d.ts +88 -0
  19. package/dist/agent/overlays.d.ts.map +1 -0
  20. package/dist/agent/overlays.js +447 -0
  21. package/dist/agent/overlays.js.map +1 -0
  22. package/dist/agent/repair-loop.d.ts +8 -1
  23. package/dist/agent/repair-loop.d.ts.map +1 -1
  24. package/dist/agent/repair-loop.js +18 -3
  25. package/dist/agent/repair-loop.js.map +1 -1
  26. package/dist/analyze/index.d.ts +1 -1
  27. package/dist/analyze/index.d.ts.map +1 -1
  28. package/dist/analyze/index.js +3 -2
  29. package/dist/analyze/index.js.map +1 -1
  30. package/dist/api/adversarial.d.ts +1 -1
  31. package/dist/api/adversarial.js +1 -1
  32. package/dist/api/collection.d.ts +20 -0
  33. package/dist/api/collection.d.ts.map +1 -0
  34. package/dist/api/collection.js +357 -0
  35. package/dist/api/collection.js.map +1 -0
  36. package/dist/api/derived.d.ts +179 -0
  37. package/dist/api/derived.d.ts.map +1 -0
  38. package/dist/api/derived.js +852 -0
  39. package/dist/api/derived.js.map +1 -0
  40. package/dist/api/discover.d.ts +66 -0
  41. package/dist/api/discover.d.ts.map +1 -0
  42. package/dist/api/discover.js +125 -0
  43. package/dist/api/discover.js.map +1 -0
  44. package/dist/api/flows.d.ts +194 -0
  45. package/dist/api/flows.d.ts.map +1 -0
  46. package/dist/api/flows.js +663 -0
  47. package/dist/api/flows.js.map +1 -0
  48. package/dist/api/guard.d.ts +19 -0
  49. package/dist/api/guard.d.ts.map +1 -1
  50. package/dist/api/guard.js +18 -4
  51. package/dist/api/guard.js.map +1 -1
  52. package/dist/api/openapi.d.ts +17 -1
  53. package/dist/api/openapi.d.ts.map +1 -1
  54. package/dist/api/openapi.js +64 -3
  55. package/dist/api/openapi.js.map +1 -1
  56. package/dist/api/runner.d.ts.map +1 -1
  57. package/dist/api/runner.js +18 -14
  58. package/dist/api/runner.js.map +1 -1
  59. package/dist/api/two-actor.d.ts +165 -0
  60. package/dist/api/two-actor.d.ts.map +1 -0
  61. package/dist/api/two-actor.js +627 -0
  62. package/dist/api/two-actor.js.map +1 -0
  63. package/dist/artifacts/contract.d.ts +1 -1
  64. package/dist/artifacts/contract.d.ts.map +1 -1
  65. package/dist/artifacts/index.d.ts +5 -0
  66. package/dist/artifacts/index.d.ts.map +1 -1
  67. package/dist/artifacts/index.js +14 -10
  68. package/dist/artifacts/index.js.map +1 -1
  69. package/dist/artifacts/report.d.ts +29 -2
  70. package/dist/artifacts/report.d.ts.map +1 -1
  71. package/dist/artifacts/report.js +65 -1
  72. package/dist/artifacts/report.js.map +1 -1
  73. package/dist/artifacts/testcase-md.d.ts +18 -0
  74. package/dist/artifacts/testcase-md.d.ts.map +1 -1
  75. package/dist/artifacts/testcase-md.js +15 -1
  76. package/dist/artifacts/testcase-md.js.map +1 -1
  77. package/dist/browser/api-traffic.d.ts +85 -0
  78. package/dist/browser/api-traffic.d.ts.map +1 -0
  79. package/dist/browser/api-traffic.js +283 -0
  80. package/dist/browser/api-traffic.js.map +1 -0
  81. package/dist/browser/backends/playwright-cli.d.ts.map +1 -1
  82. package/dist/browser/backends/playwright-cli.js +3 -0
  83. package/dist/browser/backends/playwright-cli.js.map +1 -1
  84. package/dist/browser/backends/playwright-lib.d.ts +84 -1
  85. package/dist/browser/backends/playwright-lib.d.ts.map +1 -1
  86. package/dist/browser/backends/playwright-lib.js +677 -32
  87. package/dist/browser/backends/playwright-lib.js.map +1 -1
  88. package/dist/browser/click-effect.d.ts +84 -0
  89. package/dist/browser/click-effect.d.ts.map +1 -0
  90. package/dist/browser/click-effect.js +235 -0
  91. package/dist/browser/click-effect.js.map +1 -0
  92. package/dist/browser/gateway.d.ts +9 -1
  93. package/dist/browser/gateway.d.ts.map +1 -1
  94. package/dist/browser/index.d.ts +3 -0
  95. package/dist/browser/index.d.ts.map +1 -1
  96. package/dist/browser/index.js +5 -0
  97. package/dist/browser/index.js.map +1 -1
  98. package/dist/browser/types.d.ts +196 -1
  99. package/dist/browser/types.d.ts.map +1 -1
  100. package/dist/cli/index.d.ts +1 -1
  101. package/dist/cli/index.d.ts.map +1 -1
  102. package/dist/cli/index.js +123 -5
  103. package/dist/cli/index.js.map +1 -1
  104. package/dist/codegen/index.d.ts +10 -1
  105. package/dist/codegen/index.d.ts.map +1 -1
  106. package/dist/codegen/index.js +28 -7
  107. package/dist/codegen/index.js.map +1 -1
  108. package/dist/codegen/lint.d.ts +32 -1
  109. package/dist/codegen/lint.d.ts.map +1 -1
  110. package/dist/codegen/lint.js +286 -1
  111. package/dist/codegen/lint.js.map +1 -1
  112. package/dist/codegen/mailbox.d.ts +19 -0
  113. package/dist/codegen/mailbox.d.ts.map +1 -0
  114. package/dist/codegen/mailbox.js +78 -0
  115. package/dist/codegen/mailbox.js.map +1 -0
  116. package/dist/codegen/schema.d.ts.map +1 -1
  117. package/dist/codegen/schema.js +3 -2
  118. package/dist/codegen/schema.js.map +1 -1
  119. package/dist/config/profiles.d.ts +2 -0
  120. package/dist/config/profiles.d.ts.map +1 -1
  121. package/dist/config/profiles.js +2 -0
  122. package/dist/config/profiles.js.map +1 -1
  123. package/dist/core/modalities/api.d.ts.map +1 -1
  124. package/dist/core/modalities/api.js +265 -29
  125. package/dist/core/modalities/api.js.map +1 -1
  126. package/dist/core/modalities/check-docs.d.ts +3 -0
  127. package/dist/core/modalities/check-docs.d.ts.map +1 -0
  128. package/dist/core/modalities/check-docs.js +64 -0
  129. package/dist/core/modalities/check-docs.js.map +1 -0
  130. package/dist/core/modalities/collect-docs.d.ts +3 -0
  131. package/dist/core/modalities/collect-docs.d.ts.map +1 -0
  132. package/dist/core/modalities/collect-docs.js +48 -0
  133. package/dist/core/modalities/collect-docs.js.map +1 -0
  134. package/dist/core/modalities/explore.d.ts.map +1 -1
  135. package/dist/core/modalities/explore.js +2 -0
  136. package/dist/core/modalities/explore.js.map +1 -1
  137. package/dist/core/modalities/mcp-test.d.ts +3 -0
  138. package/dist/core/modalities/mcp-test.d.ts.map +1 -0
  139. package/dist/core/modalities/mcp-test.js +26 -0
  140. package/dist/core/modalities/mcp-test.js.map +1 -0
  141. package/dist/core/registry.d.ts.map +1 -1
  142. package/dist/core/registry.js +11 -3
  143. package/dist/core/registry.js.map +1 -1
  144. package/dist/decider/uses/repair-triage.d.ts +9 -0
  145. package/dist/decider/uses/repair-triage.d.ts.map +1 -1
  146. package/dist/decider/uses/repair-triage.js +20 -3
  147. package/dist/decider/uses/repair-triage.js.map +1 -1
  148. package/dist/design/critique.d.ts +1 -1
  149. package/dist/design/index.d.ts +7 -1
  150. package/dist/design/index.d.ts.map +1 -1
  151. package/dist/design/index.js +20 -2
  152. package/dist/design/index.js.map +1 -1
  153. package/dist/design/schema.d.ts +9 -3
  154. package/dist/design/schema.d.ts.map +1 -1
  155. package/dist/design/schema.js +4 -1
  156. package/dist/design/schema.js.map +1 -1
  157. package/dist/documentarian/check.d.ts +91 -0
  158. package/dist/documentarian/check.d.ts.map +1 -0
  159. package/dist/documentarian/check.js +230 -0
  160. package/dist/documentarian/check.js.map +1 -0
  161. package/dist/documentarian/docs.d.ts +103 -0
  162. package/dist/documentarian/docs.d.ts.map +1 -0
  163. package/dist/documentarian/docs.js +243 -0
  164. package/dist/documentarian/docs.js.map +1 -0
  165. package/dist/documentarian/index.d.ts +2 -0
  166. package/dist/documentarian/index.d.ts.map +1 -1
  167. package/dist/documentarian/index.js +5 -4
  168. package/dist/documentarian/index.js.map +1 -1
  169. package/dist/environment/apply.js +1 -1
  170. package/dist/environment/apply.js.map +1 -1
  171. package/dist/flow/crawl.d.ts +4 -0
  172. package/dist/flow/crawl.d.ts.map +1 -1
  173. package/dist/flow/crawl.js +9 -2
  174. package/dist/flow/crawl.js.map +1 -1
  175. package/dist/fs/inside-dir.d.ts +8 -0
  176. package/dist/fs/inside-dir.d.ts.map +1 -0
  177. package/dist/fs/inside-dir.js +15 -0
  178. package/dist/fs/inside-dir.js.map +1 -0
  179. package/dist/index.d.ts +6 -2
  180. package/dist/index.d.ts.map +1 -1
  181. package/dist/index.js +3 -0
  182. package/dist/index.js.map +1 -1
  183. package/dist/llm/index.d.ts +1 -1
  184. package/dist/llm/index.d.ts.map +1 -1
  185. package/dist/llm/index.js +1 -1
  186. package/dist/llm/index.js.map +1 -1
  187. package/dist/llm/structured.d.ts +19 -0
  188. package/dist/llm/structured.d.ts.map +1 -1
  189. package/dist/llm/structured.js +61 -0
  190. package/dist/llm/structured.js.map +1 -1
  191. package/dist/mailbox/doctor.d.ts +10 -0
  192. package/dist/mailbox/doctor.d.ts.map +1 -0
  193. package/dist/mailbox/doctor.js +33 -0
  194. package/dist/mailbox/doctor.js.map +1 -0
  195. package/dist/mailbox/rule.d.ts +34 -0
  196. package/dist/mailbox/rule.d.ts.map +1 -0
  197. package/dist/mailbox/rule.js +47 -0
  198. package/dist/mailbox/rule.js.map +1 -0
  199. package/dist/mailbox/session.d.ts +5 -0
  200. package/dist/mailbox/session.d.ts.map +1 -1
  201. package/dist/mailbox/session.js +8 -0
  202. package/dist/mailbox/session.js.map +1 -1
  203. package/dist/mcp/server.d.ts +15 -5
  204. package/dist/mcp/server.d.ts.map +1 -1
  205. package/dist/mcp/server.js +75 -27
  206. package/dist/mcp/server.js.map +1 -1
  207. package/dist/mcp/tools.d.ts +194 -82
  208. package/dist/mcp/tools.d.ts.map +1 -1
  209. package/dist/mcp/tools.js +82 -8
  210. package/dist/mcp/tools.js.map +1 -1
  211. package/dist/mcp-test/adversarial.d.ts +80 -0
  212. package/dist/mcp-test/adversarial.d.ts.map +1 -0
  213. package/dist/mcp-test/adversarial.js +99 -0
  214. package/dist/mcp-test/adversarial.js.map +1 -0
  215. package/dist/mcp-test/advice.d.ts +20 -0
  216. package/dist/mcp-test/advice.d.ts.map +1 -0
  217. package/dist/mcp-test/advice.js +22 -0
  218. package/dist/mcp-test/advice.js.map +1 -0
  219. package/dist/mcp-test/call.d.ts +76 -0
  220. package/dist/mcp-test/call.d.ts.map +1 -0
  221. package/dist/mcp-test/call.js +105 -0
  222. package/dist/mcp-test/call.js.map +1 -0
  223. package/dist/mcp-test/cases.d.ts +154 -0
  224. package/dist/mcp-test/cases.d.ts.map +1 -0
  225. package/dist/mcp-test/cases.js +643 -0
  226. package/dist/mcp-test/cases.js.map +1 -0
  227. package/dist/mcp-test/connect.d.ts +70 -0
  228. package/dist/mcp-test/connect.d.ts.map +1 -0
  229. package/dist/mcp-test/connect.js +426 -0
  230. package/dist/mcp-test/connect.js.map +1 -0
  231. package/dist/mcp-test/coverage.d.ts +61 -0
  232. package/dist/mcp-test/coverage.d.ts.map +1 -0
  233. package/dist/mcp-test/coverage.js +76 -0
  234. package/dist/mcp-test/coverage.js.map +1 -0
  235. package/dist/mcp-test/discover.d.ts +40 -0
  236. package/dist/mcp-test/discover.d.ts.map +1 -0
  237. package/dist/mcp-test/discover.js +149 -0
  238. package/dist/mcp-test/discover.js.map +1 -0
  239. package/dist/mcp-test/guard.d.ts +161 -0
  240. package/dist/mcp-test/guard.d.ts.map +1 -0
  241. package/dist/mcp-test/guard.js +363 -0
  242. package/dist/mcp-test/guard.js.map +1 -0
  243. package/dist/mcp-test/model.d.ts +89 -0
  244. package/dist/mcp-test/model.d.ts.map +1 -0
  245. package/dist/mcp-test/model.js +88 -0
  246. package/dist/mcp-test/model.js.map +1 -0
  247. package/dist/mcp-test/payloads.d.ts +20 -0
  248. package/dist/mcp-test/payloads.d.ts.map +1 -0
  249. package/dist/mcp-test/payloads.js +20 -0
  250. package/dist/mcp-test/payloads.js.map +1 -0
  251. package/dist/mcp-test/report.d.ts +55 -0
  252. package/dist/mcp-test/report.d.ts.map +1 -0
  253. package/dist/mcp-test/report.js +157 -0
  254. package/dist/mcp-test/report.js.map +1 -0
  255. package/dist/mcp-test/run.d.ts +68 -0
  256. package/dist/mcp-test/run.d.ts.map +1 -0
  257. package/dist/mcp-test/run.js +467 -0
  258. package/dist/mcp-test/run.js.map +1 -0
  259. package/dist/mcp-test/runner.d.ts +133 -0
  260. package/dist/mcp-test/runner.d.ts.map +1 -0
  261. package/dist/mcp-test/runner.js +412 -0
  262. package/dist/mcp-test/runner.js.map +1 -0
  263. package/dist/mcp-test/schema.d.ts +103 -0
  264. package/dist/mcp-test/schema.d.ts.map +1 -0
  265. package/dist/mcp-test/schema.js +513 -0
  266. package/dist/mcp-test/schema.js.map +1 -0
  267. package/dist/mcp-test/secrets.d.ts +25 -0
  268. package/dist/mcp-test/secrets.d.ts.map +1 -0
  269. package/dist/mcp-test/secrets.js +67 -0
  270. package/dist/mcp-test/secrets.js.map +1 -0
  271. package/dist/observe/index.d.ts +3 -1
  272. package/dist/observe/index.d.ts.map +1 -1
  273. package/dist/observe/index.js +1 -0
  274. package/dist/observe/index.js.map +1 -1
  275. package/dist/observe/locator-hints.d.ts +18 -0
  276. package/dist/observe/locator-hints.d.ts.map +1 -0
  277. package/dist/observe/locator-hints.js +36 -0
  278. package/dist/observe/locator-hints.js.map +1 -0
  279. package/dist/observe/overlays.d.ts +135 -0
  280. package/dist/observe/overlays.d.ts.map +1 -0
  281. package/dist/observe/overlays.js +242 -0
  282. package/dist/observe/overlays.js.map +1 -0
  283. package/dist/observe/parse-aria.d.ts +7 -1
  284. package/dist/observe/parse-aria.d.ts.map +1 -1
  285. package/dist/observe/parse-aria.js +79 -4
  286. package/dist/observe/parse-aria.js.map +1 -1
  287. package/dist/probe/index.d.ts +3 -1
  288. package/dist/probe/index.d.ts.map +1 -1
  289. package/dist/probe/index.js +3 -2
  290. package/dist/probe/index.js.map +1 -1
  291. package/dist/project/index.d.ts +2 -0
  292. package/dist/project/index.d.ts.map +1 -1
  293. package/dist/project/index.js +10 -2
  294. package/dist/project/index.js.map +1 -1
  295. package/dist/prompts/local/describe-screen.d.ts +7 -0
  296. package/dist/prompts/local/describe-screen.d.ts.map +1 -0
  297. package/dist/prompts/local/describe-screen.js +29 -0
  298. package/dist/prompts/local/describe-screen.js.map +1 -0
  299. package/dist/prompts/local/index.d.ts.map +1 -1
  300. package/dist/prompts/local/index.js +7 -0
  301. package/dist/prompts/local/index.js.map +1 -1
  302. package/dist/prompts/local/name-overlays.d.ts +6 -0
  303. package/dist/prompts/local/name-overlays.d.ts.map +1 -0
  304. package/dist/prompts/local/name-overlays.js +16 -0
  305. package/dist/prompts/local/name-overlays.js.map +1 -0
  306. package/dist/prompts/local/qa-api-flows.d.ts +8 -0
  307. package/dist/prompts/local/qa-api-flows.d.ts.map +1 -0
  308. package/dist/prompts/local/qa-api-flows.js +19 -0
  309. package/dist/prompts/local/qa-api-flows.js.map +1 -0
  310. package/dist/prompts/local/qa-playwright-ts-writer.d.ts +1 -1
  311. package/dist/prompts/local/qa-playwright-ts-writer.d.ts.map +1 -1
  312. package/dist/prompts/local/qa-playwright-ts-writer.js +5 -1
  313. package/dist/prompts/local/qa-playwright-ts-writer.js.map +1 -1
  314. package/dist/prompts/local/qa-testcase-from-ui.d.ts +1 -1
  315. package/dist/prompts/local/qa-testcase-from-ui.d.ts.map +1 -1
  316. package/dist/prompts/local/qa-testcase-from-ui.js +2 -0
  317. package/dist/prompts/local/qa-testcase-from-ui.js.map +1 -1
  318. package/dist/session/index.d.ts.map +1 -1
  319. package/dist/session/index.js +24 -2
  320. package/dist/session/index.js.map +1 -1
  321. package/dist/validate/index.d.ts +11 -0
  322. package/dist/validate/index.d.ts.map +1 -1
  323. package/dist/validate/index.js +21 -0
  324. package/dist/validate/index.js.map +1 -1
  325. package/dist/validate/runner.d.ts +15 -1
  326. package/dist/validate/runner.d.ts.map +1 -1
  327. package/dist/validate/runner.js +158 -25
  328. package/dist/validate/runner.js.map +1 -1
  329. package/dist/validate/write-guard.d.ts +24 -0
  330. package/dist/validate/write-guard.d.ts.map +1 -0
  331. package/dist/validate/write-guard.js +210 -0
  332. package/dist/validate/write-guard.js.map +1 -0
  333. package/dist/view/index.d.ts +9 -0
  334. package/dist/view/index.d.ts.map +1 -0
  335. package/dist/view/index.js +126 -0
  336. package/dist/view/index.js.map +1 -0
  337. package/package.json +3 -2
package/README.md CHANGED
@@ -18,8 +18,8 @@ pages (ARIA snapshot + screenshot), designs methodology-based UI test cases (ISO
18
18
  generates runnable `@playwright/test` code, self-validates, self-repairs, and **self-improves** via
19
19
  Langfuse. A portable CLI + library for embedding into other TypeScript projects.
20
20
 
21
- **Cairn is the generation layer** — it produces tests across surfaces (UI + API shipped; unit / docs
22
- planned), each arriving by demand. A separate **Plune** layer owns record / management / eval.
21
+ **Cairn is the generation layer** — it produces tests across surfaces (UI + API shipped, and docs written from a
22
+ walk of the UI; unit planned), each arriving by demand. A separate **Plune** layer owns record / management / eval.
23
23
 
24
24
  > **Renamed Lex-Bot → Cairn.** The old `lex-bot` command and `@plune-ai/lex-bot` package still work
25
25
  > (the CLI prints a one-line deprecation notice) — prefer `cairn` / `@plune-ai/cairn`. Legacy
@@ -87,11 +87,82 @@ Add `--screencast` (to `explore`, or `automate --validate`) to record a **`.webm
87
87
  validation into `runs/<id>/screencasts/`, with a Playwright `trace.zip` beside each and a `screencasts.json`
88
88
  sidecar mapping each scenario's step chapters (step → timecode). The timecodes come from the trace, counted
89
89
  from the video's first frame (`"timing": "trace"`); when a trace cannot be read they are estimated from the step
90
- durations (`"timing": "estimated"`). A run with a session, Basic Auth, environment secrets or a mailbox keeps no
90
+ durations (`"timing": "estimated"`). A run with a session, Basic Auth, environment secrets, a mailbox or API flows keeps no
91
91
  trace, since Playwright would write them into it in the clear: its timecodes are estimated, and in the first
92
92
  scenario of a worker they can run seconds late. It's a review-gate affordance — watch what the agent did before
93
93
  approving a case. Off by default; the recorded `.webm` paths are linked from the run summary and the TUI result screen.
94
94
 
95
+ ### Watch a run offline: `cairn view`
96
+
97
+ `cairn view <runDir>` (a path or a bare run id) builds **`view.html`** in a run that has screencasts and prints its
98
+ path. It is one self-contained file (inline CSS and JS) that plays the local `.webm` by a relative path and lists the
99
+ steps from `screencasts.json` with their times: click a step (or press Enter on it) to jump the video there; the
100
+ current step is marked while it plays. It works offline and nothing leaves your machine. A run with no steps shows
101
+ only the video and a note; a run with no video exits with an error naming the run directory. Add `--open` to open
102
+ the page in your default browser.
103
+
104
+ ### API security: IDOR and privilege escalation across two actors
105
+
106
+ `cairn api --base-url https://staging.example.com --actors actors.json --allow-mutations` runs a check the
107
+ single-request `hacker` style cannot: it needs two identities and state. The owner (actor A) creates a resource
108
+ through a saved [API flow](docs/api-flows.md); the other actor (B) then tries to read it, change it and delete it, and
109
+ reads the ids next to it. Each 2xx answer to B is a finding with its OWASP WSTG id: `WSTG-ATHZ-04` (IDOR) when B is
110
+ another user, `WSTG-ATHZ-03` (privilege escalation) when B is a lower role. Only `401`, `403` and `404` count as
111
+ refused; any other answer (a redirect, `400`, `405`, `422`, a `5xx`) is inconclusive — a `PATCH {}` stopped by
112
+ validation never reached the access check — and fails the run like a finding. When every answer B got within a check
113
+ is a `401`, those cases are inconclusive too: B's credentials may not be valid, so access was not checked. A `401` next
114
+ to any other answer stays refused. A neighbouring id counts only when both actors can read it. The flow's own cleanup
115
+ deletes what was created, also when the check stops halfway; a check refused before its first request has no cleanup.
116
+ A cleanup step without `expect` is done only on a 2xx, and a cleanup that answers otherwise, or cannot be sent because
117
+ the create never returned its id, is reported as a cleanup error: the data may still be there. A captured JSON whole number past 2^53, or a number written with more digits than a number holds, stops the check, naming the capture: it may have been rounded, and a read or a cleanup must
118
+ not reach another record. A string id above 2^53 is used as written, and its neighbours are skipped.
119
+
120
+ ```json
121
+ {
122
+ "version": 1,
123
+ "flows": "flows.json",
124
+ "actors": {
125
+ "owner": { "session": "alice" },
126
+ "other": { "headers": { "Authorization": "Bearer {{env.BOB_TOKEN}}" }, "role": "peer" }
127
+ },
128
+ "checks": [
129
+ { "flow": "project", "resource": "/api/projects/{{projectId}}", "change": { "method": "PATCH", "body": { "name": "x" } }, "neighbours": 2 }
130
+ ]
131
+ }
132
+ ```
133
+
134
+ An actor is a saved session by its name (`.auth/<name>.storageState.json`, from `cairn session capture --name`; set
135
+ `sessionsDir` to look elsewhere) or headers whose secrets are `{{env.NAME}}` only. The flow file's own `headers` (where
136
+ the owner's token usually sits) go to the owner whole. The other actor's requests carry no identity but its own actor
137
+ definition. From the flow file it takes only `Accept`, `Accept-Language`, `Content-Type` and `User-Agent`; its own
138
+ headers and session cookie come from `actors.json`. An error about a request says its method, its path and a category
139
+ (such as `network: ECONNREFUSED`), never the text of the underlying error. In the report and the terminal a captured
140
+ value is shown only as a whole number in the path, and not when it equals the value of an `{{env.NAME}}` that the flow
141
+ file or `actors.json` names; everything else stays as written, `{{name}}` and `{{env.NAME}}` alike, and so does the
142
+ whole query. The real values go only on the wire. What is known in advance is refused before the first request: a bad
143
+ header name, a header value whose characters cannot be sent because of an actor's header or an `{{env.NAME}}`, and,
144
+ anywhere in the flow's steps and cleanup, an `{{env.NAME}}` that is not set or that cannot stand in a path. A refused
145
+ header names itself and the templates it was built from. What a captured value holds is known only when it is sent: a
146
+ header with characters from one is refused then, naming the header. A URL that cannot be parsed is refused instead of
147
+ sent. So a secret from the environment never reaches the report or the terminal, with two known limits: a whole number
148
+ the server answered is shown unless it equals a value a file names, so a number that is a secret or part of one can be
149
+ shown when neither file names that exact value (`007` echoed as `7`); and a neighbour hidden because it equals a named
150
+ value, next to an id that is shown, tells what that value is. Header
151
+ names are merged case-insensitively (the actor's own win, a saved session's cookies win over a written
152
+ `Cookie`), so one name goes out with one value. The check uses the same guardrails as
153
+ every `cairn api` run: nothing is sent without `--allow-mutations`, so give it only a staging address you own, never
154
+ production; `--allowed-methods`, `--allowed-paths`, `--max-requests` and `--rps` hold as well, and a check whose flow or
155
+ cleanup they refuse is not started. Findings print with their WSTG id and go to `two-actor.json` in `--out`.
156
+
157
+ Exit codes, the first that applies wins: `1` for a two-actor file or saved session that cannot be used, a finding, an
158
+ inconclusive case, a check that stopped, a cleanup that failed, or a check `not tested` (it ran with no probe answered,
159
+ or `--allowed-methods`/`--allowed-paths` refused its flow or cleanup) while another check got an answer; `4` for a check
160
+ not started because the budget could not cover it; `5` when no probe in the run got an answer, because nothing was
161
+ tested (the owner's own requests do not count); otherwise `0`. A probe skipped next to answered ones stays a pass,
162
+ counted in the summary line.
163
+
164
+ More: [the runbook](docs/runbooks/run-api-cases.md#two-actor-check-idor-and-privilege-escalation---actors-233).
165
+
95
166
  ## Interactive TUI
96
167
 
97
168
  Run `cairn` with **no arguments** in a terminal for a guided UI (launcher → form → live dashboard →
@@ -103,11 +174,16 @@ result summary → past-run browser). Ink/React are optional deps — see **[doc
103
174
  |---|---|
104
175
  | `cairn session capture --url <loginUrl> --name <s>` | Capture a login session → `.auth/` (`cairn login` is a shorthand; `session ls` / `rm`) |
105
176
  | `cairn observe --url <u> [--session <s>]` | ARIA snapshot + interactive elements + screenshot |
106
- | `cairn design --url <u> --session <s> [--checklist <f>] [--style <s>] [--fresh] [--critique]` | Test cases only (ATC/MTC `.md` + selectors), no code |
107
- | `cairn automate --run <dir> [--validate --session <s>] [--screencast]` | `@playwright/test` from `ATC-*` cases |
177
+ | `cairn design --url <u> --session <s> [--checklist <f>] [--style <s>] [--fresh] [--critique] [--flows <f>]` | Test cases only (ATC/MTC `.md` + selectors), no code; with `--flows`, data and sign-in preconditions use saved [API flows](docs/api-flows.md) |
178
+ | `cairn automate --run <dir> [--validate --session <s>] [--screencast] [--flows <f> [--allow-mutations]]` | `@playwright/test` from `ATC-*` cases; with `--flows`, specs get their data and sign-in from the flows' Playwright fixture |
179
+ | `cairn view <runDir> [--open]` | Build `view.html`: a run's screencast video with its steps as clickable chapters (offline) |
108
180
  | `cairn promote --run <dir> --cases <ids> [--session <s>]` | Promote manual MTC case(s) to ATC (.md only; then `automate`) |
109
- | `cairn explore --url <u> --session <s> [--checklist <f>] [--fresh] [--critique] [--screencast]` | Full pipeline (cases → code → validate → repair → Pilot) |
110
- | `cairn api --spec <path\|url> [--base-url <u>] [--negative] [--scenarios] [--adversarial [styles]] [--min-coverage <percent> [--count-partial]] [--allow-mutations] [--allowed-methods <list>] [--allowed-paths <list>] [--max-requests <n>] [--rps <n>]` | Generate (and, with `--base-url`, run + assert status/contract) happy-path, negative-schema, multi-endpoint-scenario, and adversarial (`normal`/`curious`/`psycho`/`hacker`) cases from an OpenAPI 3.x spec. **With `--base-url` only GET/HEAD/OPTIONS are sent unless you pass `--allow-mutations`** (300 requests max, 5 req/s, host pinned, no redirects) |
181
+ | `cairn explore --url <u> --session <s> [--checklist <f>] [--fresh] [--critique] [--screencast] [--api-origin <list>]` | Full pipeline (cases → code → validate → repair → Pilot); on the lib backend the app's API traffic is also saved as an OpenAPI draft, `openapi.derived.json`, for `cairn api --spec` |
182
+ | `cairn api [--spec <path\|url>] [--base-url <u>] [--negative] [--scenarios] [--adversarial [styles]] [--min-coverage <percent> [--count-partial]] [--allow-mutations] [--allowed-methods <list>] [--allowed-paths <list>] [--max-requests <n>] [--rps <n>]` | Generate (and, with `--base-url`, run + assert status/contract) happy-path, negative-schema, multi-endpoint-scenario, and adversarial (`normal`/`curious`/`psycho`/`hacker`) cases from an OpenAPI 3.x spec. **With `--base-url` only GET/HEAD/OPTIONS are sent unless you pass `--allow-mutations`** (300 requests max, 5 req/s, host pinned, no redirects). Without `--spec`, the `--base-url` server is searched for a spec it serves (`/openapi.json`, `/v3/api-docs`, …). `--spec` also takes a Postman collection (v2.1) or a HAR file: it is converted to OpenAPI and saved as `openapi.derived.json` in the run directory |
183
+ | `cairn api --spec <s> --scenarios --save-flows <f>` · `cairn api --flows <f> [--out <dir>] [--base-url <u> --allow-mutations]` | Save scenario chains as [API flows](docs/api-flows.md) (create → return its id → delete), and write their Playwright fixture (`api-flows.fixture.ts`) for UI test setup and cleanup; sends no request. A flow that changes data runs only against an address allowed with `--allow-mutations` |
184
+ | `cairn api --base-url <u> --actors <f> --allow-mutations` | Two-actor API security check: IDOR (`WSTG-ATHZ-04`) and privilege escalation (`WSTG-ATHZ-03`) — the owner creates a resource through a saved API flow, the other actor tries to read, change and delete it and reads the ids next to it; the flow's cleanup always runs. See [below](#api-security-idor-and-privilege-escalation-across-two-actors) |
185
+ | `cairn collect-docs --url <u> [--session <s>] [--max-pages <n>] [--out <dir>] [--fresh]` | Walk the app's screens (by its links) and their dialogs, drawers, menus and wizards, and write its user docs: `docs.md` with a section and a screenshot per screen and overlay — what it is, who gets here, fields and required fields, what a user can do and where it leads — and a list of open questions; plus `openapi.derived.json` from the app's traffic. `cairn docs` is an alias. See [Collect docs](docs/collect-docs.md) |
186
+ | `cairn check-docs --docs <dir\|file> --url <u> [--session <s>] [--spec <file>]` | Walk the app and compare it with docs in the collect-docs format: screens, overlays, fields and controls in the docs but not in the UI, in the UI but not in the docs, or named differently; with `--spec`, API operations the app called that the spec lacks. Report `check-docs.md` with links to the docs section and the screen; exit 0 on a match, 2 on a mismatch (for CI); no LLM call. See [Check docs](docs/check-docs.md) |
111
187
  | `cairn experiment --dataset <d> --candidate name=file` | Compare prompt versions on a dataset |
112
188
 
113
189
  > `lex-bot <command>` still runs every command above (deprecated alias — prints a notice, then runs `cairn`).
@@ -125,7 +201,7 @@ const result = await runDesign({ url, config, sessionName: "myapp", checklistTex
125
201
  ## Documentation
126
202
 
127
203
  - **[Getting started](docs/getting-started.md)** — step-by-step onboarding (session → design → review → promote → automate → validate).
128
- - **[Authenticated targets](docs/sessions.md)** · **[Configuration & role routing](docs/configuration.md)** · **[Prompts & styles](docs/prompts-and-styles.md)** · **[Interactive TUI](docs/tui.md)** · **[MCP server](docs/mcp.md)**
204
+ - **[Authenticated targets](docs/sessions.md)** · **[Configuration & role routing](docs/configuration.md)** · **[Prompts & styles](docs/prompts-and-styles.md)** · **[Interactive TUI](docs/tui.md)** · **[MCP server](docs/mcp.md)** · **[Test an MCP server](docs/mcp-test.md)**
129
205
  - **[Metrics](docs/metrics.md)** · **[Cost benchmark](docs/cost.md)** · **[Langfuse](docs/langfuse.md)**
130
206
  - **[Decision layer](docs/decider.md)** — an optional System One model (Jev in the cloud, Laya on your machine) for repair triage, checklist coverage and healing a broken locator; off by default, with a shadow mode to judge it first.
131
207
  - **[Architecture overview](docs/architecture/overview.md)** — the plain async pipeline, locator grounding, self-improvement.
@@ -0,0 +1,25 @@
1
+ import { type CheckReport, type ReadSection } from "../documentarian/check.js";
2
+ import { type WalkInput } from "./collect-docs.js";
3
+ export declare const CHECK_REPORT_FILE = "check-docs.md";
4
+ export interface CheckDocsInput extends WalkInput {
5
+ /** A docs file in the collect-docs format, or a directory holding `docs.md`. */
6
+ docs: string;
7
+ /** An OpenAPI 3.x spec (JSON or YAML file) to compare with the traffic of the walk. */
8
+ spec?: string;
9
+ /** The run's directory (default `runs/check-docs-<id>/`). */
10
+ out?: string;
11
+ }
12
+ export interface CheckDocsResult {
13
+ outDir: string;
14
+ reportFile: string;
15
+ report: CheckReport;
16
+ /** What fails the run: UI mismatches plus API operations the spec does not have. 0: the docs match. */
17
+ mismatches: number;
18
+ }
19
+ /** The docs as sections, or a one-line error that says what was expected. Read before the walk, so a wrong path costs no browser. */
20
+ export declare function readDocs(path: string): Promise<{
21
+ file: string;
22
+ sections: ReadSection[];
23
+ }>;
24
+ export declare function runCheckDocs(input: CheckDocsInput): Promise<CheckDocsResult>;
25
+ //# sourceMappingURL=check-docs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check-docs.d.ts","sourceRoot":"","sources":["../../src/agent/check-docs.ts"],"names":[],"mappings":"AAcA,OAAO,EAOL,KAAK,WAAW,EAChB,KAAK,WAAW,EACjB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAW,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE5D,eAAO,MAAM,iBAAiB,kBAAkB,CAAC;AAEjD,MAAM,WAAW,cAAe,SAAQ,SAAS;IAC/C,gFAAgF;IAChF,IAAI,EAAE,MAAM,CAAC;IACb,uFAAuF;IACvF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,6DAA6D;IAC7D,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,WAAW,CAAC;IACpB,uGAAuG;IACvG,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,qIAAqI;AACrI,wBAAsB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,WAAW,EAAE,CAAA;CAAE,CAAC,CAc/F;AAED,wBAAsB,YAAY,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC,CAqBlF"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * #231 — `cairn check-docs`: walk the app as `collect-docs` does (#24) and compare what it sees with the docs.
3
+ *
4
+ * The walk makes no LLM call: only facts are compared (screens, overlays, fields, controls and where they lead), and
5
+ * those are read from the ARIA snapshot. The UI side is rendered in the docs format and read back with the docs reader
6
+ * (`documentarian/check.ts`), so both sides go through one parser. With `--spec`, the API operations the app called
7
+ * while it was walked (`openapi.derived.json`, #229) are compared with the spec's.
8
+ */
9
+ import { randomUUID } from "node:crypto";
10
+ import { mkdir, readFile, stat, writeFile } from "node:fs/promises";
11
+ import { join, relative, resolve } from "node:path";
12
+ import { ingestOpenApi } from "../api/openapi.js";
13
+ import { defaultRunsBaseDir } from "../fs/run-dir.js";
14
+ import { DOCS_FILE, renderDocsMd } from "../documentarian/docs.js";
15
+ import { compareApi, compareDocs, docsFileIn, mismatchCount, parseDocsMd, renderCheckMd, } from "../documentarian/check.js";
16
+ import { walkApp } from "./collect-docs.js";
17
+ export const CHECK_REPORT_FILE = "check-docs.md";
18
+ /** The docs as sections, or a one-line error that says what was expected. Read before the walk, so a wrong path costs no browser. */
19
+ export async function readDocs(path) {
20
+ if (/^https?:\/\//i.test(path))
21
+ throw new Error(`--docs takes a file or a directory, not an address (${path}).`);
22
+ const full = resolve(path);
23
+ const st = await stat(full).catch(() => undefined);
24
+ if (!st)
25
+ throw new Error(`No docs at ${path}.`);
26
+ const file = docsFileIn(st.isDirectory(), full);
27
+ const md = await readFile(file, "utf8").catch(() => {
28
+ throw new Error(`No ${DOCS_FILE} in ${path}.`);
29
+ });
30
+ const sections = parseDocsMd(md);
31
+ if (sections.length === 0) {
32
+ throw new Error(`No sections in ${file}: check-docs reads the format \`cairn collect-docs\` writes ("## Screen: <title>" and so on; see docs/collect-docs.md).`);
33
+ }
34
+ return { file, sections };
35
+ }
36
+ export async function runCheckDocs(input) {
37
+ const docs = await readDocs(input.docs);
38
+ const spec = input.spec ? await ingestOpenApi(resolve(input.spec)) : undefined;
39
+ const outDir = input.out ? resolve(input.out) : join(defaultRunsBaseDir(), `check-docs-${randomUUID()}`);
40
+ const walk = await walkApp(input, outDir);
41
+ const ui = parseDocsMd(renderDocsMd(walk.docs.model));
42
+ const traffic = walk.openApiFile ? (await ingestOpenApi(walk.openApiFile)).endpoints : [];
43
+ const screens = ui.filter((s) => s.kind === "Screen").length;
44
+ const report = {
45
+ origin: walk.docs.model.origin,
46
+ docsLink: relative(outDir, docs.file).replace(/\\/g, "/"),
47
+ screens,
48
+ overlays: ui.length - screens,
49
+ mismatches: compareDocs(docs.sections, ui),
50
+ ...(spec ? { api: compareApi(spec.endpoints, traffic) } : {}),
51
+ };
52
+ await mkdir(outDir, { recursive: true });
53
+ const reportFile = join(outDir, CHECK_REPORT_FILE);
54
+ await writeFile(reportFile, renderCheckMd(report), "utf8");
55
+ return { outDir, reportFile, report, mismatches: mismatchCount(report) };
56
+ }
57
+ //# sourceMappingURL=check-docs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check-docs.js","sourceRoot":"","sources":["../../src/agent/check-docs.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EACL,UAAU,EACV,WAAW,EACX,UAAU,EACV,aAAa,EACb,WAAW,EACX,aAAa,GAGd,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,OAAO,EAAkB,MAAM,mBAAmB,CAAC;AAE5D,MAAM,CAAC,MAAM,iBAAiB,GAAG,eAAe,CAAC;AAmBjD,qIAAqI;AACrI,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,IAAY;IACzC,IAAI,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,uDAAuD,IAAI,IAAI,CAAC,CAAC;IACjH,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CA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
3
+ import { PromptRegistry } from "../prompts/index.js";
4
+ import { type DocsModel } from "../documentarian/docs.js";
5
+ import type { AppConfig } from "../config/index.js";
6
+ /** Screens walked unless `--max-pages` says otherwise (cost guardrail: one LLM call per new or changed screen). */
7
+ export declare const DEFAULT_MAX_SCREENS = 10;
8
+ export interface CollectDocsDeps {
9
+ gateway: BrowserGateway;
10
+ prompts: PromptRegistry;
11
+ /** Absent: no screen is described (no LLM call) — `check-docs` (#231) compares facts only. */
12
+ describeInvoke?: StructuredInvoke;
13
+ /** Where screen descriptions are cached across runs; undefined: no cache. */
14
+ cacheDir?: string;
15
+ /** Ignore the cache (describe every screen again). */
16
+ fresh?: boolean;
17
+ maxScreens?: number;
18
+ language?: string;
19
+ onProgress?: (event: string) => void;
20
+ }
21
+ export interface CollectedDocs {
22
+ model: DocsModel;
23
+ /** Screenshots to write, each at its path relative to the docs file. */
24
+ screenshots: {
25
+ path: string;
26
+ b64: string;
27
+ }[];
28
+ /** Screens described by the model in this run, and those whose description came from the cache. */
29
+ described: number;
30
+ cached: number;
31
+ }
32
+ /** The start page shows nothing a user could read about or do. */
33
+ export declare function emptyAppMessage(url: string): string;
34
+ /** The walk: screens, their overlays, their descriptions. Throws a one-line error on an unreachable or empty app. */
35
+ export declare function collectDocs(deps: CollectDocsDeps, url: string): Promise<CollectedDocs>;
36
+ export interface CollectDocsInput {
37
+ url: string;
38
+ config: AppConfig;
39
+ sessionName?: string;
40
+ sessionFile?: string;
41
+ /** The run's directory (default `runs/docs-<id>/`). */
42
+ out?: string;
43
+ maxScreens?: number;
44
+ fresh?: boolean;
45
+ headed?: boolean;
46
+ /** #229: origins besides `url`'s whose API requests go into openapi.derived.json (comma-separated). */
47
+ apiOrigins?: string;
48
+ /** Default `.cairn-cache/understanding` (descriptions go to its `screens/`). */
49
+ cacheDir?: string;
50
+ sessionsDir?: string;
51
+ /** Injected in tests; else the worker role's model. */
52
+ describeInvoke?: StructuredInvoke;
53
+ onProgress?: (event: string) => void;
54
+ }
55
+ export interface CollectDocsResult {
56
+ outDir: string;
57
+ docsFile: string;
58
+ /** Absent when the app made no API request the draft could use. */
59
+ openApiFile?: string;
60
+ model: DocsModel;
61
+ described: number;
62
+ cached: number;
63
+ cost: CostReport;
64
+ }
65
+ /** What a walk needs to open the app; shared by `collect-docs` and `check-docs` (#231). */
66
+ export interface WalkInput {
67
+ url: string;
68
+ browser: {
69
+ backend: AppConfig["browser"]["backend"];
70
+ channel?: string;
71
+ };
72
+ sessionName?: string;
73
+ sessionFile?: string;
74
+ sessionsDir?: string;
75
+ maxScreens?: number;
76
+ headed?: boolean;
77
+ /** #229: origins besides `url`'s whose API requests go into openapi.derived.json (comma-separated). */
78
+ apiOrigins?: string;
79
+ onProgress?: (event: string) => void;
80
+ }
81
+ export interface WalkResult {
82
+ docs: CollectedDocs;
83
+ /** Absent when the app made no API request the draft could use. */
84
+ openApiFile?: string;
85
+ }
86
+ /**
87
+ * Opens the app, walks it ({@link collectDocs}) and writes into `outDir` what the walk saw: the screenshots and the
88
+ * OpenAPI draft from the traffic. `outDir` is created only after the walk succeeds, or by a failed walk that leaves a partial draft. `describe`: what the model needs
89
+ * (absent: no screen is described and no LLM call is made).
90
+ */
91
+ export declare function walkApp(input: WalkInput, outDir: string, describe?: Pick<CollectDocsDeps, "describeInvoke" | "cacheDir" | "fresh" | "language">): Promise<WalkResult>;
92
+ /** `cairn collect-docs`: the walk, then `docs.md`, its screenshots and the OpenAPI draft in the run's directory. */
93
+ export declare function runCollectDocs(input: CollectDocsInput): Promise<CollectDocsResult>;
94
+ //# sourceMappingURL=collect-docs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collect-docs.d.ts","sourceRoot":"","sources":["../../src/agent/collect-docs.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAe,KAAK,cAAc,EAAqB,MAAM,qBAAqB,CAAC;AAK1F,OAAO,EAA0B,KAAK,UAAU,EAAE,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACjG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