agentpath 0.0.0-stage → 0.1.0-alpha.2
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.
- package/LICENSE.md +105 -0
- package/README.md +101 -2
- package/THIRD_PARTY_NOTICES +12 -0
- package/apps/demo-site/dist/site.js +92 -0
- package/apps/studio/dist/assets/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
- package/apps/studio/dist/assets/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
- package/apps/studio/dist/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
- package/apps/studio/dist/assets/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
- package/apps/studio/dist/assets/geist-mono-cyrillic-ext-wght-normal-X_5orZeX.woff2 +0 -0
- package/apps/studio/dist/assets/geist-mono-cyrillic-wght-normal-DiZS0aHC.woff2 +0 -0
- package/apps/studio/dist/assets/geist-mono-latin-ext-wght-normal-Bwz-egvJ.woff2 +0 -0
- package/apps/studio/dist/assets/geist-mono-latin-wght-normal-XN7g48iV.woff2 +0 -0
- package/apps/studio/dist/assets/geist-mono-symbols2-wght-normal-CO5SzqOn.woff2 +0 -0
- package/apps/studio/dist/assets/geist-mono-vietnamese-wght-normal-DadHysG0.woff2 +0 -0
- package/apps/studio/dist/assets/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
- package/apps/studio/dist/assets/index-DH4wJPHm.js +67 -0
- package/apps/studio/dist/assets/index-DrnNh2ip.css +1 -0
- package/apps/studio/dist/index.html +14 -0
- package/audit.md +173 -0
- package/autonomous-mode.md +104 -0
- package/ci.md +118 -0
- package/coding-agents.md +143 -0
- package/concepts.md +145 -0
- package/contracts.md +356 -0
- package/examples/tasks/ambiguous.json +98 -0
- package/examples/tasks/assertion-failure.json +98 -0
- package/examples/tasks/broken.json +98 -0
- package/examples/tasks/fixed.json +98 -0
- package/examples/tasks/recovery.json +19 -0
- package/images/compare-recovery-desktop.jpg +0 -0
- package/images/compare-variants-desktop.jpg +0 -0
- package/images/overview-desktop.jpg +0 -0
- package/images/run-autonomous-passed-desktop.jpg +0 -0
- package/images/run-failed-desktop.jpg +0 -0
- package/images/run-failed-mobile.jpg +0 -0
- package/images/run-missing-artifact-desktop.jpg +0 -0
- package/images/task-editor-laptop.jpg +0 -0
- package/installation.md +102 -0
- package/ledger.md +62 -0
- package/licenses/-fontsource-variable-geist-mono.txt +93 -0
- package/licenses/-fontsource-variable-geist.txt +93 -0
- package/licenses/lucide-react.txt +43 -0
- package/licenses/react-dom.txt +21 -0
- package/licenses/react.txt +21 -0
- package/licenses/scheduler.txt +21 -0
- package/licenses/tailwindcss.txt +21 -0
- package/licenses/zod.txt +21 -0
- package/package.json +165 -4
- package/packages/cli/bin/agentpath.js +39 -0
- package/packages/cli/dist/audit-rerun.js +384 -0
- package/packages/cli/dist/audit.js +387 -0
- package/packages/cli/dist/change-summaries.js +87 -0
- package/packages/cli/dist/ci-report.js +88 -0
- package/packages/cli/dist/demo.js +88 -0
- package/packages/cli/dist/doctor.js +265 -0
- package/packages/cli/dist/explain.js +89 -0
- package/packages/cli/dist/git.js +7 -0
- package/packages/cli/dist/inspect.js +118 -0
- package/packages/cli/dist/ledger.js +509 -0
- package/packages/cli/dist/local.js +102 -0
- package/packages/cli/dist/main.js +708 -0
- package/packages/cli/dist/mcp.js +231 -0
- package/packages/cli/dist/paths.js +6 -0
- package/packages/cli/dist/playwright-fixture.js +185 -0
- package/packages/cli/dist/playwright-reporter.js +49 -0
- package/packages/cli/dist/tasks.js +37 -0
- package/packages/cli/dist/test-source.js +283 -0
- package/packages/cli/dist/watch.js +96 -0
- package/packages/contracts/dist/agent-settings.js +18 -0
- package/packages/contracts/dist/agent.js +175 -0
- package/packages/contracts/dist/audit.js +115 -0
- package/packages/contracts/dist/guidance.js +339 -0
- package/packages/contracts/dist/index.js +14 -0
- package/packages/contracts/dist/inspect.js +63 -0
- package/packages/contracts/dist/ledger.js +80 -0
- package/packages/contracts/dist/local.js +171 -0
- package/packages/contracts/dist/outcomes.js +94 -0
- package/packages/contracts/dist/platform.js +105 -0
- package/packages/contracts/dist/playwright-live.js +76 -0
- package/packages/contracts/dist/policy.js +93 -0
- package/packages/contracts/dist/run.js +178 -0
- package/packages/contracts/dist/task-issues.js +39 -0
- package/packages/contracts/dist/task.js +185 -0
- package/packages/contracts/dist/watch.js +57 -0
- package/packages/core/dist/action-feedback.js +103 -0
- package/packages/core/dist/actions.js +160 -0
- package/packages/core/dist/agent-loop.js +122 -0
- package/packages/core/dist/artifacts.js +156 -0
- package/packages/core/dist/assertions.js +120 -0
- package/packages/core/dist/autonomous.js +1 -0
- package/packages/core/dist/browser.js +196 -0
- package/packages/core/dist/compare.js +141 -0
- package/packages/core/dist/control-state.js +62 -0
- package/packages/core/dist/diagnostics.js +134 -0
- package/packages/core/dist/evidence-diff.js +93 -0
- package/packages/core/dist/evidence.js +203 -0
- package/packages/core/dist/index.js +22 -0
- package/packages/core/dist/inspect.js +257 -0
- package/packages/core/dist/integrity.js +176 -0
- package/packages/core/dist/liveness.js +114 -0
- package/packages/core/dist/local-files.js +61 -0
- package/packages/core/dist/locators.js +214 -0
- package/packages/core/dist/model-provider.js +88 -0
- package/packages/core/dist/observation.js +257 -0
- package/packages/core/dist/playwright-live.js +519 -0
- package/packages/core/dist/playwright-results.js +543 -0
- package/packages/core/dist/policy.js +182 -0
- package/packages/core/dist/privacy.js +93 -0
- package/packages/core/dist/recovery.js +54 -0
- package/packages/core/dist/retention.js +204 -0
- package/packages/core/dist/run-index.js +177 -0
- package/packages/core/dist/run-plan.js +28 -0
- package/packages/core/dist/run-repository.js +518 -0
- package/packages/core/dist/runner.js +913 -0
- package/packages/core/dist/storage.js +63 -0
- package/packages/core/dist/task-fingerprint.js +36 -0
- package/packages/core/dist/test-change-rerun.js +84 -0
- package/packages/core/dist/test-changes.js +896 -0
- package/packages/core/dist/timing.js +41 -0
- package/packages/core/dist/watch.js +165 -0
- package/packages/server/dist/index.js +265 -0
- package/packages/server/dist/task-store.js +103 -0
- package/quickstart.md +85 -0
- package/security.md +136 -0
- package/try-on-your-repo.md +54 -0
- package/understanding-results.md +159 -0
- package/writing-tasks.md +196 -0
package/contracts.md
ADDED
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
# AgentPath contracts v1
|
|
2
|
+
|
|
3
|
+
The Zod schemas in `packages/contracts` define the task, report, evidence, and comparison formats. Versioned objects use `schemaVersion: 1`. Unknown keys and versions are rejected.
|
|
4
|
+
|
|
5
|
+
## Tasks
|
|
6
|
+
|
|
7
|
+
A task has an `id` chosen by its author, `name`, `goal`, `baseUrl`, `mode`, `allowedHosts`, and at least one `assertions` entry. Task IDs use lowercase ASCII letters, digits, underscores, and hyphens. A deterministic task also has one or more `steps`. An autonomous task omits `steps`. Execution requires the optional `agent` configuration described below; legacy definitions without it remain readable and receive a configuration error when run.
|
|
8
|
+
|
|
9
|
+
The runner resolves `navigate.url` against `baseUrl`. Both the base and resolved URLs must be credential-free HTTP(S) on explicitly allowed hosts. Use canonical hostnames with nondefault ports where needed, such as `127.0.0.1:4173`. Host entries are exact. `setup` and `teardown` accept descriptive metadata only.
|
|
10
|
+
|
|
11
|
+
Optional `browser.mobile` (boolean, no default) turns on phone emulation in Chromium; tasks without it are unchanged, fingerprint included. A task that sets it needs this version or later, because older versions reject unknown task fields. Browser defaults are a 1280 × 800 viewport and 5,000 ms per action or assertion, with a configurable range of 100 to 60,000 ms. Optional `browser.runTimeoutMs` limits overall execution from 250 to 600,000 ms and has an effective default of 120,000 ms. An action shares its budget between target lookup and interaction. Evidence capture has a separate budget.
|
|
12
|
+
|
|
13
|
+
A role locator has `by: "role"`, a supported `role`, and exact accessible `name`. A label locator has `by: "label"` and an exact `label`. Locators query the primary page. Single-target actions reject multiple matches.
|
|
14
|
+
|
|
15
|
+
| `action` | Fields |
|
|
16
|
+
| --- | --- |
|
|
17
|
+
| `navigate` | `url` |
|
|
18
|
+
| `click` | Role locator in `target` |
|
|
19
|
+
| `fill` | Semantic `target` and string `value` |
|
|
20
|
+
| `select` | Semantic `target` and `option` with either `{ by: "label", label }` or `{ by: "value", value }` |
|
|
21
|
+
| `press` | Semantic `target` and supported `key`, such as `Enter`, `ArrowDown`, or `ControlOrMeta+a` |
|
|
22
|
+
| `wait` | Semantic `target` and `state` of `visible` or `hidden`. Hidden also accepts an absent target. |
|
|
23
|
+
|
|
24
|
+
| `assert` | Condition |
|
|
25
|
+
| --- | --- |
|
|
26
|
+
| `url` | The full current URL matches `pattern`. Only `*` is special and matches zero or more characters. |
|
|
27
|
+
| `visible` | Exactly one semantic `target` is visible. |
|
|
28
|
+
| `text` | One visible `target` contains the case-sensitive substring `contains`. Whitespace is normalized. |
|
|
29
|
+
| `count` | The number of matching elements equals `count`. Zero is valid. |
|
|
30
|
+
|
|
31
|
+
Screenshots and accessibility each accept `off`, `failure`, or `steps`. The defaults are screenshots off and accessibility on failure. Step-mode capture includes pre-action and post-action state and post-assertion state. Trace capture is opt-in.
|
|
32
|
+
|
|
33
|
+
## Runs
|
|
34
|
+
|
|
35
|
+
`result.json` contains the run ID, task ID, execution mode, timestamps, duration, verdict, executed steps, evaluated assertions, and the artifact manifest. A failed result carries a failure category, phase, zero-based operation index where applicable, expected and observed conditions, supporting observations, and relative artifact references. CLI display uses one-based operation numbers.
|
|
36
|
+
|
|
37
|
+
`events.jsonl` is an ordered stream with one schema-valid event per line. Sequence numbers start at zero. Start events identify the operation and its pre-operation URL. Semantic steps also include the locator kind and its role where applicable. Finish events record duration, verdict, URL, and evidence references. The stream ends with `run.finished` when the run is finalized.
|
|
38
|
+
|
|
39
|
+
`environment.json` records runtime, browser, viewport, timeout, and capture settings. `evidence/failure.json` preserves the structured evidence behind a failure classification. Accessibility snapshots contain a bounded list of Chromium accessibility role/name pairs. `trace.zip` is a native Playwright trace when enabled.
|
|
40
|
+
|
|
41
|
+
The verdicts are `passed`, `failed`, and `cancelled`. Failure categories are `TARGET_NOT_FOUND`, `TARGET_AMBIGUOUS`, `TARGET_NOT_INTERACTABLE`, `NAVIGATION_FAILURE`, `ASSERTION_FAILED`, `TIMEOUT`, `BROWSER_ERROR`, and `UNKNOWN`.
|
|
42
|
+
|
|
43
|
+
The existing comparison summary identifies the baseline and candidate runs, their statuses, and an optional first divergence. The local API and CLI return it inside a detailed response with alignment rows, timing deltas, task IDs, and failure categories. The optional `plan.json` and `browser-observations.json` sidecars have their own v1 schemas. First-version `result.json`, `events.jsonl`, and manifest formats are unchanged.
|
|
44
|
+
|
|
45
|
+
## Local API
|
|
46
|
+
|
|
47
|
+
All paths are relative to the Studio loopback origin. Requests that change state require `X-AgentPath-Client: studio`. JSON bodies have an 8 MiB limit.
|
|
48
|
+
|
|
49
|
+
| Method | Path | Request and response |
|
|
50
|
+
| --- | --- | --- |
|
|
51
|
+
| GET | `/api/health` | Local API readiness, runtime, platform, Chromium executable status, run capacity |
|
|
52
|
+
| GET | `/api/tasks` | List saved v1 task definitions |
|
|
53
|
+
| GET | `/api/tasks/:taskId` | Read a v1 task definition |
|
|
54
|
+
| POST | `/api/tasks` | Create from a v1 task definition. Returns the saved task with HTTP 201 |
|
|
55
|
+
| PUT | `/api/tasks/:taskId` | Replace a v1 task with the same ID. Returns the saved task |
|
|
56
|
+
| DELETE | `/api/tasks/:taskId` | Delete the saved task. Returns HTTP 204 |
|
|
57
|
+
| POST | `/api/runs` | Start with `{ "taskId": "…" }`. Returns a run summary and Location header with HTTP 202 |
|
|
58
|
+
| GET | `/api/runs` | List run summaries, newest first |
|
|
59
|
+
| GET | `/api/runs/:runId` | Read the summary, finalized result when present, and optional run metadata |
|
|
60
|
+
| GET | `/api/runs/:runId/events` | Poll the ordered persisted events |
|
|
61
|
+
| POST | `/api/runs/:runId/cancel` | Request cancellation. Returns the run detail with HTTP 202 |
|
|
62
|
+
| GET | `/api/runs/:runId/artifacts/:index` | Read a finalized manifest entry by zero-based index |
|
|
63
|
+
| GET | `/api/compare?baseline=<run-id>&candidate=<run-id>&mode=<mode>` | Compare finalized runs in `same-task` or `scenario-variants` mode |
|
|
64
|
+
|
|
65
|
+
Errors use a shared `{ error, issues? }` shape. Validation returns HTTP 400, out-of-scope access returns 403, missing resources return 404, run capacity or comparison conflicts return 409, and a stored record that is malformed or uses an unsupported schema version returns 422.
|
|
66
|
+
|
|
67
|
+
Listings isolate unreadable records. `GET /api/runs` keeps every readable run and reports a malformed run directory as `{ "runId": "…", "status": "unreadable" }`. `GET /api/tasks` returns the readable tasks and sets `X-AgentPath-Unreadable-Tasks` to the number of task files it skipped. The `unreadable` run summary status was added later. It is an API summary value only, and the persisted run formats are unchanged.
|
|
68
|
+
|
|
69
|
+
Scenario-variants comparison requires at least one aligned operation with a semantic target. Navigation steps and URL assertions align by kind alone, so they do not by themselves make two tasks comparable. A Chromium installation status of `installed` indicates the configured executable is present. The runner still checks whether it can actually launch with the sandbox enabled.
|
|
70
|
+
|
|
71
|
+
## Evidence minimization
|
|
72
|
+
|
|
73
|
+
The persisted v1 task, result, and event formats remain readable. New optional observation fields are `timeoutScope` and the error kinds `run_timeout`, `renderer_crash`, and `browser_disconnected`. Environment browser settings accept the optional overall deadline. Existing failure category values remain unchanged.
|
|
74
|
+
|
|
75
|
+
| Record | Added information |
|
|
76
|
+
| --- | --- |
|
|
77
|
+
| `metadata.json` | v1 run/task IDs, fingerprint version and algorithm, task and assertion digests, operation counts, privacy policy |
|
|
78
|
+
| `operations.json` | v1 run ID and phase/index scalar observations for recorded operations |
|
|
79
|
+
| `plan.json` | Optional identity version 2, safe target presentation and generic expected behavior |
|
|
80
|
+
| Accessibility JSON | Optional `nameState` of `withheld` or `redacted`, with an empty name payload |
|
|
81
|
+
| `browser-observations.json` | Optional cleanup state of `complete`, `forced`, or `unconfirmed` |
|
|
82
|
+
|
|
83
|
+
New local API run details expose the optional metadata and operation records. Legacy files do not acquire inferred metadata. The comparison response adds `contract`, `interpretation`, and per-row `evidenceDiff`. These local API response additions ship with Studio and the CLI in the same workspace. A fact references its actual run ID, source file, and JSON pointer. Sources can describe a directly stored field or a deterministic rendering of its status or bounded node list.
|
|
84
|
+
|
|
85
|
+
Contract status is `identical`, `changed`, or `unavailable`. Assertions are equivalent only when their recorded assertion fingerprints match. The recovery interpretations are `verified-recovery`, `observed-improvement`, `unchanged`, `regression`, `inconclusive`, and `different-definitions`.
|
|
86
|
+
|
|
87
|
+
Required evidence comprises finalized result and terminal events, validated metadata and plan, operation observations, browser observations, an environment manifest entry, a failure manifest entry for a failed run, and all referenced artifacts. Candidate operation and assertion counts must agree with the plan and metadata. Capture files that were never produced remain optional diagnostics. A referenced missing or unreadable capture makes strict verification inconclusive. PNG and ZIP responses validate their format signatures. The comparison does not validate every pixel or ZIP member.
|
|
88
|
+
|
|
89
|
+
Same-task mode accepts changed definitions under one ID and reports their limitation explicitly. Variants mode retains the requirement for a shared semantic operation and permits differing IDs. Strict recovery additionally requires the same task ID. Incomplete runs return a comparison conflict. Unreadable run records return the existing 422 response. Cancelled finalized runs can be inspected and aligned but their verification interpretation is inconclusive.
|
|
90
|
+
|
|
91
|
+
## Liveness, integrity and capture state
|
|
92
|
+
|
|
93
|
+
All of these records are new optional sidecars. Earlier runs stay readable without them. The `result.json`, `events.jsonl`, and task formats are unchanged.
|
|
94
|
+
|
|
95
|
+
| Record | Schema | Content |
|
|
96
|
+
| --- | --- | --- |
|
|
97
|
+
| `liveness.json` | `runLivenessRecordSchema` v1 | Run ID, `active` or `released`, owner `{ pid, hostDigest, processStartedAt, instance }`, `heartbeatAt`, `intervalMs`, `ttlMs`, `sequence` |
|
|
98
|
+
| `integrity.json` | `integrityRecordSchema` v1 | `pending`, or `sealed` with algorithm `sha256`, `sealedAt`, per-file `{ path, bytes, sha256 }`, and `events: { bytes, sha256 }` for the `events.jsonl` prefix |
|
|
99
|
+
| `capture-state.json` | `captureStateRecordSchema` v1 | Entries `{ phase, index, point, kind, state, reason, path? }` |
|
|
100
|
+
| `.index/runs-v1.sqlite` | Derived, not a contract | Rebuildable listing index. Never read as evidence |
|
|
101
|
+
|
|
102
|
+
Run summaries add the statuses `stale` and `abandoned` and an optional `liveness` object `{ state, reason, heartbeatAt?, expiresAt? }`. Run details add optional `captureStates`. Evidence availability adds the reasons `modified` and `unexpected` for integrity findings. The integrity report is `{ runId, status, algorithm?, checkedFiles, sealedAt?, issues: [{ path, problem }] }`, with problems `missing`, `modified`, `truncated`, `unexpected`, and `unreadable`.
|
|
103
|
+
|
|
104
|
+
| Method | Path | Change |
|
|
105
|
+
| --- | --- | --- |
|
|
106
|
+
| GET | `/api/runs?limit=&cursor=&status=&taskId=&since=&until=` | Pages newest first. Default 50, maximum 200. `status` is a comma list. The body stays an array of summaries. `X-AgentPath-Next-Cursor` is set when more runs exist, and `X-AgentPath-Run-Source` is `index` or `scan`. Unknown parameters, a malformed cursor, or an out-of-range limit return 400 |
|
|
107
|
+
| GET | `/api/runs/:runId/integrity` | Integrity report for one run |
|
|
108
|
+
| GET | `/api/runs/:runId/artifacts/:index` | Returns 422 when the file no longer matches its sealed digest |
|
|
109
|
+
| POST | `/api/runs/:runId/cancel` | Returns 409 for a run this server does not own, including CLI runs |
|
|
110
|
+
|
|
111
|
+
## Autonomous host
|
|
112
|
+
|
|
113
|
+
All changes are additive to the v1 schemas; earlier task/run records remain readable. New autonomous results use `mode: "autonomous"`; summaries and plans add optional `mode`. New failure categories are `AGENT_RESPONSE_INVALID`, `AGENT_BUDGET_EXHAUSTED`, `AGENT_STOPPED`, and `PROVIDER_ERROR`. A failure may have `{ phase: "agent", index: <zero-based decision> }`. Existing browser, cancellation and deadline classifications remain distinct.
|
|
114
|
+
|
|
115
|
+
`agent` is a strict object: provider (`openai-compatible` or `ollama`), credential-free HTTP(S) endpoint without query/fragment, model (1–200 characters), maxActions (1–100, default 20), maxDecisions (1–150, default 30), maxOutputTokens (64–4096, default 512), maxTokenBudget (1024–262144, default 65536), requestTimeoutMs (100–60000, default 30000), storeMessages (default false). Overall and browser-action deadlines remain under `browser`.
|
|
116
|
+
|
|
117
|
+
`agentDecisionSchema` is a strict union with `schemaVersion: 1`: `{ tool: "observe" | "complete" | "unable" }` or `{ tool: "act", action: <existing semantic action> }`. Wait is excluded; observe refreshes state. Unknown fields and unsupported actions fail validation. No selectors, script execution or filesystem tools are added. `agentObservationSchema` carries URL and at most 200 bounded role/name pairs.
|
|
118
|
+
|
|
119
|
+
`agent.json` uses `agentTraceSchema` v1 and manifest kind `agent`. It contains run ID, protocol, model, endpoint origin (not credentials or path), effective limits, action/decision counts, conservative charged allowance, declaredCompletion, verifiedCompletion, optional failureKind, and ordered entries. Entries hold observation/proposal SHA-256 digests, URL, node count, validated tool/action kind, optional actual stepIndex and opt-in response text. Invalid proposals retain a digest and invalid classification, not raw text. The independent assertion results and final verdict are in result.json; entries reference its actual actions. Run detail exposes optional `agent`, including while active; final consistency checks compare its run ID, mode, action count and verified flag with the result. The integrity manifest covers the finalized trace.
|
|
120
|
+
|
|
121
|
+
Autonomous fingerprints include the goal and effective agent settings. No task fingerprint is synthesized for a legacy run. Existing comparison semantics and source references apply to generated operations and independent assertions. Different modes/settings are different contracts, regardless of a matching task ID.
|
|
122
|
+
|
|
123
|
+
## Live inference
|
|
124
|
+
|
|
125
|
+
The v1 agent settings add optional `temperature` (0–2), `ollamaThink` (boolean), and `ollamaFormat` (`json` or `schema`). Absent values preserve the previous provider behavior and existing effective fingerprints. Ollama-only controls apply to the Ollama protocol; temperature also applies to Chat Completions. Explicit settings enter the task fingerprint. No run/event version changes or index migration are required.
|
|
126
|
+
|
|
127
|
+
`browserActionSchema` owns the shared navigate/click/fill/select/press union; deterministic `browserStepSchema` additionally permits wait. `agentDecisionJsonSchema` is generated from the same strict runtime decision contract and excludes wait. Optional Ollama schema decoding constrains the format; runtime validation remains authoritative, including semantic strings, key refinements and unsupported proposals. No invalid JSON is repaired into an action.
|
|
128
|
+
|
|
129
|
+
`agent.json` adds optional `inference: { temperature?, ollamaThink?, ollamaFormat? }`, recording explicit configuration only. Legacy traces omit it and remain readable. Provider thinking text is ignored, not stored or parsed. Reported prompt plus generated token usage still includes thinking when present; reservations and output limits remain enforced. Studio displays the recorded endpoint **origin**, not an invented full route, and explicit inference settings. Model decisions and referenced actual step results remain separate.
|
|
130
|
+
|
|
131
|
+
## Grounding and action policy
|
|
132
|
+
|
|
133
|
+
All changes are additive. Run and event schema versions, the v1 task schema version and the SQLite index format are unchanged. Earlier task, run, trace and comparison records remain readable.
|
|
134
|
+
|
|
135
|
+
### Observations v2
|
|
136
|
+
|
|
137
|
+
`agentObservationSchema` keeps `url` and the flat `accessibility` role/name list and adds optional `controls` and `truncated`. Each control is `{ ref, role, name, kind, enabled, supports, expanded?, multiple?, choices?, choiceCount? }`:
|
|
138
|
+
|
|
139
|
+
- `ref` is an observation-local reference (`c1`–`c999`). Each observation replaces every earlier reference. A reference the current observation does not hold fails with `TARGET_STALE` (`errorKind: stale_reference`). Before a referenced action runs, the host confirms that the same DOM node still has the observed role and name; a replaced node is also stale.
|
|
140
|
+
- `kind` is `native-select`, `custom-combobox` or `text-input`. `supports` lists the agent actions the control accepts: `select` for a native select, `click`/`press` for a custom combobox, `fill`/`press` for a text input.
|
|
141
|
+
- `choices` (native selects only) are `{ label, value?, group?, selected?: true, disabled?: true }`. `value` appears only when it differs from the label; `group` is the `optgroup` label. `choiceCount` is present when the list was truncated.
|
|
142
|
+
- A custom ARIA combobox exposes only its role, name and `expanded` state. Its options are reachable as ordinary flat nodes after the model opens it. AgentPath does not claim to select options of custom widgets.
|
|
143
|
+
- Bounds (`OBSERVATION_LIMITS`): 200 flat nodes, 500-character names, 25 controls, 25 choices per control, 200-character control names, 120-character choice labels, 16,000 bytes in total. Trimming order: flat nodes down to 50, then choice lists down to 5, then remaining flat nodes, then trailing controls, whose references are withdrawn. `truncated: true` records any trimming. Control subtrees are not repeated as flat nodes.
|
|
144
|
+
- Values of text fields are never observed. Names pass through the same privacy filter as before, including redaction of values the agent typed.
|
|
145
|
+
|
|
146
|
+
### Decision protocol v2
|
|
147
|
+
|
|
148
|
+
`agentDecisionSchema` accepts `schemaVersion: 2` and `schemaVersion: 1`; other versions are rejected. Ollama schema decoding uses only the v2 schema (`agentDecisionJsonSchema`). In v2:
|
|
149
|
+
|
|
150
|
+
- `select` is `{ action: "select", control: <target>, option: { by: "label", label } | { by: "value", value } }`. The control and the choice are separate fields.
|
|
151
|
+
- Targets for click, fill, press and the select control may be `{ by: "role", role, name }`, `{ by: "label", label }` or `{ by: "ref", ref }`. Click still requires a role or reference target.
|
|
152
|
+
- v1 decisions, including v1 `select` with `target`, are normalized to the v2 shape by `normalizeAgentAction`. Stored plans always record the resolved semantic locator, never a reference.
|
|
153
|
+
|
|
154
|
+
New failure categories and observation kinds:
|
|
155
|
+
|
|
156
|
+
| Category | `errorKind` | Meaning |
|
|
157
|
+
| --- | --- | --- |
|
|
158
|
+
| `TARGET_NOT_INTERACTABLE` | `wrong_control_type` | `select` on a control that is not a native select |
|
|
159
|
+
| `UNSUPPORTED_CONTROL` | `unsupported_control` | `select` on a custom combobox |
|
|
160
|
+
| `OPTION_NOT_FOUND` | `option_not_found` | No choice matched within the action timeout |
|
|
161
|
+
| `TARGET_NOT_INTERACTABLE` | `option_disabled` | The matching choice is disabled |
|
|
162
|
+
| `TARGET_AMBIGUOUS` | — | More than one choice matched |
|
|
163
|
+
| `TARGET_STALE` | `stale_reference` | Unknown or replaced observation reference |
|
|
164
|
+
| `POLICY_BLOCKED` | `policy_blocked` | The trusted action policy rejected the action |
|
|
165
|
+
|
|
166
|
+
`agent.json` adds optional `observationVersion: 2`, per-entry `controlCount`, and per-entry `policy: { decision: "blocked" | "permitted-violation", ruleIds }`. The adapter's `perform` may resolve to `"rejected"`; a rejected action is not planned, executed or counted.
|
|
167
|
+
|
|
168
|
+
### Action policy v1
|
|
169
|
+
|
|
170
|
+
A task may carry `policy: { schemaVersion: 1, mode: "audit" | "enforce", rules }` with 1–50 rules and unique rule IDs (`/^[a-z0-9][a-z0-9_-]{0,63}$/`):
|
|
171
|
+
|
|
172
|
+
- Action rule: `{ id, kind: "action", actions: [click|fill|select|press, …], target?: <semantic locator>, description? }`. Without a target it matches every action of those kinds.
|
|
173
|
+
- Request rule: `{ id, kind: "request", path, match?: "exact" | "prefix", methods?: [GET|POST|PUT|PATCH|DELETE, …], host?, description? }`. `path` is absolute with no query or fragment. `host`, when present, must be one of the task's allowed hosts.
|
|
174
|
+
|
|
175
|
+
The policy is excluded from `definitionFingerprint`, so adding one does not change goal-contract equivalence and tasks without a policy keep their fingerprints. `metadata.json` adds optional `policyFingerprint` (SHA-256 of the canonical policy).
|
|
176
|
+
|
|
177
|
+
`policy.json` (manifest kind `policy`, sealed in the integrity manifest before `run.finished`) is `{ schemaVersion: 1, runId, mode, policyFingerprint, rules: [{ id, kind, description? }], checked, decisions, requests, requestsTruncated?, complete, outcome }`.
|
|
178
|
+
|
|
179
|
+
- Each decision is `{ sequence, source: agent|step, agentSequence?, stepIndex?, action, target?, ruleIds, decision: allowed|blocked|permitted-violation|unevaluated, execution: executed|failed|blocked|not-executed, checkpoint: proposal|execution, reason }`.
|
|
180
|
+
- Each request is `{ sequence, ruleIds, method, decision: blocked|permitted-violation, stepIndex?, resourceType }`.
|
|
181
|
+
- Fill values, request URLs and bodies are never recorded. Target names pass through the privacy filter.
|
|
182
|
+
- At most 400 decisions and 200 requests are recorded. Truncated requests make the outcome inconclusive.
|
|
183
|
+
|
|
184
|
+
### Outcomes
|
|
185
|
+
|
|
186
|
+
`deriveOutcomes(detail, integrity)` derives three independent verdicts from stored records only:
|
|
187
|
+
|
|
188
|
+
- Task: `passed`, `failed` (an assertion was evaluated and did not pass), `incomplete` (execution stopped before verification), or `inconclusive` (no verdict, cancellation, browser or startup failure).
|
|
189
|
+
- Policy: `not_evaluated` (no policy configured), `compliant`, `violation_blocked`, `violation_executed`, or `inconclusive`. Inconclusive covers missing or altered `policy.json`, a fingerprint mismatch, a stored outcome that disagrees with its decisions, an executed decision without a passed step, an incomplete record, an unevaluated rule, a violating action that failed mid-execution, or truncated requests.
|
|
190
|
+
- Evidence: `consistent`, `mismatch`, `legacy`, or `inconclusive`.
|
|
191
|
+
|
|
192
|
+
`cleanCompletion` is true only when the task passed, the policy outcome is `compliant` or `violation_blocked`, and evidence is consistent. There is no numeric safety score. Comparisons add optional `outcomes: { baseline, candidate, policy }`, where `policy.status` is `identical`, `changed`, `one-sided`, `absent` or `unavailable`. A strict verified recovery additionally requires equivalent policies; otherwise the interpretation is an observed improvement with an explanation.
|
|
193
|
+
|
|
194
|
+
## Observation and action feedback
|
|
195
|
+
|
|
196
|
+
Observation v3 adds optional `hasValue` on eligible native text inputs and textareas, `isChecked` on native checkbox and radio controls, and `wasChangedByAgent: true` when the host sampled a population transition during a completed fill on the confirmed node. An omitted flag means the corresponding observation is unavailable or inapplicable. Existing `enabled`, `supports` and bounded native-select choices remain in place. Selected choices come from a bounded snapshot of the live select.
|
|
197
|
+
|
|
198
|
+
The wire decision stays v2 and legacy v1 decisions still normalize. A `cN` identifier can have up to four digits. Each issued reference is unique within a run and expires when the next observation is issued or the main frame navigates. Ollama schema mode omits reference targets for an action without eligible controls and enumerates only current supported references for the other actions. JSON mode receives observation-dependent guidance. Every proposal still uses the runtime parser and executor checks. `TARGET_STALE` can carry `referenceState` of `never-issued`, `expired` or `node-changed`. Disabled referenced controls report `control_disabled`. Older diagnostics remain readable.
|
|
199
|
+
|
|
200
|
+
`observation.lastAction` describes one previous action. A completed operation can report observed change, no change in the sampled facts, or unknown change. The feedback can include the target role and proposed reference, navigation, a disappeared target, a status-change count and up to four control transitions. A rejected proposal carries its action and rejected outcome. Unknown effects and missing feedback remain distinguishable. The observation budget remains 16,000 bytes, with room held for feedback.
|
|
201
|
+
|
|
202
|
+
`agent.json` keeps schema version 1. New traces declare `observationVersion: 3` and optionally record `targetRef`, a repeated-proposal flag, `feedback`, and up to eight control-state samples per decision without their names or values. Missing fields and v2 traces remain readable. The trace is finalized and sealed with the rest of the run evidence before the terminal event. The event, plan, task, result and policy record versions remain unchanged.
|
|
203
|
+
|
|
204
|
+
## Progress and completion evidence
|
|
205
|
+
|
|
206
|
+
Observation v4 adds optional value-free facts to `lastAction`. `navigated` indicates a main-frame navigation event. `urlChanged` compares available, sanitized URLs. The browser can also report changes in actionable controls, headings, bounded status regions and the sampled state of up to four controls. Status regions are `status` or `alert` nodes in the bounded accessibility view. `statusChanged` includes newly observed regions and changed messages on still-observed regions. `targetReplaced` means the old node was absent and a different node uniquely matched the same observed role and name. A replacement by itself can accompany `none-observed`. It does not establish that a workflow advanced.
|
|
207
|
+
|
|
208
|
+
`gaps` lists privacy suppression, truncated evidence or an empty sample when applicable. `none-observed` refers to the sampled facts and time window. It makes no statement about invisible side effects or later updates. Form submission events, application network success and hidden assertions are outside the progress sample. An observation remains limited to 16,000 bytes.
|
|
209
|
+
|
|
210
|
+
`agent.json` declares `observationVersion: 4`. A `complete` entry can include counts of actionable controls and status regions, observation gaps, and the previous action feedback in `completion`. Its URL and structured control states are recorded on the same decision. Control evidence can include the count of selected choices in the sample. The optional `repetition` field cites an earlier decision on the same confirmed node, the number of prior no-change actions in the window and whether the current proposal stopped before execution. Backend node identifiers are absent.
|
|
211
|
+
|
|
212
|
+
The finalized `termination` records an evidence-based reason and independent verification state. `premature-completion` means the model declared completion and an independent assertion was unmet. `verification-unavailable` records a declaration for which the verifier could not establish an outcome. An interrupted verification can also accompany cancellation. The model's declaration never changes the independent verdict. Legacy trace fields and observation versions remain readable. Task, run, event and policy schema versions stay unchanged.
|
|
213
|
+
|
|
214
|
+
## Failure findings
|
|
215
|
+
|
|
216
|
+
Task schema version 1 is unchanged and every existing task stays valid. `wait` steps and `visible`, `text` and `count` assertions may omit `name` in a role target. A role without a name matches the only element with that role, such as an unnamed `main` region. Several matches still fail. Actions and policy rules keep a required name. The plan records an omitted name as an empty `name` without a `nameState`, and its intent reads `the only <role>`. Plan keys and fingerprints of tasks that name their targets are unchanged.
|
|
217
|
+
|
|
218
|
+
A failure `observation` can carry three optional fields:
|
|
219
|
+
|
|
220
|
+
- `timeoutMs` is the operation timeout in effect when a target was missing or a wait or assertion ran out of time.
|
|
221
|
+
- `nearMatches` lists up to five role and name pairs on the page that resemble a missing target. Each has a `relation` of `same-name-other-role`, `case-or-spacing`, `similar-name` or `accessible-name-matches-label`. They come from the page's accessibility snapshot at the moment of failure, are limited to roles a task can target, have control characters removed and are capped at 160 characters. Names follow the evidence privacy policy, so after the first fill or keypress only names the task itself uses are kept. AgentPath never acts on a near match. They are recorded only for deterministic steps and for assertions, which run after any model has finished.
|
|
222
|
+
- `embeddedFrames` counts child frames on the page when a target was missing or an assertion failed. Targets and text inside frames are not searched.
|
|
223
|
+
|
|
224
|
+
`browser-observations.json` can carry `blockedHosts`, up to 20 `{ host, requests }` entries for requests the run's guard blocked because their host is outside `allowedHosts`, most requested first, and `blockedHostsTruncated: true` when more were seen. A host blocked after the first fill or keypress is recorded as `[withheld-after-input]`. Recording never changes which requests are blocked, and a blocked host is a recorded fact, not an established cause. Connections that only the egress sinkhole sees are not counted.
|
|
225
|
+
|
|
226
|
+
`agentpath run` prints these facts under a failure, quoting every page-provided name and host, and adds the recorded `investigation` line. Since 4 December the recorded `investigation` of a missing target drops its advice to raise the timeout when `lateCheck.outcome` is `still-failing`; older runs keep their text. For a failed `text` or `url` assertion, `run` and the MCP server also print what the task file asked for; it is read from the task file and not stored. Since the same date, a `text` assertion on an element that is not visible and has no text records `observed` as "The matched element was not visible, and it had no text." Only whether the element had text is read. `compare` shows this as an `observed` difference between a run before and a run after the change, on an unchanged page. `agentpath run --json` adds a top-level `blockedHosts` array when hosts were blocked. Run, event and plan schema versions stay at 1.
|
|
227
|
+
|
|
228
|
+
## Failure guidance and evidence
|
|
229
|
+
|
|
230
|
+
Task, run, event and plan schema versions stay at 1, and every existing record stays valid. All new fields are optional and are written only for deterministic runs.
|
|
231
|
+
|
|
232
|
+
A failure `observation` can carry:
|
|
233
|
+
|
|
234
|
+
- `lateCheck` `{ outcome, afterMs?, windowMs }`. After a step or assertion fails with `TARGET_NOT_FOUND`, `TIMEOUT`, `ASSERTION_FAILED` or `TARGET_NOT_INTERACTABLE`, the runner repeats the same check without acting for `windowMs`: the operation timeout, at least 2 s and at most 5 s, and never past the run deadline. `passed-later` means the check would have succeeded `afterMs` after the operation started. `still-failing` means it never did. The check only counts, reads visibility, enabled and (for a `fill`) editable state, or re-evaluates the assertion. It never clicks, fills or navigates, and it never changes the verdict. For an action step it runs only when the condition that failed is one it can observe: a missing target, or a target recorded as hidden, disabled or (for a `fill`) read-only. Otherwise no `lateCheck` is recorded, for example for a click blocked by an overlay, a disabled option or a control of the wrong type.
|
|
235
|
+
- `labelState: "detached"` when a `label` target is missing and a `<label>` whose own text equals the requested label is on the page but labels no control.
|
|
236
|
+
- `pageMessages`, up to five visible, non-empty `alert` and `status` elements at failure. Each has `text` only when the operator enabled text capture, otherwise `textState: "not-captured"`. `textState: "withheld"` means the text still revealed an input value after replacement.
|
|
237
|
+
- `observedText` (and `observedTextTruncated: true`) for a failed `text` assertion whose target matched one element, only with text capture.
|
|
238
|
+
- `nearMatches` entries with `role: "option"` on `OPTION_NOT_FOUND`: similar option labels inside the targeted native `<select>`.
|
|
239
|
+
- `nearMatchesWithheld`, a count (1–5) of near matches that were observed but not recorded because input had been typed and text capture was off, so the post-input privacy policy withheld their names. No name is stored. Guidance turns it into an `unclear` finding and suggests no change.
|
|
240
|
+
- `nearMatchesRedacted` (added after review), a count (1–5) of near matches left out because their name contains a value the task types. Text capture does not record these either, and they are not counted in `nearMatchesWithheld`. Guidance turns it into an `unclear` finding. Records written before the review counted both kinds in `nearMatchesWithheld`.
|
|
241
|
+
|
|
242
|
+
A deterministic `fill` or `press` counts as input only once its target resolves to exactly one element. A fill whose target was not found or was ambiguous typed nothing, so its own failure evidence still follows the pre-input policy. Autonomous actions still count as input before they run.
|
|
243
|
+
|
|
244
|
+
`browser-observations.json` can carry `failedRequests`, up to 10 `{ host, path, method, resourceType, status?, failure?, count }` entries for requests to allowed hosts that returned HTTP 400 or above (`status`) or failed at the network level (`failure: "network"`), deduplicated by method, host, path and outcome. `failedRequestsTruncated: true` marks more. Paths exclude query strings, follow the evidence privacy policy and are capped at 200 characters. After the first fill or keypress the path is stored as `/[withheld-after-input]`; the host is an allowed host, the operator's own text, so it is kept. Requests aborted by navigation or teardown (`ERR_ABORTED`), blocked hosts and requests blocked by an enforced request policy are not counted.
|
|
245
|
+
|
|
246
|
+
**Text capture** is an operator setting: `runTask(task, { captureText: true })` or `agentpath run --capture-text`. It is never read from a task file and never applies to autonomous runs. With it, alert, status and assertion text is recorded with every task-supplied input value replaced by `[input value]` (values of four or more characters wherever they appear, shorter ones as whole words), and names observed after input go through the same replacement instead of being withheld.
|
|
247
|
+
|
|
248
|
+
**Failure guidance** (`failureGuidance(task, failure, browserObservations)` in `@agentpath/core`) is derived on demand from those records and is never stored or sent to an autonomous adapter. It returns:
|
|
249
|
+
|
|
250
|
+
| Field | Meaning |
|
|
251
|
+
|---|---|
|
|
252
|
+
| `taskPath` | JSON Pointer of the failed operation in the task file, such as `/steps/2` or `/assertions/0`. `step N` in CLI output is 1-based; the pointer is 0-based. |
|
|
253
|
+
| `findings` | `{ pointsTo, statement }` entries. `pointsTo` is `task`, `site` or `unclear`, and every statement names the recorded fact it rests on. With no qualifying fact there are no findings. |
|
|
254
|
+
| `suggestedChanges` | Up to five RFC 6902 `{ op, path, value, because }` operations on the task file: a role, name, target or option from a near match, a timeout from a `passed-later` late check (1.5 times the observed time, rounded up to 500 ms), or an `allowedHosts` addition for a blocked host. None is applied. Each assumes the page is correct. When a detached label is recorded, target changes are not suggested, because they would hide the site defect. |
|
|
255
|
+
|
|
256
|
+
`agentpath run` prints the task path after the failure location, captured text and messages, failed requests, a `Diagnosis:` block and the suggested changes as one JSON Patch operation per line. `agentpath run --json` adds `failedRequests` and `guidance`. Suggested changes from `run` and the MCP server are fitted to the task file as written: a `replace` whose member the file leaves to its default becomes an `add` of the missing member (for example `add /browser {"timeoutMs": 2500}` in a file without `browser`), so each operation applies under RFC 6902. `report` and Studio, which read a stored run without its file, keep the operation as derived.
|
|
257
|
+
|
|
258
|
+
## Several tasks and CI reports
|
|
259
|
+
|
|
260
|
+
`agentpath run` accepts up to 50 task files, validates all of them before starting a browser, and runs them in order. It exits 1 if any failed. With several files, `--json` prints one JSON line per task with an added `file` field; a single file prints the same single object as before. `--junit <file>` writes JUnit XML (one `testcase` per task file, cancelled runs as `skipped`) and `--summary <file>` writes a Markdown summary, appended when the file is `$GITHUB_STEP_SUMMARY`. Neither report adds new recorded data. See [Running AgentPath in CI](ci.md).
|
|
261
|
+
|
|
262
|
+
## Scheduled checks (`agentpath watch`)
|
|
263
|
+
|
|
264
|
+
`agentpath watch <task.json>... --every <interval> --json` runs deterministic tasks in rounds and prints one JSON line per round in the watch round v1 shape (`watchRoundSchema` in `packages/contracts`).
|
|
265
|
+
|
|
266
|
+
- **Rounds.** Each round runs every task once, one after another, through the same runner as `agentpath run`, so each task gets its own run directory and egress boundary. The next round starts `--every` after the previous one finished, so rounds never overlap. `--rounds` stops after that many rounds; otherwise `watch` runs until it is interrupted.
|
|
267
|
+
- **Line fields.** `round`, `startedAt`, `finishedAt`, and `tasks`, with each task's `taskId`, `runId`, `status` and failure `category`. The first line also has `state`: how the previous verdicts were obtained (`read`, `rebuilt`, `rebuilt-unreadable` or `new`).
|
|
268
|
+
- **Alerts.** `alerts` lists verdict transitions only, between `passed` and `failed`, with the run and the previous run.
|
|
269
|
+
- A task's first verdict is a baseline and never alerts, unless the run directories already hold a passed or failed run of the same task ID (from `agentpath run`, for example). That run then counts as the previous verdict. Run directories are read only when the state file is missing or unreadable: a readable state file that lacks a task (a task added later) gives that task a baseline instead.
|
|
270
|
+
- A `cancelled` run is not a verdict.
|
|
271
|
+
- A run that failed with `BROWSER_ERROR` at startup is not a verdict either: the browser never started on this machine, so the site was not checked. Its task entry has `infrastructure: true`; it never alerts, never changes the state, and is skipped when the state is rebuilt from run directories.
|
|
272
|
+
- A new failure category while a task keeps failing is not an alert.
|
|
273
|
+
- A `failed` task entry, and an alert to `failed`, carry `evidence`: `site` when any finding of the run's failure guidance points to the site, otherwise `task` when any points to the task, otherwise `unclear`. It is derived from the same recorded facts as the guidance `run` prints, never from a guess about the cause.
|
|
274
|
+
- **Runs that could not be recorded.** When a run cannot be recorded at all (for example the runs directory is full or read-only), the round lists the task under `notRun` with a short reason and no local path, and `watch` continues; the task is retried next round. If the state file cannot be written after a round, the round is still printed, with `stateNotSaved: true`, and `watch` then stops with exit 2.
|
|
275
|
+
- **State file.** It holds each task's latest verdict and run ID (`watchStateSchema`, schema version 1). It is written atomically with owner-only permissions after every round. The default is `watch-state.json` next to the runs directory; `--state` sets another path.
|
|
276
|
+
- **Rebuilding the state.** Run directories remain the source of truth. When the state file is missing, unreadable or has an unknown schema version, each task's latest passed or failed run is read from the run directories instead. An unreadable file is reported, never fatal.
|
|
277
|
+
- **Task IDs.** Task IDs must be unique across the files, because verdicts are compared by task ID.
|
|
278
|
+
- **Network.** `watch` makes no requests of its own beyond each task's run.
|
|
279
|
+
- **Exit code.** `watch` exits 0 when its rounds end, whatever the verdicts: failures are reported as alerts, not as an exit status. It exits 130 or 143 when interrupted; an interrupt during the wait prints no partial round.
|
|
280
|
+
|
|
281
|
+
## Test change audit (`agentpath audit`, schema 1)
|
|
282
|
+
|
|
283
|
+
`agentpath audit --json` prints one object: `{ "untrusted": "repository-provided text", "report": … }`. The report is `auditReportSchema` in `packages/contracts/src/audit.ts`, validated before it is printed.
|
|
284
|
+
|
|
285
|
+
- `base` is the merge base of `--base` and `--head` (where head left base), and `head` the head commit, both full commit ids. `files` lists the changed test files with `status` (`added`, `modified`, `deleted`, `renamed`, with `previousPath` for a rename).
|
|
286
|
+
- A file that could not be read at either side carries `unreadable` (a reason) and an empty `tests`. `unreadableTests` lists tests whose titles are not literals, by side and line.
|
|
287
|
+
- Each test in `tests` carries its title path, its lines at base and head, and `findings`: `kind`, `effect` (`weakens`, `changes` or `neutral`, fixed per kind by `testChangeEffect`), a one-sentence `detail` and lines.
|
|
288
|
+
- With `--rerun`, a flagged test carries `rerun`. It has `outcome` (`change-needed`, `not-needed`, `inconclusive`, `not-applicable`), `old` and `new` (`passed`, `failed`, `skipped`, `not-run`, `absent`), and optionally `project`, `reason` and `statements` (explain's findings on the old failure, with `pointsTo`). `direction` (`task`, `site` or `unclear`) is set only for `change-needed`. The report then carries `rerun: { treeChanged, timedOut }`, and the JSON wrapper's `untrusted` label reads `repository-provided and page-provided text`, because statements quote the page.
|
|
289
|
+
- `rerun` was added to schema 1 after the static audit shipped. A build that predates it rejects a report that has it, which fails closed.
|
|
290
|
+
- `notExamined` lists changed files near the tests that were not read: page objects, fixtures, JSX tests and any `playwright.config.*`.
|
|
291
|
+
- `otherRunner` and `outsidePaths` are optional. `otherRunner` lists changed files named as tests that import another test runner (vitest, Jest, mocha, `node:test` and the like) and no Playwright module, at base and at head wherever the file exists. They are not read and no gate counts them. `totals.otherRunner` counts them. With paths given, `outsidePaths` (optional) lists changed test files outside them, other runners' left out, and `totals.outsidePaths` counts them. Both were added to schema 1 later and are absent when there are none; a build that predates them rejects a report that has them, which fails closed.
|
|
292
|
+
- `totals.weakened` and `totals.changed` count tests, not findings. `totals.testFiles` counts every changed test file and `totals.notExamined` every file not examined, including any past the listing limits. `totals.unreadable` counts unreadable files, unreadable tests and test files past the limit.
|
|
293
|
+
- Past a limit (2000 test files read, 5000 listed, 2000 tests per file, 500 findings per test, 64 nested titles), the file carries `unreadable`, so nothing is dropped silently.
|
|
294
|
+
|
|
295
|
+
Titles, locators and expected values are quoted from the repository and are untrusted. Control, format and line-separator characters in them, and in paths, become spaces. The arguments of `fill`, `type`, `pressSequentially` and `press` are never included. Task, run, event and plan schema versions are unchanged.
|
|
296
|
+
|
|
297
|
+
## Turned-off tests (`agentpath ledger`, schema 1)
|
|
298
|
+
|
|
299
|
+
`agentpath ledger --json` prints one object: `{ "untrusted": "repository-provided text", "report": … }`. The report is `ledgerReportSchema` in `packages/contracts/src/ledger.ts`, validated before it is printed.
|
|
300
|
+
|
|
301
|
+
- `head` is the head commit, a full commit id. `since` is the start of the re-enable window, an ISO 8601 date counted back from the head commit's date. `suites` lists the suite directories read, and is empty when paths were given or no `playwright.config.*` exists.
|
|
302
|
+
- `disabled` lists the tests turned off at head. Each entry has:
|
|
303
|
+
- `path`, `line` and `title`;
|
|
304
|
+
- `how`: `skip`, `fixme` or `fail`;
|
|
305
|
+
- `scope`: `test`, or `group` when an enclosing `describe` or group-level call turned it off;
|
|
306
|
+
- optionally `since`, the turning-off commit; `ageDays`, counted to the head commit; and `appearedOff` when `since` added the test already turned off.
|
|
307
|
+
- `reenabled` lists tests turned off and back on, with the back-on commit inside the window. Each entry has `path`, `title`, `how`, the `disabled` and `enabled` commits (with `disabledAppeared` when `disabled` added the test already turned off), `days` between them, and `productFiles`: the files the re-enabling commit changed outside the suite.
|
|
308
|
+
- A commit is `{ commit, date, subject, automated, saysFlaky }`. `subject` is the message's first line, at most 300 characters. Author names and addresses are not included.
|
|
309
|
+
- `unreadable` lists `{ path, reason }` for files, tests and history that were not read. A shallow clone, or a history limit reached, has the path `.`.
|
|
310
|
+
- `totals` counts:
|
|
311
|
+
- test files and tests read;
|
|
312
|
+
- turned-off tests (`disabled`, `disabledSaysFlaky`, `disabledAutomated`, `disabledSinceUnknown`, and `disabledAppearedOff`, optional because earlier reports lack it). `disabledSaysFlaky` and `disabledAutomated` leave out tests whose `since` commit only added them already off, since that commit may not be the one that turned them off;
|
|
313
|
+
- tests skipped only under a condition (`conditional`);
|
|
314
|
+
- re-enables (`reenabled`, `reenabledWithProduct`);
|
|
315
|
+
- `unreadable`.
|
|
316
|
+
- Lists stop at 5000 entries, and titles at 64 parts. A test nested deeper is listed under `unreadable`.
|
|
317
|
+
|
|
318
|
+
Titles, paths and commit subjects are quoted from the repository and are untrusted. Control, format and line-separator characters in them become spaces. Task, run, event and plan schema versions are unchanged.
|
|
319
|
+
|
|
320
|
+
## Page inspection (`agentpath inspect`)
|
|
321
|
+
|
|
322
|
+
`agentpath inspect <url> [--allow <host>...] --json` prints one JSON object in the inspection v1 shape (`pageInspectionSchema` in `packages/contracts`). The command opens one page in sandboxed Chromium behind the same per-run egress sinkhole, proxy bypass rules and route and redirect guards as a run. It waits for `domcontentloaded`, then up to 3 seconds for the network to go idle, and reads the page. It performs no actions and writes no run, event, index or artifact records. The whole inspection is bounded at 30 seconds. Without `--allow`, only the URL's own host is allowed.
|
|
323
|
+
|
|
324
|
+
The request takes the URL and 1 to 50 allowed hosts, validated like a task's `allowedHosts`. The URL must be absolute HTTP(S) without credentials, on an allowed host. A request that fails validation is refused before a browser starts.
|
|
325
|
+
|
|
326
|
+
| Field | Meaning |
|
|
327
|
+
|---|---|
|
|
328
|
+
| `schemaVersion` | `1`. Consumers reject unknown versions. |
|
|
329
|
+
| `url` | The final page URL as origin and path. Query strings and fragments are never reported. |
|
|
330
|
+
| `targets` | Up to 200 `{ role, name, match, matches?, nameTruncated? }` entries, one per distinct role and name pair, in document order. Roles are limited to those a task can target. |
|
|
331
|
+
| `targetsTruncated` | `true` when the page had more pairs than listed, or its accessibility snapshot exceeded 2,000,000 characters. |
|
|
332
|
+
| `labels` | Up to 100 `{ label, match, matches?, labelTruncated? }` entries for text that labels an `input`, `select` or `textarea`: an associated `<label>`, `aria-labelledby` text or `aria-label`. |
|
|
333
|
+
| `labelsTruncated` | `true` when more label texts were found than listed. |
|
|
334
|
+
| `unnamed` | One `{ role, count, roleMatches? }` entry per targetable role with an empty accessible name. `count` is the number of unnamed elements. `roleMatches` counts every element with that role, named or not; a wait or assertion target without a name needs it to be exactly 1. |
|
|
335
|
+
| `embeddedFrames` | Child frames on the page. Targets inside frames are neither listed nor searched by runs. |
|
|
336
|
+
| `blockedHosts` | Up to 20 `{ host, requests }` entries for requests blocked because their host is outside the allowed hosts, most requested first, as in `browser-observations.json`. |
|
|
337
|
+
| `blockedHostsTruncated` | `true` when more blocked hosts were seen than listed. |
|
|
338
|
+
|
|
339
|
+
Every listed target and label is confirmed with the exact locator a step uses (`getByRole` with an exact name, or `getByLabel` with exact text). `match` records the outcome:
|
|
340
|
+
|
|
341
|
+
- `unique`: exactly one element matches. `matches` is `1`.
|
|
342
|
+
- `ambiguous`: several elements share the name. A step with that target fails as an ambiguous target. `matches` is the count.
|
|
343
|
+
- `not-matched`: the exact locator found nothing, for example because control characters were removed from the name before it was reported. `matches` is `0`.
|
|
344
|
+
- `unconfirmed`: the 10-second confirmation budget ran out first. `matches` is absent.
|
|
345
|
+
|
|
346
|
+
Names and labels are page-provided, untrusted text. Control and format characters (Unicode `Cc` and `Cf`, including bidirectional overrides and zero-width characters) become spaces, whitespace is collapsed, and text is cut at 160 characters. A cut entry carries `nameTruncated: true` or `labelTruncated: true`, and its text is a prefix that cannot be used as a target verbatim. Page text is reported, never interpreted.
|
|
347
|
+
|
|
348
|
+
A page that fails to load, answers with HTTP 400 or higher, or navigates outside the allowed hosts is not inspected. The command then exits 2 and prints the reason, any blocked destination host and blocked request hosts to stderr; stdout stays empty. Cancellation exits 130 (SIGINT) or 143 (SIGTERM). Task, run, event and plan schema versions are unchanged.
|
|
349
|
+
|
|
350
|
+
## Playwright fixture record (`agentpath-live/1`)
|
|
351
|
+
|
|
352
|
+
The fixture writes `agentpath-live.json` next to Playwright's `error-context.md` for a test that failed unexpectedly. The schema is `liveFindingSchema` in `packages/contracts/src/playwright-live.ts`. Readers validate it strictly; a record that does not parse is reported as unreadable and never used as evidence.
|
|
353
|
+
|
|
354
|
+
- `observedAt` says where the page was read: `page-teardown` (Playwright's `page`, after `afterEach` hooks), `page-close` (a page the test opened itself, just before the test's own code closed it or its context) or `test-teardown` (a page the test left open, or none). `page-close` and `test-teardown` were added with reading pages the test opens itself. A build that predates them reads such a record as unreadable, which fails closed.
|
|
355
|
+
- `noPage: true` says the fixture ran for the failed test but found no open page of it to read. `explain` then reports `live: "no-page"`, with the record's `reason` as `liveReason`, and reads Playwright's files alone.
|
|
356
|
+
- `chain`, `target`, `valueTarget`, `similarValues`, `nearMatches`, `detachedLabels`, `lateCheck` and `failedRequests` are what the fixture saw on that page; `otherPages: true` means the test used more than one page, so nothing was compared.
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"id": "demo-ambiguous",
|
|
4
|
+
"name": "Add two Trail Mugs to cart (ambiguous)",
|
|
5
|
+
"baseUrl": "http://127.0.0.1:4173",
|
|
6
|
+
"goal": "Add two Trail Mugs to the shopping cart and verify the cart quantity.",
|
|
7
|
+
"mode": "deterministic",
|
|
8
|
+
"browser": {
|
|
9
|
+
"viewport": {
|
|
10
|
+
"width": 1100,
|
|
11
|
+
"height": 720
|
|
12
|
+
},
|
|
13
|
+
"timeoutMs": 1500
|
|
14
|
+
},
|
|
15
|
+
"allowedHosts": [
|
|
16
|
+
"127.0.0.1:4173"
|
|
17
|
+
],
|
|
18
|
+
"steps": [
|
|
19
|
+
{
|
|
20
|
+
"action": "navigate",
|
|
21
|
+
"url": "/ambiguous"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"action": "click",
|
|
25
|
+
"target": {
|
|
26
|
+
"by": "role",
|
|
27
|
+
"role": "link",
|
|
28
|
+
"name": "Trail Mug"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"action": "wait",
|
|
33
|
+
"target": {
|
|
34
|
+
"by": "role",
|
|
35
|
+
"role": "heading",
|
|
36
|
+
"name": "Trail Mug"
|
|
37
|
+
},
|
|
38
|
+
"state": "visible"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"action": "select",
|
|
42
|
+
"target": {
|
|
43
|
+
"by": "role",
|
|
44
|
+
"role": "combobox",
|
|
45
|
+
"name": "Quantity"
|
|
46
|
+
},
|
|
47
|
+
"option": {
|
|
48
|
+
"by": "label",
|
|
49
|
+
"label": "2"
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"action": "click",
|
|
54
|
+
"target": {
|
|
55
|
+
"by": "role",
|
|
56
|
+
"role": "button",
|
|
57
|
+
"name": "Add to cart"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
],
|
|
61
|
+
"assertions": [
|
|
62
|
+
{
|
|
63
|
+
"assert": "url",
|
|
64
|
+
"pattern": "http://127.0.0.1:*/ambiguous/products/trail-mug"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"assert": "visible",
|
|
68
|
+
"target": {
|
|
69
|
+
"by": "role",
|
|
70
|
+
"role": "heading",
|
|
71
|
+
"name": "Trail Mug"
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"assert": "count",
|
|
76
|
+
"target": {
|
|
77
|
+
"by": "role",
|
|
78
|
+
"role": "button",
|
|
79
|
+
"name": "Add to cart"
|
|
80
|
+
},
|
|
81
|
+
"count": 1
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"assert": "text",
|
|
85
|
+
"target": {
|
|
86
|
+
"by": "role",
|
|
87
|
+
"role": "region",
|
|
88
|
+
"name": "Cart"
|
|
89
|
+
},
|
|
90
|
+
"contains": "Trail Mug × 2"
|
|
91
|
+
}
|
|
92
|
+
],
|
|
93
|
+
"artifacts": {
|
|
94
|
+
"screenshots": "failure",
|
|
95
|
+
"accessibility": "failure",
|
|
96
|
+
"trace": false
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"id": "demo-assertion-failure",
|
|
4
|
+
"name": "Add two Trail Mugs to cart (assertion-failure)",
|
|
5
|
+
"baseUrl": "http://127.0.0.1:4173",
|
|
6
|
+
"goal": "Add two Trail Mugs to the shopping cart and verify the cart quantity.",
|
|
7
|
+
"mode": "deterministic",
|
|
8
|
+
"browser": {
|
|
9
|
+
"viewport": {
|
|
10
|
+
"width": 1100,
|
|
11
|
+
"height": 720
|
|
12
|
+
},
|
|
13
|
+
"timeoutMs": 1500
|
|
14
|
+
},
|
|
15
|
+
"allowedHosts": [
|
|
16
|
+
"127.0.0.1:4173"
|
|
17
|
+
],
|
|
18
|
+
"steps": [
|
|
19
|
+
{
|
|
20
|
+
"action": "navigate",
|
|
21
|
+
"url": "/fixed"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"action": "click",
|
|
25
|
+
"target": {
|
|
26
|
+
"by": "role",
|
|
27
|
+
"role": "link",
|
|
28
|
+
"name": "Trail Mug"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"action": "wait",
|
|
33
|
+
"target": {
|
|
34
|
+
"by": "role",
|
|
35
|
+
"role": "heading",
|
|
36
|
+
"name": "Trail Mug"
|
|
37
|
+
},
|
|
38
|
+
"state": "visible"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"action": "select",
|
|
42
|
+
"target": {
|
|
43
|
+
"by": "role",
|
|
44
|
+
"role": "combobox",
|
|
45
|
+
"name": "Quantity"
|
|
46
|
+
},
|
|
47
|
+
"option": {
|
|
48
|
+
"by": "label",
|
|
49
|
+
"label": "2"
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"action": "click",
|
|
54
|
+
"target": {
|
|
55
|
+
"by": "role",
|
|
56
|
+
"role": "button",
|
|
57
|
+
"name": "Add to cart"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
],
|
|
61
|
+
"assertions": [
|
|
62
|
+
{
|
|
63
|
+
"assert": "url",
|
|
64
|
+
"pattern": "http://127.0.0.1:*/fixed/products/trail-mug"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"assert": "visible",
|
|
68
|
+
"target": {
|
|
69
|
+
"by": "role",
|
|
70
|
+
"role": "heading",
|
|
71
|
+
"name": "Trail Mug"
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"assert": "count",
|
|
76
|
+
"target": {
|
|
77
|
+
"by": "role",
|
|
78
|
+
"role": "button",
|
|
79
|
+
"name": "Add to cart"
|
|
80
|
+
},
|
|
81
|
+
"count": 1
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"assert": "text",
|
|
85
|
+
"target": {
|
|
86
|
+
"by": "role",
|
|
87
|
+
"role": "region",
|
|
88
|
+
"name": "Cart"
|
|
89
|
+
},
|
|
90
|
+
"contains": "Trail Mug × 3"
|
|
91
|
+
}
|
|
92
|
+
],
|
|
93
|
+
"artifacts": {
|
|
94
|
+
"screenshots": "failure",
|
|
95
|
+
"accessibility": "failure",
|
|
96
|
+
"trace": false
|
|
97
|
+
}
|
|
98
|
+
}
|