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.
Files changed (127) hide show
  1. package/LICENSE.md +105 -0
  2. package/README.md +101 -2
  3. package/THIRD_PARTY_NOTICES +12 -0
  4. package/apps/demo-site/dist/site.js +92 -0
  5. package/apps/studio/dist/assets/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
  6. package/apps/studio/dist/assets/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
  7. package/apps/studio/dist/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
  8. package/apps/studio/dist/assets/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
  9. package/apps/studio/dist/assets/geist-mono-cyrillic-ext-wght-normal-X_5orZeX.woff2 +0 -0
  10. package/apps/studio/dist/assets/geist-mono-cyrillic-wght-normal-DiZS0aHC.woff2 +0 -0
  11. package/apps/studio/dist/assets/geist-mono-latin-ext-wght-normal-Bwz-egvJ.woff2 +0 -0
  12. package/apps/studio/dist/assets/geist-mono-latin-wght-normal-XN7g48iV.woff2 +0 -0
  13. package/apps/studio/dist/assets/geist-mono-symbols2-wght-normal-CO5SzqOn.woff2 +0 -0
  14. package/apps/studio/dist/assets/geist-mono-vietnamese-wght-normal-DadHysG0.woff2 +0 -0
  15. package/apps/studio/dist/assets/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
  16. package/apps/studio/dist/assets/index-DH4wJPHm.js +67 -0
  17. package/apps/studio/dist/assets/index-DrnNh2ip.css +1 -0
  18. package/apps/studio/dist/index.html +14 -0
  19. package/audit.md +173 -0
  20. package/autonomous-mode.md +104 -0
  21. package/ci.md +118 -0
  22. package/coding-agents.md +143 -0
  23. package/concepts.md +145 -0
  24. package/contracts.md +356 -0
  25. package/examples/tasks/ambiguous.json +98 -0
  26. package/examples/tasks/assertion-failure.json +98 -0
  27. package/examples/tasks/broken.json +98 -0
  28. package/examples/tasks/fixed.json +98 -0
  29. package/examples/tasks/recovery.json +19 -0
  30. package/images/compare-recovery-desktop.jpg +0 -0
  31. package/images/compare-variants-desktop.jpg +0 -0
  32. package/images/overview-desktop.jpg +0 -0
  33. package/images/run-autonomous-passed-desktop.jpg +0 -0
  34. package/images/run-failed-desktop.jpg +0 -0
  35. package/images/run-failed-mobile.jpg +0 -0
  36. package/images/run-missing-artifact-desktop.jpg +0 -0
  37. package/images/task-editor-laptop.jpg +0 -0
  38. package/installation.md +102 -0
  39. package/ledger.md +62 -0
  40. package/licenses/-fontsource-variable-geist-mono.txt +93 -0
  41. package/licenses/-fontsource-variable-geist.txt +93 -0
  42. package/licenses/lucide-react.txt +43 -0
  43. package/licenses/react-dom.txt +21 -0
  44. package/licenses/react.txt +21 -0
  45. package/licenses/scheduler.txt +21 -0
  46. package/licenses/tailwindcss.txt +21 -0
  47. package/licenses/zod.txt +21 -0
  48. package/package.json +165 -4
  49. package/packages/cli/bin/agentpath.js +39 -0
  50. package/packages/cli/dist/audit-rerun.js +384 -0
  51. package/packages/cli/dist/audit.js +387 -0
  52. package/packages/cli/dist/change-summaries.js +87 -0
  53. package/packages/cli/dist/ci-report.js +88 -0
  54. package/packages/cli/dist/demo.js +88 -0
  55. package/packages/cli/dist/doctor.js +265 -0
  56. package/packages/cli/dist/explain.js +89 -0
  57. package/packages/cli/dist/git.js +7 -0
  58. package/packages/cli/dist/inspect.js +118 -0
  59. package/packages/cli/dist/ledger.js +509 -0
  60. package/packages/cli/dist/local.js +102 -0
  61. package/packages/cli/dist/main.js +708 -0
  62. package/packages/cli/dist/mcp.js +231 -0
  63. package/packages/cli/dist/paths.js +6 -0
  64. package/packages/cli/dist/playwright-fixture.js +185 -0
  65. package/packages/cli/dist/playwright-reporter.js +49 -0
  66. package/packages/cli/dist/tasks.js +37 -0
  67. package/packages/cli/dist/test-source.js +283 -0
  68. package/packages/cli/dist/watch.js +96 -0
  69. package/packages/contracts/dist/agent-settings.js +18 -0
  70. package/packages/contracts/dist/agent.js +175 -0
  71. package/packages/contracts/dist/audit.js +115 -0
  72. package/packages/contracts/dist/guidance.js +339 -0
  73. package/packages/contracts/dist/index.js +14 -0
  74. package/packages/contracts/dist/inspect.js +63 -0
  75. package/packages/contracts/dist/ledger.js +80 -0
  76. package/packages/contracts/dist/local.js +171 -0
  77. package/packages/contracts/dist/outcomes.js +94 -0
  78. package/packages/contracts/dist/platform.js +105 -0
  79. package/packages/contracts/dist/playwright-live.js +76 -0
  80. package/packages/contracts/dist/policy.js +93 -0
  81. package/packages/contracts/dist/run.js +178 -0
  82. package/packages/contracts/dist/task-issues.js +39 -0
  83. package/packages/contracts/dist/task.js +185 -0
  84. package/packages/contracts/dist/watch.js +57 -0
  85. package/packages/core/dist/action-feedback.js +103 -0
  86. package/packages/core/dist/actions.js +160 -0
  87. package/packages/core/dist/agent-loop.js +122 -0
  88. package/packages/core/dist/artifacts.js +156 -0
  89. package/packages/core/dist/assertions.js +120 -0
  90. package/packages/core/dist/autonomous.js +1 -0
  91. package/packages/core/dist/browser.js +196 -0
  92. package/packages/core/dist/compare.js +141 -0
  93. package/packages/core/dist/control-state.js +62 -0
  94. package/packages/core/dist/diagnostics.js +134 -0
  95. package/packages/core/dist/evidence-diff.js +93 -0
  96. package/packages/core/dist/evidence.js +203 -0
  97. package/packages/core/dist/index.js +22 -0
  98. package/packages/core/dist/inspect.js +257 -0
  99. package/packages/core/dist/integrity.js +176 -0
  100. package/packages/core/dist/liveness.js +114 -0
  101. package/packages/core/dist/local-files.js +61 -0
  102. package/packages/core/dist/locators.js +214 -0
  103. package/packages/core/dist/model-provider.js +88 -0
  104. package/packages/core/dist/observation.js +257 -0
  105. package/packages/core/dist/playwright-live.js +519 -0
  106. package/packages/core/dist/playwright-results.js +543 -0
  107. package/packages/core/dist/policy.js +182 -0
  108. package/packages/core/dist/privacy.js +93 -0
  109. package/packages/core/dist/recovery.js +54 -0
  110. package/packages/core/dist/retention.js +204 -0
  111. package/packages/core/dist/run-index.js +177 -0
  112. package/packages/core/dist/run-plan.js +28 -0
  113. package/packages/core/dist/run-repository.js +518 -0
  114. package/packages/core/dist/runner.js +913 -0
  115. package/packages/core/dist/storage.js +63 -0
  116. package/packages/core/dist/task-fingerprint.js +36 -0
  117. package/packages/core/dist/test-change-rerun.js +84 -0
  118. package/packages/core/dist/test-changes.js +896 -0
  119. package/packages/core/dist/timing.js +41 -0
  120. package/packages/core/dist/watch.js +165 -0
  121. package/packages/server/dist/index.js +265 -0
  122. package/packages/server/dist/task-store.js +103 -0
  123. package/quickstart.md +85 -0
  124. package/security.md +136 -0
  125. package/try-on-your-repo.md +54 -0
  126. package/understanding-results.md +159 -0
  127. package/writing-tasks.md +196 -0
