@reclaimprotocol/agent 0.1.1-dev.1 → 0.1.2

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 (232) hide show
  1. package/README.md +1 -1
  2. package/lib/cdp/capture-engine.d.ts +66 -0
  3. package/lib/cdp/capture-engine.js +153 -0
  4. package/lib/cdp/capture.d.ts +9 -20
  5. package/lib/cdp/capture.js +14 -138
  6. package/lib/cdp/index.d.ts +3 -0
  7. package/lib/cdp/index.js +6 -0
  8. package/lib/cdp/launcher.js +4 -3
  9. package/lib/config/store.d.ts +7 -6
  10. package/lib/config/store.js +2 -2
  11. package/lib/consts.d.ts +68 -0
  12. package/lib/consts.js +134 -0
  13. package/lib/index.d.ts +2 -2
  14. package/lib/index.js +1 -1
  15. package/lib/logger.js +2 -1
  16. package/lib/mcp/api/operations.gen.d.ts +100 -48
  17. package/lib/mcp/api/operations.gen.js +1129 -194
  18. package/lib/mcp/api/to-zod.d.ts +24 -0
  19. package/lib/mcp/api/to-zod.js +94 -0
  20. package/lib/mcp/api/tools.js +1 -1
  21. package/lib/mcp/credentials/authenticate.d.ts +3 -0
  22. package/lib/mcp/{tools/credentials → credentials}/authenticate.js +3 -3
  23. package/lib/mcp/credentials/build.d.ts +5 -0
  24. package/lib/mcp/credentials/build.js +18 -0
  25. package/lib/mcp/{tools/credentials → credentials}/cache.d.ts +9 -9
  26. package/lib/mcp/{tools/credentials → credentials}/cache.js +36 -19
  27. package/lib/mcp/credentials/import.d.ts +2 -0
  28. package/lib/mcp/{tools/credentials → credentials}/import.js +2 -2
  29. package/lib/mcp/credentials/issue.d.ts +2 -0
  30. package/lib/mcp/{tools/credentials → credentials}/issue.js +4 -4
  31. package/lib/mcp/credentials/keypair.d.ts +17 -0
  32. package/lib/mcp/credentials/keypair.js +48 -0
  33. package/lib/mcp/credentials/link.d.ts +3 -0
  34. package/lib/mcp/credentials/link.js +107 -0
  35. package/lib/mcp/{tools/credentials → credentials}/list-cached.d.ts +1 -1
  36. package/lib/mcp/{tools/credentials → credentials}/list-cached.js +5 -5
  37. package/lib/mcp/credentials/owner-key.d.ts +23 -0
  38. package/lib/mcp/credentials/owner-key.js +58 -0
  39. package/lib/mcp/credentials/paths.d.ts +12 -0
  40. package/lib/mcp/credentials/paths.js +35 -0
  41. package/lib/mcp/credentials/poll.d.ts +27 -0
  42. package/lib/mcp/credentials/poll.js +61 -0
  43. package/lib/mcp/{tools/credentials → credentials}/resolve-owner-key.d.ts +1 -1
  44. package/lib/mcp/{tools/credentials → credentials}/resolve-owner-key.js +2 -2
  45. package/lib/mcp/credentials/session-cache.d.ts +14 -0
  46. package/lib/mcp/credentials/session-cache.js +42 -0
  47. package/lib/mcp/{tools/credentials → credentials}/status.d.ts +1 -1
  48. package/lib/mcp/credentials/status.js +76 -0
  49. package/lib/mcp/instructions.d.ts +1 -0
  50. package/lib/mcp/instructions.js +11 -0
  51. package/lib/mcp/register.d.ts +38 -0
  52. package/lib/mcp/register.js +80 -0
  53. package/lib/mcp/server.d.ts +2 -8
  54. package/lib/mcp/server.js +3 -33
  55. package/lib/mcp/start.js +17 -11
  56. package/lib/mcp/tools/agent/build.d.ts +5 -9
  57. package/lib/mcp/tools/agent/build.js +7 -24
  58. package/lib/mcp/tools/agent/index.d.ts +2 -0
  59. package/lib/mcp/tools/agent/index.js +3 -0
  60. package/lib/mcp/tools/agent/proof.js +3 -7
  61. package/lib/mcp/tools/agent/propose.js +13 -2
  62. package/lib/mcp/tools/agent/publish.js +172 -75
  63. package/lib/mcp/tools/agent/replay.js +0 -5
  64. package/lib/mcp/tools/analyze.d.ts +3 -0
  65. package/lib/mcp/tools/analyze.js +26 -0
  66. package/lib/mcp/tools/attach.d.ts +11 -0
  67. package/lib/mcp/tools/attach.js +72 -0
  68. package/lib/mcp/tools/authenticate/authenticate.js +107 -0
  69. package/lib/mcp/tools/authenticate/build.d.ts +15 -0
  70. package/lib/mcp/tools/authenticate/build.js +28 -0
  71. package/lib/mcp/tools/authenticate/decrypt-key.d.ts +19 -0
  72. package/lib/mcp/tools/authenticate/decrypt-key.js +46 -0
  73. package/lib/mcp/tools/authenticate/eth-key.d.ts +31 -0
  74. package/lib/mcp/tools/authenticate/eth-key.js +116 -0
  75. package/lib/mcp/tools/authenticate/import.js +57 -0
  76. package/lib/mcp/tools/authenticate/index.d.ts +2 -0
  77. package/lib/mcp/tools/authenticate/index.js +4 -0
  78. package/lib/mcp/tools/authenticate/issue.js +42 -0
  79. package/lib/mcp/tools/authenticate/resolve-owner-key.d.ts +13 -0
  80. package/lib/mcp/tools/authenticate/resolve-owner-key.js +53 -0
  81. package/lib/mcp/tools/capture.d.ts +10 -0
  82. package/lib/mcp/tools/capture.js +142 -0
  83. package/lib/mcp/tools/eval.d.ts +5 -0
  84. package/lib/mcp/tools/eval.js +127 -0
  85. package/lib/mcp/tools/find.d.ts +3 -0
  86. package/lib/mcp/tools/find.js +60 -0
  87. package/lib/mcp/tools/index.d.ts +3 -0
  88. package/lib/mcp/tools/index.js +6 -0
  89. package/lib/mcp/tools/owner-key.d.ts +2 -0
  90. package/lib/mcp/tools/owner-key.js +63 -0
  91. package/lib/mcp/tools/proof.d.ts +3 -0
  92. package/lib/mcp/tools/proof.js +214 -0
  93. package/lib/mcp/tools/propose.d.ts +9 -0
  94. package/lib/mcp/tools/propose.js +75 -0
  95. package/lib/mcp/tools/publish.d.ts +3 -0
  96. package/lib/mcp/tools/publish.js +59 -0
  97. package/lib/mcp/tools/replay.d.ts +3 -0
  98. package/lib/mcp/tools/replay.js +46 -0
  99. package/lib/mcp/tools/session.d.ts +10 -0
  100. package/lib/mcp/tools/session.js +29 -0
  101. package/lib/mcp/tools/verification/build.d.ts +12 -0
  102. package/lib/mcp/tools/verification/build.js +14 -0
  103. package/lib/mcp/tools/verification/diagnose.d.ts +11 -0
  104. package/lib/mcp/tools/verification/diagnose.js +132 -0
  105. package/lib/mcp/tools/verification/index.d.ts +1 -0
  106. package/lib/mcp/tools/verification/index.js +2 -0
  107. package/lib/mcp/tools/verification/result.d.ts +11 -0
  108. package/lib/mcp/tools/verification/result.js +126 -0
  109. package/lib/mcp/verifications/build.d.ts +5 -0
  110. package/lib/mcp/verifications/build.js +14 -0
  111. package/lib/mcp/verifications/create.d.ts +3 -0
  112. package/lib/mcp/verifications/create.js +57 -0
  113. package/lib/mcp/verifications/find.d.ts +3 -0
  114. package/lib/mcp/verifications/find.js +37 -0
  115. package/lib/mcp/verifications/get.d.ts +3 -0
  116. package/lib/mcp/verifications/get.js +26 -0
  117. package/lib/mcp/verifications/update.d.ts +3 -0
  118. package/lib/mcp/verifications/update.js +78 -0
  119. package/lib/old/client.d.ts +3 -0
  120. package/lib/old/flag.d.ts +4 -1
  121. package/lib/old/flag.js +4 -3
  122. package/lib/old/identity.d.ts +0 -10
  123. package/lib/old/identity.js +8 -7
  124. package/lib/old/instructions.d.ts +0 -6
  125. package/lib/old/instructions.js +6 -24
  126. package/lib/old/login-cdp.d.ts +0 -3
  127. package/lib/old/login-cdp.js +2 -4
  128. package/lib/old/to-register.d.ts +3 -0
  129. package/lib/old/to-register.js +32 -7
  130. package/lib/old/tools/authenticate.js +2 -1
  131. package/lib/old/tools/publish.js +71 -10
  132. package/lib/paths.js +2 -2
  133. package/lib/proof/attestor.d.ts +33 -1
  134. package/lib/proof/attestor.js +67 -64
  135. package/lib/proof/index.d.ts +5 -0
  136. package/lib/proof/index.js +6 -0
  137. package/lib/proof/proof-core.d.ts +35 -0
  138. package/lib/proof/proof-core.js +84 -0
  139. package/lib/provider/index.d.ts +5 -0
  140. package/lib/provider/index.js +9 -0
  141. package/lib/provider/injection-doc.d.ts +1 -0
  142. package/lib/provider/injection-doc.js +17 -0
  143. package/lib/provider/match-redaction-warning.d.ts +25 -0
  144. package/lib/provider/match-redaction-warning.js +35 -0
  145. package/lib/provider/schema.d.ts +16 -0
  146. package/lib/provider/schema.js +11 -1
  147. package/lib/provider/to-version.d.ts +61 -12
  148. package/lib/provider/to-version.js +109 -24
  149. package/lib/provider/verification-checks.d.ts +12 -0
  150. package/lib/provider/verification-checks.js +30 -0
  151. package/lib/routes.gen.d.ts +271 -0
  152. package/lib/routes.gen.js +73 -0
  153. package/lib/types/openapi.gen.d.ts +3967 -0
  154. package/lib/types/openapi.gen.js +5 -0
  155. package/package.json +16 -7
  156. package/skill/SKILL.md +35 -14
  157. package/skill/builder-mode.md +13 -0
  158. package/skill/injection-api.md +42 -0
  159. package/skill/old-mode.md +15 -0
  160. package/src/cdp/capture-engine.ts +256 -0
  161. package/src/cdp/capture.ts +25 -185
  162. package/src/cdp/index.ts +6 -0
  163. package/src/cdp/launcher.ts +5 -4
  164. package/src/config/store.ts +7 -6
  165. package/src/consts.ts +164 -0
  166. package/src/index.ts +2 -4
  167. package/src/logger.ts +2 -1
  168. package/src/mcp/api/operations.gen.ts +1155 -194
  169. package/src/mcp/api/to-zod.ts +115 -0
  170. package/src/mcp/api/tools.ts +9 -3
  171. package/src/mcp/instructions.ts +15 -0
  172. package/src/mcp/server.ts +5 -50
  173. package/src/mcp/start.ts +27 -11
  174. package/src/mcp/tools/agent/build.ts +7 -27
  175. package/src/mcp/tools/agent/index.ts +4 -0
  176. package/src/mcp/tools/agent/proof.ts +3 -8
  177. package/src/mcp/tools/agent/propose.ts +13 -2
  178. package/src/mcp/tools/agent/publish.ts +218 -92
  179. package/src/mcp/tools/agent/replay.ts +0 -5
  180. package/src/mcp/tools/{credentials → authenticate}/authenticate.ts +9 -8
  181. package/src/mcp/tools/authenticate/build.ts +32 -0
  182. package/src/mcp/tools/authenticate/decrypt-key.ts +59 -0
  183. package/src/mcp/tools/authenticate/eth-key.ts +162 -0
  184. package/src/mcp/tools/authenticate/import.ts +73 -0
  185. package/src/mcp/tools/authenticate/index.ts +4 -0
  186. package/src/mcp/tools/authenticate/issue.ts +50 -0
  187. package/src/mcp/tools/authenticate/resolve-owner-key.ts +60 -0
  188. package/src/mcp/tools/index.ts +6 -0
  189. package/src/mcp/tools/verification/build.ts +16 -0
  190. package/src/mcp/tools/verification/index.ts +2 -0
  191. package/src/mcp/tools/verification/result.ts +154 -0
  192. package/src/old/client.ts +3 -0
  193. package/src/old/flag.ts +4 -3
  194. package/src/old/identity.ts +8 -7
  195. package/src/old/instructions.ts +10 -25
  196. package/src/old/login-cdp.ts +2 -5
  197. package/src/old/to-register.ts +58 -26
  198. package/src/old/tools/authenticate.ts +2 -1
  199. package/src/old/tools/publish.ts +92 -16
  200. package/src/paths.ts +2 -2
  201. package/src/proof/attestor.ts +114 -72
  202. package/src/proof/index.ts +21 -0
  203. package/src/proof/proof-core.ts +119 -0
  204. package/src/provider/index.ts +20 -0
  205. package/src/provider/injection-doc.ts +21 -0
  206. package/src/provider/match-redaction-warning.ts +53 -0
  207. package/src/provider/schema.ts +23 -0
  208. package/src/provider/to-version.ts +180 -33
  209. package/src/provider/verification-checks.ts +36 -0
  210. package/lib/mcp/tools/credentials/build.d.ts +0 -16
  211. package/lib/mcp/tools/credentials/build.js +0 -33
  212. package/lib/mcp/tools/credentials/status.js +0 -62
  213. package/src/mcp/tools/credentials/build.ts +0 -37
  214. package/src/mcp/tools/credentials/cache.ts +0 -161
  215. package/src/mcp/tools/credentials/env-file.ts +0 -101
  216. package/src/mcp/tools/credentials/import.ts +0 -72
  217. package/src/mcp/tools/credentials/issue.ts +0 -107
  218. package/src/mcp/tools/credentials/list-cached.ts +0 -66
  219. package/src/mcp/tools/credentials/register.ts +0 -49
  220. package/src/mcp/tools/credentials/resolve-owner-key.ts +0 -78
  221. package/src/mcp/tools/credentials/status.ts +0 -82
  222. package/src/types/openapi.ts +0 -7
  223. /package/lib/mcp/{tools/credentials → credentials}/env-file.d.ts +0 -0
  224. /package/lib/mcp/{tools/credentials → credentials}/env-file.js +0 -0
  225. /package/lib/mcp/{tools/credentials → credentials}/register.d.ts +0 -0
  226. /package/lib/mcp/{tools/credentials → credentials}/register.js +0 -0
  227. /package/lib/mcp/tools/{credentials → authenticate}/authenticate.d.ts +0 -0
  228. /package/lib/mcp/tools/{credentials → authenticate}/import.d.ts +0 -0
  229. /package/lib/mcp/tools/{credentials → authenticate}/issue.d.ts +0 -0
  230. /package/lib/mcp/tools/{credentials → authenticate}/session-cache.d.ts +0 -0
  231. /package/lib/mcp/tools/{credentials → authenticate}/session-cache.js +0 -0
  232. /package/src/mcp/tools/{credentials → authenticate}/session-cache.ts +0 -0
