@reclaimprotocol/agent 0.1.22 → 0.1.24

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 (163) hide show
  1. package/README.md +55 -20
  2. package/lib/authoring/backend.d.ts +13 -10
  3. package/lib/authoring/tools.js +106 -9
  4. package/lib/cdp/browser-proxy.d.ts +78 -0
  5. package/lib/cdp/browser-proxy.js +186 -0
  6. package/lib/cdp/capture-engine.js +8 -7
  7. package/lib/cdp/client.d.ts +10 -0
  8. package/lib/cdp/geo.d.ts +10 -0
  9. package/lib/cdp/geo.js +36 -0
  10. package/lib/cdp/index.d.ts +1 -0
  11. package/lib/cdp/index.js +1 -0
  12. package/lib/live/cloudflared.d.ts +15 -0
  13. package/lib/live/cloudflared.js +268 -0
  14. package/lib/live/page.d.ts +20 -0
  15. package/lib/live/page.js +134 -0
  16. package/lib/live/tunnel.d.ts +23 -0
  17. package/lib/live/tunnel.js +120 -0
  18. package/lib/live/viewer.d.ts +28 -0
  19. package/lib/live/viewer.js +232 -0
  20. package/lib/mcp/api/operations.gen.js +34 -26
  21. package/lib/mcp/api/to-zod.d.ts +1 -1
  22. package/lib/mcp/api/to-zod.js +1 -1
  23. package/lib/mcp/api/tools.js +1 -1
  24. package/lib/mcp/instructions.d.ts +15 -2
  25. package/lib/mcp/instructions.js +101 -38
  26. package/lib/mcp/start.js +4 -3
  27. package/lib/mcp/tools/agent/analyze.js +5 -1
  28. package/lib/mcp/tools/agent/attach.d.ts +8 -1
  29. package/lib/mcp/tools/agent/attach.js +166 -22
  30. package/lib/mcp/tools/agent/build.d.ts +13 -8
  31. package/lib/mcp/tools/agent/build.js +22 -11
  32. package/lib/mcp/tools/agent/capture.js +5 -1
  33. package/lib/mcp/tools/agent/eval.js +3 -1
  34. package/lib/mcp/tools/agent/find.js +6 -5
  35. package/lib/mcp/tools/agent/how-it-works.d.ts +15 -7
  36. package/lib/mcp/tools/agent/how-it-works.js +57 -17
  37. package/lib/mcp/tools/agent/live-view.d.ts +21 -0
  38. package/lib/mcp/tools/agent/live-view.js +153 -0
  39. package/lib/mcp/tools/agent/pod-proof.d.ts +8 -0
  40. package/lib/mcp/tools/agent/pod-proof.js +64 -0
  41. package/lib/mcp/tools/agent/propose.js +29 -3
  42. package/lib/mcp/tools/agent/proxy.d.ts +3 -0
  43. package/lib/mcp/tools/agent/proxy.js +199 -0
  44. package/lib/mcp/tools/agent/publish.js +49 -77
  45. package/lib/mcp/tools/agent/session.d.ts +2 -1
  46. package/lib/mcp/tools/agent/session.js +26 -7
  47. package/lib/mcp/tools/agent/shared.js +17 -8
  48. package/lib/mcp/tools/authenticate/authenticate.d.ts +11 -0
  49. package/lib/mcp/tools/authenticate/authenticate.js +143 -121
  50. package/lib/mcp/tools/authenticate/builder-access.d.ts +8 -3
  51. package/lib/mcp/tools/authenticate/builder-access.js +8 -3
  52. package/lib/mcp/tools/mode/mode.d.ts +1 -1
  53. package/lib/mcp/tools/mode/mode.js +26 -7
  54. package/lib/old/client.d.ts +9 -0
  55. package/lib/old/client.js +19 -1
  56. package/lib/old/instructions.d.ts +9 -1
  57. package/lib/old/instructions.js +4 -6
  58. package/lib/old/login-cdp.d.ts +2 -2
  59. package/lib/old/login-cdp.js +46 -6
  60. package/lib/old/to-register.d.ts +20 -8
  61. package/lib/old/to-register.js +7 -1
  62. package/lib/old/tools/authenticate.js +9 -1
  63. package/lib/old/tools/get-provider-info.js +6 -5
  64. package/lib/old/tools/issue-app-credentials.js +3 -2
  65. package/lib/old/tools/me-providers.js +3 -1
  66. package/lib/old/tools/publish.d.ts +1 -1
  67. package/lib/old/tools/publish.js +132 -129
  68. package/lib/old/tools/update-provider-metadata.d.ts +1 -1
  69. package/lib/old/tools/update-provider-metadata.js +1 -1
  70. package/lib/old/tools/verify-sdk-setup.js +1 -1
  71. package/lib/proof/attestor.d.ts +3 -3
  72. package/lib/proof/debug-response-dump.js +4 -4
  73. package/lib/proof/index.d.ts +1 -0
  74. package/lib/proof/index.js +1 -0
  75. package/lib/proof/page-replay.d.ts +36 -0
  76. package/lib/proof/page-replay.js +76 -0
  77. package/lib/proof/pod-prover.d.ts +47 -0
  78. package/lib/proof/pod-prover.js +155 -0
  79. package/lib/proof/replay.d.ts +28 -0
  80. package/lib/proof/replay.js +39 -18
  81. package/lib/provider/dom-xpath.js +11 -9
  82. package/lib/provider/draft.d.ts +13 -8
  83. package/lib/provider/draft.js +47 -13
  84. package/lib/provider/injection-doc.d.ts +23 -1
  85. package/lib/provider/injection-doc.js +34 -21
  86. package/lib/provider/match-redaction-warning.d.ts +2 -2
  87. package/lib/provider/match-redaction-warning.js +3 -3
  88. package/lib/provider/matcher.js +122 -12
  89. package/lib/provider/secrets.d.ts +3 -3
  90. package/lib/provider/secrets.js +3 -3
  91. package/lib/provider/to-version.d.ts +12 -9
  92. package/lib/provider/to-version.js +16 -4
  93. package/lib/tools/registry.d.ts +5 -5
  94. package/lib/tools/registry.js +5 -5
  95. package/package.json +4 -3
  96. package/samples/demo-server/README.md +7 -6
  97. package/skill/SKILL.builder.md +356 -189
  98. package/skill/SKILL.common.md +314 -79
  99. package/skill/SKILL.old.md +340 -155
  100. package/skill/builder-mode.md +58 -17
  101. package/skill/hash-validation.md +170 -0
  102. package/skill/interception.md +235 -0
  103. package/skill/js-sdk-integration.md +13 -7
  104. package/skill/old-mode.md +53 -12
  105. package/skill/user-script.md +61 -0
  106. package/src/authoring/backend.ts +13 -10
  107. package/src/authoring/tools.ts +128 -9
  108. package/src/cdp/capture-engine.ts +8 -7
  109. package/src/cdp/client.ts +8 -0
  110. package/src/cdp/geo.ts +52 -0
  111. package/src/cdp/index.ts +1 -0
  112. package/src/consts.ts +1 -0
  113. package/src/live/cloudflared.ts +348 -0
  114. package/src/live/page.ts +145 -0
  115. package/src/live/tunnel.ts +157 -0
  116. package/src/live/viewer.ts +293 -0
  117. package/src/mcp/api/operations.gen.ts +34 -26
  118. package/src/mcp/api/to-zod.ts +1 -1
  119. package/src/mcp/api/tools.ts +1 -1
  120. package/src/mcp/instructions.ts +121 -48
  121. package/src/mcp/start.ts +4 -3
  122. package/src/mcp/tools/agent/analyze.ts +5 -1
  123. package/src/mcp/tools/agent/attach.ts +194 -22
  124. package/src/mcp/tools/agent/build.ts +26 -15
  125. package/src/mcp/tools/agent/capture.ts +5 -1
  126. package/src/mcp/tools/agent/eval.ts +4 -1
  127. package/src/mcp/tools/agent/find.ts +6 -5
  128. package/src/mcp/tools/agent/how-it-works.ts +62 -21
  129. package/src/mcp/tools/agent/live-view.ts +198 -0
  130. package/src/mcp/tools/agent/pod-proof.ts +90 -0
  131. package/src/mcp/tools/agent/propose.ts +31 -3
  132. package/src/mcp/tools/agent/publish.ts +54 -78
  133. package/src/mcp/tools/agent/session.ts +26 -5
  134. package/src/mcp/tools/agent/shared.ts +19 -8
  135. package/src/mcp/tools/authenticate/authenticate.ts +167 -165
  136. package/src/mcp/tools/authenticate/builder-access.ts +8 -3
  137. package/src/mcp/tools/mode/mode.ts +28 -7
  138. package/src/old/client.ts +30 -1
  139. package/src/old/instructions.ts +4 -10
  140. package/src/old/login-cdp.ts +50 -6
  141. package/src/old/to-register.ts +28 -8
  142. package/src/old/tools/authenticate.ts +9 -1
  143. package/src/old/tools/get-provider-info.ts +6 -5
  144. package/src/old/tools/issue-app-credentials.ts +3 -2
  145. package/src/old/tools/me-providers.ts +3 -1
  146. package/src/old/tools/publish.ts +140 -130
  147. package/src/old/tools/update-provider-metadata.ts +1 -1
  148. package/src/old/tools/verify-sdk-setup.ts +1 -1
  149. package/src/proof/attestor.ts +3 -3
  150. package/src/proof/debug-response-dump.ts +4 -4
  151. package/src/proof/index.ts +8 -0
  152. package/src/proof/page-replay.ts +131 -0
  153. package/src/proof/pod-prover.ts +231 -0
  154. package/src/proof/replay.ts +60 -19
  155. package/src/provider/dom-xpath.ts +11 -9
  156. package/src/provider/draft.ts +56 -13
  157. package/src/provider/injection-doc.ts +37 -24
  158. package/src/provider/match-redaction-warning.ts +3 -3
  159. package/src/provider/matcher.ts +151 -10
  160. package/src/provider/secrets.ts +3 -3
  161. package/src/provider/to-version.ts +30 -13
  162. package/src/tools/registry.ts +5 -5
  163. package/skill/injection-api.md +0 -335
