@reclaimprotocol/agent 0.1.33 → 0.1.34

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 (88) hide show
  1. package/lib/authoring/backend.d.ts +13 -0
  2. package/lib/authoring/index.d.ts +1 -1
  3. package/lib/authoring/tools.js +78 -42
  4. package/lib/config/store.d.ts +10 -0
  5. package/lib/mcp/api/operations.gen.d.ts +238 -4
  6. package/lib/mcp/api/operations.gen.js +6433 -328
  7. package/lib/mcp/api/tools.js +21 -8
  8. package/lib/mcp/instructions.js +11 -11
  9. package/lib/mcp/server.d.ts +1 -1
  10. package/lib/mcp/server.js +3 -0
  11. package/lib/mcp/success-response.js +5 -1
  12. package/lib/mcp/tools/agent/analyze.js +5 -4
  13. package/lib/mcp/tools/agent/attach.js +11 -7
  14. package/lib/mcp/tools/agent/build.js +3 -1
  15. package/lib/mcp/tools/agent/capture.d.ts +2 -2
  16. package/lib/mcp/tools/agent/capture.js +15 -11
  17. package/lib/mcp/tools/agent/eval.js +4 -3
  18. package/lib/mcp/tools/agent/find.js +9 -10
  19. package/lib/mcp/tools/agent/how-it-works.js +1 -0
  20. package/lib/mcp/tools/agent/live-view.js +10 -7
  21. package/lib/mcp/tools/agent/pod-proof.js +7 -11
  22. package/lib/mcp/tools/agent/propose.js +4 -3
  23. package/lib/mcp/tools/agent/publish.d.ts +2 -1
  24. package/lib/mcp/tools/agent/publish.js +12 -6
  25. package/lib/mcp/tools/agent/replay.js +10 -7
  26. package/lib/mcp/tools/agent/session.js +16 -8
  27. package/lib/mcp/tools/agent/shared.js +3 -2
  28. package/lib/mcp/tools/agent/start-integration.d.ts +15 -0
  29. package/lib/mcp/tools/agent/start-integration.js +61 -0
  30. package/lib/mcp/tools/authenticate/authenticate.js +9 -11
  31. package/lib/mcp/tools/authenticate/build.js +2 -0
  32. package/lib/mcp/tools/authenticate/builder-access.js +1 -0
  33. package/lib/mcp/tools/authenticate/eth-key.d.ts +8 -0
  34. package/lib/mcp/tools/authenticate/eth-key.js +27 -15
  35. package/lib/mcp/tools/authenticate/import.js +18 -31
  36. package/lib/mcp/tools/authenticate/issue-org-token.d.ts +8 -0
  37. package/lib/mcp/tools/authenticate/issue-org-token.js +60 -0
  38. package/lib/mcp/tools/authenticate/issue.js +9 -9
  39. package/lib/mcp/tools/authenticate/org-key-store.d.ts +10 -0
  40. package/lib/mcp/tools/authenticate/org-key-store.js +23 -0
  41. package/lib/mcp/tools/authenticate/resolve-owner-key.js +10 -12
  42. package/lib/mcp/tools/mode/mode.js +2 -0
  43. package/lib/mcp/tools/verification/result.js +10 -7
  44. package/lib/tools/registry.d.ts +12 -0
  45. package/lib/tools/registry.js +1 -0
  46. package/package.json +2 -2
  47. package/skill/SKILL.builder.md +77 -74
  48. package/skill/SKILL.common.md +2 -1
  49. package/skill/builder-mode.md +135 -138
  50. package/skill/start-integration.md +49 -0
  51. package/skill/user-script.md +64 -0
  52. package/skill/verification-client-integration.md +28 -22
  53. package/src/authoring/backend.ts +15 -0
  54. package/src/authoring/index.ts +2 -0
  55. package/src/authoring/tools.ts +86 -42
  56. package/src/config/store.ts +11 -0
  57. package/src/mcp/api/operations.gen.ts +6477 -364
  58. package/src/mcp/api/tools.ts +21 -8
  59. package/src/mcp/instructions.ts +11 -11
  60. package/src/mcp/server.ts +4 -0
  61. package/src/mcp/success-response.ts +5 -1
  62. package/src/mcp/tools/agent/analyze.ts +5 -4
  63. package/src/mcp/tools/agent/attach.ts +11 -7
  64. package/src/mcp/tools/agent/build.ts +5 -1
  65. package/src/mcp/tools/agent/capture.ts +20 -12
  66. package/src/mcp/tools/agent/eval.ts +4 -3
  67. package/src/mcp/tools/agent/find.ts +9 -10
  68. package/src/mcp/tools/agent/how-it-works.ts +1 -0
  69. package/src/mcp/tools/agent/live-view.ts +10 -7
  70. package/src/mcp/tools/agent/pod-proof.ts +7 -11
  71. package/src/mcp/tools/agent/propose.ts +4 -3
  72. package/src/mcp/tools/agent/publish.ts +12 -4
  73. package/src/mcp/tools/agent/replay.ts +10 -7
  74. package/src/mcp/tools/agent/session.ts +16 -8
  75. package/src/mcp/tools/agent/shared.ts +7 -2
  76. package/src/mcp/tools/agent/start-integration.ts +83 -0
  77. package/src/mcp/tools/authenticate/authenticate.ts +9 -11
  78. package/src/mcp/tools/authenticate/build.ts +2 -0
  79. package/src/mcp/tools/authenticate/builder-access.ts +1 -0
  80. package/src/mcp/tools/authenticate/eth-key.ts +48 -18
  81. package/src/mcp/tools/authenticate/import.ts +21 -36
  82. package/src/mcp/tools/authenticate/issue-org-token.ts +84 -0
  83. package/src/mcp/tools/authenticate/issue.ts +9 -9
  84. package/src/mcp/tools/authenticate/org-key-store.ts +25 -0
  85. package/src/mcp/tools/authenticate/resolve-owner-key.ts +10 -12
  86. package/src/mcp/tools/mode/mode.ts +2 -0
  87. package/src/mcp/tools/verification/result.ts +10 -7
  88. package/src/tools/registry.ts +14 -0
