@reclaimprotocol/agent 0.1.4 → 0.1.6

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 (126) hide show
  1. package/README.md +5 -5
  2. package/lib/authoring/backend.d.ts +71 -0
  3. package/lib/authoring/backend.js +24 -0
  4. package/lib/authoring/find.d.ts +3 -0
  5. package/lib/authoring/find.js +54 -0
  6. package/lib/authoring/index.d.ts +4 -0
  7. package/lib/authoring/index.js +6 -0
  8. package/lib/authoring/propose.d.ts +3 -0
  9. package/lib/authoring/propose.js +109 -0
  10. package/lib/authoring/replay.d.ts +10 -0
  11. package/lib/authoring/replay.js +34 -0
  12. package/lib/authoring/tools.d.ts +16 -0
  13. package/lib/authoring/tools.js +193 -0
  14. package/lib/authoring/util.d.ts +27 -0
  15. package/lib/authoring/util.js +21 -0
  16. package/lib/cdp/capture-engine.js +1 -1
  17. package/lib/consts.d.ts +6 -1
  18. package/lib/consts.js +9 -2
  19. package/lib/mcp/api/operations.gen.js +46 -18
  20. package/lib/mcp/server.d.ts +2 -25
  21. package/lib/mcp/server.js +4 -17
  22. package/lib/mcp/start.js +4 -2
  23. package/lib/mcp/tools/agent/analyze.js +3 -3
  24. package/lib/mcp/tools/agent/build.d.ts +4 -4
  25. package/lib/mcp/tools/agent/build.js +13 -15
  26. package/lib/mcp/tools/agent/capture.d.ts +13 -1
  27. package/lib/mcp/tools/agent/capture.js +18 -85
  28. package/lib/mcp/tools/agent/eval.d.ts +5 -2
  29. package/lib/mcp/tools/agent/eval.js +11 -121
  30. package/lib/mcp/tools/agent/find.d.ts +10 -3
  31. package/lib/mcp/tools/agent/find.js +25 -31
  32. package/lib/mcp/tools/agent/proof.d.ts +13 -3
  33. package/lib/mcp/tools/agent/proof.js +81 -132
  34. package/lib/mcp/tools/agent/propose.d.ts +10 -9
  35. package/lib/mcp/tools/agent/propose.js +87 -64
  36. package/lib/mcp/tools/agent/publish.js +2 -2
  37. package/lib/mcp/tools/agent/replay.d.ts +10 -3
  38. package/lib/mcp/tools/agent/replay.js +29 -36
  39. package/lib/mcp/tools/agent/session.d.ts +1 -3
  40. package/lib/mcp/tools/agent/session.js +5 -5
  41. package/lib/mcp/tools/agent/shared.d.ts +8 -0
  42. package/lib/mcp/tools/agent/shared.js +125 -0
  43. package/lib/old/client.d.ts +35 -0
  44. package/lib/old/client.js +18 -0
  45. package/lib/old/login-cdp.d.ts +24 -0
  46. package/lib/old/login-cdp.js +28 -3
  47. package/lib/old/sdk-client.d.ts +39 -0
  48. package/lib/old/sdk-client.js +85 -0
  49. package/lib/old/to-register.d.ts +69 -0
  50. package/lib/old/to-register.js +52 -2
  51. package/lib/old/tools/build.d.ts +6 -1
  52. package/lib/old/tools/build.js +11 -1
  53. package/lib/old/tools/get-provider-info.d.ts +16 -0
  54. package/lib/old/tools/get-provider-info.js +73 -0
  55. package/lib/old/tools/get-version-config.d.ts +17 -0
  56. package/lib/old/tools/get-version-config.js +47 -0
  57. package/lib/old/tools/publish.js +189 -2
  58. package/lib/old/tools/update-provider-metadata.d.ts +16 -0
  59. package/lib/old/tools/update-provider-metadata.js +61 -0
  60. package/lib/proof/attestor.d.ts +6 -3
  61. package/lib/proof/attestor.js +10 -1
  62. package/lib/proof/debug-response-dump.d.ts +4 -0
  63. package/lib/proof/debug-response-dump.js +55 -0
  64. package/lib/proof/patch-domhandler.d.ts +1 -0
  65. package/lib/proof/patch-domhandler.js +59 -0
  66. package/lib/proof/proof-core.d.ts +1 -1
  67. package/lib/proof/proof-core.js +1 -1
  68. package/lib/proof/zk-files.js +7 -6
  69. package/lib/provider/dom-xpath.d.ts +17 -0
  70. package/lib/provider/dom-xpath.js +187 -0
  71. package/lib/provider/draft.d.ts +30 -2
  72. package/lib/provider/draft.js +117 -28
  73. package/lib/provider/index.d.ts +4 -0
  74. package/lib/provider/index.js +7 -0
  75. package/lib/provider/injection-doc.js +6 -0
  76. package/lib/provider/matcher.d.ts +17 -20
  77. package/lib/provider/matcher.js +394 -280
  78. package/lib/provider/schema.d.ts +7 -5
  79. package/lib/tools/registry.d.ts +50 -0
  80. package/lib/tools/registry.js +49 -0
  81. package/package.json +9 -1
  82. package/skill/SKILL.builder.md +55 -32
  83. package/skill/SKILL.old.md +20 -12
  84. package/skill/builder-mode.md +1 -1
  85. package/skill/injection-api.md +117 -0
  86. package/src/authoring/backend.ts +98 -0
  87. package/src/authoring/index.ts +20 -0
  88. package/src/authoring/tools.ts +273 -0
  89. package/src/authoring/util.ts +42 -0
  90. package/src/cdp/capture-engine.ts +1 -1
  91. package/src/consts.ts +15 -2
  92. package/src/mcp/api/operations.gen.ts +46 -18
  93. package/src/mcp/server.ts +9 -39
  94. package/src/mcp/start.ts +4 -1
  95. package/src/mcp/tools/agent/analyze.ts +3 -3
  96. package/src/mcp/tools/agent/build.ts +13 -21
  97. package/src/mcp/tools/agent/capture.ts +31 -115
  98. package/src/mcp/tools/agent/eval.ts +19 -155
  99. package/src/mcp/tools/agent/find.ts +33 -36
  100. package/src/mcp/tools/agent/proof.ts +87 -160
  101. package/src/mcp/tools/agent/propose.ts +93 -85
  102. package/src/mcp/tools/agent/publish.ts +2 -2
  103. package/src/mcp/tools/agent/replay.ts +32 -42
  104. package/src/mcp/tools/agent/session.ts +4 -5
  105. package/src/mcp/tools/agent/shared.ts +152 -0
  106. package/src/old/client.ts +56 -0
  107. package/src/old/login-cdp.ts +28 -3
  108. package/src/old/sdk-client.ts +105 -0
  109. package/src/old/to-register.ts +98 -6
  110. package/src/old/tools/build.ts +12 -0
  111. package/src/old/tools/get-provider-info.ts +91 -0
  112. package/src/old/tools/get-version-config.ts +56 -0
  113. package/src/old/tools/publish.ts +244 -1
  114. package/src/old/tools/update-provider-metadata.ts +72 -0
  115. package/src/proof/attestor.ts +16 -4
  116. package/src/proof/debug-response-dump.ts +70 -0
  117. package/src/proof/patch-domhandler.ts +68 -0
  118. package/src/proof/proof-core.ts +1 -1
  119. package/src/proof/zk-files.ts +7 -6
  120. package/src/provider/dom-xpath.ts +225 -0
  121. package/src/provider/draft.ts +168 -35
  122. package/src/provider/index.ts +8 -0
  123. package/src/provider/injection-doc.ts +6 -0
  124. package/src/provider/matcher.ts +477 -357
  125. package/src/provider/schema.ts +7 -5
  126. package/src/tools/registry.ts +92 -0