@@ -0,0 +1,73 @@
1
+ import { readFileSync } from 'node:fs'
2
+ import { findProjectRoot } from '../../../paths.ts'
3
+ import { defineTool, type RegisteredTool } from '../../server.ts'
4
+ import { writeEthKey } from './eth-key.ts'
5
+
6
+ export function importTool(): RegisteredTool {
7
+ return defineTool<{
8
+ privateKey?: string
9
+ keyFile?: string
10
+ projectDir?: string
11
+ }>(
12
+ {
13
+ name: 'import_credentials',
14
+ description:
15
+ 'Import an eth proof-owner key the dev already holds and persist it ' +
16
+ 'to the project `.env` as RECLAIM_PRIVATE_KEY=0x… (mode 0600; `.env` ' +
17
+ 'added to .gitignore). Provide EITHER `privateKey` (raw 0x-hex, 64 ' +
18
+ 'chars) OR `keyFile` (path to a file holding the raw 0x-hex key). ' +
19
+ 'The address is derived locally; the private key is never ' +
20
+ 'returned. This is a local signing key only (not registered ' +
21
+ 'with any server, ' +
22
+ 'unrelated to org auth or encryption).',
23
+ inputSchema: {
24
+ type: 'object',
25
+ properties: {
26
+ privateKey: {
27
+ type: 'string',
28
+ pattern: '^0x?[0-9a-fA-F]{64}$',
29
+ description:
30
+ 'Raw Ethereum private key, 0x-prefixed hex (64 hex chars).',
31
+ },
32
+ keyFile: {
33
+ type: 'string',
34
+ description:
35
+ 'Path to a file containing the raw 0x-hex private key ' +
36
+ '(absolute or project-relative).',
37
+ },
38
+ projectDir: {
39
+ type: 'string',
40
+ description:
41
+ 'Project directory whose `.env` the key is written to. ' +
42
+ 'Defaults to the closest ancestor of cwd containing .git or ' +
43
+ 'package.json.',
44
+ },
45
+ },
46
+ },
47
+ },
48
+ async(args) => {
49
+ if(!args.privateKey && !args.keyFile) {
50
+ throw new Error('Provide either `privateKey` (0x-hex) or `keyFile`.')
51
+ }
52
+
53
+ if(args.privateKey && args.keyFile) {
54
+ throw new Error('Provide only one of `privateKey` or `keyFile`.')
55
+ }
56
+
57
+ const projectDir = findProjectRoot(args.projectDir || process.cwd())
58
+ const privateKeyHex = args.keyFile
59
+ ? readFileSync(args.keyFile, 'utf8')
60
+ : args.privateKey!
61
+ const { path, address } = writeEthKey(privateKeyHex, projectDir)
62
+
63
+ return {
64
+ address,
65
+ path,
66
+ note:
67
+ 'Eth proof-owner key written to .env as RECLAIM_PRIVATE_KEY ' +
68
+ '(mode 0600). resolve_owner_key resolves it from .env. Keep .env ' +
69
+ 'secret — it has been added to .gitignore.',
70
+ }
71
+ },
72
+ )
73
+ }
@@ -0,0 +1,4 @@
1
+ // Barrel for the credential tool group: local eth proof-owner key (env/PEM)
2
+ // and the org-token-authenticated builder tools. Import from here.
3
+ export { buildCredentialTools, buildLocalCredentialTools } from './build.ts'
4
+ export { readSession } from './session-cache.ts'
@@ -0,0 +1,50 @@
1
+ import { generateKeypair } from '@reclaimprotocol/client'
2
+ import { findProjectRoot } from '../../../paths.ts'
3
+ import { defineTool, type RegisteredTool } from '../../server.ts'
4
+ import { writeEthKey } from './eth-key.ts'
5
+
6
+ export function issueTool(): RegisteredTool {
7
+ return defineTool<{ projectDir?: string }>(
8
+ {
9
+ name: 'issue_credentials',
10
+ description:
11
+ 'Generate a fresh secp256k1 eth proof-owner key-pair (the key ' +
12
+ 'that signs local claim creation) and write the raw private key to ' +
13
+ 'the project `.env` as RECLAIM_PRIVATE_KEY=0x… (mode 0600; `.env` ' +
14
+ 'added to .gitignore). This is a LOCAL signing key only — it is NOT ' +
15
+ 'registered with any server and is unrelated to org auth (the org ' +
16
+ 'secret) or encryption (the eth decrypt key). ALWAYS confirm with ' +
17
+ 'the dev before generating a new key. After writing, run_proof picks ' +
18
+ 'it up automatically via resolve_owner_key. The private key is never ' +
19
+ 'returned in the response.',
20
+ inputSchema: {
21
+ type: 'object',
22
+ properties: {
23
+ projectDir: {
24
+ type: 'string',
25
+ description:
26
+ 'Project directory whose `.env` the key is written to. ' +
27
+ 'Defaults to the closest ancestor of cwd containing .git or ' +
28
+ 'package.json.',
29
+ },
30
+ },
31
+ },
32
+ },
33
+ async(args) => {
34
+ const projectDir = findProjectRoot(args.projectDir || process.cwd())
35
+ const keypair = generateKeypair()
36
+ const { path, address } = writeEthKey(keypair.privateKey, projectDir)
37
+
38
+ return {
39
+ address,
40
+ path,
41
+ note:
42
+ 'Eth proof-owner key written to .env as RECLAIM_PRIVATE_KEY ' +
43
+ '(mode 0600); the private key is NOT in this response on purpose. ' +
44
+ 'resolve_owner_key will now resolve it from .env (or set ' +
45
+ 'RECLAIM_PRIVATE_KEY in the environment to override). Keep .env ' +
46
+ 'secret — it has been added to .gitignore.',
47
+ }
48
+ },
49
+ )
50
+ }
@@ -0,0 +1,60 @@
1
+ import { join } from 'node:path'
2
+ import { findProjectRoot } from '../../../paths.ts'
3
+ import { defineTool, type RegisteredTool } from '../../server.ts'
4
+ import { ENV_FILE, resolveEthKey } from './eth-key.ts'
5
+
6
+ /**
7
+ * Decide which eth proof-owner key `run_proof` should sign with, BEFORE
8
+ * calling it. The key is a raw 0x-hex Ethereum private key, resolved (no
9
+ * `~/.reclaim` cache) from:
10
+ * 1. `RECLAIM_PRIVATE_KEY` in the MCP env
11
+ * 2. a `RECLAIM_PRIVATE_KEY=0x…` line in the project `.env`
12
+ * 3. a file at `RECLAIM_PRIVATE_KEY_FILE` holding the raw hex
13
+ * 4. none → ask the dev to generate (issue_credentials) or provide one
14
+ * (import_credentials), then call again.
15
+ * Never returns the private key — only the derived address.
16
+ */
17
+ export function resolveOwnerKeyTool(): RegisteredTool {
18
+ return defineTool<Record<string, never>>(
19
+ {
20
+ name: 'resolve_owner_key',
21
+ description:
22
+ 'Resolve which eth proof-owner key run_proof should sign with — ' +
23
+ 'call this BEFORE run_proof. Checks, in order: RECLAIM_PRIVATE_KEY ' +
24
+ 'in the MCP env, a RECLAIM_PRIVATE_KEY=0x… line in the project .env, ' +
25
+ 'then a file at RECLAIM_PRIVATE_KEY_FILE holding the raw hex. ' +
26
+ 'Returns { ready: true, address, source } when one is ' +
27
+ 'available — pass `address` to run_proof as `ownerAddress`. ' +
28
+ 'Returns { ready: false } ' +
29
+ 'when none exists: then ask the dev to generate one ' +
30
+ '(issue_credentials) or import one they already hold ' +
31
+ '(import_credentials, accepts 0x-hex or a key-file path), and call ' +
32
+ 'resolve_owner_key again. Never exposes the private key.',
33
+ inputSchema: { type: 'object', properties: {} },
34
+ },
35
+ async() => {
36
+ const projectDir = findProjectRoot(process.cwd())
37
+ const resolved = resolveEthKey(projectDir)
38
+ if(resolved) {
39
+ return {
40
+ ready: true,
41
+ address: resolved.address,
42
+ source: resolved.source,
43
+ ...(resolved.path ? { path: resolved.path } : {}),
44
+ }
45
+ }
46
+
47
+ return {
48
+ ready: false,
49
+ message:
50
+ 'No eth proof-owner key available — no RECLAIM_PRIVATE_KEY in the ' +
51
+ `env, no RECLAIM_PRIVATE_KEY in ${join(projectDir, ENV_FILE)}, and ` +
52
+ 'no RECLAIM_PRIVATE_KEY_FILE. Ask the dev to generate one via ' +
53
+ 'issue_credentials, or import one they already hold via ' +
54
+ 'import_credentials (0x-hex or a key-file path). Then call ' +
55
+ 'resolve_owner_key again and pass its address to run_proof as ' +
56
+ 'ownerAddress.',
57
+ }
58
+ },
59
+ )
60
+ }
@@ -0,0 +1,6 @@
1
+ // Top-level barrel for every MCP tool group. The MCP server (start.ts) and the
2
+ // package entry (src/index.ts) import tool builders from here, never from the
3
+ // individual tool files.
4
+ export * from './agent/index.ts'
5
+ export * from './authenticate/index.ts'
6
+ export * from './verification/index.ts'
@@ -0,0 +1,16 @@
1
+ import type { RegisteredTool } from '../../server.ts'
2
+ import { verificationResultTool } from './result.ts'
3
+
4
+ /**
5
+ * Builder-mode verification tools: higher-level orchestrations over the
6
+ * generated API surface. `get_verification_result` authenticates with the org
7
+ * token, checks status, pulls the stored payload, and decrypts it locally with
8
+ * the optional eth key — a flow the generated raw-API tools can't express
9
+ * (the decryption key never leaves the consumer). Diagnosis is left to the
10
+ * agent over the generated tools (`get_verification_session`,
11
+ * `list_verification_events`, `list_verification_deliveries`), whose
12
+ * descriptions carry the lifecycle and delivery semantics.
13
+ */
14
+ export function buildVerificationTools(): RegisteredTool[] {
15
+ return [verificationResultTool()]
16
+ }
@@ -0,0 +1,2 @@
1
+ // Barrel for the verification tool group (result retrieval + decryption).
2
+ export { buildVerificationTools } from './build.ts'
@@ -0,0 +1,154 @@
1
+ import {
2
+ createReclaim,
3
+ decryptCallback,
4
+ type DecryptionKey,
5
+ verifyResultFull,
6
+ } from '@reclaimprotocol/client'
7
+ import assert from 'node:assert'
8
+ import { apiUrl, orgSecret } from '../../../consts.ts'
9
+ import { defineTool, type RegisteredTool } from '../../server.ts'
10
+ import { resolveDecryptionKey } from '../authenticate/decrypt-key.ts'
11
+
12
+ /** Statuses that can carry a submitted (terminal) result. `expired`/`pending`
13
+ * never have one. */
14
+ const TERMINAL = new Set(['success', 'rejected', 'error'])
15
+
16
+ /**
17
+ * Resolve the org secret used to authenticate verification reads. Auth is a
18
+ * single per-org bearer secret (`rorg_…`), not an eth signature — read it from
19
+ * `RECLAIM_ORG_SECRET`.
20
+ */
21
+ function resolveOrgSecret(): string {
22
+ const secret = orgSecret()?.trim()
23
+ assert(
24
+ secret,
25
+ new Error(
26
+ 'RECLAIM_ORG_SECRET is not set. Verification reads authenticate with ' +
27
+ 'the org secret (rorg_…) — issue one from the dashboard ' +
28
+ '(POST /orgs/{orgId}/token) and export it as RECLAIM_ORG_SECRET.',
29
+ ),
30
+ )
31
+ return secret
32
+ }
33
+
34
+ /**
35
+ * `get_verification_result` — check a session's status and, once a result has
36
+ * been submitted, pull the stored payload(s) and verify locally. Auth is the
37
+ * org token; delivery is org-scoped. Each stored payload is either the
38
+ * plaintext signed JWS (when the org's encryption is off) or an ECIES
39
+ * ciphertext that we decrypt here with the optional eth key
40
+ * (`RECLAIM_DECRYPT_KEY` or the `reclaim-decrypt.key` hex file). The Builder
41
+ * only ever relays the payload — decryption, when needed, happens here.
42
+ */
43
+ export function verificationResultTool(): RegisteredTool {
44
+ return defineTool<{ sessionId: string }>(
45
+ {
46
+ name: 'get_verification_result',
47
+ description:
48
+ 'Check a verification session and return its result when ready. ' +
49
+ 'Authenticates with the org secret (RECLAIM_ORG_SECRET). Fetches the ' +
50
+ 'session status; if it is terminal and a result has been submitted, ' +
51
+ 'pulls the stored result(s) and verifies them locally. Encrypted ' +
52
+ 'deliveries (ECIES over secp256k1) are decrypted with your optional ' +
53
+ 'eth key (RECLAIM_DECRYPT_KEY or reclaim-decrypt.key); plaintext ' +
54
+ 'deliveries are read directly. Returns ' +
55
+ '`ready: false` while the session is still pending or no result has ' +
56
+ 'been delivered yet. Use list_verification_events for the full ' +
57
+ 'lifecycle log.',
58
+ inputSchema: {
59
+ type: 'object',
60
+ required: ['sessionId'],
61
+ properties: {
62
+ sessionId: {
63
+ type: 'string',
64
+ description:
65
+ 'The verification session id from create_verification_session.',
66
+ },
67
+ },
68
+ },
69
+ },
70
+ async(args) => {
71
+ const secret = resolveOrgSecret()
72
+ // Optional eth decryption key — absent ⇒ plaintext-only.
73
+ const decryptionKey: DecryptionKey | undefined =
74
+ await resolveDecryptionKey()
75
+
76
+ const reclaim = createReclaim({
77
+ baseUrl: apiUrl(),
78
+ orgSecret: secret,
79
+ })
80
+
81
+ const sessionRes = await reclaim.api('GetVerificationSession', {
82
+ params: { sessionId: args.sessionId },
83
+ })
84
+ const status = sessionRes.data.status
85
+
86
+ if(!TERMINAL.has(status)) {
87
+ return { sessionId: args.sessionId, status, ready: false }
88
+ }
89
+
90
+ const resultRes = await reclaim.api('GetVerificationResult', {
91
+ params: { sessionId: args.sessionId },
92
+ })
93
+ const { items } = resultRes.data
94
+
95
+ if(!items.length) {
96
+ return {
97
+ sessionId: args.sessionId,
98
+ status,
99
+ ready: false,
100
+ note: 'Session is terminal but no result has been submitted yet.',
101
+ }
102
+ }
103
+
104
+ // Each item's `payload` is a compact JWE (encrypted to the org's
105
+ // credential) or the plaintext signed JWS, as raw text. `decryptCallback`
106
+ // branches on the body shape; an encrypted delivery with no key throws
107
+ // a clear error, which we surface per-subscription rather than skip.
108
+ const results: unknown[] = []
109
+ const undecryptable: string[] = []
110
+ for(const item of items) {
111
+ let jws
112
+ try {
113
+ jws = await decryptCallback(decryptionKey, item.payload)
114
+ } catch(err) {
115
+ undecryptable.push(item.subscriptionId)
116
+ void err
117
+ continue
118
+ }
119
+
120
+ const outcome = await verifyResultFull(jws, {
121
+ expectedReclaimSessionId: args.sessionId,
122
+ })
123
+ results.push({
124
+ subscriptionId: item.subscriptionId,
125
+ valid: outcome.valid,
126
+ reason: outcome.reason,
127
+ payload: outcome.payload,
128
+ proofs: outcome.proofs,
129
+ })
130
+ }
131
+
132
+ if(!results.length) {
133
+ return {
134
+ sessionId: args.sessionId,
135
+ status,
136
+ ready: false,
137
+ note:
138
+ 'A result was stored, but no payload could be read — it is ' +
139
+ 'corrupt, or encrypted (ECIES) to a key this consumer does not ' +
140
+ 'hold. Set RECLAIM_DECRYPT_KEY (or reclaim-decrypt.key) to the ' +
141
+ 'eth private key matching the org keypair.',
142
+ }
143
+ }
144
+
145
+ return {
146
+ sessionId: args.sessionId,
147
+ status,
148
+ ready: true,
149
+ results,
150
+ ...(undecryptable.length ? { undecryptable } : {}),
151
+ }
152
+ },
153
+ )
154
+ }
package/src/old/client.ts CHANGED
@@ -25,6 +25,9 @@ export interface RegisterProviderBody {
25
25
  description?: string
26
26
  loginUrl: string
27
27
  geoLocation?: string
28
+ /** Provider-level flag on the old backend (defaults false there; the
29
+ * translator sends `true` to match the builder default). */
30
+ useProxy?: boolean
28
31
  providerType?: 'PRIVATE' | 'PUBLIC'
29
32
  requestData: unknown[]
30
33
  }
