@nifrajs/e2e 0.0.0-stage → 5.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 (84) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/LICENSE +21 -0
  3. package/README.md +127 -2
  4. package/dist/agent.d.ts +119 -0
  5. package/dist/agent.d.ts.map +1 -0
  6. package/dist/agent.js +315 -0
  7. package/dist/agent.js.map +1 -0
  8. package/dist/cache.d.ts +84 -0
  9. package/dist/cache.d.ts.map +1 -0
  10. package/dist/cache.js +166 -0
  11. package/dist/cache.js.map +1 -0
  12. package/dist/decision.d.ts +54 -0
  13. package/dist/decision.d.ts.map +1 -0
  14. package/dist/decision.js +122 -0
  15. package/dist/decision.js.map +1 -0
  16. package/dist/engine.d.ts +75 -0
  17. package/dist/engine.d.ts.map +1 -0
  18. package/dist/engine.js +13 -0
  19. package/dist/engine.js.map +1 -0
  20. package/dist/evidence.d.ts +14 -0
  21. package/dist/evidence.d.ts.map +1 -0
  22. package/dist/evidence.js +52 -0
  23. package/dist/evidence.js.map +1 -0
  24. package/dist/expect.d.ts +28 -0
  25. package/dist/expect.d.ts.map +1 -0
  26. package/dist/expect.js +88 -0
  27. package/dist/expect.js.map +1 -0
  28. package/dist/fake.d.ts +35 -0
  29. package/dist/fake.d.ts.map +1 -0
  30. package/dist/fake.js +129 -0
  31. package/dist/fake.js.map +1 -0
  32. package/dist/index.d.ts +11 -0
  33. package/dist/index.d.ts.map +1 -0
  34. package/dist/index.js +8 -0
  35. package/dist/index.js.map +1 -0
  36. package/dist/internal/record.d.ts +3 -0
  37. package/dist/internal/record.d.ts.map +1 -0
  38. package/dist/internal/record.js +6 -0
  39. package/dist/internal/record.js.map +1 -0
  40. package/dist/locator.d.ts +53 -0
  41. package/dist/locator.d.ts.map +1 -0
  42. package/dist/locator.js +103 -0
  43. package/dist/locator.js.map +1 -0
  44. package/dist/params.d.ts +44 -0
  45. package/dist/params.d.ts.map +1 -0
  46. package/dist/params.js +108 -0
  47. package/dist/params.js.map +1 -0
  48. package/dist/playwright.d.ts +72 -0
  49. package/dist/playwright.d.ts.map +1 -0
  50. package/dist/playwright.js +169 -0
  51. package/dist/playwright.js.map +1 -0
  52. package/dist/replay.d.ts +34 -0
  53. package/dist/replay.d.ts.map +1 -0
  54. package/dist/replay.js +111 -0
  55. package/dist/replay.js.map +1 -0
  56. package/dist/route.d.ts +7 -0
  57. package/dist/route.d.ts.map +1 -0
  58. package/dist/route.js +26 -0
  59. package/dist/route.js.map +1 -0
  60. package/dist/session.d.ts +62 -0
  61. package/dist/session.d.ts.map +1 -0
  62. package/dist/session.js +105 -0
  63. package/dist/session.js.map +1 -0
  64. package/dist/snapshot.d.ts +8 -0
  65. package/dist/snapshot.d.ts.map +1 -0
  66. package/dist/snapshot.js +49 -0
  67. package/dist/snapshot.js.map +1 -0
  68. package/package.json +73 -4
  69. package/src/agent.ts +525 -0
  70. package/src/cache.ts +229 -0
  71. package/src/decision.ts +152 -0
  72. package/src/engine.ts +92 -0
  73. package/src/evidence.ts +58 -0
  74. package/src/expect.ts +171 -0
  75. package/src/fake.ts +185 -0
  76. package/src/index.ts +64 -0
  77. package/src/internal/record.ts +5 -0
  78. package/src/locator.ts +157 -0
  79. package/src/params.ts +128 -0
  80. package/src/playwright.ts +236 -0
  81. package/src/replay.ts +153 -0
  82. package/src/route.ts +26 -0
  83. package/src/session.ts +178 -0
  84. package/src/snapshot.ts +46 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,23 @@
