@reclaimprotocol/agent 0.1.15 → 0.1.18
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/lib/authoring/index.d.ts +1 -1
- package/lib/authoring/index.js +1 -1
- package/lib/authoring/util.js +3 -0
- package/lib/config/store.d.ts +7 -0
- package/lib/consts.d.ts +15 -0
- package/lib/consts.js +35 -0
- package/lib/index.js +1 -1
- package/lib/mcp/api/operations.gen.d.ts +8 -16
- package/lib/mcp/api/operations.gen.js +428 -479
- package/lib/mcp/remap_errors.js +7 -14
- package/lib/mcp/start.js +10 -3
- package/lib/mcp/tools/agent/proof.js +3 -3
- package/lib/mcp/tools/agent/publish.js +33 -0
- package/lib/mcp/tools/authenticate/authenticate.js +178 -93
- package/lib/mcp/tools/authenticate/eth-key.js +2 -3
- package/lib/mcp/tools/index.d.ts +1 -0
- package/lib/mcp/tools/index.js +1 -0
- package/lib/mcp/tools/mode/index.d.ts +1 -0
- package/lib/mcp/tools/mode/index.js +3 -0
- package/lib/mcp/tools/mode/mode.d.ts +17 -0
- package/lib/mcp/tools/mode/mode.js +69 -0
- package/lib/old/to-register.d.ts +16 -8
- package/lib/old/to-register.js +29 -21
- package/lib/old/tools/publish.js +86 -8
- package/lib/provider/injection-doc.js +4 -3
- package/lib/provider/schema.d.ts +26 -1
- package/lib/provider/to-version.d.ts +19 -2
- package/lib/provider/to-version.js +22 -4
- package/lib/tools/registry.d.ts +6 -13
- package/lib/tools/registry.js +29 -0
- package/package.json +5 -8
- package/scripts/prepend-shebang.js +1 -1
- package/skill/builder-mode.md +2 -0
- package/skill/old-mode.md +3 -1
- package/src/authoring/index.ts +1 -0
- package/src/authoring/util.ts +3 -0
- package/src/cdp/launcher.ts +1 -1
- package/src/config/store.ts +8 -0
- package/src/consts.ts +44 -0
- package/src/index.ts +1 -1
- package/src/mcp/api/operations.gen.ts +430 -487
- package/src/mcp/remap_errors.ts +8 -15
- package/src/mcp/start.ts +11 -2
- package/src/mcp/tools/agent/proof.ts +3 -3
- package/src/mcp/tools/agent/publish.ts +42 -0
- package/src/mcp/tools/authenticate/authenticate.ts +238 -108
- package/src/mcp/tools/authenticate/eth-key.ts +7 -5
- package/src/mcp/tools/index.ts +1 -0
- package/src/mcp/tools/mode/index.ts +3 -0
- package/src/mcp/tools/mode/mode.ts +82 -0
- package/src/old/to-register.ts +50 -27
- package/src/old/tools/publish.ts +108 -8
- package/src/proof/debug-response-dump.ts +1 -1
- package/src/proof/proof-core.ts +1 -1
- package/src/proof/zk-files.ts +2 -2
- package/src/provider/dom-xpath.ts +1 -1
- package/src/provider/draft.ts +3 -3
- package/src/provider/injection-doc.ts +4 -3
- package/src/provider/schema.ts +27 -1
- package/src/provider/to-version.ts +45 -6
- package/src/tools/registry.ts +19 -0
- package/src/cli/args.ts +0 -20
- package/src/cli/commands.ts +0 -27
- package/src/cli.ts +0 -7
|
@@ -4,10 +4,12 @@ import type {
|
|
|
4
4
|
ProviderVersionRef,
|
|
5
5
|
} from '@reclaimprotocol/client/openapi'
|
|
6
6
|
import type {
|
|
7
|
+
DraftResponseMatch,
|
|
7
8
|
HttpMethod,
|
|
9
|
+
OldUrlType,
|
|
8
10
|
ReclaimProvider,
|
|
9
|
-
ResponseMatch,
|
|
10
11
|
ResponseRedaction,
|
|
12
|
+
WebCredentials,
|
|
11
13
|
} from './schema.ts'
|
|
12
14
|
import { DYNAMIC_GEO, normalizeGeoLocation } from './schema.ts'
|
|
13
15
|
|
|
@@ -24,8 +26,15 @@ export interface DraftRequest {
|
|
|
24
26
|
body?: string
|
|
25
27
|
writeRedactionMode?: ReclaimProvider['writeRedactionMode']
|
|
26
28
|
additionalClientOptions?: ReclaimProvider['additionalClientOptions']
|
|
27
|
-
responseMatches?:
|
|
29
|
+
responseMatches?: DraftResponseMatch[]
|
|
28
30
|
responseRedactions?: ResponseRedaction[]
|
|
31
|
+
/** How the verification client supplies cookies/auth on replay. Default
|
|
32
|
+
* `include` (both backends). */
|
|
33
|
+
credentials?: WebCredentials
|
|
34
|
+
/** Old-devtools `urlType` override. Ignored by THIS translator (the
|
|
35
|
+
* builder backend has no urlType) — read only by the old-devtools
|
|
36
|
+
* translator (`old/to-register.ts`). */
|
|
37
|
+
urlType?: OldUrlType
|
|
29
38
|
}
|
|
30
39
|
|
|
31
40
|
/** A request the page's injection script is allowed to fire, plus the
|
|
@@ -60,6 +69,16 @@ export interface CreateVersionOptions {
|
|
|
60
69
|
jsUserScripts?: string
|
|
61
70
|
/** Requests the injection script may fire, as `RequestSelectionTemplate`s. */
|
|
62
71
|
allowedJsRequests?: AllowedJsRequest[]
|
|
72
|
+
/** In-app interception options, mapped verbatim to
|
|
73
|
+
* `webSettings.clientOptions.inapp.interceptorOptions`. `interceptorType`
|
|
74
|
+
* is required by the backend whenever the object is present.
|
|
75
|
+
* `isDocumentRequestReplayEnabled` is the INVERSE of old-devtools'
|
|
76
|
+
* `disableRequestReplay` (default false). */
|
|
77
|
+
interceptorOptions?: {
|
|
78
|
+
interceptorType: 'HAWKEYE' | 'MSWJS' | 'CDP'
|
|
79
|
+
isDocumentRequestReplayEnabled?: boolean
|
|
80
|
+
interceptorSettings?: string
|
|
81
|
+
}
|
|
63
82
|
}
|
|
64
83
|
|
|
65
84
|
/**
|
|
@@ -139,14 +158,14 @@ export function providerToRequestSelection(
|
|
|
139
158
|
const responseMatches = (provider.responseMatches ?? []).map((match) => ({
|
|
140
159
|
type: match.type,
|
|
141
160
|
value: match.value,
|
|
142
|
-
isOptional: false,
|
|
161
|
+
isOptional: match.isOptional ?? false,
|
|
143
162
|
}))
|
|
144
163
|
const responseRedactions = provider.responseRedactions ?? []
|
|
145
164
|
|
|
146
165
|
return {
|
|
147
166
|
url: provider.url,
|
|
148
167
|
method: provider.method,
|
|
149
|
-
credentials: 'include',
|
|
168
|
+
credentials: provider.credentials ?? 'include',
|
|
150
169
|
...(provider.body ? { requestBodyTemplate: provider.body } : {}),
|
|
151
170
|
...(provider.writeRedactionMode
|
|
152
171
|
? { writeRedactionMode: provider.writeRedactionMode }
|
|
@@ -177,7 +196,9 @@ export function providerToCreateVersionRequest(
|
|
|
177
196
|
initialUrl: string,
|
|
178
197
|
opts: CreateVersionOptions = {},
|
|
179
198
|
): CreateProviderVersionRequest {
|
|
180
|
-
const {
|
|
199
|
+
const {
|
|
200
|
+
notes, version, jsUserScripts, allowedJsRequests, interceptorOptions,
|
|
201
|
+
} = opts
|
|
181
202
|
const requiredContext = deriveRequiredContext(providers, {
|
|
182
203
|
allowedJsRequests,
|
|
183
204
|
jsUserScripts,
|
|
@@ -189,6 +210,10 @@ export function providerToCreateVersionRequest(
|
|
|
189
210
|
...providerToRequestSelection(req),
|
|
190
211
|
multiple: req.multiple ?? true,
|
|
191
212
|
required: req.required ?? true,
|
|
213
|
+
templateParamsMode: req.templateParamsMode ?? 'separate',
|
|
214
|
+
...(req.templateParams?.length
|
|
215
|
+
? { templateParams: req.templateParams }
|
|
216
|
+
: {}),
|
|
192
217
|
}))
|
|
193
218
|
const script = jsUserScripts?.trim()
|
|
194
219
|
|
|
@@ -202,7 +227,21 @@ export function providerToCreateVersionRequest(
|
|
|
202
227
|
// apply schema defaults to request bodies.
|
|
203
228
|
webSettings: {
|
|
204
229
|
geoLocation: pickGeoLocation(providers),
|
|
205
|
-
clientOptions: {
|
|
230
|
+
clientOptions: {
|
|
231
|
+
portal: { useProxy: true },
|
|
232
|
+
...(interceptorOptions
|
|
233
|
+
? {
|
|
234
|
+
inapp: {
|
|
235
|
+
interceptorOptions: {
|
|
236
|
+
// openapi `default: false` — the generated type
|
|
237
|
+
// requires the key even when the author omits it.
|
|
238
|
+
isDocumentRequestReplayEnabled: false,
|
|
239
|
+
...interceptorOptions,
|
|
240
|
+
},
|
|
241
|
+
},
|
|
242
|
+
}
|
|
243
|
+
: {}),
|
|
244
|
+
},
|
|
206
245
|
// Only set when non-empty; an empty string would store a no-op script.
|
|
207
246
|
...(script ? { jsUserScripts: script } : {}),
|
|
208
247
|
},
|
package/src/tools/registry.ts
CHANGED
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
* glue (`registerToolList` onto an `McpServer`) stays in `mcp/server.ts`, which
|
|
12
12
|
* re-exports this primitive for the MCP-side tool files.
|
|
13
13
|
*/
|
|
14
|
+
import { type Boom, isBoom } from '@hapi/boom'
|
|
15
|
+
import type { ProblemDetails } from '@reclaimprotocol/client'
|
|
14
16
|
import type { JSONSchema } from 'zod/v4/core'
|
|
15
17
|
import { toZod } from '../mcp/api/to-zod.ts'
|
|
16
18
|
|
|
@@ -51,6 +53,20 @@ export function defineTool<TArgs>(
|
|
|
51
53
|
}
|
|
52
54
|
}
|
|
53
55
|
|
|
56
|
+
/**
|
|
57
|
+
* Render a tool-handler error as the text every host shows the LLM.
|
|
58
|
+
* Boom errors carrying an RFC 9457 problem include its `detail`; anything
|
|
59
|
+
* else falls back to the plain message.
|
|
60
|
+
*/
|
|
61
|
+
export function errorAsToolText(err: unknown): string {
|
|
62
|
+
if(isBoom(err) && err.output?.statusCode) {
|
|
63
|
+
const detail = (err as Boom<ProblemDetails>).data?.detail
|
|
64
|
+
return detail ? `${err.message}: ${detail}` : err.message
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return err instanceof Error ? err.message : String(err)
|
|
68
|
+
}
|
|
69
|
+
|
|
54
70
|
/**
|
|
55
71
|
* Adapt a tool to a host by WIDENING its input schema — add properties, mark
|
|
56
72
|
* some required, optionally override the description — without touching the
|
|
@@ -73,6 +89,9 @@ export function extendTool(
|
|
|
73
89
|
...(base.inputSchema.required ?? []),
|
|
74
90
|
...(extra.required ?? []),
|
|
75
91
|
]
|
|
92
|
+
// The merged `properties` spread carries the base's untyped property values,
|
|
93
|
+
// which don't structurally match ObjectSchema's strict per-property schema
|
|
94
|
+
// type — assert the merged shape.
|
|
76
95
|
const inputSchema = {
|
|
77
96
|
...base.inputSchema,
|
|
78
97
|
properties: {
|
package/src/cli/args.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { parseArgs as nodeParseArgs } from 'node:util'
|
|
2
|
-
|
|
3
|
-
// Placeholder. Final shape decided once the backend openapi stabilises and
|
|
4
|
-
// the CLI surface is fleshed out (see AGENTS.md → "CLI").
|
|
5
|
-
export function parseCliArgs(argv: string[]) {
|
|
6
|
-
return nodeParseArgs({
|
|
7
|
-
args: argv,
|
|
8
|
-
options: {
|
|
9
|
-
'base-url': { type: 'string' },
|
|
10
|
-
token: { type: 'string' },
|
|
11
|
-
param: { type: 'string', multiple: true },
|
|
12
|
-
query: { type: 'string', multiple: true },
|
|
13
|
-
body: { type: 'string' },
|
|
14
|
-
help: { type: 'boolean', short: 'h' },
|
|
15
|
-
version: { type: 'boolean', short: 'v' },
|
|
16
|
-
},
|
|
17
|
-
allowPositionals: true,
|
|
18
|
-
strict: false,
|
|
19
|
-
})
|
|
20
|
-
}
|
package/src/cli/commands.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { notImplemented } from '@hapi/boom'
|
|
2
|
-
import { DESCRIPTION, NAME, VERSION } from '../pkg.ts'
|
|
3
|
-
import { parseCliArgs } from './args.ts'
|
|
4
|
-
|
|
5
|
-
// Entry point for the `reclaim` bin. Placeholder until backend openapi
|
|
6
|
-
// finalises — `--version` and `--help` work; everything else throws.
|
|
7
|
-
export async function run(argv: string[]) {
|
|
8
|
-
const parsed = parseCliArgs(argv)
|
|
9
|
-
|
|
10
|
-
if(parsed.values['version']) {
|
|
11
|
-
process.stdout.write(`${NAME} ${VERSION}\n`)
|
|
12
|
-
return
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
if(parsed.values['help']) {
|
|
16
|
-
process.stdout.write(
|
|
17
|
-
`${NAME} ${VERSION}\n${DESCRIPTION}\n\n` +
|
|
18
|
-
'Usage: reclaim call <OperationId> ' +
|
|
19
|
-
'[--param k=v] [--query k=v] [--body <json>]\n',
|
|
20
|
-
)
|
|
21
|
-
return
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
throw notImplemented(
|
|
25
|
-
'reclaim CLI: pending @reclaimprotocol/app spec finalisation',
|
|
26
|
-
)
|
|
27
|
-
}
|