package/src/old/flag.ts CHANGED
@@ -7,7 +7,8 @@
7
7
  * EXPLICITLY by setting `USE_OLD_DEVTOOLS=false`. Anything else — unset,
8
8
  * empty, `true`, `1`, a typo — keeps old mode on, so a forgotten env var
9
9
  * can never silently route a developer at the half-built builder backend.
10
+ *
11
+ * The actual env read lives in `../consts.ts` (the single env-access module);
12
+ * this widely-imported path re-exports it for back-compat.
10
13
  */
11
- export function useOldDevtools(): boolean {
12
- return (process.env.USE_OLD_DEVTOOLS ?? '').trim().toLowerCase() !== 'false'
13
- }
14
+ export { useOldDevtools } from '../consts.ts'
@@ -1,5 +1,6 @@
1
1
  import { deriveFromPrivateKey } from '@reclaimprotocol/client'
2
2
  import { ConfigStore } from '../config/store.ts'
3
+ import { oldApiToken, oldEthUid, privateKey } from '../consts.ts'
3
4
  import type { OldIdentity } from './client.ts'
4
5
 
5
6
  /** Normalize an eth uid input to `eth:<lowercase-address>`. Accepts a bare
@@ -17,27 +18,27 @@ export function toEthUid(addressOrUid: string): OldIdentity {
17
18
  * 3. `RECLAIM_PRIVATE_KEY` — derive the eth uid from the local app key.
18
19
  * Returns undefined when none is set.
19
20
  */
