@reclaimprotocol/agent 0.1.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 (73) hide show
  1. package/lib/cdp/launcher.js +4 -3
  2. package/lib/consts.d.ts +68 -0
  3. package/lib/consts.js +134 -0
  4. package/lib/logger.js +2 -1
  5. package/lib/mcp/api/operations.gen.d.ts +3 -7
  6. package/lib/mcp/api/operations.gen.js +264 -199
  7. package/lib/mcp/server.d.ts +0 -6
  8. package/lib/mcp/server.js +0 -30
  9. package/lib/mcp/start.js +7 -7
  10. package/lib/mcp/tools/agent/build.d.ts +5 -9
  11. package/lib/mcp/tools/agent/build.js +5 -9
  12. package/lib/mcp/tools/agent/proof.js +2 -1
  13. package/lib/mcp/tools/agent/publish.js +166 -77
  14. package/lib/mcp/tools/authenticate/decrypt-key.d.ts +10 -23
  15. package/lib/mcp/tools/authenticate/decrypt-key.js +23 -26
  16. package/lib/mcp/tools/authenticate/eth-key.d.ts +0 -7
  17. package/lib/mcp/tools/authenticate/eth-key.js +5 -19
  18. package/lib/mcp/tools/authenticate/issue.js +1 -1
  19. package/lib/mcp/tools/verification/build.d.ts +1 -1
  20. package/lib/mcp/tools/verification/build.js +1 -1
  21. package/lib/mcp/tools/verification/result.d.ts +4 -5
  22. package/lib/mcp/tools/verification/result.js +17 -17
  23. package/lib/old/flag.d.ts +4 -1
  24. package/lib/old/flag.js +4 -3
  25. package/lib/old/identity.d.ts +0 -10
  26. package/lib/old/identity.js +8 -7
  27. package/lib/old/login-cdp.d.ts +0 -3
  28. package/lib/old/login-cdp.js +2 -4
  29. package/lib/old/to-register.js +6 -9
  30. package/lib/old/tools/authenticate.js +2 -1
  31. package/lib/old/tools/publish.js +58 -9
  32. package/lib/paths.js +2 -2
  33. package/lib/proof/attestor.js +2 -1
  34. package/lib/proof/proof-core.js +13 -2
  35. package/lib/provider/injection-doc.d.ts +1 -0
  36. package/lib/provider/injection-doc.js +17 -0
  37. package/lib/provider/match-redaction-warning.d.ts +25 -0
  38. package/lib/provider/match-redaction-warning.js +35 -0
  39. package/lib/provider/schema.d.ts +16 -0
  40. package/lib/provider/schema.js +11 -1
  41. package/lib/provider/to-version.d.ts +59 -7
  42. package/lib/provider/to-version.js +79 -28
  43. package/package.json +1 -1
  44. package/skill/builder-mode.md +6 -2
  45. package/skill/injection-api.md +42 -0
  46. package/skill/old-mode.md +2 -0
  47. package/src/cdp/launcher.ts +5 -4
  48. package/src/consts.ts +164 -0
  49. package/src/logger.ts +2 -1
  50. package/src/mcp/api/operations.gen.ts +262 -203
  51. package/src/mcp/server.ts +0 -46
  52. package/src/mcp/start.ts +13 -7
  53. package/src/mcp/tools/agent/build.ts +5 -9
  54. package/src/mcp/tools/agent/proof.ts +2 -1
  55. package/src/mcp/tools/agent/publish.ts +212 -94
  56. package/src/mcp/tools/authenticate/decrypt-key.ts +24 -29
  57. package/src/mcp/tools/authenticate/eth-key.ts +5 -25
  58. package/src/mcp/tools/authenticate/issue.ts +1 -1
  59. package/src/mcp/tools/verification/build.ts +1 -1
  60. package/src/mcp/tools/verification/result.ts +16 -17
  61. package/src/old/flag.ts +4 -3
  62. package/src/old/identity.ts +8 -7
  63. package/src/old/login-cdp.ts +2 -5
  64. package/src/old/to-register.ts +7 -10
  65. package/src/old/tools/authenticate.ts +2 -1
  66. package/src/old/tools/publish.ts +75 -15
  67. package/src/paths.ts +2 -2
  68. package/src/proof/attestor.ts +2 -1
  69. package/src/proof/proof-core.ts +13 -3
  70. package/src/provider/injection-doc.ts +21 -0
  71. package/src/provider/match-redaction-warning.ts +53 -0
  72. package/src/provider/schema.ts +23 -0
  73. package/src/provider/to-version.ts +137 -31
