> ## Documentation Index
> Fetch the complete documentation index at: https://e2e.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# E2EConfig

> Reference for e2e.config.ts (E2EConfig), with every configuration key, its default, its valid range, the run limits, and the environment variables.

`e2e.config.ts` configures the runner: the targets tests run on, the app each
one tests, the agents, and the replay cache. Export an object with
`satisfies E2EConfig` to check its shape and keep its inferred types, or
pass it to [`defineConfig`](#defineconfig). The runner validates the config again at load, including ranges and rules
TypeScript cannot check.
For the options most projects change, see [Configure the project](https://e2e.com/docs/quickstart#configure-the-project).

```ts title="e2e.config.ts"

export default {
  targets: [
    {
      name: 'web',
      engine: web({ browser: 'chromium' }),
      app: { url: process.env.APP_URL ?? 'http://localhost:3000' },
    },
  ],
} satisfies E2EConfig;
```

## Reference

### `defineConfig`

`defineConfig` returns the config it's given. Use it in place of
`satisfies E2EConfig` so options that depend on other options in the same
config are typed.

```ts title="e2e.config.ts"

export default defineConfig({
  services: { email },
  targets: [
    {
      engine: web(),
      app: {
        url: 'http://127.0.0.1:0',
        command: { executable: 'node', args: ['app/server.mjs'], env: ({ services }) => ({ PORT: '{port}', EMAIL_API_URL: services.email.url }) },
      },
    },
  ],
});
```

- As with `satisfies E2EConfig`, the editor completes every key, and an
  unknown top-level key is a type error.
- The config keeps its inferred type, so `typeof config` still works as a
  type argument of [`test.extend`](https://e2e.com/docs/reference/test#test-extend).
- Every rule below is enforced when the runner resolves the config, not when
  `defineConfig` is called.

```ts
export function defineConfig<
  const Config extends E2EConfig<ServiceValues<Services>>,
  Services extends Readonly<Record<string, Service | undefined>> = {},
>(config: Config & { readonly services?: Services } & { readonly [Key in Exclude<keyof Config, keyof E2EConfig>]: never }): Config;
```

### Top level

| Option | Type | Default |
| --- | --- | --- |
| [`projectId`](#projectid) | `string` | `package.json` name |
| [`targets`](#targets) | `Target[]` | required |
| [`tests`](#tests) | `string \| string[]` | `'tests/**/*.e2e.ts'` |
| [`timeout`](#timeout) | `number` | `120000` |
| [`launchTimeout`](#launchtimeout) | `number` | `60000` |
| [`actionTimeout`](#actiontimeout) | `number` | `30000` |
| [`assertionTimeout`](#assertiontimeout) | `number` | `5000` |
| [`toPass`](#topass) | `PassOptions` | [See defaults](#topass) |
| [`cleanupTimeout`](#cleanuptimeout) | `number` | `30000` |
| [`retries`](#retries) | `number` | `0`, `1` in CI |
| [`failOnSkippedFailure`](#failonskippedfailure) | `boolean` | `false` |
| [`maxDuration`](#maxduration) | `number` | - |
| [`workers`](#workers) | `number` | half the cores, `1` in CI |
| [`fullyParallel`](#fullyparallel) | `boolean` | `false` |
| [`reporters`](#reporters) | `(BuiltinReporter \| Reporter)[]` | `['list']` |
| [`output`](#output) | `string` | `'.e2e'` |
| [`artifacts`](#artifacts) | `ArtifactsConfig` | local only |
| [`trace`](#trace) | `RecordingMode` | `'retain-on-failure'` |
| [`video`](#video) | `RecordingMode` | `'off'` |
| [`agents`](#agents) | `Record<string, AgentConfig \| undefined>` | `default`, no model |
| [`filters`](#filters) | `TestFilter[]` | - |
| [`services`](#services) | `Record<string, Service \| undefined>` | - |
| [`cache`](#cache) | `CacheMode \| CacheConfig` | `'read-write'`, `'read-only'` in CI |
| [`credentials`](#credentials) | `Record<string, CredentialConfig \| undefined>` | - |
| [`secrets`](#secrets) | `Record<string, SecretConfig \| undefined>` | - |

The full declaration is [`E2EConfig`](#e2econfig).

- An unknown key at any level is `INVALID_CONFIG`. There is no top-level
  `app` key: each target declares [the app it tests](#the-app-under-test).
- Every numeric value must be a safe integer.
- Every timeout in milliseconds, here and in `app.command` and `agents`, is at
  most 2147483647 (about 24 days). A larger one is `INVALID_CONFIG`.
- An optional key takes a value or is left out. Under
  `exactOptionalPropertyTypes`, `undefined` is a type error, so
  `store: process.env.CACHE_URL && createStore(...)` fails to compile. At
  runtime, `undefined` counts as unset.
- The target's `app` fields also accept `undefined` in their types, so they
  can read `process.env` directly. Spread any other key that depends on the
  environment in only when it has a value:

```ts
export default {
  targets: [{ engine: web(), app: { url: 'http://localhost:3000' } }],
  ...(process.env.CACHE_URL === undefined ? {} : { cache: { store: createStore(process.env.CACHE_URL) } }),
} satisfies E2EConfig;
```

#### `projectId`

A stable id for the project.

```ts
projectId: 'acme-web', // default: the root package.json name
```

- 1 through 256 characters.
- Without a `name` in the root `package.json`, it falls back to
  `unportable-<hash of the project root>`.

#### `tests`

The test file globs, relative to the project root.

```ts
tests: ['tests/**/*.e2e.ts', '!tests/wip/**'], // default: 'tests/**/*.e2e.ts'
```

- A glob takes `*`, `?`, and a whole `**` segment. `?` matches one Unicode
  code point, including an emoji.
- An entry that starts with `!` excludes.
- A file is selected when an including glob matches it and no exclusion does,
  whatever the order of the list.
- Discovery skips `node_modules` and ignores symlinks.
- A dot directory is included only when a glob segment starts with a dot.
- The default selects TypeScript only. For JavaScript tests, set
  `'tests/**/*.e2e.js'` ([JavaScript](#javascript)).

| Throws | When |
| --- | --- |
| `INVALID_CONFIG` | The list holds only exclusions. |
| `INVALID_GLOB` | An entry with no wildcard names a directory (`'!tests/wip'`). A glob names files; the error names the glob to write (`'!tests/wip/**'`). |
| `NO_TESTS` | A file passed to `e2e run` is taken out by an exclusion. The error names that entry. |

#### `timeout`

The deadline of one test attempt, in milliseconds.

```ts
timeout: 180_000, // default: 120000
```

#### `launchTimeout`

The budget for engine init and attempt start, in milliseconds.

```ts
launchTimeout: 90_000, // default: 60000
```

#### `actionTimeout`

The budget of every engine operation, in milliseconds.

```ts
actionTimeout: 10_000, // default: 30000
```

- A targeted agent action is bounded by the smaller of `actionTimeout` and 15 s.
- A call's own `timeout` option wins over it. `timeout: 0` sets no deadline
  for that call; the test timeout, or `cleanupTimeout` in `afterEach`, still
  bounds it.
- `--action-timeout <ms>` overrides it for one run.

#### `assertionTimeout`

The default `expect` deadline, in milliseconds.

```ts
assertionTimeout: 10_000, // default: 5000
```

- A matcher's own `timeout` option wins over it. `timeout: 0` sets no deadline
  for that matcher; the test timeout, or `cleanupTimeout` in `afterEach`,
  still bounds it.
- `--assertion-timeout <ms>` overrides it for one run.

#### `toPass`

The default timeout and pauses for [retrying a block](https://e2e.com/docs/reference/expect#retrying-a-block).
Each call option takes precedence over the corresponding config field.

```ts
toPass: { timeout: 10_000, intervals: [100, 250, 500] },
```

| Option | Type | Default |
| --- | --- | --- |
| `timeout` | `number` | `0` |
| `intervals` | `readonly number[]` | `[100, 250, 500, 1000]` |

- `timeout` is an integer in milliseconds from 0 through 2147483647.
  At `0`, retries are bounded only by the test or hook deadline.
- `intervals` is a non-empty list of positive integers in milliseconds.
  The last pause is repeated.

Invalid values or unknown keys are reported as `INVALID_CONFIG` at config load.

In `beforeAll`, `afterAll`, and worker fixture teardown, the configured
defaults apply to `expect.poll` and `toPass`. Retries are capped by the
hook deadline.

#### `cleanupTimeout`

The budget of each `afterEach` hook, fixture teardown, and engine cleanup, in
milliseconds.

```ts
cleanupTimeout: 60_000, // default: 30000
```

#### `retries`

Retries per test.

```ts
retries: 2, // default: 1 in CI, else 0
```

- 0 through 10.

#### `failOnSkippedFailure`

Fails the run with exit code 1 when a test skips a retry after an earlier
failed attempt.

```ts
failOnSkippedFailure: true, // default: false
```

- The test keeps its `skipped` status and reason.
- Its failures remain in the report, and the CLI shows them under
  `Skipped After Failure` with either setting.
- Clean skips, successful retries, and engine cleanup diagnostics do not
  trigger it.

<Note>
A skip after a failed `expect.soft` needs no option: it
[fails the attempt](https://e2e.com/docs/reference/test#members).
</Note>

#### `maxDuration`

The wall-clock budget for running the tests, in milliseconds.

```ts
export default { targets, maxDuration: 900_000 } satisfies E2EConfig; // default: none
```

- The clock starts when the tests start. The app command's
  [`startupTimeout`](#command) bounds app startup instead.
- Once the time is spent, the running tests end as `interrupted`, and the
  tests not started are skipped with cause `time-limit`. The run records a
  `RUN_TIMEOUT` error and exits 1.
- `--last-failed` runs the interrupted and skipped tests next.
- `--max-duration <ms>` overrides it for one run.
- `e2e explore` ignores it and keeps its own `--timeout`.

#### `workers`

Parallel workers.

```ts
workers: 4, // default: 1 in CI, else half the cores
```

- 1 through 1024.
- Locally the default is `max(1, floor(availableParallelism() / 2))`.
- An engine may cap it lower.
- With more than one worker, each target's files start longest first by the
  [timings history](https://e2e.com/docs/ci#cache-the-timings-history). With `--changed-since`,
  the [likeliest files start first](https://e2e.com/docs/filters#start-the-likeliest-first).

#### `fullyParallel`

Runs the tests of one file at the same time on separate workers, in every
file.

```ts
fullyParallel: true, // default: false
```

- By default, files run in parallel and a file's tests run in order on one
  worker.
- It works as [`parallel: true`](https://e2e.com/docs/reference/test#parallel) on every file.
  That entry has the rules for hooks, serial groups, and `parallel: false`.
- A target's `fullyParallel` wins over it. `--fully-parallel` wins over
  both.
- With one worker, the default in CI, tests still run one at a time. Set
  [`workers`](#workers) above 1.

#### `reporters`

The reporters of the run: built-in ids, and reporter objects such as the
factories in `e2e/reporters`.

```ts
reporters: ['list', 'junit'], // default: ['list']
```

| Value | Does |
| --- | --- |
| `'list'`, `list()` | Terminal progress, failures, and a run summary. |
| `'dot'`, `dot()` | Compact terminal progress, failures, and a run summary. |
| `'line'`, `line()` | One row of terminal progress, each failure as it happens, and a run summary. |
| `'junit'`, `junit()` | Writes `<output>/junit.xml`, or `outputFile`. |
| `'markdown'`, `markdown()` | Writes `<output>/summary.md`, or `outputFile`. |
| `'ctrf'`, `ctrf()` | Writes `<output>/ctrf.json`, or `outputFile`, in the CTRF format. |
| `'json'`, `json()` | Prints the report on stdout. Beside it, `list`, `dot`, or `line` prints to stderr unless given a `stream`. |
| another `Reporter` object | Runs beside the built-in ones. `--reporter` never removes it. |

An id is its factory called with no options. An unknown id is
`INVALID_CONFIG`, and so are two of `list`, `dot`, and `line` together. See [Reporters](https://e2e.com/docs/reference/reporters).

### targets

A target is one named surface tests run on: the app under test and the
[engine](#engine) that drives it. `targets` is required and holds at least
one.

```ts title="e2e.config.ts"
targets: [
  { name: 'chromium', engine: web(), app: { url: 'http://localhost:3000' } },
  { name: 'firefox', engine: web({ browser: 'firefox' }), app: { url: 'http://localhost:3000' } },
],
```

| Option | Type | Default |
| --- | --- | --- |
| [`name`](#name) | `string` | the platform |
| [`platform`](#platform) | `string` | the engine's platform |
| [`engine`](#engine) | `EngineHandle` | - |
| [`app`](#the-app-under-test) | `TargetApp` | - |
| [`trace`](#trace) | `RecordingMode` | the config's `trace` |
| [`video`](#video) | `RecordingMode` | the config's `video` |
| [`fullyParallel`](#fullyparallel) | `boolean` | the config's |

- `{ engine: web(), app: { url } }` is a complete target.
- A test whose `platforms` leaves out the target's platform is skipped for
  it. A `test.setup` that a selected test depends on must be runnable there,
  or selection fails with `COLLECTION_ERROR`.

The full declaration is [`Target`](#target).

#### `name`

The id `--target`, reports, sessions, and artifact paths use.

```ts
name: 'chromium', // default: the platform
```

- ASCII letters, digits, `_`, `-`, and `.`, not only dots (`.` and `..` are
  path segments).
- Unique across targets. Two targets on one platform need names.

#### `platform`

The platform label.

```ts
platform: 'web', // default: inherited from the engine
```

- Required for a target without an engine.
- When the target and its engine both name one, they must agree.

#### `engine`

The engine driving the surface: `web(...)`, `mobile(...)`, or any
`defineEngine` handle.

```ts
engine: web({ browser: 'firefox' }),
```

A target without an engine runs through agent tools and
[`request`](https://e2e.com/docs/reference/request) calls to absolute URLs. A target with `app`
and no engine is `INVALID_CONFIG`.

### The app under test

A target declares the app it tests in `app`; the engine only drives it. A
browser target names the URL it opens, a device target the installed app or
the build it launches.

```ts title="e2e.config.ts"
targets: [
  {
    name: 'web',
    engine: web({ viewport: { width: 1440, height: 900 } }),
    app: {
      url: 'http://localhost:3000',
      command: { executable: 'npm', args: ['run', 'dev'] },
      readyUrl: 'http://localhost:3000/health',
    },
  },
  {
    name: 'ios',
    engine: mobile({ platform: 'ios' }),
    app: {
      bundleId: 'com.example.app',
      appPath: './build/App.app',
      launchArguments: ['-e2e', 'YES'],
      permissions: { camera: 'grant' },
    },
  },
],
```

| Option | Type | Default |
| --- | --- | --- |
| [`url`](#url) | `string` | - |
| [`bundleId`](#bundleid) | `string` | - |
| [`appPath`](#apppath) | `string` | - |
| [`linkBase`](#linkbase) | `string` | - |
| [`identity`](#identity) | `string` | derived from the app |
| [`environment`](#environment) | `'test' \| 'staging' \| 'production'` | `'test'` or `'production'` |
| [`launchArguments`](#launcharguments) | `string[] \| Record<string, LaunchArgumentValue>` | - |
| [`permissions`](#permissions) | `Record<string, AppPermissionState \| undefined> \| 'all'` | - |
| [`command`](#command) | `CommandConfig` | - |
| [`readyUrl`](#readyurl) | `string` | `url` |

Each engine checks the keys at config load, with `INVALID_CONFIG` naming the
target. A target with `app` needs an [engine](#engine).

- A `web()` target needs `app.url` and refuses `bundleId`, `appPath`, and
  `launchArguments`.
- A `mobile()` target needs `app.bundleId` or `app.appPath`. `app.url` on a
  mobile target is not supported yet.
- A `desktop()` target needs `app.bundleId` or `app.appPath` and refuses
  `app.url` and `app.permissions`. With both, it launches the `appPath`
  build, whose bundle id must equal `bundleId`.
- `app.linkBase` needs an engine that opens links, such as `mobile()`.
- An unknown key in `app` or `app.command` fails with a did-you-mean.

<Note>
The old spellings are unknown keys and fail at config load with
`INVALID_CONFIG`: `web({ url })` and the other app options of `web()` and
`mobile()`, `mobile({ app })` (now `app.bundleId`), an app key directly on the
target, and a top-level `app` or `url`.
</Note>

#### `url`

The base URL: `app.open()` opens it and relative navigation resolves against
it.

```ts
url: 'http://localhost:3000',
```

- WHATWG-normalized; no userinfo, query, or fragment.
- A missing scheme becomes `https://`, or `http://` for a loopback host.
- Plain HTTP is accepted for loopback hosts only.
- A `file:` URL opens one file on this machine in a locally launched
  browser: see [a file as the app](#a-file-as-the-app).
- Port `0` on `127.0.0.1` or `[::1]` asks for a [free port](#free-ports).
- Its origin scopes engine request credentials, and its site scopes observed
  frames: see [the app's site](#the-apps-site).

| Throws | When |
| --- | --- |
| `INVALID_APP_URL` | Port `0` on any host other than `127.0.0.1` or `[::1]`, `localhost` included. |
| `INVALID_APP_URL` | A `file:` URL with a host, or one that names a directory. |
| `INVALID_CONFIG` | A port-0 `url` with nothing to start on it (no `app.command`). |
| `INVALID_CONFIG` | A `file:` URL on a `web()` target with a browser provider, `connect`, `headers`, or `basicAuth`, or on an engine that does not declare `fileApps`. |

#### `bundleId`

The installed app a device launches: a bundle id, an Android package name, or
a display name the device resolves (`Settings`). On a `desktop()` target, the
bundle id or name of an installed macOS app.

```ts
bundleId: 'com.example.app',
```

A link is `INVALID_CONFIG`: a test opens one with `device.openLink`.

#### `appPath`

The build the suite runs against, an iOS `.app` bundle or an Android `.apk`,
resolved against the project root. On a `desktop()` target, a macOS `.app`
bundle.

```ts
appPath: './build/App.app',
```

Without `bundleId`, the app it installs is the one launched. See
[the device engine](https://e2e.com/docs/reference/mobile#engine) for when it is installed.

#### `linkBase`

Where `app.open(path)` opens on a device target: the path joins the link base,
and the link opens in the pinned app.

```ts
linkBase: 'https://shop.example.com', // app.open('/orders/42') opens https://shop.example.com/orders/42
linkBase: 'shopapp://', // app.open('/orders/42') opens shopapp://orders/42
```

- One slash joins the base and the path; none follows a bare scheme
  (`shopapp://`).
- An absolute link passed to `app.open` opens as given, a custom app scheme
  included; `file:`, `data:`, `javascript:`, `view-source:`, `blob:`, and
  `filesystem:` links are `POLICY_DENIED`.
- Without `linkBase`, `app.open()` on a device launches the app and takes no
  path (`APP_URL_REQUIRED`).

| Throws | When |
| --- | --- |
| `INVALID_CONFIG` | The engine opens no links (a `web()` target), the value is not an absolute URL or a scheme, it has a query or fragment (an empty `?` or `#` included), it has leading or trailing whitespace, or it names `file:`, `data:`, `javascript:`, `view-source:`, `blob:`, or `filesystem:`. |
| `POLICY_DENIED` | `app.open` got an absolute link with one of those schemes. |

#### `identity`

The stable identity keying replay cache and session entries.

```ts
identity: 'checkout-web', // default: the URL's origin and base path, else bundleId, else appPath
```

Set a stable value to reuse entries across preview URLs or versioned build
paths. With a [free port](#free-ports), the default derives from the declared
`:0`, not the port the run picks.

<Note>
Different apps must have different identities. A shared identity replays
recordings across them.
</Note>

#### `environment`

Labels the target in the report and joins the cache and session identity
digest. It never gates a run.

```ts
environment: 'staging', // default: 'test' for a local host or no URL, else 'production'
```

- `'test'`, `'staging'`, or `'production'`.
- A local host is a loopback, `.localhost`, or `.test` host.

#### `launchArguments`

Arguments every fresh launch passes the app: `app.open()`, `app.restart()`,
and `app.clearState()`. Give a list of strings, the arguments themselves, or
an object of argument name to value. On iOS and macOS an entry becomes
`-name value`. On Android it becomes an `am start` extra of the value's type.

```ts
launchArguments: ['-e2e', 'YES'],
```

```ts
launchArguments: { AppleLanguages: ['fr'], AppleLocale: 'fr_FR', e2e: true },
```

```ts
type LaunchArgumentValue = string | number | boolean | readonly string[];
type LaunchArguments = readonly string[] | Readonly<Record<string, LaunchArgumentValue | undefined>>;
```

- An object value is a string, a finite number below 2^53 in magnitude, a
  boolean, or a list of strings. A name has no leading dash and no control
  characters. Spaces inside a name are fine, as in
  `'NSSplitView Subview Frames Main'`; a space at either end and any other
  whitespace are not. Nothing holds a NUL character. A
  value read from the environment may be `undefined`: that entry is left out.
- The table under
  [Launch arguments and permissions](https://e2e.com/docs/reference/mobile#launch-arguments-and-permissions)
  shows each value type on iOS and Android.
- Arguments that select a build mode change what the app is. Give each mode
  its own `identity`.

| Throws | When |
| --- | --- |
| `INVALID_CONFIG` | A list item that is not a string, an empty name, or a name or value that breaks the rules above. The engine adds its own rules: see [the mobile reference](https://e2e.com/docs/reference/mobile#launch-arguments-and-permissions). |

#### `permissions`

Permissions the app holds, by name.

```ts
permissions: { camera: 'grant' },
```

Each is `'grant'`, `'deny'`, or `'reset'`. An `undefined` value is the
permission left out. `permissions: 'all'` grants every permission the
target's engine can grant.

- A `mobile()` target sets each one before every fresh launch. See
  [permissions](https://e2e.com/docs/reference/mobile#engine).
- A `web()` target takes `'grant'` only and grants it to every page of the
  attempt, on any origin. Headless Chromium refuses a permission left out. See
  [Granting browser permissions](https://e2e.com/docs/web#granting-browser-permissions). `'all'`
  grants each name in the table below for its browser.

| Browser | Names |
| --- | --- |
| `chromium` | `accelerometer`, `ambient-light-sensor`, `background-sync`, `camera`, `clipboard-read`, `clipboard-write`, `geolocation`, `gyroscope`, `local-fonts`, `local-network-access`, `magnetometer`, `microphone`, `midi`, `midi-sysex`, `notifications`, `payment-handler`, `screen-wake-lock`, `storage-access` |
| `firefox` | `geolocation`, `local-network-access`, `notifications`, `persistent-storage`, `push`, `screen-wake-lock` |
| `webkit` | `camera`, `clipboard-read`, `geolocation`, `microphone`, `notifications`, `screen-wake-lock` |

A browser provider or `connect` takes the `chromium` names, Lightpanda
included.

#### `command`

The process the runner starts before the first test and stops on every exit
path: a dev server, or Metro for a debug build.

```ts
command: {
  executable: 'pnpm',
  args: ['dev', '--port', '{port}'],
  inheritEnv: ['STRIPE_*'],
  startupTimeout: 120_000, // default: 60000
},
```

| Field | Example | Default |
| --- | --- | --- |
| `executable` | `'npm'` | required |
| `args` | `['run', 'dev']` | none |
| `cwd` | `'apps/web'` | the project root |
| `env` | `{ PORT: '{port}' }` | none |
| `inheritEnv` | `['STRIPE_*']` | none |
| `startupTimeout` | `120_000` | `60000` |
| `shutdownTimeout` | `5_000` | `10000` |
| `log` | `'.e2e/logs/app.log'` | output discarded |
| `reuseExisting` | `true` | `false` |

- `executable` is resolved with `PATH` and never shell-interpreted.
- `args` pass verbatim. `{port}` in `args` and `env` values expands to the
  port of `url`.
- `cwd` resolves from the project root.
- The child inherits only `PATH`, `HOME`, the temp-directory variables, the
  variables `inheritEnv` matches, and `command.env`. Pass what the app needs
  explicitly.
- `inheritEnv` takes exact names or prefixes ending in `*` (`'STRIPE_*'`). It
  copies a variable only when it is set. `env` wins over an inherited value.
- Every `args` entry and `env` value is a string. An `undefined` `env` value
  is dropped.
- `env` can be a sync or async function receiving `{ services }`, the same
  [`services`](#services) values available in tests (like `env: ({ services })
  => ({ EMAIL_API_URL: services.email.url })`). It is called after services
  start and before any app command starts: once per run, once per `e2e mcp`
  session, once per `openHost` host, and once for all the targets that share
  it. Its returned values are treated like an `env` object's.
- With `reuseExisting` and a process already running, the function still
  runs, but that process doesn't get the returned variables, and a notice is
  printed. Give the services the app uses fixed ports and start the app with
  the same values.
- `startupTimeout` applies to the `env` function and then to the
  [`readyUrl`](#readyurl) probe, the full time each.
- `shutdownTimeout` is the grace period before force-kill.
- In `e2e run`, a command that exits after readiness fails the run with `APP_UNREACHABLE` if a dependent target has unfinished work.
  This includes exit code 0 and termination by a signal.
  The runner interrupts active tests and skips queued tests only for those targets.
  Targets that have finished their work ignore the exit.
- `log` receives the process's stdout and stderr, appended, resolved from the
  project root. It must stay inside the project root.
- With a `log`, startup timeouts and command exits quote the lines appended
  since the command started. A log of up to 40 lines inside 8 KiB is quoted
  whole. Otherwise the quote keeps up to 20 lines from each end, with
  `[startup output omitted]` between them, and for a log past 8 KiB those
  lines come from its first and last 4 KiB.
  An empty or unreadable log produces `no output in <log>`.
  A shared log can include lines from other processes.
  The quote replaces `command.env` and `inheritEnv` values of at least 4 characters with `<secret:NAME>` markers.
  A command that fails to spawn reports the spawn error instead.
- `reuseExisting`: when the readiness URL already answers before the command
  starts, the runner uses that process. It starts nothing and stops nothing.
  CI ignores it, with a notice, and always starts the command.
- Targets declaring the same command share one process, probed at the first
  declaring target's `readyUrl`. Commands with an `env` function are compared
  by the variables the function returns.
- The runner never terminates a process it did not start.

| Throws | When |
| --- | --- |
| `INVALID_CONFIG` | A bare `'*'` in `inheritEnv`. |
| `INVALID_CONFIG` | An `args` entry or `env` value that is not a string, a number or a `secrets.get()` handle included. |
| `INVALID_CONFIG` | An `env` function that throws an error without its own error code, or returns anything other than an object of strings and `undefined` values. |
| `INVALID_CONFIG` | `reuseExisting` on an app whose `url` asks for port 0: a process already running cannot serve the port the run assigns. |
| `APP_URL_REQUIRED` | An `app.command` with neither `app.url` nor `app.readyUrl`, at config load. |
| `APP_ALREADY_RUNNING` | Without `reuseExisting`, a `readyUrl` that already answers. |
| `APP_UNREACHABLE` | The command fails to spawn, its `log` cannot be opened, `startupTimeout` expires, the command exits before readiness, it exits unexpectedly during `e2e run`, or an `env` function doesn't return within `startupTimeout`. |

<Warning>
`log` holds the raw, unredacted output. Keep it in an ignored directory.
</Warning>

The full declaration is [`CommandConfig`](#commandconfig).

#### `readyUrl`

The URL polled until `command` is ready, at a 200-499 status.

```ts
readyUrl: 'http://localhost:3000/health', // default: url
```

- Required without a `url`.
- `{port}` in it is the port of `url`.

#### The app's site

A test or the agent may open any http(s) URL, and `about:blank`. Every other
scheme (`file:`, `data:`, `javascript:`, `view-source:`, `blob:`) is
`POLICY_DENIED`. The site of `url` is its registrable domain:
`app.example.com` and `auth.example.com` are one site. Child frames off the
site stay out of observations.

#### A file as the app

```ts

app: { url: pathToFileURL('dist/index.html').href },
```

- Navigation takes a `file:` URL only for a file in that file's directory or
  below it: `app.open('pages/about.html')`. A file outside it and any
  directory are `POLICY_DENIED`, with symbolic links resolved. A path that
  starts with `/` is the disk's root, so write it relative.
- That directory is what the agent may read. Keep the file in a folder
  that holds only the app, not in a project root beside `.env`. See
  [Navigation](https://e2e.com/docs/reference/security#navigation).
- A file has no site and no origin. Frames that load another document stay
  out of observations, and the `environment` defaults to `'test'`.
- The agent works from the tree alone: it is sent no screenshot.
  `agent.assert` with
  `vision: true` judges from the tree, `vision: 'only'` is `POLICY_DENIED`,
  and neither `agent.assert` nor a failure keeps a screenshot.
- A `command` beside it needs a `readyUrl`, since a file answers no poll.
- A `web()` target with a browser provider or `connect` refuses it. An
  engine opens a file app only when it
  [declares it](https://e2e.com/docs/reference/engine#capabilities).
- An `agent.act` recording is keyed by the file's absolute path, so it
  replays only where the file sits at that path.

The browser engine's [`headers`](https://e2e.com/docs/reference/web#headers) and
[`basicAuth`](https://e2e.com/docs/reference/web#basicauth) are scoped tighter, to the origin of
`url` (scheme, host, and port, the run's free port included) plus the
origins you list. See
[request credentials](https://e2e.com/docs/reference/security#request-credentials).

#### Free ports

A `url` on a literal loopback address with port `0` (`http://127.0.0.1:0`,
`http://[::1]:0`) asks the run for a free TCP port. The port replaces the `0`
in the base URL, the default `readyUrl`, and the report. The command must
take the port through `{port}` in `args` or `env`.

```ts title="e2e.config.ts"
engine: web(),
app: {
  url: 'http://127.0.0.1:0',
  command: { executable: 'pnpm', args: ['dev', '--port', '{port}'], env: { PORT: '{port}' } },
},
```

- `localhost:0` is [`INVALID_APP_URL`](#url). Write the address the command
  will bind.
- Each target asking for port `0` gets its own port and its own process. Two
  targets that declare the same command on a fixed port share one.
- Tests read the allocated URL from [`app.baseUrl`](https://e2e.com/docs/reference/app).

### output

The directory everything a run writes about itself goes under, resolved from
the project root.

```ts
output: 'test-results/e2e', // default: '.e2e'
```

`--output <dir>` on [`e2e run`](https://e2e.com/docs/reference/cli#e2e-run) and `e2e explore`
overrides it for one run.

| Path under the output | What |
| --- | --- |
| `report.json` | The canonical report; `--last-failed` reads the one here |
| `junit.xml`, `summary.md`, `ctrf.json` | The `junit`, `markdown`, and `ctrf` reporters' files |
| `ai-trace.json` | `--ai-trace` |
| `timings.json` | How long each file took, which sets the [start order](#workers); see [Cache the timings history](https://e2e.com/docs/ci#cache-the-timings-history) |
| `report-with-reruns.json` | Written by a `--last-failed` rerun: the first run and every rerun since as one report, with the same run id as `report.json`. A run without `--last-failed` removes it |
| `results/` | One directory per test: its [trace page](https://e2e.com/docs/debugging#traces), `trace.md`, when the [`trace`](#trace) mode keeps one, and its screenshots, videos, downloads, and logs, one `attempt-<n>/` per attempt. Cleared once a run's tests start. A `--last-failed` rerun keeps the files the runs before it name and writes its own attempts under each test's `rerun-<n>/` |
| `sessions/` | The run's encrypted `test.setup` sessions, deleted when it ends |
| `videos/<session>/` | [`e2e mcp`](https://e2e.com/docs/reference/mcp#recording) session recordings |

- A run that stops before its tests start writes nothing here: `NO_TESTS`, a
  collection error, `UNSUPPORTED_ARTIFACT`, `NO_LAST_RUN`, an app command
  that fails to start, or an interrupt. The previous run's `report.json`,
  `ai-trace.json`, and `results/` stay as they were, so `--last-failed` still
  reads the last run that executed.
- An `e2e mcp` session writes its attempt's artifacts under `results/mcp/` and
  never clears it.
- The replay cache stays in [`cache.dir`](#dir) whatever `output` says.
- `e2e init` writes `.gitignore` entries for the default `.e2e/` paths only.
  With `output` set elsewhere, add that directory to `.gitignore` yourself.

The config load fails with `INVALID_CONFIG`, naming the reason, when the
directory:

- is the project root, or outside it;
- is a file, or a path under one (a missing directory is created);
- is the cache directory (`cache.dir`, `--cache-dir`, or `E2E_CACHE_DIR`) or
  inside it, or would hold it under `results/`, `sessions/`, or `videos/`;
- holds a directory a `tests` glob scans (`output: 'tests'` with the default
  `tests/**/*.e2e.ts`).

Paths are compared with symlinks resolved, including a symlink whose target
does not exist yet.

<Note>
The removed `--artifacts <dir>` flag fails with the `--output` it maps to.
</Note>

### artifacts

`artifacts` says where artifacts go, not which are made. `{ store }` hands
every artifact to a host store as it is produced; without one, files stay
local only.

```ts
artifacts: {
  store: {
    async put(artifact) {
      const key = await bucket.upload(artifact.path, artifact.bytes);
      return { ref: key };
    },
  },
},
```

| Member | Returns |
| --- | --- |
| [`store.put`](#put) | `Promise<{ ref }>` |
| [`store.putLink`](#putlink) | `Promise<{ ref }>` |

- [`trace` and `video`](#recording) choose the recordings. The runner
  captures a failure's screenshot and screen text whenever the engine can.
- Each worker constructs its own store from the config module.
- A failed `put` or `putLink` never fails the run.

The removed forms (a kinds list, `artifacts.kinds`, `artifacts.trace`, and
`artifacts.video`) fail with `INVALID_CONFIG` naming the `trace` mode or
`video` option that replaced them.

The declarations are under [`ArtifactsConfig`](#artifactsconfig).

#### `put`

Receives every artifact once it is complete on disk and returns a reference
the report records as `ref` beside the local path.

```ts
async put(artifact) {
  return { ref: await bucket.upload(artifact.path, artifact.bytes) };
},
```

- Required on every store.
- `artifact.redaction` is the report's label. A store that exports only what
  the runner vouches for keeps back an `incomplete` artifact: a video or a
  download the runner did not rewrite.

#### `putLink`

Receives a video a hosted service keeps (a
[provider's own recording](#what-a-video-writes)). Such a video is a link with
no bytes, so `put` never receives it.

```ts
async putLink(link) {
  return { ref: await index.record(link.url, link.attemptId) };
},
```

- Optional. Called for each link once the attempt stopped the recording.
- Its `ref` lands on the report's artifact beside `url`.
- A passed attempt's link under `retain-on-failure` is never handed over,
  since the report leaves it out too.

#### What a run captures

Each test gets one directory under [`<output>`](#output)`/results/`, with
its trace page and one `attempt-<n>` per attempt. A serial group's tests
share one directory.

```text
.e2e/results/todos-adds-a-todo-1a2b3c4d5e6f7a8b/trace.md
.e2e/results/todos-adds-a-todo-1a2b3c4d5e6f7a8b/attempt-1/screen-at-failure.txt
.e2e/results/todos-adds-a-todo-1a2b3c4d5e6f7a8b/attempt-1/screenshots/001-failure.png
```

| Artifact | When |
| --- | --- |
| Screenshots | A failed attempt captures one when the engine can. The built-in `agent.assert` captures one after either verdict, unless `screenshot: false`. `app.screenshot('label')` captures one on request, and `locator.screenshot('label')` one element. They mask secure fields only. See [screenshots after a secret fill](https://e2e.com/docs/reference/security#screenshots-after-a-secret-fill). |
| Downloads | Files saved through `browser.waitForDownload`, kind `download`, as the app served them. [Downloads](https://e2e.com/docs/reference/security#downloads) says when the runner masks secrets in them. |
| Videos | When a [`video`](#video) mode records the attempt. Videos mask nothing. See [where redaction stops](https://e2e.com/docs/reference/security#where-redaction-stops). |
| Agent transcripts | With [`--debug`](https://e2e.com/docs/reference/cli#debug-output), one per planned agent step. |

### Recording

`trace` and `video` choose what is recorded, with one set of modes.

```ts
trace: 'on',
video: 'retain-on-failure',
targets: [
  { name: 'chromium', engine: web(), app: { url } },
  { name: 'firefox', engine: web({ browser: 'firefox' }), app: { url }, video: 'on-first-retry' },
],
```

| Option | Type | Default |
| --- | --- | --- |
| [`trace`](#trace) | `RecordingMode` | `'retain-on-failure'` |
| [`video`](#video) | `RecordingMode` | `'off'` |

```ts
export type RecordingMode = 'off' | 'on' | 'retain-on-failure' | 'on-first-retry' | 'on-all-retries';
```

| Mode | Trace page | Video |
| --- | --- | --- |
| `off` | none | none |
| `on` | every test, passing ones included | every attempt |
| `retain-on-failure` | each failed, timed-out, interrupted, or flaky test | every attempt, keeping those that did not pass |
| `on-first-retry` | each test whose first retry ran | the first retry only, the second attempt |
| `on-all-retries` | each test that was retried | every attempt after the first |

Under a retry mode, a test with `retries: 0` records nothing, and neither
does a failure the runner does not retry, such as `LAUNCH_TIMEOUT`. The run
prints a notice before the tests start when such a test will run.

Four places set a mode, lowest first. Each replaces the one before it, for
`trace` and `video` alike:

1. `trace` or `video` at the top of the config.
2. A target's `trace` or `video`.
3. `--trace [mode]` or `--video [mode]` on [`e2e run`](https://e2e.com/docs/reference/cli#e2e-run),
   over the config and every target. A bare flag is `on`.
4. A test's or describe's own [`trace` or `video` option](https://e2e.com/docs/reference/test#options),
   innermost wins: `test('checkout', { video: 'on' }, ...)`.

- A serial group records as one unit, so its members cannot set `trace` or
  `video` (a `COLLECTION_ERROR`, like `retries`). The value on the serial
  `describe`, or on a group around it, applies to every member.
- `e2e explore` is one attempt and uses the target's mode, `--trace` and
  `--video` included, so a retry mode records nothing there.
- An `e2e mcp` session writes no trace and never records video from the
  configured mode. Its recordings are the ones `start_recording` and
  `stop_recording` make.
- Changing `trace` or `video`, at the top or on a target, never invalidates
  [cached replays](https://e2e.com/docs/cache#what-must-match).

<Note>
The old trace spellings fail with `INVALID_CONFIG` naming the mode they
meant, wherever a mode goes (the config, a target, a test, `--trace`):
`'all'` and `{ record: 'all' }` are `'on'`, and `'retries'` and `{ record:
'retries' }` are `'on-all-retries'`.
</Note>

#### `trace`

Which tests keep a trace page.

```ts
trace: 'on', // default: 'retain-on-failure'
```

- The default is the same locally and in CI.
- A trace page is markdown, `trace.md` in the
  [test's directory](#what-a-run-captures) under `<output>/results/`.
- It works on every engine. [What a trace page holds](#what-a-trace-page-holds)
  lists its parts, and [Debugging](https://e2e.com/docs/debugging#traces) shows one.

#### `video`

Which attempts record a video.

```ts
video: 'retain-on-failure', // default: 'off'
```

- Where the mode is set decides what an engine that cannot record does. See
  [Engines that cannot record](#engines-that-cannot-record).
- A video masks nothing, secrets included. See
  [What a video writes](#what-a-video-writes).

#### Engines that cannot record

Where a `video` mode was set decides what an engine that cannot record video
does, before any test starts:

- Set at the top of the config or with `--video`: the mode applies to the
  targets whose engine can record it. The run prints one notice at plan time
  naming the targets that cannot, and runs them without video.
- Set on a target, or on a test that will run on that target: the mode is
  required. A target whose engine cannot record it fails the run with
  `UNSUPPORTED_ARTIFACT`, naming the target and, for a test's, the test.

Only a mode that records on some attempt counts: a run whose tests all
resolve to `off`, or to a retry mode with `retries: 0`, asks nothing of the
engine.

#### What a video writes

| Recorder | Files under the attempt's artifact directory |
| --- | --- |
| Browser engine, Playwright screencast | `video/video.webm`, one segment per page the attempt showed, later ones as `video/video-part<n>.webm`. [`web({ screencast })`](https://e2e.com/docs/reference/web#options) sets the frame size and quality |
| Mobile engine, agent-device | `video/video.mp4` |
| A provider's own recording ([`BrowserProvider.record`](https://e2e.com/docs/reference/web#recording-on-the-provider), [`DeviceProvider.record`](https://e2e.com/docs/mobile#hosted-devices)) | the file the provider wrote, as `video/<file>`: Kernel's is `video/replay.mp4`. Or a link to a recording the service keeps, recorded with `url` in place of `path`; the runner never downloads it |

- Each segment carries `startedAt`, so `step.startedAt - artifact.startedAt`
  is a step's offset into it.
- The failure recap prints the recording's path, or its URL when a hosted
  browser keeps it.
- A recording masks nothing and is recorded with `redaction: 'incomplete'`.

<Note>
Under `retain-on-failure` a link is left out of the report of a passed
attempt, but the service still holds the recording.
</Note>

#### What a trace page holds

After the browser or device the test ran on, a trace page has four parts.

| Part | Holds |
| --- | --- |
| Steps | The node an action landed on, the values an assertion read while it waited, the replay cache's decision, what the app logged, where the page went, and how the screen changed since the step before |
| App log | Console output, uncaught exceptions, failed requests, and 4xx and 5xx responses, each with its step: up to 50 lines, errors and warnings first. An attempt keeps at most 200 errors and warnings and 100 other lines |
| The agent's last turns | The agent's most recent model turns |
| Screen at failure | The screenshot and the semantic tree, captured in at most 5 s. An app that doesn't answer in time gets no screen section |

- Open the page in an editor's markdown preview so its links work.
  [Debugging a run](https://e2e.com/docs/debugging#traces) shows an example page.
- `screen: unchanged` after an action means the action had no visible
  effect.
- On web, a step's screen is the one an action left. On a device, it's the
  screen the step acted on.

### agents

Named agents, each one plain object: the built-in agent's options, or
`{ executor }` for a custom brain.

```ts title="e2e.config.ts"

export default {
  targets: [{ engine: web(), app: { url: 'http://localhost:3000' } }],
  agents: {
    default: { model: gateway('openai/gpt-6-luna-fast') },
    ux: { model: gateway('openai/gpt-6-luna-fast'), system: 'Check labels, contrast, and keyboard access.' },
    thorough: { model: gateway('anthropic/claude-opus-5'), context: 'Verify every claim on screen.' },
    buyer: {
      model: gateway('openai/gpt-6-luna-fast'),
      system: 'You are a first-time buyer.',
      context: 'Plans are called tiers. Billing lives under Settings.',
      maxSteps: 40,
    },
    house: { executor: houseBrain, model: gateway('openai/gpt-6-luna-fast'), maxModelCalls: 10 },
  },
} satisfies E2EConfig;
```

| Option | Type | Default |
| --- | --- | --- |
| [`model`](#model) | `ModelInstance` | - |
| [`judge`](#judge) | `ModelInstance` | `model` |
| [`context`](#context) | `string` | - |
| [`system`](#system) | `string` | - |
| [`tools`](#tools) | `Record<string, AgentTool \| undefined>` | - |
| [`executor`](#executor) | `StepExecutor` | the built-in agent |
| [`maxSteps`](#maxsteps) | `number` | `25` |
| [`maxModelCalls`](#maxmodelcalls) | `number` | `25` |
| [`judgmentTimeout`](#judgmenttimeout) | `number` | `30000` |
| [`maxObservationBytes`](#maxobservationbytes) | `number` | `262144` |
| [`maxInputTokens`](#maxinputtokens) | `number` | `64000` |
| [`maxContextBytes`](#maxcontextbytes) | `number` | `16384` |
| [`providerOptions`](#provideroptions) | `Record<string, ProviderOptions[string] \| undefined>` | - |

- Tests use the `default` agent unless you select another: with
  `e2e run --agent <name>`, a test or group option, or an `agent.*` call. A
  test with `{ agent: ['buyer', 'admin'] }` runs once for each agent.
- `default` exists even when the config declares no agents, but has no model.
- Agents do not inherit from each other. A key left out of an entry takes the
  built-in default: `ux` above gets no `context` from `default`.
- An entry set to `undefined` is the agent left out.
- Each worker constructs its own agents from this config module.
- Names may contain ASCII letters, numbers, `_`, `-`, or `.`, and are never
  only dots: a name is an artifact path segment.

| Throws | When |
| --- | --- |
| `INVALID_CONFIG` | An unknown agent name on the `--agent` flag. |
| `COLLECTION_ERROR` | An unknown agent name on a test or group. |
| `INVALID_ARGUMENT` | An unknown agent name on a call. |

See [Agents and personas](https://e2e.com/docs/agents). The declarations are under
[`AgentConfig`](#agentconfig).

#### `model`

An AI SDK model instance. There is no implicit default.

```ts
model: gateway('openai/gpt-6-luna-fast'),
```

Construct the model in your config with an AI SDK provider. Every provider
that supports tool calls works, see
[AI SDK providers](https://e2e.com/docs/models#ai-sdk-providers). For subscription sign-in, use
the [`e2e/oauth/*` models](https://e2e.com/docs/subscriptions).

| Gateway | Constructor | Package | Reads |
| --- | --- | --- | --- |
| [Vercel AI Gateway](https://vercel.com/docs/ai-gateway) | `gateway('openai/gpt-6-luna-fast')` | `ai` | `AI_GATEWAY_API_KEY`, or a Vercel OIDC token without it |
| [OpenRouter](https://openrouter.ai/models) | `openrouter('openai/gpt-6-luna-fast')` | `@openrouter/ai-sdk-provider` | `OPENROUTER_API_KEY` |
| Any OpenAI-compatible endpoint | `createOpenAICompatible({ name, baseURL, apiKey? }).chatModel('llama3.2')` | `@ai-sdk/openai-compatible` | `apiKey`, when the endpoint needs one |
| A provider directly | `openai('gpt-6-luna')`, `anthropic(...)`, ... | `@ai-sdk/openai`, `@ai-sdk/anthropic`, ... | the provider's own variable |

- Reports record `provider` and `modelId` per step.
- A config whose digest differs between the runner and a worker is
  `CONFIG_NOT_DETERMINISTIC`.
- A string is `INVALID_CONFIG` naming the constructor to write.
- An agent never falls back to `default`'s model. See
  [Resolution order](#resolution-order).

See [Models](https://e2e.com/docs/models) and [`ModelInstance`](#modelinstance).

#### `judge`

The model for non-exploring `assert`, `waitFor`, and `extract`. Built-in
exploring assertions use `agents.<name>.model`, even when `judge` is set.

```ts
judge: gateway('anthropic/claude-opus-5'), // default: model
```

- Judgments allow 8192 output tokens per call.
- A judgment sees the instruction, its params, the agent's context, and the current screen with its location.

See [A judge of its own](https://e2e.com/docs/models#a-judge-of-its-own).

#### `context`

What the app calls things, told to every model call this agent makes, act
turns and judgments alike.

```ts
context: 'Plans are called tiers. Billing lives under Settings.',
```

At most [`maxContextBytes`](#maxcontextbytes).

#### `system`

How the acting agent should work, appended to the built-in rules. Only the
act loop reads it.

```ts
system: 'You are a first-time buyer.',
```

With `executor` it is `INVALID_CONFIG`: the executor brings its own prompt.

#### `tools`

Project tools from `defineTool` (`e2e/agent`), offered beside the built-in
toolset.

```ts
tools: { lookupOrder },
```

`tools` beside `executor` is `INVALID_CONFIG`: the executor brings its own
tools. An entry set to `undefined` is the tool left out.

#### `executor`

A custom brain `agent.act()` dispatches to instead of the built-in agent.

```ts
house: { executor: houseBrain, model: gateway('openai/gpt-6-luna-fast'), maxModelCalls: 10 },
```

- `model`, `judge`, `context`, and the budgets still apply; judgments need a
  model unless the executor has `answer`. [`system`](#system) and [`tools`](#tools) beside it are
  `INVALID_CONFIG`.
- `maxModelCalls` bounds the model turns of one step.
- A `model` or `judge` that differs from the one the executor brought is
  `INVALID_CONFIG`.

See [Custom executors](https://e2e.com/docs/executors).

#### `maxSteps`

Committed actions per agent call.

```ts
maxSteps: 40, // default: 25
```

1 through 100.

#### `maxModelCalls`

Model requests per agent call.

```ts
maxModelCalls: 10, // default: 25
```

1 through 100.

#### `judgmentTimeout`

The deadline of one `assert`, `waitFor`, or `extract` call, in milliseconds.

```ts
judgmentTimeout: 60_000, // default: 30000
```

Raise it for a slow judge. Engine operations keep `actionTimeout`.

#### `maxObservationBytes`

The observation payload ceiling for act turns and judgments.

```ts
maxObservationBytes: 524_288, // default: 262144
```

1024 through 16777216.

#### `maxInputTokens`

Input tokens per model request.

```ts
maxInputTokens: 128_000, // default: 64000
```

- 1 through 1000000.
- A dense screen is cut to fit under it.

#### `maxContextBytes`

Bytes [`context`](#context) may take. A longer one fails the config load.

```ts
maxContextBytes: 32_768, // default: 16384
```

- 1024 through 65536.
- The context counts against [`maxInputTokens`](#maxinputtokens) byte for
  byte and leaves the screen less room, so raise both together. A context
  that leaves the screen no room fails the config load.

#### `providerOptions`

Provider options every model call carries, such as a reasoning effort.

```ts
providerOptions: { openai: { reasoningEffort: 'low' } },
```

OpenAI and Azure OpenAI Responses calls also carry `store: false` and a prompt
cache key unless set here. An entry set to `undefined` is the provider left
out.

#### Removed options

An unknown key (the error names the nearest known one), a removed key, or a
value in an old shape fails the config load with `INVALID_CONFIG`:

| Written | Now |
| --- | --- |
| a bare `StepExecutor` as the entry | `{ executor }` |
| `timeout` | `judgmentTimeout` |
| `maxTurns` (on the entry or `createToolLoopExecutor`) | `maxModelCalls` |
| top-level `limits.maxModelTokensPerCall` | `maxInputTokens` on each agent |
| top-level `limits.maxAgentContextBytes` | `maxContextBytes` on each agent |
| top-level `limits.maxLedgerBytes`, `maxEventsPerStep` | removed; the runner fixes them at 8192 bytes and 1000 events |

### filters

[Test filters](https://e2e.com/docs/filters) that leave out the tests a change can't affect,
applied in order when the run passes `--changed-since`. Each judges the
tests the one before it kept.

```ts title="e2e.config.ts"

export default {
  targets: [{ engine: web(), app: { url: 'http://localhost:3000' } }],
  filters: [decisionFilter({ model: gateway.decisionModel('typesafe-ai/jev') })],
} satisfies E2EConfig;
```

Which tests always run is on
[Test filters](https://e2e.com/docs/filters#what-always-runs). A `name` follows the target name
rules, is at most 256 characters, and is unique among `filters`.

| Throws | When |
| --- | --- |
| `INVALID_CONFIG` | A bad `name`, an item that isn't `{ name, filter }`, or a bare function such as `decisionFilter` in place of `decisionFilter({ model })`. |

The declarations are under [`TestFilter`](#testfilter), exported from `e2e`.

### services

Dependencies of the app under test (like an email API or a database), keyed by
name. Each entry is defined with `defineService`:

```ts title="e2e.config.ts"

const inbox = defineService({
  startupTimeout: 180_000, // default: 60000
  async *start({ signal }) {
    const server = await startInbox({ signal });

    yield { url: server.url };

    await server.close();
  },
});

export default defineConfig({
  services: { inbox },
  targets: [{ engine: web(), app: { url: 'http://localhost:3000' } }],
});
```

`start` is an async generator. In it, you start the dependency, yield one time
with the value you want tests to get, and stop the dependency after the
`yield`. The code after `yield` runs when the services are no longer needed.
`{ signal }` is passed to `start`. The signal aborts when starting or stopping
takes too long (see [`ServiceStartContext`](#service)).

On a service, `startupTimeout` and `shutdownTimeout` are the time limits in
milliseconds for starting (default 60000) and stopping (default 10000).

Service lifecycle:

- `e2e run` and `e2e explore`: services start in key order before any app
  commands and stop in reverse order after the app commands stop.
- `e2e mcp`: services start with the first session on a config file and stop
  when the last session on that file closes.
- `openHost`: services start when the host opens and stop in `host.close()`.

If a service fails to start, any services already started are stopped. An
entry set to `undefined` starts nothing, and its value in tests is
`undefined`.

One instance of each service is shared across all workers. The values are
available in tests through the [`services` fixture](https://e2e.com/docs/reference/test#services)
and in the argument to an [`env` function](#command) on `app.command`. See
[Services](https://e2e.com/docs/services) for a full example.

| Throws | When |
| --- | --- |
| `INVALID_CONFIG` | At config load, `services` isn't a plain object, an entry isn't a plain object with a `start` function, or an entry has an unknown key. |
| `SERVICE_START_FAILED` | `start` throws, finishes without yielding, isn't an async generator, or doesn't yield within its `startupTimeout`. |
| `INVALID_SERVICE_VALUE` | The yielded value isn't a plain object, contains a value that can't be copied, like a custom class instance, or contains a function inside a map or a set. See [What a service can yield](https://e2e.com/docs/services#what-a-service-can-yield). |
| `SERVICE_STOP_FAILED` | The code after `yield` throws, yields a second time, or doesn't finish within the service's `shutdownTimeout`. |

The declarations are under [`Service`](#service), exported from `e2e`.

### credentials

Named accounts. Each entry is a username and a password the model never sees.

```ts
credentials: {
  admin: { username: 'admin@example.com', password: () => readFile('.secrets/admin', 'utf8') },
},
```

| Field | Type |
| --- | --- |
| [`username`](#username) | `string` |
| [`password`](#password) | `string \| SecretProvider` |

- Credentials and secrets are separate namespaces. `secrets.get(name)`
  returns a `secrets` entry only. A credential's password is reachable only
  as `credentials.user(name).password`.
- The agent, the replay cache, and the reports know that password as a secret
  named `<name>.password` (`<secret:admin.password>`). So `credentials.admin`
  and `secrets.admin` can both exist.
- An entry set to `undefined` takes its username and password from
  `E2E_USER_<NAME>_USERNAME` and `E2E_USER_<NAME>_PASSWORD`.

| Throws | When |
| --- | --- |
| `INVALID_CONFIG` | A `secrets` entry named exactly `admin.password` beside an `admin` credential. |
| `INVALID_CONFIG` | Two credentials whose names map to one `E2E_USER_<NAME>_*` override, like `svc-a` and `svc_a` (see [Environment variables](https://e2e.com/docs/reference/environment)). |

See [Authentication](https://e2e.com/docs/authentication). The declarations are under
[`CredentialConfig`](#credentialconfig).

#### `username`

The account's plain username.

```ts
username: 'admin@example.com',
```

`E2E_USER_<NAME>_USERNAME` wins over the config value. With neither, the
entry is `INVALID_CONFIG`.

#### `password`

The account's password: a static value, or a `SecretProvider` function.

```ts
password: () => readFile('.secrets/admin', 'utf8'),
```

- A static password is at least 6 characters (code points), like a
  [secret](#secrets), or `INVALID_CONFIG`.
- A `SecretProvider` runs on every authorized fill, like a
  [secret's provider](#secrets). One returning fewer than 6 characters fails
  the fill with `AUTH_CREDENTIAL_UNAVAILABLE`.
- `E2E_USER_<NAME>_PASSWORD` wins over both.

#### `credentials.user()`

Resolves a configured entry into a `Credential` in a test.

```ts
const admin = credentials.user('admin');
```

- Its `name` is the entry's name in `credentials`.
- The username is a plain string. The password is an opaque `Secret` that
  test code cannot read, accepted only by `locator.fill` and `agent.act`
  params.
- An unconfigured name throws `AUTH_CREDENTIAL_UNAVAILABLE`.

### secrets

Named values the model must never see: API keys, tokens, anything sourced
from the environment.

```ts
secrets: {
  apiKey: () => readFile('.secrets/api-key', 'utf8'),
},
```

| Entry | Example | Checked |
| --- | --- | --- |
| a static value | `'sk_test_51Hx…'` | at config load |
| a provider | `() => readFile('.secrets/api-key', 'utf8')` | on every authorized fill |

- A provider runs on every authorized fill (a vault lookup, a freshly
  computed TOTP). The config digest records it by name only.
- An `E2E_SECRET_<NAME>` override wins over both. It's the only value of an
  entry set to `undefined`, like `process.env.STRIPE_KEY` when the variable
  is unset.
- Every entry must resolve to a string of at least 6 characters (code points)
  or a function; anything else is `INVALID_CONFIG`. A provider's value is held
  to the same minimum at fill time, with `SECRET_UNAVAILABLE`.
- Two entries whose names map to one variable, like `api-key` and `api_key`,
  are `INVALID_CONFIG`.

The declarations are under [`SecretConfig`](#secretconfig). See
[Secrets that are not passwords](https://e2e.com/docs/authentication#secrets-that-are-not-passwords).

#### `secrets.get()`

Returns the opaque `Secret` for a configured entry.

```ts
await screen.getByLabel('API key').fill(secrets.get('apiKey'));
```

- It has no plaintext accessor and is accepted only by `locator.fill` and
  `agent.act` params.
- The runner fills the field, masks the value in every observation, and
  redacts it from logs, traces, and the report.
- An unconfigured name throws `SECRET_UNAVAILABLE`.

#### Secrets in engine options

While `e2e.config.ts` evaluates, before any run exists, `secrets.get(name)`
returns a reference by name that an engine option can hold.

```ts
engine: web({ basicAuth: { username, password: secrets.get('previewPassword') } }),
```

- The engine declares it. When no `secrets` entry has the name, the config
  load fails with `INVALID_CONFIG`. A credential's password is not one:
  declare a value an engine option needs under `secrets`.
- The engine resolves the value when each attempt starts, so a provider runs
  again every time. The value then joins the attempt's redaction. It goes to
  the engine, not onto the page, so it brings none of a fill's screenshot
  restrictions.
- The reference is not the value. Turned into a string (a template literal,
  `String()`, `+`, `JSON.stringify`), it throws `INVALID_CONFIG`. So does a
  reference in an `args` entry or `env` value of `app.command`, which takes
  strings and placeholders only. Read a value a string needs, such as an
  app's API key, from `process.env` yourself.

### cache

Replay cache mode or options. In `read-write` mode the replay cache records an
`agent.act()` only after a later verification passes, such as a locator
assertion or `agent.assert()`.

```ts
cache: { mode: 'read-write', dir: '.e2e/cache', strict: true },
```

| Option | Type | Default |
| --- | --- | --- |
| [`mode`](#mode) | `CacheMode` | `'read-write'`, `'read-only'` in CI |
| [`store`](#store) | `CacheStore` | the file store at `dir` |
| [`dir`](#dir) | `string` | `'.e2e/cache'` |
| [`strict`](#strict) | `boolean` | `false` |

A bare string is shorthand for `{ mode }`: `cache: 'read-only'`. See
[Caching](https://e2e.com/docs/cache). The declarations are under [`CacheConfig`](#cacheconfig).

#### `mode`

What the replay cache reads and writes.

```ts
cache: 'read-write', // default: 'read-write' locally, 'read-only' in CI
```

| Mode | Does |
| --- | --- |
| `'read-write'` | Replays entries and records new ones. |
| `'read-only'` | Replays existing entries and writes none. |
| `'off'` | Disables both. |

- An explicit mode overrides the default. Set `'read-write'` explicitly when
  CI restores the cache from its own cache service.
- `--no-cache` wins over both and disables caching for the run.

#### `store`

A custom entry store that replaces the file store.

```ts
cache: { store: createStore(cacheUrl) },
```

- Each worker constructs its own.
- Exempt from the CI demotion: it states its own trust through `writable`.
- `--cache-dir` beside it is `INVALID_CONFIG`, and `E2E_CACHE_DIR` is ignored.

`CacheStore`, `CacheReadResult`, `TraceEntry`, and `ActionTrace` are exported
from `e2e`.

#### `dir`

The file store directory, resolved against the project root.

```ts
cache: { dir: '.cache/e2e' }, // default: '.e2e/cache'
```

- `--cache-dir` and `E2E_CACHE_DIR` replace it.

#### `strict`

Fails a step whose recording exists but no longer replays with
`REPLAY_STALE`, instead of handing it to the agent.

```ts
cache: { strict: true }, // default: false
```

- `--strict-cache` turns it on for one run.
- The run then never writes the cache.

See [Fail on a stale recording](https://e2e.com/docs/cache#fail-on-a-stale-recording).

#### Commit the replay cache

`e2e init` adds `.e2e/cache/` to `.gitignore`, so committing entries is
opt-in. Remove that line to share replays with CI and teammates. CI stays
`read-only` unless `cache: 'read-write'` is set. See
[Caching](https://e2e.com/docs/cache#commit-the-replay-cache).

## Run limits

The report's `run.limits` block records the ceilings a run enforced. There is
no `limits` key: three fields come from the agents, and the runner fixes the
rest.

| Report field | Value |
| --- | --- |
| `maxAgentContextBytes` | the largest `agents.<name>.maxContextBytes` |
| `maxLedgerBytes` | 8192: the prior-step ledger an act step reads |
| `maxEventsPerStep` | 1000: events recorded per step |
| `maxObservationBytes` | the largest `agents.<name>.maxObservationBytes` |
| `maxModelTokensPerCall` | the largest `agents.<name>.maxInputTokens` |

Per-call options may only lower an agent's budgets.

## Environment variables

The runner reads a closed set, listed on the
[Environment variables](https://e2e.com/docs/reference/environment) page. `E2E_USER_<NAME>_USERNAME`
and `E2E_USER_<NAME>_PASSWORD` override a credential, `E2E_SECRET_<NAME>` a
secret, and `CI` switches the defaults below.

### Resolution order

| Setting | Order |
| --- | --- |
| Base URL | the target's `app.url`, otherwise `APP_URL_REQUIRED` at the first navigation. The runner reads no `APP_URL`; the scaffolded config reads it itself |
| Built-in agent model | `agents.<name>.model`, then `MODEL_UNAVAILABLE` at `agent` acquisition |
| Custom executor model | `agents.<name>.model`, or the model the executor brought; two different values is `INVALID_CONFIG` |
| Model credential | the provider package's own variable or the key passed at construction, read by the provider on the first model call |
| Credential username and password | the `E2E_USER_*` variable, then the config value |

The built-in agent checks for a missing model once per run, when the `agent`
fixture is first acquired, and stops the run with exit 2. A custom
[executor](#executor) can implement `act` and `assert` without a model.
`waitFor` and `extract` still require one, unless the executor
[answers judgments itself](https://e2e.com/docs/executors#what-the-executor-handles).

### CI

CI mode is on unless `CI` is unset, blank, `0`, or `false`.

| Setting | Local | CI |
| --- | --- | --- |
| `retries` | `0` | `1` |
| `workers` | half the cores | `1` |
| `cache` | `read-write` | `read-only` when unset |
| `test.only`, `describe.only` | allowed | `ONLY_IN_CI`, exit code 2 |
| `command.reuseExisting` | honored | ignored, with a notice |

## Loading

### Finding the config file

- `--config <path>` selects an explicit file.
- Otherwise the runner searches the working directory and each parent for
  `e2e.config.ts`, `e2e.config.mts`, `e2e.config.js`, or `e2e.config.mjs`,
  stopping at the repository root.
- A TypeScript config wins over a JavaScript one in the same directory, so
  the `e2e.config.js` that `tsc` emits beside `e2e.config.ts` is ignored.
- Both TypeScript names, or both JavaScript names, in one directory is
  `CONFIG_AMBIGUOUS`.
- The selected file's directory is the project root.

### `.env` files

e2e loads no `.env` file itself. Load one at the top of `e2e.config.ts` with
Node's `process.loadEnvFile()`. Every worker imports the config again, so the
variables reach the workers too:

```ts title="e2e.config.ts"
process.loadEnvFile('.env');
```

It throws when the file is missing; guard it with `existsSync` from
`node:fs` when only some machines have one. The path resolves against the
directory e2e runs from, but workers start in the config's directory. To run
from a subdirectory, pass `new URL('.env', import.meta.url)` instead.

### Module format

- Config and test files run as ESM whatever the nearest `package.json`
  `type` says. So does every `.ts`, `.mts`, `.tsx`, and `.jsx` file they
  reach: a helper by path, a package that exports its `.ts` source by name, or
  a `.ts` file a CommonJS file requires.
- A `.cts` file is CommonJS, written with `require`, `import x = require()`,
  and `export =`; its `import` statements are not turned into `require`
  calls.
- A `.ts` file written with `require` or `module.exports` fails to load: name
  it `.cts`.
- JavaScript keeps the format its package declares.

### JavaScript

A config and tests can be plain JavaScript, with no `tsconfig.json`:

```js title="e2e.config.js"

/** @type {import('e2e').E2EConfig} */
export default {
  tests: 'tests/**/*.e2e.js',
  agents: { default: { model: gateway('openai/gpt-6-luna-fast') } },
  targets: [{ engine: web(), app: { url: 'http://localhost:3000' } }],
};
```

- Name the config `e2e.config.js` or `e2e.config.mjs`
  ([Finding the config file](#finding-the-config-file)).
- Write ES modules. Set `"type": "module"` in `package.json`, or name the
  files `.mjs`. Without either, Node.js warns on every load that it reparsed
  the file as ESM.
- Set [`tests`](#tests): the default selects only `*.e2e.ts`. Use
  `'tests/**/*.e2e.mjs'` for `.mjs` tests. List `'tests/**/*.e2e.ts'` as
  well to run both kinds while you move a suite.
- The `@type` comment does the job of `satisfies E2EConfig`: an editor
  completes keys and shows their documentation. Test fixtures get their
  types from the `test` import, with no annotation.
- The runner never type-checks. For editor errors, add `// @ts-check` to a
  file, or `"checkJs": true` to a `jsconfig.json`.
- A JavaScript file imports a TypeScript helper by its `.ts` name
  (`'./helpers.ts'`), not `.js`; see [Import resolution](#import-resolution).
  Under `checkJs`, that import also needs `"allowImportingTsExtensions": true`
  and `"noEmit": true`.

### Import resolution

e2e compiles TypeScript and JSX itself. An import in such a file resolves the
way TypeScript resolves it:

- `./helper.js` and `./helper` load `helper.ts`, and `./view.jsx` loads
  `view.tsx`.
- `./lib` loads the file `lib/package.json` names as `main`, else
  `lib/index.ts`.
- A bare import that `tsconfig.json` maps through `paths` or `baseUrl` loads
  the mapped file.
- A `#` import or package export that names a missing `./x.js`, `./x.jsx`, or
  `./x` loads its `x.ts` or `x.tsx` source when imported.
- A `#` import or package export that names a directory, or a subpath of a
  package without `exports` that is a directory (`@acme/db/enums`), loads it
  the way `./lib` loads. Under Yarn PnP that package subpath still fails.
- A `require()` of any of the last two fails as Node.js reports it.
- An import written in a JavaScript file resolves as Node.js resolves it.

### `tsconfig.json`

- The `tsconfig.json` is the nearest one above the file. When that one has
  `references` and does not include the file itself (as Vite writes it), it
  is the transitively referenced one that does.
- References are tried in declaration order. If none includes the file, the
  nearest config is used.
- e2e reads its `paths`, `baseUrl`, `jsx`, `jsxFactory`,
  `jsxFragmentFactory`, `jsxImportSource`, `experimentalDecorators`,
  `emitDecoratorMetadata`, `useDefineForClassFields` (and `target`, which
  sets its default), and `verbatimModuleSyntax`, once per process and again
  for each session `e2e mcp` opens.
- A `tsconfig.json` e2e cannot read, such as one that `extends` a package that
  is not installed, is skipped with a warning.
- TypeScript inside an installed package compiles without the project's
  `tsconfig.json`.

### What fails to compile

- e2e refuses, naming the file and line, two things it cannot compile:
  auto-accessors (`accessor x = 1`) and decorators without
  `experimentalDecorators`.
- Each file compiles on its own, without type information. So a type
  imported without `import type` fails to load when the import stays in the
  output (a decorated member's type under `emitDecoratorMetadata`, a
  re-exported type). The error names the import to change.
- A JSON file imported without `with { type: 'json' }` loads with its parsed
  contents as the default export.
- Stack traces and failure locations point at the TypeScript source, through
  another loader's source map too (`NODE_OPTIONS=--import tsx`).

## Types

### `E2EConfig`

`Services` is the type of `services` passed to an `env` function, inferred
by `defineConfig`.

```ts
export interface E2EConfig<Services = Readonly<Record<string, unknown>>> {
  projectId?: string;
  targets: readonly Target<Services>[];
  tests?: string | readonly string[];
  timeout?: number;
  launchTimeout?: number;
  actionTimeout?: number;
  assertionTimeout?: number;
  toPass?: PassOptions;
  cleanupTimeout?: number;
  retries?: number;
  failOnSkippedFailure?: boolean;
  maxDuration?: number;
  workers?: number;
  fullyParallel?: boolean;
  artifacts?: ArtifactsConfig;
  trace?: RecordingMode;
  video?: RecordingMode;
  output?: string;
  reporters?: readonly (BuiltinReporter | Reporter)[];
  agents?: Readonly<Record<string, AgentConfig | undefined>>;
  filters?: readonly TestFilter[];
  services?: Readonly<Record<string, Service | undefined>>;
  cache?: CacheMode | CacheConfig;
  credentials?: Readonly<Record<string, CredentialConfig | undefined>>;
  secrets?: Readonly<Record<string, SecretConfig | undefined>>;
}
```

### `Target`

```ts
export interface Target<Services = Readonly<Record<string, unknown>>> {
  name?: string;
  platform?: string;
  engine?: EngineHandle;
  app?: TargetApp<Services>;
  trace?: RecordingMode;
  video?: RecordingMode;
  fullyParallel?: boolean;
}
```

### `CommandConfig`

```ts
export interface CommandConfig<Services = Readonly<Record<string, unknown>>> {
  executable: string;
  args?: readonly string[];
  cwd?: string;
  env?:
    | Readonly<Record<string, string>>
    | ((context: { readonly services: Services }) => Readonly<Record<string, string>> | Promise<Readonly<Record<string, string>>>);
  inheritEnv?: readonly string[];
  startupTimeout?: number;
  shutdownTimeout?: number;
  log?: string;
  reuseExisting?: boolean;
}
```

### `Service`

```ts
export type Service<Value extends object = object> = {
  startupTimeout?: number;
  shutdownTimeout?: number;
  start(context: ServiceStartContext): AsyncGenerator<Value, void, undefined>;
};

export type ServiceStartContext = {
  readonly signal: AbortSignal;
};

export function defineService<Value extends object>(
  service: Service<Value> & { start(context: ServiceStartContext): AsyncGenerator<NoInfer<CopyableServiceValue<Value>>, void, undefined> },
): Service<Value>;
```

| Field | Description |
| --- | --- |
| `ServiceStartContext.signal` | Aborts when startup is cancelled or the service doesn't yield within `startupTimeout`, when the code after `yield` doesn't finish within `shutdownTimeout`, and when Ctrl+C is pressed a second time in `e2e run` or `e2e explore`, during the tests or while services are stopping. |

`defineService` returns the service unchanged. Each function on a yielded
value becomes an async function in tests and `env` functions
(`ServiceValue<Value>`), and every other value is copied. A yielded value
that can't be copied to tests is a type error.

### `ArtifactsConfig`

```ts
export interface ArtifactsConfig {
  store?: ArtifactStore;
}

export interface ArtifactStore {
  put(artifact: StoredArtifact): Promise<{ readonly ref: string }>;
  putLink?(link: StoredArtifactLink): Promise<{ readonly ref: string }>;
}

export interface StoredArtifact {
  readonly kind: 'screenshot' | 'video' | 'download' | 'log';
  readonly mediaType: string;
  readonly bytes: Uint8Array;
  readonly size: number;
  readonly sha256: string;
  readonly path: string;
  readonly redaction: 'complete' | 'incomplete';
  readonly runId: string;
  readonly testId: string;
  readonly attemptId: string;
  readonly stepId?: string;
  readonly startedAt?: string;
}

export interface StoredArtifactLink {
  readonly kind: 'video';
  readonly url: string;
  readonly mediaType: string;
  readonly redaction: 'incomplete';
  readonly runId: string;
  readonly testId: string;
  readonly attemptId: string;
  readonly startedAt: string;
  readonly stepId?: string;
}
```

| Field | Description |
| --- | --- |
| `StoredArtifact.path` | Report-relative, with `/` separators, and stable across runs of the same test. |
| `StoredArtifact.redaction` | How much of the file the runner masked, as the report records it. |
| `StoredArtifact.stepId` | The step that produced the artifact, when one was running. |
| `StoredArtifact.startedAt` | When a time-based artifact, such as a video segment, began recording. |
| `StoredArtifactLink.url` | The `http(s)` URL the service serves the recording from. |
| `StoredArtifactLink.redaction` | Always `incomplete`: a recording masks nothing. |
| `StoredArtifactLink.startedAt` | When the recording started, as an ISO timestamp. |
| `StoredArtifactLink.stepId` | The step that was running when the recording was registered, if any. |

### `AgentConfig`

```ts
export interface AgentTool {
  readonly tool: object;
  readonly annotations: { readonly mutates: boolean; readonly platforms?: readonly string[] };
}

export interface AgentOptions {
  model?: ModelInstance;
  judge?: ModelInstance;
  context?: string;
  maxSteps?: number;
  maxModelCalls?: number;
  judgmentTimeout?: number;
  maxObservationBytes?: number;
  maxInputTokens?: number;
  maxContextBytes?: number;
  providerOptions?: Readonly<Record<string, ProviderOptions[string] | undefined>>;
}

export type AgentConfig = AgentOptions &
  (
    | {
        system?: string;
        tools?: Readonly<Record<string, AgentTool | undefined>>;
      }
    | {
        executor: StepExecutor;
      }
  );
```

### `ModelInstance`

An AI SDK LanguageModelV2+ instance. Its provider handles transport and
credentials.

```ts
export interface ModelInstance {
  readonly specificationVersion: string;
  readonly provider: string;
  readonly modelId: string;
  readonly doGenerate: (...args: never[]) => unknown;
}
```

### `TestFilter`

```ts
interface TestFilter {
  readonly name: string;
  readonly filter: (tests: readonly TestFilterCandidate[], context: TestFilterContext) => TestFilterResult | Promise<TestFilterResult>;
}

interface TestFilterCandidate {
  readonly id: string;
  readonly file: string;
  readonly titlePath: readonly string[];
  readonly tags: readonly string[];
  readonly setupFile?: string;
}

interface TestFilterContext {
  readonly projectRoot: string;
  readonly changes: TestFilterChanges;
  readonly configFile?: string | undefined;
  readonly signal: AbortSignal;
  log(line: string): void;
  redact(text: string): string;
}

interface TestFilterChanges {
  readonly base: string;
  readonly root: string;
  readonly files: readonly string[];
}

interface TestFilterResult {
  readonly exclude: Readonly<Record<string, string>>;
  readonly relevance?: Readonly<Record<string, number>>;
  readonly note?: string;
}
```

| Field | Description |
| --- | --- |
| `TestFilter.name` | Names the filter in the report and in errors. |
| `TestFilterCandidate.id` | The report's `testId`, and the key `exclude` and `relevance` take. |
| `TestFilterCandidate.file` | Project-relative path of the test file. |
| `TestFilterCandidate.titlePath` | The describe titles, then the test title. |
| `TestFilterCandidate.tags` | The describe chain's tags, then the test's own. |
| `TestFilterCandidate.setupFile` | Project-relative path of the setup test file that saves the test's session. Absent without one. |
| `TestFilterContext.projectRoot` | Absolute project root, spelled as on disk like `changes.root`. |
| `TestFilterContext.configFile` | The config file the run loaded, relative to `changes.root` like `changes.files`. `undefined` for a config object or a file outside the repository. |
| `TestFilterContext.signal` | Aborts when the run is interrupted, or with a `TimeoutError` after 5 minutes. |
| `TestFilterContext.log` | Prints one progress line. |
| `TestFilterContext.redact` | Replaces every fixed-value secret and credential password in `text`, and any run of 8 or more consecutive characters of one. |
| `TestFilterChanges.base` | The merge base of the `--changed-since` ref and `HEAD`. |
| `TestFilterChanges.root` | Absolute path of the repository root, spelled as on disk like `projectRoot`. |
| `TestFilterChanges.files` | Repository-relative POSIX paths of every changed file, uncommitted and untracked files included. Sorted, never empty. |
| `TestFilterResult.exclude` | The tests to leave out, by `id`, each with a non-empty reason the report shows. An `id` of a collected test this filter wasn't given is ignored; any other fails the filter. |
| `TestFilterResult.relevance` | How likely each test is to fail on this change, by `id` as for `exclude`, from 0 to 1; any other score fails the filter. Each target starts the files of the likeliest first, in bands at 75%, 50%, and 25%, and targets go by the band of their best file, ties in config order. A test no filter scores counts as 0, and a test several filters score keeps its highest. |
| `TestFilterResult.note` | One line about the whole decision. |

`TestFilter`, `TestFilterCandidate`, `TestFilterContext`,
`TestFilterChanges`, and `TestFilterResult` are exported from `e2e`.

A filter that throws, returns an invalid result, or runs past 5 minutes
leaves nothing out, and a warning says so. An error it throws can carry
`relevance`, shaped as in `TestFilterResult`: the run still starts the
likeliest first. See [Test filters](https://e2e.com/docs/filters#write-your-own).

### `CredentialConfig`

```ts
export interface CredentialConfig {
  username: string;
  password: string | SecretProvider;
}

type SecretProvider = () => string | Promise<string>;

export interface Credential {
  readonly name: string;
  readonly username: string;
  readonly password: Secret;
  readonly [credentialBrand]: true;
}
```

### `SecretConfig`

```ts
export type SecretConfig = string | SecretProvider;

export type SecretPurpose = 'password' | 'generic-secret';

export interface Secret {
  readonly name: string;
  readonly purpose: SecretPurpose;
  readonly [secretBrand]: true;
}
```

| Field | Description |
| --- | --- |
| `Secret.name` | The entry's name in `secrets`, or `<credential>.password` for a credential's password. |
| `Secret.purpose` | Where an agent may fill the value: a `password` only into a password field, a `generic-secret` (an API key, a token, any value from the environment) into any editable input. `locator.fill` does not check it. |

### `CacheConfig`

```ts
export interface CacheConfig {
  mode?: CacheMode;
  store?: CacheStore;
  dir?: string;
  strict?: boolean;
}

export interface CacheStore {
  readonly writable: boolean;
  read(keyHash: string): Promise<CacheReadResult>;
  write(keyHash: string, payload: ActionTrace): Promise<{ bytes: number } | undefined>;
  delete?(keyHash: string): Promise<void>;
}

export type CacheReadResult =
  | { readonly status: 'hit'; readonly entry: TraceEntry; readonly bytes: number }
  | { readonly status: 'miss' }
  | { readonly status: 'invalid'; readonly reason: string; readonly bytes?: number };
```

| Field | Description |
| --- | --- |
| `CacheStore.write` | Persists one trace and returns its size, or `undefined` when not written. |
| `CacheStore.delete` | Optional. Evicts one entry, best-effort. Called when a replayed or just-recorded flow is implicated in a failed attempt, so the entry re-records on the next pass. A store without it stays stale until the next confirmed write. |
