@reclaimprotocol/agent 0.1.5 → 0.1.7

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.
Files changed (117) hide show
  1. package/lib/authoring/backend.d.ts +0 -24
  2. package/lib/authoring/find.d.ts +3 -0
  3. package/lib/authoring/find.js +54 -0
  4. package/lib/authoring/index.d.ts +3 -3
  5. package/lib/authoring/index.js +4 -3
  6. package/lib/authoring/propose.d.ts +3 -0
  7. package/lib/authoring/propose.js +109 -0
  8. package/lib/authoring/replay.d.ts +10 -0
  9. package/lib/authoring/replay.js +34 -0
  10. package/lib/authoring/tools.d.ts +13 -6
  11. package/lib/authoring/tools.js +108 -293
  12. package/lib/authoring/util.d.ts +27 -0
  13. package/lib/authoring/util.js +21 -0
  14. package/lib/consts.d.ts +6 -1
  15. package/lib/consts.js +9 -2
  16. package/lib/mcp/server.d.ts +2 -41
  17. package/lib/mcp/server.js +6 -34
  18. package/lib/mcp/start.js +4 -2
  19. package/lib/mcp/tools/agent/analyze.js +3 -3
  20. package/lib/mcp/tools/agent/build.d.ts +4 -4
  21. package/lib/mcp/tools/agent/build.js +13 -15
  22. package/lib/mcp/tools/agent/capture.d.ts +13 -1
  23. package/lib/mcp/tools/agent/capture.js +18 -85
  24. package/lib/mcp/tools/agent/eval.d.ts +5 -2
  25. package/lib/mcp/tools/agent/eval.js +11 -121
  26. package/lib/mcp/tools/agent/find.d.ts +10 -3
  27. package/lib/mcp/tools/agent/find.js +25 -31
  28. package/lib/mcp/tools/agent/proof.d.ts +13 -3
  29. package/lib/mcp/tools/agent/proof.js +81 -132
  30. package/lib/mcp/tools/agent/propose.d.ts +10 -9
  31. package/lib/mcp/tools/agent/propose.js +87 -64
  32. package/lib/mcp/tools/agent/replay.d.ts +10 -3
  33. package/lib/mcp/tools/agent/replay.js +29 -36
  34. package/lib/mcp/tools/agent/session.d.ts +1 -3
  35. package/lib/mcp/tools/agent/session.js +5 -5
  36. package/lib/mcp/tools/agent/shared.d.ts +5 -3
  37. package/lib/mcp/tools/agent/shared.js +29 -19
  38. package/lib/old/client.d.ts +39 -0
  39. package/lib/old/client.js +18 -0
  40. package/lib/old/login-cdp.d.ts +24 -5
  41. package/lib/old/login-cdp.js +29 -15
  42. package/lib/old/sdk-client.d.ts +39 -0
  43. package/lib/old/sdk-client.js +85 -0
  44. package/lib/old/to-register.d.ts +69 -0
  45. package/lib/old/to-register.js +55 -2
  46. package/lib/old/tools/authenticate.js +3 -7
  47. package/lib/old/tools/build.d.ts +6 -1
  48. package/lib/old/tools/build.js +11 -1
  49. package/lib/old/tools/get-provider-info.d.ts +16 -0
  50. package/lib/old/tools/get-provider-info.js +73 -0
  51. package/lib/old/tools/get-version-config.d.ts +17 -0
  52. package/lib/old/tools/get-version-config.js +47 -0
  53. package/lib/old/tools/publish.js +208 -2
  54. package/lib/old/tools/update-provider-metadata.d.ts +16 -0
  55. package/lib/old/tools/update-provider-metadata.js +61 -0
  56. package/lib/proof/attestor.d.ts +6 -3
  57. package/lib/proof/attestor.js +10 -1
  58. package/lib/proof/debug-response-dump.d.ts +4 -0
  59. package/lib/proof/debug-response-dump.js +55 -0
  60. package/lib/proof/patch-domhandler.d.ts +1 -0
  61. package/lib/proof/patch-domhandler.js +59 -0
  62. package/lib/proof/zk-files.js +7 -6
  63. package/lib/provider/dom-xpath.d.ts +17 -0
  64. package/lib/provider/dom-xpath.js +187 -0
  65. package/lib/provider/draft.d.ts +30 -2
  66. package/lib/provider/draft.js +117 -28
  67. package/lib/provider/index.d.ts +4 -0
  68. package/lib/provider/index.js +7 -0
  69. package/lib/provider/injection-doc.js +6 -0
  70. package/lib/provider/matcher.d.ts +17 -20
  71. package/lib/provider/matcher.js +394 -280
  72. package/lib/provider/schema.d.ts +7 -5
  73. package/lib/tools/registry.d.ts +14 -0
  74. package/lib/tools/registry.js +32 -0
  75. package/package.json +9 -1
  76. package/skill/SKILL.builder.md +42 -23
  77. package/skill/SKILL.old.md +6 -2
  78. package/skill/builder-mode.md +1 -1
  79. package/skill/injection-api.md +117 -0
  80. package/src/authoring/backend.ts +98 -0
  81. package/src/authoring/index.ts +20 -0
  82. package/src/authoring/tools.ts +273 -0
  83. package/src/authoring/util.ts +42 -0
  84. package/src/consts.ts +15 -2
  85. package/src/mcp/server.ts +11 -78
  86. package/src/mcp/start.ts +4 -1
  87. package/src/mcp/tools/agent/analyze.ts +3 -3
  88. package/src/mcp/tools/agent/build.ts +13 -21
  89. package/src/mcp/tools/agent/capture.ts +31 -115
  90. package/src/mcp/tools/agent/eval.ts +19 -155
  91. package/src/mcp/tools/agent/find.ts +33 -36
  92. package/src/mcp/tools/agent/proof.ts +87 -160
  93. package/src/mcp/tools/agent/propose.ts +93 -85
  94. package/src/mcp/tools/agent/replay.ts +32 -42
  95. package/src/mcp/tools/agent/session.ts +4 -5
  96. package/src/mcp/tools/agent/shared.ts +152 -0
  97. package/src/old/client.ts +60 -0
  98. package/src/old/login-cdp.ts +29 -23
  99. package/src/old/sdk-client.ts +105 -0
  100. package/src/old/to-register.ts +102 -6
  101. package/src/old/tools/authenticate.ts +3 -11
  102. package/src/old/tools/build.ts +12 -0
  103. package/src/old/tools/get-provider-info.ts +91 -0
  104. package/src/old/tools/get-version-config.ts +56 -0
  105. package/src/old/tools/publish.ts +264 -1
  106. package/src/old/tools/update-provider-metadata.ts +72 -0
  107. package/src/proof/attestor.ts +16 -4
  108. package/src/proof/debug-response-dump.ts +70 -0
  109. package/src/proof/patch-domhandler.ts +68 -0
  110. package/src/proof/zk-files.ts +7 -6
  111. package/src/provider/dom-xpath.ts +225 -0
  112. package/src/provider/draft.ts +168 -35
  113. package/src/provider/index.ts +8 -0
  114. package/src/provider/injection-doc.ts +6 -0
  115. package/src/provider/matcher.ts +477 -357
  116. package/src/provider/schema.ts +7 -5
  117. package/src/tools/registry.ts +92 -0
@@ -25,11 +25,13 @@ export type ResponseRedaction =
25
25
  NonNullable<HttpParams['responseRedactions']>[number]
26
26
 
27
27
  /**
28
- * OPRF mode for hashed redactions. `oprf-raw` is what the dev-loop defaults
29
- * to when privacy is requested — the only variant that runs without external
30
- * deps (gnark for `oprf`, a TEE for `oprf-mpc`). It is the weakest of the
31
- * three (the attestor participates in hashing) and is meant to be swapped
32
- * out before production.
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
+ }