@@ -2,6 +2,7 @@ import { spawn } from 'node:child_process';
2
2
  import { existsSync, mkdirSync } from 'node:fs';
3
3
  import { homedir, platform } from 'node:os';
4
4
  import { join } from 'node:path';
5
+ import { chromePath, localAppData } from "../consts.js";
5
6
  import { reclaimHomeDirPath } from "../paths.js";
6
7
  /**
7
8
  * Build the platform-specific list of Chromium-family binaries to probe.
@@ -24,13 +25,13 @@ function browserCandidates() {
24
25
  '/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge',
25
26
  ];
26
27
  case 'win32': {
27
- const localAppData = process.env['LOCALAPPDATA'] ?? join(homedir(), 'AppData', 'Local');
28
+ const appData = localAppData() ?? join(homedir(), 'AppData', 'Local');
28
29
  return [
29
30
  // System-wide Chrome
30
31
  'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe',
31
32
  'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe',
32
33
  // Per-user Chrome ("Install for me only")
33
- join(localAppData, 'Google', 'Chrome', 'Application', 'chrome.exe'),
34
+ join(appData, 'Google', 'Chrome', 'Application', 'chrome.exe'),
34
35
  // Edge — Chromium-based, preinstalled on Win 10/11
35
36
  'C:\\Program Files\\Microsoft\\Edge\\Application\\msedge.exe',
36
37
  'C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe',
@@ -65,7 +66,7 @@ export function findChromeBinary() {
65
66
  'your chrome.exe / msedge.exe / chromium binary.');
66
67
  }
67
68
  export function launchChrome(opts) {
68
- const binary = process.env.RECLAIM_AGENT_CHROME_PATH ?? findChromeBinary();
69
+ const binary = chromePath() ?? findChromeBinary();
69
70
  if (!existsSync(opts.profileDir)) {
70
71
  mkdirSync(opts.profileDir, { recursive: true });
71
72
  }
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Centralized environment access for `@reclaimprotocol/agent`.
3
+ *
4
+ * This is the ONLY non-test source file under `src/` that reads
5
+ * `process.env`. Every other module imports a getter from here instead of
6
+ * touching `process.env` directly.
7
+ *
8
+ * Almost everything is exposed as a LAZY GETTER FUNCTION rather than an eager
9
+ * `const`, on purpose: several tests mutate env at runtime (mcp-credentials
10
+ * sets/deletes RECLAIM_PRIVATE_KEY / RECLAIM_PRIVATE_KEY_FILE / RECLAIM_HOME;
11
+ * old-devtools sets/deletes USE_OLD_DEVTOOLS), and most of these vars are read
12
+ * at call time anyway. An eager const captured at import time would freeze the
13
+ * value and break those tests. The one eager const that's safe is `LOG_LEVEL`,
14
+ * which is read once at logger construction.
15
+ *
16
+ * Each var's default/fallback literal is co-located with its getter.
17
+ */
18
+ import { DEFAULT_BASE_URL } from '@reclaimprotocol/client';
19
+ import { DEFAULT_OLD_API_URL } from './old/client.ts';
20
+ /** Public attestor websocket URL — fallback for `RECLAIM_ATTESTOR_URL`. */
21
+ export declare const FALLBACK_ATTESTOR_URL = "wss://attestor.reclaimprotocol.org:444/ws";
22
+ /** The devtools dashboard login page — fallback for `RECLAIM_OLD_LOGIN_URL`. */
23
+ export declare const DEFAULT_LOGIN_URL = "https://dev.reclaimprotocol.org";
24
+ export { DEFAULT_BASE_URL, DEFAULT_OLD_API_URL };
25
+ /** Pino log level. Read once at logger construction, so an eager const is
26
+ * safe (no test mutates LOG_LEVEL at runtime). */
27
+ export declare const LOG_LEVEL: string;
28
+ /** Reclaim cache directory (`~/.reclaim`). `RECLAIM_HOME` overrides it so
29
+ * tests can sandbox writes. */
30
+ export declare function reclaimHome(): string;
31
+ /**
32
+ * `USE_OLD_DEVTOOLS` — single source of truth for which backend the MCP
33
+ * server targets. Defaults to OLD devtools while the builder backend is under
34
+ * development. Builder mode must be opted into EXPLICITLY with
35
+ * `USE_OLD_DEVTOOLS=false`; anything else keeps old mode on.
36
+ */
37
+ export declare function useOldDevtools(): boolean;
38
+ /** `%LOCALAPPDATA%` on Windows, used to probe a per-user Chrome install. */
39
+ export declare function localAppData(): string | undefined;
40
+ /** Explicit Chrome/Edge/Chromium binary path override. */
41
+ export declare function chromePath(): string | undefined;
42
+ /** Agent tools (Chrome CDP capture, synthesis, proof) are disabled in hosted
43
+ * deployments by setting `RECLAIM_AGENT_DISABLED=1`. Shared by mcp/start and
44
+ * the old-mode authenticate tool. */
45
+ export declare function agentDisabled(): boolean;
46
+ /** Old-devtools backend base URL. */
47
+ export declare function oldApiUrl(): string;
48
+ /** Builder backend base URL. Shared by mcp/start and the verification tool. */
49
+ export declare function apiUrl(): string;
50
+ /** Explicit builder API token (overrides the cached session token). */
51
+ export declare function apiToken(): string | undefined;
52
+ /** Diagnostic trace capture (`RECLAIM_AGENT_TRACE=1`). Shared by the attestor
53
+ * logger capture and the proof-run dump. */
54
+ export declare function agentTraceEnabled(): boolean;
55
+ /** Attestor websocket URL override (`RECLAIM_ATTESTOR_URL`). */
56
+ export declare function attestorUrlOverride(): string | undefined;
57
+ /** Raw 0x-hex Ethereum private key (`RECLAIM_PRIVATE_KEY`). */
58
+ export declare function privateKey(): string | undefined;
59
+ /** Path to a raw-hex key file (`RECLAIM_PRIVATE_KEY_FILE`). */
60
+ export declare function privateKeyFile(): string | undefined;
61
+ /** Per-org bearer secret (`rorg_…`) used to authenticate verification reads. */
62
+ export declare function orgSecret(): string | undefined;
63
+ /** Dashboard Firebase bearer token for the old backend. */
64
+ export declare function oldApiToken(): string | undefined;
65
+ /** An `eth:<addr>` (or bare `0x…`) uid for the old backend. */
66
+ export declare function oldEthUid(): string | undefined;
67
+ /** Override for the old-devtools dashboard login URL. */
68
+ export declare function oldLoginUrl(): string | undefined;
package/lib/consts.js ADDED
@@ -0,0 +1,134 @@
1
+ /**
2
+ * Centralized environment access for `@reclaimprotocol/agent`.
3
+ *
4
+ * This is the ONLY non-test source file under `src/` that reads
5
+ * `process.env`. Every other module imports a getter from here instead of
6
+ * touching `process.env` directly.
7
+ *
8
+ * Almost everything is exposed as a LAZY GETTER FUNCTION rather than an eager
9
+ * `const`, on purpose: several tests mutate env at runtime (mcp-credentials
10
+ * sets/deletes RECLAIM_PRIVATE_KEY / RECLAIM_PRIVATE_KEY_FILE / RECLAIM_HOME;
11
+ * old-devtools sets/deletes USE_OLD_DEVTOOLS), and most of these vars are read
12
+ * at call time anyway. An eager const captured at import time would freeze the
13
+ * value and break those tests. The one eager const that's safe is `LOG_LEVEL`,
14
+ * which is read once at logger construction.
15
+ *
16
+ * Each var's default/fallback literal is co-located with its getter.
17
+ */
18
+ import { DEFAULT_BASE_URL } from '@reclaimprotocol/client';
19
+ import { homedir } from 'node:os';
20
+ import { join } from 'node:path';
21
+ import { DEFAULT_OLD_API_URL } from "./old/client.js";
22
+ // ---------------------------------------------------------------------------
23
+ // Default / fallback literals (used only as env fallbacks).
24
+ // ---------------------------------------------------------------------------
25
+ /** Public attestor websocket URL — fallback for `RECLAIM_ATTESTOR_URL`. */
26
+ export const FALLBACK_ATTESTOR_URL = 'wss://attestor.reclaimprotocol.org:444/ws';
27
+ /** The devtools dashboard login page — fallback for `RECLAIM_OLD_LOGIN_URL`. */
28
+ export const DEFAULT_LOGIN_URL = 'https://dev.reclaimprotocol.org';
29
+ // Re-export the two non-env-fallback defaults so callers can keep importing
30
+ // their URL defaults from a single place if they wish.
31
+ export { DEFAULT_BASE_URL, DEFAULT_OLD_API_URL };
32
+ // ---------------------------------------------------------------------------
33
+ // Logging.
34
+ // ---------------------------------------------------------------------------
35
+ /** Pino log level. Read once at logger construction, so an eager const is
36
+ * safe (no test mutates LOG_LEVEL at runtime). */
37
+ export const LOG_LEVEL = process.env.LOG_LEVEL || 'info';
38
+ // ---------------------------------------------------------------------------
39
+ // Paths.
40
+ // ---------------------------------------------------------------------------
41
+ /** Reclaim cache directory (`~/.reclaim`). `RECLAIM_HOME` overrides it so
42
+ * tests can sandbox writes. */
43
+ export function reclaimHome() {
44
+ return process.env.RECLAIM_HOME || join(homedir(), '.reclaim');
45
+ }
46
+ // ---------------------------------------------------------------------------
47
+ // Mode flag.
48
+ // ---------------------------------------------------------------------------
49
+ /**
50
+ * `USE_OLD_DEVTOOLS` — single source of truth for which backend the MCP
51
+ * server targets. Defaults to OLD devtools while the builder backend is under
52
+ * development. Builder mode must be opted into EXPLICITLY with
53
+ * `USE_OLD_DEVTOOLS=false`; anything else keeps old mode on.
54
+ */
55
+ export function useOldDevtools() {
56
+ return (process.env.USE_OLD_DEVTOOLS ?? '').trim().toLowerCase() !== 'false';
57
+ }
58
+ // ---------------------------------------------------------------------------
59
+ // Chrome / CDP launcher.
60
+ // ---------------------------------------------------------------------------
61
+ /** `%LOCALAPPDATA%` on Windows, used to probe a per-user Chrome install. */
62
+ export function localAppData() {
63
+ return process.env['LOCALAPPDATA'];
64
+ }
65
+ /** Explicit Chrome/Edge/Chromium binary path override. */
66
+ export function chromePath() {
67
+ return process.env.RECLAIM_AGENT_CHROME_PATH;
68
+ }
69
+ // ---------------------------------------------------------------------------
70
+ // MCP server / API clients.
71
+ // ---------------------------------------------------------------------------
72
+ /** Agent tools (Chrome CDP capture, synthesis, proof) are disabled in hosted
73
+ * deployments by setting `RECLAIM_AGENT_DISABLED=1`. Shared by mcp/start and
74
+ * the old-mode authenticate tool. */
75
+ export function agentDisabled() {
76
+ return process.env.RECLAIM_AGENT_DISABLED === '1';
77
+ }
78
+ /** Old-devtools backend base URL. */
79
+ export function oldApiUrl() {
80
+ return process.env.RECLAIM_OLD_API_URL || DEFAULT_OLD_API_URL;
81
+ }
82
+ /** Builder backend base URL. Shared by mcp/start and the verification tool. */
83
+ export function apiUrl() {
84
+ return process.env.RECLAIM_API_URL || DEFAULT_BASE_URL;
85
+ }
86
+ /** Explicit builder API token (overrides the cached session token). */
87
+ export function apiToken() {
88
+ return process.env.RECLAIM_API_TOKEN;
89
+ }
90
+ // ---------------------------------------------------------------------------
91
+ // Proof tracing.
92
+ // ---------------------------------------------------------------------------
93
+ /** Diagnostic trace capture (`RECLAIM_AGENT_TRACE=1`). Shared by the attestor
94
+ * logger capture and the proof-run dump. */
95
+ export function agentTraceEnabled() {
96
+ return process.env['RECLAIM_AGENT_TRACE'] === '1';
97
+ }
98
+ /** Attestor websocket URL override (`RECLAIM_ATTESTOR_URL`). */
99
+ export function attestorUrlOverride() {
100
+ return process.env['RECLAIM_ATTESTOR_URL'];
101
+ }
102
+ // ---------------------------------------------------------------------------
103
+ // Eth proof-owner key resolution.
104
+ // ---------------------------------------------------------------------------
105
+ /** Raw 0x-hex Ethereum private key (`RECLAIM_PRIVATE_KEY`). */
106
+ export function privateKey() {
107
+ return process.env.RECLAIM_PRIVATE_KEY;
108
+ }
109
+ /** Path to a raw-hex key file (`RECLAIM_PRIVATE_KEY_FILE`). */
110
+ export function privateKeyFile() {
111
+ return process.env.RECLAIM_PRIVATE_KEY_FILE;
112
+ }
113
+ // ---------------------------------------------------------------------------
114
+ // Verification reads.
115
+ // ---------------------------------------------------------------------------
116
+ /** Per-org bearer secret (`rorg_…`) used to authenticate verification reads. */
117
+ export function orgSecret() {
118
+ return process.env.RECLAIM_ORG_SECRET;
119
+ }
120
+ // ---------------------------------------------------------------------------
121
+ // Old-devtools identity / login.
122
+ // ---------------------------------------------------------------------------
123
+ /** Dashboard Firebase bearer token for the old backend. */
124
+ export function oldApiToken() {
125
+ return process.env.RECLAIM_OLD_API_TOKEN;
126
+ }
127
+ /** An `eth:<addr>` (or bare `0x…`) uid for the old backend. */
128
+ export function oldEthUid() {
129
+ return process.env.RECLAIM_OLD_ETH_UID;
130
+ }
131
+ /** Override for the old-devtools dashboard login URL. */
132
+ export function oldLoginUrl() {
133
+ return process.env.RECLAIM_OLD_LOGIN_URL;
134
+ }
package/lib/logger.js CHANGED
@@ -1,7 +1,8 @@
1
1
  import pino, { stdTimeFunctions } from 'pino';
