@routedock/routedock 0.1.2 → 0.3.0

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 (74) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +532 -4
  3. package/dist/MppSessionHandler-1EL8QBAn.d.cts +215 -0
  4. package/dist/MppSessionHandler-Bq4S-JTE.d.ts +215 -0
  5. package/dist/ProviderRegistry-CA_TdREG.d.ts +142 -0
  6. package/dist/ProviderRegistry-D-0rqK0N.d.cts +142 -0
  7. package/dist/RouteDockClient-Bh86bVly.d.ts +469 -0
  8. package/dist/RouteDockClient-go9aopfF.d.cts +469 -0
  9. package/dist/SessionReconciler-Bw-PoBVl.d.ts +134 -0
  10. package/dist/SessionReconciler-Cz2nuOlJ.d.cts +134 -0
  11. package/dist/SessionStore-B4-Hi4H8.d.cts +143 -0
  12. package/dist/SessionStore-BaYiegP0.d.ts +143 -0
  13. package/dist/client.cjs +2746 -217
  14. package/dist/client.d.cts +51 -81
  15. package/dist/client.d.ts +51 -81
  16. package/dist/client.js +2690 -218
  17. package/dist/index.cjs +3634 -420
  18. package/dist/index.d.cts +12 -3
  19. package/dist/index.d.ts +12 -3
  20. package/dist/index.js +3569 -419
  21. package/dist/logger-D8_Q2ytp.d.cts +467 -0
  22. package/dist/logger-D8_Q2ytp.d.ts +467 -0
  23. package/dist/provider/fastify.cjs +1099 -0
  24. package/dist/provider/fastify.d.cts +40 -0
  25. package/dist/provider/fastify.d.ts +40 -0
  26. package/dist/provider/fastify.js +1097 -0
  27. package/dist/provider/hono.cjs +1152 -0
  28. package/dist/provider/hono.d.cts +101 -0
  29. package/dist/provider/hono.d.ts +101 -0
  30. package/dist/provider/hono.js +1142 -0
  31. package/dist/provider.cjs +1105 -147
  32. package/dist/provider.d.cts +38 -27
  33. package/dist/provider.d.ts +38 -27
  34. package/dist/provider.js +1079 -148
  35. package/dist/react.cjs +2931 -0
  36. package/dist/react.d.cts +107 -0
  37. package/dist/react.d.ts +107 -0
  38. package/dist/react.js +2924 -0
  39. package/dist/routedockMiddleware-57gUaEMf.d.ts +64 -0
  40. package/dist/routedockMiddleware-DlyLrxp7.d.cts +64 -0
  41. package/dist/schema.cjs +404 -0
  42. package/dist/schema.d.cts +3 -0
  43. package/dist/schema.d.ts +3 -0
  44. package/dist/schema.js +399 -0
  45. package/dist/sign-AKH67sft.d.cts +53 -0
  46. package/dist/sign-BEq-OsSq.d.ts +53 -0
  47. package/dist/testing.cjs +59 -0
  48. package/dist/testing.d.cts +114 -0
  49. package/dist/testing.d.ts +114 -0
  50. package/dist/testing.js +56 -0
  51. package/package.json +143 -23
  52. package/PUBLISH_CHECKLIST.md +0 -70
  53. package/dist/SessionStore-CCVO0PHM.d.cts +0 -152
  54. package/dist/SessionStore-CCVO0PHM.d.ts +0 -152
  55. package/dist/routedockMiddleware-B7WTB3LT.d.cts +0 -53
  56. package/dist/routedockMiddleware-DRgdrycG.d.ts +0 -53
  57. package/src/client/ModeRouter.ts +0 -104
  58. package/src/client/MppChargeClient.ts +0 -44
  59. package/src/client/MppSessionClient.ts +0 -144
  60. package/src/client/RouteDockClient.ts +0 -124
  61. package/src/client/index.ts +0 -8
  62. package/src/client/x402Client.ts +0 -84
  63. package/src/index.ts +0 -9
  64. package/src/provider/MppChargeHandler.ts +0 -90
  65. package/src/provider/MppSessionHandler.ts +0 -157
  66. package/src/provider/index.ts +0 -7
  67. package/src/provider/routedockMiddleware.ts +0 -154
  68. package/src/provider/x402Handler.ts +0 -164
  69. package/src/schemas/routedock.schema.json +0 -159
  70. package/src/store/SessionStore.ts +0 -90
  71. package/src/tests/smoke.test.ts +0 -228
  72. package/src/types.ts +0 -165
  73. package/tsconfig.json +0 -14
  74. package/tsup.config.ts +0 -15