@@ -0,0 +1,120 @@
1
+ /**
2
+ * Public HTTPS front door for the local live-view server, via a `cloudflared`
3
+ * quick tunnel.
4
+ *
5
+ * A quick tunnel needs no Cloudflare account and no DNS: `cloudflared` dials
6
+ * out, Cloudflare hands back a throwaway `*.trycloudflare.com` hostname, and
7
+ * traffic arrives on the loopback port we pass in. That is the whole reason it
8
+ * is used here — the developer's machine keeps no inbound port open.
9
+ *
10
+ * The tunnel itself carries NO authorization. Anyone holding the hostname can
11
+ * reach the local server, so the server is the thing that must authenticate
12
+ * (see `viewer.ts`, which puts an unguessable token in every path).
13
+ */
14
+ import { spawn } from 'node:child_process';
15
+ import { LOGGER } from "../logger.js";
16
+ import { resolveCloudflared } from "./cloudflared.js";
17
+ /** How long to wait for cloudflared to report its hostname before giving up. */
18
+ const URL_TIMEOUT_MS = 30000;
19
+ /** After the hostname is printed, Cloudflare needs a moment before the edge
20
+ * routes to it — measured at ~3s. Poll until it answers so the caller never
21
+ * hands out a URL that errors, but don't fail the share if it's slow. */
22
+ const READY_TIMEOUT_MS = 20000;
23
+ const READY_POLL_MS = 1000;
24
+ /** `https://<something>.trycloudflare.com`, as printed on cloudflared's log
25
+ * stream. Anchored to the scheme so a hostname inside prose can't match. */
26
+ const QUICK_TUNNEL_URL = /https:\/\/[a-z0-9-]+\.trycloudflare\.com/i;
27
+ /**
28
+ * Poll the public origin until Cloudflare's edge routes to it. ANY HTTP
29
+ * response counts, including a 404: the live-view server 404s unknown paths,
30
+ * so a status code at all proves the hop is live.
31
+ */
32
+ async function waitUntilRouted(url) {
33
+ const deadline = Date.now() + READY_TIMEOUT_MS;
34
+ while (Date.now() < deadline) {
35
+ try {
36
+ await fetch(url, {
37
+ method: 'GET',
38
+ redirect: 'manual',
39
+ signal: AbortSignal.timeout(READY_POLL_MS * 4),
40
+ });
41
+ return true;
42
+ }
43
+ catch {
44
+ await new Promise((r) => setTimeout(r, READY_POLL_MS));
45
+ }
46
+ }
47
+ return false;
48
+ }
49
+ /**
50
+ * Open a quick tunnel to `http://127.0.0.1:<port>` and resolve once
51
+ * Cloudflare has assigned a hostname.
52
+ *
53
+ * Rejects with an actionable message when `cloudflared` is not installed,
54
+ * exits early, or never reports a hostname.
55
+ */
56
+ export async function startTunnel(port, { autoInstall = true } = {}) {
57
+ // Resolves an existing cloudflared, or fetches one on first use. Throws
58
+ // with an actionable message when neither is possible.
59
+ const binary = await resolveCloudflared({ autoInstall });
60
+ const child = spawn(binary.path, [
61
+ 'tunnel',
62
+ '--no-autoupdate',
63
+ '--url', `http://127.0.0.1:${port}`,
64
+ ], { stdio: ['ignore', 'pipe', 'pipe'] });
65
+ const stop = async () => {
66
+ if (!child.killed) {
67
+ child.kill('SIGTERM');
68
+ }
69
+ };
70
+ return new Promise((resolve, reject) => {
71
+ const timer = setTimeout(() => {
72
+ void stop();
73
+ reject(new Error('cloudflared did not report a tunnel hostname within '
74
+ + `${URL_TIMEOUT_MS / 1000}s. Check network egress to Cloudflare, `
75
+ + 'or run `cloudflared tunnel --url http://127.0.0.1:'
76
+ + `${port}` + '` by hand to see its output.'));
77
+ }, URL_TIMEOUT_MS);
78
+ let settled = false;
79
+ const finish = (fn) => {
80
+ if (settled) {
81
+ return;
82
+ }
83
+ settled = true;
84
+ clearTimeout(timer);
85
+ fn();
86
+ };
87
+ // cloudflared logs the assigned hostname to stderr, not stdout. Watch
88
+ // both so a future version that switches streams still works.
89
+ const onChunk = (chunk) => {
90
+ const text = chunk.toString();
91
+ const match = QUICK_TUNNEL_URL.exec(text);
92
+ if (match) {
93
+ const url = match[0];
94
+ finish(() => {
95
+ void waitUntilRouted(url).then((ready) => {
96
+ if (!ready) {
97
+ LOGGER.warn({ url }, 'tunnel not routed yet; returning anyway');
98
+ }
99
+ resolve({ url, ready, stop, binary });
100
+ });
101
+ });
102
+ }
103
+ };
104
+ child.stdout?.on('data', onChunk);
105
+ child.stderr?.on('data', onChunk);
106
+ child.on('error', (err) => {
107
+ // `resolveCloudflared` already proved the binary runs, so an ENOENT
108
+ // here means it vanished between resolving and spawning.
109
+ finish(() => reject(err.code === 'ENOENT'
110
+ ? new Error(`cloudflared disappeared from ${binary.path} before it could `
111
+ + 'start. Retry — the agent will fetch it again if needed.')
112
+ : err));
113
+ });
114
+ child.on('exit', (code) => {
115
+ LOGGER.debug({ code }, 'cloudflared exited');
116
+ finish(() => reject(new Error(`cloudflared exited with code ${code} before reporting a `
117
+ + 'hostname.')));
118
+ });
119
+ });
120
+ }
@@ -0,0 +1,28 @@
1
+ import type { CdpTabClient } from '../cdp/client.ts';
2
+ export interface LiveViewOptions {
3
+ /** The tab to stream. */
4
+ tab: CdpTabClient;
5
+ /** Forward viewer input into the page. */
6
+ interactive: boolean;
7
+ /** Shown in the viewer's header. */
8
+ title?: string;
9
+ }
10
+ export interface LiveView {
11
+ /** Loopback origin the tunnel should point at. */
12
+ localUrl: string;
13
+ /** Port the server bound to. */
14
+ port: number;
15
+ /** Unguessable path segment guarding every route. */
16
+ token: string;
17
+ /** Path prefix, `/v/<token>`. Append this to the public origin. */
18
+ path: string;
19
+ /** Number of viewers currently streaming. */
20
+ viewers: () => number;
21
+ stop: () => Promise<void>;
22
+ }
23
+ /**
24
+ * Start the loopback live-view server for `tab`. Resolves once it is
25
+ * listening; the screencast starts with the first viewer and stops with the
26
+ * last, so an idle share costs the page nothing.
27
+ */
28
+ export declare function startLiveView(opts: LiveViewOptions): Promise<LiveView>;
@@ -0,0 +1,232 @@
1
+ /**
2
+ * Interactive live view of one attached tab, over a public URL.
3
+ *
4
+ * Two halves:
5
+ * - OUT: CDP `Page.startScreencast` pushes JPEG frames; each is forwarded to
6
+ * every connected browser as a Server-Sent Event and acked back to CDP.
7
+ * - IN: the viewer POSTs pointer and key events, which are replayed into the
8
+ * page with `Input.dispatch*`.
9
+ *
10
+ * Only ever bound to 127.0.0.1. Reaching it from outside is the tunnel's job
11
+ * (see `tunnel.ts`), and because a quick tunnel is unauthenticated, EVERY
12
+ * route sits behind an unguessable token in the path. A request without it
13
+ * gets a flat 404 — not a 401, which would confirm the server exists.
14
+ *
15
+ * Interactivity is the caller's choice. `interactive: false` still streams,
16
+ * but the input route refuses, which is the right setting for showing someone
17
+ * a run rather than handing them the wheel.
18
+ */
19
+ import { randomBytes } from 'node:crypto';
20
+ import { createServer, } from 'node:http';
21
+ import { LOGGER } from "../logger.js";
22
+ import { renderViewerPage } from "./page.js";
23
+ /** JPEG quality for streamed frames. 60 keeps a text-heavy page readable
24
+ * while staying small enough for a tunnel's uplink. */
25
+ const FRAME_QUALITY = 60;
26
+ /** Cap the streamed frame size. Screencast scales to fit, so this bounds
27
+ * bandwidth without changing the page's own layout viewport. */
28
+ const MAX_FRAME_WIDTH = 1280;
29
+ const MAX_FRAME_HEIGHT = 800;
30
+ /** Bytes accepted on an input POST. Events are tiny; anything larger is
31
+ * either a bug or someone probing. */
32
+ const MAX_INPUT_BYTES = 4096;
33
+ /**
34
+ * Start the loopback live-view server for `tab`. Resolves once it is
35
+ * listening; the screencast starts with the first viewer and stops with the
36
+ * last, so an idle share costs the page nothing.
37
+ */
38
+ export async function startLiveView(opts) {
39
+ const token = randomBytes(24).toString('base64url');
40
+ const path = `/v/${token}`;
41
+ const clients = new Set();
42
+ let streaming = false;
43
+ let unsubscribe;
44
+ const startScreencast = async () => {
45
+ if (streaming) {
46
+ return;
47
+ }
48
+ streaming = true;
49
+ unsubscribe = opts.tab.subscribe('Page.screencastFrame', (frame) => {
50
+ // Ack first: CDP sends at most one un-acked frame, so a slow or failed
51
+ // write must not stall the stream.
52
+ void opts.tab
53
+ .send('Page.screencastFrameAck', { sessionId: frame.sessionId })
54
+ .catch(() => { });
55
+ const payload = JSON.stringify({ data: frame.data });
56
+ for (const res of clients) {
57
+ res.write(`event: frame\ndata: ${payload}\n\n`);
58
+ }
59
+ });
60
+ await opts.tab.send('Page.enable');
61
+ await opts.tab.send('Page.startScreencast', {
62
+ format: 'jpeg',
63
+ quality: FRAME_QUALITY,
64
+ maxWidth: MAX_FRAME_WIDTH,
65
+ maxHeight: MAX_FRAME_HEIGHT,
66
+ everyNthFrame: 1,
67
+ });
68
+ };
69
+ const stopScreencast = async () => {
70
+ if (!streaming) {
71
+ return;
72
+ }
73
+ streaming = false;
74
+ unsubscribe?.();
75
+ unsubscribe = undefined;
76
+ await opts.tab.send('Page.stopScreencast').catch(() => { });
77
+ };
78
+ const server = createServer((req, res) => {
79
+ const url = req.url ?? '/';
80
+ // Constant prefix check: everything is scoped under the token, so an
81
+ // unmatched path is indistinguishable from a server that isn't there.
82
+ if (!url.startsWith(path)) {
83
+ res.writeHead(404).end('not found');
84
+ return;
85
+ }
86
+ const route = url.slice(path.length) || '/';
87
+ if (req.method === 'GET' && (route === '/' || route.startsWith('/?'))) {
88
+ const body = renderViewerPage({
89
+ base: path,
90
+ interactive: opts.interactive,
91
+ title: opts.title ?? 'Attached tab',
92
+ });
93
+ res.writeHead(200, {
94
+ 'content-type': 'text/html; charset=utf-8',
95
+ // A share URL must never be cached or indexed by anything between
96
+ // the viewer and here.
97
+ 'cache-control': 'no-store',
98
+ 'referrer-policy': 'no-referrer',
99
+ }).end(body);
100
+ return;
101
+ }
102
+ if (req.method === 'GET' && route === '/stream') {
103
+ res.writeHead(200, {
104
+ 'content-type': 'text/event-stream',
105
+ 'cache-control': 'no-store',
106
+ connection: 'keep-alive',
107
+ // Defeat proxy buffering, which would otherwise hold frames back.
108
+ 'x-accel-buffering': 'no',
109
+ });
110
+ res.write(': connected\n\n');
111
+ clients.add(res);
112
+ void startScreencast().catch((err) => {
113
+ LOGGER.warn({ err }, 'live view: screencast failed to start');
114
+ });
115
+ req.on('close', () => {
116
+ clients.delete(res);
117
+ if (!clients.size) {
118
+ void stopScreencast();
119
+ }
120
+ });
121
+ return;
122
+ }
123
+ if (req.method === 'POST' && route === '/input') {
124
+ if (!opts.interactive) {
125
+ res.writeHead(403).end('view only');
126
+ return;
127
+ }
128
+ readJson(req, MAX_INPUT_BYTES)
129
+ .then((body) => dispatchInput(opts.tab, body))
130
+ .then(() => res.writeHead(204).end())
131
+ .catch((err) => {
132
+ LOGGER.debug({ err }, 'live view: input rejected');
133
+ res.writeHead(400).end('bad input');
134
+ });
135
+ return;
136
+ }
137
+ res.writeHead(404).end('not found');
138
+ });
139
+ await new Promise((resolve) => {
140
+ server.listen(0, '127.0.0.1', resolve);
141
+ });
142
+ const port = server.address().port;
143
+ return {
144
+ localUrl: `http://127.0.0.1:${port}`,
145
+ port,
146
+ token,
147
+ path,
148
+ viewers: () => clients.size,
149
+ stop: async () => {
150
+ await stopScreencast();
151
+ for (const res of clients) {
152
+ res.end();
153
+ }
154
+ clients.clear();
155
+ await closeServer(server);
156
+ },
157
+ };
158
+ }
159
+ function closeServer(server) {
160
+ return new Promise((resolve) => {
161
+ server.close(() => resolve());
162
+ // A held-open SSE response would otherwise keep the server alive.
163
+ server.closeAllConnections?.();
164
+ });
165
+ }
166
+ function readJson(req, limit) {
167
+ return new Promise((resolve, reject) => {
168
+ let size = 0;
169
+ const chunks = [];
170
+ req.on('data', (chunk) => {
171
+ size += chunk.length;
172
+ if (size > limit) {
173
+ reject(new Error('input too large'));
174
+ req.destroy();
175
+ return;
176
+ }
177
+ chunks.push(chunk);
178
+ });
179
+ req.on('end', () => {
180
+ try {
181
+ resolve(JSON.parse(Buffer.concat(chunks).toString('utf8')));
182
+ }
183
+ catch (err) {
184
+ reject(err instanceof Error ? err : new Error('bad json'));
185
+ }
186
+ });
187
+ req.on('error', reject);
188
+ });
189
+ }
190
+ /** Replay one viewer event into the page. Unknown shapes throw, so the route
191
+ * answers 400 rather than forwarding something arbitrary to CDP. */
192
+ async function dispatchInput(tab, body) {
193
+ const num = (v) => (typeof v === 'number' && Number.isFinite(v)
194
+ ? v
195
+ : 0);
196
+ if (body.kind === 'mouse') {
197
+ const type = String(body.type);
198
+ if (!['mousePressed', 'mouseReleased', 'mouseMoved', 'mouseWheel']
199
+ .includes(type)) {
200
+ throw new Error(`unsupported mouse type ${type}`);
201
+ }
202
+ await tab.send('Input.dispatchMouseEvent', {
203
+ type,
204
+ x: num(body.x),
205
+ y: num(body.y),
206
+ button: type === 'mouseWheel' ? 'none' : 'left',
207
+ clickCount: type === 'mouseWheel' ? 0 : 1,
208
+ ...(type === 'mouseWheel'
209
+ ? { deltaX: num(body.deltaX), deltaY: num(body.deltaY) }
210
+ : {}),
211
+ });
212
+ return;
213
+ }
214
+ if (body.kind === 'key') {
215
+ const type = String(body.type);
216
+ if (type !== 'keyDown' && type !== 'keyUp') {
217
+ throw new Error(`unsupported key type ${type}`);
218
+ }
219
+ const key = String(body.key ?? '');
220
+ // A single printable character needs `text` as well, or the page sees the
221
+ // keypress but no character is inserted.
222
+ const text = key.length === 1 ? key : undefined;
223
+ await tab.send('Input.dispatchKeyEvent', {
224
+ type,
225
+ key,
226
+ code: String(body.code ?? ''),
227
+ ...(text && type === 'keyDown' ? { text } : {}),
228
+ });
229
+ return;
230
+ }
231
+ throw new Error('unknown event kind');
232
+ }
@@ -440,7 +440,7 @@ export const MCP_TOOLS = {
440
440
  }),
