@e2edev/e2e 0.11.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (344) hide show
  1. package/README.md +7 -7
  2. package/dist/agent/act.d.ts +43 -9
  3. package/dist/agent/act.d.ts.map +1 -1
  4. package/dist/agent/act.js +126 -734
  5. package/dist/agent/act.js.map +1 -1
  6. package/dist/agent/action-dispatcher.d.ts +98 -0
  7. package/dist/agent/action-dispatcher.d.ts.map +1 -0
  8. package/dist/agent/action-dispatcher.js +319 -0
  9. package/dist/agent/action-dispatcher.js.map +1 -0
  10. package/dist/agent/actions.d.ts +16 -1
  11. package/dist/agent/actions.d.ts.map +1 -1
  12. package/dist/agent/actions.js +5 -1
  13. package/dist/agent/actions.js.map +1 -1
  14. package/dist/agent/default-agent.d.ts +17 -8
  15. package/dist/agent/default-agent.d.ts.map +1 -1
  16. package/dist/agent/default-agent.js +65 -43
  17. package/dist/agent/default-agent.js.map +1 -1
  18. package/dist/agent/executor.d.ts +30 -2
  19. package/dist/agent/executor.d.ts.map +1 -1
  20. package/dist/agent/executor.js.map +1 -1
  21. package/dist/agent/index.js +1 -1
  22. package/dist/agent/index.js.map +1 -1
  23. package/dist/agent/interactive-step.d.ts +38 -0
  24. package/dist/agent/interactive-step.d.ts.map +1 -0
  25. package/dist/agent/interactive-step.js +131 -0
  26. package/dist/agent/interactive-step.js.map +1 -0
  27. package/dist/agent/invocation.d.ts +4 -9
  28. package/dist/agent/invocation.d.ts.map +1 -1
  29. package/dist/agent/invocation.js +1 -6
  30. package/dist/agent/invocation.js.map +1 -1
  31. package/dist/agent/model/sdk.d.ts +1 -1
  32. package/dist/agent/model/sdk.js +1 -1
  33. package/dist/agent/model/tool-choice.d.ts +21 -0
  34. package/dist/agent/model/tool-choice.d.ts.map +1 -0
  35. package/dist/agent/model/tool-choice.js +49 -0
  36. package/dist/agent/model/tool-choice.js.map +1 -0
  37. package/dist/agent/observation-feed.d.ts +123 -0
  38. package/dist/agent/observation-feed.d.ts.map +1 -0
  39. package/dist/agent/observation-feed.js +281 -0
  40. package/dist/agent/observation-feed.js.map +1 -0
  41. package/dist/agent/observation.d.ts +14 -1
  42. package/dist/agent/observation.d.ts.map +1 -1
  43. package/dist/agent/observation.js +58 -2
  44. package/dist/agent/observation.js.map +1 -1
  45. package/dist/agent/operation-queue.d.ts +21 -0
  46. package/dist/agent/operation-queue.d.ts.map +1 -0
  47. package/dist/agent/operation-queue.js +27 -0
  48. package/dist/agent/operation-queue.js.map +1 -0
  49. package/dist/agent/pixels.d.ts +21 -0
  50. package/dist/agent/pixels.d.ts.map +1 -0
  51. package/dist/agent/pixels.js +85 -0
  52. package/dist/agent/pixels.js.map +1 -0
  53. package/dist/agent/point-tap.d.ts +52 -0
  54. package/dist/agent/point-tap.d.ts.map +1 -0
  55. package/dist/agent/point-tap.js +88 -0
  56. package/dist/agent/point-tap.js.map +1 -0
  57. package/dist/agent/primitives.d.ts +7 -1
  58. package/dist/agent/primitives.d.ts.map +1 -1
  59. package/dist/agent/primitives.js +96 -25
  60. package/dist/agent/primitives.js.map +1 -1
  61. package/dist/agent/replay.d.ts +8 -3
  62. package/dist/agent/replay.d.ts.map +1 -1
  63. package/dist/agent/replay.js +44 -15
  64. package/dist/agent/replay.js.map +1 -1
  65. package/dist/agent/screen-update.d.ts +50 -18
  66. package/dist/agent/screen-update.d.ts.map +1 -1
  67. package/dist/agent/screen-update.js +76 -94
  68. package/dist/agent/screen-update.js.map +1 -1
  69. package/dist/agent/step-accounting.d.ts +95 -0
  70. package/dist/agent/step-accounting.d.ts.map +1 -0
  71. package/dist/agent/step-accounting.js +201 -0
  72. package/dist/agent/step-accounting.js.map +1 -0
  73. package/dist/agent/step-cache.d.ts.map +1 -1
  74. package/dist/agent/step-cache.js +2 -2
  75. package/dist/agent/step-cache.js.map +1 -1
  76. package/dist/agent/tool-loop.d.ts +4 -4
  77. package/dist/agent/tool-loop.d.ts.map +1 -1
  78. package/dist/agent/tool-loop.js +109 -25
  79. package/dist/agent/tool-loop.js.map +1 -1
  80. package/dist/agent/transcript-compaction.d.ts +38 -0
  81. package/dist/agent/transcript-compaction.d.ts.map +1 -0
  82. package/dist/agent/transcript-compaction.js +165 -0
  83. package/dist/agent/transcript-compaction.js.map +1 -0
  84. package/dist/cache/recorder.d.ts.map +1 -1
  85. package/dist/cache/recorder.js +20 -0
  86. package/dist/cache/recorder.js.map +1 -1
  87. package/dist/cache/trace.d.ts +28 -1
  88. package/dist/cache/trace.d.ts.map +1 -1
  89. package/dist/cache/trace.js +44 -0
  90. package/dist/cache/trace.js.map +1 -1
  91. package/dist/cli/docs-url.d.ts +1 -1
  92. package/dist/cli/docs-url.d.ts.map +1 -1
  93. package/dist/cli/docs-url.js +1 -1
  94. package/dist/cli/docs-url.js.map +1 -1
  95. package/dist/cli/index.d.ts.map +1 -1
  96. package/dist/cli/index.js +71 -26
  97. package/dist/cli/index.js.map +1 -1
  98. package/dist/cli/init/engine-versions.json +1 -1
  99. package/dist/cli/init/engines.d.ts +26 -16
  100. package/dist/cli/init/engines.d.ts.map +1 -1
  101. package/dist/cli/init/engines.js +33 -24
  102. package/dist/cli/init/engines.js.map +1 -1
  103. package/dist/cli/init/gateways.js +3 -3
  104. package/dist/cli/init/mcp-config.d.ts +31 -0
  105. package/dist/cli/init/mcp-config.d.ts.map +1 -0
  106. package/dist/cli/init/mcp-config.js +72 -0
  107. package/dist/cli/init/mcp-config.js.map +1 -0
  108. package/dist/cli/init/scaffold.d.ts +1 -1
  109. package/dist/cli/init/scaffold.js +2 -2
  110. package/dist/cli/init/scaffold.js.map +1 -1
  111. package/dist/cli/init.d.ts.map +1 -1
  112. package/dist/cli/init.js +65 -29
  113. package/dist/cli/init.js.map +1 -1
  114. package/dist/cli/mcp.d.ts +15 -0
  115. package/dist/cli/mcp.d.ts.map +1 -0
  116. package/dist/cli/mcp.js +63 -0
  117. package/dist/cli/mcp.js.map +1 -0
  118. package/dist/collect/collect.d.ts +8 -3
  119. package/dist/collect/collect.d.ts.map +1 -1
  120. package/dist/collect/collect.js +29 -5
  121. package/dist/collect/collect.js.map +1 -1
  122. package/dist/collect/registry.d.ts +20 -5
  123. package/dist/collect/registry.d.ts.map +1 -1
  124. package/dist/collect/registry.js +162 -56
  125. package/dist/collect/registry.js.map +1 -1
  126. package/dist/collect/select.d.ts +9 -2
  127. package/dist/collect/select.d.ts.map +1 -1
  128. package/dist/collect/select.js +60 -12
  129. package/dist/collect/select.js.map +1 -1
  130. package/dist/config/agent.d.ts +1 -7
  131. package/dist/config/agent.d.ts.map +1 -1
  132. package/dist/config/agent.js +5 -8
  133. package/dist/config/agent.js.map +1 -1
  134. package/dist/config/app.d.ts +24 -2
  135. package/dist/config/app.d.ts.map +1 -1
  136. package/dist/config/app.js +82 -15
  137. package/dist/config/app.js.map +1 -1
  138. package/dist/config/resolve.d.ts +23 -6
  139. package/dist/config/resolve.d.ts.map +1 -1
  140. package/dist/config/resolve.js +34 -14
  141. package/dist/config/resolve.js.map +1 -1
  142. package/dist/credentials.d.ts +6 -0
  143. package/dist/credentials.d.ts.map +1 -1
  144. package/dist/credentials.js +9 -0
  145. package/dist/credentials.js.map +1 -1
  146. package/dist/engine/contract.d.ts +9 -2
  147. package/dist/engine/contract.d.ts.map +1 -1
  148. package/dist/engine/contract.js.map +1 -1
  149. package/dist/engine/index.d.ts +18 -4
  150. package/dist/engine/index.d.ts.map +1 -1
  151. package/dist/engine/index.js +8 -0
  152. package/dist/engine/index.js.map +1 -1
  153. package/dist/engine/session.d.ts.map +1 -1
  154. package/dist/engine/session.js +3 -0
  155. package/dist/engine/session.js.map +1 -1
  156. package/dist/engine/surface.d.ts +6 -2
  157. package/dist/engine/surface.d.ts.map +1 -1
  158. package/dist/engine/surface.js.map +1 -1
  159. package/dist/expect/attempt.d.ts +15 -0
  160. package/dist/expect/attempt.d.ts.map +1 -0
  161. package/dist/expect/attempt.js +33 -0
  162. package/dist/expect/attempt.js.map +1 -0
  163. package/dist/expect/index.d.ts +7 -5
  164. package/dist/expect/index.d.ts.map +1 -1
  165. package/dist/expect/index.js +8 -1
  166. package/dist/expect/index.js.map +1 -1
  167. package/dist/expect/poll.d.ts +5 -0
  168. package/dist/expect/poll.d.ts.map +1 -0
  169. package/dist/expect/poll.js +118 -0
  170. package/dist/expect/poll.js.map +1 -0
  171. package/dist/expect/values.d.ts.map +1 -1
  172. package/dist/expect/values.js +6 -1
  173. package/dist/expect/values.js.map +1 -1
  174. package/dist/explore/body.d.ts.map +1 -1
  175. package/dist/explore/body.js +2 -0
  176. package/dist/explore/body.js.map +1 -1
  177. package/dist/explore/executor.js +16 -11
  178. package/dist/explore/executor.js.map +1 -1
  179. package/dist/explore/index.d.ts +3 -2
  180. package/dist/explore/index.d.ts.map +1 -1
  181. package/dist/explore/index.js +11 -9
  182. package/dist/explore/index.js.map +1 -1
  183. package/dist/explore/plan.d.ts.map +1 -1
  184. package/dist/explore/plan.js +16 -5
  185. package/dist/explore/plan.js.map +1 -1
  186. package/dist/explore/progress.d.ts +43 -0
  187. package/dist/explore/progress.d.ts.map +1 -0
  188. package/dist/explore/progress.js +9 -0
  189. package/dist/explore/progress.js.map +1 -0
  190. package/dist/explore/state.d.ts +13 -12
  191. package/dist/explore/state.d.ts.map +1 -1
  192. package/dist/explore/state.js +28 -11
  193. package/dist/explore/state.js.map +1 -1
  194. package/dist/internal/ai-trace.d.ts +2 -0
  195. package/dist/internal/ai-trace.d.ts.map +1 -1
  196. package/dist/internal/ai-trace.js +3 -0
  197. package/dist/internal/ai-trace.js.map +1 -1
  198. package/dist/internal/brands.d.ts +2 -0
  199. package/dist/internal/brands.d.ts.map +1 -1
  200. package/dist/internal/brands.js +2 -0
  201. package/dist/internal/brands.js.map +1 -1
  202. package/dist/internal/geometry.d.ts +13 -0
  203. package/dist/internal/geometry.d.ts.map +1 -0
  204. package/dist/internal/geometry.js +16 -0
  205. package/dist/internal/geometry.js.map +1 -0
  206. package/dist/internal/ids.d.ts +2 -2
  207. package/dist/internal/ids.d.ts.map +1 -1
  208. package/dist/internal/ids.js +3 -3
  209. package/dist/internal/ids.js.map +1 -1
  210. package/dist/internal/package-manager.d.ts +4 -0
  211. package/dist/internal/package-manager.d.ts.map +1 -1
  212. package/dist/internal/package-manager.js +26 -0
  213. package/dist/internal/package-manager.js.map +1 -1
  214. package/dist/internal/urls.d.ts +6 -0
  215. package/dist/internal/urls.d.ts.map +1 -1
  216. package/dist/internal/urls.js +28 -0
  217. package/dist/internal/urls.js.map +1 -1
  218. package/dist/mcp/catalog.d.ts +51 -0
  219. package/dist/mcp/catalog.d.ts.map +1 -0
  220. package/dist/mcp/catalog.js +141 -0
  221. package/dist/mcp/catalog.js.map +1 -0
  222. package/dist/mcp/config.d.ts +11 -0
  223. package/dist/mcp/config.d.ts.map +1 -0
  224. package/dist/mcp/config.js +16 -0
  225. package/dist/mcp/config.js.map +1 -0
  226. package/dist/mcp/server.d.ts +29 -0
  227. package/dist/mcp/server.d.ts.map +1 -0
  228. package/dist/mcp/server.js +86 -0
  229. package/dist/mcp/server.js.map +1 -0
  230. package/dist/mcp/session.d.ts +68 -0
  231. package/dist/mcp/session.d.ts.map +1 -0
  232. package/dist/mcp/session.js +319 -0
  233. package/dist/mcp/session.js.map +1 -0
  234. package/dist/mcp/tools.d.ts +77 -0
  235. package/dist/mcp/tools.d.ts.map +1 -0
  236. package/dist/mcp/tools.js +179 -0
  237. package/dist/mcp/tools.js.map +1 -0
  238. package/dist/report/build.d.ts +8 -0
  239. package/dist/report/build.d.ts.map +1 -1
  240. package/dist/report/build.js +3 -1
  241. package/dist/report/build.js.map +1 -1
  242. package/dist/report/format.d.ts +19 -0
  243. package/dist/report/format.d.ts.map +1 -1
  244. package/dist/report/format.js +42 -0
  245. package/dist/report/format.js.map +1 -1
  246. package/dist/report/junit.d.ts.map +1 -1
  247. package/dist/report/junit.js +4 -1
  248. package/dist/report/junit.js.map +1 -1
  249. package/dist/report/list-explore.d.ts +109 -0
  250. package/dist/report/list-explore.d.ts.map +1 -0
  251. package/dist/report/list-explore.js +388 -0
  252. package/dist/report/list-explore.js.map +1 -0
  253. package/dist/report/list.d.ts +31 -1
  254. package/dist/report/list.d.ts.map +1 -1
  255. package/dist/report/list.js +114 -16
  256. package/dist/report/list.js.map +1 -1
  257. package/dist/report/running-tree.d.ts +7 -7
  258. package/dist/report/running-tree.d.ts.map +1 -1
  259. package/dist/report/running-tree.js +12 -13
  260. package/dist/report/running-tree.js.map +1 -1
  261. package/dist/run/app-ports.d.ts +17 -0
  262. package/dist/run/app-ports.d.ts.map +1 -0
  263. package/dist/run/app-ports.js +74 -0
  264. package/dist/run/app-ports.js.map +1 -0
  265. package/dist/run/events.d.ts +21 -7
  266. package/dist/run/events.d.ts.map +1 -1
  267. package/dist/run/events.js.map +1 -1
  268. package/dist/run/execute.d.ts +2 -2
  269. package/dist/run/execute.d.ts.map +1 -1
  270. package/dist/run/execute.js +42 -20
  271. package/dist/run/execute.js.map +1 -1
  272. package/dist/run/extended-fixtures.d.ts +33 -0
  273. package/dist/run/extended-fixtures.d.ts.map +1 -0
  274. package/dist/run/extended-fixtures.js +91 -0
  275. package/dist/run/extended-fixtures.js.map +1 -0
  276. package/dist/run/fixtures.d.ts +10 -4
  277. package/dist/run/fixtures.d.ts.map +1 -1
  278. package/dist/run/fixtures.js +40 -27
  279. package/dist/run/fixtures.js.map +1 -1
  280. package/dist/run/in-process.d.ts.map +1 -1
  281. package/dist/run/in-process.js +4 -3
  282. package/dist/run/in-process.js.map +1 -1
  283. package/dist/run/managed-process.d.ts +18 -0
  284. package/dist/run/managed-process.d.ts.map +1 -1
  285. package/dist/run/managed-process.js +101 -6
  286. package/dist/run/managed-process.js.map +1 -1
  287. package/dist/run/provision.d.ts +51 -0
  288. package/dist/run/provision.d.ts.map +1 -0
  289. package/dist/run/provision.js +94 -0
  290. package/dist/run/provision.js.map +1 -0
  291. package/dist/run/realm.d.ts +5 -4
  292. package/dist/run/realm.d.ts.map +1 -1
  293. package/dist/run/realm.js +8 -7
  294. package/dist/run/realm.js.map +1 -1
  295. package/dist/run/records.d.ts +4 -0
  296. package/dist/run/records.d.ts.map +1 -1
  297. package/dist/run/runner.d.ts +14 -5
  298. package/dist/run/runner.d.ts.map +1 -1
  299. package/dist/run/runner.js +28 -71
  300. package/dist/run/runner.js.map +1 -1
  301. package/dist/run/scheduler.d.ts +5 -2
  302. package/dist/run/scheduler.d.ts.map +1 -1
  303. package/dist/run/scheduler.js +13 -10
  304. package/dist/run/scheduler.js.map +1 -1
  305. package/dist/run/serial.d.ts +1 -1
  306. package/dist/run/serial.d.ts.map +1 -1
  307. package/dist/run/serial.js +7 -2
  308. package/dist/run/serial.js.map +1 -1
  309. package/dist/run/standalone.d.ts +63 -0
  310. package/dist/run/standalone.d.ts.map +1 -0
  311. package/dist/run/standalone.js +152 -0
  312. package/dist/run/standalone.js.map +1 -0
  313. package/dist/run/units.d.ts +6 -3
  314. package/dist/run/units.d.ts.map +1 -1
  315. package/dist/run/units.js +0 -0
  316. package/dist/run/units.js.map +1 -1
  317. package/dist/run/worker/entry.js +4 -3
  318. package/dist/run/worker/entry.js.map +1 -1
  319. package/dist/run/worker/protocol.d.ts +12 -1
  320. package/dist/run/worker/protocol.d.ts.map +1 -1
  321. package/dist/run/worker/protocol.js.map +1 -1
  322. package/dist/run/worker/session.d.ts +3 -4
  323. package/dist/run/worker/session.d.ts.map +1 -1
  324. package/dist/run/worker/session.js +5 -4
  325. package/dist/run/worker/session.js.map +1 -1
  326. package/dist/types.d.ts +77 -17
  327. package/dist/types.d.ts.map +1 -1
  328. package/package.json +11 -7
  329. package/skills/e2e/SKILL.md +9 -7
  330. package/skills/e2e/references/agent.md +27 -12
  331. package/skills/e2e/references/debugging.md +5 -5
  332. package/skills/e2e/references/explore.md +15 -9
  333. package/skills/e2e/references/mcp.md +88 -0
  334. package/skills/e2e/references/running.md +23 -18
  335. package/skills/e2e/references/setup.md +32 -18
  336. package/skills/e2e/references/writing-tests.md +12 -5
  337. package/dist/agent/model/router.d.ts +0 -36
  338. package/dist/agent/model/router.d.ts.map +0 -1
  339. package/dist/agent/model/router.js +0 -45
  340. package/dist/agent/model/router.js.map +0 -1
  341. package/dist/explore/reporter.d.ts +0 -11
  342. package/dist/explore/reporter.d.ts.map +0 -1
  343. package/dist/explore/reporter.js +0 -54
  344. package/dist/explore/reporter.js.map +0 -1
