@e2edev/e2e 0.5.0 → 0.5.1

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 (256) hide show
  1. package/README.md +41 -15
  2. package/dist/agent/act.d.ts +1 -1
  3. package/dist/agent/act.js +12 -36
  4. package/dist/agent/act.js.map +1 -1
  5. package/dist/agent/actions.d.ts +2 -2
  6. package/dist/agent/actions.d.ts.map +1 -1
  7. package/dist/agent/actions.js +1 -1
  8. package/dist/agent/default-agent.d.ts +3 -29
  9. package/dist/agent/default-agent.d.ts.map +1 -1
  10. package/dist/agent/default-agent.js +4 -11
  11. package/dist/agent/default-agent.js.map +1 -1
  12. package/dist/agent/error.d.ts +0 -2
  13. package/dist/agent/error.d.ts.map +1 -1
  14. package/dist/agent/error.js +1 -3
  15. package/dist/agent/error.js.map +1 -1
  16. package/dist/agent/executor.d.ts +15 -49
  17. package/dist/agent/executor.d.ts.map +1 -1
  18. package/dist/agent/executor.js +0 -1
  19. package/dist/agent/executor.js.map +1 -1
  20. package/dist/agent/index.js +2 -2
  21. package/dist/agent/invocation.d.ts +6 -4
  22. package/dist/agent/invocation.d.ts.map +1 -1
  23. package/dist/agent/invocation.js +2 -2
  24. package/dist/agent/invocation.js.map +1 -1
  25. package/dist/agent/ledger.d.ts +16 -11
  26. package/dist/agent/ledger.d.ts.map +1 -1
  27. package/dist/agent/ledger.js +5 -8
  28. package/dist/agent/ledger.js.map +1 -1
  29. package/dist/agent/observation.d.ts +6 -6
  30. package/dist/agent/observation.d.ts.map +1 -1
  31. package/dist/agent/observation.js +5 -5
  32. package/dist/agent/observation.js.map +1 -1
  33. package/dist/agent/phases.d.ts +3 -3
  34. package/dist/agent/phases.d.ts.map +1 -1
  35. package/dist/agent/phases.js +4 -4
  36. package/dist/agent/phases.js.map +1 -1
  37. package/dist/agent/primitives.d.ts +4 -25
  38. package/dist/agent/primitives.d.ts.map +1 -1
  39. package/dist/agent/primitives.js +3 -36
  40. package/dist/agent/primitives.js.map +1 -1
  41. package/dist/agent/protocol.d.ts +1 -1
  42. package/dist/agent/protocol.js +1 -1
  43. package/dist/agent/public.d.ts +7 -9
  44. package/dist/agent/public.d.ts.map +1 -1
  45. package/dist/agent/public.js +6 -7
  46. package/dist/agent/public.js.map +1 -1
  47. package/dist/agent/replay.d.ts +1 -1
  48. package/dist/agent/replay.d.ts.map +1 -1
  49. package/dist/agent/secrets.d.ts +2 -2
  50. package/dist/agent/secrets.d.ts.map +1 -1
  51. package/dist/agent/secrets.js +3 -3
  52. package/dist/agent/secrets.js.map +1 -1
  53. package/dist/agent/tool-loop.d.ts +2 -30
  54. package/dist/agent/tool-loop.d.ts.map +1 -1
  55. package/dist/agent/tool-loop.js +9 -33
  56. package/dist/agent/tool-loop.js.map +1 -1
  57. package/dist/agent/tool.d.ts +4 -5
  58. package/dist/agent/tool.d.ts.map +1 -1
  59. package/dist/agent/tool.js +2 -7
  60. package/dist/agent/tool.js.map +1 -1
  61. package/dist/cache/anchors.d.ts +1 -1
  62. package/dist/cache/anchors.d.ts.map +1 -1
  63. package/dist/cache/identity.d.ts +8 -8
  64. package/dist/cache/identity.d.ts.map +1 -1
  65. package/dist/cache/identity.js +5 -5
  66. package/dist/cache/identity.js.map +1 -1
  67. package/dist/cache/relocate.d.ts +1 -1
  68. package/dist/cache/relocate.d.ts.map +1 -1
  69. package/dist/cli/index.js +3 -3
  70. package/dist/cli/index.js.map +1 -1
  71. package/dist/cli/init/{backends.d.ts → engines.d.ts} +12 -13
  72. package/dist/cli/init/engines.d.ts.map +1 -0
  73. package/dist/cli/init/{backends.js → engines.js} +13 -14
  74. package/dist/cli/init/engines.js.map +1 -0
  75. package/dist/cli/init/scaffold.d.ts +3 -3
  76. package/dist/cli/init/scaffold.d.ts.map +1 -1
  77. package/dist/cli/init/scaffold.js +9 -9
  78. package/dist/cli/init/scaffold.js.map +1 -1
  79. package/dist/cli/init.d.ts.map +1 -1
  80. package/dist/cli/init.js +11 -10
  81. package/dist/cli/init.js.map +1 -1
  82. package/dist/cli/signals.d.ts +1 -1
  83. package/dist/cli/signals.d.ts.map +1 -1
  84. package/dist/cli/signals.js +1 -1
  85. package/dist/cli/signals.js.map +1 -1
  86. package/dist/collect/collect.d.ts +32 -3
  87. package/dist/collect/collect.d.ts.map +1 -1
  88. package/dist/collect/collect.js +95 -17
  89. package/dist/collect/collect.js.map +1 -1
  90. package/dist/collect/registry.js +1 -1
  91. package/dist/collect/registry.js.map +1 -1
  92. package/dist/collect/select.d.ts.map +1 -1
  93. package/dist/collect/select.js +9 -5
  94. package/dist/collect/select.js.map +1 -1
  95. package/dist/config/app.d.ts +76 -19
  96. package/dist/config/app.d.ts.map +1 -1
  97. package/dist/config/app.js +157 -102
  98. package/dist/config/app.js.map +1 -1
  99. package/dist/config/resolve.d.ts +6 -5
  100. package/dist/config/resolve.d.ts.map +1 -1
  101. package/dist/config/resolve.js +24 -26
  102. package/dist/config/resolve.js.map +1 -1
  103. package/dist/{backend → engine}/contract.d.ts +26 -18
  104. package/dist/engine/contract.d.ts.map +1 -0
  105. package/dist/{backend → engine}/contract.js +18 -18
  106. package/dist/engine/contract.js.map +1 -0
  107. package/dist/{backend → engine}/index.d.ts +141 -79
  108. package/dist/engine/index.d.ts.map +1 -0
  109. package/dist/{backend → engine}/index.js +60 -35
  110. package/dist/engine/index.js.map +1 -0
  111. package/dist/engine/session.d.ts +23 -0
  112. package/dist/engine/session.d.ts.map +1 -0
  113. package/dist/{backend → engine}/session.js +55 -51
  114. package/dist/engine/session.js.map +1 -0
  115. package/dist/{backend → engine}/surface.d.ts +11 -11
  116. package/dist/engine/surface.d.ts.map +1 -0
  117. package/dist/{backend → engine}/surface.js +2 -2
  118. package/dist/engine/surface.js.map +1 -0
  119. package/dist/engine/timing.d.ts.map +1 -0
  120. package/dist/engine/timing.js +8 -0
  121. package/dist/engine/timing.js.map +1 -0
  122. package/dist/expect/index.js +1 -1
  123. package/dist/index.d.ts +3 -2
  124. package/dist/index.d.ts.map +1 -1
  125. package/dist/index.js +1 -1
  126. package/dist/index.js.map +1 -1
  127. package/dist/internal/brands.d.ts +1 -1
  128. package/dist/internal/brands.d.ts.map +1 -1
  129. package/dist/internal/brands.js +1 -1
  130. package/dist/internal/brands.js.map +1 -1
  131. package/dist/internal/errors.d.ts +16 -16
  132. package/dist/internal/errors.d.ts.map +1 -1
  133. package/dist/internal/errors.js +39 -39
  134. package/dist/internal/errors.js.map +1 -1
  135. package/dist/internal/objects.d.ts +21 -0
  136. package/dist/internal/objects.d.ts.map +1 -0
  137. package/dist/internal/objects.js +14 -0
  138. package/dist/internal/objects.js.map +1 -0
  139. package/dist/internal/urls.d.ts +1 -1
  140. package/dist/internal/urls.d.ts.map +1 -1
  141. package/dist/internal/urls.js +6 -1
  142. package/dist/internal/urls.js.map +1 -1
  143. package/dist/locator/engine.d.ts +6 -6
  144. package/dist/locator/engine.d.ts.map +1 -1
  145. package/dist/locator/engine.js +13 -13
  146. package/dist/locator/engine.js.map +1 -1
  147. package/dist/locator/expression.d.ts +4 -2
  148. package/dist/locator/expression.d.ts.map +1 -1
  149. package/dist/locator/expression.js +24 -4
  150. package/dist/locator/expression.js.map +1 -1
  151. package/dist/locator/screen.d.ts +1 -1
  152. package/dist/locator/screen.d.ts.map +1 -1
  153. package/dist/locator/screen.js +2 -2
  154. package/dist/locator/screen.js.map +1 -1
  155. package/dist/report/build.d.ts +9 -8
  156. package/dist/report/build.d.ts.map +1 -1
  157. package/dist/report/build.js +21 -18
  158. package/dist/report/build.js.map +1 -1
  159. package/dist/report/code-frame.d.ts +8 -4
  160. package/dist/report/code-frame.d.ts.map +1 -1
  161. package/dist/report/code-frame.js +23 -18
  162. package/dist/report/code-frame.js.map +1 -1
  163. package/dist/report/debug-steps.js +1 -1
  164. package/dist/report/debug-steps.js.map +1 -1
  165. package/dist/report/format.d.ts +73 -0
  166. package/dist/report/format.d.ts.map +1 -0
  167. package/dist/report/format.js +147 -0
  168. package/dist/report/format.js.map +1 -0
  169. package/dist/report/list.d.ts +96 -47
  170. package/dist/report/list.d.ts.map +1 -1
  171. package/dist/report/list.js +485 -244
  172. package/dist/report/list.js.map +1 -1
  173. package/dist/report/live-window.d.ts +28 -0
  174. package/dist/report/live-window.d.ts.map +1 -0
  175. package/dist/report/live-window.js +102 -0
  176. package/dist/report/live-window.js.map +1 -0
  177. package/dist/run/declared-processes.d.ts +30 -0
  178. package/dist/run/declared-processes.d.ts.map +1 -0
  179. package/dist/run/declared-processes.js +61 -0
  180. package/dist/run/declared-processes.js.map +1 -0
  181. package/dist/run/events.d.ts +30 -2
  182. package/dist/run/events.d.ts.map +1 -1
  183. package/dist/run/events.js.map +1 -1
  184. package/dist/run/execute.d.ts +17 -13
  185. package/dist/run/execute.d.ts.map +1 -1
  186. package/dist/run/execute.js +61 -62
  187. package/dist/run/execute.js.map +1 -1
  188. package/dist/run/fixture-recording.d.ts +10 -4
  189. package/dist/run/fixture-recording.d.ts.map +1 -1
  190. package/dist/run/fixture-recording.js +19 -6
  191. package/dist/run/fixture-recording.js.map +1 -1
  192. package/dist/run/fixtures.d.ts +1 -1
  193. package/dist/run/fixtures.d.ts.map +1 -1
  194. package/dist/run/fixtures.js +33 -41
  195. package/dist/run/fixtures.js.map +1 -1
  196. package/dist/run/in-process.d.ts +1 -1
  197. package/dist/run/in-process.js +1 -1
  198. package/dist/run/managed-process.d.ts +39 -9
  199. package/dist/run/managed-process.d.ts.map +1 -1
  200. package/dist/run/managed-process.js +102 -34
  201. package/dist/run/managed-process.js.map +1 -1
  202. package/dist/run/runner.d.ts +1 -1
  203. package/dist/run/runner.d.ts.map +1 -1
  204. package/dist/run/runner.js +67 -31
  205. package/dist/run/runner.js.map +1 -1
  206. package/dist/run/scheduler.d.ts +4 -3
  207. package/dist/run/scheduler.d.ts.map +1 -1
  208. package/dist/run/scheduler.js +5 -4
  209. package/dist/run/scheduler.js.map +1 -1
  210. package/dist/run/serial.d.ts +9 -1
  211. package/dist/run/serial.d.ts.map +1 -1
  212. package/dist/run/serial.js +2 -0
  213. package/dist/run/serial.js.map +1 -1
  214. package/dist/run/sessions.d.ts +9 -9
  215. package/dist/run/sessions.d.ts.map +1 -1
  216. package/dist/run/sessions.js +10 -10
  217. package/dist/run/sessions.js.map +1 -1
  218. package/dist/run/steps.d.ts +1 -1
  219. package/dist/run/steps.d.ts.map +1 -1
  220. package/dist/run/worker/entry.d.ts +1 -1
  221. package/dist/run/worker/entry.js +2 -2
  222. package/dist/run/worker/entry.js.map +1 -1
  223. package/dist/run/worker/protocol.d.ts +18 -6
  224. package/dist/run/worker/protocol.d.ts.map +1 -1
  225. package/dist/run/worker/protocol.js +1 -1
  226. package/dist/run/worker/protocol.js.map +1 -1
  227. package/dist/run/worker/session.d.ts +2 -2
  228. package/dist/run/worker/session.d.ts.map +1 -1
  229. package/dist/run/worker/session.js +5 -3
  230. package/dist/run/worker/session.js.map +1 -1
  231. package/dist/types.d.ts +32 -34
  232. package/dist/types.d.ts.map +1 -1
  233. package/package.json +5 -5
  234. package/dist/backend/contract.d.ts.map +0 -1
  235. package/dist/backend/contract.js.map +0 -1
  236. package/dist/backend/index.d.ts.map +0 -1
  237. package/dist/backend/index.js.map +0 -1
  238. package/dist/backend/session.d.ts +0 -23
  239. package/dist/backend/session.d.ts.map +0 -1
  240. package/dist/backend/session.js.map +0 -1
  241. package/dist/backend/surface.d.ts.map +0 -1
  242. package/dist/backend/surface.js.map +0 -1
  243. package/dist/backend/timing.d.ts.map +0 -1
  244. package/dist/backend/timing.js +0 -8
  245. package/dist/backend/timing.js.map +0 -1
  246. package/dist/cli/init/backends.d.ts.map +0 -1
  247. package/dist/cli/init/backends.js.map +0 -1
  248. package/dist/report/live-status.d.ts +0 -51
  249. package/dist/report/live-status.d.ts.map +0 -1
  250. package/dist/report/live-status.js +0 -163
  251. package/dist/report/live-status.js.map +0 -1
  252. package/dist/run/fixture-legacy.d.ts +0 -36
  253. package/dist/run/fixture-legacy.d.ts.map +0 -1
  254. package/dist/run/fixture-legacy.js +0 -143
  255. package/dist/run/fixture-legacy.js.map +0 -1
  256. /package/dist/{backend → engine}/timing.d.ts +0 -0
