@catena/sdk 0.0.0-alpha-20260724191736

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.
@@ -0,0 +1,566 @@
1
+ import * as v from "valibot";
2
+
3
+ //#region src/user-agent.d.ts
4
+ /**
5
+ * Optional caller identification prepended to the User-Agent, Stripe-style
6
+ * (`name/version (url)`). Telemetry only: the value is self-reported and
7
+ * spoofable, so it must never carry authority — client kind and privilege
8
+ * are derived server-side from the OAuth client_id.
9
+ */
10
+ interface AppInfo {
11
+ name: string;
12
+ version?: string;
13
+ url?: string;
14
+ }
15
+ //#endregion
16
+ //#region src/schemas.d.ts
17
+ declare const agentSchema: v.ObjectSchema<{
18
+ readonly id: v.StringSchema<undefined>;
19
+ readonly name: v.StringSchema<undefined>;
20
+ readonly status: v.StringSchema<undefined>;
21
+ readonly organizationId: v.StringSchema<undefined>;
22
+ readonly operatorEmail: v.NullableSchema<v.StringSchema<undefined>, undefined>;
23
+ }, undefined>;
24
+ type Agent = v.InferOutput<typeof agentSchema>;
25
+ declare const policySchema: v.ObjectSchema<{
26
+ readonly id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
27
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
28
+ readonly version: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
29
+ readonly name: v.StringSchema<undefined>;
30
+ readonly capabilities: v.ArraySchema<v.StringSchema<undefined>, undefined>;
31
+ readonly counterpartyRules: v.OptionalSchema<v.ObjectSchema<{
32
+ readonly mode: v.PicklistSchema<["open", "restricted"], undefined>;
33
+ readonly allowedCounterparties: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
34
+ readonly createAction: v.OptionalSchema<v.PicklistSchema<["allow", "block", "require_approval"], undefined>, undefined>;
35
+ readonly allowCreate: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
36
+ }, undefined>, undefined>;
37
+ readonly policyCapabilities: v.ArraySchema<v.ObjectSchema<{
38
+ readonly id: v.StringSchema<undefined>;
39
+ readonly organizationId: v.StringSchema<undefined>;
40
+ readonly policyId: v.StringSchema<undefined>;
41
+ readonly capability: v.PicklistSchema<["query_balance", "read", "send", "transfer"], undefined>;
42
+ readonly accountId: v.StringSchema<undefined>;
43
+ readonly rules: v.ArraySchema<v.ObjectSchema<{
44
+ readonly id: v.StringSchema<undefined>;
45
+ readonly ruleType: v.PicklistSchema<["per_transaction_amount", "daily_amount", "weekly_amount", "monthly_amount", "hourly_count", "daily_count"], undefined>;
46
+ readonly thresholdAmount: v.OptionalSchema<v.ObjectSchema<{
47
+ /**
48
+ * Decimal string in the asset's major unit: "12.50" is $12.50. Never cents or
49
+ * atomic units.
50
+ */
51
+ readonly amount: v.StringSchema<undefined>;
52
+ /**
53
+ * Asset identifier, e.g. "USD".
54
+ */
55
+ readonly asset_id: v.StringSchema<undefined>;
56
+ }, undefined>, undefined>;
57
+ readonly thresholdCount: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
58
+ readonly action: v.PicklistSchema<["block", "require_approval"], undefined>;
59
+ readonly requiredApprovals: v.NumberSchema<undefined>;
60
+ readonly accountAggregationScope: v.PicklistSchema<["per_account", "across_accounts"], undefined>;
61
+ readonly actorAggregationScope: v.PicklistSchema<["per_agent", "per_policy"], undefined>;
62
+ readonly displayOrder: v.NumberSchema<undefined>;
63
+ }, undefined>, undefined>;
64
+ readonly createdAt: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, undefined>]>;
65
+ readonly updatedAt: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, undefined>]>;
66
+ }, undefined>, undefined>;
67
+ }, undefined>;
68
+ type Policy = v.InferOutput<typeof policySchema>;
69
+ declare const accountsResponseSchema: v.ObjectSchema<{
70
+ readonly accounts: v.ArraySchema<v.ObjectSchema<{
71
+ readonly id: v.StringSchema<undefined>;
72
+ readonly name: v.StringSchema<undefined>;
73
+ readonly type: v.StringSchema<undefined>;
74
+ readonly currency: v.StringSchema<undefined>;
75
+ }, undefined>, undefined>;
76
+ }, undefined>;
77
+ type AccountsResponse = v.InferOutput<typeof accountsResponseSchema>;
78
+ declare const accountBalanceResponseSchema: v.ObjectSchema<{
79
+ readonly accountId: v.StringSchema<undefined>;
80
+ /**
81
+ * @deprecated Flat alias of `balances.total`; use `balances` instead.
82
+ */
83
+ readonly balance: v.ObjectSchema<{
84
+ /**
85
+ * Decimal string in the asset's major unit: "12.50" is $12.50. Never cents or
86
+ * atomic units.
87
+ */
88
+ readonly amount: v.StringSchema<undefined>;
89
+ /**
90
+ * Asset identifier, e.g. "USD".
91
+ */
92
+ readonly asset_id: v.StringSchema<undefined>;
93
+ }, undefined>;
94
+ /**
95
+ * `available` (what a send is checked against) is `total` minus reserved
96
+ * funds. Absent only from API deployments that predate the field.
97
+ */
98
+ readonly balances: v.OptionalSchema<v.ObjectSchema<{
99
+ readonly total: v.ObjectSchema<{
100
+ /**
101
+ * Decimal string in the asset's major unit: "12.50" is $12.50. Never cents or
102
+ * atomic units.
103
+ */
104
+ readonly amount: v.StringSchema<undefined>;
105
+ /**
106
+ * Asset identifier, e.g. "USD".
107
+ */
108
+ readonly asset_id: v.StringSchema<undefined>;
109
+ }, undefined>;
110
+ readonly available: v.ObjectSchema<{
111
+ /**
112
+ * Decimal string in the asset's major unit: "12.50" is $12.50. Never cents or
113
+ * atomic units.
114
+ */
115
+ readonly amount: v.StringSchema<undefined>;
116
+ /**
117
+ * Asset identifier, e.g. "USD".
118
+ */
119
+ readonly asset_id: v.StringSchema<undefined>;
120
+ }, undefined>;
121
+ }, undefined>, undefined>;
122
+ }, undefined>;
123
+ type AccountBalanceResponse = v.InferOutput<typeof accountBalanceResponseSchema>;
124
+ declare const accountTransactionsResponseSchema: v.ObjectSchema<{
125
+ readonly accountId: v.StringSchema<undefined>;
126
+ readonly transactions: v.ArraySchema<v.ObjectSchema<{
127
+ readonly id: v.StringSchema<undefined>;
128
+ readonly type: v.PicklistSchema<["operator-send", "operator-transfer", "operator-deposit", "operator-refund", "microdeposit"], undefined>;
129
+ /**
130
+ * Display action — `receive` for on-chain receives, distinct from the raw
131
+ * `type`. Optional to tolerate an API deployed before this field existed.
132
+ */
133
+ readonly action: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
134
+ readonly status: v.PicklistSchema<["pending", "processing", "completed", "failed", "reversed"], undefined>;
135
+ readonly movementStatus: v.PicklistSchema<["initiated", "provider_pending", "processing", "completed", "failed", "reversed", "manual_review"], undefined>;
136
+ readonly direction: v.PicklistSchema<["incoming", "outgoing"], undefined>;
137
+ readonly amount: v.ObjectSchema<{
138
+ /**
139
+ * Decimal string in the asset's major unit: "12.50" is $12.50. Never cents or
140
+ * atomic units.
141
+ */
142
+ readonly amount: v.StringSchema<undefined>;
143
+ /**
144
+ * Asset identifier, e.g. "USD".
145
+ */
146
+ readonly asset_id: v.StringSchema<undefined>;
147
+ }, undefined>;
148
+ readonly fee: v.ObjectSchema<{
149
+ /**
150
+ * Decimal string in the asset's major unit: "12.50" is $12.50. Never cents or
151
+ * atomic units.
152
+ */
153
+ readonly amount: v.StringSchema<undefined>;
154
+ /**
155
+ * Asset identifier, e.g. "USD".
156
+ */
157
+ readonly asset_id: v.StringSchema<undefined>;
158
+ }, undefined>;
159
+ readonly currency: v.StringSchema<undefined>;
160
+ readonly counterpartyName: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
161
+ readonly method: v.OptionalSchema<v.PicklistSchema<["ach", "wire", "on-chain"], undefined>, undefined>;
162
+ readonly memo: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
163
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
164
+ readonly txHash: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
165
+ readonly createdAt: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, undefined>]>;
166
+ readonly completedAt: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, undefined>]>, undefined>;
167
+ }, undefined>, undefined>;
168
+ readonly total: v.NumberSchema<undefined>;
169
+ }, undefined>;
170
+ type AccountTransactionsResponse = v.InferOutput<typeof accountTransactionsResponseSchema>;
171
+ type AccountTransactionsParams = {
172
+ /**
173
+ * Inclusive lower bound on `createdAt`, as an ISO 8601 timestamp.
174
+ */
175
+ start?: string;
176
+ /**
177
+ * Inclusive upper bound on `createdAt`, as an ISO 8601 timestamp.
178
+ */
179
+ end?: string;
180
+ /**
181
+ * Page size; positive integer, defaults to 50, values above 200 are
182
+ * clamped to 200. Non-integer or non-positive values are rejected (400).
183
+ */
184
+ limit?: number;
185
+ /**
186
+ * Rows to skip; nonnegative integer, defaults to 0. Non-integer or
187
+ * negative values are rejected (400).
188
+ */
189
+ offset?: number;
190
+ };
191
+ declare const accountDepositAddressResponseSchema: v.ObjectSchema<{
192
+ readonly accountId: v.StringSchema<undefined>;
193
+ readonly address: v.StringSchema<undefined>;
194
+ readonly liquidationAddressId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
195
+ readonly source: v.PicklistSchema<["wallet", "liquidation"], undefined>;
196
+ }, undefined>;
197
+ type AccountDepositAddressResponse = v.InferOutput<typeof accountDepositAddressResponseSchema>;
198
+ /**
199
+ * Widened network/asset inputs: autocomplete from the literal half, but any
200
+ * string is accepted — the server is the enforcement boundary, so a network
201
+ * or asset added server-side never becomes a compile-time wall for an older
202
+ * SDK. Response schemas parse plain strings for the same reason.
203
+ */
204
+ type OnchainNetworkInput = "base" | "base-sepolia" | (string & {});
205
+ type OnchainAssetInput = "usdc" | (string & {});
206
+ type AccountDepositAddressParams = {
207
+ network: OnchainNetworkInput;
208
+ asset: OnchainAssetInput;
209
+ };
210
+ /**
211
+ * Rails are modeled tolerantly rather than as a variant on `type`: each
212
+ * field is present only on the rail types it applies to (wallet rails carry
213
+ * `walletAddress`/`network`, bank rails carry `bankName`/`accountNumber`),
214
+ * and a server that later adds a new rail type must not break older clients.
215
+ */
216
+ declare const counterpartySchema: v.ObjectSchema<{
217
+ readonly id: v.StringSchema<undefined>;
218
+ readonly name: v.StringSchema<undefined>;
219
+ readonly rails: v.ArraySchema<v.ObjectSchema<{
220
+ readonly id: v.StringSchema<undefined>;
221
+ /**
222
+ * Rail kind — currently "wallet" or "bank"; treat other values as
223
+ * future rail types. Sends must match method to rail: "ach" and
224
+ * "wire" need a bank rail, "on-chain" needs a wallet rail.
225
+ */
226
+ readonly type: v.StringSchema<undefined>;
227
+ readonly walletAddress: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
228
+ readonly network: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
229
+ readonly bankName: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
230
+ readonly accountNumber: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
231
+ }, undefined>, undefined>;
232
+ }, undefined>;
233
+ type Counterparty = v.InferOutput<typeof counterpartySchema>;
234
+ declare const counterpartiesResponseSchema: v.ObjectSchema<{
235
+ readonly counterparties: v.ArraySchema<v.ObjectSchema<{
236
+ readonly id: v.StringSchema<undefined>;
237
+ readonly name: v.StringSchema<undefined>;
238
+ readonly rails: v.ArraySchema<v.ObjectSchema<{
239
+ readonly id: v.StringSchema<undefined>;
240
+ /**
241
+ * Rail kind — currently "wallet" or "bank"; treat other values as
242
+ * future rail types. Sends must match method to rail: "ach" and
243
+ * "wire" need a bank rail, "on-chain" needs a wallet rail.
244
+ */
245
+ readonly type: v.StringSchema<undefined>;
246
+ readonly walletAddress: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
247
+ readonly network: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
248
+ readonly bankName: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
249
+ readonly accountNumber: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
250
+ }, undefined>, undefined>;
251
+ }, undefined>, undefined>;
252
+ }, undefined>;
253
+ type CounterpartiesResponse = v.InferOutput<typeof counterpartiesResponseSchema>;
254
+ type CounterpartiesParams = {
255
+ /**
256
+ * Only counterparties with a wallet rail at this address.
257
+ */
258
+ address?: `0x${string}` | undefined;
259
+ /**
260
+ * Only counterparties with a wallet rail on this network.
261
+ */
262
+ network?: OnchainNetworkInput | undefined;
263
+ };
264
+ declare const wireIntentResultSchema: v.ObjectSchema<{
265
+ readonly id: v.StringSchema<undefined>;
266
+ readonly type: v.PicklistSchema<["send", "transfer", "wallet_send", "create_counterparty", "x402"], undefined>;
267
+ /**
268
+ * Disposition of the intent:
269
+ *
270
+ * - "pending" — accepted but not yet executing, typically parked for a human
271
+ * approval; `reasons` says why and `expiresAt` when it lapses.
272
+ * - "processing" — accepted and in progress. Executing intents advance on their
273
+ * own; poll `getIntent`. An approved x402 payment instead rests here until
274
+ * the paid request is re-run — polling never advances it — and `expiresAt`
275
+ * is when that grant lapses.
276
+ * - "completed" — the action succeeded: money moved for send, transfer, and
277
+ * wallet_send; for x402 the payment authorization was delivered
278
+ * (`data.x402.paymentSignature`), with on-chain settlement verified
279
+ * separately; for create_counterparty the counterparty exists.
280
+ * - "blocked" — declined by policy or denied by an operator; `reasons` explains
281
+ * why approval was required, not necessarily why it was denied. Terminal.
282
+ * - "failed" — failed, expired, or reversed. Terminal.
283
+ */
284
+ readonly status: v.PicklistSchema<["pending", "processing", "completed", "blocked", "failed"], undefined>;
285
+ /**
286
+ * Human-readable explanations for a pending, blocked, or failed status.
287
+ */
288
+ readonly reasons: v.ArraySchema<v.StringSchema<undefined>, undefined>;
289
+ /**
290
+ * Deadline for an awaiting state: while parked for approval, when the
291
+ * request self-expires; while an approved x402 grant rests, when the grant
292
+ * lapses. Optional to tolerate an API deployed before this field existed.
293
+ */
294
+ readonly expiresAt: v.OptionalSchema<v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, undefined>]>, undefined>, null>;
295
+ /**
296
+ * Intent-type-specific payload. A completed x402 intent carries the encoded
297
+ * retry header at `data.x402.paymentSignature`.
298
+ */
299
+ readonly data: v.OptionalSchema<v.NullableSchema<v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, undefined>, null>;
300
+ readonly metadata: v.OptionalSchema<v.ObjectSchema<{
301
+ readonly dataUrl: v.NullableSchema<v.StringSchema<undefined>, undefined>;
302
+ }, undefined>, undefined>;
303
+ readonly nextAction: v.OptionalSchema<v.ObjectSchema<{
304
+ readonly type: v.LiteralSchema<"submit_stamp", undefined>;
305
+ readonly signingRequestId: v.StringSchema<undefined>;
306
+ readonly signer: v.ObjectSchema<{
307
+ readonly algorithm: v.LiteralSchema<"p256", undefined>;
308
+ readonly publicKeyHex: v.StringSchema<undefined>;
309
+ }, undefined>;
310
+ readonly preparedBody: v.ObjectSchema<{
311
+ readonly body: v.StringSchema<undefined>;
312
+ readonly bodyHash: v.StringSchema<undefined>;
313
+ readonly expiresAt: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, undefined>]>;
314
+ readonly prepareToken: v.StringSchema<undefined>;
315
+ }, undefined>;
316
+ }, undefined>, undefined>;
317
+ }, undefined>;
318
+ type WireIntentResult = v.InferOutput<typeof wireIntentResultSchema>;
319
+ /**
320
+ * Public view of an intent, as returned by `submitIntent` and `getIntent`.
321
+ * Branch on `status`; `reasons` explains non-completed outcomes.
322
+ *
323
+ * The co-signing step inside `submitIntent` is not resumable from a re-read
324
+ * intent: one awaiting its co-signature reads as plain "processing" here.
325
+ * Recovery from a failed submit follows `IntentSubmitError`'s outcome
326
+ * contract: a new `submitIntent` only when the outcome was "not-submitted";
327
+ * when it was "unknown", poll `getIntent` to a terminal status and submit
328
+ * again only if it ended blocked or failed.
329
+ */
330
+ type IntentResult = Omit<WireIntentResult, "nextAction">;
331
+ declare const SEND_METHODS: readonly ["ach", "wire", "on-chain"];
332
+ declare const sendMethodSchema: v.PicklistSchema<readonly ["ach", "wire", "on-chain"], undefined>;
333
+ type SendMethod = v.InferOutput<typeof sendMethodSchema>;
334
+ /**
335
+ * The `PaymentRequirements` a 402 challenge names, relayed to the API
336
+ * verbatim. Loose on purpose: the API is the enforcement boundary (shape,
337
+ * guardrails, policy); the client only needs the discriminating fields to
338
+ * pick a candidate from `accepts`.
339
+ */
340
+ declare const x402PaymentRequirementsSchema: v.LooseObjectSchema<{
341
+ readonly scheme: v.StringSchema<undefined>;
342
+ readonly network: v.StringSchema<undefined>;
343
+ readonly asset: v.StringSchema<undefined>;
344
+ readonly amount: v.StringSchema<undefined>;
345
+ readonly payTo: v.StringSchema<undefined>;
346
+ readonly maxTimeoutSeconds: v.NumberSchema<undefined>;
347
+ }, undefined>;
348
+ type X402PaymentRequirements = v.InferOutput<typeof x402PaymentRequirementsSchema>;
349
+ declare const x402ResourceSchema: v.LooseObjectSchema<{
350
+ readonly url: v.StringSchema<undefined>;
351
+ /**
352
+ * Human-readable name of the paid service, when the challenge advertises
353
+ * one — a suggested name when creating the counterparty. Parsed leniently:
354
+ * a malformed value (non-string, or over-long) drops to undefined rather
355
+ * than failing the whole challenge parse, which would silently downgrade
356
+ * an otherwise-payable 402 to an unpaid passthrough.
357
+ */
358
+ readonly serviceName: v.SchemaWithFallback<v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 255, undefined>]>, undefined>, undefined>;
359
+ }, undefined>;
360
+ type X402Resource = v.InferOutput<typeof x402ResourceSchema>;
361
+ declare const intentActionSchema: v.VariantSchema<"type", [v.ObjectSchema<{
362
+ readonly type: v.LiteralSchema<"send", undefined>;
363
+ readonly accountId: v.StringSchema<undefined>;
364
+ /**
365
+ * Id of one entry in a counterparty's `rails` array (from
366
+ * `listCounterparties`) — not the counterparty id itself.
367
+ */
368
+ readonly counterpartyRailId: v.StringSchema<undefined>;
369
+ /**
370
+ * Decimal USD string: "12.50" is $12.50. Never cents or atomic units.
371
+ */
372
+ readonly amount: v.StringSchema<undefined>;
373
+ readonly method: v.PicklistSchema<readonly ["ach", "wire", "on-chain"], undefined>;
374
+ readonly memo: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
375
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
376
+ }, undefined>, v.ObjectSchema<{
377
+ readonly type: v.LiteralSchema<"transfer", undefined>;
378
+ readonly accountId: v.StringSchema<undefined>;
379
+ readonly toAccountId: v.StringSchema<undefined>;
380
+ /**
381
+ * Decimal USD string: "12.50" is $12.50. Never cents or atomic units.
382
+ */
383
+ readonly amount: v.StringSchema<undefined>;
384
+ readonly memo: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
385
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
386
+ }, undefined>, v.ObjectSchema<{
387
+ readonly type: v.LiteralSchema<"create_counterparty", undefined>;
388
+ readonly name: v.StringSchema<undefined>;
389
+ readonly email: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
390
+ readonly rail: v.UnknownSchema;
391
+ }, undefined>, v.ObjectSchema<{
392
+ readonly type: v.LiteralSchema<"x402", undefined>;
393
+ readonly accountId: v.StringSchema<undefined>;
394
+ readonly paymentRequirements: v.LooseObjectSchema<{
395
+ readonly scheme: v.StringSchema<undefined>;
396
+ readonly network: v.StringSchema<undefined>;
397
+ readonly asset: v.StringSchema<undefined>;
398
+ readonly amount: v.StringSchema<undefined>;
399
+ readonly payTo: v.StringSchema<undefined>;
400
+ readonly maxTimeoutSeconds: v.NumberSchema<undefined>;
401
+ }, undefined>;
402
+ readonly resource: v.OptionalSchema<v.LooseObjectSchema<{
403
+ readonly url: v.StringSchema<undefined>;
404
+ /**
405
+ * Human-readable name of the paid service, when the challenge advertises
406
+ * one — a suggested name when creating the counterparty. Parsed leniently:
407
+ * a malformed value (non-string, or over-long) drops to undefined rather
408
+ * than failing the whole challenge parse, which would silently downgrade
409
+ * an otherwise-payable 402 to an unpaid passthrough.
410
+ */
411
+ readonly serviceName: v.SchemaWithFallback<v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 255, undefined>]>, undefined>, undefined>;
412
+ }, undefined>, undefined>;
413
+ }, undefined>], undefined>;
414
+ type IntentAction = v.InferOutput<typeof intentActionSchema>;
415
+ //#endregion
416
+ //#region src/client.d.ts
417
+ /**
418
+ * Non-OK API response. `code` is the API's stable error code — branch on it,
419
+ * not on message prose. The code is also embedded in the message so hosts
420
+ * that only print `error.message` still surface it.
421
+ */
422
+ declare class ApiError extends Error {
423
+ readonly status: number;
424
+ readonly code: string | undefined;
425
+ constructor(status: number, message: string, code?: string);
426
+ }
427
+ /**
428
+ * A `submitIntent` failure after the intent was created. `outcome` is the
429
+ * contract — callers branch on effect, never on which internal phase failed:
430
+ *
431
+ * - `"not-submitted"`: nothing happened server-side after create; no money moved.
432
+ * Recovery is a new `submitIntent` with a fresh explicit `idempotencyKey`
433
+ * (without one, the server's content-derived default replays the stranded
434
+ * intent), typically after fixing the signing credential; the stranded intent
435
+ * settles or expires server-side.
436
+ * - `"unknown"`: the failure landed where the server may have already acted. Poll
437
+ * `getIntent(intentId)` to a terminal status — completed means it succeeded;
438
+ * submit again only after blocked or failed. A blind re-submit risks a double
439
+ * effect.
440
+ *
441
+ * `cause` carries the raw underlying error for diagnostics, not contract.
442
+ * Its summary is embedded in the message so hosts that print only
443
+ * `error.message` keep the actionable detail — e.g. which key a signer
444
+ * mismatch names.
445
+ */
446
+ declare class IntentSubmitError extends Error {
447
+ readonly intentId: string;
448
+ readonly outcome: "not-submitted" | "unknown";
449
+ constructor(params: {
450
+ intentId: string;
451
+ outcome: "not-submitted" | "unknown";
452
+ cause: unknown;
453
+ });
454
+ }
455
+ /**
456
+ * Transport signature: the callable subset of the global `fetch`. Deliberately
457
+ * structural rather than `typeof globalThis.fetch` — that alias resolves
458
+ * against the consumer's platform types, where fetch may carry extra statics
459
+ * (e.g. Bun's `fetch.preconnect`) that custom transports and the x402 wrapper
460
+ * do not have. Exported so hosts can type a custom implementation and name
461
+ * what `wrapFetchWithX402Payment` returns.
462
+ */
463
+ type FetchLike = (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
464
+ interface CatenaClientOptions {
465
+ /**
466
+ * API origin, defaulting to the hosted Catena API. Override for local
467
+ * development or a self-hosted deployment.
468
+ */
469
+ baseUrl?: string;
470
+ /**
471
+ * P-256 private key of a linked agent credential, 64 hex characters (see
472
+ * `@catena/sdk/keypair` to generate one). The public half is derived, so a
473
+ * corrupt value throws here instead of failing with 401s at the bank. The
474
+ * key signs every request (RFC 9421) and co-signs wallet sends during
475
+ * `submitIntent`.
476
+ */
477
+ privateKeyHex: string;
478
+ /**
479
+ * Signature-Agent identity URL, defaulting to a URL derived from the
480
+ * key's thumbprint. The default changes on key rotation; pass a stable
481
+ * URL (an agent page, a self-hosted JWKS) when the identity must survive it.
482
+ */
483
+ identityUrl?: string;
484
+ /**
485
+ * Caller identification prepended to the User-Agent. Telemetry only —
486
+ * never carries authority.
487
+ */
488
+ appInfo?: AppInfo;
489
+ /**
490
+ * Merged into every request; per-request headers win.
491
+ */
492
+ defaultHeaders?: Record<string, string>;
493
+ /**
494
+ * Transport override, defaulting to the global `fetch`. Injected so hosts can
495
+ * route requests through a proxy or instrumentation layer, and so tests can
496
+ * pass a stub instead of patching `globalThis.fetch`.
497
+ */
498
+ fetch?: FetchLike;
499
+ }
500
+ declare class CatenaClient {
501
+ #private;
502
+ constructor(opts: CatenaClientOptions);
503
+ whoami(): Promise<Agent>;
504
+ /**
505
+ * Send free-form feedback about this integration to the bank's operators —
506
+ * an in-band channel for agents to report friction, confusing errors, or
507
+ * missing capabilities. Stored for humans to read; never a protocol or
508
+ * money effect.
509
+ */
510
+ submitFeedback(body: string): Promise<void>;
511
+ getPolicy(): Promise<Policy>;
512
+ listAccounts(): Promise<AccountsResponse>;
513
+ getAccountBalance(accountId: string): Promise<AccountBalanceResponse>;
514
+ listAccountTransactions(accountId: string, params?: AccountTransactionsParams): Promise<AccountTransactionsResponse>;
515
+ getAccountDepositAddress(accountId: string, params: AccountDepositAddressParams): Promise<AccountDepositAddressResponse>;
516
+ listCounterparties(params?: CounterpartiesParams): Promise<CounterpartiesResponse>;
517
+ /**
518
+ * Submit an intent and run its full lifecycle: create, and when the server
519
+ * requires a co-signature, stamp and submit it. Returns the final intent
520
+ * view from the submit response itself — no follow-up `getIntent` needed.
521
+ * The result is a disposition, not a guarantee of execution — the intent
522
+ * may be completed, blocked, or parked pending approval; branch on `status`
523
+ * and read `reasons`.
524
+ *
525
+ * The server derives a replay-safe default idempotency key when none is
526
+ * supplied. Pass `idempotencyKey` only to intentionally submit a distinct
527
+ * duplicate with the same details.
528
+ *
529
+ * Errors: create-phase failures propagate unwrapped — `ApiError` for
530
+ * non-OK responses (callers depend on its `code`), raw transport/signing
531
+ * errors otherwise. Once the intent exists, failures surface as
532
+ * `IntentSubmitError` — see its outcome contract.
533
+ */
534
+ submitIntent(params: {
535
+ action: IntentAction;
536
+ idempotencyKey?: string;
537
+ }): Promise<IntentResult>;
538
+ getIntent(id: string): Promise<IntentResult>;
539
+ /**
540
+ * Permanently sever this agent link: the server revokes the link's active
541
+ * auth keys, so every request signed with this credential fails from then
542
+ * on. Irreversible — recovery is a new linking ceremony in the host app.
543
+ */
544
+ unlinkAgent(): Promise<void>;
545
+ /**
546
+ * Report the facilitator's on-chain settlement tx for a completed x402
547
+ * payment, decoded from the paid retry's PAYMENT-RESPONSE header. An
548
+ * untrusted hint the server stores for ops/debugging and to narrow the
549
+ * chain verifier's log range; never a money effect. The x402 fetch wrapper
550
+ * calls this automatically.
551
+ */
552
+ reportSettlement(params: {
553
+ intentId: string;
554
+ txHash: string;
555
+ }): Promise<void>;
556
+ }
557
+ /**
558
+ * Create a client for the Catena agent API from a linked agent's P-256
559
+ * private key (see `@catena/sdk/keypair` to generate one). This factory is
560
+ * the only way to construct a client; `CatenaClient` is exported as a type
561
+ * only. Throws immediately on a malformed key; network traffic starts with
562
+ * the first method call.
563
+ */
564
+ declare function createCatenaClient(options: CatenaClientOptions): CatenaClient;
565
+ //#endregion
566
+ export { SendMethod as C, AppInfo as E, SEND_METHODS as S, X402Resource as T, IntentAction as _, IntentSubmitError as a, OnchainNetworkInput as b, AccountDepositAddressParams as c, AccountTransactionsResponse as d, AccountsResponse as f, Counterparty as g, CounterpartiesResponse as h, FetchLike as i, AccountDepositAddressResponse as l, CounterpartiesParams as m, CatenaClient as n, createCatenaClient as o, Agent as p, CatenaClientOptions as r, AccountBalanceResponse as s, ApiError as t, AccountTransactionsParams as u, IntentResult as v, X402PaymentRequirements as w, Policy as x, OnchainAssetInput as y };