1
+ # @nifrajs/e2e
2
+
3
+ ## 5.13.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 2e7a043: Add `@nifrajs/e2e`: browser end-to-end tests for Nifra apps. `e2e(app)` serves the app on an ephemeral port and drives it through a browser engine (Playwright by default, an in-memory engine at `@nifrajs/e2e/fake`). `open()` takes only paths the app declares and requires their `:params`. Locators (`getByRole`, `getByLabel`, `getByText`, `getByTestId`, `filter`) and retrying assertions (`toBeVisible`, `toHaveText`, `toHaveCount`, `toHaveURL` and more, each with `.not`) run in any test runner. On a page that loads a module script, actions wait for `data-nifra-hydrated`. `t.agent` adds goal-driven steps over a model you supply: `act`, `assert`, `waitFor` and `extract`, with call, action and time budgets, `Secret` params the model never reads, and a pruned page outline. A replay cache makes the second run of an `act` model-free: it is written only after a later check passes, replays only when each control still matches exactly, and hands off to the model from where it stopped. Modes are `read-write`, `read-only`, `strict` and `off`; `unique()` keeps run-varying data from missing.
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [591f74e]
12
+ - Updated dependencies [b427443]
13
+ - Updated dependencies [3b39e39]
14
+ - Updated dependencies [16023e9]
15
+ - Updated dependencies [d75437b]
16
+ - Updated dependencies [9c8a464]
17
+ - @nifrajs/core@5.13.0
18
+ - @nifrajs/node@5.13.0
19
+ - @nifrajs/testing@5.13.0
20
+
21
+ ## 5.12.1
22
+
23
+ - Initial release: browser end-to-end tests for Nifra apps, with typed paths, locators, retrying assertions, agent steps and a replay cache.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Nifra Authors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,128 @@
1
- # Temporary Holding Version
1
+ # @nifrajs/e2e
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Browser end-to-end tests for Nifra apps. It serves your app on an ephemeral port, drives it through
4
+ a browser engine, and gives you locators and retrying assertions. The route table types `open()`.
5
+
6
+ ```ts
7
+ import { test } from "bun:test"
8
+ import { e2e, expect } from "@nifrajs/e2e"
9
+ import { app } from "../src/app"
10
+
11
+ test("a user page renders", async () => {
12
+ await using t = await e2e(app)
13
+ await t.open("/users/:id", { params: { id: 42 } }) // a path or param the app lacks fails typecheck
14
+ await expect(t.screen.getByRole("heading")).toHaveText("User 42")
15
+ await t.screen.getByLabel("Nickname").fill("grace")
16
+ await expect(t).toHaveURL("/users/42")
17
+ })
18
+ ```
19
+
20
+ `await using` closes the browser and the server at scope exit; `t.close()` does the same by hand.
21
+
22
+ ## Locators and assertions
23
+
24
+ `getByRole(role, name)`, `getByLabel`, `getByText`, `getByTestId`, `.filter({ hasText })`, and chaining
25
+ to scope into a row. Names and text match as a case-insensitive substring; pass `{ exact: true }` for
26
+ a full match. Actions: `tap`, `fill`, `press`. Assertions retry until they pass or `assertionTimeout`
27
+ (default 5000 ms) runs out: `toBeVisible`, `toBeHidden`, `toHaveText`, `toContainText`, `toHaveCount`,
28
+ `toHaveValue`, `toHaveURL`, each with `.not`.
29
+
30
+ A locator that matches several elements is an error for `tap`, `fill`, `press` and the one-element
31
+ assertions (`LOCATOR_AMBIGUOUS`, or a failed assertion naming the count).
32
+
33
+ ## Hydration
34
+
35
+ On a page that loads a module script, the Playwright engine waits for `data-nifra-hydrated` on `<html>`
36
+ after each navigation and before each action, so a tap does not land before its handler exists. Pass
37
+ `hydration: "off"` for a page that is not a hydrated Nifra page.
38
+
39
+ ## Signed-in sessions
40
+
41
+ ```ts
42
+ const { client, cookies } = testSession<typeof app>(app)
43
+ await client.auth.login.post(credentials)
44
+ await using t = await e2e(app, { cookies })
45
+ ```
46
+
47
+ ## Agent steps
48
+
49
+ Say what you want in words; a model you supply drives the page. Locators and agent steps mix in one test.
50
+
51
+ ```ts
52
+ await using t = await e2e(app, { model, agentContext: "Acme calls a plan a seat" })
53
+ await t.open("/login")
54
+ await t.agent.act("sign in as {email} with {password}", {
55
+ params: { email: "ada@example.test", password: new Secret("password", process.env.PASSWORD ?? "") },
56
+ })
57
+ await t.agent.assert("the dashboard greets Ada")
58
+ await t.agent.waitFor("the export is finished", { timeout: 60_000 })
59
+ const plan = await t.agent.extract("the current plan", { schema: PlanSchema })
60
+ ```
61
+
62
+ `model` is `{ decide(request) }`: the request carries the goal, a pruned outline of the page and what was
63
+ already tried, and the answer is `{ kind: "tap" | "fill" | "press" | "goto" | "done" | "fail", ... }` for
64
+ `act`, `{ pass, reason }` for `assert` and `waitFor`, and `{ value }` for `extract`. Nothing here names a
65
+ vendor; you own the credentials, the retries and the cost. Without `model`, agent steps reject with
66
+ `MODEL_MISSING` and locator tests are unaffected.
67
+
68
+ - **Budgets.** `act` stops at `maxModelCalls` (12), `maxActions` (25) or `timeout` (120000 ms), each a
69
+ distinct error. The time limit is checked between decisions; it does not interrupt a `decide()` call
70
+ that never resolves, so enforce a deadline inside `decide` (the request carries a `signal`). A tap that finds no element or several goes back to the model, which can retry with `nth`.
71
+ - **Secrets.** A `Secret` is typed into the page by name. The model sees `{password}`, never the value,
72
+ and every snapshot a session sends has any secret it was given replaced by its placeholder.
73
+ - **Same origin.** `goto` takes an app path only; anything else is refused and reported to the model.
74
+ - **`extract`** validates the answer with your Standard Schema (`EXTRACT_INVALID` on a mismatch).
75
+ - **`waitFor`** asks the model again only when the page outline changed.
76
+
77
+ ## Replay cache
78
+
79
+ The first run of an `act` asks the model; the next runs replay what it did, with no model call.
80
+
81
+ ```ts
82
+ await using t = await e2e(app, { model, cache: { testId: "member upgrades to Pro" } })
83
+ await t.open("/settings/billing")
84
+ await t.agent.act("upgrade the workspace to the {plan} plan", { params: { plan: "Pro" } })
85
+ await expect(t.screen.getByRole("status")).toHaveText("Pro") // a later check that passes saves the recording
86
+ console.log(formatReport(t.agent.report())) // Cache: 1 replayed - 0 handed off - 0 missed (0 model calls)
87
+ ```
88
+
89
+ - **Written only after a later check passes.** A locator `expect` or `agent.assert`/`waitFor` that passes
90
+ saves what the `act`s before it recorded. One that fails deletes them. A test that ends with no check
91
+ records nothing.
92
+ - **Replay** needs the same start route, finds each control by the role, name, label, text or test id
93
+ it had, and requires it to match exactly as often as it did. It never taps a near miss. It then checks
94
+ the end route and the controls and headings that appeared or went away.
95
+ - **Hand-off.** When a replay stops (`target-not-found`, `ambiguous`, `end-mismatch`, `action-uncertain`,
96
+ `route-mismatch`) the actions it already did stay done, and the model finishes the goal from the current
97
+ page. `ActRequest.handoff` carries the reason and how many actions to leave alone. A passing check
98
+ re-records the repaired steps. If the goal then fails, the recording is deleted.
99
+ - **Modes** (`cache.mode`): `read-write` (default; `read-only` when `CI` is set), `read-only` (replays and
100
+ hands off, never writes or deletes), `strict` (replay only: a stale recording is `REPLAY_STALE`, a
101
+ missing one `REPLAY_MISSING`), `off`.
102
+ - **The key** is the test (`cache.testId`: pass it), the goal text, the params, `agentContext`, and
103
+ `cache.appIdentity`. Wrap run-varying data in `unique(value)` so a new value does not miss; it is
104
+ typed again on replay. A `Secret` is stored by name only, never by value.
105
+ - **Where.** `.nifra/e2e-cache/<hash>.json` under the working directory (`cache.dir`), small and meant to
106
+ be committed. `cache.store` swaps in your own store; `memoryCacheStore()` is one for tests. A store
107
+ that refuses a write is counted in the cache, not thrown. `cache: false` turns the whole thing off.
108
+ - Replay needs no model: in CI `model` can be left out and a stale recording then fails with
109
+ `MODEL_MISSING`. `assert`, `waitFor` and `extract` always ask the model.
110
+
111
+ ## Engines
112
+
113
+ `e2e()` uses the Playwright engine by default; install `playwright` yourself (optional peer). The engine
114
+ is a six-method interface (`goto`, `url`, `resolve`, `act`, `snapshot`, `close`), so anything else can plug in with
115
+ `e2e(app, { engine })`. `@nifrajs/e2e/fake` is an in-memory engine with the same locator semantics, for
116
+ testing code built on this package without a browser.
117
+
118
+ ## Not included yet
119
+
120
+ Token counts (the model port returns decisions, not usage) and a test runner. Use `bun:test` or Vitest.
121
+
122
+ ## For AI agents
123
+
124
+ Start with [`LLM.md`](./LLM.md) - this package's contract card (the exports you call + its footguns),
125
+ one cheap read instead of the whole corpus. For the wider framework: the repo's
126
+ [`AGENTS.md`](../../AGENTS.md) is the copy-paste quick reference, and
127
+ [`llms-full.txt`](../../llms-full.txt) is the full machine-readable corpus. Run `nifra check` as the
128
+ done-gate, or `nifra mcp` to give the agent live project tools.
@@ -0,0 +1,119 @@
1
+ import { type InferOutput, type StandardSchemaV1 } from "@nifrajs/core/schema";
2
+ import { type Cache } from "./cache.js";
3
+ import { type PerformedDecision } from "./decision.js";
4
+ import { type Clock, type Engine } from "./engine.js";
5
+ import { type Params } from "./params.js";
6
+ import { type StopReason } from "./replay.js";
7
+ /** One thing the agent tried inside a goal, and whether the page took it. */
8
+ export interface ActionRecord {
9
+ readonly action: PerformedDecision;
10
+ readonly ok: boolean;
11
+ readonly error?: string;
12
+ }
13
+ /** A recorded run that stopped partway: its actions are already done, so do not redo them. */
14
+ export interface HandOff {
15
+ readonly reason: StopReason;
16
+ readonly detail: string;
17
+ /** How many actions at the start of `history` the replay performed. */
18
+ readonly performed: number;
19
+ }
20
+ export interface ActRequest {
21
+ readonly kind: "act";
22
+ readonly goal: string;
23
+ readonly context?: string;
24
+ readonly snapshot: string;
25
+ readonly history: readonly ActionRecord[];
26
+ /** Names of params whose values stay out of the goal and the snapshot; write `{name}` to type one. */
27
+ readonly secrets: readonly string[];
28
+ readonly modelCallsLeft: number;
29
+ readonly actionsLeft: number;
30
+ readonly handoff: HandOff | undefined;
31
+ readonly signal: AbortSignal;
32
+ }
33
+ export interface JudgeRequest {
34
+ readonly kind: "assert" | "waitFor";
35
+ readonly statement: string;
36
+ readonly context?: string;
37
+ readonly snapshot: string;
38
+ readonly secrets: readonly string[];
39
+ readonly signal: AbortSignal;
40
+ }
41
+ export interface ExtractRequest {
42
+ readonly kind: "extract";
43
+ readonly prompt: string;
44
+ readonly context?: string;
45
+ readonly snapshot: string;
46
+ readonly secrets: readonly string[];
47
+ /** The JSON Schema the caller supplied, to put in the prompt; the answer is validated against the real schema. */
48
+ readonly jsonSchema?: unknown;
49
+ readonly signal: AbortSignal;
50
+ }
51
+ export type ModelRequest = ActRequest | JudgeRequest | ExtractRequest;
52
+ /**
53
+ * The seam to a model. Answer an `act` request with a decision (`{ kind: "tap", target }`, `fill`,
54
+ * `press`, `goto`, `done` or `fail`), an `assert` or `waitFor` with `{ pass, reason }`, and an
55
+ * `extract` with `{ value }`. The answer is unknown until the runner has parsed it. Nothing here
56
+ * names a vendor; the caller owns credentials, retries and cost.
57
+ */
58
+ export interface E2EModel {
59
+ decide(request: ModelRequest): unknown | PromiseLike<unknown>;
60
+ }
61
+ export interface StepOptions {
62
+ readonly params?: Params;
63
+ readonly signal?: AbortSignal;
64
+ }
65
+ export interface ActOptions extends StepOptions {
66
+ /** Model decisions one goal may use. Default 12. */
67
+ readonly maxModelCalls?: number;
68
+ /** Page actions one goal may take, failed ones included. Default 25. */
69
+ readonly maxActions?: number;
70
+ /** ms for the whole goal on the session clock. Default 120000. */
71
+ readonly timeout?: number;
72
+ }
73
+ export interface WaitForOptions extends StepOptions {
74
+ /** ms to wait for the statement to hold. Default 30000. */
75
+ readonly timeout?: number;
76
+ }
77
+ export interface ExtractOptions<S extends StandardSchemaV1> extends StepOptions {
78
+ readonly schema: S;
79
+ readonly jsonSchema?: unknown;
80
+ }
81
+ export interface ActResult {
82
+ /** `replay`: no model call. `handoff`: a recording stopped and the model finished the goal. */
83
+ readonly source: "model" | "replay" | "handoff";
84
+ readonly modelCalls: number;
85
+ /** The actions the page accepted, in order. */
86
+ readonly actions: readonly PerformedDecision[];
87
+ readonly summary?: string;
88
+ }
89
+ /** What the replay cache did for this session, and how many model calls it still took. */
90
+ export interface AgentReport {
91
+ readonly replayed: number;
92
+ readonly handedOff: number;
93
+ readonly missed: number;
94
+ readonly modelCalls: number;
95
+ }
96
+ export declare function formatReport(report: AgentReport): string;
97
+ export interface Agent {
98
+ report(): AgentReport;
99
+ act(goal: string, options?: ActOptions): Promise<ActResult>;
100
+ assert(statement: string, options?: StepOptions): Promise<void>;
101
+ waitFor(statement: string, options?: WaitForOptions): Promise<void>;
102
+ extract<S extends StandardSchemaV1>(prompt: string, options: ExtractOptions<S>): Promise<InferOutput<S>>;
103
+ }
104
+ export interface AgentDeps {
105
+ readonly engine: Engine;
106
+ readonly clock: Clock;
107
+ readonly pollInterval: number;
108
+ readonly actionTimeout: number;
109
+ readonly model: E2EModel | undefined;
110
+ readonly context: string | undefined;
111
+ readonly snapshotChars: number;
112
+ /** Origin of the app under test. */
113
+ readonly origin: string;
114
+ readonly cache: Cache | undefined;
115
+ /** Opens a same-origin path; refuses any other. */
116
+ readonly navigate: (path: string) => Promise<void>;
117
+ }
118
+ export declare function createAgent(deps: AgentDeps): Agent;
119
+ //# sourceMappingURL=agent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,gBAAgB,EAAoB,MAAM,sBAAsB,CAAA;AAChG,OAAO,EAAE,KAAK,KAAK,EAAqD,MAAM,YAAY,CAAA;AAC1F,OAAO,EAEL,KAAK,iBAAiB,EAKvB,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,KAAK,KAAK,EAAY,KAAK,MAAM,EAAE,MAAM,aAAa,CAAA;AAE/D,OAAO,EAIL,KAAK,MAAM,EAIZ,MAAM,aAAa,CAAA;AACpB,OAAO,EAAe,K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,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;IAC9B,QAAQ,CAAC,KAAK,EAAE,QAAQ,GAAG,SAAS,CAAA;IACpC,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAA;IACpC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;IAC9B,oCAAoC;IACpC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,SAAS,CAAA;IACjC,mDAAmD;IACnD,QAAQ,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CACnD;AA+BD,wBAAgB,WAAW,CAAC,IAAI,EAAE,SAAS,GAAG,KAAK,CAkVlD"}
package/dist/agent.js ADDED
@@ -0,0 +1,315 @@
1
+ import { validateStandard } from "@nifrajs/core/schema";
2
+ import { performedOf } from "./cache.js";
3
+ import { parseActDecision, parseExtraction, parseVerdict, targetSelector, } from "./decision.js";
4
+ import { E2EError } from "./engine.js";
5
+ import { diffEvidence } from "./evidence.js";
6
+ import { forModel, forPage, redactSecrets, Secret, templatize, } from "./params.js";
7
+ import { replayEntry, visibleCount, withoutNth } from "./replay.js";
8
+ import { normalizeRoute } from "./route.js";
9
+ import { pruneSnapshot } from "./snapshot.js";
10
+ export function formatReport(report) {
11
+ return `Cache: ${report.replayed} replayed - ${report.handedOff} handed off - ${report.missed} missed (${report.modelCalls} model calls)`;
12
+ }
13
+ const NEVER = new AbortController().signal;
14
+ function withContext(context) {
15
+ return context === undefined ? {} : { context };
16
+ }
17
+ function entryOf(goal, startRoute, actions, before, after, route, params) {
18
+ const changes = diffEvidence(before, after);
19
+ return {
20
+ version: 1,
21
+ instruction: goal,
22
+ startRoute,
23
+ actions,
24
+ end: {
25
+ route,
26
+ appeared: changes.appeared.map((line) => templatize(line, params)),
27
+ disappeared: changes.disappeared.map((line) => templatize(line, params)),
28
+ },
29
+ };
30
+ }
31
+ export function createAgent(deps) {
32
+ const { engine, clock, cache } = deps;
33
+ const stats = { replayed: 0, handedOff: 0, missed: 0, modelCalls: 0 };
34
+ const requireModel = () => {
35
+ if (deps.model === undefined) {
36
+ throw new E2EError("MODEL_MISSING", "this step needs a model: pass `model` to e2e()");
37
+ }
38
+ return deps.model;
39
+ };
40
+ const ask = async (model, request) => {
41
+ stats.modelCalls += 1;
42
+ return model.decide(request);
43
+ };
44
+ // Every secret any step has been given stays redacted for the whole session: a value typed in one
45
+ // step is still on the page when a later step, which was not handed it, takes a snapshot. They are
46
+ // kept by value, so two steps that reuse a name for different secrets are both redacted.
47
+ const vault = [];
48
+ const remember = (params) => {
49
+ for (const [name, param] of Object.entries(params)) {
50
+ if (!(param instanceof Secret))
51
+ continue;
52
+ const known = vault.some(([, held]) => Secret.reveal(held) === Secret.reveal(param));
53
+ if (!known)
54
+ vault.push([name, param]);
55
+ }
56
+ };
57
+ const scrub = (text) => redactSecrets(text, vault);
58
+ const observe = async () => {
59
+ const raw = scrub(await engine.snapshot());
60
+ return { raw, shown: pruneSnapshot(raw, deps.snapshotChars) };
61
+ };
62
+ const look = async () => (await observe()).shown;
63
+ const perform = async (decision, params, recording) => {
64
+ try {
65
+ if (decision.kind === "goto") {
66
+ await deps.navigate(decision.path);
67
+ return {
68
+ record: { action: decision, ok: true },
69
+ recorded: recording
70
+ ? { kind: "goto", path: templatize(decision.path, params) }
71
+ : undefined,
72
+ };
73
+ }
74
+ const selector = targetSelector(decision.target);
75
+ const matches = recording ? await visibleCount(engine, withoutNth(selector)) : 1;
76
+ let recorded;
77
+ if (decision.kind === "tap") {
78
+ await engine.act(selector, { kind: "tap" }, deps.actionTimeout);
79
+ recorded = { kind: "tap", target: decision.target, matches };
80
+ }
81
+ else if (decision.kind === "fill") {
82
+ const value = forPage(decision.value, params);
83
+ await engine.act(selector, { kind: "fill", value }, deps.actionTimeout);
84
+ recorded = {
85
+ kind: "fill",
86
+ target: decision.target,
87
+ matches,
88
+ value: templatize(decision.value, params),
89
+ };
90
+ }
91
+ else {
92
+ await engine.act(selector, { kind: "press", key: decision.key }, deps.actionTimeout);
93
+ recorded = { kind: "press", target: decision.target, matches, key: decision.key };
94
+ }
95
+ return { record: { action: decision, ok: true }, recorded: recording ? recorded : undefined };
96
+ }
97
+ catch (error) {
98
+ if (error instanceof E2EError || error instanceof TypeError) {
99
+ return {
100
+ record: { action: decision, ok: false, error: scrub(error.message) },
101
+ recorded: undefined,
102
+ };
103
+ }
104
+ throw error;
105
+ }
106
+ };
107
+ return {
108
+ report: () => ({ ...stats }),
109
+ async act(goal, options = {}) {
110
+ const params = options.params ?? {};
111
+ remember(params);
112
+ const { text, secrets } = forModel(goal, params);
113
+ const maxCalls = options.maxModelCalls ?? 12;
114
+ const maxActions = options.maxActions ?? 25;
115
+ const deadline = clock.now() + (options.timeout ?? 120_000);
116
+ const recording = cache?.canWrite === true;
117
+ const key = cache === undefined || cache.mode === "off"
118
+ ? undefined
119
+ : cache.key(goal, params, deps.context);
120
+ const startRoute = normalizeRoute(await engine.url(), deps.origin);
121
+ const before = recording ? (await observe()).raw : "";
122
+ const history = [];
123
+ const taken = [];
124
+ let handoff;
125
+ if (cache !== undefined && key !== undefined) {
126
+ const entry = await cache.read(key);
127
+ if (entry === undefined) {
128
+ if (cache.mode === "strict") {
129
+ throw new E2EError("REPLAY_MISSING", `goal "${text}" has no recording and the cache is strict`);
130
+ }
131
+ stats.missed += 1;
132
+ }
133
+ else {
134
+ const outcome = await replayEntry({ ...deps, observe: async () => (await observe()).raw }, entry, params);
135
+ if (outcome.ok) {
136
+ stats.replayed += 1;
137
+ cache.replayed(key);
138
+ return { source: "replay", modelCalls: 0, actions: entry.actions.map(performedOf) };
139
+ }
140
+ if (cache.mode === "strict") {
141
+ throw new E2EError("REPLAY_STALE", `goal "${text}" no longer replays (${outcome.reason}): ${outcome.detail}`);
142
+ }
143
+ stats.handedOff += 1;
144
+ handoff = {
145
+ reason: outcome.reason,
146
+ detail: scrub(outcome.detail),
147
+ performed: outcome.performed.length,
148
+ };
149
+ for (const action of outcome.performed) {
150
+ taken.push(action);
151
+ history.push({ action: performedOf(action), ok: true });
152
+ }
153
+ }
154
+ }
155
+ const runGoal = async () => {
156
+ let calls = 0;
157
+ for (;;) {
158
+ if (clock.now() >= deadline) {
159
+ throw new E2EError("STEP_TIMEOUT", `goal "${text}" ran past its time limit`);
160
+ }
161
+ if (calls >= maxCalls) {
162
+ throw new E2EError("STEP_BUDGET_EXCEEDED", `goal "${text}" used its ${maxCalls} model calls`);
163
+ }
164
+ const model = requireModel();
165
+ const seen = await observe();
166
+ calls += 1;
167
+ const raw = await ask(model, {
168
+ kind: "act",
169
+ goal: text,
170
+ ...withContext(deps.context),
171
+ snapshot: seen.shown,
172
+ history,
173
+ secrets,
174
+ modelCallsLeft: maxCalls - calls,
175
+ actionsLeft: maxActions - history.length,
176
+ handoff,
177
+ signal: options.signal ?? NEVER,
178
+ });
179
+ const parsed = parseActDecision(raw);
180
+ if (!parsed.ok) {
181
+ throw new E2EError("MODEL_INVALID", `the model's decision was refused: ${parsed.reason}`);
182
+ }
183
+ const decision = parsed.value;
184
+ if (decision.kind === "fail") {
185
+ throw new E2EError("STEP_FAILED", `goal "${text}" failed: ${decision.reason}`);
186
+ }
187
+ if (decision.kind === "done") {
188
+ if (recording && cache !== undefined && key !== undefined && taken.length > 0) {
189
+ cache.stage(key, entryOf(goal, startRoute, taken, before, seen.raw, normalizeRoute(await engine.url(), deps.origin), params));
190
+ }
191
+ const result = {
192
+ source: handoff === undefined ? "model" : "handoff",
193
+ modelCalls: calls,
194
+ actions: history.filter((entry) => entry.ok).map((entry) => entry.action),
195
+ };
196
+ if (decision.summary !== undefined)
197
+ result.summary = decision.summary;
198
+ return result;
199
+ }
200
+ if (history.length >= maxActions) {
201
+ throw new E2EError("STEP_BUDGET_EXCEEDED", `goal "${text}" used its ${maxActions} actions`);
202
+ }
203
+ const step = await perform(decision, params, recording);
204
+ history.push(step.record);
205
+ if (step.recorded !== undefined)
206
+ taken.push(step.recorded);
207
+ }
208
+ };
209
+ try {
210
+ return await runGoal();
211
+ }
212
+ catch (error) {
213
+ const missingModel = error instanceof E2EError && error.code === "MODEL_MISSING";
214
+ if (handoff !== undefined && !missingModel && cache !== undefined && key !== undefined) {
215
+ await cache.discard(key);
216
+ }
217
+ throw error;
218
+ }
219
+ },
220
+ async assert(statement, options = {}) {
221
+ const model = requireModel();
222
+ const params = options.params ?? {};
223
+ remember(params);
224
+ const { text, secrets } = forModel(statement, params);
225
+ const raw = await ask(model, {
226
+ kind: "assert",
227
+ statement: text,
228
+ ...withContext(deps.context),
229
+ snapshot: await look(),
230
+ secrets,
231
+ signal: options.signal ?? NEVER,
232
+ });
233
+ const verdict = parseVerdict(raw);
234
+ if (!verdict.ok) {
235
+ throw new E2EError("MODEL_INVALID", `the model's verdict was refused: ${verdict.reason}`);
236
+ }
237
+ if (verdict.value.pass === true) {
238
+ await cache?.onCheck(true);
239
+ return;
240
+ }
241
+ const reason = verdict.value.reason === "" ? "" : `: ${verdict.value.reason}`;
242
+ if (verdict.value.pass === "inconclusive") {
243
+ throw new E2EError("ASSERTION_INCONCLUSIVE", `could not tell whether "${text}"${reason}`);
244
+ }
245
+ await cache?.onCheck(false);
246
+ throw new E2EError("ASSERTION_FAILED", `"${text}" does not hold${reason}`);
247
+ },
248
+ async waitFor(statement, options = {}) {
249
+ const model = requireModel();
250
+ const params = options.params ?? {};
251
+ remember(params);
252
+ const { text, secrets } = forModel(statement, params);
253
+ const timeout = options.timeout ?? 30_000;
254
+ const deadline = clock.now() + timeout;
255
+ let seen;
256
+ let lastReason = "";
257
+ for (;;) {
258
+ const snapshot = await look();
259
+ if (snapshot !== seen) {
260
+ seen = snapshot;
261
+ const raw = await ask(model, {
262
+ kind: "waitFor",
263
+ statement: text,
264
+ ...withContext(deps.context),
265
+ snapshot,
266
+ secrets,
267
+ signal: options.signal ?? NEVER,
268
+ });
269
+ const verdict = parseVerdict(raw);
270
+ if (!verdict.ok) {
271
+ throw new E2EError("MODEL_INVALID", `the model's verdict was refused: ${verdict.reason}`);
272
+ }
273
+ if (verdict.value.pass === true) {
274
+ await cache?.onCheck(true);
275
+ return;
276
+ }
277
+ lastReason = verdict.value.reason;
278
+ }
279
+ const remaining = deadline - clock.now();
280
+ if (remaining <= 0) {
281
+ await cache?.onCheck(false);
282
+ const reason = lastReason === "" ? "" : `: ${lastReason}`;
283
+ throw new E2EError("WAIT_TIMEOUT", `"${text}" did not hold within ${timeout} ms${reason}`);
284
+ }
285
+ await clock.sleep(Math.min(deps.pollInterval, remaining));
286
+ }
287
+ },
288
+ async extract(prompt, options) {
289
+ const model = requireModel();
290
+ const params = options.params ?? {};
291
+ remember(params);
292
+ const { text, secrets } = forModel(prompt, params);
293
+ const raw = await ask(model, {
294
+ kind: "extract",
295
+ prompt: text,
296
+ ...withContext(deps.context),
297
+ snapshot: await look(),
298
+ secrets,
299
+ ...(options.jsonSchema === undefined ? {} : { jsonSchema: options.jsonSchema }),
300
+ signal: options.signal ?? NEVER,
301
+ });
302
+ const extraction = parseExtraction(raw);
303
+ if (!extraction.ok) {
304
+ throw new E2EError("MODEL_INVALID", `the model's answer was refused: ${extraction.reason}`);
305
+ }
306
+ const checked = await validateStandard(options.schema, extraction.value);
307
+ if (!checked.ok) {
308
+ const issues = checked.issues.map((issue) => issue.message).join("; ");
309
+ throw new E2EError("EXTRACT_INVALID", `the extracted data does not match the schema: ${issues}`);
310
+ }
311
+ return checked.value;
312
+ },
313
+ };
314
+ }
315
+ //# sourceMappingURL=agent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.js","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2C,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAChG,OAAO,EAA+B,WAAW,EAAuB,MAAM,YAAY,CAAA;AAC1F,OAAO,EAGL,gBAAgB,EAChB,eAAe,EACf,YA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