autokap 1.0.6 → 1.0.8

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 (347) hide show
  1. package/assets/chrome/ios-statusbar-comparison-reference.jpg +0 -0
  2. package/assets/chrome/ios-statusbar-dark-reference.jpg +0 -0
  3. package/assets/chrome/ios-statusbar-light-reference.jpg +0 -0
  4. package/assets/cursors/macos.svg +4 -0
  5. package/assets/cursors/windows.svg +15 -0
  6. package/assets/devices/ipad-pro-11-m4.json +52 -0
  7. package/assets/devices/iphone-16-pro.json +53 -0
  8. package/assets/devices/macbook-air-13.json +45 -0
  9. package/assets/frames/MacBook Air 13.svg +242 -0
  10. package/assets/frames/Status bar - iPhone.png +0 -0
  11. Menu bar- iPad.png +0 -0
  12. package/assets/frames/iPad Pro M4 11_.png +0 -0
  13. package/assets/frames/iPhone 16 Pro.png +0 -0
  14. package/assets/icons/Cellular Connection.svg +3 -0
  15. package/assets/icons/Union.svg +6 -0
  16. package/assets/icons/Wifi.svg +3 -0
  17. package/assets/icons/battery.svg +5 -0
  18. package/assets/icons/battery_charging.svg +8 -0
  19. package/assets/skill/OPCODE-REFERENCE.md +607 -0
  20. package/assets/skill/README.md +39 -0
  21. package/assets/skill/SKILL.md +453 -468
  22. package/assets/skill/STUDIO-SKILL.md +476 -0
  23. package/assets/skill/references/examples.md +104 -0
  24. package/assets/skill/references/interactive-demo.md +225 -0
  25. package/assets/skill/references/mock-data.md +178 -0
  26. package/dist/abort.d.ts +5 -0
  27. package/dist/abort.js +44 -0
  28. package/dist/action-verifier.d.ts +29 -0
  29. package/dist/action-verifier.js +133 -0
  30. package/dist/agent-action-recovery.d.ts +45 -0
  31. package/dist/agent-action-recovery.js +370 -0
  32. package/dist/agent-message-utils.d.ts +21 -0
  33. package/dist/agent-message-utils.js +77 -0
  34. package/dist/agent-url-utils.d.ts +30 -0
  35. package/dist/agent-url-utils.js +138 -0
  36. package/dist/agent.d.ts +226 -0
  37. package/dist/agent.js +6666 -0
  38. package/dist/ak-tree.d.ts +39 -0
  39. package/dist/ak-tree.js +368 -0
  40. package/dist/alt-text.d.ts +26 -0
  41. package/dist/alt-text.js +55 -0
  42. package/dist/auth-capture.d.ts +17 -0
  43. package/dist/auth-capture.js +164 -0
  44. package/dist/benchmark.d.ts +59 -0
  45. package/dist/benchmark.js +135 -0
  46. package/dist/billing-operation-logging.d.ts +38 -0
  47. package/dist/billing-operation-logging.js +248 -0
  48. package/dist/browser-bar.d.ts +48 -0
  49. package/dist/browser-bar.js +284 -0
  50. package/dist/browser-pool.d.ts +7 -0
  51. package/dist/browser-pool.js +15 -5
  52. package/dist/browser-utils.d.ts +31 -0
  53. package/dist/browser-utils.js +97 -0
  54. package/dist/browser.d.ts +76 -1
  55. package/dist/browser.js +1657 -39
  56. package/dist/capture-alt-text.d.ts +12 -0
  57. package/dist/capture-alt-text.js +52 -0
  58. package/dist/capture-encryption.d.ts +10 -0
  59. package/dist/capture-encryption.js +41 -0
  60. package/dist/capture-language-preflight.d.ts +41 -0
  61. package/dist/capture-language-preflight.js +300 -0
  62. package/dist/capture-llm-page-identity.d.ts +15 -0
  63. package/dist/capture-llm-page-identity.js +128 -0
  64. package/dist/capture-model-resolution.d.ts +9 -0
  65. package/dist/capture-model-resolution.js +21 -0
  66. package/dist/capture-page-identity.d.ts +7 -0
  67. package/dist/capture-page-identity.js +352 -0
  68. package/dist/capture-preset-credentials.d.ts +62 -0
  69. package/dist/capture-preset-credentials.js +184 -0
  70. package/dist/capture-request-plan.d.ts +58 -0
  71. package/dist/capture-request-plan.js +264 -0
  72. package/dist/capture-run-optimizer.d.ts +139 -0
  73. package/dist/capture-run-optimizer.js +863 -0
  74. package/dist/capture-selector-memory.d.ts +31 -0
  75. package/dist/capture-selector-memory.js +345 -0
  76. package/dist/capture-session-profile-encryption.d.ts +2 -0
  77. package/dist/capture-session-profile-encryption.js +22 -0
  78. package/dist/capture-step-timeout.d.ts +10 -0
  79. package/dist/capture-step-timeout.js +30 -0
  80. package/dist/capture-strategy.d.ts +36 -0
  81. package/dist/capture-strategy.js +95 -0
  82. package/dist/capture-studio-sync.d.ts +23 -0
  83. package/dist/capture-studio-sync.js +172 -0
  84. package/dist/capture-surface-contract.d.ts +36 -0
  85. package/dist/capture-surface-contract.js +299 -0
  86. package/dist/capture-transition-engine.d.ts +28 -0
  87. package/dist/capture-transition-engine.js +292 -0
  88. package/dist/capture-variant-state.d.ts +56 -0
  89. package/dist/capture-variant-state.js +182 -0
  90. package/dist/capture-verification.d.ts +35 -0
  91. package/dist/capture-verification.js +95 -0
  92. package/dist/capture-viewport-lock.d.ts +48 -0
  93. package/dist/capture-viewport-lock.js +74 -0
  94. package/dist/circuit-breaker.d.ts +42 -0
  95. package/dist/circuit-breaker.js +119 -0
  96. package/dist/cli-config.d.ts +8 -1
  97. package/dist/cli-config.js +62 -6
  98. package/dist/cli-contract.d.ts +15 -0
  99. package/dist/cli-contract.js +167 -0
  100. package/dist/cli-runner-local.d.ts +12 -0
  101. package/dist/cli-runner-local.js +102 -0
  102. package/dist/cli-runner.d.ts +34 -0
  103. package/dist/cli-runner.js +433 -0
  104. package/dist/cli-utils.d.ts +0 -1
  105. package/dist/cli-utils.js +2 -5
  106. package/dist/cli.js +1005 -252
  107. package/dist/clip-orchestrator.d.ts +148 -0
  108. package/dist/clip-orchestrator.js +957 -0
  109. package/dist/clip-postprocess.d.ts +42 -0
  110. package/dist/clip-postprocess.js +201 -0
  111. package/dist/cookie-dismiss.d.ts +2 -0
  112. package/dist/cookie-dismiss.js +48 -13
  113. package/dist/cost-logging.d.ts +35 -0
  114. package/dist/cost-logging.js +242 -0
  115. package/dist/cost-resolution-monitor.d.ts +16 -0
  116. package/dist/cost-resolution-monitor.js +34 -0
  117. package/dist/credential-templates.d.ts +5 -0
  118. package/dist/credential-templates.js +60 -0
  119. package/dist/cursor-overlay-script.d.ts +6 -0
  120. package/dist/cursor-overlay-script.js +169 -0
  121. package/dist/dom-css-purger.d.ts +65 -0
  122. package/dist/dom-css-purger.js +333 -0
  123. package/dist/dom-font-inliner.d.ts +45 -0
  124. package/dist/dom-font-inliner.js +148 -0
  125. package/dist/dom-patch-resolver.d.ts +52 -0
  126. package/dist/dom-patch-resolver.js +242 -0
  127. package/dist/dom-serializer.d.ts +82 -0
  128. package/dist/dom-serializer.js +378 -0
  129. package/dist/element-capture.d.ts +13 -0
  130. package/dist/element-capture.js +522 -0
  131. package/dist/env-validation.d.ts +5 -0
  132. package/dist/env-validation.js +29 -0
  133. package/dist/execution-schema.d.ts +4423 -0
  134. package/dist/execution-schema.js +507 -0
  135. package/dist/execution-types.d.ts +886 -0
  136. package/dist/execution-types.js +65 -0
  137. package/dist/fonts-loader.d.ts +14 -0
  138. package/dist/fonts-loader.js +55 -0
  139. package/dist/hybrid-navigator.d.ts +138 -0
  140. package/dist/hybrid-navigator.js +468 -0
  141. package/dist/index.d.ts +18 -0
  142. package/dist/index.js +17 -0
  143. package/dist/legacy/agent-action-recovery.d.ts +45 -0
  144. package/dist/legacy/agent-action-recovery.js +370 -0
  145. package/dist/legacy/agent-message-utils.d.ts +21 -0
  146. package/dist/legacy/agent-message-utils.js +77 -0
  147. package/dist/legacy/agent-url-utils.d.ts +30 -0
  148. package/dist/legacy/agent-url-utils.js +138 -0
  149. package/dist/legacy/agent.d.ts +226 -0
  150. package/dist/legacy/agent.js +6666 -0
  151. package/dist/legacy/clip-orchestrator.d.ts +148 -0
  152. package/dist/legacy/clip-orchestrator.js +957 -0
  153. package/dist/legacy/credential-templates.d.ts +5 -0
  154. package/dist/legacy/credential-templates.js +60 -0
  155. package/dist/legacy/hybrid-navigator.d.ts +138 -0
  156. package/dist/legacy/hybrid-navigator.js +468 -0
  157. package/dist/legacy/llm-usage.d.ts +17 -0
  158. package/dist/legacy/llm-usage.js +45 -0
  159. package/dist/legacy/prompt-cache.d.ts +10 -0
  160. package/dist/legacy/prompt-cache.js +24 -0
  161. package/dist/legacy/prompts.d.ts +175 -0
  162. package/dist/legacy/prompts.js +1038 -0
  163. package/dist/legacy/tools.d.ts +4 -0
  164. package/dist/legacy/tools.js +216 -0
  165. package/dist/legacy/video-agent.d.ts +143 -0
  166. package/dist/legacy/video-agent.js +4788 -0
  167. package/dist/legacy/video-observation.d.ts +36 -0
  168. package/dist/legacy/video-observation.js +192 -0
  169. package/dist/legacy/video-planner.d.ts +12 -0
  170. package/dist/legacy/video-planner.js +501 -0
  171. package/dist/legacy/video-prompts.d.ts +37 -0
  172. package/dist/legacy/video-prompts.js +569 -0
  173. package/dist/legacy/video-tools.d.ts +3 -0
  174. package/dist/legacy/video-tools.js +59 -0
  175. package/dist/legacy/video-variant-state.d.ts +29 -0
  176. package/dist/legacy/video-variant-state.js +80 -0
  177. package/dist/legacy/vision-model.d.ts +17 -0
  178. package/dist/legacy/vision-model.js +74 -0
  179. package/dist/llm-healer.d.ts +63 -0
  180. package/dist/llm-healer.js +166 -0
  181. package/dist/llm-provider.d.ts +29 -0
  182. package/dist/llm-provider.js +80 -0
  183. package/dist/llm-usage.d.ts +17 -0
  184. package/dist/llm-usage.js +45 -0
  185. package/dist/logger.d.ts +6 -2
  186. package/dist/logger.js +15 -1
  187. package/dist/mockup-html.d.ts +119 -0
  188. package/dist/mockup-html.js +263 -0
  189. package/dist/mockup.d.ts +187 -0
  190. package/dist/mockup.js +869 -0
  191. package/dist/mouse-animation.d.ts +46 -0
  192. package/dist/mouse-animation.js +114 -0
  193. package/dist/opcode-actions.d.ts +42 -0
  194. package/dist/opcode-actions.js +511 -0
  195. package/dist/opcode-runner.d.ts +51 -0
  196. package/dist/opcode-runner.js +770 -0
  197. package/dist/openrouter-client.d.ts +40 -0
  198. package/dist/openrouter-client.js +16 -0
  199. package/dist/overlay-engine.d.ts +24 -0
  200. package/dist/overlay-engine.js +176 -0
  201. package/dist/overlay-utils.d.ts +14 -0
  202. package/dist/overlay-utils.js +13 -0
  203. package/dist/postcondition.d.ts +16 -0
  204. package/dist/postcondition.js +269 -0
  205. package/dist/posthog.d.ts +4 -0
  206. package/dist/posthog.js +26 -0
  207. package/dist/program-patcher.d.ts +25 -0
  208. package/dist/program-patcher.js +44 -0
  209. package/dist/prompt-cache.d.ts +10 -0
  210. package/dist/prompt-cache.js +24 -0
  211. package/dist/prompts.d.ts +175 -0
  212. package/dist/prompts.js +1038 -0
  213. package/dist/provider-config.d.ts +12 -0
  214. package/dist/provider-config.js +15 -0
  215. package/dist/recovery-chain.d.ts +37 -0
  216. package/dist/recovery-chain.js +350 -0
  217. package/dist/remote-browser.d.ts +215 -0
  218. package/dist/remote-browser.js +360 -0
  219. package/dist/safari-browser-bar.d.ts +15 -0
  220. package/dist/safari-browser-bar.js +95 -0
  221. package/dist/safari-toolbar-asset.d.ts +15 -0
  222. package/dist/safari-toolbar-asset.js +12 -0
  223. package/dist/security.d.ts +21 -0
  224. package/dist/security.js +608 -0
  225. package/dist/selector-resolver.d.ts +34 -0
  226. package/dist/selector-resolver.js +181 -0
  227. package/dist/semantic-resolver.d.ts +35 -0
  228. package/dist/semantic-resolver.js +161 -0
  229. package/dist/server-capture-runtime.d.ts +125 -0
  230. package/dist/server-capture-runtime.js +585 -0
  231. package/dist/server-credit-usage.d.ts +12 -0
  232. package/dist/server-credit-usage.js +41 -0
  233. package/dist/server-posthog.d.ts +2 -0
  234. package/dist/server-posthog.js +16 -0
  235. package/dist/server-project-webhooks.d.ts +59 -0
  236. package/dist/server-project-webhooks.js +123 -0
  237. package/dist/server-screenshot-watermark.d.ts +7 -0
  238. package/dist/server-screenshot-watermark.js +60 -0
  239. package/dist/session-profile.d.ts +86 -0
  240. package/dist/session-profile.js +1536 -0
  241. package/dist/sf-pro-fonts.d.ts +4 -0
  242. package/dist/sf-pro-fonts.js +7 -0
  243. package/dist/sf-pro-symbols.d.ts +1 -0
  244. package/dist/sf-pro-symbols.js +55 -0
  245. package/dist/skill-packaging.d.ts +28 -0
  246. package/dist/skill-packaging.js +169 -0
  247. package/dist/smart-wait.d.ts +27 -0
  248. package/dist/smart-wait.js +81 -0
  249. package/dist/status-bar-l10n.d.ts +14 -0
  250. package/dist/status-bar-l10n.js +177 -0
  251. package/dist/status-bar-render.d.ts +20 -0
  252. package/dist/status-bar-render.js +410 -0
  253. package/dist/status-bar.d.ts +53 -0
  254. package/dist/status-bar.js +620 -0
  255. package/dist/svg-browser-bar.d.ts +33 -0
  256. package/dist/svg-browser-bar.js +206 -0
  257. package/dist/svg-status-bar.d.ts +36 -0
  258. package/dist/svg-status-bar.js +597 -0
  259. package/dist/svg-text.d.ts +61 -0
  260. package/dist/svg-text.js +118 -0
  261. package/dist/tools.d.ts +4 -0
  262. package/dist/tools.js +216 -0
  263. package/dist/types.d.ts +240 -5
  264. package/dist/types.js +23 -1
  265. package/dist/v2/action-verifier.d.ts +29 -0
  266. package/dist/v2/action-verifier.js +133 -0
  267. package/dist/v2/alt-text.d.ts +26 -0
  268. package/dist/v2/alt-text.js +55 -0
  269. package/dist/v2/benchmark.d.ts +59 -0
  270. package/dist/v2/benchmark.js +135 -0
  271. package/dist/v2/capture-strategy.d.ts +30 -0
  272. package/dist/v2/capture-strategy.js +67 -0
  273. package/dist/v2/capture-verification.d.ts +35 -0
  274. package/dist/v2/capture-verification.js +95 -0
  275. package/dist/v2/circuit-breaker.d.ts +42 -0
  276. package/dist/v2/circuit-breaker.js +119 -0
  277. package/dist/v2/cli-runner-local.d.ts +11 -0
  278. package/dist/v2/cli-runner-local.js +91 -0
  279. package/dist/v2/cli-runner.d.ts +34 -0
  280. package/dist/v2/cli-runner.js +300 -0
  281. package/dist/v2/compiler-prompts.d.ts +27 -0
  282. package/dist/v2/compiler-prompts.js +123 -0
  283. package/dist/v2/compiler.d.ts +37 -0
  284. package/dist/v2/compiler.js +147 -0
  285. package/dist/v2/explorer.d.ts +41 -0
  286. package/dist/v2/explorer.js +56 -0
  287. package/dist/v2/index.d.ts +37 -0
  288. package/dist/v2/index.js +31 -0
  289. package/dist/v2/llm-healer.d.ts +62 -0
  290. package/dist/v2/llm-healer.js +166 -0
  291. package/dist/v2/llm-provider.d.ts +29 -0
  292. package/dist/v2/llm-provider.js +80 -0
  293. package/dist/v2/opcode-runner.d.ts +47 -0
  294. package/dist/v2/opcode-runner.js +634 -0
  295. package/dist/v2/overlay-engine.d.ts +24 -0
  296. package/dist/v2/overlay-engine.js +150 -0
  297. package/dist/v2/postcondition.d.ts +16 -0
  298. package/dist/v2/postcondition.js +249 -0
  299. package/dist/v2/program-patcher.d.ts +25 -0
  300. package/dist/v2/program-patcher.js +44 -0
  301. package/dist/v2/recovery-chain.d.ts +30 -0
  302. package/dist/v2/recovery-chain.js +368 -0
  303. package/dist/v2/schema.d.ts +2580 -0
  304. package/dist/v2/schema.js +295 -0
  305. package/dist/v2/selector-resolver.d.ts +34 -0
  306. package/dist/v2/selector-resolver.js +181 -0
  307. package/dist/v2/semantic-resolver.d.ts +35 -0
  308. package/dist/v2/semantic-resolver.js +161 -0
  309. package/dist/v2/smart-wait.d.ts +27 -0
  310. package/dist/v2/smart-wait.js +81 -0
  311. package/dist/v2/types.d.ts +444 -0
  312. package/dist/v2/types.js +19 -0
  313. package/dist/v2/web-playwright-local.d.ts +69 -0
  314. package/dist/v2/web-playwright-local.js +392 -0
  315. package/dist/version.d.ts +1 -0
  316. package/dist/version.js +5 -0
  317. package/dist/video-agent.d.ts +143 -0
  318. package/dist/video-agent.js +4788 -0
  319. package/dist/video-observation.d.ts +36 -0
  320. package/dist/video-observation.js +192 -0
  321. package/dist/video-planner.d.ts +12 -0
  322. package/dist/video-planner.js +501 -0
  323. package/dist/video-prompts.d.ts +37 -0
  324. package/dist/video-prompts.js +554 -0
  325. package/dist/video-tools.d.ts +3 -0
  326. package/dist/video-tools.js +59 -0
  327. package/dist/video-variant-state.d.ts +29 -0
  328. package/dist/video-variant-state.js +80 -0
  329. package/dist/vision-model.d.ts +17 -0
  330. package/dist/vision-model.js +74 -0
  331. package/dist/web-playwright-local.d.ts +126 -0
  332. package/dist/web-playwright-local.js +819 -0
  333. package/dist/ws-auth.d.ts +20 -0
  334. package/dist/ws-auth.js +70 -0
  335. package/dist/ws-broadcast.d.ts +34 -0
  336. package/dist/ws-broadcast.js +85 -0
  337. package/dist/ws-connection-limits.d.ts +12 -0
  338. package/dist/ws-connection-limits.js +44 -0
  339. package/dist/ws-handler-utils.d.ts +32 -0
  340. package/dist/ws-handler-utils.js +139 -0
  341. package/dist/ws-handler.d.ts +10 -0
  342. package/dist/ws-handler.js +1793 -0
  343. package/dist/ws-metrics-server.d.ts +9 -0
  344. package/dist/ws-metrics-server.js +31 -0
  345. package/dist/ws-server.d.ts +9 -0
  346. package/dist/ws-server.js +92 -0
  347. package/package.json +142 -71