@@ -1,27 +1,27 @@
1
1
  /**
2
- * The backend contract (RFC0002): the typed, model-free body of one target.
2
+ * The engine contract (RFC0002): the typed, model-free body of one target.
3
3
  *
4
- * A backend never talks to a model. It declares capabilities - observation,
4
+ * An engine never talks to a model. It declares capabilities - observation,
5
5
  * actions, location, state, artifacts, contributed fixtures - and the harness
6
- * grades what a target can do from what its backend declares: observation
6
+ * grades what a target can do from what its engine declares: observation
7
7
  * unlocks the judgment tier and prompt snapshots, `perform` unlocks the
8
8
  * harness-routed node actions (the agent's grammar verbs and the `screen`
9
9
  * tier's actions alike), location unlocks `screen`/`expect`. Every piece of
10
10
  * model-facing vocabulary is an agent-side `defineTool`; a target with no
11
- * backend at all is valid and simply runs everything opaque.
11
+ * engine at all is valid and simply runs everything opaque.
12
12
  *
13
- * Core knows this contract and never a backend's internals: no platform noun
14
- * appears here. A document backend, a simulator backend, and a desktop backend
13
+ * Core knows this contract and never an engine's internals: no platform noun
14
+ * appears here. A document engine, a simulator engine, and a desktop engine
15
15
  * fill in the same members with different bodies.
16
16
  *
17
- * `defineBackend` is the loud manifest: capability detection happens here,
18
- * synchronously, at config load - a malformed backend fails the run instead
17
+ * `defineEngine` is the loud manifest: capability detection happens here,
18
+ * synchronously, at config load - a malformed engine fails the run instead
19
19
  * of silently demoting itself to a lower tier.
20
20
  */