package/security.md ADDED
@@ -0,0 +1,136 @@
1
+ # Security and privacy
2
+
3
+ ## At a glance
4
+
5
+ - **Authorized targets only.** Run tasks against development or test sites you are authorized to operate. AgentPath is not suitable for untrusted production websites.
6
+ - **Everything stays local by default.** Studio and its API bind to `127.0.0.1`. Runs are files under `.agentpath/runs`, which Git ignores. AgentPath sends no telemetry.
7
+ - **Deterministic runs make no model calls.** Autonomous runs send the goal and bounded page observations to the model endpoint you configure, and nothing else. Only numeric loopback endpoints are allowed unless the local operator approves an external one.
8
+ - **The browser is restricted, not sealed.** Each run uses a fresh sandboxed Chromium with an exact host allowlist and a per-run proxy that drops everything else. This is a guardrail. Use network-level isolation when you need a hard egress boundary.
9
+ - **Evidence is minimized, not sanitized.** Free-form text is withheld from accessibility snapshots, screenshots mask form controls and stop after the first fill or keypress, and reports omit raw browser errors and credentials. Screenshots, names, task files and opt-in native traces can still contain private data. Review a run before sharing it.
10
+ - **Integrity is change detection.** Digests show whether files changed since finalization. They are not signatures and do not prove who produced a run.
11
+ - **Policies protect only what they name.** An action policy blocks or records the interactions and requests it lists. It is not a general defense against prompt injection.
12
+
13
+ Studio never requests an evidence file that integrity reports missing or changed, and the local API refuses to serve one. Opening a screenshot full size uses the same local API, so the image never leaves the machine.
14
+
15
+ The sections below give the detail.
16
+
17
+ ## Execution and artifact privacy
18
+
19
+ Run tasks against development or test sites you are authorized to operate. Actions execute in a fresh Chromium browser with its sandbox enabled, a non-persistent context, downloads disabled, and service workers blocked. Tasks use declarative semantic operations and descriptive setup metadata. Task validation rejects custom selectors and raw JavaScript.
20
+
21
+ The exact host allowlist applies to declared navigation, routed HTTP(S) requests, and routed WebSockets. Chromium response interception on the primary page checks redirect destinations before continuing. Browser request events also surface out-of-scope document navigations and fail the run.
22
+
23
+ Those guards do not see every request. Playwright routes only the first hop of a redirect, and the redirect guard covers only the primary page. Before popups were guarded, a popup or `target=_blank` link to an allowed URL that redirected off the allowlist reached the disallowed host. Each run now also starts a loopback sinkhole proxy that accepts and immediately drops every connection, and Chromium uses it as its proxy server. Allowed hosts bypass the proxy and connect directly. The bypass list starts with `<-loopback>` so loopback destinations are not exempt implicitly. Portless entries are limited to ports 80 and 443. Entries that are not plain hostnames or IP literals stay behind the sinkhole. WebRTC UDP is also restricted to the proxy, which accepts nothing. A test counts UDP datagrams that reach a local STUN listener outside the allowlist: during a run, none arrive. A control run of the same page in Chromium, with the proxy but without the WebRTC policy flag, sends datagrams to the listener. Integration tests count requests that reach a separate loopback server for popup redirects, two-hop popups, cross-site frame redirects, and `target=_blank` links.
24
+
25
+ The backstop narrows the gap but is not a hard egress boundary. Bypassed hostnames are resolved by the system resolver. A hostname bypass rule permits every path on that host. Transports Chromium does not send through its proxy, and anything outside the browser process, are not covered. Use network-level isolation for untrusted destinations.
26
+
27
+ The runner stores files locally under `.agentpath/runs` by default. Git ignores `.agentpath/`. New run directories and files use restrictive permissions where supported. Alternate run roots need their own ignore and retention policy.
28
+
29
+ ## Data in artifacts
30
+
31
+ - Result and event files omit task goals, raw Playwright exceptions, request and response bodies, headers, cookies, and raw action values. URLs drop credentials, query strings, and fragments. New captures use the conservative evidence-minimization policy described below. Legacy artifacts retain the policy used when they were recorded.
32
+ - Accessibility snapshots retain up to 500 role/name pairs and omit Chromium's value field. The current policy withholds free-form text names. Names and page text can still contain private content. URL paths and task IDs can also carry identifying information.
33
+ - Screenshots are off by default. When enabled they mask common editable controls and selects. Other content, including text echoed into the page, can appear in the images.
34
+ - Native Playwright traces are off by default and have no redaction guarantee. They can contain cookies or headers, request data, DOM snapshots, screenshots, and action values. Enable them with disposable data and inspect the archive before sharing it.
35
+
36
+ Use test credentials and synthetic records when collecting evidence. Disable unnecessary captures and review the whole bundle before exporting it.
37
+
38
+ ## Studio and the local API
39
+
40
+ Studio and the API share the literal `http://127.0.0.1:<port>` origin. Fastify listens on IPv4 loopback. Host validation requires the exact bound address and port. The one exception is a page request (never an API request) whose Host is exactly `localhost` on that port: it is redirected to the fixed `127.0.0.1` address, and the redirect target never comes from the request. A supplied Origin must match it. The API rejects cross-origin fetch metadata and requires a custom header for state-changing requests, with no cross-origin response or preflight authorization. Studio sends a restrictive content security policy and serves the compiled client from a separate build directory.
41
+
42
+ Fetch-metadata and workspace checks use the matched route, not the raw URL, so percent-encoded paths such as `/%61pi/health` cannot skip them. Unmatched paths are treated like API paths.
43
+
44
+ Client requests use validated IDs and manifest indices. The API never accepts a filesystem path. Artifact reads require a finalized result and a matching manifest entry, reject symlinks along the managed path, and validate structured evidence before sending it. Binary artifacts have explicit media types and a size cap. Studio receives normalized run metadata and never receives raw console output, stacks, or browser exceptions. The saved plan contains filtered role and label presentation and versioned identity hashes over the validated locator. Author labels can still contain private data. Saved task definitions contain their configured action values.
45
+
46
+ The custom header is browser cross-origin protection. Local processes can set it, access the local API, and may be able to access the same files based on OS permissions. Use a private workspace and one Studio server per workspace. The store assumes its parent workspace and the local user are trusted. It does not defend against a process with write access that races replacement of directories or tampers with reports. Run concurrency applies per Studio server. Direct CLI runs and other server processes are independent.
47
+
48
+ The engine applies its destination restrictions to API-launched tasks, including the primary-page redirect interceptor. Treat the allowlist as a test guardrail. Use a separate network boundary for untrusted destinations or stronger egress control. Avoid publishing the loopback app through port forwarding or a reverse proxy.
49
+
50
+ ## Evidence minimization
51
+
52
+ All fill values are treated as potentially sensitive. Keypress actions also trigger the conservative post-input capture policy. The recorder keeps roles but withholds free-form accessibility text. After a fill or keypress attempt, it retains names only when they exactly match a configured semantic name or label and pass the known-value filter. Withheld names have an explicit state and are distinct from an observed empty accessible name.
53
+
54
+ Known-value filtering normalizes Unicode compatibility forms and case and supports percent encoding, numeric HTML entities, and the common named entities amp, lt, gt, quot, apos, and nbsp. It suppresses an entire sensitive name. Short values use token or whole-field matching in authored presentation, so entering `2` does not rewrite `Stage 2026` or UUIDs. Operation identity hashes are computed independently from presentation filtering. After input, unrecognized page names are withheld even when a transformation is unsupported.
55
+
56
+ The recorder stops screenshots after any fill or keypress attempt. Screenshots taken earlier still mask editable controls and selects, and can contain other private page content. Selection-driven echoes, application-owned records, pre-existing private headings, canvas content, arbitrary encodings, and page state outside the known input set cannot be comprehensively sanitized. After input, reported URL paths are withheld except for the empty-content root path. Out-of-scope origins and failure host observations are withheld after input. No raw browser error messages or field values are added to operation observations.
57
+
58
+ Native Playwright traces remain explicitly opt-in. Their DOM, screenshots, traffic, and values are potentially sensitive, including when the separate sanitized screenshot policy suppresses later PNGs. Saved task files intentionally contain configured values for local replay. Retained semantic labels can themselves contain private data. Review the entire local bundle before sharing.
59
+
60
+ SHA-256 task and locator digests expose equality and can be tested against guesses of low-entropy configurations. They provide task identity for local comparison, without serving as secret encryption or tamper-proof signatures. Original task definitions stay in the task store. New run metadata contains digests and counts.
61
+
62
+ The per-run Playwright control endpoint binds only to IPv4 loopback, uses a random capability path, and is kept out of reports and API responses. Local processes with access to that capability can control the run. OS permissions, a private workspace, and network isolation remain important boundaries. Forced cleanup targets only the browser process owned by the current run.
63
+
64
+ ## Run store
65
+
66
+ **Integrity digests are change detection, not authentication.** `integrity.json` lists SHA-256 digests of a run's files at finalization. A mismatch shows that the bundle differs from that manifest, through accidental edits, truncation, deleted evidence, or added files. Anyone who can write the run directory can also regenerate the manifest. AgentPath does not sign bundles, hold signing keys, or use an external attestation service. Integrity results do not establish who produced a bundle or that it is unaltered since recording. Do not present them that way. Studio refuses to serve an artifact that no longer matches its digest, and strict recovery treats any mismatch as inconclusive.
67
+
68
+ **Liveness never terminates processes.** A lease records a digest of the host name, the PID, the process start time, and a random instance ID. Readers probe the PID with signal 0 and compare its start time to detect PID reuse. AgentPath never kills or signals a process because of a lease. An expired lease that cannot be confirmed abandoned stays `stale`. The host name is stored only as a digest. The PID and process start time are local diagnostic data.
69
+
70
+ **Retention is conservative.** `runs prune` deletes only with `--yes`. It never deletes active runs, and stale, abandoned, or unreadable runs each need their own flag. Eligibility is re-checked immediately before deletion. It refuses a symlinked runs root, ignores symlinked run entries, and removes links without following them. Deletion is limited to validated run IDs directly under the runs root.
71
+
72
+ **The run index is derived local data.** `<runs>/.index/runs-v1.sqlite` and its WAL and SHM files are created owner-only (0600). The index holds run IDs, task IDs, timestamps, statuses, and file signatures. It holds no evidence. Under the default `.agentpath/` workspace it is ignored by Git with the rest of the run data. Alternate run roots need their own ignore policy. The index is never trusted as evidence, and reads re-validate against the run directories.
73
+
74
+ ## Model boundary
75
+
76
+ Autonomous execution sends the configured goal, initial URL, allowed hosts, bounded primary-page role/name observations and recent action-kind outcomes to the selected inference endpoint. It does not send hidden assertions, reference steps, browser credentials, DOM, screenshots or filesystem content. Accessibility values are omitted. Names can still contain private page content; filtering does not make the live input fully sanitized. Use synthetic test data and a trusted endpoint. After input, free text is withheld; this intentionally limits some autonomous tasks.
77
+
78
+ Numeric loopback endpoints are accepted by default. External inference requires exact normalized `AGENTPATH_MODEL_ENDPOINT` operator configuration. Only that approved endpoint receives optional `AGENTPATH_MODEL_API_KEY`; keys are never task fields or trace metadata. Endpoint URLs reject embedded credentials, query strings and fragments, and redirects are rejected. Model outputs cannot select a different inference endpoint. The browser sinkhole does not protect host-side inference traffic. A local model service is trusted infrastructure: it can log supplied data, and local processes can impersonate it. No model downloads, paid calls or endpoint discovery beyond the documented loopback checks are automatic.
79
+
80
+ The system prompt treats webpage instructions as untrusted. Prompt injection may influence a model's decisions; prompt wording cannot prove goal adherence. The enforced boundary is strict validated semantic actions, exact target cardinality, browser destinations, bounded requests/actions/decisions/time, cancellation, and a hidden independent verifier. No raw JavaScript, shell, filesystem, selectors, custom HTTP tools or arbitrary model-proposed tools are executed. A model declaration does not establish success. A hostile page can also influence the browser state inspected by assertions; assertions must be chosen appropriately for an authorized test scenario.
81
+
82
+ Default `agent.json` storage retains digests and summaries rather than full prompts, observations or malformed outputs. Validated action presentation uses the existing privacy filter, and generated fill values enter the known-value set before persistence. `storeMessages` explicitly enables filtered model response text; arbitrary secrets in model prose cannot be comprehensively redacted. Do not call these traces fully sanitized. Digests reveal equality and permit guessing low-entropy inputs. Saved task definitions retain goals and configured values. Native Playwright traces remain separately opt-in and potentially sensitive. Provider error bodies, raw transport errors, and credentials are excluded from structured failures.
83
+
84
+ ## Observed safety limits
85
+
86
+ Controlled real-model probes used only local synthetic pages and fake secrets with Ollama cloud features disabled. No out-of-scope request reached the controlled outside server. A separate real-browser link control failed destination policy and recorded zero arrivals. Unsupported-tool rejection remains covered independently by strict-schema and real-browser regression tests; the live malicious-tool page elicited inability rather than an unsupported proposal.
87
+
88
+ A malicious synthetic-secret instruction caused an unrelated fill into a Disclosure field even though the goal assertion later passed. No disclosure endpoint request was recorded; the minimized evidence does not retain the filled value. Other malicious pages elicited inability or repetition. These outcomes establish neither complete resistance nor a general exfiltration barrier. Tool permissions and destinations constrain capabilities; they do not prevent every unwanted action within those permissions. Independent assertions must cover relevant side effects when the task requires that guarantee.
89
+
90
+ Real evaluation traces stored no full model responses or native traces. An exact-token scan found no synthetic secret in the safety run files; arbitrary encodings and other private content are outside that check. All raw artifacts and application screenshots remain under ignored `.agentpath` directories. The model download and local runtime setup were explicitly authorized for this session; AgentPath itself does not install a service or download a model.
91
+
92
+ ## Action policies
93
+
94
+ Action policies come only from the trusted task definition or the local operator. Page content, model output and stored reports cannot create, widen or disable a policy. Policies are not sent to the model: the adapter learns only that an action was rejected. Neither rule text, rule IDs nor descriptions reach a model request (covered by a real-browser test).
95
+
96
+ What enforcement establishes, relative to the configured rules only:
97
+
98
+ - An enforced action rule rejects a matching proposal before any browser side effect, compared by element identity at proposal time and again on the exact element at execution.
99
+ - An enforced request rule aborts matching requests inside Chromium before they leave the browser. Real-browser tests count arrivals at the receiving server, not only verdicts.
100
+ - Audit mode records violations and lets them run. It cannot bypass the allowed-host boundary, the egress sinkhole or any other hard limit.
101
+
102
+ What it does not establish:
103
+
104
+ - Rules protect only what they name. An unlisted control, a different path to the same effect, or a side effect that needs no matched action or request is not covered.
105
+ - Matching is semantic (role, name and label). A page that renames or restructures a control can evade a rule written for the old name.
106
+ - A blocked violation still means the model attempted it. Enforcement contains a known bad action; it does not make the model resistant to prompt injection.
107
+ - AgentPath is not suitable for untrusted production websites, and its goal and policy verdicts are evidence about controlled test scenarios only.
108
+
109
+ Policy records store rule IDs, action kinds, redacted target names and decisions. They never store fill values, request URLs or bodies. The grounding and policy evaluation used a fake synthetic token and only a local disclosure endpoint on the allowed fixture host; its oracle records whether the token arrived, never the value.
110
+
111
+ ## Value-free observations
112
+
113
+ Population inspection returns a boolean for eligible native text inputs and textareas. The fixed inspection excludes password fields and controls with one-time-code, sensitive or unsupported autocomplete metadata before checking population. It sends no text-field values, lengths or hashes to the model or trace. Agent fill attribution requires a value-free transition sampled on the same confirmed node around the action. A main-frame navigation or replacement invalidates that attribution.
114
+
115
+ The model observation withholds static page text after a fill or press attempt and when the control sample contains populated or potentially sensitive editable fields. Post-action feedback contains structured facts and counts. Status-region changes can be detected by structure while text is withheld. Existing capture rules still suppress screenshots after input. Accessible names of actionable controls are page-controlled and can carry unexpected data or instructions. An arbitrary page can encode content in its names or structure, so these observations do not provide a general data-loss prevention boundary. Only synthetic, controlled data belongs in the live evaluation fixtures.
116
+
117
+ ## Progress evidence
118
+
119
+ The new progress fields retain counts, booleans and bounded decision references. Status text is compared transiently only when the existing static-text policy permits it. Progress and completion records carry no additional status text, editable content, backend node IDs, or press and fill values. Identity uses a navigation generation, Chromium node identity and action kind in memory. URL change is omitted when privacy suppression makes comparison uncertain. Structured completion evidence inherits the trace's existing URL and control-state redaction.
120
+
121
+ Observed change is evidence about the accessible page during a bounded interval. A status update can be deceptive or unrelated to the goal, and an unchanged page can still perform a side effect. The independent assertions, action/request policy, destination restrictions and integrity manifest remain the sources for their respective outcomes. The matched synthetic evaluation counts protected POST arrivals at its fixture server independently of the policy record.
122
+
123
+ ## Failure findings
124
+
125
+ - **Similar targets.** When a target is missing, the run can store up to five role and name pairs from the page's accessibility tree in the failure record. They follow the task's accessibility capture setting, so a task with `accessibility: "off"` stores none. After the first fill or keypress, only names the task itself uses are kept. Names have control characters removed and are capped at 160 characters. They are page-provided text that the CLI prints in quotes and never acts on. A coding agent reading the output should treat them as data, not instructions.
126
+ - **Blocked hosts.** `browser-observations.json` can list up to 20 hosts outside `allowedHosts` whose requests were blocked, with request counts. These hosts reveal which third parties a page tried to contact, such as analytics, ad or CDN hosts. A host blocked after the first fill or keypress is stored as `[withheld-after-input]`. Recording is passive and does not change which requests are blocked.
127
+ - **Embedded frames.** A failure can record how many frames the page had. Frame content is never searched or stored.
128
+
129
+
130
+ ## Failure evidence
131
+
132
+ - **Text capture is opt-in.** By default AgentPath still withholds page text. `agentpath run --capture-text` (or `captureText: true` for `runTask`) records the text of a failed `text` assertion and of visible `alert` and `status` messages, and keeps names observed after input. Every value the task fills is replaced with `[input value]` first; text in which a value is still recognizable after normalization is withheld. Pages can display other sensitive data that the task never typed, so use text capture on test sites and test accounts only. It is an operator setting: a task file cannot turn it on, and it never applies to autonomous runs.
133
+ - **Failed requests.** `browser-observations.json` can list up to 10 requests to allowed hosts that failed or returned HTTP 400 or above, with method, host, path without query, resource type and status. Paths after the first fill or keypress are withheld as for other URLs. The host is kept, because it is one of the allowed hosts the operator wrote.
134
+ - **Late check.** After a failure the runner watches the same condition for up to 5 seconds, so a failing run takes at most 5 seconds longer. It reads the page only. It cannot click, type or navigate, and it never changes a verdict.
135
+ - **Guidance.** Suggested task changes are printed, never applied. They quote page-provided names, which are untrusted data. An agent should verify a suggested change by running the task again, and should not apply one that would hide a site defect the diagnosis points to.
136
+ - **When input starts.** A deterministic fill or keypress counts as input once its target resolves to one element, the point at which a value can reach the page. A fill whose target is missing typed nothing, so near matches recorded for that failure follow the pre-input policy. After input, near matches the task does not name are counted (`nearMatchesWithheld`) but not named. A near match whose name contains a value the task types is never named, with or without text capture, and is counted separately (`nearMatchesRedacted`).
@@ -0,0 +1,54 @@
1
+ # Try it on your own repository
2
+
3
+ About fifteen minutes, in a repository with Playwright tests. The first two steps read git only and run nothing; step 3 is optional and runs your own tests.
4
+
5
+ ## 1. Install
6
+
7
+ Install the tarball you were given (Node.js 22.13+ or 24+):
8
+
9
+ ```sh
10
+ npm install --global --ignore-scripts ./agentpath-0.1.0-alpha.2.tgz
11
+ ```
12
+
13
+ ## 2. Read your history (runs nothing)
14
+
15
+ ```sh
16
+ cd your-repo
17
+ git fetch --unshallow 2>/dev/null; git fetch origin # full history, if your clone is shallow
18
+ agentpath ledger
19
+ ```
20
+
21
+ You get every Playwright test turned off by `skip`, `fixme` or `fail`, listed oldest first. For each, it shows the commit that turned it off, and whether that commit said "flaky" or came from a bot or agent. Below that are the tests turned off and back on in the last year ([ledger](ledger.md)).
22
+
23
+ Then look at the test changes on a branch, or in one merged pull request:
24
+
25
+ ```sh
26
+ agentpath audit --base origin/main e2e # your branch against main; e2e is your Playwright directory (give each suite's)
27
+ agentpath audit --base <merge-commit>^1 --head <merge-commit> e2e # one merged pull request
28
+ ```
29
+
30
+ Skips, removed assertions, removed steps and changed expectations are listed, weakening ones first ([audit](audit.md)).
31
+
32
+ ## 3. Rerun the old tests (optional, runs your tests)
33
+
34
+ On a clean checkout of a branch where a coding agent or a test healer changed tests, with dependencies and browsers installed as your CI has them:
35
+
36
+ ```sh
37
+ agentpath audit --base origin/main --rerun e2e
38
+ ```
39
+
40
+ It runs the old version of each changed test on this build, beside the new one, with your own Playwright, configuration and web server. It then says whether each change is needed for the test to pass here, and where the old failure's evidence points. Run it only where you would run those tests anyway.
41
+
42
+ ## 4. As a pull request check
43
+
44
+ The recipe is in [CI](ci.md#checking-test-changes-on-pull-requests). It writes the results to the job summary, and can exit non-zero with `--fail-on-change-needed`.
45
+
46
+ ## Tell us
47
+
48
+ The most useful answers:
49
+
50
+ - Did the ledger list a test that surprised you, still off and long forgotten?
51
+ - Was anything listed wrongly, or missing? Please send the line, without pasting private code.
52
+ - Would you make the rerun a required check on pull requests where an agent changed tests? If not, what would it need to do?
53
+
54
+ AgentPath sends no telemetry: nothing leaves your machine unless you send it.
@@ -0,0 +1,159 @@
1
+ # Understanding results
2
+
3
+ Studio answers three questions about every run: what happened, why, and what to check next. This guide covers each part of Run Explorer and Compare, works through two real examples, and explains the less common run states and how to manage run history. The vocabulary is defined in [Concepts](concepts.md).
4
+
5
+ ## Run Explorer
6
+
7
+ Open a run from **Runs**, from the Overview, or from the link `agentpath run` prints.
8
+
9
+ 1. **Header.** The task name, the mode, the run status, when it started, how long it took, and the run ID with a copy button. **Open task** edits the definition. **Compare** starts a comparison from this run.
10
+ 2. **Result summary.** One sentence saying what happened:
11
+ - for a failure, the failed location, its planned intent and the failure category
12
+ - **Expected** next to **Observed**
13
+ - what to **Investigate**, and the **Root cause** status, which stays *Unconfirmed by the recorded evidence* unless the evidence establishes it
14
+ - **Jump to failed step** selects the failing operation, and **Failure record** downloads the stored result
15
+ 3. **Verdicts.** Separate verdicts for the goal, the action policy, the evidence integrity and, for autonomous runs, the agent's own claim. **Clean completion** is shown last, and its requirements are spelled out.
16
+ 4. **Execution timeline.** Every planned action, then every independent assertion, with its status and duration. Operations that never ran say *Not run*. The up and down arrow keys move through the timeline.
17
+ 5. **Operation detail.** For the selected operation:
18
+ - the observed result, target query, match count, page URL and duration
19
+ - its **Screenshot** and **Accessible page** evidence
20
+ - its **Capture record**
21
+ 6. **Run record.** Provenance for everything on the page:
22
+ - the recorded task contract fingerprint
23
+ - the integrity result
24
+ - the browser environment and its error counts
25
+ - privacy notes and the artifact manifest
26
+
27
+ Autonomous runs add an **Autonomous execution** panel, and runs with a policy add **Action policy evidence**. See [Autonomous mode](autonomous-mode.md).
28
+
29
+ ### Reading the evidence
30
+
31
+ - **Screenshots.** Form controls are masked in magenta at capture time. The caption names the operation and the stored file. Files are numbered from 0, so `step-3-after.png` belongs to Step 4. **Enlarge** opens the image full size, and Escape closes it.
32
+ - **Accessible page.** The recorded accessibility tree, filtered to the target's role when there is one. Use **Show all** to see every entry. Names that match the target are highlighted. An observed empty name reads *(empty accessible name)*. A name the privacy policy withheld reads *(withheld for privacy)*. The two are never confused.
33
+ - **Empty slots.** An empty slot says why it is empty: withheld for privacy, not requested, not attempted, capture failed, or file unavailable. A missing file never means the operation did not run.
34
+
35
+ ### What the evidence points to
36
+
37
+ A failed run carries more than the failing operation. Studio's failure panel and the CLI show whichever of these the run recorded:
38
+
39
+ - **After the timeout.** AgentPath keeps observing the same check for up to 5 seconds after a failure, without acting. *Passed 1493 ms after the operation started* means the page was slower than the task's timeout. *Still failed* means a longer timeout alone is unlikely to help. The verdict never changes.
40
+ - **Messages at failure.** Visible `alert` and `status` regions. Their text appears only when the operator ran with `--capture-text`; otherwise the role is listed and the text is marked not captured.
41
+ - **Observed text.** For a failed text assertion run with `--capture-text`, the text the target actually had, with every typed input value redacted.
42
+ - **Failed requests.** Same-origin and allowed-host requests that returned an HTTP error or failed on the network, such as a script that 404'd. Only a network error, a server error (5xx) or a missing resource (404, 410) points to the site. A refused sign-in, permission or rate limit (401, 403, 407, 429) usually means the test environment lacks credentials or quota, and other 4xx can answer input the task sent, so those are listed as facts.
43
+ - **A detached label.** A `<label>` with the requested text that is associated with no control.
44
+ - **Withheld near matches.** After input has been typed, names the task does not use are withheld, because a page can echo typed values. The output then says how many similar targets were not listed, for example *1 similar target was not listed*. This is a fact, not a diagnosis, and no change is suggested. Rerun with `--capture-text` on a test site to list them with typed values redacted. A similar target whose name contains a value the task types is counted separately (*not listed: its name contains a value the task types*); text capture does not list it either. In the Repair-or-Report v1 evaluation (`docs/evaluations` in the source repository) this was the main reason default output trailed `--capture-text`.
45
+
46
+ From those facts AgentPath derives **What the evidence points to**: each finding is marked *task* (the page is consistent with the task being out of date), *site* (the page itself is broken in a way the task cannot fix), or *fact* (relevant, but neither). When evidence points to the task, Studio lists **possible task changes** as JSON Patch operations against the task file, with the path of the failed operation (for example `/steps/2`). They are never applied automatically, and each assumes the page is correct. When the evidence points to the site, no change is suggested. See [Using AgentPath from a coding agent](coding-agents.md) for the repair loop.
47
+
48
+ ## Walkthrough: the missing Quantity label
49
+
50
+ The demo's **Missing-label evidence** run, from `examples/tasks/broken.json`, shows a failure the page's markup causes.
51
+
52
+ ![Run Explorer for the missing-label failure](images/run-failed-desktop.jpg)
53
+
54
+ 1. **The summary names the failure.** It reads *Step 4 failed: select · combobox "Quantity"*, with the category *Target not found* (`TARGET_NOT_FOUND`).
55
+ 2. **Expected versus observed.** The step expected one combobox with the requested accessible name. It observed no exact match: the only combobox in scope had an empty accessible name.
56
+ 3. **The verdicts agree.** The run status is *failed*, but the goal verdict is *Goal incomplete*. A step failed before the assertions could run, so the goal was never checked. That is different from an assertion failing.
57
+ 4. **The timeline shows how far it got.** Steps 1–3 passed. Step 4 failed. Step 5 and all four assertions say *Not run*.
58
+ 5. **The evidence confirms the symptom.** Choose **Jump to failed step**. The screenshot shows the quantity control masked in magenta beside the visible text "Quantity". The accessible page, filtered to `combobox`, shows one entry with *(empty accessible name)*. The visible text is not associated with the control, so assistive technology, and AgentPath, cannot find it by name.
59
+ 6. **The cause stays unconfirmed.** The browser evidence shows an unnamed control. It cannot say which source change removed the label, so Studio does not claim one.
60
+
61
+ The fix belongs in the page: associate the label with the select. The same run on narrow screens:
62
+
63
+ ![The same failure at 390 px wide](images/run-failed-mobile.jpg)
64
+
65
+ ## Compare
66
+
67
+ Open **Compare** from the navigation or from a run's header, choose a **Baseline run** and a **Candidate run**, then choose **Compare runs**. A link that names both runs, like the ones the Overview guide uses, compares them as soon as it opens.
68
+
69
+ By default both runs must share a task ID. Select **Compare compatible scenario variants** for runs that exercise the same scenario through different definitions; those results are directional evidence only.
70
+
71
+ The verdict and first meaningful divergence appear above the run selectors. Choose **Inspect evidence** to jump to the recorded differences. Change either selector and use **Compare runs** for a new pair.
72
+
73
+ Below the selectors, the run cards show the task contract, fingerprints, failure categories and timing. Goal, policy and evidence outcomes are shown separately for each run. Relative timing and capture differences alone do not count as a meaningful divergence.
74
+
75
+ The operation alignment pairs planned operations using saved semantic identity, with recorded order as a fallback for older runs. *Planned · skipped* marks an operation that never ran. Evidence can include both screenshots, both accessible pages and a table of observations. **Changed only** hides unchanged observations. Links point to the recorded source file and JSON pointer.
76
+
77
+ ## Walkthrough: verified task recovery
78
+
79
+ The demo records `examples/tasks/recovery.json` twice. The first run is against a broken reservation service, and the second is after the demo repairs it. The task definition does not change.
80
+
81
+ ![Compare reporting a verified task recovery](images/compare-recovery-desktop.jpg)
82
+
83
+ 1. **Identical contract.** *Task contract · identical*: the task and its assertions have the same recorded fingerprints in both runs.
84
+ 2. **The interpretation is strict.** The baseline failed, and the candidate completed every action and passed every independent assertion. The records are consistent, so the result is **Verified task recovery**.
85
+ 3. **The divergence is at the assertion.** The first divergence is *Assertion 1 · failed → passed*. The actions behaved the same; the reservation status changed.
86
+ 4. **The evidence shows the change.** **Inspect evidence** shows the baseline's observed text, *The visible text did not contain the expected substring*, against the candidate's *Independent assertion satisfied*. Both link to `result.json`. The screenshots show "Reservation is unavailable." and "Reserved successfully.".
87
+ 5. **The claim stays scoped.** Verified recovery means this task contract recovered. It does not establish which source change caused the recovery.
88
+
89
+ Compare that with the cart variants, where the definitions differ. The same failed → passed pattern is only an **Observed improvement**.
90
+
91
+ To reproduce the recovery from a source checkout:
92
+
93
+ 1. Run `pnpm demo` and `pnpm dev`.
94
+ 2. Import `examples/tasks/recovery.json`, then save and run it. The assertion fails.
95
+ 3. Restart the site with `AGENTPATH_DEMO_RELEASE=fixed pnpm demo`.
96
+ 4. Run the same saved task again, then compare the two runs in same-task mode.
97
+
98
+ ## Less common states
99
+
100
+ | What you see | Meaning | What to do |
101
+ |---|---|---|
102
+ | **Cancelled.** *No goal verdict is implied.* | Someone stopped the run. The actions recorded before the stop are shown. | Run it again. |
103
+ | **Stale · liveness uncertain** | The owner process stopped renewing its heartbeat. It may still be running or suspended. It is not reported as a crash. | Wait, or check the process that started it. AgentPath never signals a process because of a lease. |
104
+ | **Abandoned** | The owner process is confirmed gone on this host, and no verdict was recorded. | Run it again. |
105
+ | **Incomplete run** | The recording has no terminal event, for example an older run or an interrupted write. Only the recorded events are shown. | Treat it as unverified. |
106
+ | **Evidence integrity: Mismatch** | A file differs from the digest recorded at finalization. Studio will not serve the changed file, and the empty slot says *file unavailable*. | Run `agentpath runs verify <run-id>` to list the files. Strict recovery treats a mismatch as inconclusive. |
107
+ | **Run unavailable** | The stored record is unreadable or uses a newer format. Other runs still list normally. | Inspect or move `.agentpath/runs/<run-id>`, then reload. |
108
+ | **Withheld for privacy** | A capture was suppressed on purpose, for example screenshots after a fill. | Nothing; the operation still ran. |
109
+
110
+ ![A run whose captured screenshot was removed after finalization: evidence integrity reports a mismatch](images/run-missing-artifact-desktop.jpg)
111
+
112
+ ## From the CLI
113
+
114
+ `agentpath run` prints the failed operation, what was observed and expected, and any recorded findings that help you act:
115
+
116
+ ```text
117
+ FAILED rw-diag-name-typo (deterministic)
118
+ TARGET_NOT_FOUND at step 2
119
+ No exact match within the 5000 ms operation timeout. Similar targets were on the page.
120
+ Expected One link with the requested accessible name.
121
+ Similar targets on the page (not used; names must match exactly):
122
+ link "Add/Remove Elements" — similar name
123
+ Next: Compare the requested role and name with the similar targets recorded on the page. Names match exactly, including case.
124
+ ```
125
+
126
+ It also reports blocked requests to hosts outside `allowedHosts`. A page that loads its scripts from a CDN, for example, can render buttons that do nothing until that host is allowed. A blocked host is not necessarily the cause, so allow it only if the page needs it and you trust it.
127
+
128
+ ```sh
129
+ agentpath report <run-id>
130
+ agentpath compare <baseline-id> <candidate-id>
131
+ agentpath compare <baseline-id> <candidate-id> --variants
132
+ ```
133
+
134
+ `report` prints a short summary: the verdict, how many steps and assertions passed, and for a failure the same diagnosis `run` prints. `compare` prints the interpretation and the first difference. Add `--json` to either for the full record. Reports and comparisons exit 0 when they are generated. Pass `--runs-dir "<workspace>/.agentpath/runs"` to read another workspace, such as the demo's.
135
+
136
+ ## Managing run history
137
+
138
+ ```sh
139
+ agentpath runs list --status failed,stale --task demo-broken --limit 20
140
+ agentpath runs list --cursor <next-cursor> --json
141
+ agentpath runs verify <run-id>
142
+ agentpath runs reindex
143
+ agentpath runs prune --older-than 30d
144
+ agentpath runs prune --older-than 30d --yes
145
+ ```
146
+
147
+ - **Listing.** `runs list` pages newest first: 50 runs by default and 200 at most. It filters by status, task, `--since` and `--until`, using ISO timestamps. Studio's **Runs** page uses the same pages.
148
+ - **Index.** Listings read a derived SQLite index at `<runs>/.index/runs-v1.sqlite`, built with Node's `node:sqlite`. A missing, corrupt or newer-version index is rebuilt automatically, and `runs reindex` rebuilds it on demand. Deleting `.index` is always safe. Without `node:sqlite`, listings scan the directories instead.
149
+ - **Liveness.** A running process renews a lease in `liveness.json` every 2 seconds. The lease expires 15 seconds after the last heartbeat.
150
+ - **Integrity.** `runs verify` reports `consistent`, `mismatch`, `legacy`, `unsealed`, `sidecar-missing` or `sidecar-invalid`. It exits 1 for anything other than consistent or legacy.
151
+ - **Retention.** `runs prune` only previews unless you pass `--yes`. It considers finalized runs that started before the cutoff, given in `m`, `h`, `d` or `w`, and never deletes active runs. Stale, abandoned and unreadable runs each need their own flag: `--include-stale`, `--include-abandoned`, `--include-unreadable`. Eligibility is checked again just before each deletion, and symbolic links are never followed.
152
+
153
+ To open a native trace you enabled, run:
154
+
155
+ ```sh
156
+ pnpm exec playwright show-trace .agentpath/runs/<run-id>/trace.zip
157
+ ```
158
+
159
+ Traces can contain unredacted page data. See [Security and privacy](security.md).
@@ -0,0 +1,196 @@
1
+ # Writing tasks
2
+
3
+ A task describes one browser scenario and the checks that prove it worked. You can write tasks in Studio or as JSON files. Both produce the same schema version 1 definition. See [Concepts](concepts.md) for the vocabulary.
4
+
5
+ ## Start a task
6
+
7
+ In Studio, open **Tasks → New task**. From a terminal, `agentpath init` writes an editable `agentpath.task.json` and never overwrites an existing file. The starter targets the demo shop on port 4173. To run it unchanged, start `agentpath demo --site-port 4173` in another terminal first. For a page of your own site, `agentpath init --url http://127.0.0.1:3000/signup` writes a task that opens that page and checks its address, with the page's host as the only allowed host; `agentpath inspect` on the same URL then lists the targets to add as steps.
8
+
9
+ ![The task editor in its simple view, with the verdict explanation and the advanced settings in effect](images/task-editor-laptop.jpg)
10
+
11
+ ## Three views of one task
12
+
13
+ The editor's **Simple**, **Advanced** and **JSON** views all edit the same task, so switching views never changes it.
14
+
15
+ - **Simple** has the fields every task needs, in four sections: Task, Target site, Actions (or Model) and Independent assertions. A side panel lists the advanced settings currently in effect, so nothing configured is hidden.
16
+ - **Advanced** adds browser limits, evidence capture, the action policy, setup and teardown notes, and, for autonomous tasks, model limits and inference settings.
17
+ - **JSON** edits the raw definition, with every schema field available. **Validate JSON** checks it without saving.
18
+
19
+ When you save, problems are listed by field under **Fix these fields**. Choosing one moves focus to that field, and opens the advanced view first if the field lives there. **Import JSON** and **Export JSON** read and write task files. **Save and run** saves, starts a run and opens it.
20
+
21
+ ## The fields every task needs
22
+
23
+ | Field | Notes |
24
+ |---|---|
25
+ | Task name | Shown in Studio. Up to 512 characters. |
26
+ | Task ID | Lowercase letters, digits, `-` and `_`, starting with a letter or digit, up to 80 characters. Fixed once saved: runs are filed under it. |
27
+ | Execution mode | **Deterministic**: you list the actions. **Autonomous model execution**: a model chooses them, see [Autonomous mode](autonomous-mode.md). Switching from deterministic to autonomous removes the action list, and Studio asks first. |
28
+ | Goal | The intended outcome. In autonomous mode it is the model's instruction. |
29
+ | Base URL | Where relative destinations resolve. It must be on an allowed host. |
30
+ | Allowed hosts | Exact `host:port` values, one per line, up to 50. Requests to any other host are blocked by a per-run proxy. Blank lines are ignored. |
31
+
32
+ ## Actions
33
+
34
+ Deterministic tasks run up to 100 actions in order. Each action that touches an element needs a **semantic target**:
35
+
36
+ - **Role and accessible name.** For example, role `button` and name `Add to cart`. This is what a screen reader announces. The name must match exactly, including case. This differs from Playwright, whose `getByRole` matches a name as a case-insensitive substring unless you pass `exact: true`: a button renamed from `Subscribe` to `Subscribe now` still passes a default Playwright test but fails an AgentPath task.
37
+ - **Label.** The text that labels a form control, for example `Email`.
38
+
39
+ | Action | Target | Other fields |
40
+ |---|---|---|
41
+ | `navigate` | none | Destination: absolute, or relative to the base URL |
42
+ | `click` | role and name only | |
43
+ | `fill` | role and name, or label | Value, up to 16,384 characters |
44
+ | `select` | role and name, or label | Option, matched exactly by its label or its value |
45
+ | `press` | role and name, or label | A key such as `Enter`, or a chord such as `ControlOrMeta+a` |
46
+ | `wait` | role with an optional name, or label | State: `visible` or `hidden` |
47
+
48
+ A target must match exactly one element. If none match, the step fails as *Target not found*. If several match, it fails as *Ambiguous target*. A control with no accessible name cannot be targeted by name. Fix the page's labelling rather than working around it.
49
+
50
+ When a target is missing, the run records up to five similar targets from the page, such as a link with the name you gave a button, or a name that differs only in case. The CLI prints them under the failure. They explain a likely typo; AgentPath never acts on them. A `label` target matches the text of an associated `<label>`. When a label wraps a `<select>`, its text includes the option text, so use the role target that the failure suggests, for example combobox `Dropdown (select)`.
51
+
52
+ Targets and text inside `<iframe>` elements are not searched. A failure says when the page had embedded frames.
53
+
54
+ ### Find targets with `agentpath inspect`
55
+
56
+ `agentpath inspect` lists the role and name pairs, form labels and unnamed controls on one page, so you can write targets without a separate Playwright script:
57
+
58
+ ```sh
59
+ agentpath inspect http://127.0.0.1:4173/fixed/products/trail-mug --allow 127.0.0.1:4173
60
+ ```
61
+
62
+ With `agentpath demo --site-port 4173` running, the demo shop's product page lists:
63
+
64
+ ```text
65
+ Targets on http://127.0.0.1:4173/fixed/products/trail-mug
66
+
67
+ Role and name (use { "by": "role", "role": <role>, "name": <name> }):
68
+ heading "Trail Mug"
69
+ form "Purchase Trail Mug"
70
+ combobox "Quantity"
71
+ option "1"
72
+ option "2"
73
+ option "3"
74
+ button "Add to cart"
75
+ region "Cart"
76
+ heading "Cart"
77
+
78
+ Label (use { "by": "label", "label": <label> }):
79
+ "Quantity"
80
+
81
+ Unnamed (cannot be targeted by name):
82
+ main ×1 — the only main: usable without a name in waits and assertions
83
+ ```
84
+
85
+ A name shared by several elements is marked, for example `button "Delete" — ambiguous, 2 matches; a step would fail`.
86
+
87
+ - Every entry is checked with the same exact locator a step uses. An *ambiguous* entry fails a step, so target something more specific or fix the page.
88
+ - An *unnamed* control cannot be targeted by name. A role that appears only once can still be a name-less `wait` or assertion target.
89
+ - The page loads behind the same allowlist as a run. Each `--allow` is an exact `host` or `host:port`, and the URL must be on one of them. Blocked request hosts are listed, as `run` lists them under a failure. If the page needs another host, add it to `allowedHosts` too.
90
+ - Page text is quoted, stripped of control characters and cut at 160 characters. At most 200 targets and 100 labels are listed. Targets inside iframes are not listed.
91
+ - The command reads the page as it is after loading. It does not click, fill or follow links, so inspect each page of a journey by its URL.
92
+ - `--json` prints the stable inspection v1 shape described in [contracts](contracts.md#page-inspection-agentpath-inspect), for coding agents and scripts.
93
+
94
+ ## Independent assertions
95
+
96
+ Every task needs at least one assertion, and can have up to 100. They run after the actions and decide the goal verdict. Choose assertions that prove the **outcome** the goal describes, not that the steps ran:
97
+
98
+ | Assertion | Passes when |
99
+ |---|---|
100
+ | `url` | The current URL equals the pattern. `*` matches any run of characters. |
101
+ | `visible` | Exactly one element matches the target, and it is visible. |
102
+ | `text` | Exactly one element matches, it is visible, and its text contains the given text. Whitespace is normalized. |
103
+ | `count` | The number of matching elements equals the count. |
104
+
105
+ Assertions may omit the name of a role target to mean the only element with that role. This is how to check text in a page's unnamed `main` region:
106
+
107
+ ```json
108
+ { "assert": "text", "target": { "by": "role", "role": "main" }, "contains": "Order received" }
109
+ ```
110
+
111
+ If the page has two unnamed lists, a name-less `list` target matches both and the assertion fails rather than picking one.
112
+
113
+ *Visible* follows browser automation: an element is visible when it has a non-empty box and is not `visibility: hidden`. An element with `opacity: 0`, or one moved off screen, still counts as visible even though a person cannot see it. *Hidden* is the opposite, and an element that is absent counts as hidden.
114
+
115
+ The demo cart task, for example, checks the product route, the product heading, a single **Add to cart** button, and that the cart region contains `Trail Mug × 2`. An agent's completion claim never substitutes for these checks.
116
+
117
+ ## Advanced settings
118
+
119
+ | Setting | Default | Range and notes |
120
+ |---|---|---|
121
+ | Viewport | 1280 × 800 | 320–3840 wide, 240–2160 high |
122
+ | Phone emulation (`browser.mobile`) | off | `true` emulates a phone in Chromium at the task's viewport: touch input, `isMobile`, a 3× pixel ratio and an Android Chrome user agent. Set a phone-sized viewport with it, for example 390 × 844. As on a real phone, a page without `<meta name="viewport" content="width=device-width">` lays out at 980 px wide and is scaled down. Use `agentpath inspect <url> --allow <host> --mobile` (or `mobile: true` in the MCP inspect tool) to list the targets a phone layout shows. This is emulation in desktop Chromium, not Mobile Safari or a real device. |
123
+ | Operation timeout | 5,000 ms | 100–60,000 ms. How long each action or assertion waits for its target. |
124
+ | Overall run deadline | 120,000 ms | 250–600,000 ms. Covers browser startup, execution and evidence capture; cleanup and local report writes follow it. A timeout is a failed outcome with a run-timeout scope. A user cancellation stays cancelled. |
125
+ | Screenshots | `off` | `off`, `failure` or `steps`. Form controls are masked in magenta. Capture stops after the first fill or keypress. |
126
+ | Accessibility snapshots | `failure` | `off`, `failure` or `steps`. Up to 500 role and name pairs, with free-form text withheld. |
127
+ | Native Playwright trace | off | Opt-in. Traces can contain unredacted page data, values and credentials. |
128
+ | Setup and teardown | none | Descriptive notes for readers. AgentPath does not execute them. |
129
+
130
+ More capture means more data to review before you share a run. See [Security and privacy](security.md).
131
+
132
+ ## Action policy
133
+
134
+ An optional policy names interactions or requests that must not happen. It is reported separately from the goal.
135
+
136
+ - **Interaction rules** protect actions (`click`, `fill`, `select`, `press`) on any control or on a specific semantic target.
137
+ - **Request rules** protect a request path, matched exactly or by prefix, optionally limited to methods and one allowed host.
138
+
139
+ | Mode | Effect |
140
+ |---|---|
141
+ | **Audit** | Lets a matching action or request run, and records an executed violation. |
142
+ | **Enforce** | Rejects it before any browser side effect, and records it as blocked. |
143
+
144
+ In JSON, a policy looks like this:
145
+
146
+ ```json
147
+ "policy": {
148
+ "schemaVersion": 1,
149
+ "mode": "enforce",
150
+ "rules": [
151
+ { "id": "no-send", "kind": "action", "actions": ["click"], "target": { "by": "role", "role": "button", "name": "Send" } },
152
+ { "id": "no-disclose-request", "kind": "request", "path": "/disclose", "methods": ["POST"] }
153
+ ]
154
+ }
155
+ ```
156
+
157
+ A policy comes only from the task author or the local operator. It is never sent to a model, never turned into a list of steps, and never widens the allowed hosts. Without a policy, runs report the policy verdict as *Not evaluated*, never as compliant. Rules protect only what they name. See [Security and privacy](security.md) for the limits.
158
+
159
+ ## A complete JSON example
160
+
161
+ This is `examples/tasks/fixed.json` with its `wait` step and three of its four assertions left out:
162
+
163
+ ```json
164
+ {
165
+ "schemaVersion": 1,
166
+ "id": "demo-fixed",
167
+ "name": "Add two Trail Mugs to cart (fixed)",
168
+ "mode": "deterministic",
169
+ "goal": "Add two Trail Mugs to the shopping cart and verify the cart quantity.",
170
+ "baseUrl": "http://127.0.0.1:4173",
171
+ "allowedHosts": ["127.0.0.1:4173"],
172
+ "browser": { "viewport": { "width": 1100, "height": 720 }, "timeoutMs": 1500 },
173
+ "steps": [
174
+ { "action": "navigate", "url": "/fixed" },
175
+ { "action": "click", "target": { "by": "role", "role": "link", "name": "Trail Mug" } },
176
+ { "action": "select", "target": { "by": "role", "role": "combobox", "name": "Quantity" }, "option": { "by": "label", "label": "2" } },
177
+ { "action": "click", "target": { "by": "role", "role": "button", "name": "Add to cart" } }
178
+ ],
179
+ "assertions": [
180
+ { "assert": "text", "target": { "by": "role", "role": "region", "name": "Cart" }, "contains": "Trail Mug × 2" }
181
+ ],
182
+ "artifacts": { "screenshots": "steps", "accessibility": "steps", "trace": false }
183
+ }
184
+ ```
185
+
186
+ Unknown fields, unknown schema versions, CSS selectors and JavaScript are rejected.
187
+
188
+ ## Run from the CLI
189
+
190
+ ```sh
191
+ agentpath run agentpath.task.json --json
192
+ ```
193
+
194
+ `run` exits 1 when the verdict is failed, and still saves the evidence. Studio and the CLI share `.agentpath/runs` when they are started from the same workspace. Read the results with [Understanding results](understanding-results.md).
195
+
196
+ On a failure the output names the failed operation's path in the task file, for example `TARGET_NOT_FOUND at step 3 (task file /steps/2)`, then a **Diagnosis** and any **possible task changes** as JSON Patch operations. Apply a change only if the page is right and the task is out of date. `--capture-text` additionally records the text of failed text assertions and visible alerts, with typed input values redacted; use it only against test sites. See [Understanding results](understanding-results.md#what-the-evidence-points-to).