441
441
  },
442
442
  "CreateProvider": {
443
- description: "Create a provider\n\nCreate a new Reclaim provider. Use this only after `providers` returned nothing useful for the domain. The caller must be an active member of the target organization.\nCreates a new provider in the specified organization. `visibility` is coerced to `PRIVATE` at creation regardless of what's sent; the author may toggle to `PUBLIC` later via `PATCH /providers/{id}`. While `PRIVATE`, versions go to the go live freely; once `PUBLIC`, non-admin versions need admin review. See `Provider.visibility`.\nThe server also seeds an initial `0.1.0` version on the `draft` branch in the same transaction so the provider is immediately editable. Its `initialUrl` defaults to `https://<domain>`; all other version fields fall back to their schema-declared defaults (a `structured` verificationType, empty requests, empty web settings). `Provider.latestVersion` stays `null` until the draft is promoted to the live channel.",
443
+ description: "Create a provider\n\nCreate a new Reclaim provider. Use this only after `providers` returned nothing useful for the domain. The caller must be an active member of the target organization.\nCreates a new provider in the specified organization. `visibility` is coerced to `PRIVATE` at creation regardless of what's sent; the author may toggle to `PUBLIC` later via `PATCH /providers/{id}`. While `PRIVATE`, versions go live freely; once `PUBLIC`, non-admin versions need admin review. See `Provider.visibility`.\nThe server also seeds an initial `0.1.0` version on the `draft` branch in the same transaction so the provider is immediately editable. Its `initialUrl` defaults to `https://<domain>`; all other version fields fall back to their schema-declared defaults (a `structured` verificationType, empty requests, empty web settings). `Provider.latestVersion` stays `null` until the draft is promoted to the live channel.",
444
444
  inputSchema: toZod({
445
445
  "type": "object",
446
446
  "properties": {
@@ -467,7 +467,7 @@ export const MCP_TOOLS = {
467
467
  "format": "uuid"
468
468
  },
469
469
  "domain": {
470
- "description": "Canonical root domain (e.g. `github.com`). No scheme, no port, no path.",
470
+ "description": "Canonical root domain (for example, `github.com`). No scheme, no port, no path.",
471
471
  "type": "string",
472
472
  "format": "hostname",
473
473
  "minLength": 1,
@@ -526,12 +526,12 @@ export const MCP_TOOLS = {
526
526
  "brandUrl": {
527
527
  "type": "string",
528
528
  "format": "uri",
529
- "description": "Canonical homepage of the brand (e.g. `https://google.com`). Used in brand-link cards and JSON-LD.",
529
+ "description": "Canonical homepage of the brand (for example, `https://google.com`). Used in brand-link cards and JSON-LD.",
530
530
  "maxLength": 2000
531
531
  },
532
532
  "primaryDataPoint": {
533
533
  "type": "string",
534
- "description": "Headline data point — the single most-important variable this provider can verify (e.g. `subscriber count`). Used in the provider's SEO title.",
534
+ "description": "Headline data point — the single most-important variable this provider can verify (for example, `subscriber count`). Used in the provider's SEO title.",
535
535
  "maxLength": 200
536
536
  },
537
537
  "dataPoints": {
@@ -636,10 +636,11 @@ export const MCP_TOOLS = {
636
636
  },
637
637
  "branch": {
638
638
  "type": "string",
639
- "description": "Branch (lifecycle stage) of this provider version.\n\n- `ai`: changes authored by the AI assistant live on this branch.\n\n- `draft`: a human is actively editing the version.\n\n- `in_review`: the author has submitted the version to be made\n public and it is awaiting review. On approval the branch tag\n is cleared (the version is promoted to the live channel and becomes\n public).\n\n- `rejected`: review concluded with a rejection. When the author\n addresses the feedback the branch transitions back to\n `in_review`.",
639
+ "description": "Branch (lifecycle stage) of this provider version.\n\n- `ai`: changes authored by the AI assistant live on this branch.\n\n- `draft`: a human is actively editing the version.\n\n- `fixed`: a proven AI repair. It remains pinned to its explicit\n version and does not replace the live trunk version.\n\n- `in_review`: the author has submitted the version to be made\n public and it is awaiting review. On approval the branch tag\n is cleared (the version is promoted to the live channel and becomes\n public).\n\n- `rejected`: review concluded with a rejection. When the author\n addresses the feedback the branch transitions back to\n `in_review`.",
640
640
  "enum": [
641
641
  "ai",
642
642
  "draft",
643
+ "fixed",
643
644
  "in_review",
644
645
  "rejected"
645
646
  ]
@@ -775,7 +776,7 @@ export const MCP_TOOLS = {
775
776
  "items": {
776
777
  "type": "object",
777
778
  "additionalProperties": false,
778
- "description": "Which portions to select from a response. These are selected in order, xpath => jsonPath => regex * These redactions are done client side and only the selected portions are sent to the attestor. The attestor will only be able to see the selected portions alongside the first line of the HTTP response (i.e. \"HTTP/1.1 200 OK\")",
779
+ "description": "Which portions to select from a response. These are selected in order, xpath => jsonPath => regex * These redactions are done client side and only the selected portions are sent to the attestor. The attestor will only be able to see the selected portions alongside the first line of the HTTP response (that is, \"HTTP/1.1 200 OK\")",
779
780
  "properties": {
780
781
  "xPath": {
781
782
  "type": "string",
@@ -783,7 +784,7 @@ export const MCP_TOOLS = {
783
784
  },
784
785
  "jsonPath": {
785
786
  "type": "string",
786
- "description": "expect a JSON response, retrieve the item at this path using dot notation for e.g. 'email.addresses.0'"
787
+ "description": "expect a JSON response, retrieve the item at this path using dot notation, for example 'email.addresses.0'."
787
788
  },
788
789
  "regex": {
789
790
  "type": "string",
@@ -926,7 +927,7 @@ export const MCP_TOOLS = {
926
927
  "items": {
927
928
  "type": "object",
928
929
  "additionalProperties": false,
929
- "description": "Which portions to select from a response. These are selected in order, xpath => jsonPath => regex * These redactions are done client side and only the selected portions are sent to the attestor. The attestor will only be able to see the selected portions alongside the first line of the HTTP response (i.e. \"HTTP/1.1 200 OK\")",
930
+ "description": "Which portions to select from a response. These are selected in order, xpath => jsonPath => regex * These redactions are done client side and only the selected portions are sent to the attestor. The attestor will only be able to see the selected portions alongside the first line of the HTTP response (that is, \"HTTP/1.1 200 OK\")",
930
931
  "properties": {
931
932
  "xPath": {
932
933
  "type": "string",
@@ -934,7 +935,7 @@ export const MCP_TOOLS = {
934
935
  },
935
936
  "jsonPath": {
936
937
  "type": "string",
937
- "description": "expect a JSON response, retrieve the item at this path using dot notation for e.g. 'email.addresses.0'"
938
+ "description": "expect a JSON response, retrieve the item at this path using dot notation, for example 'email.addresses.0'."
938
939
  },
939
940
  "regex": {
940
941
  "type": "string",
@@ -991,8 +992,8 @@ export const MCP_TOOLS = {
991
992
  "properties": {
992
993
  "geoLocation": {
993
994
  "type": "string",
994
- "description": "Geographic location (e.g. ISO country code or {{DYNAMIC_GEO}} to use user's geo location) the verification should appear to originate from.",
995
- "maxLength": 15,
995
+ "description": "Geographic location the verification should appear to originate from: a 2-letter ISO country code, or a parameter the attestor resolves at proof time. `{{DYNAMIC_GEO}}` and `{{DYNAMIC_GEO_SECRET}}` are the Verification Client's standard names for the end-user's own country — the `_SECRET` one is delivered as a secret param, so the attestor never learns which country the proof egressed from.",
996
+ "maxLength": 64,
996
997
  "default": "{{DYNAMIC_GEO}}"
997
998
  },
998
999
  "clientOptions": {
@@ -1386,7 +1387,7 @@ export const MCP_TOOLS = {
1386
1387
  }),
1387
1388
  },
1388
1389
  "DeleteProviderVersion": {
1389
- description: "Delete a provider version\n\nSoft-archives a version on the `draft`, `ai`, or `rejected` branch — sets `status` to `ARCHIVED` so history is preserved. Trunk (live) and `in_review` versions cannot be archived this way; archive the parent provider instead. Supports optimistic concurrency via `If-Match`.",
1390
+ description: "Delete a provider version\n\nSoft-archives a version on the `draft`, `ai`, or `rejected` branch — sets `status` to `ARCHIVED` so history is preserved. `fixed`, trunk (live), and `in_review` versions cannot be archived this way; archive the parent provider instead. Supports optimistic concurrency via `If-Match`.",
1390
1391
  inputSchema: toZod({
1391
1392
  "type": "object",
1392
1393
  "properties": {
@@ -1706,7 +1707,7 @@ export const MCP_TOOLS = {
1706
1707
  }),
1707
1708
  },
1708
1709
  "GetProviderVersion": {
1709
- description: "Get a specific provider version",
1710
+ description: "Get a specific provider version\n\nFetches one exact canonical version. Trunk is public when the provider is public. Non-trunk versions are visible to admins and members of the provider's organization. A member of the organization that paid for a successful AI repair may also read only the exact `fixed` version created by that repair.",
1710
1711
  inputSchema: toZod({
1711
1712
  "type": "object",
1712
1713
  "properties": {
@@ -2061,7 +2062,7 @@ export const MCP_TOOLS = {
2061
2062
  }),
2062
2063
  },
2063
2064
  "ListProviderVersions": {
2064
- description: "List a provider's versions\n\nLists versions visible to the caller. Non-public branches (`ai`, `draft`, `in_review`, `rejected`) are only visible to members of the provider's owning organization.",
2065
+ description: "List a provider's versions\n\nLists versions visible to the caller. Non-public branches (`ai`, `draft`, `fixed`, `in_review`, `rejected`) are only visible to members of the provider's owning organization.",
2065
2066
  inputSchema: toZod({
2066
2067
  "type": "object",
2067
2068
  "properties": {
@@ -2210,7 +2211,7 @@ export const MCP_TOOLS = {
2210
2211
  }),
2211
2212
  },
2212
2213
  "Providers": {
2213
- description: "Search providers\n\nSearch published Reclaim providers by domain or data point. A provider is the recipe an end-user follows to prove something about themselves (e.g. \"I have N followers on Twitter\"). Returns a list of matches. Call this BEFORE `create_provider` — most popular domains already have a public provider you can reuse.\nCatalog page listing all providers. Returns a paginated list of providers the caller can see. Public providers are visible to everyone; private providers are only visible to org members.",
2214
+ description: "Search providers\n\nSearch Reclaim providers by domain or data point. A provider is the recipe an end-user follows to prove something about themselves, such as \"I have N followers on Twitter\".\nCall this BEFORE `create_provider` — most popular domains already have a public provider you can reuse, and creating another one just stacks duplicates.\nReturns a paginated list of the providers the caller can see: public providers to everyone, private providers only to members of the owning organization.",
2214
2215
  inputSchema: toZod({
2215
2216
  "type": "object",
2216
2217
  "properties": {
@@ -2567,7 +2568,7 @@ export const MCP_TOOLS = {
2567
2568
  "properties": {
2568
2569
  "notes": {
2569
2570
  "type": "string",
2570
- "description": "Optional note from the author to reviewers (changelog, areas to focus on, etc.).",
2571
+ "description": "Optional note from the author to reviewers (changelog, areas to focus on, and so on).",
2571
2572
  "maxLength": 10000
2572
2573
  }
2573
2574
  }
@@ -2724,6 +2725,13 @@ export const MCP_TOOLS = {
2724
2725
  "minLength": 1,
2725
2726
  "maxLength": 200
2726
2727
  },
2728
+ "region": {
2729
+ "type": "string",
2730
+ "nullable": true,
2731
+ "description": "Confirm or override the provider's region. Send `null` to clear it so the provider applies to every region. See `Provider.region`.",
2732
+ "pattern": "^[a-z]{2}(-[a-z]{2})?$",
2733
+ "maxLength": 5
2734
+ },
2727
2735
  "title": {
2728
2736
  "type": "string",
2729
2737
  "minLength": 1,
@@ -2776,12 +2784,12 @@ export const MCP_TOOLS = {
2776
2784
  "brandUrl": {
2777
2785
  "type": "string",
2778
2786
  "format": "uri",
2779
- "description": "Canonical homepage of the brand (e.g. `https://google.com`). Used in brand-link cards and JSON-LD.",
2787
+ "description": "Canonical homepage of the brand (for example, `https://google.com`). Used in brand-link cards and JSON-LD.",
2780
2788
  "maxLength": 2000
2781
2789
  },
2782
2790
  "primaryDataPoint": {
2783
2791
  "type": "string",
2784
- "description": "Headline data point — the single most-important variable this provider can verify (e.g. `subscriber count`). Used in the provider's SEO title.",
2792
+ "description": "Headline data point — the single most-important variable this provider can verify (for example, `subscriber count`). Used in the provider's SEO title.",
2785
2793
  "maxLength": 200
2786
2794
  },
2787
2795
  "dataPoints": {
@@ -2817,7 +2825,7 @@ export const MCP_TOOLS = {
2817
2825
  }),
2818
2826
  },
2819
2827
  "UpdateProviderVersion": {
2820
- description: "Update a provider version\n\nMutable only while the version is on the `draft` or `rejected` branch. Versions on `in_review` or the live channel reject all writes here. Caller must be a member of the provider's owning organization. Supports optimistic concurrency via `If-Match`.",
2828
+ description: "Update a provider version\n\nMutable only while the version is on the `draft` or `rejected` branch. Versions on `fixed`, `in_review`, or the live channel reject all writes here. Caller must be a member of the provider's owning organization. Supports optimistic concurrency via `If-Match`.",
2821
2829
  inputSchema: toZod({
2822
2830
  "type": "object",
2823
2831
  "properties": {
@@ -2857,7 +2865,7 @@ export const MCP_TOOLS = {
2857
2865
  "body": {
2858
2866
  "type": "object",
2859
2867
  "additionalProperties": false,
2860
- "description": "Partial update of a provider version. Mutable only while the version is on the `draft` or `rejected` branch; versions on `in_review` or the live channel reject all writes here. The semver does not change on update — `build_number` increments instead, giving callers a monotonic revision counter without touching the (major, minor, patch) PK. `verificationType` and `prompt` may be updated; omit either to carry the prior build's value forward.",
2868
+ "description": "Partial update of a provider version. Mutable only while the version is on the `draft` or `rejected` branch; versions on `fixed`, `in_review`, or the live channel reject all writes here. The semver does not change on update — `build_number` increments instead, giving callers a monotonic revision counter without touching the (major, minor, patch) PK. `verificationType` and `prompt` may be updated; omit either to carry the prior build's value forward.",
2861
2869
  "properties": {
2862
2870
  "initialUrl": {
2863
2871
  "type": "string",
@@ -2996,7 +3004,7 @@ export const MCP_TOOLS = {
2996
3004
  "items": {
2997
3005
  "type": "object",
2998
3006
  "additionalProperties": false,
2999
- "description": "Which portions to select from a response. These are selected in order, xpath => jsonPath => regex * These redactions are done client side and only the selected portions are sent to the attestor. The attestor will only be able to see the selected portions alongside the first line of the HTTP response (i.e. \"HTTP/1.1 200 OK\")",
3007
+ "description": "Which portions to select from a response. These are selected in order, xpath => jsonPath => regex * These redactions are done client side and only the selected portions are sent to the attestor. The attestor will only be able to see the selected portions alongside the first line of the HTTP response (that is, \"HTTP/1.1 200 OK\")",
3000
3008
  "properties": {
3001
3009
  "xPath": {
3002
3010
  "type": "string",
@@ -3004,7 +3012,7 @@ export const MCP_TOOLS = {
3004
3012
  },
3005
3013
  "jsonPath": {
3006
3014
  "type": "string",
3007
- "description": "expect a JSON response, retrieve the item at this path using dot notation for e.g. 'email.addresses.0'"
3015
+ "description": "expect a JSON response, retrieve the item at this path using dot notation, for example 'email.addresses.0'."
3008
3016
  },
3009
3017
  "regex": {
3010
3018
  "type": "string",
@@ -3146,7 +3154,7 @@ export const MCP_TOOLS = {
3146
3154
  "items": {
3147
3155
  "type": "object",
3148
3156
  "additionalProperties": false,
3149
- "description": "Which portions to select from a response. These are selected in order, xpath => jsonPath => regex * These redactions are done client side and only the selected portions are sent to the attestor. The attestor will only be able to see the selected portions alongside the first line of the HTTP response (i.e. \"HTTP/1.1 200 OK\")",
3157
+ "description": "Which portions to select from a response. These are selected in order, xpath => jsonPath => regex * These redactions are done client side and only the selected portions are sent to the attestor. The attestor will only be able to see the selected portions alongside the first line of the HTTP response (that is, \"HTTP/1.1 200 OK\")",
3150
3158
  "properties": {
3151
3159
  "xPath": {
3152
3160
  "type": "string",
@@ -3154,7 +3162,7 @@ export const MCP_TOOLS = {
3154
3162
  },
3155
3163
  "jsonPath": {
3156
3164
  "type": "string",
3157
- "description": "expect a JSON response, retrieve the item at this path using dot notation for e.g. 'email.addresses.0'"
3165
+ "description": "expect a JSON response, retrieve the item at this path using dot notation, for example 'email.addresses.0'."
3158
3166
  },
3159
3167
  "regex": {
3160
3168
  "type": "string",
@@ -3211,8 +3219,8 @@ export const MCP_TOOLS = {
3211
3219
  "properties": {
3212
3220
  "geoLocation": {
3213
3221
  "type": "string",
3214
- "description": "Geographic location (e.g. ISO country code or {{DYNAMIC_GEO}} to use user's geo location) the verification should appear to originate from.",
3215
- "maxLength": 15,
3222
+ "description": "Geographic location the verification should appear to originate from: a 2-letter ISO country code, or a parameter the attestor resolves at proof time. `{{DYNAMIC_GEO}}` and `{{DYNAMIC_GEO_SECRET}}` are the Verification Client's standard names for the end-user's own country — the `_SECRET` one is delivered as a secret param, so the attestor never learns which country the proof egressed from.",
3223
+ "maxLength": 64,
3216
3224
  "default": "{{DYNAMIC_GEO}}"
3217
3225
  },
3218
3226
  "clientOptions": {
@@ -5,7 +5,7 @@ import type { JSONSchema } from 'zod/v4/core';
5
5
  *
6
6
  * The generator (`packages/app/scripts/mcp-tools-gen.ts`) inlines `$ref`s it
7
7
  * walks through `properties`/`items`, but it does NOT recurse into `allOf` /
8
- * `anyOf` / `oneOf`. So a schema composed with `allOf` (e.g.
8
+ * `anyOf` / `oneOf`. So a schema composed with `allOf` (for example,
9
9
  * `RequestSelectionTemplate =
10
10
  * allOf[ RequestSelection, { multiple, required } ]`,
11
11
  * surfaced by the proof tools' `allowedJsRequests`) can carry a dangling
@@ -4,7 +4,7 @@ import { z } from 'zod';
4
4
  *
5
5
  * The generator (`packages/app/scripts/mcp-tools-gen.ts`) inlines `$ref`s it
6
6
  * walks through `properties`/`items`, but it does NOT recurse into `allOf` /
7
- * `anyOf` / `oneOf`. So a schema composed with `allOf` (e.g.
7
+ * `anyOf` / `oneOf`. So a schema composed with `allOf` (for example,
8
8
  * `RequestSelectionTemplate =
9
9
  * allOf[ RequestSelection, { multiple, required } ]`,
10
10
  * surfaced by the proof tools' `allowedJsRequests`) can carry a dangling
@@ -2,7 +2,7 @@ import { remapErrorAsResponse } from "../remap_errors.js";
2
2
  import { MCP_TOOLS } from "./operations.gen.js";
3
3
  /**
4
4
  * The generated `MCP_TOOLS` are keyed by OpenAPI `operationId` (PascalCase,
5
- * e.g. `GetMe`). MCP tools are conventionally snake_case, matching the
5
+ * For example, `GetMe`). MCP tools are conventionally snake_case, matching the
6
6
  * hand-written tools in this server. Convert the public tool name here while
7
7
  * still dispatching to the API with the original operationId — doing this in
8
8
  * the (non-generated) registration keeps it from being reverted on regen.