@@ -2,160 +2,24 @@ import { listTabs } from '../../../cdp/tabs.ts'
2
2
  import { defineTool, type RegisteredTool } from '../../server.ts'
3
3
  import type { AttachState } from './attach.ts'
4
4
 
5
- export function browserTools(attachRef: {
5
+ /** The one browser tool that isn't session-bound: enumerate tabs so the caller
6
+ * can pick one to `start_capture` on. Navigate/eval/wait are the shared
7
+ * authoring tools (keyed by captureId — see `shared.ts`). */
8
+ export function listTabsTool(attachRef: {
6
9
  current?: AttachState
7
- }): RegisteredTool[] {
8
- const requireAttached = (): AttachState => {
9
- if(!attachRef.current) {
10
- throw new Error('Not attached. Call attach_chrome first.')
11
- }
12
-
13
- return attachRef.current
14
- }
15
-
16
- return [
17
- defineTool<Record<string, never>>(
18
- {
19
- name: 'list_tabs',
20
- description: 'List open Chrome tabs.',
21
- inputSchema: { type: 'object', properties: {} },
22
- },
23
- async() => {
24
- const attached = requireAttached()
25
- return { tabs: await listTabs(attached.port) }
26
- },
27
- ),
28
- defineTool<{ tabId: string, expression: string }>(
29
- {
30
- name: 'eval_in_page',
31
- description:
32
- 'Run a JS expression in a tab via Runtime.evaluate ' +
33
- 'and return the result. ' +
34
- 'Useful for reading visible values from the DOM.',
35
- inputSchema: {
36
- type: 'object',
37
- properties: {
38
- tabId: { type: 'string' },
39
- expression: { type: 'string' },
40
- },
41
- required: ['tabId', 'expression'],
42
- },
43
- },
44
- async({ tabId, expression }) => {
45
- const attached = requireAttached()
46
- const { Runtime } = await attached.handles.attachToTab(tabId)
47
- const result = await Runtime.evaluate({
48
- expression,
49
- returnByValue: true,
50
- })
51
- if(result.exceptionDetails) {
52
- return { error: result.exceptionDetails.text }
53
- }
54
-
55
- return { value: result.result.value }
56
- },
57
- ),
58
- defineTool<{ tabId: string, url: string, timeoutMs?: number }>(
59
- {
60
- name: 'navigate',
61
- description:
62
- 'Navigate a tab to a URL via Page.navigate, ' +
63
- 'waiting for the load event. ' +
64
- 'Use this to drive the browser yourself ' +
65
- 'instead of asking the developer to navigate. ' +
66
- 'Returns the final URL after navigation ' +
67
- '(which may differ from the requested URL due to redirects).',
68
- inputSchema: {
69
- type: 'object',
70
- properties: {
71
- tabId: { type: 'string' },
72
- url: { type: 'string' },
73
- timeoutMs: { type: 'number' },
74
- },
75
- required: ['tabId', 'url'],
76
- },
77
- },
78
- async({ tabId, url, timeoutMs }) => {
79
- const attached = requireAttached()
80
- const { Page, Runtime } = await attached.handles.attachToTab(tabId)
81
-
82
- await Page.enable()
83
- const loadPromise = new Promise<void>((resolve) => {
84
- Page.loadEventFired(() => resolve())
85
- })
86
- const nav = await Page.navigate({ url })
87
- if(nav.errorText) {
88
- return { ok: false, error: nav.errorText }
89
- }
90
-
91
- const t = timeoutMs ?? 30_000
92
- const raced = await Promise.race([
93
- loadPromise.then(() => 'loaded' as const),
94
- new Promise<'timeout'>(
95
- (resolve) => setTimeout(() => resolve('timeout'), t),
96
- ),
97
- ])
98
- const final = await Runtime.evaluate({
99
- expression: 'location.href',
100
- returnByValue: true,
101
- })
102
- return {
103
- ok: true,
104
- loadStatus: raced,
105
- finalUrl: final.result.value,
106
- }
107
- },
108
- ),
109
- defineTool<{
110
- tabId: string
111
- expression: string
112
- timeoutMs?: number
113
- pollMs?: number
114
- }>(
115
- {
116
- name: 'wait_for_page',
117
- description:
118
- 'Poll a JS expression in a tab until it ' +
119
- 'returns truthy (or timeout). ' +
120
- 'Use this for steps that require the ' +
121
- 'developer to do something in the browser — ' +
122
- 'most commonly waiting for them to finish logging in. ' +
123
- 'Pass an expression that ' +
124
- 'evaluates true once the desired state is reached, e.g. ' +
125
- '`!!document.querySelector' +
126
- '(\'summary[aria-label*="View profile"]\')`' +
127
- ' for GitHub post-login.',
128
- inputSchema: {
129
- type: 'object',
130
- properties: {
131
- tabId: { type: 'string' },
132
- expression: { type: 'string' },
133
- timeoutMs: { type: 'number' },
134
- pollMs: { type: 'number' },
135
- },
136
- required: ['tabId', 'expression'],
137
- },
138
- },
139
- async({ tabId, expression, timeoutMs, pollMs }) => {
140
- const attached = requireAttached()
141
- const { Runtime } = await attached.handles.attachToTab(tabId)
142
- const deadline = Date.now() + (timeoutMs ?? 120_000)
143
- const interval = pollMs ?? 1000
144
- while(Date.now() < deadline) {
145
- const r = await Runtime.evaluate({ expression, returnByValue: true })
146
- if(r.exceptionDetails) {
147
- return { matched: false, error: r.exceptionDetails.text }
148
- }
149
-
150
- if(r.result.value) {
151
- return { matched: true, value: r.result.value }
152
- }
153
-
154
- await new Promise((resolve) => setTimeout(resolve, interval))
155
- }
156
-
157
- return { matched: false, reason: 'timeout' }
158
- },
159
- ),
160
- ]
10
+ }): RegisteredTool {
11
+ return defineTool<Record<string, never>>(
12
+ {
13
+ name: 'list_tabs',
14
+ description: 'List open Chrome tabs.',
15
+ inputSchema: { type: 'object', properties: {} },
16
+ },
17
+ async() => {
18
+ if(!attachRef.current) {
19
+ throw new Error('Not attached. Call attach_chrome first.')
20
+ }
21
+
22
+ return { tabs: await listTabs(attachRef.current.port) }
23
+ },
24
+ )
161
25
  }
@@ -1,36 +1,37 @@
1
+ /**
2
+ * `find_requests_containing` — search captured responses for any encoding of a
3
+ * value and rank the requests that return it. Authored once as a plain
4
+ * {@link RegisteredTool}; the MCP and cloud loop each pass their own backend
5
+ * resolver (see authoring/tools.ts / shared.ts). Server-side: response bodies
6
+ * stay here, only metadata + a short snippet leave.
7
+ */
8
+ import {
9
+ objectSchema,
10
+ publicRequest,
11
+ type ResolveBackend,
12
+ } from '../../../authoring/util.ts'
1
13
  import { normalizeCandidates } from '../../../provider/normalize.ts'
2
- import { defineTool, type RegisteredTool } from '../../server.ts'
3
- import type { CaptureStore } from './capture.ts'
14
+ import { defineTool, type RegisteredTool } from '../../../tools/registry.ts'
4
15
 
5
- export function findTool(captures: CaptureStore): RegisteredTool {
6
- return defineTool<{ captureId: string, value: string, limit?: number }>(
16
+ export function findTool(resolveBackend: ResolveBackend): RegisteredTool {
17
+ return defineTool<Record<string, unknown>>(
7
18
  {
8
19
  name: 'find_requests_containing',
9
20
  description:
10
- 'Search captured responses for any encoding of `value`.' +
11
- 'Returns a ranked candidate list ' +
12
- 'with the JSON path (when applicable), score, and a short snippet.' +
13
- 'Server-side; bodies stay here.',
14
- inputSchema: {
15
- type: 'object',
16
- properties: {
17
- captureId: { type: 'string' },
18
- value: { type: 'string' },
19
- limit: { type: 'number' },
20
- },
21
- required: ['captureId', 'value'],
22
- },
21
+ 'Search captured responses for any encoding of `value` (raw, '
22
+ + 'URL/JSON/HTML-escaped, …). Returns a ranked candidate list with '
23
+ + 'the matched variant, score, and a short snippet — used to locate '
24
+ + 'the request that returns a target. Server-side; bodies stay here.',
25
+ inputSchema: objectSchema(
26
+ { value: { type: 'string' }, limit: { type: 'number' } },
27
+ ['value'],
28
+ ),
23
29
  },
24
- async({ captureId, value, limit }) => {
25
- const session = captures.sessions.get(captureId)
26
- if(!session) {
27
- throw new Error(`no capture ${captureId}`)
28
- }
29
-
30
- const variants = normalizeCandidates(value)
31
-
30
+ async(args) => {
31
+ const backend = resolveBackend(args)
32
+ const variants = normalizeCandidates(String(args.value))
32
33
  const ranked = []
33
- for(const r of session.requests.values()) {
34
+ for(const r of backend.capture.requests.values()) {
34
35
  if(!r.responseBody) {
35
36
  continue
36
37
  }
@@ -50,16 +51,11 @@ export function findTool(captures: CaptureStore): RegisteredTool {
50
51
  continue
51
52
  }
52
53
 
53
- // Score: prefer JSON responses + smaller bodies (likely API endpoints).
54
- const score =
55
- (r.contentType.includes('json') ? 10 : 0) +
56
- Math.max(0, 5 - Math.log10(Math.max(r.size, 1)))
54
+ // Prefer JSON responses + smaller bodies (likely API endpoints).
55
+ const score = (r.contentType.includes('json') ? 10 : 0)
56
+ + Math.max(0, 5 - Math.log10(Math.max(r.size, 1)))
57
57
  ranked.push({
58
- requestId: r.requestId,
59
- url: r.url,
60
- method: r.method,
61
- status: r.status,
62
- contentType: r.contentType,
58
+ ...publicRequest(r),
63
59
  matchedVariant: hit.variant,
64
60
  snippet: hit.snippet,
65
61
  score,
@@ -67,7 +63,8 @@ export function findTool(captures: CaptureStore): RegisteredTool {
67
63
  }
68
64
 
69
65
  ranked.sort((a, b) => b.score - a.score)
70
- return { candidates: ranked.slice(0, limit ?? 10) }
66
+ const limit = Number(args.limit) || 10
67
+ return { candidates: ranked.slice(0, limit) }
71
68
  },
72
69
  )
73
70
  }
@@ -3,13 +3,10 @@ import { join } from 'node:path'
3
3
  import { agentTraceEnabled } from '../../../consts.ts'
4
4
  import { reclaimHomeDirPath } from '../../../paths.ts'
5
5
  import {
6
- runAttestorProof,
6
+ type ProofResult,
7
7
  tailLogs,
8
8
  warnsAndErrors,
9
9
  } from '../../../proof/attestor.ts'
10
- import type { ReclaimProvider } from '../../../provider/schema.ts'
11
- import { defineTool, type RegisteredTool } from '../../server.ts'
12
- import type { SecretStore } from './propose.ts'
13
10
 
14
11
  function claimsDir(): string {
15
12
  return join(reclaimHomeDirPath(), 'claims')
@@ -98,170 +95,100 @@ function isLikelyByteArray(v: unknown[]): boolean {
98
95
  return true
99
96
  }
100
97
 
101
- export function proofTool(secrets: SecretStore): RegisteredTool {
102
- return defineTool<{
103
- provider: unknown
104
- secretParamsRef?: string
105
- attestorUrl?: string
106
- ownerAddress?: string
107
- }>(
108
- {
109
- name: 'run_proof',
110
- description:
111
- 'Run a full zkTLS proof through the Reclaim attestor SDK. ' +
112
- 'Use only after replay_request ' +
113
- 'returns matchesOriginal=true — attestor calls are expensive. ' +
114
- 'Writes the full claim to ' +
115
- '~/.reclaim/claims/<timestamp>.json and ' +
116
- 'returns identifier + extractedParameters + ' +
117
- 'claimPath + a prettified `claim` field ' +
118
- '(request dropped, byte arrays as base64) suitable ' +
119
- 'for displaying directly to the dev. ' +
120
- 'When the MCP server is started with ' +
121
- '`RECLAIM_AGENT_TRACE=1`, ALSO writes ' +
122
- 'a per-call diagnostic dump (input provider, ' +
123
- 'sentParams the SDK saw post-substitution, ' +
124
- 'FULL attestor log stream, result) to ' +
125
- '~/.reclaim/proof-runs/<timestamp>.json and ' +
126
- 'returns the path as `runLogPath`. ' +
127
- '`attestorUrl` overrides the default attestor URL only when the dev ' +
128
- 'supplies a specific ' +
129
- 'alternative — do NOT invent backup URLs ' +
130
- '(there is one live public attestor right now; ' +
131
- 'surface real errors to the dev instead of guessing). ' +
132
- '`ownerAddress` (the credential to sign with) is REQUIRED — ' +
133
- 'call resolve_owner_key first to obtain it, then pass it here. ' +
134
- 'errorKind="missing-owner-key" means that address has no known ' +
135
- 'private key; re-run resolve_owner_key or issue/import a credential.',
136
- inputSchema: {
137
- type: 'object',
138
- properties: {
139
- provider: { type: 'object', properties: {} },
140
- secretParamsRef: { type: 'string' },
141
- attestorUrl: { type: 'string' },
142
- ownerAddress: {
143
- type: 'string',
144
- pattern: '^0x[0-9a-fA-F]{40}$',
145
- description:
146
- 'ETH address of the credential to sign the claim with. ' +
147
- 'Get it from resolve_owner_key first. The private key is ' +
148
- 'resolved locally (cache / env / .env) — never passed here.',
149
- },
150
- },
151
- required: ['provider', 'ownerAddress'],
152
- },
153
- },
154
- async({ provider, secretParamsRef, attestorUrl, ownerAddress }) => {
155
- let resolved: Record<string, string> = {}
156
- if(secretParamsRef !== undefined) {
157
- const r = secrets.resolve(secretParamsRef)
158
- if(!r) {
159
- throw new Error(
160
- `unknown secretParamsRef "${secretParamsRef}" — ` +
161
- 'the MCP server has restarted or reset_session was called. ' +
162
- 'Re-run propose_provider to mint a fresh ref.',
163
- )
164
- }
165
-
166
- resolved = r
167
- }
168
-
169
- const result = await runAttestorProof(
170
- provider as ReclaimProvider,
171
- resolved,
172
- { attestorUrl, ownerAddress },
173
- )
174
-
175
- // Persist the full claim to disk for the dev to inspect/share.
176
- let claimPath: string | undefined
177
- if(result.proof !== undefined && result.proof !== null) {
178
- try {
179
- mkdirSync(claimsDir(), { recursive: true })
180
- claimPath = join(claimsDir(), `${Date.now()}.json`)
181
- writeFileSync(
182
- claimPath,
183
- JSON.stringify(result.proof, null, 2),
184
- 'utf8',
185
- )
186
- } catch{
187
- // Persistence is best-effort; don't fail the proof for it.
188
- claimPath = undefined
189
- }
190
- }
98
+ /**
99
+ * The MCP's rich `run_proof` view: persist the full claim to disk, return
100
+ * identifier + extractedParameters + a prettified claim (request dropped, byte
101
+ * arrays as base64) + trimmed logs, and — under `RECLAIM_AGENT_TRACE=1` — a
102
+ * forensic run dump. This is the developer-facing shape; the cloud backend
103
+ * projects the same {@link ProofResult} to a lean summary instead.
104
+ */
105
+ export function shapeRichProofResult(
106
+ result: ProofResult,
107
+ opts: { provider: unknown, hasSecrets: boolean, attestorUrl?: string },
108
+ ): Record<string, unknown> {
109
+ // Persist the full claim to disk for the dev to inspect/share.
110
+ let claimPath: string | undefined
111
+ if(result.proof !== undefined && result.proof !== null) {
112
+ try {
113
+ mkdirSync(claimsDir(), { recursive: true })
114
+ claimPath = join(claimsDir(), `${Date.now()}.json`)
115
+ writeFileSync(claimPath, JSON.stringify(result.proof, null, 2), 'utf8')
116
+ } catch{
117
+ // Persistence is best-effort; don't fail the proof for it.
118
+ claimPath = undefined
119
+ }
120
+ }
191
121
 
192
- const out: Record<string, unknown> = {
193
- verified: result.verified,
194
- extractedValue: result.extractedValue,
195
- extractedParameters: result.extractedParameters,
196
- }
197
- if(result.identifier !== undefined) {
198
- out.identifier = result.identifier
199
- }
122
+ const out: Record<string, unknown> = {
123
+ verified: result.verified,
124
+ extractedValue: result.extractedValue,
125
+ extractedParameters: result.extractedParameters,
126
+ }
127
+ if(result.identifier !== undefined) {
128
+ out.identifier = result.identifier
129
+ }
200
130
 
201
- if(result.owner !== undefined) {
202
- out.owner = result.owner
203
- }
131
+ if(result.owner !== undefined) {
132
+ out.owner = result.owner
133
+ }
204
134
 
205
- if(claimPath !== undefined) {
206
- out.claimPath = claimPath
207
- }
135
+ if(claimPath !== undefined) {
136
+ out.claimPath = claimPath
137
+ }
208
138
 
209
- if(result.proof !== undefined && result.proof !== null) {
210
- out.claim = prettifyClaim(result.proof)
211
- }
139
+ if(result.proof !== undefined && result.proof !== null) {
140
+ out.claim = prettifyClaim(result.proof)
141
+ }
212
142
 
213
- if(result.error !== undefined) {
214
- out.error = result.error
215
- }
143
+ if(result.error !== undefined) {
144
+ out.error = result.error
145
+ }
216
146
 
217
- if(result.errorKind !== undefined) {
218
- out.errorKind = result.errorKind
219
- }
147
+ if(result.errorKind !== undefined) {
148
+ out.errorKind = result.errorKind
149
+ }
220
150
 
221
- // Trim the LLM-visible logs — full stream goes to runLogPath.
222
- if(result.attestorLogs !== undefined && result.attestorLogs.length > 0) {
223
- out.attestorLogs = result.verified
224
- ? warnsAndErrors(result.attestorLogs)
225
- : tailLogs(result.attestorLogs)
226
- if((out.attestorLogs as unknown[]).length === 0) {
227
- delete out.attestorLogs
228
- }
229
- }
151
+ // Trim the LLM-visible logs — full stream goes to runLogPath.
152
+ if(result.attestorLogs !== undefined && result.attestorLogs.length > 0) {
153
+ out.attestorLogs = result.verified
154
+ ? warnsAndErrors(result.attestorLogs)
155
+ : tailLogs(result.attestorLogs)
156
+ if((out.attestorLogs as unknown[]).length === 0) {
157
+ delete out.attestorLogs
158
+ }
159
+ }
230
160
 
231
- if(result.sentParams !== undefined) {
232
- out.sentParams = result.sentParams
233
- }
161
+ if(result.sentParams !== undefined) {
162
+ out.sentParams = result.sentParams
163
+ }
234
164
 
235
- // Persist a diagnostic dump for forensics — gated behind
236
- // RECLAIM_AGENT_TRACE=1 (matches the attestor logger capture).
237
- // Off by default since happy-path runs don't need it; turn on
238
- // when investigating proof failures and the file at runLogPath
239
- // will carry the input provider, sentParams, full attestor log
240
- // stream, and result.
241
- if(agentTraceEnabled()) {
242
- const runLogPath = writeProofRunDump({
243
- provider,
244
- hasSecretParamsRef: secretParamsRef !== undefined,
245
- attestorUrl,
246
- result: {
247
- verified: result.verified,
248
- error: result.error,
249
- errorKind: result.errorKind,
250
- extractedValue: result.extractedValue,
251
- extractedParameters: result.extractedParameters,
252
- identifier: result.identifier,
253
- owner: result.owner,
254
- sentParams: result.sentParams,
255
- attestorLogs: result.attestorLogs,
256
- claimPath,
257
- },
258
- })
259
- if(runLogPath !== undefined) {
260
- out.runLogPath = runLogPath
261
- }
262
- }
165
+ // Persist a diagnostic dump for forensics — gated behind
166
+ // RECLAIM_AGENT_TRACE=1 (matches the attestor logger capture). Off by
167
+ // default since happy-path runs don't need it; turn on when investigating
168
+ // proof failures and the file at runLogPath will carry the input provider,
169
+ // sentParams, full attestor log stream, and result.
170
+ if(agentTraceEnabled()) {
171
+ const runLogPath = writeProofRunDump({
172
+ provider: opts.provider,
173
+ hasSecretParamsRef: opts.hasSecrets,
174
+ attestorUrl: opts.attestorUrl,
175
+ result: {
176
+ verified: result.verified,
177
+ error: result.error,
178
+ errorKind: result.errorKind,
179
+ extractedValue: result.extractedValue,
180
+ extractedParameters: result.extractedParameters,
181
+ identifier: result.identifier,
182
+ owner: result.owner,
183
+ sentParams: result.sentParams,
184
+ attestorLogs: result.attestorLogs,
185
+ claimPath,
186
+ },
187
+ })
188
+ if(runLogPath !== undefined) {
189
+ out.runLogPath = runLogPath
190
+ }
191
+ }
263
192
 
264
- return out
265
- },
266
- )
193
+ return out
267
194
  }