@nuanu-ai/agentbrowse 0.2.46 → 0.2.48

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 (190) hide show
  1. package/README.md +69 -10
  2. package/dist/agentpay-gateway.d.ts +9 -0
  3. package/dist/agentpay-gateway.d.ts.map +1 -1
  4. package/dist/agentpay-gateway.js +30 -0
  5. package/dist/agentpay-stagehand-llm.d.ts.map +1 -1
  6. package/dist/agentpay-stagehand-llm.js +9 -1
  7. package/dist/command-api-tracing.d.ts +19 -0
  8. package/dist/command-api-tracing.d.ts.map +1 -0
  9. package/dist/command-api-tracing.js +137 -0
  10. package/dist/commands/act.d.ts.map +1 -1
  11. package/dist/commands/act.js +822 -670
  12. package/dist/commands/act.test-harness.d.ts +6 -0
  13. package/dist/commands/act.test-harness.d.ts.map +1 -1
  14. package/dist/commands/act.test-harness.js +44 -1
  15. package/dist/commands/action-acceptance.d.ts.map +1 -1
  16. package/dist/commands/action-acceptance.js +115 -0
  17. package/dist/commands/captcha-solve.d.ts.map +1 -1
  18. package/dist/commands/captcha-solve.js +83 -16
  19. package/dist/commands/click-action-executor.d.ts +0 -1
  20. package/dist/commands/click-action-executor.d.ts.map +1 -1
  21. package/dist/commands/click-action-executor.js +31 -77
  22. package/dist/commands/close.d.ts +3 -3
  23. package/dist/commands/close.d.ts.map +1 -1
  24. package/dist/commands/close.js +178 -0
  25. package/dist/commands/descriptor-validation.d.ts.map +1 -1
  26. package/dist/commands/descriptor-validation.js +75 -57
  27. package/dist/commands/end-session.d.ts +25 -0
  28. package/dist/commands/end-session.d.ts.map +1 -0
  29. package/dist/commands/end-session.js +161 -0
  30. package/dist/commands/extract-stagehand-executor.js +1 -1
  31. package/dist/commands/extract.d.ts.map +1 -1
  32. package/dist/commands/extract.js +339 -202
  33. package/dist/commands/fill-secret.d.ts +3 -3
  34. package/dist/commands/fill-secret.d.ts.map +1 -1
  35. package/dist/commands/fill-secret.js +419 -234
  36. package/dist/commands/get-secrets-catalog.d.ts.map +1 -1
  37. package/dist/commands/get-secrets-catalog.js +66 -5
  38. package/dist/commands/interaction-kernel.d.ts +46 -0
  39. package/dist/commands/interaction-kernel.d.ts.map +1 -0
  40. package/dist/commands/interaction-kernel.js +215 -0
  41. package/dist/commands/launch.d.ts +0 -2
  42. package/dist/commands/launch.d.ts.map +1 -1
  43. package/dist/commands/launch.js +109 -17
  44. package/dist/commands/navigate.d.ts.map +1 -1
  45. package/dist/commands/navigate.js +188 -45
  46. package/dist/commands/observe-accessibility.d.ts.map +1 -1
  47. package/dist/commands/observe-accessibility.js +50 -39
  48. package/dist/commands/observe-dom-label-contract.d.ts.map +1 -1
  49. package/dist/commands/observe-dom-label-contract.js +5 -0
  50. package/dist/commands/observe-inventory.d.ts +13 -0
  51. package/dist/commands/observe-inventory.d.ts.map +1 -1
  52. package/dist/commands/observe-inventory.js +320 -65
  53. package/dist/commands/observe-persistence.d.ts.map +1 -1
  54. package/dist/commands/observe-persistence.js +3 -0
  55. package/dist/commands/observe-projection.d.ts +1 -0
  56. package/dist/commands/observe-projection.d.ts.map +1 -1
  57. package/dist/commands/observe-projection.js +7 -2
  58. package/dist/commands/observe-protected.d.ts +1 -0
  59. package/dist/commands/observe-protected.d.ts.map +1 -1
  60. package/dist/commands/observe-protected.js +9 -4
  61. package/dist/commands/observe-semantics.d.ts.map +1 -1
  62. package/dist/commands/observe-semantics.js +5 -2
  63. package/dist/commands/observe-stagehand.d.ts +1 -0
  64. package/dist/commands/observe-stagehand.d.ts.map +1 -1
  65. package/dist/commands/observe-stagehand.js +2 -0
  66. package/dist/commands/observe.d.ts +2 -0
  67. package/dist/commands/observe.d.ts.map +1 -1
  68. package/dist/commands/observe.js +387 -203
  69. package/dist/commands/observe.test-harness.d.ts +8 -0
  70. package/dist/commands/observe.test-harness.d.ts.map +1 -1
  71. package/dist/commands/observe.test-harness.js +48 -1
  72. package/dist/commands/poll-secret.d.ts +6 -0
  73. package/dist/commands/poll-secret.d.ts.map +1 -0
  74. package/dist/commands/poll-secret.js +159 -0
  75. package/dist/commands/request-secret.d.ts +6 -0
  76. package/dist/commands/request-secret.d.ts.map +1 -0
  77. package/dist/commands/request-secret.js +284 -0
  78. package/dist/commands/screenshot.d.ts.map +1 -1
  79. package/dist/commands/screenshot.js +172 -7
  80. package/dist/commands/select-action-executor.d.ts.map +1 -1
  81. package/dist/commands/semantic-observe.d.ts +4 -0
  82. package/dist/commands/semantic-observe.d.ts.map +1 -1
  83. package/dist/commands/semantic-observe.js +388 -17
  84. package/dist/commands/start-session.d.ts +31 -0
  85. package/dist/commands/start-session.d.ts.map +1 -0
  86. package/dist/commands/start-session.js +347 -0
  87. package/dist/commands/status.d.ts +2 -1
  88. package/dist/commands/status.d.ts.map +1 -1
  89. package/dist/commands/status.js +166 -144
  90. package/dist/control-semantics.d.ts +1 -0
  91. package/dist/control-semantics.d.ts.map +1 -1
  92. package/dist/control-semantics.js +51 -9
  93. package/dist/index.d.ts.map +1 -1
  94. package/dist/index.js +144 -45
  95. package/dist/otel-exporter.d.ts +58 -0
  96. package/dist/otel-exporter.d.ts.map +1 -0
  97. package/dist/otel-exporter.js +263 -0
  98. package/dist/otel-projector.d.ts +75 -0
  99. package/dist/otel-projector.d.ts.map +1 -0
  100. package/dist/otel-projector.js +409 -0
  101. package/dist/owned-browser.d.ts +1 -1
  102. package/dist/owned-browser.d.ts.map +1 -1
  103. package/dist/owned-browser.js +13 -1
  104. package/dist/owned-process.d.ts +2 -0
  105. package/dist/owned-process.d.ts.map +1 -1
  106. package/dist/owned-process.js +7 -3
  107. package/dist/playwright-runtime.d.ts +1 -1
  108. package/dist/playwright-runtime.d.ts.map +1 -1
  109. package/dist/playwright-runtime.js +8 -8
  110. package/dist/run-observability.d.ts +25 -0
  111. package/dist/run-observability.d.ts.map +1 -0
  112. package/dist/run-observability.js +115 -0
  113. package/dist/run-store.d.ts +274 -0
  114. package/dist/run-store.d.ts.map +1 -0
  115. package/dist/run-store.js +631 -0
  116. package/dist/runtime-metrics.d.ts +27 -0
  117. package/dist/runtime-metrics.d.ts.map +1 -0
  118. package/dist/runtime-metrics.js +66 -0
  119. package/dist/runtime-page-state.d.ts +11 -0
  120. package/dist/runtime-page-state.d.ts.map +1 -0
  121. package/dist/runtime-page-state.js +62 -0
  122. package/dist/runtime-protected-state.d.ts +16 -0
  123. package/dist/runtime-protected-state.d.ts.map +1 -0
  124. package/dist/runtime-protected-state.js +157 -0
  125. package/dist/runtime-state.d.ts +10 -44
  126. package/dist/runtime-state.d.ts.map +1 -1
  127. package/dist/runtime-state.js +57 -222
  128. package/dist/secrets/backend.d.ts +65 -16
  129. package/dist/secrets/backend.d.ts.map +1 -1
  130. package/dist/secrets/backend.js +135 -95
  131. package/dist/secrets/catalog-sync.d.ts.map +1 -1
  132. package/dist/secrets/catalog-sync.js +4 -1
  133. package/dist/secrets/form-matcher.d.ts +5 -5
  134. package/dist/secrets/form-matcher.d.ts.map +1 -1
  135. package/dist/secrets/form-matcher.js +292 -164
  136. package/dist/secrets/intent-output.d.ts +6 -10
  137. package/dist/secrets/intent-output.d.ts.map +1 -1
  138. package/dist/secrets/intent-output.js +4 -58
  139. package/dist/secrets/mock-agentpay-cabinet.d.ts +38 -27
  140. package/dist/secrets/mock-agentpay-cabinet.d.ts.map +1 -1
  141. package/dist/secrets/mock-agentpay-cabinet.js +177 -111
  142. package/dist/secrets/protected-artifact-guard.d.ts +2 -2
  143. package/dist/secrets/protected-artifact-guard.d.ts.map +1 -1
  144. package/dist/secrets/protected-artifact-guard.js +2 -2
  145. package/dist/secrets/protected-bindings.d.ts +1 -1
  146. package/dist/secrets/protected-bindings.d.ts.map +1 -1
  147. package/dist/secrets/protected-bindings.js +6 -0
  148. package/dist/secrets/protected-field-semantics.d.ts +9 -0
  149. package/dist/secrets/protected-field-semantics.d.ts.map +1 -0
  150. package/dist/secrets/protected-field-semantics.js +154 -0
  151. package/dist/secrets/protected-field-values.d.ts.map +1 -1
  152. package/dist/secrets/protected-field-values.js +3 -3
  153. package/dist/secrets/protected-fill.d.ts +1 -1
  154. package/dist/secrets/protected-fill.d.ts.map +1 -1
  155. package/dist/secrets/protected-fill.js +45 -149
  156. package/dist/secrets/protected-value-adapters.d.ts +2 -1
  157. package/dist/secrets/protected-value-adapters.d.ts.map +1 -1
  158. package/dist/secrets/protected-value-adapters.js +80 -1
  159. package/dist/secrets/request-output.d.ts +11 -0
  160. package/dist/secrets/request-output.d.ts.map +1 -0
  161. package/dist/secrets/request-output.js +75 -0
  162. package/dist/secrets/types.d.ts +15 -9
  163. package/dist/secrets/types.d.ts.map +1 -1
  164. package/dist/secrets/types.js +3 -0
  165. package/dist/session-event-exporter.d.ts +36 -0
  166. package/dist/session-event-exporter.d.ts.map +1 -0
  167. package/dist/session-event-exporter.js +428 -0
  168. package/dist/session.d.ts +16 -7
  169. package/dist/session.d.ts.map +1 -1
  170. package/dist/session.js +150 -23
  171. package/dist/sessions-backend.d.ts +354 -0
  172. package/dist/sessions-backend.d.ts.map +1 -0
  173. package/dist/sessions-backend.js +126 -0
  174. package/dist/solver/browser-launcher.d.ts +1 -1
  175. package/dist/solver/browser-launcher.d.ts.map +1 -1
  176. package/dist/solver/browser-launcher.js +39 -13
  177. package/dist/solver/captcha-solver.d.ts.map +1 -1
  178. package/dist/solver/captcha-solver.js +8 -1
  179. package/dist/solver/types.d.ts +1 -0
  180. package/dist/solver/types.d.ts.map +1 -1
  181. package/dist/workflow-session-completion.d.ts +33 -0
  182. package/dist/workflow-session-completion.d.ts.map +1 -0
  183. package/dist/workflow-session-completion.js +156 -0
  184. package/package.json +9 -1
  185. package/dist/commands/create-intent.d.ts +0 -6
  186. package/dist/commands/create-intent.d.ts.map +0 -1
  187. package/dist/commands/create-intent.js +0 -75
  188. package/dist/commands/poll-intent.d.ts +0 -6
  189. package/dist/commands/poll-intent.d.ts.map +0 -1
  190. package/dist/commands/poll-intent.js +0 -57