@@ -0,0 +1,281 @@
1
+ /**
2
+ * What one step has seen of the screen, and how it looks again.
3
+ *
4
+ * The feed owns every capture of a step: the settle that reads an action's
5
+ * result after its effect, the ring of recent observations an id is resolved
6
+ * against, the pixel decision (masking proven, viewport untainted), and the
7
+ * executor's redacted view of a capture. Nothing else in the step observes
8
+ * the engine; the dispatcher and the pixel tier ask the feed.
9
+ */
10
+ import { TestError } from '../internal/errors.js';
11
+ import { describeTarget } from './actions.js';
12
+ import { relocateDescriptor } from '../cache/relocate.js';
13
+ import { AgentError } from './error.js';
14
+ import { isTransitionalObservation, observationShape, pixelsForModel, prepareObservation, projectTree, settleObservation, } from './observation.js';
15
+ import { observationByteBudget } from './observation-budget.js';
16
+ import { instrumentPhase, recordPolicyEvent, retryingObserve } from './phases.js';
17
+ /**
18
+ * Observations kept for resolving an id the newest one no longer carries.
19
+ * A turn that batches actions addresses the screen it saw, while every
20
+ * action's own look re-observes; on an engine that mints ids per observation
21
+ * (a device), each look renumbers the tree. A few looks back is as far as one
22
+ * turn can reach.
23
+ */
24
+ const MAX_RECENT_OBSERVATIONS = 8;
25
+ export class ObservationFeed {
26
+ runtime;
27
+ accounting;
28
+ queue;
29
+ options;
30
+ newest;
31
+ /** The newest observations of the step, oldest first; see MAX_RECENT_OBSERVATIONS. */
32
+ recent = [];
33
+ /**
34
+ * The screen shape the newest committed action was resolved against, kept
35
+ * until the next settled observation has waited for the screen to leave it.
36
+ * Armed by actions whose effect shows in the tree; a secret fill leaves no
37
+ * visible trace and a scroll moves nothing the tree records, so neither
38
+ * arms it. Without this, the observation after a tap on a link reads the
39
+ * old page, stable and wrong, and the model repairs what already worked.
40
+ */
41
+ pendingChange;
42
+ /** The change wait the pending action asked for; undefined takes the default. */
43
+ pendingChangeWaitMs;
44
+ /** The last pixel decision recorded on this step: `allowed`, or the withheld reason. */
45
+ pixelsDecided;
46
+ /** Why requested pixels did not become model input, when they did not. */
47
+ visionDegraded;
48
+ /** True once pixels this feed cleared were handed to the executor as model input. */
49
+ pixelsSent = false;
50
+ constructor(runtime, accounting, queue, options) {
51
+ this.runtime = runtime;
52
+ this.accounting = accounting;
53
+ this.queue = queue;
54
+ this.options = options;
55
+ }
56
+ /** The newest observation of the step, if any was captured. */
57
+ get latest() {
58
+ return this.newest;
59
+ }
60
+ /** The newest observation, which an action addresses; before the first look there is nothing to address. */
61
+ requireLatest() {
62
+ if (this.newest === undefined) {
63
+ throw new AgentError('LOCATOR_NOT_FOUND', 'no observation has been captured yet; observe before acting');
64
+ }
65
+ return this.newest;
66
+ }
67
+ /** One raw capture in queue order, for replay's looks between retries. */
68
+ observeLatest() {
69
+ return this.queue.run(() => this.observeNow(false, false));
70
+ }
71
+ /**
72
+ * One settled capture in queue order: the executor-facing observe. An
73
+ * executor observation is followed by a model call measured in seconds, so
74
+ * the bounded settle wait is noise there — and it guarantees the model never
75
+ * reads a snapshot the app is still reacting to, which a fast model turns
76
+ * into a repeated action (double-committing a toggle) and a verdict judged
77
+ * on pre-render state. Replay's pre-action looks and the cache session's
78
+ * probes settle through this same path.
79
+ */
80
+ observeSettled(pixels = false) {
81
+ return this.queue.run(() => this.observeNow(true, pixels));
82
+ }
83
+ /** The executor-facing observe: the options checked before anything is captured, then one settled look, viewed. */
84
+ async observe(options = {}) {
85
+ if (options === null || typeof options !== 'object') {
86
+ throw new TestError('INVALID_ARGUMENT', 'observe options must be an object');
87
+ }
88
+ return this.view(await this.observeSettled(options.pixels === true), options);
89
+ }
90
+ /** The executor's view of one capture: redacted text, and the tree and pixels it asked for. */
91
+ async view(observation, options) {
92
+ const redact = this.runtime.redact;
93
+ // Prefer location from this capture; only engines without it need a separate probe.
94
+ const path = await this.currentPath(observation);
95
+ return {
96
+ revision: observation.revision,
97
+ text: observation.text,
98
+ truncated: observation.truncated,
99
+ viewport: observation.viewport,
100
+ ...(path === undefined ? {} : { path: redact(path) }),
101
+ ...(options.tree === true ? { tree: projectTree(observation.tree, redact) } : {}),
102
+ ...(options.pixels === true ? this.pixelsFor(observation) : {}),
103
+ };
104
+ }
105
+ /** Best-effort current location path + query, for trace preconditions. */
106
+ async currentPath(observation) {
107
+ const currentUrl = this.runtime.engine.session.url;
108
+ if (observation?.url === undefined && currentUrl === undefined)
109
+ return undefined;
110
+ try {
111
+ const url = new URL(observation?.url ?? (await currentUrl(this.accounting.operation())));
112
+ return `${url.pathname}${url.search}`;
113
+ }
114
+ catch {
115
+ return undefined;
116
+ }
117
+ }
118
+ /**
119
+ * Arms the change wait: the next settled observation waits for the screen
120
+ * to leave the newest observation's shape, for the default two seconds or
121
+ * the given brief window.
122
+ */
123
+ armChange(waitMs) {
124
+ if (this.newest === undefined)
125
+ return;
126
+ this.pendingChange = observationShape(this.newest);
127
+ this.pendingChangeWaitMs = waitMs;
128
+ }
129
+ /**
130
+ * Resolves an executor target against the newest observation. An id the
131
+ * newest observation no longer carries, but a recent one did, is re-found
132
+ * in the newest one by its descriptor: a turn that batches actions keeps
133
+ * addressing the screen it saw while each action's own look re-observes,
134
+ * and an engine that mints ids per observation renumbers the tree between
135
+ * them. Exactly one match, or the id counts as gone.
136
+ */
137
+ resolve(target) {
138
+ if (typeof target?.id !== 'string' || target.id === '') {
139
+ throw new TestError('INVALID_ARGUMENT', 'action target must be { id: string }');
140
+ }
141
+ const id = target.id.replace(/^#/, '');
142
+ const latest = this.requireLatest();
143
+ const node = latest.nodes.get(id) ?? this.refound(id, latest);
144
+ if (node === undefined) {
145
+ throw new AgentError('LOCATOR_NOT_FOUND', `node #${id} is not on the current screen (observation ${latest.revision}); it was removed or never existed`);
146
+ }
147
+ return { node, observation: latest };
148
+ }
149
+ /**
150
+ * Re-finds a node that went stale: one fresh capture, then the trace
151
+ * recorder's own descriptor matching (`cache/relocate.ts`) against it,
152
+ * exactly one match or nothing. The capture is taken directly rather than
153
+ * through the queued observe: this runs inside a queued action body, and a
154
+ * queued observation would wait on its own caller.
155
+ */
156
+ async relocate(stale) {
157
+ const options = { redact: this.runtime.redact, testIdAttribute: this.runtime.config.testIdAttribute };
158
+ const descriptor = describeTarget(stale, options.redact, options.testIdAttribute);
159
+ if (descriptor === undefined)
160
+ return undefined;
161
+ this.accounting.checkpoint();
162
+ const observation = await instrumentPhase(this.runtime, { api: this.accounting.api, kind: 'observation', phase: 'agent.observe', name: 'relocate' }, () => this.capture(false), (prepared) => ({ count: prepared.nodes.size, bytes: prepared.bytes }));
163
+ this.publish(observation);
164
+ const relocated = relocateDescriptor(descriptor, observation.nodes, options);
165
+ if (relocated.kind !== 'found')
166
+ return undefined;
167
+ const node = observation.nodes.get(relocated.id);
168
+ return node === undefined ? undefined : { node, observation };
169
+ }
170
+ /** The step's pixel record for the report. */
171
+ visionReport() {
172
+ return {
173
+ ...(this.pixelsSent ? { visionInput: true } : {}),
174
+ ...(this.visionDegraded === undefined ? {} : { visionDegraded: this.visionDegraded }),
175
+ };
176
+ }
177
+ /** One recorded observation; when `settle`, the captures loop inside it. */
178
+ async observeNow(settle, pixels) {
179
+ this.accounting.checkpoint();
180
+ // A tainted viewport never captures pixels: the engine would mask what it
181
+ // knows about, and the secret may be anywhere on screen by now.
182
+ const capturePixels = pixels && !this.runtime.taint.value;
183
+ // A settled look consumes the pending change: it waits for the screen to
184
+ // leave the pre-action shape once, and later looks read the screen as is.
185
+ const changedFrom = settle ? this.pendingChange : undefined;
186
+ const changeWaitMs = settle ? this.pendingChangeWaitMs : undefined;
187
+ if (settle) {
188
+ this.pendingChange = undefined;
189
+ this.pendingChangeWaitMs = undefined;
190
+ }
191
+ const observation = await instrumentPhase(this.runtime, { api: this.accounting.api, kind: 'observation', phase: 'agent.observe' }, () => settle
192
+ ? settleObservation(() => this.capture(capturePixels), observationShape, {
193
+ remainingMs: () => this.accounting.remainingMs(),
194
+ // The step's own hard stop must interrupt a settle sleep too —
195
+ // the attempt signal alone would let settling outlive the step
196
+ // by one poll interval.
197
+ signal: this.accounting.signal,
198
+ }, { changedFrom, changeWaitMs, transitional: isTransitionalObservation })
199
+ : this.capture(capturePixels), (prepared) => ({ count: prepared.nodes.size, bytes: prepared.bytes }));
200
+ this.publish(observation);
201
+ return observation;
202
+ }
203
+ /** Makes an observation the newest, remembers it among the recent ones, and books its size. */
204
+ publish(observation) {
205
+ this.newest = observation;
206
+ this.recent.push(observation);
207
+ if (this.recent.length > MAX_RECENT_OBSERVATIONS)
208
+ this.recent.shift();
209
+ const metrics = this.accounting.metrics;
210
+ metrics.observationBytes = Math.max(metrics.observationBytes, observation.bytes);
211
+ }
212
+ /** One raw observation capture: retried at the engine, then redacted and bounded. */
213
+ async capture(pixels) {
214
+ const raw = await retryingObserve({
215
+ observe: (operation) => this.runtime.engine.session.observe(operation, { pixels }),
216
+ operation: () => this.accounting.operation(),
217
+ guard: (cause) => this.accounting.checkpoint(cause),
218
+ signal: this.runtime.engine.signal,
219
+ api: this.accounting.api,
220
+ });
221
+ return prepareObservation(raw, {
222
+ redact: this.runtime.redact,
223
+ maxBytes: this.byteBudget(pixels),
224
+ testIdAttribute: this.runtime.config.testIdAttribute,
225
+ });
226
+ }
227
+ /**
228
+ * Bytes one act observation may contribute to a model turn, clamped like a
229
+ * judgment's. The loop's history grows past what any one observation costs,
230
+ * so the fixed part counted here is what every turn resends: the project
231
+ * context and the prior-step ledger.
232
+ */
233
+ byteBudget(pixels) {
234
+ const metrics = this.accounting.metrics;
235
+ return observationByteBudget({
236
+ maxObservationBytes: this.options.maxObservationBytes,
237
+ maxModelTokensPerCall: this.runtime.config.limits.maxModelTokensPerCall,
238
+ }, { fixedBytes: metrics.contextBytes + metrics.ledgerBytes, pixels });
239
+ }
240
+ /**
241
+ * Pixels for a caller that asked for them, or the reason they are withheld —
242
+ * the same decision the judgment tier makes, recorded as a policy event
243
+ * whenever it changes within the step.
244
+ */
245
+ pixelsFor(observation) {
246
+ const outcome = pixelsForModel(observation, this.runtime.taint.value);
247
+ if ('withheld' in outcome) {
248
+ this.recordPixelDecision('denied', outcome.withheld);
249
+ this.visionDegraded = outcome.withheld;
250
+ return { pixelsWithheld: outcome.withheld };
251
+ }
252
+ this.recordPixelDecision('allowed');
253
+ this.pixelsSent = true;
254
+ const metrics = this.accounting.metrics;
255
+ metrics.pixelBytes = Math.max(metrics.pixelBytes ?? 0, outcome.pixels.data.byteLength);
256
+ return { pixels: outcome.pixels };
257
+ }
258
+ recordPixelDecision(decision, code) {
259
+ const key = code ?? decision;
260
+ if (this.pixelsDecided === key)
261
+ return;
262
+ this.pixelsDecided = key;
263
+ recordPolicyEvent(this.runtime.steps, 'vision.pixels', decision, code);
264
+ }
265
+ /** The newest node matching the descriptor of what `id` named in a recent observation, if exactly one. */
266
+ refound(id, latest) {
267
+ let earlier;
268
+ for (let index = this.recent.length - 1; index >= 0 && earlier === undefined; index -= 1) {
269
+ earlier = this.recent[index].nodes.get(id);
270
+ }
271
+ if (earlier === undefined)
272
+ return undefined;
273
+ const options = { redact: this.runtime.redact, testIdAttribute: this.runtime.config.testIdAttribute };
274
+ const descriptor = describeTarget(earlier, options.redact, options.testIdAttribute);
275
+ if (descriptor === undefined)
276
+ return undefined;
277
+ const relocated = relocateDescriptor(descriptor, latest.nodes, options);
278
+ return relocated.kind === 'found' ? latest.nodes.get(relocated.id) : undefined;
279
+ }
280
+ }
281
+ //# sourceMappingURL=observation-feed.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"observation-feed.js","sourceRoot":"","sources":["../../src/agent/observation-feed.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBA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AAM,CAAC,MAAM,GAAG,CAAC,EAAE,KAAK,IAAI,CAAC,IAAI,OAAO,KAAK,SAAS,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;YACzF,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAE,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC9C,CAAC;QACD,IAAI,OAAO,KAAK,SAAS;YAAE,OAAO,SAAS,CAAC;QAC5C,MAAM,OAAO,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,eAAe,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,eAAe,EAAE,CAAC;QACtG,MAAM,UAAU,GAAG,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;QACpF,IAAI,UAAU,KAAK,SAAS;YAAE,OAAO,SAAS,CAAC;QAC/C,MAAM,SAAS,GAAG,kBAAkB,CAAC,UAAU,EAAE,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QACxE,OAAO,SAAS,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACjF,CAAC;CACF"}
@@ -1,7 +1,7 @@
1
1
  /** Observation capture, redaction, and model serialization. */
2
2
  import type { Observation, SemanticNode } from '../engine/surface.ts';
3
3
  import type { VisionDegradation } from '../run/steps.ts';
4
- import type { ExecutorNode, ExecutorPixels } from './executor.ts';
4
+ import type { ExecutorNode, ExecutorObservation, ExecutorPixels } from './executor.ts';
5
5
  /** Why pixels the caller asked for are not part of this observation. */
6
6
  type PixelsWithheld = 'MASKING_UNPROVEN';
7
7
  export interface AgentObservation {
@@ -51,6 +51,19 @@ export declare function pixelsForModel(observation: AgentObservation, tainted: b
51
51
  } | {
52
52
  readonly withheld: VisionDegradation;
53
53
  };
54
+ /**
55
+ * Roles the model can act on by id: the controls a hit-tested point resolves
56
+ * to, and the lines that mark a screen as one the tree can drive at all.
57
+ */
58
+ export declare const INTERACTIVE_ROLES: ReadonlySet<string>;
59
+ /**
60
+ * How many listed nodes the model could act on by id, read off the rendered
61
+ * lines. A screen with none is one the tree cannot describe (a canvas, a
62
+ * game, a native surface the platform exposes no semantics for), and the
63
+ * model needs pixels from the first turn rather than a round trip to discover
64
+ * that. Lives next to `formatNode` so the line grammar keeps one owner.
65
+ */
66
+ export declare function interactiveNodeCount(observation: Pick<ExecutorObservation, 'text'>): number;
54
67
  /**
55
68
  * Projects the raw tree onto the executor-facing node shape: the same
56
69
  * redaction the text serialization applies, field by field, and no value at
@@ -1 +1 @@
1
- {"version":3,"file":"observation.d.ts","sourceRoot":"","sources":["../../src/agent/observation.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAE/D,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGtE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAKlE,wEAAwE;AACxE,KAAK,cAAc,GAAG,kBAAkB,CAAC;AAEzC,MAAM,WAAW,gBAAgB;IAC/B,wEAAwE;IACxE,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,8DAA8D;IAC9D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAClD,4EAA4E;IAC5E,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9C,4EAA4E;IAC5E,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EAAE,gBAAgB,GAAG,OAAO,CAEhF"}
@@ -1,6 +1,7 @@
1
1
  /** Observation capture, redaction, and model serialization. */
2
2
  import { collapseText } from '../internal/text.js';
3
3
  import { sleep } from '../internal/time.js';
4
+ import { sizeForModel } from './pixels.js';
4
5
  /** Appended when the node walk stopped at the observation byte budget. */
5
6
  const TRUNCATION_MARKER = '[observation truncated at the resolved observation byte limit]';
6
7
  /**
@@ -90,7 +91,47 @@ export function pixelsForModel(observation, tainted) {
90
91
  if (observation.pixels === undefined) {
91
92
  return { withheld: observation.pixelsWithheld ?? 'UNSUPPORTED_CAPABILITY' };
92
93
  }
93
- return { pixels: observation.pixels };
94
+ // Sized here, once per observation a model receives, not per capture: the
95
+ // settle loop captures several times per action and only digests the bytes.
96
+ return { pixels: sizeForModel(observation.pixels) };
97
+ }
98
+ /**
99
+ * Roles the model can act on by id: the controls a hit-tested point resolves
100
+ * to, and the lines that mark a screen as one the tree can drive at all.
101
+ */
102
+ export const INTERACTIVE_ROLES = new Set([
103
+ 'button',
104
+ 'link',
105
+ 'textbox',
106
+ 'searchbox',
107
+ 'combobox',
108
+ 'checkbox',
109
+ 'radio',
110
+ 'switch',
111
+ 'tab',
112
+ 'menuitem',
113
+ 'menuitemcheckbox',
114
+ 'menuitemradio',
115
+ 'option',
116
+ 'slider',
117
+ 'spinbutton',
118
+ 'treeitem',
119
+ ]);
120
+ /**
121
+ * How many listed nodes the model could act on by id, read off the rendered
122
+ * lines. A screen with none is one the tree cannot describe (a canvas, a
123
+ * game, a native surface the platform exposes no semantics for), and the
124
+ * model needs pixels from the first turn rather than a round trip to discover
125
+ * that. Lives next to `formatNode` so the line grammar keeps one owner.
126
+ */
127
+ export function interactiveNodeCount(observation) {
128
+ let count = 0;
129
+ for (const line of observation.text.split('\n')) {
130
+ const role = /^\s*#\S+ (\S+)/.exec(line)?.[1];
131
+ if (role !== undefined && INTERACTIVE_ROLES.has(role))
132
+ count += 1;
133
+ }
134
+ return count;
94
135
  }
95
136
  /**
96
137
  * Projects the raw tree onto the executor-facing node shape: the same
@@ -178,13 +219,28 @@ function formatNode(node, depth, redact, testIdAttribute) {
178
219
  * Lives next to `formatNode` so the line grammar keeps one owner.
179
220
  */
180
221
  export function observationShape(observation) {
181
- return observation.text
222
+ const text = observation.text
182
223
  .replaceAll(/(^|\n)(\s*)#\S+/g, '$1$2')
183
224
  .replaceAll(/ \[([^\]]*)\]/g, (_match, states) => {
184
225
  const stable = states.split(' ').filter((state) => state !== 'focused');
185
226
  return stable.length === 0 ? '' : ` [${stable.join(' ')}]`;
186
227
  })
187
228
  .replaceAll(CLOCK_PATTERN, '<time>');
229
+ // A capture taken with pixels is shaped by them too: on a canvas, a map, or
230
+ // a game the tree never moves, and without the pixels every action would
231
+ // wait out the whole change window and then be reported as having done
232
+ // nothing. A digest keeps the shape a string and the comparison cheap.
233
+ const pixels = observation.pixels;
234
+ return pixels === undefined ? text : `${text}\n<pixels ${digest(pixels.data)}>`;
235
+ }
236
+ /** FNV-1a over the image bytes: fast, and equal frames encode to equal bytes. */
237
+ function digest(bytes) {
238
+ let hash = 0x811c9dc5;
239
+ for (const byte of bytes) {
240
+ hash ^= byte;
241
+ hash = Math.imul(hash, 0x01000193) >>> 0;
242
+ }
243
+ return hash.toString(16);
188
244
  }
189
245
  /** `12:05`, `0:59`, `23:59:59`: a value that changes on its own once a second or minute. */
190
246
  const CLOCK_PATTERN = /\b\d{1,2}:\d{2}(?::\d{2})?\b/g;
@@ -1 +1 @@
1
- {"version":3,"file":"observation.js","sourceRoot":"","sources":["../../src/agent/observation.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAG/D,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAI5C,0EAA0E;AAC1E,MAAM,iBAAiB,GAAG,gEAAgE,CAAC;AAyB3F;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAChC,WAAwB,EACxB,OAIC;I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OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,UAAU,IAAI,KAAK,CAAC,WAAW,EAAE,GAAG,MAAM,EAAE,CAAC;QAC/D,MAAM,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QAClC,KAAK,GAAG,MAAM,OAAO,EAAE,CAAC;QACxB,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;QAC5B,MAAM,MAAM,GAAG,IAAI,KAAK,KAAK,CAAC;QAC9B,KAAK,GAAG,IAAI,CAAC;QACb,IAAI,MAAM;YAAE,MAAM;IACpB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,yBAAyB,CAAC,WAA6B;IACrE,OAAO,WAAW,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC;AACrC,CAAC;AAED,SAAS,UAAU,CACjB,IAAkB,EAClB,IAA+B,EAC/B,OAA4B;IAE5B,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;IAC5B,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,QAAQ,IAAI,EAAE,EAAE,CAAC;QACxC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACvC,UAAU,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IACnC,CAAC;AACH,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Call-order serialization for one step's observations and actions.
3
+ *
4
+ * An executor (or an AI SDK loop running parallel tool calls) that issues a
5
+ * second action before the first settles would otherwise resolve both
6
+ * targets against the same pre-action observation — exactly the wrong-node
7
+ * hazard the staleness rule exists to prevent. Queued, the second call sees
8
+ * the newest observation and a stale id fails loud instead of acting on the
9
+ * wrong node.
10
+ *
11
+ * Invariant: a queued body must never enqueue another operation itself — the
12
+ * inner call would wait behind its own caller and deadlock. Action bodies
13
+ * call the engine session directly, secret authorization never observes, and
14
+ * a relocation captures raw rather than through the queued observe.
15
+ */
16
+ export declare class OperationQueue {
17
+ private chain;
18
+ /** Runs `body` after every operation queued before it, in call order. */
19
+ run<T>(body: () => Promise<T>): Promise<T>;
20
+ }
21
+ //# sourceMappingURL=operation-queue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operation-queue.d.ts","sourceRoot":"","sources":["../../src/agent/operation-queue.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,KAAK,CAAuC;IAEpD,yEAAyE;IACzE,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CASzC;CACF"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Call-order serialization for one step's observations and actions.
3
+ *
4
+ * An executor (or an AI SDK loop running parallel tool calls) that issues a
5
+ * second action before the first settles would otherwise resolve both
6
+ * targets against the same pre-action observation — exactly the wrong-node
7
+ * hazard the staleness rule exists to prevent. Queued, the second call sees
8
+ * the newest observation and a stale id fails loud instead of acting on the
9
+ * wrong node.
10
+ *
11
+ * Invariant: a queued body must never enqueue another operation itself — the
12
+ * inner call would wait behind its own caller and deadlock. Action bodies
13
+ * call the engine session directly, secret authorization never observes, and
14
+ * a relocation captures raw rather than through the queued observe.
15
+ */
16
+ export class OperationQueue {
17
+ chain = Promise.resolve();
18
+ /** Runs `body` after every operation queued before it, in call order. */
19
+ run(body) {
20
+ // The chain is always already settled-to-undefined, so failures propagate
21
+ // to their own caller and never poison the queue.
22
+ const run = this.chain.then(body);
23
+ this.chain = run.then(() => undefined, () => undefined);
24
+ return run;
25
+ }
26
+ }
27
+ //# sourceMappingURL=operation-queue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operation-queue.js","sourceRoot":"","sources":["../../src/agent/operation-queue.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,cAAc;IACjB,KAAK,GAAqB,OAAO,CAAC,OAAO,EAAE,CAAC;IAEpD,yEAAyE;IACzE,GAAG,CAAI,IAAsB;QAC3B,0EAA0E;QAC1E,kDAAkD;QAClD,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAClC,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,IAAI,CACnB,GAAG,EAAE,CAAC,SAAS,EACf,GAAG,EAAE,CAAC,SAAS,CAChB,CAAC;QACF,OAAO,GAAG,CAAC;IACb,CAAC;CACF"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * The screenshot a model receives, sized for it. Engines capture at CSS or
3
+ * device scale; a 1280 by 720 web viewport or a 1170 by 2532 phone is more
4
+ * image than a model needs to place a tap, and every image pixel is paid
5
+ * for on every turn it stays in the conversation. The long side is capped
6
+ * and the image resampled, and `scale` (image pixels per CSS pixel) is
7
+ * reduced with it, so every coordinate a model reads off the image still
8
+ * maps onto the viewport through the same arithmetic. Masked regions stay
9
+ * masked: a box filter over black stays black.
10
+ */
11
+ import type { ObservationPixels } from '../engine/surface.ts';
12
+ /** Sizes a captured screenshot for the model; the input is returned as is when it already fits. */
13
+ export declare function sizeForModel<P extends ObservationPixels>(pixels: P): P;
14
+ /**
15
+ * Resamples the image so its longer side is at most `maxLongSide`, with a
16
+ * box filter over the source pixels each target pixel covers. Returns the
17
+ * input untouched when it already fits or cannot be decoded; whatever else
18
+ * the caller's pixels carry (a masked-region count) rides along unchanged.
19
+ */
20
+ export declare function downscalePixels<P extends ObservationPixels>(pixels: P, maxLongSide: number): P;
21
+ //# sourceMappingURL=pixels.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pixels.d.ts","sourceRoot":"","sources":["../../src/agent/pixels.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAa9D,mGAAmG;AACnG,wBAAgB,YAAY,CAAC,CAAC,SAAS,iBAAiB,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,CAEtE;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,iBAAiB,EAAE,MAAM,EAAE,CAAC,EAAE,WAAW,EAAE,MAAM,GAAG,CAAC,CAgB9F"}
@@ -0,0 +1,85 @@
1
+ /**
2
+ * The screenshot a model receives, sized for it. Engines capture at CSS or
3
+ * device scale; a 1280 by 720 web viewport or a 1170 by 2532 phone is more
4
+ * image than a model needs to place a tap, and every image pixel is paid
5
+ * for on every turn it stays in the conversation. The long side is capped
6
+ * and the image resampled, and `scale` (image pixels per CSS pixel) is
7
+ * reduced with it, so every coordinate a model reads off the image still
8
+ * maps onto the viewport through the same arithmetic. Masked regions stay
9
+ * masked: a box filter over black stays black.
10
+ */
11
+ import { PNG } from 'pngjs';
12
+ /**
13
+ * Longest side a model-bound screenshot keeps, in image pixels. Measured on
14
+ * gpt-5.6 over a ten-key drawn keypad and an eight-screen drawn wizard, four
15
+ * runs per size: a 1280 by 720 capture costs about 1390 input tokens per
16
+ * turn, 1024 about 960, 768 about 680, 640 about 580, 512 about 500. Every
17
+ * size down to 640 passed every run; at 512 the model misread the keypad's
18
+ * display, needed retries, and once accepted a wrong code. 768 keeps a full
19
+ * step of margin above that cliff for 35% less per run than full size.
20
+ */
21
+ const MAX_SCREENSHOT_LONG_SIDE = 768;
22
+ /** Sizes a captured screenshot for the model; the input is returned as is when it already fits. */
23
+ export function sizeForModel(pixels) {
24
+ return downscalePixels(pixels, MAX_SCREENSHOT_LONG_SIDE);
25
+ }
26
+ /**
27
+ * Resamples the image so its longer side is at most `maxLongSide`, with a
28
+ * box filter over the source pixels each target pixel covers. Returns the
29
+ * input untouched when it already fits or cannot be decoded; whatever else
30
+ * the caller's pixels carry (a masked-region count) rides along unchanged.
31
+ */
32
+ export function downscalePixels(pixels, maxLongSide) {
33
+ const longSide = Math.max(pixels.width, pixels.height);
34
+ if (longSide <= maxLongSide || maxLongSide <= 0)
35
+ return pixels;
36
+ const factor = maxLongSide / longSide;
37
+ const width = Math.max(1, Math.round(pixels.width * factor));
38
+ const height = Math.max(1, Math.round(pixels.height * factor));
39
+ let source;
40
+ try {
41
+ source = PNG.sync.read(Buffer.from(pixels.data));
42
+ }
43
+ catch {
44
+ return pixels;
45
+ }
46
+ const target = new PNG({ width, height });
47
+ boxResample(source.data, source.width, source.height, target.data, width, height);
48
+ const data = new Uint8Array(PNG.sync.write(target));
49
+ return { ...pixels, data, width, height, scale: pixels.scale * (width / pixels.width) };
50
+ }
51
+ /** Averages, per channel, every source pixel a target pixel covers. RGBA, 8 bits per channel. */
52
+ function boxResample(source, sourceWidth, sourceHeight, target, targetWidth, targetHeight) {
53
+ const xRatio = sourceWidth / targetWidth;
54
+ const yRatio = sourceHeight / targetHeight;
55
+ for (let ty = 0; ty < targetHeight; ty += 1) {
56
+ const y0 = Math.floor(ty * yRatio);
57
+ const y1 = Math.min(sourceHeight, Math.max(y0 + 1, Math.floor((ty + 1) * yRatio)));
58
+ for (let tx = 0; tx < targetWidth; tx += 1) {
59
+ const x0 = Math.floor(tx * xRatio);
60
+ const x1 = Math.min(sourceWidth, Math.max(x0 + 1, Math.floor((tx + 1) * xRatio)));
61
+ let r = 0;
62
+ let g = 0;
63
+ let b = 0;
64
+ let a = 0;
65
+ let count = 0;
66
+ for (let y = y0; y < y1; y += 1) {
67
+ let offset = (y * sourceWidth + x0) * 4;
68
+ for (let x = x0; x < x1; x += 1) {
69
+ r += source[offset];
70
+ g += source[offset + 1];
71
+ b += source[offset + 2];
72
+ a += source[offset + 3];
73
+ offset += 4;
74
+ count += 1;
75
+ }
76
+ }
77
+ const at = (ty * targetWidth + tx) * 4;
78
+ target[at] = Math.round(r / count);
79
+ target[at + 1] = Math.round(g / count);
80
+ target[at + 2] = Math.round(b / count);
81
+ target[at + 3] = Math.round(a / count);
82
+ }
83
+ }
84
+ }
85
+ //# sourceMappingURL=pixels.js.map