20
- export function resolveIdentityFromEnv(): OldIdentity | undefined {
21
- const token = process.env.RECLAIM_OLD_API_TOKEN?.trim()
21
+ function resolveIdentityFromEnv(): OldIdentity | undefined {
22
+ const token = oldApiToken()?.trim()
22
23
  if(token) {
23
24
  return { kind: 'bearer', token }
24
25
  }
25
26
 
26
- const ethUid = process.env.RECLAIM_OLD_ETH_UID?.trim()
27
+ const ethUid = oldEthUid()?.trim()
27
28
  if(ethUid) {
28
29
  return toEthUid(ethUid)
29
30
  }
30
31
 
31
- const privateKey = process.env.RECLAIM_PRIVATE_KEY?.trim()
32
- if(privateKey) {
33
- return toEthUid(deriveFromPrivateKey(privateKey).address)
32
+ const key = privateKey()?.trim()
33
+ if(key) {
34
+ return toEthUid(deriveFromPrivateKey(key).address)
34
35
  }
35
36
 
36
37
  return undefined
37
38
  }
38
39
 
39
40
  /** Read the identity persisted by a prior `reclaim_authenticate` call. */
40
- export function loadPersistedIdentity(): OldIdentity | undefined {
41
+ function loadPersistedIdentity(): OldIdentity | undefined {
41
42
  return new ConfigStore().read()?.old_devtools
42
43
  }
43
44
 
@@ -2,29 +2,14 @@
2
2
  * MCP server instructions shown to the LLM when running in OLD-devtools mode
3
3
  * (`USE_OLD_DEVTOOLS` unset or not `false`). Describes the REDUCED tool
4
4
  * surface — there are no org/credential-link/review flows and no generated
5
- * API tools here. Must not mention disabled tools.
5
+ * API tools here. The prose lives in `skill/old-mode.md` (published via the
6
+ * `files` array); the path resolves identically from `src/old` (dev) and
7
+ * `lib/old` (published).
6
8
  */
7
- export const OLD_MODE_INSTRUCTIONS =
8
- 'This server is running against the LEGACY Reclaim devtools backend ' +
9
- '(temporary, while the new builder backend is in development), so its ' +
10
- 'capabilities are intentionally limited.\n\n' +
11
- 'Provider-authoring flow:\n' +
12
- '1. `reclaim_authenticate` — by default opens the dashboard in Chrome, ' +
13
- 'waits for you to sign in, captures the token automatically, and closes ' +
14
- 'the tab (or paste a `token` / pass an eth `ethAddress` to skip the ' +
15
- 'browser). Do this once before publishing or listing.\n' +
16
- '2. `attach_chrome` → `start_capture` → drive the page (`navigate`, ' +
17
- '`wait_for_page`) → inspect (`list_requests`, `get_request`, ' +
18
- '`find_requests_containing`).\n' +
19
- '3. `propose_provider` to draft a provider, `replay_request` to ' +
20
- 'pre-flight, `run_proof` to verify with the attestor. OPRF/`hash` ' +
21
- 'redactions are optional and supported.\n' +
22
- '4. `create_provider_version_from_capture` to publish. With NO ' +
23
- '`providerId` it REGISTERS A NEW provider (re-running creates a ' +
24
- 'duplicate); pass a ' +
25
- '`providerId` from `get_me_providers` to add a new version to an existing ' +
26
- 'provider instead.\n' +
27
- '5. `get_me_providers` lists the providers you own (the only ' +
28
- 'provider-listing tool available in this mode).\n\n' +
29
- 'Only GET/POST endpoints can be captured into providers here. There is no ' +
30
- 'organization, credential-linking, or public-review workflow in this mode.'
9
+ import { readFileSync } from 'node:fs'
10
+ import { fileURLToPath } from 'node:url'
11
+
12
+ export const OLD_MODE_INSTRUCTIONS = readFileSync(
13
+ fileURLToPath(new URL('../../skill/old-mode.md', import.meta.url)),
14
+ 'utf8',
15
+ ).trim()
@@ -5,10 +5,7 @@ import {
5
5
  waitForCdpReady,
6
6
  } from '../cdp/launcher.ts'
7
7
  import { ConfigStore } from '../config/store.ts'
8
-
9
- /** The devtools dashboard login page. Override per-call or via
10
- * `RECLAIM_OLD_LOGIN_URL`. */
11
- export const DEFAULT_LOGIN_URL = 'https://dev.reclaimprotocol.org'
8
+ import { DEFAULT_LOGIN_URL, oldLoginUrl } from '../consts.ts'
12
9
 
13
10
  /**
14
11
  * Read the Firebase ID token the dashboard persisted after login.
@@ -84,7 +81,7 @@ export async function captureFirebaseTokenViaCdp(opts: {
84
81
  pollMs?: number
85
82
  }): Promise<CdpLoginResult> {
86
83
  const loginUrl =
87
- opts.loginUrl || process.env.RECLAIM_OLD_LOGIN_URL || DEFAULT_LOGIN_URL
84
+ opts.loginUrl || oldLoginUrl() || DEFAULT_LOGIN_URL
88
85
  const timeoutMs = opts.timeoutMs ?? 180_000
89
86
  const pollMs = opts.pollMs ?? 1000
90
87
 
@@ -4,6 +4,13 @@ import type {
4
4
  UpdateProviderConfigBody,
5
5
  } from './client.ts'
6
6
 
7
+ /** Default web settings, mirroring the builder openapi defaults
8
+ * (`ProviderWebSettings.geoLocation`, `PortalClientOptions.useProxy`). The old
9
+ * backend accepts both: `geoLocation` lives on the providerConfig, `useProxy`
10
+ * is a Provider-level flag (register only). */
11
+ const DEFAULT_GEO_LOCATION = '{{DYNAMIC_GEO}}'
12
+ const DEFAULT_USE_PROXY = true
13
+
7
14
  /**
8
15
  * Translate a drafted `ReclaimProvider` (from `propose_provider`) into the
9
16
  * OLD devtools backend shapes. Deliberately a SEPARATE module from
@@ -22,7 +29,10 @@ import type {
22
29
  export interface OldProviderOpts {
23
30
  initialUrl: string
24
31
  description?: string
32
+ /** Defaults to `{{DYNAMIC_GEO}}` when omitted. */
25
33
  geoLocation?: string
34
+ /** Defaults to `true` when omitted. Register only (Provider-level flag). */
35
+ useProxy?: boolean
26
36
  providerType?: 'PRIVATE' | 'PUBLIC'
27
37
  }
28
38
 
@@ -63,6 +73,20 @@ function requestDataFromProvider(provider: ReclaimProvider): OldRequestData {
63
73
  )
64
74
  }
65
75
 
76
+ // The old backend has no dotted interpolation: consumer-supplied params
77
+ // must use the `{{context_<name>}}` form here, not the builder's
78
+ // `{{context.<name>}}`. Catch the mix-up at publish with a clear error
79
+ // instead of a template that silently never resolves.
80
+ const dotted = `${provider.url}\n${provider.body ?? ''}`
81
+ .match(/\{\{context\.[A-Za-z_][A-Za-z0-9_]*\}\}/)
82
+ if(dotted) {
83
+ throw new Error(
84
+ `Old devtools does not support ${dotted[0]} — rename ` +
85
+ 'consumer-supplied params to the {{context_<name>}} form ' +
86
+ 'for this backend.',
87
+ )
88
+ }
89
+
66
90
  const responseMatches: OldResponseMatch[] = provider.responseMatches.map(
67
91
  (m, i) => ({
68
92
  value: m.value,
@@ -72,29 +96,37 @@ function requestDataFromProvider(provider: ReclaimProvider): OldRequestData {
72
96
  }),
73
97
  )
74
98
 
75
- const responseRedactions: OldResponseRedaction[] = (
76
- provider.responseRedactions ?? []
77
- ).map((r, i) => {
78
- const out: OldResponseRedaction = { order: i }
79
- if(r.xPath !== undefined) {
80
- out.xPath = r.xPath
81
- }
99
+ // Old devtools wants `responseMatches` and `responseRedactions` as PARALLEL
100
+ // arrays — same shape the builder uses, so pass them through directly. We do
101
+ // NOT enforce any match/redaction count relationship here (and never pad —
102
+ // empty placeholder matches break proof generation): the author keeps full
103
+ // control. The publish tool surfaces a non-blocking warning when matches <
104
+ // redactions (see `matchRedactionWarnings`), and the dev decides.
105
+ const sourceRedactions = provider.responseRedactions ?? []
82
106
 
83
- if(r.jsonPath !== undefined) {
84
- out.jsonPath = r.jsonPath
85
- }
107
+ const responseRedactions: OldResponseRedaction[] = sourceRedactions.map(
108
+ (r, i) => {
109
+ const out: OldResponseRedaction = { order: i }
110
+ if(r.xPath !== undefined) {
111
+ out.xPath = r.xPath
112
+ }
86
113
 
87
- if(r.regex !== undefined) {
88
- out.regex = r.regex
89
- }
114
+ if(r.jsonPath !== undefined) {
115
+ out.jsonPath = r.jsonPath
116
+ }
90
117
 
91
- // OPRF redactions are supported — pass the mode through unchanged.
92
- if(r.hash !== undefined) {
93
- out.hash = r.hash
94
- }
118
+ if(r.regex !== undefined) {
119
+ out.regex = r.regex
120
+ }
95
121
 
96
- return out
97
- })
122
+ // OPRF redactions are supported — pass the mode through unchanged.
123
+ if(r.hash !== undefined) {
124
+ out.hash = r.hash
125
+ }
126
+
127
+ return out
128
+ },
129
+ )
98
130
 
99
131
  const requestData: OldRequestData = {
100
132
  url: provider.url,
@@ -127,16 +159,15 @@ export function providerToRegisterBody(
127
159
  name: provider.name,
128
160
  loginUrl: opts.initialUrl,
129
161
  providerType: opts.providerType ?? 'PRIVATE',
162
+ // Web-settings defaults mirror the builder openapi defaults.
163
+ geoLocation: opts.geoLocation ?? DEFAULT_GEO_LOCATION,
164
+ useProxy: opts.useProxy ?? DEFAULT_USE_PROXY,
130
165
  requestData: [requestDataFromProvider(provider)],
131
166
  }
132
167
  if(opts.description !== undefined) {
133
168
  body.description = opts.description
134
169
  }
135
170
 
136
- if(opts.geoLocation !== undefined) {
137
- body.geoLocation = opts.geoLocation
138
- }
139
-
140
171
  return body
141
172
  }
142
173
 
@@ -149,13 +180,14 @@ export function providerToConfigBody(
149
180
  version: string,
150
181
  versionInfo: string,
151
182
  ): UpdateProviderConfigBody {
183
+ // `useProxy` is a Provider-level flag on the old backend, not part of a
184
+ // version's providerConfig — so the config (new-version) path only carries
185
+ // `geoLocation`. It defaults the same way as register.
152
186
  const providerConfig: Record<string, unknown> = {
153
187
  loginUrl: opts.initialUrl,
188
+ geoLocation: opts.geoLocation ?? DEFAULT_GEO_LOCATION,
154
189
  requestData: [requestDataFromProvider(provider)],
155
190
  }
156
- if(opts.geoLocation !== undefined) {
157
- providerConfig.geoLocation = opts.geoLocation
158
- }
159
191
 
160
192
  return { providerConfig, version, versionInfo }
161
193
  }
@@ -1,3 +1,4 @@
1
+ import { agentDisabled } from '../../consts.ts'
1
2
  import { defineTool, type RegisteredTool } from '../../mcp/server.ts'
2
3
  import type { OldIdentity, ReclaimOldClient } from '../client.ts'
3
4
  import { persistIdentity, toEthUid } from '../identity.ts'
@@ -128,7 +129,7 @@ export function authenticateTool(client: ReclaimOldClient): RegisteredTool {
128
129
  }
129
130
 
130
131
  // CDP browser login (the default headline flow).
131
- if(process.env.RECLAIM_AGENT_DISABLED === '1') {
132
+ if(agentDisabled()) {
132
133
  throw new Error(
133
134
  'Browser login is unavailable (RECLAIM_AGENT_DISABLED=1). Pass a ' +
134
135
  '`token` (Firebase ID token) or `ethAddress` instead.',