@@ -0,0 +1,467 @@
1
+ import { Store } from 'mppx';
2
+
3
+ /**
4
+ * TypeScript types for the RouteDock manifest format.
5
+ * Derived from packages/sdk/src/schemas/routedock.schema.json (draft-07).
6
+ *
7
+ * Section 5 of ROUTEDOCK_MASTER.md is the canonical specification.
8
+ */
9
+
10
+ type PaymentMode = 'x402' | 'mpp-charge' | 'mpp-session' | 'mpp-session-ws';
11
+ /** Payment asset configuration with optional mode/endpoint scoping */
12
+ interface AssetConfig {
13
+ /** Asset ticker symbol, e.g. "USDC" or "XLM" */
14
+ asset: string;
15
+ /** Stellar Asset Contract (SAC) address for this payment asset */
16
+ asset_contract: string;
17
+ /** Optional: restrict this asset to specific payment modes. If omitted, available for all modes. */
18
+ modes?: PaymentMode[];
19
+ /** Optional: restrict this asset to specific endpoints (by name). If omitted, available for all endpoints. */
20
+ endpoints?: string[];
21
+ }
22
+ /**
23
+ * Agent custody mode — declared in routedock.json when provider accepts ZK vault payers.
24
+ * `nulth` = Nulth proof-authorized account (the ZK-account primitive; formerly "covenant-zk").
25
+ */
26
+ type VaultMode = 'local-key' | 'agent-vault' | 'nulth';
27
+ /** Per-request pricing config — used by x402 and mpp-charge modes */
28
+ interface PricingConfig {
29
+ /** Cost per request in the payment asset, e.g. "0.001" */
30
+ amount: string;
31
+ per: 'request';
32
+ /** x402 facilitator URL (OpenZeppelin Channels). Required for x402 mode. */
33
+ facilitator?: string;
34
+ /**
35
+ * Optional per-mode payee override (Stellar G... address). When set, payments
36
+ * for this mode are directed here instead of the top-level manifest `payee`,
37
+ * enabling treasury separation by settlement type (e.g. x402 → facilitator
38
+ * hot wallet, mpp-charge → direct-settlement account). Falls back to the
39
+ * top-level `payee` when omitted.
40
+ */
41
+ payee?: string;
42
+ }
43
+ /** Per-voucher pricing config — used by mpp-session (one-way-channel) mode */
44
+ interface SessionPricingConfig {
45
+ /** Cost per voucher, e.g. "0.0001" */
46
+ rate: string;
47
+ per: 'voucher';
48
+ /** Stable Soroban factory address (C...) used to deploy a per-session channel */
49
+ channel_factory: string;
50
+ /** Minimum initial deposit to open a channel, e.g. "0.10" */
51
+ min_deposit: string;
52
+ /**
53
+ * Ledgers the server has to settle before the funder can reclaim.
54
+ * Default: 17280 (~24h). Do NOT reduce in production — this is a
55
+ * security parameter the server depends on to settle first.
56
+ */
57
+ refund_waiting_period_ledgers: number;
58
+ }
59
+ /** SLA configuration */
60
+ interface SLAConfig {
61
+ uptime_30d_percent: number;
62
+ p95_latency_ms: number;
63
+ maintenance_windows?: {
64
+ cron: string;
65
+ duration_minutes: number;
66
+ }[];
67
+ }
68
+ /** Endpoint descriptor */
69
+ interface EndpointDescriptor {
70
+ method: string;
71
+ path: string;
72
+ /**
73
+ * Whether this endpoint is retained only for backwards compatibility.
74
+ * The SDK logs a `[RouteDock] WARNING:` line before paying a deprecated
75
+ * endpoint.
76
+ */
77
+ deprecated?: boolean;
78
+ /**
79
+ * ISO 8601 timestamp after which callers should stop using this endpoint.
80
+ * The SDK refuses to pay (`RouteDockManifestSunsetError`) once it has passed.
81
+ */
82
+ sunset_at?: string;
83
+ headers?: Record<string, string>;
84
+ request_schema?: unknown;
85
+ response_schema?: unknown;
86
+ rate_limit?: {
87
+ requests: number;
88
+ window_seconds: number;
89
+ };
90
+ }
91
+ /** Full RouteDock discovery manifest — served at /.well-known/routedock.json */
92
+ interface RouteDockManifest {
93
+ /** Manifest schema version (major.minor), e.g. "1.0", "1.1", "2.0" */
94
+ routedock: string;
95
+ /**
96
+ * Minimum SDK client version (major.minor) required to use this manifest.
97
+ * Clients below this version must refuse to pay.
98
+ */
99
+ min_client_version?: string;
100
+ /**
101
+ * Payment modes still listed in `modes` for backwards compatibility
102
+ * but deprecated for new integrations.
103
+ */
104
+ deprecated_modes?: PaymentMode[];
105
+ /** ISO 8601 timestamp after which this manifest version is no longer supported. */
106
+ sunset_at?: string;
107
+ /** Human-readable provider name */
108
+ name: string;
109
+ /** Human-readable description of the provider's data or service */
110
+ description: string;
111
+ /** Payment modes supported by this provider */
112
+ modes: PaymentMode[];
113
+ /** Stellar network this provider operates on */
114
+ network: 'testnet' | 'mainnet';
115
+ /** Asset ticker symbol, e.g. "USDC" */
116
+ asset: string;
117
+ /** Stellar Asset Contract (SAC) address for the payment asset */
118
+ asset_contract: string;
119
+ /**
120
+ * Payment assets accepted by this provider. Each asset can be scoped to specific
121
+ * modes and endpoints. When present, assets[0] must match the root-level
122
+ * asset and asset_contract.
123
+ */
124
+ assets?: AssetConfig[];
125
+ /**
126
+ * Stellar address (G...) that receives payments. Used as the default
127
+ * recipient for all modes. Individual per-request modes (x402, mpp-charge)
128
+ * may override this via `pricing.<mode>.payee` for treasury separation.
129
+ * Note: mpp-session settlements always land in the server signer's account
130
+ * (the channel pays out to the closer), so they cannot be redirected by a
131
+ * manifest field and always use this top-level `payee` for discovery display.
132
+ */
133
+ payee: string;
134
+ /** Pricing configuration per supported payment mode */
135
+ pricing: {
136
+ x402?: PricingConfig;
137
+ 'mpp-charge'?: PricingConfig;
138
+ 'mpp-session'?: SessionPricingConfig;
139
+ /**
140
+ * WebSocket transport variant of mpp-session. The channel is opened and the
141
+ * first voucher negotiated over HTTP exactly like mpp-session, then the
142
+ * connection upgrades to WebSocket for push-based streaming (OpenAI-style
143
+ * inference providers). Same SessionPricingConfig shape — only the
144
+ * streaming transport differs.
145
+ */
146
+ 'mpp-session-ws'?: SessionPricingConfig;
147
+ };
148
+ /** Service Level Agreement for the provider */
149
+ sla?: SLAConfig;
150
+ /** Map of endpoint name to endpoint descriptors */
151
+ endpoints: Record<string, EndpointDescriptor>;
152
+ /** Capability tags indexed with trigram search in the provider registry */
153
+ tags: string[];
154
+ /**
155
+ * Optional vault custody mode declared by the provider.
156
+ * When set to `nulth`, the provider accepts payers using Nulth smart accounts.
157
+ */
158
+ vault?: VaultMode;
159
+ /**
160
+ * Optional Nulth smart account address (C...) that this provider is linked to.
161
+ * Used by the client to verify the nulth_account before sending proofs.
162
+ */
163
+ nulth_account?: string;
164
+ /** Optional protocol features this provider supports */
165
+ capabilities?: {
166
+ /** Supported streaming transports */
167
+ streaming?: ('sse' | 'websocket')[];
168
+ /** Whether webhook callbacks are supported */
169
+ webhooks?: boolean;
170
+ /** Whether idempotency keys are supported */
171
+ idempotency_keys?: boolean;
172
+ /** Supported content types for request/response */
173
+ content_types?: string[];
174
+ };
175
+ /**
176
+ * IATA airport codes or UN/LOCODE identifiers for regions where this provider
177
+ * has infrastructure (e.g. ["IAD", "AMS"]). Used by agents to select the
178
+ * nearest provider and reduce mpp-session round-trip latency.
179
+ */
180
+ regions?: string[];
181
+ /**
182
+ * Provider-declared p50 latency in milliseconds per region code.
183
+ * Keys must be a subset of `regions`. Agents can use these hints to
184
+ * rank providers by expected round-trip cost before opening a session.
185
+ * Example: { "IAD": 14, "AMS": 22 }
186
+ */
187
+ latency_hints?: Record<string, number>;
188
+ /**
189
+ * Base64 Ed25519 signature of the payee keypair over the SHA-256 digest of
190
+ * this manifest with the `signature` field omitted. Clients must verify this
191
+ * before trusting any routing field (payee, endpoints, pricing).
192
+ */
193
+ signature?: string;
194
+ /** Canonical manifest-signature format. Version 2 signs nested fields recursively. */
195
+ signature_version?: '2';
196
+ /** Optional hierarchical categories from a published taxonomy (e.g. "data/price/crypto") */
197
+ categories?: string[];
198
+ }
199
+ /** Result returned by client.pay() for any payment mode */
200
+ interface PaymentResult {
201
+ /** Parsed response body from the provider */
202
+ data: unknown;
203
+ /** On-chain Stellar transaction hash, or null for session voucher calls */
204
+ txHash: string | null;
205
+ /** Payment mode that was used for this call */
206
+ mode: PaymentMode;
207
+ /** Amount paid in the payment asset (decimal string) */
208
+ amount: string;
209
+ /** Unix timestamp (ms) when the payment completed */
210
+ timestamp: number;
211
+ }
212
+ /** Result returned by client.preflight() — summary of trustline status and provider capabilities */
213
+ interface PreflightResult {
214
+ /** Whether the trustline exists on-chain for the payer */
215
+ hasTrustline: boolean;
216
+ /** Payment asset ticker, e.g. "USDC" */
217
+ asset: string;
218
+ /** Payment modes supported by this provider */
219
+ modes: PaymentMode[];
220
+ /** Regions where this provider has infrastructure */
221
+ regions?: string[];
222
+ /** Provider-declared p50 latency in milliseconds per region code */
223
+ latency_hints?: Record<string, number>;
224
+ /** Optional protocol features supported by this provider */
225
+ capabilities?: RouteDockManifest['capabilities'];
226
+ }
227
+ /** Result returned by client.estimateCost() — the expected charge without submitting any transaction */
228
+ interface EstimateCostResult {
229
+ /** Expected charge in the payment asset (decimal string, e.g. "0.001") */
230
+ amount: string;
231
+ /** Payment asset ticker, e.g. "USDC" */
232
+ asset: string;
233
+ /** Payment mode that would be used */
234
+ mode: PaymentMode;
235
+ /** Full manifest — available for approval-gate / budget-routing decisions */
236
+ manifest: RouteDockManifest;
237
+ /** Regions where this provider has infrastructure */
238
+ regions?: string[];
239
+ /** Provider-declared p50 latency in milliseconds per region code */
240
+ latency_hints?: Record<string, number>;
241
+ /** Optional protocol features supported by this provider */
242
+ capabilities?: RouteDockManifest['capabilities'];
243
+ }
244
+ /** Result returned by session.close() */
245
+ interface SessionCloseResult {
246
+ /** On-chain transaction hash for the channel close */
247
+ closeTxHash: string;
248
+ /** Total amount settled across all vouchers (decimal string) */
249
+ totalPaid: string;
250
+ /** Number of vouchers issued during the session */
251
+ vouchersIssued: number;
252
+ }
253
+ /**
254
+ * Live session statistics returned by {@link SessionHandle.stats}.
255
+ * Read at any point during the session — no need to close it first.
256
+ */
257
+ interface SessionStats {
258
+ /** Number of vouchers issued so far in this session */
259
+ vouchersIssued: number;
260
+ /**
261
+ * Cumulative amount authorized across all signed vouchers so far, in
262
+ * payment-asset decimal units (e.g. "0.0001"). Matches the units of
263
+ * {@link SessionCloseResult.totalPaid}, so a per-session sub-cap can be
264
+ * enforced by comparing against it mid-stream.
265
+ */
266
+ currentCumulative: string;
267
+ /** Stellar channel contract address (C...) */
268
+ channelId: string;
269
+ /**
270
+ * Transaction hash of the on-chain channel-open call, or null for a
271
+ * pre-deployed channel (no open transaction was issued).
272
+ */
273
+ openTxHash: string | null;
274
+ }
275
+ /** Default wall-clock lifetime of a session before it auto-closes (1h). */
276
+ declare const DEFAULT_MAX_SESSION_DURATION_MS = 3600000;
277
+ /** Options accepted by client.openSession() */
278
+ interface SessionOptions {
279
+ /**
280
+ * Session payment mode. Defaults to 'mpp-session' (SSE-style one HTTP
281
+ * request per voucher). Set to 'mpp-session-ws' to negotiate the channel
282
+ * and first voucher over HTTP and then upgrade the connection to WebSocket
283
+ * for push-based streaming. Requires the provider's manifest to advertise
284
+ * the selected mode.
285
+ */
286
+ mode?: 'mpp-session' | 'mpp-session-ws';
287
+ /**
288
+ * Maximum wall-clock lifetime of the session in milliseconds. When the
289
+ * timer fires, the session emits 'session:timeout' and auto-closes so an
290
+ * orphaned channel cannot keep collateral locked on-chain indefinitely.
291
+ * Defaults to {@link DEFAULT_MAX_SESSION_DURATION_MS} (1h). Pass 0 or
292
+ * Infinity to disable the guard (not recommended).
293
+ */
294
+ maxDurationMs?: number;
295
+ /**
296
+ * Optional persistent store for the client-side cumulative baseline.
297
+ *
298
+ * Every challenge is validated against what this client has already signed,
299
+ * so without a store a session refuses a challenge that reports a non-zero
300
+ * cumulative — it cannot tell how much a channel already owes from an earlier
301
+ * session (e.g. across an agent restart that skipped `close()`). Supply a
302
+ * store to resume such a channel, or close it first.
303
+ */
304
+ store?: Store.Store;
305
+ }
306
+ /**
307
+ * Lifecycle events emitted by a SessionHandle.
308
+ *
309
+ * - 'session:timeout' — the maxDurationMs budget elapsed; auto-close started.
310
+ * - 'session:close-failed' — that auto-close rejected. The channel may still
311
+ * hold collateral, so the caller should retry close() or fall back to
312
+ * requestRefund().
313
+ */
314
+ type SessionEvent = 'session:timeout' | 'session:close-failed';
315
+ /** Payload delivered with the 'session:timeout' event. */
316
+ interface SessionTimeoutPayload {
317
+ /** The wall-clock budget (ms) that elapsed before auto-close was triggered. */
318
+ maxDurationMs: number;
319
+ }
320
+ /** Payload delivered with the 'session:close-failed' event. */
321
+ interface SessionCloseFailedPayload {
322
+ /** The wall-clock budget (ms) that elapsed before auto-close was triggered. */
323
+ maxDurationMs: number;
324
+ /**
325
+ * The rejection thrown by the failed auto-close. Typed `unknown` because the
326
+ * close path wraps transport, RPC, and channel-state failures, and a rejection
327
+ * is not guaranteed to be an Error.
328
+ */
329
+ error: unknown;
330
+ }
331
+ /**
332
+ * Maps each lifecycle event to the payload its listener receives, so on() can
333
+ * narrow the callback argument per event.
334
+ */
335
+ interface SessionEventPayloadMap {
336
+ 'session:timeout': SessionTimeoutPayload;
337
+ 'session:close-failed': SessionCloseFailedPayload;
338
+ }
339
+ /**
340
+ * Options for SessionHandle.stream().
341
+ */
342
+ interface StreamOptions {
343
+ /**
344
+ * Maximum number of voucher requests outstanding at once before backpressure
345
+ * is applied. Default: 1 (strictly sequential — safe for all providers).
346
+ * Increase only when the provider explicitly advertises support for concurrent
347
+ * vouchers; out-of-order sequence numbers will cause payment failures otherwise.
348
+ */
349
+ concurrency?: number;
350
+ }
351
+ /** Handle for a live MPP session returned by client.openSession() */
352
+ interface SessionHandle {
353
+ /** Stellar channel contract address (C...) */
354
+ channelId: string;
355
+ /**
356
+ * Transaction hash of the on-chain channel-open call, or null.
357
+ * The one-way-channel contract is deployed and funded before the agent
358
+ * runs, so openSession() performs no on-chain open and has no hash to
359
+ * report — it returns null rather than a non-transaction identifier.
360
+ */
361
+ openTxHash: string | null;
362
+ /**
363
+ * Async generator of streamed data.
364
+ *
365
+ * mpp-session: each iteration sends a voucher over HTTP and yields the
366
+ * parsed response body. With default concurrency (1) the next voucher is not
367
+ * issued until the provider returns HTTP 200 for the previous one.
368
+ *
369
+ * mpp-session-ws: opens the channel and negotiates the first voucher over
370
+ * HTTP, upgrades the connection to WebSocket, and yields each server frame
371
+ * (JSON frames parsed, raw strings yielded as-is). The stream ends when the
372
+ * server closes the socket with a normal close code.
373
+ *
374
+ * Once close() has been called (manually or by the maxDurationMs lifetime
375
+ * guard), the next next() on an mpp-session iterator rejects with a
376
+ * RouteDockChannelStateError whose message is "session closed" instead of
377
+ * signing another voucher. Pipelined streams (concurrency > 1) stop refilling
378
+ * their in-flight window the same way.
379
+ * UNAUDITED: uses stellar-experimental/one-way-channel contract.
380
+ */
381
+ stream(options?: StreamOptions): AsyncIterable<unknown>;
382
+ /**
383
+ * Snapshot of live session statistics (vouchers issued, cumulative amount
384
+ * authorized, channel identity). Values are updated synchronously on every
385
+ * stream() yield, so callers can log spend or enforce a per-session sub-cap
386
+ * without terminating the session.
387
+ */
388
+ stats(): SessionStats;
389
+ /** Close the channel on-chain with the highest signed voucher */
390
+ close(): Promise<SessionCloseResult>;
391
+ /** Request refund from the channel contract (initiates dispute) */
392
+ requestRefund(): Promise<string>;
393
+ /** Server-side counter-mechanism to settle with latest voucher before refund window expires */
394
+ settleWithLatestVoucher(): Promise<string>;
395
+ /** Get the current dispute status of the channel */
396
+ getDisputeStatus(): Promise<DisputeStatus>;
397
+ /**
398
+ * Subscribe to a session lifecycle event (e.g. 'session:timeout').
399
+ * Returns an unsubscribe function. Throwing inside the listener is caught;
400
+ * a rejected promise it returns is swallowed the same way.
401
+ */
402
+ on<E extends SessionEvent>(event: E, listener: (payload: SessionEventPayloadMap[E]) => void): () => void;
403
+ }
404
+ /**
405
+ * Durable session state stored in Supabase (sessions table).
406
+ * cumulative_amount is a decimal string to avoid float precision loss.
407
+ * The monotonic invariant is enforced both here and at the DB level via trigger.
408
+ */
409
+ interface SessionState {
410
+ channel_id: string;
411
+ payee: string;
412
+ payer: string;
413
+ channel_contract: string;
414
+ network: 'testnet' | 'mainnet';
415
+ /** Monotonically increasing cumulative amount — stored as string to preserve precision */
416
+ cumulative_amount: string;
417
+ last_signature: string;
418
+ status: 'open' | 'closing' | 'closed';
419
+ opened_at: string;
420
+ updated_at: string;
421
+ settlement_tx_hash: string | null;
422
+ }
423
+
424
+ /** Dispute status of a channel */
425
+ type DisputeStatus = 'open' | 'in-refund-window' | 'refundable' | 'settled';
426
+
427
+ /**
428
+ * Structured logging hook shared by the client and provider adapters.
429
+ *
430
+ * The SDK used to write straight to `console` in a couple of dozen error
431
+ * paths, which is unusable on structured-logging runtimes (Cloudflare Workers,
432
+ * Datadog, …) and untestable without spying on `console`. Every internal
433
+ * diagnostic now goes through a {@link RouteDockLogger}, so a consumer can
434
+ * silence it, redirect it, or attach correlation fields.
435
+ *
436
+ * The default implementation is console-backed, so behaviour is unchanged when
437
+ * no logger is supplied.
438
+ */
439
+ /** Severity of a log line. */
440
+ type RouteDockLogLevel = 'debug' | 'info' | 'warn' | 'error';
441
+ /**
442
+ * Structured context attached to a log line, typically `{ error: err }`. Sinks
443
+ * receive the values unresolved, so a serialising sink must project non-JSON
444
+ * values such as `Error` itself.
445
+ */
446
+ type RouteDockLogFields = Record<string, unknown>;
447
+ /**
448
+ * Consumer-supplied log sink.
449
+ *
450
+ * `fields` carries the structured payload (the error, the channel id, …) that
451
+ * a bare string would drop at the boundary.
452
+ */
453
+ type RouteDockLogger = (level: RouteDockLogLevel, message: string, fields?: RouteDockLogFields) => void;
454
+ /**
455
+ * Default logger that forwards to the console at the matching level. Field
456
+ * values are spread as additional console arguments so `console.error(msg, err)`
457
+ * spies (and existing log shippers) keep seeing the raw error object.
458
+ */
459
+ declare function createConsoleLogger(): RouteDockLogger;
460
+ /** Shared console-backed logger — the default when none is configured. */
461
+ declare const consoleLogger: RouteDockLogger;
462
+ /** Logger that discards every line. */
463
+ declare const noopLogger: RouteDockLogger;
464
+ /** Resolve an optional logger to a concrete sink, defaulting to `fallback`. */
465
+ declare function resolveLogger(logger: RouteDockLogger | undefined, fallback?: RouteDockLogger): RouteDockLogger;
466
+
467
+ export { type AssetConfig as A, DEFAULT_MAX_SESSION_DURATION_MS as D, type EndpointDescriptor as E, type PaymentMode as P, type RouteDockLogFields as R, type SLAConfig as S, type VaultMode as V, type DisputeStatus as a, type EstimateCostResult as b, type PaymentResult as c, type PreflightResult as d, type PricingConfig as e, type RouteDockLogLevel as f, type RouteDockLogger as g, type RouteDockManifest as h, type SessionCloseFailedPayload as i, type SessionCloseResult as j, type SessionEvent as k, type SessionEventPayloadMap as l, type SessionHandle as m, type SessionOptions as n, type SessionPricingConfig as o, type SessionState as p, type SessionStats as q, type SessionTimeoutPayload as r, type StreamOptions as s, consoleLogger as t, createConsoleLogger as u, noopLogger as v, resolveLogger as w };