@reclaimprotocol/agent 0.1.23 → 0.1.25
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 +56 -20
- package/lib/authoring/backend.d.ts +5 -4
- package/lib/authoring/tools.js +30 -30
- package/lib/cdp/capture-engine.js +8 -7
- package/lib/cdp/claims.d.ts +21 -0
- package/lib/cdp/claims.js +129 -0
- package/lib/cdp/container.d.ts +85 -0
- package/lib/cdp/container.js +481 -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/tunnel.d.ts +26 -0
- package/lib/live/tunnel.js +160 -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 +102 -38
- package/lib/mcp/start.js +62 -6
- package/lib/mcp/tools/agent/analyze.js +5 -1
- package/lib/mcp/tools/agent/attach.d.ts +29 -2
- package/lib/mcp/tools/agent/attach.js +310 -24
- package/lib/mcp/tools/agent/build.d.ts +18 -8
- package/lib/mcp/tools/agent/build.js +30 -12
- 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/index.d.ts +1 -2
- package/lib/mcp/tools/agent/index.js +1 -1
- package/lib/mcp/tools/agent/live-view.d.ts +17 -0
- package/lib/mcp/tools/agent/live-view.js +146 -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 +4 -2
- package/lib/mcp/tools/agent/publish.js +47 -77
- package/lib/mcp/tools/agent/session.d.ts +16 -1
- package/lib/mcp/tools/agent/session.js +32 -7
- package/lib/mcp/tools/authenticate/authenticate.js +26 -13
- package/lib/mcp/tools/mode/mode.d.ts +1 -1
- package/lib/mcp/tools/mode/mode.js +10 -22
- package/lib/old/client.d.ts +1 -1
- package/lib/old/client.js +1 -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 +3 -2
- package/lib/old/to-register.js +1 -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/publish.d.ts +1 -1
- package/lib/old/tools/publish.js +90 -131
- 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 +1 -1
- package/lib/proof/page-replay.js +1 -1
- package/lib/proof/pod-prover.d.ts +47 -0
- package/lib/proof/pod-prover.js +155 -0
- package/lib/provider/dom-xpath.js +11 -9
- package/lib/provider/draft.d.ts +10 -7
- package/lib/provider/draft.js +11 -9
- 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 +13 -12
- package/lib/provider/secrets.d.ts +3 -3
- package/lib/provider/secrets.js +3 -3
- package/lib/provider/to-version.d.ts +7 -6
- package/lib/provider/to-version.js +3 -3
- package/lib/tools/registry.d.ts +5 -5
- package/lib/tools/registry.js +5 -5
- package/package.json +3 -3
- package/samples/demo-server/README.md +7 -6
- package/skill/SKILL.builder.md +356 -189
- package/skill/SKILL.common.md +400 -97
- package/skill/SKILL.old.md +340 -155
- package/skill/builder-mode.md +60 -17
- package/skill/hash-validation.md +170 -0
- package/skill/interception.md +236 -0
- package/skill/js-sdk-integration.md +13 -7
- package/skill/old-mode.md +62 -21
- package/skill/user-script.md +61 -0
- package/src/authoring/backend.ts +5 -4
- package/src/authoring/tools.ts +31 -30
- package/src/cdp/capture-engine.ts +8 -7
- package/src/cdp/claims.ts +153 -0
- package/src/cdp/container.ts +593 -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/tunnel.ts +208 -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 +122 -48
- package/src/mcp/start.ts +69 -5
- package/src/mcp/tools/agent/analyze.ts +5 -1
- package/src/mcp/tools/agent/attach.ts +367 -26
- package/src/mcp/tools/agent/build.ts +35 -16
- 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/index.ts +6 -2
- package/src/mcp/tools/agent/live-view.ts +182 -0
- package/src/mcp/tools/agent/pod-proof.ts +90 -0
- package/src/mcp/tools/agent/propose.ts +4 -2
- package/src/mcp/tools/agent/publish.ts +52 -77
- package/src/mcp/tools/agent/session.ts +33 -6
- package/src/mcp/tools/authenticate/authenticate.ts +28 -13
- package/src/mcp/tools/mode/mode.ts +10 -22
- package/src/old/client.ts +2 -2
- package/src/old/instructions.ts +4 -10
- package/src/old/login-cdp.ts +50 -6
- package/src/old/to-register.ts +3 -2
- 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/publish.ts +95 -131
- 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 +1 -1
- package/src/proof/pod-prover.ts +231 -0
- package/src/provider/dom-xpath.ts +11 -9
- package/src/provider/draft.ts +13 -10
- package/src/provider/injection-doc.ts +37 -24
- package/src/provider/match-redaction-warning.ts +3 -3
- package/src/provider/matcher.ts +13 -12
- package/src/provider/secrets.ts +3 -3
- package/src/provider/to-version.ts +11 -9
- package/src/tools/registry.ts +5 -5
- package/skill/injection-api.md +0 -364
|
@@ -1,32 +1,73 @@
|
|
|
1
|
-
import {
|
|
2
|
-
PROVIDER_GUIDE_BUILDER,
|
|
3
|
-
PROVIDER_GUIDE_OLD,
|
|
4
|
-
} from '../../instructions.ts'
|
|
1
|
+
import { guideFor } from '../../instructions.ts'
|
|
5
2
|
import { defineTool, type RegisteredTool } from '../../server.ts'
|
|
6
3
|
|
|
7
4
|
/**
|
|
8
|
-
* Serves the
|
|
9
|
-
* always-on `instructions` are a terse tool-flow reference; this tool
|
|
10
|
-
* the deep version
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
5
|
+
* Serves the provider-authoring guide on demand, ONE TOPIC AT A TIME. The
|
|
6
|
+
* server's always-on `instructions` are a terse tool-flow reference; this tool
|
|
7
|
+
* is the deep version, so any MCP client — not just Claude Code, which alone
|
|
8
|
+
* auto-loads skills — can pull it.
|
|
9
|
+
*
|
|
10
|
+
* Topic-scoped rather than all-at-once because the full guide is ~7k tokens:
|
|
11
|
+
* paying that to answer "how do I mark a header secret?" crowds out the actual
|
|
12
|
+
* task, which is exactly what makes an agent slow and prone to inventing
|
|
13
|
+
* details. Every response carries the topic index, so a caller that guessed
|
|
14
|
+
* wrong (or called with no topic at all) always learns what else is available
|
|
15
|
+
* without a second round-trip.
|
|
16
|
+
*
|
|
17
|
+
* `oldMode` selects the backend-specific guide, so the agent is never told to
|
|
18
|
+
* call auth/publish tools that aren't registered in its mode. Stateless:
|
|
19
|
+
* callable before `attach_browser`.
|
|
15
20
|
*/
|
|
16
21
|
export function howItWorksTool(oldMode: boolean): RegisteredTool {
|
|
17
|
-
const guide = oldMode
|
|
18
|
-
|
|
22
|
+
const guide = guideFor(oldMode)
|
|
23
|
+
const names = [...guide.topics.keys()]
|
|
24
|
+
|
|
25
|
+
return defineTool<{ topic?: string }>(
|
|
19
26
|
{
|
|
20
27
|
name: 'how_it_works',
|
|
21
28
|
description:
|
|
22
|
-
'
|
|
23
|
-
+ '
|
|
24
|
-
+ '
|
|
25
|
-
+ '
|
|
26
|
-
+ '
|
|
27
|
-
+ '
|
|
28
|
-
|
|
29
|
+
'Reclaim provider-authoring guide for THIS server, by topic. Call it '
|
|
30
|
+
+ 'with no arguments for the overview plus the topic index, then again '
|
|
31
|
+
+ 'for whichever topic you need. Topics: '
|
|
32
|
+
+ names.join(', ')
|
|
33
|
+
+ '. Use `all` for the entire guide at once (large — prefer a topic). '
|
|
34
|
+
+ 'Read the relevant topic BEFORE acting unless you are already fluent '
|
|
35
|
+
+ 'in that part of the flow.',
|
|
36
|
+
inputSchema: {
|
|
37
|
+
type: 'object',
|
|
38
|
+
properties: {
|
|
39
|
+
topic: {
|
|
40
|
+
type: 'string',
|
|
41
|
+
// Deliberately NOT an `enum`: schema validation runs before the
|
|
42
|
+
// handler, so an enum turns a mistyped topic into a validation
|
|
43
|
+
// error instead of a response carrying the real topic list. A
|
|
44
|
+
// plain string lets the tool answer the mistake usefully.
|
|
45
|
+
description:
|
|
46
|
+
'Which section to return: ' + names.join(', ')
|
|
47
|
+
+ ', or `all`. Omit for the overview + topic index. An '
|
|
48
|
+
+ 'unrecognized value comes back with the list, not an error.',
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
async({ topic }) => {
|
|
54
|
+
if(topic === 'all') {
|
|
55
|
+
return { topic: 'all', topics: guide.index, guide: guide.full }
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const requested = topic ?? 'overview'
|
|
59
|
+
const section = guide.topics.get(requested)
|
|
60
|
+
if(!section) {
|
|
61
|
+
// Not an error: hand back the index so the caller self-corrects in
|
|
62
|
+
// the same turn rather than retrying blind.
|
|
63
|
+
return {
|
|
64
|
+
error: `Unknown topic "${requested}".`,
|
|
65
|
+
topics: guide.index,
|
|
66
|
+
guide: guide.topics.get('overview'),
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return { topic: requested, topics: guide.index, guide: section }
|
|
29
71
|
},
|
|
30
|
-
async() => ({ guide }),
|
|
31
72
|
)
|
|
32
73
|
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
// Barrel for the agent tool group (Chrome CDP capture, provider synthesis,
|
|
2
2
|
// replay, zkTLS proof). Import from here, not the individual files.
|
|
3
|
-
export {
|
|
4
|
-
|
|
3
|
+
export {
|
|
4
|
+
type AgentState,
|
|
5
|
+
buildAgentState,
|
|
6
|
+
buildAgentTools,
|
|
7
|
+
disposeAgentState,
|
|
8
|
+
} from './build.ts'
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `share_browser_view` / `stop_browser_view` — put the LOCAL attached tab
|
|
3
|
+
* behind a public URL so someone who is not at this machine can watch it, and
|
|
4
|
+
* optionally drive it.
|
|
5
|
+
*
|
|
6
|
+
* Scoped to the CDP-attached modes (`dedicated`, `attach`, `custom`) on
|
|
7
|
+
* purpose. A `builder`-mode browser is a Popcorn pod that already ships its
|
|
8
|
+
* own hosted live view on `attach_browser`'s `liveViewUrl`; tunnelling a
|
|
9
|
+
* second one would duplicate it and burn a share URL for nothing, so this
|
|
10
|
+
* refuses and points at the one that exists.
|
|
11
|
+
*
|
|
12
|
+
* The share is deliberately explicit and single-instance: one live view per
|
|
13
|
+
* attached browser, started only when asked for, and torn down by
|
|
14
|
+
* `stop_browser_view`, `dispose_browser`, or `reset_session`.
|
|
15
|
+
*/
|
|
16
|
+
import { badRequest, conflict } from '@hapi/boom'
|
|
17
|
+
import assert from 'node:assert'
|
|
18
|
+
import { startTunnel, type Tunnel } from '../../../live/tunnel.ts'
|
|
19
|
+
import { LOGGER } from '../../../logger.ts'
|
|
20
|
+
import { defineTool, type RegisteredTool } from '../../server.ts'
|
|
21
|
+
import { type AttachState, SHAREABLE_MODES } from './attach.ts'
|
|
22
|
+
|
|
23
|
+
export interface LiveShare {
|
|
24
|
+
tunnel: Tunnel
|
|
25
|
+
/** The public URL handed to whoever is watching. */
|
|
26
|
+
url: string
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface LiveShareRef {
|
|
30
|
+
current?: LiveShare
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Tear down whatever share is running. Safe when none is. Exported so the
|
|
34
|
+
* session tools can call it from `dispose_browser` / `reset_session`. */
|
|
35
|
+
export async function stopLiveShare(ref: LiveShareRef): Promise<boolean> {
|
|
36
|
+
const share = ref.current
|
|
37
|
+
if(!share) {
|
|
38
|
+
return false
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
ref.current = undefined
|
|
42
|
+
// Only the tunnel is ours to close. The browser and its viewer belong to the
|
|
43
|
+
// container, which keeps running until the browser is disposed.
|
|
44
|
+
await share.tunnel.stop().catch((err) => {
|
|
45
|
+
LOGGER.warn({ err }, 'live view: tunnel stop failed')
|
|
46
|
+
})
|
|
47
|
+
return true
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function liveViewTools(
|
|
51
|
+
attachRef: { current?: AttachState },
|
|
52
|
+
shareRef: LiveShareRef,
|
|
53
|
+
): RegisteredTool[] {
|
|
54
|
+
return [
|
|
55
|
+
defineTool<Record<string, never>>(
|
|
56
|
+
{
|
|
57
|
+
name: 'share_browser_view',
|
|
58
|
+
description:
|
|
59
|
+
'Put the attached browser\'s live view behind a PUBLIC HTTPS URL (a '
|
|
60
|
+
+ 'cloudflared quick tunnel) so someone elsewhere can watch it and '
|
|
61
|
+
+ 'act in it. Use it to hand a login or a 2FA step to the person '
|
|
62
|
+
+ 'who holds the credentials, or to let a colleague watch a '
|
|
63
|
+
+ 'capture. Returns the URL — relay it to the developer VERBATIM, '
|
|
64
|
+
+ 'on its own line. '
|
|
65
|
+
+ 'ONLY for `container` mode, whose browser runs its own viewer. '
|
|
66
|
+
+ 'A `builder` browser already has a hosted live view: use the '
|
|
67
|
+
+ '`liveViewUrl` attach_browser returned. A local browser '
|
|
68
|
+
+ '(`dedicated`, `attach`, `custom`) cannot be shared at all — no '
|
|
69
|
+
+ 'tunnel can fix that, because there is no viewer behind it. Tell '
|
|
70
|
+
+ 'them so, and offer to re-attach: `container` is free and needs '
|
|
71
|
+
+ 'Docker, `builder` needs no install but is chargeable. '
|
|
72
|
+
+ 'THE URL IS THE ONLY CREDENTIAL: the random hostname is the whole '
|
|
73
|
+
+ 'secret, with no token or login behind it, so anyone who learns '
|
|
74
|
+
+ 'it can see and drive this browser as the signed-in user. Share '
|
|
75
|
+
+ 'it only with the person who needs it, and call stop_browser_view '
|
|
76
|
+
+ 'the moment they are done. '
|
|
77
|
+
+ 'Needs cloudflared: an existing install on PATH is used as-is, '
|
|
78
|
+
+ 'otherwise it is downloaded once to ~/.reclaim/bin on first '
|
|
79
|
+
+ 'share (never at install time). Set RECLAIM_CLOUDFLARED_PATH to '
|
|
80
|
+
+ 'point at your own copy instead.',
|
|
81
|
+
inputSchema: { type: 'object', properties: {} },
|
|
82
|
+
},
|
|
83
|
+
async() => {
|
|
84
|
+
|
|
85
|
+
const attached = attachRef.current
|
|
86
|
+
assert(attached, badRequest(
|
|
87
|
+
'No browser attached. Call attach_browser first.',
|
|
88
|
+
))
|
|
89
|
+
assert(SHAREABLE_MODES.has(attached.mode), badRequest(
|
|
90
|
+
`share_browser_view does not apply to \`${attached.mode}\` mode. `
|
|
91
|
+
+ (attached.liveViewUrl
|
|
92
|
+
? 'That browser already has a hosted live view — use the '
|
|
93
|
+
+ `\`liveViewUrl\` from attach_browser: ${attached.liveViewUrl}`
|
|
94
|
+
: 'That browser has no live view to put behind a URL. To let '
|
|
95
|
+
+ 'someone else in, re-attach with mode "container" (the '
|
|
96
|
+
+ 'Reclaim runtime in Docker — free, needs Docker) or '
|
|
97
|
+
+ '"builder" (hosted, no install, chargeable)')
|
|
98
|
+
+ '.',
|
|
99
|
+
))
|
|
100
|
+
assert(!shareRef.current, conflict(
|
|
101
|
+
'A live view is already running at '
|
|
102
|
+
+ `${shareRef.current?.url}. Call stop_browser_view first, or `
|
|
103
|
+
+ 'reuse that URL.',
|
|
104
|
+
))
|
|
105
|
+
|
|
106
|
+
// The container publishes its viewer on loopback and its full CDP
|
|
107
|
+
// port beside it. Only the VIEWER is ever tunnelled: the CDP port is
|
|
108
|
+
// unauthenticated, total control of the browser, and putting it on a
|
|
109
|
+
// public URL would hand that to anyone with the link.
|
|
110
|
+
const viewerPort = attached.viewerPort
|
|
111
|
+
assert(viewerPort, badRequest(
|
|
112
|
+
'This browser reports no live-view port. Re-attach with mode '
|
|
113
|
+
+ '"container".',
|
|
114
|
+
))
|
|
115
|
+
|
|
116
|
+
const tunnel = await startTunnel(viewerPort)
|
|
117
|
+
// The path is the runtime's own viewer page; `magnify=1` is what makes
|
|
118
|
+
// it lay out for the device that opens it.
|
|
119
|
+
const url = `${tunnel.url}/liveview.html?magnify=1`
|
|
120
|
+
const share: LiveShare = {
|
|
121
|
+
tunnel, url,
|
|
122
|
+
}
|
|
123
|
+
shareRef.current = share
|
|
124
|
+
LOGGER.info({ mode: attached.mode }, 'live view shared')
|
|
125
|
+
|
|
126
|
+
return {
|
|
127
|
+
url,
|
|
128
|
+
...(share.tunnel.binary.source === 'downloaded'
|
|
129
|
+
? { cloudflaredInstalled: true }
|
|
130
|
+
: {}),
|
|
131
|
+
...(share.tunnel.ready
|
|
132
|
+
? {}
|
|
133
|
+
: {
|
|
134
|
+
propagating: true,
|
|
135
|
+
// cloudflared's own last words. Without them, "the URL does
|
|
136
|
+
// not connect" is unactionable: the tunnel, the local server
|
|
137
|
+
// and this machine's egress all look identical from outside.
|
|
138
|
+
...(share.tunnel.diagnostics
|
|
139
|
+
? { cloudflaredLog: share.tunnel.diagnostics }
|
|
140
|
+
: {}),
|
|
141
|
+
}),
|
|
142
|
+
_notes: [
|
|
143
|
+
...(share.tunnel.binary.source === 'downloaded'
|
|
144
|
+
? ['cloudflared was not installed, so it was downloaded once '
|
|
145
|
+
+ 'to ~/.reclaim/bin. Mention that; later shares reuse it.']
|
|
146
|
+
: []),
|
|
147
|
+
...(share.tunnel.ready
|
|
148
|
+
? []
|
|
149
|
+
: ['The tunnel never confirmed a connection to Cloudflare, so '
|
|
150
|
+
+ 'the URL may not resolve yet. Give it ~10s and reload '
|
|
151
|
+
+ 'first. If it still fails, say so and offer to retry '
|
|
152
|
+
+ '(stop_browser_view then share_browser_view) — a quick '
|
|
153
|
+
+ 'tunnel does sometimes fail to register. '
|
|
154
|
+
+ '`cloudflaredLog` has its output if it keeps happening.']),
|
|
155
|
+
'Relay `url` to the developer verbatim, on its own line.',
|
|
156
|
+
'The URL is a credential: it needs no login, and anyone with it '
|
|
157
|
+
+ 'can see this browser and act in it as the signed-in user.',
|
|
158
|
+
'It shows the whole browser, so a sign-in that opens a separate '
|
|
159
|
+
+ 'window is visible too — unlike a single-tab stream.',
|
|
160
|
+
'Opening it on a phone lays the page out for that phone, with '
|
|
161
|
+
+ 'touch, pinch-zoom and the soft keyboard.',
|
|
162
|
+
'Call stop_browser_view when they are done. That closes the '
|
|
163
|
+
+ 'tunnel only — the browser keeps running.',
|
|
164
|
+
],
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
),
|
|
168
|
+
defineTool<Record<string, never>>(
|
|
169
|
+
{
|
|
170
|
+
name: 'stop_browser_view',
|
|
171
|
+
description:
|
|
172
|
+
'Close the public URL opened by share_browser_view: shuts the '
|
|
173
|
+
+ 'tunnel down, so the URL stops resolving for whoever still has '
|
|
174
|
+
+ 'it. Call it as soon as the person you shared with is finished. '
|
|
175
|
+
+ 'Nothing else changes — the browser stays attached, its own live '
|
|
176
|
+
+ 'view keeps serving locally, and any capture keeps running.',
|
|
177
|
+
inputSchema: { type: 'object', properties: {} },
|
|
178
|
+
},
|
|
179
|
+
async() => ({ stopped: await stopLiveShare(shareRef) }),
|
|
180
|
+
),
|
|
181
|
+
]
|
|
182
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prove a drafted recipe through the Popcorn pod's OWN `/reclaim/prove` — the
|
|
3
|
+
* remote browser session's own API for creating a proof from that same
|
|
4
|
+
* session — instead of the local in-process attestor SDK (`run_proof`).
|
|
5
|
+
* Recommended for any `builder`-mode attach: the pod is the SAME enclave that
|
|
6
|
+
* holds the browser's TLS session, so proving there reaches the target from
|
|
7
|
+
* the identical exit IP the browser used — including the country-routed egress
|
|
8
|
+
* Popcorn applies when the session was allocated with a country. A local SDK
|
|
9
|
+
* proof runs from the agent's own network instead, which won't match a
|
|
10
|
+
* country-locked / IP-allowlisted target the remote browser could reach.
|
|
11
|
+
*
|
|
12
|
+
* Builder mode only (needs the attach's pod `apiUrl`, from
|
|
13
|
+
* `CreateAgentBrowserSession`) — throws a clear error otherwise rather than
|
|
14
|
+
* silently falling back to the local path.
|
|
15
|
+
*/
|
|
16
|
+
import { badRequest } from '@hapi/boom'
|
|
17
|
+
import assert from 'node:assert'
|
|
18
|
+
import type { ConfigStore } from '../../../config/store.ts'
|
|
19
|
+
import { popcornProve } from '../../../proof/pod-prover.ts'
|
|
20
|
+
import { buildHttpParams } from '../../../proof/proof-core.ts'
|
|
21
|
+
import { defineTool, type RegisteredTool } from '../../server.ts'
|
|
22
|
+
import type { AttachState } from './attach.ts'
|
|
23
|
+
import type { CaptureStore } from './capture.ts'
|
|
24
|
+
import { shapeRichProofResult } from './proof.ts'
|
|
25
|
+
|
|
26
|
+
export function podProofTools(
|
|
27
|
+
attachRef: { current?: AttachState, config: ConfigStore },
|
|
28
|
+
captures: CaptureStore,
|
|
29
|
+
): RegisteredTool[] {
|
|
30
|
+
const tool = defineTool<{ captureId: string, draftId: string }>(
|
|
31
|
+
{
|
|
32
|
+
name: 'run_proof_via_pod',
|
|
33
|
+
description:
|
|
34
|
+
'Prove the drafted recipe through the Popcorn pod\'s own TEE '
|
|
35
|
+
+ '(/reclaim/prove) instead of the local attestor SDK — this is '
|
|
36
|
+
+ 'the remote browser session\'s own api for creating a proof '
|
|
37
|
+
+ 'from that same session. Use this instead of run_proof '
|
|
38
|
+
+ 'whenever this capture\'s '
|
|
39
|
+
+ 'attach mode is "builder": the pod is the same enclave that '
|
|
40
|
+
+ 'held the browser\'s TLS session (and its country-routed egress, '
|
|
41
|
+
+ 'if any), so '
|
|
42
|
+
+ 'the proof reaches the target from the browser\'s own exit IP. '
|
|
43
|
+
+ 'No ownerAddress needed — the pod signs with the attestor\'s '
|
|
44
|
+
+ 'own TEE key, not a local credential.',
|
|
45
|
+
inputSchema: {
|
|
46
|
+
type: 'object',
|
|
47
|
+
properties: {
|
|
48
|
+
captureId: { type: 'string' },
|
|
49
|
+
draftId: { type: 'string' },
|
|
50
|
+
},
|
|
51
|
+
required: ['captureId', 'draftId'],
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
async({ captureId, draftId }) => {
|
|
55
|
+
const apiUrl = attachRef.current?.apiUrl
|
|
56
|
+
assert(
|
|
57
|
+
apiUrl,
|
|
58
|
+
badRequest(
|
|
59
|
+
'No pod api available for this attach — run_proof_via_pod needs '
|
|
60
|
+
+ 'mode "builder" (attach_browser), not local/custom CDP.',
|
|
61
|
+
),
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
const entry = captures.sessions.get(captureId)
|
|
65
|
+
assert(
|
|
66
|
+
entry,
|
|
67
|
+
badRequest(
|
|
68
|
+
`no capture ${captureId} — call start_capture first `
|
|
69
|
+
+ '(it has been reset or never started).',
|
|
70
|
+
),
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
const draft = entry.drafts.get(draftId)
|
|
74
|
+
assert(draft, badRequest(`no draft ${draftId} in capture ${captureId}`))
|
|
75
|
+
|
|
76
|
+
const result = await popcornProve({
|
|
77
|
+
apiUrl,
|
|
78
|
+
params: buildHttpParams(draft.provider),
|
|
79
|
+
secretParams: { headers: draft.secrets },
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
return shapeRichProofResult(result, {
|
|
83
|
+
provider: draft.provider,
|
|
84
|
+
hasSecrets: Object.keys(draft.secrets).length > 0,
|
|
85
|
+
})
|
|
86
|
+
},
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
return [tool]
|
|
90
|
+
}
|
|
@@ -25,13 +25,15 @@ export function proposeTool(resolveBackend: ResolveBackend): RegisteredTool {
|
|
|
25
25
|
+ 'Single-value shorthand: `target` + `name`. Per-target `hash` '
|
|
26
26
|
+ 'OPRF-hashes that value. BY DEFAULT each `name` is shortened to '
|
|
27
27
|
+ 'its last alphanumeric token, lowercased, to form the param key '
|
|
28
|
-
+ '(
|
|
28
|
+
+ '(for example, "employer_name" → "name") — pick names that stay '
|
|
29
|
+
+ 'distinct '
|
|
29
30
|
+ 'after shortening ("firstName"/"surname", not "first_name"/'
|
|
30
31
|
+ '"last_name"). Pass `shortenNames: false` to use each `name` '
|
|
31
32
|
+ 'VERBATIM as the param key instead — it becomes both a regex '
|
|
32
33
|
+ 'capture-group name and a paramValues key, so it must be a plain '
|
|
33
34
|
+ 'identifier (letters/digits/underscore, not starting with a '
|
|
34
|
-
+ 'digit); we recommend lower_snake_case (
|
|
35
|
+
+ 'digit); we recommend lower_snake_case (for example, '
|
|
36
|
+
+ '"employer_name"), '
|
|
35
37
|
+ 'but you choose the exact name.',
|
|
36
38
|
inputSchema: objectSchema(
|
|
37
39
|
{
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { ReclaimClient } from '@reclaimprotocol/client'
|
|
2
2
|
import type { JSONSchema } from 'zod/v4/core'
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
ALLOWED_REQUESTS_HINT,
|
|
5
|
+
USER_SCRIPT_HINT,
|
|
6
|
+
} from '../../../provider/injection-doc.ts'
|
|
4
7
|
import {
|
|
5
8
|
countsFor,
|
|
6
9
|
matchRedactionWarnings,
|
|
@@ -82,7 +85,8 @@ const PROVIDER_SCHEMA: JSONSchema.Schema = {
|
|
|
82
85
|
type: 'object',
|
|
83
86
|
description:
|
|
84
87
|
'A `provider` object from propose_provider, passed through verbatim — ' +
|
|
85
|
-
'the tool builds the version body (the requests[] entry
|
|
88
|
+
'the tool builds the version body (the requests[] entry and so on) ' +
|
|
89
|
+
'for you.',
|
|
86
90
|
properties: {
|
|
87
91
|
name: { type: 'string', description: 'Verification name.' },
|
|
88
92
|
...REQUEST_DRAFT_PROPERTIES,
|
|
@@ -95,7 +99,7 @@ const PROVIDER_SCHEMA: JSONSchema.Schema = {
|
|
|
95
99
|
paramValues: {
|
|
96
100
|
type: 'object',
|
|
97
101
|
description:
|
|
98
|
-
'Real values for the {{param}} placeholders,
|
|
102
|
+
'Real values for the {{param}} placeholders, for example, ' +
|
|
99
103
|
'{ "username": "Syed" }.',
|
|
100
104
|
},
|
|
101
105
|
},
|
|
@@ -111,8 +115,8 @@ const ALLOWED_JS_REQUEST_SCHEMA: JSONSchema.Schema = {
|
|
|
111
115
|
multiple: {
|
|
112
116
|
type: 'boolean',
|
|
113
117
|
description:
|
|
114
|
-
'Allow the template to match many requests (
|
|
115
|
-
'Default true.',
|
|
118
|
+
'Allow the template to match many requests (for example, ' +
|
|
119
|
+
'pagination). Default true.',
|
|
116
120
|
},
|
|
117
121
|
required: {
|
|
118
122
|
type: 'boolean',
|
|
@@ -137,6 +141,7 @@ interface PublishArgs {
|
|
|
137
141
|
interceptorOptions?: {
|
|
138
142
|
interceptorType: 'HAWKEYE' | 'MSWJS' | 'CDP'
|
|
139
143
|
interceptorSettings?: string
|
|
144
|
+
isDocumentRequestReplayEnabled?: boolean
|
|
140
145
|
}
|
|
141
146
|
}
|
|
142
147
|
|
|
@@ -148,36 +153,21 @@ export function createVersionFromCaptureTool(
|
|
|
148
153
|
{
|
|
149
154
|
name: 'create_provider_version_from_capture',
|
|
150
155
|
description:
|
|
151
|
-
'Persist drafted ReclaimProvider(s) as a provider version
|
|
152
|
-
'
|
|
153
|
-
'
|
|
154
|
-
'
|
|
155
|
-
'
|
|
156
|
-
'
|
|
157
|
-
'
|
|
158
|
-
'
|
|
159
|
-
'
|
|
160
|
-
'
|
|
161
|
-
'page-injection script that drives the page to where the request ' +
|
|
162
|
-
'fires) and/or `allowedJsRequests` (extra requests the script may ' +
|
|
163
|
-
'fire, e.g. pagination). ' +
|
|
164
|
-
'Omit `version` to have the tool auto-select the next available ' +
|
|
165
|
-
'version (it lists existing versions and bumps past the highest). ' +
|
|
166
|
-
'The version lands on the draft branch — to go live, call ' +
|
|
167
|
-
'`publish_provider_version` (PRIVATE) or ' +
|
|
168
|
-
'`submit_provider_version_for_review` (PUBLIC) afterwards. ' +
|
|
156
|
+
'Persist drafted ReclaimProvider(s) as a provider version, after ' +
|
|
157
|
+
'run_proof succeeds. Pass the `provider` object(s) from ' +
|
|
158
|
+
'propose_provider VERBATIM — this tool builds the version body ' +
|
|
159
|
+
'(requests[], webSettings, …) for you; do NOT hand-construct that ' +
|
|
160
|
+
'shape or call create_provider_version directly. Exactly one of ' +
|
|
161
|
+
'`provider` (one request) or `providers` (a multi-request provider — ' +
|
|
162
|
+
'every entry is required at verification time). Omit `version` to ' +
|
|
163
|
+
'auto-bump past the highest existing one. The version lands on the ' +
|
|
164
|
+
'draft branch: call `publish_provider_version` (PRIVATE) or ' +
|
|
165
|
+
'`submit_provider_version_for_review` (PUBLIC) to go live. ' +
|
|
169
166
|
'`requiredContext` is derived from any {{context.<name>}} ' +
|
|
170
|
-
'placeholders
|
|
171
|
-
'
|
|
172
|
-
'
|
|
173
|
-
'
|
|
174
|
-
'field is a 400 at session create). ' +
|
|
175
|
-
'Refine types/descriptions via `update_provider_version` while ' +
|
|
176
|
-
'still on draft. ' +
|
|
177
|
-
'On success, if a browser is still attached, the response\'s ' +
|
|
178
|
-
'`_notes` reminds you to confirm with the developer before ' +
|
|
179
|
-
'calling `dispose_browser` — never close it unprompted, they ' +
|
|
180
|
-
'may want it for further edits.',
|
|
167
|
+
'placeholders and returned on the created version — relay it to the ' +
|
|
168
|
+
'dev verbatim, since a session missing those fields is a 400. Always ' +
|
|
169
|
+
'read the response\'s `_notes`. ' +
|
|
170
|
+
'Full walkthrough: how_it_works({ topic: "publish" }).',
|
|
181
171
|
inputSchema: {
|
|
182
172
|
type: 'object',
|
|
183
173
|
properties: {
|
|
@@ -199,13 +189,15 @@ export function createVersionFromCaptureTool(
|
|
|
199
189
|
type: 'string',
|
|
200
190
|
description:
|
|
201
191
|
'The website URL the user landed on to trigger the request ' +
|
|
202
|
-
'(
|
|
203
|
-
'flow opens for end-users — NOT the API URL
|
|
192
|
+
'(for example, https://github.com/Syed). The URL the ' +
|
|
193
|
+
'verification flow opens for end-users — NOT the API URL ' +
|
|
194
|
+
'inside the provider.',
|
|
204
195
|
},
|
|
205
196
|
notes: {
|
|
206
197
|
type: 'string',
|
|
207
198
|
description:
|
|
208
|
-
'Short change note (
|
|
199
|
+
'Short change note (for example, "Initial draft from ' +
|
|
200
|
+
'browser capture").',
|
|
209
201
|
},
|
|
210
202
|
version: {
|
|
211
203
|
type: 'object',
|
|
@@ -222,45 +214,22 @@ export function createVersionFromCaptureTool(
|
|
|
222
214
|
jsUserScripts: {
|
|
223
215
|
type: 'string',
|
|
224
216
|
description:
|
|
225
|
-
|
|
226
|
-
'
|
|
227
|
-
'
|
|
228
|
-
'
|
|
229
|
-
'
|
|
230
|
-
'
|
|
231
|
-
'verification client installs this to run before every page ' +
|
|
232
|
-
'load (before navigating to initialUrl), matching old-devtool ' +
|
|
233
|
-
'customInjection; window.Reclaim itself is not yet exposed ' +
|
|
234
|
-
'there, so prefer plain browser JS. Guide:\n\n' +
|
|
235
|
-
INJECTION_GUIDE,
|
|
217
|
+
USER_SCRIPT_HINT +
|
|
218
|
+
' Stored as webSettings.jsUserScripts; the Builder ' +
|
|
219
|
+
'verification client runs it before every page load ' +
|
|
220
|
+
'(including before navigating to initialUrl), matching ' +
|
|
221
|
+
'old-devtools customInjection. window.Reclaim is not exposed ' +
|
|
222
|
+
'there yet, so prefer plain browser JS.',
|
|
236
223
|
},
|
|
237
224
|
allowedJsRequests: {
|
|
238
225
|
type: 'array',
|
|
239
226
|
description:
|
|
240
|
-
'Extra requests the
|
|
241
|
-
'
|
|
242
|
-
'
|
|
243
|
-
'
|
|
244
|
-
'
|
|
245
|
-
|
|
246
|
-
'different field name): this whole entry (url, method, body, ' +
|
|
247
|
-
'responseMatches, responseRedactions) feeds a client-side ' +
|
|
248
|
-
'hash-equality check, and `url` is hashed VERBATIM — no regex/ ' +
|
|
249
|
-
'template resolution, even with `urlType: REGEX` or ' +
|
|
250
|
-
'`TEMPLATE`. If the real captured URL contains ANY per-session ' +
|
|
251
|
-
'part (a tracking nonce, CSRF token, cache-busting timestamp), ' +
|
|
252
|
-
'no declared spec can EVER hash-match a real proof — populating' +
|
|
253
|
-
' this for such a provider makes verifyProof reject every real ' +
|
|
254
|
-
'proof, which is worse than leaving it empty. Diff the same ' +
|
|
255
|
-
'endpoint\'s captured URL across two separate sessions before ' +
|
|
256
|
-
'wiring this up. If provider-hash validation keeps causing ' +
|
|
257
|
-
'problems (unstable url, or any other persistent mismatch), ' +
|
|
258
|
-
'the fallback on the verifying side is `verifyProof(proof, { ' +
|
|
259
|
-
'dangerouslyDisableContentValidation: true })` — trusts only ' +
|
|
260
|
-
'the attestor\'s signature, skips the hash-equality check ' +
|
|
261
|
-
'entirely; see the "Provider-hash validation" section of the ' +
|
|
262
|
-
'injection script\'s guide for the full mechanics and when to ' +
|
|
263
|
-
'reach for it.',
|
|
227
|
+
'Extra requests the user script is allowed to fire (for ' +
|
|
228
|
+
'example, paginated API calls), as ' +
|
|
229
|
+
'RequestSelectionTemplates. ' +
|
|
230
|
+
'`multiple`/`required` default to true. Old-devtools calls the ' +
|
|
231
|
+
'same concept `allowedInjectedRequestData`. ' +
|
|
232
|
+
ALLOWED_REQUESTS_HINT,
|
|
264
233
|
items: ALLOWED_JS_REQUEST_SCHEMA,
|
|
265
234
|
},
|
|
266
235
|
interceptorOptions: {
|
|
@@ -269,11 +238,7 @@ export function createVersionFromCaptureTool(
|
|
|
269
238
|
'In-app interception settings, stored as ' +
|
|
270
239
|
'webSettings.clientOptions.inapp.interceptorOptions — only ' +
|
|
271
240
|
'needed for a genuine live-interception provider (a real ' +
|
|
272
|
-
'HAWKEYE/MSWJS script, not the standard capture→replay flow).
|
|
273
|
-
'Document replay (webSettings.clientOptions.inapp' +
|
|
274
|
-
'.interceptorOptions.isDocumentRequestReplayEnabled) is ' +
|
|
275
|
-
'ALWAYS published disabled regardless of this field — there ' +
|
|
276
|
-
'is no way to enable it here.',
|
|
241
|
+
'HAWKEYE/MSWJS script, not the standard capture→replay flow).',
|
|
277
242
|
properties: {
|
|
278
243
|
interceptorType: {
|
|
279
244
|
type: 'string',
|
|
@@ -285,6 +250,16 @@ export function createVersionFromCaptureTool(
|
|
|
285
250
|
description:
|
|
286
251
|
'Free-form JSON config for the chosen interceptor.',
|
|
287
252
|
},
|
|
253
|
+
isDocumentRequestReplayEnabled: {
|
|
254
|
+
type: 'boolean',
|
|
255
|
+
description:
|
|
256
|
+
'Whether the page\'s own document/navigation request is ' +
|
|
257
|
+
'genuinely replayed through the interceptor, rather than ' +
|
|
258
|
+
'constructed locally. Defaults to `false` (disabled) when ' +
|
|
259
|
+
'omitted. Only meaningful for HAWKEYE/MSWJS — pass `true` ' +
|
|
260
|
+
'when the target value is embedded in the page\'s own HTML ' +
|
|
261
|
+
'rather than a separate API call. Inert for CDP.',
|
|
262
|
+
},
|
|
288
263
|
},
|
|
289
264
|
required: ['interceptorType'],
|
|
290
265
|
},
|