@reclaimprotocol/agent 0.1.28 → 0.1.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -9
- package/lib/consts.d.ts +5 -5
- package/lib/consts.js +7 -7
- package/lib/live/tunnel-watchdog.d.ts +1 -0
- package/lib/live/tunnel-watchdog.js +66 -0
- package/lib/live/tunnel.d.ts +30 -7
- package/lib/live/tunnel.js +217 -40
- package/lib/mcp/api/operations.gen.d.ts +12 -0
- package/lib/mcp/api/operations.gen.js +537 -59
- package/lib/mcp/api/tools.js +27 -5
- package/lib/mcp/instructions.js +25 -32
- package/lib/mcp/remap_errors.js +6 -0
- package/lib/mcp/server.js +2 -8
- package/lib/mcp/start.js +3 -5
- package/lib/mcp/success-response.d.ts +5 -0
- package/lib/mcp/success-response.js +21 -0
- package/lib/mcp/tools/agent/attach.js +9 -66
- package/lib/mcp/tools/agent/build.d.ts +0 -3
- package/lib/mcp/tools/agent/build.js +3 -4
- package/lib/mcp/tools/agent/how-it-works.d.ts +5 -15
- package/lib/mcp/tools/agent/how-it-works.js +9 -22
- package/lib/mcp/tools/agent/live-view.d.ts +1 -15
- package/lib/mcp/tools/agent/live-view.js +71 -96
- package/lib/mcp/tools/agent/propose.js +7 -23
- package/lib/mcp/tools/agent/publish.js +80 -18
- package/lib/mcp/tools/agent/session.d.ts +4 -7
- package/lib/mcp/tools/agent/session.js +8 -23
- package/lib/mcp/tools/verification/result.d.ts +2 -1
- package/lib/mcp/tools/verification/result.js +29 -28
- package/lib/old/client.d.ts +2 -2
- package/lib/old/flag.d.ts +2 -5
- package/lib/old/flag.js +2 -5
- package/lib/old/instructions.d.ts +1 -1
- package/lib/old/instructions.js +1 -1
- package/lib/old/to-register.d.ts +4 -3
- package/lib/old/tools/publish.js +11 -14
- package/lib/proof/attestor-auth.d.ts +9 -1
- package/lib/proof/attestor-auth.js +15 -2
- package/lib/proof/attestor.d.ts +2 -2
- package/lib/proof/attestor.js +20 -2
- package/lib/proof/pod-prover.js +1 -1
- package/lib/proof/proof-core.d.ts +4 -0
- package/lib/proof/proof-core.js +20 -0
- package/lib/provider/injection-doc.d.ts +3 -2
- package/lib/provider/injection-doc.js +12 -10
- package/lib/provider/matcher.js +19 -15
- package/lib/provider/to-version.d.ts +3 -0
- package/lib/provider/to-version.js +2 -1
- package/package.json +3 -3
- package/skill/SKILL.builder.md +32 -85
- package/skill/SKILL.common.md +38 -22
- package/skill/SKILL.old.md +17 -3
- package/skill/builder-mode.md +37 -4
- package/skill/community-contributions.md +12 -3
- package/skill/hash-validation.md +9 -9
- package/skill/interception.md +39 -46
- package/skill/old-mode.md +13 -0
- package/skill/user-script.md +24 -8
- package/skill/verification-client-integration.md +130 -0
- package/src/consts.ts +9 -7
- package/src/mcp/api/operations.gen.ts +539 -59
- package/src/mcp/api/tools.ts +38 -7
- package/src/mcp/instructions.ts +35 -32
- package/src/mcp/remap_errors.ts +6 -0
- package/src/mcp/server.ts +2 -8
- package/src/mcp/start.ts +3 -5
- package/src/mcp/success-response.ts +26 -0
- package/src/mcp/tools/agent/attach.ts +9 -71
- package/src/mcp/tools/agent/build.ts +4 -7
- package/src/mcp/tools/agent/how-it-works.ts +9 -22
- package/src/mcp/tools/agent/live-view.ts +76 -116
- package/src/mcp/tools/agent/propose.ts +7 -23
- package/src/mcp/tools/agent/publish.ts +89 -18
- package/src/mcp/tools/agent/session.ts +6 -23
- package/src/mcp/tools/verification/result.ts +30 -29
- package/src/old/client.ts +2 -2
- package/src/old/flag.ts +2 -5
- package/src/old/instructions.ts +1 -1
- package/src/old/to-register.ts +4 -3
- package/src/old/tools/publish.ts +16 -14
- package/src/proof/attestor-auth.ts +18 -1
- package/src/proof/attestor.ts +24 -3
- package/src/proof/pod-prover.ts +1 -1
- package/src/proof/proof-core.ts +28 -0
- package/src/provider/injection-doc.ts +12 -10
- package/src/provider/matcher.ts +25 -17
- package/src/provider/to-version.ts +7 -1
- package/src/live/cloudflared.ts +0 -348
- package/src/live/tunnel.ts +0 -254
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# Integrate a Builder verification client
|
|
2
|
+
|
|
3
|
+
## Set up an application with the coding agent
|
|
4
|
+
|
|
5
|
+
When asked to integrate Reclaim into an app, inspect that app's frontend,
|
|
6
|
+
backend, package manager, configuration, and callback conventions. Complete
|
|
7
|
+
the integration in its codebase and run its relevant checks. The MCP tools
|
|
8
|
+
configure Builder resources; the coding agent's file tools edit the app.
|
|
9
|
+
|
|
10
|
+
If the app depends on `@reclaimprotocol/js-sdk`, ask the developer first:
|
|
11
|
+
keep it (call `set_devtools_mode({ mode: "old" })` and have them restart the MCP
|
|
12
|
+
server), or migrate to `@reclaimprotocol/client` with the steps below. When
|
|
13
|
+
migrating, remove `@reclaimprotocol/js-sdk` and replace its
|
|
14
|
+
`ReclaimProofRequest` and `verifyProof` calls with the session flow below.
|
|
15
|
+
|
|
16
|
+
1. Use `get_devtools_mode` to confirm Builder mode and `get_me` or
|
|
17
|
+
`authenticate` to sign in as the developer. Find the intended organization
|
|
18
|
+
with `list_orgs`; call `create_org` only when a new organization is wanted.
|
|
19
|
+
2. Register a callback URL owned by the app's backend with
|
|
20
|
+
`create_org_callback_subscription`. Include terminal success, rejection,
|
|
21
|
+
error, cancellation, and expiry events. If the app needs encrypted results,
|
|
22
|
+
register its public key with `set_org_keypair`; retain the private key only
|
|
23
|
+
in the backend.
|
|
24
|
+
3. An organization owner can call `issue_org_token`. Its `orgSecret` is shown
|
|
25
|
+
once. Put it in the app backend's secret configuration as
|
|
26
|
+
`RECLAIM_ORG_SECRET`; keep it out of frontend bundles, logs, source control,
|
|
27
|
+
and the final response. Reuse an already configured secret when available;
|
|
28
|
+
issue a new token when setup needs one.
|
|
29
|
+
4. Install `@reclaimprotocol/client` in the backend. Use
|
|
30
|
+
`ReclaimVerification.create({ orgSecret })` to create sessions, save each
|
|
31
|
+
returned session ID alongside the app's own user or order, and return only
|
|
32
|
+
`verificationUrl` to the frontend. The frontend opens that URL and asks its
|
|
33
|
+
backend for the final status; a browser redirect alone is not proof of
|
|
34
|
+
success.
|
|
35
|
+
5. Add a backend callback endpoint. Persist each delivery idempotently, load
|
|
36
|
+
the expected session ID and org ID from app storage, and call
|
|
37
|
+
`reclaim.results.receive(body, { reclaimSessionId, expectedAud,
|
|
38
|
+
orgEthPrivateKey })`. Use the verified proof data to update app state.
|
|
39
|
+
Handle callback retries and terminal failure outcomes.
|
|
40
|
+
6. Exercise one session through the selected registered Verification Client,
|
|
41
|
+
inspect its Builder events, and test the app's success and failure paths.
|
|
42
|
+
Omit `verificationClientUrl` to use the Portal, or select another client
|
|
43
|
+
from `VerificationClient` in the SDK. Do not send an unregistered URL or
|
|
44
|
+
call a legacy backend for an `api=2` session.
|
|
45
|
+
|
|
46
|
+
The one-time management calls above use the developer's Builder login. The
|
|
47
|
+
consumer backend uses the separate organization token. The SDK's API-only
|
|
48
|
+
entry point, `@reclaimprotocol/client/api`, is available when an application
|
|
49
|
+
needs typed Builder operations without the full verification workflow.
|
|
50
|
+
|
|
51
|
+
## Create and launch a session
|
|
52
|
+
|
|
53
|
+
Consumers authenticate with an organization token (`rorg_…`, issued in the
|
|
54
|
+
dashboard or via `POST /orgs/{orgId}/token`) and call
|
|
55
|
+
`POST /verifications/sessions`. Open the returned `verificationUrl` for the
|
|
56
|
+
claimant. It contains only the registered Verification Client URL, session ID,
|
|
57
|
+
and `api=2` mode selector.
|
|
58
|
+
|
|
59
|
+
A consumer can pass `launchOptions` (`redirectUrl`/`redirectUrlOptions` on
|
|
60
|
+
success, `cancelRedirectUrl`/`cancelRedirectUrlOptions` on cancellation, `https:`
|
|
61
|
+
only) in the `POST /verifications/sessions` body. Builder validates and stores
|
|
62
|
+
them on the session at creation and returns them unchanged from bootstrap
|
|
63
|
+
(`session.launchOptions`); it never redirects to them itself — only the
|
|
64
|
+
Verification Client that renders the flow does. Set `diagnostics: true` on the
|
|
65
|
+
same request only for deliberate troubleshooting, since diagnostic logs can
|
|
66
|
+
contain personal data; Builder appends `diag=1` to `verificationUrl` for that
|
|
67
|
+
session and strips any `diag` the consumer's own `verificationClientUrl` carries.
|
|
68
|
+
|
|
69
|
+
An optional `themeId` selects an active organization theme. If it is absent,
|
|
70
|
+
Builder snapshots the organization's most recently updated active theme. A
|
|
71
|
+
localized consent block tells supported clients to show consent before the
|
|
72
|
+
first provider. Branding and theme data don't affect proof trust.
|
|
73
|
+
|
|
74
|
+
## Call the direct Builder API
|
|
75
|
+
|
|
76
|
+
In `api=2` mode, send the registered client UUID in `x-reclaim-vc-id` on every
|
|
77
|
+
request. Generate the client from `packages/app/openapi.yaml`; don't hand-write
|
|
78
|
+
route types or proxy these calls through `api.reclaimprotocol.org`.
|
|
79
|
+
The UUID must match the session, but it is public and doesn't authenticate the
|
|
80
|
+
caller.
|
|
81
|
+
|
|
82
|
+
| Route | Purpose |
|
|
83
|
+
| --- | --- |
|
|
84
|
+
| `GET /verifications/sessions/{sessionId}/bootstrap` | Load the session, resolved recipes, runtime configuration, branding, and theme. |
|
|
85
|
+
| `PATCH /verifications/sessions/{sessionId}/claimant` | Update the latest claimant and device snapshot. |
|
|
86
|
+
| `POST /verifications/sessions/{sessionId}/events` | Report canonical lower-snake-case analytics events. |
|
|
87
|
+
| `POST /verifications/sessions/{sessionId}/attestor-auth` | Request session-bound attestor authentication. Don't send a legacy application secret or provider signature. |
|
|
88
|
+
| `POST /verifications/sessions/{sessionId}/results` | Submit exact proof objects or a terminal error/cancellation. Builder atomically records the canonical outcome and prepares signed callback delivery. |
|
|
89
|
+
|
|
90
|
+
URLs without `api=2` stay on each client's existing legacy path. Builder mode
|
|
91
|
+
must not call legacy lifecycle, application-info, or result APIs.
|
|
92
|
+
|
|
93
|
+
## Preserve and verify proofs
|
|
94
|
+
|
|
95
|
+
Verification Clients put each exact proof in the Builder result. They
|
|
96
|
+
don't reverify proofs. Builder signs the outer result JWS without
|
|
97
|
+
rewriting the proof.
|
|
98
|
+
|
|
99
|
+
Consumers call `verifyResultFull` on their backend. It verifies the registered
|
|
100
|
+
Builder issuer, outer JWS, session, audience, and every proof with the local
|
|
101
|
+
`verifyRequestProof` implementation. Treat outer `extracted_parameters` and
|
|
102
|
+
`content_hash` as diagnostics, not trusted proof inputs.
|
|
103
|
+
|
|
104
|
+
Results are delivered to the org's registered callback subscriptions
|
|
105
|
+
(`POST /orgs/{orgId}/callback-subscriptions`), plaintext by default. When the
|
|
106
|
+
org has enabled `canEncryptResult` on its secp256k1 keypair
|
|
107
|
+
(`PUT /orgs/{orgId}/keypair`), Builder ECIES-encrypts the terminal payload to
|
|
108
|
+
that public key instead; decrypt it with `@reclaimprotocol/client`'s
|
|
109
|
+
`decryptCallback`/`verifyResult` and the org's eth private key before treating
|
|
110
|
+
it as a result. A session created without `canEncryptResult` never needs this
|
|
111
|
+
step. Troubleshoot a stuck or failed session with `get_verification_session`,
|
|
112
|
+
`list_verification_events`, and `list_org_verification_sessions`.
|
|
113
|
+
|
|
114
|
+
## Use the browser extension
|
|
115
|
+
|
|
116
|
+
For an `api=2` URL, use
|
|
117
|
+
`reclaimExtensionSDK.fromVerificationUrl` or `initBuilder` with the returned
|
|
118
|
+
`verificationClientId`, then call `startVerification()`. The extension sends
|
|
119
|
+
`x-reclaim-vc-id`, loads recipes from bootstrap, runs them sequentially, and
|
|
120
|
+
submits the raw proofs. It doesn't perform redundant `allowedJsRequests`
|
|
121
|
+
validation. Missing or unknown `api` values keep the existing `init`,
|
|
122
|
+
`fromJsonString`, and direct-callback behavior.
|
|
123
|
+
|
|
124
|
+
## Bind a TEE nonce when required
|
|
125
|
+
|
|
126
|
+
A consumer can pass `orgEthPrivateKey` to `sessions.create`. The SDK derives the
|
|
127
|
+
legacy-compatible nonce locally, signs the binding payload with EIP-191, and
|
|
128
|
+
calls `PUT /verifications/sessions/{sessionId}/tee-nonce` with the organization
|
|
129
|
+
token. The private key stays in the consumer process. Bind before proof
|
|
130
|
+
generation; the same binding is idempotent and a different binding is rejected.
|
package/src/consts.ts
CHANGED
|
@@ -64,12 +64,13 @@ export function reclaimHome(): string {
|
|
|
64
64
|
|
|
65
65
|
/**
|
|
66
66
|
* `USE_OLD_DEVTOOLS` — single source of truth for which backend the MCP
|
|
67
|
-
* server targets.
|
|
68
|
-
*
|
|
69
|
-
* `USE_OLD_DEVTOOLS=false`; anything else keeps old mode on.
|
|
67
|
+
* server targets. Builder is the default. Set `USE_OLD_DEVTOOLS=true` to
|
|
68
|
+
* explicitly use the legacy backend.
|
|
70
69
|
*/
|
|
71
70
|
export function useOldDevtools(): boolean {
|
|
72
|
-
return
|
|
71
|
+
return ['true', '1'].includes(
|
|
72
|
+
(process.env.USE_OLD_DEVTOOLS ?? '').trim().toLowerCase(),
|
|
73
|
+
)
|
|
73
74
|
}
|
|
74
75
|
|
|
75
76
|
/** True when `USE_OLD_DEVTOOLS` is set to a non-empty value (explicit). */
|
|
@@ -79,7 +80,8 @@ function oldDevtoolsEnvSet(): boolean {
|
|
|
79
80
|
|
|
80
81
|
/**
|
|
81
82
|
* Effective mode, layering the persisted preference under the env var:
|
|
82
|
-
* explicit `USE_OLD_DEVTOOLS` wins → persisted config `mode` →
|
|
83
|
+
* explicit `USE_OLD_DEVTOOLS` wins → persisted config `mode` →
|
|
84
|
+
* default (builder).
|
|
83
85
|
* The persisted value comes from `~/.reclaim/config.json` (set via the
|
|
84
86
|
* `set_devtools_mode` tool); the caller reads it so this module needn't import
|
|
85
87
|
* `ConfigStore` (which would create an import cycle).
|
|
@@ -93,13 +95,13 @@ export function resolveOldMode(persisted?: 'old' | 'builder'): boolean {
|
|
|
93
95
|
return persisted === 'old'
|
|
94
96
|
}
|
|
95
97
|
|
|
96
|
-
return
|
|
98
|
+
return false
|
|
97
99
|
}
|
|
98
100
|
|
|
99
101
|
/**
|
|
100
102
|
* Where the effective mode came from — the same precedence as
|
|
101
103
|
* `resolveOldMode`: explicit `USE_OLD_DEVTOOLS` env var → persisted config
|
|
102
|
-
* `mode` → default (
|
|
104
|
+
* `mode` → default (builder). Surfaced by the `get_devtools_mode` tool so the
|
|
103
105
|
* user can tell why the server is in the mode it reports.
|
|
104
106
|
*/
|
|
105
107
|
export function oldModeSource(
|