@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.
- package/README.md +55 -20
- package/lib/authoring/backend.d.ts +13 -10
- package/lib/authoring/tools.js +106 -9
- package/lib/cdp/browser-proxy.d.ts +78 -0
- package/lib/cdp/browser-proxy.js +186 -0
- package/lib/cdp/capture-engine.js +8 -7
- package/lib/cdp/client.d.ts +10 -0
- package/lib/cdp/geo.d.ts +10 -0
- package/lib/cdp/geo.js +36 -0
- package/lib/cdp/index.d.ts +1 -0
- package/lib/cdp/index.js +1 -0
- package/lib/live/cloudflared.d.ts +15 -0
- package/lib/live/cloudflared.js +268 -0
- package/lib/live/page.d.ts +20 -0
- package/lib/live/page.js +134 -0
- package/lib/live/tunnel.d.ts +23 -0
- package/lib/live/tunnel.js +120 -0
- package/lib/live/viewer.d.ts +28 -0
- package/lib/live/viewer.js +232 -0
- package/lib/mcp/api/operations.gen.js +34 -26
- package/lib/mcp/api/to-zod.d.ts +1 -1
- package/lib/mcp/api/to-zod.js +1 -1
- package/lib/mcp/api/tools.js +1 -1
- package/lib/mcp/instructions.d.ts +15 -2
- package/lib/mcp/instructions.js +101 -38
- package/lib/mcp/start.js +4 -3
- package/lib/mcp/tools/agent/analyze.js +5 -1
- package/lib/mcp/tools/agent/attach.d.ts +8 -1
- package/lib/mcp/tools/agent/attach.js +166 -22
- package/lib/mcp/tools/agent/build.d.ts +13 -8
- package/lib/mcp/tools/agent/build.js +22 -11
- package/lib/mcp/tools/agent/capture.js +5 -1
- package/lib/mcp/tools/agent/eval.js +3 -1
- package/lib/mcp/tools/agent/find.js +6 -5
- package/lib/mcp/tools/agent/how-it-works.d.ts +15 -7
- package/lib/mcp/tools/agent/how-it-works.js +57 -17
- package/lib/mcp/tools/agent/live-view.d.ts +21 -0
- package/lib/mcp/tools/agent/live-view.js +153 -0
- package/lib/mcp/tools/agent/pod-proof.d.ts +8 -0
- package/lib/mcp/tools/agent/pod-proof.js +64 -0
- package/lib/mcp/tools/agent/propose.js +29 -3
- package/lib/mcp/tools/agent/proxy.d.ts +3 -0
- package/lib/mcp/tools/agent/proxy.js +199 -0
- package/lib/mcp/tools/agent/publish.js +49 -77
- package/lib/mcp/tools/agent/session.d.ts +2 -1
- package/lib/mcp/tools/agent/session.js +26 -7
- package/lib/mcp/tools/agent/shared.js +17 -8
- package/lib/mcp/tools/authenticate/authenticate.d.ts +11 -0
- package/lib/mcp/tools/authenticate/authenticate.js +143 -121
- package/lib/mcp/tools/authenticate/builder-access.d.ts +8 -3
- package/lib/mcp/tools/authenticate/builder-access.js +8 -3
- package/lib/mcp/tools/mode/mode.d.ts +1 -1
- package/lib/mcp/tools/mode/mode.js +26 -7
- package/lib/old/client.d.ts +9 -0
- package/lib/old/client.js +19 -1
- package/lib/old/instructions.d.ts +9 -1
- package/lib/old/instructions.js +4 -6
- package/lib/old/login-cdp.d.ts +2 -2
- package/lib/old/login-cdp.js +46 -6
- package/lib/old/to-register.d.ts +20 -8
- package/lib/old/to-register.js +7 -1
- package/lib/old/tools/authenticate.js +9 -1
- package/lib/old/tools/get-provider-info.js +6 -5
- package/lib/old/tools/issue-app-credentials.js +3 -2
- package/lib/old/tools/me-providers.js +3 -1
- package/lib/old/tools/publish.d.ts +1 -1
- package/lib/old/tools/publish.js +132 -129
- package/lib/old/tools/update-provider-metadata.d.ts +1 -1
- package/lib/old/tools/update-provider-metadata.js +1 -1
- package/lib/old/tools/verify-sdk-setup.js +1 -1
- package/lib/proof/attestor.d.ts +3 -3
- package/lib/proof/debug-response-dump.js +4 -4
- package/lib/proof/index.d.ts +1 -0
- package/lib/proof/index.js +1 -0
- package/lib/proof/page-replay.d.ts +36 -0
- package/lib/proof/page-replay.js +76 -0
- package/lib/proof/pod-prover.d.ts +47 -0
- package/lib/proof/pod-prover.js +155 -0
- package/lib/proof/replay.d.ts +28 -0
- package/lib/proof/replay.js +39 -18
- package/lib/provider/dom-xpath.js +11 -9
- package/lib/provider/draft.d.ts +13 -8
- package/lib/provider/draft.js +47 -13
- package/lib/provider/injection-doc.d.ts +23 -1
- package/lib/provider/injection-doc.js +34 -21
- package/lib/provider/match-redaction-warning.d.ts +2 -2
- package/lib/provider/match-redaction-warning.js +3 -3
- package/lib/provider/matcher.js +122 -12
- package/lib/provider/secrets.d.ts +3 -3
- package/lib/provider/secrets.js +3 -3
- package/lib/provider/to-version.d.ts +12 -9
- package/lib/provider/to-version.js +16 -4
- package/lib/tools/registry.d.ts +5 -5
- package/lib/tools/registry.js +5 -5
- package/package.json +4 -3
- package/samples/demo-server/README.md +7 -6
- package/skill/SKILL.builder.md +356 -189
- package/skill/SKILL.common.md +314 -79
- package/skill/SKILL.old.md +340 -155
- package/skill/builder-mode.md +58 -17
- package/skill/hash-validation.md +170 -0
- package/skill/interception.md +235 -0
- package/skill/js-sdk-integration.md +13 -7
- package/skill/old-mode.md +53 -12
- package/skill/user-script.md +61 -0
- package/src/authoring/backend.ts +13 -10
- package/src/authoring/tools.ts +128 -9
- package/src/cdp/capture-engine.ts +8 -7
- package/src/cdp/client.ts +8 -0
- package/src/cdp/geo.ts +52 -0
- package/src/cdp/index.ts +1 -0
- package/src/consts.ts +1 -0
- package/src/live/cloudflared.ts +348 -0
- package/src/live/page.ts +145 -0
- package/src/live/tunnel.ts +157 -0
- package/src/live/viewer.ts +293 -0
- package/src/mcp/api/operations.gen.ts +34 -26
- package/src/mcp/api/to-zod.ts +1 -1
- package/src/mcp/api/tools.ts +1 -1
- package/src/mcp/instructions.ts +121 -48
- package/src/mcp/start.ts +4 -3
- package/src/mcp/tools/agent/analyze.ts +5 -1
- package/src/mcp/tools/agent/attach.ts +194 -22
- package/src/mcp/tools/agent/build.ts +26 -15
- package/src/mcp/tools/agent/capture.ts +5 -1
- package/src/mcp/tools/agent/eval.ts +4 -1
- package/src/mcp/tools/agent/find.ts +6 -5
- package/src/mcp/tools/agent/how-it-works.ts +62 -21
- package/src/mcp/tools/agent/live-view.ts +198 -0
- package/src/mcp/tools/agent/pod-proof.ts +90 -0
- package/src/mcp/tools/agent/propose.ts +31 -3
- package/src/mcp/tools/agent/publish.ts +54 -78
- package/src/mcp/tools/agent/session.ts +26 -5
- package/src/mcp/tools/agent/shared.ts +19 -8
- package/src/mcp/tools/authenticate/authenticate.ts +167 -165
- package/src/mcp/tools/authenticate/builder-access.ts +8 -3
- package/src/mcp/tools/mode/mode.ts +28 -7
- package/src/old/client.ts +30 -1
- package/src/old/instructions.ts +4 -10
- package/src/old/login-cdp.ts +50 -6
- package/src/old/to-register.ts +28 -8
- package/src/old/tools/authenticate.ts +9 -1
- package/src/old/tools/get-provider-info.ts +6 -5
- package/src/old/tools/issue-app-credentials.ts +3 -2
- package/src/old/tools/me-providers.ts +3 -1
- package/src/old/tools/publish.ts +140 -130
- package/src/old/tools/update-provider-metadata.ts +1 -1
- package/src/old/tools/verify-sdk-setup.ts +1 -1
- package/src/proof/attestor.ts +3 -3
- package/src/proof/debug-response-dump.ts +4 -4
- package/src/proof/index.ts +8 -0
- package/src/proof/page-replay.ts +131 -0
- package/src/proof/pod-prover.ts +231 -0
- package/src/proof/replay.ts +60 -19
- package/src/provider/dom-xpath.ts +11 -9
- package/src/provider/draft.ts +56 -13
- package/src/provider/injection-doc.ts +37 -24
- package/src/provider/match-redaction-warning.ts +3 -3
- package/src/provider/matcher.ts +151 -10
- package/src/provider/secrets.ts +3 -3
- package/src/provider/to-version.ts +30 -13
- package/src/tools/registry.ts +5 -5
- package/skill/injection-api.md +0 -335
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ALLOWED_REQUESTS_HINT, USER_SCRIPT_HINT, } from "../../../provider/injection-doc.js";
|
|
2
2
|
import { countsFor, matchRedactionWarnings, } from "../../../provider/match-redaction-warning.js";
|
|
3
3
|
import { nextVersion, providerToCreateVersionRequest, } from "../../../provider/to-version.js";
|
|
4
4
|
import { defineTool } from "../../server.js";
|
|
@@ -62,7 +62,8 @@ const REQUEST_DRAFT_PROPERTIES = {
|
|
|
62
62
|
const PROVIDER_SCHEMA = {
|
|
63
63
|
type: 'object',
|
|
64
64
|
description: 'A `provider` object from propose_provider, passed through verbatim — ' +
|
|
65
|
-
'the tool builds the version body (the requests[] entry
|
|
65
|
+
'the tool builds the version body (the requests[] entry and so on) ' +
|
|
66
|
+
'for you.',
|
|
66
67
|
properties: {
|
|
67
68
|
name: { type: 'string', description: 'Verification name.' },
|
|
68
69
|
...REQUEST_DRAFT_PROPERTIES,
|
|
@@ -73,7 +74,7 @@ const PROVIDER_SCHEMA = {
|
|
|
73
74
|
},
|
|
74
75
|
paramValues: {
|
|
75
76
|
type: 'object',
|
|
76
|
-
description: 'Real values for the {{param}} placeholders,
|
|
77
|
+
description: 'Real values for the {{param}} placeholders, for example, ' +
|
|
77
78
|
'{ "username": "Syed" }.',
|
|
78
79
|
},
|
|
79
80
|
},
|
|
@@ -87,8 +88,8 @@ const ALLOWED_JS_REQUEST_SCHEMA = {
|
|
|
87
88
|
...REQUEST_DRAFT_PROPERTIES,
|
|
88
89
|
multiple: {
|
|
89
90
|
type: 'boolean',
|
|
90
|
-
description: 'Allow the template to match many requests (
|
|
91
|
-
'Default true.',
|
|
91
|
+
description: 'Allow the template to match many requests (for example, ' +
|
|
92
|
+
'pagination). Default true.',
|
|
92
93
|
},
|
|
93
94
|
required: {
|
|
94
95
|
type: 'boolean',
|
|
@@ -100,36 +101,21 @@ const ALLOWED_JS_REQUEST_SCHEMA = {
|
|
|
100
101
|
export function createVersionFromCaptureTool(client, attachRef) {
|
|
101
102
|
return defineTool({
|
|
102
103
|
name: 'create_provider_version_from_capture',
|
|
103
|
-
description: 'Persist drafted ReclaimProvider(s) as a provider version
|
|
104
|
-
'
|
|
105
|
-
'
|
|
106
|
-
'
|
|
107
|
-
'
|
|
108
|
-
'
|
|
109
|
-
'
|
|
110
|
-
'
|
|
111
|
-
'
|
|
112
|
-
'
|
|
113
|
-
'page-injection script that drives the page to where the request ' +
|
|
114
|
-
'fires) and/or `allowedJsRequests` (extra requests the script may ' +
|
|
115
|
-
'fire, e.g. pagination). ' +
|
|
116
|
-
'Omit `version` to have the tool auto-select the next available ' +
|
|
117
|
-
'version (it lists existing versions and bumps past the highest). ' +
|
|
118
|
-
'The version lands on the draft branch — to go live, call ' +
|
|
119
|
-
'`publish_provider_version` (PRIVATE) or ' +
|
|
120
|
-
'`submit_provider_version_for_review` (PUBLIC) afterwards. ' +
|
|
104
|
+
description: 'Persist drafted ReclaimProvider(s) as a provider version, after ' +
|
|
105
|
+
'run_proof succeeds. Pass the `provider` object(s) from ' +
|
|
106
|
+
'propose_provider VERBATIM — this tool builds the version body ' +
|
|
107
|
+
'(requests[], webSettings, …) for you; do NOT hand-construct that ' +
|
|
108
|
+
'shape or call create_provider_version directly. Exactly one of ' +
|
|
109
|
+
'`provider` (one request) or `providers` (a multi-request provider — ' +
|
|
110
|
+
'every entry is required at verification time). Omit `version` to ' +
|
|
111
|
+
'auto-bump past the highest existing one. The version lands on the ' +
|
|
112
|
+
'draft branch: call `publish_provider_version` (PRIVATE) or ' +
|
|
113
|
+
'`submit_provider_version_for_review` (PUBLIC) to go live. ' +
|
|
121
114
|
'`requiredContext` is derived from any {{context.<name>}} ' +
|
|
122
|
-
'placeholders
|
|
123
|
-
'
|
|
124
|
-
'
|
|
125
|
-
'
|
|
126
|
-
'field is a 400 at session create). ' +
|
|
127
|
-
'Refine types/descriptions via `update_provider_version` while ' +
|
|
128
|
-
'still on draft. ' +
|
|
129
|
-
'On success, if a browser is still attached, the response\'s ' +
|
|
130
|
-
'`_notes` reminds you to confirm with the developer before ' +
|
|
131
|
-
'calling `dispose_browser` — never close it unprompted, they ' +
|
|
132
|
-
'may want it for further edits.',
|
|
115
|
+
'placeholders and returned on the created version — relay it to the ' +
|
|
116
|
+
'dev verbatim, since a session missing those fields is a 400. Always ' +
|
|
117
|
+
'read the response\'s `_notes`. ' +
|
|
118
|
+
'Full walkthrough: how_it_works({ topic: "publish" }).',
|
|
133
119
|
inputSchema: {
|
|
134
120
|
type: 'object',
|
|
135
121
|
properties: {
|
|
@@ -149,12 +135,14 @@ export function createVersionFromCaptureTool(client, attachRef) {
|
|
|
149
135
|
initialUrl: {
|
|
150
136
|
type: 'string',
|
|
151
137
|
description: 'The website URL the user landed on to trigger the request ' +
|
|
152
|
-
'(
|
|
153
|
-
'flow opens for end-users — NOT the API URL
|
|
138
|
+
'(for example, https://github.com/Syed). The URL the ' +
|
|
139
|
+
'verification flow opens for end-users — NOT the API URL ' +
|
|
140
|
+
'inside the provider.',
|
|
154
141
|
},
|
|
155
142
|
notes: {
|
|
156
143
|
type: 'string',
|
|
157
|
-
description: 'Short change note (
|
|
144
|
+
description: 'Short change note (for example, "Initial draft from ' +
|
|
145
|
+
'browser capture").',
|
|
158
146
|
},
|
|
159
147
|
version: {
|
|
160
148
|
type: 'object',
|
|
@@ -169,64 +157,48 @@ export function createVersionFromCaptureTool(client, attachRef) {
|
|
|
169
157
|
},
|
|
170
158
|
jsUserScripts: {
|
|
171
159
|
type: 'string',
|
|
172
|
-
description:
|
|
173
|
-
'
|
|
174
|
-
'
|
|
175
|
-
'
|
|
176
|
-
'
|
|
177
|
-
'
|
|
178
|
-
'verification client installs this to run before every page ' +
|
|
179
|
-
'load (before navigating to initialUrl), matching old-devtool ' +
|
|
180
|
-
'customInjection; window.Reclaim itself is not yet exposed ' +
|
|
181
|
-
'there, so prefer plain browser JS. Guide:\n\n' +
|
|
182
|
-
INJECTION_GUIDE,
|
|
160
|
+
description: USER_SCRIPT_HINT +
|
|
161
|
+
' Stored as webSettings.jsUserScripts; the Builder ' +
|
|
162
|
+
'verification client runs it before every page load ' +
|
|
163
|
+
'(including before navigating to initialUrl), matching ' +
|
|
164
|
+
'old-devtools customInjection. window.Reclaim is not exposed ' +
|
|
165
|
+
'there yet, so prefer plain browser JS.',
|
|
183
166
|
},
|
|
184
167
|
allowedJsRequests: {
|
|
185
168
|
type: 'array',
|
|
186
|
-
description: 'Extra requests the
|
|
187
|
-
'
|
|
188
|
-
'
|
|
189
|
-
'
|
|
190
|
-
'
|
|
191
|
-
|
|
192
|
-
'different field name): this whole entry (url, method, body, ' +
|
|
193
|
-
'responseMatches, responseRedactions) feeds a client-side ' +
|
|
194
|
-
'hash-equality check, and `url` is hashed VERBATIM — no regex/ ' +
|
|
195
|
-
'template resolution, even with `urlType: REGEX` or ' +
|
|
196
|
-
'`TEMPLATE`. If the real captured URL contains ANY per-session ' +
|
|
197
|
-
'part (a tracking nonce, CSRF token, cache-busting timestamp), ' +
|
|
198
|
-
'no declared spec can EVER hash-match a real proof — populating' +
|
|
199
|
-
' this for such a provider makes verifyProof reject every real ' +
|
|
200
|
-
'proof, which is worse than leaving it empty. Diff the same ' +
|
|
201
|
-
'endpoint\'s captured URL across two separate sessions before ' +
|
|
202
|
-
'wiring this up. If provider-hash validation keeps causing ' +
|
|
203
|
-
'problems (unstable url, or any other persistent mismatch), ' +
|
|
204
|
-
'the fallback on the verifying side is `verifyProof(proof, { ' +
|
|
205
|
-
'dangerouslyDisableContentValidation: true })` — trusts only ' +
|
|
206
|
-
'the attestor\'s signature, skips the hash-equality check ' +
|
|
207
|
-
'entirely; see the "Provider-hash validation" section of the ' +
|
|
208
|
-
'injection script\'s guide for the full mechanics and when to ' +
|
|
209
|
-
'reach for it.',
|
|
169
|
+
description: 'Extra requests the user script is allowed to fire (for ' +
|
|
170
|
+
'example, paginated API calls), as ' +
|
|
171
|
+
'RequestSelectionTemplates. ' +
|
|
172
|
+
'`multiple`/`required` default to true. Old-devtools calls the ' +
|
|
173
|
+
'same concept `allowedInjectedRequestData`. ' +
|
|
174
|
+
ALLOWED_REQUESTS_HINT,
|
|
210
175
|
items: ALLOWED_JS_REQUEST_SCHEMA,
|
|
211
176
|
},
|
|
212
177
|
interceptorOptions: {
|
|
213
178
|
type: 'object',
|
|
214
179
|
description: 'In-app interception settings, stored as ' +
|
|
215
|
-
'webSettings.clientOptions.inapp.interceptorOptions
|
|
216
|
-
'
|
|
217
|
-
'
|
|
218
|
-
'main document request via the attestor (default false).',
|
|
180
|
+
'webSettings.clientOptions.inapp.interceptorOptions — only ' +
|
|
181
|
+
'needed for a genuine live-interception provider (a real ' +
|
|
182
|
+
'HAWKEYE/MSWJS script, not the standard capture→replay flow).',
|
|
219
183
|
properties: {
|
|
220
184
|
interceptorType: {
|
|
221
185
|
type: 'string',
|
|
222
186
|
enum: ['HAWKEYE', 'MSWJS', 'CDP'],
|
|
223
187
|
description: 'How traffic interception is implemented.',
|
|
224
188
|
},
|
|
225
|
-
isDocumentRequestReplayEnabled: { type: 'boolean' },
|
|
226
189
|
interceptorSettings: {
|
|
227
190
|
type: 'string',
|
|
228
191
|
description: 'Free-form JSON config for the chosen interceptor.',
|
|
229
192
|
},
|
|
193
|
+
isDocumentRequestReplayEnabled: {
|
|
194
|
+
type: 'boolean',
|
|
195
|
+
description: 'Whether the page\'s own document/navigation request is ' +
|
|
196
|
+
'genuinely replayed through the interceptor, rather than ' +
|
|
197
|
+
'constructed locally. Defaults to `false` (disabled) when ' +
|
|
198
|
+
'omitted. Only meaningful for HAWKEYE/MSWJS — pass `true` ' +
|
|
199
|
+
'when the target value is embedded in the page\'s own HTML ' +
|
|
200
|
+
'rather than a separate API call. Inert for CDP.',
|
|
201
|
+
},
|
|
230
202
|
},
|
|
231
203
|
required: ['interceptorType'],
|
|
232
204
|
},
|
|
@@ -2,7 +2,8 @@ import type { ConfigStore } from '../../../config/store.ts';
|
|
|
2
2
|
import { type RegisteredTool } from '../../server.ts';
|
|
3
3
|
import { type AttachState } from './attach.ts';
|
|
4
4
|
import { type CaptureStore } from './capture.ts';
|
|
5
|
+
import { type LiveShareRef } from './live-view.ts';
|
|
5
6
|
export declare function sessionTools(attachRef: {
|
|
6
7
|
current?: AttachState;
|
|
7
8
|
config: ConfigStore;
|
|
8
|
-
}, captures: CaptureStore): RegisteredTool[];
|
|
9
|
+
}, captures: CaptureStore, liveShare: LiveShareRef): RegisteredTool[];
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { defineTool } from "../../server.js";
|
|
2
2
|
import { disposeAttached } from "./attach.js";
|
|
3
3
|
import { resetCaptures } from "./capture.js";
|
|
4
|
-
|
|
4
|
+
import { stopLiveShare } from "./live-view.js";
|
|
5
|
+
export function sessionTools(attachRef, captures, liveShare) {
|
|
5
6
|
return [
|
|
6
7
|
defineTool({
|
|
7
8
|
name: 'get_session',
|
|
8
|
-
description: '
|
|
9
|
+
description: 'Report the current attach state, the live captureIds, and the '
|
|
10
|
+
+ 'persisted browser config. Call it to check whether a browser is '
|
|
11
|
+
+ 'still attached before reattaching, or to recover a captureId.',
|
|
9
12
|
inputSchema: { type: 'object', properties: {} },
|
|
10
13
|
}, async () => ({
|
|
11
14
|
config: attachRef.config.read()?.browser_agent,
|
|
@@ -17,29 +20,45 @@ export function sessionTools(attachRef, captures) {
|
|
|
17
20
|
orgId: attachRef.current?.orgId,
|
|
18
21
|
captures: [...captures.sessions.keys()],
|
|
19
22
|
activeTab: captures.activeTab,
|
|
23
|
+
// The public share, when one is open — so a caller that lost the
|
|
24
|
+
// URL can recover it instead of opening a second tunnel.
|
|
25
|
+
...(liveShare.current
|
|
26
|
+
? {
|
|
27
|
+
sharedView: {
|
|
28
|
+
url: liveShare.current.url,
|
|
29
|
+
interactive: liveShare.current.interactive,
|
|
30
|
+
viewers: liveShare.current.view.viewers(),
|
|
31
|
+
},
|
|
32
|
+
}
|
|
33
|
+
: {}),
|
|
20
34
|
})),
|
|
21
35
|
defineTool({
|
|
22
36
|
name: 'dispose_browser',
|
|
23
37
|
description: 'Stop captures, disconnect the current browser, and immediately '
|
|
24
38
|
+ 'delete a Builder-hosted Popcorn session. Custom CDP sessions '
|
|
25
|
-
+ 'are disconnected but never deleted by Reclaim.'
|
|
39
|
+
+ 'are disconnected but never deleted by Reclaim. Also closes a '
|
|
40
|
+
+ 'public live view opened by share_browser_view.',
|
|
26
41
|
inputSchema: { type: 'object', properties: {} },
|
|
27
42
|
}, async () => {
|
|
28
|
-
await resetAll(attachRef, captures);
|
|
43
|
+
await resetAll(attachRef, captures, liveShare);
|
|
29
44
|
return { disposed: true };
|
|
30
45
|
}),
|
|
31
46
|
defineTool({
|
|
32
47
|
name: 'reset_session',
|
|
33
48
|
description: 'Stop all captures and clear capture state — drops every '
|
|
34
|
-
+ 'session\'s drafts and their in-memory secrets
|
|
49
|
+
+ 'session\'s drafts and their in-memory secrets, and closes a '
|
|
50
|
+
+ 'public live view opened by share_browser_view.',
|
|
35
51
|
inputSchema: { type: 'object', properties: {} },
|
|
36
52
|
}, async () => {
|
|
37
|
-
await resetAll(attachRef, captures);
|
|
53
|
+
await resetAll(attachRef, captures, liveShare);
|
|
38
54
|
return { reset: true };
|
|
39
55
|
}),
|
|
40
56
|
];
|
|
41
57
|
}
|
|
42
|
-
async function resetAll(attachRef, captures) {
|
|
58
|
+
async function resetAll(attachRef, captures, liveShare) {
|
|
59
|
+
// Before the captures: the live view holds a tab session of its own, and a
|
|
60
|
+
// public URL must never outlive the browser it points at.
|
|
61
|
+
await stopLiveShare(liveShare);
|
|
43
62
|
await resetCaptures(captures);
|
|
44
63
|
await disposeAttached(attachRef);
|
|
45
64
|
}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import { authoringTools, extendTool, } from "../../../authoring/index.js";
|
|
11
11
|
import { runAttestorProof } from "../../../proof/attestor.js";
|
|
12
|
-
import {
|
|
12
|
+
import { replayProviderInPage } from "../../../proof/page-replay.js";
|
|
13
13
|
import { shapeRichProofResult } from "./proof.js";
|
|
14
14
|
/**
|
|
15
15
|
* OPRF mode this LOCAL (non-TEE) attestor can actually run. Recipes carry
|
|
@@ -39,13 +39,17 @@ function withLocalOprfMode(provider) {
|
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
41
|
/** The local backend for one capture: drive its tab over CDP, read its
|
|
42
|
-
* captured requests, prove via the in-process attestor, replay by re-
|
|
42
|
+
* captured requests, prove via the in-process attestor, replay by re-fetching
|
|
43
|
+
* FROM INSIDE the tab (real cookies/session — see proof/page-replay.ts). */
|
|
43
44
|
function localBackend(entry) {
|
|
44
45
|
const { tabClient, session, drafts } = entry;
|
|
46
|
+
const sendCdp = (method, params) => {
|
|
47
|
+
return tabClient.send(method, params ?? {});
|
|
48
|
+
};
|
|
45
49
|
return {
|
|
46
50
|
capture: session,
|
|
47
51
|
drafts,
|
|
48
|
-
sendCdp
|
|
52
|
+
sendCdp,
|
|
49
53
|
waitForEvent: (method, timeoutMs) => new Promise((resolve) => {
|
|
50
54
|
let stopListening = () => { };
|
|
51
55
|
const onEvent = () => {
|
|
@@ -63,10 +67,9 @@ function localBackend(entry) {
|
|
|
63
67
|
stopListening = tabClient.subscribeOnce(method, onEvent);
|
|
64
68
|
}),
|
|
65
69
|
replay: async (draft, opts) => {
|
|
66
|
-
//
|
|
67
|
-
//
|
|
68
|
-
const
|
|
69
|
-
const result = await replayProvider(draft.provider, secrets);
|
|
70
|
+
// Replayed FROM INSIDE the attached tab (real cookies/session), not
|
|
71
|
+
// a detached Node fetch — see proof/page-replay.ts.
|
|
72
|
+
const result = await replayProviderInPage({ sendCdp }, draft.provider, draft.secrets, opts);
|
|
70
73
|
return {
|
|
71
74
|
status: result.status,
|
|
72
75
|
matchesOriginal: result.matchesOriginal,
|
|
@@ -105,7 +108,13 @@ const RUN_PROOF_EXTRAS = {
|
|
|
105
108
|
+ 'specific alternative — do NOT invent backup URLs. `ownerAddress` '
|
|
106
109
|
+ '(the credential to sign with) is REQUIRED — call resolve_owner_key '
|
|
107
110
|
+ 'first. errorKind="missing-owner-key" means that address has no known '
|
|
108
|
-
+ 'private key; re-run resolve_owner_key or issue/import a credential.'
|
|
111
|
+
+ 'private key; re-run resolve_owner_key or issue/import a credential. '
|
|
112
|
+
+ 'NOTE: unlike replay_request (which re-issues from inside the live '
|
|
113
|
+
+ 'attached browser tab), the ATTESTOR calls the target from its OWN '
|
|
114
|
+
+ 'network/IP, separate from the browser\'s. A request that replayed '
|
|
115
|
+
+ 'fine can still fail here for geo/IP-bound content (country-locked '
|
|
116
|
+
+ "pages, IP-allowlisted APIs) — if that happens, it's a property of "
|
|
117
|
+
+ 'the site, not a bug in the draft.',
|
|
109
118
|
properties: {
|
|
110
119
|
ownerAddress: {
|
|
111
120
|
type: 'string',
|
|
@@ -1,3 +1,14 @@
|
|
|
1
1
|
import type { ReclaimClient } from '@reclaimprotocol/client';
|
|
2
2
|
import { type RegisteredTool } from '../../server.ts';
|
|
3
3
|
export declare function authenticateTool(client: ReclaimClient, name?: 'reclaim_authenticate' | 'authenticate_builder'): RegisteredTool;
|
|
4
|
+
/**
|
|
5
|
+
* Standard OAuth 2.0 Authorization Code + PKCE, native-app style (RFC 8252):
|
|
6
|
+
* dynamically register a public client (RFC 7591 — Better Auth's
|
|
7
|
+
* `oauth-provider` plugin issues no secret for it), send the user to the
|
|
8
|
+
* browser, and catch the redirect on a loopback server. `openid-client`
|
|
9
|
+
* handles PKCE, `state` CSRF protection, and authorization-response
|
|
10
|
+
* validation (including a denied/failed login surfacing as
|
|
11
|
+
* `AuthorizationResponseError`) — this function only wires those calls
|
|
12
|
+
* together and owns the loopback server (no library spins that up for you).
|
|
13
|
+
*/
|
|
14
|
+
export declare function runOAuthLoopback(client: ReclaimClient, openBrowserFn?: (url: string) => void): Promise<unknown>;
|