@reticlehq/core 1.3.1 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/README.md +14 -88
  2. package/dist/brand.d.ts +21 -0
  3. package/dist/brand.d.ts.map +1 -0
  4. package/dist/brand.js +16 -0
  5. package/dist/brand.js.map +1 -0
  6. package/dist/constants.d.ts +378 -0
  7. package/dist/constants.d.ts.map +1 -0
  8. package/dist/constants.js +352 -0
  9. package/dist/constants.js.map +1 -0
  10. package/dist/daemon-registry.d.ts +36 -0
  11. package/dist/daemon-registry.d.ts.map +1 -0
  12. package/dist/daemon-registry.js +48 -0
  13. package/dist/daemon-registry.js.map +1 -0
  14. package/dist/flow-constants.d.ts +175 -0
  15. package/dist/flow-constants.d.ts.map +1 -0
  16. package/dist/flow-constants.js +162 -0
  17. package/dist/flow-constants.js.map +1 -0
  18. package/dist/flow-types.d.ts +1204 -0
  19. package/dist/flow-types.d.ts.map +1 -0
  20. package/dist/flow-types.js +152 -0
  21. package/dist/flow-types.js.map +1 -0
  22. package/dist/index.d.ts +14 -2
  23. package/dist/index.d.ts.map +1 -0
  24. package/dist/index.js +14 -5563
  25. package/dist/index.js.map +1 -0
  26. package/dist/messages.d.ts +424 -0
  27. package/dist/messages.d.ts.map +1 -0
  28. package/dist/messages.js +103 -0
  29. package/dist/messages.js.map +1 -0
  30. package/dist/notices.d.ts +60 -0
  31. package/dist/notices.d.ts.map +1 -0
  32. package/dist/notices.js +64 -0
  33. package/dist/notices.js.map +1 -0
  34. package/dist/schema/command-message.json +41 -0
  35. package/dist/schema/command-result.json +34 -0
  36. package/dist/schema/event-message.json +77 -0
  37. package/dist/schema/event-type.json +35 -0
  38. package/dist/schema/hello-message.json +59 -0
  39. package/dist/schema/reticle-event.json +63 -0
  40. package/dist/schema/reticle-message.json +193 -0
  41. package/dist/security.d.ts +5 -0
  42. package/dist/security.d.ts.map +1 -0
  43. package/dist/security.js +22 -0
  44. package/dist/security.js.map +1 -0
  45. package/dist/session-constants.d.ts +116 -0
  46. package/dist/session-constants.d.ts.map +1 -0
  47. package/dist/session-constants.js +113 -0
  48. package/dist/session-constants.js.map +1 -0
  49. package/dist/state-select.d.ts +23 -0
  50. package/dist/state-select.d.ts.map +1 -0
  51. package/dist/state-select.js +60 -0
  52. package/dist/state-select.js.map +1 -0
  53. package/dist/toon.d.ts +44 -0
  54. package/dist/toon.d.ts.map +1 -0
  55. package/dist/toon.js +153 -0
  56. package/dist/toon.js.map +1 -0
  57. package/dist/types.d.ts +833 -0
  58. package/dist/types.d.ts.map +1 -0
  59. package/dist/types.js +165 -0
  60. package/dist/types.js.map +1 -0
  61. package/dist/upgrade.d.ts +74 -0
  62. package/dist/upgrade.d.ts.map +1 -0
  63. package/dist/upgrade.js +87 -0
  64. package/dist/upgrade.js.map +1 -0
  65. package/dist/verification-run.d.ts +1195 -0
  66. package/dist/verification-run.d.ts.map +1 -0
  67. package/dist/verification-run.js +261 -0
  68. package/dist/verification-run.js.map +1 -0
  69. package/package.json +32 -79
  70. package/dist/babel.d.ts +0 -7
  71. package/dist/babel.js +0 -32
  72. package/dist/cli.d.ts +0 -1
  73. package/dist/cli.js +0 -11273
  74. package/dist/eslint.d.ts +0 -1
  75. package/dist/eslint.js +0 -134
  76. package/dist/loader.cjs +0 -52
  77. package/dist/next.d.ts +0 -21
  78. package/dist/next.js +0 -24
  79. package/dist/server.d.ts +0 -1
  80. package/dist/server.js +0 -9495
  81. package/dist/test.d.ts +0 -1
  82. package/dist/test.js +0 -9377
  83. package/dist/vite.d.ts +0 -1
  84. package/dist/vite.js +0 -196
package/README.md CHANGED
@@ -1,99 +1,25 @@
1
- <div align="center">
1
+ # @reticlehq/core
2
2
 
