autokap 1.0.7 → 1.0.10

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 (301) hide show
  1. package/assets/cursors/macos.svg +4 -0
  2. package/assets/cursors/windows.svg +15 -0
  3. package/assets/skill/OPCODE-REFERENCE.md +635 -0
  4. package/assets/skill/README.md +39 -0
  5. package/assets/skill/SKILL.md +454 -468
  6. package/assets/skill/STUDIO-SKILL.md +476 -0
  7. package/assets/skill/references/examples.md +104 -0
  8. package/assets/skill/references/interactive-demo.md +225 -0
  9. package/assets/skill/references/mock-data.md +178 -0
  10. package/dist/action-verifier.d.ts +29 -0
  11. package/dist/action-verifier.js +133 -0
  12. package/dist/agent-action-recovery.d.ts +45 -0
  13. package/dist/agent-action-recovery.js +370 -0
  14. package/dist/agent-message-utils.d.ts +21 -0
  15. package/dist/agent-message-utils.js +77 -0
  16. package/dist/agent-url-utils.d.ts +30 -0
  17. package/dist/agent-url-utils.js +138 -0
  18. package/dist/agent.d.ts +92 -8
  19. package/dist/agent.js +2936 -781
  20. package/dist/ak-tree.d.ts +39 -0
  21. package/dist/ak-tree.js +368 -0
  22. package/dist/alt-text.d.ts +26 -0
  23. package/dist/alt-text.js +55 -0
  24. package/dist/auth-capture.d.ts +17 -0
  25. package/dist/auth-capture.js +197 -0
  26. package/dist/benchmark.d.ts +59 -0
  27. package/dist/benchmark.js +135 -0
  28. package/dist/billing-operation-logging.d.ts +3 -1
  29. package/dist/billing-operation-logging.js +4 -0
  30. package/dist/browser-bar.d.ts +14 -6
  31. package/dist/browser-bar.js +145 -8
  32. package/dist/browser-pool.d.ts +7 -0
  33. package/dist/browser-pool.js +15 -5
  34. package/dist/browser-utils.d.ts +31 -0
  35. package/dist/browser-utils.js +97 -0
  36. package/dist/browser.d.ts +61 -11
  37. package/dist/browser.js +1513 -59
  38. package/dist/capture-alt-text.js +2 -1
  39. package/dist/capture-encryption.d.ts +3 -1
  40. package/dist/capture-encryption.js +21 -6
  41. package/dist/capture-language-preflight.js +14 -0
  42. package/dist/capture-llm-page-identity.js +22 -10
  43. package/dist/capture-page-identity.d.ts +5 -7
  44. package/dist/capture-page-identity.js +211 -78
  45. package/dist/capture-preset-credentials.d.ts +50 -0
  46. package/dist/capture-preset-credentials.js +127 -0
  47. package/dist/capture-request-plan.d.ts +2 -2
  48. package/dist/capture-request-plan.js +64 -16
  49. package/dist/capture-run-optimizer.js +48 -33
  50. package/dist/capture-selector-memory.d.ts +5 -0
  51. package/dist/capture-selector-memory.js +18 -0
  52. package/dist/capture-strategy.d.ts +36 -0
  53. package/dist/capture-strategy.js +96 -0
  54. package/dist/capture-studio-sync.d.ts +1 -0
  55. package/dist/capture-studio-sync.js +9 -3
  56. package/dist/capture-surface-contract.d.ts +36 -0
  57. package/dist/capture-surface-contract.js +299 -0
  58. package/dist/capture-transition-engine.d.ts +28 -0
  59. package/dist/capture-transition-engine.js +292 -0
  60. package/dist/capture-variant-state.d.ts +2 -0
  61. package/dist/capture-variant-state.js +26 -0
  62. package/dist/capture-verification.d.ts +35 -0
  63. package/dist/capture-verification.js +95 -0
  64. package/dist/capture-viewport-lock.d.ts +48 -0
  65. package/dist/capture-viewport-lock.js +74 -0
  66. package/dist/circuit-breaker.d.ts +42 -0
  67. package/dist/circuit-breaker.js +119 -0
  68. package/dist/cli-config.d.ts +9 -1
  69. package/dist/cli-config.js +112 -7
  70. package/dist/cli-contract.d.ts +19 -0
  71. package/dist/cli-contract.js +173 -0
  72. package/dist/cli-runner-local.d.ts +12 -0
  73. package/dist/cli-runner-local.js +115 -0
  74. package/dist/cli-runner.d.ts +34 -0
  75. package/dist/cli-runner.js +580 -0
  76. package/dist/cli-utils.d.ts +0 -1
  77. package/dist/cli-utils.js +2 -5
  78. package/dist/cli.js +1011 -267
  79. package/dist/clip-begin-frame-recorder.d.ts +44 -0
  80. package/dist/clip-begin-frame-recorder.js +250 -0
  81. package/dist/clip-capture-backend.d.ts +25 -0
  82. package/dist/clip-capture-backend.js +189 -0
  83. package/dist/clip-capture-loop.d.ts +61 -0
  84. package/dist/clip-capture-loop.js +111 -0
  85. package/dist/clip-frame-recorder.d.ts +63 -0
  86. package/dist/clip-frame-recorder.js +305 -0
  87. package/dist/clip-orchestrator.js +9 -2
  88. package/dist/clip-postprocess.d.ts +31 -2
  89. package/dist/clip-postprocess.js +194 -68
  90. package/dist/clip-runtime.d.ts +18 -0
  91. package/dist/clip-runtime.js +67 -0
  92. package/dist/clip-scale.d.ts +10 -0
  93. package/dist/clip-scale.js +21 -0
  94. package/dist/clip-screencast-recorder.d.ts +42 -0
  95. package/dist/clip-screencast-recorder.js +242 -0
  96. package/dist/clip-sidecar.d.ts +54 -0
  97. package/dist/clip-sidecar.js +208 -0
  98. package/dist/cookie-dismiss.d.ts +2 -0
  99. package/dist/cookie-dismiss.js +48 -13
  100. package/dist/cost-logging.d.ts +8 -0
  101. package/dist/cost-logging.js +160 -46
  102. package/dist/cost-resolution-monitor.d.ts +16 -0
  103. package/dist/cost-resolution-monitor.js +34 -0
  104. package/dist/credential-templates.js +2 -2
  105. package/dist/cursor-overlay-script.d.ts +6 -0
  106. package/dist/cursor-overlay-script.js +169 -0
  107. package/dist/dom-css-purger.d.ts +65 -0
  108. package/dist/dom-css-purger.js +333 -0
  109. package/dist/dom-font-inliner.d.ts +45 -0
  110. package/dist/dom-font-inliner.js +148 -0
  111. package/dist/dom-patch-resolver.d.ts +52 -0
  112. package/dist/dom-patch-resolver.js +242 -0
  113. package/dist/dom-serializer.d.ts +82 -0
  114. package/dist/dom-serializer.js +378 -0
  115. package/dist/element-capture.d.ts +1 -41
  116. package/dist/element-capture.js +202 -446
  117. package/dist/env-validation.d.ts +5 -0
  118. package/dist/env-validation.js +63 -0
  119. package/dist/execution-schema.d.ts +4753 -0
  120. package/dist/execution-schema.js +563 -0
  121. package/dist/execution-types.d.ts +936 -0
  122. package/dist/execution-types.js +66 -0
  123. package/dist/fonts-loader.d.ts +14 -0
  124. package/dist/fonts-loader.js +55 -0
  125. package/dist/hybrid-navigator.js +12 -12
  126. package/dist/index.d.ts +11 -6
  127. package/dist/index.js +11 -4
  128. package/dist/legacy/agent-action-recovery.d.ts +45 -0
  129. package/dist/legacy/agent-action-recovery.js +370 -0
  130. package/dist/legacy/agent-message-utils.d.ts +21 -0
  131. package/dist/legacy/agent-message-utils.js +77 -0
  132. package/dist/legacy/agent-url-utils.d.ts +30 -0
  133. package/dist/legacy/agent-url-utils.js +138 -0
  134. package/dist/legacy/agent.d.ts +226 -0
  135. package/dist/legacy/agent.js +6666 -0
  136. package/dist/legacy/clip-orchestrator.d.ts +148 -0
  137. package/dist/legacy/clip-orchestrator.js +957 -0
  138. package/dist/legacy/credential-templates.d.ts +5 -0
  139. package/dist/legacy/credential-templates.js +60 -0
  140. package/dist/legacy/hybrid-navigator.d.ts +138 -0
  141. package/dist/legacy/hybrid-navigator.js +468 -0
  142. package/dist/legacy/llm-usage.d.ts +17 -0
  143. package/dist/legacy/llm-usage.js +45 -0
  144. package/dist/legacy/prompt-cache.d.ts +10 -0
  145. package/dist/legacy/prompt-cache.js +24 -0
  146. package/dist/legacy/prompts.d.ts +175 -0
  147. package/dist/legacy/prompts.js +1038 -0
  148. package/dist/legacy/tools.d.ts +4 -0
  149. package/dist/legacy/tools.js +216 -0
  150. package/dist/legacy/video-agent.d.ts +143 -0
  151. package/dist/legacy/video-agent.js +4788 -0
  152. package/dist/legacy/video-observation.d.ts +36 -0
  153. package/dist/legacy/video-observation.js +192 -0
  154. package/dist/legacy/video-planner.d.ts +12 -0
  155. package/dist/legacy/video-planner.js +501 -0
  156. package/dist/legacy/video-prompts.d.ts +37 -0
  157. package/dist/legacy/video-prompts.js +569 -0
  158. package/dist/legacy/video-tools.d.ts +3 -0
  159. package/dist/legacy/video-tools.js +59 -0
  160. package/dist/legacy/video-variant-state.d.ts +29 -0
  161. package/dist/legacy/video-variant-state.js +80 -0
  162. package/dist/legacy/vision-model.d.ts +17 -0
  163. package/dist/legacy/vision-model.js +74 -0
  164. package/dist/llm-healer.d.ts +55 -0
  165. package/dist/llm-healer.js +213 -0
  166. package/dist/llm-provider.d.ts +29 -0
  167. package/dist/llm-provider.js +83 -0
  168. package/dist/logger.d.ts +6 -2
  169. package/dist/logger.js +15 -1
  170. package/dist/mockup-html.js +35 -25
  171. package/dist/mockup.d.ts +95 -2
  172. package/dist/mockup.js +427 -166
  173. package/dist/mouse-animation.d.ts +2 -2
  174. package/dist/mouse-animation.js +34 -20
  175. package/dist/opcode-actions.d.ts +42 -0
  176. package/dist/opcode-actions.js +524 -0
  177. package/dist/opcode-runner.d.ts +51 -0
  178. package/dist/opcode-runner.js +779 -0
  179. package/dist/openrouter-client.d.ts +40 -0
  180. package/dist/openrouter-client.js +16 -0
  181. package/dist/overlay-engine.d.ts +24 -0
  182. package/dist/overlay-engine.js +176 -0
  183. package/dist/postcondition.d.ts +16 -0
  184. package/dist/postcondition.js +269 -0
  185. package/dist/program-patcher.d.ts +25 -0
  186. package/dist/program-patcher.js +44 -0
  187. package/dist/program-signing.d.ts +1094 -0
  188. package/dist/program-signing.js +140 -0
  189. package/dist/prompts.d.ts +13 -5
  190. package/dist/prompts.js +224 -351
  191. package/dist/provider-config.d.ts +17 -0
  192. package/dist/provider-config.js +42 -0
  193. package/dist/recovery-chain.d.ts +37 -0
  194. package/dist/recovery-chain.js +374 -0
  195. package/dist/remote-browser.d.ts +28 -4
  196. package/dist/remote-browser.js +60 -5
  197. package/dist/safari-browser-bar.d.ts +15 -0
  198. package/dist/safari-browser-bar.js +95 -0
  199. package/dist/safari-toolbar-asset.d.ts +15 -0
  200. package/dist/safari-toolbar-asset.js +12 -0
  201. package/dist/security.d.ts +2 -1
  202. package/dist/security.js +49 -10
  203. package/dist/selector-resolver.d.ts +34 -0
  204. package/dist/selector-resolver.js +181 -0
  205. package/dist/semantic-resolver.d.ts +35 -0
  206. package/dist/semantic-resolver.js +161 -0
  207. package/dist/server-capture-runtime.d.ts +5 -3
  208. package/dist/server-capture-runtime.js +42 -95
  209. package/dist/server-credit-usage.d.ts +2 -2
  210. package/dist/server-project-webhooks.d.ts +15 -1
  211. package/dist/server-project-webhooks.js +34 -8
  212. package/dist/server-screenshot-watermark.js +27 -5
  213. package/dist/session-profile.js +164 -1
  214. package/dist/sf-pro-symbols.d.ts +1 -0
  215. package/dist/sf-pro-symbols.js +55 -0
  216. package/dist/skill-packaging.d.ts +28 -0
  217. package/dist/skill-packaging.js +169 -0
  218. package/dist/smart-wait.d.ts +27 -0
  219. package/dist/smart-wait.js +81 -0
  220. package/dist/status-bar-render.d.ts +20 -0
  221. package/dist/status-bar-render.js +410 -0
  222. package/dist/status-bar.d.ts +9 -0
  223. package/dist/status-bar.js +298 -14
  224. package/dist/svg-browser-bar.d.ts +33 -0
  225. package/dist/svg-browser-bar.js +206 -0
  226. package/dist/svg-status-bar.d.ts +36 -0
  227. package/dist/svg-status-bar.js +597 -0
  228. package/dist/svg-text.d.ts +61 -0
  229. package/dist/svg-text.js +118 -0
  230. package/dist/tools.js +89 -451
  231. package/dist/types.d.ts +248 -7
  232. package/dist/types.js +23 -1
  233. package/dist/v2/action-verifier.d.ts +29 -0
  234. package/dist/v2/action-verifier.js +133 -0
  235. package/dist/v2/alt-text.d.ts +26 -0
  236. package/dist/v2/alt-text.js +55 -0
  237. package/dist/v2/benchmark.d.ts +59 -0
  238. package/dist/v2/benchmark.js +135 -0
  239. package/dist/v2/capture-strategy.d.ts +30 -0
  240. package/dist/v2/capture-strategy.js +67 -0
  241. package/dist/v2/capture-verification.d.ts +35 -0
  242. package/dist/v2/capture-verification.js +95 -0
  243. package/dist/v2/circuit-breaker.d.ts +42 -0
  244. package/dist/v2/circuit-breaker.js +119 -0
  245. package/dist/v2/cli-runner-local.d.ts +11 -0
  246. package/dist/v2/cli-runner-local.js +91 -0
  247. package/dist/v2/cli-runner.d.ts +34 -0
  248. package/dist/v2/cli-runner.js +300 -0
  249. package/dist/v2/compiler-prompts.d.ts +27 -0
  250. package/dist/v2/compiler-prompts.js +123 -0
  251. package/dist/v2/compiler.d.ts +37 -0
  252. package/dist/v2/compiler.js +147 -0
  253. package/dist/v2/explorer.d.ts +41 -0
  254. package/dist/v2/explorer.js +56 -0
  255. package/dist/v2/index.d.ts +37 -0
  256. package/dist/v2/index.js +31 -0
  257. package/dist/v2/llm-healer.d.ts +62 -0
  258. package/dist/v2/llm-healer.js +166 -0
  259. package/dist/v2/llm-provider.d.ts +29 -0
  260. package/dist/v2/llm-provider.js +80 -0
  261. package/dist/v2/opcode-runner.d.ts +47 -0
  262. package/dist/v2/opcode-runner.js +634 -0
  263. package/dist/v2/overlay-engine.d.ts +24 -0
  264. package/dist/v2/overlay-engine.js +150 -0
  265. package/dist/v2/postcondition.d.ts +16 -0
  266. package/dist/v2/postcondition.js +249 -0
  267. package/dist/v2/program-patcher.d.ts +25 -0
  268. package/dist/v2/program-patcher.js +44 -0
  269. package/dist/v2/recovery-chain.d.ts +30 -0
  270. package/dist/v2/recovery-chain.js +368 -0
  271. package/dist/v2/schema.d.ts +2580 -0
  272. package/dist/v2/schema.js +295 -0
  273. package/dist/v2/selector-resolver.d.ts +34 -0
  274. package/dist/v2/selector-resolver.js +181 -0
  275. package/dist/v2/semantic-resolver.d.ts +35 -0
  276. package/dist/v2/semantic-resolver.js +161 -0
  277. package/dist/v2/smart-wait.d.ts +27 -0
  278. package/dist/v2/smart-wait.js +81 -0
  279. package/dist/v2/types.d.ts +444 -0
  280. package/dist/v2/types.js +19 -0
  281. package/dist/v2/web-playwright-local.d.ts +69 -0
  282. package/dist/v2/web-playwright-local.js +392 -0
  283. package/dist/version.d.ts +1 -0
  284. package/dist/version.js +5 -0
  285. package/dist/video-agent.js +18 -13
  286. package/dist/video-planner.js +2 -1
  287. package/dist/video-prompts.js +3 -3
  288. package/dist/web-playwright-local.d.ts +156 -0
  289. package/dist/web-playwright-local.js +989 -0
  290. package/dist/ws-auth.js +4 -1
  291. package/dist/ws-broadcast.d.ts +34 -0
  292. package/dist/ws-broadcast.js +85 -0
  293. package/dist/ws-connection-limits.d.ts +12 -0
  294. package/dist/ws-connection-limits.js +44 -0
  295. package/dist/ws-handler-utils.d.ts +32 -0
  296. package/dist/ws-handler-utils.js +139 -0
  297. package/dist/ws-handler.js +294 -164
  298. package/dist/ws-metrics-server.d.ts +9 -0
  299. package/dist/ws-metrics-server.js +31 -0
  300. package/dist/ws-server.js +41 -1
  301. package/package.json +62 -35
