autokap 1.0.7 → 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 (278) 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 +607 -0
  4. package/assets/skill/README.md +39 -0
  5. package/assets/skill/SKILL.md +453 -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 +164 -0
  26. package/dist/benchmark.d.ts +59 -0
  27. package/dist/benchmark.js +135 -0
  28. package/dist/browser-bar.d.ts +14 -6
  29. package/dist/browser-bar.js +145 -8
  30. package/dist/browser-pool.d.ts +7 -0
  31. package/dist/browser-pool.js +15 -5
  32. package/dist/browser-utils.d.ts +31 -0
  33. package/dist/browser-utils.js +97 -0
  34. package/dist/browser.d.ts +51 -1
  35. package/dist/browser.js +1481 -31
  36. package/dist/capture-alt-text.js +2 -1
  37. package/dist/capture-language-preflight.js +14 -0
  38. package/dist/capture-llm-page-identity.js +22 -10
  39. package/dist/capture-page-identity.d.ts +5 -7
  40. package/dist/capture-page-identity.js +211 -78
  41. package/dist/capture-preset-credentials.d.ts +50 -0
  42. package/dist/capture-preset-credentials.js +127 -0
  43. package/dist/capture-request-plan.d.ts +2 -2
  44. package/dist/capture-request-plan.js +64 -16
  45. package/dist/capture-run-optimizer.js +48 -33
  46. package/dist/capture-selector-memory.d.ts +5 -0
  47. package/dist/capture-selector-memory.js +18 -0
  48. package/dist/capture-strategy.d.ts +36 -0
  49. package/dist/capture-strategy.js +95 -0
  50. package/dist/capture-studio-sync.d.ts +1 -0
  51. package/dist/capture-studio-sync.js +9 -3
  52. package/dist/capture-surface-contract.d.ts +36 -0
  53. package/dist/capture-surface-contract.js +299 -0
  54. package/dist/capture-transition-engine.d.ts +28 -0
  55. package/dist/capture-transition-engine.js +292 -0
  56. package/dist/capture-variant-state.d.ts +2 -0
  57. package/dist/capture-variant-state.js +26 -0
  58. package/dist/capture-verification.d.ts +35 -0
  59. package/dist/capture-verification.js +95 -0
  60. package/dist/capture-viewport-lock.d.ts +48 -0
  61. package/dist/capture-viewport-lock.js +74 -0
  62. package/dist/circuit-breaker.d.ts +42 -0
  63. package/dist/circuit-breaker.js +119 -0
  64. package/dist/cli-config.d.ts +8 -1
  65. package/dist/cli-config.js +62 -6
  66. package/dist/cli-contract.d.ts +15 -0
  67. package/dist/cli-contract.js +167 -0
  68. package/dist/cli-runner-local.d.ts +12 -0
  69. package/dist/cli-runner-local.js +102 -0
  70. package/dist/cli-runner.d.ts +34 -0
  71. package/dist/cli-runner.js +433 -0
  72. package/dist/cli-utils.d.ts +0 -1
  73. package/dist/cli-utils.js +2 -5
  74. package/dist/cli.js +1005 -267
  75. package/dist/clip-orchestrator.js +9 -2
  76. package/dist/clip-postprocess.js +25 -16
  77. package/dist/cookie-dismiss.d.ts +2 -0
  78. package/dist/cookie-dismiss.js +48 -13
  79. package/dist/cost-logging.d.ts +8 -0
  80. package/dist/cost-logging.js +160 -46
  81. package/dist/cost-resolution-monitor.d.ts +16 -0
  82. package/dist/cost-resolution-monitor.js +34 -0
  83. package/dist/credential-templates.js +2 -2
  84. package/dist/cursor-overlay-script.d.ts +6 -0
  85. package/dist/cursor-overlay-script.js +169 -0
  86. package/dist/dom-css-purger.d.ts +65 -0
  87. package/dist/dom-css-purger.js +333 -0
  88. package/dist/dom-font-inliner.d.ts +45 -0
  89. package/dist/dom-font-inliner.js +148 -0
  90. package/dist/dom-patch-resolver.d.ts +52 -0
  91. package/dist/dom-patch-resolver.js +242 -0
  92. package/dist/dom-serializer.d.ts +82 -0
  93. package/dist/dom-serializer.js +378 -0
  94. package/dist/element-capture.d.ts +1 -41
  95. package/dist/element-capture.js +202 -446
  96. package/dist/env-validation.d.ts +5 -0
  97. package/dist/env-validation.js +29 -0
  98. package/dist/execution-schema.d.ts +4423 -0
  99. package/dist/execution-schema.js +507 -0
  100. package/dist/execution-types.d.ts +886 -0
  101. package/dist/execution-types.js +65 -0
  102. package/dist/fonts-loader.d.ts +14 -0
  103. package/dist/fonts-loader.js +55 -0
  104. package/dist/hybrid-navigator.js +12 -12
  105. package/dist/index.d.ts +9 -6
  106. package/dist/index.js +10 -4
  107. package/dist/legacy/agent-action-recovery.d.ts +45 -0
  108. package/dist/legacy/agent-action-recovery.js +370 -0
  109. package/dist/legacy/agent-message-utils.d.ts +21 -0
  110. package/dist/legacy/agent-message-utils.js +77 -0
  111. package/dist/legacy/agent-url-utils.d.ts +30 -0
  112. package/dist/legacy/agent-url-utils.js +138 -0
  113. package/dist/legacy/agent.d.ts +226 -0
  114. package/dist/legacy/agent.js +6666 -0
  115. package/dist/legacy/clip-orchestrator.d.ts +148 -0
  116. package/dist/legacy/clip-orchestrator.js +957 -0
  117. package/dist/legacy/credential-templates.d.ts +5 -0
  118. package/dist/legacy/credential-templates.js +60 -0
  119. package/dist/legacy/hybrid-navigator.d.ts +138 -0
  120. package/dist/legacy/hybrid-navigator.js +468 -0
  121. package/dist/legacy/llm-usage.d.ts +17 -0
  122. package/dist/legacy/llm-usage.js +45 -0
  123. package/dist/legacy/prompt-cache.d.ts +10 -0
  124. package/dist/legacy/prompt-cache.js +24 -0
  125. package/dist/legacy/prompts.d.ts +175 -0
  126. package/dist/legacy/prompts.js +1038 -0
  127. package/dist/legacy/tools.d.ts +4 -0
  128. package/dist/legacy/tools.js +216 -0
  129. package/dist/legacy/video-agent.d.ts +143 -0
  130. package/dist/legacy/video-agent.js +4788 -0
  131. package/dist/legacy/video-observation.d.ts +36 -0
  132. package/dist/legacy/video-observation.js +192 -0
  133. package/dist/legacy/video-planner.d.ts +12 -0
  134. package/dist/legacy/video-planner.js +501 -0
  135. package/dist/legacy/video-prompts.d.ts +37 -0
  136. package/dist/legacy/video-prompts.js +569 -0
  137. package/dist/legacy/video-tools.d.ts +3 -0
  138. package/dist/legacy/video-tools.js +59 -0
  139. package/dist/legacy/video-variant-state.d.ts +29 -0
  140. package/dist/legacy/video-variant-state.js +80 -0
  141. package/dist/legacy/vision-model.d.ts +17 -0
  142. package/dist/legacy/vision-model.js +74 -0
  143. package/dist/llm-healer.d.ts +63 -0
  144. package/dist/llm-healer.js +166 -0
  145. package/dist/llm-provider.d.ts +29 -0
  146. package/dist/llm-provider.js +80 -0
  147. package/dist/logger.d.ts +6 -2
  148. package/dist/logger.js +15 -1
  149. package/dist/mockup-html.js +35 -25
  150. package/dist/mockup.d.ts +95 -2
  151. package/dist/mockup.js +427 -166
  152. package/dist/mouse-animation.d.ts +2 -2
  153. package/dist/mouse-animation.js +34 -20
  154. package/dist/opcode-actions.d.ts +42 -0
  155. package/dist/opcode-actions.js +511 -0
  156. package/dist/opcode-runner.d.ts +51 -0
  157. package/dist/opcode-runner.js +770 -0
  158. package/dist/openrouter-client.d.ts +40 -0
  159. package/dist/openrouter-client.js +16 -0
  160. package/dist/overlay-engine.d.ts +24 -0
  161. package/dist/overlay-engine.js +176 -0
  162. package/dist/postcondition.d.ts +16 -0
  163. package/dist/postcondition.js +269 -0
  164. package/dist/program-patcher.d.ts +25 -0
  165. package/dist/program-patcher.js +44 -0
  166. package/dist/prompts.d.ts +13 -5
  167. package/dist/prompts.js +224 -351
  168. package/dist/provider-config.d.ts +12 -0
  169. package/dist/provider-config.js +15 -0
  170. package/dist/recovery-chain.d.ts +37 -0
  171. package/dist/recovery-chain.js +350 -0
  172. package/dist/remote-browser.d.ts +28 -4
  173. package/dist/remote-browser.js +60 -5
  174. package/dist/safari-browser-bar.d.ts +15 -0
  175. package/dist/safari-browser-bar.js +95 -0
  176. package/dist/safari-toolbar-asset.d.ts +15 -0
  177. package/dist/safari-toolbar-asset.js +12 -0
  178. package/dist/security.d.ts +2 -1
  179. package/dist/security.js +49 -10
  180. package/dist/selector-resolver.d.ts +34 -0
  181. package/dist/selector-resolver.js +181 -0
  182. package/dist/semantic-resolver.d.ts +35 -0
  183. package/dist/semantic-resolver.js +161 -0
  184. package/dist/server-capture-runtime.d.ts +5 -3
  185. package/dist/server-capture-runtime.js +42 -95
  186. package/dist/server-credit-usage.d.ts +2 -2
  187. package/dist/server-project-webhooks.d.ts +15 -1
  188. package/dist/server-project-webhooks.js +34 -8
  189. package/dist/server-screenshot-watermark.js +27 -5
  190. package/dist/session-profile.js +164 -1
  191. package/dist/sf-pro-symbols.d.ts +1 -0
  192. package/dist/sf-pro-symbols.js +55 -0
  193. package/dist/skill-packaging.d.ts +28 -0
  194. package/dist/skill-packaging.js +169 -0
  195. package/dist/smart-wait.d.ts +27 -0
  196. package/dist/smart-wait.js +81 -0
  197. package/dist/status-bar-render.d.ts +20 -0
  198. package/dist/status-bar-render.js +410 -0
  199. package/dist/status-bar.d.ts +9 -0
  200. package/dist/status-bar.js +298 -14
  201. package/dist/svg-browser-bar.d.ts +33 -0
  202. package/dist/svg-browser-bar.js +206 -0
  203. package/dist/svg-status-bar.d.ts +36 -0
  204. package/dist/svg-status-bar.js +597 -0
  205. package/dist/svg-text.d.ts +61 -0
  206. package/dist/svg-text.js +118 -0
  207. package/dist/tools.js +89 -451
  208. package/dist/types.d.ts +240 -5
  209. package/dist/types.js +23 -1
  210. package/dist/v2/action-verifier.d.ts +29 -0
  211. package/dist/v2/action-verifier.js +133 -0
  212. package/dist/v2/alt-text.d.ts +26 -0
  213. package/dist/v2/alt-text.js +55 -0
  214. package/dist/v2/benchmark.d.ts +59 -0
  215. package/dist/v2/benchmark.js +135 -0
  216. package/dist/v2/capture-strategy.d.ts +30 -0
  217. package/dist/v2/capture-strategy.js +67 -0
  218. package/dist/v2/capture-verification.d.ts +35 -0
  219. package/dist/v2/capture-verification.js +95 -0
  220. package/dist/v2/circuit-breaker.d.ts +42 -0
  221. package/dist/v2/circuit-breaker.js +119 -0
  222. package/dist/v2/cli-runner-local.d.ts +11 -0
  223. package/dist/v2/cli-runner-local.js +91 -0
  224. package/dist/v2/cli-runner.d.ts +34 -0
  225. package/dist/v2/cli-runner.js +300 -0
  226. package/dist/v2/compiler-prompts.d.ts +27 -0
  227. package/dist/v2/compiler-prompts.js +123 -0
  228. package/dist/v2/compiler.d.ts +37 -0
  229. package/dist/v2/compiler.js +147 -0
  230. package/dist/v2/explorer.d.ts +41 -0
  231. package/dist/v2/explorer.js +56 -0
  232. package/dist/v2/index.d.ts +37 -0
  233. package/dist/v2/index.js +31 -0
  234. package/dist/v2/llm-healer.d.ts +62 -0
  235. package/dist/v2/llm-healer.js +166 -0
  236. package/dist/v2/llm-provider.d.ts +29 -0
  237. package/dist/v2/llm-provider.js +80 -0
  238. package/dist/v2/opcode-runner.d.ts +47 -0
  239. package/dist/v2/opcode-runner.js +634 -0
  240. package/dist/v2/overlay-engine.d.ts +24 -0
  241. package/dist/v2/overlay-engine.js +150 -0
  242. package/dist/v2/postcondition.d.ts +16 -0
  243. package/dist/v2/postcondition.js +249 -0
  244. package/dist/v2/program-patcher.d.ts +25 -0
  245. package/dist/v2/program-patcher.js +44 -0
  246. package/dist/v2/recovery-chain.d.ts +30 -0
  247. package/dist/v2/recovery-chain.js +368 -0
  248. package/dist/v2/schema.d.ts +2580 -0
  249. package/dist/v2/schema.js +295 -0
  250. package/dist/v2/selector-resolver.d.ts +34 -0
  251. package/dist/v2/selector-resolver.js +181 -0
  252. package/dist/v2/semantic-resolver.d.ts +35 -0
  253. package/dist/v2/semantic-resolver.js +161 -0
  254. package/dist/v2/smart-wait.d.ts +27 -0
  255. package/dist/v2/smart-wait.js +81 -0
  256. package/dist/v2/types.d.ts +444 -0
  257. package/dist/v2/types.js +19 -0
  258. package/dist/v2/web-playwright-local.d.ts +69 -0
  259. package/dist/v2/web-playwright-local.js +392 -0
  260. package/dist/version.d.ts +1 -0
  261. package/dist/version.js +5 -0
  262. package/dist/video-agent.js +18 -13
  263. package/dist/video-planner.js +2 -1
  264. package/dist/video-prompts.js +3 -3
  265. package/dist/web-playwright-local.d.ts +126 -0
  266. package/dist/web-playwright-local.js +819 -0
  267. package/dist/ws-auth.js +4 -1
  268. package/dist/ws-broadcast.d.ts +34 -0
  269. package/dist/ws-broadcast.js +85 -0
  270. package/dist/ws-connection-limits.d.ts +12 -0
  271. package/dist/ws-connection-limits.js +44 -0
  272. package/dist/ws-handler-utils.d.ts +32 -0
  273. package/dist/ws-handler-utils.js +139 -0
  274. package/dist/ws-handler.js +294 -164
  275. package/dist/ws-metrics-server.d.ts +9 -0
  276. package/dist/ws-metrics-server.js +31 -0
  277. package/dist/ws-server.js +41 -1
  278. package/package.json +51 -34
