@reclaimprotocol/agent 0.1.32 → 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.
- package/lib/authoring/backend.d.ts +13 -0
- package/lib/authoring/index.d.ts +1 -1
- package/lib/authoring/tools.js +78 -42
- package/lib/config/store.d.ts +10 -0
- package/lib/mcp/api/operations.gen.d.ts +247 -4
- package/lib/mcp/api/operations.gen.js +6519 -337
- package/lib/mcp/api/tools.d.ts +10 -2
- package/lib/mcp/api/tools.js +55 -4
- package/lib/mcp/instructions.js +11 -11
- package/lib/mcp/server.d.ts +1 -1
- package/lib/mcp/server.js +3 -0
- package/lib/mcp/start.js +6 -1
- package/lib/mcp/success-response.js +5 -1
- package/lib/mcp/tools/agent/analyze.js +5 -4
- package/lib/mcp/tools/agent/attach.js +11 -7
- package/lib/mcp/tools/agent/build.js +3 -1
- package/lib/mcp/tools/agent/capture.d.ts +2 -2
- package/lib/mcp/tools/agent/capture.js +15 -11
- package/lib/mcp/tools/agent/eval.js +4 -3
- package/lib/mcp/tools/agent/find.js +9 -10
- package/lib/mcp/tools/agent/how-it-works.js +1 -0
- package/lib/mcp/tools/agent/live-view.js +10 -7
- package/lib/mcp/tools/agent/pod-proof.js +7 -11
- package/lib/mcp/tools/agent/propose.js +4 -3
- package/lib/mcp/tools/agent/publish.d.ts +2 -1
- package/lib/mcp/tools/agent/publish.js +12 -6
- package/lib/mcp/tools/agent/replay.js +10 -7
- package/lib/mcp/tools/agent/session.js +16 -8
- package/lib/mcp/tools/agent/shared.js +3 -2
- package/lib/mcp/tools/agent/start-integration.d.ts +15 -0
- package/lib/mcp/tools/agent/start-integration.js +61 -0
- package/lib/mcp/tools/authenticate/authenticate.js +9 -11
- package/lib/mcp/tools/authenticate/build.js +2 -0
- package/lib/mcp/tools/authenticate/builder-access.js +1 -0
- package/lib/mcp/tools/authenticate/eth-key.d.ts +8 -0
- package/lib/mcp/tools/authenticate/eth-key.js +27 -15
- package/lib/mcp/tools/authenticate/import.js +18 -31
- package/lib/mcp/tools/authenticate/issue-org-token.d.ts +8 -0
- package/lib/mcp/tools/authenticate/issue-org-token.js +60 -0
- package/lib/mcp/tools/authenticate/issue.js +9 -9
- package/lib/mcp/tools/authenticate/org-key-store.d.ts +10 -0
- package/lib/mcp/tools/authenticate/org-key-store.js +23 -0
- package/lib/mcp/tools/authenticate/resolve-owner-key.js +10 -12
- package/lib/mcp/tools/mode/mode.js +2 -0
- package/lib/mcp/tools/verification/result.js +52 -12
- package/lib/tools/registry.d.ts +12 -0
- package/lib/tools/registry.js +1 -0
- package/package.json +2 -2
- package/skill/SKILL.builder.md +77 -73
- package/skill/SKILL.common.md +2 -1
- package/skill/builder-mode.md +135 -120
- package/skill/start-integration.md +49 -0
- package/skill/user-script.md +64 -0
- package/skill/verification-client-integration.md +131 -28
- package/src/authoring/backend.ts +15 -0
- package/src/authoring/index.ts +2 -0
- package/src/authoring/tools.ts +86 -42
- package/src/config/store.ts +11 -0
- package/src/mcp/api/operations.gen.ts +6563 -373
- package/src/mcp/api/tools.ts +70 -5
- package/src/mcp/instructions.ts +11 -11
- package/src/mcp/server.ts +4 -0
- package/src/mcp/start.ts +6 -1
- package/src/mcp/success-response.ts +5 -1
- package/src/mcp/tools/agent/analyze.ts +5 -4
- package/src/mcp/tools/agent/attach.ts +11 -7
- package/src/mcp/tools/agent/build.ts +5 -1
- package/src/mcp/tools/agent/capture.ts +20 -12
- package/src/mcp/tools/agent/eval.ts +4 -3
- package/src/mcp/tools/agent/find.ts +9 -10
- package/src/mcp/tools/agent/how-it-works.ts +1 -0
- package/src/mcp/tools/agent/live-view.ts +10 -7
- package/src/mcp/tools/agent/pod-proof.ts +7 -11
- package/src/mcp/tools/agent/propose.ts +4 -3
- package/src/mcp/tools/agent/publish.ts +12 -4
- package/src/mcp/tools/agent/replay.ts +10 -7
- package/src/mcp/tools/agent/session.ts +16 -8
- package/src/mcp/tools/agent/shared.ts +7 -2
- package/src/mcp/tools/agent/start-integration.ts +83 -0
- package/src/mcp/tools/authenticate/authenticate.ts +9 -11
- package/src/mcp/tools/authenticate/build.ts +2 -0
- package/src/mcp/tools/authenticate/builder-access.ts +1 -0
- package/src/mcp/tools/authenticate/eth-key.ts +48 -18
- package/src/mcp/tools/authenticate/import.ts +21 -36
- package/src/mcp/tools/authenticate/issue-org-token.ts +84 -0
- package/src/mcp/tools/authenticate/issue.ts +9 -9
- package/src/mcp/tools/authenticate/org-key-store.ts +25 -0
- package/src/mcp/tools/authenticate/resolve-owner-key.ts +10 -12
- package/src/mcp/tools/mode/mode.ts +2 -0
- package/src/mcp/tools/verification/result.ts +58 -13
- package/src/tools/registry.ts +14 -0
|
@@ -7,6 +7,7 @@ import assert from 'node:assert'
|
|
|
7
7
|
import { apiUrl, orgSecret } from '../../../consts.ts'
|
|
8
8
|
import { defineTool, type RegisteredTool } from '../../server.ts'
|
|
9
9
|
import { resolveDecryptionKey } from '../authenticate/decrypt-key.ts'
|
|
10
|
+
import { savedOrgKey } from '../authenticate/org-key-store.ts'
|
|
10
11
|
|
|
11
12
|
/** Statuses that can carry a Builder-managed terminal result. */
|
|
12
13
|
const TERMINAL = new Set([
|
|
@@ -17,19 +18,28 @@ const TERMINAL = new Set([
|
|
|
17
18
|
'expired',
|
|
18
19
|
])
|
|
19
20
|
|
|
21
|
+
/** Events whose delivery is a signed result; the rest are plaintext event
|
|
22
|
+
* notifications. Mirrors `verification_result_events()`. */
|
|
23
|
+
const RESULT_EVENTS = new Set([
|
|
24
|
+
'verification_success',
|
|
25
|
+
'verification_rejected',
|
|
26
|
+
'verification_error',
|
|
27
|
+
'verification_cancelled',
|
|
28
|
+
])
|
|
29
|
+
|
|
20
30
|
/**
|
|
21
31
|
* Resolve the org secret used to authenticate verification reads. Auth is a
|
|
22
|
-
* single per-org bearer secret (`rorg_…`), not an eth signature
|
|
23
|
-
* `RECLAIM_ORG_SECRET`.
|
|
32
|
+
* single per-org bearer secret (`rorg_…`), not an eth signature: the call's
|
|
33
|
+
* `orgToken`, else `RECLAIM_ORG_SECRET`.
|
|
24
34
|
*/
|
|
25
|
-
function resolveOrgSecret(): string {
|
|
26
|
-
const secret = orgSecret()?.trim()
|
|
35
|
+
function resolveOrgSecret(orgToken?: string): string {
|
|
36
|
+
const secret = orgToken?.trim() || orgSecret()?.trim() || savedOrgKey()
|
|
27
37
|
assert(
|
|
28
38
|
secret,
|
|
29
39
|
new Error(
|
|
30
|
-
'
|
|
31
|
-
'
|
|
32
|
-
'
|
|
40
|
+
'No organization API key. Verification reads authenticate with the org '
|
|
41
|
+
+ 'secret (rorg_…): run issue_org_token to save a key, pass orgToken, '
|
|
42
|
+
+ 'or export RECLAIM_ORG_SECRET for the MCP server.',
|
|
33
43
|
),
|
|
34
44
|
)
|
|
35
45
|
return secret
|
|
@@ -46,12 +56,16 @@ function resolveOrgSecret(): string {
|
|
|
46
56
|
* Decryption, when needed, happens here.
|
|
47
57
|
*/
|
|
48
58
|
export function verificationResultTool(): RegisteredTool {
|
|
49
|
-
return defineTool<{ reclaimSessionId: string }>(
|
|
59
|
+
return defineTool<{ reclaimSessionId: string, orgToken?: string }>(
|
|
50
60
|
{
|
|
51
61
|
name: 'get_verification_result',
|
|
52
62
|
description:
|
|
53
|
-
'Fetches and verifies a terminal Builder result for one session
|
|
54
|
-
+ '
|
|
63
|
+
'Fetches and verifies a terminal Builder result for one session, '
|
|
64
|
+
+ 'while Builder still holds it: until its callback is delivered, or '
|
|
65
|
+
+ '7 days undelivered. The callback is the normal way to get results. '
|
|
66
|
+
+ 'Authenticates with the org API key: `orgToken`, else '
|
|
67
|
+
+ '`RECLAIM_ORG_SECRET`, else the key saved by `issue_org_token`. '
|
|
68
|
+
+ 'Encrypted deliveries also require '
|
|
55
69
|
+ 'the matching ETH decryption key. Returns `ready: false` until a '
|
|
56
70
|
+ 'payload is available. Invalid results fail verification and are not '
|
|
57
71
|
+ 'returned. Use `list_verification_events` to diagnose '
|
|
@@ -65,11 +79,22 @@ export function verificationResultTool(): RegisteredTool {
|
|
|
65
79
|
description:
|
|
66
80
|
'The verification session id from create_verification_session.',
|
|
67
81
|
},
|
|
82
|
+
orgToken: {
|
|
83
|
+
type: 'string',
|
|
84
|
+
pattern: '^rorg_',
|
|
85
|
+
maxLength: 200,
|
|
86
|
+
description: 'The organization API key (`rorg_…`): from '
|
|
87
|
+
+ '`issue_org_token`, or the app\'s RECLAIM_ORG_SECRET. '
|
|
88
|
+
+ 'Defaults to the MCP server\'s RECLAIM_ORG_SECRET, then the '
|
|
89
|
+
+ 'key saved by `issue_org_token`. Never echo it back to the '
|
|
90
|
+
+ 'user.',
|
|
91
|
+
},
|
|
68
92
|
},
|
|
69
93
|
},
|
|
94
|
+
annotations: { readOnlyHint: true, openWorldHint: true },
|
|
70
95
|
},
|
|
71
96
|
async(args) => {
|
|
72
|
-
const secret = resolveOrgSecret()
|
|
97
|
+
const secret = resolveOrgSecret(args.orgToken)
|
|
73
98
|
// Optional eth decryption key — absent ⇒ plaintext-only.
|
|
74
99
|
const decryptionKey: DecryptionKey | undefined =
|
|
75
100
|
await resolveDecryptionKey()
|
|
@@ -91,14 +116,34 @@ export function verificationResultTool(): RegisteredTool {
|
|
|
91
116
|
const resultRes = await reclaim.api('GetVerificationResult', {
|
|
92
117
|
params: { sessionId: args.reclaimSessionId },
|
|
93
118
|
})
|
|
94
|
-
const
|
|
119
|
+
const signed = resultRes.data.items
|
|
120
|
+
.filter((item) => RESULT_EVENTS.has(item.event))
|
|
121
|
+
if(!signed.length) {
|
|
122
|
+
return {
|
|
123
|
+
reclaimSessionId: args.reclaimSessionId,
|
|
124
|
+
status,
|
|
125
|
+
ready: false,
|
|
126
|
+
note: 'Session is terminal but no result is stored: none submitted '
|
|
127
|
+
+ 'yet, or no callback subscription covers its ending event.',
|
|
128
|
+
}
|
|
129
|
+
}
|
|
95
130
|
|
|
131
|
+
// Builder keeps a result (which can carry proofs) only until its
|
|
132
|
+
// callback is delivered, or 7 days undelivered.
|
|
133
|
+
const items = signed.flatMap((item) => (
|
|
134
|
+
item.payload === null ? [] : [{ ...item, payload: item.payload }]
|
|
135
|
+
))
|
|
96
136
|
if(!items.length) {
|
|
97
137
|
return {
|
|
98
138
|
reclaimSessionId: args.reclaimSessionId,
|
|
99
139
|
status,
|
|
100
140
|
ready: false,
|
|
101
|
-
|
|
141
|
+
delivered: signed.some((item) => (
|
|
142
|
+
item.deliveryStatus === 'delivered'
|
|
143
|
+
)),
|
|
144
|
+
note: 'Builder no longer holds this result: it was delivered to '
|
|
145
|
+
+ 'the callback (read it there), or went undelivered for 7 days. '
|
|
146
|
+
+ 'See list_verification_deliveries.',
|
|
102
147
|
}
|
|
103
148
|
}
|
|
104
149
|
|
package/src/tools/registry.ts
CHANGED
|
@@ -16,10 +16,23 @@ import { isProblemDetails, isProblemError } from '@reclaimprotocol/client/api'
|
|
|
16
16
|
import type { JSONSchema } from 'zod/v4/core'
|
|
17
17
|
import { toZod } from '../mcp/api/to-zod.ts'
|
|
18
18
|
|
|
19
|
+
/** MCP tool hints that let a client decide when to ask for approval. */
|
|
20
|
+
export interface ToolAnnotations {
|
|
21
|
+
/** The tool never changes state. */
|
|
22
|
+
readOnlyHint?: boolean
|
|
23
|
+
/** The tool can delete or overwrite state. */
|
|
24
|
+
destructiveHint?: boolean
|
|
25
|
+
/** Repeating a call with the same input has no further effect. */
|
|
26
|
+
idempotentHint?: boolean
|
|
27
|
+
/** The tool reaches systems outside this machine. */
|
|
28
|
+
openWorldHint?: boolean
|
|
29
|
+
}
|
|
30
|
+
|
|
19
31
|
export interface ToolDefinition {
|
|
20
32
|
name: string
|
|
21
33
|
description: string
|
|
22
34
|
inputSchema: JSONSchema.ObjectSchema
|
|
35
|
+
annotations?: ToolAnnotations
|
|
23
36
|
}
|
|
24
37
|
|
|
25
38
|
export interface RegisteredTool {
|
|
@@ -108,6 +121,7 @@ export function extendTool(
|
|
|
108
121
|
name: base.name,
|
|
109
122
|
description: extra.description ?? base.description,
|
|
110
123
|
inputSchema,
|
|
124
|
+
...(base.annotations ? { annotations: base.annotations } : {}),
|
|
111
125
|
},
|
|
112
126
|
handler: tool.handler,
|
|
113
127
|
}
|