@@ -0,0 +1,15 @@
1
+ import { type RegisteredTool } from '../../server.ts';
2
+ interface StartIntegrationArgs {
3
+ goal: string;
4
+ orgId?: string;
5
+ providerIds?: string[];
6
+ }
7
+ /**
8
+ * Returns the plan a coding agent follows to add Reclaim verification to the
9
+ * developer's app, from sign-in to a tested Verify button. The plan lives in
10
+ * `skill/start-integration.md`; this tool fills in the inputs.
11
+ */
12
+ export declare function startIntegrationTool(): RegisteredTool;
13
+ /** Fill the plan template. Exported for tests. */
14
+ export declare function renderStartIntegration(args: StartIntegrationArgs): string;
15
+ export {};
@@ -0,0 +1,61 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { fileURLToPath } from 'node:url';
3
+ import { defineTool } from "../../server.js";
4
+ /**
5
+ * Returns the plan a coding agent follows to add Reclaim verification to the
6
+ * developer's app, from sign-in to a tested Verify button. The plan lives in
7
+ * `skill/start-integration.md`; this tool fills in the inputs.
8
+ */
9
+ export function startIntegrationTool() {
10
+ return defineTool({
11
+ name: 'start_integration',
12
+ description: 'Returns a step-by-step plan for adding Reclaim verification to the '
13
+ + 'current codebase: sign in, build or choose a provider, then add the '
14
+ + 'session route, callback, and Verify button. Call it first when a '
15
+ + 'developer wants their users to prove something, and follow the '
16
+ + 'plan to the end. Changes nothing itself.',
17
+ inputSchema: {
18
+ type: 'object',
19
+ required: ['goal'],
20
+ properties: {
21
+ goal: {
22
+ type: 'string',
23
+ minLength: 1,
24
+ maxLength: 300,
25
+ description: 'What the developer\'s users prove, for example, "they have '
26
+ + 'a GitHub account with 100 followers".',
27
+ },
28
+ orgId: {
29
+ type: 'string',
30
+ format: 'uuid',
31
+ description: 'Organization to use. Omit to choose from the list.',
32
+ },
33
+ providerIds: {
34
+ type: 'array',
35
+ maxItems: 10,
36
+ items: { type: 'string' },
37
+ description: 'Existing provider IDs to use. Omit to build a new provider.',
38
+ },
39
+ },
40
+ },
41
+ annotations: { readOnlyHint: true, openWorldHint: false },
42
+ }, async (args) => renderStartIntegration(args));
43
+ }
44
+ /** Fill the plan template. Exported for tests. */
45
+ export function renderStartIntegration(args) {
46
+ const providerIds = args.providerIds?.length
47
+ ? args.providerIds.map((id) => `\`${id}\``).join(', ')
48
+ : undefined;
49
+ const values = {
50
+ goal: args.goal,
51
+ orgId: args.orgId,
52
+ providerIds,
53
+ };
54
+ const template = readFileSync(fileURLToPath(new URL('../../../../skill/start-integration.md', import.meta.url)), 'utf8');
55
+ return template
56
+ // Keep a conditional block only when its input was given (or not given).
57
+ .replace(/<!-- (if|ifnot):(\w+) -->\n([\s\S]*?)<!-- endif -->\n/g, (_, kind, name, body) => {
58
+ return (kind === 'if') === Boolean(values[name]) ? body : '';
59
+ })
60
+ .replace(/\{\{(\w+)\}\}/g, (_, name) => values[name] ?? '');
61
+ }
@@ -16,18 +16,16 @@ export function authenticateTool(client, name = 'reclaim_authenticate') {
16
16
  + 'get_me_providers; those need the separate old-devtools login, '
17
17
  + 'reclaim_authenticate. Check both with get_devtools_mode. '
18
18
  : '')