3
- <picture>
4
- <source media="(prefers-color-scheme: dark)" srcset="https://cdn.jsdelivr.net/gh/reticlehq/reticle@main/assets/readme/dark-logo.png" />
5
- <img alt="Reticle" src="https://cdn.jsdelivr.net/gh/reticlehq/reticle@main/assets/readme/light-logo.png" width="80" />
6
- </picture>
3
+ The **foundation** of [Reticle](https://github.com/reticlehq/reticle) — the shared wire contract that every Reticle package imports: types, [zod](https://zod.dev) schemas, constants, and the messages that cross the browser ↔ bridge ↔ agent boundary. It is isomorphic (runs in a browser or in Node), depends only on `zod`, and re-exports nothing.
7
4
 
8
- # Reticle
5
+ Most people never install this directly. Install the package for your audience instead:
9
6
 
10
- ### Your AI writes the code. Reticle tells it whether the code actually works — with evidence, not screenshots.
7
+ - **Browser app:** `npx @reticlehq/server init` (wires `@reticlehq/react` + a build plugin)
8
+ - **Agent / MCP:** `npx @reticlehq/server mcp`
9
+ - **CI specs:** `@reticlehq/test`
11
10
 
12
- <a href="https://github.com/reticlehq/reticle"><img src="https://cdn.jsdelivr.net/gh/reticlehq/reticle@main/assets/readme/hero.gif" alt="Reticle catches a 401 your agent said was 'done' — pass:false with evidence, then a one-line fix to pass:true" width="760" /></a>
11
+ See the [main README](https://github.com/reticlehq/reticle) and [MIGRATION.md](https://github.com/reticlehq/reticle/blob/main/MIGRATION.md).
13
12
 
14
- [![npm](https://img.shields.io/npm/v/@reticlehq/core?color=8b7bff&labelColor=15131f&logo=npm)](https://www.npmjs.com/package/@reticlehq/core) [![downloads](https://img.shields.io/npm/dm/@reticlehq/core?color=5fd9f5&labelColor=15131f)](https://www.npmjs.com/package/@reticlehq/core) [![license](https://img.shields.io/badge/license-Apache--2.0%20%2B%20FSL-46d6a0?labelColor=15131f)](https://github.com/reticlehq/reticle/blob/main/LICENSE)
13
+ ## The wire contract as JSON Schema
15
14
 
16
- **TypeScript · Model Context Protocol · React-first · dev-only · localhost-only · open-core (Apache-2.0 SDK + FSL server)**
15
+ `@reticlehq/core` ships machine-readable [JSON Schema](https://json-schema.org) for the wire contract under `dist/schema/`, generated from the zod schemas so the two can never drift (a parity test enforces it). This is the **conformance target for non-TypeScript SDKs**: a Python, Go, or Rust SDK validates its messages against these schemas without importing the TypeScript library.
17
16
 
18
- [Docs & full README](https://github.com/reticlehq/reticle) · [Getting Started](https://github.com/reticlehq/reticle/blob/main/docs/getting-started.md) · [Why it's ~73× cheaper](https://github.com/reticlehq/reticle/blob/main/docs/token-efficiency.md)
19
-
20
- </div>
21
-
22
- ---
23
-
24
- ## The problem: your agent has hands, but no eyes
25
-
26
- You ask your AI agent to build a feature. It edits the files, says _"done ✅"_ — and then **you** open the browser, click around, and find out it isn't. Every. Single. Time. The agent can't really check its own work, so you become its QA department. Screenshots are bad eyes: ~1,500+ tokens through a vision model, slow, non-deterministic, and **blind to everything non-visual** — the failed request, the console error, the route that didn't change, the webhook that never came.
27
-
28
- ## The idea: your app already knows what happened — let the agent ask
29
-
30
- Reticle exposes your running app to your agent over **MCP** as a tight loop — **look → act → observe → assert** — and one call checks many things at once and comes back with proof:
31
-
32
- ```jsonc
33
- // The agent clicked "Pay". Did the right things actually happen? One call, ~33 tokens, no screenshot:
34
- reticle_assert({
35
- predicate: { allOf: [
36
- { kind: "net", method: "POST", urlContains: "/api/order", status: 200 },
37
- { kind: "element", query: { role: "dialog", name: "Order confirmed" }, state: "visible" },
38
- { kind: "signal", name: "order:saved" }, // the charge actually committed
39
- { kind: "console", level: "error", absent: true } // ...and nothing errored
40
- ]}
41
- })
42
- // → { pass: false, evidence: { net: { status: 500, url: "/api/order" } },
43
- // failureReason: "POST /api/order returned 500, expected 200",
44
- // source: { file: "src/checkout/PayButton.tsx", line: 42 } } ❌ caught before you ever saw it
45
- ```
46
-
47
- Deterministic (structured events, not pixels), cheap (any model, no vision), and it points at the **file:line** to fix.
48
-
49
- ## Quickstart
50
-
51
- **One install** — SDK, React adapter, source-mapping plugins, spec runner, and the MCP server all ship in a single package:
52
-
53
- ```bash
54
- npm i -D @reticlehq/core
55
- ```
56
-
57
- **1. Point your agent at the MCP server** (Claude Code `.mcp.json`, Cursor, Windsurf, …):
58
-
59
- ```jsonc
60
- { "mcpServers": { "reticle": { "command": "npx", "args": ["@reticlehq/core"] } } }
17
+ ```js
18
+ import reticleMessage from '@reticlehq/core/schema/reticle-message.json' with { type: 'json' };
61
19
  ```
62
20
 
63
- **2. Embed the SDK in your app (dev only):**
64
-
65
- ```ts
66
- import { reticle } from '@reticlehq/core';
67
- if (import.meta.env.DEV) reticle.connect({ session: 'my-app' });
68
- ```
69
-
70
- Run your app and ask your agent: _"add a logout button and verify it works with Reticle."_ → [Full Getting Started walkthrough](https://github.com/reticlehq/reticle/blob/main/docs/getting-started.md).
71
-
72
- ## What it can verify
73
-
74
- API calls (`net`) · DOM changes · SPA navigation · console & errors (incl. "**no** errors") · animations · app **signals** (webhooks, store commits, async jobs you surface via `reticle.signal()`) · **regressions** (baseline now, diff later) · **source mapping** (DOM → React component → file:line). Plus an autonomous crawler. ~44 MCP tools in total.
75
-
76
- ## ~73× fewer tokens than feeding the agent the whole page
77
-
78
- | | Tokens per step |
79
- | ------------------------------------------------------ | --------------: |
80
- | Full accessibility-tree snapshot (e.g. Playwright MCP) | ~7,300 |
81
- | **Reticle verify loop** (query + observe + assert) | **~100** |
82
-
83
- The honest version: force Reticle to dump the whole tree too and the gap is only ~1.8×. The 73× comes from **not needing the whole tree** — that's architectural. [Full methodology + caveats →](https://github.com/reticlehq/reticle/blob/main/docs/token-efficiency.md)
84
-
85
- ## Benchmarked two ways — a toy app and a real one — both published
86
-
87
- <img src="https://cdn.jsdelivr.net/gh/reticlehq/reticle@main/assets/readme/bench-two-apps.png" alt="On a controlled app Reticle has the highest Verification Efficiency (12.3 vs 10.6 vs 7.0); on a real production dashboard Reticle is the cheapest to observe (1,023 vs 1,357 vs 2,193 tokens)" width="820" />
88
-
89
- On a real production app (the [Reticle](https://reticle.ai) dashboard — React 19, auth, live data), Reticle observed the authenticated app for **1,023 tokens vs Chrome DevTools MCP 1,357 vs Playwright MCP 2,193 (2.1× leaner)** — and was the **only** tool that could assert login actually succeeded from the app's own signal (46 tok, un-fakeable) and read program state the DOM never shows. On the first uninstrumented pass it even caught two live `500`s the page completely hid (a missing DB migration). Full honest breakdown, including where Reticle **loses** (true pixels, sites you don't own): [`docs/benchmarks.md`](https://github.com/reticlehq/reticle/blob/main/docs/benchmarks.md).
90
-
91
- ## How is this different?
92
-
93
- Everyone now gives agents _eyes_; **Reticle gives agents a _verdict_.** Playwright/Cypress are scripted CI tests you write and maintain. Playwright MCP / Chrome DevTools MCP let an agent _drive_ a separate browser (token-heavy snapshots, no first-class assert/regression/source-map). Reticle runs _inside_ your real running app (your session/auth), returns a verdict-with-evidence in ~100 tokens, sees what screenshots can't, catches silent regressions, and points at the file to fix. **They compose: drive with Playwright MCP, verify with Reticle.**
94
-
95
- ---
21
+ Shipped schemas: `reticle-message`, `reticle-event`, `hello-message`, `command-message`, `command-result`, `event-message`, `event-type`.
96
22
 
97
- dev-only and localhost-only by default · no telemetry · tree-shaken out of production · open-core (Apache-2.0 SDK + FSL server)
23
+ ## License
98
24
 
99
- **[→ Full documentation on GitHub](https://github.com/reticlehq/reticle)**
25
+ Apache-2.0.
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Opaque/branded primitive types — give domain strings (and numbers) a NOMINAL type so a value can only
3
+ * be passed where that exact kind is expected. A plain `string` runId and a `string` flowName are
4
+ * interchangeable to the compiler and get swapped by accident (both feed path helpers!); a branded
5
+ * `RunId` vs `FlowName` cannot. This complements the "no free strings" rule (named constants for the
6
+ * allowed *set*) with type safety for the *values* that travel.
7
+ *
8
+ * Pattern:
9
+ * export type RunId = Brand<string, 'RunId'>;
10
+ * export const asRunId = (s: string): RunId => s as RunId; // mint at a trusted/validated boundary
11
+ * The brand is a phantom (erased at runtime) — `RunId` is just a string at runtime, free to serialize.
12
+ * Mint ONLY after validation (e.g. behind a `(s): s is RunId` guard) so a branded value is also a valid
13
+ * one. Zod-validated fields use `z.string().brand<'X'>()` instead, so the schema is the single source.
14
+ */
15
+ declare const brand: unique symbol;
16
+ /** A nominal wrapper: `T` tagged with brand `B`, assignable FROM nowhere except an explicit mint/cast. */
17
+ export type Brand<T, B extends string> = T & {
18
+ readonly [brand]: B;
19
+ };
20
+ export {};
21
+ //# sourceMappingURL=brand.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"brand.d.ts","sourceRoot":"","sources":["../src/brand.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,CAAC,MAAM,KAAK,EAAE,OAAO,MAAM,CAAC;AAEnC,0GAA0G;AAC1G,MAAM,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,IAAI,CAAC,GAAG;IAAE,QAAQ,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;CAAE,CAAC"}
package/dist/brand.js ADDED
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Opaque/branded primitive types — give domain strings (and numbers) a NOMINAL type so a value can only
3
+ * be passed where that exact kind is expected. A plain `string` runId and a `string` flowName are
4
+ * interchangeable to the compiler and get swapped by accident (both feed path helpers!); a branded
5
+ * `RunId` vs `FlowName` cannot. This complements the "no free strings" rule (named constants for the
6
+ * allowed *set*) with type safety for the *values* that travel.
7
+ *
8
+ * Pattern:
9
+ * export type RunId = Brand<string, 'RunId'>;
10
+ * export const asRunId = (s: string): RunId => s as RunId; // mint at a trusted/validated boundary
11
+ * The brand is a phantom (erased at runtime) — `RunId` is just a string at runtime, free to serialize.
12
+ * Mint ONLY after validation (e.g. behind a `(s): s is RunId` guard) so a branded value is also a valid
13
+ * one. Zod-validated fields use `z.string().brand<'X'>()` instead, so the schema is the single source.
14
+ */
15
+ export {};
16
+ //# sourceMappingURL=brand.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"brand.js","sourceRoot":"","sources":["../src/brand.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG"}
@@ -0,0 +1,378 @@
1
+ /**
2
+ * Wire-level constants. No free strings anywhere in Reticle reference these directly —
3
+ * every string/number that crosses the browser <-> bridge <-> agent boundary is named here.
4
+ */
5
+ export declare const RETICLE_DEFAULT_PORT = 4400;
6
+ export declare const RETICLE_WS_PATH = "/reticle";
7
+ export declare const RETICLE_PROTOCOL_VERSION = 1;
8
+ /**
9
+ * The one place the bridge WebSocket URL is built. The SDK connect default, the vite/next snippet
10
+ * generators, and the CLI's inject-connect all call this instead of hand-writing `ws://…${path}` —
11
+ * so the wire string can never drift across the four call sites. Host defaults to `localhost` (the
12
+ * dev app connects from the browser); pass it only for a non-default bind.
13
+ */
14
+ export declare function bridgeWsUrl(port?: number, host?: string): string;
15
+ /**
16
+ * Namespaced URL params a pooled/headless launcher appends to the app URL so the app's own SDK adopts
17
+ * the lease's identity (session + project) on connect — no app code changes. Wire contract shared by
18
+ * the server (BrowserPool/lease tools) and the browser SDK; namespaced to avoid clashing with the
19
+ * app's own query params.
20
+ */
21
+ export declare const RETICLE_URL_PARAM: {
22
+ readonly SESSION: "__reticle_session";
23
+ readonly PROJECT: "__reticle_project";
24
+ };
25
+ /** The loopback bind address. The daemon/bridge bind here by default — never expose Reticle off-host. */
26
+ export declare const LOOPBACK_HOST = "127.0.0.1";
27
+ /**
28
+ * Every environment variable Reticle reads, named once. A misspelled inline env string silently
29
+ * disables the control it gates (e.g. a typo'd `RETICLE_TOKEN` would disable auth) — so the names live
30
+ * here and nowhere else. The values are the literal process.env keys.
31
+ */
32
+ export declare const ReticleEnv: {
33
+ /** Shared-secret the browser SDK must present in HELLO; absent ⇒ loopback-trust only. */
34
+ readonly TOKEN: "RETICLE_TOKEN";
35
+ /** Bridge bind host. Defaults to loopback; setting anything else is opt-in remote exposure. */
36
+ readonly HOST: "RETICLE_HOST";
37
+ /** Comma-separated WS Origin allow-list for the bridge. */
38
+ readonly ALLOWED_ORIGINS: "RETICLE_ALLOWED_ORIGINS";
39
+ /** Bridge/daemon WS port override. */
40
+ readonly PORT: "RETICLE_PORT";
41
+ /** Attach to an already-running browser over CDP instead of launching one. */
42
+ readonly CDP_URL: "RETICLE_CDP_URL";
43
+ /** Max simultaneous leased headless contexts in the browser pool (resource cap). */
44
+ readonly MAX_CONTEXTS: "RETICLE_MAX_CONTEXTS";
45
+ /** Bearer token required by the optional `reticle serve --http` verify endpoint. */
46
+ readonly VERIFY_TOKEN: "RETICLE_VERIFY_TOKEN";
47
+ /** Ms of continuous idleness (no agent, no browser session, no lease) before the daemon self-exits;
48
+ * `0` disables. Keeps Reticle from lingering on a user's machine after the editor closes. */
49
+ readonly IDLE_SHUTDOWN: "RETICLE_IDLE_SHUTDOWN_MS";
50
+ /** Directory holding the auto-provisioned pairing token. Defaults to ~/.reticle; relocatable for CI. */
51
+ readonly PAIRING_TOKEN_DIR: "RETICLE_PAIRING_TOKEN_DIR";
52
+ };
53
+ /** Hard transport bounds shared by the browser and bridge. */
54
+ export declare const TRANSPORT_LIMITS: {
55
+ readonly MAX_MESSAGE_BYTES: number;
56
+ readonly MAX_MESSAGES_PER_SECOND: 1000;
57
+ readonly MAX_SESSIONS: 32;
58
+ readonly MAX_PENDING_CONNECTIONS: 16;
59
+ readonly HELLO_TIMEOUT_MS: 5000;
60
+ readonly MAX_BUFFER_BYTES: number;
61
+ readonly MAX_SESSION_ID_LENGTH: 128;
62
+ readonly MAX_URL_LENGTH: 4096;
63
+ readonly MAX_TITLE_LENGTH: 512;
64
+ readonly MAX_ADAPTERS: 32;
65
+ readonly MAX_ADAPTER_NAME_LENGTH: 128;
66
+ readonly MAX_TOKEN_LENGTH: 512;
67
+ readonly MAX_COMMAND_ID_LENGTH: 128;
68
+ readonly MAX_COMMAND_NAME_LENGTH: 128;
69
+ readonly MAX_REF_LENGTH: 128;
70
+ readonly MAX_ERROR_LENGTH: 4096;
71
+ readonly MAX_SERIALIZE_DEPTH: 8;
72
+ readonly MAX_COLLECTION_ITEMS: 200;
73
+ readonly MAX_OBJECT_KEYS: 200;
74
+ readonly MAX_STRING_LENGTH: number;
75
+ /** Human review marks: the note the human types when flagging a mistake on the page. */
76
+ readonly MAX_MARK_NOTE_LENGTH: 2000;
77
+ /** Human review marks: the legible element label that pins the mark (e.g. "Submit button"). */
78
+ readonly MAX_MARK_LABEL_LENGTH: 256;
79
+ };
80
+ /** Replacement used when sensitive data is removed before crossing the bridge. */
81
+ export declare const REDACTED_VALUE = "[REDACTED]";
82
+ /** Explicit opt-in argument required for potentially destructive actions. */
83
+ export declare const DANGEROUS_ACTION_CONFIRM_ARG = "confirmDangerous";
84
+ /** Schema version stamped onto compiled replay programs. */
85
+ export declare const REPLAY_PROGRAM_VERSION = 1;
86
+ /** The git-checked Reticle workspace directory + its layout. No free strings. */
87
+ export declare const ReticleDir: {
88
+ readonly ROOT: ".reticle";
89
+ readonly CONTRACT_FILE: "contract.json";
90
+ readonly FLOWS_SUBDIR: "flows";
91
+ readonly BASELINES_SUBDIR: "baselines";
92
+ /** cross-run memory — outcomes of past runs (the "did it behave like last time?" file). */
93
+ readonly PROJECT_FILE: "project.json";
94
+ /** opt-in pixel baselines — .reticle/visual/<name>.png + <name>.diff.png. */
95
+ readonly VISUAL_SUBDIR: "visual";
96
+ /** verification-run artifacts — .reticle/runs/<runId>.json (the OEM/CI-consumable verdict). */
97
+ readonly RUNS_SUBDIR: "runs";
98
+ /**
99
+ * Auto-provisioned bridge pairing token, stored at ~/.reticle/pairing-token (mode 0600). Written by
100
+ * the daemon, read Node-side by the build plugins to inject into connect(). A browser sandbox cannot
101
+ * read it, so a rogue localhost app can't present it — that's what stops cross-app session hijack.
102
+ */
103
+ readonly PAIRING_TOKEN_FILE: "pairing-token";
104
+ };
105
+ /**
106
+ * Structured reasons a screenshot/visual-diff could not produce a verdict (never
107
+ * thrown as free strings). The visual layer is OPT-IN and CDP/Playwright-driven — it is NEVER
108
+ * bundled into the always-on browser SDK — so NO_PROVIDER is the common "you must `reticle drive`" case.
109
+ */
110
+ export declare const VisualReason: {
111
+ readonly NO_PROVIDER: "no-visual-provider";
112
+ readonly CAPTURE_FAILED: "capture-failed";
113
+ readonly BASELINE_MISSING: "baseline-missing";
114
+ readonly DIMENSION_MISMATCH: "dimension-mismatch";
115
+ };
116
+ export type VisualReason = (typeof VisualReason)[keyof typeof VisualReason];
117
+ /** Actionable companion to NO_PROVIDER — the visual layer needs a driven browser. */
118
+ export declare const VISUAL_NO_PROVIDER_RECOMMENDATION = "visual capture needs a driven browser \u2014 start with `reticle drive <url>` or set RETICLE_CDP_URL; the always-on SDK does not ship a screenshotter";
119
+ /** Default per-pixel color-distance threshold (pixelmatch 0..1; higher = more lenient). */
120
+ export declare const VISUAL_PIXEL_THRESHOLD = 0.1;
121
+ /**
122
+ * Autonomous "smart monkey" anomaly classes reticle_crawl reports after clicking a
123
+ * reachable control. Named so the agent (and tests) branch on cause, never on message text.
124
+ */
125
+ export declare const CrawlAnomalyKind: {
126
+ readonly CONSOLE_ERROR: "console-error";
127
+ readonly FAILED_REQUEST: "failed-request";
128
+ readonly DEAD_CONTROL: "dead-control";
129
+ };
130
+ export type CrawlAnomalyKind = (typeof CrawlAnomalyKind)[keyof typeof CrawlAnomalyKind];
131
+ /**
132
+ * Bounds for reticle_scroll_to — how many viewport scrolls to try before giving up on
133
+ * a virtualized/windowed list (which only renders visible rows, so a plain reticle_query misses
134
+ * off-screen items). Each scroll advances ~one viewport; the loop also stops early at the list end.
135
+ */
136
+ export declare const SCROLL_FIND_DEFAULTS: {
137
+ readonly MAX_SCROLLS: 20;
138
+ };
139
+ /** Bounds so a crawl always terminates and each click has time to settle. */
140
+ export declare const CRAWL_DEFAULTS: {
141
+ /** Max controls clicked in one crawl (then `truncated:true`). */
142
+ readonly MAX_STEPS: 25;
143
+ /** ms to wait for a click's reaction to land in the buffer before classifying. */
144
+ readonly SETTLE_MS: 300;
145
+ /** HTTP status at/above which a response counts as a failed request. */
146
+ readonly FAILED_STATUS: 400;
147
+ };
148
+ /** How long to wait between npm registry update checks (24 h). */
149
+ export declare const UpdateCheckIntervalMs: number;
150
+ /** Schema version stamped into contract.json so a reader can reject/upgrade old files. */
151
+ export declare const CONTRACT_FILE_VERSION = 1;
152
+ /** Arg key on reticle_capabilities selecting the on-disk contract over the live session. */
153
+ export declare const FROM_DISK_ARG = "fromDisk";
154
+ /** Structured outcome when reading contract.json fails (never thrown to the agent). */
155
+ export declare const ContractReadError: {
156
+ readonly MISSING: "contract-missing";
157
+ readonly MALFORMED: "contract-malformed";
158
+ };
159
+ export type ContractReadError = (typeof ContractReadError)[keyof typeof ContractReadError];
160
+ /** On-disk artifact constants (project/flow/replay/recorder/heal/annotation) live here. */
161
+ export * from './flow-constants.js';
162
+ /** Bounds for the per-session ring buffer (see plan/02-architecture.md). */
163
+ export declare const RING_BUFFER_DEFAULTS: {
164
+ readonly MAX_EVENTS: 2000;
165
+ readonly MAX_AGE_MS: 60000;
166
+ readonly MAX_BYTES: number;
167
+ };
168
+ /** Normalized event types pushed into the ring buffer. */
169
+ export declare const EventType: {
170
+ readonly DOM_ADDED: "dom.added";
171
+ readonly DOM_REMOVED: "dom.removed";
172
+ readonly DOM_ATTR: "dom.attr";
173
+ readonly DOM_TEXT: "dom.text";
174
+ readonly NET_REQUEST: "net.request";
175
+ readonly NET_PENDING: "net.pending";
176
+ readonly ROUTE_CHANGE: "route.change";
177
+ readonly CONSOLE_LOG: "console.log";
178
+ readonly CONSOLE_WARN: "console.warn";
179
+ readonly CONSOLE_ERROR: "console.error";
180
+ readonly ERROR_UNCAUGHT: "error.uncaught";
181
+ readonly VISIBLE_SHOWN: "visible.shown";
182
+ readonly VISIBLE_HIDDEN: "visible.hidden";
183
+ readonly ANIM_START: "anim.start";
184
+ readonly ANIM_END: "anim.end";
185
+ readonly SCROLL_POSITION: "scroll.position";
186
+ readonly REVEAL_SHOWN: "reveal.shown";
187
+ readonly SIGNAL: "signal";
188
+ readonly STATE_CHANGE: "state.change";
189
+ /** page-level visibility/focus health (distinct from element-level VISIBLE_*). */
190
+ readonly PAGE_HEALTH: "page.health";
191
+ /** browser → bridge: a human recording compiled in-page. */
192
+ readonly FLOW_RECORDED: "flow.recorded";
193
+ /** synthetic: browser transport queue overflowed; events were dropped. `data: { dropped: number }`. */
194
+ readonly TRANSPORT_OVERFLOW: "transport.overflow";
195
+ /**
196
+ * Live-control: browser → bridge. A human acted on the presenter panel.
197
+ * `data: { kind: HumanControlKind; text?: string }`. Rides the existing EventMessage.
198
+ */
199
+ readonly HUMAN_CONTROL: "human.control";
200
+ /**
201
+ * Human review: browser → bridge. A human pinned a mistake to an element on the running page
202
+ * (the "annotate the bug where you see it" loop). `data` narrows to HumanMarkDataSchema — a note
203
+ * plus a re-resolvable element anchor (and its source file:line when the framework stamped one) so
204
+ * the agent that drains the mark knows exactly which element and which source to fix.
205
+ */
206
+ readonly HUMAN_MARK: "human.mark";
207
+ };
208
+ export type EventType = (typeof EventType)[keyof typeof EventType];
209
+ /** Which input path executed an action — native (CDP/Playwright) vs synthetic dispatchEvent. */
210
+ export declare const InputMode: {
211
+ readonly REAL: "real";
212
+ readonly SYNTHETIC: "synthetic";
213
+ };
214
+ export type InputMode = (typeof InputMode)[keyof typeof InputMode];
215
+ /**
216
+ * Why a pointer action ran SYNTHETIC even though a real-input provider is configured. Attached as
217
+ * `inputModeReason` so a real→synthetic fallback is never silent (field bug #2) — the agent can
218
+ * tell "I couldn't locate the element" from "the page isn't correlated to a CDP target".
219
+ */
220
+ export declare const InputModeReason: {
221
+ readonly NOT_POINTER: "not-a-pointer-action";
222
+ readonly SYNTHETIC_CLICK_PREFERRED: "synthetic-click-preferred";
223
+ readonly PAGE_NOT_CORRELATED: "page-not-correlated-to-a-cdp-target";
224
+ readonly ELEMENT_NOT_LOCATABLE: "element-not-locatable";
225
+ readonly DRAG_TARGET_UNRESOLVED: "drag-target-unresolved";
226
+ readonly PROVIDER_DECLINED: "provider-declined";
227
+ readonly PROVIDER_ERROR: "provider-error";
228
+ };
229
+ export type InputModeReason = (typeof InputModeReason)[keyof typeof InputModeReason];
230
+ /** Best-effort caveats attached to action results so the agent can interpret a no-op. */
231
+ export declare const ActionWarning: {
232
+ readonly HOVER_NATIVE_ENTER_LEAVE: "target has enter/leave handlers; synthetic hover may not trigger them — expect no state change";
233
+ /** real-input provider was available but failed; the action fell back to synthetic dispatch. */
234
+ readonly REAL_INPUT_FELL_BACK: "real-input provider was available but failed; fell back to synthetic dispatch";
235
+ /**
236
+ * The click point was covered by another element. Synthetic dispatch still delivered the event to
237
+ * your target, but a real user could NOT click it — treat the target as visually blocked, not
238
+ * actionable. Scroll it into a clear area or dismiss the overlay on top.
239
+ */
240
+ readonly CLICK_OCCLUDED: "target is visually occluded by another element; a real user could not click it (synthetic dispatch still delivered the event) — dismiss the overlay or scroll the target clear";
241
+ };
242
+ export type ActionWarning = (typeof ActionWarning)[keyof typeof ActionWarning];
243
+ /** Failure modes when Reticle launches/drives its own browser (`reticle drive`). */
244
+ export declare const DriveErrorCode: {
245
+ readonly PLAYWRIGHT_MISSING: "playwright_missing";
246
+ readonly LAUNCH_FAILED: "launch_failed";
247
+ readonly NAVIGATE_FAILED: "navigate_failed";
248
+ };
249
+ export type DriveErrorCode = (typeof DriveErrorCode)[keyof typeof DriveErrorCode];
250
+ /** Human-facing message when the optional playwright dep is absent. */
251
+ export declare const DRIVE_PLAYWRIGHT_MISSING_MSG = "reticle drive needs the optional 'playwright' package \u2014 install it: pnpm add -D playwright && npx playwright install chromium";
252
+ /** Actions the executor can perform against a ref (plan/03 + plan/05). */
253
+ export declare const ActionType: {
254
+ readonly CLICK: "click";
255
+ readonly DBLCLICK: "dblclick";
256
+ readonly HOVER: "hover";
257
+ readonly FOCUS: "focus";
258
+ readonly BLUR: "blur";
259
+ readonly FILL: "fill";
260
+ readonly TYPE: "type";
261
+ readonly CLEAR: "clear";
262
+ readonly SELECT: "select";
263
+ readonly CHECK: "check";
264
+ readonly UNCHECK: "uncheck";
265
+ readonly SUBMIT: "submit";
266
+ readonly PRESS: "press";
267
+ readonly UPLOAD: "upload";
268
+ readonly SCROLL_INTO_VIEW: "scrollIntoView";
269
+ readonly DRAG: "drag";
270
+ readonly WEBMCP: "webmcp";
271
+ };
272
+ export type ActionType = (typeof ActionType)[keyof typeof ActionType];
273
+ /** Why an action's settle wait ended without a real animation frame. */
274
+ export declare const SettleReason: {
275
+ readonly TIMEOUT: "timeout";
276
+ readonly THROTTLED: "throttled";
277
+ };
278
+ export type SettleReason = (typeof SettleReason)[keyof typeof SettleReason];
279
+ /** Outcome reasons for a bounded component-state read. Store reads never use these. */
280
+ export declare const ComponentStateReason: {
281
+ readonly UNAVAILABLE: "component-state-unavailable";
282
+ };
283
+ export type ComponentStateReason = (typeof ComponentStateReason)[keyof typeof ComponentStateReason];
284
+ /**
285
+ * Result of a component-state read attempt, discriminated on `ok`. Crosses
286
+ * browser -> bridge -> agent as `result.component`, so the contract lives in protocol.
287
+ * Always JSON-serializable: hook values are sanitized (no functions/DOM nodes/cycles).
288
+ */
289
+ export interface ComponentStateResult {
290
+ ok: boolean;
291
+ reason?: ComponentStateReason;
292
+ /** Component display name, when known. */
293
+ component?: string;
294
+ /** Positional, JSON-safe hook states. */
295
+ hooks?: unknown[];
296
+ }
297
+ /** Element states the assertion engine can check (plan/06). */
298
+ export declare const ElementState: {
299
+ readonly VISIBLE: "visible";
300
+ readonly HIDDEN: "hidden";
301
+ readonly ENABLED: "enabled";
302
+ readonly DISABLED: "disabled";
303
+ readonly CHECKED: "checked";
304
+ readonly EXPANDED: "expanded";
305
+ readonly FOCUSED: "focused";
306
+ readonly PRESENT: "present";
307
+ };
308
+ export type ElementState = (typeof ElementState)[keyof typeof ElementState];
309
+ /** Query strategies, aligned with Testing Library semantics (plan/04). */
310
+ export declare const QueryBy: {
311
+ readonly ROLE: "role";
312
+ readonly TEXT: "text";
313
+ readonly LABEL: "label";
314
+ readonly PLACEHOLDER: "placeholder";
315
+ readonly TESTID: "testid";
316
+ readonly ALT: "alt";
317
+ /** Resolve by component identity / source location (auto-anchors — addresses any element with
318
+ * no hand-added testid). Pair with ElementQuery.component and/or .source. */
319
+ readonly COMPONENT: "component";
320
+ };
321
+ export type QueryBy = (typeof QueryBy)[keyof typeof QueryBy];
322
+ /** Commands the bridge sends to the browser SDK (the `name` field of a CommandMessage). */
323
+ export declare const ReticleCommand: {
324
+ readonly SNAPSHOT: "snapshot";
325
+ readonly QUERY: "query";
326
+ readonly MATCH: "match";
327
+ readonly INSPECT: "inspect";
328
+ readonly ACT: "act";
329
+ readonly ACT_SEQUENCE: "act_sequence";
330
+ readonly ANIMATIONS: "animations";
331
+ readonly NARRATE: "narrate";
332
+ readonly CLOCK: "clock";
333
+ readonly CAPABILITIES: "capabilities";
334
+ readonly STATE_READ: "state_read";
335
+ /** scroll a ref's nearest scrollable container by ~a viewport (virtualized lists). */
336
+ readonly SCROLL: "scroll";
337
+ /** Session lifecycle: agent tunes the presenter session (e.g. idle-end timeout) for the app's needs. */
338
+ readonly SESSION_CONFIG: "session_config";
339
+ /**
340
+ * Live-control: bridge → browser. Pushes the current session state to the panel so an
341
+ * AGENT-driven pause/end keeps the presenter in sync. `args: { state, text? }`.
342
+ */
343
+ readonly PRESENTER: "presenter";
344
+ /** Navigate the page to a new URL. `args: { url: string }`. */
345
+ readonly NAVIGATE: "navigate";
346
+ /** Reload the page. `args: { hard?: boolean }` — hard clears the cache via location replace trick. */
347
+ readonly REFRESH: "refresh";
348
+ /**
349
+ * Bridge → browser: the saved flows the human can replay from the panel.
350
+ * `args: { flows: [{ name, start? }] }` — `start` is the first step's testid anchor, a page hint the
351
+ * HUD uses to show a flow only where it can begin. Absent when the first step isn't testid-anchored.
352
+ */
353
+ readonly FLOWS: "flows";
354
+ };
355
+ export type ReticleCommand = (typeof ReticleCommand)[keyof typeof ReticleCommand];
356
+ /** Presenter intent shown to the human watcher: is the agent reading or acting? */
357
+ export declare const PresenterMode: {
358
+ readonly IDLE: "idle";
359
+ readonly READING: "reading";
360
+ readonly ACTING: "acting";
361
+ };
362
+ export type PresenterMode = (typeof PresenterMode)[keyof typeof PresenterMode];
363
+ /** Snapshot rendering modes (plan/04). */
364
+ export declare const SnapshotMode: {
365
+ readonly FULL: "full";
366
+ readonly INTERACTIVE: "interactive";
367
+ readonly STATUS: "status";
368
+ };
369
+ export type SnapshotMode = (typeof SnapshotMode)[keyof typeof SnapshotMode];
370
+ /** Top-level envelope discriminator for messages on the WS channel. */
371
+ export declare const MessageKind: {
372
+ readonly HELLO: "hello";
373
+ readonly COMMAND: "command";
374
+ readonly COMMAND_RESULT: "command_result";
375
+ readonly EVENT: "event";
376
+ };
377
+ export type MessageKind = (typeof MessageKind)[keyof typeof MessageKind];
378
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,eAAO,MAAM,oBAAoB,OAAO,CAAC;AACzC,eAAO,MAAM,eAAe,aAAa,CAAC;AAC1C,eAAO,MAAM,wBAAwB,IAAI,CAAC;AAE1C;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,IAAI,GAAE,MAA6B,EAAE,IAAI,SAAc,GAAG,MAAM,CAE3F;AAED;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB;;;CAGpB,CAAC;AAEX,yGAAyG;AACzG,eAAO,MAAM,aAAa,cAAc,CAAC;AAEzC;;;;GAIG;AACH,eAAO,MAAM,UAAU;IACrB,yFAAyF;;IAEzF,+FAA+F;;IAE/F,2DAA2D;;IAE3D,sCAAsC;;IAEtC,8EAA8E;;IAE9E,oFAAoF;;IAEpF,oFAAoF;;IAEpF;iGAC6F;;IAE7F,wGAAwG;;CAEhG,CAAC;AAEX,8DAA8D;AAC9D,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;IAqB3B,wFAAwF;;IAExF,+FAA+F;;CAEvF,CAAC;AAEX,kFAAkF;AAClF,eAAO,MAAM,cAAc,eAAe,CAAC;AAE3C,6EAA6E;AAC7E,eAAO,MAAM,4BAA4B,qBAAqB,CAAC;AAE/D,4DAA4D;AAC5D,eAAO,MAAM,sBAAsB,IAAI,CAAC;AAExC,iFAAiF;AACjF,eAAO,MAAM,UAAU;;;;;IAKrB,2FAA2F;;IAE3F,6EAA6E;;IAE7E,+FAA+F;;IAE/F;;;;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