@reclaimprotocol/agent 0.1.33 → 0.1.35
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 +3 -3
- package/lib/authoring/backend.d.ts +13 -0
- package/lib/authoring/index.d.ts +1 -1
- package/lib/authoring/tools.js +78 -42
- package/lib/config/store.d.ts +10 -0
- package/lib/mcp/api/operations.gen.d.ts +238 -4
- package/lib/mcp/api/operations.gen.js +6967 -672
- package/lib/mcp/api/tools.js +21 -8
- package/lib/mcp/instructions.js +12 -12
- package/lib/mcp/server.d.ts +1 -1
- package/lib/mcp/server.js +3 -0
- package/lib/mcp/start.js +8 -7
- package/lib/mcp/success-response.js +5 -1
- package/lib/mcp/tools/agent/analyze.js +5 -4
- package/lib/mcp/tools/agent/attach.js +11 -7
- package/lib/mcp/tools/agent/build.js +5 -1
- package/lib/mcp/tools/agent/capture.d.ts +2 -2
- package/lib/mcp/tools/agent/capture.js +15 -11
- package/lib/mcp/tools/agent/check-attestor.d.ts +5 -0
- package/lib/mcp/tools/agent/check-attestor.js +37 -0
- package/lib/mcp/tools/agent/eval.js +4 -3
- package/lib/mcp/tools/agent/find.js +9 -10
- package/lib/mcp/tools/agent/how-it-works.js +1 -0
- package/lib/mcp/tools/agent/live-view.js +49 -22
- package/lib/mcp/tools/agent/pod-proof.js +7 -11
- package/lib/mcp/tools/agent/proof.d.ts +12 -0
- package/lib/mcp/tools/agent/proof.js +32 -0
- package/lib/mcp/tools/agent/propose.js +4 -3
- package/lib/mcp/tools/agent/publish.d.ts +2 -1
- package/lib/mcp/tools/agent/publish.js +12 -6
- package/lib/mcp/tools/agent/replay.js +10 -7
- package/lib/mcp/tools/agent/session.js +16 -8
- package/lib/mcp/tools/agent/shared.d.ts +2 -1
- package/lib/mcp/tools/agent/shared.js +29 -24
- package/lib/mcp/tools/agent/start-integration.d.ts +15 -0
- package/lib/mcp/tools/agent/start-integration.js +62 -0
- package/lib/mcp/tools/authenticate/authenticate.js +9 -11
- package/lib/mcp/tools/authenticate/build.js +2 -0
- package/lib/mcp/tools/authenticate/builder-access.js +1 -0
- package/lib/mcp/tools/authenticate/eth-key.d.ts +8 -0
- package/lib/mcp/tools/authenticate/eth-key.js +27 -15
- package/lib/mcp/tools/authenticate/import.js +18 -31
- package/lib/mcp/tools/authenticate/issue-org-token.d.ts +8 -0
- package/lib/mcp/tools/authenticate/issue-org-token.js +60 -0
- package/lib/mcp/tools/authenticate/issue.js +9 -9
- package/lib/mcp/tools/authenticate/org-key-store.d.ts +10 -0
- package/lib/mcp/tools/authenticate/org-key-store.js +23 -0
- package/lib/mcp/tools/authenticate/resolve-owner-key.js +10 -12
- package/lib/mcp/tools/mode/mode.js +2 -0
- package/lib/mcp/tools/verification/build.d.ts +3 -1
- package/lib/mcp/tools/verification/build.js +10 -2
- package/lib/mcp/tools/verification/callback-listener.d.ts +51 -0
- package/lib/mcp/tools/verification/callback-listener.js +163 -0
- package/lib/mcp/tools/verification/index.d.ts +2 -0
- package/lib/mcp/tools/verification/index.js +2 -0
- package/lib/mcp/tools/verification/proxy-callback-events.d.ts +59 -0
- package/lib/mcp/tools/verification/proxy-callback-events.js +300 -0
- package/lib/mcp/tools/verification/read-callback-events.d.ts +3 -0
- package/lib/mcp/tools/verification/read-callback-events.js +135 -0
- package/lib/mcp/tools/verification/result.d.ts +6 -0
- package/lib/mcp/tools/verification/result.js +11 -8
- package/lib/proof/check-attestor.d.ts +67 -0
- package/lib/proof/check-attestor.js +156 -0
- package/lib/tools/registry.d.ts +12 -0
- package/lib/tools/registry.js +1 -0
- package/package.json +2 -2
- package/skill/SKILL.builder.md +84 -75
- package/skill/SKILL.common.md +23 -10
- package/skill/builder-mode.md +140 -138
- package/skill/start-integration.md +74 -0
- package/skill/user-script.md +64 -0
- package/skill/verification-client-integration.md +40 -28
- package/src/authoring/backend.ts +15 -0
- package/src/authoring/index.ts +2 -0
- package/src/authoring/tools.ts +86 -42
- package/src/config/store.ts +11 -0
- package/src/mcp/api/operations.gen.ts +7011 -704
- package/src/mcp/api/tools.ts +21 -8
- package/src/mcp/instructions.ts +12 -12
- package/src/mcp/server.ts +4 -0
- package/src/mcp/start.ts +9 -7
- package/src/mcp/success-response.ts +5 -1
- package/src/mcp/tools/agent/analyze.ts +5 -4
- package/src/mcp/tools/agent/attach.ts +11 -7
- package/src/mcp/tools/agent/build.ts +7 -1
- package/src/mcp/tools/agent/capture.ts +20 -12
- package/src/mcp/tools/agent/check-attestor.ts +49 -0
- package/src/mcp/tools/agent/eval.ts +4 -3
- package/src/mcp/tools/agent/find.ts +9 -10
- package/src/mcp/tools/agent/how-it-works.ts +1 -0
- package/src/mcp/tools/agent/live-view.ts +49 -22
- package/src/mcp/tools/agent/pod-proof.ts +7 -11
- package/src/mcp/tools/agent/proof.ts +55 -0
- package/src/mcp/tools/agent/propose.ts +4 -3
- package/src/mcp/tools/agent/publish.ts +12 -4
- package/src/mcp/tools/agent/replay.ts +10 -7
- package/src/mcp/tools/agent/session.ts +16 -8
- package/src/mcp/tools/agent/shared.ts +39 -24
- package/src/mcp/tools/agent/start-integration.ts +84 -0
- package/src/mcp/tools/authenticate/authenticate.ts +9 -11
- package/src/mcp/tools/authenticate/build.ts +2 -0
- package/src/mcp/tools/authenticate/builder-access.ts +1 -0
- package/src/mcp/tools/authenticate/eth-key.ts +48 -18
- package/src/mcp/tools/authenticate/import.ts +21 -36
- package/src/mcp/tools/authenticate/issue-org-token.ts +84 -0
- package/src/mcp/tools/authenticate/issue.ts +9 -9
- package/src/mcp/tools/authenticate/org-key-store.ts +25 -0
- package/src/mcp/tools/authenticate/resolve-owner-key.ts +10 -12
- package/src/mcp/tools/mode/mode.ts +2 -0
- package/src/mcp/tools/verification/build.ts +10 -2
- package/src/mcp/tools/verification/callback-listener.ts +203 -0
- package/src/mcp/tools/verification/index.ts +2 -0
- package/src/mcp/tools/verification/proxy-callback-events.ts +374 -0
- package/src/mcp/tools/verification/read-callback-events.ts +160 -0
- package/src/mcp/tools/verification/result.ts +11 -8
- package/src/proof/check-attestor.ts +209 -0
- package/src/tools/registry.ts +14 -0
package/src/mcp/api/tools.ts
CHANGED
|
@@ -9,6 +9,7 @@ import assert from 'node:assert'
|
|
|
9
9
|
import { orgSecret } from '../../consts.ts'
|
|
10
10
|
import { remapErrorAsResponse } from '../remap_errors.ts'
|
|
11
11
|
import { successResponse } from '../success-response.ts'
|
|
12
|
+
import { savedOrgKey } from '../tools/authenticate/org-key-store.ts'
|
|
12
13
|
import { MCP_TOOLS } from './operations.gen.ts'
|
|
13
14
|
|
|
14
15
|
/**
|
|
@@ -47,6 +48,11 @@ export function registerTools(
|
|
|
47
48
|
const shape = {
|
|
48
49
|
description: tool.description,
|
|
49
50
|
inputSchema: tool.inputSchema,
|
|
51
|
+
// Generated entries gain `annotations` when the spec marks them; read
|
|
52
|
+
// it defensively so an older generated file still registers.
|
|
53
|
+
...('annotations' in tool && tool.annotations
|
|
54
|
+
? { annotations: tool.annotations }
|
|
55
|
+
: {}),
|
|
50
56
|
}
|
|
51
57
|
if(!isOperationId(opId)) {
|
|
52
58
|
throw new Error(
|
|
@@ -73,7 +79,7 @@ export function registerTools(
|
|
|
73
79
|
}
|
|
74
80
|
|
|
75
81
|
const caller = orgTokenOnly
|
|
76
|
-
? orgClient(orgTokenFor(toSnakeCase(opId), orgToken))
|
|
82
|
+
? orgClient(orgTokenFor(toSnakeCase(opId), orgToken, args))
|
|
77
83
|
: client
|
|
78
84
|
const result = await caller.call(
|
|
79
85
|
opId,
|
|
@@ -117,16 +123,23 @@ function isRecord(value: unknown): value is Record<string, unknown> {
|
|
|
117
123
|
}
|
|
118
124
|
|
|
119
125
|
/** The org API key a call authenticates with: its `orgToken`, else the
|
|
120
|
-
* server's RECLAIM_ORG_SECRET
|
|
121
|
-
*
|
|
122
|
-
|
|
123
|
-
|
|
126
|
+
* server's RECLAIM_ORG_SECRET, else the key `issue_org_token` saved (for the
|
|
127
|
+
* call's `orgId` when it has one, otherwise the most recent). The session
|
|
128
|
+
* token (the developer's sign-in) can't stand in, since these routes accept
|
|
129
|
+
* only an org key. */
|
|
130
|
+
function orgTokenFor(tool: string, orgToken: unknown, args: unknown) {
|
|
131
|
+
const orgId = isRecord(args) && isRecord(args.params)
|
|
132
|
+
? args.params.orgId
|
|
133
|
+
: undefined
|
|
134
|
+
const token = (typeof orgToken === 'string' && orgToken)
|
|
135
|
+
|| orgSecret()
|
|
136
|
+
|| savedOrgKey(typeof orgId === 'string' ? orgId : undefined)
|
|
124
137
|
assert(
|
|
125
138
|
token,
|
|
126
139
|
unauthorized(
|
|
127
|
-
`${tool} authenticates with the organization's API key.
|
|
128
|
-
+ '
|
|
129
|
-
+ 'RECLAIM_ORG_SECRET
|
|
140
|
+
`${tool} authenticates with the organization's API key. Run `
|
|
141
|
+
+ 'issue_org_token to save one, or pass orgToken, or set '
|
|
142
|
+
+ 'RECLAIM_ORG_SECRET for the MCP server.',
|
|
130
143
|
),
|
|
131
144
|
)
|
|
132
145
|
return token
|
package/src/mcp/instructions.ts
CHANGED
|
@@ -56,7 +56,7 @@ const BUILDER_TOPIC_FILES: Record<string, string> = {
|
|
|
56
56
|
* the right one without fetching several. Keyed across both modes; only the
|
|
57
57
|
* topics a mode actually has are listed back to it. */
|
|
58
58
|
const TOPIC_SUMMARIES: Record<string, string> = {
|
|
59
|
-
'overview': 'Terminology, your stance, and the
|
|
59
|
+
'overview': 'Terminology, your stance, and the authoring checklist.',
|
|
60
60
|
'contributions': 'Contributing a public provider as a volunteer: the '
|
|
61
61
|
+ 'candidate-and-review workflow and the extra rules it adds.',
|
|
62
62
|
'auth': 'Signing in to the backend, and which token authorizes what.',
|
|
@@ -65,23 +65,23 @@ const TOPIC_SUMMARIES: Record<string, string> = {
|
|
|
65
65
|
'browser': 'Choosing a browser source (local Chrome, the Reclaim runtime in '
|
|
66
66
|
+ 'Docker, a remote Builder browser, or a custom CDP endpoint), '
|
|
67
67
|
+ 'geolocation, live view, and launch troubleshooting.',
|
|
68
|
-
'capture': 'Tabs,
|
|
69
|
-
+ 'authenticated request to prove.',
|
|
68
|
+
'capture': 'Tabs, sign-in detection, capturing through the navigation '
|
|
69
|
+
+ 'script, and picking an authenticated request to prove.',
|
|
70
70
|
'draft': 'The OPRF/privacy decision, propose_provider, and the canonical '
|
|
71
71
|
+ 'drafted shape.',
|
|
72
72
|
'params': 'Extracted vs consumer-supplied vs secret params, the URL '
|
|
73
73
|
+ 'character budget, and runtime resolution.',
|
|
74
74
|
'prove': 'replay_request, the mandatory auth-bound check, run_proof, and '
|
|
75
75
|
+ 'diagnosing failures.',
|
|
76
|
-
'publish': 'Creating
|
|
77
|
-
+ 'and going live.',
|
|
78
|
-
'discover': '
|
|
79
|
-
+ 'session.',
|
|
80
|
-
'integration': '
|
|
81
|
-
+ '
|
|
82
|
-
+ 'verification.',
|
|
83
|
-
'user-script': '
|
|
84
|
-
+ '
|
|
76
|
+
'publish': 'Creating a provider, provider versions, multi-request '
|
|
77
|
+
+ 'providers, and going live.',
|
|
78
|
+
'discover': 'Reusing existing providers: finding, resolving, and '
|
|
79
|
+
+ 'creating a verification session.',
|
|
80
|
+
'integration': 'After start_integration: org key, callback (local '
|
|
81
|
+
+ 'proxy_callback_events or deployed webhook), frontend and backend '
|
|
82
|
+
+ 'over the HTTP session API; `api=2` and result verification.',
|
|
83
|
+
'user-script': 'The navigation script (jsUserScripts): sign-in redirect, '
|
|
84
|
+
+ 'multi-page walk, test_user_script with keep.',
|
|
85
85
|
'interception': 'injectionType / interceptorType, live interception, the '
|
|
86
86
|
+ 'document-replay flag, and what to do when a site won\'t load or '
|
|
87
87
|
+ 'won\'t let the user sign in.',
|
package/src/mcp/server.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { successResponse } from './success-response.ts'
|
|
|
10
10
|
export {
|
|
11
11
|
defineTool,
|
|
12
12
|
type RegisteredTool,
|
|
13
|
+
type ToolAnnotations,
|
|
13
14
|
type ToolDefinition,
|
|
14
15
|
} from '../tools/registry.ts'
|
|
15
16
|
|
|
@@ -25,6 +26,9 @@ export function registerToolList(server: McpServer, tools: RegisteredTool[]) {
|
|
|
25
26
|
{
|
|
26
27
|
description: tool.definition.description,
|
|
27
28
|
inputSchema: toZod(tool.definition.inputSchema),
|
|
29
|
+
...(tool.definition.annotations
|
|
30
|
+
? { annotations: tool.definition.annotations }
|
|
31
|
+
: {}),
|
|
28
32
|
},
|
|
29
33
|
async(args) => {
|
|
30
34
|
try {
|
package/src/mcp/start.ts
CHANGED
|
@@ -31,6 +31,8 @@ import {
|
|
|
31
31
|
buildVerificationTools,
|
|
32
32
|
disposeAgentState,
|
|
33
33
|
readSession,
|
|
34
|
+
releaseAllListeners,
|
|
35
|
+
stopAllForwarders,
|
|
34
36
|
} from './tools/index.ts'
|
|
35
37
|
import { BUILDER_MODE_INSTRUCTIONS } from './instructions.ts'
|
|
36
38
|
import { registerToolList } from './server.ts'
|
|
@@ -133,7 +135,7 @@ export async function startMcpServer() {
|
|
|
133
135
|
// the session can end without a single tool call: the developer closes their
|
|
134
136
|
// agent, the client kills the server, stdin drops. Nothing ran here before,
|
|
135
137
|
// which left a container up after the session that made it was gone.
|
|
136
|
-
if(agentToolsEnabled) {
|
|
138
|
+
if(agentToolsEnabled || !oldMode) {
|
|
137
139
|
installShutdownHooks(() => agentState)
|
|
138
140
|
}
|
|
139
141
|
|
|
@@ -160,11 +162,7 @@ function installShutdownHooks(state: () => AgentState | undefined): void {
|
|
|
160
162
|
|
|
161
163
|
shuttingDown = true
|
|
162
164
|
const current = state()
|
|
163
|
-
|
|
164
|
-
process.exit(0)
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
LOGGER.info({ reason }, 'releasing the browser before exit')
|
|
165
|
+
LOGGER.info({ reason }, 'releasing resources before exit')
|
|
168
166
|
// Bounded: a wedged `docker stop` must not keep the process alive, but
|
|
169
167
|
// nor should we skip cleanup that would have finished in a second.
|
|
170
168
|
const timer = setTimeout(() => {
|
|
@@ -172,7 +170,11 @@ function installShutdownHooks(state: () => AgentState | undefined): void {
|
|
|
172
170
|
process.exit(0)
|
|
173
171
|
}, SHUTDOWN_GRACE_MS)
|
|
174
172
|
timer.unref()
|
|
175
|
-
void
|
|
173
|
+
void Promise.all([
|
|
174
|
+
stopAllForwarders(),
|
|
175
|
+
releaseAllListeners(),
|
|
176
|
+
current && disposeAgentState(current),
|
|
177
|
+
])
|
|
176
178
|
.catch((err: unknown) => {
|
|
177
179
|
LOGGER.warn({ err }, 'teardown failed')
|
|
178
180
|
})
|
|
@@ -8,7 +8,11 @@ export function successResponse(value: unknown): CallToolResult {
|
|
|
8
8
|
structuredContent: structured(value),
|
|
9
9
|
content: [{
|
|
10
10
|
type: 'text',
|
|
11
|
-
text
|
|
11
|
+
// A string result is text written for the agent (a plan, a guide):
|
|
12
|
+
// JSON-quoting it would escape every newline.
|
|
13
|
+
text: typeof value === 'string'
|
|
14
|
+
? value
|
|
15
|
+
: JSON.stringify(value, null, 2) ?? 'null',
|
|
12
16
|
}],
|
|
13
17
|
}
|
|
14
18
|
}
|
|
@@ -7,10 +7,10 @@ export function analyzeTool(captures: CaptureStore): RegisteredTool {
|
|
|
7
7
|
{
|
|
8
8
|
name: 'analyze_request_constraints',
|
|
9
9
|
description:
|
|
10
|
-
'
|
|
11
|
-
+ 'request, CSRF dependency, bot challenge, short-lived
|
|
12
|
-
+ 'GraphQL. Call it on each top candidate from '
|
|
13
|
-
+ 'find_requests_containing before drafting, and relay the
|
|
10
|
+
'Returns provider-authoring concerns for one captured request: '
|
|
11
|
+
+ 'signed request, CSRF dependency, bot challenge, short-lived '
|
|
12
|
+
+ 'token, or GraphQL. Call it on each top candidate from '
|
|
13
|
+
+ '`find_requests_containing` before drafting, and relay the '
|
|
14
14
|
+ '`concerns` to the developer verbatim.',
|
|
15
15
|
inputSchema: {
|
|
16
16
|
type: 'object',
|
|
@@ -20,6 +20,7 @@ export function analyzeTool(captures: CaptureStore): RegisteredTool {
|
|
|
20
20
|
},
|
|
21
21
|
required: ['captureId', 'requestId'],
|
|
22
22
|
},
|
|
23
|
+
annotations: { readOnlyHint: true, openWorldHint: false },
|
|
23
24
|
},
|
|
24
25
|
async({ captureId, requestId }) => {
|
|
25
26
|
const entry = captures.sessions.get(captureId)
|
|
@@ -197,13 +197,16 @@ export function attachTool(
|
|
|
197
197
|
{
|
|
198
198
|
name: 'attach_browser',
|
|
199
199
|
description:
|
|
200
|
-
'Connects
|
|
201
|
-
+ '
|
|
202
|
-
+ '
|
|
203
|
-
+ '
|
|
204
|
-
+ '
|
|
205
|
-
+ '
|
|
206
|
-
+ '
|
|
200
|
+
'Connects the authoring tools to a browser that loads the '
|
|
201
|
+
+ 'developer\'s sign-in page and target site. `builder` and '
|
|
202
|
+
+ '`container` run the browser remotely or in Docker, away from the '
|
|
203
|
+
+ 'developer\'s own profile; `dedicated`, `attach`, and `custom` use a '
|
|
204
|
+
+ 'local or supplied Chrome. Call without `mode` to receive the '
|
|
205
|
+
+ 'options, ask the developer to choose, then call again once with '
|
|
206
|
+
+ 'the chosen mode. `builder` consumes quota. Only `container` and '
|
|
207
|
+
+ '`builder` support a shareable live view. Relay returned live-view '
|
|
208
|
+
+ 'URLs verbatim. See how_it_works({ topic: "browser" }) for '
|
|
209
|
+
+ 'selection, geolocation, and lifecycle.',
|
|
207
210
|
inputSchema: {
|
|
208
211
|
type: 'object',
|
|
209
212
|
properties: {
|
|
@@ -249,6 +252,7 @@ export function attachTool(
|
|
|
249
252
|
},
|
|
250
253
|
},
|
|
251
254
|
},
|
|
255
|
+
annotations: { openWorldHint: true, destructiveHint: false },
|
|
252
256
|
},
|
|
253
257
|
async(parsed) => {
|
|
254
258
|
const persisted = state.config.read()?.browser_agent
|
|
@@ -17,6 +17,7 @@ import { type RegisteredTool } from '../../server.ts'
|
|
|
17
17
|
import { analyzeTool } from './analyze.ts'
|
|
18
18
|
import { type AttachState, attachTool } from './attach.ts'
|
|
19
19
|
import { type CaptureStore, captureTools, resetCaptures } from './capture.ts'
|
|
20
|
+
import { checkAttestorTool } from './check-attestor.ts'
|
|
20
21
|
import { listTabsTool } from './eval.ts'
|
|
21
22
|
import { howItWorksTool } from './how-it-works.ts'
|
|
22
23
|
import { liveViewTools } from './live-view.ts'
|
|
@@ -24,6 +25,7 @@ import { podProofTools } from './pod-proof.ts'
|
|
|
24
25
|
import { createVersionFromCaptureTool } from './publish.ts'
|
|
25
26
|
import { resetAll, sessionTools } from './session.ts'
|
|
26
27
|
import { sharedAuthoringTools } from './shared.ts'
|
|
28
|
+
import { startIntegrationTool } from './start-integration.ts'
|
|
27
29
|
|
|
28
30
|
export interface AgentState {
|
|
29
31
|
attach: { current?: AttachState, config: ConfigStore }
|
|
@@ -82,6 +84,7 @@ export function buildAgentTools(
|
|
|
82
84
|
}
|
|
83
85
|
|
|
84
86
|
tools.push(analyzeTool(state.captures))
|
|
87
|
+
tools.push(checkAttestorTool())
|
|
85
88
|
// navigate / eval_in_page / wait_for_page / get_cookies / list_requests /
|
|
86
89
|
// find_requests_containing / propose_provider / replay_request / run_proof —
|
|
87
90
|
// shared with the cloud loop, bound to each capture's local backend.
|
|
@@ -90,7 +93,10 @@ export function buildAgentTools(
|
|
|
90
93
|
}
|
|
91
94
|
|
|
92
95
|
if(client) {
|
|
93
|
-
tools.push(
|
|
96
|
+
tools.push(startIntegrationTool())
|
|
97
|
+
tools.push(createVersionFromCaptureTool(
|
|
98
|
+
client, state.attach, state.captures,
|
|
99
|
+
))
|
|
94
100
|
}
|
|
95
101
|
|
|
96
102
|
return tools
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
type DraftStore,
|
|
3
|
+
type KeptScriptRef,
|
|
4
|
+
makeDraftStore,
|
|
5
|
+
} from '../../../authoring/index.ts'
|
|
2
6
|
import { type CaptureSession, startCapture } from '../../../cdp/capture.ts'
|
|
3
7
|
import { defineTool, type RegisteredTool } from '../../server.ts'
|
|
4
8
|
import type { AttachState } from './attach.ts'
|
|
@@ -15,7 +19,7 @@ export interface CaptureEntry {
|
|
|
15
19
|
drafts: DraftStore
|
|
16
20
|
}
|
|
17
21
|
|
|
18
|
-
export interface CaptureStore {
|
|
22
|
+
export interface CaptureStore extends KeptScriptRef {
|
|
19
23
|
sessions: Map<string, CaptureEntry>
|
|
20
24
|
activeTab?: string
|
|
21
25
|
}
|
|
@@ -27,6 +31,7 @@ export async function resetCaptures(captures: CaptureStore) {
|
|
|
27
31
|
|
|
28
32
|
captures.sessions.clear()
|
|
29
33
|
delete captures.activeTab
|
|
34
|
+
delete captures.keptScript
|
|
30
35
|
}
|
|
31
36
|
|
|
32
37
|
export function captureTools(
|
|
@@ -45,14 +50,15 @@ export function captureTools(
|
|
|
45
50
|
{
|
|
46
51
|
name: 'start_capture',
|
|
47
52
|
description:
|
|
48
|
-
'
|
|
49
|
-
+ '
|
|
50
|
-
+ '
|
|
53
|
+
'Starts recording network requests on a tab. Returns a captureId, '
|
|
54
|
+
+ 'the session handle that the authoring tools (`navigate`, '
|
|
55
|
+
+ '`propose_provider`, `run_proof`) take.',
|
|
51
56
|
inputSchema: {
|
|
52
57
|
type: 'object',
|
|
53
58
|
properties: { tabId: { type: 'string' } },
|
|
54
59
|
required: ['tabId'],
|
|
55
60
|
},
|
|
61
|
+
annotations: { openWorldHint: true },
|
|
56
62
|
},
|
|
57
63
|
async({ tabId }) => {
|
|
58
64
|
const attached = requireAttached()
|
|
@@ -70,13 +76,14 @@ export function captureTools(
|
|
|
70
76
|
{
|
|
71
77
|
name: 'stop_capture',
|
|
72
78
|
description:
|
|
73
|
-
'
|
|
74
|
-
+ '
|
|
79
|
+
'Stops recording on a capture. Captured requests stay queryable '
|
|
80
|
+
+ 'until `reset_session`.',
|
|
75
81
|
inputSchema: {
|
|
76
82
|
type: 'object',
|
|
77
83
|
properties: { captureId: { type: 'string' } },
|
|
78
84
|
required: ['captureId'],
|
|
79
85
|
},
|
|
86
|
+
annotations: { openWorldHint: false, idempotentHint: true },
|
|
80
87
|
},
|
|
81
88
|
async({ captureId }) => {
|
|
82
89
|
const entry = captures.sessions.get(captureId)
|
|
@@ -93,11 +100,11 @@ export function captureTools(
|
|
|
93
100
|
{
|
|
94
101
|
name: 'get_request',
|
|
95
102
|
description:
|
|
96
|
-
'
|
|
97
|
-
+ '
|
|
98
|
-
+ '
|
|
99
|
-
+ '
|
|
100
|
-
+ '
|
|
103
|
+
'Returns the full headers and bodies of one captured request, to '
|
|
104
|
+
+ 'inspect a candidate that `find_requests_containing` ranked. Unlike '
|
|
105
|
+
+ 'the other tools, headers are raw: cookie and authorization values '
|
|
106
|
+
+ 'are visible. Read them for diagnosis; do not repeat them to the '
|
|
107
|
+
+ 'developer or write them to a file.',
|
|
101
108
|
inputSchema: {
|
|
102
109
|
type: 'object',
|
|
103
110
|
properties: {
|
|
@@ -106,6 +113,7 @@ export function captureTools(
|
|
|
106
113
|
},
|
|
107
114
|
required: ['captureId', 'requestId'],
|
|
108
115
|
},
|
|
116
|
+
annotations: { readOnlyHint: true, openWorldHint: false },
|
|
109
117
|
},
|
|
110
118
|
async({ captureId, requestId }) => {
|
|
111
119
|
const entry = captures.sessions.get(captureId)
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import {
|
|
2
|
+
checkAttestor,
|
|
3
|
+
type CheckAttestorOptions,
|
|
4
|
+
} from '../../../proof/check-attestor.ts'
|
|
5
|
+
import { defineTool, type RegisteredTool } from '../../server.ts'
|
|
6
|
+
|
|
7
|
+
/** `check_attestor`: proves a public request to show whether the attestor
|
|
8
|
+
* works from this machine. `check` is injectable so tests need no network. */
|
|
9
|
+
export function checkAttestorTool(
|
|
10
|
+
check: (opts: CheckAttestorOptions) => ReturnType<typeof checkAttestor>
|
|
11
|
+
= checkAttestor,
|
|
12
|
+
): RegisteredTool {
|
|
13
|
+
return defineTool<{ attestorUrl?: string }>(
|
|
14
|
+
{
|
|
15
|
+
name: 'check_attestor',
|
|
16
|
+
description:
|
|
17
|
+
'Checks that the Reclaim attestor works from this machine by proving '
|
|
18
|
+
+ 'a public CoinGecko price request with a throwaway key. It uses no '
|
|
19
|
+
+ 'credential, provider, or logged-in site, and takes up to 45 '
|
|
20
|
+
+ 'seconds (about 8 when healthy). Call it once when you set up a '
|
|
21
|
+
+ 'new provider build, and after `run_proof` fails with a network '
|
|
22
|
+
+ 'error. Returns `{ ok, attestorUrl, durationMs, '
|
|
23
|
+
+ 'extractedParameters, error, errorKind }`. If `ok` is true, the '
|
|
24
|
+
+ 'attestor is fine and a failing proof points to the target site. '
|
|
25
|
+
+ 'If `errorKind` is `attestor-unreachable`, this machine cannot '
|
|
26
|
+
+ 'reach the attestor (network, VPN, firewall, or proxy): tell the '
|
|
27
|
+
+ 'developer. If it is `setup-failed`, the ZK file download failed '
|
|
28
|
+
+ 'before the attestor was contacted: tell the developer to check '
|
|
29
|
+
+ 'network access to the circuit download. If it is '
|
|
30
|
+
+ '`attestor-error`, the attestor rejected the claim: report '
|
|
31
|
+
+ '`error`.',
|
|
32
|
+
inputSchema: {
|
|
33
|
+
type: 'object',
|
|
34
|
+
properties: {
|
|
35
|
+
attestorUrl: {
|
|
36
|
+
type: 'string',
|
|
37
|
+
description:
|
|
38
|
+
'Attestor websocket URL. Set it only if the developer '
|
|
39
|
+
+ 'supplied one; the default is the public attestor.',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
annotations: { openWorldHint: true, readOnlyHint: true },
|
|
44
|
+
},
|
|
45
|
+
async({ attestorUrl }) => {
|
|
46
|
+
return check(attestorUrl ? { attestorUrl } : {})
|
|
47
|
+
},
|
|
48
|
+
)
|
|
49
|
+
}
|
|
@@ -11,10 +11,11 @@ export function listTabsTool(attachRef: {
|
|
|
11
11
|
{
|
|
12
12
|
name: 'list_tabs',
|
|
13
13
|
description:
|
|
14
|
-
'
|
|
15
|
-
+ 'and URL. Call it after attach_browser to pick the tabId
|
|
16
|
-
+ 'start_capture
|
|
14
|
+
'Returns the open tabs of the attached browser, each with its tabId, '
|
|
15
|
+
+ 'title, and URL. Call it after `attach_browser` to pick the tabId '
|
|
16
|
+
+ 'for `start_capture`.',
|
|
17
17
|
inputSchema: { type: 'object', properties: {} },
|
|
18
|
+
annotations: { readOnlyHint: true, openWorldHint: true },
|
|
18
19
|
},
|
|
19
20
|
async() => {
|
|
20
21
|
if(!attachRef.current) {
|
|
@@ -18,20 +18,19 @@ export function findTool(resolveBackend: ResolveBackend): RegisteredTool {
|
|
|
18
18
|
{
|
|
19
19
|
name: 'find_requests_containing',
|
|
20
20
|
description:
|
|
21
|
-
'
|
|
22
|
-
+ 'URL
|
|
23
|
-
+ '
|
|
24
|
-
+ '
|
|
25
|
-
+ '`value`
|
|
26
|
-
+ '
|
|
27
|
-
+ '
|
|
28
|
-
+ '
|
|
29
|
-
+ 'per-field (a redaction per part) rather than as one string. '
|
|
30
|
-
+ 'Server-side; bodies stay here.',
|
|
21
|
+
'Searches captured responses for any encoding of `value` (raw, '
|
|
22
|
+
+ 'URL-, JSON-, or HTML-escaped). Returns ranked candidates with the '
|
|
23
|
+
+ 'matched variant, score, and a short snippet, to locate the '
|
|
24
|
+
+ 'request that returns a data point. Also finds split matches: when '
|
|
25
|
+
+ '`value` has several words (for example, a full name) and a '
|
|
26
|
+
+ 'response carries each word in a separate field, the candidate has '
|
|
27
|
+
+ '`splitMatch: true`; prove those per field (one redaction per '
|
|
28
|
+
+ 'part). Response bodies stay server-side.',
|
|
31
29
|
inputSchema: objectSchema(
|
|
32
30
|
{ value: { type: 'string' }, limit: { type: 'number' } },
|
|
33
31
|
['value'],
|
|
34
32
|
),
|
|
33
|
+
annotations: { readOnlyHint: true, openWorldHint: false },
|
|
35
34
|
},
|
|
36
35
|
async(args) => {
|
|
37
36
|
const backend = resolveBackend(args)
|
|
@@ -20,6 +20,7 @@ export function howItWorksTool(oldMode: boolean): RegisteredTool {
|
|
|
20
20
|
+ 'backend. Call without a topic for the overview and index. Before an '
|
|
21
21
|
+ 'unfamiliar or sensitive step, request that topic. Prefer one topic; '
|
|
22
22
|
+ '`all` returns the much larger complete guide.',
|
|
23
|
+
annotations: { readOnlyHint: true, openWorldHint: false },
|
|
23
24
|
inputSchema: {
|
|
24
25
|
type: 'object',
|
|
25
26
|
properties: {
|
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
* attached container browser's built-in viewer behind a public URL, so someone
|
|
4
4
|
* who is not at this machine can watch it and optionally drive it.
|
|
5
5
|
*
|
|
6
|
-
* The server never runs, downloads or resolves cloudflared
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* The server never runs, downloads or resolves cloudflared. The developer
|
|
7
|
+
* chooses who runs it: they run it themselves (recommended) or approve the
|
|
8
|
+
* agent running it. Either way the `trycloudflare.com` URL it prints comes
|
|
9
|
+
* back as `publicUrl` to get the link to hand out.
|
|
9
10
|
*
|
|
10
11
|
* Scoped to `container` mode on purpose. A `builder`-mode browser already has
|
|
11
12
|
* a hosted live view at `attach_browser`'s `liveViewUrl`.
|
|
@@ -27,13 +28,19 @@ export function liveViewTools(
|
|
|
27
28
|
{
|
|
28
29
|
name: 'share_browser_view',
|
|
29
30
|
description:
|
|
30
|
-
'
|
|
31
|
-
+ '
|
|
32
|
-
+ '
|
|
33
|
-
+ '
|
|
34
|
-
+ '`
|
|
35
|
-
+ '
|
|
36
|
-
+ '
|
|
31
|
+
'Returns a link that lets someone who is not at this machine watch '
|
|
32
|
+
+ 'and drive the attached `container` browser, for example to sign '
|
|
33
|
+
+ 'in. This server opens no tunnel itself. Step 1: call with no '
|
|
34
|
+
+ 'arguments. It returns the local viewer URL, the `cloudflared` '
|
|
35
|
+
+ 'command, and two `choices`. Ask the developer to pick one before '
|
|
36
|
+
+ 'any tunnel runs: (a, recommended) they run `! cloudflared tunnel '
|
|
37
|
+
+ '--url http://localhost:<port>` themselves and paste the printed '
|
|
38
|
+
+ '`https://*.trycloudflare.com` URL; (b) they explicitly approve '
|
|
39
|
+
+ 'you running the command in the background. Never install '
|
|
40
|
+
+ '`cloudflared` without approval. Step 2: call again with the URL '
|
|
41
|
+
+ 'as `publicUrl` to get the link to relay. The link grants access '
|
|
42
|
+
+ 'to that browser session only, so share it only with the person '
|
|
43
|
+
+ 'who needs it. For `builder`, use the `liveViewUrl` from '
|
|
37
44
|
+ '`attach_browser`.',
|
|
38
45
|
inputSchema: {
|
|
39
46
|
type: 'object',
|
|
@@ -45,6 +52,7 @@ export function liveViewTools(
|
|
|
45
52
|
},
|
|
46
53
|
},
|
|
47
54
|
},
|
|
55
|
+
annotations: { openWorldHint: true, idempotentHint: true },
|
|
48
56
|
},
|
|
49
57
|
async(parsed) => {
|
|
50
58
|
const attached = attachRef.current
|
|
@@ -87,28 +95,47 @@ export function liveViewTools(
|
|
|
87
95
|
+ 'separate window is visible too.',
|
|
88
96
|
'Opening it on a phone lays the page out for that phone, with '
|
|
89
97
|
+ 'touch, pinch-zoom and the soft keyboard.',
|
|
90
|
-
'When they are done, stop the cloudflared process
|
|
91
|
-
+ '
|
|
98
|
+
'When they are done, stop the cloudflared process: yourself if '
|
|
99
|
+
+ 'you started it, otherwise ask the developer. The browser '
|
|
100
|
+
+ 'keeps running until `dispose_browser`.',
|
|
92
101
|
],
|
|
93
102
|
}
|
|
94
103
|
}
|
|
95
104
|
|
|
96
105
|
const localUrl = `http://localhost:${viewerPort}`
|
|
106
|
+
const command = `cloudflared tunnel --url ${localUrl}`
|
|
97
107
|
return {
|
|
98
108
|
localViewerUrl: ensureLiveViewUrl(localUrl),
|
|
99
109
|
port: viewerPort,
|
|
100
|
-
command
|
|
110
|
+
command,
|
|
111
|
+
choices: [
|
|
112
|
+
{
|
|
113
|
+
id: 'developer-runs',
|
|
114
|
+
recommended: true,
|
|
115
|
+
action: `Run \`! ${command}\` in the prompt, then paste the `
|
|
116
|
+
+ 'https://*.trycloudflare.com URL it prints.',
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
id: 'agent-runs',
|
|
120
|
+
recommended: false,
|
|
121
|
+
action: 'Approve the agent to run the command in the '
|
|
122
|
+
+ 'background and read the URL from its output.',
|
|
123
|
+
},
|
|
124
|
+
],
|
|
101
125
|
_notes: [
|
|
102
|
-
'
|
|
103
|
-
+ '
|
|
104
|
-
|
|
105
|
-
+ '
|
|
126
|
+
'Ask the developer to choose before any tunnel runs. Do not run '
|
|
127
|
+
+ '`command` until they pick `agent-runs`.',
|
|
128
|
+
'If they pick `developer-runs`, wait for the pasted URL. If they '
|
|
129
|
+
+ 'pick `agent-runs`, run `command` in a background process and '
|
|
130
|
+
+ 'read its output for a line containing '
|
|
131
|
+
+ '`https://<words>.trycloudflare.com`.',
|
|
132
|
+
'If `cloudflared` is not installed, tell the developer and ask '
|
|
133
|
+
+ 'them to install it '
|
|
134
|
+
+ '(https://developers.cloudflare.com/cloudflare-one/'
|
|
135
|
+
+ 'connections/connect-networks/downloads/). Never install it '
|
|
106
136
|
+ 'without their approval.',
|
|
107
|
-
'
|
|
108
|
-
+ '
|
|
109
|
-
'Call share_browser_view again with that value as `publicUrl` '
|
|
110
|
-
+ 'to get the link to relay. Never guess or reconstruct the '
|
|
111
|
-
+ 'hostname.',
|
|
137
|
+
'Call share_browser_view again with the URL as `publicUrl` to get '
|
|
138
|
+
+ 'the link to relay. Never guess or reconstruct the hostname.',
|
|
112
139
|
'Expose only this port. Never tunnel the browser\'s CDP port.',
|
|
113
140
|
],
|
|
114
141
|
}
|
|
@@ -31,17 +31,12 @@ export function podProofTools(
|
|
|
31
31
|
{
|
|
32
32
|
name: 'run_proof_via_pod',
|
|
33
33
|
description:
|
|
34
|
-
'
|
|
35
|
-
+ '(/reclaim/prove) instead of the local attestor SDK
|
|
36
|
-
+ '
|
|
37
|
-
+ '
|
|
38
|
-
+ '
|
|
39
|
-
+ '
|
|
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.',
|
|
34
|
+
'Proves the drafted recipe through the remote browser pod\'s own '
|
|
35
|
+
+ 'TEE (/reclaim/prove) instead of the local attestor SDK. Use it '
|
|
36
|
+
+ 'instead of `run_proof` when the attach mode is "builder": the '
|
|
37
|
+
+ 'proof then reaches the target from the browser\'s own exit IP and '
|
|
38
|
+
+ 'country. Needs no `ownerAddress`; the pod signs with its own TEE '
|
|
39
|
+
+ 'key.',
|
|
45
40
|
inputSchema: {
|
|
46
41
|
type: 'object',
|
|
47
42
|
properties: {
|
|
@@ -50,6 +45,7 @@ export function podProofTools(
|
|
|
50
45
|
},
|
|
51
46
|
required: ['captureId', 'draftId'],
|
|
52
47
|
},
|
|
48
|
+
annotations: { openWorldHint: true, destructiveHint: false },
|
|
53
49
|
},
|
|
54
50
|
async({ captureId, draftId }) => {
|
|
55
51
|
const apiUrl = attachRef.current?.apiUrl
|