2
+ import { LOG_LEVEL } from "./consts.js";
2
3
  export const LOGGER = pino({
3
4
  name: '@reclaimprotocol/agent',
4
5
  timestamp: stdTimeFunctions.isoTime,
5
6
  base: { hostname: undefined, pid: undefined },
6
7
  });
7
- LOGGER.level = process.env.LOG_LEVEL || 'info';
8
+ LOGGER.level = LOG_LEVEL;
@@ -63,7 +63,7 @@ export declare const MCP_TOOLS: {
63
63
  description: string;
64
64
  inputSchema: import("zod").ZodType<unknown, unknown, import("zod/v4/core").$ZodTypeInternals<unknown, unknown>>;
65
65
  };
66
- DeleteOrgCredential: {
66
+ DeleteOrgKeypair: {
67
67
  description: string;
68
68
  inputSchema: import("zod").ZodType<unknown, unknown, import("zod/v4/core").$ZodTypeInternals<unknown, unknown>>;
69
69
  };
@@ -91,7 +91,7 @@ export declare const MCP_TOOLS: {
91
91
  description: string;
92
92
  inputSchema: import("zod").ZodType<unknown, unknown, import("zod/v4/core").$ZodTypeInternals<unknown, unknown>>;
93
93
  };
94
- GetOrgCredential: {
94
+ GetOrgKeypair: {
95
95
  description: string;
96
96
  inputSchema: import("zod").ZodType<unknown, unknown, import("zod/v4/core").$ZodTypeInternals<unknown, unknown>>;
97
97
  };
@@ -171,7 +171,7 @@ export declare const MCP_TOOLS: {
171
171
  description: string;
172
172
  inputSchema: import("zod").ZodType<unknown, unknown, import("zod/v4/core").$ZodTypeInternals<unknown, unknown>>;
173
173
  };
174
- SetOrgCredential: {
174
+ SetOrgKeypair: {
175
175
  description: string;
176
176
  inputSchema: import("zod").ZodType<unknown, unknown, import("zod/v4/core").$ZodTypeInternals<unknown, unknown>>;
177
177
  };
@@ -183,10 +183,6 @@ export declare const MCP_TOOLS: {
183
183
  description: string;
184
184
  inputSchema: import("zod").ZodType<unknown, unknown, import("zod/v4/core").$ZodTypeInternals<unknown, unknown>>;
185
185
  };
186
- UpdateMe: {
187
- description: string;
188
- inputSchema: import("zod").ZodType<unknown, unknown, import("zod/v4/core").$ZodTypeInternals<unknown, unknown>>;
189
- };
190
186
  UpdateOrg: {
191
187
  description: string;
192
188
  inputSchema: import("zod").ZodType<unknown, unknown, import("zod/v4/core").$ZodTypeInternals<unknown, unknown>>;