@@ -0,0 +1,225 @@
1
+ # Interactive Demo Workflow Reference
2
+
3
+ Use this reference when the user wants an embeddable product demo driven by
4
+ captured DOM states plus deterministic local interactions, not just static
5
+ screenshots or clips.
6
+
7
+ ## When to use interactive demos
8
+
9
+ Choose this mode when:
10
+
11
+ - the output should feel clickable and alive on a landing page or docs page
12
+ - the user wants to recreate a focused product loop, not the entire app
13
+ - 2-6 distinct base states are enough and the rest can be reconstructed locally
14
+ - the main value comes from local UI reactions such as switching tabs, opening
15
+ a panel, swapping a preview, or editing small bits of content
16
+
17
+ Prefer plain screenshots or clips when the user only needs static visuals or a
18
+ linear recording.
19
+
20
+ ## Core mental model
21
+
22
+ For interactive demos, the captured DOM is only the substrate. The quality of
23
+ the result depends on the interaction model:
24
+
25
+ 1. what the viewer can click or edit
26
+ 2. which parts of the UI react immediately
27
+ 3. which changes need a new captured state vs local reconstruction
28
+
29
+ Do not start from "capture every page". Start from the feature loop the user
30
+ wants to showcase, then capture only what is needed to support that loop.
31
+
32
+ ## What to capture vs what to reconstruct
33
+
34
+ Use this decision rule:
35
+
36
+ - whole page or route changes: create another `CAPTURE_DOM` base state
37
+ - one focused shell matters more than the whole page: use `CAPTURE_DOM` with a
38
+ `selector`
39
+ - modal / popover / dropdown / sheet: use `CAPTURE_FRAGMENT`
40
+ - local text / class / visible-state changes: use player API or bindings
41
+ - repeated editable content: use templates / repeaters / model bindings
42
+ - complex app-specific logic: use custom interaction `code` as the last resort
43
+
44
+ Default bias:
45
+
46
+ - fewer base states
47
+ - more local reconstruction
48
+ - a small number of meaningful viewer interactions
49
+ - focus on the central product experience
50
+
51
+ ## Required authored markers
52
+
53
+ ### Viewer interaction markers
54
+
55
+ Add `data-ak-interact="<name>"` to every element the viewer should operate in
56
+ the published demo.
57
+
58
+ ```tsx
59
+ <button data-ak-interact="open-chat">Open chat</button>
60
+ <button data-ak-interact="settings-link">Settings</button>
61
+ ```
62
+
63
+ Use kebab-case names and keep the marker set intentionally small.
64
+
65
+ ### Fragment markers
66
+
67
+ Add `data-ak-fragment="<name>"` on the root of every modal/popover/dropdown
68
+ subtree that should be captured separately.
69
+
70
+ Use `data-ak-mount` when mounting behavior matters:
71
+
72
+ - `inline`
73
+ - `overlay`
74
+ - `portal:<target-name>`
75
+
76
+ Add `data-ak-mount-target="<target-name>"` when a portal mount location is
77
+ required.
78
+
79
+ ### Model / behavior markers
80
+
81
+ Prefer authored markers before custom code:
82
+
83
+ - `data-ak-model="<path>"`
84
+ - `data-ak-bind="..."`
85
+ - `data-ak-action="..."`
86
+ - `data-ak-template="<name>"`
87
+ - `data-ak-behavior="tabs|popover|slider|..."` for standard widget hints
88
+
89
+ These give the player enough structure to replay many standard UI behaviors
90
+ without bespoke JavaScript.
91
+
92
+ ## Capture flow
93
+
94
+ ### Base states
95
+
96
+ Set `mediaMode: "dom"` and `artifactPlan: { "mediaMode": "dom" }`, then use
97
+ normal deterministic opcodes to reach each captured state.
98
+
99
+ Use `CAPTURE_DOM` for:
100
+
101
+ - the full page
102
+ - or a focused shell via `selector`
103
+
104
+ Good focused-shell selectors:
105
+
106
+ - `[data-ak="studio-shell"]`
107
+ - `[data-ak="pricing-calculator"]`
108
+ - `[data-ak="dashboard-hero"]`
109
+
110
+ Avoid targeting tiny leaf nodes.
111
+
112
+ ### Fragments
113
+
114
+ Use `CAPTURE_FRAGMENT` when only a local subtree changes.
115
+
116
+ Preferred pattern:
117
+
118
+ 1. use visible UI to open the fragment
119
+ 2. `WAIT_FOR` the fragment root
120
+ 3. capture it with `CAPTURE_FRAGMENT`
121
+
122
+ Fallback pattern:
123
+
124
+ Add a hidden fragment trigger button when the fragment is not reachable through
125
+ visible UI.
126
+
127
+ ## Fragment variants
128
+
129
+ Capture the same fragment under multiple `variantName`s when an interaction only
130
+ swaps a subtree in place, for example:
131
+
132
+ - preview background changes
133
+ - before / after toggle
134
+ - local layout switch
135
+
136
+ Rules:
137
+
138
+ - capture the baseline first
139
+ - keep variant names kebab-case
140
+ - keep the same fragment root selector across variants
141
+ - use variants only for structurally related subtree swaps
142
+
143
+ ## Interaction script
144
+
145
+ The interaction script lives in `config.interactiveDemo.script`.
146
+
147
+ Each interaction has only four required fields:
148
+
149
+ - `state`
150
+ - `selector`
151
+ - `trigger`
152
+ - `code`
153
+
154
+ Canonical shape:
155
+
156
+ ```json
157
+ {
158
+ "state": "dashboard",
159
+ "selector": "[data-ak-interact='open-chat']",
160
+ "trigger": "click",
161
+ "code": "await api.navigate('dashboard-chat-open', 'fade');"
162
+ }
163
+ ```
164
+
165
+ Use `[data-ak-interact='...']` selectors by default.
166
+
167
+ Supported triggers:
168
+
169
+ - `click`
170
+ - `hover`
171
+ - `submit`
172
+
173
+ ## Player API
174
+
175
+ The interaction `code` receives:
176
+
177
+ - `doc`
178
+ - `iframe`
179
+ - `api`
180
+ - `state`
181
+ - `target`
182
+
183
+ Prefer the player API before raw DOM mutation:
184
+
185
+ - `api.navigate(...)`
186
+ - `api.delay(...)`
187
+ - `api.query(...)`
188
+ - `api.setText(...)`
189
+ - `api.toggleClass(...)`
190
+ - `api.setValue(...)`
191
+ - `api.show(...)` / `api.hide(...)`
192
+ - `api.model.*`
193
+ - `api.template.*`
194
+ - `api.fragment.show / hide / swap / toggle / current / variants`
195
+
196
+ Use raw DOM access only when the built-in helpers and declarative markers are
197
+ not expressive enough.
198
+
199
+ ## Common failure modes
200
+
201
+ - treating a custom dropdown like a native `<select>`
202
+ - not preserving active-state markers such as `aria-selected` or `data-state`
203
+ - capturing the trigger but not the controlled surface
204
+ - using unstable selectors like utility classes or text selectors
205
+ - forgetting that portal UI lives outside the main subtree
206
+ - capturing before the controlled DOM has actually settled
207
+ - trying to reconstruct canvas/WebGL internals directly from DOM capture
208
+ - over-capturing every page instead of focusing on the feature loop
209
+
210
+ ## Preview and publish
211
+
212
+ After a run, the user previews the demo at:
213
+
214
+ `/projects/<projectId>/presets/<presetId>/preview`
215
+
216
+ The public URL is:
217
+
218
+ `/demo/<presetId>`
219
+
220
+ The embed snippet is:
221
+
222
+ ```html
223
+ <div data-ak-demo="<presetId>"></div>
224
+ <script src="https://autokap.app/api/v1/loader.js" defer></script>
225
+ ```
@@ -0,0 +1,178 @@
1
+ # Mock Data Injection Reference
2
+
3
+ Use this reference when the user enables mock data generation or when a target
4
+ capture would otherwise show empty tables, empty lists, empty charts, or other
5
+ unhelpful placeholder states.
6
+
7
+ ## When to use it
8
+
9
+ Use mock data when:
10
+
11
+ - the page would otherwise render an empty state
12
+ - the marketing value depends on populated cards, rows, charts, or metrics
13
+ - the user explicitly enabled "Generate mock data"
14
+
15
+ Do not use it just because the feature exists. If the real page already renders
16
+ stable, attractive data, prefer the real state.
17
+
18
+ ## Core model
19
+
20
+ Mock data injection has two complementary delivery mechanisms and the runtime
21
+ applies both when they are wired:
22
+
23
+ ### Clone
24
+
25
+ Clone a DOM template element, then write slot values into the cloned
26
+ descendants.
27
+
28
+ Best for:
29
+
30
+ - tables
31
+ - card grids
32
+ - simple lists
33
+ - badge rows
34
+
35
+ ### Trigger
36
+
37
+ Write JSON into a hidden input and click a hidden button the app exposes. The
38
+ component reads the payload and re-renders through normal app state.
39
+
40
+ Best for:
41
+
42
+ - charts
43
+ - calendars
44
+ - maps
45
+ - library-owned DOM
46
+ - anything likely to re-render and overwrite a clone
47
+
48
+ ## Default rule
49
+
50
+ For modern React/Vue/Svelte apps, wire **both** clone and trigger whenever
51
+ possible.
52
+
53
+ Use only one mechanism when:
54
+
55
+ - the page is pure server-rendered HTML with no client-side state: clone-only
56
+ - the widget has no useful DOM template to clone: trigger-only
57
+
58
+ ## Critical slot rule
59
+
60
+ Every variable UI element must be represented as a slot.
61
+
62
+ Commonly missed slots:
63
+
64
+ - dates
65
+ - counts
66
+ - status badges
67
+ - labels that look static
68
+ - type icons or icon variants
69
+ - prices
70
+ - ratings
71
+ - role / owner / modified-at metadata
72
+ - chart legends and series labels
73
+
74
+ Rule of thumb:
75
+
76
+ Walk through each JSX expression, ternary, and conditional class. If that value
77
+ could differ across items, it should be a slot.
78
+
79
+ ## Step 1 — add authored markers
80
+
81
+ Tag:
82
+
83
+ - the clone template
84
+ - the clone container
85
+ - every variable child node
86
+ - the hidden trigger input/button pair
87
+
88
+ Example:
89
+
90
+ ```tsx
91
+ <div data-ak="preset-card-grid">
92
+ {cards.map((card) => (
93
+ <article key={card.id} data-ak="preset-card">
94
+ <h3 data-ak="preset-card-title">{card.name}</h3>
95
+ <span data-ak="preset-card-type">{card.mediaMode}</span>
96
+ <span data-ak="preset-card-variant-count">{card.variantCount}</span>
97
+ </article>
98
+ ))}
99
+ </div>
100
+
101
+ <input type="hidden" data-ak-fill-input="preset-cards" />
102
+ <button
103
+ type="button"
104
+ style={{ display: "none" }}
105
+ data-ak-fill-trigger="preset-cards"
106
+ onClick={(e) => {
107
+ const input = e.currentTarget.previousElementSibling as HTMLInputElement;
108
+ try {
109
+ const parsed = JSON.parse(input.value);
110
+ if (Array.isArray(parsed)) setCards(parsed);
111
+ } catch {
112
+ // ignore malformed payloads
113
+ }
114
+ }}
115
+ />
116
+ ```
117
+
118
+ ## Step 2 — declare `mockDataInjection.groups`
119
+
120
+ Declare groups at the top level of the preset config, not inside `program`.
121
+
122
+ Each group needs:
123
+
124
+ - `name`
125
+ - `description`
126
+ - `slots[]`
127
+ - `defaultValues[]`
128
+
129
+ Keep values realistic for the user's domain. Seed 5-10 rows when that makes
130
+ sense.
131
+
132
+ ## Step 3 — emit `INJECT_MOCK_DATA`
133
+
134
+ Place each `INJECT_MOCK_DATA` opcode:
135
+
136
+ - after the relevant `WAIT_FOR`
137
+ - before the relevant `CAPTURE_SCREENSHOT`
138
+
139
+ Wire both clone and trigger fields whenever possible:
140
+
141
+ - `containerSelector`
142
+ - `templateSelector`
143
+ - `slotMappings[]`
144
+ - `inputSelector`
145
+ - `triggerSelector`
146
+
147
+ Always keep the opcode non-blocking:
148
+
149
+ ```json
150
+ {
151
+ "postcondition": { "type": "always" },
152
+ "recovery": {
153
+ "retries": 0,
154
+ "useSelectorMemory": false,
155
+ "useAltInteraction": false,
156
+ "allowReload": false,
157
+ "allowHealer": false
158
+ }
159
+ }
160
+ ```
161
+
162
+ ## Implementation rules
163
+
164
+ - `slotMappings[].selector` is relative to the cloned template item
165
+ - `removeTemplate: true` when the original template should disappear
166
+ - `replaceExisting: true` on the group when placeholder content should be wiped
167
+ - use `attribute` only when the value belongs in an attribute such as `src`
168
+ - a group counts as applied if at least one delivery mechanism succeeds
169
+
170
+ ## When not to use `INJECT_MOCK_DATA`
171
+
172
+ Use lower-level DOM mutation opcodes instead when the change is narrow:
173
+
174
+ - `CLONE_ELEMENT`
175
+ - `REMOVE_ELEMENT`
176
+ - `SET_ATTRIBUTE`
177
+
178
+ Reserve `INJECT_MOCK_DATA` for real structured seed-data scenarios.
@@ -0,0 +1,5 @@
1
+ export declare function createAbortError(message: string): Error;
2
+ export declare function getAbortMessage(signal: AbortSignal | undefined, fallback: string): string;
3
+ export declare function throwIfAborted(signal: AbortSignal | undefined, fallback?: string): void;
4
+ export declare function isAbortError(error: unknown): boolean;
5
+ export declare function sleepWithAbort(ms: number, signal?: AbortSignal): Promise<void>;
package/dist/abort.js ADDED
@@ -0,0 +1,44 @@
1
+ export function createAbortError(message) {
2
+ const error = new Error(message);
3
+ error.name = 'AbortError';
4
+ return error;
5
+ }
6
+ export function getAbortMessage(signal, fallback) {
7
+ const reason = signal?.reason;
8
+ if (reason instanceof Error && reason.message)
9
+ return reason.message;
10
+ if (typeof reason === 'string' && reason.trim().length > 0)
11
+ return reason;
12
+ return fallback;
13
+ }
14
+ export function throwIfAborted(signal, fallback = 'Operation cancelled.') {
15
+ if (!signal?.aborted)
16
+ return;
17
+ throw createAbortError(getAbortMessage(signal, fallback));
18
+ }
19
+ export function isAbortError(error) {
20
+ return error instanceof Error && error.name === 'AbortError';
21
+ }
22
+ export async function sleepWithAbort(ms, signal) {
23
+ if (!signal) {
24
+ await new Promise((resolve) => setTimeout(resolve, ms));
25
+ return;
26
+ }
27
+ throwIfAborted(signal);
28
+ await new Promise((resolve, reject) => {
29
+ const timeout = setTimeout(() => {
30
+ cleanup();
31
+ resolve();
32
+ }, ms);
33
+ const onAbort = () => {
34
+ clearTimeout(timeout);
35
+ cleanup();
36
+ reject(createAbortError(getAbortMessage(signal, 'Operation cancelled.')));
37
+ };
38
+ const cleanup = () => {
39
+ signal.removeEventListener('abort', onAbort);
40
+ };
41
+ signal.addEventListener('abort', onAbort, { once: true });
42
+ });
43
+ }
44
+ //# sourceMappingURL=abort.js.map
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Capture Agent — Action Verifier
3
+ *
4
+ * Post-action validation: diff AKTree before/after an action
5
+ * to detect whether the action had a real effect or was intercepted.
6
+ */
7
+ import type { RuntimeAdapter } from './execution-types.js';
8
+ export interface ActionVerification {
9
+ /** Whether the action caused a detectable change */
10
+ hadEffect: boolean;
11
+ /** What changed */
12
+ changes: ActionChange[];
13
+ /** Summary for logging */
14
+ summary: string;
15
+ }
16
+ export type ActionChangeKind = 'url_changed' | 'tree_structure_changed' | 'node_appeared' | 'node_disappeared' | 'overlay_changed' | 'no_change';
17
+ export interface ActionChange {
18
+ kind: ActionChangeKind;
19
+ detail: string;
20
+ }
21
+ /**
22
+ * Captures AKTree state before and after an action to detect changes.
23
+ */
24
+ export declare class ActionVerifier {
25
+ private beforeTree;
26
+ private beforeUrl;
27
+ captureBeforeState(adapter: RuntimeAdapter): Promise<void>;
28
+ verifyAfterAction(adapter: RuntimeAdapter): Promise<ActionVerification>;
29
+ }
@@ -0,0 +1,133 @@
1
+ /**
2
+ * Capture Agent — Action Verifier
3
+ *
4
+ * Post-action validation: diff AKTree before/after an action
5
+ * to detect whether the action had a real effect or was intercepted.
6
+ */
7
+ /**
8
+ * Captures AKTree state before and after an action to detect changes.
9
+ */
10
+ export class ActionVerifier {
11
+ beforeTree = null;
12
+ beforeUrl = null;
13
+ async captureBeforeState(adapter) {
14
+ try {
15
+ this.beforeTree = await adapter.getAKTree();
16
+ }
17
+ catch {
18
+ this.beforeTree = null;
19
+ }
20
+ try {
21
+ this.beforeUrl = await adapter.getCurrentUrl();
22
+ }
23
+ catch {
24
+ this.beforeUrl = null;
25
+ }
26
+ }
27
+ async verifyAfterAction(adapter) {
28
+ if (!this.beforeTree || !this.beforeUrl) {
29
+ return {
30
+ hadEffect: true, // assume effect if no before state
31
+ changes: [],
32
+ summary: 'no before state captured, assuming action had effect',
33
+ };
34
+ }
35
+ let afterUrl;
36
+ let afterTree;
37
+ try {
38
+ [afterUrl, afterTree] = await Promise.all([
39
+ adapter.getCurrentUrl(),
40
+ adapter.getAKTree(),
41
+ ]);
42
+ }
43
+ catch {
44
+ this.beforeTree = null;
45
+ this.beforeUrl = null;
46
+ return {
47
+ hadEffect: true,
48
+ changes: [],
49
+ summary: 'after state unavailable, skipping AKTree effect verification',
50
+ };
51
+ }
52
+ const changes = [];
53
+ // 1. URL change
54
+ if (afterUrl !== this.beforeUrl) {
55
+ changes.push({
56
+ kind: 'url_changed',
57
+ detail: `${this.beforeUrl} -> ${afterUrl}`,
58
+ });
59
+ }
60
+ // 2. Overlay changes
61
+ const beforeOverlayCount = this.beforeTree.overlays.length;
62
+ const afterOverlayCount = afterTree.overlays.length;
63
+ if (beforeOverlayCount !== afterOverlayCount) {
64
+ changes.push({
65
+ kind: 'overlay_changed',
66
+ detail: `overlays: ${beforeOverlayCount} -> ${afterOverlayCount}`,
67
+ });
68
+ }
69
+ // 3. Tree structure diff (node count at top level)
70
+ const beforeNodes = countVisibleNodes(this.beforeTree.root);
71
+ const afterNodes = countVisibleNodes(afterTree.root);
72
+ if (Math.abs(beforeNodes - afterNodes) > 2) {
73
+ changes.push({
74
+ kind: 'tree_structure_changed',
75
+ detail: `visible nodes: ${beforeNodes} -> ${afterNodes}`,
76
+ });
77
+ }
78
+ // 4. Check for new visible interactive nodes (e.g., modal appeared)
79
+ const beforeIds = collectVisibleInteractiveIds(this.beforeTree.root);
80
+ const afterIds = collectVisibleInteractiveIds(afterTree.root);
81
+ const appeared = afterIds.filter(id => !beforeIds.includes(id));
82
+ const disappeared = beforeIds.filter(id => !afterIds.includes(id));
83
+ if (appeared.length > 0) {
84
+ changes.push({
85
+ kind: 'node_appeared',
86
+ detail: `${appeared.length} new interactive node(s)`,
87
+ });
88
+ }
89
+ if (disappeared.length > 0) {
90
+ changes.push({
91
+ kind: 'node_disappeared',
92
+ detail: `${disappeared.length} interactive node(s) gone`,
93
+ });
94
+ }
95
+ // 5. Check page title change
96
+ if (this.beforeTree.page.title !== afterTree.page.title) {
97
+ changes.push({
98
+ kind: 'tree_structure_changed',
99
+ detail: `title: "${this.beforeTree.page.title}" -> "${afterTree.page.title}"`,
100
+ });
101
+ }
102
+ // If no changes detected at all
103
+ if (changes.length === 0) {
104
+ changes.push({ kind: 'no_change', detail: 'no detectable changes in URL, tree, or overlays' });
105
+ }
106
+ const hadEffect = changes.some(c => c.kind !== 'no_change');
107
+ const summary = changes.map(c => `${c.kind}: ${c.detail}`).join('; ');
108
+ // Reset state
109
+ this.beforeTree = null;
110
+ this.beforeUrl = null;
111
+ return { hadEffect, changes, summary };
112
+ }
113
+ }
114
+ // ── Helpers ─────────────────────────────────────────────────────────
115
+ function countVisibleNodes(node) {
116
+ let count = node.visible ? 1 : 0;
117
+ for (const child of node.children) {
118
+ count += countVisibleNodes(child);
119
+ }
120
+ return count;
121
+ }
122
+ function collectVisibleInteractiveIds(node) {
123
+ const ids = [];
124
+ function walk(n) {
125
+ if (n.visible && n.interactive) {
126
+ ids.push(n.id);
127
+ }
128
+ n.children.forEach(walk);
129
+ }
130
+ walk(node);
131
+ return ids;
132
+ }
133
+ //# sourceMappingURL=action-verifier.js.map
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Action recovery, guard inference, and login detection utilities for the capture agent.
3
+ * Extracted from agent.ts — these are pure functions with no closure dependencies.
4
+ */
5
+ import type { ExecutedAction, ActionType } from './types.js';
6
+ export declare const META_ACTIONS: Set<ActionType>;
7
+ export declare const BOOTSTRAP_ACTIONS: Set<ActionType>;
8
+ export declare const REPLAYABLE_ACTIONS: ReadonlyArray<ActionType>;
9
+ export declare function isNoEffectAction(action: ExecutedAction): boolean;
10
+ export declare function isBootstrapStabilizationAction(action: ExecutedAction): boolean;
11
+ export declare function hasMeaningfulBrowserAction(actionHistory: ExecutedAction[]): boolean;
12
+ export declare function buildRecoveryActionSignature(action: ExecutedAction): string;
13
+ export declare function isExplicitLoginAction(action: ExecutedAction): boolean;
14
+ export declare function hasRecentExplicitLoginAction(previousActions: ExecutedAction[]): boolean;
15
+ export declare function isLoginAction(action: ExecutedAction, previousActions?: ExecutedAction[]): boolean;
16
+ export declare function compactReplayActions(recordedActions: ExecutedAction[], params?: {
17
+ currentUrl?: string;
18
+ targetUrl?: string;
19
+ currentViewport?: {
20
+ width: number;
21
+ height: number;
22
+ } | null;
23
+ isAuthenticated?: boolean;
24
+ ignoreRecordedViewport?: boolean;
25
+ }): ExecutedAction[];
26
+ export declare function countRecentNoEffectActions(actionHistory: ExecutedAction[]): number;
27
+ export declare function shouldTriggerRecovery(actionHistory: ExecutedAction[]): boolean;
28
+ export declare function inferPrematureGiveUpCorrection(params: {
29
+ reason: string;
30
+ actionHistory: ExecutedAction[];
31
+ lastVerificationFailure?: string;
32
+ iteration: number;
33
+ maxIterations: number;
34
+ }): string | null;
35
+ export declare function inferSearchScrollLoopGuard(params: {
36
+ actionHistory: ExecutedAction[];
37
+ action: ActionType;
38
+ args: Record<string, unknown>;
39
+ }): string | null;
40
+ export declare function inferRepeatedActionGuard(params: {
41
+ actionHistory: ExecutedAction[];
42
+ action: ActionType;
43
+ args: Record<string, unknown>;
44
+ currentUrl?: string;
45
+ }): string | null;