@@ -0,0 +1,4 @@
1
+ <svg width="28" height="29" viewBox="0 0 28 29" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M14.501 11.8601L22.884 20.2611C23.937 21.3171 23.19 23.1191 21.699 23.1191L20.475 23.119L21.6908 26.0067C21.9038 26.5127 21.9068 27.0727 21.6998 27.5817C21.4918 28.0917 21.0978 28.4897 20.5898 28.7027C20.3338 28.8097 20.0658 28.8637 19.7918 28.8637C18.9608 28.8637 18.2158 28.3687 17.8938 27.6027L16.616 24.565L15.784 25.3031C14.703 26.2591 13 25.4921 13 24.0481V12.4811C13 11.6971 13.947 11.3051 14.501 11.8601Z" fill="white"/>
3
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M13.9995 13.1292C13.9995 12.9982 14.1585 12.9322 14.2505 13.0252L22.1585 20.9502C22.5895 21.3822 22.2835 22.1192 21.6735 22.1192L18.9695 22.1177L20.7691 26.3936C20.9961 26.9336 20.7421 27.5546 20.2031 27.7806C19.6621 28.0076 19.0421 27.7546 18.8161 27.2156L16.9985 22.8917L15.1385 24.5392C14.7225 24.9072 14.0806 24.6507 14.0066 24.1274L13.9995 24.0262V13.1292Z" fill="black"/>
4
+ </svg>
@@ -0,0 +1,15 @@
1
+ <svg width="28" height="28" viewBox="0 0 28 28" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <g clip-path="url(#clip0_575_755)">
3
+ <mask id="mask0_575_755" style="mask-type:luminance" maskUnits="userSpaceOnUse" x="0" y="0" width="28" height="28">
4
+ <path d="M28 0H0V28H28V0Z" fill="white"/>
5
+ </mask>
6
+ <g mask="url(#mask0_575_755)">
7
+ <path d="M15.1388 23.7243L15.1355 23.7274C15.1355 23.7274 15.1322 23.7289 15.1296 23.7298C15.1186 23.7338 15.1046 23.7364 15.0911 23.7364C15.0409 23.7364 15 23.6978 15 23.6505V13.0765C15 13.0631 15.0091 13.0333 15.0565 13.012C15.0948 12.9948 15.1274 12.9974 15.1526 13.0115L23.3195 20.7147C23.3441 20.7458 23.3531 20.7662 23.3565 20.7754C23.3599 20.7848 23.36 20.7895 23.36 20.7926C23.36 20.84 23.3191 20.8786 23.2689 20.8786H19.6763L21.6633 25.2605L19.8237 26.0044L17.7977 21.5384L15.1388 23.7243Z" fill="white" stroke="black"/>
8
+ </g>
9
+ </g>
10
+ <defs>
11
+ <clipPath id="clip0_575_755">
12
+ <rect width="28" height="28" fill="white"/>
13
+ </clipPath>
14
+ </defs>
15
+ </svg>
@@ -0,0 +1,635 @@
1
+ # AutoKap Opcode Reference
2
+
3
+ Detailed parameter documentation for all 25 opcodes. For workflow, rules, and examples, see [SKILL.md](SKILL.md).
4
+
5
+ ## Common Fields (all opcodes)
6
+
7
+ | Field | Type | Required | Default | Description |
8
+ |-------|------|----------|---------|-------------|
9
+ | `kind` | string | yes | — | Opcode type (see sections below) |
10
+ | `description` | string | yes | — | Human-readable description of this step |
11
+ | `postcondition` | PostconditionSpec | yes | — | Condition that must hold after execution |
12
+ | `recovery` | RecoveryPolicy | yes | — | Recovery behavior on failure |
13
+ | `timeoutMs` | number | yes | 15000 | Max time (ms) including recovery |
14
+ | `maxFailures` | number | yes | 3 | Max recovery attempts before fatal |
15
+
16
+ ### RecoveryPolicy
17
+
18
+ | Field | Type | Default | Description |
19
+ |-------|------|---------|-------------|
20
+ | `retries` | number (0-10) | 2 | Deterministic retry attempts |
21
+ | `useSelectorMemory` | boolean | true | Try known-good selectors from previous runs |
22
+ | `useAltInteraction` | boolean | true | Try keyboard/JS/coordinate click |
23
+ | `allowReload` | boolean | false | Reload page and retry. **Use sparingly** — loses UI state (open modals, form data). Only safe after full page transitions. |
24
+ | `allowHealer` | boolean | true | Allow LLM to rewrite the failing opcode as last resort |
25
+
26
+ ### SemanticTarget (optional on interaction opcodes)
27
+
28
+ Fallback when CSS selector fails. The runtime resolves via Playwright semantic locators, then AKTree fuzzy matching.
29
+
30
+ | Field | Type | Description |
31
+ |-------|------|-------------|
32
+ | `text` | string | Visible text content (substring match by default) |
33
+ | `role` | string | ARIA role: `"button"`, `"link"`, `"textbox"`, `"checkbox"`, `"tab"`, `"menuitem"` |
34
+ | `label` | string | `aria-label`, associated `<label>` text, or `title` attribute |
35
+ | `near` | string | Nearby text for disambiguation (e.g. `"in the pricing section"`) |
36
+ | `placeholder` | string | Input placeholder text |
37
+ | `exact` | boolean | If `true`, match text exactly. Default: `false` (substring) |
38
+
39
+ ### PostconditionSpec
40
+
41
+ | Field | Type | Used by | Description |
42
+ |-------|------|---------|-------------|
43
+ | `type` | string | all | One of the 8 postcondition types (see SKILL.md) |
44
+ | `pattern` | string | `route_matches` | URL glob pattern (`*` = segment, `**` = any path) |
45
+ | `selector` | string | `element_visible`, `element_absent`, `text_contains` | CSS selector to check |
46
+ | `text` | string | `text_contains` | Expected text substring |
47
+ | `threshold` | number (0-1) | `screenshot_stable` | Pixel diff tolerance. Default: `0.01` |
48
+ | `waitMs` | number | all except `always` | Max polling time (ms). Default: `5000` |
49
+
50
+ ---
51
+
52
+ ## NAVIGATE
53
+
54
+ Navigate to a URL.
55
+
56
+ | Param | Type | Required | Description |
57
+ |-------|------|----------|-------------|
58
+ | `url` | string | yes | Full URL to navigate to |
59
+
60
+ **Can:** Load any URL, follow redirects, handle SPA route changes.
61
+ **Cannot:** Open new tabs/windows. Use CLICK with `button: "middle"` for that.
62
+
63
+ ```json
64
+ { "kind": "NAVIGATE", "url": "https://app.example.com/pricing", "postcondition": { "type": "route_matches", "pattern": "/pricing" } }
65
+ ```
66
+
67
+ ## DISMISS_OVERLAYS
68
+
69
+ Automatically dismisses cookie banners, newsletter popups, chat widgets, and age gates. Multi-pass: adapter dismissal, Escape key, close-button clicks (multilingual patterns).
70
+
71
+ No additional parameters.
72
+
73
+ **Can:** Handle common overlays in any language (en, fr, de, es, it patterns).
74
+ **Cannot:** Dismiss overlays that require form input (e.g. age verification with date entry) or CAPTCHAs.
75
+
76
+ ```json
77
+ { "kind": "DISMISS_OVERLAYS", "postcondition": { "type": "overlay_dismissed" } }
78
+ ```
79
+
80
+ ## CLICK
81
+
82
+ Click an element.
83
+
84
+ | Param | Type | Required | Default | Description |
85
+ |-------|------|----------|---------|-------------|
86
+ | `selector` | string | yes | — | CSS selector (use `data-ak` attributes) |
87
+ | `target` | SemanticTarget | no | — | Fallback for recovery chain |
88
+ | `button` | `"right"` \| `"middle"` | no | left | `"right"` = context menu, `"middle"` = new tab |
89
+ | `fingerprint` | string | no | — | AKTree fingerprint for fuzzy matching |
90
+ | `selectorAlternates` | string[] | no | — | Alternative selectors tried in order |
91
+
92
+ **Can:** Left/right/middle click, trigger navigation, open modals, toggle dropdowns.
93
+ **Cannot:** Drag-and-drop, long-press, touch gestures.
94
+
95
+ ```json
96
+ { "kind": "CLICK", "selector": "[data-ak=\"pricing-btn\"]", "postcondition": { "type": "element_visible", "selector": "[data-ak=\"pricing-modal\"]", "waitMs": 5000 } }
97
+ ```
98
+
99
+ ## TYPE
100
+
101
+ Type text into a form field.
102
+
103
+ | Param | Type | Required | Default | Description |
104
+ |-------|------|----------|---------|-------------|
105
+ | `selector` | string | yes | — | CSS selector of the input/textarea |
106
+ | `text` | string | yes | — | Text to type. Use `{{email}}` / `{{password}}` for credentials |
107
+ | `clearFirst` | boolean | yes | true | Clear existing value before typing |
108
+ | `target` | SemanticTarget | no | — | Fallback for recovery chain |
109
+ | `fingerprint` | string | no | — | AKTree fingerprint |
110
+ | `selectorAlternates` | string[] | no | — | Alternative selectors |
111
+
112
+ **Can:** Type into text inputs, textareas, contenteditable elements. Clear existing values. Use credential placeholders.
113
+ **Cannot:** Type into file inputs (use file upload instead). Paste from clipboard.
114
+
115
+ ```json
116
+ { "kind": "TYPE", "selector": "[data-ak=\"search-input\"]", "text": "dashboard", "clearFirst": true, "postcondition": { "type": "any_change" } }
117
+ ```
118
+
119
+ ## PRESS_KEY
120
+
121
+ Press a keyboard key.
122
+
123
+ | Param | Type | Required | Description |
124
+ |-------|------|----------|-------------|
125
+ | `key` | string | yes | Key name: `"Enter"`, `"Escape"`, `"Tab"`, `"ArrowDown"`, `"Backspace"`, etc. |
126
+
127
+ **Can:** Submit forms (Enter), close modals (Escape), navigate focus (Tab), trigger keyboard shortcuts.
128
+ **Cannot:** Key combinations (Ctrl+C, Cmd+V). For shortcuts, use the individual key name that Playwright supports.
129
+
130
+ ```json
131
+ { "kind": "PRESS_KEY", "key": "Enter", "postcondition": { "type": "any_change" } }
132
+ ```
133
+
134
+ ## WAIT_FOR
135
+
136
+ Wait for an element to appear.
137
+
138
+ | Param | Type | Required | Default | Description |
139
+ |-------|------|----------|---------|-------------|
140
+ | `selector` | string | no* | — | CSS selector to wait for |
141
+ | `target` | SemanticTarget | no* | — | Semantic target to wait for |
142
+ | `state` | `"visible"` \| `"attached"` | yes | — | `"visible"` = rendered and visible. `"attached"` = in DOM but may be hidden |
143
+
144
+ *At least one of `selector` or `target` is required.
145
+
146
+ **Can:** Wait for page content to load, modals to appear, dynamic elements to render.
147
+ **Cannot:** Wait for network requests or API responses directly. Use `state: "attached"` for elements that exist in DOM but are initially hidden (e.g. lazy-loaded tabs).
148
+
149
+ ```json
150
+ { "kind": "WAIT_FOR", "selector": "[data-ak=\"dashboard\"]", "state": "visible", "postcondition": { "type": "element_visible", "selector": "[data-ak=\"dashboard\"]", "waitMs": 10000 } }
151
+ ```
152
+
153
+ ## SCROLL
154
+
155
+ Scroll the page or scroll an element into view.
156
+
157
+ | Param | Type | Required | Default | Description |
158
+ |-------|------|----------|---------|-------------|
159
+ | `direction` | `"up"` \| `"down"` \| `"left"` \| `"right"` | yes | — | Scroll direction |
160
+ | `amount` | number | no | viewport height | Pixels to scroll |
161
+ | `targetSelector` | string | no | — | CSS selector to scroll into view |
162
+ | `target` | SemanticTarget | no | — | Semantic target to scroll into view |
163
+
164
+ **Can:** Scroll page in any direction, scroll specific element into view, scroll by pixel amount.
165
+ **Cannot:** Scroll inside a specific scrollable container (always scrolls the page). For nested scrollable areas, use CLICK to focus the container first.
166
+
167
+ **Tip:** When `targetSelector` is provided, the runtime scrolls the element into view regardless of `direction`/`amount`. Use `direction` + `amount` for blind scrolling, `targetSelector` for precise positioning.
168
+
169
+ ```json
170
+ { "kind": "SCROLL", "direction": "down", "targetSelector": "[data-ak=\"pricing\"]", "postcondition": { "type": "element_visible", "selector": "[data-ak=\"pricing\"]" } }
171
+ ```
172
+
173
+ ## HOVER
174
+
175
+ Hover over an element.
176
+
177
+ | Param | Type | Required | Description |
178
+ |-------|------|----------|-------------|
179
+ | `selector` | string | yes | CSS selector |
180
+ | `target` | SemanticTarget | no | Fallback for recovery chain |
181
+ | `fingerprint` | string | no | AKTree fingerprint |
182
+ | `selectorAlternates` | string[] | no | Alternative selectors |
183
+
184
+ **Can:** Trigger tooltips, dropdown menus, CSS `:hover` states, hover cards.
185
+ **Cannot:** Hover state persists only until the next interaction. If you need to capture a hover state, place CAPTURE_SCREENSHOT immediately after HOVER.
186
+
187
+ ```json
188
+ { "kind": "HOVER", "selector": "[data-ak=\"nav-products\"]", "postcondition": { "type": "element_visible", "selector": "[data-ak=\"products-dropdown\"]", "waitMs": 3000 } }
189
+ ```
190
+
191
+ ## SELECT_OPTION
192
+
193
+ Select an option in a **native `<select>` element**.
194
+
195
+ | Param | Type | Required | Description |
196
+ |-------|------|----------|-------------|
197
+ | `selector` | string | yes | CSS selector of the `<select>` element |
198
+ | `optionLabel` | string | no* | Select by visible label text |
199
+ | `optionValue` | string | no* | Select by `value` attribute |
200
+ | `optionIndex` | number | no* | Select by zero-based index |
201
+ | `target` | SemanticTarget | no | Fallback for recovery chain |
202
+ | `fingerprint` | string | no | AKTree fingerprint |
203
+ | `selectorAlternates` | string[] | no | Alternative selectors |
204
+
205
+ *Exactly one of `optionLabel`, `optionValue`, or `optionIndex` must be provided. Prefer `optionLabel` for readability.
206
+
207
+ **Can:** Select from native `<select>` dropdowns.
208
+ **Cannot:** Select from custom dropdowns (Radix Select, Headless UI Listbox, MUI Select, cmdk). For custom dropdowns, use a CLICK + WAIT_FOR + CLICK sequence: click to open, wait for options, click the option.
209
+
210
+ ```json
211
+ { "kind": "SELECT_OPTION", "selector": "[data-ak=\"country-select\"]", "optionLabel": "France", "postcondition": { "type": "text_contains", "selector": "[data-ak=\"country-select\"]", "text": "France" } }
212
+ ```
213
+
214
+ ## CHECK
215
+
216
+ Set a checkbox or toggle to a specific state.
217
+
218
+ | Param | Type | Required | Description |
219
+ |-------|------|----------|-------------|
220
+ | `selector` | string | yes | CSS selector of the checkbox/toggle |
221
+ | `checked` | boolean | yes | `true` = checked, `false` = unchecked |
222
+ | `target` | SemanticTarget | no | Fallback for recovery chain |
223
+ | `fingerprint` | string | no | AKTree fingerprint |
224
+ | `selectorAlternates` | string[] | no | Alternative selectors |
225
+
226
+ **Can:** Idempotently set checkbox state. Safer than CLICK because it sets the desired state directly without toggling.
227
+ **Cannot:** Interact with custom toggle components that don't use native checkbox semantics. For those, use CLICK.
228
+
229
+ ```json
230
+ { "kind": "CHECK", "selector": "[data-ak=\"terms-checkbox\"]", "checked": true, "postcondition": { "type": "always" } }
231
+ ```
232
+
233
+ ## DOUBLE_CLICK
234
+
235
+ Double-click an element.
236
+
237
+ | Param | Type | Required | Description |
238
+ |-------|------|----------|-------------|
239
+ | `selector` | string | yes | CSS selector |
240
+ | `target` | SemanticTarget | no | Fallback for recovery chain |
241
+ | `fingerprint` | string | no | AKTree fingerprint |
242
+ | `selectorAlternates` | string[] | no | Alternative selectors |
243
+
244
+ **Can:** Trigger inline editing, text selection, and any UI that responds to `dblclick`.
245
+ **Cannot:** Triple-click (select paragraph). Use TYPE with `clearFirst: true` to replace full text content instead.
246
+
247
+ ```json
248
+ { "kind": "DOUBLE_CLICK", "selector": "[data-ak=\"editable-title\"]", "postcondition": { "type": "element_visible", "selector": "[data-ak=\"title-editor\"]", "waitMs": 3000 } }
249
+ ```
250
+
251
+ ## DRAG
252
+
253
+ Drag the source element from point A to point B with an animated cursor. In clip recordings the cursor overlay glides along a Bezier curve, shows a pressed state during the drag, and emits a drop pulse at the destination.
254
+
255
+ | Param | Type | Required | Description |
256
+ |-------|------|----------|-------------|
257
+ | `selector` | string | yes | CSS selector of the source element (the one being dragged) |
258
+ | `target` | SemanticTarget | no | Semantic fallback for the source |
259
+ | `fingerprint` | string | no | AKTree fingerprint for the source |
260
+ | `selectorAlternates` | string[] | no | Alternative source selectors |
261
+ | `toSelector` | string | no* | CSS selector of the drop target element |
262
+ | `toTarget` | SemanticTarget | no* | Semantic fallback for the drop target |
263
+ | `toSelectorAlternates` | string[] | no | Alternative destination selectors |
264
+ | `offset` | `{ dx: number, dy: number }` | no* | Pixel offset from the source center (use for sliders, canvas drawing, or any drop that isn't a DOM node) |
265
+
266
+ *Provide EITHER `toSelector` / `toTarget` (element drag) OR `offset` (relative drag). Not both.
267
+
268
+ **Can:** Element-to-element drag (Kanban columns, sortable lists), slider adjustments, canvas drawing, any interaction driven by mousedown + mousemove + mouseup. Works with native HTML5 drag, dnd-kit, react-dnd, Radix DnD primitives — `page.mouse.*` fires both mouse and pointer events.
269
+ **Cannot:** Multi-touch gestures, drag between different browser windows, file drops (use a file input instead).
270
+
271
+ ```json
272
+ { "kind": "DRAG", "selector": "[data-ak=\"task-card-todo-1\"]", "toSelector": "[data-ak=\"column-in-progress\"]", "postcondition": { "type": "element_visible", "selector": "[data-ak=\"column-in-progress\"] [data-ak=\"task-card-todo-1\"]", "waitMs": 3000 } }
273
+ ```
274
+
275
+ ```json
276
+ { "kind": "DRAG", "selector": "[data-ak=\"volume-slider-thumb\"]", "offset": { "dx": 120, "dy": 0 }, "postcondition": { "type": "any_change" } }
277
+ ```
278
+
279
+ ## SET_LOCALE
280
+
281
+ Set the application's locale/language for the current variant.
282
+
283
+ | Param | Type | Required | Description |
284
+ |-------|------|----------|-------------|
285
+ | `locale` | string | yes | BCP-47 locale (e.g. `"fr"`, `"en-US"`). Use `"$variant"` for runtime substitution |
286
+ | `method` | `"browser_context"` \| `"ui_interaction"` \| `"storage"` | yes | How to apply the locale |
287
+ | `selector` | string | no | Element to click (for `ui_interaction` only) |
288
+ | `storageHints` | StorageHint[] | no | Storage writes (for `storage` only) |
289
+
290
+ **StorageHint:** `{ "storage": "localStorage" | "sessionStorage" | "cookie", "key": string, "value": string }`
291
+
292
+ **Can:** Switch locale via storage writes (instant, reliable), browser context, or UI click.
293
+ **Cannot:** Handle URL-based routing (e.g. `/fr/page`). For URL-based i18n, use NAVIGATE with the locale path.
294
+
295
+ **Method decision tree:**
296
+ - **next-intl** -> `method: "storage"`, `storage: "cookie"`, key: `"NEXT_LOCALE"`
297
+ - **i18next / react-intl** -> `method: "storage"`, `storage: "localStorage"`, key: `"i18nextLng"`
298
+ - **URL-based** (e.g. `/fr/page`) -> Use NAVIGATE instead
299
+ - **Browser-level only** -> `method: "browser_context"`
300
+
301
+ ```json
302
+ { "kind": "SET_LOCALE", "locale": "$variant", "method": "storage", "storageHints": [{ "storage": "cookie", "key": "NEXT_LOCALE", "value": "$variant" }], "postcondition": { "type": "always" } }
303
+ ```
304
+
305
+ ## SET_THEME
306
+
307
+ Set the application's color theme for the current variant.
308
+
309
+ | Param | Type | Required | Description |
310
+ |-------|------|----------|-------------|
311
+ | `theme` | `"light"` \| `"dark"` \| `"$variant"` | yes | Target theme. Use `"$variant"` for runtime substitution |
312
+ | `method` | `"color_scheme"` \| `"ui_interaction"` \| `"storage"` | yes | How to apply the theme |
313
+ | `selector` | string | no | Element to click (for `ui_interaction` only) |
314
+ | `storageHints` | StorageHint[] | no | Storage writes (for `storage` only) |
315
+
316
+ **Can:** Switch theme via storage writes (instant, reliable), CSS `prefers-color-scheme`, or UI click.
317
+ **Cannot:** Handle complex theme systems with more than light/dark (e.g. "system", "sepia"). For those, use `method: "storage"` with the exact value the app expects.
318
+
319
+ **Method decision tree:**
320
+ - **next-themes** -> `method: "storage"`, `storage: "localStorage"`, key: `"theme"`
321
+ - **CSS only** (reads `prefers-color-scheme`) -> `method: "color_scheme"`
322
+ - **Custom storage** -> `method: "storage"` with app-specific key
323
+
324
+ ```json
325
+ { "kind": "SET_THEME", "theme": "$variant", "method": "storage", "storageHints": [{ "storage": "localStorage", "key": "theme", "value": "$variant" }], "postcondition": { "type": "always" } }
326
+ ```
327
+
328
+ ## ASSERT_ROUTE
329
+
330
+ Assert the current URL matches a pattern. Pure validation, no navigation.
331
+
332
+ | Param | Type | Required | Description |
333
+ |-------|------|----------|-------------|
334
+ | `urlPattern` | string | yes | URL glob pattern (`*` = segment, `**` = any path) |
335
+
336
+ **Can:** Validate the browser is on the expected page. Useful as a checkpoint before capture.
337
+ **Cannot:** Navigate or change the URL. Use NAVIGATE for that.
338
+
339
+ ```json
340
+ { "kind": "ASSERT_ROUTE", "urlPattern": "/dashboard/**", "postcondition": { "type": "route_matches", "pattern": "/dashboard/**" } }
341
+ ```
342
+
343
+ ## ASSERT_SURFACE
344
+
345
+ Assert that specific elements are visible on the page. Pure validation.
346
+
347
+ | Param | Type | Required | Default | Description |
348
+ |-------|------|----------|---------|-------------|
349
+ | `selectors` | string[] | yes | — | CSS selectors that must be visible |
350
+ | `matchAll` | boolean | yes | true | `true` = ALL must match, `false` = ANY one suffices |
351
+
352
+ **Can:** Validate page state before capture. Confirm multiple elements are rendered.
353
+ **Cannot:** Interact with elements or wait for them. Use WAIT_FOR for dynamic elements.
354
+
355
+ ```json
356
+ { "kind": "ASSERT_SURFACE", "selectors": ["[data-ak=\"header\"]", "[data-ak=\"sidebar\"]"], "matchAll": true, "postcondition": { "type": "always" } }
357
+ ```
358
+
359
+ ## CAPTURE_SCREENSHOT
360
+
361
+ Capture a screenshot of the viewport or a specific element.
362
+
363
+ | Param | Type | Required | Description |
364
+ |-------|------|----------|-------------|
365
+ | `captureId` | string | no | Stable identifier for Studio/dev links. Should match preset page/element id |
366
+ | `captureName` | string | no | Human-readable label shown in Studio |
367
+ | `elementSelector` | string | no | CSS selector for element-level capture (crops to element bounds) |
368
+
369
+ **Can:** Full-page viewport capture, element-level capture (cropped), LLM verification (detects blank/error/loading/overlay states), alt text generation, favicon extraction.
370
+ **Cannot:** Capture content below the fold in a single shot (use SCROLL first). Capture cross-origin iframe content.
371
+
372
+ **Tip:** Without `elementSelector`, captures the full viewport. With `elementSelector`, captures only that element's bounding box — useful for component-level screenshots.
373
+
374
+ ```json
375
+ { "kind": "CAPTURE_SCREENSHOT", "captureId": "dashboard-main", "captureName": "Dashboard", "elementSelector": "[data-ak=\"main-content\"]", "postcondition": { "type": "always" } }
376
+ ```
377
+
378
+ ## CAPTURE_DOM
379
+
380
+ Capture a DOM snapshot for an interactive demo state.
381
+
382
+ | Param | Type | Required | Description |
383
+ |-------|------|----------|-------------|
384
+ | `stateName` | string | yes | Stable state identifier used by the interactive demo player |
385
+ | `selector` | string | no | CSS selector of a focused subtree to serialize instead of the whole page |
386
+
387
+ **Can:** Capture the full page DOM for a state, or a focused subtree when only part of the page matters. Feed the interactive demo player with a state that can later host fragments and transitions.
388
+ **Cannot:** Produce screenshots or clips. Use only when `mediaMode` is `dom`.
389
+
390
+ **Tip:** Omit `selector` for page-level states. Add it when the interactive demo should ignore surrounding chrome and serialize only a mounted area.
391
+
392
+ ```json
393
+ { "kind": "CAPTURE_DOM", "stateName": "dashboard-default", "selector": "[data-ak=\"dashboard-shell\"]", "postcondition": { "type": "always" } }
394
+ ```
395
+
396
+ ## CAPTURE_FRAGMENT
397
+
398
+ Capture a local DOM fragment that mounts on top of a previously captured state.
399
+
400
+ | Param | Type | Required | Description |
401
+ |-------|------|----------|-------------|
402
+ | `fragmentName` | string | yes | Stable fragment identifier |
403
+ | `parentState` | string | yes | Name of the CAPTURE_DOM state this fragment belongs to |
404
+ | `selector` | string | yes | CSS selector of the fragment root to serialize |
405
+ | `variantName` | string | no | Optional named fragment variant for in-place swaps |
406
+ | `triggerSelector` | string | no | Selector of the element that should trigger this fragment in the player |
407
+ | `mountStrategy` | `"replace"` \| `"append"` | no | How the player should mount the fragment relative to the parent state |
408
+
409
+ **Can:** Capture modals, popovers, dropdowns, drawers, or any local subtree that should be replayed on top of a parent state. Capture multiple variants of the same fragment to enable in-place swaps in the player.
410
+ **Cannot:** Stand alone without a `parentState`. Replace full-page routing states; use CAPTURE_DOM for those.
411
+
412
+ **Tip:** Use `variantName` when the same fragment can appear in multiple visual forms, such as color/theme swaps or alternate content blocks on the same background state.
413
+
414
+ ```json
415
+ { "kind": "CAPTURE_FRAGMENT", "fragmentName": "pricing-modal", "parentState": "dashboard-default", "selector": "[data-ak=\"pricing-modal\"]", "triggerSelector": "[data-ak=\"open-pricing\"]", "mountStrategy": "append", "postcondition": { "type": "always" } }
416
+ ```
417
+
418
+ ## BEGIN_CLIP
419
+
420
+ Start recording a clip. All interactions between BEGIN_CLIP and END_CLIP are recorded.
421
+
422
+ | Param | Type | Required | Description |
423
+ |-------|------|----------|-------------|
424
+ | `clipId` | string | no | Stable identifier for Studio/dev links. Should match preset clip id |
425
+ | `clipName` | string | no | Human-readable label shown in Studio |
426
+
427
+ **Can:** Record viewport interactions as a clip.
428
+ **Cannot:** Record element-level clips (always full viewport). Record audio.
429
+
430
+ ```json
431
+ { "kind": "BEGIN_CLIP", "clipId": "open-modal-flow", "clipName": "Open modal", "postcondition": { "type": "always" } }
432
+ ```
433
+
434
+ ## END_CLIP
435
+
436
+ Stop recording the clip. Must pair with a prior BEGIN_CLIP.
437
+
438
+ | Param | Type | Required | Description |
439
+ |-------|------|----------|-------------|
440
+ | `clipId` | string | no | Must match the BEGIN_CLIP's `clipId` |
441
+ | `clipName` | string | no | Must match the BEGIN_CLIP's `clipName` |
442
+
443
+ **Can:** Finalize recording and produce GIF/MP4 artifact.
444
+ **Cannot:** Trim or edit the recording. The full BEGIN_CLIP to END_CLIP duration is captured.
445
+
446
+ ```json
447
+ { "kind": "END_CLIP", "clipId": "open-modal-flow", "clipName": "Open modal", "postcondition": { "type": "always" } }
448
+ ```
449
+
450
+ ## CLONE_ELEMENT
451
+
452
+ Duplicate a template element N times into a container. **Non-blocking** — if a selector misses, the opcode is skipped and the run continues.
453
+
454
+ | Param | Type | Required | Default | Description |
455
+ |-------|------|----------|---------|-------------|
456
+ | `sourceSelector` | string | yes | — | CSS selector of the element to clone |
457
+ | `containerSelector` | string | yes | — | CSS selector of the container that receives the clones |
458
+ | `count` | number (1-500) | yes | — | Number of clones to produce |
459
+ | `removeSource` | boolean | no | false | If true, remove the template after cloning (template must be a child of the container) |
460
+
461
+ **Can:** Duplicate any DOM node including its descendants and attributes. Optionally remove the source after cloning.
462
+ **Cannot:** Clone content from cross-origin iframes. Clone the shadow tree of Web Components (only the host is cloned).
463
+
464
+ **Soft-failure semantics:** Throws if `sourceSelector` or `containerSelector` is missing. The runner converts the throw into `status: "skipped"` and the variant continues.
465
+
466
+ ```json
467
+ { "kind": "CLONE_ELEMENT", "description": "Clone customer row 5 times", "sourceSelector": "[data-ak=\"customer-row\"]", "containerSelector": "[data-ak=\"customers-tbody\"]", "count": 5, "postcondition": { "type": "always" }, "recovery": { "retries": 0, "useSelectorMemory": false, "useAltInteraction": false, "allowReload": false, "allowHealer": false }, "timeoutMs": 5000, "maxFailures": 1 }
468
+ ```
469
+
470
+ ## INJECT_MOCK_DATA
471
+
472
+ Orchestrator opcode that fills a fillable region with mock data. Carries fields for **two complementary delivery mechanisms** and applies BOTH whenever they are wired:
473
+
474
+ - **Clone**: clones a template DOM element N times into a container and writes each slot value into the cloned descendants. Provides instant visual feedback even before any state-driven re-render. Works for any container whose children are pure markup the runtime can mutate.
475
+ - **Trigger**: writes the JSON-encoded `defaultValues` array into a hidden `<input>` the user's app exposed, then clicks a hidden trigger element via `element.click()`. The user's `onClick` handler reads the input, parses the JSON, and re-renders the widget through normal React/Vue/Svelte state updates. Survives any future re-renders that would clobber the cloned DOM, and works for libraries that own their DOM (Chart.js, Recharts, D3).
476
+
477
+ The two mechanisms are independent and additive. **Wire both whenever possible** — clone for instant paint, trigger to survive re-renders. The runtime applies clone first, then trigger. The opcode is recorded as `applied` if AT LEAST ONE mechanism succeeds.
478
+
479
+ The named group is looked up from `ExecutionProgram.mockDataGroups` (compiled from `PresetConfig.mockDataInjection.groups`). **Non-blocking** — if both mechanisms fail (or neither was wired), the opcode is recorded as `mockDataGroupResults[groupName] = "skipped"` and the run continues.
480
+
481
+ ### Common params
482
+
483
+ | Param | Type | Required | Description |
484
+ |-------|------|----------|-------------|
485
+ | `groupName` | string | yes | Name of the MockDataGroup to use (must exist in the preset's `mockDataInjection.groups`) |
486
+
487
+ ### Clone params (optional but typically populated)
488
+
489
+ | Param | Type | Required | Default | Description |
490
+ |-------|------|----------|---------|-------------|
491
+ | `containerSelector` | string | conditional | — | CSS selector of the container that holds the cloned items. Required if any other clone field is present. |
492
+ | `templateSelector` | string | no | first child of container | CSS selector of the element to clone (defaults to `${containerSelector} > *:first-child`) |
493
+ | `count` | number (1-500) | no | `defaultValues.length` | Override the row count |
494
+ | `removeTemplate` | boolean | no | `false` | If true, remove the template after cloning (use to replace empty-state placeholders) |
495
+ | `slotMappings` | array of `{ slot, selector, attribute? }` | conditional | — | Maps each slot name to a target inside a cloned item. Required if `containerSelector` is present. |
496
+
497
+ **`slotMappings` entry:**
498
+
499
+ | Field | Type | Required | Description |
500
+ |-------|------|----------|-------------|
501
+ | `slot` | string | yes | Name of a slot from the MockDataGroup |
502
+ | `selector` | string | yes | CSS selector RELATIVE to the cloned item |
503
+ | `attribute` | string | no | If present, write to `setAttribute(name, value)`. If absent, write to `textContent`. |
504
+
505
+ The runtime tags each clone with `data-ak-mock-clone="<i>"` so slot selectors are addressed via the tag rather than `nth-child` math — robust against non-template siblings (placeholders, headers).
506
+
507
+ ### Trigger params (optional but typically populated)
508
+
509
+ | Param | Type | Required | Description |
510
+ |-------|------|----------|-------------|
511
+ | `inputSelector` | string | conditional | CSS selector of the hidden `<input>` / `<textarea>` / `<select>` that receives the JSON payload. Required if `triggerSelector` is present. Use `[data-ak-fill-input="<group>"]`. |
512
+ | `triggerSelector` | string | conditional | CSS selector of the hidden trigger element AutoKap clicks programmatically. Required if `inputSelector` is present. Use `[data-ak-fill-trigger="<group>"]`. |
513
+
514
+ The runtime serializes `defaultValues` as a JSON array (`JSON.stringify(group.defaultValues)`) and writes it into the input via the React-aware native value setter, then dispatches `input` and `change` events, then calls `triggerElement.click()` directly. The user's `onClick` handler is responsible for parsing and applying the data.
515
+
516
+ ### Validation
517
+
518
+ At least one mechanism must be complete (clone = `containerSelector` + `slotMappings`; trigger = `inputSelector` + `triggerSelector`). Partial mechanisms are rejected at compile time.
519
+
520
+ ### Capabilities
521
+
522
+ **Can:**
523
+ - Apply both mechanisms additively for the same group, in a single opcode.
524
+ - Populate tables, lists, card grids, badge rows, and any container with text or image-source values via the clone mechanism.
525
+ - Re-render charts, maps, calendars, and any programmatic widget via the trigger mechanism, by asking the user's app to handle the seed data through normal state updates.
526
+
527
+ **Cannot:**
528
+ - Trigger mechanism cannot work without app-side cooperation (the assistant must add a hidden trigger + input + `onClick` handler to the user's source code). The handler must JSON.parse the input value and validate the shape defensively.
529
+ - Clone mechanism cannot persist DOM mutations into React/Vue/Svelte state — on the next render the framework reconciles its virtual tree against the real DOM and overwrites the cloned children. (This is exactly why you should also wire the trigger mechanism — it routes the same data through state, so the next render preserves it.)
530
+
531
+ ### Soft-failure semantics
532
+
533
+ Returns failure if the group is missing, has no `defaultValues`, the opcode declares neither mechanism, or both wired mechanisms fail at runtime. The runner converts failure into `status: "skipped"` and records `mockDataGroupResults[groupName] = "skipped"`. If at least one mechanism succeeds, the group is recorded as `"applied"` even if the other failed.
534
+
535
+ ### Example — Both mechanisms (recommended)
536
+
537
+ ```json
538
+ {
539
+ "kind": "INJECT_MOCK_DATA",
540
+ "description": "Populate preset cards with mock data",
541
+ "groupName": "preset-cards",
542
+
543
+ "containerSelector": "[data-ak=\"preset-card-grid\"]",
544
+ "templateSelector": "[data-ak=\"preset-card-grid\"] > [data-ak=\"preset-card\"]",
545
+ "removeTemplate": true,
546
+ "slotMappings": [
547
+ { "slot": "title", "selector": "[data-ak=\"preset-card-title\"]" },
548
+ { "slot": "lastCapture", "selector": "[data-ak=\"preset-card-last-capture\"]" },
549
+ { "slot": "variantCount", "selector": "[data-ak=\"preset-card-variant-count\"]" },
550
+ { "slot": "creditCost", "selector": "[data-ak=\"preset-card-credit-cost\"]" },
551
+ { "slot": "typeBadge", "selector": "[data-ak=\"preset-card-type-badge\"]" }
552
+ ],
553
+
554
+ "inputSelector": "[data-ak-fill-input=\"preset-cards\"]",
555
+ "triggerSelector": "[data-ak-fill-trigger=\"preset-cards\"]",
556
+
557
+ "postcondition": { "type": "always" },
558
+ "recovery": { "retries": 0, "useSelectorMemory": false, "useAltInteraction": false, "allowReload": false, "allowHealer": false },
559
+ "timeoutMs": 5000,
560
+ "maxFailures": 1
561
+ }
562
+ ```
563
+
564
+ ### Example — Clone-only (static HTML, no app state)
565
+
566
+ ```json
567
+ {
568
+ "kind": "INJECT_MOCK_DATA",
569
+ "description": "Populate static customers table",
570
+ "groupName": "customers-table",
571
+ "containerSelector": "[data-ak=\"customers-tbody\"]",
572
+ "templateSelector": "[data-ak=\"customers-tbody\"] > [data-ak=\"customer-row\"]",
573
+ "removeTemplate": true,
574
+ "slotMappings": [
575
+ { "slot": "name", "selector": "[data-ak=\"customer-name\"]" },
576
+ { "slot": "avatar", "selector": "[data-ak=\"customer-avatar\"]", "attribute": "src" }
577
+ ],
578
+ "postcondition": { "type": "always" },
579
+ "recovery": { "retries": 0, "useSelectorMemory": false, "useAltInteraction": false, "allowReload": false, "allowHealer": false },
580
+ "timeoutMs": 5000,
581
+ "maxFailures": 1
582
+ }
583
+ ```
584
+
585
+ ### Example — Trigger-only (pure D3 widget, no DOM template to clone)
586
+
587
+ ```json
588
+ {
589
+ "kind": "INJECT_MOCK_DATA",
590
+ "description": "Seed revenue chart with mock data",
591
+ "groupName": "revenue-chart",
592
+ "inputSelector": "[data-ak-fill-input=\"revenue-chart\"]",
593
+ "triggerSelector": "[data-ak-fill-trigger=\"revenue-chart\"]",
594
+ "postcondition": { "type": "always" },
595
+ "recovery": { "retries": 0, "useSelectorMemory": false, "useAltInteraction": false, "allowReload": false, "allowHealer": false },
596
+ "timeoutMs": 5000,
597
+ "maxFailures": 1
598
+ }
599
+ ```
600
+
601
+ ## REMOVE_ELEMENT
602
+
603
+ Remove all elements matching a CSS selector. **Non-blocking.**
604
+
605
+ | Param | Type | Required | Description |
606
+ |-------|------|----------|-------------|
607
+ | `selector` | string | yes | CSS selector — every match is removed |
608
+
609
+ **Can:** Strip empty-state illustrations, debug banners, "powered by" footers, or any visual noise that would distract from the screenshot.
610
+ **Cannot:** Remove an element from a parent that re-renders it via React state — the next render will recreate it.
611
+
612
+ **Soft-failure semantics:** Throws if the selector matches zero elements. The runner converts the throw into `status: "skipped"`.
613
+
614
+ ```json
615
+ { "kind": "REMOVE_ELEMENT", "description": "Remove empty-state illustration", "selector": "[data-ak=\"empty-state\"]", "postcondition": { "type": "always" }, "recovery": { "retries": 0, "useSelectorMemory": false, "useAltInteraction": false, "allowReload": false, "allowHealer": false }, "timeoutMs": 3000, "maxFailures": 1 }
616
+ ```
617
+
618
+ ## SET_ATTRIBUTE
619
+
620
+ Set an attribute on the first matching element. **Non-blocking.**
621
+
622
+ | Param | Type | Required | Description |
623
+ |-------|------|----------|-------------|
624
+ | `selector` | string | yes | CSS selector of the target element (first match only) |
625
+ | `attribute` | string | yes | Attribute name (e.g. `"src"`, `"href"`, `"data-state"`) |
626
+ | `value` | string | yes | Attribute value |
627
+
628
+ **Can:** Swap an `<img src>`, change a `data-*` flag to trigger CSS state, set `aria-*` for a11y previews, or override `href` on a link.
629
+ **Cannot:** Trigger React state updates — only the DOM attribute changes. Replace `style` reliably (prefer setting a `class` or `data-*` and letting CSS handle the visual).
630
+
631
+ **Soft-failure semantics:** Throws if the selector is unmatched. The runner converts the throw into `status: "skipped"`.
632
+
633
+ ```json
634
+ { "kind": "SET_ATTRIBUTE", "description": "Override hero image src", "selector": "[data-ak=\"hero-image\"]", "attribute": "src", "value": "https://picsum.photos/1200/600", "postcondition": { "type": "always" }, "recovery": { "retries": 0, "useSelectorMemory": false, "useAltInteraction": false, "allowReload": false, "allowHealer": false }, "timeoutMs": 3000, "maxFailures": 1 }
635
+ ```