lane-sdk 0.1.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.
@@ -0,0 +1,1985 @@
1
+ import { EventEmitter } from 'node:events';
2
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3
+
4
+ /** Configuration accepted by the Lane constructor. */
5
+ interface LaneConfig {
6
+ /** SDK API key (`lane_sk_...` or `lane_sk_test_...`). */
7
+ apiKey?: string;
8
+ /** Override the Lane API base URL. */
9
+ baseUrl?: string;
10
+ /** Force test mode regardless of key prefix. */
11
+ testMode?: boolean;
12
+ /** Request timeout in milliseconds (default 30 000). */
13
+ timeout?: number;
14
+ /** Max automatic retries on transient failures (default 2). */
15
+ maxRetries?: number;
16
+ /** Circuit breaker configuration. */
17
+ circuitBreaker?: {
18
+ /** Number of consecutive failures before opening the circuit (default 3). */
19
+ failureThreshold?: number;
20
+ /** Time in ms before attempting to close the circuit (default 30000). */
21
+ resetTimeoutMs?: number;
22
+ };
23
+ /** Custom token store implementation. */
24
+ tokenStore?: TokenStore;
25
+ }
26
+ /** Resolved, immutable configuration used internally. */
27
+ interface ResolvedConfig {
28
+ readonly apiKey: string;
29
+ readonly baseUrl: string;
30
+ readonly testMode: boolean;
31
+ readonly timeout: number;
32
+ readonly maxRetries: number;
33
+ readonly circuitBreaker?: {
34
+ readonly failureThreshold: number;
35
+ readonly resetTimeoutMs: number;
36
+ };
37
+ }
38
+ interface Credentials {
39
+ apiKey: string;
40
+ refreshToken?: string;
41
+ expiresAt?: string;
42
+ developerId?: string;
43
+ environment?: 'live' | 'test';
44
+ }
45
+ interface DeveloperProfile {
46
+ id: string;
47
+ email: string;
48
+ plan: string;
49
+ memberSince: string;
50
+ }
51
+ interface RotateKeyResult {
52
+ apiKey: string;
53
+ expiresOldKeyAt: string;
54
+ }
55
+ interface Wallet {
56
+ id: string;
57
+ developerId: string;
58
+ userId?: string;
59
+ createdAt: string;
60
+ }
61
+ interface CreateWalletParams {
62
+ userId?: string;
63
+ idempotencyKey?: string;
64
+ }
65
+ interface Card {
66
+ id: string;
67
+ last4: string;
68
+ brand: string;
69
+ status: 'active' | 'inactive';
70
+ isDefault: boolean;
71
+ createdAt: string;
72
+ }
73
+ interface AgenticToken {
74
+ id: string;
75
+ walletId: string;
76
+ amount: number;
77
+ currency: string;
78
+ merchant: string;
79
+ permissions: string[];
80
+ status: 'active' | 'used' | 'expired' | 'revoked';
81
+ expiresAt: string;
82
+ createdAt: string;
83
+ }
84
+ interface CreateTokenParams {
85
+ walletId: string;
86
+ amount: number;
87
+ currency?: string;
88
+ merchant?: string;
89
+ expiresIn?: string;
90
+ permissions?: string[];
91
+ idempotencyKey?: string;
92
+ }
93
+ interface ExecutePaymentParams {
94
+ tokenId?: string;
95
+ recipient: string;
96
+ amount: number;
97
+ currency?: string;
98
+ description?: string;
99
+ idempotencyKey?: string;
100
+ }
101
+ interface Transaction {
102
+ id: string;
103
+ amount: number;
104
+ currency: string;
105
+ recipient: string;
106
+ description?: string;
107
+ status: 'success' | 'denied' | 'pending' | 'refunded';
108
+ receiptUrl?: string;
109
+ testMode: boolean;
110
+ createdAt: string;
111
+ }
112
+ interface RefundParams {
113
+ transactionId: string;
114
+ amount?: number;
115
+ reason?: string;
116
+ idempotencyKey?: string;
117
+ }
118
+ interface Refund {
119
+ id: string;
120
+ transactionId: string;
121
+ amount: number;
122
+ reason?: string;
123
+ status: 'initiated' | 'under_review' | 'resolved';
124
+ createdAt: string;
125
+ }
126
+ interface Product {
127
+ id: string;
128
+ name: string;
129
+ description?: string;
130
+ type: 'skill' | 'api' | 'saas' | 'opensource';
131
+ pricing: PricingConfig;
132
+ sellerId: string;
133
+ rating?: number;
134
+ createdAt: string;
135
+ }
136
+ interface PricingConfig {
137
+ model: 'fixed' | 'subscription' | 'consumption';
138
+ price?: number;
139
+ monthlyPrice?: number;
140
+ pricePerCall?: number;
141
+ currency: string;
142
+ }
143
+ interface ProductSearchParams {
144
+ query: string;
145
+ type?: Product['type'];
146
+ limit?: number;
147
+ offset?: number;
148
+ }
149
+ interface CheckoutSession {
150
+ id: string;
151
+ productId: string;
152
+ walletId: string;
153
+ quantity: number;
154
+ status: 'pending' | 'completed' | 'cancelled';
155
+ orderId?: string;
156
+ createdAt: string;
157
+ }
158
+ interface CreateCheckoutParams {
159
+ productId: string;
160
+ walletId: string;
161
+ quantity?: number;
162
+ idempotencyKey?: string;
163
+ }
164
+ interface Order {
165
+ id: string;
166
+ checkoutSessionId: string;
167
+ productId: string;
168
+ amount: number;
169
+ currency: string;
170
+ status: 'completed' | 'refunded';
171
+ apiKey?: string;
172
+ endpoint?: string;
173
+ createdAt: string;
174
+ }
175
+ interface CreateProductParams {
176
+ name: string;
177
+ type: Product['type'];
178
+ endpoint?: string;
179
+ mcpEndpoint?: string;
180
+ pricing: PricingConfig;
181
+ description?: string;
182
+ auth?: {
183
+ type: 'api_key' | 'oauth' | 'none';
184
+ };
185
+ idempotencyKey?: string;
186
+ }
187
+ interface ProductAnalytics {
188
+ revenue: number;
189
+ transactions: number;
190
+ uniqueAgents: number;
191
+ topBuyers: {
192
+ agentId: string;
193
+ spent: number;
194
+ }[];
195
+ avgCallsPerDay: number;
196
+ }
197
+ interface AnalyticsParams {
198
+ productId: string;
199
+ period: string;
200
+ }
201
+ interface BudgetConfig {
202
+ dailyLimit?: number;
203
+ weeklyLimit?: number;
204
+ monthlyLimit?: number;
205
+ perTaskLimit?: number;
206
+ confirmationThreshold?: number;
207
+ merchantAllowlist?: string[];
208
+ merchantBlocklist?: string[];
209
+ }
210
+ interface SpendingSummary {
211
+ total: number;
212
+ currency: string;
213
+ teams?: TeamSpending[];
214
+ topMerchants: string[];
215
+ alerts: string[];
216
+ }
217
+ interface TeamSpending {
218
+ name: string;
219
+ spent: number;
220
+ budget: number;
221
+ status: 'ok' | 'warning' | 'over';
222
+ }
223
+ interface TeamMember {
224
+ id: string;
225
+ email: string;
226
+ role: 'admin' | 'developer' | 'viewer';
227
+ teamId?: string;
228
+ createdAt: string;
229
+ }
230
+ type WebhookEvent = 'transaction.completed' | 'transaction.denied' | 'transaction.refunded' | 'transaction.pending_approval' | 'budget.exceeded' | 'budget.warning' | 'card.added' | 'card.removed' | 'agent.connected' | 'agent.disconnected' | 'key.rotated' | 'product.purchased' | 'payout.sent';
231
+ interface WebhookConfig {
232
+ id?: string;
233
+ url: string;
234
+ events: (WebhookEvent | `${string}.*`)[];
235
+ secret?: string;
236
+ }
237
+ interface WebhookPayload {
238
+ id: string;
239
+ event: WebhookEvent;
240
+ data: Record<string, unknown>;
241
+ createdAt: string;
242
+ testMode: boolean;
243
+ }
244
+ interface RequestOptions {
245
+ method: 'GET' | 'POST' | 'PUT' | 'DELETE';
246
+ path: string;
247
+ body?: Record<string, unknown>;
248
+ query?: Record<string, string | number | boolean | undefined>;
249
+ idempotencyKey?: string;
250
+ timeout?: number;
251
+ }
252
+ interface APIResponse<T> {
253
+ data: T;
254
+ requestId: string;
255
+ testMode: boolean;
256
+ rateLimitRemaining?: number;
257
+ rateLimitLimit?: number;
258
+ rateLimitReset?: number;
259
+ }
260
+ interface PaginatedResponse<T> {
261
+ data: T[];
262
+ total: number;
263
+ limit: number;
264
+ offset: number;
265
+ requestId: string;
266
+ }
267
+ interface TokenStore {
268
+ read(): Promise<Credentials | null>;
269
+ write(credentials: Credentials): Promise<void>;
270
+ clear(): Promise<void>;
271
+ }
272
+ interface Merchant {
273
+ id: string;
274
+ name: string;
275
+ slug: string;
276
+ description?: string;
277
+ categories: string[];
278
+ supportedPaymentMethods: string[];
279
+ }
280
+ /** Visa network token — issued by VIC, used for merchant-agnostic payments. */
281
+ interface VICToken {
282
+ id: string;
283
+ walletId: string;
284
+ networkTokenId: string;
285
+ last4: string;
286
+ brand: 'visa';
287
+ status: 'active' | 'suspended' | 'expired' | 'revoked';
288
+ expiresAt: string;
289
+ createdAt: string;
290
+ }
291
+ /** Parameters to issue a VIC agentic token. */
292
+ interface VICIssuanceParams {
293
+ walletId: string;
294
+ cardId: string;
295
+ /** Max single-transaction amount in cents. */
296
+ maxTransactionAmount?: number;
297
+ /** Merchant category codes (MCCs) the token is restricted to. */
298
+ allowedMCCs?: string[];
299
+ /** Expiry duration (e.g., '24h', '7d'). */
300
+ expiresIn?: string;
301
+ idempotencyKey?: string;
302
+ }
303
+ /** A Visa network token with associated cryptogram for a single transaction. */
304
+ interface NetworkTokenPayload {
305
+ /** Visa-provisioned token number (DPAN). */
306
+ tokenNumber: string;
307
+ /** Transaction-specific cryptogram. */
308
+ cryptogram: string;
309
+ /** Electronic Commerce Indicator. */
310
+ eci: string;
311
+ expMonth: number;
312
+ expYear: number;
313
+ }
314
+ /** Payment route used by the routing engine. */
315
+ type PaymentRoute = 'billing_api' | 'acp' | 'vic' | 'fallback';
316
+ /** Result from the payment routing engine. */
317
+ interface RoutingDecision {
318
+ route: PaymentRoute;
319
+ merchantId: string;
320
+ /** Why this route was chosen. */
321
+ reason: string;
322
+ /** Fallback routes if primary fails. */
323
+ fallbacks: PaymentRoute[];
324
+ }
325
+ interface UsageRecord {
326
+ id: string;
327
+ productId: string;
328
+ buyerId: string;
329
+ /** Number of units consumed (API calls, tokens, etc.). */
330
+ quantity: number;
331
+ /** Unit type for billing. */
332
+ unit: string;
333
+ timestamp: string;
334
+ }
335
+ interface MeteringConfig {
336
+ /** Billing period: 'hourly' | 'daily' | 'monthly'. */
337
+ period: 'hourly' | 'daily' | 'monthly';
338
+ /** Price per unit in cents. */
339
+ pricePerUnit: number;
340
+ /** Currency code. */
341
+ currency: string;
342
+ /** Free tier units per period. */
343
+ freeUnits?: number;
344
+ /** Hard cap on units per period. */
345
+ maxUnits?: number;
346
+ }
347
+ interface UsageReport {
348
+ productId: string;
349
+ period: string;
350
+ totalUnits: number;
351
+ totalRevenue: number;
352
+ uniqueBuyers: number;
353
+ breakdown: {
354
+ date: string;
355
+ units: number;
356
+ revenue: number;
357
+ }[];
358
+ }
359
+ interface PayoutConfig {
360
+ id: string;
361
+ sellerId: string;
362
+ destination: 'bank_account' | 'stripe_connect';
363
+ destinationId: string;
364
+ schedule: 'daily' | 'weekly' | 'monthly';
365
+ currency: string;
366
+ minimumPayout: number;
367
+ }
368
+ interface Payout {
369
+ id: string;
370
+ sellerId: string;
371
+ amount: number;
372
+ currency: string;
373
+ status: 'pending' | 'processing' | 'completed' | 'failed';
374
+ periodStart: string;
375
+ periodEnd: string;
376
+ createdAt: string;
377
+ }
378
+ /** Organization-level entity that owns teams and developers. */
379
+ interface Organization {
380
+ id: string;
381
+ name: string;
382
+ plan: 'free' | 'pro' | 'team' | 'enterprise';
383
+ createdAt: string;
384
+ }
385
+ /** Team within an organization. */
386
+ interface Team {
387
+ id: string;
388
+ orgId: string;
389
+ name: string;
390
+ budget?: BudgetConfig;
391
+ memberCount: number;
392
+ createdAt: string;
393
+ }
394
+ interface CreateTeamParams {
395
+ name: string;
396
+ budget?: BudgetConfig;
397
+ }
398
+ /** Registered agent in a fleet. */
399
+ interface AgentRecord {
400
+ id: string;
401
+ developerId: string;
402
+ name: string;
403
+ type: string;
404
+ status: 'active' | 'suspended' | 'revoked';
405
+ walletId?: string;
406
+ policy?: AgentPolicy;
407
+ lastSeenAt?: string;
408
+ createdAt: string;
409
+ }
410
+ /** Policy governing what an agent can do. */
411
+ interface AgentPolicy {
412
+ /** Budget limits specific to this agent. */
413
+ budget?: BudgetConfig;
414
+ /** Allowed merchant categories. */
415
+ allowedMCCs?: string[];
416
+ /** Max single transaction amount in cents. */
417
+ maxTransactionAmount?: number;
418
+ /** Whether the agent can initiate refunds. */
419
+ canRefund?: boolean;
420
+ /** Whether the agent can discover new products. */
421
+ canDiscover?: boolean;
422
+ /** Require human approval above this amount in cents. */
423
+ approvalThreshold?: number;
424
+ }
425
+ interface RegisterAgentParams {
426
+ name: string;
427
+ type: string;
428
+ walletId?: string;
429
+ policy?: AgentPolicy;
430
+ }
431
+ /** Hierarchical budget that cascades: Org > Team > Developer > Agent. */
432
+ interface HierarchicalBudget {
433
+ orgBudget?: BudgetConfig;
434
+ teamBudget?: BudgetConfig;
435
+ developerBudget?: BudgetConfig;
436
+ agentBudget?: BudgetConfig;
437
+ /** The effective limit is the minimum across all levels. */
438
+ effectiveLimits: BudgetConfig;
439
+ }
440
+ /** Audit log entry. */
441
+ interface AuditEntry {
442
+ id: string;
443
+ timestamp: string;
444
+ action: string;
445
+ actorType: 'developer' | 'agent' | 'system';
446
+ actorId: string;
447
+ resource: string;
448
+ resourceId: string;
449
+ details: Record<string, unknown>;
450
+ requestId: string;
451
+ ipAddress?: string;
452
+ }
453
+ interface AuditQueryParams {
454
+ startDate?: string;
455
+ endDate?: string;
456
+ actorType?: AuditEntry['actorType'];
457
+ actorId?: string;
458
+ action?: string;
459
+ resource?: string;
460
+ limit?: number;
461
+ offset?: number;
462
+ }
463
+ /** Lane-issued agent identity credential. */
464
+ interface AgentIdentity {
465
+ id: string;
466
+ agentId: string;
467
+ developerId: string;
468
+ /** Verified identity chain. */
469
+ kycChain: KYCChain;
470
+ /** Lane-issued attestation. */
471
+ attestation: IdentityAttestation;
472
+ status: 'pending' | 'verified' | 'suspended' | 'revoked';
473
+ createdAt: string;
474
+ verifiedAt?: string;
475
+ }
476
+ /** KYC verification chain: Human -> Lane -> Agent -> Transaction. */
477
+ interface KYCChain {
478
+ /** Developer identity verification status. */
479
+ humanVerified: boolean;
480
+ /** Lane platform verification. */
481
+ laneVerified: boolean;
482
+ /** Agent registration and policy binding. */
483
+ agentBound: boolean;
484
+ /** Transaction-level verification via cryptographic attestation. */
485
+ transactionSigned: boolean;
486
+ }
487
+ /** Cryptographic attestation issued by Lane for an agent. */
488
+ interface IdentityAttestation {
489
+ /** Base64-encoded attestation document. */
490
+ document: string;
491
+ /** Signature over the attestation. */
492
+ signature: string;
493
+ /** Public key fingerprint of the signing key. */
494
+ keyFingerprint: string;
495
+ /** ISO 8601 expiry. */
496
+ expiresAt: string;
497
+ }
498
+ interface RegisterIdentityParams {
499
+ agentId: string;
500
+ /** Agent capabilities declaration. */
501
+ capabilities?: string[];
502
+ /** Agent's intended use description. */
503
+ purpose?: string;
504
+ }
505
+ interface VerifyIdentityParams {
506
+ identityId: string;
507
+ /** Developer verification code (from email/SMS). */
508
+ verificationCode: string;
509
+ }
510
+ interface SCPManifest {
511
+ scp_version: string;
512
+ product: SCPProduct;
513
+ plans: SCPPlan[];
514
+ provisioning: SCPProvisioning;
515
+ selection_parameters?: SCPSelectionParameters;
516
+ }
517
+ interface SCPProduct {
518
+ id: string;
519
+ name: string;
520
+ vendor: string;
521
+ type: 'api' | 'saas' | 'skill' | 'oss_tool';
522
+ description: string;
523
+ documentation_url?: string;
524
+ category: string[];
525
+ }
526
+ interface SCPPlan {
527
+ id: string;
528
+ name: string;
529
+ pricing: SCPPricing;
530
+ limits?: Record<string, string | number>;
531
+ features: string[];
532
+ }
533
+ interface SCPPricing {
534
+ model: 'fixed' | 'subscription' | 'consumption';
535
+ amount?: number;
536
+ monthly?: number;
537
+ yearly?: number;
538
+ per_unit?: number;
539
+ unit_name?: string;
540
+ currency: string;
541
+ }
542
+ interface SCPProvisioning {
543
+ method: 'instant' | 'webhook' | 'proxied';
544
+ credentials_type?: 'api_key' | 'oauth' | 'bearer_token';
545
+ env_var_name?: string;
546
+ sdk_package?: string;
547
+ sdk_install?: string;
548
+ quickstart_code?: string;
549
+ }
550
+ interface SCPSelectionParameters {
551
+ required: string[];
552
+ optional?: SCPParameter[];
553
+ }
554
+ interface SCPParameter {
555
+ name: string;
556
+ type: string;
557
+ description: string;
558
+ }
559
+ interface Subscription {
560
+ id: string;
561
+ walletId: string;
562
+ productId: string;
563
+ plan: string;
564
+ status: 'active' | 'paused' | 'canceled' | 'past_due' | 'trialing';
565
+ accessToken?: string;
566
+ currentPeriodStart: string;
567
+ currentPeriodEnd: string;
568
+ canceledAt?: string;
569
+ createdAt: string;
570
+ }
571
+ interface CreateSubscriptionParams {
572
+ productId: string;
573
+ plan: string;
574
+ parameters?: Record<string, string>;
575
+ paymentSource: 'wallet';
576
+ }
577
+ interface UpdateSubscriptionParams {
578
+ plan?: string;
579
+ parameters?: Record<string, string>;
580
+ }
581
+ interface CredentialInjection {
582
+ type: 'api_key' | 'oauth' | 'bearer_token';
583
+ value: string;
584
+ envVar: string;
585
+ expiresAt?: string;
586
+ }
587
+ interface SDKInfo {
588
+ package: string;
589
+ install: string;
590
+ quickstart: string;
591
+ }
592
+ interface SoftwareCheckoutParams extends CreateCheckoutParams {
593
+ plan?: string;
594
+ parameters?: Record<string, string>;
595
+ }
596
+ interface SoftwareOrder extends Order {
597
+ credentials?: CredentialInjection;
598
+ sdk?: SDKInfo;
599
+ subscription?: {
600
+ plan: string;
601
+ billingPeriod: 'monthly' | 'yearly';
602
+ nextCharge: string;
603
+ amount: number;
604
+ };
605
+ }
606
+ interface SoftwareProductSearchParams extends Omit<ProductSearchParams, 'type'> {
607
+ type?: 'ecommerce' | 'software' | 'skill' | 'oss';
608
+ pricingModel?: 'fixed' | 'subscription' | 'consumption';
609
+ }
610
+ interface DepositParams {
611
+ amount: number;
612
+ idempotencyKey?: string;
613
+ }
614
+ interface DepositResult {
615
+ walletId: string;
616
+ amount: number;
617
+ newBalance: number;
618
+ transactionId: string;
619
+ currency: string;
620
+ }
621
+ interface AutoReloadConfig {
622
+ enabled: boolean;
623
+ threshold: number;
624
+ amount: number;
625
+ }
626
+ interface CardAttributes {
627
+ last4: string;
628
+ brand: string;
629
+ type: 'credit' | 'debit' | 'prepaid';
630
+ country: string;
631
+ isVirtual: boolean;
632
+ }
633
+ interface WalletBalance {
634
+ balance: number;
635
+ currency: string;
636
+ card?: CardAttributes;
637
+ autoReload?: AutoReloadConfig;
638
+ }
639
+ type MerchantType = 'ecommerce' | 'software' | 'api' | 'saas' | 'skill' | 'service';
640
+ interface DirectoryMerchant {
641
+ id: string;
642
+ name: string;
643
+ slug: string;
644
+ domain: string;
645
+ description?: string;
646
+ logoUrl?: string;
647
+ website?: string;
648
+ tier: 'lane_onboarded' | 'protocol';
649
+ merchantType: MerchantType;
650
+ vertical: string;
651
+ subcategories: string[];
652
+ supportedPaymentMethods: string[];
653
+ protocols: string[];
654
+ productAttributes?: Record<string, unknown>;
655
+ capabilities: {
656
+ hasBillingAPI: boolean;
657
+ supportsACP: boolean;
658
+ supportsUCP: boolean;
659
+ supportsVIC: boolean;
660
+ acceptsVisa: boolean;
661
+ acceptsMastercard: boolean;
662
+ };
663
+ productCount?: number;
664
+ lastSyncedAt?: string;
665
+ }
666
+ interface MerchantSearchParams {
667
+ query?: string;
668
+ tier?: 'lane_onboarded' | 'protocol';
669
+ merchantType?: MerchantType;
670
+ vertical?: string;
671
+ subcategory?: string;
672
+ protocol?: string;
673
+ limit?: number;
674
+ offset?: number;
675
+ }
676
+ interface ProtocolDiscoveryResult {
677
+ merchant: DirectoryMerchant;
678
+ protocols: string[];
679
+ manifestUrl: string;
680
+ }
681
+ interface MerchantVerticalSummary {
682
+ vertical: string;
683
+ merchantType: string;
684
+ subcategories: string[];
685
+ count: number;
686
+ }
687
+ interface CheckoutProfile {
688
+ id: string;
689
+ walletId: string;
690
+ email: string;
691
+ phone?: string;
692
+ fullName: string;
693
+ billingLine1: string;
694
+ billingLine2?: string;
695
+ billingCity: string;
696
+ billingState: string;
697
+ billingPostalCode: string;
698
+ billingCountry: string;
699
+ shippingLine1?: string;
700
+ shippingLine2?: string;
701
+ shippingCity?: string;
702
+ shippingState?: string;
703
+ shippingPostalCode?: string;
704
+ shippingCountry?: string;
705
+ shippingSameAsBilling: boolean;
706
+ createdAt: string;
707
+ updatedAt: string;
708
+ }
709
+ interface SetCheckoutProfileParams {
710
+ email: string;
711
+ phone?: string;
712
+ fullName: string;
713
+ billingLine1: string;
714
+ billingLine2?: string;
715
+ billingCity: string;
716
+ billingState: string;
717
+ billingPostalCode: string;
718
+ billingCountry?: string;
719
+ shippingLine1?: string;
720
+ shippingLine2?: string;
721
+ shippingCity?: string;
722
+ shippingState?: string;
723
+ shippingPostalCode?: string;
724
+ shippingCountry?: string;
725
+ shippingSameAsBilling?: boolean;
726
+ }
727
+ interface MerchantAccount {
728
+ id: string;
729
+ walletId: string;
730
+ merchantDomain: string;
731
+ merchantName?: string;
732
+ accountEmail?: string;
733
+ accountUsername?: string;
734
+ authType: 'password' | 'api_key' | 'oauth' | 'sso';
735
+ status: 'active' | 'expired' | 'revoked';
736
+ lastUsedAt?: string;
737
+ createdAt: string;
738
+ }
739
+ interface SaveMerchantAccountParams {
740
+ merchantDomain: string;
741
+ merchantName?: string;
742
+ accountEmail?: string;
743
+ accountUsername?: string;
744
+ passwordAlias?: string;
745
+ authType?: 'password' | 'api_key' | 'oauth' | 'sso';
746
+ apiKeyAlias?: string;
747
+ oauthTokenAlias?: string;
748
+ }
749
+
750
+ interface LaneErrorOptions {
751
+ code: string;
752
+ statusCode: number;
753
+ requestId?: string;
754
+ retryable?: boolean;
755
+ suggestedAction?: string;
756
+ }
757
+ /**
758
+ * Base error class for all Lane SDK errors.
759
+ *
760
+ * Carries structured metadata so agents can make programmatic decisions
761
+ * without parsing human-readable messages.
762
+ */
763
+ declare class LaneError extends Error {
764
+ /** Machine-readable error code (e.g. 'budget_exceeded'). */
765
+ readonly code: string;
766
+ /** HTTP status code from the API (or synthetic for client-side errors). */
767
+ readonly statusCode: number;
768
+ /** Request ID for support and audit trail correlation. */
769
+ readonly requestId: string;
770
+ /** Whether the caller should retry this request. */
771
+ readonly retryable: boolean;
772
+ /** Human-readable suggestion for what the agent should do next. */
773
+ readonly suggestedAction?: string;
774
+ /** Executable suggestion for agents (e.g. "lane.wallet.deposit(2000)"). */
775
+ fix?: string;
776
+ /** Current state context for agent decision-making. */
777
+ currentState?: Record<string, unknown>;
778
+ constructor(message: string, options: LaneErrorOptions);
779
+ /** Serialize to a plain object for structured logging / JSON responses. */
780
+ toJSON(): Record<string, unknown>;
781
+ }
782
+ declare class LaneAuthError extends LaneError {
783
+ constructor(message: string, options: Omit<LaneErrorOptions, 'statusCode'> & {
784
+ statusCode?: number;
785
+ });
786
+ static invalidApiKey(requestId?: string): LaneAuthError;
787
+ static expiredToken(requestId?: string): LaneAuthError;
788
+ static insufficientScope(requiredScope: string, requestId?: string): LaneAuthError;
789
+ }
790
+ declare class LanePaymentError extends LaneError {
791
+ constructor(message: string, options: LaneErrorOptions);
792
+ static declined(requestId?: string): LanePaymentError;
793
+ static insufficientFunds(currentBalance?: number, required?: number, requestId?: string): LanePaymentError;
794
+ static merchantUnavailable(merchant: string, requestId?: string): LanePaymentError;
795
+ static serviceError(requestId?: string): LanePaymentError;
796
+ }
797
+ declare class LaneBudgetError extends LaneError {
798
+ /** The budget limit that was exceeded. */
799
+ readonly limit: number;
800
+ /** The amount that was requested. */
801
+ readonly requested: number;
802
+ constructor(message: string, options: LaneErrorOptions & {
803
+ limit: number;
804
+ requested: number;
805
+ });
806
+ static dailyExceeded(limit: number, requested: number, requestId?: string): LaneBudgetError;
807
+ static taskExceeded(limit: number, requested: number, requestId?: string): LaneBudgetError;
808
+ static monthlyExceeded(limit: number, requested: number, requestId?: string): LaneBudgetError;
809
+ static merchantNotAllowed(merchant: string, requestId?: string): LaneBudgetError;
810
+ toJSON(): Record<string, unknown>;
811
+ }
812
+ declare class LaneNotFoundError extends LaneError {
813
+ constructor(resource: string, id: string, requestId?: string);
814
+ }
815
+ declare class LaneRateLimitError extends LaneError {
816
+ /** Seconds until the rate limit resets. */
817
+ readonly retryAfter: number;
818
+ constructor(retryAfter: number, requestId?: string);
819
+ toJSON(): Record<string, unknown>;
820
+ }
821
+ interface FieldError {
822
+ field: string;
823
+ message: string;
824
+ }
825
+ declare class LaneValidationError extends LaneError {
826
+ readonly fields: FieldError[];
827
+ constructor(fields: FieldError[], requestId?: string);
828
+ toJSON(): Record<string, unknown>;
829
+ }
830
+ interface APIErrorBody {
831
+ error: {
832
+ code: string;
833
+ message: string;
834
+ statusCode: number;
835
+ retryable?: boolean;
836
+ suggestedAction?: string;
837
+ retryAfter?: number;
838
+ limit?: number;
839
+ requested?: number;
840
+ fields?: FieldError[];
841
+ };
842
+ requestId: string;
843
+ }
844
+ /** Parse an API error response into the appropriate typed LaneError subclass. */
845
+ declare function createErrorFromResponse(body: APIErrorBody): LaneError;
846
+
847
+ interface LaneClientEvents {
848
+ request: [{
849
+ method: string;
850
+ path: string;
851
+ requestId: string;
852
+ }];
853
+ response: [{
854
+ statusCode: number;
855
+ requestId: string;
856
+ durationMs: number;
857
+ }];
858
+ error: [{
859
+ error: LaneError;
860
+ requestId: string;
861
+ }];
862
+ retry: [{
863
+ attempt: number;
864
+ maxRetries: number;
865
+ requestId: string;
866
+ }];
867
+ }
868
+ /**
869
+ * Low-level HTTP client for the Lane API.
870
+ *
871
+ * Handles authentication, signing, retries, circuit breaking, and error
872
+ * parsing. All Resource classes delegate HTTP calls through this client.
873
+ */
874
+ declare class LaneClient extends EventEmitter<LaneClientEvents> {
875
+ private readonly config;
876
+ private readonly signer;
877
+ private readonly circuitBreaker;
878
+ constructor(config: ResolvedConfig);
879
+ /** Whether this client is operating in test mode. */
880
+ get testMode(): boolean;
881
+ /** The resolved base URL. */
882
+ get baseUrl(): string;
883
+ get<T>(path: string, query?: RequestOptions['query']): Promise<APIResponse<T>>;
884
+ post<T>(path: string, body?: Record<string, unknown>, idempotencyKey?: string): Promise<APIResponse<T>>;
885
+ put<T>(path: string, body?: Record<string, unknown>): Promise<APIResponse<T>>;
886
+ delete<T>(path: string): Promise<APIResponse<T>>;
887
+ request<T>(options: RequestOptions): Promise<APIResponse<T>>;
888
+ private executeRequest;
889
+ private buildUrl;
890
+ private parseErrorBody;
891
+ private isRetryable;
892
+ private backoff;
893
+ }
894
+
895
+ /**
896
+ * Abstract base class for all Lane API resources.
897
+ *
898
+ * Subclasses focus on domain logic; the base class handles HTTP delegation,
899
+ * pagination helpers, and idempotency key forwarding.
900
+ */
901
+ declare abstract class Resource {
902
+ protected readonly client: LaneClient;
903
+ constructor(client: LaneClient);
904
+ /** The API path prefix for this resource (e.g. '/api/sdk/wallets'). */
905
+ protected abstract get basePath(): string;
906
+ protected _get<T>(subpath?: string, query?: Record<string, string | number | boolean | undefined>): Promise<APIResponse<T>>;
907
+ protected _post<T>(subpath?: string, body?: Record<string, unknown>, idempotencyKey?: string): Promise<APIResponse<T>>;
908
+ protected _put<T>(subpath?: string, body?: Record<string, unknown>): Promise<APIResponse<T>>;
909
+ protected _delete<T>(subpath?: string): Promise<APIResponse<T>>;
910
+ /**
911
+ * Helper for paginated list endpoints.
912
+ */
913
+ protected _list<T>(subpath?: string, params?: {
914
+ limit?: number;
915
+ offset?: number;
916
+ } & Record<string, unknown>): Promise<PaginatedResponse<T>>;
917
+ }
918
+
919
+ declare class Auth extends Resource {
920
+ protected get basePath(): string;
921
+ /** Get the authenticated developer's profile. */
922
+ whoami(): Promise<DeveloperProfile>;
923
+ /**
924
+ * Start a login session. Returns a URL the developer opens in their browser.
925
+ */
926
+ login(): Promise<{
927
+ sessionId: string;
928
+ authUrl: string;
929
+ port: number;
930
+ }>;
931
+ /**
932
+ * Exchange a one-time code (from browser callback) for an API key.
933
+ */
934
+ exchangeCode(code: string, sessionId: string): Promise<{
935
+ apiKey: string;
936
+ developerId: string;
937
+ }>;
938
+ /**
939
+ * Rotate the API key. Old key remains valid for 15 minutes.
940
+ */
941
+ rotateKey(): Promise<RotateKeyResult>;
942
+ }
943
+
944
+ declare class Wallets extends Resource {
945
+ protected get basePath(): string;
946
+ /** Create a new wallet, optionally scoped to an end user. */
947
+ create(params?: CreateWalletParams): Promise<Wallet>;
948
+ /** Get a wallet by ID. */
949
+ get(walletId: string): Promise<Wallet>;
950
+ /** List all wallets for the authenticated developer. */
951
+ list(params?: {
952
+ limit?: number;
953
+ offset?: number;
954
+ }): Promise<PaginatedResponse<Wallet>>;
955
+ /** List cards in a wallet. Returns last4/brand only — never full PAN. */
956
+ listCards(walletId: string): Promise<Card[]>;
957
+ /**
958
+ * Get a secure link for the end user to add a card via VGS Collect.
959
+ * PAN goes directly to VGS vault — Lane never sees it.
960
+ */
961
+ getAddCardLink(walletId: string): Promise<{
962
+ url: string;
963
+ expiresAt: string;
964
+ }>;
965
+ /** Revoke a wallet. All linked tokens are immediately invalidated. */
966
+ revoke(walletId: string): Promise<void>;
967
+ /** Remove a specific card from a wallet. */
968
+ removeCard(walletId: string, cardId: string): Promise<void>;
969
+ /** Deposit funds into a wallet. */
970
+ deposit(walletId: string, params: DepositParams): Promise<DepositResult>;
971
+ /** Get wallet balance and metadata. */
972
+ balance(walletId?: string): Promise<WalletBalance>;
973
+ /** Configure auto-reload for a wallet. */
974
+ setAutoReload(walletId: string, config: AutoReloadConfig): Promise<AutoReloadConfig>;
975
+ /** Get card attributes for a wallet. */
976
+ getAttributes(walletId: string): Promise<CardAttributes>;
977
+ /** Set the checkout profile for a wallet (billing, shipping, email). */
978
+ setProfile(walletId: string, profile: SetCheckoutProfileParams): Promise<CheckoutProfile>;
979
+ /** Get the checkout profile. Addresses and email are visible; no sensitive data. */
980
+ getProfile(walletId: string): Promise<CheckoutProfile>;
981
+ /** Update the checkout profile (partial). */
982
+ updateProfile(walletId: string, updates: Partial<SetCheckoutProfileParams>): Promise<CheckoutProfile>;
983
+ /** Save a merchant account (for sites without guest checkout). */
984
+ saveMerchantAccount(walletId: string, params: SaveMerchantAccountParams): Promise<MerchantAccount>;
985
+ /** List saved merchant accounts (domain + email only). */
986
+ listMerchantAccounts(walletId: string): Promise<MerchantAccount[]>;
987
+ /** Remove a saved merchant account. */
988
+ removeMerchantAccount(walletId: string, accountId: string): Promise<void>;
989
+ }
990
+
991
+ declare class Pay extends Resource {
992
+ protected get basePath(): string;
993
+ /**
994
+ * Create a scoped agentic token — amount-limited, merchant-locked,
995
+ * time-bounded. The token can be used to execute a single payment.
996
+ */
997
+ createToken(params: CreateTokenParams): Promise<AgenticToken>;
998
+ /**
999
+ * Execute a payment. Routed via the best available path:
1000
+ * 1. Billing API (for services like OpenAI, Replicate, Vercel)
1001
+ * 2. ACP-enabled merchant checkout
1002
+ * 3. VIC agentic token (when available)
1003
+ *
1004
+ * Idempotency key is strongly recommended to prevent double charges.
1005
+ */
1006
+ execute(params: ExecutePaymentParams): Promise<Transaction>;
1007
+ private generateIdempotencyKey;
1008
+ /** Get a transaction by ID. */
1009
+ getTransaction(transactionId: string): Promise<Transaction>;
1010
+ /** List transactions with optional filters. */
1011
+ listTransactions(params?: {
1012
+ limit?: number;
1013
+ offset?: number;
1014
+ cardId?: string;
1015
+ status?: Transaction['status'];
1016
+ }): Promise<PaginatedResponse<Transaction>>;
1017
+ /**
1018
+ * Initiate a refund. Full or partial.
1019
+ *
1020
+ * Refund routing mirrors payment routing:
1021
+ * - Billing API merchants: calls their refund API
1022
+ * - ACP merchants: initiates refund through PSP
1023
+ * - VIC transactions: standard Visa dispute flow
1024
+ */
1025
+ refund(params: RefundParams): Promise<Refund>;
1026
+ /** Get a refund by ID. */
1027
+ getRefund(refundId: string): Promise<Refund>;
1028
+ }
1029
+
1030
+ declare class Products extends Resource {
1031
+ protected get basePath(): string;
1032
+ /** Search the Lane product catalog. */
1033
+ search(params: ProductSearchParams | SoftwareProductSearchParams): Promise<PaginatedResponse<Product>>;
1034
+ /** Get a product by ID. */
1035
+ get(productId: string): Promise<Product>;
1036
+ /** List available merchants. */
1037
+ listMerchants(params?: {
1038
+ limit?: number;
1039
+ offset?: number;
1040
+ query?: string;
1041
+ }): Promise<PaginatedResponse<Merchant>>;
1042
+ /** Get a merchant by ID or slug. */
1043
+ getMerchant(merchantIdOrSlug: string): Promise<Merchant>;
1044
+ }
1045
+
1046
+ declare class Checkout extends Resource {
1047
+ protected get basePath(): string;
1048
+ /** Create a new checkout session for a product. */
1049
+ create(params: CreateCheckoutParams | SoftwareCheckoutParams): Promise<CheckoutSession>;
1050
+ /** Complete a checkout session — processes payment and returns the order. */
1051
+ complete(sessionId: string): Promise<Order | SoftwareOrder>;
1052
+ /** Get the status of a checkout session. */
1053
+ get(sessionId: string): Promise<CheckoutSession>;
1054
+ /** Cancel a pending checkout session. */
1055
+ cancel(sessionId: string): Promise<CheckoutSession>;
1056
+ }
1057
+
1058
+ declare class Sell extends Resource {
1059
+ protected get basePath(): string;
1060
+ /**
1061
+ * List a product for sale on the Lane marketplace.
1062
+ *
1063
+ * Lane will:
1064
+ * 1. List the product in the Product API (discoverable by any agent)
1065
+ * 2. Create a proxy endpoint (handles auth + metering)
1066
+ * 3. Generate API keys for buyers automatically
1067
+ * 4. Meter usage and bill buyer wallets
1068
+ * 5. Pay out to seller (minus Lane fee)
1069
+ */
1070
+ create(params: CreateProductParams): Promise<Product>;
1071
+ /** Update an existing product listing. */
1072
+ update(productId: string, params: Partial<CreateProductParams>): Promise<Product>;
1073
+ /** Deactivate a product listing (soft delete). */
1074
+ deactivate(productId: string): Promise<void>;
1075
+ /** Get a product you've listed. */
1076
+ get(productId: string): Promise<Product>;
1077
+ /** List all products you've listed for sale. */
1078
+ list(params?: {
1079
+ limit?: number;
1080
+ offset?: number;
1081
+ }): Promise<PaginatedResponse<Product>>;
1082
+ /** Get analytics for a product you've listed. */
1083
+ analytics(params: AnalyticsParams): Promise<ProductAnalytics>;
1084
+ /** List a software product using an SCP manifest. */
1085
+ createSoftwareProduct(manifest: SCPManifest): Promise<Product>;
1086
+ }
1087
+
1088
+ declare class Admin extends Resource {
1089
+ protected get basePath(): string;
1090
+ /** Get spending summary with optional grouping by team/developer/agent. */
1091
+ spending(params: {
1092
+ period: string;
1093
+ groupBy?: 'team' | 'developer' | 'agent';
1094
+ }): Promise<SpendingSummary>;
1095
+ /** Get current budget configuration. */
1096
+ getBudget(scope?: {
1097
+ teamId?: string;
1098
+ developerId?: string;
1099
+ }): Promise<BudgetConfig>;
1100
+ /** Update budget limits. */
1101
+ setBudget(config: BudgetConfig & {
1102
+ teamId?: string;
1103
+ developerId?: string;
1104
+ }): Promise<BudgetConfig>;
1105
+ /** List team members. */
1106
+ listMembers(params?: {
1107
+ limit?: number;
1108
+ offset?: number;
1109
+ teamId?: string;
1110
+ }): Promise<PaginatedResponse<TeamMember>>;
1111
+ /** Invite a team member. */
1112
+ inviteMember(params: {
1113
+ email: string;
1114
+ role: TeamMember['role'];
1115
+ teamId?: string;
1116
+ }): Promise<TeamMember>;
1117
+ /** Update a team member's role. */
1118
+ updateMember(memberId: string, params: {
1119
+ role: TeamMember['role'];
1120
+ }): Promise<TeamMember>;
1121
+ /** Remove a team member. */
1122
+ removeMember(memberId: string): Promise<void>;
1123
+ /**
1124
+ * Export all developer data as JSON (GDPR data portability).
1125
+ */
1126
+ exportData(): Promise<Record<string, unknown>>;
1127
+ /**
1128
+ * Delete the developer account and purge all PII (GDPR right to erasure).
1129
+ * Transaction records are anonymized (amount + merchant retained for regulatory).
1130
+ */
1131
+ deleteAccount(): Promise<{
1132
+ status: string;
1133
+ deletionCompletesAt: string;
1134
+ }>;
1135
+ }
1136
+
1137
+ declare class Webhooks extends Resource {
1138
+ protected get basePath(): string;
1139
+ /** Register a new webhook endpoint. */
1140
+ create(params: Omit<WebhookConfig, 'id'>): Promise<WebhookConfig>;
1141
+ /** List registered webhooks. */
1142
+ list(): Promise<PaginatedResponse<WebhookConfig>>;
1143
+ /** Get a webhook by ID. */
1144
+ get(webhookId: string): Promise<WebhookConfig>;
1145
+ /** Update a webhook configuration. */
1146
+ update(webhookId: string, params: Partial<WebhookConfig>): Promise<WebhookConfig>;
1147
+ /** Delete a webhook endpoint. */
1148
+ delete(webhookId: string): Promise<void>;
1149
+ /**
1150
+ * Verify a webhook payload's signature.
1151
+ *
1152
+ * Use this in your webhook handler to confirm the payload was sent by Lane.
1153
+ *
1154
+ * @param payload - Raw request body string
1155
+ * @param signature - Value of X-Lane-Signature header
1156
+ * @param secret - Your webhook signing secret
1157
+ * @param timestamp - Value of X-Lane-Timestamp header (unix seconds)
1158
+ */
1159
+ verify(payload: string, signature: string, secret: string, timestamp: number): boolean;
1160
+ /**
1161
+ * Parse and verify a webhook payload in one step.
1162
+ * Throws if signature is invalid.
1163
+ */
1164
+ constructEvent(payload: string, signature: string, secret: string, timestamp: number): WebhookPayload;
1165
+ }
1166
+
1167
+ declare class VIC extends Resource {
1168
+ protected get basePath(): string;
1169
+ /**
1170
+ * Issue a VIC agentic token. This provisions a Visa network token (DPAN)
1171
+ * scoped to the agent's constraints: amount limits, merchant restrictions,
1172
+ * and time bounds.
1173
+ *
1174
+ * The token works at any Visa-accepting merchant — not just Lane catalog.
1175
+ */
1176
+ issue(params: VICIssuanceParams): Promise<VICToken>;
1177
+ /**
1178
+ * Get a transaction-specific cryptogram for a VIC token.
1179
+ * Called just before payment execution — the cryptogram is single-use.
1180
+ */
1181
+ getCryptogram(tokenId: string, params: {
1182
+ amount: number;
1183
+ currency: string;
1184
+ merchantId: string;
1185
+ }): Promise<NetworkTokenPayload>;
1186
+ /** Get a VIC token by ID. */
1187
+ get(tokenId: string): Promise<VICToken>;
1188
+ /** List VIC tokens for a wallet. */
1189
+ list(params?: {
1190
+ walletId?: string;
1191
+ status?: VICToken['status'];
1192
+ limit?: number;
1193
+ offset?: number;
1194
+ }): Promise<PaginatedResponse<VICToken>>;
1195
+ /** Revoke a VIC token immediately. */
1196
+ revoke(tokenId: string): Promise<VICToken>;
1197
+ /** Suspend a VIC token (can be reactivated). */
1198
+ suspend(tokenId: string): Promise<VICToken>;
1199
+ /** Reactivate a suspended VIC token. */
1200
+ reactivate(tokenId: string): Promise<VICToken>;
1201
+ }
1202
+
1203
+ declare class Metering extends Resource {
1204
+ protected get basePath(): string;
1205
+ /**
1206
+ * Record a usage event (API call, token consumption, etc.).
1207
+ * Called by the seller's service when a buyer uses it.
1208
+ */
1209
+ record(params: {
1210
+ productId: string;
1211
+ buyerId: string;
1212
+ quantity: number;
1213
+ unit?: string;
1214
+ idempotencyKey?: string;
1215
+ }): Promise<UsageRecord>;
1216
+ /**
1217
+ * Record a batch of usage events efficiently.
1218
+ */
1219
+ recordBatch(records: {
1220
+ productId: string;
1221
+ buyerId: string;
1222
+ quantity: number;
1223
+ unit?: string;
1224
+ timestamp?: string;
1225
+ }[]): Promise<{
1226
+ recorded: number;
1227
+ failed: number;
1228
+ }>;
1229
+ /** Query usage for a product. */
1230
+ query(params: {
1231
+ productId: string;
1232
+ buyerId?: string;
1233
+ startDate?: string;
1234
+ endDate?: string;
1235
+ limit?: number;
1236
+ offset?: number;
1237
+ }): Promise<PaginatedResponse<UsageRecord>>;
1238
+ /** Get an aggregated usage report. */
1239
+ report(params: {
1240
+ productId: string;
1241
+ period: string;
1242
+ }): Promise<UsageReport>;
1243
+ /** Get or update metering config for a product. */
1244
+ getConfig(productId: string): Promise<MeteringConfig>;
1245
+ setConfig(productId: string, config: MeteringConfig): Promise<MeteringConfig>;
1246
+ }
1247
+
1248
+ declare class Payouts extends Resource {
1249
+ protected get basePath(): string;
1250
+ /** Get payout configuration. */
1251
+ getConfig(): Promise<PayoutConfig>;
1252
+ /** Set up or update payout configuration. */
1253
+ setConfig(config: {
1254
+ destination: PayoutConfig['destination'];
1255
+ destinationId: string;
1256
+ schedule?: PayoutConfig['schedule'];
1257
+ currency?: string;
1258
+ minimumPayout?: number;
1259
+ }): Promise<PayoutConfig>;
1260
+ /** List payouts. */
1261
+ list(params?: {
1262
+ status?: Payout['status'];
1263
+ limit?: number;
1264
+ offset?: number;
1265
+ }): Promise<PaginatedResponse<Payout>>;
1266
+ /** Get a specific payout. */
1267
+ get(payoutId: string): Promise<Payout>;
1268
+ }
1269
+
1270
+ declare class Teams extends Resource {
1271
+ protected get basePath(): string;
1272
+ /** Create a new team. */
1273
+ create(params: CreateTeamParams): Promise<Team>;
1274
+ /** List teams. */
1275
+ list(params?: {
1276
+ limit?: number;
1277
+ offset?: number;
1278
+ }): Promise<PaginatedResponse<Team>>;
1279
+ /** Get a team by ID. */
1280
+ get(teamId: string): Promise<Team>;
1281
+ /** Update a team. */
1282
+ update(teamId: string, params: {
1283
+ name?: string;
1284
+ budget?: BudgetConfig;
1285
+ }): Promise<Team>;
1286
+ /** Delete a team. */
1287
+ delete(teamId: string): Promise<void>;
1288
+ /** Add a member to a team. */
1289
+ addMember(teamId: string, params: {
1290
+ email: string;
1291
+ role: TeamMember['role'];
1292
+ }): Promise<TeamMember>;
1293
+ /** List team members. */
1294
+ listMembers(teamId: string, params?: {
1295
+ limit?: number;
1296
+ offset?: number;
1297
+ }): Promise<PaginatedResponse<TeamMember>>;
1298
+ /** Remove a member from a team. */
1299
+ removeMember(teamId: string, memberId: string): Promise<void>;
1300
+ /** Get the hierarchical budget for a team (org > team > developer > agent). */
1301
+ getHierarchicalBudget(teamId: string): Promise<HierarchicalBudget>;
1302
+ /** Set the team-level budget. */
1303
+ setBudget(teamId: string, budget: BudgetConfig): Promise<BudgetConfig>;
1304
+ }
1305
+
1306
+ declare class Agents extends Resource {
1307
+ protected get basePath(): string;
1308
+ /** Register a new agent in the fleet. */
1309
+ register(params: RegisterAgentParams): Promise<AgentRecord>;
1310
+ /** Get an agent by ID. */
1311
+ get(agentId: string): Promise<AgentRecord>;
1312
+ /** List agents in the fleet. */
1313
+ list(params?: {
1314
+ status?: AgentRecord['status'];
1315
+ limit?: number;
1316
+ offset?: number;
1317
+ }): Promise<PaginatedResponse<AgentRecord>>;
1318
+ /** Update an agent's policy. */
1319
+ setPolicy(agentId: string, policy: AgentPolicy): Promise<AgentRecord>;
1320
+ /** Suspend an agent (temporary, can be reactivated). */
1321
+ suspend(agentId: string): Promise<AgentRecord>;
1322
+ /** Reactivate a suspended agent. */
1323
+ reactivate(agentId: string): Promise<AgentRecord>;
1324
+ /** Permanently revoke an agent. */
1325
+ revoke(agentId: string): Promise<AgentRecord>;
1326
+ /** Assign a wallet to an agent (per-agent wallet). */
1327
+ assignWallet(agentId: string, walletId: string): Promise<AgentRecord>;
1328
+ }
1329
+
1330
+ declare class Audit extends Resource {
1331
+ protected get basePath(): string;
1332
+ /** Query audit log entries. */
1333
+ query(params?: AuditQueryParams): Promise<PaginatedResponse<AuditEntry>>;
1334
+ /** Get a specific audit entry by ID. */
1335
+ get(entryId: string): Promise<AuditEntry>;
1336
+ /**
1337
+ * Export audit logs for a date range (SOC 2 compliance).
1338
+ * Returns a download URL for the audit log archive.
1339
+ */
1340
+ export(params: {
1341
+ startDate: string;
1342
+ endDate: string;
1343
+ format?: 'json' | 'csv';
1344
+ }): Promise<{
1345
+ downloadUrl: string;
1346
+ expiresAt: string;
1347
+ }>;
1348
+ /** Get audit summary/statistics for a period. */
1349
+ summary(params: {
1350
+ period: string;
1351
+ groupBy?: 'action' | 'actor' | 'resource';
1352
+ }): Promise<{
1353
+ totalEntries: number;
1354
+ byAction: Record<string, number>;
1355
+ byActorType: Record<string, number>;
1356
+ topActors: {
1357
+ id: string;
1358
+ count: number;
1359
+ }[];
1360
+ }>;
1361
+ }
1362
+
1363
+ declare class Identity extends Resource {
1364
+ protected get basePath(): string;
1365
+ /**
1366
+ * Register an agent for identity verification.
1367
+ * This starts the KYC chain: Human (developer) vouches for Agent.
1368
+ */
1369
+ register(params: RegisterIdentityParams): Promise<AgentIdentity>;
1370
+ /**
1371
+ * Complete identity verification using a developer-provided code.
1372
+ * This establishes the Human -> Lane -> Agent chain.
1373
+ */
1374
+ verify(params: VerifyIdentityParams): Promise<AgentIdentity>;
1375
+ /** Get an agent identity by ID. */
1376
+ get(identityId: string): Promise<AgentIdentity>;
1377
+ /** List agent identities. */
1378
+ list(params?: {
1379
+ agentId?: string;
1380
+ status?: AgentIdentity['status'];
1381
+ limit?: number;
1382
+ offset?: number;
1383
+ }): Promise<PaginatedResponse<AgentIdentity>>;
1384
+ /**
1385
+ * Get the current attestation for a verified identity.
1386
+ * The attestation is a cryptographic proof that Lane has verified the
1387
+ * Human -> Agent chain.
1388
+ */
1389
+ getAttestation(identityId: string): Promise<IdentityAttestation>;
1390
+ /**
1391
+ * Refresh the attestation (generates a new signed document).
1392
+ * Useful when the previous attestation is nearing expiry.
1393
+ */
1394
+ refreshAttestation(identityId: string): Promise<IdentityAttestation>;
1395
+ /** Suspend an agent identity. */
1396
+ suspend(identityId: string): Promise<AgentIdentity>;
1397
+ /** Revoke an agent identity permanently. */
1398
+ revoke(identityId: string): Promise<AgentIdentity>;
1399
+ }
1400
+
1401
+ declare class Subscriptions extends Resource {
1402
+ protected get basePath(): string;
1403
+ /** Create a new subscription. */
1404
+ create(params: CreateSubscriptionParams): Promise<Subscription>;
1405
+ /** List subscriptions, optionally filtered by status. */
1406
+ list(params?: {
1407
+ status?: string;
1408
+ limit?: number;
1409
+ offset?: number;
1410
+ }): Promise<PaginatedResponse<Subscription>>;
1411
+ /** Get a subscription by ID. */
1412
+ get(subscriptionId: string): Promise<Subscription>;
1413
+ /** Cancel a subscription. */
1414
+ cancel(subscriptionId: string): Promise<Subscription>;
1415
+ /** Upgrade a subscription to a higher plan. */
1416
+ upgrade(subscriptionId: string, params: UpdateSubscriptionParams): Promise<Subscription>;
1417
+ /** Downgrade a subscription to a lower plan. */
1418
+ downgrade(subscriptionId: string, params: UpdateSubscriptionParams): Promise<Subscription>;
1419
+ /** Pause a subscription. */
1420
+ pause(subscriptionId: string): Promise<Subscription>;
1421
+ /** Resume a paused subscription. */
1422
+ resume(subscriptionId: string): Promise<Subscription>;
1423
+ }
1424
+
1425
+ declare class Merchants extends Resource {
1426
+ protected get basePath(): string;
1427
+ /** List/search the merchant directory. */
1428
+ list(params?: MerchantSearchParams): Promise<PaginatedResponse<DirectoryMerchant>>;
1429
+ /** Get a merchant by ID, slug, or domain. */
1430
+ get(idOrSlug: string): Promise<DirectoryMerchant>;
1431
+ /** List merchants that support a specific protocol. */
1432
+ listByProtocol(protocol: string, params?: Omit<MerchantSearchParams, 'protocol'>): Promise<PaginatedResponse<DirectoryMerchant>>;
1433
+ /** List merchants in a specific vertical. */
1434
+ listByVertical(vertical: string, params?: Omit<MerchantSearchParams, 'vertical'>): Promise<PaginatedResponse<DirectoryMerchant>>;
1435
+ /** List only Lane-onboarded merchants. */
1436
+ listOnboarded(params?: Omit<MerchantSearchParams, 'tier'>): Promise<PaginatedResponse<DirectoryMerchant>>;
1437
+ /** List all verticals with subcategories and counts. */
1438
+ verticals(): Promise<MerchantVerticalSummary[]>;
1439
+ /** Discover a protocol-compatible merchant by domain. */
1440
+ discover(domain: string): Promise<ProtocolDiscoveryResult>;
1441
+ }
1442
+
1443
+ /**
1444
+ * Lane SDK client.
1445
+ *
1446
+ * Provides access to all Lane API resources through a composable,
1447
+ * object-oriented interface. Resources are lazily initialized on first access.
1448
+ *
1449
+ * @example
1450
+ * ```typescript
1451
+ * import Lane from 'lane'
1452
+ *
1453
+ * const lane = await Lane.create({ apiKey: process.env.LANE_KEY })
1454
+ *
1455
+ * const wallet = await lane.wallets.create({ userId: 'user_123' })
1456
+ * const products = await lane.products.search({ query: 'API credits' })
1457
+ * const txn = await lane.pay.execute({ recipient: 'replicate.com', amount: 20 })
1458
+ * ```
1459
+ */
1460
+ declare class Lane {
1461
+ private readonly client;
1462
+ private readonly _config;
1463
+ private _auth?;
1464
+ private _wallets?;
1465
+ private _pay?;
1466
+ private _products?;
1467
+ private _checkout?;
1468
+ private _sell?;
1469
+ private _admin?;
1470
+ private _webhooks?;
1471
+ private _vic?;
1472
+ private _metering?;
1473
+ private _payouts?;
1474
+ private _teams?;
1475
+ private _agents?;
1476
+ private _audit?;
1477
+ private _identity?;
1478
+ private _subscriptions?;
1479
+ private _merchants?;
1480
+ /**
1481
+ * Private constructor — use `Lane.create()` for async config resolution,
1482
+ * or `new Lane(resolvedConfig)` if you've already resolved config.
1483
+ */
1484
+ private constructor();
1485
+ /**
1486
+ * Create a new Lane SDK instance with async config resolution.
1487
+ *
1488
+ * Resolves API key from: constructor > env var > credentials file.
1489
+ */
1490
+ static create(options?: LaneConfig): Promise<Lane>;
1491
+ /**
1492
+ * Create a Lane SDK instance synchronously (requires explicit apiKey).
1493
+ *
1494
+ * Use this when you already have the API key and don't need file-based
1495
+ * credential resolution.
1496
+ */
1497
+ static fromApiKey(apiKey: string, options?: Omit<LaneConfig, 'apiKey'>): Lane;
1498
+ /** Authentication — login, whoami, key rotation. */
1499
+ get auth(): Auth;
1500
+ /** Wallets — create, list cards, add card, revoke. */
1501
+ get wallets(): Wallets;
1502
+ /** Pay — agentic tokens, payment execution, refunds. */
1503
+ get pay(): Pay;
1504
+ /** Products — search catalog, list merchants. */
1505
+ get products(): Products;
1506
+ /** Checkout — create and complete checkout sessions. */
1507
+ get checkout(): Checkout;
1508
+ /** Sell — list products for sale, analytics (Make-a-SaaS). */
1509
+ get sell(): Sell;
1510
+ /** Admin — spending, budgets, team management, GDPR. */
1511
+ get admin(): Admin;
1512
+ /** Webhooks — register, verify, manage webhook endpoints. */
1513
+ get webhooks(): Webhooks;
1514
+ /** VIC — Visa Intelligent Commerce agentic tokens (Phase 2). */
1515
+ get vic(): VIC;
1516
+ /** Metering — usage tracking for Make-a-SaaS sellers (Phase 4). */
1517
+ get metering(): Metering;
1518
+ /** Payouts — seller disbursements (Phase 4). */
1519
+ get payouts(): Payouts;
1520
+ /** Teams — team management with hierarchical budgets (Phase 5). */
1521
+ get teams(): Teams;
1522
+ /** Agents — fleet management with per-agent policies (Phase 5). */
1523
+ get agents(): Agents;
1524
+ /** Audit — immutable audit trail for SOC 2 compliance (Phase 5). */
1525
+ get audit(): Audit;
1526
+ /** Identity — agent identity and KYC chain (Phase 6). */
1527
+ get identity(): Identity;
1528
+ /** Subscriptions — manage software subscriptions (SCP). */
1529
+ get subscriptions(): Subscriptions;
1530
+ /** Merchants — discover and search the merchant directory. */
1531
+ get merchants(): Merchants;
1532
+ /** Subscribe to SDK events (request, response, error, retry). */
1533
+ on(event: 'request' | 'response' | 'error' | 'retry', listener: (...args: any[]) => void): this;
1534
+ /** Whether this instance is operating in test mode. */
1535
+ get testMode(): boolean;
1536
+ /** The resolved base URL. */
1537
+ get baseUrl(): string;
1538
+ }
1539
+
1540
+ interface SignatureComponents {
1541
+ method: string;
1542
+ path: string;
1543
+ timestamp: number;
1544
+ body?: string;
1545
+ }
1546
+ declare class HMACSignature {
1547
+ private readonly secret;
1548
+ constructor(secret: string);
1549
+ /**
1550
+ * Sign request components and return the hex-encoded HMAC-SHA256 signature.
1551
+ */
1552
+ sign(components: SignatureComponents): string;
1553
+ /**
1554
+ * Verify a signature against request components.
1555
+ * Uses constant-time comparison to prevent timing attacks.
1556
+ */
1557
+ verify(signature: string, components: SignatureComponents, toleranceSeconds?: number): boolean;
1558
+ /**
1559
+ * Generate the signature headers for an outgoing request.
1560
+ */
1561
+ headers(components: SignatureComponents): Record<string, string>;
1562
+ }
1563
+ /**
1564
+ * Verify a webhook payload signature.
1565
+ *
1566
+ * @param payload - Raw webhook body string
1567
+ * @param signature - Value of X-Lane-Signature header
1568
+ * @param secret - Webhook signing secret
1569
+ * @param timestamp - Value of X-Lane-Timestamp header
1570
+ */
1571
+ declare function verifyWebhookSignature(payload: string, signature: string, secret: string, timestamp: number): boolean;
1572
+
1573
+ /**
1574
+ * File-system backed token store.
1575
+ *
1576
+ * Stores credentials at ~/.lane/credentials.json with strict permissions.
1577
+ * Implements the TokenStore interface so it can be swapped for Redis,
1578
+ * Keychain, etc.
1579
+ */
1580
+ declare class FileTokenStore implements TokenStore {
1581
+ private readonly dirPath;
1582
+ private readonly filePath;
1583
+ constructor(basePath?: string);
1584
+ /**
1585
+ * Read credentials from disk. Returns null if file doesn't exist.
1586
+ * Warns to stderr if file permissions are too permissive.
1587
+ */
1588
+ read(): Promise<Credentials | null>;
1589
+ /**
1590
+ * Write credentials to disk with secure permissions.
1591
+ */
1592
+ write(credentials: Credentials): Promise<void>;
1593
+ /**
1594
+ * Remove the credentials file.
1595
+ */
1596
+ clear(): Promise<void>;
1597
+ /** Return the path to the credentials file (for CLI display). */
1598
+ get path(): string;
1599
+ private ensureDirectory;
1600
+ /**
1601
+ * Check file permissions and warn if too open.
1602
+ * SOC 2 control: credentials should only be readable by owner.
1603
+ */
1604
+ private validatePermissions;
1605
+ private validateCredentials;
1606
+ }
1607
+
1608
+ /**
1609
+ * Resolve SDK configuration from multiple sources.
1610
+ *
1611
+ * Immutable after construction — no config drift during a session.
1612
+ */
1613
+ declare function resolveConfig(options?: LaneConfig, tokenStore?: TokenStore): Promise<ResolvedConfig>;
1614
+
1615
+ interface LaneMCPServerOptions {
1616
+ /** Override the server name shown to clients. */
1617
+ name?: string;
1618
+ /** Override the server version shown to clients. */
1619
+ version?: string;
1620
+ }
1621
+ /**
1622
+ * LaneMCPServer wraps @modelcontextprotocol/sdk McpServer and registers
1623
+ * all Lane agent tools. Connect it to any MCP transport (stdio, HTTP, etc.).
1624
+ */
1625
+ declare class LaneMCPServer {
1626
+ private readonly lane;
1627
+ readonly mcp: McpServer;
1628
+ private readonly tools;
1629
+ constructor(lane: Lane, options?: LaneMCPServerOptions);
1630
+ private registerTools;
1631
+ }
1632
+
1633
+ interface VGSTokenConfig {
1634
+ /** VGS vault ID (e.g., tntxxxxxxxx). */
1635
+ vaultId: string;
1636
+ /** VGS service account client ID. */
1637
+ clientId: string;
1638
+ /** VGS service account client secret. */
1639
+ clientSecret: string;
1640
+ /** VGS environment: 'sandbox' | 'live'. */
1641
+ environment: 'sandbox' | 'live';
1642
+ }
1643
+ /**
1644
+ * VGSTokenManager handles OAuth2 client_credentials flow for VGS vault access.
1645
+ * Tokens are cached and auto-refreshed before expiry.
1646
+ */
1647
+ declare class VGSTokenManager {
1648
+ private readonly config;
1649
+ private cached;
1650
+ constructor(config: VGSTokenConfig);
1651
+ /**
1652
+ * Get a valid access token, refreshing if expired or near-expiry.
1653
+ */
1654
+ getAccessToken(): Promise<string>;
1655
+ /**
1656
+ * Force-refresh the token.
1657
+ */
1658
+ refresh(): Promise<string>;
1659
+ /**
1660
+ * Invalidate the cached token.
1661
+ */
1662
+ invalidate(): void;
1663
+ private getTokenUrl;
1664
+ }
1665
+
1666
+ interface VGSProxyConfig extends VGSTokenConfig {
1667
+ /** Outbound route ID for PSP-bound requests. */
1668
+ routeId: string;
1669
+ }
1670
+ interface ProxyRequest {
1671
+ /** Target PSP endpoint URL. */
1672
+ url: string;
1673
+ /** HTTP method. */
1674
+ method: 'POST' | 'PUT' | 'PATCH';
1675
+ /** Request headers (Authorization, Content-Type, etc.). */
1676
+ headers: Record<string, string>;
1677
+ /** Request body containing VGS aliases that will be revealed by the proxy. */
1678
+ body: unknown;
1679
+ }
1680
+ interface ProxyResponse {
1681
+ status: number;
1682
+ headers: Record<string, string>;
1683
+ body: unknown;
1684
+ }
1685
+ /**
1686
+ * VGSOutboundProxy routes requests through VGS so that aliased card data
1687
+ * is revealed only to whitelisted PSP endpoints.
1688
+ */
1689
+ declare class VGSOutboundProxy {
1690
+ private readonly config;
1691
+ private readonly tokenManager;
1692
+ constructor(config: VGSProxyConfig);
1693
+ /**
1694
+ * Send a request through the VGS outbound proxy.
1695
+ * VGS aliases in the body are de-tokenized and revealed to the target PSP.
1696
+ */
1697
+ forward(request: ProxyRequest): Promise<ProxyResponse>;
1698
+ /**
1699
+ * Invalidate the cached VGS access token.
1700
+ */
1701
+ invalidateToken(): void;
1702
+ private getProxyUrl;
1703
+ }
1704
+
1705
+ type CardBrand = 'visa' | 'mastercard' | 'amex' | 'discover' | 'diners' | 'jcb' | 'unionpay' | 'unknown';
1706
+ /**
1707
+ * Detect card brand from a card number or VGS alias token.
1708
+ * Only uses the BIN (first 6-8 digits) — safe to call with tokenized values
1709
+ * as long as the BIN prefix is preserved (VGS format-preserving tokens).
1710
+ */
1711
+ declare function detectCardBrand(cardNumber: string): CardBrand;
1712
+ /**
1713
+ * Validate a card number using the Luhn algorithm.
1714
+ * NOTE: Only works with real PANs — NOT VGS aliases.
1715
+ * This is used only in test mode or client-side pre-validation.
1716
+ */
1717
+ declare function luhnCheck(cardNumber: string): boolean;
1718
+ /**
1719
+ * Mask a card number, showing only the last 4 digits.
1720
+ * Works with both real PANs and VGS aliases.
1721
+ */
1722
+ declare function maskCardNumber(cardNumber: string): string;
1723
+
1724
+ interface VGSCollectConfig {
1725
+ /** VGS vault ID. */
1726
+ vaultId: string;
1727
+ /** VGS environment. */
1728
+ environment: 'sandbox' | 'live';
1729
+ /** VGS route ID for inbound collection. */
1730
+ routeId: string;
1731
+ /** Callback URL after successful tokenization. */
1732
+ callbackUrl: string;
1733
+ /** Lane developer ID (for associating the card). */
1734
+ developerId: string;
1735
+ }
1736
+ /**
1737
+ * Generate the VGS Collect HTML page for secure card entry.
1738
+ * The page:
1739
+ * 1. Loads VGS Collect.js from VGS CDN
1740
+ * 2. Creates secure iframe fields for card number, CVV, expiry
1741
+ * 3. On submit, sends card data directly to VGS vault
1742
+ * 4. VGS returns aliases (tok_xxx) — Lane stores only the alias
1743
+ * 5. Redirects to callbackUrl with the alias + last4 + brand
1744
+ */
1745
+ declare function generateCollectPage(config: VGSCollectConfig): string;
1746
+
1747
+ type PSPName = 'stripe' | 'worldpay' | 'cybersource';
1748
+ interface PSPChargeParams {
1749
+ /** Amount in cents. */
1750
+ amount: number;
1751
+ /** ISO 4217 currency code (e.g., 'USD'). */
1752
+ currency: string;
1753
+ /** VGS alias for the card PAN (de-tokenized by VGS outbound proxy). */
1754
+ cardAlias: string;
1755
+ /** VGS alias for the CVV. */
1756
+ cvvAlias?: string;
1757
+ /** Card expiry month (1-12). */
1758
+ expMonth: number;
1759
+ /** Card expiry year (4-digit). */
1760
+ expYear: number;
1761
+ /** Merchant descriptor. */
1762
+ merchantDescriptor: string;
1763
+ /** Idempotency key to prevent duplicate charges. */
1764
+ idempotencyKey?: string;
1765
+ /** Metadata attached to the charge. */
1766
+ metadata?: Record<string, string>;
1767
+ }
1768
+ interface PSPChargeResult {
1769
+ /** PSP's transaction/charge ID. */
1770
+ pspTransactionId: string;
1771
+ /** Charge status. */
1772
+ status: 'succeeded' | 'pending' | 'failed';
1773
+ /** Authorization code from the issuer. */
1774
+ authorizationCode?: string;
1775
+ /** Decline reason if failed. */
1776
+ declineReason?: string;
1777
+ /** Raw PSP response for audit logging. */
1778
+ rawResponse: unknown;
1779
+ }
1780
+ interface PSPRefundParams {
1781
+ /** Original PSP transaction ID. */
1782
+ pspTransactionId: string;
1783
+ /** Refund amount in cents. If omitted, full refund. */
1784
+ amount?: number;
1785
+ /** Reason for refund. */
1786
+ reason?: string;
1787
+ /** Idempotency key. */
1788
+ idempotencyKey?: string;
1789
+ }
1790
+ interface PSPRefundResult {
1791
+ /** PSP's refund ID. */
1792
+ pspRefundId: string;
1793
+ /** Refund status. */
1794
+ status: 'succeeded' | 'pending' | 'failed';
1795
+ /** Amount refunded in cents. */
1796
+ amount: number;
1797
+ /** Raw PSP response for audit logging. */
1798
+ rawResponse: unknown;
1799
+ }
1800
+ /**
1801
+ * PSP Adapter interface — strategy pattern.
1802
+ *
1803
+ * Each payment processor (Stripe, Worldpay, CyberSource) implements this
1804
+ * interface. The payment engine calls charge/refund without knowing which
1805
+ * PSP is handling the request.
1806
+ */
1807
+ interface PSPAdapter {
1808
+ /** PSP identifier. */
1809
+ readonly name: PSPName;
1810
+ /**
1811
+ * Create a charge. The card data arrives as VGS aliases;
1812
+ * the VGS outbound proxy reveals them to the PSP endpoint.
1813
+ */
1814
+ charge(params: PSPChargeParams): Promise<PSPChargeResult>;
1815
+ /**
1816
+ * Refund a previous charge (full or partial).
1817
+ */
1818
+ refund(params: PSPRefundParams): Promise<PSPRefundResult>;
1819
+ /**
1820
+ * Health check — verify PSP connectivity.
1821
+ */
1822
+ healthCheck(): Promise<boolean>;
1823
+ }
1824
+
1825
+ /**
1826
+ * PSPRegistry manages available payment processor adapters.
1827
+ *
1828
+ * The payment engine queries the registry to find the best adapter
1829
+ * for a given transaction based on priority, card brand support,
1830
+ * and availability.
1831
+ */
1832
+ declare class PSPRegistry {
1833
+ private adapters;
1834
+ /**
1835
+ * Register an adapter with a priority (lower = higher priority).
1836
+ */
1837
+ register(adapter: PSPAdapter, priority?: number): void;
1838
+ /**
1839
+ * Remove an adapter from the registry.
1840
+ */
1841
+ unregister(name: PSPName): void;
1842
+ /**
1843
+ * Get a specific adapter by name.
1844
+ */
1845
+ get(name: PSPName): PSPAdapter | undefined;
1846
+ /**
1847
+ * Get the highest-priority adapter (lowest priority number).
1848
+ * Optionally exclude specific adapters (e.g., after a failure).
1849
+ */
1850
+ getPrimary(exclude?: Set<PSPName>): PSPAdapter | undefined;
1851
+ /**
1852
+ * Get all registered adapters sorted by priority.
1853
+ */
1854
+ getAll(): PSPAdapter[];
1855
+ /**
1856
+ * Run health checks on all adapters. Returns names of healthy adapters.
1857
+ */
1858
+ healthCheckAll(): Promise<PSPName[]>;
1859
+ }
1860
+
1861
+ interface StripeAdapterConfig {
1862
+ /** Stripe secret key (sk_live_... or sk_test_...). */
1863
+ secretKey: string;
1864
+ /** VGS outbound proxy instance. */
1865
+ proxy: VGSOutboundProxy;
1866
+ /** Stripe API version. */
1867
+ apiVersion?: string;
1868
+ }
1869
+ declare class StripeAdapter implements PSPAdapter {
1870
+ readonly name: "stripe";
1871
+ private readonly config;
1872
+ constructor(config: StripeAdapterConfig);
1873
+ charge(params: PSPChargeParams): Promise<PSPChargeResult>;
1874
+ refund(params: PSPRefundParams): Promise<PSPRefundResult>;
1875
+ healthCheck(): Promise<boolean>;
1876
+ }
1877
+
1878
+ interface WorldpayAdapterConfig {
1879
+ /** Worldpay merchant ID. */
1880
+ merchantId: string;
1881
+ /** Worldpay API key. */
1882
+ apiKey: string;
1883
+ /** Worldpay API endpoint. */
1884
+ baseUrl: string;
1885
+ /** VGS outbound proxy instance. */
1886
+ proxy: VGSOutboundProxy;
1887
+ }
1888
+ declare class WorldpayAdapter implements PSPAdapter {
1889
+ readonly name: "worldpay";
1890
+ private readonly config;
1891
+ constructor(config: WorldpayAdapterConfig);
1892
+ charge(params: PSPChargeParams): Promise<PSPChargeResult>;
1893
+ refund(params: PSPRefundParams): Promise<PSPRefundResult>;
1894
+ healthCheck(): Promise<boolean>;
1895
+ }
1896
+
1897
+ interface CyberSourceAdapterConfig {
1898
+ /** CyberSource merchant ID. */
1899
+ merchantId: string;
1900
+ /** CyberSource API key ID. */
1901
+ apiKeyId: string;
1902
+ /** CyberSource shared secret. */
1903
+ sharedSecret: string;
1904
+ /** API endpoint. */
1905
+ baseUrl: string;
1906
+ /** VGS outbound proxy instance. */
1907
+ proxy: VGSOutboundProxy;
1908
+ }
1909
+ interface CyberSourceChargeParams extends PSPChargeParams {
1910
+ /** VIC network token cryptogram (for token-based payments). */
1911
+ cryptogram?: string;
1912
+ /** ECI value for network token transactions. */
1913
+ eci?: string;
1914
+ /** Whether this is a network token (DPAN) or regular PAN. */
1915
+ isNetworkToken?: boolean;
1916
+ }
1917
+ declare class CyberSourceAdapter implements PSPAdapter {
1918
+ readonly name: "cybersource";
1919
+ private readonly config;
1920
+ constructor(config: CyberSourceAdapterConfig);
1921
+ charge(params: PSPChargeParams): Promise<PSPChargeResult>;
1922
+ refund(params: PSPRefundParams): Promise<PSPRefundResult>;
1923
+ healthCheck(): Promise<boolean>;
1924
+ }
1925
+
1926
+ /** Merchant capability data used for routing decisions. */
1927
+ interface MerchantCapabilities {
1928
+ merchantId: string;
1929
+ hasBillingAPI: boolean;
1930
+ supportsACP: boolean;
1931
+ supportsVIC: boolean;
1932
+ acceptsVisa: boolean;
1933
+ acceptsMastercard: boolean;
1934
+ mccs: string[];
1935
+ }
1936
+ /** Context for a routing decision. */
1937
+ interface RoutingContext {
1938
+ /** Amount in cents. */
1939
+ amount: number;
1940
+ currency: string;
1941
+ merchantId: string;
1942
+ /** Card brand being used. */
1943
+ cardBrand: string;
1944
+ /** Whether a VIC token is available. */
1945
+ hasVICToken: boolean;
1946
+ /** Current effective budget. */
1947
+ budget?: BudgetConfig;
1948
+ /** Current spend for the period. */
1949
+ currentSpend?: number;
1950
+ }
1951
+ /** Registry of merchant capabilities (populated from Lane backend). */
1952
+ declare class MerchantRegistry {
1953
+ private merchants;
1954
+ register(capabilities: MerchantCapabilities): void;
1955
+ get(merchantId: string): MerchantCapabilities | undefined;
1956
+ registerBatch(merchants: MerchantCapabilities[]): void;
1957
+ /** Create a registry pre-populated from directory capabilities. */
1958
+ static fromDirectory(capabilities: MerchantCapabilities[]): MerchantRegistry;
1959
+ /** Clear and repopulate with new capabilities. */
1960
+ reload(capabilities: MerchantCapabilities[]): void;
1961
+ /** Number of registered merchants. */
1962
+ get size(): number;
1963
+ /** List all registered merchant IDs. */
1964
+ listIds(): string[];
1965
+ }
1966
+ /**
1967
+ * PaymentRouter determines the optimal payment path for a transaction.
1968
+ *
1969
+ * Priority order:
1970
+ * 1. Billing API — direct merchant API integration (cheapest, fastest)
1971
+ * 2. ACP — Agent Commerce Protocol checkout (Stripe-compatible)
1972
+ * 3. VIC — Visa Intelligent Commerce token (works at any Visa merchant)
1973
+ * 4. Fallback — standard card payment via PSP
1974
+ */
1975
+ declare class PaymentRouter {
1976
+ private readonly registry;
1977
+ constructor(registry: MerchantRegistry);
1978
+ /**
1979
+ * Decide the payment route for a transaction.
1980
+ */
1981
+ route(context: RoutingContext): RoutingDecision;
1982
+ private filterFallbacks;
1983
+ }
1984
+
1985
+ export { type APIResponse, Admin, type AgentIdentity, type AgentPolicy, type AgentRecord, type AgenticToken, Agents, type AnalyticsParams, Audit, type AuditEntry, type AuditQueryParams, Auth, type AutoReloadConfig, type BudgetConfig, type Card, type CardAttributes, type CardBrand, Checkout, type CheckoutSession, type CreateCheckoutParams, type CreateProductParams, type CreateSubscriptionParams, type CreateTeamParams, type CreateTokenParams, type CreateWalletParams, type CredentialInjection, type Credentials, CyberSourceAdapter, type CyberSourceAdapterConfig, type CyberSourceChargeParams, type DepositParams, type DepositResult, type DeveloperProfile, type DirectoryMerchant, type ExecutePaymentParams, FileTokenStore, HMACSignature, type HierarchicalBudget, Identity, type IdentityAttestation, type KYCChain, Lane, LaneAuthError, LaneBudgetError, LaneClient, type LaneConfig, LaneError, LaneMCPServer, type LaneMCPServerOptions, LaneNotFoundError, LanePaymentError, LaneRateLimitError, LaneValidationError, type Merchant, type MerchantCapabilities, MerchantRegistry, type MerchantSearchParams, type MerchantType, type MerchantVerticalSummary, Merchants, Metering, type MeteringConfig, type NetworkTokenPayload, type Order, type Organization, type PSPAdapter, type PSPChargeParams, type PSPChargeResult, type PSPName, type PSPRefundParams, type PSPRefundResult, PSPRegistry, type PaginatedResponse, Pay, type PaymentRoute, PaymentRouter, type Payout, type PayoutConfig, Payouts, type PricingConfig, type Product, type ProductAnalytics, type ProductSearchParams, Products, type ProtocolDiscoveryResult, type ProxyRequest, type ProxyResponse, type Refund, type RefundParams, type RegisterAgentParams, type RegisterIdentityParams, type RequestOptions, type ResolvedConfig, Resource, type RotateKeyResult, type RoutingContext, type RoutingDecision, type SCPManifest, type SCPParameter, type SCPPlan, type SCPPricing, type SCPProduct, type SCPProvisioning, type SCPSelectionParameters, type SDKInfo, Sell, type SoftwareCheckoutParams, type SoftwareOrder, type SoftwareProductSearchParams, type SpendingSummary, StripeAdapter, type StripeAdapterConfig, type Subscription, Subscriptions, type Team, type TeamMember, type TeamSpending, Teams, type TokenStore, type Transaction, type UpdateSubscriptionParams, type UsageRecord, type UsageReport, type VGSCollectConfig, VGSOutboundProxy, type VGSProxyConfig, type VGSTokenConfig, VGSTokenManager, VIC, type VICIssuanceParams, type VICToken, type VerifyIdentityParams, type Wallet, type WalletBalance, Wallets, type WebhookConfig, type WebhookEvent, type WebhookPayload, Webhooks, WorldpayAdapter, type WorldpayAdapterConfig, createErrorFromResponse, Lane as default, detectCardBrand, generateCollectPage, luhnCheck, maskCardNumber, resolveConfig, verifyWebhookSignature };