@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.
Files changed (91) 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 +247 -4
  6. package/lib/mcp/api/operations.gen.js +6519 -337
  7. package/lib/mcp/api/tools.d.ts +10 -2
  8. package/lib/mcp/api/tools.js +55 -4
  9. package/lib/mcp/instructions.js +11 -11
  10. package/lib/mcp/server.d.ts +1 -1
  11. package/lib/mcp/server.js +3 -0
  12. package/lib/mcp/start.js +6 -1
  13. package/lib/mcp/success-response.js +5 -1
  14. package/lib/mcp/tools/agent/analyze.js +5 -4
  15. package/lib/mcp/tools/agent/attach.js +11 -7
  16. package/lib/mcp/tools/agent/build.js +3 -1
  17. package/lib/mcp/tools/agent/capture.d.ts +2 -2
  18. package/lib/mcp/tools/agent/capture.js +15 -11
  19. package/lib/mcp/tools/agent/eval.js +4 -3
  20. package/lib/mcp/tools/agent/find.js +9 -10
  21. package/lib/mcp/tools/agent/how-it-works.js +1 -0
  22. package/lib/mcp/tools/agent/live-view.js +10 -7
  23. package/lib/mcp/tools/agent/pod-proof.js +7 -11
  24. package/lib/mcp/tools/agent/propose.js +4 -3
  25. package/lib/mcp/tools/agent/publish.d.ts +2 -1
  26. package/lib/mcp/tools/agent/publish.js +12 -6
  27. package/lib/mcp/tools/agent/replay.js +10 -7
  28. package/lib/mcp/tools/agent/session.js +16 -8
  29. package/lib/mcp/tools/agent/shared.js +3 -2
  30. package/lib/mcp/tools/agent/start-integration.d.ts +15 -0
  31. package/lib/mcp/tools/agent/start-integration.js +61 -0
  32. package/lib/mcp/tools/authenticate/authenticate.js +9 -11
  33. package/lib/mcp/tools/authenticate/build.js +2 -0
  34. package/lib/mcp/tools/authenticate/builder-access.js +1 -0
  35. package/lib/mcp/tools/authenticate/eth-key.d.ts +8 -0
  36. package/lib/mcp/tools/authenticate/eth-key.js +27 -15
  37. package/lib/mcp/tools/authenticate/import.js +18 -31
  38. package/lib/mcp/tools/authenticate/issue-org-token.d.ts +8 -0
  39. package/lib/mcp/tools/authenticate/issue-org-token.js +60 -0
  40. package/lib/mcp/tools/authenticate/issue.js +9 -9
  41. package/lib/mcp/tools/authenticate/org-key-store.d.ts +10 -0
  42. package/lib/mcp/tools/authenticate/org-key-store.js +23 -0
  43. package/lib/mcp/tools/authenticate/resolve-owner-key.js +10 -12
  44. package/lib/mcp/tools/mode/mode.js +2 -0
  45. package/lib/mcp/tools/verification/result.js +52 -12
  46. package/lib/tools/registry.d.ts +12 -0
  47. package/lib/tools/registry.js +1 -0
  48. package/package.json +2 -2
  49. package/skill/SKILL.builder.md +77 -73
  50. package/skill/SKILL.common.md +2 -1
  51. package/skill/builder-mode.md +135 -120
  52. package/skill/start-integration.md +49 -0
  53. package/skill/user-script.md +64 -0
  54. package/skill/verification-client-integration.md +131 -28
  55. package/src/authoring/backend.ts +15 -0
  56. package/src/authoring/index.ts +2 -0
  57. package/src/authoring/tools.ts +86 -42
  58. package/src/config/store.ts +11 -0
  59. package/src/mcp/api/operations.gen.ts +6563 -373
  60. package/src/mcp/api/tools.ts +70 -5
  61. package/src/mcp/instructions.ts +11 -11
  62. package/src/mcp/server.ts +4 -0
  63. package/src/mcp/start.ts +6 -1
  64. package/src/mcp/success-response.ts +5 -1
  65. package/src/mcp/tools/agent/analyze.ts +5 -4
  66. package/src/mcp/tools/agent/attach.ts +11 -7
  67. package/src/mcp/tools/agent/build.ts +5 -1
  68. package/src/mcp/tools/agent/capture.ts +20 -12
  69. package/src/mcp/tools/agent/eval.ts +4 -3
  70. package/src/mcp/tools/agent/find.ts +9 -10
  71. package/src/mcp/tools/agent/how-it-works.ts +1 -0
  72. package/src/mcp/tools/agent/live-view.ts +10 -7
  73. package/src/mcp/tools/agent/pod-proof.ts +7 -11
  74. package/src/mcp/tools/agent/propose.ts +4 -3
  75. package/src/mcp/tools/agent/publish.ts +12 -4
  76. package/src/mcp/tools/agent/replay.ts +10 -7
  77. package/src/mcp/tools/agent/session.ts +16 -8
  78. package/src/mcp/tools/agent/shared.ts +7 -2
  79. package/src/mcp/tools/agent/start-integration.ts +83 -0
  80. package/src/mcp/tools/authenticate/authenticate.ts +9 -11
  81. package/src/mcp/tools/authenticate/build.ts +2 -0
  82. package/src/mcp/tools/authenticate/builder-access.ts +1 -0
  83. package/src/mcp/tools/authenticate/eth-key.ts +48 -18
  84. package/src/mcp/tools/authenticate/import.ts +21 -36
  85. package/src/mcp/tools/authenticate/issue-org-token.ts +84 -0
  86. package/src/mcp/tools/authenticate/issue.ts +9 -9
  87. package/src/mcp/tools/authenticate/org-key-store.ts +25 -0
  88. package/src/mcp/tools/authenticate/resolve-owner-key.ts +10 -12
  89. package/src/mcp/tools/mode/mode.ts +2 -0
  90. package/src/mcp/tools/verification/result.ts +58 -13
  91. 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 — read it from
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
- 'RECLAIM_ORG_SECRET is not set. Verification reads authenticate with ' +
31
- 'the org secret (rorg_…) — issue one from the dashboard ' +
32
- '(POST /orgs/{orgId}/token) and export it as RECLAIM_ORG_SECRET.',
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
- + 'Requires `RECLAIM_ORG_SECRET`; encrypted deliveries also require '
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 { items } = resultRes.data
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
- note: 'Session is terminal but no result has been submitted yet.',
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
 
@@ -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
  }