19
- + 'Authorize the CLI / MCP to make authenticated API calls. Opens '
20
- + 'the '
21
- + 'browser to the builder sign-in page (standard OAuth 2.0 ' +
22
- 'authorization-code + PKCE with a localhost redirect) and waits for ' +
23
- 'the user to sign in and approve. On success the access token is ' +
24
- 'cached in ~/.reclaim/config.json and activated for this session.\n\n' +
25
- 'Call with no arguments. This bearer token authenticates ' +
26
- 'dashboard/org-management calls (for example, list_orgs, or ' +
27
- 'issuing an org secret). Programmatic verification calls use a ' +
28
- 'separate org secret ' +
29
- '(rorg_…, set as RECLAIM_ORG_SECRET).',
19
+ + 'Signs the developer in to Builder. Opens the Builder sign-in page '
20
+ + 'in their browser (OAuth 2.0 authorization code with PKCE, '
21
+ + 'redirecting to a localhost port this server opens) and waits for '
22
+ + 'them to approve. Saves the access token in ~/.reclaim/config.json '
23
+ + 'with mode 0600 and uses it for this session; the token is never '
24
+ + 'returned. The token authorizes organization-management tools such '
25
+ + 'as `list_orgs`. Programmatic verification tools use a separate '
26
+ + 'organization key; see `issue_org_token`. Call with no arguments.',
30
27
  inputSchema: { type: 'object', properties: {} },
28
+ annotations: { openWorldHint: true, idempotentHint: true },
31
29
  }, async () => runOAuthLoopback(client));
32
30
  }
33
31
  const _customFetchForOauth = async (url, options) => {
@@ -1,6 +1,7 @@
1
1
  import { authenticateTool } from "./authenticate.js";
2
2
  import { importTool } from "./import.js";
3
3
  import { issueTool } from "./issue.js";
4
+ import { issueOrgTokenTool } from "./issue-org-token.js";
4
5
  import { resolveOwnerKeyTool } from "./resolve-owner-key.js";
5
6
  /**
6
7
  * Local-only key tools — no backend client needed. These manage the eth
@@ -23,6 +24,7 @@ export function buildLocalCredentialTools() {
23
24
  export function buildCredentialTools(client) {
24
25
  return [
25
26
  authenticateTool(client),
27
+ issueOrgTokenTool(client),
26
28
  ...buildLocalCredentialTools(),
27
29
  ];
28
30
  }
@@ -26,6 +26,7 @@ export function buildBuilderOrganizationTools(client) {
26
26
  cursor: { type: 'string', maxLength: 500 },
27
27
  },
28
28
  },
29
+ annotations: { readOnlyHint: true, openWorldHint: true },
29
30
  }, async ({ cursor }) => {
30
31
  const { data } = await client.call('ListOrgs', {
31
32
  query: { ...(cursor ? { cursor } : {}) },
@@ -19,6 +19,14 @@ export declare function normalizeEthHex(value: string): string;
19
19
  * ask for one (see `resolve_owner_key`).
20
20
  */
21
21
  export declare function resolveEthKey(projectDir?: string): ResolvedEthKey | undefined;
22
+ /** Append `entry` to the project `.gitignore` if not already present. */
23
+ export declare function ensureGitignored(projectDir: string, entry: string): void;
24
+ /**
25
+ * Set `name=value` in a dotenv file, replacing an existing line or appending
26
+ * one. Writes with mode 0600 and adds the file to the project `.gitignore`.
27
+ * `envFile` is relative to `projectDir`.
28
+ */
29
+ export declare function upsertEnvVar(projectDir: string, envFile: string, name: string, value: string): string;
22
30
  /**
23
31
  * Persist a raw eth private key to the project `.env` as
24
32
  * `RECLAIM_PRIVATE_KEY=0x…` (upsert; mode 0600; `.env` added to `.gitignore`).
@@ -16,8 +16,8 @@
16
16
  */
17
17
  import { deriveFromPrivateKey } from '@reclaimprotocol/client';
18
18
  import assert from 'node:assert';
19
- import { existsSync, readFileSync, writeFileSync } from 'node:fs';
20
- import { isAbsolute, join } from 'node:path';
19
+ import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync, } from 'node:fs';
20
+ import { dirname, isAbsolute, join, relative, resolve } from 'node:path';
21
21
  import { privateKey, privateKeyFile } from "../../../consts.js";