@@ -1,41 +1,66 @@
1
1
  import { tryResolveAgentpayGatewayConfig } from '../agentpay-gateway.js';
2
+ import { AgentpayRequestError, claimRemoteSecret, createRemoteSecretRequest, getRemoteSessionSecretCatalog, getRemoteSecretRequest, } from '../sessions-backend.js';
2
3
  import { resolveHostFromInput, resolveMockStoredSecretValues, syncMockSecretCatalog, } from './mock-agentpay-backend.js';
3
- import { createOrReuseMockSecretIntent, getMockSecretIntent, markMockSecretIntentCompleted, } from './mock-agentpay-cabinet.js';
4
+ import { approveMockSecretRequest, claimMockSecretRequest, createOrReuseMockSecretRequest, denyMockSecretRequest, getMockSecretRequest, } from './mock-agentpay-cabinet.js';
4
5
  const ENABLE_MOCK_SECRETS_ENV = 'AGENTBROWSE_ENABLE_MOCK_SECRETS';
5
- const APPROVAL_CHANNEL = 'agentpay-cabinet';
6
- function tryParseJsonRecord(value) {
7
- try {
8
- const parsed = JSON.parse(value);
9
- return parsed && typeof parsed === 'object' && !Array.isArray(parsed)
10
- ? parsed
11
- : null;
12
- }
13
- catch {
14
- return null;
15
- }
6
+ function asJsonRecord(value) {
7
+ return value && typeof value === 'object' && !Array.isArray(value)
8
+ ? { ...value }
9
+ : {};
16
10
  }
17
- function formatAgentpayBackendError(status, text) {
18
- const parsed = text ? tryParseJsonRecord(text) : null;
19
- if (!parsed) {
20
- return `agentpay_secret_backend_http_${status}${text ? `:${text}` : ''}`;
21
- }
22
- if (typeof parsed.error === 'string' && parsed.error.length > 0) {
23
- return `agentpay_secret_backend_http_${status}:${parsed.error}`;
11
+ function pickFirstString(record, keys) {
12
+ for (const key of keys) {
13
+ const value = record[key];
14
+ if (typeof value === 'string' && value.trim().length > 0) {
15
+ return value.trim();
16
+ }
24
17
  }
25
- return `agentpay_secret_backend_http_${status}${text ? `:${text}` : ''}`;
18
+ return undefined;
26
19
  }
27
- function envFlagEnabled(value) {
28
- if (!value) {
29
- return false;
30
- }
31
- const normalized = value.trim().toLowerCase();
32
- return normalized === '1' || normalized === 'true' || normalized === 'yes' || normalized === 'on';
20
+ function mapRemoteSessionState(response) {
21
+ return {
22
+ sessionId: response.session.id,
23
+ status: response.session.status,
24
+ currentRequestId: response.current_request?.id ?? null,
25
+ lastEventSeq: response.session.last_event_seq,
26
+ browserSessionId: response.browser_session_id,
27
+ };
33
28
  }
34
- export class SecretBackendDisabledError extends Error {
35
- constructor(message = 'Mock secret backend is disabled for this build/runtime.') {
36
- super(message);
37
- this.name = 'SecretBackendDisabledError';
38
- }
29
+ function mapSessionRequestToSnapshot(request) {
30
+ const payload = asJsonRecord(request.payload);
31
+ const storedSecret = asJsonRecord(payload.stored_secret);
32
+ return {
33
+ requestId: request.id,
34
+ fillRef: pickFirstString(payload, ['fill_ref', 'fillRef']) ?? '',
35
+ requestType: request.type === 'secret_write' ? 'secret_write' : 'secret_read',
36
+ status: request.status,
37
+ storedSecretRef: pickFirstString(payload, ['stored_secret_ref', 'storedSecretRef']) ??
38
+ pickFirstString(storedSecret, ['id']),
39
+ kind: payload.kind === 'login' || payload.kind === 'identity' || payload.kind === 'payment_card'
40
+ ? payload.kind
41
+ : undefined,
42
+ host: pickFirstString(payload, ['host']),
43
+ pageRef: pickFirstString(asJsonRecord(payload.page), ['ref']),
44
+ scopeRef: pickFirstString(payload, ['scope_ref', 'scopeRef']),
45
+ createdAt: request.created_at,
46
+ updatedAt: request.updated_at,
47
+ ...(request.expires_at ? { expiresAt: request.expires_at } : {}),
48
+ ...(request.resolved_at ? { resolvedAt: request.resolved_at } : {}),
49
+ };
50
+ }
51
+ function mapClaimedSecret(response) {
52
+ return {
53
+ requestId: response.request_id,
54
+ issuedAt: response.issued_at,
55
+ expiresAt: response.expires_at ?? undefined,
56
+ secret: {
57
+ values: { ...response.secret.values },
58
+ source: response.secret.source,
59
+ storedSecretRef: response.secret.stored_secret_ref ?? undefined,
60
+ credentialId: response.secret.credential_id ?? undefined,
61
+ kind: response.secret.kind ?? undefined,
62
+ },
63
+ };
39
64
  }
40
65
  function toStoredSecretFieldKeys(fields) {
41
66
  return fields
@@ -70,71 +95,63 @@ function mapApiCatalogEntryToStoredSecret(entry, host) {
70
95
  : { target: 'host', value: host },
71
96
  };
72
97
  }
73
- function mapApiIntentResponse(intent) {
74
- const metadata = intent.metadata && typeof intent.metadata === 'object'
75
- ? intent.metadata
76
- : {};
77
- return {
78
- intentId: intent.id,
79
- fillRef: typeof metadata.fill_ref === 'string' ? metadata.fill_ref : '',
80
- storedSecretRef: typeof metadata.secret_id === 'string' ? metadata.secret_id : '',
81
- status: intent.status,
82
- approvalChannel: APPROVAL_CHANNEL,
83
- host: typeof metadata.host === 'string' ? metadata.host : undefined,
84
- scopeRef: typeof metadata.scope_ref === 'string' ? metadata.scope_ref : undefined,
85
- createdAt: intent.created_at,
86
- };
87
- }
88
- async function requestAgentpay(method, path, body) {
89
- const gateway = tryResolveAgentpayGatewayConfig();
90
- if (!gateway) {
91
- throw new SecretBackendDisabledError('Secret backend is not configured. AgentPay API key is required.');
98
+ function envFlagEnabled(value) {
99
+ if (!value) {
100
+ return false;
92
101
  }
93
- const response = await fetch(`${gateway.apiUrl}${path}`, {
94
- method,
95
- headers: {
96
- Authorization: `Bearer ${gateway.apiKey}`,
97
- 'Content-Type': 'application/json',
98
- },
99
- ...(body ? { body: JSON.stringify(body) } : {}),
100
- });
101
- if (!response.ok) {
102
- const text = await response.text().catch(() => '');
103
- throw new Error(formatAgentpayBackendError(response.status, text));
102
+ const normalized = value.trim().toLowerCase();
103
+ return normalized === '1' || normalized === 'true' || normalized === 'yes' || normalized === 'on';
104
+ }
105
+ export class SecretBackendDisabledError extends Error {
106
+ constructor(message = 'Mock secret backend is disabled for this build/runtime.') {
107
+ super(message);
108
+ this.name = 'SecretBackendDisabledError';
104
109
  }
105
- return (await response.json());
106
110
  }
107
111
  const mockSecretBackend = {
108
112
  kind: 'mock',
109
113
  resolveCatalogHost: resolveHostFromInput,
110
- async syncSecretCatalog(urlOrHost) {
114
+ async syncSecretCatalog(_sessionId, urlOrHost) {
111
115
  return syncMockSecretCatalog(urlOrHost);
112
116
  },
113
- async createOrReuseSecretIntent(input) {
114
- return createOrReuseMockSecretIntent(input);
117
+ async createOrReuseSecretRequest(input) {
118
+ return createOrReuseMockSecretRequest({
119
+ sessionId: input.sessionId,
120
+ clientRequestId: input.clientRequestId,
121
+ fillRef: input.fillRef,
122
+ purpose: input.purpose,
123
+ merchantName: input.merchantName,
124
+ host: input.secretHint.host ?? resolveHostFromInput(input.page?.url ?? input.fillRef),
125
+ pageRef: input.page?.ref ?? 'p0',
126
+ scopeRef: input.secretHint.scopeRef,
127
+ storedSecretRef: input.secretHint.storedSecretRef,
128
+ kind: input.secretHint.kind,
129
+ fields: input.secretHint.fields,
130
+ });
115
131
  },
116
- async getSecretIntent(intentId) {
117
- const snapshot = getMockSecretIntent(intentId);
118
- if (!snapshot) {
132
+ async getSecretRequest(sessionId, requestId) {
133
+ const request = getMockSecretRequest(sessionId, requestId);
134
+ if (!request) {
119
135
  return null;
120
136
  }
121
- if (snapshot.status !== 'approved') {
122
- return { snapshot };
123
- }
124
- const deliveredValues = resolveMockStoredSecretValues(snapshot.storedSecretRef) ?? undefined;
125
- const completed = markMockSecretIntentCompleted(intentId);
126
137
  return {
127
- snapshot: completed,
128
- deliveredValues,
138
+ snapshot: request.snapshot,
139
+ session: request.session,
129
140
  };
130
141
  },
142
+ async claimSecretRequest(sessionId, requestId, claimId) {
143
+ const claimed = claimMockSecretRequest(sessionId, requestId, claimId, {
144
+ resolveValues: (storedSecretRef) => resolveMockStoredSecretValues(storedSecretRef),
145
+ });
146
+ return claimed;
147
+ },
131
148
  };
132
149
  const agentpayApiSecretBackend = {
133
150
  kind: 'agentpay_api',
134
151
  resolveCatalogHost: resolveHostFromInput,
135
- async syncSecretCatalog(urlOrHost) {
152
+ async syncSecretCatalog(sessionId, urlOrHost) {
136
153
  const host = resolveHostFromInput(urlOrHost);
137
- const entries = await requestAgentpay('GET', `/secrets/catalog?host=${encodeURIComponent(host)}`);
154
+ const entries = await getRemoteSessionSecretCatalog(sessionId, host);
138
155
  return {
139
156
  source: 'agentpay_api',
140
157
  host,
@@ -142,39 +159,58 @@ const agentpayApiSecretBackend = {
142
159
  storedSecrets: entries.map((entry) => mapApiCatalogEntryToStoredSecret(entry, host)),
143
160
  };
144
161
  },
145
- async createOrReuseSecretIntent(input) {
146
- const response = await requestAgentpay('POST', '/intents', {
147
- intent_type: 'stored_secret',
148
- description: `Protected fill for ${input.purpose}`,
149
- metadata: {
150
- secret_id: input.storedSecretRef,
151
- secret_kind: input.secretKind,
152
- purpose: input.purpose,
153
- host: input.host,
154
- fill_ref: input.fillRef,
155
- requested_field_keys: input.requestedFieldKeys,
162
+ async createOrReuseSecretRequest(input) {
163
+ const response = await createRemoteSecretRequest(input.sessionId, {
164
+ clientRequestId: input.clientRequestId,
165
+ fillRef: input.fillRef,
166
+ purpose: input.purpose,
167
+ merchantName: input.merchantName,
168
+ ...(input.page ? { page: input.page } : {}),
169
+ secretHint: {
170
+ ...(input.secretHint.storedSecretRef
171
+ ? { storedSecretRef: input.secretHint.storedSecretRef }
172
+ : {}),
173
+ ...(input.secretHint.credentialKey
174
+ ? { credentialKey: input.secretHint.credentialKey }
175
+ : {}),
176
+ ...(input.secretHint.credentialName
177
+ ? { credentialName: input.secretHint.credentialName }
178
+ : {}),
179
+ ...(input.secretHint.kind ? { kind: input.secretHint.kind } : {}),
180
+ ...(input.secretHint.host ? { host: input.secretHint.host } : {}),
181
+ ...(input.secretHint.scopeRef ? { scopeRef: input.secretHint.scopeRef } : {}),
182
+ fields: input.secretHint.fields,
156
183
  },
184
+ ...(input.telemetry ? { telemetry: input.telemetry } : {}),
185
+ ...(input.run ? { run: input.run } : {}),
186
+ ...(input.step ? { step: input.step } : {}),
157
187
  });
158
188
  return {
159
- intent: mapApiIntentResponse(response),
160
- reused: false,
189
+ snapshot: mapSessionRequestToSnapshot(response.request),
190
+ reused: response.reused,
191
+ duplicate: response.duplicate,
192
+ session: mapRemoteSessionState(response),
161
193
  };
162
194
  },
163
- async getSecretIntent(intentId) {
195
+ async getSecretRequest(sessionId, requestId) {
164
196
  try {
165
- const response = await requestAgentpay('GET', `/intents/${intentId}`);
197
+ const response = await getRemoteSecretRequest(sessionId, requestId);
166
198
  return {
167
- snapshot: mapApiIntentResponse(response),
168
- deliveredValues: response.secret?.values,
199
+ snapshot: mapSessionRequestToSnapshot(response.request),
200
+ session: mapRemoteSessionState(response),
169
201
  };
170
202
  }
171
203
  catch (error) {
172
- if (error instanceof Error && error.message.startsWith('agentpay_secret_backend_http_404')) {
204
+ if (error instanceof AgentpayRequestError && error.status === 404) {
173
205
  return null;
174
206
  }
175
207
  throw error;
176
208
  }
177
209
  },
210
+ async claimSecretRequest(sessionId, requestId, claimId) {
211
+ const response = await claimRemoteSecret(sessionId, requestId, claimId);
212
+ return mapClaimedSecret(response);
213
+ },
178
214
  };
179
215
  export function isMockSecretBackendEnabled() {
180
216
  return envFlagEnabled(process.env[ENABLE_MOCK_SECRETS_ENV]);
@@ -188,3 +224,7 @@ export function getSecretBackend() {
188
224
  }
189
225
  throw new SecretBackendDisabledError(`Secret backend is not configured. Set AGENTPAY_API_KEY for real AgentPay API access or ${ENABLE_MOCK_SECRETS_ENV}=1 only for local/dev testing.`);
190
226
  }
227
+ export const __testSecretBackend = {
228
+ approveMockSecretRequest,
229
+ denyMockSecretRequest,
230
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"catalog-sync.d.ts","sourceRoot":"","sources":["../../src/secrets/catalog-sync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAGnD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAExD,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,qBAAqB,CAAC,QAAQ,CAAC,CAAC;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,aAAa,GAAG,MAAM,GAAG,IAAI,CAG9E;AAED,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,qBAAqB,GAAG,oBAAoB,CAO5F;AAED,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,aAAa,EACtB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,qBAAqB,CAAC,CAGhC;AAED,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAE5D;AAED,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAazF"}
1
+ {"version":3,"file":"catalog-sync.d.ts","sourceRoot":"","sources":["../../src/secrets/catalog-sync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAGnD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAExD,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,qBAAqB,CAAC,QAAQ,CAAC,CAAC;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,aAAa,GAAG,MAAM,GAAG,IAAI,CAG9E;AAED,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,qBAAqB,GAAG,oBAAoB,CAO5F;AAED,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,aAAa,EACtB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,qBAAqB,CAAC,CAOhC;AAED,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAE5D;AAED,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAazF"}
@@ -13,7 +13,10 @@ export function summarizeSecretCatalog(snapshot) {
13
13
  };
14
14
  }
15
15
  export async function syncSecretCatalogForUrl(session, urlOrHost) {
16
- const snapshot = await getSecretBackend().syncSecretCatalog(urlOrHost);
16
+ if (!session.intentSessionId) {
17
+ throw new Error('Workflow session id is required for secret catalog sync.');
18
+ }
19
+ const snapshot = await getSecretBackend().syncSecretCatalog(session.intentSessionId, urlOrHost);
17
20
  return saveSecretCatalog(session, snapshot);
18
21
  }
19
22
  export function resolveCatalogHost(urlOrHost) {
@@ -16,29 +16,29 @@ declare const protectedFormPlanSchema: z.ZodObject<{
16
16
  bindings: z.ZodArray<z.ZodObject<{
17
17
  targetRef: z.ZodString;
18
18
  fieldKey: z.ZodString;
19
- valueHint: z.ZodOptional<z.ZodEnum<["direct", "full_name.given", "full_name.family"]>>;
19
+ valueHint: z.ZodOptional<z.ZodEnum<["direct", "full_name.given", "full_name.family", "date_of_birth.day", "date_of_birth.month", "date_of_birth.year"]>>;
20
20
  }, "strip", z.ZodTypeAny, {
21
21
  targetRef: string;
22
22
  fieldKey: string;
23
- valueHint?: "direct" | "full_name.given" | "full_name.family" | undefined;
23
+ valueHint?: "direct" | "full_name.given" | "full_name.family" | "date_of_birth.day" | "date_of_birth.month" | "date_of_birth.year" | undefined;
24
24
  }, {
25
25
  targetRef: string;
26
26
  fieldKey: string;
27
- valueHint?: "direct" | "full_name.given" | "full_name.family" | undefined;
27
+ valueHint?: "direct" | "full_name.given" | "full_name.family" | "date_of_birth.day" | "date_of_birth.month" | "date_of_birth.year" | undefined;
28
28
  }>, "many">;
29
29
  }, "strip", z.ZodTypeAny, {
30
30
  confidence: "high" | "medium" | "low";
31
31
  bindings: {
32
32
  targetRef: string;
33
33
  fieldKey: string;
34
- valueHint?: "direct" | "full_name.given" | "full_name.family" | undefined;
34
+ valueHint?: "direct" | "full_name.given" | "full_name.family" | "date_of_birth.day" | "date_of_birth.month" | "date_of_birth.year" | undefined;
35
35
  }[];
36
36
  }, {
37
37
  confidence: "high" | "medium" | "low";
38
38
  bindings: {
39
39
  targetRef: string;
40
40
  fieldKey: string;
41
- valueHint?: "direct" | "full_name.given" | "full_name.family" | undefined;
41
+ valueHint?: "direct" | "full_name.given" | "full_name.family" | "date_of_birth.day" | "date_of_birth.month" | "date_of_birth.year" | undefined;
42
42
  }[];
43
43
  }>;
44
44
  declare function selectorSignalFragments(selector: string): string[];
@@ -1 +1 @@
1
- {"version":3,"file":"form-matcher.d.ts","sourceRoot":"","sources":["../../src/secrets/form-matcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAEpE,OAAO,KAAK,EAAE,gBAAgB,EAA2B,MAAM,qBAAqB,CAAC;AACrF,OAAO,KAAK,EACV,wBAAwB,EAExB,qBAAqB,EACrB,qBAAqB,EAErB,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAQpB,KAAK,iBAAiB,GAAG,IAAI,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC;AAEhE,UAAU,cAAc;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,qBAAqB,GAAG,IAAI,CAAC;CAC9C;AAED,UAAU,eAAe;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,gBAAgB,EAAE,CAAC;CAC7B;AAgCD,QAAA,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAW3B,CAAC;AAsCH,iBAAS,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAS3D;AAED,iBAAS,cAAc,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,EAAE,CAsC1D;AAuYD,iBAAS,cAAc,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CAgBxD;AAED,iBAAS,kBAAkB,CAAC,OAAO,EAAE,aAAa,CAAC,gBAAgB,CAAC,GAAG,eAAe,EAAE,CAkBvF;AAoFD,iBAAS,kBAAkB,CAAC,IAAI,EAAE,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