21
- import { backendBrand } from '../internal/brands.js';
21
+ import { engineBrand } from '../internal/brands.js';
22
22
  import { ConfigurationError } from '../internal/errors.js';
23
- // Semantics the spec requires every backend and contributed fixture to
24
- // reproduce exactly, exported so a backend never carries its own copy: the
23
+ // Semantics the spec requires every engine and contributed fixture to
24
+ // reproduce exactly, exported so an engine never carries its own copy: the
25
25
  // runner error taxonomy (06-cli.md), text-pattern matching (04-locators.md),
26
26
  // URL matching (03-assertions.md), assertion polling (03-assertions.md), and
27
27
  // the JSON-value rules for data a fixture returns.
@@ -31,9 +31,10 @@ export { describePattern, matchesText, toTextPattern } from '../internal/text.js
31
31
  export { raceAbort } from './timing.js';
32
32
  export { Deadline, pollCondition, withTimeout, withinCleanupBudget } from '../internal/time.js';
33
33
  export { urlMatches } from '../internal/urls.js';
34
- import { BACKEND_SPI_VERSION, } from './contract.js';
35
- export { BACKEND_ERROR_CODES, BACKEND_SPI_VERSION, BackendError, OBSERVED_NAME_LIMIT, OBSERVED_TEXT_LIMIT, RETRYABLE_BACKEND_ERROR_CODES, } from './contract.js';
36
- /** Every key a backend may declare; anything else is rejected at config load. */
34
+ export { obj } from '../internal/objects.js';
35
+ import { ENGINE_SPI_VERSION, } from './contract.js';
36
+ export { ENGINE_ERROR_CODES, ENGINE_SPI_VERSION, EngineError, OBSERVED_NAME_LIMIT, OBSERVED_TEXT_LIMIT, RETRYABLE_ENGINE_ERROR_CODES, } from './contract.js';
37
+ /** Every key an engine may declare; anything else is rejected at config load. */
37
38
  const KNOWN_KEYS = [
38
39
  'name',
39
40
  'version',
@@ -59,6 +60,20 @@ const NESTED_KEYS = {
59
60
  artifacts: ['screenshot', 'startTrace', 'stopTrace'],
60
61
  app: ['navigate', 'back', 'restart', 'clearState'],
61
62
  };
63
+ /**
64
+ * Declarative members of the `app` manifest: facts about the app under test,
65
+ * copied through as data. Their values are validated when the config resolves
66
+ * the target, where an error can name it.
67
+ */
68
+ const APP_DECLARATION_KEYS = [
69
+ 'url',
70
+ 'allowedOrigins',
71
+ 'environment',
72
+ 'identity',
73
+ 'command',
74
+ 'readyUrl',
75
+ 'services',
76
+ ];
62
77
  const FUNCTION_MEMBERS = [
63
78
  'observe',
64
79
  'locate',
@@ -75,26 +90,36 @@ const FUNCTION_MEMBERS = [
75
90
  const RESERVED_FIXTURES = new Set(['agent', 'app', 'screen', 'platform', 'session']);
76
91
  const FIXTURE_NAME_PATTERN = /^[a-z][A-Za-z0-9]*$/;
77
92
  function invalid(name, detail) {
78
- return new ConfigurationError('INVALID_CONFIG', `backend "${name}": ${detail}`);
93
+ return new ConfigurationError('INVALID_CONFIG', `engine "${name}": ${detail}`);
79
94
  }
80
95
  /**
81
96
  * Validates one nested manifest (`state`, `artifacts`, `app`): a plain object
82
- * whose keys are closed and whose declared members are functions. Returns a
83
- * copy with every member bound to the manifest, so class-based bodies work.
97
+ * whose keys are closed and whose declared members are functions, except the
98
+ * `app` declaration's data members, which are copied through. Returns a copy
99
+ * with every function bound to the manifest, so class-based bodies work.
84
100
  */
85
101
  function nestedManifest(name, key, value, required = []) {
86
- if (typeof value !== 'object' || value === null) {
102
+ if (typeof value !== 'object' || value === null || Array.isArray(value)) {
87
103
  throw invalid(name, `${key} must be an object`);
88
104
  }
89
- const allowed = NESTED_KEYS[key];
105
+ const hooks = NESTED_KEYS[key];
106
+ const data = key === 'app' ? APP_DECLARATION_KEYS : [];
90
107
  const source = value;
91
108
  for (const member of Object.keys(source)) {
92
- if (!allowed.includes(member)) {
93
- throw invalid(name, `${key} has unknown key "${member}"; expected one of ${allowed.join(', ')}`);
109
+ if (!hooks.includes(member) && !data.includes(member)) {
110
+ throw invalid(name, `${key} has unknown key "${member}"; expected one of ${[...data, ...hooks].join(', ')}`);
94
111
  }
95
112
  }
96
113
  const bound = {};
97
- for (const member of allowed) {
114
+ for (const member of data) {
115
+ const fact = source[member];
116
+ if (fact === undefined)
117
+ continue;
118
+ if (typeof fact === 'function')
119
+ throw invalid(name, `${key}.${member} is a declaration, not a hook`);
120
+ bound[member] = fact;
121
+ }
122
+ for (const member of hooks) {
98
123
  const fn = source[member];
99
124
  if (fn === undefined) {
100
125
  if (required.includes(member))
@@ -108,7 +133,7 @@ function nestedManifest(name, key, value, required = []) {
108
133
  return bound;
109
134
  }
110
135
  /**
111
- * Validates a backend and computes its capability set. Runs synchronously at
136
+ * Validates an engine and computes its capability set. Runs synchronously at
112
137
  * config load and fails loud: a misspelled member or an undeclared dependency
113
138
  * is `INVALID_CONFIG`, never a silent demotion to a lower tier.
114
139
  *
@@ -116,19 +141,19 @@ function nestedManifest(name, key, value, required = []) {
116
141
  * through the prototype chain and binding every function to the spec, so a
117
142
  * class instance (own state fields included) is as valid a body as a literal.
118
143
  */
119
- export function defineBackend(spec) {
144
+ export function defineEngine(spec) {
120
145
  if (typeof spec !== 'object' || spec === null) {
121
- throw new ConfigurationError('INVALID_CONFIG', 'defineBackend requires a backend object');
146
+ throw new ConfigurationError('INVALID_CONFIG', 'defineEngine requires an engine object');
122
147
  }
123
148
  if (typeof spec.name !== 'string' || spec.name.trim() === '') {
124
- throw new ConfigurationError('INVALID_CONFIG', 'backend.name must be a non-empty string');
149
+ throw new ConfigurationError('INVALID_CONFIG', 'engine.name must be a non-empty string');
125
150
  }
126
151
  const name = spec.name;
127
152
  if (typeof spec.version !== 'string' || spec.version.trim() === '') {
128
153
  throw invalid(name, 'version must be a non-empty string; it is provenance and keys the trace cache');
129
154
  }
130
- if (spec.spiVersion !== BACKEND_SPI_VERSION) {
131
- throw invalid(name, `declares spiVersion ${String(spec.spiVersion)}; this runner supports ${BACKEND_SPI_VERSION}`);
155
+ if (spec.spiVersion !== ENGINE_SPI_VERSION) {
156
+ throw invalid(name, `declares spiVersion ${String(spec.spiVersion)}; this runner supports ${ENGINE_SPI_VERSION}`);
132
157
  }
133
158
  // A literal's unknown key is a misspelling or a misplaced tool; a class
134
159
  // instance's own fields are its state, so only literals are checked.
@@ -136,7 +161,7 @@ export function defineBackend(spec) {
136
161
  const known = KNOWN_KEYS;
137
162
  for (const key of Object.keys(spec)) {
138
163
  if (!known.includes(key)) {
139
- throw invalid(name, `unknown key "${key}" - tools belong on the agent, not the backend`);
164
+ throw invalid(name, `unknown key "${key}" - tools belong on the agent, not the engine`);
140
165
  }
141
166
  }
142
167
  }
@@ -185,7 +210,7 @@ export function defineBackend(spec) {
185
210
  }
186
211
  capabilities.add(fixture);
187
212
  }
188
- // Bound like every other member, so a class-based backend keeps `this`
213
+ // Bound like every other member, so a class-based engine keeps `this`
189
214
  // in its fixture factories too.
190
215
  handle['fixtures'] = Object.freeze(Object.fromEntries(Object.entries(spec.fixtures).map(([fixture, factory]) => [
191
216
  fixture,
@@ -206,17 +231,17 @@ export function defineBackend(spec) {
206
231
  }
207
232
  if (spec.app !== undefined)
208
233
  handle['app'] = nestedManifest(name, 'app', spec.app);
209
- // Assembled key by key above, so the record is a Backend by construction.
234
+ // Assembled key by key above, so the record is an Engine by construction.
210
235
  return Object.freeze({
211
236
  ...handle,
212
- [backendBrand]: true,
237
+ [engineBrand]: true,
213
238
  capabilities,
214
239
  });
215
240
  }
216
- /** True for a defineBackend-branded handle, across realms. */
217
- export function isBackendHandle(value) {
241
+ /** True for a defineEngine-branded handle, across realms. */
242
+ export function isEngineHandle(value) {
218
243
  return (typeof value === 'object' &&
219
244
  value !== null &&
220
- value[backendBrand] === true);
245
+ value[engineBrand] === true);
221
246
  }
222
247
  //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/engine/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3D,sEAAsE;AACtE,2EAA2E;AAC3E,6EAA6E;AAC7E,6EAA6E;AAC7E,mDAAmD;AACnD,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAC3F,OAAO,EAAE,iBAAiB,EAAuB,MAAM,2BAA2B,CAAC;AACnF,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAElF,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,WAAW,EAAE,mBAAmB,EAA6B,MAAM,qBAAqB,CAAC;AAC3H,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CA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C,EAAE,CAAC;YACvF,MAAM,OAAO,CAAC,IAAI,EAAE,8DAA8D,CAAC,CAAC;QACtF,CAAC;QACD,MAAM,CAAC,WAAW,CAAC,GAAG,SAAS,CAAC;QAChC,YAAY,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAChC,CAAC;IACD,IAAI,IAAI,CAAC,GAAG,KAAK,SAAS;QAAE,MAAM,CAAC,KAAK,CAAC,GAAG,cAAc,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;IAElF,0EAA0E;IAC1E,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,GAAG,MAAM;QACT,CAAC,WAAW,CAAC,EAAE,IAAa;QAC5B,YAAY;KACb,CAA4B,CAAC;AAChC,CAAC;AAED,6DAA6D;AAC7D,MAAM,UAAU,cAAc,CAAC,KAAc;IAC3C,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACb,KAAsC,CAAC,WAAW,CAAC,KAAK,IAAI,CAC9D,CAAC;AACJ,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * The engine-to-session adapter (RFC0002). One adapter per attempt satisfies
3
+ * the internal `TargetSession` surface over the engine contract, so the agent
4
+ * tier, the judgment tier, the trace cache, and the fixture graph program
5
+ * against one shape. It is the single seam every engine call crosses, which
6
+ * makes it the one place two rules are enforced: a capability the engine does
7
+ * not declare fails loud with `UNSUPPORTED_CAPABILITY` at the moment of use,
8
+ * and anything an engine throws that is not an `EngineError` is normalized to
9
+ * a non-retryable `ENGINE_FAILURE`, so a crashed engine is an infrastructure
10
+ * failure everywhere and never a retry-eligible test failure.
11
+ */
12
+ import type { EngineHandle } from './index.ts';
13
+ import { type TargetSession } from './surface.ts';
14
+ export interface EngineSessionOptions {
15
+ readonly engine: EngineHandle | undefined;
16
+ readonly targetName: string;
17
+ }
18
+ /**
19
+ * Builds one session over an engine. One adapter per attempt; revisions are
20
+ * minted per adapter, so refs can never leak across attempts.
21
+ */
22
+ export declare function createEngineSession(options: EngineSessionOptions): TargetSession;
23
+ //# sourceMappingURL=session.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/engine/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AASH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAOL,KAAK,aAAa,EACnB,MAAM,cAAc,CAAC;AAEtB,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,MAAM,EAAE,YAAY,GAAG,SAAS,CAAC;IAC1C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAmED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,oBAAoB,GAAG,aAAa,CAmJhF"}
@@ -1,25 +1,25 @@
1
1
  /**
2
- * The backend-to-session adapter (RFC0002). One adapter per attempt satisfies
3
- * the internal `TargetSession` surface over the backend contract, so the agent
2
+ * The engine-to-session adapter (RFC0002). One adapter per attempt satisfies
3
+ * the internal `TargetSession` surface over the engine contract, so the agent
4
4
  * tier, the judgment tier, the trace cache, and the fixture graph program
5
- * against one shape. It is the single seam every backend call crosses, which
6
- * makes it the one place two rules are enforced: a capability the backend does
5
+ * against one shape. It is the single seam every engine call crosses, which
6
+ * makes it the one place two rules are enforced: a capability the engine does
7
7
  * not declare fails loud with `UNSUPPORTED_CAPABILITY` at the moment of use,
8
- * and anything a backend throws that is not a `BackendError` is normalized to
9
- * a non-retryable `BACKEND_FAILURE`, so a crashed backend is an infrastructure
8
+ * and anything an engine throws that is not an `EngineError` is normalized to
9
+ * a non-retryable `ENGINE_FAILURE`, so a crashed engine is an infrastructure
10
10
  * failure everywhere and never a retry-eligible test failure.
11
11
  */
12
- import { asBackendError, ConfigurationError, E2EError, errorMessage, isForeignE2EError, } from '../internal/errors.js';
13
- import { BackendError, } from './surface.js';
12
+ import { asEngineError, ConfigurationError, E2EError, errorMessage, isForeignE2EError, } from '../internal/errors.js';
13
+ import { EngineError, } from './surface.js';
14
14
  /** Located refs are pruned oldest-first past this bound so the map cannot grow unboundedly. */
15
15
  const MAX_LOCATED_REFS = 2048;
16
16
  /** Revision prefixes: the adapter mints `l<n>` for locate and `b<n>` for observe. */
17
17
  const LOCATE_REVISION_PREFIX = 'l';
18
18
  const OBSERVE_REVISION_PREFIX = 'b';
19
19
  /**
20
- * Stamps the adapter's revision onto every ref. Backends mint stable ids;
20
+ * Stamps the adapter's revision onto every ref. Engines mint stable ids;
21
21
  * the adapter owns revisions, so the staleness rule (act on the newest
22
- * observation only) holds without every backend reimplementing it.
22
+ * observation only) holds without every engine reimplementing it.
23
23
  */
24
24
  function stampRevision(node, revision) {
25
25
  return {
@@ -30,7 +30,7 @@ function stampRevision(node, revision) {
30
30
  : { children: node.children.map((child) => stampRevision(child, revision)) }),
31
31
  };
32
32
  }
33
- /** Wraps a backend snapshot's root nodes into the single-root observation tree. */
33
+ /** Wraps an engine snapshot's root nodes into the single-root observation tree. */
34
34
  function toTree(nodes, revision) {
35
35
  const stamped = nodes.map((node) => stampRevision(node, revision));
36
36
  const first = stamped[0];
@@ -49,46 +49,46 @@ function countSecure(nodes) {
49
49
  return count;
50
50
  }
51
51
  /**
52
- * Normalizes what a backend threw onto the error contract. `BackendError`
52
+ * Normalizes what an engine threw onto the error contract. `EngineError`
53
53
  * (from any module copy) and runner errors pass through; anything else is the
54
- * backend failing outside its contract, reported as infrastructure.
54
+ * engine failing outside its contract, reported as infrastructure.
55
55
  */
56
56
  function normalize(cause, label) {
57
- if (cause instanceof E2EError || isForeignE2EError(cause) || asBackendError(cause) !== undefined) {
57
+ if (cause instanceof E2EError || isForeignE2EError(cause) || asEngineError(cause) !== undefined) {
58
58
  throw cause;
59
59
  }
60
- throw new BackendError('BACKEND_FAILURE', `${label} failed: ${errorMessage(cause)}`, {
60
+ throw new EngineError('ENGINE_FAILURE', `${label} failed: ${errorMessage(cause)}`, {
61
61
  retryable: false,
62
62
  cause,
63
63
  });
64
64
  }
65
- /** The grammar verbs a backend declaration can honor. */
66
- function declaredVerbs(backend) {
65
+ /** The grammar verbs an engine declaration can honor. */
66
+ function declaredVerbs(engine) {
67
67
  const verbs = new Set();
68
- if (backend?.perform !== undefined) {
68
+ if (engine?.perform !== undefined) {
69
69
  for (const verb of ['tap', 'type', 'typeSecret', 'press', 'select'])
70
70
  verbs.add(verb);
71
71
  }
72
- if (backend?.swipe !== undefined)
72
+ if (engine?.swipe !== undefined)
73
73
  verbs.add('scroll');
74
- if (backend?.app?.navigate !== undefined)
74
+ if (engine?.app?.navigate !== undefined)
75
75
  verbs.add('navigate');
76
76
  return verbs;
77
77
  }
78
78
  /**
79
- * Builds one session over a backend. One adapter per attempt; revisions are
79
+ * Builds one session over an engine. One adapter per attempt; revisions are
80
80
  * minted per adapter, so refs can never leak across attempts.
81
81
  */
82
- export function createBackendSession(options) {
83
- const { backend, targetName } = options;
82
+ export function createEngineSession(options) {
83
+ const { engine, targetName } = options;
84
84
  let revision = 0;
85
85
  let viewport = { width: 1, height: 1, scale: 1 };
86
86
  const unsupported = (what) => {
87
- throw new ConfigurationError('UNSUPPORTED_CAPABILITY', `target "${targetName}" has no backend capability for ${what}`);
87
+ throw new ConfigurationError('UNSUPPORTED_CAPABILITY', `target "${targetName}" has no engine capability for ${what}`);
88
88
  };
89
89
  /**
90
90
  * One declared member as a guarded call: capability-checked at the moment of
91
- * use and error-normalized. `defineBackend` bound every member to its body,
91
+ * use and error-normalized. `defineEngine` bound every member to its body,
92
92
  * so the function is called as is.
93
93
  */
94
94
  const guard = (what, fn) => async (...args) => {
@@ -103,14 +103,14 @@ export function createBackendSession(options) {
103
103
  };
104
104
  // Located nodes, cached by id so `read(ref)` answers from the resolution
105
105
  // that minted the ref. A read against an older resolution is NODE_STALE,
106
- // which the engine treats as retryable: it re-resolves and reads again.
106
+ // which the locator engine treats as retryable: it re-resolves and reads again.
107
107
  let locateRevision = 0;
108
108
  const located = new Map();
109
- const stale = (ref) => new BackendError('NODE_STALE', `node ${ref.id} is stale; re-resolve`, { retryable: true });
109
+ const stale = (ref) => new EngineError('NODE_STALE', `node ${ref.id} is stale; re-resolve`, { retryable: true });
110
110
  /**
111
- * A located ref from a superseded resolution never reaches the backend.
112
- * Observation refs are exempt: they are checked by the backend against its
113
- * newest observation, and a backend with stable ids may legitimately hand
111
+ * A located ref from a superseded resolution never reaches the engine.
112
+ * Observation refs are exempt: they are checked by the engine against its
113
+ * newest observation, and an engine with stable ids may legitimately hand
114
114
  * the same id to both tiers.
115
115
  */
116
116
  const rejectSupersededLocate = (ref) => {
@@ -120,35 +120,35 @@ export function createBackendSession(options) {
120
120
  if (known !== undefined && known.ref.revision !== ref.revision)
121
121
  throw stale(ref);
122
122
  };
123
- const locateRaw = guard('locators (screen)', backend?.locate);
124
- const observeRaw = guard('observation', backend?.observe);
123
+ const locateRaw = guard('locators (screen)', engine?.locate);
124
+ const observeRaw = guard('observation', engine?.observe);
125
125
  const app = {
126
- open: guard('navigation', backend?.app?.navigate),
127
- back: guard('back navigation', backend?.app?.back),
128
- restart: guard('app restart', backend?.app?.restart),
129
- clearState: guard('app state clearing', backend?.app?.clearState),
126
+ open: guard('navigation', engine?.app?.navigate),
127
+ back: guard('back navigation', engine?.app?.back),
128
+ restart: guard('app restart', engine?.app?.restart),
129
+ clearState: guard('app state clearing', engine?.app?.clearState),
130
130
  };
131
131
  const artifacts = {
132
- screenshot: guard('screenshots', backend?.artifacts?.screenshot),
133
- ...(backend?.artifacts?.startTrace === undefined || backend.artifacts.stopTrace === undefined
132
+ screenshot: guard('screenshots', engine?.artifacts?.screenshot),
133
+ ...(engine?.artifacts?.startTrace === undefined || engine.artifacts.stopTrace === undefined
134
134
  ? {}
135
135
  : {
136
- startTrace: guard('traces', backend.artifacts.startTrace),
137
- stopTrace: guard('traces', backend.artifacts.stopTrace),
136
+ startTrace: guard('traces', engine.artifacts.startTrace),
137
+ stopTrace: guard('traces', engine.artifacts.stopTrace),
138
138
  }),
139
139
  };
140
140
  let ended = false;
141
141
  return {
142
- verbs: declaredVerbs(backend),
142
+ verbs: declaredVerbs(engine),
143
143
  app,
144
144
  artifacts,
145
- ...(backend?.state === undefined
145
+ ...(engine?.state === undefined
146
146
  ? {}
147
147
  : {
148
- captureState: guard('state capture', backend.state.capture),
149
- restoreState: guard('state restore', backend.state.restore),
148
+ captureState: guard('state capture', engine.state.capture),
149
+ restoreState: guard('state restore', engine.state.restore),
150
150
  }),
151
- ...(backend?.url === undefined ? {} : { url: guard('the current URL', backend.url) }),
151
+ ...(engine?.url === undefined ? {} : { url: guard('the current URL', engine.url) }),
152
152
  async observe(operation, observeOptions) {
153
153
  const snapshot = await observeRaw(operation, observeOptions?.pixels === true ? { pixels: true } : {});
154
154
  if (snapshot.viewport !== undefined)
@@ -169,7 +169,11 @@ export function createBackendSession(options) {
169
169
  };
170
170
  },
171
171
  async locate(expression, operation) {
172
- const nodes = await locateRaw(expression, operation);
172
+ // An engine answers `visible` inside scopes, filters, and indices, where
173
+ // only it can; the harness holds a top-level query to the same predicate
174
+ // so a direct query never resolves to a node its own state calls hidden.
175
+ const nodes = (await locateRaw(expression, operation)).filter((node) => !(expression.kind === 'query' && expression.query.visible === true) ||
176
+ node.states?.hidden !== true);
173
177
  locateRevision += 1;
174
178
  const locateRev = `${LOCATE_REVISION_PREFIX}${locateRevision}`;
175
179
  const refs = [];
@@ -187,7 +191,7 @@ export function createBackendSession(options) {
187
191
  return refs;
188
192
  },
189
193
  async read(ref) {
190
- if (backend?.locate === undefined)
194
+ if (engine?.locate === undefined)
191
195
  unsupported('locators (screen)');
192
196
  const node = located.get(ref.id);
193
197
  if (node === undefined || node.ref.revision !== ref.revision)
@@ -198,16 +202,16 @@ export function createBackendSession(options) {
198
202
  rejectSupersededLocate(ref);
199
203
  if (action.kind === 'dragTo')
200
204
  rejectSupersededLocate(action.target);
201
- await guard(`the "${action.kind}" action`, backend?.perform)(ref, action, operation);
205
+ await guard(`the "${action.kind}" action`, engine?.perform)(ref, action, operation);
202
206
  },
203
- swipe: guard('swipe gestures', backend?.swipe),
204
- // The backend outlives the attempt; only the per-attempt isolation ends
207
+ swipe: guard('swipe gestures', engine?.swipe),
208
+ // The engine outlives the attempt; only the per-attempt isolation ends
205
209
  // here, exactly once. dispose() belongs to the worker.
206
210
  close: guard('attempt end', async (operation) => {
207
211
  if (ended)
208
212
  return;
209
213
  ended = true;
210
- await backend?.endAttempt?.({ signal: operation.signal, timeoutMs: operation.timeoutMs });
214
+ await engine?.endAttempt?.({ signal: operation.signal, timeoutMs: operation.timeoutMs });
211
215
  }),
212
216
  };
213
217
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/engine/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,QAAQ,EACR,YAAY,EACZ,iBAAiB,GAClB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,WAAW,GAOZ,MAAM,cAAc,CAAC;AAOtB,+FAA+F;AAC/F,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAE9B,qFAAqF;AACrF,MAAM,sBAAsB,GAAG,GAAG,CAAC;AACnC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAEpC;;;;GAIG;AACH,SAAS,aAAa,CAAC,IAAkB,EAAE,QAAgB;IACzD,OAAO;QACL,GAAG,IAAI;QACP,GAAG,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,QAAQ,EAAE;QAClC,GAAG,CAAC,IAAI,CAAC,QAAQ,KAAK,SAAS;YAC7B,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC;KAChF,CAAC;AACJ,C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E,MAAM,KAAK,CAAC,QAAQ,MAAM,CAAC,IAAI,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;QACtF,CAAC;QACD,KAAK,EAAE,KAAK,CAAC,gBAAgB,EAAE,MAAM,EAAE,KAAK,CAAC;QAC7C,uEAAuE;QACvE,uDAAuD;QACvD,KAAK,EAAE,KAAK,CAAC,aAAa,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE;YAC9C,IAAI,KAAK;gBAAE,OAAO;YAClB,KAAK,GAAG,IAAI,CAAC;YACb,MAAM,MAAM,EAAE,UAAU,EAAE,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,CAAC,SAAS,EAAE,CAAC,CAAC;QAC3F,CAAC,CAAC;KACH,CAAC;AACJ,CAAC"}
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * The internal session surface the harness consumes for one attempt. It is
3
- * produced only by `createBackendSession` (the backend-to-session adapter) and
3
+ * produced only by `createEngineSession` (the engine-to-session adapter) and
4
4
  * is never part of the public API: the locator engine, the agent tiers, and
5
5
  * the attempt executor program against it so that revision minting, staleness
6
6
  * checks, and capability gating exist exactly once.
@@ -9,17 +9,17 @@
9
9
  */
10
10
  import type { Momentum, ScrollDirection } from '../types.ts';
11
11
  import type { LocatorAction, LocatorExpression, NodeRef, ObservationPixels, OperationContext, SemanticNode } from './contract.ts';
12
- import type { BackendObserveOptions, BackendState } from './index.ts';
12
+ import type { EngineObserveOptions, EngineState } from './index.ts';
13
13
  export type * from './contract.ts';
14
- export { BackendError } from './contract.ts';
15
- export type { BackendObserveOptions, BackendState } from './index.ts';
14
+ export { EngineError } from './contract.ts';
15
+ export type { EngineObserveOptions, EngineState } from './index.ts';
16
16
  /**
17
17
  * The agent's action grammar, by verb. A session declares which verbs its
18
- * backend can honor so the agent offers the model exactly that vocabulary.
18
+ * engine can honor so the agent offers the model exactly that vocabulary.
19
19
  */
20
20
  export type GrammarVerb = 'tap' | 'type' | 'typeSecret' | 'press' | 'select' | 'scroll' | 'navigate';
21
21
  export interface Observation {
22
- /** Location captured with this tree, when the backend can provide it. */
22
+ /** Location captured with this tree, when the engine can provide it. */
23
23
  readonly url?: string;
24
24
  readonly revision: string;
25
25
  readonly capturedAt: string;
@@ -31,7 +31,7 @@ export interface Observation {
31
31
  readonly scale: number;
32
32
  };
33
33
  /**
34
- * What the backend masked against what it saw. Pixel completeness is judged
34
+ * What the engine masked against what it saw. Pixel completeness is judged
35
35
  * downstream from these counts: fewer masked regions than secure nodes
36
36
  * withholds the pixels and keeps the tree.
37
37
  */
@@ -59,10 +59,10 @@ export interface SessionArtifacts {
59
59
  stopTrace?(operation: OperationContext): Promise<string>;
60
60
  }
61
61
  export interface TargetSession {
62
- /** Grammar verbs the backend can honor, read from its declaration. */
62
+ /** Grammar verbs the engine can honor, read from its declaration. */
63
63
  readonly verbs: ReadonlySet<GrammarVerb>;
64
64
  /** Captures one atomic agent observation; the harness redacts it downstream. */
65
- observe(operation: OperationContext, options?: BackendObserveOptions): Promise<Observation>;
65
+ observe(operation: OperationContext, options?: EngineObserveOptions): Promise<Observation>;
66
66
  /** Resolves immediately; the runner owns query polling and strictness. */
67
67
  locate(expression: LocatorExpression, operation: OperationContext): Promise<readonly NodeRef[]>;
68
68
  /** Reads one node from the resolution that minted its ref. */
@@ -74,9 +74,9 @@ export interface TargetSession {
74
74
  readonly app: SessionApp;
75
75
  readonly artifacts: SessionArtifacts;
76
76
  /** Captures immutable app state for a session envelope. */
77
- captureState?(operation: OperationContext): Promise<BackendState>;
77
+ captureState?(operation: OperationContext): Promise<EngineState>;
78
78
  /** Replaces current app state with an immutable captured state. */
79
- restoreState?(state: BackendState, operation: OperationContext): Promise<void>;
79
+ restoreState?(state: EngineState, operation: OperationContext): Promise<void>;
80
80
  /** Current top-level URL of the surface, when the platform has one. */
81
81
  url?(operation: OperationContext): Promise<string>;
82
82
  /** Ends the attempt's isolation within the operation's budget. Idempotent. */
@@ -0,0 +1 @@
1
+ {"version":3,"file":"surface.d.ts","sourceRoot":"","sources":["../../src/engine/surface.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,KAAK,EACV,aAAa,EACb,iBAAiB,EACjB,OAAO,EACP,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,EACb,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEpE,mBAAmB,eAAe,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,YAAY,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEpE;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,MAAM,GAAG,YAAY,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,UAAU,CAAC;AAErG,MAAM,WAAW,WAAW;IAC1B,wEAAwE;IACxE,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,MAAM,CAAC,EAAE,iBAAiB,CAAC;IACpC,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE;QACjB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;KACxB,CAAC;IACF;;;;OAIG;IACH,QAAQ,CAAC,SAAS,EAAE;QAClB,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;QACjC,QAAQ,CAAC,iBAAiB,EAAE,M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CAAC,YAAY,CAAC,CAAC;IACvE,iEAAiE;IACjE,OAAO,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,SAAS,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACzF,uCAAuC;IACvC,KAAK,CACH,SAAS,EAAE,eAAe,EAC1B,QAAQ,EAAE,QAAQ,GAAG,SAAS,EAC9B,SAAS,EAAE,gBAAgB,GAC1B,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAC;IACzB,QAAQ,CAAC,SAAS,EAAE,gBAAgB,CAAC;IACrC,2DAA2D;IAC3D,YAAY,CAAC,CAAC,SAAS,EAAE,gBAAgB,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IACjE,mEAAmE;IACnE,YAAY,CAAC,CAAC,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9E,uEAAuE;IACvE,GAAG,CAAC,CAAC,SAAS,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACnD,8EAA8E;IAC9E,KAAK,CAAC,SAAS,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACnD"}
@@ -1,11 +1,11 @@
1
1
  /**
2
2
  * The internal session surface the harness consumes for one attempt. It is
3
- * produced only by `createBackendSession` (the backend-to-session adapter) and
3
+ * produced only by `createEngineSession` (the engine-to-session adapter) and
4
4
  * is never part of the public API: the locator engine, the agent tiers, and
5
5
  * the attempt executor program against it so that revision minting, staleness
6
6
  * checks, and capability gating exist exactly once.
7
7
  *
8
8
  * Re-exports the contract vocabulary so internal modules import one path.
9
9
  */
10
- export { BackendError } from './contract.js';
10
+ export { EngineError } from './contract.js';
11
11
  //# sourceMappingURL=surface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"surface.js","sourceRoot":"","sources":["../../src/engine/surface.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAcH,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timing.d.ts","sourceRoot":"","sources":["../../src/engine/timing.ts"],"names":[],"mappings":"AAIA,uFAAuF;AACvF,wBAAgB,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAElH"}
@@ -0,0 +1,8 @@
1
+ /** Cancellation with the engine error taxonomy and shared lifecycle mechanics. */
2
+ import { withAbort } from '../internal/time.js';
3
+ import { EngineError } from './contract.js';
4
+ /** Checks cancellation before dispatching a thunk, then abandons the wait on abort. */
5
+ export function raceAbort(work, signal, label) {
6
+ return withAbort(work, signal, () => new EngineError('CANCELLED', `${label} cancelled`, { retryable: false }));
7
+ }
8
+ //# sourceMappingURL=timing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timing.js","sourceRoot":"","sources":["../../src/engine/timing.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,uFAAuF;AACvF,MAAM,UAAU,SAAS,CAAI,IAAqC,EAAE,MAAmB,EAAE,KAAa;IACpG,OAAO,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,WAAW,CAAC,WAAW,EAAE,GAAG,KAAK,YAAY,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;AACjH,CAAC"}
@@ -6,7 +6,7 @@ import { createAsyncExpectation } from './async.js';
6
6
  import { createValueExpectation } from './values.js';
7
7
  /**
8
8
  * A fixture's attached expectation surface hangs off the fixture object under
9
- * a global symbol (`BackendFixtureContext.expectable`), so an expect()
9
+ * a global symbol (`EngineFixtureContext.expectable`), so an expect()
10
10
  * imported in an isolated test-module realm can still reach it. Core routes
11
11
  * to the surface and never knows which matchers a platform contributed.
12
12
  */
package/dist/index.d.ts CHANGED
@@ -4,11 +4,12 @@ export { test } from './collect/registry.ts';
4
4
  export { expect } from './expect/index.ts';
5
5
  export { credentials } from './credentials.ts';
6
6
  export { AgentError } from './agent/error.ts';
7
- export { BLOCKABLE_CODES, RUNTIME_CODES, blockedCategoryOf } from './agent/executor.ts';
7
+ export { BLOCKABLE_CODES, RUNTIME_CODES } from './agent/executor.ts';
8
8
  export { buildTraceEntry, readTraceEntry } from './cache/trace.ts';
9
9
  /** Type-checks and returns an e2e configuration object. */
10
10
  export declare function defineConfig(config: E2EConfig): E2EConfig;
11
11
  export type * from './types.ts';
12
- export type { BlockedCategory, ExecutorActions, ExecutorAttempt, ExecutorBudgets, ExecutorModelCall, ExecutorNode, ExecutorObservation, ExecutorObserveOptions, ExecutorPixels, ExecutorPriorStep, ExecutorStep, ExecutorTarget, ReplayedPrefix, ReplayHandOffReason, StepExecutor, StepExecutorContext, StepVerdict, StepVerdictStatus, } from './agent/executor.ts';
12
+ export type { ExecutorActions, ExecutorAttempt, ExecutorBudgets, ExecutorModelCall, ExecutorNode, ExecutorObservation, ExecutorObserveOptions, ExecutorPixels, ExecutorStep, ExecutorTarget, ReplayedPrefix, ReplayHandOffReason, StepExecutor, StepExecutorContext, StepVerdict, StepVerdictStatus, } from './agent/executor.ts';
13
13
  export type { VisionDegradation } from './run/steps.ts';
14
+ export type { EngineAppDeclaration } from './engine/index.ts';
14
15
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,iCAAiC;AAEjC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO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