22
22
  import { findProjectRoot } from "../../../paths.js";
23
23
  const ENV_VAR = 'RECLAIM_PRIVATE_KEY';
@@ -80,7 +80,7 @@ export function resolveEthKey(projectDir = findProjectRoot(process.cwd())) {
80
80
  return undefined;
81
81
  }
82
82
  /** Append `entry` to the project `.gitignore` if not already present. */
83
- function ensureGitignored(projectDir, entry) {
83
+ export function ensureGitignored(projectDir, entry) {
84
84
  const path = join(projectDir, '.gitignore');
85
85
  const current = existsSync(path) ? readFileSync(path, 'utf8') : '';
86
86
  if (current.split('\n').some((l) => l.trim() === entry)) {
@@ -90,26 +90,38 @@ function ensureGitignored(projectDir, entry) {
90
90
  writeFileSync(path, current + prefix + entry + '\n');
91
91
  }
92
92
  /**
93
- * Persist a raw eth private key to the project `.env` as
94
- * `RECLAIM_PRIVATE_KEY=0x…` (upsert; mode 0600; `.env` added to `.gitignore`).
95
- * Used by `issue_credentials` (generate) and `import_credentials` (supplied
96
- * hex). Returns the derived address and the `.env` path.
93
+ * Set `name=value` in a dotenv file, replacing an existing line or appending
94
+ * one. Writes with mode 0600 and adds the file to the project `.gitignore`.
95
+ * `envFile` is relative to `projectDir`.
97
96
  */
98
- export function writeEthKey(privateKeyHex, projectDir = findProjectRoot(process.cwd())) {
99
- const hex = normalizeEthHex(privateKeyHex);
100
- const envPath = join(projectDir, ENV_FILE);
101
- const line = `${ENV_VAR}=${hex}`;
97
+ export function upsertEnvVar(projectDir, envFile, name, value) {
98
+ const envPath = resolve(projectDir, envFile);
99
+ const line = `${name}=${value}`;
102
100
  const existing = existsSync(envPath) ? readFileSync(envPath, 'utf8') : '';
103
- const re = new RegExp(`^\\s*${ENV_VAR}\\s*=.*$`, 'm');
101
+ const re = new RegExp(`^\\s*${name}\\s*=.*$`, 'm');
104
102
  let next;
105
103
  if (re.test(existing)) {
106
- next = existing.replace(re, line);
104
+ // A function replacer keeps `$` sequences in the value literal.
105
+ next = existing.replace(re, () => line);
107
106
  }
108
107
  else {
109
108
  const prefix = existing && !existing.endsWith('\n') ? '\n' : '';
110
109
  next = existing + prefix + line + '\n';
111
110
  }
111
+ mkdirSync(dirname(envPath), { recursive: true });
112
112
  writeFileSync(envPath, next, { mode: 0o600 });
113
- ensureGitignored(projectDir, ENV_FILE);
114
- return { path: envPath, address: deriveFromPrivateKey(hex).address };
113
+ chmodSync(envPath, 0o600);
114
+ ensureGitignored(projectDir, relative(projectDir, envPath));
115
+ return envPath;
116
+ }
117
+ /**
118
+ * Persist a raw eth private key to the project `.env` as
119
+ * `RECLAIM_PRIVATE_KEY=0x…` (upsert; mode 0600; `.env` added to `.gitignore`).
120
+ * Used by `issue_credentials` (generate) and `import_credentials` (supplied
121
+ * hex). Returns the derived address and the `.env` path.
122
+ */
123
+ export function writeEthKey(privateKeyHex, projectDir = findProjectRoot(process.cwd())) {
124
+ const hex = normalizeEthHex(privateKeyHex);
125
+ const path = upsertEnvVar(projectDir, ENV_FILE, ENV_VAR, hex);
126
+ return { path, address: deriveFromPrivateKey(hex).address };
115
127
  }
@@ -5,53 +5,40 @@ import { writeEthKey } from "./eth-key.js";
5
5
  export function importTool() {
6
6
  return defineTool({
7
7
  name: 'import_credentials',
8
- description: 'Import an eth proof-owner key the dev already holds and persist it ' +
9
- 'to the project `.env` as RECLAIM_PRIVATE_KEY=0x… (mode 0600; `.env` ' +
10
- 'added to .gitignore). Provide EITHER `privateKey` (raw 0x-hex, 64 ' +
11
- 'chars) OR `keyFile` (path to a file holding the raw 0x-hex key). ' +
12
- 'The address is derived locally; the private key is never ' +
13
- 'returned. This is a local signing key only (not registered ' +
14
- 'with any server, ' +
15
- 'unrelated to org auth or encryption).',
8
+ description: 'Imports an eth proof-owner key from a file the developer already '
9
+ + 'holds. Reads the raw 0x-hex key from `keyFile` and writes it to '
10
+ + 'the project `.env` as RECLAIM_PRIVATE_KEY (mode 0600; `.env` '
11
+ + 'added to .gitignore). Returns the derived address and the `.env` '
12
+ + 'path; never the key. The key is a local signing key only: it is '
13
+ + 'not registered with any server and is unrelated to org auth or '
14
+ + 'encryption. To create a new key instead, use `issue_credentials`.',
16
15
  inputSchema: {
17
16
  type: 'object',
17
+ required: ['keyFile'],
18
18
  properties: {
19
- privateKey: {
20
- type: 'string',
21
- pattern: '^0x?[0-9a-fA-F]{64}$',
22
- description: 'Raw Ethereum private key, 0x-prefixed hex (64 hex chars).',
23
- },
24
19
  keyFile: {
25
20
  type: 'string',
26
- description: 'Path to a file containing the raw 0x-hex private key ' +
27
- '(absolute or project-relative).',
21
+ description: 'Path to a file containing the raw 0x-hex private key '
22
+ + '(absolute or relative to the working directory).',
28
23
  },
29
24
  projectDir: {
30
25
  type: 'string',
31
- description: 'Project directory whose `.env` the key is written to. ' +
32
- 'Defaults to the closest ancestor of cwd containing .git or ' +
33
- 'package.json.',
26
+ description: 'Project directory whose `.env` the key is written to. '
27
+ + 'Defaults to the closest ancestor of cwd containing .git or '
28
+ + 'package.json.',
34
29
  },
35
30
  },
36
31
  },
32
+ annotations: { readOnlyHint: false, destructiveHint: false },
37
33
  }, async (args) => {
38
- if (!args.privateKey && !args.keyFile) {
39
- throw new Error('Provide either `privateKey` (0x-hex) or `keyFile`.');
40
- }
41
- if (args.privateKey && args.keyFile) {
42
- throw new Error('Provide only one of `privateKey` or `keyFile`.');
43
- }
44
34
  const projectDir = findProjectRoot(args.projectDir || process.cwd());
45
- const privateKeyHex = args.keyFile
46
- ? readFileSync(args.keyFile, 'utf8')
47
- : args.privateKey;
48
- const { path, address } = writeEthKey(privateKeyHex, projectDir);
35
+ const { path, address } = writeEthKey(readFileSync(args.keyFile, 'utf8'), projectDir);
49
36
  return {
50
37
  address,
51
38
  path,
52
- note: 'Eth proof-owner key written to .env as RECLAIM_PRIVATE_KEY ' +
53
- '(mode 0600). resolve_owner_key resolves it from .env. Keep .env ' +
54
- 'secret — it has been added to .gitignore.',
39
+ note: 'Eth proof-owner key written to .env as RECLAIM_PRIVATE_KEY '
40
+ + '(mode 0600). resolve_owner_key resolves it from .env. Keep .env '
41
+ + 'secret: it has been added to .gitignore.',
55
42
  };
56
43
  });
57
44
  }
@@ -0,0 +1,8 @@
1
+ import type { ReclaimClient } from '@reclaimprotocol/client/api';
2
+ import { type RegisteredTool } from '../../server.ts';
3
+ /**
4
+ * Issues an organization API key and stores it on disk, so the key never
5
+ * passes through the agent's transcript. Replaces the generated
6
+ * `issue_org_token` operation, which returned the key in its response.
7
+ */
8
+ export declare function issueOrgTokenTool(client: ReclaimClient): RegisteredTool;
@@ -0,0 +1,60 @@
1
+ import assert from 'node:assert';
2
+ import { isAbsolute, relative, resolve } from 'node:path';
3
+ import { defineTool } from "../../server.js";
4
+ import { upsertEnvVar } from "./eth-key.js";
5
+ import { saveOrgKey } from "./org-key-store.js";
6
+ /**
7
+ * Issues an organization API key and stores it on disk, so the key never
8
+ * passes through the agent's transcript. Replaces the generated
9
+ * `issue_org_token` operation, which returned the key in its response.
10
+ */
11
+ export function issueOrgTokenTool(client) {
12
+ return defineTool({
13
+ name: 'issue_org_token',
14
+ description: 'Issues an organization API key (owner only) and writes it to a '
15
+ + 'server env file in the project, so the app can read it at runtime. '
16
+ + 'Also saves it on this machine for the org-key tools. Returns the '
17
+ + 'org, file, variable, and last four characters; never the key. '
18
+ + 'Replaces an existing variable of the same name in the file. '
19
+ + 'Adds the file to .gitignore. Use when the app needs a key, or '
20
+ + 'before `create_verification_session`.',
21
+ inputSchema: {
22
+ type: 'object',
23
+ required: ['orgId', 'projectDir'],
24
+ properties: {
25
+ orgId: { type: 'string', format: 'uuid' },
26
+ projectDir: {
27
+ type: 'string',
28
+ description: 'Absolute path of the app\'s project directory.',
29
+ },
30
+ envFile: {
31
+ type: 'string',
32
+ description: 'Env file to write, relative to `projectDir`. Default `.env`.',
33
+ },
34
+ envVar: {
35
+ type: 'string',
36
+ pattern: '^[A-Za-z_][A-Za-z0-9_]*$',
37
+ description: 'Variable name to set. Default `RECLAIM_ORG_SECRET`.',
38
+ },
39
+ },
40
+ },
41
+ annotations: { openWorldHint: true, destructiveHint: false },
42
+ }, async (args) => {
43
+ assert(isAbsolute(args.projectDir), new Error('`projectDir` must be an absolute path.'));
44
+ const envFile = args.envFile || '.env';
45
+ const envVar = args.envVar || 'RECLAIM_ORG_SECRET';
46
+ const inside = relative(args.projectDir, resolve(args.projectDir, envFile));
47
+ assert(inside && !inside.startsWith('..') && !isAbsolute(inside), new Error('`envFile` must be inside `projectDir`.'));
48
+ const { data } = await client.call('IssueOrgToken', {
49
+ params: { orgId: args.orgId },
50
+ });
51
+ const path = upsertEnvVar(args.projectDir, envFile, envVar, data.orgSecret);
52
+ saveOrgKey(args.orgId, data.orgSecret);
53
+ return {
54
+ orgId: args.orgId,
55
+ envFile: path,
56
+ envVar,
57
+ last4: data.last4,
58
+ };
59
+ });
60
+ }
@@ -5,15 +5,14 @@ import { writeEthKey } from "./eth-key.js";
5
5
  export function issueTool() {
6
6
  return defineTool({
7
7
  name: 'issue_credentials',
8
- description: 'Generate a fresh secp256k1 eth proof-owner key-pair (the key ' +
9
- 'that signs local claim creation) and write the raw private key to ' +
10
- 'the project `.env` as RECLAIM_PRIVATE_KEY=0x… (mode 0600; `.env` ' +
11
- 'added to .gitignore). This is a LOCAL signing key only — it is NOT ' +
12
- 'registered with any server and is unrelated to org auth (the org ' +
13
- 'secret) or encryption (the eth decrypt key). ALWAYS confirm with ' +
14
- 'the dev before generating a new key. After writing, run_proof picks ' +
15
- 'it up automatically via resolve_owner_key. The private key is never ' +
16
- 'returned in the response.',
8
+ description: 'Generates a new secp256k1 eth proof-owner key and writes the '
9
+ + 'private key to the project `.env` as RECLAIM_PRIVATE_KEY (mode '
10
+ + '0600; `.env` added to .gitignore). Returns the address and the '
11
+ + '`.env` path; never the key. The key is a local signing key only: '
12
+ + 'it is not registered with any server and is unrelated to org auth '
13
+ + 'or encryption. Confirm with the developer before replacing an '
14
+ + 'existing key. `run_proof` then picks it up through '
15
+ + '`resolve_owner_key`.',
17
16
  inputSchema: {
18
17
  type: 'object',
19
18
  properties: {
@@ -25,6 +24,7 @@ export function issueTool() {
25
24
  },
26
25
  },
27
26
  },
27
+ annotations: { destructiveHint: false },
28
28
  }, async (args) => {
29
29
  const projectDir = findProjectRoot(args.projectDir || process.cwd());
30
30
  const keypair = generateKeypair();
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Save an organization API key (`rorg_…`) in the local config (mode 0600), so
3
+ * the org-key tools can use it without the key passing through a transcript.
4
+ */
5
+ export declare function saveOrgKey(orgId: string, secret: string): void;
6
+ /**
7
+ * The saved key for `orgId`, or the most recently saved key when no org is
8
+ * given. Returns `undefined` when none is saved.
9
+ */
10
+ export declare function savedOrgKey(orgId?: string): string | undefined;
@@ -0,0 +1,23 @@
1
+ import { ConfigStore } from "../../../config/store.js";
2
+ /**
3
+ * Save an organization API key (`rorg_…`) in the local config (mode 0600), so
4
+ * the org-key tools can use it without the key passing through a transcript.
5
+ */
6
+ export function saveOrgKey(orgId, secret) {
7
+ const saved = new ConfigStore().read()?.org_keys;
8
+ new ConfigStore().write({
9
+ org_keys: {
10
+ byOrg: { ...saved?.byOrg, [orgId]: secret },
11
+ recent: orgId,
12
+ },
13
+ });
14
+ }
15
+ /**
16
+ * The saved key for `orgId`, or the most recently saved key when no org is
17
+ * given. Returns `undefined` when none is saved.
18
+ */
19
+ export function savedOrgKey(orgId) {
20
+ const saved = new ConfigStore().read()?.org_keys;
21
+ const id = orgId || saved?.recent;
22
+ return id ? saved?.byOrg[id] : undefined;
23
+ }
@@ -16,18 +16,16 @@ import { ENV_FILE, resolveEthKey } from "./eth-key.js";
16
16
  export function resolveOwnerKeyTool() {
17
17
  return defineTool({
18
18
  name: 'resolve_owner_key',
19
- description: 'Resolve which eth proof-owner key run_proof should sign with — ' +
20
- 'call this BEFORE run_proof. Checks, in order: RECLAIM_PRIVATE_KEY ' +
21
- 'in the MCP env, a RECLAIM_PRIVATE_KEY=0x… line in the project .env, ' +
22
- 'then a file at RECLAIM_PRIVATE_KEY_FILE holding the raw hex. ' +
23
- 'Returns { ready: true, address, source } when one is ' +
24
- 'available — pass `address` to run_proof as `ownerAddress`. ' +
25
- 'Returns { ready: false } ' +
26
- 'when none exists: then ask the dev to generate one ' +
27
- '(issue_credentials) or import one they already hold ' +
28
- '(import_credentials, accepts 0x-hex or a key-file path), and call ' +
29
- 'resolve_owner_key again. Never exposes the private key.',
19
+ description: 'Finds the eth proof-owner key `run_proof` signs with. Call it '
20
+ + 'before `run_proof`. Checks RECLAIM_PRIVATE_KEY in the MCP env, a '
21
+ + 'RECLAIM_PRIVATE_KEY line in the project .env, then the file at '
22
+ + 'RECLAIM_PRIVATE_KEY_FILE. Returns { ready: true, address, source '
23
+ + '}: pass `address` to `run_proof` as `ownerAddress`. Returns { '
24
+ + 'ready: false } when none exists: ask the developer to create one '
25
+ + 'with `issue_credentials` or import one with `import_credentials` '
26
+ + '(a key file), then call it again. Never returns the key.',
30
27
  inputSchema: { type: 'object', properties: {} },
28
+ annotations: { readOnlyHint: true, openWorldHint: false },
31
29
  }, async () => {
32
30
  const projectDir = findProjectRoot(process.cwd());
33
31
  const resolved = resolveEthKey(projectDir);
@@ -45,7 +43,7 @@ export function resolveOwnerKeyTool() {
45
43
  `env, no RECLAIM_PRIVATE_KEY in ${join(projectDir, ENV_FILE)}, and ` +
46
44
  'no RECLAIM_PRIVATE_KEY_FILE. Ask the dev to generate one via ' +
47
45
  'issue_credentials, or import one they already hold via ' +
48
- 'import_credentials (0x-hex or a key-file path). Then call ' +
46
+ 'import_credentials (a key file). Then call ' +
49
47
  'resolve_owner_key again and pass its address to run_proof as ' +
50
48
  'ownerAddress.',
51
49
  };
@@ -44,6 +44,7 @@ export function buildModeTools(config, currentOldMode) {
44
44
  },
45
45
  required: ['mode'],
46
46
  },
47
+ annotations: { openWorldHint: false, idempotentHint: true },
47
48
  }, async (parsed) => {
48
49
  config.write({ mode: parsed.mode });
49
50
  const restartRequired = parsed.mode !== current;
@@ -71,6 +72,7 @@ export function buildModeTools(config, currentOldMode) {
71
72
  + 'the staleness with an error naming the tool to re-run. Which '
72
73
  + 'login authorizes what: how_it_works({ topic: "auth" }).',
73
74
  inputSchema: { type: 'object', properties: {} },
75
+ annotations: { readOnlyHint: true, openWorldHint: false },
74
76
  }, async () => {
75
77
  const persisted = config.read()?.mode;
76
78
  const oldIdentity = config.read()?.old_devtools;
@@ -3,6 +3,7 @@ import assert from 'node:assert';
3
3
  import { apiUrl, orgSecret } from "../../../consts.js";
4
4
  import { defineTool } from "../../server.js";
5
5
  import { resolveDecryptionKey } from "../authenticate/decrypt-key.js";
6
+ import { savedOrgKey } from "../authenticate/org-key-store.js";
6
7
  /** Statuses that can carry a Builder-managed terminal result. */
7
8
  const TERMINAL = new Set([
8
9
  'success',
@@ -25,11 +26,10 @@ const RESULT_EVENTS = new Set([
25
26
  * `orgToken`, else `RECLAIM_ORG_SECRET`.
26
27
  */
27
28
  function resolveOrgSecret(orgToken) {
28
- const secret = orgToken?.trim() || orgSecret()?.trim();
29
+ const secret = orgToken?.trim() || orgSecret()?.trim() || savedOrgKey();
29
30
  assert(secret, new Error('No organization API key. Verification reads authenticate with the org '
30
- + 'secret (rorg_…): pass orgToken (from issue_org_token, or the '
31
- + 'app\'s RECLAIM_ORG_SECRET), or export RECLAIM_ORG_SECRET for the '
32
- + 'MCP server.'));
31
+ + 'secret (rorg_…): run issue_org_token to save a key, pass orgToken, '
32
+ + 'or export RECLAIM_ORG_SECRET for the MCP server.'));
33
33
  return secret;
34
34
  }
35
35
  /**
@@ -49,7 +49,8 @@ export function verificationResultTool() {
49
49
  + 'while Builder still holds it: until its callback is delivered, or '
50
50
  + '7 days undelivered. The callback is the normal way to get results. '
51
51
  + 'Authenticates with the org API key: `orgToken`, else '
52
- + '`RECLAIM_ORG_SECRET`. Encrypted deliveries also require '
52
+ + '`RECLAIM_ORG_SECRET`, else the key saved by `issue_org_token`. '
53
+ + 'Encrypted deliveries also require '
53
54
  + 'the matching ETH decryption key. Returns `ready: false` until a '
54
55
  + 'payload is available. Invalid results fail verification and are not '
55
56
  + 'returned. Use `list_verification_events` to diagnose '
@@ -68,11 +69,13 @@ export function verificationResultTool() {
68
69
  maxLength: 200,
69
70
  description: 'The organization API key (`rorg_…`): from '
70
71
  + '`issue_org_token`, or the app\'s RECLAIM_ORG_SECRET. '
71
- + 'Defaults to the MCP server\'s RECLAIM_ORG_SECRET. Never echo '
72
- + 'it back to the user.',
72
+ + 'Defaults to the MCP server\'s RECLAIM_ORG_SECRET, then the '
73
+ + 'key saved by `issue_org_token`. Never echo it back to the '
74
+ + 'user.',
73
75
  },
74
76
  },
75
77
  },
78
+ annotations: { readOnlyHint: true, openWorldHint: true },
76
79
  }, async (args) => {
77
80
  const secret = resolveOrgSecret(args.orgToken);
78
81
  // Optional eth decryption key — absent ⇒ plaintext-only.
@@ -1,8 +1,20 @@
1
1
  import type { JSONSchema } from 'zod/v4/core';
2
+ /** MCP tool hints that let a client decide when to ask for approval. */
3
+ export interface ToolAnnotations {
4
+ /** The tool never changes state. */
5
+ readOnlyHint?: boolean;
6
+ /** The tool can delete or overwrite state. */
7
+ destructiveHint?: boolean;
8
+ /** Repeating a call with the same input has no further effect. */
9
+ idempotentHint?: boolean;
10
+ /** The tool reaches systems outside this machine. */
11
+ openWorldHint?: boolean;
12
+ }
2
13
  export interface ToolDefinition {
3
14
  name: string;
4
15
  description: string;
5
16
  inputSchema: JSONSchema.ObjectSchema;
17
+ annotations?: ToolAnnotations;
6
18
  }
7
19
  export interface RegisteredTool {
8
20
  definition: ToolDefinition;
@@ -75,6 +75,7 @@ export function extendTool(tool, extra) {
75
75
  name: base.name,
76
76
  description: extra.description ?? base.description,
77
77
  inputSchema,
78
+ ...(base.annotations ? { annotations: base.annotations } : {}),
78
79
  },
79
80
  handler: tool.handler,
80
81
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@reclaimprotocol/agent",
3
3
  "title": "Reclaim Agent",
4
- "version": "0.1.33",
4
+ "version": "0.1.34",
5
5
  "description": "Reclaim Protocol tools for AI coding agents. Reclaim lets your app verify data points about its users, such as a follower count, an account balance, or an order history. This package is the Reclaim MCP server: it gives your agent the tools to find, build, test, and fix data verification providers by capturing and replaying browser requests, drafting provider recipes, running zkTLS proofs, and publishing provider versions.",
6
6
  "type": "module",
7
7
  "main": "./lib/index.js",
@@ -83,7 +83,7 @@
83
83
  "@modelcontextprotocol/sdk": "^1.29.0",
84
84
  "@noble/hashes": "^2.2.0",
85
85
  "@reclaimprotocol/attestor-core": "^5.1.5",
86
- "@reclaimprotocol/client": "0.1.33",
86
+ "@reclaimprotocol/client": "0.1.34",
87
87
  "@reclaimprotocol/tls": "^0.1.3",
88
88
  "chrome-remote-interface": "^0.33.0",
89
89
  "domhandler": "^6.0.0",