@@ -0,0 +1,4 @@
1
+ import type { ChatCompletionFunctionTool } from 'openai/resources/chat/completions';
2
+ export declare const agentTools: ChatCompletionFunctionTool[];
3
+ /** Restricted tool set for the element capture mini-agent */
4
+ export declare const elementCaptureTools: ChatCompletionFunctionTool[];
@@ -0,0 +1,216 @@
1
+ // Note: evaluation_previous_action and memory fields are no longer injected into
2
+ // tool schemas. They are documented in the system prompt instead (see prompts.ts),
3
+ // which saves tokens on every iteration.
4
+ const akTypeEnum = [
5
+ 'button', 'input', 'link', 'text', 'image', 'heading',
6
+ 'list', 'table', 'container', 'icon', 'toggle', 'select',
7
+ 'checkbox', 'radio', 'slider', 'tab', 'modal', 'nav', 'form',
8
+ 'video', 'audio', 'iframe',
9
+ ];
10
+ const semanticPatternEnum = [
11
+ 'cookie-banner', 'modal', 'navbar', 'footer', 'hero',
12
+ 'sidebar', 'dropdown', 'toast', 'tooltip', 'form', 'card',
13
+ 'pricing-table', 'cta-group',
14
+ ];
15
+ const semanticTraitEnum = [
16
+ 'floating', 'overlay', 'sticky', 'fixed',
17
+ 'above-fold', 'below-fold', 'full-width', 'scrollable',
18
+ ];
19
+ export const agentTools = [
20
+ {
21
+ type: 'function',
22
+ function: {
23
+ name: 'tap',
24
+ description: 'Click an element identified by its AKTree nodeId.',
25
+ parameters: {
26
+ type: 'object',
27
+ properties: {
28
+ nodeId: {
29
+ type: 'string',
30
+ description: 'Stable AKTree node id, for example "ak_3f8a2c1b".',
31
+ },
32
+ },
33
+ required: ['nodeId'],
34
+ },
35
+ },
36
+ },
37
+ {
38
+ type: 'function',
39
+ function: {
40
+ name: 'type',
41
+ description: 'Type text into a text-like control identified by AKTree nodeId.',
42
+ parameters: {
43
+ type: 'object',
44
+ properties: {
45
+ nodeId: {
46
+ type: 'string',
47
+ description: 'Stable AKTree node id of the target input.',
48
+ },
49
+ text: {
50
+ type: 'string',
51
+ description: 'Text to type. Use credential placeholders when available.',
52
+ },
53
+ },
54
+ required: ['nodeId', 'text'],
55
+ },
56
+ },
57
+ },
58
+ {
59
+ type: 'function',
60
+ function: {
61
+ name: 'scroll',
62
+ description: 'Scroll the page or a scrollable AKTree container. Use direction/offset for manual scrolling, or centerOn to center another AKTree node inside the page or container.',
63
+ parameters: {
64
+ type: 'object',
65
+ properties: {
66
+ direction: {
67
+ type: 'string',
68
+ enum: ['up', 'down', 'left', 'right'],
69
+ description: 'Scroll direction for manual scrolling. Optional when centerOn is provided.',
70
+ },
71
+ offset: {
72
+ type: 'number',
73
+ description: 'Optional scroll offset in pixels for manual scrolling, or bias in pixels from perfect center when centerOn is provided.',
74
+ },
75
+ target: {
76
+ type: 'string',
77
+ description: 'Optional AKTree node id of a scrollable container. Omit to scroll the page.',
78
+ },
79
+ centerOn: {
80
+ type: 'string',
81
+ description: 'Optional AKTree node id to bring to the center of the page or of the target container.',
82
+ },
83
+ },
84
+ required: [],
85
+ },
86
+ },
87
+ },
88
+ {
89
+ type: 'function',
90
+ function: {
91
+ name: 'navigate_to',
92
+ description: 'Navigate directly to a URL on the current site when that is the fastest deterministic way to reach the target.',
93
+ parameters: {
94
+ type: 'object',
95
+ properties: {
96
+ url: {
97
+ type: 'string',
98
+ description: 'Absolute or site-relative URL to navigate to.',
99
+ },
100
+ },
101
+ required: ['url'],
102
+ },
103
+ },
104
+ },
105
+ {
106
+ type: 'function',
107
+ function: {
108
+ name: 'press_key',
109
+ description: 'Press a keyboard key when the workflow requires Escape, Enter, Tab, or arrow keys.',
110
+ parameters: {
111
+ type: 'object',
112
+ properties: {
113
+ key: {
114
+ type: 'string',
115
+ description: 'Keyboard key name, for example "Escape", "Enter", "Tab", "ArrowDown".',
116
+ },
117
+ },
118
+ required: ['key'],
119
+ },
120
+ },
121
+ },
122
+ {
123
+ type: 'function',
124
+ function: {
125
+ name: 'capture',
126
+ description: 'Capture the current target and end the current run. When nodeId is provided, crop to that node bounds.',
127
+ parameters: {
128
+ type: 'object',
129
+ properties: {
130
+ nodeId: {
131
+ type: 'string',
132
+ description: 'Optional AKTree node id to crop. Omit for a page-level capture.',
133
+ },
134
+ },
135
+ required: [],
136
+ },
137
+ },
138
+ },
139
+ {
140
+ type: 'function',
141
+ function: {
142
+ name: 'analyze_screenshot',
143
+ description: 'Ask the vision model a targeted question about the current screenshot when AKTree structure is insufficient.',
144
+ parameters: {
145
+ type: 'object',
146
+ properties: {
147
+ question: {
148
+ type: 'string',
149
+ description: 'Specific visual question to answer, for example "Is a modal blocking the page?" or "Does this dialog already show the target template selected?"',
150
+ },
151
+ },
152
+ required: ['question'],
153
+ },
154
+ },
155
+ },
156
+ {
157
+ type: 'function',
158
+ function: {
159
+ name: 'focus',
160
+ description: 'Return a filtered AKTree view using typed filters only.',
161
+ parameters: {
162
+ type: 'object',
163
+ properties: {
164
+ type: {
165
+ type: 'array',
166
+ items: { type: 'string', enum: [...akTypeEnum] },
167
+ description: 'Optional node types to keep.',
168
+ },
169
+ semantic: {
170
+ type: 'array',
171
+ items: { type: 'string', enum: [...semanticPatternEnum] },
172
+ description: 'Optional semantic patterns to keep.',
173
+ },
174
+ trait: {
175
+ type: 'array',
176
+ items: { type: 'string', enum: [...semanticTraitEnum] },
177
+ description: 'Optional semantic traits to keep.',
178
+ },
179
+ interactive: {
180
+ type: 'boolean',
181
+ description: 'Optional interactive filter.',
182
+ },
183
+ visible: {
184
+ type: 'boolean',
185
+ description: 'Optional visibility filter.',
186
+ },
187
+ within: {
188
+ type: 'string',
189
+ description: 'Optional AKTree node id used as subtree scope.',
190
+ },
191
+ labelContains: {
192
+ type: 'string',
193
+ description: 'Case-insensitive substring match against node labels.',
194
+ },
195
+ maxDepth: {
196
+ type: 'number',
197
+ description: 'Optional maximum subtree depth.',
198
+ },
199
+ includeAncestors: {
200
+ type: 'boolean',
201
+ description: 'Include parent path to the root when true.',
202
+ },
203
+ },
204
+ required: [],
205
+ },
206
+ },
207
+ },
208
+ ];
209
+ /** Restricted tool set for the element capture mini-agent */
210
+ export const elementCaptureTools = [
211
+ agentTools[7],
212
+ agentTools[2],
213
+ agentTools[6],
214
+ agentTools[5],
215
+ ];
216
+ //# sourceMappingURL=tools.js.map
@@ -0,0 +1,143 @@
1
+ import { Browser } from '../browser.js';
2
+ import type { VideoAgentConfig, VideoAgentResult, VideoPhase, InteractiveElement, VideoStep, VideoPlan, StepUsage, VideoStepAttemptTrace, VideoStepArtifact, VideoSelectorMemoryUpdate, VideoPageSignals, VideoObservationSnapshot, BrowserSessionStorageState, BrowserStorageState } from '../types.js';
3
+ export type VideoLogCallback = (entry: {
4
+ level: 'info' | 'success' | 'error' | 'ai';
5
+ message: string;
6
+ timestamp: number;
7
+ }) => void;
8
+ export type VideoPhaseCallback = (phase: VideoPhase) => void;
9
+ export type VideoStepCallback = (stepIndex: number, total: number, description: string, phase: 'dry_run' | 'recording') => void;
10
+ export type VideoStepResultCallback = (stepIndex: number, ok: boolean, reason?: string) => void;
11
+ export type VideoVariantPhase = 'preflight' | 'planning' | 'dry_run' | 'recording' | 'done' | 'failed';
12
+ export interface VideoPreflightResult {
13
+ ok: boolean;
14
+ reason?: string;
15
+ code?: string;
16
+ detectedLang?: string | null;
17
+ detectedTheme?: 'light' | 'dark' | null;
18
+ finalUrl?: string;
19
+ storageState?: BrowserStorageState;
20
+ sessionStorage?: BrowserSessionStorageState;
21
+ pageSignals?: VideoPageSignals;
22
+ observationSummary?: string;
23
+ observationSnapshot?: VideoObservationSnapshot;
24
+ usage?: StepUsage[];
25
+ }
26
+ export type VideoPreflightCallback = (result: VideoPreflightResult) => void;
27
+ export type VideoVariantPhaseCallback = (phase: VideoVariantPhase) => void;
28
+ export type VideoStepAttemptCallback = (attempt: VideoStepAttemptTrace) => void;
29
+ export type VideoStepArtifactCallback = (artifact: VideoStepArtifact) => void;
30
+ export interface VideoRunCallbacks {
31
+ onLog?: VideoLogCallback;
32
+ onPhaseChange?: VideoPhaseCallback;
33
+ onVariantPhase?: VideoVariantPhaseCallback;
34
+ onStep?: VideoStepCallback;
35
+ onStepResult?: VideoStepResultCallback;
36
+ onStepAttempt?: VideoStepAttemptCallback;
37
+ onStepArtifact?: VideoStepArtifactCallback;
38
+ onPreflightResult?: VideoPreflightCallback;
39
+ /** Emit a live Playwright screenshot (base64 JPEG) for real-time preview in the UI. */
40
+ onScreenshot?: (base64: string) => void;
41
+ }
42
+ type VideoDryRunFailureSubphase = 'prepared_variant' | 'deterministic_exec' | 'verification_snapshot' | 'verification_llm' | 'repair_lane' | 'llm_fixer' | 'checkpoint_restore' | 'budget';
43
+ export interface VideoDryRunFailure {
44
+ stepIndex: number;
45
+ subphase: VideoDryRunFailureSubphase;
46
+ reason: string;
47
+ resolvedTargetSummary?: string;
48
+ }
49
+ interface VideoStepCheckpoint {
50
+ url: string;
51
+ scrollX: number;
52
+ scrollY: number;
53
+ }
54
+ interface ViewportRectSnapshot {
55
+ top: number;
56
+ bottom: number;
57
+ left: number;
58
+ right: number;
59
+ width: number;
60
+ height: number;
61
+ }
62
+ export declare function restoreVideoStepCheckpoint(browser: Browser, checkpoint: VideoStepCheckpoint): Promise<void>;
63
+ export declare function isRectMeaningfullyVisibleInViewport(params: {
64
+ rect: ViewportRectSnapshot;
65
+ viewportWidth: number;
66
+ viewportHeight: number;
67
+ topInset?: number;
68
+ bottomInset?: number;
69
+ }): boolean;
70
+ export declare function sanitizeVariantPrefixSteps(steps: VideoStep[], requestedLang?: string, requestedTheme?: 'light' | 'dark'): VideoStep[];
71
+ export declare function evaluateVideoStepSafety(step: VideoStep, config: VideoAgentConfig, page: import('playwright').Page, currentUrl: string, interactiveElements: InteractiveElement[]): Promise<{
72
+ allowed: boolean;
73
+ reason?: string;
74
+ }>;
75
+ export declare function extractNamedScrollTarget(description?: string): string | null;
76
+ export declare function inspectVideoTarget(page: import('playwright').Page, selector?: string, coordinates?: {
77
+ x: number;
78
+ y: number;
79
+ }): Promise<InteractiveElement | null>;
80
+ interface VerifyStepResult {
81
+ ok: boolean;
82
+ reason?: string;
83
+ suggestion?: string;
84
+ giveUp?: boolean;
85
+ usage: Partial<StepUsage>;
86
+ }
87
+ export declare function verifyVideoStepDeterministically(browser: Browser, step: VideoStep): Promise<VerifyStepResult | null>;
88
+ export declare function runVariantPreflight(config: VideoAgentConfig, prefixPlan: VideoPlan | null, callbacks?: VideoRunCallbacks): Promise<VideoPreflightResult>;
89
+ export declare function composeHybridPlan(basePlan: VideoPlan, variantPrefixPlan: VideoPlan | null): VideoPlan;
90
+ export declare function createBasePlan(config: VideoAgentConfig): Promise<{
91
+ plan: VideoPlan;
92
+ usage: StepUsage;
93
+ }>;
94
+ export declare function createVariantPrefixPlan(config: VideoAgentConfig): Promise<{
95
+ plan: VideoPlan;
96
+ usage: StepUsage;
97
+ }>;
98
+ export declare function verifyAndPatchPlan(plan: VideoPlan, config: VideoAgentConfig, callbacks?: VideoRunCallbacks): Promise<{
99
+ success: true;
100
+ plan: VideoPlan;
101
+ usage: StepUsage[];
102
+ memoryUpdates: VideoSelectorMemoryUpdate[];
103
+ } | {
104
+ success: false;
105
+ error: string;
106
+ usage: StepUsage[];
107
+ memoryUpdates: VideoSelectorMemoryUpdate[];
108
+ failedStepIndex?: number;
109
+ failedSubphase?: VideoDryRunFailureSubphase;
110
+ }>;
111
+ /**
112
+ * Backward-compatible helper: full planning + verify in one call.
113
+ */
114
+ export declare function planAndVerify(config: VideoAgentConfig, callbacks?: VideoRunCallbacks): Promise<{
115
+ success: true;
116
+ plan: VideoPlan;
117
+ usage: StepUsage[];
118
+ memoryUpdates: VideoSelectorMemoryUpdate[];
119
+ } | {
120
+ success: false;
121
+ error: string;
122
+ usage: StepUsage[];
123
+ memoryUpdates: VideoSelectorMemoryUpdate[];
124
+ }>;
125
+ /**
126
+ * Run phase 3 (recording only) using a pre-verified plan.
127
+ * Call after `planAndVerify()` to record across multiple lang/theme combinations.
128
+ */
129
+ export declare function recordPlan(plan: VideoPlan, config: VideoAgentConfig, callbacks?: VideoRunCallbacks): Promise<{
130
+ videoPath: string | null;
131
+ durationMs: number;
132
+ stepsExecuted: number;
133
+ setupDurationSec: number;
134
+ usage: StepUsage[];
135
+ }>;
136
+ /**
137
+ * Run the full 3-phase video capture pipeline:
138
+ * 1. Planning: script → structured plan (LLM)
139
+ * 2. Dry-run: verify all steps work
140
+ * 3. Recording: execute with Bezier mouse + cursor overlay
141
+ */
142
+ export declare function runVideoAgent(config: VideoAgentConfig, callbacks?: VideoRunCallbacks): Promise<VideoAgentResult>;
143
+ export {};