@reclaimprotocol/agent 0.1.4 → 0.1.6
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 +5 -5
- package/lib/authoring/backend.d.ts +71 -0
- package/lib/authoring/backend.js +24 -0
- package/lib/authoring/find.d.ts +3 -0
- package/lib/authoring/find.js +54 -0
- package/lib/authoring/index.d.ts +4 -0
- package/lib/authoring/index.js +6 -0
- package/lib/authoring/propose.d.ts +3 -0
- package/lib/authoring/propose.js +109 -0
- package/lib/authoring/replay.d.ts +10 -0
- package/lib/authoring/replay.js +34 -0
- package/lib/authoring/tools.d.ts +16 -0
- package/lib/authoring/tools.js +193 -0
- package/lib/authoring/util.d.ts +27 -0
- package/lib/authoring/util.js +21 -0
- package/lib/cdp/capture-engine.js +1 -1
- package/lib/consts.d.ts +6 -1
- package/lib/consts.js +9 -2
- package/lib/mcp/api/operations.gen.js +46 -18
- package/lib/mcp/server.d.ts +2 -25
- package/lib/mcp/server.js +4 -17
- package/lib/mcp/start.js +4 -2
- package/lib/mcp/tools/agent/analyze.js +3 -3
- package/lib/mcp/tools/agent/build.d.ts +4 -4
- package/lib/mcp/tools/agent/build.js +13 -15
- package/lib/mcp/tools/agent/capture.d.ts +13 -1
- package/lib/mcp/tools/agent/capture.js +18 -85
- package/lib/mcp/tools/agent/eval.d.ts +5 -2
- package/lib/mcp/tools/agent/eval.js +11 -121
- package/lib/mcp/tools/agent/find.d.ts +10 -3
- package/lib/mcp/tools/agent/find.js +25 -31
- package/lib/mcp/tools/agent/proof.d.ts +13 -3
- package/lib/mcp/tools/agent/proof.js +81 -132
- package/lib/mcp/tools/agent/propose.d.ts +10 -9
- package/lib/mcp/tools/agent/propose.js +87 -64
- package/lib/mcp/tools/agent/publish.js +2 -2
- package/lib/mcp/tools/agent/replay.d.ts +10 -3
- package/lib/mcp/tools/agent/replay.js +29 -36
- package/lib/mcp/tools/agent/session.d.ts +1 -3
- package/lib/mcp/tools/agent/session.js +5 -5
- package/lib/mcp/tools/agent/shared.d.ts +8 -0
- package/lib/mcp/tools/agent/shared.js +125 -0
- package/lib/old/client.d.ts +35 -0
- package/lib/old/client.js +18 -0
- package/lib/old/login-cdp.d.ts +24 -0
- package/lib/old/login-cdp.js +28 -3
- package/lib/old/sdk-client.d.ts +39 -0
- package/lib/old/sdk-client.js +85 -0
- package/lib/old/to-register.d.ts +69 -0
- package/lib/old/to-register.js +52 -2
- package/lib/old/tools/build.d.ts +6 -1
- package/lib/old/tools/build.js +11 -1
- package/lib/old/tools/get-provider-info.d.ts +16 -0
- package/lib/old/tools/get-provider-info.js +73 -0
- package/lib/old/tools/get-version-config.d.ts +17 -0
- package/lib/old/tools/get-version-config.js +47 -0
- package/lib/old/tools/publish.js +189 -2
- package/lib/old/tools/update-provider-metadata.d.ts +16 -0
- package/lib/old/tools/update-provider-metadata.js +61 -0
- package/lib/proof/attestor.d.ts +6 -3
- package/lib/proof/attestor.js +10 -1
- package/lib/proof/debug-response-dump.d.ts +4 -0
- package/lib/proof/debug-response-dump.js +55 -0
- package/lib/proof/patch-domhandler.d.ts +1 -0
- package/lib/proof/patch-domhandler.js +59 -0
- package/lib/proof/proof-core.d.ts +1 -1
- package/lib/proof/proof-core.js +1 -1
- package/lib/proof/zk-files.js +7 -6
- package/lib/provider/dom-xpath.d.ts +17 -0
- package/lib/provider/dom-xpath.js +187 -0
- package/lib/provider/draft.d.ts +30 -2
- package/lib/provider/draft.js +117 -28
- package/lib/provider/index.d.ts +4 -0
- package/lib/provider/index.js +7 -0
- package/lib/provider/injection-doc.js +6 -0
- package/lib/provider/matcher.d.ts +17 -20
- package/lib/provider/matcher.js +394 -280
- package/lib/provider/schema.d.ts +7 -5
- package/lib/tools/registry.d.ts +50 -0
- package/lib/tools/registry.js +49 -0
- package/package.json +9 -1
- package/skill/SKILL.builder.md +55 -32
- package/skill/SKILL.old.md +20 -12
- package/skill/builder-mode.md +1 -1
- package/skill/injection-api.md +117 -0
- package/src/authoring/backend.ts +98 -0
- package/src/authoring/index.ts +20 -0
- package/src/authoring/tools.ts +273 -0
- package/src/authoring/util.ts +42 -0
- package/src/cdp/capture-engine.ts +1 -1
- package/src/consts.ts +15 -2
- package/src/mcp/api/operations.gen.ts +46 -18
- package/src/mcp/server.ts +9 -39
- package/src/mcp/start.ts +4 -1
- package/src/mcp/tools/agent/analyze.ts +3 -3
- package/src/mcp/tools/agent/build.ts +13 -21
- package/src/mcp/tools/agent/capture.ts +31 -115
- package/src/mcp/tools/agent/eval.ts +19 -155
- package/src/mcp/tools/agent/find.ts +33 -36
- package/src/mcp/tools/agent/proof.ts +87 -160
- package/src/mcp/tools/agent/propose.ts +93 -85
- package/src/mcp/tools/agent/publish.ts +2 -2
- package/src/mcp/tools/agent/replay.ts +32 -42
- package/src/mcp/tools/agent/session.ts +4 -5
- package/src/mcp/tools/agent/shared.ts +152 -0
- package/src/old/client.ts +56 -0
- package/src/old/login-cdp.ts +28 -3
- package/src/old/sdk-client.ts +105 -0
- package/src/old/to-register.ts +98 -6
- package/src/old/tools/build.ts +12 -0
- package/src/old/tools/get-provider-info.ts +91 -0
- package/src/old/tools/get-version-config.ts +56 -0
- package/src/old/tools/publish.ts +244 -1
- package/src/old/tools/update-provider-metadata.ts +72 -0
- package/src/proof/attestor.ts +16 -4
- package/src/proof/debug-response-dump.ts +70 -0
- package/src/proof/patch-domhandler.ts +68 -0
- package/src/proof/proof-core.ts +1 -1
- package/src/proof/zk-files.ts +7 -6
- package/src/provider/dom-xpath.ts +225 -0
- package/src/provider/draft.ts +168 -35
- package/src/provider/index.ts +8 -0
- package/src/provider/injection-doc.ts +6 -0
- package/src/provider/matcher.ts +477 -357
- package/src/provider/schema.ts +7 -5
- package/src/tools/registry.ts +92 -0
package/src/provider/schema.ts
CHANGED
|
@@ -25,11 +25,13 @@ export type ResponseRedaction =
|
|
|
25
25
|
NonNullable<HttpParams['responseRedactions']>[number]
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
|
-
* OPRF mode for hashed redactions
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
28
|
+
* OPRF mode for hashed redactions:
|
|
29
|
+
* - `oprf-mpc` — TEE-based MPC OPRF. The default for the cloud/hosted flow: a
|
|
30
|
+
* TEE attestor accepts (and expects) this and REJECTS `oprf-raw`.
|
|
31
|
+
* - `oprf` — client-side ZK OPRF via gnark (needs the gnark deps).
|
|
32
|
+
* - `oprf-raw` — server-side OPRF, no external deps; the local dev-loop
|
|
33
|
+
* default (Windows / non-TEE). Weakest of the three (the attestor
|
|
34
|
+
* participates in hashing) and not accepted by a TEE attestor.
|
|
33
35
|
*/
|
|
34
36
|
export type OprfMode = NonNullable<ResponseRedaction['hash']>
|
|
35
37
|
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The ONE tool primitive for the agent. A tool is authored once with
|
|
3
|
+
* {@link defineTool} — `{ definition, handler }`, where the handler receives
|
|
4
|
+
* args already parsed + validated against the definition's JSON Schema (via
|
|
5
|
+
* zod), so the schema shown to the model and the validation applied to inbound
|
|
6
|
+
* args cannot drift.
|
|
7
|
+
*
|
|
8
|
+
* This lives outside `mcp/` on purpose: it depends only on zod (NOT the MCP
|
|
9
|
+
* SDK), so non-MCP consumers — the cloud authoring loop — can author and run
|
|
10
|
+
* these tools without pulling in `@modelcontextprotocol/sdk`. The MCP-specific
|
|
11
|
+
* glue (`registerToolList` onto an `McpServer`) stays in `mcp/server.ts`, which
|
|
12
|
+
* re-exports this primitive for the MCP-side tool files.
|
|
13
|
+
*/
|
|
14
|
+
import type { JSONSchema } from 'zod/v4/core'
|
|
15
|
+
import { toZod } from '../mcp/api/to-zod.ts'
|
|
16
|
+
|
|
17
|
+
export interface ToolDefinition {
|
|
18
|
+
name: string
|
|
19
|
+
description: string
|
|
20
|
+
inputSchema: JSONSchema.ObjectSchema
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface RegisteredTool {
|
|
24
|
+
definition: ToolDefinition
|
|
25
|
+
/**
|
|
26
|
+
* @param args Tool arguments (already zod-validated against the schema).
|
|
27
|
+
* @returns A JSON-stringifiable value to return to the LLM.
|
|
28
|
+
* @throws Any error; the host (MCP `registerToolList` / the cloud loop)
|
|
29
|
+
* catches it and surfaces it as an error tool-result.
|
|
30
|
+
*/
|
|
31
|
+
handler: (args: unknown) => Promise<unknown>
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Define a tool with a single inputSchema (JSON Schema) as the source of truth.
|
|
36
|
+
* The handler receives args already parsed and type-narrowed via a Zod schema
|
|
37
|
+
* derived from that same JSON Schema — so the description sent to the client
|
|
38
|
+
* and the validation applied to inbound args cannot drift.
|
|
39
|
+
*/
|
|
40
|
+
export function defineTool<TArgs>(
|
|
41
|
+
definition: ToolDefinition,
|
|
42
|
+
handler: (args: TArgs) => Promise<unknown>,
|
|
43
|
+
): RegisteredTool {
|
|
44
|
+
const schema = toZod(definition.inputSchema)
|
|
45
|
+
return {
|
|
46
|
+
definition,
|
|
47
|
+
handler: async(raw) => {
|
|
48
|
+
const args = schema.parse(raw) as TArgs
|
|
49
|
+
return await handler(args)
|
|
50
|
+
},
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Adapt a tool to a host by WIDENING its input schema — add properties, mark
|
|
56
|
+
* some required, optionally override the description — without touching the
|
|
57
|
+
* handler. A host maps whichever shared tools it needs through this (e.g. the
|
|
58
|
+
* MCP adds its `captureId` session handle + the credential-aware `run_proof`
|
|
59
|
+
* contract). Args parse loosely, so the extra fields flow through to the
|
|
60
|
+
* handler (its backend resolver reads them); the base tool stays untouched for
|
|
61
|
+
* hosts that don't need them.
|
|
62
|
+
*/
|
|
63
|
+
export function extendTool(
|
|
64
|
+
tool: RegisteredTool,
|
|
65
|
+
extra: {
|
|
66
|
+
description?: string
|
|
67
|
+
properties?: Record<string, unknown>
|
|
68
|
+
required?: string[]
|
|
69
|
+
},
|
|
70
|
+
): RegisteredTool {
|
|
71
|
+
const base = tool.definition
|
|
72
|
+
const required = [
|
|
73
|
+
...(base.inputSchema.required ?? []),
|
|
74
|
+
...(extra.required ?? []),
|
|
75
|
+
]
|
|
76
|
+
const inputSchema = {
|
|
77
|
+
...base.inputSchema,
|
|
78
|
+
properties: {
|
|
79
|
+
...base.inputSchema.properties,
|
|
80
|
+
...extra.properties,
|
|
81
|
+
},
|
|
82
|
+
...(required.length ? { required } : {}),
|
|
83
|
+
} as unknown as JSONSchema.ObjectSchema
|
|
84
|
+
return {
|
|
85
|
+
definition: {
|
|
86
|
+
name: base.name,
|
|
87
|
+
description: extra.description ?? base.description,
|
|
88
|
+
inputSchema,
|
|
89
|
+
},
|
|
90
|
+
handler: tool.handler,
|
|
91
|
+
}
|
|
92
|
+
}
|